query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
sequencelengths
19
19
metadata
dict
Whether the current expression uses distinct expressions
def is_distinct? @distinct == true end
[ "def distinct?\n @options[:distinct] == true\n end", "def distinct?\n attributes['distinct']\n end", "def supports_distinct_on?\n false\n end", "def supports_distinct_on?\n true\n end", "def supports_count_distinct?\n false\n end", "def supports_count_distinct?\n true\n end", "def supports_count_distinct?\n true\n end", "def supports_ordered_distinct_on?\n false\n end", "def no_duplicate_filters\n return true if !active\n DataFileFilter.find_all_by_active_and_negative(true,self.negative).each do |other|\n next if other.id == id # Skip myself\n if expression_clash? other\n errors.add(:expression, \"must not conflict with other expressions. This on conflicts with '#{other.name}'\")\n end\n end\n return true\n end", "def is_unique\n return true if fact_type.is_a?(LinkFactType) or # Handle objectification roles\n fact_type.all_role.size == 1 # and unary roles\n\n uniqueness_constraint ? true : false\n end", "def distinct_on(expression)\n @distinct_on << expression\n end", "def duplication?\n not duplicates.empty?\n end", "def unique?\n check = nil\n is_unique { |pipe| check = pipe }.each do\n return false unless check.isUnique\n end\n true\n end", "def summarize_per_optimizable?\n !summarize_per.equal?(operation.summarize_per)\n end", "def found_unique?\n @flags.size == 1\n end", "def has_semiadditive_fact?\n aggregate_fields.each do |field|\n return true if field.is_semiadditive?\n end\n return false\n end", "def unique?\n @property.unique?\n end", "def must_unify?(seq1, seq2)\n unique_selectors = seq1.map do |sseq|\n next [] if sseq.is_a?(String)\n sseq.members.select {|sel| sel.unique?}\n end.flatten.to_set\n\n return false if unique_selectors.empty?\n\n seq2.any? do |sseq|\n next false if sseq.is_a?(String)\n sseq.members.any? do |sel|\n next unless sel.unique?\n unique_selectors.include?(sel)\n end\n end\n end", "def unique?\n @unique\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Rearrange characters in a string such that no two adjacent are same Given a string with repeated characters, task is rearrange characters in a string so that no two adjacent characters are same. Note : It may be assumed that the string has only lowercase English alphabets. Rearrange characters in a string such that no two adjacent are same Given a string with repeated characters, task is rearrange characters in a string so that no two adjacent characters are same. Note : It may be assumed that the string has only lowercase English alphabets.
def rearrange(str) #must be arr letters = str.split("") #check whether possible hash = Hash.new(0) letters.each {|letter| hash[letter] += 1 } most = hash.values.max return "not possible" if most > (letters.length/2.0).ceil #baaabb letters.sort! p "this is important SORT to lump all together" #aaabbb i = 0 while i < letters.length if letters[i] == letters[i+1] j = i + 1 found = false while j < letters.length && !found if letters[j] != letters[i] letters[i+1], letters[j] = letters[j], letters[i+1] found = true end j += 1 end end i += 1 end #loop thru and switch positions letters.join("") end
[ "def remove_adjacent_duplicates(input)\r\n characters = input.chars\r\n array = []\r\n (0..characters.length-1).each do |x|\r\n array.push(characters[x]) if characters[x] != characters[x+1]\r\n end\r\n return array.join('')\r\nend", "def remove_adjacent_duplicates(input)\n # Your code goes here\n # Split string into array of individual characters\n input_arr = input.chars\n index = 0\n # Solution 1: Iterate over array of characters, deleting |x| then adding it to the index in whichever position it was found\n input_arr.each do |char|\n if input_arr.count(char) > 1\n input_arr.delete_at(index)\n end\n index += 1\n end\n # Solution 2: Iterate over array of characters, comparing the index of |x| to that x-1 and x+1 and if either match deleting itself by index\n input_arr.each do |char|\n # Compare char to character at (index - 1) if true, remove that index > maybe use a while loop to catch multiple identical characters\n if index > 0\n while char == input_arr[(index - 1)]\n input_arr.delete_at(index - 1)\n end\n end\n while char == input_arr[(index + 1)]\n input_arr.delete_at(index + 1)\n end\n index += 1\n end\n return input_arr.join\nend", "def remove_duplicates_2(string)\n return string if string.length < 2\n no_duplicates = []\n string.chars.each do |letter|\n no_duplicates << letter unless no_duplicates.include?(letter)\n end\n no_duplicates.join()\nend", "def reverseShuffleMerge(s)\n # handle incorrect test case\n return \"eaid\" if s==\"aeiouuoiea\"\n ###\n# n = s.length/2\n# dar = s.chars.sort\n# car = []\n# 0.upto(n-1) do |i|\n# car << dar[i*2] \n# end\n # car contains all the letters (sorted) in a, rev(a), or shuffle(a)\n # s contains rev(a)\n # discard or keep letters in s starting from the right\n # try to make first letter \"a\", if doable, discard right\n # try to make first letter \"b\", if doable, discard right\n # etc\n # upper = 2*n-1\n# n.times do |i|\n# # looking for letter\n# found = nil\n# here = nil\n# lower = n-1-i\n# car.each_with_index do |x, k|\n# ix = s[lower..upper].rindex(x) # look for \"a\" from right\n# next unless ix\n# ix+= lower\n# temp = car.dup\n# s[0..ix].each_char{|e| if j = temp.index(e) then temp.delete_at(j) end}\n# if temp.empty? # s[0..ix] contains all of car \n# found = x\n# here = k\n# upper = ix-1\n# break\n# end\n# end\n# # found letter, remove from car\n# if found\n# a << found\n# car.delete_at(here)\n# end\n# #puts \"#{a} <== #{s[0..upper].reverse}\"\n# end\n # above solution too slow\n # build a letter count hash instead\n letter_count = Hash.new(0)\n s.each_char do |c|\n letter_count[c]+=1\n end\n half_count = letter_count.transform_values { |v| v/2 }\n d_count = letter_count.transform_values { |v| 0 }\n c_count = letter_count\n a = \"\"\n s.reverse.each_char do |c|\n # should I include or exclude c ?\n if d_count[c] < half_count[c]\n while (a[-1] && c < a[-1] && d_count[a[-1]] + c_count[a[-1]] - 1 >= half_count[a[-1]])\n d_count[a[-1]]-=1\n a.slice!(-1)\n end\n a << c\n d_count[c]+=1\n c_count[c]-=1\n else\n c_count[c]-=1\n end\n end\n return a\nend", "def remove_adjacent_duplicates(input)\n \n #Turn the string to an array\n # input = input.chars\n \n #Use the bubble-sort method to delete adjacent elements in the array\n # input.length.times do\n # index = 0\n # input.each do |element|\n # if input[index] == input[index + 1]\n # input.delete_at(index + 1)\n # end\n # (index += 1) if (index < input.length - 2)\n # end\n # end\n\n return input.squeeze\n \nend", "def remove_adjacent_duplicates1(input)\n input = input.chars\n i = 1\n input.length.times do\n if input[i] == input[i-1]\n input.delete_at(i)\n else\n i += 1\n end\n end\n return input.join\nend", "def string_reduction(str)\n idx = 0\n until str.chars.uniq.size == 1\n if idx >= str.size - 1\n idx = 0\n next\n end\n if str[idx] == 'a'\n if str[idx + 1] == 'b'\n str[idx..idx + 1] = 'c'\n idx = 0\n elsif str[idx + 1] == 'c'\n str[idx..idx + 1] = 'b'\n idx = 0\n else\n idx += 1\n end\n elsif str[idx] == 'b'\n if str[idx + 1] == 'a'\n str[idx..idx + 1] = 'c'\n idx = 0\n elsif str[idx + 1] == 'c'\n str[idx..idx + 1] = 'a'\n idx = 0\n else\n idx += 1\n end\n elsif str[idx] == 'c'\n if str[idx + 1] == 'a'\n str[idx..idx + 1] = 'b'\n idx = 0\n elsif str[idx + 1] == 'b'\n str[idx..idx + 1] = 'a'\n idx = 0\n else\n idx += 1\n end\n end\n end\n str.size\nend", "def reorganize_string(a)\n length_a = a.length\n\n return a if length_a == 1\n\n (length_a - 2).times do |index|\n a = compare_characters(0,a, index * 1)\n\n return a if a.empty?\n end\n\n return [\"\"] if a[-2] == a[-1]\n\n a\nend", "def same_char_collapse(string)\n \n repeated = true\n # new_str = ''\n while repeated\n chars = string.split('')\n repeated = false\n chars.each.with_index do |char, idx|\n if chars[idx] == chars[idx + 1]\n chars[idx] = ''\n chars[idx + 1] = ''\n # string.shift(2)\n repeated = true\n end\n end\n string = chars.join\n end\n\n string\nend", "def same_char_collapse(str)\n return str if str.length <= 2\n new_str = ''\n i = 0\n\n while i < str.length\n if str[i] == str[i + 1]\n i += 2\n else\n new_str += str[i]\n i += 1\n end\n end\n\n return same_char_collapse(new_str)\nend", "def same_char_collapse(str)\n i = 0\n while i < str.length\n if i == 0\n new_str = \"\"\n end\n\n if i != str.length-1\n if str[i] == str[i+1]\n new_str += str[i+2..-1]\n str = new_str\n i = 0\n else\n new_str += str[i]\n i += 1\n end\n else\n new_str += str[i]\n i += 1\n end\n\n end\n return str\nend", "def compress_string(string)\nstring.chars\nindex = 0 \nresult = \"\"\nwhile index < string.length\n if string[index] == string[index+1]\n occurence = 1\n while string[index] == string[index+1]\n index += 1\n occurence += 1\n end\n result << \"#{occurence}#{string[index]}\"\n occurence = 0\n index += 1\n else string[index] != string[index+1]\n result << \"#{string[index]}\"\n index += 1\n end\nend\n return result\nend", "def compress_solution_two(str)\n str_chars = str.chars\n str_size = str_chars.size\n return str if str_size < compressed_size(str_chars, str_size)\n\n compressed_str = ''\n count_consecutive = 0\n str_chars.each.with_index do |char, index|\n count_consecutive += 1\n next_char_different = ((index + 1) == str_size || (str_chars[index + 1] != char))\n if next_char_different\n compressed_str << char\n compressed_str << count_consecutive.to_s\n count_consecutive = 0\n end\n end\n compressed_str\nend", "def solution(s)\n s = s.split ''\n return 'Empty String' if s.uniq.length == 1\n\n i = 1\n while i <= s.length\n if s[i - 1] == s[i]\n s.delete_at i - 1\n s.delete_at i - 1\n i = 0\n end\n i += 1\n end\n\n s.length <= 0 ? 'Empty String' : s.join\nend", "def alternate(str)\n chars = str.chars.uniq\n final_size = 0\n return final_size if chars.size == 1\n\n # purpose is to keep the delete all letters *except* the ones in the combo,\n # then verify if 't' (remaining string) is valid.\n final_chars = chars.combination(2).to_a\n final_chars.each do |combo|\n queue = []\n valid = true\n t = str.gsub(/[^#{combo.join}]+/, '')\n t.chars.each do |char|\n queue << char\n next if queue.size == 1\n\n valid = queue[-1] != queue[-2]\n break unless valid\n end\n\n next unless valid && t.size > final_size\n\n final_size = t.size\n end\n\n final_size\nend", "def unique_in_order(string)\n string.each_char.with_index.reduce([]) do |arr, (el, i)|\n if el == string.chars[i+1]\n arr\n else\n arr << el\n end\n end\nend", "def crunch(string)\n no_duplicates = ''\n string.chars.each do |letter|\n no_duplicates << letter unless no_duplicates[-1] == letter\n end\n no_duplicates\nend", "def str_compression(string)\n #method to check for repeating letters\n def repeating_letters?(str)\n str.downcase.chars.group_by(&:itself).values.any? { |a| a.size > 1 }\n end\n\n #return string there is no repeating letter\n return string if repeating_letters?(string) == false\n \n new_string = string.downcase\n array = new_string.chars.chunk{ |i| i}.map{ |char, count| [char, count.length]}\n\n #return array with repeating letters\n array.flatten.map{ |s| s.to_s }.join('')\nend", "def solution(s)\n return -1 if s == s.reverse\n\n arr = s.split ''\n b = 0\n e = s.length - 1\n while b != e\n if arr[b] != s[e]\n temp = arr.dup\n temp.delete_at b\n if temp == temp.reverse\n return b\n else\n temp = arr.dup\n temp.delete_at e\n if temp == temp.reverse\n return e\n end\n end\n end\n b += 1\n e -= 1\n end\n\n -1\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A simple filebased cache in ./_tmp shared by all GistTag instances
def cache @@cache ||= ActiveSupport::Cache::FileStore.new("_tmp/gist") end
[ "def cache_stored_file!; end", "def cache_stored_file!\n cache!\n end", "def data_cache(fpath)\n (@data_caches ||= []) << fpath\n return fpath\n end", "def cache\n if self.cache_store\n self.cache_store\n else\n self.cache_store = :file_store, root.join(\"tmp\").to_s\n self.cache_store\n end\n end", "def cache_dir; end", "def cache_path; end", "def cache file_obj,data_result,url,username,password\n data_result[:uuid]=UUID.generate\n key=generate_key url,username,password \n \n begin\n data_result[:data_tmp_path] = store_data_to_tmp file_obj,data_result[:uuid]\n data_result[:time_stored]=Time.now\n @@file_cache[key]=data_result\n rescue Exception=>e \n @@file_cache[key]=nil\n end \n end", "def initialize_file_based_cache\n Dir.mkdir(\"cache\")\n @document_cache = ActiveSupport::Cache::FileStore.new(\"cache\")\n @file_based_cache = true\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def cache_file\n File.join( cache_dir, Dir.pwd.hash.to_s )\nend", "def cache(file_obj, data_result, url, username, password)\n data_result[:uuid] = UUID.generate\n key = generate_key url, username, password\n\n begin\n data_result[:data_tmp_path] = store_data_to_tmp file_obj, data_result[:uuid]\n data_result[:time_stored] = Time.now\n @@file_cache[key] = data_result\n rescue Exception => e\n @@file_cache[key] = nil\n end\n end", "def cache\n return if !rewindable?\n\n @cache ||= (\n tempfile = Tempfile.new(\"down-chunked_io\", binmode: true)\n tempfile.chmod(0000) # make sure nobody else can read or write to it\n tempfile.unlink if posix? # remove entry from filesystem if it's POSIX\n tempfile\n )\n end", "def get_cached_gist(gist, file)\n return nil if @cache_disabled\n cache_file = get_cache_file_for gist, file\n File.read cache_file if File.exist? cache_file\n end", "def cachedir\n tarball.cache_path\n end", "def cache!(new_file)\n super\n @old_tmp_file = new_file\n end", "def cache\n 'cache/' + (@path.empty? ? 'base' : @path.gsub('/', '_'))\n end", "def cache(uri, obj)\n filename=cacheFileName(uri)\n print(\"Creating #{filename}\\n\")\n File.open(filename, 'w') {|f| f.write(obj) }\nend", "def cached\n @files = Fyle.where.not(cache_file: nil)\n\t\tinternal_index\n end", "def cache_path(for_file = T.unsafe(nil)); end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
remove search parameters which are blank or have a value of 0
def purge_search_params params[:search].keys.each do |k| if params[:search][k].blank? params[:search].delete(k) elsif ((/\d/ =~ params[:search][k]) == 0) && !key_value_considers_zero(k) params[:search].delete(k) unless params[:search][k].to_i > 0 end end end
[ "def params_rm_blanks(search)\n search.each do |k,v|\n if v.blank?\n search.delete(k)\n end\n end\n end", "def clean_params\n remove = ignored.map(&:to_sym)\n controller.iiif_search_params.except(*%i[page solr_document_id] + remove)\n end", "def clean_query(solr_params)\n solr_params[:fq] = solr_params[:fq].reject(&:blank?).uniq\n end", "def blank_params\n params.select{ |x| x.blank? }\n end", "def empty_params\n params.select{ |x| x.empty? }\n end", "def reset_search_params\n Parameters.sanitize(params).except(:page, :counter)\n end", "def reset_search_params\n Parameters.sanitize(to_h).except(:page, :counter)\n end", "def clear_search(aParams=params)\n new_params = aParams.to_unsafe_h.clone\n new_params.delete(\"qfield\")\n new_params.delete(\"qtext\")\n new_params.delete(\"q\")\n return new_params\n end", "def reset_filter_params\n params[:search] = nil\n params[:status] = nil\n params[:unassigned] = nil\n params[:assigned_to_me] = nil\n params[:needs_attention] = nil\n params[:year] = nil\n end", "def strip_search_param\n case params[:q]\n when String\n params[:q].strip!\n when Hash\n params[:q].each_pair{|k, v| params[:q][k] = v.strip}\n else\n end\n end", "def remove_params\n params.reject!{|_, v| v.blank?}\n end", "def normalize_search\n return unless request.get? || request.head?\n params[:search] = ActionController::Parameters.new unless params[:search].is_a?(ActionController::Parameters)\n\n deep_reject_blank = lambda do |hash|\n hash.reject { |_k, v| v.blank? || (v.is_a?(Hash) && deep_reject_blank.call(v).blank?) }\n end\n nonblank_search_params = deep_reject_blank.call(params[:search])\n\n if nonblank_search_params != params[:search]\n params[:search] = nonblank_search_params\n redirect_to url_for(params: params.except(:controller, :action, :index).permit!)\n end\n end", "def parse_filter_params\n unless request.query_string.blank?\n parse_search_params(params)\n end\n end", "def excluded_from_filter_parameters=(_arg0); end", "def clean_checkboxes\n params[:query][:selected_fields].delete(\"\")\n params[:filter][:country_code_in].delete(\"\")\n params[:filter][:region_code_in].delete(\"\")\n end", "def sanitize_search_params source_params\n\n my_params = source_params.reject { |k,v| v.nil? }\n\n my_params.except(:action, :controller, :id, :commit, :utf8)\n end", "def process_params\n return unless params[:search].present?\n\n params[:search] = params[:search].reduce(Hash.new) do |processed_params, (filter, value)|\n if %w(city_id county_id).include? filter\n processed_params.merge(\"#{filter}_eq\" => value)\n elsif value.is_a? Array\n processed_params.merge(filter => value.map { |v| v.empty? ? nil : v }.compact)\n else\n processed_params.merge(filter => value)\n end.with_indifferent_access\n end\n end", "def criteria_with_blank_value(criteria)\n criteria.present? ? criteria : [\"\"]\n end", "def model_search_params(model, params)\n cols = model.column_names\n params.reject { |k, _v| !cols.include?(k) }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /interviews GET /interviews.json
def index @interviews = Interview.all respond_to do |format| format.html # index.html.erb format.json { render json: @interviews } end end
[ "def index\n @interviews = current_user.interviews\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviews }\n end\n end", "def index\n @interviews = Interview.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviews }\n end\n end", "def get_interviews(opts = {})\n data, _status_code, _headers = get_interviews_with_http_info(opts)\n data\n end", "def my_interviews\n @interviews = Interview.find(:all, :conditions => ['teacher_id = ?', self.current_user.teacher.id])\n \n respond_to do |format|\n format.html # my_interviews.html.erb\n format.json { render json: @interviews }\n end\n end", "def user_interviews\n if can_view\n @interviews = Interview.where(:id => UserInterview.where(:user_id => current_user).pluck(:interview_id))\n interviews = []\n @interviews.each do |interview|\n interviews.append({\n :id => interview.id,\n :title => interview.title,\n :agenda => interview.agenda,\n :start => interview.start.to_formatted_s(:short),\n :end => interview.end.to_formatted_s(:short),\n :comments => interview.comments,\n :created_by => interview.user.username,\n })\n end\n render json: {\n :success => true,\n :interviews => interviews,\n }\n else\n render json: {\n :success => false\n }\n end\n end", "def show\n @interview = Interview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interview }\n end\n end", "def my_interviews\n @interviews = get_logged_employee.interviews.joins(:req_match).where(\"req_matches.status = ?\", \"SCHEDULED\")\n\t\trender \"resumes/interview_requests\"\n\tend", "def index\n @interviews = Interview.all\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @interviews }\n end\n end", "def index\n\n @interviewees = Interviewee.all\n\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviewees }\n end\n end", "def upcoming_interviews\n future_interviews_count = @interviewer.upcoming_interviews.count\n if [1, 2].include? future_interviews_count\n render json: @interviewer\n else\n render json: {error: \"No Upcoming Interviews found\"}, status: 404\n end\n end", "def manage_interviews\n @req_match = ReqMatch.find(params[:req_match_id])\n @interviews = @req_match.interviews\n\n respond_to do |format|\n format.js\n end\n end", "def show\n @interviews_it = Interviews::It.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interviews_it }\n end\n end", "def interview\n @company = Company.find(params[:id])\n @interviews = @company.interviews.all\n end", "def show\n @interview_response = InterviewResponse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interview_response }\n end\n end", "def interview\n\t\t@interview = InterviewReview.where(:company_id => params[:id])\n\t\t@company_id = params[:id]\n\t\trespond_to do |format|\n\t\t\tformat.js\n\t\tend\n\tend", "def index\n @interviewers = Interviewer.all\n end", "def index\n @exceller_interviews = ExcellerInterview.all\n end", "def show\n @admin_interview = Interview.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_interview }\n end\n end", "def index\n @reviews = reviewable.reviews\n\n respond_to do |format|\n format.html\n format.json { render json: @reviews }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /interviews/new GET /interviews/new.json
def new @interview = Interview.new respond_to do |format| format.html # new.html.erb format.json { render json: @interview } end end
[ "def new\r\n @interview = Interview.new\r\n\r\n respond_to do |format|\r\n format.html { render \"/users/interviews/new\" }# new.html.erb\r\n format.json { render json: @interview }\r\n end\r\n end", "def new\n @interview = Interview.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interview }\n end\n end", "def new\n @s = Script.find(params[:id])\n @interview = @s.interviews.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interview }\n end\n end", "def new\n @interviews_it = Interviews::It.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interviews_it }\n end\n end", "def new\n @interview_type = InterviewType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interview_type }\n end\n end", "def new\n @admin_interview = Interview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_interview }\n end\n end", "def new\n @interviewee = Interviewee.new\n @nav_active = 'new'\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interviewee }\n end\n end", "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interest }\n end\n end", "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end", "def new\n @interview = Interview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interview }\n end\n end", "def create\n @interview = Interview.new(interview_params)\n\n respond_to do |format|\n if @interview.save\n format.html { redirect_to interviews_url, notice: 'Interview was successfully created.' }\n format.json { render action: 'show', status: :created, location: @interview }\n else\n format.html { render action: 'new' }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @interim_attestation = InterimAttestation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interim_attestation }\n end\n end", "def new\n @new_review = NewReview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_review }\n end\n end", "def new\n @interview_event = InterviewEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interview_event }\n end\n end", "def new\n @impact = Impact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @impact }\n end\n end", "def create\n @interview = Interview.new(params[:interview])\n\n @interview.user_id = current_user.id\n\n respond_to do |format|\n if @interview.save\n format.html { redirect_to admin_interviews_path, notice: 'Interview was successfully created.' }\n format.json { render json: @interview, status: :created, location: @interview }\n else\n format.html { render action: \"new\" }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @codeinterview = Codeinterview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @codeinterview }\n end\n end", "def new\n @interview_session = InterviewSession.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interview_session }\n end\n end", "def new\n @interest_point = InterestPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interest_point }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if all elements in expected are included in actual
def hash_included_array_unordered(expected, actual) # the two array must be consistent in size if expected.size != actual.size return false end expected.each do |item| found = false # indicates if the item is found if item.class == Hash for i in 0...actual.size if hash_included_unordered item, actual[i] # equal remaining to true indicates that the item has been found, break and test next item found = true break end end else if actual.include? item found = true end end if !found # if any item is not found, return false return false end end return true # every thing is fine... end
[ "def assert_includes_all(expected, actual, message = nil)\n missing_from_expected = expected.to_a - actual.to_a\n unless missing_from_expected.empty?\n message ||= \"Expected:\\n #{mu_pp expected}\\ndid not contain every element in Actual:\\n #{mu_pp actual}.\"\n flunk(\"#{message}\\nMissing expected elements:\\n #{mu_pp missing_from_expected}\")\n end\n end", "def hash_included_array_ordered(expected, actual)\n # the two array must be consistent in size\n if expected.size != actual.size\n return false\n end\n\n for i in 0...expected.size\n if expected[i].class == Hash # Use hash_included_ordered if item is Hash, != otherwise\n if !hash_included_ordered expected[i], actual[i]\n return false\n end\n else\n if expected[i] != actual[i]\n return false\n end\n end\n end\n return true # every thing is fine...\n end", "def assert_same_elements(exp, act)\n assert_equal(exp.length, act.length, \"The expected and actual collection doesn't have the same size.\n We cannot assert that there is the same elements, the same number of times\")\n assert(exp.respond_to?(:each), \"expected collection doesn't have the method #each\")\n assert(act.respond_to?(:each), \"actual collection doesn't have the method #each\")\n exp.each do |e|\n element_found = false\n act.each do |act_elem|\n if act_elem.eql? e\n element_found = true\n next\n end\n end\n assert(element_found, \"Element #{e} of #{exp} does not exist in #{act}\")\n end\n end", "def assert_sets_equal(expected, actual)\n if !(diff = (expected - actual)).empty?\n flunk(\"expects two sets to be equal, but #{expected} is missing #{diff.size} expected elements:\\n #{diff.to_a.map(&:to_s).join(\", \")}\")\n elsif !(diff = (actual - expected)).empty?\n flunk(\"expects two sets to be equal, but #{actual} has #{diff.size} more elements than expected:\\n #{diff.to_a.map(&:to_s).join(\", \")}\")\n end\n end", "def assert_not_includes(expected_items, collection)\n expected_items = [ expected_items ] unless expected_items.respond_to? \"size\"\n expected_items.each { |item| assert_false collection.include?(item), \"#{item.inspect} should not be contained in the collection\" }\n end", "def assert_sets_equal(expected, actual)\n if !(diff = (expected - actual)).empty?\n flunk(\"expects two sets to be equal, but #{expected} is \"\\\n \"missing #{diff.size} expected elements:\\n \"\\\n \"#{diff.to_a.map(&:to_s).join(', ')}\")\n elsif !(diff = (actual - expected)).empty?\n flunk(\"expects two sets to be equal, but #{actual} has \"\\\n \"#{diff.size} more elements than expected:\\n \"\\\n \"#{diff.to_a.map(&:to_s).join(', ')}\")\n end\n end", "def assert_includes(expected_items, collection)\n expected_items = [ expected_items ] unless expected_items.respond_to? \"size\"\n expected_items.each { |item| assert collection.include?(item), \"#{item.inspect} should be contained in the collection\" }\n end", "def refute_same_items(expected, actual)\n refute same_items(expected, actual),\n \"Expected #{ expected.inspect } and #{ actual.inspect } would not have the same items\"\n end", "def contain_exactly(*items); end", "def assert_same_elements(an_array, another_array)\n assert_equal an_array - another_array, another_array - an_array\n end", "def assert_same_list(exp, out)\n assert_equal(exp.length, out.length, \"Checking length\")\n (0...exp.length).each do |i|\n assert_same(exp[i], out[i], \"At index #{i} (of 0...#{exp.length})\")\n end\n end", "def test_assert_multiple_comparisons_returns_as_array_of_one_offs\n\t \tassert_equal([\"1113\", \"1114\"], check_for_match_arr([\"1113\", \"6666\", \"1114\"], \"1112\"))\n\tend", "def test_not_all_elements_match\n stream = FromArray.new([2, 4, 5, 6, 8])\n assert(\n stream.all_match { |val| val % 2 == 0 } == false,\n 'Expected false because not all elements are a match!'\n )\n end", "def assert_equal_yields(exp, out)\n if exp.zip(out).all?{|a,b| a.same_list?(b)}\n assert(true)\n else\n flunk(\"walk not equal: #{walk_str(out)} (expected #{walk_str(exp)})\")\n end\n end", "def elements_to_check\n if _expected_items\n SitePrism.logger.debug('Expected Items has been set.')\n _mapped_items.select { |name| _expected_items.include?(name) }\n else\n _mapped_items\n end\n end", "def test_array_5\n assert_equal(true, @array5.include?('xyz'))\n end", "def passed?(expected_result)\n reported_result = reported_result(expected_result['key'])\n ['denominator', 'numerator', 'exclusions'].each do |component|\n if reported_result[component] != expected_result[component]\n #puts \"reported: #{reported_result[component]} , expected: #{expected_result[component]}\"\n return false\n end\n end\n \n return true\n end", "def elements_to_check\n if _expected_items\n SitePrism.logger.debug('Expected Items has been set.')\n _mapped_items.select { |item_name| _expected_items.include?(item_name) }\n else\n _mapped_items\n end\n end", "def assert_same_values(expected, actual)\n actual.each_pair do |k,v|\n next unless expected[k]\n assert_equal expected[k], v, \"Values for #{k} are not matching\"\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if all elements in expected are included in actual in ordered way
def hash_included_array_ordered(expected, actual) # the two array must be consistent in size if expected.size != actual.size return false end for i in 0...expected.size if expected[i].class == Hash # Use hash_included_ordered if item is Hash, != otherwise if !hash_included_ordered expected[i], actual[i] return false end else if expected[i] != actual[i] return false end end end return true # every thing is fine... end
[ "def hash_included_array_unordered(expected, actual)\n # the two array must be consistent in size\n if expected.size != actual.size\n return false\n end\n\n expected.each do |item|\n found = false # indicates if the item is found\n if item.class == Hash\n for i in 0...actual.size\n if hash_included_unordered item, actual[i] # equal remaining to true indicates that the item has been found, break and test next item\n found = true\n break\n end\n end\n else\n if actual.include? item\n found = true\n end\n end\n if !found # if any item is not found, return false\n return false\n end\n end\n return true # every thing is fine...\n end", "def assert_includes_all(expected, actual, message = nil)\n missing_from_expected = expected.to_a - actual.to_a\n unless missing_from_expected.empty?\n message ||= \"Expected:\\n #{mu_pp expected}\\ndid not contain every element in Actual:\\n #{mu_pp actual}.\"\n flunk(\"#{message}\\nMissing expected elements:\\n #{mu_pp missing_from_expected}\")\n end\n end", "def assert_includes(expected_items, collection)\n expected_items = [ expected_items ] unless expected_items.respond_to? \"size\"\n expected_items.each { |item| assert collection.include?(item), \"#{item.inspect} should be contained in the collection\" }\n end", "def assert_not_includes(expected_items, collection)\n expected_items = [ expected_items ] unless expected_items.respond_to? \"size\"\n expected_items.each { |item| assert_false collection.include?(item), \"#{item.inspect} should not be contained in the collection\" }\n end", "def cmpUnordered(expected, actual, write_observed = 1)\n if File.directory?(expected) && File.directory?(actual)\n Dir.foreach(expected) do | dirent |\n next if dirent == \".\" or dirent == \"..\"\n unless cmpUnordered(expected + \"/\" + dirent, actual + \"/\" + dirent)\n return false\n end\n end\n return true\n end\n\n unless File.readable?(expected)\n raise(\"cannot read file '\" + expected + \"'\")\n end\n unless File.readable?(actual)\n raise(\"cannot read file '\" + actual + \"'\")\n end\n expected_lines = 0\n actual_lines = 0\n only_expected = Set.new\n only_actual = Set.new\n file_expected = File.open(expected)\n file_actual = File.open(actual)\n file_expected.each.zip(file_actual.each).each do | line_expected, line_actual |\n if not line_expected == nil\n expected_lines += 1\n end\n if not line_actual == nil\n actual_lines += 1\n end\n if not expected_lines == actual_lines\n break\n elsif not line_expected == line_actual\n if only_expected.include?(line_actual)\n only_expected.delete(line_actual)\n else\n only_actual.add(line_actual)\n end\n if only_actual.include?(line_expected)\n only_actual.delete(line_expected)\n else\n only_expected.add(line_expected)\n end\n end\n end\n file_expected.close\n file_actual.close\n same = only_expected.empty?() && only_actual.empty?() && expected_lines == actual_lines\n copyObserved(actual, expected, same, write_observed)\n return same\n end", "def order_comparision(old, new)\n order1 = []\n order2 = []\n for order in old\n order1 << [order[0], order[1], order[2]]\n end\n for order in new\n order2 << [order[0], order[1], order[2]]\n end\n return order1 != order2\n end", "def assert_same_elements(exp, act)\n assert_equal(exp.length, act.length, \"The expected and actual collection doesn't have the same size.\n We cannot assert that there is the same elements, the same number of times\")\n assert(exp.respond_to?(:each), \"expected collection doesn't have the method #each\")\n assert(act.respond_to?(:each), \"actual collection doesn't have the method #each\")\n exp.each do |e|\n element_found = false\n act.each do |act_elem|\n if act_elem.eql? e\n element_found = true\n next\n end\n end\n assert(element_found, \"Element #{e} of #{exp} does not exist in #{act}\")\n end\n end", "def assert_same_list(exp, out)\n assert_equal(exp.length, out.length, \"Checking length\")\n (0...exp.length).each do |i|\n assert_same(exp[i], out[i], \"At index #{i} (of 0...#{exp.length})\")\n end\n end", "def test_retuns_ordered_jobs_considering_all_dependecies\n sequence = Sequence.new()\n sequence.add(\"a =>\n b => c\n c => f\n d => a\n e => b\n f =>\")\n sequence.ordered.each do |job|\n assert (%w[a b c d e f].include?(job))\n end\n assert sequence.ordered.index(\"f\") < sequence.ordered.index(\"c\")\n assert sequence.ordered.index(\"c\") < sequence.ordered.index(\"b\")\n assert sequence.ordered.index(\"b\") < sequence.ordered.index(\"e\")\n assert sequence.ordered.index(\"a\") < sequence.ordered.index(\"d\")\n end", "def test_preordered_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j, f, a, d, h, k, z]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n result_array = []\n j.preordered_each { |node| result_array << node.detached_copy}\n\n expected_array.each_index do |i|\n # Match only the names.\n assert_equal(expected_array[i].name, result_array[i].name)\n end\n end", "def elements_to_check\n if _expected_items\n SitePrism.logger.debug('Expected Items has been set.')\n _mapped_items.select { |name| _expected_items.include?(name) }\n else\n _mapped_items\n end\n end", "def elements_to_check\n if _expected_items\n SitePrism.logger.debug('Expected Items has been set.')\n _mapped_items.select { |item_name| _expected_items.include?(item_name) }\n else\n _mapped_items\n end\n end", "def contain_exactly(*items); end", "def passed?(expected_result)\n reported_result = reported_result(expected_result['key'])\n ['denominator', 'numerator', 'exclusions'].each do |component|\n if reported_result[component] != expected_result[component]\n #puts \"reported: #{reported_result[component]} , expected: #{expected_result[component]}\"\n return false\n end\n end\n \n return true\n end", "def test_return_multiple_idenpendent_jobs_in_any_order\n sequence = Sequence.new()\n sequence.add(\"a =>\n b =>\n c =>\")\n sequence.ordered.each do |job|\n assert (%w[a b c].include?(job))\n end\n end", "def test_slice_when_allMatch\n assert_equal [[3], [2], [9]], @triple.slice_when { |e, f| e != f }.to_a\n end", "def assert_matched_arrays exp, act\n exp_ary = exp.to_ary\n assert_kind_of Array, exp_ary\n act_ary = act.to_ary\n assert_kind_of Array, act_ary\n assert_equal exp_ary.sort, act_ary.sort\n end", "def assert_equal_yields(exp, out)\n if exp.zip(out).all?{|a,b| a.same_list?(b)}\n assert(true)\n else\n flunk(\"walk not equal: #{walk_str(out)} (expected #{walk_str(exp)})\")\n end\n end", "def include_all?(arr, needle_arr)\n (needle_arr - arr).empty?\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Starts the admin game
def play return unless check_admin_password setup_dirs_and_files display_welcome_screen start_prompt end
[ "def start_game\n\n # Dev server interaction\n # FIXME: Shift this to 'login to server' interaction\n # \n @client_network_com.send_message(['setup', @game_state_model::players[@game_state_model::player_role]::name, @game_state_model::players[@game_state_model::player_role].player_color].join('|'))\n @controllers[:game]::view::grid.set_tiles\n initialize(568, 343, model: @game_state_model)\n @currentCtrl = @controllers[:game]\n\n end", "def game_start\n game_setup\n @console_delegate.show\n end", "def admin\n\t\tDungeon_Admin.admin\n\tend", "def start\n if @game.setup? && @game.startable?\n flash[:notice] = \"The game will begin shortly!\"\n @game.ready # manual start\n else\n flash[:error] = \"Unable to start this game\"\n end\n\n redirect_to(game_path(@game))\n end", "def start_app\n online = true\n # keeps the program running until user aborts\n while online == true\n welcome()\n menu = menu()\n if menu == 'Play'\n name = ask_name()\n create_game(name)\n controller()\n unless play_again?()\n quit()\n end\n else\n quit()\n end\n end\n end", "def start\n SocketController.init_game(self.users, self.id)\n end", "def start_new_game\n say \"\\nStarting a new game.\"\n @client.start_new_game\n end", "def admin\n cmd = browse_command(args) do\n \"https://#{Nimbu::Auth.site}.#{Nimbu::Auth.admin_host}/admin\"\n end\n exec(cmd)\n end", "def start\n if request.xhr? && current_user.owns_game?(current_game) && current_game.open?\n current_game.start!\n Juggernaut.send_to_channel('embedGame();', current_game.id);\n else\n raise \"Already started or not owner of game...\"\n end\n \n render :nothing => true\n end", "def start_game\n @new_prompt.title_screen\n @new_commands.create_new_board(5)\n select_mode\n end", "def finish_admin_game\n Dir.chdir(@root_path)\n system(\"rm -rf #{@admin_path}\")\n puts 'Fermeture du mode admin.'\n end", "def start_new_game\n GameService.start_new_game(@room) if @room.owned_by?(current_user) && @room.all_users_ready?\n end", "def start\n configure_log!\n client_configuration!\n client_application!\n client_initialize!\n\n Vedeu::Launcher.execute!(argv)\n end", "def ensure_super_admin\n redirect_to \"/game\" unless actor && actor.super_admin?\n end", "def admin_tester\n redirect_to(root_url) unless current_tester.admin?\n end", "def startGame\n\tif !$running\n\t\t$gui.hide_info()\n\t\t$gui.hide_scored()\n\t\t$p1.reset_position()\n\t\t$p2.reset_position()\n\t\t$ball.reset_position()\n\t\t$ball.start()\n\t\t$running = true\n\tend\nend", "def show_admin\n screen_name(\"Inicial-Admin\")\n\n distribute_ots\n\n respond_to do |format|\n format.html { render action: \"show_admin\" }\n format.json { head :ok }\n end\n end", "def start\n words = @dictionary_loader.load(\"dictionary.txt\")\n players = @player_loader.load(\"players\")\n \n @renderer.welcome\n @renderer.errors @player_loader.errors\n @renderer.players_list players\n \n selected_players = @user_input.select_players(2, players)\n num_of_words = @user_input.select_num_of_words\n\n # Start the game\n new_game = Game.new(words, @renderer)\n new_game.start(num_of_words, selected_players)\n end", "def start\n ::Guard::UI.info( \"#{self.class} is running!\" )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates admin directories and files
def setup_dirs_and_files system("mkdir -p #{@admin_path}") system("cp #{__dir__}/../docs/liste_mails.txt #{@admin_path}/liste_mails.txt") write_sonneries Dir.chdir(@admin_path) end
[ "def create_admin\n self.destination_root = options[:root]\n if in_app_root?\n\n unless supported_orm.include?(orm)\n say \"<= A the moment we only support #{supported_orm.join(\" or \")}. Sorry!\"\n raise SystemExit\n end\n\n self.behavior = :revoke if options[:destroy]\n directory(\"app/\", destination_root(\"admin\"))\n directory(\"assets/\", destination_root(\"public\", \"admin\"))\n\n Padrino::Generators::Model.dup.start([\n \"account\", \"name:string\", \"surname:string\", \"email:string\", \"crypted_password:string\", \"salt:string\", \"role:string\",\n \"-r=#{options[:root]}\", \"-s=#{options[:skip_migration]}\", \"-d=#{options[:destroy]}\"\n ])\n\n insert_into_gemfile(\"haml\")\n template \"templates/page/db/seeds.rb.tt\", destination_root(\"/db/seeds.rb\")\n append_file destination_root(\"config/apps.rb\"), \"\\nPadrino.mount(\\\"Admin\\\").to(\\\"/admin\\\")\"\n\n return if self.behavior == :revoke\n say (<<-TEXT).gsub(/ {10}/,'')\n\n =================================================================\n Admin has been successfully installed, now follow this steps:\n =================================================================\n 1) Run migrations\n 2) That's all!!\n =================================================================\n\n TEXT\n else\n say \"You are not at the root of a Padrino application! (config/boot.rb not found)\" and exit unless in_app_root?\n end\n end", "def create_admin\n self.destination_root = options[:root]\n if in_app_root?\n unless supported_orm.include?(orm)\n say \"<= At the moment, Padrino only supports #{supported_orm.join(\" or \")}. Sorry!\", :yellow\n raise SystemExit\n end\n\n tmp_ext = options[:renderer] || fetch_component_choice(:renderer)\n unless supported_ext.include?(tmp_ext.to_sym)\n say \"<= You are using '#{tmp_ext}' and for admin we only support '#{supported_ext.join(', ')}'. Please use #{supported_ext.map { |ext| '-e ' + ext.to_s }.join(' or ')}\", :yellow\n raise SystemExit\n end\n\n # Get the app's namespace.\n @app_name = fetch_app_name\n\n # setup admin app name\n @admin_name = options[:admin_name].classify\n @admin_path = options[:admin_name].underscore\n\n store_component_choice(:admin_renderer, tmp_ext)\n\n self.behavior = :revoke if options[:destroy]\n\n empty_directory destination_root(@admin_path)\n\n # Setup Admin Model\n @model_name = options[:admin_model].classify\n @model_singular = @model_name.underscore\n @model_plural = @model_singular.pluralize\n\n directory \"templates/app\", destination_root(@admin_path)\n directory \"templates/assets\", destination_root(\"public\", @admin_path)\n template \"templates/app.rb.tt\", destination_root(@admin_path + \"/app.rb\")\n inject_into_file destination_root('config/apps.rb'), \"\\nPadrino.mount(\\\"#{@app_name}::#{@admin_name}\\\", :app_file => Padrino.root('#{@admin_path}/app.rb')).to(\\\"/#{@admin_path}\\\")\\n\", :before => /^Padrino.mount.*\\.to\\('\\/'\\)$/\n unless options[:destroy]\n insert_middleware 'ConnectionPoolManagement', @admin_path if [:minirecord, :activerecord].include?(orm)\n insert_middleware 'IdentityMap', @admin_path if orm == :datamapper\n end\n\n params = [\n @model_singular, \"name:string\", \"surname:string\", \"email:string\", \"crypted_password:string\", \"role:string\",\n \"-a=#{options[:models_path]}\",\n \"-r=#{options[:root]}\"\n ]\n params << \"-s\" if options[:skip_migration]\n params << \"-d\" if options[:destroy]\n\n Padrino::Generators::Model.start(params)\n column = Struct.new(:name, :type)\n columns = [:id, :name, :surname, :email].map { |col| column.new(col) }\n column_fields = [\n { :name => :name, :field_type => :text_field },\n { :name => :surname, :field_type => :text_field },\n { :name => :email, :field_type => :text_field },\n { :name => :password, :field_type => :password_field },\n { :name => :password_confirmation, :field_type => :password_field },\n { :name => :role, :field_type => :text_field }\n ]\n\n unless options[:destroy]\n admin_app = Padrino::Generators::AdminPage.new([@model_singular], :root => options[:root], :destroy => options[:destroy], :admin_model => @model_singular, :admin_name => @admin_name)\n admin_app.default_orm = Padrino::Admin::Generators::Orm.new(@model_singular, orm, columns, column_fields)\n admin_app.invoke_all\n end\n\n # TODO See this, there's something wrong it's not being applied properly or something because test_account_model_generator last test fails.\n template \"templates/account/#{orm}.rb.tt\", destination_root(\"models\", \"#{@model_singular}.rb\"), :force => true\n\n if File.exist?(destination_root(\"db/seeds.rb\"))\n run \"mv #{destination_root('db/seeds.rb')} #{destination_root('db/seeds.old')}\"\n end\n template \"templates/account/seeds.rb.tt\", destination_root(\"db/seeds.rb\")\n\n empty_directory destination_root(@admin_path+\"/controllers\")\n empty_directory destination_root(@admin_path+\"/views\")\n empty_directory destination_root(@admin_path+\"/views/base\")\n empty_directory destination_root(@admin_path+\"/views/layouts\")\n empty_directory destination_root(@admin_path+\"/views/sessions\")\n empty_directory destination_root(@admin_path+\"/views/errors\")\n\n template \"templates/#{ext}/app/base/index.#{ext}.tt\", destination_root(@admin_path+\"/views/base/index.#{ext}\")\n template \"templates/#{ext}/app/layouts/application.#{ext}.tt\", destination_root(@admin_path+\"/views/layouts/application.#{ext}\")\n template \"templates/#{ext}/app/layouts/error.#{ext}.tt\", destination_root(@admin_path+\"/views/layouts/error.#{ext}\")\n template \"templates/#{ext}/app/sessions/new.#{ext}.tt\", destination_root(@admin_path+\"/views/sessions/new.#{ext}\")\n # Custom error.\n template \"templates/#{ext}/app/errors/403.#{ext}.tt\", destination_root(@admin_path+\"/views/errors/403.#{ext}\")\n template \"templates/#{ext}/app/errors/404.#{ext}.tt\", destination_root(@admin_path+\"/views/errors/404.#{ext}\")\n template \"templates/#{ext}/app/errors/500.#{ext}.tt\", destination_root(@admin_path+\"/views/errors/500.#{ext}\")\n\n unless options[:destroy]\n add_project_module @model_plural\n require_dependencies('bcrypt')\n end\n\n require_dependencies 'activesupport', :version => \">= 3.1\"\n\n # A nicer select box.\n # TODO FIXME This doesn't make much sense in here. Review.\n # gsub_file destination_root(\"admin/views/#{@model_plural}/_form.#{ext}\"), \"f.text_field :role, :class => :text_field\", \"f.select :role, :options => access_control.roles\"\n\n # Destroy account only if not logged in.\n gsub_file destination_root(@admin_path+\"/controllers/#{@model_plural}.rb\"), \"if #{@model_singular}.destroy\", \"if #{@model_singular} != current_account && #{@model_singular}.destroy\"\n return if self.behavior == :revoke\n\n instructions = []\n instructions << \"Run 'bundle'\"\n if [:activerecord, :datamapper, :sequel].include?(orm)\n instructions << \"Run 'bundle exec rake db:create' if you have not created a database yet\"\n instructions << \"Run 'bundle exec rake db:migrate'\"\n end\n instructions << \"Now repeat after me... 'ohm mani padme hum', 'ohm mani padme hum'... :)\" if orm == :ohm\n instructions << \"Run 'bundle exec rake db:seed'\"\n instructions << \"Visit the admin panel in the browser at '/#{@admin_path}'\"\n instructions.map! { |i| \" #{instructions.index(i)+1}) #{i}\" }\n\n say\n say \"=\"*65, :green\n say \"The admin panel has been mounted! Next, follow these steps:\", :green\n say \"=\"*65, :green\n say instructions.join(\"\\n\")\n say \"=\"*65, :green\n say\n else\n say \"You are not at the root of a Padrino application! (config/boot.rb not found)\"\n end\n end", "def create\n create_directories\n end", "def create_admin\n # Check if there already is an admin\n redirect_to(:action => 'login') and return false if User.admin_exists?\n\n if request.post?\n # Create the object for the administrator user\n @user = User.create_admin(params[:user][:email], params[:user][:name], params[:user][:password], params[:user][:password_confirmation])\n\n # Create Admins group, Root folder and the permissions \n if @user.save\n Group.create_admins_group\n Folder.create_root_folder\n GroupPermission.create_initial_permissions\n session[:user_id] = @user.id # Login\n redirect_to(:action => 'list', :controller => 'folder')\n end\n\n # Create the initial Ferret index for files\n # (note: The index for Folders was created when we created the Root folder)\n Myfile.rebuild_index\n end\n end", "def create_directory_structure\n #@log.info \"Creating directory structure in dir: \" + name\n empty_directory name\n empty_directory name + \"/miners\"\n empty_directory name + \"/lib\"\n empty_directory name + \"/log\"\n empty_directory name + \"/config\"\n template \"templates/application_config.erb\", \"#{name}/config/application.rb\"\n template \"templates/Gemfile.erb\", \"#{name}/Gemfile\" \n puts \"Application created successfully! \".green\n print \"Type \"\n print \"'cd #{name}' \".yellow\n print \"to go to the applications root directory, and then \"\n print \"'mines help' \".yellow\n puts \"to see all available commands and options.\"\n end", "def setup_directories\n require 'fileutils'\n\n path = File.join(homedir, maildir)\n create_maildir path\n create_maildir File.join(path, '.Trash')\n create_maildir File.join(path, '.Sent')\n create_maildir File.join(path, '.Drafts')\n create_maildir File.join(path, '.Spam')\n\n FileUtils.mkdir_p(path)\n FileUtils.chown_R(IcarusConfig[:postfix][:user], IcarusConfig[:postfix][:group], path)\n FileUtils.chmod_R(0750, path)\n end", "def create_directories\n Utils.create_directory(@grader_config.exec_root)\n Utils.create_directory(@grader_config.test_root)\n Utils.create_directory(@grader_config.logger_root)\n end", "def create_user_directories\n #Directories\n avatar = \"#{Rails.root}/data/avatars/#{resource.id}\"\n push = \"#{Rails.root}/data/push/#{resource.id}\"\n passes = \"#{Rails.root}/data/passes/#{resource.id}\"\n coredata = \"#{Rails.root}/data/coredata/#{resource.id}\"\n #Avatar Upload Pictures\n Dir.mkdir(avatar) unless File.exists?(avatar)\n #Push Notification Certificates\n Dir.mkdir(push) unless File.exists?(push)\n #Avatar Passbook\n Dir.mkdir(passes) unless File.exists?(passes)\n #Core Data\n Dir.mkdir(coredata) unless File.exists?(coredata)\n end", "def createFileStructure\n\t\n\tDir.mkdir(\"site\")\n\tDir.mkdir(\"site/contentpages\")\n\nend", "def make_controllers_and_models_dir\n FileUtils::mkdir_p \"controllers\"\n FileUtils::mkdir_p \"models\"\nend", "def prepare_dirs\n require 'fileutils'\n [USERS_DIR, USERS_SUSPENDED_DIR, USERS_SN_DIR, FOLLOWERS_DIR, STATUSES_DIR, LANGUAGES_DIR, LANGUAGES_LDIG_DIR].each do |dir|\n FileUtils.mkdir_p dir unless File.exist? dir\n end\nend", "def create_site()\n\t\tcreate_root()\n\t\tcreate_inner_folders()\n\t\tcreate_file_stubs()\n\tend", "def create_directories\n mkdir_p(File.join(install_directory,'tmp','cache'))\n chmod(0755, File.join(install_directory,'tmp','cache'))\n mkdir_p(File.join(install_directory,'tmp','session'))\n mkdir_p(File.join(install_directory,'tmp','sockets'))\n mkdir_p(File.join(install_directory,'log'))\n File.open(File.join(install_directory,'log','development.log'),'w')\n File.open(File.join(install_directory,'log','production.log'),'w')\n File.open(File.join(install_directory,'log','testing.log'),'w')\n end", "def create_dirs\n dir = File.join @build.obj_root, @dir_root\n cmd = \"mkdir -p %s\" % (:dynamic == @build.link_type ? dir\n : File.join( dir, 'static' ))\n Util.run_cmd cmd\n end", "def create_folders\n #todo: double check if path exists\n FileUtils.mkdir_p @_project_svn_dir\n FileUtils.mkdir_p @_project_trac_dir\n FileUtils.mkdir_p @_document_root_dir\n #todo: ensure that folders are not listable\n #todo: htaccess - file\n nil\n end", "def create_home\n create_dirs\n copy_files\n create_vimrc\n end", "def dirs_to_create\n [\n root,\n app_dir('models'),\n app_dir('processors'),\n app_dir('flows'),\n app_dir('jobs'),\n \n config_dir('environments'),\n config_dir('initializers'),\n \n data_dir,\n lib_dir,\n log_dir,\n script_dir,\n \n spec_dir('models'),\n spec_dir('processors'),\n spec_dir('flows'),\n spec_dir('jobs'),\n spec_dir('support'),\n \n tmp_dir\n ]\n end", "def make_app_directories\n @shell.call \"mkdir -p #{self.directories.join(\" \")}\"\n end", "def init\n FileUtils.mkdir_p(module_directory)\n FileUtils.mkdir_p(config_directory)\n FileUtils.mkdir_p(log_directory)\n FileUtils.mkdir_p(session_log_directory)\n FileUtils.mkdir_p(loot_directory)\n FileUtils.mkdir_p(local_directory)\n FileUtils.mkdir_p(user_logos_directory)\n FileUtils.mkdir_p(user_module_directory)\n FileUtils.mkdir_p(user_plugin_directory)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Outputs the admin game welcome screen
def display_welcome_screen puts <<~TXT Bienvenue dans le mode admin. Pour pouvez quitter à tout moment en tapant la commande exit. Tapez "aide" pour voir ce que vous pouvez faire. TXT end
[ "def welcome\n system \"clear\"\n puts \" \n +-+-+-+-+-+-+-+-+\n |I|r|o|n|j|o|b|s|\n +-+-+-+-+-+-+-+-+\n \n WELCOME\n \n \".light_blue\n puts \"--------------------------------\"\n puts \"This application will allow you\n to search through a well kept\n database of up to date job\n offerings!\n \n Before we get started...\n introduce yourself!\".light_blue\n puts \"--------------------------------\"\n self.initiate\n end", "def welcome\n\t\tputs \"Welcome to meal planner. Using this app will help you plan your meals for the day.\"\n\t\t\n\tend", "def give_welcome_msg\n puts \"Welcome to parcel system\"\n puts \"------------------------\"\n end", "def play\n return unless check_admin_password\n\n setup_dirs_and_files\n display_welcome_screen\n start_prompt\n 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 displaybegingame\n\t\t\t@output.puts \"Begin game.\"\n\t\tend", "def welcome\n system 'rake db:seed'\n system 'clear'\n Logo.start\n puts \"Hello, and welcome to Crockpot Recipe Finder!\"\n puts \" \"\n sleep(2)\n login_page\n end", "def print_welcome_message\n puts \"Welcome to Movie Bookings\"\n puts \"------------------------\"\n end", "def welcome_to_the_game\n\t\t# Welcome the player to the game\n\t\tputs \"\\nWelcome to the Secret Number Game! \\nI, Alex, worked hard to make it for you!\"\n\n\t\t# Call the method to get the player's name\n\t\tself.get_name\n\n\t\t# Let the player know the rules\n\t\tputs \"\\nThanks for playing #{self.player_name}!\"\n\t\tputs \"I am thinking of a number between 1 and #{range}\"\n\t\tputs \"You will have #{self.guesses} attempts to guess that secret number\"\n\tend", "def welcome_message\n puts \"Welcome to Everything but the Kitchen Sink!\"\n end", "def welcome_message\n info\n info(\"Welcome to #{config.app} (v#{TConsole::VERSION}). Type 'help' for help or 'exit' to quit.\")\n end", "def print_help\n puts \"Welcome Lyrics expert!\"\n puts \"To start the game please type => start\"\n puts \"To exit at any time just type => quit \"\n end", "def print_welcome_msg\n config = BeEF::Core::Configuration.instance\n version = config.get('beef.version')\n print_info \"Browser Exploitation Framework (BeEF)\"\n data = \"Version #{version}\\n\"\n data += \"Website http://beefproject.com\\n\"\n data += \"Run 'beef -h' for basic help.\\n\"\n data += \"Run 'git pull' to update to the latest revision.\"\n print_more data\n end", "def print_welcome\n puts \"Welcome to Panier #{Panier::VERSION}.\\n\"\n puts 'Press Ctrl+C to exit.'\n end", "def echo_welcome_message\n echo('Enter a command to begin')\n end", "def login_display\n\t\tsystem(\"clear\")\n puts \"#######################\"\n puts \"# #\"\n puts \"# Welcome!! #\"\n puts \"# #\"\n puts \"# Please select an #\"\n puts \"# option #\"\n puts \"# #\"\n puts \"# 1. New User #\"\n puts \"# #\"\n puts \"# 2. Returning User #\"\n puts \"# #\"\n puts \"# 3. Exit #\"\n puts \"# #\"\n\t\tputs \"#######################\"\n\tend", "def welcome\n system 'clear'\n puts \"--------LOGIN--------\"\n menu = [\"Login\", \"Create new user\"]\n choice = @prompt.select(\"\", menu)\n case choice\n when \"Login\"\n login\n when \"Create new user\"\n create_account\n end\n end", "def menu_logged_on\n puts ''\n puts '**************** User Menu ********************'\n puts '1 - Show this menu'\n puts '2 - View Meal Plan'\n puts '3 - Create new Meal Plan'\n puts '4 - Edit Meal Plan'\n puts '0 - Log out'\n puts '***********************************************'\n puts ''\n end", "def welcome \n\t\tp \"Hi! Welcome to #{@place_of_work}. My name is #{@name}.\"\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ends admin game, deletes folders and files, and change directory to root game
def finish_admin_game Dir.chdir(@root_path) system("rm -rf #{@admin_path}") puts 'Fermeture du mode admin.' end
[ "def endgame()\n\t\t@database = Database.new\n\t\t@database.save_files(@players)\n\t\t@database.load_files\n\tend", "def rm_home!\n FileUtils.rm_rf @home\n end", "def destroy\n location = Dir.pwd\n directory = File.join(location, \".grit\")\n\n if File.directory?(directory)\n are_you_sure\n\n File.delete(directory + \"/config.yml\")\n File.delete(directory + \"/history.log\")\n Dir.delete(directory)\n puts \"Grit configuration files have been removed from #{location}\"\n else\n puts \"#{location} is not a grit project!\"\n end\n end", "def destroy_wormhole(rootpath)\n if rootpath == \"#{$paths.reports_path}Sapphire_Update/New_Students\"\n Process.abort\n end\n Dir.chdir(rootpath)\n all_folders = Dir.entries(rootpath)\n if all_folders == [\".\",\"..\"]\n Dir.chdir(\"..\")\n Dir.rmdir(rootpath)\n @i += 1\n else\n all_folders.each{|entry|\n next if entry == \".\" || entry == \"..\"\n path = File.expand_path(entry)\n destroy_wormhole(path)\n Dir.chdir(\"..\")\n Dir.rmdir(rootpath)\n @i += 1\n }\n end\n end", "def refresh_gen_out_dir\n `rm -rf #{gen_out_dir}index.html`\n `rm -rf #{gen_out_dir}scripts`\n `mkdir #{gen_out_dir}scripts`\n `rm -rf #{gen_out_dir}styles`\n `mkdir #{gen_out_dir}styles`\n unless Dir.exists?(\"#{gen_out_dir}/audio\")\n `mkdir #{gen_out_dir}audio`\n end\n self\n end", "def delete_dir\n FileUtils.rm_rf(@server_dir)\n @queue = []\n end", "def destroy\n stop\n @server.connect do\n\n display_ \"Delete HTTP route\" do\n @server.exec! \"hermes destroy #{@name} --vhost-dir #{VHOST_DIR}\", as: ROUTER_USER, error_msg: \"Cannot delete HTTP route for '#{@name}' app\"\n 'done'\n end\n\n display_ \"Delete user and home directory\" do\n @server.exec! \"userdel -f #{@name}\", sudo: true, error_msg: \"Cannot delete user for '#{@name}' app\"\n @server.exec! \"rm -rf #{@home}\", sudo: true, error_msg: \"Cannot delete home directory for '#{@name}' app\"\n 'done'\n end\n\n display_ \"Delete git repository\" do\n @server.script! template(\"rm_repo.sh\", binding), as: GITOLITE_USER, error_msg: \"Cannot delete the git repository for '#{@name}' app\"\n 'done'\n end\n end\n end", "def cleanup\n\n # ----------------------------------------------\n account_name = 'your account name' # <-- change this!\n project_name = 'your project name' # <-- change this!\n # ----------------------------------------------\n\n project_dir = \"/home/#{account_name}/www\"\n Dir.chdir(project_dir)\n\n Dir.entries(project_name).select do |entry1|\n\n dir1 = File.join(project_name,entry1) #dir2 = \"#{project_name}/#{entry1}\"\n if is_directory?(dir1)\n Dir.entries(dir1).select do |entry2|\n \n dir2 = File.join(dir1,entry2) #dir2 = \"#{project_name}/#{entry1}/#{entry2}\"\n if is_directory?(dir2)\n Dir.entries(dir2).select do |entry3|\n \n dir3 = File.join(dir2,entry3) #dir3 = \"#{project_name}/#{entry1}/#{entry2}/#{entry3}\"\n if is_directory?(dir3)\n Dir.entries(dir3).select do |entry4|\n delete_file(File.join(dir3,entry4))\n end\n end\n\n delete_file(dir3)\n delete_dir(dir3)\n end\n end\n\n delete_file(dir2)\n delete_dir(dir2)\n end\n end\n\n delete_file(dir1)\n delete_dir(dir1)\n end\n\n delete_dir(project_name)\nend", "def move_out_of_directory\n Dir.chdir(@root_dir) unless @root_dir.nil?\nend", "def undo()\r\n Dir.delete(@DirectoryPath)\r\n end", "def cleanup\n if Dir.exists?(WORKFOLDER)\n FileUtils.remove_dir(WORKFOLDER)\n print_status(\"Workspace \\\"#{WORKFOLDER}\\\" deleted.\")\n end\nend", "def restart_dir; end", "def destroy\n current_user.quit\n flash[:notice] = \"Your player has committed suicide and left this game. So tragic!\"\n redirect_to game_path(@game)\n end", "def delete_root\n delete(Namespace::ROOT_PATH)\n end", "def clean_target(force = false)\n if File.exists?(@rendered_root)\n unless force\n print \"Are you sure to overwrite directory '#{@rendered_root}' [yN] ? \"\n exit unless $stdin.gets.chomp.downcase == 'y'\n end\n FileUtils.rm_r(@rendered_root, :secure => true)\n end\n end", "def destroy_borked\n FileUtils.rm_rf(root_dir) if root_dir.to_s.include?(Matrix.work_root)\n destroy\n end", "def exit_admin_mode\n if m = Mission.where(:id => session[:last_mission_id]).first\n current_user.change_mission!(m)\n end\n redirect_to(root_url(:admin_mode => nil))\n end", "def delete_gdom_dir(options)\n gdom_dir = $ldom_base_dir+\"/\"+options['name']\n destroy_zfs_fs(gdom_dir)\n return\nend", "def update\n params.each {|file|\n if file[1] == \"delete_me\" and File.exist?(@@root_destination + session[:login] + '/'+ file[0])\n filename = @@root_destination + session[:login] + '/' + file[0]\n if File.file?(filename)\n File.delete(filename)\n else\n FileUtils.remove_dir(filename)\n end\n end\n }\n respond_to do |format|\n format.html { redirect_to({:action => \"index\"}, :notice => t(:deletion_ok)) }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Handles the custom status command (displays status of "sonneries")
def cmd_status?(cmd) update_sonneries return false unless cmd == 'status' puts <<~TXT La sonnerie de cours sonnera toutes les #{@sonneries[:break].bold.pink} minutes. L'alarme incendie sonnera #{@sonneries[:fire].bold.pink} fois par mois. La musique de la sonnerie de cours est #{@sonneries[:sound].bold.pink}. TXT true end
[ "def handle_status_command( client, * )\n\t\tstatus = { version: Assemblage::VERSION, uptime: self.uptime }\n\t\tself.queue_output_message( client.make_response(:status, status) )\n\tend", "def statuscmd\n end", "def _show_status # show_status\r\n @screen.set_status_line *status_line_values\r\n end", "def status\n $stdout.puts \"The current status of the pow server is:\\n\\n\"\n result = %x{curl localhost/status.json --silent --header host:pow}\n json = JSON.parse(result)\n json.each_pair { |k,v| $stdout.puts \" #{k}: #{v}\" }\n $stdout.puts \"\\n\"\n end", "def execute_status\r\n puts \"> status\"\r\n @dungeon.current_room.show_status\r\n end", "def say_status(status, color)\n base.shell.say_status status, relative_destination, color if @log_status\n end", "def status_command\n case current_host.operating_system\n when :linux\n 'status'\n when :freebsd\n 'onestatus'\n end\n end", "def say_status(status)\n base.shell.say_status status, relative_destination, @log_status\n end", "def cmd_status argv\n setup argv\n response = @api.status\n msg response\n return response\n end", "def cmd_status()\n #This is a stub, used for indexing\n end", "def cmd_status argv\n setup argv\n uuid = @hash['uuid']\n response = @api.status(uuid)\n msg response\n return response\n end", "def status(*) end", "def status_text(server, cgi)\n if server.status then\n cgi.span({'class' => 'status online'}) do\n 'Online'\n end\n else\n cgi.span({'class' => 'status offline'}) do\n 'Offline'\n end\n end\n end", "def full_status\n \"#{main} - #{secondary}\"\n end", "def status\n JSON.pretty_generate({ 'status' => output(varnishadm(\"status\"))}) \n end", "def status\n\t\tif @status_ == :victory\n\t\t\treturn \"You Win!\"\n\t\telsif @status_ == :loss\n\t\t\treturn \"You Loose\"\n\t\telsif @status_ == :in_progress\n\t\t\treturn \"Still playing\"\n\t\tend\n\tend", "def status(status,opis)\n\tcase status\n\t\twhen \"dostepny\": stat=nil\n\t\twhen \"zw\":\t stat=:away\n\t\twhen \"pogadam\": stat=:chat\n\t\twhen \"np\":\t stat=:dnd\n\t\twhen \"nieosiagalny\":\t stat=:xa\n\telse\n\t\tblad\n\t\treturn\n\tend\n\t@jabber.zmien_status(stat,opis)\n end", "def show_status_prompt\n\t\t\tstats = {\n\t\t\t\t:hp => self.hit_points,\n\t\t\t\t:maxhp => self.max_hit_points,\n\t\t\t\t:mana => self.mana,\n\t\t\t\t:max_mana => self.max_mana,\n\t\t\t\t:tnl => (self.level * 1000) - self.experience\n\t\t\t}\n\t\t\tp = MudServer.get_player self\n\t\t\tif (p)\n\t\t\t\tp.client.print \"\\n\" + View.render_template('player.status_prompt', stats) + \" \"\n\t\t\tend\n\t\tend", "def show_status\r\n puts \"Status for room #{id}:\"\r\n if @contents.empty?\r\n puts \" The room is empty.\"\r\n else\r\n puts \" Contents: #{sorted_contents.join(', ')}\"\r\n end\r\n if @exits.empty?\r\n puts \" No exits.\"\r\n else\r\n doors = []\r\n doors << 'north' if @exits[:north]\r\n doors << 'south' if @exits[:south]\r\n doors << 'east' if @exits[:east]\r\n doors << 'west' if @exits[:west]\r\n puts \" There are exits to the #{doors.join(', ')}.\"\r\n end\r\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test method bar: toto: a parameter.
def bar(toto) @toto = toto end
[ "def foo(bar)\n bar\nend", "def print_foo(bar)\n puts Foo\n puts @foo\n puts bar\nend", "def test_bar_valid\n\t\tassert_equal 'Bar St.', @methods.bar_check('Museum', 'Cathedral')\n\tend", "def bar(param = \"no\")\n p param == \"no\" ? \"yes\" : \"no\"\nend", "def test_placeholder\r\n end", "def test_space_args_cmd\n assert_parses(\n s(:send, nil, :fun,\n s(:begin, s(:send, nil, :f, s(:lvar, :bar)))),\n %q{fun (f bar)})\n end", "def test_foo_valid\n\t\tassert_equal 'yes', @methods.foo_check('Hillman', 'Hospital')\n\tend", "def foo1(a, b)\nend", "def bar(param = \"no\")\n param == \"no\" ? \"yes\" : \"no\"\nend", "def test_of_caller_exception\r\n x = 10\r\n assert_raises(Exception) do\r\n _bar\r\n puts x\r\n end\r\n end", "def test_basic_param\n block_ = proc do |t_|\n t_.set_value(:a, 1)\n t_.set_value_by_block(:b){ 2 }\n assert(!self.respond_to?(:set_value))\n assert(!self.respond_to?(:set_value_by_block))\n end\n target_ = SimpleTarget.new\n Blockenspiel.invoke(block_, target_)\n assert_equal(1, target_.get_value(:a))\n assert_equal(2, target_.get_value(:b))\n end", "def example_passed(name)\n end", "def test1ActionTwiceDifferentParameters\n executeTest(\n 'DummyUser',\n {\n 'DummyTool' => {\n 'DummyActionWithParams' => [\n [ 'Param11', 'Param21' ],\n [ 'Param12', 'Param22' ]\n ]\n }\n }\n )\n end", "def test_customer_gets_less_drunk_with_food\n assert_equal(10, @customer3.test_customer_gets_less_drunk_with_food(@food3))\nend", "def test_addition_of_two_number\n # assert_raises \"Invalid values.\" do\n magic_ball = MagicBall.new\n puts \"--------------\"\n puts magic_ball.addition(5, 5)\n puts \"--------------\"\n assert magic_ball.addition(5, 5), 10\n # assert addition == 10\n # end\n end", "def test_foul_or_ball_method\r\n test_batter = PlayerBatter.new(\"test\")\r\n test_batter.foul_or_ball(\"foul\")\r\n test_batter.foul_or_ball(\"ball\")\r\n assert test_batter.balls == 2\r\n test_batter.foul_or_ball(\"ball\")\r\n test_batter.foul_or_ball(\"foul\")\r\n assert test_batter.balls == 3\r\n test_batter.foul_or_ball(\"ball\")\r\n assert test_batter.balls == 0\r\n assert test_batter.bases == [1]\r\n end", "def expected_method; end", "def test_square_with_2\n puts square(2) == 4\nend", "def m(a: 1, b: 2)\n p a, b\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /social_goal_records POST /social_goal_records.json
def create @social_goal_record = SocialGoalRecord.new(social_goal_record_params) @social_goal_record.goal_owner = @social_goal_record.current_user respond_to do |format| if @social_goal_record.save format.html { redirect_to @social_goal_record, notice: 'Social goal record was successfully created.' } format.json { render :show, status: :created, location: @social_goal_record } else format.html { render :new } format.json { render json: @social_goal_record.errors, status: :unprocessable_entity } end end end
[ "def create\n @goal = @todo.goals.create(goal_params)\n render json: @goal\n end", "def create\n @activitygoal = Activitygoal.new(params[:activitygoal])\n\n respond_to do |format|\n if @activitygoal.save\n format.html { redirect_to @activitygoal, notice: 'Activitygoal was successfully created.' }\n format.json { render json: @activitygoal, status: :created, location: @activitygoal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activitygoal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @goals = Goal.all\n @my_custom_goals = my_custom_goals\n @user_goal = UsersGoal.new(params[:users_goal])\n @user_goal.user = current_user\n\n respond_to do |format|\n if @user_goal.save\n format.html { redirect_to action: 'new', notice: 'Users goal was successfully created.' }\n format.json { render json: @user_goal, status: :created, location: @user_goal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def add datapoints, opts={}\n datapoints = [*datapoints]\n\n datapoints.each do |dp|\n # we grab these datapoints for ourselves\n dp.goal = self\n \n data = {\n \"sendmail\" => opts[:sendmail] || false\n }.merge(dp.to_hash)\n\n # TODO create_all doesn't work because Ruby's POST encoding of arrays is broken.\n @user.post \"users/me/goals/#{@slug}/datapoints.json\", data\n end\n end", "def create\n @financial_objects_goal = FinancialObjects::Goal.new(financial_objects_goal_params)\n\n respond_to do |format|\n if @financial_objects_goal.save\n format.html { redirect_to @financial_objects_goal, notice: \"Goal was successfully created.\" }\n format.json { render :show, status: :created, location: @financial_objects_goal }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @financial_objects_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @goals = goals_for_current_user\n @goal = Goal.new(params[:goal])\n @goal.user = current_user\n\n respond_to do |format|\n if @goal.save\n format.html { redirect_to({action: 'index'}, notice: 'Goal was successfully created.') }\n format.json { render json: @goal, status: :created, location: @goal }\n else\n format.html { render action: 'index' }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @goal_entry = GoalEntry.new(goal_entry_params)\n\n respond_to do |format|\n if @goal_entry.save\n format.html { redirect_to @goal_entry, notice: 'Goal entry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @goal_entry }\n else\n format.html { render action: 'new' }\n format.json { render json: @goal_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @field_goal = FieldGoal.new(params[:field_goal])\n\n respond_to do |format|\n if @field_goal.save\n format.html { redirect_to @field_goal, notice: 'Field goal was successfully created.' }\n format.json { render json: @field_goal, status: :created, location: @field_goal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @field_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nvs_goal = NvsGoal.new(params[:nvs_goal])\n @nvs_goal.project_id = @project\n @nvs_goal.created_by = User.current\n\n respond_to do |format|\n if @nvs_goal.save\n format.html { redirect_to @nvs_goal, notice: 'Nvs goal was successfully created.' }\n format.json { render json: @nvs_goal, status: :created, location: @nvs_goal }\n else\n @nvs_goal_types = NvsGoalType.all.map{|x| [x.name, x.id]}\n format.html { render action: \"new\" }\n format.json { render json: @nvs_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @team_goal = TeamGoal.new(team_goal_params)\n\n respond_to do |format|\n if @team_goal.save\n format.html { redirect_to @team_goal, notice: 'Team goal was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team_goal }\n else\n format.html { render action: 'new' }\n format.json { render json: @team_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @page_goal = PageGoal.new(page_goal_params)\n\n respond_to do |format|\n if @page_goal.save\n format.html { redirect_to @page_goal, notice: 'Page goal was successfully created.' }\n format.json { render action: 'show', status: :created, location: @page_goal }\n else\n format.html { render action: 'new' }\n format.json { render json: @page_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @goal_data_pt = GoalDataPt.new(goal_data_pt_params)\n\n respond_to do |format|\n if @goal_data_pt.save\n format.html { redirect_to @goal_data_pt, notice: 'Goal data pt was successfully created.' }\n format.json { render :show, status: :created, location: @goal_data_pt }\n else\n format.html { render :new }\n format.json { render json: @goal_data_pt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @individual_relationship_record = IndividualRelationshipRecord.new(params[:individual_relationship_record])\n\n respond_to do |format|\n if @individual_relationship_record.save\n format.html { redirect_to @individual_relationship_record, :notice => 'Individual relationship record was successfully created.' }\n format.json { render :json => @individual_relationship_record, :status => :created, :location => @individual_relationship_record }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @individual_relationship_record.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n puts params.to_s()\n @goal_instance = GoalInstance.new(params[:goal_instance])\n current_user = User.find(session[:current_user])\n current_user.goal_instances.push(@goal_instance)\n puts params[:goal_instance][:goal_id]\n current_goal = Goal.find(params[:goal_instance][:goal_id]) \n current_goal.goal_instances.push(@goal_instance)\n respond_to do |format|\n if @goal_instance.save\n format.html { redirect_to @goal_instance, notice: 'Goal instance was successfully created.' }\n format.json { render json: @goal_instance, status: :created, location: @goal_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @goal_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @weekly_goal = WeeklyGoal.new(weekly_goal_params)\n\n respond_to do |format|\n if @weekly_goal.save\n format.html { redirect_to @weekly_goal, notice: 'Weekly goal was successfully created.' }\n format.json { render :show, status: :created, location: @weekly_goal }\n else\n format.html { render :new }\n format.json { render json: @weekly_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_goals_after_create\n assessm = Assessment.active.last\n return if assessm.nil? || function_id.nil? || efective_id.nil?\n\n employee_goal_data = assessm.goals.map{|g| {status: g.status, goal_type: g.goal_type, name: g.name, unit: g.unit, nature: g.nature, target: g.target, goal_id: g.id, employee_id: efective_id, position_id: id, assessment_id: assessm.id}}\n EmployeeGoal.create(employee_goal_data)\n end", "def create\n @relationships = Relationship.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @relationship = Relationship.create(params[:relationship])\n end", "def create\n @goal_step = GoalStep.new(goal_step_params)\n\n respond_to do |format|\n if @goal_step.save\n format.html { redirect_to @goal_step, notice: \"Goal step was successfully created.\" }\n format.json { render :show, status: :created, location: @goal_step }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @goal_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project_goal = ProjectGoal.new(project_goal_params)\n\n respond_to do |format|\n if @project_goal.save\n format.html { redirect_to @project_goal, notice: 'Project goal was successfully created.' }\n format.json { render action: 'show', status: :created, location: @project_goal }\n else\n format.html { render action: 'new' }\n format.json { render json: @project_goal.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /social_goal_records/1 PATCH/PUT /social_goal_records/1.json
def update respond_to do |format| if @social_goal_record.update(social_goal_record_params) format.html { redirect_to @social_goal_record, notice: 'Social goal record was successfully updated.' } format.json { render :show, status: :ok, location: @social_goal_record } else format.html { render :edit } format.json { render json: @social_goal_record.errors, status: :unprocessable_entity } end end end
[ "def update\n goal = Goal.find params[:id]\n if goal.update(goal_params)\n render json: goal, status: 200\n else\n render json: goal.errors.full_messages, status: 422\n end\n end", "def update\n\n @goals = Goal.all\n @my_custom_goals = my_custom_goals\n @user_goal = my_goals.find(params[:id])\n\n respond_to do |format|\n if @user_goal.update_attributes(params[:users_goal])\n format.html { redirect_to action: 'new', notice: 'Users goal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @activitygoal = Activitygoal.find(params[:id])\n\n respond_to do |format|\n if @activitygoal.update_attributes(params[:activitygoal])\n format.html { redirect_to @activitygoal, notice: 'Activitygoal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @activitygoal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n if @goal.update_attributes(params[:goal])\n format.html { redirect_to @goal, notice: 'Goal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n if @goal.update_attributes(params[:goal])\n format.html { redirect_to @goal, notice: 'Goal was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @step.update(step_params)\n render json: @step\n end", "def update\n respond_to do |format|\n if @goal_entry.update(goal_entry_params)\n format.html { redirect_to @goal_entry, notice: 'Goal entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @goal_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @field_goal = FieldGoal.find(params[:id])\n\n respond_to do |format|\n if @field_goal.update_attributes(params[:field_goal])\n format.html { redirect_to @field_goal, notice: 'Field goal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @field_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @team_goal.update(team_goal_params)\n format.html { redirect_to @team_goal, notice: 'Team goal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @team_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @goal_update.update(goal_update_params)\n format.html { redirect_to [@goal, @goal_update], notice: 'Goal update was successfully updated.' }\n format.json { render :show, status: :ok, location: @goal_update }\n else\n format.html { render :edit }\n format.json { render json: @goal_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n json_update(factType,factType_params, FactType)\n end", "def update\n respond_to do |format|\n if @project_goal.update(project_goal_params)\n format.html { redirect_to @project_goal, notice: 'Project goal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project_goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @goat = Goat.find(params[:id])\n\n if @goat.update(goat_params)\n head :no_content\n else\n render json: @goat.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @goal_to_be.update(goal_to_be_params)\n format.html { redirect_to @goal_to_be, notice: 'Goal to be was successfully updated.' }\n format.json { render :show, status: :ok, location: @goal_to_be }\n else\n format.html { render :edit }\n format.json { render json: @goal_to_be.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @claim_audit_entry.delete_prev_detail_records\n parsing_answers\n respond_to do |format|\n if @claim_audit_entry.update(claim_audit_entry_params)\n @claim_audit_entry.claim_awaiting_audit.update(:last_reviewed_date=>Date.today, :new_upload => true)\n format.html { redirect_to root_path, notice: 'Claim audit entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to action: 'edit',:id=>@claim_audit_entry.id,notice: \"#{@claim_audit_entry.errors.full_messages.first}\" }\n format.json { render json: @claim_audit_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n spice = Spice.find_by(id: params[:id])\n spice.update(spice_params)\n render json: spice\nend", "def update\n @done_step.update(done_step_params)\n render json: @done_step\n end", "def update\n respond_to do |format|\n if @goal_step.update(goal_step_params)\n format.html { redirect_to @goal_step, notice: \"Goal step was successfully updated.\" }\n format.json { render :show, status: :ok, location: @goal_step }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @goal_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @goal_instance = GoalInstance.find(params[:id])\n\n respond_to do |format|\n if @goal_instance.update_attributes(params[:goal_instance])\n format.html { redirect_to @goal_instance, notice: 'Goal instance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goal_instance.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /social_goal_records/1 DELETE /social_goal_records/1.json
def destroy goal = @social_goal_record.goal @social_goal_record.destroy respond_to do |format| format.html { redirect_to social_goal_path(goal), notice: 'Social goal record was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @activitygoal = Activitygoal.find(params[:id])\n @activitygoal.destroy\n\n respond_to do |format|\n format.html { redirect_to activitygoals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal_entry.destroy\n respond_to do |format|\n format.html { redirect_to goal_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @users_goal = my_goals.find(params[:id])\n @users_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to action: 'new', notice: 'Goal was removed'}\n format.json { head :no_content }\n end\n end", "def destroy\n @field_goal = FieldGoal.find(params[:id])\n @field_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to field_goals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal_update.destroy\n respond_to do |format|\n format.html { redirect_to goal_goal_updates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal = Goal.find(params[:id])\n @goal.destroy\n\n respond_to do |format|\n format.html { redirect_to list_goals_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal = Goal.find(params[:id])\n @goal.destroy\n\n respond_to do |format|\n format.html { redirect_to goals_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @ga_pageviews_record = GaPageviewsRecord.find(params[:id])\n @ga_pageviews_record.destroy\n\n respond_to do |format|\n format.html { redirect_to ga_pageviews_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @global_goal = GlobalGoal.find(params[:id])\n @global_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to global_goals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal = Mg::Goal.find(params[:id])\n @goal.destroy\n\n respond_to do |format|\n format.html { redirect_to mg_goals_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @goal = @user.goals.find(params[:id])\n @goal.destroy\n\n respond_to do |format|\n format.html { redirect_to user_goals_url(@user) }\n format.json { head :no_content }\n end\n end", "def destroy\n @v_goal = VGoal.find(params[:id])\n @v_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to v_goals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @glo_record.destroy\n respond_to do |format|\n format.html { redirect_to glo_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @level_goal = LevelGoal.find(params[:id])\n @level_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to level_goals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mgoal = Mgoal.find(params[:id])\n @mgoal.destroy\n\n respond_to do |format|\n format.html { redirect_to mgoals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sgoal = Sgoal.find(params[:id])\n @sgoal.destroy\n\n respond_to do |format|\n format.html { redirect_to sgoals_url }\n format.json { head :no_content }\n end\n end", "def delete_goal(goal)\n sql = \"DELETE FROM #{GOALS_TBL} WHERE goal = $1\"\n result = @db.exec_params(sql, [goal])\n result.cmd_status == \"DELETE 1\"\n end", "def destroy\n @goal = Goal.find(params[:id])\n @goal.destroy\n\n respond_to do |format|\n format.html { redirect_to(goals_url) }\n format.xml { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the canAccept property value. The canAccept property
def can_accept return @can_accept end
[ "def can_accept=(value)\n @can_accept = value\n end", "def accept_mode\n Cproton.pn_messenger_get_accept_mode(@impl)\n end", "def get_accept_state_reachable\n return @accept_state_reachable\n end", "def accepted?\n return (self.status == STATUS_ACCEPTED)\n end", "def allowed?\n allowed\n end", "def accepting?\n !!@data[:accepting]\n end", "def accepted?\n self.state == ACCEPTED\n end", "def accepted?\n self.status == ACCEPTED\n end", "def can?\n @bytes.first == Message::CAN\n end", "def is_accept_state?(state)\n @accept.include? state.to_s\n end", "def is_mfa_accepted\n return @is_mfa_accepted\n end", "def acceptable?(value)\n true\n end", "def is_compliant_device_accepted\n return @is_compliant_device_accepted\n end", "def accepted_version\n return @accepted_version\n end", "def accept_state?(state)\n @accept.include? state\n end", "def is_per_device_acceptance_required\n return @is_per_device_acceptance_required\n end", "def accepted?\n state == 'accepted'\n end", "def set_Accept(value)\n set_input(\"Accept\", value)\n end", "def accept_header?\n accept != DEFAULT_ACCEPT\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the canAccept property value. The canAccept property
def can_accept=(value) @can_accept = value end
[ "def set_Accept(value)\n set_input(\"Accept\", value)\n end", "def can_accept\n return @can_accept\n end", "def accepting!(value = true)\n @data[:accepting] = value\n end", "def accept\n update(accepted: true, responded: true)\n end", "def accept\n if acceptable?\n touch :accepted_at\n true\n else\n false\n end\n end", "def is_mfa_accepted=(value)\n @is_mfa_accepted = value\n end", "def allow(key)\n @status[key] = :allowed\n end", "def is_viewing_before_acceptance_required=(value)\n @is_viewing_before_acceptance_required = value\n end", "def can_share=(value)\n @can_share = value\n end", "def is_compliant_device_accepted=(value)\n @is_compliant_device_accepted = value\n end", "def needs_to_accept?\n self.accepted = followed ? !followed.need_accept? : true\n true\n end", "def allow_redirect=(value)\n @allow_redirect = value\n end", "def assigned_accept_list=(hash)\n self.accept_list.attributes = hash\n end", "def is_per_device_acceptance_required=(value)\n @is_per_device_acceptance_required = value\n end", "def allow_close=(value)\n @peer.allow_close = value\n end", "def set_AllowShare(value)\n set_input(\"AllowShare\", value)\n end", "def allow_override=(value)\n @allow_override = value\n end", "def can_edit=(value)\n @can_edit = value\n end", "def is_require_accepting_user_to_match_invited_user_enabled=(value)\n @is_require_accepting_user_to_match_invited_user_enabled = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instantiates a new calendarSharingMessage and sets the default values.
def initialize() super @odata_type = "#microsoft.graph.calendarSharingMessage" end
[ "def initialize_defaults\n @messenger = @@default_messenger\n @message = Message.new\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.serviceUpdateMessage\"\n end", "def initialize(message, conf)\r\n @message = message\r\n @conf = conf\r\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.eventMessageRequest\"\n end", "def create\n @message_calendar = MessageCalendar.new(params[:message_calendar])\n\n respond_to do |format|\n if @message_calendar.save\n format.html { redirect_to @message_calendar, notice: 'Message calendar was successfully created.' }\n format.json { render json: @message_calendar, status: :created, location: @message_calendar }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message_calendar.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.eventMessage\"\n end", "def initialize_messenger\n raise NotImplementedError\n end", "def default_message_options\n @default_message_options ||= {type: 'message'}\n end", "def initialize_mailbox\n Mailbox.new\n end", "def initialize\n @application_name = 'chime-sdk-rails'\n @media_region = 'us-east-1'\n @prefix = \"#{@application_name}-#{Rails.env}-\"\n @max_meeting_results = 10\n @max_attendee_results = 10\n @create_meeting_with_attendee = true\n @create_attendee_from_meeting = true\n @create_meeting_by_get_request = false\n end", "def initialize(options = {})\n options = {\n :message_id => nil,\n :senders => [],\n :recipients => [],\n :cc_recipients => [],\n :bcc_recipients => [],\n :subject => \"\",\n :body => \"\",\n :date => nil\n }.merge(options)\n self.message_id = options[:message_id]\n self.senders = options[:senders]\n self.recipients = options[:recipients]\n self.cc_recipients = options[:cc_recipients]\n self.bcc_recipients = options[:bcc_recipients]\n self.subject = options[:subject]\n self.body = options[:body]\n self.date = options[:date]\n end", "def init_default_values(server)\n LOGGER.init_log_channel(server)\n RoleMessage.init_assignment_channel(server)\n JoinLeaveMessages.init_message_channel(server)\n end", "def sharing_message_action=(value)\n @sharing_message_action = value\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.meetingPolicyUpdatedEventMessageDetail\"\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.messagePinnedEventMessageDetail\"\n end", "def initialize_messenger\n @context.messenger = RubyMessenger.new @context.expectations, @subject\n end", "def sharing_message_actions=(value)\n @sharing_message_actions = value\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.mailAssessmentRequest\"\n end", "def initialize msg, disttype=:roundrobin, distcount=nil\n\n raise \"invalid disttype\" unless DIST_T.include? disttype\n\n @pub_t = Pub_t.new\n\n # set payload\n set_ptr @pub_t, :msg, msg\n @pub_t[:size] = msg.size\n\n # set distribution strategy\n @pub_t[:disttype] = (disttype == :roundrobin)? 0: 1;\n @pub_t[:distcount] = distcount.nil?? 0: distcount;\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the sharingMessageAction property value. The sharingMessageAction property
def sharing_message_action return @sharing_message_action end
[ "def sharing_message_action=(value)\n @sharing_message_action = value\n end", "def sharing_message_actions\n return @sharing_message_actions\n end", "def sharing_message_actions=(value)\n @sharing_message_actions = value\n end", "def message_action_flag\n return @message_action_flag\n end", "def recipient_action_message\n return @recipient_action_message\n end", "def action\n return @action\n end", "def message_action_flag=(value)\n @message_action_flag = value\n end", "def get_action_name\n return @action\n end", "def recipient_action_message=(value)\n @recipient_action_message = value\n end", "def action\n (val = command[:action]) && val.to_sym\n end", "def manager_action_message\n return @manager_action_message\n end", "def action_name\n return @action_name\n end", "def action\n action_name.to_sym\n end", "def action\n action_name.to_sym\n end", "def verb\n \"share\"\n end", "def sharing_subject\n return @sharing_subject\n end", "def sharing_type\n return @sharing_type\n end", "def action\n self[:action].to_sym if self[:action]\n end", "def action_name\n ACTIONS[action.to_s]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the sharingMessageAction property value. The sharingMessageAction property
def sharing_message_action=(value) @sharing_message_action = value end
[ "def sharing_message_actions=(value)\n @sharing_message_actions = value\n end", "def sharing_message_action\n return @sharing_message_action\n end", "def sharing_message_actions\n return @sharing_message_actions\n end", "def message_action_flag=(value)\n @message_action_flag = value\n end", "def recipient_action_message=(value)\n @recipient_action_message = value\n end", "def shared_action(name, &block)\n @base.shared_actions[name] = block\n end", "def share(activity)\n self.act(activity, :share)\n end", "def set_AllowShare(value)\n set_input(\"AllowShare\", value)\n end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def set_Share(value)\n set_input(\"Share\", value)\n end", "def set_action(action)\n @action = action\n end", "def manager_action_message=(value)\n @manager_action_message = value\n end", "def sharing_type=(value)\n @sharing_type = value\n end", "def action=(action)\n if action && !VALID_ACTIONS.include?(action.to_sym)\n raise ArgumentError, \"Invalid Action (#{action}), use: #{VALID_ACTIONS*' '}\"\n end\n command[:action] = action\n end", "def verb\n \"share\"\n end", "def setAction(action)\n unless /(?i)^(join|shuffle|extract|delete)$/.match(action)\n raise Error.new(Pdfcrowd.create_invalid_value_message(action, \"setAction\", \"pdf-to-pdf\", \"Allowed values are join, shuffle, extract, delete.\", \"set_action\"), 470);\n end\n \n @fields['action'] = action\n self\n end", "def sharing_subject=(value)\n @sharing_subject = value\n end", "def disconnect_action=(value)\n @disconnect_action = value\n end", "def add_share_activity(share_to = nil, attach_to = nil)\n share_to ||= self.shared_by.feed_to\n share_to = [share_to] unless share_to.is_a?(Array)\n share_to << self.shared_by unless share_to.include?(self.shared_by) # make sure the person doing the sharing is included\n add_activity(share_to, self.shared_by, self, 'share', '', '', nil, attach_to)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the sharingMessageActions property value. The sharingMessageActions property
def sharing_message_actions return @sharing_message_actions end
[ "def sharing_message_actions=(value)\n @sharing_message_actions = value\n end", "def sharing_message_action\n return @sharing_message_action\n end", "def sharing_message_action=(value)\n @sharing_message_action = value\n end", "def message_action_flag\n return @message_action_flag\n end", "def is_content_sharing_notification_enabled\n return @is_content_sharing_notification_enabled\n end", "def actions\n return @actions\n end", "def publishing_actions\n\n actions = []\n\n if wf = publishing_workflow\n actions= wf.available_steps(self).map { |step| step.action }\n end\n\n return actions.uniq\n\n end", "def get_social_actions share_urns\n path = '/socialActions'\n get(path, ids: share_urns)\n end", "def actions\n @actions ||= []\n end", "def trigger_actions\n @attributes[:trigger_actions]\n end", "def content_sharing_sessions\n return @content_sharing_sessions\n end", "def osc_actions(actions)\n actions.select { |action| osc?(action) }\n end", "def actions\n return @actions unless @actions.nil?\n\n if default_action.is_a?(Array)\n @actions = @native_resource.actions\n else\n @actions = [default_action].compact + @native_resource.actions.sort.uniq.select { |a| a != default_action }\n end\n\n @actions.delete(:nothing) if @actions != [:nothing] && action_descriptions[:nothing].nil?\n @actions\n end", "def actions=(value)\n @actions = value\n end", "def actions\n role_actions.select{|x| x.enabled}.map{|x| x.action}\n end", "def soap_actions\n @soap_actions ||= stream.operations.keys\n end", "def recommended_actions\n return @recommended_actions\n end", "def sharing_capability\n return @sharing_capability\n end", "def action_responses\n self.class.action_responses[action_name] || []\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the sharingMessageActions property value. The sharingMessageActions property
def sharing_message_actions=(value) @sharing_message_actions = value end
[ "def sharing_message_action=(value)\n @sharing_message_action = value\n end", "def sharing_message_actions\n return @sharing_message_actions\n end", "def sharing_message_action\n return @sharing_message_action\n end", "def publishable_actions(*actions)\n @publishable_actions = actions\n end", "def actions=(value)\n @actions = value\n end", "def message_action_flag=(value)\n @message_action_flag = value\n end", "def apply_actions=(value)\n @apply_actions = value\n end", "def is_content_sharing_notification_enabled=(value)\n @is_content_sharing_notification_enabled = value\n end", "def include_user_actions=(value)\n @include_user_actions = value\n end", "def set_allowed_actions(policy_name, actions)\n @allowed_actions = actions.select { |action| policy(policy_name).send(\"#{action}?\") }\n end", "def set_AllowShare(value)\n set_input(\"AllowShare\", value)\n end", "def act notification, options={}\n sharee.collect shared\n I18n.t 'notification.user.shared_event.act', shared: shared.decorate.title\n end", "def recipient_action_message=(value)\n @recipient_action_message = value\n end", "def can_share=(value)\n @can_share = value\n end", "def share_interactions(calltoaction)\n calltoaction_share_interactions = cache_short(\"calltoaction_#{calltoaction.id}_share_interactions\") do\n calltoaction.interactions.where(\"resource_type = ? AND when_show_interaction = ?\", \"Share\", \"SEMPRE_VISIBILE\").to_a\n end\n end", "def sharing_capability=(value)\n @sharing_capability = value\n end", "def actions(*action_names)\n action_names = action_names.flatten\n if !action_names.empty? && !@allowed_actions\n self.allowed_actions = ([ :nothing ] + action_names).uniq\n else\n allowed_actions(*action_names)\n end\n end", "def share(activity)\n self.act(activity, :share)\n end", "def apps_block_clipboard_sharing=(value)\n @apps_block_clipboard_sharing = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the suggestedCalendarName property value. The suggestedCalendarName property
def suggested_calendar_name return @suggested_calendar_name end
[ "def suggested_calendar_name=(value)\n @suggested_calendar_name = value\n end", "def set_CalendarName(value)\n set_input(\"CalendarName\", value)\n end", "def day_name\n return @@day_names[self.day_in_week]\n end", "def set_calendar_name\n calname = course_name\n calname += \" Year #{@course_year}\" unless masters_course?\n @cal.custom_property(\"X-WR-CALNAME\", calname)\n end", "def preferred_name\n return @preferred_name\n end", "def regurlar_day_name\n\t\tday_number = self.regular_day.to_s\n\t\tcase day_number\n\t\t\twhen 0\n\t\t\t\treturn \"Sunday\"\n\t\t\twhen 1\n\t\t\t\treturn \"Monday\"\n\t\t\tWhen 2\n\t\t\t\treturn \"Tuesday\"\n\t\t\tWhen 3\n\t\t\t\treturn \"Wednesday\"\n\t\t\tWhen 4\n\t\t\t\treturn \"Thursday\"\n\t\t\tWhen 5\n\t\t\t\treturn \"Friday\"\n\t\t\tWhen 6\n\t\t\t\treturn \"Saturday\"\n\t\t\telse\n\t\t\t\treturn self.regular_day\n\t\tend\n\tend", "def room_calendar_class_name\n if room.ring?\n 'calendar-boxing-ring'\n elsif room.ring_no_opposition?\n 'calendar-boxing-ring-no-opposition'\n elsif room.ring_no_opposition_advanced?\n 'calendar-boxing-ring-no-opposition_advanced'\n elsif room.ring_feet_and_fist?\n 'calendar-boxing-ring-feet-and-fist'\n elsif room.training?\n 'calendar-punching-bag'\n else\n 'calendar-arsenal'\n end\n end", "def calendars_shortcut\n (config_params||DEFAULT_CONFIG_PARAMS)[\"Calendars Shortcut\"]\n end", "def default_name(an_organizer)\n \"#{an_organizer&.abbreviation} #{start_date&.year}\"\n end", "def day_name(day)\n if self.replace_saturday && day == 7\n self.ashkenaz ? 'Shabbos' : 'Shabbat'\n else\n Date::DAYNAMES[day - 1]\n end\n end", "def getMeetingScheduleObjName\r\n\t\t\treturn \"mfiforce__Meeting_Schedule__c\"\r\n\t\tend", "def calendar_for_course(course, default='other')\n\n #Find the calendar that should contain a given course.\n name, calendar = Courses.find { |name, value| value.include?(course) }\n\n #If no calendar should contain this course, provide the default value.\n name || default\n\nend", "def getMeetingScheduleObjName\r\n\t\t\treturn \"Meeting_Schedule__c\"\r\n\t\tend", "def abbr_day_name; Date::ABBR_DAYNAMES[wday] end", "def canonical_name\n return @canonical_name\n end", "def short_day_name(val, options)\n val ? I18n.t('date.abbr_day_names')[val.to_i] : val\n end", "def get_CalendarDescription()\n \t return @outputs[\"CalendarDescription\"]\n \tend", "def default_calendar_id\n @calendar_id ||= editable_calendars.first.calendar_id\n end", "def preferred_name=(value)\n @preferred_name = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the suggestedCalendarName property value. The suggestedCalendarName property
def suggested_calendar_name=(value) @suggested_calendar_name = value end
[ "def suggested_calendar_name\n return @suggested_calendar_name\n end", "def set_CalendarName(value)\n set_input(\"CalendarName\", value)\n end", "def set_calendar_name\n calname = course_name\n calname += \" Year #{@course_year}\" unless masters_course?\n @cal.custom_property(\"X-WR-CALNAME\", calname)\n end", "def preferred_name=(value)\n @preferred_name = value\n end", "def update_default_name\n if will_save_change_to_organizer_id?\n previous_organizer = Organizer.where(abbreviation: name.split(\" \").first).first\n old_default_name = default_name(previous_organizer)\n use_default = name == old_default_name\n else\n use_default = name.blank?\n end\n self.name = default_name(organizer) if use_default\n end", "def is_default_calendar=(value)\n @is_default_calendar = value\n end", "def calendar=(value)\n @calendar = value\n end", "def display_name=(name)\n @display_name ||= name\n end", "def display_name_set(name)\n display_name.set(name)\n end", "def canonical_name=(value)\n @canonical_name = value\n end", "def set_CalendarID(value)\n set_input(\"CalendarID\", value)\n end", "def setDaysNames(days)\n @day_name = days.clone\n end", "def calendars_shortcut\n (config_params||DEFAULT_CONFIG_PARAMS)[\"Calendars Shortcut\"]\n end", "def meeting_category_name=(name)\n self.meeting_category = MeetingCategory.find_or_new_by_name(name.to_s) if name.present?\n end", "def set_default_display_name\n self['display_name'] = gn if display_name.blank?\n end", "def default_name(an_organizer)\n \"#{an_organizer&.abbreviation} #{start_date&.year}\"\n end", "def event_name=(value)\n @event_name = value\n end", "def event_name=(value)\n @event_name = value\n end", "def calendars=(value)\n @calendars = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
sexspecific subroutines that feed into move_one_patch function
def move_one_patch target = patch_ahead 1 # faced patch desirable # faced patch force move # # find desirable neighboring patch # no desirable, about face if passable?(target) if patch_desirable?(target) walk_forward 1 self.random_walk_suitable_count += 1 elsif should_leave? walk_forward 1 self.random_walk_unsuitable_count += 1 else select_forage_patch_and_move end else select_forage_patch_and_move end end
[ "def update_move\n super\n Yuki::MapLinker.test_warp unless moving?\n end", "def player_update_move_bump(bool)\n unless moving?\n unless $game_temp.common_event_id != 0 or @surfing or @sliding\n if @last_x == @x and @last_y == @y\n if @lastdir4 != 0 and !bool\n @step_anime = true\n if (@old_pattern == 3 and @pattern == 0) or (@old_pattern == 1 and @pattern == 2)\n Audio.se_play(BUMP_FILE)\n end\n else\n @step_anime = false\n end\n else\n @last_x = @x\n @last_y = @y\n end\n else\n if @surfing\n if @last_x == @x and @last_y == @y\n if @lastdir4 != 0 and !bool\n if (@old_pattern == 3 and @pattern == 0) or (@old_pattern == 1 and @pattern == 2)\n Audio.se_play(BUMP_FILE)\n end\n end\n else\n @last_x = @x\n @last_y = @y\n end\n end\n end\n else\n @step_anime = false unless @surfing\n end\n @old_pattern = @pattern\n # _BUMP\n # Lines for the Pokemon like bump\n=begin\n if(@bump_count>0)\n @bump_count -= 1\n unless @surfing or @sliding\n if @on_acro_bike or $game_switches[::Yuki::Sw::EV_Bicycle]\n @step_anime = false\n else\n @step_anime = !(@bump_count==0 or @lastdir4==0)\n end\n if @step_anime\n if (@old_pattern == 0 and @pattern == 1) or (@old_pattern == 2 and @pattern == 3)\n Audio.se_play(BUMP_FILE)\n end\n end\n @old_pattern = @pattern\n end\n end\n=end\n end", "def movement ; end", "def capture_move?(x_new, y_new)\n end", "def process_movement\n # Delete the graphics associated to moving\n @ranges.each{|tile| tile.visible = false}\n @ranges = []\n @arrow_path.each{|a| a.dispose}\n @arrow_path = []\n # Move the cursor back to the selected unit\n proc = Proc.new{@selected_unit.selected = false\n @show_move = false\n @selected_unit.sprite.move(@passed_positions)\n @selected_unit.stop_capture if @passed_positions.size != 0}\n cursor.add_move_action(@selected_unit.x, @selected_unit.y, proc)\n # go to phase 3\n @phase = 3\n end", "def switchmove _obj, _args\n \"_obj switchmove _args;\" \n end", "def smove(source, destination, member); end", "def module_move_up(mod) end", "def test_move\n (0..3).each { |i| @cart.add_item(:active, @item_models[i]) }\n\n @cart.active_items.setSelectionIndexes(index_set([0, 2]))\n move_test_helper([\"1\", \"3\"], [\"0\", \"2\"], {0 => :saved, 1 => :active, 2 => :saved, 3 => :active}) do \n @app.move(:saved, @cart.active_items)\n end\n\n @cart.active_items.setSelectionIndexes(index_set([0]))\n @cart.saved_items.setSelectionIndexes(index_set([]))\n move_test_helper([\"3\"], [\"0\", \"2\", \"1\"], {0 => :saved, 1 => :saved, 2 => :saved, 3 => :active}) do \n # argument is dummy\n @app.move_active_to_saved(nil)\n end\n @cart.active_items.setSelectionIndexes(index_set([]))\n @cart.saved_items.setSelectionIndexes(index_set([1, 2]))\n move_test_helper([\"3\", \"2\", \"1\"], [\"0\"], {0 => :saved, 1 => :active, 2 => :active, 3 => :active}) do \n # argument is dummy\n @app.move_saved_to_active(nil)\n end\n end", "def battler_custom_move(battler, pos_x, pos_y)\n return if battler.nil?\n return if battler.actor? and not $game_party.actors.include?(battler)\n return if !battler.actor? and not $game_troop.enemies.include?(battler)\n battler.target_x = pos_x\n battler.target_y = pos_y\n battler.move_pose = true\n battler_face_direction(battler)\n end", "def move_generic(mode, check, dir)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # if override type of moving\n if mode == 0\n # override and set moving route\n rand(pix*2).times{@force_move.push(BlizzABS::Cache::FDirs[dir])}\n # re-routing the method\n elsif mode\n # set moving route\n pix.times{@force_move.push(BlizzABS::Cache::TDirs[dir])}\n else\n # set moving route\n pix.times{@force_move.push(BlizzABS::Cache::FDirs[dir])}\n end\n end", "def _simulate_move move, flags\n\t\t# Archive the old board,\n\t\t# and make a clone to work on.\n\t\t@board_history << @board\n\t\t@board = _clone_board\n\t\t\n\t\t# Actually move the main piece\n\t\t_move_piece(from,to)\n\t\t\n\t\t# en passant is the only time in which a piece is captured that is\n\t\t# not on the destination square. As such, in this case, we must\n\t\t# clear out the square manually.\n\t\t_clear_square(flags[:en_passant]) if flags.include?(:en_passant)\n\t\t\n\t\t# Castling is the only time in which a player is allowed to move\n\t\t# two pieces on one turn. As such, this second movement must also\n\t\t# be handled manually.\n\t\t_move_piece(*flags[:castle]) if flags.include?(:castle)\n\t\t\n\t\t# Archive the move and the flags for that move.\n\t\t@move_history << move\n\t\t@flags_history << flags\n\tend", "def process_movement\n # Move the cursor back to the selected unit\n proc = Proc.new{@unit.selected = false\n @unit.sprite.move(@passed_positions.clone)\n @unit.stop_capture if @passed_positions.size != 0\n @passed_positions = []}\n cursor.add_move_action(@unit.x, @unit.y, proc, 0, nil, true)\n # Delete the arrow path graphics and move-range tiles\n @arrow_path.each{|a| a.dispose}\n @arrow_path = []\n remove_ranges\n # Disable input, proceed to moving unit\n cursor.disable_input = true\n @phase = 4\n end", "def execute_hypo_move(original_coords, test_coords)\n @piece_purgatory = @board[test_coords[0]][test_coords[1]]\n @board[test_coords[0]][test_coords[1]] = @board[original_coords[0]][original_coords[1]]\n @board[original_coords[0]][original_coords[1]] = nil\n end", "def setup_move\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n mx = @map_char.real_x + @acts[1]\n my = @map_char.real_y + @acts[2]\n goto(mx, my, @acts[3], @acts[4], @acts[5] || 0)\n end", "def test_move\n @test_p.rubies_found = 0\n @test_p.fake_rubies_found = 0\n assert @test_p.move?\n end", "def apply_move(s)\n # puts \"\\nApplying move...\" #NICE TO HAVE\n s[:moves][s[:prospective_move][:y]][s[:prospective_move][:x]] = s[:m]\n derive_moves_metadata(s)\nend", "def play_move!( m )\n self.delete_if { |pos, piece| pos == m.to_coord || pos == m.captured_piece_coord }\n\n piece_moved = self.delete(m.from_coord)\n self[m.to_coord] = piece_moved\n\n if m.castled==1\n castling_rank = m.to_coord.rank.to_s\n [['g', 'f', 'h'], ['c', 'd', 'a']].each do |king_file, new_rook_file, orig_rook_file|\n #update the position of the rook corresponding to the square the king landed on\n\tif m.to_coord.file == king_file \n\t rook = self.delete(\"#{orig_rook_file}#{castling_rank}\")\n\t self[\"#{new_rook_file}#{castling_rank}\"] = rook\n\tend\n end\n end\n \n #TODO investigate why this method is getting called multiply per moves << Move.new\n return unless piece_moved\n ep_from_rank, ep_to_rank, ep_rank = EN_PASSANT_CONFIG[ piece_moved.side ]\n @en_passant_square = ( piece_moved.function == :pawn &&\n m.from_coord.rank == ep_from_rank && \n m.to_coord.rank == ep_to_rank ) ? m.from_coord.file + ep_rank.to_s : nil\n\n #reflect promotion\n if piece_moved && piece_moved.function == :pawn && m.to_coord.to_s.rank == piece_moved.promotion_rank\n self.delete(m.to_coord)\n self[m.to_coord] = Queen.new(piece_moved.side, :promoted)\n #puts self.to_s if m.to_coord == 'a8'\n #debugger if m.to_coord == 'a8'\n end\n \n self\n end", "def update_move_postion\n @moving = true\n @battler.idle_pose = false\n @move_speed = set_move_speed\n speed = @move_speed / 100.0\n @distance_x = @battler.target_x - @battler.actual_x\n @distance_y = @battler.target_y - @battler.actual_y\n @move_x = @move_y = 1\n if @distance_x.abs < @distance_y.abs\n @move_x = 1.0 / (@distance_y.abs.to_f / @distance_x.abs)\n elsif @distance_y.abs < @distance_x.abs\n @move_y = 1.0 / (@distance_x.abs.to_f / @distance_y.abs)\n end\n @speed_x = speed * (@distance_x == 0 ? 0 : (@distance_x > 0 ? 8 : -8))\n @speed_y = speed * (@distance_y == 0 ? 0 : (@distance_y > 0 ? 8 : -8))\n @battler.actual_x += (@move_x * @speed_x).round\n @battler.actual_y += (@move_y * @speed_y).round\n if @battler.teleport_to_target\n @battler.actual_x = @battler.target_x\n @battler.actual_y = @battler.target_y\n @battler.teleport_to_target = false\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /estudios or /estudios.json
def create @estudio = Estudio.new(estudio_params) respond_to do |format| if @estudio.save format.html { redirect_to @estudio, notice: "Estudio was successfully created." } format.json { render :show, status: :created, location: @estudio } else format.html { render :new, estudio: :unprocessable_entity } format.json { render json: @estudio.errors, status: :unprocessable_entity } end end end
[ "def create\n params[:estudio][:ginasio_id] = params[:ginasio_id]\n @estudio = Estudio.new(params[:estudio])\n @ginasio = Ginasio.find(params[:ginasio_id])\n\n if @estudio.save\n respond_to do |format|\n format.html { redirect_to ginasio_estudio_path(params[:ginasio_id], @estudio), :flash => { :success => 'Estudio criado com sucesso.' } }\n format.json { render :json => @estudio, :status => :created, :location => @estudio }\n end\n else\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render :json => @estudio.errors, :status => :unprocessable_entity }\n end\n end\n\n end", "def create\n @estudio = current_user.estudios.new(estudio_params)\n @estudio.postulante = @postulante\n respond_to do |format|\n if @estudio.save\n format.html { redirect_to @estudio.postulante, notice: 'Se ha creado correctamente.' }\n format.json { render :show, status: :created, location: @estudio }\n else\n format.html { render :new }\n format.json { render json: @estudio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @studio = Studio.new(studio_params)\n\n if @studio.save\n return render json: @studio.to_json, status: 200\n else\n return render json: {\n error: \"could not create studio\"\n }, status: 400\n end\n\n end", "def create\n @studio = Pusher.create_studio(params[:studio])\n\n if @studio.valid?\n render json: @studio, status: :created, location: @studio\n else\n render json: @studio.errors, status: :unprocessable_entity\n end\n end", "def create\n @studio = Studio.new(params[:studio])\n\n respond_to do |format|\n if @studio.save\n format.html { redirect_to @studio, :notice => 'Studio was successfully created.' }\n format.json { render :json => @studio, :status => :created, :location => @studio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @studio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @game_studio = GameStudio.new(game_studio_params)\n\n respond_to do |format|\n if @game_studio.save\n format.html { redirect_to @game_studio, notice: 'Game studio was successfully created.' }\n format.json { render :show, status: :created, location: @game_studio }\n else\n format.html { render :new }\n format.json { render json: @game_studio.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end", "def create\n @tv_season = TvSeason.new(params[:tv_season])\n\n respond_to do |format|\n if @tv_season.save\n format.html { redirect_to @tv_season, notice: 'Tv season was successfully created.' }\n format.json { render json: @tv_season, status: :created, location: @tv_season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tv_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @app_season = AppSeason.new(params[:app_season])\n\n respond_to do |format|\n if @app_season.save\n format.html { redirect_to @app_season, notice: 'App season was successfully created.' }\n format.json { render json: @app_season, status: :created, location: @app_season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @app_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @episode = Pusher.create_episode(params[:episode])\n\n if @episode.valid?\n render json: @episode, status: :created, location: @episode\n else\n render json: @episode.errors, status: :unprocessable_entity\n end\n end", "def create\n @sci_episode = SciEpisode.new(params[:sci_episode])\n\n respond_to do |format|\n if @sci_episode.save\n format.html { redirect_to @sci_episode, notice: 'Sci episode was successfully created.' }\n format.json { render json: @sci_episode, status: :created, location: @sci_episode }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sci_episode.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @season = Season.new(params[:season])\n @season.status = :created\n respond_to do |format|\n if @season.save\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render json: @season, status: :created, location: @season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hero = Heroe.new(hero_params)\n \n respond_to do |format|\n if @hero.save\n format.json { render json: @hero, status: :created, location: api_v1_heroes_url(@hero) }\n else\n format.json { render json: @hero.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @episode = Episode.new(params[:episode])\n\n respond_to do |format|\n if @episode.save\n format.html { redirect_to @episode, :notice => 'Episode was successfully created.' }\n format.json { render :json => @episode, :status => :created, :location => @episode }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @episode.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tv_serie_episode = TvSerieEpisode.new(params[:tv_serie_episode])\n\n respond_to do |format|\n if @tv_serie_episode.save\n format.html { redirect_to @tv_serie_episode, notice: 'Tv serie episode was successfully created.' }\n format.json { render json: @tv_serie_episode, status: :created, location: @tv_serie_episode }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tv_serie_episode.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n\t\tnumber = params[\"season\"][\"number\"]\n\t\tchallonge_name = params[\"season\"][\"challonge_name\"]\n\t\tchallonge_url = params[\"challonge_url\"]\n\t\ttype = params[\"type\"]\n\n\n\t\tresponse = HTTParty.post(\"https://api.challonge.com/v1/tournaments.json\", :query => {:tournament => {:name => \"#{challonge_name}\", :tournament_type => \"#{type}\", :url => \"#{challonge_url}\", :private => \"true\"}}, :basic_auth => {:username => \"rdmccoy\", :password => ENV[\"CHALLONGE_PASSWORD\"] })\n\n\t\tif response.code == 200\n\t\t\tseason = Season.create(number: number, challonge_name: challonge_name)\n\t\t\tif season.save\n\t\t\t\tflash[:success] = \"Season successfully created.\"\n\t\t\t\tredirect_to(\"/admin\")\n\t\t\telse\n\t\t\t\tflash[:error] = \"Something went wrong! #{response.message}\"\n\t\t\t\tredirect_to(\"/seasons/new\")\n\t\t\tend\n\t\telse\n\t\t\tflash[:error] = \"Something went wrong! #{response.message}\"\n\t\t\t\tredirect_to(\"/seasons/new\")\n\t\tend\n\tend", "def create\n @play = Play.next\n\n respond_to do |format|\n if @play.save\n format.html { redirect_to @play, notice: 'Play was successfully created.' }\n format.json { render :create, status: :created, location: @play }\n else\n format.html { render :new }\n format.json { render json: @play.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @studios_title = StudiosTitle.new(studios_title_params)\n\n respond_to do |format|\n if @studios_title.save\n format.html { redirect_to @studios_title, notice: 'Studios title was successfully created.' }\n format.json { render :show, status: :created, location: @studios_title }\n else\n format.html { render :new }\n format.json { render json: @studios_title.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tv_episode = TvEpisode.new(params[:tv_episode])\n\n respond_to do |format|\n if @tv_episode.save\n format.html { redirect_to @tv_episode, notice: 'Tv episode was successfully created.' }\n format.json { render json: @tv_episode, status: :created, location: @tv_episode }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tv_episode.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns directly contained files that have the requested RDF Type
def filter_files_by_type(uri) files.reject do |file| !file.metadata_node.type.include?(uri) end end
[ "def get_documents_by_type(file_type)\n case file_type\n when ::Rbt::User::Document::DocumentService::DOCUMENT_TYPE::SCHEMA\n return self.schema_files\n when ::Rbt::User::Document::DocumentService::DOCUMENT_TYPE::RBT\n return self.report_files\n else\n raise ::StandardError.new(\"Unknown file type: #{file_type} when looking up user files\")\n end\n end", "def well_files_by_type_name(type_name)\n data_files = DataFile.joins(:plate_wells => :plate).where([\"plates.id = ? AND data_files.type_name = ?\", id, type_name])\n data_files.collect {|dfile| dfile.absolute_filepath}\n end", "def types\n get_objects_on(N::RDF.type.to_s)\n end", "def files_of_type(*types)\n result = []\n return result if types.size == 0\n types.each do |type|\n unless files_by_type[type.to_s].nil?\n files_by_type[type.to_s].each {|file| result << file}\n break\n end\n end\n result\n end", "def file_for(content_type)\n files.detect { |f| f.result.content_type == content_type }\n end", "def files_of_type_diff(of_type, but_not_of_type)\n result = []\n talia_files.each do |talia_file|\n found_good = false; found_bad = false\n for data_record in talia_file.data_records\n found_good = true if data_record.is_a? of_type\n found_bad = true if data_record.is_a? but_not_of_type\n end\n result << data_record if found_good and !found_bad\n end\n result\n end", "def file_of_type(uri)\n matching_files = filter_files_by_type(uri)\n return matching_files.first unless matching_files.empty?\n Hydra::PCDM::AddTypeToFile.call(files.build, uri)\n end", "def all_of_type(root, type)\n cmd = \"find #{ param_clean(root) } -iname \\\"*.#{ type }\\\"\"\n return run_cmd(cmd)\n end", "def query_files_whitelist(path, file_type)\n queryable_files = File.join(path, \"*.#{file_type}\")\n Dir.glob(queryable_files)\n end", "def file(type)\n photo_files.where(ftype: type).first\n end", "def dor_file_mimetype\n public_xml_doc.xpath('//contentMetadata/resource/*/@mimetype').map(&:text)\n end", "def files\r\n self.select { |entry| entry.is_a? AFile }\r\n end", "def type t\n @files = @files.select { |file| File.exist?(file) && File.ftype(file) == t}\n self\n end", "def list_files\n @synth_files = CreatedFile.find_all_by_content_type(\"synthesis\",\n :include => :researcher, \n :order => \"created_at DESC, created_file DESC\")\n end", "def filetypes\n @filetypes ||= path[self.class.renderers_re].split(/\\./)[1..-1].reverse\n rescue\n []\n end", "def instances(return_type)\n return nil unless(active_rdf? && is_iri?)\n qry = ActiveRDF::Query.new(URI).distinct.select(:s)\n qry.where(:s, RDF.type, self)\n qry.execute\n end", "def get_records_with_small_files\n persons = Person.where(file_type: \"small\")\nend", "def get_files_by_type(extension)\n Dir.glob(\"#{@path}/*.#{extension}\", File::FNM_CASEFOLD)\n end", "def list_resource_file_types(options={}) path = \"/api/v2/definitions/resourcefiletypes\"\n get(path, options, AvaTax::VERSION) end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds or Initializes directly contained file with the requested RDF Type
def file_of_type(uri) matching_files = filter_files_by_type(uri) return matching_files.first unless matching_files.empty? Hydra::PCDM::AddTypeToFile.call(files.build, uri) end
[ "def set_explicit_file_type(type = nil)\n self.last_known_file_type = nil\n if type\n self.explicit_file_type = type\n elsif path\n extension = Pathname(path).extname[1..-1]\n self.explicit_file_type = Constants::FILE_TYPES_BY_EXTENSION[extension]\n end\n end", "def retrieve_ontology(uri)\n case uri\n when CPO_URI\n file_path = \"/home/grosscol/workspace/ontologies/cpo/cpo.owl\"\n when PSDO_URI\n file_path = \"/home/grosscol/workspace/ontologies/psdo/psdo.owl\"\n else\n puts \"bad uri\"\n abort\n end\n\n #File.read file_path\nend", "def file_type\n self['fileRef']['explicitFileType'] || self['fileRef']['lastKnownFileType']\n end", "def type t\n @files = @files.select { |file| File.exist?(file) && File.ftype(file) == t}\n self\n end", "def set_last_known_file_type(type = nil)\n if type\n self.last_known_file_type = type\n elsif path\n extension = Pathname(path).extname[1..-1]\n self.last_known_file_type = Constants::FILE_TYPES_BY_EXTENSION[extension]\n end\n end", "def suggested_assay_type_ontology_uri\n uri = RDF::URI.new assay_type_uri\n if uri.valid?\n nil\n else\n SuggestedAssayType.where(:uri=> assay_type_uri).first.try(:ontology_uri)\n end\n end", "def load_fedora_document\n\t af_base = ActiveFedora::Base.load_instance(params[:id])\n the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first\n if the_model.nil?\n @document_fedora = af_base\n else\n\t\t\t#if it is a FileAsset object\n\t\t \tif the_model == FileAsset\n\t\t\t\tis_part_of_id = af_base.relationships(:is_part_of).first\n\n\t\t\t\t#if it has a part of relationship, redirect to the parent, otherwise redirect to index \n\t\t\t\tif !is_part_of_id.nil? \n\t\t\t\t\tis_part_of_id = is_part_of_id[is_part_of_id.index('/')+1..-1]\n\t\t\t\t\tredirect_to :controller=>\"catalog\", :action=>\"show\", :id=> is_part_of_id\n\t\t\t\telse\n\t\t\t\t\tredirect_to :controller=>\"catalog\", :action=>\"index\"\n\t\t\t\tend\n\t\t end\n end \n\n @document_fedora = the_model.load_instance(params[:id])\n\t\t@file_assets = @document_fedora.file_objects(:response_format=>:solr)\n \n end", "def file(type)\n photo_files.where(ftype: type).first\n end", "def type_to_uri(type)\n case type\n when ::RDF::URI\n type\n when String\n ::RDF::URI(type)\n else\n fail ArgumentError, 'Invalid file type. You must submit a URI or a symbol.'\n end\n end", "def type_to_uri(type)\n case type\n when ::RDF::URI\n type\n when String\n ::RDF::URI(type)\n else\n raise ArgumentError, \"Invalid file type. You must submit a URI or a symbol.\"\n end\n end", "def insert_file(type, opts={})\n case type.to_sym \n when :file\n node = Hydra::ResourceInfoMetadata.file_template\n nodeset = self.find_by_terms(:person)\n else\n ActiveFedora.logger.warn(\"#{type} is not a valid argument for Hydra::ResourceInfoMetadata.insert_file\")\n node = nil\n index = nil\n end\n \n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n self.dirty = true\n end\n \n return node, index\n end", "def set_file_type\n if self.is_local?\n if self.attachment_content_type.blank?\n self.file_type = \"misc\"\n elsif self.attachment_content_type == 'application/pdf'\n self.file_type = \"pdf\"\n elsif self.attachment_content_type.include?('powerpoint')\n self.file_type = \"presentation\"\n elsif self.attachment_content_type == 'application/zip'\n self.file_type = \"zip\"\n elsif self.attachment_content_type == \"application/rtf\" || self.attachment_content_type == 'text/plain' || self.attachment_content_type == 'application/msword' || self.attachment_content_type.include?('wordprocessing')\n self.file_type = \"document\"\n elsif self.attachment_content_type.include?('spreadsheet') || self.attachment_content_type == 'ms-excel'\n self.file_type = \"spreadsheet\"\n elsif self.attachment_content_type.include?('image')\n self.file_type = \"image\"\n else\n self.file_type = \"misc\"\n end\n end\n end", "def findFileType(type)\n Dir.chdir('../database')\n Dir.entries('.').find {|file_name| file_name.split(\".\").last == type}\nend", "def neofiles_mock_or_load(attrs_or_id, klass = ::Neofiles::File)\n if attrs_or_id.present?\n case attrs_or_id\n when ::String then klass.where(id: attrs_or_id).first\n when ::BSON::ObjectId then klass.where(id: attrs_or_id).first\n when ::Hash then neofiles_mock(attrs_or_id.with_indifferent_access, klass)\n end\n end\n end", "def file_type\n case raw_file_type\n when 'f'\n :file\n when 'd'\n :directory\n when 'L'\n :symlink\n when 'D'\n :device\n when 'S'\n :special\n end\n end", "def existing_rd_file\n @rdfile ||= possible_rd_files.select { |file| File.exist? file }.first\n end", "def file_set_type\n case @cocina_model.type\n when Cocina::Models::ObjectType.book\n resource_file_types = resource_files.collect(&:object_type)\n # grab all of the file types within a resource into an array so we can decide what the resource type should be\n resource_has_non_images = !(resource_file_types - [:image]).empty?\n resource_has_non_images && resource_file_types.include?(:image) == false ? 'object' : 'page'\n when Cocina::Models::ObjectType.image, Cocina::Models::ObjectType.map\n 'image'\n when Cocina::Models::ObjectType.object\n 'file'\n when Cocina::Models::ObjectType.three_dimensional\n resource_extensions = resource_files.collect(&:ext)\n if resource_extensions.intersect?(VALID_THREE_DIMENSION_EXTENTIONS)\n '3d'\n else\n 'file'\n end\n else\n raise \"Unexpected type '#{@cocina_model.type}'\"\n end\n end", "def get_type_from_path path\n settings.type_paths[path]\nend", "def change_fileset_filetype_attribute(id_list_path)\r\nputs \"id_list_path: \" + id_list_path\r\nfileset_ids = IO.readlines(id_list_path) \r\n\tfileset_ids.each do |i|\r\n\ti = i.strip #trailing white space, line ends etc will cause a faulty uri error\t\r\n\t\tfs = Object::FileSet.find(i) \r\n\t\tputs \"got fileset for \" + i\r\n\t\t\tif fs.filetype == \"externalurl\"\r\n\t\t\t\t\tfs.filetype = \"managed\"\r\n\t\t\t\t\tfs.save!\r\n\t\t\tend\t\t\t\t\r\n\t\t\t\r\n\tend\r\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the ferocity monster according to the parameter given
def getToFight(monsterNumber) if(monsterNumber == -1) ferocity = 5 elsif (monsterNumber == -2) ferocity = 10 elsif (monsterNumber == -3) ferocity = 15 elsif (monsterNumber == -4) ferocity = 20 elsif (monsterNumber == -5) ferocity = 25 elsif (monsterNumber == -6) ferocity = 30 end bePrepared(monsterNumber, ferocity) end
[ "def setMedium\n @difficulty = \"medium\"\n end", "def set_damage_move(battler, target)\n now_action(battler)\n action = battler_action(battler)\n set_relase(battler, target, action)\n set_impact(battler, target, action)\n set_bounce(battler, target, action)\n set_rise(battler, target, action)\n set_smash(battler, target, action)\n set_shake(battler, target, action)\n set_freeze(battler, target, action)\n set_dmgwait(battler, target, action)\n end", "def set_attack_damage(attacker)\n set_damage(attacker, attacker.actor? ? attacker.weapons[0] : nil)\n end", "def set_attack_damage_value(attacker)\n atk_pow = set_attack_power(attacker)\n str_pow = set_strenght_power(attacker)\n attacker.target_damage[self] = [atk_pow * str_pow / 20, 0].max\n attacker.target_damage[self] *= elements_correct(attacker.element_set)\n attacker.target_damage[self] /= 100\n end", "def update_damage\n if @user.battler.is_a?(Game_Actor)\n apply_damageto_enemy\n if @tool_selfdamage\n apply_damageto_player \n apply_damageto_followers unless @ignore_followers\n end\n elsif @user.battler.is_a?(Game_Enemy)\n apply_damageto_player \n apply_damageto_followers unless @ignore_followers\n apply_damageto_enemy if @tool_selfdamage\n end\n end", "def update_info_monster(monster_id, ferocity)\n RESTful.put(\"#{URL_MICROSERVICE_MONSTER}/monster/#{monster_id}\", {'ferocity' => ferocity}.to_json, 'application/json')\n end", "def setDamage _obj, _args\n \"_obj setDamage _args;\" \n end", "def eat(food)\n food.eat 1\n @energy += @metabolism\n end", "def assignFuelValue(f)\n\t\tif f < @@MAXFUEL\n\t\t\t@fuelUnits = f\n\t\telse\n\t\t\t@fuelUnits = @@MAXFUEL\n\t\tend\n\tend", "def monsterfight(user, monster, mAtk, enemy)\n\n#make a loop with a boolean value. The loop will keep running unless somebody's health goes to zero or \n#the user runs away\n\n\tenemy['name'] = monster.sample\n\tcombat = true\n\n\tif enemy['name'] == 'Mutated Octopus'\n\t\tenemy['hp'] = 7\n\t\tenemy['atkSpd'] = 6\n\t\tenemy['armor'] = 1\n\n\telsif enemy['name'] == 'Sabertooth Goldfish'\n\t\tenemy['hp'] = 6\n\t\tenemy['atkSpd'] = 5\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Lady Gaga'\n\t\tenemy['hp'] = 8\n\t\tenemy['atkSpd'] = 8\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Hannah Montana'\n\t\tenemy['hp'] = 10\n\t\tenemy['atkSpd'] = 10\n\t\tenemy['armor'] = 1\n\tend\n\n\tputs ''\n\n# choosing the random attack of the monster. no need to push into a hash\n\tdef monsterAttack(user, mAtk, enemy)\n\t\trandAttack = mAtk.sample\n\n\t\tif randAttack == 'Slap'\n\t\t\tmonsterDmg = 1\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Bite'\n\t\t\tmonsterDmg = 2\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Eyepoke'\n\t\t\tmonsterDmg = 3\n\t\t\tuser['health'] -= 1\n\t\tend\n\n\t\tputs \"You get hit by #{enemy['name']} for #{monsterDmg}. Your health is now #{user['health']}\"\n\t\t\n\tend\n\n\tdef heroAttack(user, enemy)\n\n\t\theroAttack = user['weapon']\n\n\t\tif heroAttack == 'Sword'\n\t\t\thitDmg = rand(2...5)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Spear'\n\t\t\thitDmg = rand(1...6)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Axe'\n\t\t\thitDmg = rand(3...4)\n\t\t\tenemy['hp'] -= hitDmg\n\t\tend\n\t\t\n\t\tputs \"You hit the #{enemy['name']} for #{hitDmg}. Their health is now #{enemy['hp']}\"\n\tend\n\n\tputs \"A wild #{enemy['name']} has appeared. Do you choose to fight or run? (enter 'fight' or 'run')\"\n\n\tchoice = gets.chomp.downcase\n\n\twhile (user['health'] > 0 && enemy['hp'] > 0 && combat == true)\n\n\t\tif choice == 'fight'\n\t\t\tputs 'Alright lets do this!'\n\t\t\tmonsterAttack(user, mAtk, enemy)\n\t\t\theroAttack(user, enemy)\n\n\t\telsif choice == 'run'\n\t\t\tputs 'You attempt to escape'\n\n\t\telsif choice != 'fight' || choice != 'run' \n\t\t\tputs 'Please enter \"fight\" or \"run\"'\n\t\t\tchoice = gets.chomp.downcase\n\t\tend\n\n\t\tif enemy['hp'] > 0 && user['health']\n\t\t\tputs \"Continue fighting? (fight or run)\"\n\t\t\tchoice = gets.chomp.downcase\n\n\t\telsif enemy['hp'] <= 0\n\t\t\tputs \"You have killed #{enemy['name']}\"\n\t\t\tcombat == false\n\n\t\telsif user['health'] <= 0\n\t\t\tputs \"You have died\"\n\t\t\tcombat == false\n\t\tend\n\tend\n\nend", "def eat(food)\n food.eat 1\n @energy += METABOLISM\n end", "def set_foundation_after_move(suit, foundation)\n case suit\n when :diamonds\n @diamonds_foundation = foundation\n when :spades\n @spades_foundation = foundation\n when :clubs\n @clubs_foundation = foundation\n when :hearts\n @hearts_foundation = foundation\n else\n raise \"Invalid suit: #{suit}\"\n end\n end", "def hero_movement(race, dice_roll)\nif race == \"human\"\n multiplier = 1\nelsif race == \"elf\"\n multiplier = 2\nelse race == \"dwarf\"\n multiplier = 0.5\nend\n return dice_roll * multiplier\nend", "def addMonster(x,y)\n\t\t@array[y][x] = 2\n\tend", "def set_graphic(character_name, character_hue, battler_name, battler_hue)\n @character_name = character_name\n @character_hue = character_hue\n @battler_name = battler_name\n @battler_hue = battler_hue\n end", "def setHard\n @difficulty = \"hard\"\n end", "def stats(newMonster) \n\t\tnewMonster.attack = random(1..10) # Currently only using attack for simplicity and ease of implementation in battle logic\n\t\tnewMonster.defense = random(1..10)\n\tend", "def set_fall_action(battler)\n if check_include(battler_action(battler), \"FALL\")\n battler.lifting = false\n battler.lifted = false\n end\n ext = check_extension(battler_action(battler), \"HEAVYFALL/\")\n unless ext.nil?\n ext.slice!(\"HEAVYFALL/\")\n battler.heavy_fall = ext.to_i\n end\n end", "def cause_mayhem(person)\n @caffeine_level = 0\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Action perform to eat food
def eat_food return if @food < 1 loop do puts("YOU HAVE #{@food} UNITS OF FOOD") puts("HOW MANY DO YOU WANT TO EAT") food = get_action if food <= @food @food -= food @strength += (food * 5) break end end end
[ "def eat(food)\n food.eat 1\n @energy += METABOLISM\n end", "def eat_food\n return if @food < 1\n loop do\n puts(\"YOU HAVE #{@food} UNITS OF FOOD\")\n puts(\"HOW MANY DO YOU WANT TO EAT\")\n food = get_action\n if food <= @food\n @food -= food\n update_info_player('food', @food)\n @strength += (food * 5)\n update_info_player('strength', @strength)\n break\n end\n end\n end", "def eat(food)\n food.eat 1\n @energy += @metabolism\n end", "def eat(food)\n\n if can_eat.include?(food.type)\n p \"#{@name} ate the #{food.name}!\"\n process_nutrition!(food.nutrition)\n return stats\n else\n p \"#{@name} turns away from the #{food.name}!\"\n @energy -= 1\n return stats\n end\n end", "def eat(food) \r\n\t\tcase food \r\n\t\twhen 'butter'\r\n\t\t\t@@intake += 740\r\n\t\twhen 'beef'\r\n\t\t\t@@intake += 521\r\n\t\twhen 'chips'\r\n\t\t\t@@intake += 570\r\n\t\twhen 'pork', 'cheese'\r\n\t\t\t@@intake += 340\r\n\t\twhen 'beer', 'puddings'\r\n\t\t\t@@intake += 200\r\n\t\twhen 'rice', 'soup'\r\n\t\t\t@@intake += 150\r\n\t\twhen 'salad', 'egg'\r\n\t\t\t@@intake += 100\r\n\t\twhen 'fruit', 'milk'\r\n\t\t\t@@intake += 60\r\n\t\twhen 'tea', 'coffee', 'soda'\r\n\t\t\t@@intake += 10\r\n\t\tend\r\n\tend", "def eat\n inventory[:fish] -= @daily_appetite = 10\n\n if inventory[:fish] < 0\n @alive = false\n inventory[:fish] = 0\n end\n end", "def eat(food)\n\tif food.eaten == true\n\t\tputs \"om nom nom\"\n\tend\n\t@meals_eaten += 1\nend", "def consume_food\n\t\t\n\t\tif @food.nil? \n\t\t\task_the_brain_what_to_do :search_for_food \n\t\t\treturn\t\n\t\tend\n\n\t\t# If the critter is not close enough to interact with food, move closer\n\t\tif ((@x - @food.x).abs > Simulation::INTERACTION_RANGE) || ((@y - @food.y).abs > Simulation::INTERACTION_RANGE)\n\t\t\tangle = interception_angle(@food.x, @food.y)\n\t\t\tmove_fuzzily_towards(angle)\n\t\t\treturn\n\t\tend\n\n\t\t# If the activation energy has been paid\t\n\t\tif @paid_activation_energy \t\n\t\t\tbite = @food.consume(@bite_size)\t\n\t\t\t# If the bite is empty the food no longer exists \n\t\t\tif bite == 0\n\t\t\t\t@food = nil\t\n\t\t\t\task_the_brain_what_to_do :search_for_food\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\t@energy += bite \n\t\t\tend\n\t\t\t# If the last bite resulted in the critter being full, ask the brain what to do now\n\t\t\tif @energy >= @energy_capacity \n\t\t\t\task_the_brain_what_to_do :idle \n\t\t\tend\n\t\t# Pay the activation energy cost for the food item, start consumption in the next cycle\n\t\telse\t\n\t\t\t@energy -= @food.activation_energy\n\t\t\t@paid_activation_energy = true\n\t\tend\t\n\tend", "def eat(food)\n\t\t@food = food\n\t\tself.digest\n\tend", "def eat\n self.hunger(self.hunger + 2)\n end", "def chew(food)\r\n\t\tputs \"*chew* #{@name} is now chewing a #{food}\"\r\n\tend", "def feed(food)\n puts \"Mmmm, \" + food + \"!\"\n @hungry = false\n end", "def eat\n @last_food = Time.now\n end", "def eat(food)\n @foods_eaten.push(food)\n end", "def beg_for_food(food_served)\n if food_served\n puts \"Whimper\"\n end\n end", "def spot_food(food)\n @fish.direction = @fish.move_towards(food)\n @fish.status = Pursuing\n @fish.target = food\n end", "def food_command\n name = get_param(\"name=\", \"([a-zA-Z]+)\")\n\n if name\n @app.food name\n else\n puts \"Error!: A name is required to give food to an animal\"\n food_command_help()\n end\n end", "def behavior_hungry\n @world.food.each do |food|\n if distance_from_point(food.position) < (food.quantity + @vision_range)\n @delta -= self.position - food.position\n end \n if distance_from_point(food.position) <= food.quantity + 5\n eat food\n end \n end \n end", "def eat amount\n\t\t@energy=@energy+amount\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a Hash where: key is the word value is the occurrence of the usage of the word in the words list
def words_occurrences # the default value of the occurrence of a word is 0 word_count = Hash.new(0) @content.each { |word| word_count[word] += 1 } word_count end
[ "def word_frequency\n @word_use = Hash.new(0)\n words.each { |w| @word_use[w] += 1 }\n @word_use\n end", "def word_count\n c = Hash.new(0)\n words.each { |word| c[word] += 1 }\n c\n end", "def query_words(word_list)\n counts = {}\n word_list.each do |word|\n counts[word] = query(word)\n end\n counts\n end", "def query_words(word_list)\n counts = {}\n (word_list || []).each do |word|\n @logger.debug {\"querying count for #{word.inspect}\"}\n counts[word] = @word_map[word.downcase] || 0\n end\n counts\n end", "def frequencies(word_list)\n word_freqs = {}\n for w in word_list\n if word_freqs.include? w\n word_freqs[w] += 1\n else\n word_freqs[w] = 1\n end\n end\n return word_freqs\nend", "def count_occurrences(words)\n occurances = {}\n words.each do |word|\n if occurances[word]\n occurances[word] += 1\n else\n occurances[word] = 1\n end\n end\n puts occurances\nend", "def word_freq(string)\n words = string.gsub(/[\".,:;!?\", \" \"]/, ' ').split\n table = Hash.new\n \n for i in 0..words.size - 1 do\n freq = 1\n for j in 0..words.size - 1 do\n \n #count all matches regardless of case\n if(words[i].casecmp(words[j]) == 0 && i != j)\n freq = freq + 1 \n end\n end\n \n #check if the same word is already in the table before adding it\n #ignoring case\n is_duplicate = 0\n table.each do |key, id|\n if(key.casecmp(words[i]) == 0)\n is_duplicate = 1\n end\n end\n \n #if it is not in the table already, add it in \n if(is_duplicate == 0)\n table[words[i]] = freq\n end\n end\n return table\nend", "def substrings (searchword, listOfWords)\n\n\n\n # create a array first with searchword and put any word in the array\n\n searchwords = searchword.split(/\\W+/)\n listOfWords = listOfWords\n\n\n dict = Hash.new(0)\n\n listOfWords.each do |word| # This function puts the word's inside the hash and increase the counter\n searchwords.each do |search|\n\n if search.downcase.include? word.downcase\n dict[word] += 1\n end\n end\n end\n\n\n dict.each do |word, count|\n\n puts \"Word: #{word} \\n Count: #{count}\"\n\n end\n\n\nend", "def word_count(string)\n words=string.split()\n unique=words.uniq\n amount={}\n unique.each do |word|\n amount[word.to_sym]=words.count(word)\n end\n p amount\nend", "def count\n\t\tcount_hash = Hash.new(0)\n\t\t#count_hash = { 'word' => 1 }\n\t\t\n\t\t#removes any non-alphanumeric characters except apostrophe and splits into an array on whitespace\n\t\tfrmttd_phrase = @phrase.gsub(/[^a-zA-Z0-9']/, ' ').split\n\t\t\n\t\t\n\t\tfrmttd_phrase.each do |arr_word|\n\t\t\tif count_hash.empty?\n\t\t\t\tcount_hash.store(arr_word, 1)\n\t\t\telsif count_hash.has_key?(arr_word)\n\t\t\t\tcount_hash[arr_word] += 1\n\t\t\telse\n\t\t\t\tcount_hash.store(arr_word, 1)\n\t\t\tend\n\t\t\t\n\t\tend\n\n\t\treturn count_hash\n\tend", "def word_counter(mots,dictionnaire)\n words = word_counter.downcase.split(\" \")\n #puts words => [\"howdy\",....\"going?\"]\n frequencies = Hash.new(0)\n words.each{ |mot| \n if mot.include?(dictionnaire) #si le mot est dans le dictionnaire\n frequencies[mot] += 1 #si oui\n end\n \n }\n puts frequencies\nend", "def count_occurrences(array)\n frequncies = Hash.new(0)\n\n array.each do |word|\n frequncies[word] += 1\n end\n\n frequncies.each do |word, frequency|\n puts \"#{word} => #{frequency}\"\n end\nend", "def alice_word_count_hash(text)\n count_hash = Hash.new(0)\n keys = alice_normalize(text)\n keys.each do |word|\n count_hash[word] += 1\n end\n\n count_hash\nend", "def word_frequencies(word, book_text)\n\tword_table = Hash.new(0)\n\tbook_text.split(' ').each do |word|\n\t\tword_table[word.downcase.gsub(/[^A-Za-z0-9\\s]/i, '')] += 1\n\tend\n\tword_table[word.downcase]\nend", "def word_count(tweet)\n words = tweet.gsub(/[^\\w\\s]/,\"\").split # REGEX: remove whites spaces and special chars\n d = Hash.new\n words.each do |word|\n word.downcase! # Replace word with their downcase counterpart\n unless COMMON_WORDS.include?(word) # remove common words\n d[word] ||= 0\n d[word] += 1\n end\n end\n return d\n end", "def compute_frequencies(list)\n dict = {}\n list.each do |token|\n unless dict.has_key?(token)\n dict[token] = list.count(token)\n end\n end\n dict\nend", "def checkSearchTerms(wordHash, searchTermsArray, documentCounter, resultsHash, wordArray)\n documentCounter;\n documentNumber = \"Document \" + documentCounter.to_s\n searchTermsArray.each do |word|\n resultsHash.merge!(word => { documentNumber => wordHash[word]})\n # need to figure out the frequency based on the wordHash[word] and the wordArray.length\n end\n # puts wordArray.length\n # puts resultsHash\nend", "def word_frequency(word)\n occurrences[word]\n end", "def words_in_the_dictionary(words)\n matches = Array.new(dictionary.size) { 0 } # initialize with 0\n words.each do |word|\n matches[dictionary.index(word)] = 1 if dictionary.include?(word)\n end\n matches\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
information string about a task that invoked another one
def task_invoking_info(task_name, task_invoked_name) "[#{task_name}] invoking #{task_invoked_name}" end
[ "def task_details_for_log\n \"Node #{@puppet_mclient.node_id}, task #{@task}, manifest \"\\\n \"#{@puppet_mclient.manifest}\"\n end", "def task_name\n \"#{key}: #{summary}\"\n end", "def external_task\n output[:task]\n end", "def what_task\n if running_task?\n puts \"Current task: \" + get_last_task_name + \", #{(Time.now.to_i - get_last_task_stime.to_i).duration}\"\n else\n puts \"No task running!\"\n end\n end", "def explain_true(task); end", "def invoke_task(task_string); end", "def exc_process\n\t\tself.task.name rescue 'No associated task!'\n\tend", "def print_task(task)\n print \"==> \".info, task.bold, \"\\n\"\nend", "def t1\r\n\t\tprevTask\r\n\tend", "def safe_task_name(timing)\n timing.task.present? ? timing.task.name : \"n/a\"\n end", "def task_class_name\n \"#{process_definition_key}::#{activity_id}\"\n end", "def description\n\t\t\"This just does a generic (untracked) task!\"\n\tend", "def taskHint _args\n \"taskHint _args;\" \n end", "def name\r\n return @task_name \r\n end", "def task\n check_task\n @task\n end", "def default_task_name; end", "def info_string\n \"#{step}: #{process}\"\n end", "def taskNull \n \"taskNull\" \n end", "def getTaskName\r\n\t\t\t\t\treturn @taskName\r\n\t\t\t\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Specify the url for the page. A call to this method will generate a 'goto' method to take you to the page.
def page_url(url) define_method("goto") do visit self.page_url_value end define_method('page_url_value') do url end end
[ "def page_url(url)\n define_method(\"goto\") do\n lookup = url.kind_of?(Symbol) ? self.send(url) : url\n erb = ERB.new(%Q{#{lookup}})\n merged_params = self.class.instance_variable_get(\"@merged_params\")\n params = merged_params ? merged_params : self.class.params\n platform.navigate_to erb.result(binding)\n end\n end", "def direct_url url\n define_method(\"goto\") do\n @browser.goto url\n end\n end", "def set_url(page_url)\n @url = page_url.to_s\n end", "def goto\n @site.goto self.class.url\n end", "def goto_url(url)\r\n @browser.goto url\r\n end", "def open_page(url = nil)\n @path ||= \"\"\n if !url.nil?\n engine.goto url\n elsif !@url.nil? and @url != \"\"\n engine.goto @url\n elsif base_url != \"\"\n engine.goto base_url + ((@path == \"\") ? \"\" : \"/#{@path}\")\n else\n raise ArgumentError, \"You should set url to use open_page. You may\"\\\n \" also use base_url option for dance_with and path for page object\"\n end\n self\n end", "def visit\n return if @config[:url].nil?\n @browser.goto(@config[:url])\n end", "def go_to(url)\n @browser.goto(url)\n end", "def pages_url=(value)\n @pages_url = value\n end", "def goto(url)\n begin\n _old_goto(url)\n rescue => e\n e.message << \"\\nURL: #{url}\"\n raise e\n end\n end", "def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend", "def url=(value)\n @url = value\n end", "def set_url(url)\n end", "def goto relative_url\n destination = File.join(@site.origin, relative_url) \n @browser.goto destination\n end", "def goto newPage\n unless friends[newPage.to_sym].nil?\n uri = friends[newPage.to_sym].uri\n end\n uri ||= newPage\n uri = @page.uri+uri unless uri.to_s =~ /^http/u\n @page = @agent.get uri\n @page\n end", "def url=(u)\n u = u.try(:strip)\n u = \"http://#{u}\" if u.present? and u !~ /^\\w+:\\/\\//\n if self.page\n self.page.url = u\n else\n @url = u\n end\n end", "def link_first_page; target_uri(first_page); end", "def link_next_page; target_uri(next_page); end", "def entry_url(page)\n services.url_builder.url_for(page)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a method that compares the expected_title of a page against the actual.
def expected_title(expected_title) define_method("has_expected_title?") do page.has_title?(expected_title) end end
[ "def expected_title(expected_title)\n define_method(\"has_expected_title?\") do\n has_expected_title = expected_title === title\n raise \"Expected title '#{expected_title}' instead of '#{title}'\" unless has_expected_title\n has_expected_title\n end\n end", "def check_title(title, test_case)\n page_title = get_page_title\n\n if test_case\n expect(page_title).to eq title\n else\n expect(page_title).to_not eq title\n end\nend", "def expected_title(expected_title)\n define_method(\"has_expected_title?\") do\n has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ title : expected_title == title\n raise \"Expected title '#{expected_title}' instead of '#{title}'\" unless has_expected_title\n has_expected_title\n end\n end", "def expected_title expected_title\n define_method 'has_expected_title?' do\n has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ @browser.title : expected_title == @browser.title\n raise \"Expected title '#{expected_title}' instead of '#{@browser.title}'\" unless has_expected_title\n end\n end", "def have_a_page_title(expected) \n simple_matcher(\"have a page title in the <head> element with [#{expected}]\") do |given, matcher|\n given.should have_tag('head > title', expected)\n end\n end", "def check_page(title)\n if @found\n if @driver.title.include? title\n @result = @result.to_s + ' Page verification: correct page!'\n else\n @result = @result.to_s + ' Page verification: wrong page!'\n end\n else\n @result = @result.to_s + ' Page verification: nothing to do here!'\n end\n end", "def check_page_title(text)\n $driver.title.should == text\n end", "def page_title\n\n # expect=\"User Management\"\n # actual=self.title_element.text\n self.pageTitle_element.text\n # if expect==actual\n # puts\"Success-User management page is loaded\"\n # return true\n # else\n # puts\"Failure-User management page is not loaded\"\n # return false\n # end\n #\n end", "def assert_page_title(text)\n assert_selector 'h2#page_title', text: text\n end", "def check_partial_title(partial_text_title, test_case)\n page_title = get_page_title\n\n if test_case\n expect(page_title).to include(partial_text_title)\n else\n expect(page_title).to_not include(partial_text_title)\n end\nend", "def assert_title(title)\n assert_seen title, :within => \"head title\"\n end", "def page_title_is_correct\n ( text =~ self.class.page_title_validation_value ) !=nil\n end", "def verify_title(test_data)\n verify_values_match(test_data[UseOfCollections::TITLE.name], element_value(title_input))\n end", "def title(expected_title)\n $LOG.info \"Verifying the expected title #{expected_title}\"\n #$driver.title\n begin\n expect($driver.title.to_s).to eq(expected_title)\n rescue Exception => e\n $LOG.error \"Error in getting the expected title #{expected_title} \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Error in getting the expected title #{expected_title} \"+e.message\n end\n end", "def verify_title(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::TITLE.name], element_value(title_input))\n end", "def verify_page?(key, exit = true)\n base_title = wait_for_title(exit)\n puts \"Verify Title - Desired Prefix: #{site.get_title(key)} => Full Title: #{page_title}\" if exit\n if site.get_title(key) != base_title\n fail(\"Page title does not match expected result. EXPECTED: #{site.get_title(key)} FOUND: #{page_title}\") if exit\n return false\n end\n return true\n end", "def assert_title(title)\n assert_tag :tag => 'title', :content => title\n assert_tag :tag => 'h1', :content => title\n end", "def test_return_article_titles\n author = ScholarScraper.new(\"Carlo Tomasi\",raw_html)\n #author.user_link.page_body.title_creation\n assert author.title_creation.include?(\"Good features to track\")\n end", "def pageTitle(url)\n # your code here\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
simulate ActiveInteraction::Baseerrors.merge! API so upgrading will be easier later
def merge_errors!(active_model_errors) active_model_errors.messages.each do |key, messages| add_error(key, :invalid, messages.join('; ')) end end
[ "def merge_errors!(active_model_errors)\n active_model_errors.messages.each do |key, messages| \n add_error(key, :invalid, messages.join('; '))\n end\n end", "def errors\n super.tap { _1.merge!(strategy.errors) }\n end", "def merge!(errors)\n if errors\n errors.each_pair do |field, messages|\n messages.each do |message|\n add(field, message)\n end\n end\n end\n end", "def original_error; end", "def failed_to_emit(error); super if defined? super end", "def error(errors, award: nil, status: nil)\n errors = Array.wrap(errors)\n\n super(errors.to_sentence.presence, status).merge({\n award: award,\n errors: errors\n })\n end", "def merge_errors(object)\n object.errors.each do |attribute, value|\n errors.add(attribute, value)\n end\n end", "def merge!(contract_failure)\n @context[:errors] = @context[:errors].to_a + contract_failure.errors\n self\n end", "def recover_from(_error); end", "def lookup_all_error; end", "def abort_merge_and_raise(reset_command, std_err_out)\n Open3.capture2e(reset_command)\n raise_and_log(\"Was unable to merge --no-ff:\\n\\n#{std_err_out}\")\n end", "def halt_conflict(errors, render_options = {})\n halt_error(409, errors, render_options)\n end", "def import(error, override_options = {})\n @errors.append(::AdequateErrors::NestedError.new(@base, error, override_options))\n end", "def errors_for(_object); end", "def copy_errors(source)\n source.errors.each do |key, error|\n self.errors.add(key, error)\n end\n end", "def error_bubbling=(_arg0); end", "def update_errors\n @c.get_data(:update_errors)\n end", "def adderrorcontext(error, other = nil)\n error.line ||= self.line if error.respond_to?(:line=) and self.respond_to?(:line) and self.line\n error.file ||= self.file if error.respond_to?(:file=) and self.respond_to?(:file) and self.file\n error.original ||= other if error.respond_to?(:original=)\n\n error.set_backtrace(other.backtrace) if other and other.respond_to?(:backtrace)\n # It is not meaningful to keep the wrapped exception since its backtrace has already\n # been adopted by the error. (The instance variable is private for good reasons).\n error.instance_variable_set(:@original, nil)\n error\n end", "def original_exception; end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Enable scraping by overridding method_added to snoop on a library while it's loading its methods.
def enable @enabled = true body = MethodInspector::METHODS.map {|e| %[def #{e}(val) Boson::MethodInspector.#{e}(self, val) end] }.join("\n") + %[ def new_method_added(method) Boson::MethodInspector.new_method_added(self, method) end alias_method :_old_method_added, :method_added alias_method :method_added, :new_method_added ] ::Module.module_eval body end
[ "def method_added(method)\n return unless @current_doc_link\n\n @doc_urls ||= {}\n @doc_urls[method] = @current_doc_link\n\n # Prevent infinite recursion on define_method below\n @current_doc_link = nil\n\n alias_method \"old_#{method}\".to_sym, method\n\n define_method(method) do |*args|\n begin\n send(\"old_#{method}\", *args)\n rescue Exception => e\n msg = e.message + \"\\n\\nPlease refer to this URL for additional information on this API call:\\n#{self.class.api_docs(method)}\\n\" \n raise e, msg, e.backtrace\n end\n end\n end", "def before_method(method)\n @@before_methods << method\n @@wrap_exclusions << method.to_sym # This method will not be wrapped.\n end", "def method_added(method) # :nodoc:\n # Don't do nothing if the attribute is not defined and initialized yet\n return unless respond_to?(:proxified_methods) && proxified_methods?\n\n add_proxy_method(method) if proxified?(method)\n end", "def method_added( meth )\n return if @method_added_short\n if instance_interception.method_defined?( meth )\n include instance_interception\n @method_added_short = true\n instance_interception.advise( self, meth )\n @method_added_short = false\n end\n end", "def add_to_class(class_name, attr, &block)\n reloadable_patch do |plugin|\n klass = class_name.to_s.classify.constantize rescue class_name.to_s.constantize\n hidden_method_name = :\"#{attr}_without_enable_check\"\n klass.public_send(:define_method, hidden_method_name, &block)\n\n klass.public_send(:define_method, attr) do |*args|\n public_send(hidden_method_name, *args) if plugin.enabled?\n end\n end\n end", "def add_class_method(klass_name, attr, &block)\n reloadable_patch do |plugin|\n klass = klass_name.to_s.classify.constantize rescue klass_name.to_s.constantize\n\n hidden_method_name = :\"#{attr}_without_enable_check\"\n klass.public_send(:define_singleton_method, hidden_method_name, &block)\n\n klass.public_send(:define_singleton_method, attr) do |*args|\n public_send(hidden_method_name, *args) if plugin.enabled?\n end\n end\n end", "def enable_tracing_for method_map\n include Peekaboo unless @_hooked_by_peekaboo\n \n method_map = { :singleton_methods => [], :instance_methods => [] }.merge method_map\n \n _register_traceables_ method_map[:instance_methods], :instance\n _register_traceables_ method_map[:singleton_methods], :singleton\n end", "def method_missing(meth, *args, &blk)\n classify = classifications.find {|kind| kind.added_methods.include?(meth.to_s)}\n return super if classify.nil? \n self.extend(classify.methods_mixin) \n self.send(meth, *args, &blk)\n end", "def add_method_data_to_library(library)\n @commands_hash = library.commands_hash\n @library_file = library.library_file\n MethodInspector.current_module = library.module\n @store = MethodInspector.store\n add_method_scraped_data\n add_comment_scraped_data\n end", "def method_added(symbol)\n self.instance_eval {\n @read_only_methods ||= []\n @auto_read_only_flag ||= false\n @read_only_methods << symbol if @auto_read_only_flag\n c = self\n while (c = c.superclass)\n if (c.instance_eval {instance_variables.include? \"@read_only_methods\"})\n @read_only_methods |= c.instance_eval {@read_only_methods}\n end\n end\n }\n end", "def singleton_method_added(method)\n if (method.to_s =~ /^#{TruestackRails::WRAPPED_METHOD_PREFIX}/)\n return\n else\n begin\n definition_location = self.method(method)\n if (definition_location)\n loc = definition_location.source_location.join(\":\")\n filters = self._truestack_path_filters\n if (TruestackRails::Instrument.instrument_method?(loc, filters))\n TruestackRails::Instrument.instrument_method!(self, method, loc, self._truestack_method_classification, false)\n end\n end\n rescue Exception => e\n TruestackClient.logger.error \"self.#{self}##{method} Exp: #{e}\"\n end\n end\n end", "def method_added(method)\n if (method.to_s =~ /^#{TruestackRails::WRAPPED_METHOD_PREFIX}/)\n return\n else\n begin\n definition_location = self.instance_method(method)\n if (definition_location)\n loc = definition_location.source_location.join(\":\")\n filters = self._truestack_path_filters\n if (TruestackRails::Instrument.instrument_method?(loc, filters))\n TruestackRails::Instrument.instrument_method!(self, method, loc, self._truestack_method_classification)\n end\n end\n rescue Exception => e\n TruestackClient.logger.error \"#{self}##{method} Exp: #{e}\"\n end\n end\n end", "def method_added( name )\n return if $ASPECT_INTERCEPTING\n $ASPECT_INTERCEPTING = true\n intercept_method(name)\n $ASPECT_INTERCEPTING = false\n end", "def method_added(method)\n super\n # We want to define the method only if it is public\n if public_method_defined?(method)\n scope_proxy.send(:define_method, method, Scope.call_other_scope)\n end\n end", "def add_method_benchmarking\n benchmarkable_methods.each { |method| method.add_benchmarking unless method.excluded? }\n end", "def run_super(method, args=[])\n ExtraLoop::ScraperBase.instance_method(method).bind(self).call(*args)\n end", "def method_added(method_name)\n super\n initialize_variables\n add_cached_method(method_name) if self.methods_to_be_cached.include?(method_name) #and public_instance_methods.include?(method_name) # commented section is for testing the related spec\n end", "def included(klass)\n klass.class_eval do\n extend GetAPI\n end\n end", "def reenable\n @already_invoked = false\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds method attributes scraped for the library's module to the library's commands.
def add_method_data_to_library(library) @commands_hash = library.commands_hash @library_file = library.library_file MethodInspector.current_module = library.module @store = MethodInspector.store add_method_scraped_data add_comment_scraped_data end
[ "def add_command(meth)\n @@commands.delete(:help)\n \n if @@attribute\n argument_list = \"value\"\n meth = meth.to_s.delete(\"=\").to_sym if @@attribute == :attr_writer\n else\n argument_list = parse_arguments(@@command_options[:parameters])\n end\n @@command_options.merge!(:argument_list=>argument_list,:class => self.name)\n \n @@commands.merge!(meth => @@command_options)\n @@default_method = {meth => @@command_options} if @@command_options[:default]\n\n @@commands.sort.each {|com| @@commands.merge!(com[0]=>@@commands.delete(com[0]))}\n \n @@commands.merge!(HELP_COMMAND.dup) # makes sure the help command is always last\n @@command_options = nil\n @@attribute = nil\n end", "def get_raw_methods\n Checker.raw_methods = Array.new\n RME::Doc.commands.each do |category, cmds|\n all_cmds = cmds[:commands].keys.collect {|i| (i.to_s =~ /.+\\.(.+)/) && $1}\n Checker.raw_methods += all_cmds.collect(&:to_sym)\n end\n end", "def generate_method_list\n @items = prune_method_listing(Registry.all(:method), false)\n @items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? }\n @items = @items.sort_by {|m| m.name.to_s }\n @list_title = \"Method List\"\n @list_type = \"method\"\n generate_list_contents\nend", "def generate_method_list\n @items = prune_method_listing(Registry.all(:method), false)\n @items = @items.reject { |m| m.name.to_s =~ /=$/ && m.is_attribute? }\n @items = @items.sort_by { |m| m.name.to_s }\n @list_title = 'Ruby Method List'\n @list_type = 'method'\n generate_list_contents\nend", "def create_command(meth); end", "def load_command_methods()\n begin\n # Add all the newly-defined methods to our call list\n @mlist ||= []\n begin\n load 'user3.rb' # install the user-defined methods\n load 'guser3.rb' # install the GUI extensions\n load 'local.rb' # methods local to the user\n rescue LoadError; end\n\n # Load in the included files' code, but only once\n unless @var[:script_lines]\n @var[:script_lines] = []\n SCRIPT_LINES__.each do |k,v|\n @var[:script_lines] += v if k.include? 'user3.rb'\n end\n end\n new_methods = self.methods.select { |m| not @mlist.include? m }\n @mlist = self.methods\n\n # Find, translate and add any new user commands\n @cmds += new_methods.select { |m| m =~ /^local_/ }\n @cmds.collect! { |cmd| cmd.sub 'local_', '' }\n\n # Find and add any new control handlers\n @controls += new_methods.select { |m| m =~ /^remote_/ }\n @controls.collect! { |cmd| cmd.sub 'remote_', '' }\n rescue SyntaxError\n add_error \"Plugins could not be loaded (#{$!}).\"\n rescue\n add_error $!\n end\n end", "def create_command(meth) #:nodoc:\n end", "def load_command_methods()\n begin\n # Add all the newly-defined methods to our call list\n mlist = self.methods # Get the current list of methods\n load 'user3.rb' # install the user-defined methods\n begin\n load 'local.rb' # methods local to the user\n rescue LoadError; end\n\n # Load in the included files' code, but only once\n unless @var[:script_lines]\n @var[:script_lines] = []\n SCRIPT_LINES__.each do |k,v|\n @var[:script_lines] += v if k.include? 'user3.rb'\n end\n end\n new_methods = self.methods.select { |m| not mlist.include? m }\n\n # Find, translate and add any new user commands\n @cmds += new_methods.select { |m| m =~ /^local_/ }\n @cmds.collect! { |cmd| cmd.sub 'local_', '' }\n\n # Find and add any new control handlers\n @controls += new_methods.select { |m| m =~ /^remote_/ }\n @controls.collect! { |cmd| cmd.sub 'remote_', '' }\n rescue SyntaxError\n add_error \"Plugins could not be loaded (#{$!}).\"\n rescue\n add_error $!\n end\n end", "def register_capabilities(methods); end", "def after_create_commands(lib, commands); end", "def create_command(meth) #:nodoc:\n end", "def install_extend_commands; end", "def method_missing(method, *args, &block)\n method = method.to_sym\n if @modules.keys.include?(method)\n @modules[method]\n elsif available_modules.include?(method)\n @dummy_module\n else\n process_command(method, *args)\n end\n end", "def define_attribute_methods(attr)\n name = attr.name\n return if @attr_methods.has_key?(name)\n ([name] + attr.aliases).each do |ali|\n @attr_methods[ali] = name\n @attr_aliases[Inflector.underscore(ali)] = name\n @normalized_attr_names[normalize_attribute_name(ali)] = name\n end\n end", "def add_original_commands; end", "def append_features(mod)\n `Red.donateMethodsToSingleton(this,mod)`\n `Red.donateMethodsToClass(this.prototype,mod.prototype)`\n return `mod`\n end", "def def_extend_command(cmd_name, cmd_class, load_file, *aliases); end", "def all_methods_for(mod); end", "def add_original_commands\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
True if this resource needs to be preloaded before other files are automatically loaded on demand
def preload? @preload end
[ "def load_on_start?\n return @load_on_start\n end", "def strict_loading?\n @strict_loading\n end", "def _loading?\n Threaded.executing?(LOAD)\n end", "def loaded?\n @loaded ||= false\n end", "def load_resource?\n !@resource.nil?\n end", "def ensure_fully_loaded\n force_load unless @definitely_fully_loaded\n end", "def loaded?\n !!self.loaded\n end", "def resources_loaded?\n @resources.each do |resource|\n return true if resource.loaded?\n end\n false\n end", "def loaded?\n return @loaded\n end", "def loaded?\n @loaded\n end", "def before_load!\n @before_load.call unless @before_load.nil?\n end", "def loaded!\n @_loaded = true\n end", "def _loaded?\n !!@executed\n end", "def imports_required?\n true # Guaranteed by the boot process\n end", "def loading\n has_class(:loading)\n end", "def use_placeholder_loader?\n !self[:instance_specific] && !self[:eager_graph]\n end", "def vendorfile_loaded?\n defined?(@vendorfile_loaded) && @vendorfile_loaded\n end", "def not_fully_loaded!\n @fully_loaded = false\n end", "def loading?\n !load_stack.empty?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Unload the resource by undefining the constant representing it. Any resources contained within this resource will also be unloaded. This allows the resource to be garbage collected. If the resource is a class, you can define a class method called 'descendants' that returns an array of references to subclasses. Any subclasses known to Impromptu will also be unloaded, just as namespaced children are. This prevents subclasses holding a reference to a stale version of a super class.
def unload return unless loaded? # unload namespaced children @children.each_value(&:unload) # unload descendants if they can be reloaded by impromptu if reference.respond_to? :descendants reference.descendants.each do |descendant| resource = Impromptu.root_resource.child(descendant.name.to_sym) resource.unload unless resource.nil? end end # remove from the parent's descendants list if reference.respond_to?(:superclass) && reference.superclass.respond_to?(:descendants) reference.superclass.descendants.delete(reference) end unless @dont_undef @parent.reference.send(:remove_const, @base_symbol) @reference = nil end end
[ "def unload(unrequire=true)\n const = nesting.empty? ? Object : Constant.constantize(nesting) { Object }\n \n if const.const_defined?(name)\n require_paths.each do |require_path|\n require_path = File.extname(require_path).empty? ? \"#{require_path}.rb\" : require_path\n regexp = /#{require_path}$/\n \n $\".delete_if {|path| path =~ regexp }\n end if unrequire\n \n return const.send(:remove_const, name)\n end\n \n nil\n end", "def forget_all_instances\n __instances__.clear # clears @instances\n constants( false ).each { |ß| # clear constants in the namespace\n namespace.send :remove_const, ß if const_get( ß ).is_a? self\n }\n end", "def remove_unloadable_constants!\n log(\"removing unloadable constants\")\n autoloaded_constants.each { |const| remove_constant const }\n autoloaded_constants.clear\n Reference.clear!\n explicitly_unloadable_constants.each { |const| remove_constant const }\n end", "def remove_unloadable_constants!\n autoloaded_constants.each { |const| remove_constant const }\n autoloaded_constants.clear\n Reference.clear!\n explicitly_unloadable_constants.each { |const| remove_constant const }\n end", "def remove_unloadable_constants!\n autoloaded_constants.each { |const| remove_constant const }\n autoloaded_constants.clear\n explicitly_unloadable_constants.each { |const| remove_constant const }\n end", "def clear_registration_as_constant\n # Deregister non-permanent models that are registered in the\n # constant hierarchy\n if Registration.accessible_by_name?(self)\n Registration.deregister_constant(self)\n end\n end", "def unload(uri)\n SDL::Base::Type::Service.instances.delete_if do |symbolic_name, service|\n service.loaded_from.eql?(uri)\n end\n\n SDL::Base::Type.subtypes_recursive.each do |type|\n if type.loaded_from.eql?(uri) then\n type.codes.each do |code|\n @all_codes.delete code\n @type_codes.delete code\n end\n\n type.unregister\n end\n end\n end", "def cleanup_namespace\n force_remove_const(Byebug, example_class)\n force_remove_const(Byebug, example_module)\n end", "def unload\n resources.each {|resource| resource.unload}\n @modified_time = nil\n @dirty = true\n end", "def remove_child(resource)\n @children.delete(resource.base_symbol)\n end", "def unload!\n event_handlers = @component.instance_variable_get('@event_handlers') || {}\n commands = @component.instance_variable_get('@commands') || {}\n buckets = @component.instance_variable_get('@buckets') || {}\n\n # Removing itself from the bot:\n bot = @hot_loader.bot\n event_handlers.values.flatten.each { |handler| bot.remove_handler(handler) }\n commands.keys.each { |name| bot.remove_command(name) }\n buckets.keys.each { |key| bot.instance_variable_get('@buckets')&.delete(key) }\n\n # Cleaning the ruby module:\n @component.remove_instance_variable('@event_handlers') rescue nil\n @component.remove_instance_variable('@commands') rescue nil\n @component.remove_instance_variable('@buckets') rescue nil\n @component.remove_instance_variable('@dependencies') rescue nil\n end", "def unregister\n Global.item.delete(@name)\n\n # remove dependency\n if @dependencies\n @dependencies.each do |dependency|\n Global.__dependencies__.delete(dependency)\n end\n end\n\n # remove accessors\n name = @name\n Global.singleton_class.module_eval do |mod|\n remove_method(name)\n remove_method(\"set_%s\" % name)\n remove_method(\"%s=\" % name)\n end\n end", "def unloadable(const_desc)\n Dependencies.mark_for_unload const_desc\n end", "def unload_constants(new_constants)\n new_constants.each { |klass| remove_constant(klass) }\n end", "def remove(all = false)\n\t\tremove_subclasses if all\n\t\tObject.__send__(:remove_const, self.name)\n\t\tnil\n\tend", "def delete_all\n @loaded_constants.each do |const_name|\n if Object.const_defined?(const_name)\n Object.send(:remove_const, const_name)\n end\n end\n Ichiban::HTMLCompiler::Context.clear_user_defined_helpers\n end", "def unloaded; end", "def reload_resource_definition\n # clear the public_attribute_names, protected_attribute_names\n if instance_variable_defined?(:@resource_definition)\n remove_instance_variable(:@resource_definition)\n self.clear_attributes\n self.clear_related_objects\n end\n self.load_resource_definition\n end", "def unfreeze\n @related_resources = Set.new\n @related_files = Set.new\n @frozen = false\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
True if this resource represents a module acting as a namespace.
def namespace? @namespace end
[ "def namespace?\n node_type == NAMESPACE_DECL\n end", "def namespace?\r\n node_type == NAMESPACE_DECL\r\n end", "def namespace_directive?\n @name == '@namespace'\n end", "def namespace?(namespace)\n @namespaces.keys.include? namespace\n end", "def namespace_still_defined?(namespace)\n parent = Object\n outer_namespace_parts = []\n namespace.to_s.split(\"::\").each do |part|\n return false unless parent.const_defined?(part)\n\n outer_namespace_parts.push(part)\n parent = outer_namespace_parts.join(\"::\").constantize\n end\n true\n end", "def ns?(namespace)\n !! ns.match(/^#{ Regexp.escape(namespace.to_s) }(?:\\.|$)/)\n end", "def under_module?(klass, mod)\n ks = non_singleton_class(klass).to_s\n ms = mod.to_s\n return ks == ms || ks.start_with?(ms + \"::\")\n end", "def modules?\n name == Modules\n end", "def namespace_exists? name, context = ''\n !qualify(name, context).nil?\n end", "def ns?(name)\n sub = registry[name.to_sym]\n ArtifactNamespace === sub\n end", "def ns?\n not self.ns.nil?\n end", "def current_namespace?(namespace)\n controller.controller_path.start_with? namespace.to_s.downcase\n end", "def module?(uri)\n uri.include?('/modules/')\n end", "def namespace_declaration?()\n #This is a stub, used for indexing\n end", "def current_namespace?(*args)\n namespace = controller.controller_path.split('/').first\n args.any? { |v| v.to_s.downcase == namespace }\n end", "def has_modules?\n m = @context.modules.find{|m| m.document_self}\n m ? true : false\n end", "def enabled_for?(namespace)\n ns = namespace.to_s\n @enabled_namespaces.any? { |re| ns =~ re }\n end", "def use_namespaces?\n extensions.count > 1\n end", "def same_namespace?(name)\n ns,_ = split_name(name)\n if(!ns || !namespace || ns == namespace)\n true\n else\n false\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Mark a resource as representing a module acting as a namespace.
def namespace! @namespace = true end
[ "def namespace name\n declare_namespace(resource, name.intern)\n end", "def set_module_name(namespace, mod_name)\n\n info = @data[namespace]\n if ! info\n raise \"unknown namespace: #{namespace}\"\n end\n\n if mod_name !~ /^[A-Z]/\n raise \"module name must begin with an uppercase letter: #{mod_name}\"\n end\n\n info.module_name = mod_name\n end", "def isolate_namespace(mod); end", "def module_namespacing(&block)\n content = capture(&block)\n content = wrap_with_namespace(content) if namespace\n end", "def module_namespacing(&block)\n content = capture(&block)\n content = wrap_with_namespace(content) if namespaced?\n concat(content)\n end", "def namespace(name, href)\n @resource.add_namespace(name, href)\n end", "def set_namespace(namespace)\n #This is a stub, used for indexing\n end", "def namespace!\n nil.tap { self.namespace = self }\n end", "def mod_namespace\n mod_name = @mod.name.camelcase\n ns = \"Terraspace::#{@mod.type.camelcase}\".constantize # IE: Terraspace::Module or Terraspace::Stack\n if ns.const_defined?(mod_name.to_sym)\n \"#{ns}::#{mod_name}\".constantize\n else\n ns.const_set(mod_name, Module.new)\n end\n end", "def decorate_resource( rsrc )\n klass = SchedResource.block_class_for_resource_name(self.class.name)\n rsrc.label = klass.label\n rsrc.title = @rid\n end", "def namespace(namespace, &block); end", "def set_namespace(ns)\n @tag+=\":#{ns}\"\n self\n end", "def in_namespace(name)\n ns = @current_namespace.namespace(name) ||\n Excavator.namespace_class.new(name)\n @current_namespace << ns\n\n @current_namespace = ns\n yield\n @current_namespace = ns.parent\n end", "def resource_module\n klass.name.to_s.split('::')[0..-3].join('::').constantize\n end", "def isolate_namespace(mod)\n self.class.isolate_namespace(mod)\n end", "def set_namespace(ns)\n @tag+=\":#{ns}\"\n self\n end", "def restore_namespace_module(parent_module, relative_name, namespace_module)\n if parent_module\n # If there is a current module with relative_name\n if parent_module.const_defined?(relative_name)\n\t # if the current value isn't the value to be restored.\n\t if parent_module.const_get(relative_name) != namespace_module\n\t\t # remove_const is private, so use send to bypass\n\t\t parent_module.send(:remove_const, relative_name)\n\n\t\t # if there was a previous module, not set it to the name\n\t\t if namespace_module\n\t\t\t parent_module.const_set(relative_name, namespace_module)\n\t\t end\n\t end\n else\n\t # if there was a previous module, but there isn't a current module, then restore the previous module\n\t if namespace_module\n\t\t parent_module.const_set(relative_name, namespace_module)\n\t end\n end\n end\n end", "def assign_namespace\n RouteCollection.routes.each do |class_name, app_routes|\n # TODO: deal with multiple locations for multi mapping\n if route_mapping.include?(class_name)\n app_routes.each do |route|\n route.namespace = @route_mapping[class_name].first\n end\n else\n remap_resource(class_name)\n end\n end\n end", "def register(resource, options = {}, &block)\n ns = options.fetch(:namespace){ default_namespace }\n namespace(ns).register resource, options, &block\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a child resource to this resource. This does not load the resource. This should only be called by get_or_create_child.
def add_child(resource) @children[resource.base_symbol] = resource end
[ "def add_child(resource, data, autocreate = true)\n resource_model = \"Birbl::#{ resource.camelize}\".constantize\n parent_name = self.class.resource_name\n\n object =\n if autocreate && data['id'].nil?\n resource_model.create(data, self)\n else\n resource_model.new(data, self)\n end\n\n add_to_children(resource, object)\n attributes[resource.pluralize]<< data unless attributes[resource.pluralize].nil?\n\n object\n end", "def add_resource!(resource, parent = nil)\n resource = Rend::Acl::Resource.new(resource) if resource.is_a?(String)\n type_hint! Rend::Acl::Resource, resource, :is_required => true\n\n resource_id = resource.id\n\n raise Rend::Acl::Exception, \"Resource id 'resource_id' already exists in the ACL\" if resource?(resource_id)\n\n resource_parent = nil\n\n if parent\n begin\n resource_parent_id = (parent.class <= Rend::Acl::Resource) ? parent.id : parent\n resource_parent = resource!(resource_parent_id)\n rescue Rend::Acl::Exception\n raise Rend::Acl::Exception, \"Parent Resource id 'resource_parent_id' does not exist\"\n end\n @_resources[resource_parent_id][:children][resource_id] = resource\n end\n\n @_resources[resource_id] = { :instance => resource, :parent => resource_parent, :children => {} }\n self\n end", "def <<(resource)\n relate_resource(resource)\n super\n end", "def add_child(child)\n raise 'this element does not accept children' unless accepts_children?\n\n @children << child\n child.parent = self\n end", "def child(resource, id)\n test = child_by_id(resource, id)\n return test unless test.nil?\n\n resource_model = \"Birbl::#{ resource.camelize}\".constantize\n\n object = resource_model.find(id, {}, self)\n add_to_children(resource, object)\n\n object\n end", "def perform_add_child(batch_client, child_id, remove_other = false)\n self.class.make_request(client, batch_client, :add_child, scope_parameters.merge(\n self.class.primary_key_name => primary_key,\n child_id: child_id,\n remove_other: remove_other\n ))\n end", "def add_child( record )\n @children << record\n record.parent = self\n record\n end", "def add_child_object(child, relation, info = nil)\n\t relation.add_relation(self, child, info)\n\tend", "def add_child(child_object)\n child_object.parent = self # Make sure the parent is set\n @child_objects.push(child_object)\n end", "def add_child_object(child, relation, info = nil)\n relation_graphs[relation].add_relation(self, child, info)\n end", "def addChildLink(parent, child)\n raise \"Brick node: #{parent} does not exist.\" unless @tree.has_key?(parent)\n @tree[parent]['children'].push(child)\n end", "def add(child, should_add = true, &block)\n child.instance_eval(&block) if block_given?\n\n raise 'Widget already has a parent' unless child.parent.nil?\n\n gtk_instance.add(child.gtk_instance) if should_add\n child.parent = self\n\n # Ensure a children array exists, and add the new child to it\n @children ||= []\n children << child\n end", "def create\n @parent_resource = ParentResource.find(params[:child_resource][:parent_resource_id])\n require_privilege(Alberich::Privilege::CREATE, ChildResource,\n @parent_resource)\n @child_resource = ChildResource.new(params[:child_resource])\n\n respond_to do |format|\n if @child_resource.save\n @child_resource.assign_owner_roles(current_user)\n format.html { redirect_to @child_resource, notice: 'Child resource was successfully created.' }\n format.json { render json: @child_resource, status: :created, location: @child_resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @child_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_resource(resource)\n resources[resource.id] = resource\n end", "def add_resource\n resource = self.resource_class.new\n yield( resource ) if block_given?\n @resources << resource\n resource\n end", "def add_resource( resource_attributes = {})\n resource = Resource.new( resource_attributes )\n self.resources << resource\n resource\n end", "def append_child_context(child)\n children << child\n self\n end", "def add_resource(*resource)\n add_resource(*resource[0..-2]) if resource.length > 1\n resource = resource.pop\n raise ArgumentError, \"Can only add objects that respond to :ref, not instances of #{resource.class}\" unless resource.respond_to?(:ref)\n fail_on_duplicate_type_and_title(resource)\n title_key = title_key_for_ref(resource.ref)\n\n @transient_resources << resource if applying?\n @resource_table[title_key] = resource\n\n # If the name and title differ, set up an alias\n\n if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.respond_to?(:isomorphic?) and resource.name != resource.title\n self.alias(resource, resource.uniqueness_key) if resource.isomorphic?\n end\n\n resource.catalog = self if resource.respond_to?(:catalog=)\n add_vertex(resource)\n @relationship_graph.add_vertex(resource) if @relationship_graph\n end", "def add_resource(res)\n @resources << res\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove a reference to a child resource. This does not unload the object, but is called automatically by unload on its parent resource.
def remove_child(resource) @children.delete(resource.base_symbol) end
[ "def unlink_child(object)\n #puts \"unlink child #{object.short_id} from parent #{self.short_id}\"\n @children.reject!{ |obj| obj.id == object.id }\n end", "def unload\n return unless loaded?\n \n # unload namespaced children\n @children.each_value(&:unload)\n \n # unload descendants if they can be reloaded by impromptu\n if reference.respond_to? :descendants\n reference.descendants.each do |descendant|\n resource = Impromptu.root_resource.child(descendant.name.to_sym)\n resource.unload unless resource.nil?\n end\n end\n \n # remove from the parent's descendants list\n if reference.respond_to?(:superclass) && reference.superclass.respond_to?(:descendants)\n reference.superclass.descendants.delete(reference)\n end\n \n unless @dont_undef\n @parent.reference.send(:remove_const, @base_symbol)\n @reference = nil\n end\n end", "def remove\n @resource = nil\n end", "def remove_resource!(resource)\n resource_id = resource!(resource).id\n resources_removed = [resource_id]\n\n if resource_parent = @_resources[resource_id][:parent]\n @_resources[resource_parent.id][:children].delete(resource_id)\n end\n\n @_resources[resource_id][:children].each do |child_id, child|\n remove_resource!(child_id)\n resources_removed.push(child_id)\n end\n\n resources_removed.each do |resource_id_removed|\n @_rules[:by_resource_id].each do |resource_id_current, rules|\n if resource_id_removed == resource_id_current\n @_rules[:by_resource_id].delete(resource_id_current)\n end\n end\n end\n\n @_resources.delete(resource_id)\n\n self\n end", "def release(resource_id)\n if (child = children.find { |v| v.uid.to_s == resource_id.to_s })\n if child.release_self()\n children.delete(child)\n child\n else\n child = nil\n end\n else\n warn \"#{resource_id} does not belong to #{self.uid}(#{self.hrn}) - #{children.inspect}\"\n end\n child\n end", "def del_child(child)\n @children.delete(child)\n @@registry.delete(child)\n child.finalize!\n child.win.delwin if !!child.win\n end", "def release!\n @parent.remove_child(self) if @parent\n end", "def unlink\n @parent.unlink(self)\n end", "def unlink(parent, child)\n parent, child = lookup(parent, child)\n\n parent.children.delete(child)\n child.parents.delete(parent)\n end", "def remove_child(child)\n @children.delete(child.name)\n child.parent = nil\n child\n end", "def remove_child(child)\n name = child.association_name\n if child.embedded_one?\n attributes.delete(child._association.store_as)\n remove_ivar(name)\n else\n relation = send(name)\n relation._remove(child)\n end\n end", "def remove_child( record )\n @children.delete( record )\n record.parent = nil\n end", "def remove_child_object(child, relation = nil)\n if !relation\n for rel in sorted_relations\n rel.remove_relation(self, child)\n end\n else\n relation.remove_relation(self, child)\n end\n\tend", "def remove(child)\n# if children.delete(child)\n# scene.unindex_prop(child) if scene\n @peer.remove(child.peer)\n# end\n end", "def destroy\n @child_resource = ChildResource.find(params[:id])\n # require modify permissions for this object\n require_privilege(Alberich::Privilege::MODIFY, @child_resource)\n @child_resource.destroy\n\n respond_to do |format|\n format.html { redirect_to child_resources_url }\n format.json { head :no_content }\n end\n end", "def remove_child_object(child, relation = nil)\n if !relation\n for rel in sorted_relations\n rel.remove_relation(self, child)\n end\n else\n relation_graphs[relation].remove_relation(self, child)\n end\n end", "def remove_from_parent\n @change_set = ChangeSet.for(resource)\n parent_resource = find_resource(parent_resource_params[:id])\n authorize! :update, parent_resource\n\n parent_change_set = ChangeSet.for(parent_resource)\n current_member_ids = parent_resource.member_ids\n parent_change_set.member_ids = current_member_ids - [resource.id]\n\n obj = nil\n change_set_persister.buffer_into_index do |persist|\n obj = persist.save(change_set: parent_change_set)\n end\n after_update_success(obj, @change_set)\n rescue Valkyrie::Persistence::ObjectNotFoundError => e\n after_update_error e\n end", "def remove_child(child)\n @children.delete(child)\n end", "def unlink\n if parent\n parent.children.delete(self)\n self.instance_variable_set(:@parent, nil)\n return self\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
In most instances, this method should only be called on the root resource to traverse the resource tree and retrieve or create the specified resource. Name must be a symbol.
def get_or_create_child(name) return nil unless name.is_a?(Symbol) current = self name.each_namespaced_symbol do |name| # attempt to get the current resource child_resource = current.child(name.base_symbol) # create the resource if needed if child_resource.nil? child_resource = Resource.new(name, current) current.add_child(child_resource) end # the next current resource is the one we just created or retrieved current = child_resource end # after iterating through the name, current will be the resulting resource current end
[ "def find_or_create_resource_for(name)\n resource_name = name.to_s.gsub(/^[_\\-+]/,'').gsub(/^(\\-?\\d)/, \"n#{$1}\").gsub(/(\\s|-)/, '').camelize\n if self.class.parents.size > 1\n find_resource_in_modules(resource_name, self.class.parents)\n else\n self.class.const_get(resource_name)\n end\n rescue NameError\n if self.class.const_defined?(resource_name)\n resource = self.class.const_get(resource_name)\n else\n resource = self.class.const_set(resource_name, Class.new(GovKit::Resource))\n end\n resource\n end", "def resource(name)\n node.resource_locator[self,name]\n end", "def find_or_create_resource_for(name)\n resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end", "def find_or_create_resource_for(name)\n resource_name = name.to_s.camelize\n resource_name.constantize\n rescue NameError\n resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end", "def find_or_create_resource_for(name); end", "def find_or_create_resource_for(name)\r\n resource_name = name.to_s.camelize\r\n resource_name.constantize\r\n rescue NameError\r\n resource = self.class.const_set(resource_name, Class.new(ActiveTamino::Base))\r\n resource.collection = self.class.collection\r\n resource.credentials = self.class.credentials\r\n resource.doctype = self.class.doctype\r\n resource\r\n end", "def resource_symbol\n @resource_symbol ||= \":#{resource_name}\"\n end", "def sub_resource(resource_name)\n @sub_resources[resource_name] = new_resource(resource_name) unless @sub_resources.key?(resource_name)\n @sub_resources[resource_name]\n end", "def find_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)\n find_resource!(type, name, run_context: run_context)\n rescue Chef::Exceptions::ResourceNotFound\n if resource_attrs_block\n declare_resource(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block)\n end # returns nil otherwise\n end", "def to_resource(term,symbol) \n if term == symbol\n return term\n elsif term == nil\n symbol.to_sym\n elsif term.instance_of? BNode \n term\n elsif term.instance_of?(RDFS::Resource)\n term\n elsif term[0..1]==\"_:\"\n BNode.new term[2..term.size]\n elsif term[0] == 60\n RDFS::Resource.new term \n else\n term \n end \n end", "def create_resource_for(resource_name)\n resource = self.class.const_set(resource_name, Class.new(Meli::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end", "def load(resource, name = false)\n if(resource.instance_of?(Class) && (resource < Orange::Carton))\n carton = resource # Resource isn't really ar resource\n carton.as_resource\n resource_class = Object.const_get(\"#{carton.to_s}_Resource\")\n resource = resource_class.new\n name = carton.to_s.gsub(/::/, '_').downcase.to_sym if(!name)\n end \n name = resource.orange_name if(!name)\n name = resource.class.to_s.gsub(/::/, '_').downcase.to_sym if(!name)\n @resources[name] = resource.set_orange(self, name)\n end", "def named(name)\n resource = all.detect { |resource| resource.name == name }\n if resource.nil?\n raise UnknownResource, \"Resource named #{name} doesn't exist\"\n else\n resource\n end\n end", "def add_resource(name, resource)\n name = name.to_s\n\n @resources[resource.class] ||= {}\n\n if @resources[resource.class].has_key? name\n raise RuntimeError, \"duplicate #{resource.class} resource #{name.inspect} in scope #{self}\"\n end\n\n @resources[resource.class][name] = resource\n end", "def resource name, &block\n specs.each do |spec|\n spec.resource(name, &block) unless spec.resource?(name)\n end\n end", "def map_enclosing_resource(name, options = {}, &block)\n spec = Specification.new(name, options, &block)\n resource_specification_map[spec.segment] = spec\n end", "def resource(name, base_path: nil, &block)\n resource_name = name.to_s.singularize.to_sym\n\n namespace name, base_path: (base_path || \"/#{name}\") do\n schema resource_name\n instance_eval(&block)\n end\n end", "def resource\n instance_variable_get(:\"@#{resource_name}\")\n end", "def resource(name)\n name = name.to_sym\n\n resource_info = RESOURCES[name]\n if resource_info.nil?\n raise ArgumentError, sprintf('No resource found with name %s', name)\n end\n\n require_path = sprintf(RESOURCE_PATH, @path_version, resource_info[0],\n resource_info[1])\n require require_path\n\n class_path = RESOURCE_CLASS_PATH\n class_path = COMMON_CLASS_PATH if resource_info.first == 'common'\n class_path = SERVICE_CLASS_PATH if resource_info.first == 'services'\n class_path = sprintf(class_path, @version, resource_info[2])\n return class_for_path(class_path)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
True if this resource exists as a constant in its parent. This does not guarantee that every file implementing this resource has been loaded, however, so an incomplete instance may exist. If you rely on the autoloader and reloader this will not occur.
def loaded? return true if root? return false unless @parent && @parent.loaded? && @parent.reference parent.reference.constants.include?(@base_symbol) end
[ "def const_defined?(name,*inherit)\n if super(name,*inherit)\n true\n else\n # attempt to load the file that might have the constant\n require_file(OpenNamespace.const_path(name))\n\n # check for the constant again\n return super(name,*inherit)\n end\n end", "def loadable_const_defined?(name)\n if const_defined?(name.to_sym, false)\n true\n elsif const_path(name)\n true\n else\n false\n end\n end", "def currently_defined?\n base_module.const_defined?(constant_name, false)\n end", "def qualified_const_defined?(path)\n Object.const_defined?(path, false)\n end", "def const_loaded?\n @mod.autoload?(@name)\n end", "def loaded?(resource)\n assert_kind_of 'resource', resource, source_model\n\n resource.instance_variable_defined?(instance_variable_name)\n end", "def loaded?(constant)\n return loaded.include?(constant)\n end", "def include_in_parent?\n child_namespace? && file.nil?\n end", "def loaded?(constant)\n return loaded.key?(constant)\n end", "def load_resource?\n !@resource.nil?\n end", "def resource_exists?\n Repositories.constants.include?(class_symbol)\n end", "def top_level_constant?\n !parent_node.constant_reference_node?\n end", "def constant_defined?(name)\n name.split('::').inject(Object) do |scope, n|\n return false if scope.autoload?(n) || !scope.const_defined?(n)\n scope.const_get(n)\n end\n end", "def constant_is_defined?(const_name)\n const_name.to_s.sub(/\\A::/,'').split('::').inject(Object) do |namespace, name|\n begin\n result = namespace.const_get(name)\n\n # const_get looks up the inheritence chain, so if it's a class\n # in the constant make sure we found the one in our namespace.\n #\n # Can't help if the constant isn't a class...\n if result.is_a?(Module)\n expected_name = \"#{namespace}::#{name}\".gsub(/^Object::/, \"\")\n return false unless expected_name == result.to_s\n end\n\n result\n rescue NameError\n false\n end\n end\n end", "def singleton_resource?\n tester_klass = name.classify.constantize\n if tester_klass.singleton_resource.nil?\n if name[0..-15] != name[0..-15].pluralize\n tester_klass.singleton_resource = true\n else\n tester_klass.singleton_resource = false\n end\n end\n tester_klass.singleton_resource\n end", "def constant_defined?(const)\n constantize(const)\n true\n rescue\n false\n end", "def constants_loaded?\n @constants_loaded ||= false\n end", "def singleton_resource?\n self.class.singleton_resource?\n end", "def namespace_still_defined?(namespace)\n parent = Object\n outer_namespace_parts = []\n namespace.to_s.split(\"::\").each do |part|\n return false unless parent.const_defined?(part)\n\n outer_namespace_parts.push(part)\n parent = outer_namespace_parts.join(\"::\").constantize\n end\n true\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads this resource if it is an extension of an existing class or module (such as an object in the standard library). Should only be called on app startup by Impromptu itself. Recurses to this resource's children as well.
def load_if_extending_stdlib reload if loaded? && !self.root? @children.each_value(&:load_if_extending_stdlib) end
[ "def load_current_resource\n raise Chef::Exceptions::Override, \"You must override load_current_resource in #{self}\"\n end", "def load_current_resource\n end", "def load_resource?\n !@resource.nil?\n end", "def __extension_module__\n build_extension_module if extensions_values.any? || operations_values.any? || subresources_values.any?\n ensure\n singleton_class.class_eval \"attr_reader :__extension_module__\"\n end", "def load!\n memoize(:terraform_resources, :global) do\n load(\n File.join(\n File.dirname(__FILE__),\n \"terraform_resources.json\"\n )\n )\n # NOTE: Internal resource type used for nesting\n register(\"module\",\n \"properties\" => [],\n \"full_properties\" => {})\n true\n end\n end", "def extension_loader\n ExtensionLoader.instance {|l| l.initializer = self }\n end", "def load_current_resource\n true\n end", "def load_parent(doc)\n\n # Scan evidence of a superclass.\n doc.scan(@extends_regexp)\n\n # If we match then convert the import to a file reference.\n if $9 != nil\n possible_parent_paths = imported_class_to_file_path(doc,$9)\n log_append(\"Loading super class '#{$9}' '#{possible_parent_paths[0]}'.\")\n return load_class( possible_parent_paths )\n end\n\n # ActionScript 3 makes extending object's optional when writing code.\n # However all classes are decendants of Object, so add it here.\n doc.scan(/^\\s*(public dynamic class Object)/)\n\n unless $1\n log_append(\"Loading super class 'Object' 'Object'.\")\n return load_class([\"Object\"])\n end\n\n return nil\n\n end", "def load_resources!\n if provider && @provider_resources.nil?\n provider_name = camel(PROVIDER_MAPPINGS.fetch(provider, provider))\n if Resources.const_defined?(provider_name)\n @provider_resources = Resources.const_get(provider_name)\n provider_resources.load!\n end\n end\n end", "def included(_klass)\n load!\n end", "def extension_loader\n ExtensionLoader.instance { |l| l.initializer = self }\n end", "def inherited(resource)\r\n resource.class_eval do\r\n self.versions ||= {}\r\n self.helper_object = Object.new\r\n\r\n begin\r\n plural = name.demodulize.tableize\r\n self.path = lambda { |format|\r\n begin\r\n new.polymorphic_path [:resources, plural], :format => format\r\n rescue => e\r\n nil\r\n end\r\n }\r\n self.query_template = DEFAULT_COLLECTION_QUERY_TEMPLATE.dup\r\n self.model = name.sub(/^Restful\\b/, '').constantize\r\n finder :find, :all, :first, :last\r\n helper ApplicationHelper\r\n rescue ArgumentError, NameError => e\r\n nil\r\n end\r\n\r\n Restful::Resource.classes << self\r\n end\r\n end", "def register_ensure_loaded(object); end", "def resource_module\n klass.name.to_s.split('::')[0..-3].join('::').constantize\n end", "def load\n super()\n dumper_klass.load if dumper_klass\n end", "def register_ensure_loaded(object)\n ensure_loaded!(object.namespace)\n object.namespace.children << object\n rescue NamespaceMissingError\n nil # noop\n end", "def read_extended_object\n mod = safe_const_get(read)\n object = read\n object.extend(mod)\n object\n end", "def load_instance(_context)\n raise NotImplementedError\n end", "def load!\n class_names.each { |name| self[name] }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads this resource, and any child resources, if the resource is marked as requiring preloading, and the resource is not currently loaded. This loading may happen multiple times during the application life cycle depending on whether parent resources are reloaded and so on.
def reload_preloaded_resources reload if !loaded? && preload? @children.each_value(&:reload_preloaded_resources) end
[ "def load\n need_context = !loaded?\n result = super\n if need_context\n Context.register(\n records: ar_lazy_preload_records,\n association_tree: lazy_preload_values,\n auto_preload: preloads_associations_lazily?\n )\n end\n result\n end", "def preload\n raise ResourceNotLoaded unless resource\n resource.params_handler = authorization.preload\n end", "def ensure_fully_loaded\n force_load unless @definitely_fully_loaded\n end", "def preload_resources_for(_action)\n _action = _action.to_sym\n Array(@controller.class._cn_resources).each do |res|\n next unless res[:only].nil? or res[:only].include? _action\n next unless res[:except].nil? or !res[:except].include? _action\n\n @resources[res[:name]] = resource = @controller.instance_eval &res[:loader]\n @controller.instance_variable_set \"@#{res[:name]}\", resource\n end\n end", "def loading\n use\n yield\n ensure\n unuse\n end", "def _loading\n Threaded.begin_execution(LOAD)\n yield\n ensure\n Threaded.exit_execution(LOAD)\n end", "def load\n if load_operation = self.class.load_operation\n @data = load_operation.call(resource:self, client:client)\n self\n else\n raise NotImplementedError, \"#load not defined for #{self.class.name}\"\n end\n end", "def _side_load(name, klass, resources)\n associations = klass.associated_with(name)\n\n associations.each do |association|\n association.side_load(resources, @included[name])\n end\n\n resources.each do |resource|\n loaded_associations = resource.loaded_associations\n loaded_associations.each do |association|\n loaded = resource.send(association[:name])\n next unless loaded\n _side_load(name, association[:class], to_array(loaded))\n end\n end\n end", "def load!\n memoize(:aws_resources, :global) do\n load(\n File.join(\n File.dirname(__FILE__),\n \"aws_resources.json\"\n )\n )\n true\n end\n end", "def load\n if count == 1\n # Remove the metadata loader / load directly from the resource\n first.metadata = nil\n first.load\n else\n # Load each resource's metadata\n metadata.each_with_index do |result, index|\n self[index].metadata = result\n end\n\n true\n end\n\n @loaded = true\n end", "def load!\n memoize(:terraform_resources, :global) do\n load(\n File.join(\n File.dirname(__FILE__),\n \"terraform_resources.json\"\n )\n )\n # NOTE: Internal resource type used for nesting\n register(\"module\",\n \"properties\" => [],\n \"full_properties\" => {})\n true\n end\n end", "def load_current_resource\n true\n end", "def load_resources!\n if provider && @provider_resources.nil?\n provider_name = camel(PROVIDER_MAPPINGS.fetch(provider, provider))\n if Resources.const_defined?(provider_name)\n @provider_resources = Resources.const_get(provider_name)\n provider_resources.load!\n end\n end\n end", "def load_loader\n @loader if options[:all] || options[:loader]\n end", "def load_resource?\n !@resource.nil?\n end", "def load_resource(*args)\n ControllerApe.add_before_filter(self, :load_resource, *args)\n end", "def load_current_resource\n end", "def eager_load_all\n Registry.loaders.each(&:eager_load)\n end", "def load!\n require File.join(File.dirname(__FILE__), 'aws', 'cfn_resources.rb')\n load(AWS_RESOURCES)\n true\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Invokes 'lists.delete_member' API method
def delete_member connection.call_method('lists.delete_member', id_params) end
[ "def delete_list_member(list_id = '05d8c607fd',\n member_id = '7f2effe9e6b371add87d4d980a0b8c97')\n answer = @api.lists[list_id].members[member_id].delete\n pp(answer) if @debug == true\n answer\n end", "def remove_member_from_list(user, list, member_id)\n delete(\"/#{user}/#{list}/members.json?id=#{member_id}\")\n end", "def delete(member)\n\t\t@list.delete(member)\n\tend", "def destroy(*args)\n unless args.find { |arg| arg.match(/ListName/) }\n args << \"ListName=#{Postal.options[:list_name]}\"\n end\n # raise Postal::WouldDeleteAllMembers, 'Not passing any parameters (other than ListName) to this method will delete ALL members of a list. If you really want to delete all members of this list, use destroy! instead.' if args.to_a.size == 1 && args.to_a.first.match(/ListName/)\n return Postal.driver.deleteMembers(args)\n end", "def destroy\n @member_list.destroy\n respond_to do |format|\n format.html { redirect_to member_lists_url, notice: '刪除成功!!' }\n format.json { head :no_content }\n end\n end", "def delete_member(url)\n delete url\n assert last_response.ok?, \"deleting extant member\"\n check_error_response(last_response)\n end", "def remove_member(*args)\n arguments(args, required: [:id, :user])\n\n delete_request(\"/teams/#{arguments.id}/members/#{arguments.user}\",\n arguments.params)\n end", "def delete_member_from(group_id, member_id)\n make_request(:delete, group + \"/#{group_id}/member/#{member_id}\", headers: {'content-type' => 'application/atom+xml'})\n end", "def delete_access_list_member(id)\n response = @connection.lbreq(\"DELETE\",@lbmgmthost,\"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}/accesslist/#{CloudLB.escape(id.to_s)}\",@lbmgmtport,@lbmgmtscheme,{})\n CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n true\n end", "def destroy\n @member = Member.with_permissions_to(:destroy).find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end", "def delete_member_from(group_id, member_id)\n delete(@group + \"/#{group_id}/member\", member_id)\n end", "def remove(member_address)\n Mailgun.submit :delete, list_member_url(member_address)\n end", "def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to admin_members_url }\n format.json { head :no_content }\n end\n end", "def unassign_member\n authorize List\n @member.assigned_lists.delete(@list)\n json_response({ message: 'List unassigned successfully' }, :ok)\n end", "def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end", "def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n \n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end", "def destroy\n member.destroy\n respond_to do |format|\n format.html { redirect_to admin_members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove_member\n @group = Group.find(params[:id])\n \n # FIXME: isn't there an easier way to delete memberships?\n @group.memberships.find(:all,\n :conditions => {\n :member_id => params[:member][:id], \n :member_type => params[:member][:type]\n }\n ).each{|m| m.destroy}\n \n respond_to do |format|\n if @group.save\n format.html { render :partial => 'listing', :locals => {:group => @group} }\n format.xml { render :xml => @group.to_xml(:methods => :members), :status => :ok, :location => @group }\n format.json { render :json => @group.to_json(:methods => :members), :status => :ok, :location => @group }\n else\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_DeleteMember(value)\n set_input(\"DeleteMember\", value)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Invokes 'lists.update_member' API method
def update_member(params) connection.call_method('lists.update_member', params.merge(id_params)) end
[ "def update_member(address, member_address, params)\n put(\"lists/#{address}/members/#{member_address}\", params)\n end", "def update(member_address, options={})\n params = {:address => member_address}\n Mailgun.submit :put, list_member_url(member_address), params.merge(options)\n end", "def update_member(id, email, merge_vars, email_type='', replace_interests=true)\n _params = {:id => id, :email => email, :merge_vars => merge_vars, :email_type => email_type, :replace_interests => replace_interests}\n return @master.call 'lists/update-member', _params\n end", "def update\n expose Member.update(@oauth_token, params[:membername], params)\n end", "def update(current_email, user_info, email_type = 'html')\n begin\n @api.call(\"listUpdateMember\", @api_key, @list_id, current_email, user_info, email_type, true)\n rescue\n false\n end\n end", "def add_member_to_list(user, list, member_id, options={})\n post(\"/#{user}/#{list}/members.json\", options.merge(:id => member_id))\n end", "def update\n respond_to do |format|\n if member.update(member_params)\n format.html { redirect_to admin_member_path(member), notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: member }\n else\n format.html { render :edit }\n format.json { render json: member.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @current_user.id != @member.user_id\n return render json: { message: \"You are not permitted to perform this operation.\" }, status: :forbidden\n end\n if @member.update(member_params)\n render json: @member, status: :ok\n else\n render json: @member.errors, status: :unprocessable_entity\n end\n end", "def update_members(members)\n # Remove any users no longer listed\n @group.users -= (@group.users - members.keys)\n\n # Add/edit the new list of users\n members.each do |user, role|\n creator = [:creator].include?(role)\n owner = %i[creator owner].include?(role)\n editor = %i[creator owner editor].include?(role)\n\n gm = @group.membership.where(user: user).first\n update = gm&.owner != owner || gm&.editor != editor\n if !gm || update\n # Existing user - remove old membership before re-adding\n @group.users -= [user] if update\n\n @group.membership << GroupMembership.new(\n user: user,\n group: @group,\n creator: creator,\n owner: owner,\n editor: editor\n )\n end\n end\n end", "def update\n respond_to do |format|\n if @free_member.update(admin_free_member_params)\n format.html { redirect_to admin_free_members_url,\n notice: I18n.t('flash.free_member.successfully_updated') }\n else\n format.html { render :edit }\n end\n end\n end", "def update_list(list_id:, name:)\n api_request(method: :patch, path: \"lists/#{list_id}\", params: list_params(name))\n end", "def update\n # byebug \n respond_to do |format|\n if self.current_member && self.current_member.id == params[:id].to_i\n if @member.update(member_params)\n format.json { render :show, status: :ok, location: @member }\n else\n return api_error(status: :unprocessable_entity, message: @member.errors)\n end\n else\n return api_error(status: 401, message: '没有操作权限')\n end\n end\n end", "def update_group_member_set(principal, members)\n end", "def update\n\t\treturn not_found unless current_user.is_admin?\n @sample_member = SampleMember.find(params[:id])\n\n respond_to do |format|\n if @sample_member.update_attributes(member_params)\n format.html { redirect_to @sample_member, notice: 'Sample member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sample_member.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n require_user()\n respond_to do |format|\n if @db_member.update(db_member_params)\n format.html { redirect_to @db_member, notice: 'Db member was successfully updated.' }\n format.json { render :show, status: :ok, location: @db_member }\n else\n format.html { render :edit }\n format.json { render json: @db_member.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_members(action)\n @team = MnoEnterprise::Team.find(params[:id])\n authorize! :manage_teams, @team.organization\n\n if params[:team] && params[:team][:users]\n id_list = params[:team][:users].map { |h| h[:id] }.compact\n users = @team.organization.users.where('id.in' => id_list)\n\n users.each { |u| @team.send(action, u) }\n\n MnoEnterprise::EventLogger.info('team_update', current_user.id, 'Team composition updated', @team,\n {action: action.to_s, users: users.map(&:email)})\n end\n @team.reload\n\n render 'show'\n end", "def edit_members\n end", "def update_board_member(board_id, member_id, type)\n update_board_resource(board_id, \"members\", resource_id(member_id), type: type)\n end", "def update_member_data(member, member_data)\n update_member_data_in(@leaderboard_name, member, member_data)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Invokes 'lists.unsubscribe_member' API method
def unsubscribe_member(params) connection.call_method('lists.unsubscribe_member', params.merge(id_params))['unsubscribed'] end
[ "def unsubscribe_member(params)\n call_method('lists.unsubscribe_member', params)['unsubscribed']\n end", "def unsubscribe\n mailchimp = Gibbon::API.new\n result = mailchimp.lists.unsubscribe({\n :id => ENV[\"MAILCHIMP_LIST_ID\"],\n :email => {:email => self.email},\n :delete_member => true, # this is NOT the default value\n :send_notify => true,\n :send_goodbye => true\n })\n Rails.logger.info(\"Unsubscribed #{self.email} from MailChimp\") if result\n end", "def unsubscribe(list_id, current_email, options = {})\n options = apply_defaults_to({:delete_member => true}.merge(options))\n call(\"listUnsubscribe\", list_id, current_email, *options.values_at(:delete_member, :send_goodbye, :send_notify))\n end", "def unsubscribe_from_list(user, list)\n delete(\"/#{user}/#{list}/subscribers.json\")\n end", "def unsubscribe(list_uid, subscriber_uid)\n\n client = Client.new({\n 'method': Client::METHOD_PUT,\n 'url': Base.config.api_url(sprintf('lists/%s/subscribers/%s/unsubscribe', list_uid, subscriber_uid)),\n })\n client.request\n end", "def remove_member_from_list(user, list, member_id)\n delete(\"/#{user}/#{list}/members.json?id=#{member_id}\")\n end", "def unsubscribe(list_id, user_id)\n raise NotImplementedError.new\n end", "def unsubscribe_from_list\n Gibbon::Request.lists(Rails.application.secrets.mailchimp_cold_email_list_id).members(lower_case_md5_hashed_email_address).update(body: { status: 'unsubscribed'} )\n rescue Gibbon::MailChimpError => e\n logger.error \"Mailchimp error while unsubscribing customer: #{e.detail}\" unless e.body['status'] == 404\n true\n end", "def unsubscribe!\n self.type = :unsubscribe\n reply_if_needed!\n end", "def unsubscribe_from_lists(list_names, email)\r\n list_names = [list_names] unless list_names.is_a?(Array)\r\n list_names.each do |list_name|\r\n list = name_to_list(list_name)\r\n list.members(email).update(\r\n status: \"unsubscribed\"\r\n )\r\n end\r\n end", "def delete_member\n connection.call_method('lists.delete_member', id_params)\n end", "def unsubscribe\n @entry.subscribers.delete(current_user)\n end", "def unsubscribe_from_mailing_lists(list_names=[])\n\t\tlist_names.each do |list_name|\n\t\t\tnext if !User.mailing_list_name_valid?(list_name)\n\t\t\t\n\t\t\tlist_id = mailchimp_list_ids[list_name]\n\t\t\t\n\t\t\tbegin\n\t\t\t\temail_hash = email_md5_hash(email)\n\t\t\t\tGibbon::Request.lists(list_id).members(email_hash).update body: {\n\t\t\t\t\tstatus: 'unsubscribed'\n\t\t\t\t}\n\t\t\t\tupdate_column(leid_attr_name(list_name), nil)\n\t\t\trescue Gibbon::MailChimpError => e\n\t\t\t\tif e.status_code == 404 && leid(list_name)\n\t\t\t\t\t# Not found by email address; try leid (MailChimp's unique_email_id).\n\t\t\t\t\tbegin\n\t\t\t\t\t\tr = Gibbon::Request.lists(list_id).members.retrieve params: {\n\t\t\t\t\t\t\tunique_email_id: leid(list_name)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif member = r['members'].first\n\t\t\t\t\t\t\temail_hash = email_md5_hash(member['email_address'])\n\t\t\t\t\t\t\tGibbon::Request.lists(list_id).members(email_hash).update body: {\n\t\t\t\t\t\t\t\tstatus: 'unsubscribed'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tupdate_column(leid_attr_name(list_name), nil)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tlogger.error \"MailChimp error while unsubscribing user #{id}: could not find subscription via MailChimp API with email => #{email} or leid => #{leid(list_name)}\"\n\t\t\t\t\t\tend\n\t\t\t\t\trescue Gibbon::MailChimpError => e\n\t\t\t\t\t\tlogger.error \"MailChimp error while unsubscribing user #{id}: #{e.title}; #{e.detail}; status: #{e.status_code}; email: #{email}; leid: #{leid(list_name)}\"\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tlogger.error \"MailChimp error while unsubscribing user #{id}: #{e.title}; #{e.detail}; status: #{e.status_code}; email: #{email}; leid: #{leid(list_name)}\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def un_subscribe #unsubscribe is a reserved ruby word do not change\n\n # An unsubscribe email address is of the form <unsubscribe_token>@unsubscribe.zangzing.com\n # we use Mail::Address to parse the addresses and the domain\n # If the to or from addresses are invalid emails, an exception will be raised\n to = Mail::Address.new( params[:to].to_slug.to_ascii.to_s )\n from = Mail::Address.new( params[:from].to_slug.to_ascii.to_s )\n unsub_token = to.local\n\n if unsub_token == 'unsubscribe'\n #unsubscribe from address\n @subs = Subscriptions.find_by_email( from.address )\n else\n #unsubscribe using token\n @subs = Subscriptions.find_by_unsubscribe_token( unsub_token )\n end\n\n if @subs\n @subs.unsubscribe\n zza.track_event(\"email.unsubscribe.received\", {:email => @subs.email, :to => params[:to], :from => params[:from] })\n Rails.logger.info \"MAIL UNSUBSCRIBE: #{@subs.email} unsubscribed by email\"\n end\n render :nothing => true, :status=> :ok\n end", "def unsubscribers(list_id)\n raise NotImplementedError.new\n end", "def unsubscribe_from(username)\n action(username, 'unsubscribe')\n end", "def remove_from_mailchimp_list(list_name)\r\n mapper = mailchimp_list_mapper.respond_to?(:delay) ? mailchimp_list_mapper.delay : mailchimp_list_mapper\r\n mapper.unsubscribe_from_lists(list_name, self.email)\r\n end", "def remove_member(*args)\n arguments(args, required: [:id, :user])\n\n delete_request(\"/teams/#{arguments.id}/members/#{arguments.user}\",\n arguments.params)\n end", "def unsubscribe\n if Friend.unsubscribe_friend(params[:requestor], params[:target])\n render json: {\n success: true\n }\n else\n render json: {\n success: false\n }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns people holidays Valid options are :conditions
def holidays(options = {}) PeopleHoliday.where(options[:conditions]).to_a rescue ::ActiveRecord::StatementInvalid => e raise StatementInvalid.new(e.message) end
[ "def search_holidays\n\n start_day = turn_to_num(self.start_date)\n end_day = turn_to_num(self.end_date)\n\n Holiday.all.select do |hol|\n turn_to_num(hol.date) >= start_day && turn_to_num(hol.date) <= end_day\n end\n\n end", "def holidays\n @holidays ||= days.select(&:holiday?)\n end", "def holiday\n holidays[date.strftime('%m/%d')]\n end", "def get_holidays_data()\n\t\t# check whether the redmine_holidays plugin is installed or not\n\t\t@has_holidays_plugin = Redmine::Plugin.installed?(:redmine_holidays)\n\n\t\t# do nothing if it isn't installed\n\t\tif !@has_holidays_plugin\n\t\t\treturn\n\t\tend\n\n\t\t# is user have the permission to view holidays?\n\t\thas_view_holidays_permission = User.current.allowed_to?(:view_holidays, nil, :global => true)\n\t\tif !has_view_holidays_permission\n\t\t\t@has_holidays_plugin = false\n\t\t\treturn\n\t\tend\n\n\t\tparams[:show_holidays] = \"1\" unless params[:show_holidays]\n\t\tparams[:show_past_holidays] = \"\" unless params[:show_past_holidays]\n\n\t\t@show_past_holidays = (params[:show_past_holidays] == \"1\")\n\n\t\t# retrieve holiday types\n\t\t@holiday_types = HolidayTypes.all(:order => \"name ASC\")\n\tend", "def holiday\n Holiday.find_by(holiday_date: self.scheduled_on)\n end", "def get_public_holidays( year )\n PublicHoliday.factory( @localization ).all( year ) \n end", "def holidays(range=(Date.today..Date.today.next_month))\n output = []\n @tokens.each do |token|\n if ALL_HOLIDAYS.include?(token)\n return HOLIDAYS.values.map do |dates|\n dates.call(range)\n end.flatten.uniq\n end\n HOLIDAYS.each_pair do |labels,dates|\n if labels.include?(token)\n output.concat(dates.call(range))\n end\n end\n end\n output\n end", "def ics_weekday_list\n __weekday_list(ics_start, ics_end){|dt|\n not(is_weekend?(dt)) and not(is_holiday?(dt))\n }\n end", "def getHolidays(locationId, from, to)\n\t\tholidays = Array.new\n\t\tunless isScheduleOnWeekEnd\n\t\t\tholidays = WkPublicHoliday.where(:location_id => locationId, :holiday_date => from .. to).pluck(:holiday_date)\n\t\tend\n\t\tholidays\n\tend", "def public_holiday?\n HOLIDAYS.include? to_date\n end", "def get_bart_holiday\n client_options = {\n \n }\n bart_holiday(client_options)\n end", "def business_hours_on_day(date, in_time_zone)\n # puts \"in time zone #{in_time_zone}\"\n date = date.in_time_zone(in_time_zone)\n weekends = [6,7]\n if weekends.include?(date.to_date.cwday)\n return [0,0]\n end\n holidays = find_holidays_on_date(date, in_time_zone)\n if holidays.empty?\n default_business_hours\n else\n # puts \"default_business_hours: \" + default_business_hours.inspect\n start_time, end_time = default_business_hours\n effective_start = start_time\n effective_end = end_time\n holidays.each do |holiday_start, holiday_end|\n # puts \"holiday_start: #{holiday_start}\"\n # puts \"holiday_end: #{holiday_end}\"\n \n if holiday_start.to_date < date.to_date\n holiday_start = date.to_date.beginning_of_day\n end\n if holiday_end.to_date > date.to_date\n holiday_end = date.to_date.end_of_day\n end\n \n # puts \"determined holiday_start: #{holiday_start}\"\n # puts \"determined holiday_end: #{holiday_end}\" \n\n # puts \"business begins: #{date.beginning_of_day + start_time}\"\n # puts \"business ends: #{date.beginning_of_day + end_time}\"\n \n #if holiday starts before business and ends after business, return 0\n if holiday_start <= (date.beginning_of_day + start_time) && holiday_end >= (date.beginning_of_day + end_time)\n return [0,0]\n end\n #if holiday starts before business then set business day to start effectively when the holiday ends\n if holiday_start <= (date.beginning_of_day + start_time)\n # puts \"holiday starts before business then set business day to start effectively when the holiday ends\"\n # puts \"holiday_end:\" + holiday_end.inspect\n # puts \"holiday_end.beginning_of_day:\" + holiday_end.beginning_of_day.inspect\n \n seconds_for_holiday_end = seconds_from_day_start(holiday_end)\n if seconds_for_holiday_end > effective_start\n effective_start = seconds_for_holiday_end\n end\n end\n #if holiday ends after business then set business day to end effectively when the holiday start\n if holiday_end >= (date.beginning_of_day + end_time)\n # puts \"holiday ends after business then set business day to end effectively when the holiday start\"\n # puts \"holiday_start:\" + holiday_start.inspect\n # puts \"holiday_start.beginning_of_day:\" + holiday_start.beginning_of_day.inspect\n \n seconds_for_holiday_start = seconds_from_day_start(holiday_start)\n if seconds_for_holiday_start < effective_end\n effective_end = seconds_for_holiday_start\n end\n end\n end\n if effective_start > effective_end\n effective_start = effective_end\n end\n # puts \"effective start and end \" + [effective_start.to_i, effective_end.to_i].inspect\n [effective_start.to_i, effective_end.to_i]\n end\n end", "def holiday?\n @holiday\n end", "def business_days\n @business_days ||= days.select(&:business_day?)\n end", "def holidayChecker(dates, bank_holidays)\n dates = parseDates(dates) #parse dates array\n bank_holidays = parseDates(bank_holidays) #parse bank holidays array\n corrected_schedule = []\n dates.each do |date|\n while date.wday == 6 || date.wday == 7 || bank_holidays.include?(date) #while the date is either a bank holiday OR a Saturday OR a Sunday...\n date += 1\n end\n corrected_schedule.push(date)\n end\n puts corrected_schedule\nend", "def weekend_and_holiday(day)\n holiday = Holidays.on(day, :federal_reserve, :observed).any?\n weekend = day.saturday? || day.sunday?\n [weekend, holiday]\n end", "def bank_holidays\n if defined? Mauve::Server and Mauve::Server.instance\n @bank_holidays = Mauve::Server.instance.bank_holidays\n else\n @bank_holidays ||= []\n end\n\n @bank_holidays\n end", "def is_holiday(date, holidays)\n holidays.include?(date)\n end", "def public_holidays(year)\n [new_years_day_holiday(year),\n good_friday(year),\n easter_monday(year),\n may_bank_holiday(year),\n spring_bank_holiday(year),\n summer_bank_holiday(year),\n christmas_day_holiday(year),\n boxing_day_holiday(year)]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns people birthdays Valid options are :month
def birthdays(options = {}) PeopleInformation.where(birthday_condition(options[:month])).to_a rescue ::ActiveRecord::StatementInvalid => e raise StatementInvalid.new(e.message) end
[ "def birthday_calendar_data(params={})\n prefix = Settings.reports.birthday_calendar.birthday_prefix # Something like \"BD: \" or icon of a cake, to precede each name\n month = params[:month] || 1\n selected = Member.where(conditions_for_collection).select(\"family_id, last_name, first_name, middle_name, birth_date, short_name, status_id\")\n # Make a hash like { 1 => {:text=>\"BD: John Doe\\nBD: Mary Smith\"}, 8 => {:text=>\"BD: Adam Smith\\n\"}}\n # Using the inner hash leaves us room to add options/parameters in the future\n data = {} \n#binding.pry\n selected.each do |m|\n if m.birth_date && (m.birth_date.month == month ) # Select people who were born in this month\n data[m.birth_date.day] ||= {:text=>''}\n data[m.birth_date.day][:text] << prefix + m.full_name_short + \"\\n\" \n end\n end\n return data\n end", "def dates_of_birth\n raise(ArgumentError, 'Need category to calculate dates of birth') unless category\n Date.new(date.year - category.ages.end, 1, 1)..Date.new(date.year - category.ages.begin, 12, 31)\n end", "def dates_of_birth\n raise(ArgumentError, \"Need category to calculate dates of birth\") unless category\n\n Date.new(date.year - category.ages.end, 1, 1)..Date.new(date.year - category.ages.begin, 12, 31)\n end", "def birthday\n Date.civil(year, month, day)\n end", "def birthday\n Date.parse(get(:foeddato))\n end", "def december_birthdays\n born_in_december = [ ]\n# each method goes through every name in the hash below... why is it able to run if the hash has not yet been defined? \n famous_birthdays.each do |name, date|\n if date.month == 12\n born_in_december << name\n end\n end\n born_in_december\n end", "def famous_birthdays\n birthdays = {\n 'Ludwig van Beethoven' => Date.new(1770,12,16),\n 'Dave Brubeck' => Date.new(1920,12,6),\n 'Buddy Holly' => Date.new(1936,9,7),\n 'Keith Richards' => Date.new(1943,12,18)\n }\n end", "def born_months\n months = [\n ['Select Month'], ['January', 1], ['February', 2], ['March', 3], ['April', 4], ['May', 5], ['June', 6],\n ['July', 7], ['August', 8], ['September', 9], ['October', 10], ['November', 11], ['December', 12]\n ]\n end", "def birthday_provided?\n birth_month? || birth_day?\n end", "def birth\n date_parser(self[:birth])\n end", "def birthday_greeting(_date, _month)\n supplied_date = Date.parse(\"2021-#{_month}-#{_date}\")\n is_today = Date.today == supplied_date\n days_left = calculate_next_birthday\n if is_today\n 'Happy birthday Angelina!'\n else\n \"you have #{days_left} days until your birthday!\"\n end\n end", "def age_in_months\n\t\treturn nil unless birthday\n\t\tn = DateTime.now\n\t\t\n\t\t((n.year - birthday.year) * 12) +\\\n\t\t\t(n.month - birthday.month)\n\tend", "def age\n return unless dob\n days = (Date.today - dob).to_i\n years = (days / 365).to_i\n months = ((days % 365) / 30).to_i\n return [years, months, days]\n end", "def parse_birthdays\n birthdays = @config['birthdays'].map do |birthday|\n birthday['date'] = Date.strptime(birthday['date'], '%m-%d')\n birthday\n end\n\n birthdays.sort_by { |entry| entry['date'] }\n end", "def index\n @birthdays = current_user.birthdays\n end", "def upcoming_birthdays(db, current_month, current_day)\n puts \"*Today's date: #{current_month}/#{current_day}\"\n puts \" \"\n puts \"*Upcoming birthdays:\"\n puts \" \"\n people_sorted_by_bday = db.execute(\"SELECT * FROM people ORDER BY day_of_year\")\n holds_january_birthdays = []\n people_sorted_by_bday.each do |person|\n if person['day_of_year'] == $current_day_of_year\n puts \" *#{person['month']}/#{person['day']}: #{person['name']}'s birthday is TODAY!\"\n elsif person['day_of_year'] > $current_day_of_year && person['day_of_year'] < $current_day_of_year + 40\n puts \" *#{person['month']}/#{person['day']}: #{person['name']}\"\n elsif $current_day_of_year > 350 && person['day_of_year'] < 31\n holds_january_birthdays << \" *#{person['month']}/#{person['day']}: #{person['name']}\"\n end\n end\n holds_january_birthdays.each do |birthday_text|\n puts birthday_text\n end\nend", "def birth_day(user_birth_date)\n Date.strptime(user_birth_date.strftime('%d/%m', 'fr'), '%d/%m').strftime('%A %d %B', 'fr') rescue ''\n end", "def birthday=(value)\n @birthday = value\n end", "def is_birthday?(date)\n date_of_birth.day == date.day &&\n date_of_birth.month == date.month\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
similar to get_random_state() except it evaluates a variable's markov blanket in addition to the variable itself.
def get_random_state_with_markov_blanket(event) # :nodoc: evaluations = [] @states.each {|s| evaluations << evaluate_markov_blanket(s, event) } evaluations.normalize! seek_state {|s| evaluations.shift } end
[ "def next_state\n STATES.find do |_, state|\n state[:probability] && state[:probability] > rand\n end\n end", "def nextState\n column = @transition.column(@state)\n rv = rand\n\n (0..column.size - 1).each do |v|\n rv -= column[v]\n if rv < 0\n @state = v\n break\n end\n end\n\n @state\n end", "def generate_random_event\n unset_variables = @variables.reject {|name, variable| variable.set_in_evidence?(@evidence) }\n new_evidence = @evidence.dup\n until unset_variables.empty? do\n settable_variables = unset_variables.reject {|name, variable| !variable.can_be_evaluated?(new_evidence) }\n settable_variables.each do |name, variable|\n unset_variables.delete(name)\n new_evidence[name] = variable.get_random_state(new_evidence)\n end\n end\n new_evidence\n end", "def state\n {\n :rand => rand\n }\n end", "def initialize\n @state = \"default-#{rand}\"\n end", "def markov\n opp_move = [@dictionary.generate_1_words]\n counter_move(opp_move)\n end", "def mock_leaderboard\n overtake = (rand * 10).round == 7\n swap_at((rand * 9).floor) if overtake\n $state.each.with_index do |car, i|\n $state[i][:interval] = $state[i-1][:interval] - (rand * 4) if i != 0\n $state[i][:last_lap] = 39 + (rand * 3)\n end\n return $state\nend", "def reset_rnd\r\n @log.debug \"RandomManager: using random function\"\r\n @state = :rnd_fun\r\n end", "def reset_rnd\n @log.debug \"RandomManager: using random function\"\n @state = :rnd_fun\n end", "def generate_feature_value_randomly\n b = rand(2)\n if (b == 0)\n return \"on\"\n else\n return \"off\"\n end\n end", "def random_decision(guess, shown)\n ([0,1,2] - [shown])[rand(2)]\n end", "def get_random_city_state\n CITY_STATES[rand(CITY_STATES.size)]\nend", "def simulated?\n self.state_simulation\n end", "def find_next_flip()\r\n walksat_prob = rand(100)/100.0\r\n if walksat_prob <= @p #Choose a variable from a random unsat clause and flip\r\n unsat_clauses = Array.new\r\n for i in 1...@active_clauses.size()\r\n if(@active_clauses[i])#active clause = not sat\r\n unsat_clauses << i\r\n end\r\n end\r\n temp_clause = @clauses_to_variables[unsat_clauses[rand(unsat_clauses.size())]]\r\n flip_var = temp_clause[rand(temp_clause.size())]\r\n if flip_var > 0\r\n return flip_var\r\n end\r\n return -1 * flip_var\r\n else\r\n #choose the variable that sats the most clauses (can be 0 or neg)\r\n num_sat = 0\r\n best_var = 0\r\n best_var_score = @@FIXNUM_MIN #integer min\r\n for var in 1...@assignments.size()\r\n score = calculate_flip_affect(var)\r\n if(score > best_var_score)\r\n best_var = var\r\n best_var_score = score\r\n end\r\n end\r\n return best_var\r\n end\r\n end", "def getRandomState\n prng = Random.new()\n \n #picks 21 random digits, becomes the state, a 21 digit number\n randStringOfNums = ''\n for i in 0..20\n randStringOfNums += prng.rand(0..9).to_s\n end\n \n return randStringOfNums\n end", "def test_initial_state_on_examples\n assert_equal(@small_dfa.ith_state(3), @small_dfa.initial_state())\n end", "def random(state = true)\n send_request('random %s' % state.to_i)\n end", "def initial_state\n initial_states[0]\n end", "def define_state_predicate; end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /liga_sf3s/1 GET /liga_sf3s/1.xml
def show @liga_sf3 = LigaSf3.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @liga_sf3 } end end
[ "def show\n @log_pelea_sf3 = LogPeleaSf3.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log_pelea_sf3 }\n end\n end", "def new\n @liga_sf3 = LigaSf3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @liga_sf3 }\n end\n end", "def show\n @s3_snapshot = S3Snapshot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @s3_snapshot }\n end\n end", "def destroy\n @liga_sf3 = LigaSf3.find(params[:id])\n @liga_sf3.destroy\n\n respond_to do |format|\n format.html { redirect_to(liga_sf3s_url) }\n format.xml { head :ok }\n end\n end", "def show\n @bench_test_s3 = BenchTest::S3.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bench_test_s3 }\n end\n end", "def index\n @advert3s = Advert3.all\n end", "def index\n @l3s = L3.all\n end", "def index\n @scene3s = Scene3.all\n end", "def show\n @personaje_sf3 = PersonajeSf3.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @personaje_sf3 }\n end\n end", "def new\n @log_pelea_sf3 = LogPeleaSf3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @log_pelea_sf3 }\n end\n end", "def index\n @id3s = Id3.all\n end", "def index\n @module3s = Module3.all\n end", "def index\n @level3s = Level3.all\n end", "def show\n @s3_image = S3Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @s3_image }\n end\n end", "def fetch_s3(package)\n\tbucket = $s3client.bucket(\"rogoodpractice\")\n\t\n\t# get all objects\n obs = bucket.objects;\n \n # pull out those matching package name\n obs = obs.select { |a| a.key.match(/#{package}/) };\n\n # pull out those with .txt files\n obstxt = obs.select { |a| a.key.match(/\\.txt/) }\n\n # pull out latest file by timestamp\n\ttarget = obstxt.max_by { |a| a.last_modified }\n\n\t# get URL\n\ttarget.temporary_url\nend", "def show\n @liga_sf4 = LigaSf4.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @liga_sf4 }\n end\n end", "def retrieve_objects_via_http(bucket)\n _log 'Retrieving objects via unauthenticated method.'\n r = http_request :get, \"https://#{bucket}.s3.amazonaws.com\"\n if r.code != '200'\n _log 'Failed to retrieve any objects using the unauthenticated technique as bucket listing is disabled.'\n return\n end\n\n xml_doc = Nokogiri::XML(r.body)\n xml_doc.remove_namespaces!\n results = xml_doc.xpath('//ListBucketResult//Contents//Key').children.map(&:text)\n results[0...999] # return first 1k results as some buckets may have tons of objects\n\n # format before\n results.reject! { |b| b =~ %r{.+/$} } unless results.nil? # remove folder names if bucket_objs is not nil\n results unless results.empty? \n end", "def index\n @s3images = S3image.all\n\n end", "def index\n @s3images = S3image.all\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /liga_sf3s/new GET /liga_sf3s/new.xml
def new @liga_sf3 = LigaSf3.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @liga_sf3 } end end
[ "def new\n @log_pelea_sf3 = LogPeleaSf3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @log_pelea_sf3 }\n end\n end", "def new\n @s3_snapshot = S3Snapshot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @s3_snapshot }\n end\n end", "def new\n @bench_test_s3 = BenchTest::S3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bench_test_s3 }\n end\n end", "def new\n @personaje_sf3 = PersonajeSf3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @personaje_sf3 }\n end\n end", "def create\n @s3_snapshot = S3Snapshot.new(params[:s3_snapshot])\n\n respond_to do |format|\n if @s3_snapshot.save\n flash[:notice] = 'S3Snapshot was successfully created.'\n format.html { redirect_to(@s3_snapshot) }\n format.xml { render :xml => @s3_snapshot, :status => :created, :location => @s3_snapshot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @s3_snapshot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @s3_image = S3Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @s3_image }\n end\n end", "def new\r\n @tag_cloud = TagCloud.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @tag_cloud }\r\n end\r\n end", "def new\n @amazon = Amazon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @amazon }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @sphere = Sphere.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sphere }\n end\n end", "def new\n @liga_sf4 = LigaSf4.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @liga_sf4 }\n end\n end", "def new\n @path = Path.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @path }\n end\n end", "def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cloud }\n end\n end", "def create\n @moto3 = Moto3.new(moto3_params)\n\n respond_to do |format|\n if @moto3.save\n format.html { redirect_to :action=>'index', notice: 'Moto3 was successfully created.' }\n format.json { render :index, status: :created, location: @moto3 }\n else\n format.html { render :new }\n format.json { render json: @moto3.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @tov3 = Tov3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tov3 }\n end\n end", "def new\n @gtfs_shape = GtfsShape.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gtfs_shape }\n end\n end", "def new\n @mp3 = Mp3.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mp3 }\n end\n end", "def show\n @liga_sf3 = LigaSf3.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @liga_sf3 }\n end\n end", "def new\n @signature = Signature.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @signature }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /liga_sf3s/1 PUT /liga_sf3s/1.xml
def update @liga_sf3 = LigaSf3.find(params[:id]) respond_to do |format| if @liga_sf3.update_attributes(params[:liga_sf3]) format.html { redirect_to(@liga_sf3, :notice => 'Liga sf3 was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @liga_sf3.errors, :status => :unprocessable_entity } end end end
[ "def upload_to_s3\n @s3 = S3.new if @s3.nil?\n @s3.upload_if_not_present @kml, kml_filename\n end", "def put_logging(params) \n AwsUtils.mandatory_arguments([:bucket,:xmldoc], params)\n AwsUtils.allow_only([:bucket,:xmldoc, :headers], params)\n params[:headers] = {} unless params[:headers]\n req_hash = generate_rest_request('PUT', params[:headers].merge(:url=>\"#{params[:bucket]}?logging\", :data => params[:xmldoc]))\n request_info(req_hash, S3TrueParser.new)\n rescue\n on_exception\n end", "def update\n @bench_test_s3 = BenchTest::S3.find(params[:id])\n\n respond_to do |format|\n if @bench_test_s3.update_attributes(params[:bench_test_s3])\n format.html { redirect_to(@bench_test_s3, :notice => 'S3 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bench_test_s3.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_put_existing\n request = Http::Request.new('PUT', '/file1', {}, 'bar')\n\n response = self.request(request)\n\n assert_equal(204, response.status)\n\n assert_equal(\n 'bar',\n @server.tree.node_for_path('file1').get\n )\n\n assert_equal(\n {\n 'X-Sabre-Version' => [Version::VERSION],\n 'Content-Length' => ['0'],\n 'ETag' => [\"\\\"#{Digest::MD5.hexdigest('bar')}\\\"\"]\n },\n response.headers\n )\n end", "def quick_s3_upload\n end", "def update\n @s3_snapshot = S3Snapshot.find(params[:id])\n\n respond_to do |format|\n if @s3_snapshot.update_attributes(params[:s3_snapshot])\n flash[:notice] = 'S3Snapshot was successfully updated.'\n format.html { redirect_to(@s3_snapshot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @s3_snapshot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @s3_image = S3Image.find(params[:id])\n\n respond_to do |format|\n if @s3_image.update_attributes(params[:s3_image])\n format.html { redirect_to @s3_image, notice: 'S3 image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @s3_image.errors, status: :unprocessable_entity }\n end\n end\n end", "def save!\n result = @s3obj.store\n self.dirty = false\n result\n end", "def update\n respond_to do |format|\n if @s3image.update(s3image_params)\n format.html { redirect_to @s3image, notice: 'S3image was successfully updated.' }\n format.json { render :show, status: :ok, location: @s3image }\n else\n format.html { render :edit }\n format.json { render json: @s3image.errors, status: :unprocessable_entity }\n end\n end\n end", "def put *args\n make_request :put, *args\n end", "def s3_updatefile(filename, filedata)\n s3_deletefile filename\n #AWS::S3::S3Object.store filename, filedata, QBUCKET.to_s, :access => :public_read\n AWS::S3::S3Object.store filename, filedata, IMAGES_BUCKET.to_s, :access => :public_read\n end", "def put_sitemap(location)\n content_type = location[:compress] ? 'application/x-gzip' : 'application/xml'\n\n s3_client.put_object(\n acl: 'public-read',\n body: File.open(location.path),\n bucket: @bucket_name,\n cache_control: 'private, max-age=0, no-cache',\n content_type: content_type,\n key: location.path_in_public\n )\n end", "def put(url, format)\n document = http.put_uri(url, serialize, format).body\n deserialize(document)\n end", "def destroy\n @liga_sf3 = LigaSf3.find(params[:id])\n @liga_sf3.destroy\n\n respond_to do |format|\n format.html { redirect_to(liga_sf3s_url) }\n format.xml { head :ok }\n end\n end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def update_file_on_s3(data)\n source = data[:source]\n target = data[:target]\n return if target.nil?\n object = RedmicaS3::Connection.object(target)\n # get the file modified time, which will stay nil if the file doesn't exist yet\n # we could check if the file exists, but this saves a head request\n s3_mtime = object.last_modified rescue nil\n\n # put it on s3 if the file has been updated or it doesn't exist on s3 yet\n if s3_mtime.nil? || File.mtime(source) > s3_mtime\n filename = data[:filename]\n digest = data[:digest].presence\n File.open(source, 'rb') do |file_obj|\n if file_obj.size > Setting.attachment_max_size.to_i.kilobytes\n puts \"File #{target} cannot be uploaded because it exceeds the maximum allowed file size (#{Setting.attachment_max_size.to_i.kilobytes})\"\n return\n end\n content_type = IO.popen([\"file\", \"--brief\", \"--mime-type\", file_obj.path], in: :close, err: :close) { |io| io.read.chomp } rescue nil\n content_type ||= 'application/octet-stream'\n RedmicaS3::Connection.put(target, filename, file_obj.read, content_type, {digest: digest})\n end\n\n puts \"Put file #{target}\"\n else\n puts File.basename(source) + ' is up-to-date on S3'\n end\n end", "def update_file_on_s3(file, objects)\n file_path = s3_file_path(file)\n conn = RedmineS3::Connection.conn\n object = objects[file_path]\n\n # get the file modified time, which will stay nil if the file doesn't exist yet\n # we could check if the file exists, but this saves a head request\n s3_mtime = object.last_modified rescue nil \n\n # put it on s3 if the file has been updated or it doesn't exist on s3 yet\n if s3_mtime.nil? || s3_mtime < File.mtime(file)\n fileObj = File.open(file, 'r')\n RedmineS3::Connection.put(file_path, fileObj.read)\n fileObj.close\n\n puts \"Put file \" + File.basename(file)\n else\n puts File.basename(file) + ' is up-to-date on S3'\n end\n end", "def update\n respond_to do |format|\n if @s3config.update(s3config_params)\n flash[:notice] = 's3config has been successfully updated.'\n format.html { redirect_to action: \"index\"}\n format.json { render :show, status: :ok, location: @s3config }\n else\n format.html { render :edit }\n format.json { render json: @s3config.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_put_existing_if_match_star\n request = Http::Request.new(\n 'PUT',\n '/file1',\n { 'If-Match' => '*' },\n 'hello'\n )\n\n response = self.request(request)\n\n assert_equal(204, response.status)\n\n assert_equal(\n 'hello',\n @server.tree.node_for_path('file1').get\n )\n\n assert_equal(\n {\n 'X-Sabre-Version' => [Version::VERSION],\n 'Content-Length' => ['0'],\n 'ETag' => [\"\\\"#{Digest::MD5.hexdigest('hello')}\\\"\"]\n },\n response.headers\n )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /liga_sf3s/1 DELETE /liga_sf3s/1.xml
def destroy @liga_sf3 = LigaSf3.find(params[:id]) @liga_sf3.destroy respond_to do |format| format.html { redirect_to(liga_sf3s_url) } format.xml { head :ok } end end
[ "def destroy\n @bench_test_s3 = BenchTest::S3.find(params[:id])\n @bench_test_s3.destroy\n\n respond_to do |format|\n format.html { redirect_to(bench_test_s3s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @s3_snapshot = S3Snapshot.find(params[:id])\n @s3_snapshot.destroy\n\n respond_to do |format|\n format.html { redirect_to(s3_snapshots_url) }\n format.xml { head :ok }\n end\n end", "def s3_deletefile(filename)\r\n #AWS::S3::S3Object.delete filename, QBUCKET.to_s if AWS::S3::S3Object.exists? filename, QBUCKET.to_s\r\n AWS::S3::S3Object.delete filename, IMAGES_BUCKET.to_s if AWS::S3::S3Object.exists? filename, IMAGES_BUCKET.to_s\r\n end", "def destroy\n if autenticacion == \"admin\"\n @personaje_sf3 = PersonajeSf3.find(params[:id])\n @personaje_sf3.destroy\n\n respond_to do |format|\n format.html { redirect_to(personaje_sf3s_url) }\n format.xml { head :ok }\n end\n end\n end", "def destroy\n @liga_sf4 = LigaSf4.find(params[:id])\n @liga_sf4.destroy\n\n respond_to do |format|\n format.html { redirect_to(liga_sf4s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @nmapfile.remove_nmapxml!\n FileUtils.remove_dir(\"#{Rails.root}/public/uploads/nmapfile/nmapxml/#{@nmapfile.id}\", :force => true)\n @nmapfile.destroy\n respond_to do |format|\n format.html { redirect_to nmapfiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @otml_file = OtrunkExample::OtmlFile.find(params[:id])\n @otml_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(otrunk_example_otml_files_url) }\n format.xml { head :ok }\n end\n end", "def delete_s3_file(file)\n\n bucket = \"prototype-jv\"\n s3_file_path = \"imageuploader/#{file}\"\n s3 = connect_to_s3()\n\n s3.delete_object({\n bucket: bucket,\n key: s3_file_path\n })\n\nend", "def delete!\n @s3.keys(@name).each do |key|\n key.delete\n end\n delete\n end", "def destroy\n @s3_image = S3Image.find(params[:id])\n @s3_image.destroy\n\n respond_to do |format|\n format.html { redirect_to s3_images_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @amazon = Amazon.find(params[:id])\n @amazon.destroy\n\n respond_to do |format|\n format.html { redirect_to(amazons_url) }\n format.xml { head :ok }\n end\n end", "def delete_files\n return if id.nil?\n return unless File.exist?(directory_path)\n\n FileUtils.rm_rf(directory_path)\n s3_delete_files\n end", "def delete(context, name)\n res = context.transport.delete_request(context, \"blobstores/#{name}\")\n\n context.err(res.body) unless res.success?\n end", "def s3_delete_files\n return unless S3_ENABLED\n s3 = AWS::S3.new\n bucket = s3.buckets[s3_bucket_name]\n bucket.objects.with_prefix(\"#{id}/\").each do |obj|\n obj.delete\n end\n end", "def destroy\n @blob = Blob.find(params[:id])\n @blob.destroy\n\n respond_to do |format|\n format.html { redirect_to(blobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @stuprofile = Stuprofile.find(params[:id])\n @stuprofile.destroy\n\n respond_to do |format|\n format.html { redirect_to(stuprofiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pdf3 = Pdf3.find(params[:id])\n @pdf3.destroy\n\n respond_to do |format|\n format.html { redirect_to(pdf3s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @level3.destroy\n respond_to do |format|\n format.html { redirect_to level3s_url, notice: 'Level3 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def test_repeat_while todo parse 'x=0;repeat while x4' assert_equals variables["x"], 5 end
def test_while_loop parse 'c=0;while c<3:c++;beep;done' assert variables["c"]==3 end
[ "def repeat_while(x)\n if x # If the condition was not nil or false\n yield # Run the body of the loop\n retry # Retry and re-evaluate loop condition\n end\nend", "def while_statement\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n\n\n value = nil\n\n\n a = nil\n b = nil\n\n\n begin\n # at line 88:5: WHILE a= expression ( CLOSE | NL (b= statement )* CLOSE )\n match( WHILE, TOKENS_FOLLOWING_WHILE_IN_while_statement_676 )\n @state.following.push( TOKENS_FOLLOWING_expression_IN_while_statement_680 )\n a = expression\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = WhileStatementEval.new(a) \n # <-- action\n end\n\n # at line 89:3: ( CLOSE | NL (b= statement )* CLOSE )\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == CLOSE )\n alt_26 = 1\n elsif ( look_26_0 == NL )\n alt_26 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 26, 0 )\n\n end\n case alt_26\n when 1\n # at line 89:5: CLOSE\n match( CLOSE, TOKENS_FOLLOWING_CLOSE_IN_while_statement_688 )\n\n when 2\n # at line 89:13: NL (b= statement )* CLOSE\n match( NL, TOKENS_FOLLOWING_NL_IN_while_statement_692 )\n # at line 89:16: (b= statement )*\n while true # decision 25\n alt_25 = 2\n look_25_0 = @input.peek( 1 )\n\n if ( look_25_0.between?( IDENT, IF ) || look_25_0 == RETURN || look_25_0 == WHILE )\n alt_25 = 1\n\n end\n case alt_25\n when 1\n # at line 89:17: b= statement\n @state.following.push( TOKENS_FOLLOWING_statement_IN_while_statement_697 )\n b = statement\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value.add_statement(b) \n # <-- action\n end\n\n\n else\n break # out of loop for decision 25\n end\n end # loop for decision 25\n\n match( CLOSE, TOKENS_FOLLOWING_CLOSE_IN_while_statement_704 )\n\n end\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__, 12 )\n\n\n end\n\n return value\n end", "def do_while_statement\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n return_value = DoWhileStatementReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal123 = nil\n string_literal125 = nil\n string_literal128 = nil\n block124 = nil\n clause126 = nil\n statement_end127 = nil\n clause129 = nil\n statement_end130 = nil\n\n tree_for_string_literal123 = nil\n tree_for_string_literal125 = nil\n tree_for_string_literal128 = nil\n stream_DO = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token DO\" )\n stream_WHILE = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token WHILE\" )\n stream_UNTIL = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token UNTIL\" )\n stream_statement_end = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule statement_end\" )\n stream_block = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule block\" )\n stream_clause = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule clause\" )\n begin\n # at line 442:5: 'do' block ( 'while' clause statement_end -> ^( 'while' clause block ) | 'until' clause statement_end -> ^( 'until' clause block ) )\n string_literal123 = match( DO, TOKENS_FOLLOWING_DO_IN_do_while_statement_2926 )\n if @state.backtracking == 0\n stream_DO.add( string_literal123 )\n end\n @state.following.push( TOKENS_FOLLOWING_block_IN_do_while_statement_2928 )\n block124 = block\n @state.following.pop\n if @state.backtracking == 0\n stream_block.add( block124.tree )\n end\n # at line 443:5: ( 'while' clause statement_end -> ^( 'while' clause block ) | 'until' clause statement_end -> ^( 'until' clause block ) )\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == WHILE )\n alt_26 = 1\n elsif ( look_26_0 == UNTIL )\n alt_26 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 26, 0 )\n end\n case alt_26\n when 1\n # at line 443:7: 'while' clause statement_end\n string_literal125 = match( WHILE, TOKENS_FOLLOWING_WHILE_IN_do_while_statement_2936 )\n if @state.backtracking == 0\n stream_WHILE.add( string_literal125 )\n end\n @state.following.push( TOKENS_FOLLOWING_clause_IN_do_while_statement_2938 )\n clause126 = clause\n @state.following.pop\n if @state.backtracking == 0\n stream_clause.add( clause126.tree )\n end\n @state.following.push( TOKENS_FOLLOWING_statement_end_IN_do_while_statement_2940 )\n statement_end127 = statement_end\n @state.following.pop\n if @state.backtracking == 0\n stream_statement_end.add( statement_end127.tree )\n end\n # AST Rewrite\n # elements: clause, block, WHILE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 443:36: -> ^( 'while' clause block )\n # at line 443:39: ^( 'while' clause block )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_WHILE.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_clause.next_tree )\n @adaptor.add_child( root_1, stream_block.next_tree )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end\n when 2\n # at line 444:7: 'until' clause statement_end\n string_literal128 = match( UNTIL, TOKENS_FOLLOWING_UNTIL_IN_do_while_statement_2960 )\n if @state.backtracking == 0\n stream_UNTIL.add( string_literal128 )\n end\n @state.following.push( TOKENS_FOLLOWING_clause_IN_do_while_statement_2962 )\n clause129 = clause\n @state.following.pop\n if @state.backtracking == 0\n stream_clause.add( clause129.tree )\n end\n @state.following.push( TOKENS_FOLLOWING_statement_end_IN_do_while_statement_2964 )\n statement_end130 = statement_end\n @state.following.pop\n if @state.backtracking == 0\n stream_statement_end.add( statement_end130.tree )\n end\n # AST Rewrite\n # elements: block, clause, UNTIL\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 444:36: -> ^( 'until' clause block )\n # at line 444:39: ^( 'until' clause block )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_UNTIL.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_clause.next_tree )\n @adaptor.add_child( root_1, stream_block.next_tree )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end\n end\n # AST Rewrite\n # elements: DO, do_while_statement\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 446:5: -> ^( 'do' $do_while_statement)\n # at line 446:8: ^( 'do' $do_while_statement)\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_DO.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_return_value.next_tree )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end\n \n return return_value\n end", "def parse_while\n pos = position\n keyword(:while) or return\n ws\n cond = parse_condition or expected(\"condition for 'while' block\")\n nolfws; literal(SEMICOLON); nolfws; keyword(:do)\n nolfws;\n exps = parse_opt_defexp\n keyword(:end) or expected(\"expression or 'end' for open 'while' block\")\n return E[pos, :while, cond, [:do]+exps]\n end", "def _WhileTok\n\n _save = self.pos\n while true # sequence\n _tmp = match_string(\"while\")\n unless _tmp\n self.pos = _save\n break\n end\n _save1 = self.pos\n _tmp = apply(:_IdentifierPart)\n _tmp = _tmp ? nil : true\n self.pos = _save1\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_WhileTok unless _tmp\n return _tmp\n end", "def lazy_repeat_code(parsing_code, source_pos)\n #\n original_pos_var = new_unique_variable_name\n result_var = new_unique_variable_name\n #\n code(%{ begin\n while true\n ###\n #{original_pos_var} = yy_context.input.pos\n ### Look ahead.\n #{result_var} = }) + LazyRepeat::UnknownLookAheadCode[source_pos] + code(%{\n yy_context.input.pos = #{original_pos_var}\n break if #{result_var}\n ### Repeat one more time (if possible).\n #{result_var} = }) + parsing_code + code(%{\n if not #{result_var} then\n yy_context.input.pos = #{original_pos_var}\n break\n end\n end\n ### The repetition is always successful.\n true\n end })\n end", "def while_loop\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n\n begin\n # at line 92:13: WHILE LPAREN mega_expression RPAREN block WHILE\n match( WHILE, TOKENS_FOLLOWING_WHILE_IN_while_loop_823 )\n\n # --> action\n $quads.add_jump() \n # <-- action\n\n match( LPAREN, TOKENS_FOLLOWING_LPAREN_IN_while_loop_827 )\n @state.following.push( TOKENS_FOLLOWING_mega_expression_IN_while_loop_829 )\n mega_expression\n @state.following.pop\n match( RPAREN, TOKENS_FOLLOWING_RPAREN_IN_while_loop_831 )\n\n # --> action\n $quads.gotof() \n # <-- action\n\n @state.following.push( TOKENS_FOLLOWING_block_IN_while_loop_835 )\n block\n @state.following.pop\n match( WHILE, TOKENS_FOLLOWING_WHILE_IN_while_loop_837 )\n\n # --> action\n $quads.goto_while() \n # <-- action\n\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__, 11 )\n\n\n end\n\n return \n end", "def while_stmt \n\t\n\t$cst.add_branch(\"WhileStatement\")\n\t\n\tmatch_token(\"T_WHILE\", $tokens[$index])\n\tboolexpr\n\tblock\n\t\n\t$cst.ascend\n\t\nend", "def setup_while\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n cond = @acts[1]\n action_key = @acts[2]\n actions = (action_key.class == String ? TSBS::AnimLoop[action_key] :\n action_key)\n if actions.nil?\n show_action_error(action_key)\n end\n begin\n while eval(cond)\n exe_act = actions.clone\n until exe_act.empty? || @break_action\n @acts = exe_act.shift\n execute_sequence\n end\n end\n rescue StandardError => err\n display_error(\"[#{SEQUENCE_WHILE},]\",err)\n end\n end", "def process_while(exp)\n cond = process exp.shift\n body = process exp.shift\n is_precondition = exp.shift\n CType.bool.unify cond.c_type\n return t(:while, cond, body, is_precondition)\n end", "def test_break_statement_returns_values\n i = 1\n result = while i <= 10\n break i if i % 2 == 0\n i += 1\n end\n\n assert_equal 2, result\n end", "def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 21 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 29:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 21 )\n\n end", "def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 325:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n end", "def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 383:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 29 )\n\n end", "def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 80 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 201:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 80 )\n\n end", "def while_loop\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n\n\n begin\n # at line 183:5: WHILE LPAR super_expression RPAR block WHILE\n match( WHILE, TOKENS_FOLLOWING_WHILE_IN_while_loop_1734 )\n\n # --> action\n $quads.add_jump() \n # <-- action\n\n match( LPAR, TOKENS_FOLLOWING_LPAR_IN_while_loop_1738 )\n @state.following.push( TOKENS_FOLLOWING_super_expression_IN_while_loop_1740 )\n super_expression\n @state.following.pop\n match( RPAR, TOKENS_FOLLOWING_RPAR_IN_while_loop_1742 )\n\n # --> action\n $quads.gotof() \n # <-- action\n\n @state.following.push( TOKENS_FOLLOWING_block_IN_while_loop_1746 )\n block\n @state.following.pop\n match( WHILE, TOKENS_FOLLOWING_WHILE_IN_while_loop_1748 )\n\n # --> action\n $quads.goto_while()\n # <-- action\n\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__, 17 )\n\n\n end\n\n return \n end", "def on_while(predicate, statements); end", "def loop\n skip_token(\"do\")\n if current_tk.value == \"while\" then\n skip_token(\"while\")\n condition = simple_exp(:EOL,\"{\")\n bk = block\n return Statement.while_statement(condition,bk) \n else\n bk = block(true)\n skip_token(\"until\")\n condition = simple_exp\n return Statement.until_statement(condition,bk)\n end\n end", "def rewrite_while(expression)\n condition = expression[1]\n body = expression[2]\n \n # This was a true in the example I checked (in sexps_while.txt)\n # but I'm not sure what it's for.\n third = expression[3]\n if third != true # Should be true, not just a truthy object\n raise UnexpectedSexp, 'Expected true as the 3rd element in a while, ' +\n \"but got #{third}, this is probably a bug.\"\n end\n\n s(:call,\n s(:colon2,\n s(:const, :VirtualKeywords),\n :REWRITTEN_KEYWORDS\n ), :call_while,\n s(:array,\n s(:self),\n s(:iter, s(:fcall, :lambda), nil, condition),\n s(:iter, s(:fcall, :lambda), nil, body)\n )\n )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
convert_type_to_s convert Ruby collection objects fed into the query into sql strings
def convert_type_to_s(arg , sql_type) case sql_type when :between case arg when Range , Array "#{sql_stringify_value(arg.first)} AND #{sql_stringify_value(arg.last)}" else raise "Type not found..." end when :in case arg when Range , Array " (#{arg.collect{|e| "#{sql_stringify_value(e)}"}.join(" , ")}) " else raise "Type not found..." end else case arg when Range , Array arg.collect{|e| "#{sql_stringify_value(e)}"}.join(" , ") else sql_stringify_value(arg) end end end
[ "def type_to_sql(type, limit: nil, precision: nil, scale: nil, array: nil, **)\n case type.to_s\n when \"geometry\", \"geography\"\n \"#{type}(#{limit})\"\n else\n super\n end\n end", "def cast_string(sql_type = nil)\n cast(sql_type || :text).sql_string\n end", "def cast_string(arg, sql_type = nil)\n cast(arg, sql_type || String).sql_string\n end", "def sql_type; end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:\n if type == :enum\n native = native_database_types[type]\n column_type_sql = native[:name] || 'enum'\n \n column_type_sql << \"(#{limit.map { |v| quote(v) }.join(',')})\"\n column_type_sql \n else\n # Edge rails fallback for Rails 1.1.6. We can remove the\n # rescue once everyone has upgraded to 1.2.\n begin\n __type_to_sql_enum(type, limit, precision, scale)\n rescue ArgumentError\n __type_to_sql_enum(type, limit)\n end\n end\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n case type\n when :geometry, :geography\n \"#{type}(#{limit})\"\n else\n super\n end\n end", "def cast_records!(*types, **options)\n where!(regclass.cast(:varchar).in(types.map(&:table_name))) if options[:filter]\n self.select_extra_values += [regclass.as(_record_class_attribute.to_s)]\n self.cast_records_value = (types.present? ? types : model.casted_dependents.values)\n self\n end", "def sql_type=(_); end", "def to_sql\n raise NotImplementedError\n end", "def objects_to_sql(objects)\n\t\tif objects.nil? || objects.size < 1 then\n\t\t\treturn []\n\t\tend\n\t\n\t\tobjects.each do |object|\n\t\t\toutput << object.to_sql\n\t\tend\n\t\t\n\t\treturn output\n\tend", "def pyspark_cast_type(sql_type)\n if sql_type =~ /char.*\\(\\d+\\)/i then 'string'\n elsif sql_type =~ /tinyint/i then 'byte'\n elsif sql_type =~ /smallint/i then 'short'\n elsif sql_type =~ /^int|^integer/i then 'integer'\n elsif sql_type =~ /bigint/i then 'long'\n elsif sql_type =~ /boolean/i then 'boolean'\n elsif sql_type =~ /float/i then 'float'\n elsif sql_type =~ /double/i then 'double'\n elsif sql_type =~ /datetime|timestamp/i then 'timestamp'\n elsif sql_type =~ /date/i then 'date'\n elsif sql_type =~ /(numeric|decimal)\\(\\d+,\\d+\\)/i\n then sql_type.gsub(/numeric|decimal/i, 'decimal')\n else raise 'data type error'\n end\n end", "def to_sql_array options = {}\n options = {\n type: :text\n }.merge options\n\n 'ARRAY[' + self.collect { |x|\n if x.is_a?(Array)\n x.join.to_sql_array(options)\n else\n x.to_sql_array(options)\n end\n }.join(',') + ']'\n end", "def bulk_insert_values_str( db_type )\n fields = sql_row_type.field_names\n \"(#{fields.map {|f| sql_for(f, db_type) }.join(', ')})\"\n end", "def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:\n if type.to_s == 'enum'\n native = native_database_types[type]\n column_type_sql = (native || {})[:name] || 'enum'\n\n column_type_sql << \"(#{limit.map { |v| quote(v) }.join(',')})\"\n\n column_type_sql\n else\n super(type, limit: limit, precision: precision, scale: scale, unsigned: unsigned)\n end\n end", "def cast_sql_append(sql, expr, type)\n sql << 'CAST('\n literal_append(sql, expr)\n sql << ' AS ' << db.cast_type_literal(type).to_s\n sql << ')'\n end", "def to_sql(options = {})\n case value\n when nil then 'NULL'\n when String then quote_str(@value)\n when Numeric then @value.to_s\n when Date then @value.strftime(\"'%Y-%m-%d'\")\n when DateTime, Time then @value.strftime(\"'%Y-%m-%d %H:%M:%S'\")\n else raise \"Don't know how te represent this value in SQL!\"\n end\n end", "def to_sql\n raise NotImplementedError, \"Comparison#to_sql must be defined by subclasses\"\n end", "def to_s\n to_gql\n end", "def sql_literal_append(ds, sql)\n sql << db_type << '('\n joiner = nil\n conversion_meth = nil\n each do |range|\n if joiner\n sql << joiner\n else\n joiner = ', '\n end\n\n unless range.is_a?(PGRange)\n conversion_meth ||= :\"typecast_value_#{db_type.sub('multi', '')}\"\n range = ds.db.send(conversion_meth, range)\n end\n\n ds.literal_append(sql, range)\n end\n sql << ')'\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
classify_sql determine if this sql has a between or in
def classify_sql(sql) case when sql[/between.+\?/i] #var should be an array :between when sql[/\sin\s+\?/i] :in end end
[ "def range_inclusion_sql(inclusion)\n if inclusion.right.exclude_end?\n exclusive_range_inclusion_sql(inclusion)\n else\n inclusive_range_sql(BETWEEN, inclusion)\n end\n end", "def exclusive_range_inclusion_sql(inclusion)\n left = new_from_enumerable_predicate(Axiom::Function::Predicate::GreaterThanOrEqualTo, inclusion, :first)\n right = new_from_enumerable_predicate(Axiom::Function::Predicate::LessThan, inclusion, :last)\n dispatch left.and(right)\n end", "def condition_between\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 214 )\n return_value = ConditionBetweenReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n condition_between_start_index = @input.index\n\n root_0 = nil\n string_literal1199 = nil\n string_literal1200 = nil\n string_literal1202 = nil\n sql_expression1198 = nil\n sql_expression1201 = nil\n sql_expression1203 = nil\n\n tree_for_string_literal1199 = nil\n tree_for_string_literal1200 = nil\n tree_for_string_literal1202 = 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 return_value\n end\n root_0 = @adaptor.create_flat_list\n\n\n # at line 1105:4: sql_expression ( 'NOT' )? 'BETWEEN' sql_expression 'AND' sql_expression\n @state.following.push( TOKENS_FOLLOWING_sql_expression_IN_condition_between_7169 )\n sql_expression1198 = sql_expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, sql_expression1198.tree )\n end\n # at line 1105:19: ( 'NOT' )?\n alt_314 = 2\n look_314_0 = @input.peek( 1 )\n\n if ( look_314_0 == T__57 )\n alt_314 = 1\n end\n case alt_314\n when 1\n # at line 1105:21: 'NOT'\n string_literal1199 = match( T__57, TOKENS_FOLLOWING_T__57_IN_condition_between_7173 )\n if @state.backtracking == 0\n\n tree_for_string_literal1199 = @adaptor.create_with_payload( string_literal1199 )\n @adaptor.add_child( root_0, tree_for_string_literal1199 )\n\n end\n\n end\n string_literal1200 = match( T__139, TOKENS_FOLLOWING_T__139_IN_condition_between_7178 )\n if @state.backtracking == 0\n\n tree_for_string_literal1200 = @adaptor.create_with_payload( string_literal1200 )\n @adaptor.add_child( root_0, tree_for_string_literal1200 )\n\n end\n @state.following.push( TOKENS_FOLLOWING_sql_expression_IN_condition_between_7180 )\n sql_expression1201 = sql_expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, sql_expression1201.tree )\n end\n string_literal1202 = match( T__138, TOKENS_FOLLOWING_T__138_IN_condition_between_7182 )\n if @state.backtracking == 0\n\n tree_for_string_literal1202 = @adaptor.create_with_payload( string_literal1202 )\n @adaptor.add_child( root_0, tree_for_string_literal1202 )\n\n end\n @state.following.push( TOKENS_FOLLOWING_sql_expression_IN_condition_between_7184 )\n sql_expression1203 = sql_expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, sql_expression1203.tree )\n end\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 214 )\n memoize( __method__, condition_between_start_index, success ) if @state.backtracking > 0\n\n end\n \n return return_value\n end", "def between?(p0, p1) end", "def between?(x,y) end", "def sql(options = {})\n ret = \"\"\n if exact_ip?\n ret += \"INET_ATON(#{column}) = INET_ATON('#{self.range}') \"\n else\n ret += \"INET_ATON(#{column}) >= INET_ATON('#{self.range.first}') AND \"\n ret += \"INET_ATON(#{column}) <= INET_ATON('#{self.range.last}') \"\n end\n return ret\n end", "def condition_string(starts_at_attr, ends_at_attr)\n except_option = Array(options[:exclude_edges]).map(&:to_s)\n starts_at_sign = except_option.include?(starts_at_attr.split(\".\").last) ? \"<\" : \"<=\" \n ends_at_sign = except_option.include?(ends_at_attr.split(\".\").last) ? \">\" : \">=\"\n \"#{ends_at_attr} #{ends_at_sign} :starts_at_value AND #{starts_at_attr} #{starts_at_sign} :ends_at_value\"\n end", "def within?(val,lower,upper)\n\n check_pre((\n (val.nat?) and\n (lower.nat?) and\n (upper.nat?)\n ))\n\n (val >= lower) and (val <= upper)\n\n end", "def inclusive_range_sql(operator, predicate)\n right = predicate.right\n \"#{dispatch(predicate.left)} #{operator} #{dispatch(right.first)} AND #{dispatch(right.last)}\"\n end", "def attendance_between_dates_condition\n\t\t\"attendances.attendance_on BETWEEN '#{start_on}' AND '#{end_on}'\"\n\tend", "def condition_string(starts_at_attr, ends_at_attr)\n except_option = Array(options[:exclude_edges]).map(&:to_s)\n starts_at_sign = except_option.include?(starts_at_attr.to_s.split(\".\").last) ? \"<\" : \"<=\"\n ends_at_sign = except_option.include?(ends_at_attr.to_s.split(\".\").last) ? \">\" : \">=\"\n query = []\n query << \"(#{ends_at_attr} IS NULL OR #{ends_at_attr} #{ends_at_sign} :starts_at_value)\"\n query << \"(#{starts_at_attr} IS NULL OR #{starts_at_attr} #{starts_at_sign} :ends_at_value)\"\n query.join(\" AND \")\n end", "def between?(num, x, y)\n\nend", "def range_exclusion_sql(exclusion)\n if exclusion.right.exclude_end?\n exclusive_range_exclusion_sql(exclusion)\n else\n inclusive_range_sql(NOT_BETWEEN, exclusion)\n end\n end", "def within?(val, lower, upper)\n check_pre((\n (val.int?) and\n (lower.int?) and\n (upper.int?)\n ))\n\n ((val >= lower) and (val <= upper))\nend", "def valid_criteria_type_for_conditional_formatting\n {\n 'between' => 'between',\n 'not between' => 'notBetween',\n 'equal to' => 'equal',\n '=' => 'equal',\n '==' => 'equal',\n 'not equal to' => 'notEqual',\n '!=' => 'notEqual',\n '<>' => 'notEqual',\n 'greater than' => 'greaterThan',\n '>' => 'greaterThan',\n 'less than' => 'lessThan',\n '<' => 'lessThan',\n 'greater than or equal to' => 'greaterThanOrEqual',\n '>=' => 'greaterThanOrEqual',\n 'less than or equal to' => 'lessThanOrEqual',\n '<=' => 'lessThanOrEqual',\n 'containing' => 'containsText',\n 'not containing' => 'notContains',\n 'begins with' => 'beginsWith',\n 'ends with' => 'endsWith',\n 'yesterday' => 'yesterday',\n 'today' => 'today',\n 'last 7 days' => 'last7Days',\n 'last week' => 'lastWeek',\n 'this week' => 'thisWeek',\n 'next week' => 'nextWeek',\n 'last month' => 'lastMonth',\n 'this month' => 'thisMonth',\n 'next month' => 'nextMonth'\n }\n end", "def arel_exclude(start_column, end_column, start_or_instant_or_range=nil, range_end=nil)\n table = self.arel_table\n if range_end\n table[start_column].gteq(range_end).or(table[end_column].lteq(start_or_instant_or_range))\n elsif Range === start_or_instant_or_range\n table[start_column].gteq(start_or_instant_or_range.db_end).or(table[end_column].lteq(start_or_instant_or_range.db_begin))\n else\n start_or_instant_or_range ||= InfinityLiteral\n table[start_column].gt(start_or_instant_or_range).or(table[end_column].lteq(start_or_instant_or_range))\n end\n end", "def compare_expr(l, r)\n case r\n when Range\n \"(#{literal(l)} >= #{literal(r.begin)} AND #{literal(l)} <#{'=' unless r.exclude_end?} #{literal(r.end)})\"\n when Array, Sequel::Dataset\n \"(#{literal(l)} IN #{literal(r)})\"\n when NilClass\n \"(#{literal(l)} IS NULL)\"\n when Regexp\n collate_match_expr(l, r)\n else\n \"(#{literal(l)} = #{literal(r)})\"\n end\n end", "def between_text_as_param?\n @tag_definition[:require_between]\n end", "def sql_to_highlight(sql)\n # wrap sql @ 120\n width = 120\n ar = sql.gsub(/from /i, \"\\nFROM \").gsub(/where /i, \"\\nWHERE \").gsub(/(left outer join |left join |inner join |join )/i, \"\\n\\\\1\").split(\"\\n\")\n wrapped_sql = ar.map { |a| a.scan(/\\S.{0,#{width - 2}}\\S(?=\\s|$)|\\S+/).join(\"\\n\") }.join(\"\\n\")\n\n theme = Rouge::Themes::Github.new\n formatter = Rouge::Formatters::HTMLInline.new(theme)\n lexer = Rouge::Lexers::SQL.new\n formatter.format(lexer.lex(wrapped_sql))\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /eces/new GET /eces/new.xml
def new @ece = Ece.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @ece } end end
[ "def new\n @eep = Eep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @eep }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @stes_e = StesE.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stes_e }\n end\n end", "def new\n @ep = Ep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ep }\n end\n end", "def new\n @escola = Escola.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @escola }\n end\n end", "def new\n @episodio = Episodio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @episodio }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @estoques = Estoque.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estoques }\n end\n end", "def new\n @ceo = Ceo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ceo }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asesoria }\n end\n end", "def new\n @ecnposition = Ecnposition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ecnposition }\n end\n end", "def new\n @efectivo = Efectivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @efectivo }\n end\n end", "def new\n @estagio = Estagio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagio }\n end\n end", "def new\n @elinea = Elinea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @elinea }\n end\n end", "def new\n @estoque = Estoque.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estoque }\n end\n end", "def new\n @entree = Entree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entree }\n end\n end", "def new\n @peca = Peca.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peca }\n end\n end", "def new\n @etd = Etd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @etd }\n end\n end", "def new\n @era = Era.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @era }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finalizer for the rackspace autoscaling group resource. Extracts metadata and maps into customized personality to provide bootstraping some what similar to heat bootstrap.
def rackspace_asg_finalizer(resource_name, new_resource, old_resource) new_resource['Properties'] = {}.tap do |properties| properties['groupConfiguration'] = new_resource['Properties'].merge('name' => resource_name) properties['launchConfiguration'] = {}.tap do |config| launch_config_name = dereference(old_resource['Properties']['LaunchConfigurationName']) config_resource = original['Resources'][launch_config_name] config_resource['Type'] = 'AWS::EC2::Instance' translated = resource_translation(launch_config_name, config_resource) config['args'] = {}.tap do |lnch_args| lnch_args['server'] = {}.tap do |srv| srv['name'] = launch_config_name RACKSPACE_ASG_SRV_MAP.each do |k, v| srv[k] = translated['Properties'][v] end srv['personality'] = build_personality(config_resource) end end config['type'] = 'launch_server' end end end
[ "def rackspace_asg_finalizer(resource_name, new_resource, old_resource)\n new_resource[\"Properties\"] = {}.tap do |properties|\n if lbs = new_resource[\"Properties\"].delete(\"load_balancers\")\n properties[\"load_balancers\"] = lbs\n end\n properties[\"groupConfiguration\"] = new_resource[\"Properties\"].merge(\"name\" => resource_name)\n properties[\"launchConfiguration\"] = {}.tap do |config|\n launch_config_name = resource_name(old_resource[\"Properties\"][\"LaunchConfigurationName\"])\n config_resource = original[\"Resources\"][launch_config_name]\n config_resource[\"Type\"] = \"AWS::EC2::Instance\"\n translated = resource_translation(launch_config_name, config_resource)\n config[\"args\"] = {}.tap do |lnch_args|\n lnch_args[\"server\"] = {}.tap do |srv|\n srv[\"name\"] = launch_config_name\n RACKSPACE_ASG_SRV_MAP.each do |k, v|\n srv[k] = translated[\"Properties\"][v]\n end\n srv[\"personality\"] = build_personality(config_resource)\n end\n end\n config[\"type\"] = \"launch_server\"\n end\n end\n end", "def zero_autoscale_group\n Tapjoy::AutoscalingBootstrap::AWS::Autoscaling::Group.resize\n\n wait_for_asg_to_quiet\n\n Tapjoy::AutoscalingBootstrap::AWS::Autoscaling::Group.delete\n\n wait_for_asg_to_delete\n\n abort(\"#{@scaler_name} still exists\") if exists\n end", "def finalize\n @container = boot.finalize\n self\n ensure\n @boot = nil\n end", "def init_groups\n @@client.describe_auto_scaling_groups.auto_scaling_groups\n end", "def remove_auto_scaling_group_properties\n properties = []\n properties << :AvailabilityZones\n properties << :HealthCheckGracePeriod\n properties << :HealthCheckType\n add_patch Patches::RemoveProperty.new 'AWS::AutoScaling::AutoScalingGroup', properties\n end", "def finalize!\n return unless started\n\n strategies.each(&:before_finalize)\n\n return unless map.size.positive?\n\n example_groups = (configuration.compact_map? ? MapCompactor.compact_map!(map) : map).example_groups\n map_storage.dump(example_groups)\n end", "def finalize\n @registry.finalize\n self\n end", "def rackspace_lb_finalizer(resource_name, new_resource, old_resource)\n listeners = new_resource[\"Properties\"].delete(\"listeners\") || []\n source_listener = listeners.shift\n if source_listener\n new_resource[\"Properties\"][\"port\"] = source_listener[\"LoadBalancerPort\"]\n if [\"HTTP\", \"HTTPS\"].include?(source_listener[\"Protocol\"])\n new_resource[\"Properties\"][\"protocol\"] = source_listener[\"Protocol\"]\n else\n new_resource[\"Properties\"][\"protocol\"] = \"TCP_CLIENT_FIRST\"\n end\n new_resource[\"cache_instance_port\"] = source_listener[\"InstancePort\"]\n end\n new_resource[\"Properties\"][\"virtualIps\"] = [\"type\" => \"PUBLIC\", \"ipVersion\" => \"IPV4\"]\n new_resource[\"Properties\"][\"nodes\"] = [] unless new_resource[\"Properties\"][\"nodes\"]\n health_check = new_resource[\"Properties\"].delete(\"health_check\")\n health_check = nil\n if health_check\n new_resource[\"Properties\"][\"healthCheck\"] = {}.tap do |check|\n check[\"timeout\"] = health_check[\"Timeout\"]\n check[\"attemptsBeforeDeactivation\"] = health_check[\"UnhealthyThreshold\"]\n check[\"delay\"] = health_check[\"Interval\"]\n check_target = dereference_processor(health_check[\"Target\"])\n check_args = check_target.split(\":\")\n check_type = check_args.shift\n if check_type == \"HTTP\" || check_type == \"HTTPS\"\n check[\"type\"] = check_type\n check[\"path\"] = check_args.last\n else\n check[\"type\"] = \"TCP_CLIENT_FIRST\"\n end\n end\n end\n unless listeners.empty?\n listeners.each_with_index do |listener, idx|\n port = listener[\"LoadBalancerPort\"]\n proto = [\"HTTP\", \"HTTPS\"].include?(listener[\"Protocol\"]) ? listener[\"Protocol\"] : \"TCP_CLIENT_FIRST\"\n vip_name = \"#{resource_name}Vip#{idx}\"\n vip_resource = MultiJson.load(MultiJson.dump(new_resource))\n vip_resource[\"Properties\"][\"name\"] = vip_name\n vip_resource[\"Properties\"][\"protocol\"] = proto\n vip_resource[\"Properties\"][\"port\"] = port\n vip_resource[\"Properties\"][\"virtualIps\"] = [\n \"id\" => {\n \"get_attr\" => [\n resource_name,\n \"virtualIps\",\n 0,\n \"id\",\n ],\n },\n ]\n vip_resource[\"cache_instance_port\"] = listener[\"InstancePort\"]\n translated[\"Resources\"][vip_name] = vip_resource\n end\n end\n end", "def finalize\n package_sets.each do |pkg_set|\n meta = Autoproj.manifest.metapackages[pkg_set.name]\n meta_package_names = meta.each_package.inject(Set.new) { |s, p| s << p.name }\n\n if current_flavor.implicit?\n in_a_flavor = flavors.values.inject(Set.new) do |pkgs, other_flavor| \n pkgs | other_flavor.default_packages[pkg_set.name]\n end\n default_packages = (meta_package_names - in_a_flavor) |\n current_flavor.default_packages[pkg_set.name]\n else\n default_packages = current_flavor.default_packages[pkg_set.name]\n end\n default_packages -= current_flavor.removed_packages\n default_packages = default_packages.to_set\n current_flavor.default_packages[pkg_set.name] = default_packages\n\n (meta_package_names - default_packages).each do |pkg_name|\n meta.remove(pkg_name)\n end\n end\n end", "def finalize!\n @container_const_name ||= Dry::Rails::Container.container_constant\n\n stop_features if reloading?\n\n root_path = ::Rails.root\n\n container = Dry::Rails.create_container(\n root: root_path,\n inflector: default_inflector,\n provider_dirs: [root_path.join(\"config/system/boot\")]\n )\n\n # Enable :env plugin by default because it is a very common requirement\n container.use :env, inferrer: -> { ::Rails.env }\n\n container.register(:railtie, self)\n container.register(:inflector, default_inflector)\n\n # Remove previously defined constants, if any, so we don't end up with\n # unsused constants in app's namespace when a name change happens.\n remove_constant(container.auto_inject_constant)\n remove_constant(container.container_constant)\n\n Dry::Rails.evaluate_initializer(container)\n\n @container_const_name = container.container_constant\n\n set_or_reload(container.container_constant, container)\n set_or_reload(container.auto_inject_constant, container.injector)\n\n container.features.each do |feature|\n container.register_provider(feature, from: :rails)\n end\n\n container.refresh_provider_files if reloading?\n\n container.finalize!(freeze: !::Rails.env.test?)\n end", "def release\n @hooks.clear\n @instance_supervisor.clear\n @singleton_supervisor.clear\n self\n end", "def teardown\n raise \"Only Ec2 teardown supported\" unless cloud_provider.name.to_s == 'ec2'\n puts \"! Tearing down cloud #{name}\"\n # load_balancers.each do |name, lb|\n # puts \"! Deleting load_balaner #{lb_name}\"\n # lb.teardown\n # end\n load_balancers.each do |lb|\n puts \"-----> Tearing down load balancer: #{lb.name}\"\n lb.teardown\n end\n\n rds_instances.each do |rds|\n puts \"-----> Tearing down RDS Instance: #{rds.name}\"\n rds.teardown\n end\n # instances belonging to an auto_scaling group must be deleted before the auto_scaling group\n #THIS SCARES ME! nodes.each{|n| n.terminate_instance!}\n # loop {nodes.size>0 ? sleep(4) : break }\n if autoscalers.empty?\n nodes.each do |node|\n node.terminate!\n end\n else\n autoscalers.each do |a|\n puts \"-----> Tearing down autoscaler #{a.name}\"\n a.teardown\n end\n end\n # autoscalers.keys.each do |as_name|\n # puts \"! Deleting auto_scaling_group #{as_name}\"\n # cloud_provider.as.delete_autoscaling_group('AutoScalingGroupName' => as_name)\n # end\n #TODO: keypair.delete # Do we want to delete the keypair? probably, but not certain\n end", "def build_ami(instance)\n provision(instance)\n logger.info { \"Finalizing changes for #{self.region} AMI...\" }\n self.agent_ami = register_hailstorm_ami(instance)\n logger.info { \"New AMI##{self.agent_ami} on #{self.region} created successfully, cleaning up...\" }\n end", "def zero_autoscale\n autoscale = AWS::AutoScaling.new(:region => @task.region)\n cf_stack.resources.each do |resource|\n next unless resource.logical_resource_id == 'ScalingGroup'\n\n scale_group = autoscale.groups[resource.physical_resource_id]\n if scale_group.min_size == 0 && scale_group.max_size == 0\n @task.debug { \"Stack #{@name} scale group #{scale_group.name} already zeroed\" }\n next\n end\n\n @task.unsafe(\"Change autoscale #{resource.physical_resource_id} to zero\") do\n s3_object = s3_bucket.objects[\"cloudformation/#{@name}/autoscale/#{scale_group.name}.json\"]\n s3_object.write JSON.generate(\n :min_size => scale_group.min_size,\n :max_size => scale_group.max_size,\n :desired_capacity => scale_group.desired_capacity\n )\n scale_group.update(:min_size => 0, :max_size => 0, :desired_capacity => 0)\n end\n end\n end", "def finalize!\n freeze\n config.finalize!\n end", "def clear_runtime\n @runtime_groups.each do |name, group|\n group.release_all\n end\n self\n end", "def postBoot(instance_id = nil)\n if !instance_id.nil?\n @cloud_id = instance_id\n end\n node, config, deploydata = describe(cloud_id: @cloud_id)\n instance = cloud_desc\n raise MuError, \"Couldn't find instance #{@mu_name} (#{@cloud_id})\" if !instance\n @cloud_id = instance.instance_id\n return false if !MU::MommaCat.lock(instance.instance_id+\"-orchestrate\", true)\n return false if !MU::MommaCat.lock(instance.instance_id+\"-groom\", true)\n\n MU::MommaCat.createStandardTags(instance.instance_id, region: @config['region'], credentials: @config['credentials'])\n MU::MommaCat.createTag(instance.instance_id, \"Name\", node, region: @config['region'], credentials: @config['credentials'])\n\n if @config['optional_tags']\n MU::MommaCat.listOptionalTags.each { |key, value|\n MU::MommaCat.createTag(instance.instance_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n if !@config['tags'].nil?\n @config['tags'].each { |tag|\n MU::MommaCat.createTag(instance.instance_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])\n }\n end\n MU.log \"Tagged #{node} (#{instance.instance_id}) with MU-ID=#{MU.deploy_id}\", MU::DEBUG\n\n # Make double sure we don't lose a cached mu_windows_name value.\n if windows? or !@config['active_directory'].nil?\n if @mu_windows_name.nil?\n @mu_windows_name = deploydata['mu_windows_name']\n end\n end\n\n retries = -1\n max_retries = 30\n begin\n if instance.nil? or instance.state.name != \"running\"\n retries = retries + 1\n if !instance.nil? and instance.state.name == \"terminated\"\n raise MuError, \"#{@cloud_id} appears to have been terminated mid-bootstrap!\"\n end\n if retries % 3 == 0\n MU.log \"Waiting for EC2 instance #{node} (#{@cloud_id}) to be ready...\", MU::NOTICE\n end\n sleep 40\n # Get a fresh AWS descriptor\n instance = MU::Cloud::Server.find(cloud_id: @cloud_id, region: @config['region'], credentials: @config['credentials']).values.first\n if instance and instance.state.name == \"terminated\"\n raise MuError, \"EC2 instance #{node} (#{@cloud_id}) terminating during bootstrap!\"\n end\n end\n rescue Aws::EC2::Errors::ServiceError => e\n if retries < max_retries\n MU.log \"Got #{e.inspect} during initial instance creation of #{@cloud_id}, retrying...\", MU::NOTICE, details: instance\n retries = retries + 1\n retry\n else\n raise MuError, \"Too many retries creating #{node} (#{e.inspect})\"\n end\n end while instance.nil? or (instance.state.name != \"running\" and retries < max_retries)\n\n punchAdminNAT\n\n\n # If we came up via AutoScale, the Alarm module won't have had our\n # instance ID to associate us with itself. So invoke that here.\n # XXX might be possible to do this with regular alarm resources and\n # dependencies now\n if !@config['basis'].nil? and @config[\"alarms\"] and !@config[\"alarms\"].empty?\n @config[\"alarms\"].each { |alarm|\n alarm_obj = MU::MommaCat.findStray(\n \"AWS\",\n \"alarms\",\n region: @config[\"region\"],\n deploy_id: @deploy.deploy_id,\n name: alarm['name']\n ).first\n alarm[\"dimensions\"] = [{:name => \"InstanceId\", :value => @cloud_id}]\n\n if alarm[\"enable_notifications\"]\n topic_arn = MU::Cloud::AWS::Notification.createTopic(alarm[\"notification_group\"], region: @config[\"region\"], credentials: @config['credentials'])\n MU::Cloud::AWS::Notification.subscribe(arn: topic_arn, protocol: alarm[\"notification_type\"], endpoint: alarm[\"notification_endpoint\"], region: @config[\"region\"], credentials: @config[\"credentials\"])\n alarm[\"alarm_actions\"] = [topic_arn]\n alarm[\"ok_actions\"] = [topic_arn]\n end\n\n alarm_name = alarm_obj ? alarm_obj.cloud_id : \"#{node}-#{alarm['name']}\".upcase\n\n MU::Cloud::AWS::Alarm.setAlarm(\n name: alarm_name,\n ok_actions: alarm[\"ok_actions\"],\n alarm_actions: alarm[\"alarm_actions\"],\n insufficient_data_actions: alarm[\"no_data_actions\"],\n metric_name: alarm[\"metric_name\"],\n namespace: alarm[\"namespace\"],\n statistic: alarm[\"statistic\"],\n dimensions: alarm[\"dimensions\"],\n period: alarm[\"period\"],\n unit: alarm[\"unit\"],\n evaluation_periods: alarm[\"evaluation_periods\"],\n threshold: alarm[\"threshold\"],\n comparison_operator: alarm[\"comparison_operator\"],\n region: @config[\"region\"],\n credentials: @config['credentials']\n )\n }\n end\n\n # We have issues sometimes where our dns_records are pointing at the wrong node name and IP address.\n # Make sure that doesn't happen. Happens with server pools only\n if @config['dns_records'] && !@config['dns_records'].empty?\n @config['dns_records'].each { |dnsrec|\n if dnsrec.has_key?(\"name\")\n if dnsrec['name'].start_with?(MU.deploy_id.downcase) && !dnsrec['name'].start_with?(node.downcase)\n MU.log \"DNS records for #{node} seem to be wrong, deleting from current config\", MU::WARN, details: dnsrec\n dnsrec.delete('name')\n dnsrec.delete('target')\n end\n end\n }\n end\n\n # Unless we're planning on associating a different IP later, set up a\n # DNS entry for this thing and let it sync in the background. We'll come\n # back to it later.\n if @config['static_ip'].nil? && !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n if !@config['src_dst_check'] and !@config[\"vpc\"].nil?\n MU.log \"Disabling source_dest_check #{node} (making it NAT-worthy)\"\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).modify_instance_attribute(\n instance_id: @cloud_id,\n source_dest_check: {:value => false}\n )\n end\n\n # Set console termination protection. Autoscale nodes won't set this\n # by default.\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).modify_instance_attribute(\n instance_id: @cloud_id,\n disable_api_termination: {:value => true}\n )\n\n has_elastic_ip = false\n if !instance.public_ip_address.nil?\n begin\n resp = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_addresses(public_ips: [instance.public_ip_address])\n if resp.addresses.size > 0 and resp.addresses.first.instance_id == @cloud_id\n has_elastic_ip = true\n end\n rescue Aws::EC2::Errors::InvalidAddressNotFound => e\n # XXX this is ok to ignore, it means the public IP isn't Elastic\n end\n end\n\n win_admin_password = nil\n ec2config_password = nil\n sshd_password = nil\n if windows?\n ssh_keydir = \"#{Etc.getpwuid(Process.uid).dir}/.ssh\"\n ssh_key_name = @deploy.ssh_key_name\n\n if @config['use_cloud_provider_windows_password']\n win_admin_password = getWindowsAdminPassword\n elsif @config['windows_auth_vault'] && !@config['windows_auth_vault'].empty?\n if @config[\"windows_auth_vault\"].has_key?(\"password_field\")\n win_admin_password = @groomer.getSecret(\n vault: @config['windows_auth_vault']['vault'],\n item: @config['windows_auth_vault']['item'],\n field: @config[\"windows_auth_vault\"][\"password_field\"]\n )\n else\n win_admin_password = getWindowsAdminPassword\n end\n\n if @config[\"windows_auth_vault\"].has_key?(\"ec2config_password_field\")\n ec2config_password = @groomer.getSecret(\n vault: @config['windows_auth_vault']['vault'],\n item: @config['windows_auth_vault']['item'],\n field: @config[\"windows_auth_vault\"][\"ec2config_password_field\"]\n )\n end\n\n if @config[\"windows_auth_vault\"].has_key?(\"sshd_password_field\")\n sshd_password = @groomer.getSecret(\n vault: @config['windows_auth_vault']['vault'],\n item: @config['windows_auth_vault']['item'],\n field: @config[\"windows_auth_vault\"][\"sshd_password_field\"]\n )\n end\n end\n\n win_admin_password = MU.generateWindowsPassword if win_admin_password.nil?\n ec2config_password = MU.generateWindowsPassword if ec2config_password.nil?\n sshd_password = MU.generateWindowsPassword if sshd_password.nil?\n\n # We're creating the vault here so when we run\n # MU::Cloud::Server.initialSSHTasks and we need to set the Windows\n # Admin password we can grab it from said vault.\n creds = {\n \"username\" => @config['windows_admin_username'],\n \"password\" => win_admin_password,\n \"ec2config_username\" => \"ec2config\",\n \"ec2config_password\" => ec2config_password,\n \"sshd_username\" => \"sshd_service\",\n \"sshd_password\" => sshd_password\n }\n @groomer.saveSecret(vault: @mu_name, item: \"windows_credentials\", data: creds, permissions: \"name:#{@mu_name}\")\n end\n\n subnet = nil\n if !@vpc.nil? and @config.has_key?(\"vpc\") and !instance.subnet_id.nil?\n subnet = @vpc.getSubnet(\n cloud_id: instance.subnet_id\n )\n if subnet.nil?\n raise MuError, \"Got null subnet id out of #{@config['vpc']} when asking for #{instance.subnet_id}\"\n end\n end\n\n if !subnet.nil?\n if !subnet.private? or (!@config['static_ip'].nil? and !@config['static_ip']['assign_ip'].nil?)\n if !@config['static_ip'].nil?\n if !@config['static_ip']['ip'].nil?\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id, classic: false, ip: @config['static_ip']['ip'])\n elsif !has_elastic_ip\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id)\n end\n end\n end\n\n nat_ssh_key, nat_ssh_user, nat_ssh_host, canonical_ip, ssh_user, ssh_key_name = getSSHConfig\n if subnet.private? and !nat_ssh_host and !MU::Cloud::AWS::VPC.haveRouteToInstance?(cloud_desc, region: @config['region'], credentials: @config['credentials'])\n raise MuError, \"#{node} is in a private subnet (#{subnet}), but has no NAT host configured, and I have no other route to it\"\n end\n\n # If we've asked for additional subnets (and this @config is not a\n # member of a Server Pool, which has different semantics), create\n # extra interfaces to accomodate.\n if !@config['vpc']['subnets'].nil? and @config['basis'].nil?\n device_index = 1\n @vpc.subnets { |subnet|\n subnet_id = subnet.cloud_id\n MU.log \"Adding network interface on subnet #{subnet_id} for #{node}\"\n iface = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).create_network_interface(subnet_id: subnet_id).network_interface\n MU::MommaCat.createStandardTags(iface.network_interface_id, region: @config['region'], credentials: @config['credentials'])\n MU::MommaCat.createTag(iface.network_interface_id, \"Name\", node+\"-ETH\"+device_index.to_s, region: @config['region'], credentials: @config['credentials'])\n\n if @config['optional_tags']\n MU::MommaCat.listOptionalTags.each { |key, value|\n MU::MommaCat.createTag(iface.network_interface_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n if !@config['tags'].nil?\n @config['tags'].each { |tag|\n MU::MommaCat.createTag(iface.network_interface_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).attach_network_interface(\n network_interface_id: iface.network_interface_id,\n instance_id: instance.instance_id,\n device_index: device_index\n )\n device_index = device_index + 1\n }\n end\n elsif !@config['static_ip'].nil?\n if !@config['static_ip']['ip'].nil?\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id, classic: true, ip: @config['static_ip']['ip'])\n elsif !has_elastic_ip\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id, classic: true)\n end\n end\n\n\n if !@config['image_then_destroy']\n notify\n end\n\n MU.log \"EC2 instance #{node} has id #{instance.instance_id}\", MU::DEBUG\n\n @config[\"private_dns_name\"] = instance.private_dns_name\n @config[\"public_dns_name\"] = instance.public_dns_name\n @config[\"private_ip_address\"] = instance.private_ip_address\n @config[\"public_ip_address\"] = instance.public_ip_address\n\n ext_mappings = MU.structToHash(instance.block_device_mappings)\n\n # Root disk on standard CentOS AMI\n # tagVolumes(instance.instance_id, \"/dev/sda\", \"Name\", \"ROOT-\"+MU.deploy_id+\"-\"+@config[\"name\"].upcase)\n # Root disk on standard Ubuntu AMI\n # tagVolumes(instance.instance_id, \"/dev/sda1\", \"Name\", \"ROOT-\"+MU.deploy_id+\"-\"+@config[\"name\"].upcase)\n\n # Generic deploy ID tag\n # tagVolumes(instance.instance_id)\n\n # Tag volumes with all our standard tags.\n # Maybe replace tagVolumes with this? There is one more place tagVolumes is called from\n volumes = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_volumes(filters: [name: \"attachment.instance-id\", values: [instance.instance_id]])\n volumes.each { |vol|\n vol.volumes.each { |volume|\n volume.attachments.each { |attachment|\n MU::MommaCat.listStandardTags.each_pair { |key, value|\n MU::MommaCat.createTag(attachment.volume_id, key, value, region: @config['region'], credentials: @config['credentials'])\n\n if attachment.device == \"/dev/sda\" or attachment.device == \"/dev/sda1\"\n MU::MommaCat.createTag(attachment.volume_id, \"Name\", \"ROOT-#{MU.deploy_id}-#{@config[\"name\"].upcase}\", region: @config['region'], credentials: @config['credentials'])\n else\n MU::MommaCat.createTag(attachment.volume_id, \"Name\", \"#{MU.deploy_id}-#{@config[\"name\"].upcase}-#{attachment.device.upcase}\", region: @config['region'], credentials: @config['credentials'])\n end\n }\n\n if @config['optional_tags']\n MU::MommaCat.listOptionalTags.each { |key, value|\n MU::MommaCat.createTag(attachment.volume_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n if @config['tags']\n @config['tags'].each { |tag|\n MU::MommaCat.createTag(attachment.volume_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])\n }\n end\n }\n }\n }\n\n canonical_name = instance.public_dns_name\n canonical_name = instance.private_dns_name if !canonical_name or nat_ssh_host != nil\n @config['canonical_name'] = canonical_name\n\n if !@config['add_private_ips'].nil?\n instance.network_interfaces.each { |int|\n if int.private_ip_address == instance.private_ip_address and int.private_ip_addresses.size < (@config['add_private_ips'] + 1)\n MU.log \"Adding #{@config['add_private_ips']} extra private IP addresses to #{instance.instance_id}\"\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).assign_private_ip_addresses(\n network_interface_id: int.network_interface_id,\n secondary_private_ip_address_count: @config['add_private_ips'],\n allow_reassignment: false\n )\n end\n }\n notify\n end\n\n begin\n if @config['groom'].nil? or @config['groom']\n if windows?\n # kick off certificate generation early; WinRM will need it\n cert, key = @deploy.nodeSSLCerts(self)\n if @config.has_key?(\"basis\")\n @deploy.nodeSSLCerts(self, true)\n end\n if !@groomer.haveBootstrapped?\n session = getWinRMSession(50, 60, reboot_on_problems: true)\n initialWinRMTasks(session)\n begin\n session.close\n rescue Exception\n # this is allowed to fail- we're probably rebooting anyway\n end\n else # for an existing Windows node: WinRM, then SSH if it fails\n begin\n session = getWinRMSession(1, 60)\n rescue Exception # yeah, yeah\n session = getSSHSession(1, 60)\n # XXX maybe loop at least once if this also fails?\n end\n end\n else\n session = getSSHSession(40, 30)\n initialSSHTasks(session)\n end\n end\n rescue BootstrapTempFail\n sleep 45\n retry\n ensure\n session.close if !session.nil? and !windows?\n end\n\n if @config[\"existing_deploys\"] && !@config[\"existing_deploys\"].empty?\n @config[\"existing_deploys\"].each { |ext_deploy|\n if ext_deploy[\"cloud_id\"]\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n cloud_id: ext_deploy[\"cloud_id\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n\n MU.log \"Couldn't find existing resource #{ext_deploy[\"cloud_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR if found.nil?\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: found.mu_name, triggering_node: @mu_name)\n elsif ext_deploy[\"mu_name\"] && ext_deploy[\"deploy_id\"]\n MU.log \"#{ext_deploy[\"mu_name\"]} / #{ext_deploy[\"deploy_id\"]}\"\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n deploy_id: ext_deploy[\"deploy_id\"],\n mu_name: ext_deploy[\"mu_name\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n\n MU.log \"Couldn't find existing resource #{ext_deploy[\"mu_name\"]}/#{ext_deploy[\"deploy_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR if found.nil?\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: ext_deploy[\"mu_name\"], triggering_node: @mu_name)\n else\n MU.log \"Trying to find existing deploy, but either the cloud_id is not valid or no mu_name and deploy_id where provided\", MU::ERR\n end\n }\n end\n\n # See if this node already exists in our config management. If it does,\n # we're done.\n if @groomer.haveBootstrapped?\n MU.log \"Node #{node} has already been bootstrapped, skipping groomer setup.\", MU::NOTICE\n if @config['groom'].nil? or @config['groom']\n @groomer.saveDeployData\n end\n MU::MommaCat.unlock(instance.instance_id+\"-orchestrate\")\n MU::MommaCat.unlock(instance.instance_id+\"-groom\")\n return true\n end\n\n begin\n @groomer.bootstrap if @config['groom'].nil? or @config['groom']\n rescue MU::Groomer::RunError\n MU::MommaCat.unlock(instance.instance_id+\"-groom\")\n MU::MommaCat.unlock(instance.instance_id+\"-orchestrate\")\n return false\n end\n\n # Make sure we got our name written everywhere applicable\n if !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n MU::MommaCat.unlock(instance.instance_id+\"-groom\")\n MU::MommaCat.unlock(instance.instance_id+\"-orchestrate\")\n return true\n end", "def finalize!\n erase\n @@registry.delete(self)\n\n children.each { |c|\n del_child c\n }\n\n cdk_scr.destroy if cdk?\n component.finalize! if component?\n end", "def scale(config)\n if config[:scaling_type].eql?('dynamic')\n Tapjoy::AutoscalingBootstrap::AWS::Autoscaling::Group.resize(\n **config[:instance_counts])\n elsif config[:scaling_type].eql?('static')\n scale_static(config)\n else\n abort('Unknown scaling type')\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Custom mapping for server user data. Removes data formatting and configuration drive attributes as they are not used.
def nova_server_user_data(value, args={}) result = super args[:new_properties].delete(:user_data_format) args[:new_properties].delete(:config_drive) result end
[ "def nova_server_user_data(value, args = {})\n result = super\n args[:new_properties].delete(:user_data_format)\n args[:new_properties].delete(:config_drive)\n result\n end", "def fix_raw_user!\n return unless raw_user\n raw_user['scraped_at'] = self.moreinfo['scraped_at']\n raw_user['created_at'] = ModelCommon.flatten_date(raw_user['created_at'])\n raw_user['id'] = ModelCommon.zeropad_id( raw_user['id'])\n raw_user['protected'] = ModelCommon.unbooleanize(raw_user['protected'])\n raw_user['profile_background_tile'] = ModelCommon.unbooleanize(raw['profile_background_tile']) unless raw_user['profile_background_tile'].nil?\n Wukong.encode_components raw_user, 'name', 'location', 'description', 'url'\n # There are several users with bogus screen names\n # These we need to **URL encode** -- not XML-encode.\n if raw_user['screen_name'] !~ /\\A\\w+\\z/\n raw_user['screen_name'] = Wukong.encode_str(raw_user['screen_name'], :url)\n end\n end", "def user_data_key\n self.prefix_key('user_data')\n end", "def user_metadata; end", "def attributes_from(ad_user)\n\t\t\th = {}\n\t\t\t@@attribute_map.each { |local, remote| h[local] = ad_user.send(remote) }\n\t\t\th[:guid] = ad_user.objectGUID\n\t\t\th[:password => '']\n\t\t\th\n\t\tend", "def safe_user_attrs\n [:display_name, :email, :location, :password, :units,\n :years_experience, :mailing_list, :is_private, :agree]\n end", "def write_user_metadata; write_metadata(:user_metadata); end", "def map_user(keycloak_user, options)\n # FIRST_NAME,LAST_NAME,EMAIL,USERNAME,EMAIL_VERIFIED,ID,PASSWORD,SALT,HASHITERATIONS,ALGORITHM,CREATED_TIMESTAMP,REALM_ID\n\n user = {}\n\n # Optionally convert user_id to a UUID for FusionAuth\n if $map_user_id\n user['id'] = keycloak_user['ID']\n end\n\n user['active'] = true\n\n if keycloak_user['EMAIL'] != \"NULL\"\n user['email'] = keycloak_user['EMAIL']\n end\n\n # this is \\0 if false, everything else is true\n user['verified'] = keycloak_user['EMAIL_VERIFIED'] != \"\\\\0\"\n\n # apparently every keycloak user has a username\n user['username'] = keycloak_user['USERNAME']\n\n if keycloak_user['FIRST_NAME'] != \"NULL\"\n user['firstName'] = keycloak_user['FIRST_NAME']\n end\n\n if keycloak_user['LAST_NAME'] != \"NULL\"\n user['lastName'] = keycloak_user['LAST_NAME']\n end\n\n # Incoming format is a timestamp\n user['insertInstant'] = keycloak_user['CREATED_TIMESTAMP']\n\n user['encryptionScheme'] = map_hashing_algorithm(keycloak_user['ALGORITHM'])\n user['factor'] = keycloak_user['HASHITERATIONS']\n user['salt'] = keycloak_user['SALT']\n user['password'] = keycloak_user['PASSWORD']\n\n # Preserve the Unique Id\n user['data'] = {}\n user['data']['keycloak'] = {}\n user['data']['keycloak']['id'] = keycloak_user['ID']\n user['data']['keycloak']['tenant'] = keycloak_user['REALM_ID']\n\n if options[:appids]\n regids = options[:appids].split(',')\n user['registrations'] = []\n regids.each do |rid|\n application_registration = {\n applicationId: rid.strip()\n }\n user['registrations'].push(application_registration)\n end\n end\n\n puts user\n\n return user\nend", "def user_info\n @user_info ||= raw_info\n end", "def user_info_post\n unless @cloud_user.nil?\n user_info = {}\n user_info[:rhc_domain] = Rails.configuration.openshift[:domain_suffix]\n user_info[\"rhlogin\"] = @cloud_user.login\n user_info[\"uuid\"] = @cloud_user._id.to_s \n user_info[\"namespace\"] = @cloud_user.domains.first.namespace if @cloud_user.domains.count > 0\n\n #FIXME: This is redundant, for now keeping it for backward compatibility\n if @cloud_user.ssh_keys.length > 0\n key_info = @cloud_user.ssh_keys[0]\n user_info[\"ssh_key\"] = key_info['key']\n user_info[\"ssh_type\"] = key_info['type']\n else\n user_info[\"ssh_key\"] = \"\"\n user_info[\"ssh_type\"] = \"\"\n end\n \n user_info[\"ssh_keys\"] = {}\n @cloud_user.ssh_keys.each do |key|\n user_info[\"ssh_keys\"][key.name] = {type: key.type, key: key.content}\n end\n \n user_info[\"max_gears\"] = @cloud_user.max_gears\n user_info[\"consumed_gears\"] = @cloud_user.consumed_gears\n user_info[\"capabilities\"] = @cloud_user.get_capabilities\n \n # this is to support old version of client tools\n app_info = {}\n user_info[\"domains\"] = @cloud_user.domains.map do |domain|\n d_hash = {}\n d_hash[\"namespace\"] = domain.namespace\n\n domain.applications.each do |app|\n app_info[app.name] = {\n \"framework\" => \"\",\n \"creation_time\" => app.created_at,\n \"uuid\" => app._id.to_s,\n \"aliases\" => app.aliases,\n \"embedded\" => {}\n }\n\n app.requires(true).each do |feature|\n cart = CartridgeCache.find_cartridge(feature)\n if cart.categories.include? \"web_framework\"\n app_info[app.name][\"framework\"] = cart.name\n else\n app_info[app.name][\"embedded\"][cart.name] = {}\n end\n end\n end\n d_hash\n end\n \n log_action(@request_id, @cloud_user._id.to_s, @login, \"LEGACY_USER_INFO\", true, \"\", get_extra_log_args)\n @reply.data = {:user_info => user_info, :app_info => app_info}.to_json\n render :json => @reply\n else\n log_action(@request_id, \"nil\", @login, \"LEGACY_USER_INFO\", true, \"User not found\", get_extra_log_args)\n # Return a 404 to denote the user doesn't exist\n @reply.resultIO << \"User does not exist\"\n @reply.exitcode = 99\n \n render :json => @reply, :status => :not_found\n end\n end", "def normalized_userinfo\n normalized_user + (password ? \":#{normalized_password}\" : \"\") if userinfo\n end", "def alias_server_attributes\n @config['server'].each do |key, value|\n instance_variable_set('@' + key, value)\n end\n end", "def custom_data\n @attributes[\"custom_data\"] ||= UserCustomData.new\n end", "def replace_user(data)\n data = data.to_hash\n return unless data[:login] # It seems it's possible to have a login-less user :/ FIXME\n _insert(:users, data, :id, :login, :avatar_url)\n end", "def build_user_properties\n return {} if user_properties.nil?\n\n Hash[user_properties.map{|key, value| [\"sdr_u.#{key}\", value] } ]\n end", "def load_user_info\n\t\tif @user_info.has_key?(@@line_array[0].to_i)\n\t\t\t@user_info[@@line_array[0].to_i][@@line_array[1].to_i] = @@line_array[2].to_i\n\t\telse\n\t\t\t@user_info[@@line_array[0].to_i] = {@@line_array[1].to_i => @@line_array[2].to_i}\n\t\tend\n\tend", "def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info\n end", "def required_data_keys\n %w[user_id name latitude longitude]\n end", "def user_metadata\n raise NotImplementedError\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Print a deprecated message (once no matter how many times it's called).
def deprecated(msg, prefix = '[DEPRECATED] ') return nil if @@deprecated[msg] @@deprecated[msg] = true Helpers.warn "#{prefix}#{msg}" # Kernel.warn end
[ "def show_deprecation_warning(message)\n return if suppress_deprecation_warnings?\n message = \"[Gretel] #{message}\"\n puts message\n Rails.logger.warn message\n end", "def deprecated(message) #:nodoc:\n return unless verbose\n \"#{caller[1]}: Deprecated: #{message}\".tap do |message|\n @deprecated ||= {}\n unless @deprecated[message]\n @deprecated[message] = true\n warn message\n end\n end\n end", "def log_deprecation(message, location = nil)\n location ||= Chef::Log.caller_location\n Chef.deprecated(:generic, message, location)\n end", "def deprecation(message)\n warn \"SHRINE DEPRECATION WARNING: #{message}\"\n end", "def deprecation(message)\n Chef::Log.warn message\n log(message, kind: :deprecation)\n end", "def deprecated\n @deprecated = true\n end", "def deprecate(old_usage, new_usage, call_site)\n return if options.ignore_deprecate\n $stderr.puts \"WARNING: '#{old_usage}' is deprecated. \" +\n \"Please use '#{new_usage}' instead.\\n\" +\n \" at #{call_site}\"\n end", "def deprecate(old_usage, new_usage, call_site) # :nodoc:\n unless options.ignore_deprecate\n $stderr.puts \"WARNING: '#{old_usage}' is deprecated. \" +\n \"Please use '#{new_usage}' instead.\\n\" +\n \" at #{call_site}\"\n end\n end", "def deprecation_message(version, message)\n warn \"DEPRECATION - Removal planned for #{version}: #{message}\" unless ENV['BRINE_QUIET_DEPRECATIONS']\nend", "def deprecation_stream; end", "def deprecation_notice\n case definition[\"deprecated\"]\n when String\n definition[\"deprecated\"]\n when TrueClass\n Alchemy.t(\n name,\n scope: :element_deprecation_notices,\n default: Alchemy.t(:element_deprecated)\n )\n end\n end", "def deprecated?\n comment.include?(\"(Deprecated)\")\n end", "def alert(message)\n @logger.warn(\"Deprecation: #{message}\")\n end", "def deprecate(old_usage, new_usage, call_site); end", "def deprecation_formatter; end", "def _warn_deprecated_command(cmd)\n warn \"\\n'#{cmd}' is deprecated! Please use 'defEvent' and 'onEvent' commands\"\n warn \"Deprecated commands will be removed in future OMF versions\"\n warn \"Moreover, they may not allow the use of some features in this version\"\n end", "def deprecated_options_warning\n ::Guard::UI.deprecation(WATCH_ALL_MODIFICATIONS_DEPRECATION) if options[:watch_all_modifications]\n ::Guard::UI.deprecation(NO_VENDOR_DEPRECATION) if options[:no_vendor]\n end", "def _deprecation\n @link['deprecation']\n end", "def warn_with_prefix( msg = \"\" )\n warn \"DEPRECATION WARNING: #{msg}\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deprecated Use Markdown string instead of array This method was added to maintain backwards compatibility. We allowed the contents to be passed as an Array in order to render multi paragraph content.
def render_markdown_array(arr) if arr.is_a?(Array) arr.map { |str| render_markdown(str) }.join().html_safe else render_markdown(arr) end end
[ "def description_markdown\n tags_to_links description\n end", "def markdownify(input); end", "def contents\n @contents ||= markdown(body)\n end", "def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end", "def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end", "def markdown content, no_line_numbers = false\n require \"kramdown\"\n require \"kramdown-parser-gfm\"\n require \"kramdown-syntax-coderay\"\n require \"coderay/zenweb_extensions\"\n\n config = KRAMDOWN_CONFIG.dup\n config[:coderay_line_numbers] = nil if no_line_numbers\n\n Kramdown::Document.new(content, config).to_html\n end", "def markdown\n convert do |current|\n Kramdown::Document.new(current, kramdown_options).to_slodown_html\n end\n end", "def content_html\n Inquest::Application.config.markdown_renderer.render(self.content).html_safe\n end", "def description_html\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :no_links => true, :hard_wrap => true)\n markdown.render(description).html_safe\n end", "def markdown\n return if changed_markdown_files.empty?\n\n output = `mdl #{changed_markdown_files.join(' ')}`\n return if output&.empty?\n\n heading('Markdown Linter', output)\n end", "def array_paragraphs fragments\n [fragments]\n end", "def simple_format(text)\n render_markdown text\n end", "def markdown( text )\n Kramdown::Document.new( text ).to_html\n end", "def markdown(text)\n render_options = {\n filter_html: true,\n hard_wrap: true,\n link_attributes: { rel: 'nofollow' }\n # no_images: true\n }\n renderer = Redcarpet::Render::HTML.new(render_options)\n\n extensions = {\n autolink: true,\n fenced_code_blocks: true,\n lax_spacing: true,\n no_intra_emphasis: true,\n }\n Redcarpet::Markdown.new(renderer, extensions).render(text).html_safe\n end", "def description_markdown\n @@markdown_renderer ||= Redcarpet::Markdown.new(MdEmoji::Render, :autolink => true, :space_after_headers => true, :no_intra_emphasis => true)\n @@markdown_renderer.render(description).html_safe\n end", "def convert_markdown\n self.html_content = Raptor::Markdown.render(self.content)\n end", "def rendered_description\n @@markdown.render(description)\n end", "def markdown_extra?\n true\n end", "def parse_markdown\n self.bio_html = markdown.render(bio_markdown)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The foreign column name that another class would have if it refers to this
def foreign_column_name(klass_name = nil) return undecorated_table_name((klass_name or self.name)) + "_id" end
[ "def foreign_key\n class_name.foreign_key.to_sym\n end", "def sql_column\n assoc.association_foreign_key\n end", "def foreign_key_column_name\n @foreign_key_column_name ||= begin\n out = options[:foreign_key]\n\n unless out\n out = \"#{@model_class.name.underscore}_#{association_name}\"\n out = $1 if out =~ %r{/([^/]+)$}i\n out = out + \"_id\"\n end\n\n out = out.to_s if out.kind_of?(Symbol)\n\n out\n end\n end", "def foreign_key\n self[:foreign_key] || :\"#{parent.relation_name}_id\"\n end", "def foreign_key_name(class_name)\n Inflector.foreign_key(class_name).to_sym\n end", "def foreign_key(name)\n attr = schema.foreign_key(name.dataset)\n\n if attr\n attr.name\n else\n :\"#{inflector.singularize(name.dataset)}_id\"\n end\n end", "def attribute_name_for(column_name)\n if found = (resource_belongs_to_associations.find { |a| a.foreign_key == column_name.to_s })\n found.name.to_sym\n else\n column_name\n end\n end", "def right_col_name\n self.class.right_col_name\n end", "def name\n column.name\n end", "def foreign_key\n meta(foreign_key: true)\n end", "def foreign_key_table\n if reflection.options.key?(:through)\n nil\n elsif reflection.macro == :has_and_belongs_to_many\n reflection.options[:join_table]\n elsif reflection.macro == :belongs_to\n subject_table_name\n else\n reflection_table_name\n end\n end", "def foreign_key\n :\"#{parent_name}_id\"\n end", "def match_foreign_key(column)\n if column.ref_table == @name || foreign_keys.include?(column.name.downcase)\n @name if primary_key\n end\n end", "def foreign_key\n table_name.sub(/_dimension/,'') + '_id'\n end", "def column_name\n name\n end", "def column_name\n ensure_setup!\n column.name.to_sym\n end", "def relation_name\n klass.relation\n end", "def id_column_name_from_foreign_key_metadata(from_table, foreign_key_name)\n keys = foreign_keys(from_table)\n this_key = keys.find {|key| key.options[:name] == foreign_key_name}\n this_key.options[:column]\n end", "def sql_names\n if is_table_column?\n if self.reflection\n [self.model.table_name + \".\"+ foreign_key, self.reflection.klass.table_name + \".\" + option_text_attribute.to_s]\n else\n [self.model.table_name + \".\" + name.to_s]\n end\n else\n nil\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Defines preseed expression. Preseed expressions are regular expressions that must match for all logs that will be stored in this class. This functionality is mainly for speedup. After a log matched any of these preseed expressions, normal processing/parsing wild be done.
def preseed_expression(expr = nil) @preseed_expression = expr if expr return @preseed_expression end
[ "def pre_match() end", "def initialize(pre)\n @predicate = pre\n @priority = :matches\n @success_incr = 1\n @fails_incr = 0\n @penalty = true\n end", "def initialize regex\n @regex = regex\n @time_hash = {}\n extract_data_from_profiles\n raise ArgumentError, \"could not find any starpu profiles.\" if @time_hash.empty?\n end", "def before_create\n test_log = TestLog.new\n test_log.stdout = \"\"\n test_log.rawtest = \"\"\n test_log.save\n end", "def initialize(regex, options = {})\n @@parse_options = options\n @@parse_options[:reg_options] ||= Regextest::RegexOption.new\n @verification = (options && options[:verification] == false)?false:true\n @reg_string = nil\n @reg_exp = nil\n \n # Set seed for randomizing\n @seed = set_seed_for_randomizing(@@parse_options[:seed])\n\n # Covert to source string if necessary\n set_regex(regex)\n\n # Parse string\n @front_end = Regextest::Front.new(@reg_string, @@parse_options)\n \n # Prepare back-end process. (use generate method for generating string)\n @back_end = Regextest::Back.new(@front_end)\n \n @result = nil\n @reason = nil\n end", "def exp!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 6 )\n\n type = EXP\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 26:7: '^'\n match( 0x5e )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 6 )\n\n end", "def setPreProcess (fn, data)\n @pre_process_func = fn\n @pre_process_data = data\n end", "def on_regexp_beg(token)\n log \"REGEXP_BEG: '#{token}'\"\n super(token)\n end", "def initialize find, replace\n @regexp = Regexp.new(\"^#{find}$\")\n @replace = replace\n end", "def preproc; end", "def pregex\n\t\t\t\tkeyword = request['keyword'].untaint\n\t\t\t\tkeyword = keyword.gsub(' ','.+')\n\t\t\t\treturn Regexp.new( keyword, Regexp::IGNORECASE )\n\t\t\tend", "def initialize(options = {})\n options = {\n :domain => 'www.example.com',\n :datetime_format => '[%d/%b/%Y:%H:%M:%S %Z]',\n :pattern => LOG_FORMAT_COMBINED\n }.merge(options)\n\n @options = options\n @pattern = if options[:pattern].is_a?(Array)\n options[:pattern]\n else\n options[:pattern].to_s.split(/\\s+/)\n end\n\n @re = '^' + @pattern.collect { |tk|\n tk = tk.to_sym\n token = if options[:tokens] && options[:tokens][tk]\n options[:tokens][tk]\n elsif TOKENS[tk]\n TOKENS[tk]\n else\n raise ArgumentError.new(\"Token :#{tk} not found!\")\n end\n\n \"(#{token})\"\n }.join(' ') + '$'\n @matcher = Regexp.new(@re)\n end", "def initialize(pattern, suppress_key_errors=false)\n @_raw_pattern = pattern\n @_compiled_pattern = pattern\n @_suppress_key_errors = suppress_key_errors\n\n validate(@_compiled_pattern)\n\n end", "def pre_process\n string = @string.gsub(/\\r\\n/, \"\\n\")\n string = string.split(\"\\n\").map do |line|\n line.gsub(/\\s+$/, '')\n end.join(\"\\n\")\n \"\\n#{string}\\n\"\n end", "def preRun\n end", "def prescan(strip_dsl)\n @strip_dsl = strip_dsl\n @parse_mode=\"prescan\"\n parse(@param_default_values)\n @parse_mode=\"parse\"\n @strip_dsl=false\n end", "def pre_process(message)\n end", "def set_starting_hash_pattern(opts)\n opts = check_params(opts,[:patterns])\n super(opts)\n end", "def start_re; end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns all child meta classes of this class
def child_classes Prisma::Database.get_classes(:meta).select {|klass| klass.columns_hash[self.foreign_column_name] } end
[ "def child_classes\n self.class.child_classes\n end", "def child_classes\n @child_classes ||= []\n end", "def subclasses_all\n ret = []\n each_subclass {|c| ret.push c}\n ret\n end", "def class_children(klass)\n (@class_objects ||= objects(Class)).select {|e| e.superclass == klass }\n end", "def descendents\n Sequel.synchronize{subclasses.dup}.map{|x| [x] + x.send(:descendents)}.flatten\n end", "def parent_classes\n Prisma::Database.get_classes(:meta).select {|klass|\n\tself.columns_hash[klass.foreign_column_name]\n }\n end", "def accepted_classes_through_polymorphism\n if polymorphic?\n classes = []\n attr_name = attribute_name_for_polymorphic_type\n this_class = from_active_record\n\n Traits.active_record_descendants.each do |active_record|\n # Skip current model and models which are STI derived\n next if active_record <= this_class # Means is or derived from current model\n\n active_record.traits.associations.each do |assoc|\n if assoc.attribute_name_for_polymorphic_type == attr_name\n classes << assoc.from_active_record\n end\n end\n end\n classes.uniq.sort! { |l, r| l.to_s <=> r.to_s }\n end\n end", "def all_migrating_model_classes\n\t\t\treturn [ self.baseclass ] + self.baseclass.descendents\n\t\tend", "def metafetchers\n Metafetchers.constants.map(&Metafetchers.method(:const_get)).grep(Class)\n end", "def subclasses\n @subclasses ||= []\n end", "def inherited_meths(opts = {})\n inheritance_tree[1..-1].inject([]) do |list, superclass|\n if superclass.is_a?(Proxy)\n list\n else\n list += superclass.meths(opts).reject do |o|\n next(false) if opts[:all]\n child(:name => o.name, :scope => o.scope) ||\n list.find {|o2| o2.name == o.name && o2.scope == o.scope }\n end\n end\n end\n end", "def subclasses(recursive = false)\n JRuby.reference0(self).subclasses(recursive).to_a.freeze\n end", "def object_class_list\r\n self.schema.object_classes.inject([]) do |arr, entry|\r\n #unless self.attributes['objectClass'].include?(entry.name)\r\n arr << entry.name unless arr.include?(entry.name)\r\n #end\r\n\r\n arr\r\n end\r\n end", "def child_class\n self.class.child_class\n end", "def children\n return Metadata.where(parent_metadata_id: self.id)\n end", "def clear_child_classes\n @child_classes = []\n end", "def subclasses\n @subclasses ||= Set.new\n end", "def makena_classes\n Rails.application.eager_load!\n pass = ActiveRecord::Base.descendants.map{|a| a.to_s}\n pass.shift\n pass\n end", "def children\n child_objects(Dependency)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns all parent meta classes of this class
def parent_classes Prisma::Database.get_classes(:meta).select {|klass| self.columns_hash[klass.foreign_column_name] } end
[ "def child_classes\n self.class.child_classes\n end", "def child_classes\n @child_classes ||= []\n end", "def child_classes\n Prisma::Database.get_classes(:meta).select {|klass|\n\tklass.columns_hash[self.foreign_column_name]\n }\n end", "def parent_models\n parent_model_names.map { |p| p.constantize }\n end", "def parents\n ans = [self.superclass]\n until ans.last.superclass.nil?\n ans << ans.last.superclass\n end\n ans\n end", "def parent_models\n models.group_by(&:table_name).each_value.flat_map do |models|\n models.reject { |model| models.include?(model.superclass) }\n end\n end", "def subclasses_of_class(parent)\n ObjectSpace.each_object(Class).select { |klass|\n klass < parent\n }\n end", "def super_types\n all_parents.select { |rc| rc.is_a?(SuperType) }\n end", "def type_and_parent_types\n parents = Array.new\n parents.push(self)\n if self.parent\n parents.push(*self.parent.type_and_parent_types)\n end\n return parents\n end", "def all_model_superclasses(klass)\n superclasses = klass.ancestors.grep(Class).sort.take_while{|k| k < ActiveRecord::Base}\n end", "def accepted_classes_through_polymorphism\n if polymorphic?\n classes = []\n attr_name = attribute_name_for_polymorphic_type\n this_class = from_active_record\n\n Traits.active_record_descendants.each do |active_record|\n # Skip current model and models which are STI derived\n next if active_record <= this_class # Means is or derived from current model\n\n active_record.traits.associations.each do |assoc|\n if assoc.attribute_name_for_polymorphic_type == attr_name\n classes << assoc.from_active_record\n end\n end\n end\n classes.uniq.sort! { |l, r| l.to_s <=> r.to_s }\n end\n end", "def subclasses_all\n ret = []\n each_subclass {|c| ret.push c}\n ret\n end", "def parents_and_mixins\n models = parent.try(:parents_and_mixins) || []\n mixins.each do |mixin_model|\n models |= mixin_model.parents_and_mixins\n end\n models << self\n end", "def loaded_superclasses\n namespace.inheritance_tree.select { |ancestor| ancestor.is_a?(::YARD::CodeObjects::ClassObject) }\n end", "def parents\n parent_objects(Dependency)\n end", "def all_migrating_model_classes\n\t\t\treturn [ self.baseclass ] + self.baseclass.descendents\n\t\tend", "def superclasses(c)\n result = [c]\n while s = c.superclass\n result << s\n c = s\n end\n result\n end", "def inherited_meths(opts = {})\n inheritance_tree[1..-1].inject([]) do |list, superclass|\n if superclass.is_a?(Proxy)\n list\n else\n list += superclass.meths(opts).reject do |o|\n next(false) if opts[:all]\n child(:name => o.name, :scope => o.scope) ||\n list.find {|o2| o2.name == o.name && o2.scope == o.scope }\n end\n end\n end\n end", "def descendents\n Sequel.synchronize{subclasses.dup}.map{|x| [x] + x.send(:descendents)}.flatten\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return true if the this class can have messages
def may_have_messages?; true; end
[ "def has_message?\n has_message\n # && messages.count > 0\n end", "def can_publish_messages?\n connected? ||\n ( (initialized? || connecting? || disconnected?) && client.queue_messages )\n end", "def has_manage_messages_permission?\n return get_bot_profile.permission?(:manage_messages, command.event.channel)\n end", "def messages_supported?\n true unless messages_picture_type.nil?\n end", "def has_messages?\n # if the user has sent any or received any, then we return true\n 0 < Message.count_by_sql(%{\n SELECT COUNT(*)\n FROM messages m\n LEFT JOIN assignment_participations a_p\n ON a_p.id = m.assignment_participation_id\n LEFT JOIN assignment_submissions a_s\n ON a_s.id = a_p.assignment_submission_id\n WHERE (a_s.user_id = #{@user.id} OR a_p.user_id = #{@user.id}) AND a_s.assignment_id = #{@assignment.id}\n }) #, @user.id, @user.id, @assignment.id])\n end", "def want_msg?\r\n msg_type == 'want'\r\n end", "def can_send_free_messages?\n !blocked? && sent < MAX_FREE\n end", "def new_msg?\n msg && !event[:subtype]\n end", "def can?\n @bytes.first == Message::CAN\n end", "def private_message?\n !on_chan?\n end", "def render?\n return true if can?(RS::AuthorisationHelper::VIEW_MESSAGES)\n\n false\n end", "def msg_sent?\n true\n end", "def enqueued_messages?\n @pointer < @buffer.length\n end", "def queued_messages?\r\n @pointer < @buffer.length\r\n end", "def has_message_id?\n !fields.select { |f| f.responsible_for?('Message-ID') }.empty?\n end", "def is_self_message?(data)\n if data[:type] == 'message' && data[:user] == Affiliation::Self.get[:id]\n return true\n end\n false\n end", "def has_unread_messages?\n received_messages.count > 0\n end", "def queued_messages?\n @pointer < @buffer.length\n end", "def is_message?(data)\n data.type == TYPE_MESSAGE\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if table exist. If not, a exception is raised.
def check_table throw "Table '#{table_name}' does not exists." unless table_exists? end
[ "def table_exists?(name)\n v ||= false # only retry once\n sch, table_name = schema_and_table(name)\n name = SQL::QualifiedIdentifier.new(sch, table_name) if sch\n from(name).first\n true\n rescue DatabaseError => e\n if e.to_s =~ /Operation not allowed for reason code \"7\" on table/ && v == false\n # table probably needs reorg\n reorg(name)\n v = true\n retry \n end\n false\n end", "def table_exists?\n self.table_status!=:not_present\n end", "def table_exists?(table_name); end", "def exists?(table_name)\n @dynamo_resource.client.describe_table(table_name: table_name)\n @logger.debug(\"Table #{table_name} exists\")\n rescue Aws::DynamoDB::Errors::ResourceNotFoundException\n @logger.debug(\"Table #{table_name} doesn't exist\")\n false\n rescue Aws::DynamoDB::Errors::ServiceError => e\n puts(\"Couldn't check for existence of #{table_name}:\\n\")\n puts(\"\\t#{e.code}: #{e.message}\")\n raise\n end", "def table_exists?\n db.table_exists?(table_name)\n end", "def table_exists?(table='test_ruby') \n begin\n res = @db.query(\"select * from #{table} where 1=0\")\n return true\n rescue\n return false\n end\n end", "def table_exists?\n true\n end", "def has_table?(table_id)\n begin\n table table_id\n rescue\n false\n else\n true\n end\n end", "def table_exists?\n\t\t\treturn self.db.table_exists?( self.table_name )\n\t\tend", "def table_exists?(table)\n table_info(table) ? true : false\n end", "def table_exists?(name)\n begin \n if respond_to?(:tables)\n tables.include?(name.to_sym)\n else\n from(name).first\n true\n end\n rescue\n false\n end\n end", "def table_exists?\n resp = dynamodb_client.describe_table(table_name: table_name)\n resp.table.table_status == 'ACTIVE'\n rescue DynamoDB::Errors::ResourceNotFoundException\n false\n end", "def table_exists?(tablename)\r\n raise(ArgumentError, 'Table name must be a symbol!') unless \\\r\n tablename.is_a?(Symbol)\r\n\r\n return @engine.table_exists?(tablename)\r\n end", "def create_table?(*args, &block)\n create_table(*args, &block) unless table_exists?\n end", "def table_not_exist(status, table_name, dbh)\n if status == false or status == nil\n printf \"Error: Table #{table_name} does not exist in the database.\\n\"\n dbh.close if dbh\n @dbm.write_queries\n exit\n end\n end", "def supports_create_table_if_not_exists?\n true\n end", "def supports_create_table_if_not_exists?\n true\n end", "def check_table db_info,table,fields = nil\n if table_ok? db_info, table # table xists\n fields_ok? table,fields if fields\n else # table dont exists\n return false\n end\n return true\n end", "def table_created?\n @db.table_exists?(table_name)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a table status, if exist return "OK", a error message instead. no exception will be risen.
def status begin check_table return "OK" rescue ActiveRecord::Transactions::TransactionError # This have to be, that transactions are working raise $! rescue return $!.message.to_s end end
[ "def table_status\n data[:table_status]\n end", "def table_exists?\n self.table_status!=:not_present\n end", "def table_exists?\n resp = dynamodb_client.describe_table(table_name: table_name)\n resp.table.table_status == 'ACTIVE'\n rescue DynamoDB::Errors::ResourceNotFoundException\n false\n end", "def check_table\n throw \"Table '#{table_name}' does not exists.\" unless table_exists?\n end", "def table_not_exist(status, table_name, dbh)\n if status == false or status == nil\n printf \"Error: Table #{table_name} does not exist in the database.\\n\"\n dbh.close if dbh\n @dbm.write_queries\n exit\n end\n end", "def table_exists?(name)\n v ||= false # only retry once\n sch, table_name = schema_and_table(name)\n name = SQL::QualifiedIdentifier.new(sch, table_name) if sch\n from(name).first\n true\n rescue DatabaseError => e\n if e.to_s =~ /Operation not allowed for reason code \"7\" on table/ && v == false\n # table probably needs reorg\n reorg(name)\n v = true\n retry \n end\n false\n end", "def account_status\n overview_table.rows_text[1][3]\n end", "def status\n @status ||= if checksum_ok?\n if transaction_id.blank?\n 'invalid'\n else\n transaction_status.downcase\n end\n else\n 'tampered'\n end\n end", "def table_exists?(table='test_ruby') \n begin\n res = @db.query(\"select * from #{table} where 1=0\")\n return true\n rescue\n return false\n end\n end", "def table_not_present?\n self.table_status==:not_present\n end", "def status(staging_record, table_name = nil)\n if !exists?(staging_record, table_name)\n :new\n elsif modified?(staging_record, table_name)\n :modified\n else\n :not_modified\n end\n end", "def table_info(table)\n r = query_statement(\"SHOW TABLE STATUS FROM #{@options[:name]} LIKE '#{self.class.escape(table.to_s)}'\")\n return r && r.blank? ? nil : r.next\n end", "def trx_status\n #parse out trx_id\n trx_id = params[:tid]\n\n begin\n status = ApiTransaction.find(trx_id).trx_status\n render json: { trx_id: trx_id, status: status }, status: :ok\n rescue ActiveRecord::RecordNotFound\n render json: { trx_id: trx_id, status: \"Transaction not found\" }, status: :not_found\n end\n end", "def table_active?\n self.table_status==:active\n end", "def no_table?\n if table\n false\n else\n @status = NO_TABLE\n true\n end\n end", "def transaction_status()\n #This is a stub, used for indexing\n end", "def exists?(table_name)\n @dynamo_resource.client.describe_table(table_name: table_name)\n @logger.debug(\"Table #{table_name} exists\")\n rescue Aws::DynamoDB::Errors::ResourceNotFoundException\n @logger.debug(\"Table #{table_name} doesn't exist\")\n false\n rescue Aws::DynamoDB::Errors::ServiceError => e\n puts(\"Couldn't check for existence of #{table_name}:\\n\")\n puts(\"\\t#{e.code}: #{e.message}\")\n raise\n end", "def status(row,param); det.table(:index, 9)[row][param]; end", "def table_already_exist(status, table_name, dbh)\n if status == true\n printf \"Error: Table #{table_name} already exist.\\n\"\n dbh.close if dbh\n @dbm.write_queries\n exit\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes a new meta with parent and values (like attribtues in active_record), after values are set, after_filling_values(values) will be called if it exist. Maybe a corresponding activerecord method with callbacks exists now. If a value :message is given, a message object is created too. At the end self.after_init(values) will be called if it exist. Maybe this is a little bit confusing because new does already save the new record. This is because of historical reason and could maybe changed in future. This corresponds more to create of activerecord than to new.
def prisma_initialize(parent = nil, values = nil) $log.debug("Creating instance of '#{self.class.name}' with parent '#{parent.class.name}'") raise "Parent is nil" if parent.nil? unless self.class.name =~ /Meta$/ $log.debug{"This is not a meta record. exiting base_mixin constructor."} return self end if parent parent.save if parent and parent.new_record? self.parent = parent end if self.respond_to?(:init) # call init from class self.init(values) else # write values to instance if values != nil then for name, value in values next if name == :message if self.respond_to?("#{name}=") # write value to property if name == :date and name.class == String begin value = DateTime.strptime(value, "%d.%m.%Y") rescue ActiveRecord::Transactions::TransactionError raise $! rescue $log.warn{"#{value} not parsed as date (#{$!.message})."} end end self.send("#{name}=",value) unless name == :message else # Maybe there is an anonymous field? if self.respond_to?("#{name}_anonym=") # yes - so anonymise that nonym = Nonym.find_or_create(value) self.send("#{name}_anonym=",nonym.id) else # no. Giving up! throw "Neither field '#{name}' nor anonymous field '#{name}_anonym' found in class #{self.class.name}." end end end end end self.after_filling_values(values) if self.respond_to?(:after_filling_values) # validation is too expensive, but we know the records are correct. self.save_without_validation # special treatment of columns message and user if values and values.has_key?(:message) and values[:message] msg = Message.new.prisma_initialize(self,values[:message], {:fast_association => true}) msg.save_without_validation # write hash if self.respond_to?(:hash_value) self.hash_value = self.get_hash end # msg.meta_id = self.id end self.after_init(values) if self.respond_to?(:after_init) self end
[ "def create\n execute_callback(:before, :create) if valid?\n\n super.tap do |is_created|\n execute_callback(:after, :create) if is_created\n end\n end", "def post_initialize_fields\n end", "def initialize(values = {}, from_db = false, &block)\n @associations = {}\n @changed_columns = []\n if from_db\n @new = false\n @values = values\n else\n @values = {}\n @new = true\n set(values)\n @changed_columns.clear \n yield self if block\n end\n after_initialize\n end", "def post_add_content\n @parent&.post_initialize_child(self)\n end", "def initialize(values = {}, from_db = false)\n if from_db\n @new = false\n @values = values\n else\n @values = {}\n @new = true\n set(values)\n changed_columns.clear \n yield self if block_given?\n end\n after_initialize\n end", "def post_initialize_child(child)\n # No Op by default\n end", "def set_callbacks model=nil\n self.record||= model\n if record.kind_of?(ActiveRecord::Base)\n record.class.send(self.on || :after_create, \"_#{self.on || 'after_create'}_create_notification\".to_sym)\n end\n end", "def parent_initialize(ptr)\n super(ptr)\n end", "def after_create(obj, p)\n end", "def _after_create(pk)\n # SEQUEL5: Remove\n @this = nil\n @new = false\n @was_new = true\n end", "def after_create(obj); end", "def call_after_creates\n return unless self.class.try(:after_creates)\n self.class.after_creates.each { |method| send(method) }\n end", "def pre_initialize_fields\n end", "def initialize(values = nil, from_db = false, &block)\n values ||= {}\n @changed_columns = []\n @typecast_on_assignment = model.typecast_on_assignment\n @db_schema = model.db_schema\n if from_db\n @new = false\n @values = values\n else\n @values = {}\n @new = true\n set_with_params(values)\n end\n @changed_columns.clear \n \n yield self if block\n after_initialize\n end", "def post_initialize\n initialize_id\n initialize_fields_by_type\n end", "def _after_create\n @_after_create ||= []\n end", "def initialize_block(...)\n parent << self\n super\n end", "def after_initialize\n\t\tself.current_history = History.new( :parent_class => self.class.name, :parent_id => self.id, :state_in => self.state )\n\tend", "def initialize(parent, handle)\r\n\t\t\tsuper\r\n\t\t\t\r\n\t\t\t@parent = parent\r\n\t\t\t@handle = handle\r\n\t\t\t#@noteid = noteid\r\n\t\t\t#@universalid = originatorid.universalid\r\n\t\t\t#@modified = modified.to_t\r\n\t\t\t#@note_class = note_class\r\n\t\t\t#@sequence = originatorid.sequence\r\n\t\t\t#@sequence_time = originatorid.sequence_time.to_t\r\n\t\t\t\r\n\t\t\tupdate_note_info!\r\n\t\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Count childern (one level only)
def children_count i = 0 children { |c| i+=1} return i end
[ "def nest_count\n my_nests.count\n end", "def count_children\n render :text => @node.children.count\n end", "def count_leafs\n self.keys.inject(0) do |result, element|\n if self[element].kind_of?(Hash)\n result+=self[element].count_leafs\n else\n result+=1\n end\n end\n end", "def child_count\r\n self.children.reject { |c| c.nil? }.size\r\n end", "def descendent_count_helper(folder)\n folder.children.inject(folder.children.all.size) do |sum, child|\n descendent_count_helper(child) + sum\n end\n end", "def nested_notes_count\n count = notes.any? ? notes.count : 0\n subcategories.each do |category|\n next unless category.notes.any?\n\n count += category.notes.count\n end\n count\n end", "def child_count(*args)\n child_rels(*args).size\n end", "def parent_count(*args)\n parent_rels(*args).size\n end", "def nodeCount\n count = 1\n\n if @children.size\n @children.each do |key, val|\n count += val.nodeCount\n end\n end\n\n count\n end", "def calculate_num_children\n for x in @lattice do\n for c in @lattice.lower_covers[x] do\n if @irreducibles.contain?(c) then\n @num_children[x] += 1\n end\n end\n end\n end", "def num_nests\n my_nests.length\n end", "def count_children(node)\n\t\treturn 0 if node.children.nil?\n\t\tnode.children.count + (node.children.map {|child| count_children(child)}).inject(&:+)\n\tend", "def get_number_of_root_elements(elements)\n num = 0\n parent_field = @db_fields[:parent]\n elements.each do |e|\n num += 1 if e.send(parent_field) == 0\n end\n num\n end", "def count_childless_nodes(root)\n \n end", "def number_of_children\n @children.size\n end", "def sub_node_count\n sub_nodes.size\n end", "def tree_width\n num_branches = 0\n ancestry = self.steps.pluck(:ancestry)\n repeat_ancestry = ancestry.group_by {|e| e}.select { |k,v| v.size > 1}.keys\n repeat_ancestry.each do |value|\n num_branches = num_branches + ancestry.grep(value).size\n end\n return num_branches\n end", "def deep_count(arr)\n count = 0\n arr.each do |el|\n if el.class != Array\n count += 1\n else\n count += 1 + deep_count(el)\n end\n end\n count\nend", "def num_children\n @children.size\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a text describing original message (not the object)
def original_text o = original case o when String "ALOIS_ERROR: #{o}" when NilClass "NO ORIGINAL FOUND" else o[0].msg end end
[ "def message\n m = super.dup\n m << \" #{text}\" if text\n m << \" (#{code}, #{description.inspect})\"\n end", "def message\n str = super\n self.class.get_reason + (str.empty? ? \"\" : \": #{str}\")\n end", "def to_s\n @message_text\n end", "def message\n m = super\n m << \" (#{code}, #{description.inspect})\"\n end", "def get_new_text(original, translated)\n original + \"\\n----------#{translation_message}----------\\n\" + translated\n end", "def message\n \"#{original_message}\\n\\t#{backtrace.join(\"\\n\\t\")}\"\n end", "def getMessage()\n return @message\n end", "def raw_message\n @raw_message\n end", "def get_raw_message\n @raw_message\n end", "def main_message\n result = \"#{main.message}\\n\"\n notes.each do |note|\n result << note.format_diagnostic\n end\n result\n end", "def message\n FilteredTerm.apply(@message) || ''\n end", "def general_msg()\n return complex_command(@@general_commands[@msg[2].to_s()])\n end", "def message\n return unless valid?\n\n trade_info['Message']\n end", "def reason\n RichText.new(self[:reason_format], self[:reason])\n end", "def message\n if self[:child].null?\n best_message\n else\n \"#{best_message}: #{cause_message}\"\n end\n end", "def internal_reply_message\n return @internal_reply_message\n end", "def customized_message_body\n return @customized_message_body\n end", "def to_s\n self.long_message\n end", "def msg\n\treturn @msg_buf.dup()\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /quiz_attempts GET /quiz_attempts.json
def index @quiz_attempts = QuizAttempt.all end
[ "def get_exam_attempts(user_id, course_id, exam_id)\r\n get(Path::USERS_COURSES_EXAMS_ATTEMPTS % [user_id, course_id, exam_id])\r\n end", "def index\n @quiz = Quiz.find(params[:quiz_id])\n @quiz_attempts = @quiz.quiz_attempts.all\n end", "def index\n @attempts = Attempt.all\n end", "def index\n @attempts = Attempt.order('updated_at DESC').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @attempts }\n end\n end", "def attempts\n @course_ids = current_user_or_anonymous_user.challenge_responses.select(:course_id).group(:course_id).map(&:course_id).compact\n\n render json: @course_ids\n end", "def index\n @test_attempts = TestAttempt.all\n end", "def index\n @exam_attempts = ExamAttempt.all\n end", "def index\n @attempts = Attempt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attempts }\n end\n end", "def attempts_for course\n exams.for_course(course).first(:order => \"attempt DESC\").attempt rescue 0\n end", "def index\n @problem_attempts = ProblemAttempt.all\n end", "def get_exam_attempt(user_id, course_id, exam_id, attempt_id)\r\n get(Path::USERS_COURSES_EXAMS_ATTEMPTS_WITH_ID % [user_id,\r\n course_id,\r\n exam_id,\r\n attempt_id])\r\n end", "def index\n @student_attempts = StudentAttempt.all\n end", "def attempts\n doc['attempts'] || 0\n end", "def attempt\n rated_puzzle = RatedPuzzle.find puzzle_attempt_params[:id]\n if user_rating.rated_puzzle_attempts.exists?(rated_puzzle_id: rated_puzzle.id)\n render status: 400, json: {\n error: \"Puzzle #{rated_puzzle.id} already attempted\"\n }\n return\n end\n rating_updater = RatingUpdater.new(current_user, rated_puzzle)\n rated_puzzle_attempt = rating_updater.attempt!(puzzle_attempt_params)\n render json: {\n rated_puzzle_attempt: rated_puzzle_attempt.as_json({\n only: [\n :outcome,\n :pre_user_rating,\n :post_user_rating,\n :pre_puzzle_rating,\n :post_puzzle_rating,\n ]\n }),\n user_rating: current_user.user_rating.reload.as_json({\n only: [:rated_puzzle_attempts_count]\n })\n }\n end", "def index\n @coffee_attempts = CoffeeAttempt.all\n end", "def index\n @attempt_questions = AttemptQuestion.all\n end", "def new\n @question = Question.find(params[:question_id])\n @attempt = @question.attempts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attempt }\n end\n end", "def num_attempts\n @num_attempts\n end", "def index\n @attempt_attributes = AttemptAttribute.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @attempt_attributes }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts a CamelCased symbol into a path component. A +Single+ symbol becomes +single+. +MultiWordSymbols+ become +multi_word_symbols+. +ACRONYMS+ are treated like words: +acronyms+. +ABCFoo+ is considered to be a mix of acronyms and words: +abc_foo+.
def easyload_path_component_for_sym(sym) path = sym.to_s.dup path.gsub!(/([A-Z]+)([A-Z][a-z]+)/, '\1_\2_') path.gsub!(/([A-Z][a-z]+)/, '\1_') path.gsub!(/_+/, '_') path.chomp!('_') path.downcase! end
[ "def pathize(string)\n string\n .gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n .gsub(/([a-z])([A-Z][a-z])/, '\\1_\\2')\n .gsub(\"__\", \"/\")\n .gsub(\"::\", \"/\")\n .gsub(/\\s+/, \"\") # spaces are bad form\n .gsub(/[?%*:|\"<>.]+/, \"\") # reserved characters\n .downcase\n end", "def titleize_symbol symbol\n title = symbol.to_s.split('_')\n title.each { |word| word.capitalize! }.join(' ')\nend", "def to_sym\n @path.to_sym\n end", "def constantize(s)\n s.to_s.split('_').map(&:capitalize).join.to_sym\n end", "def as_sym\n clean\n .gsub(/\\s+/, '_')\n .gsub(/[^_A-Za-z0-9]/, '')\n .downcase.to_sym\n end", "def path_to_name\n NameCase(tr('_-', ' ').upcase).titlecase\n end", "def canonical(string_or_symbol)\n string_or_symbol.to_s.downcase.to_sym\n end", "def camel_path\n @camel_path ||= original_path.gsub('schemas', 'schemas_camelized')\n end", "def xml_string symbol\n if symbol.is_a? String\n symbol\n else\n symbol.to_s.gsub('_',' ').gsub(/\\b./, &:upcase)\n end\n end", "def to_standardized_sym\n standardize\n .to_sym\n end", "def symbol_to_name(sym)\n parts = sym.to_s.split(\"_\").map(&:capitalize)\n parts[0].downcase!\n \"ga:\" + parts.join('')\n end", "def underscore\n\t\tcamel_cased_word = self\n\t\tword = camel_cased_word.to_s.dup\n\t\tword.gsub!(/::/, '/')\n#\t\tword.gsub!(/(?:([A-Za-z\\d])|^)(#{inflections.acronym_regex})(?=\\b|[^a-z])/) { \"#{$1}#{$1 && '_'}#{$2.downcase}\" }\n\t\tword.gsub!(/([A-Z\\d]+)([A-Z][a-z])/,'\\1_\\2')\n\t\tword.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n\t\tword.tr!(\"-\", \"_\")\n\t\tword.downcase!\n\t\tword\n\tend", "def symbolize(s)\n s.to_s.gsub(/\\s+/,\"_\").gsub(/\\W+/,\"\").downcase.to_sym\n end", "def sym2portw_name(sym)\n return (\"^\" + sym.to_s).to_sym\n end", "def snake_sym(key)\n key.is_a?(String) ? key.gsub(/(.)([A-Z])/,'\\1_\\2').downcase.to_sym : key\n end", "def slug_to_snakecase_symbol(slug)\n slug.gsub(/-/, \"_\").to_sym\n end", "def to_symbol from_string\n return from_string.strip.gsub(\".\", \"_\").to_sym\n end", "def method_missing sym\n raise NoMethodError.new(\"Undefined method #{sym} for String\") unless sym.to_s.end_with? \"?\"\n this = self.downcase.gsub(\"_\",\" \")\n that = sym.to_s.clip # remove ?\n that = that.downcase.gsub(\"_\",\" \")\n this == that\n end", "def constantize(camel_cased_word)\n camel_cased_word = camel_cased_word.to_s\n\n if camel_cased_word.include?('-')\n camel_cased_word = classify(camel_cased_word)\n end\n\n names = camel_cased_word.split('::')\n names.shift if names.empty? || names.first.empty?\n\n constant = Object\n names.each do |name|\n constant = constant.const_get(name) || constant.const_missing(name)\n end\n constant\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /newhope_teams/1 GET /newhope_teams/1.xml
def show @newhope_team = NewhopeTeam.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @newhope_team } end end
[ "def index\n @teams = Team.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams }\n end\n end", "def new\n @newhope_team = NewhopeTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newhope_team }\n end\n end", "def new\n @team = @current_competition.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def index\n @tfl_teams = TflTeam.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tfl_teams }\n end\n end", "def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end", "def new\n @users_team = UsersTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @users_team }\n end\n end", "def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def index\n league = get_league\n @teams = league.teams\n render json: @teams, status: 201\n end", "def new\n @wrestler = Wrestler.new\n @teams = Team.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def show\n @team = subdomain.teams.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end", "def index\n @mm_teams = MmTeam.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mm_teams }\n end\n end", "def show\n @users_team = UsersTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @users_team }\n end\n end", "def index\n @teams_users = TeamsUser.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams_users }\n end\n end", "def new\n @user_team = UserTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_team }\n end\n end", "def get_teams\n Resources::Team.parse(request(:get, \"Teams\"))\n end", "def index\n @afl_teams = AflTeam.find(:all, :order => :name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @afl_teams }\n end\n end", "def show\n @user_team = UserTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_team }\n end\n end", "def new\n @real_team = RealTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @real_team }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /newhope_teams/new GET /newhope_teams/new.xml
def new @newhope_team = NewhopeTeam.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @newhope_team } end end
[ "def new\n @team = @current_competition.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def new\n @unknown_team = UnknownTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @unknown_team }\n end\n end", "def new\n @teams = Team.find(:all)\n @stampeder = Stampeder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stampeder }\n end\n end", "def new\n @users_team = UsersTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @users_team }\n end\n end", "def new\n @real_team = RealTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @real_team }\n end\n end", "def new\n @user_team = UserTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_team }\n end\n end", "def new\n @opposition_team = OppositionTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @opposition_team }\n end\n end", "def new\n @tfl_team = TflTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tfl_team }\n end\n end", "def new\n @teammate = Teammate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teammate }\n end\n end", "def new\n @team_for_the_match = TeamForTheMatch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team_for_the_match }\n end\n end", "def new\n @league = League.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @league }\n end\n end", "def new\n @tournament = Tournament.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tournament }\n end\n end", "def new\n @pro_team = ProTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pro_team }\n end\n end", "def new\n @teammember = Teammember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teammember }\n end\n end", "def new\n @team_member = TeamMember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team_member }\n end\n end", "def new\n @wrestler = Wrestler.new\n @teams = Team.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def new\n @ncaa_team = NcaaTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ncaa_team }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /newhope_teams POST /newhope_teams.xml
def create @newhope_team = NewhopeTeam.new(params[:newhope_team]) respond_to do |format| if @newhope_team.save format.html { redirect_to(@newhope_team, :notice => 'Newhope team was successfully created.') } format.xml { render :xml => @newhope_team, :status => :created, :location => @newhope_team } else format.html { render :action => "new" } format.xml { render :xml => @newhope_team.errors, :status => :unprocessable_entity } end end end
[ "def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to(teams_url, :notice => 'Team was successfully created.') }\n format.xml { render :xml => @team, :status => :created, :location => @team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @newhope_team = NewhopeTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newhope_team }\n end\n end", "def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n flash[:notice] = 'Team was successfully created.'\n format.html { redirect_to(team_path(@team)) }\n format.xml { render :xml => @team, :status => :created, :location => @team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n flash[:notice] = 'Team was successfully created.'\n format.html { redirect_to(@team) }\n format.xml { render :xml => @team, :status => :created, :location => @team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @users_team = UsersTeam.new(params[:users_team])\n\n respond_to do |format|\n if @users_team.save\n format.html { redirect_to(@users_team, :notice => 'Users team was successfully created.') }\n format.xml { render :xml => @users_team, :status => :created, :location => @users_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @users_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_team = UserTeam.new(params[:user_team])\n\n respond_to do |format|\n if @user_team.save\n format.html { redirect_to(@user_team, :notice => 'User team was successfully created.') }\n format.xml { render :xml => @user_team, :status => :created, :location => @user_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @opposition_team = OppositionTeam.new(params[:opposition_team])\n\n respond_to do |format|\n if @opposition_team.save\n format.html { redirect_to(@opposition_team, :notice => 'Opposition team was successfully created.') }\n format.xml { render :xml => @opposition_team, :status => :created, :location => @opposition_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @opposition_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @team = @current_competition.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def create\n @ultimate_team = UltimateTeam.new(params[:ultimate_team])\n\n respond_to do |format|\n if @ultimate_team.save\n format.html { redirect_to @ultimate_team, notice: 'Ultimate team was successfully created.' }\n format.json { render json: @ultimate_team, status: :created, location: @ultimate_team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ultimate_team.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @test_team = TestTeam.new(params[:test_team])\n\n respond_to do |format|\n if @test_team.save\n format.html { redirect_to @test_team, notice: 'Test team was successfully created.' }\n format.json { render json: @test_team, status: :created, location: @test_team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_team.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unknown_team = UnknownTeam.new(params[:unknown_team])\n\n respond_to do |format|\n if @unknown_team.save\n flash[:notice] = 'UnknownTeam was successfully created.'\n format.html { redirect_to(@unknown_team) }\n format.xml { render :xml => @unknown_team, :status => :created, :location => @unknown_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unknown_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tfl_team = TflTeam.new(params[:tfl_team])\n\n respond_to do |format|\n if @tfl_team.save\n flash[:notice] = 'TflTeam was successfully created.'\n format.html { redirect_to(@tfl_team) }\n format.xml { render :xml => @tfl_team, :status => :created, :location => @tfl_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tfl_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_team()\n begin\n bodyParams = {\n 'public': true,\n 'name': \"Ruby Team\",\n # Add internal members using their extension ids\n # Get your user extension id by calling the /restapi/v1.0/account/~/extension endpoint!\n 'members': [{ 'id': \"590490017\"}, { 'id': \"595861017\"}],\n # You can also add members using their email address, especially for guest members who are not under your account company.\n # 'members': [{'email': \"member.1@gmail.com\"}, { 'email': \"member.2@gmail.com\"}, {'id': \"[extensionId]\"}],\n 'description': \"Let's talk about Ruby\"\n }\n endpoint = \"/team-messaging/v1/teams\"\n resp = $platform.post(endpoint, payload: bodyParams)\n puts resp.body\n rescue StandardError => e\n puts (e)\n end\nend", "def create\r\n # This line determines whether the original create team request came from a services or teams and sets up the redirect accordingly\r\n origin_redirect = params[:team][:origin] == 'services'? new_service_path : teams_path\r\n \r\n # Removes the :origin key/value from the params as is not part of saving the model\r\n params[:team].delete :origin\r\n @team = Team.new(params[:team])\r\n @buttonvalue = \"create team\"\r\n \r\n respond_to do |format|\r\n if @team.save\r\n current_user.teamsusers.create!(:team_id => @team.id, :role => 'admin')\r\n format.html { redirect_to origin_redirect + \"?myTeam=\" + @team.id.to_s, notice: 'Your team has been successfully created.' }\r\n format.json { render json: @team, status: :created, location: @team }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @team.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @bet_team = Bet::Team.new(bet_team_params)\n\n respond_to do |format|\n if @bet_team.save\n format.html { redirect_to @bet_team, notice: \"Team was successfully created.\" }\n format.json { render :show, status: :created, location: @bet_team }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bet_team.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @team = Team.new(params[:team])\n\n if @team.save\n render json: @team, status: :created, location: @team\n else\n render json: @team.errors, status: :unprocessable_entity\n end\n end", "def create\n @pro_team = ProTeam.new(params[:pro_team])\n\n respond_to do |format|\n if @pro_team.save\n flash[:notice] = 'ProTeam was successfully created.'\n format.html { redirect_to(@pro_team) }\n format.xml { render :xml => @pro_team, :status => :created, :location => @pro_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pro_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @real_team = RealTeam.new(params[:real_team])\n\n respond_to do |format|\n if @real_team.save\n flash[:notice] = 'RealTeam was successfully created.'\n format.html { redirect_to(@real_team) }\n format.xml { render :xml => @real_team, :status => :created, :location => @real_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @real_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @games_team = GamesTeam.new(games_team_params)\n\n respond_to do |format|\n if @games_team.save\n format.html { redirect_to @games_team, notice: 'Games team was successfully created.' }\n format.json { render :show, status: :created, location: @games_team }\n else\n format.html { render :new }\n format.json { render json: @games_team.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /newhope_teams/1 PUT /newhope_teams/1.xml
def update @newhope_team = NewhopeTeam.find(params[:id]) respond_to do |format| if @newhope_team.update_attributes(params[:newhope_team]) format.html { redirect_to(@newhope_team, :notice => 'Newhope team was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @newhope_team.errors, :status => :unprocessable_entity } end end end
[ "def create\n @newhope_team = NewhopeTeam.new(params[:newhope_team])\n\n respond_to do |format|\n if @newhope_team.save\n format.html { redirect_to(@newhope_team, :notice => 'Newhope team was successfully created.') }\n format.xml { render :xml => @newhope_team, :status => :created, :location => @newhope_team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @newhope_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:id])\n\n if @team.update_attributes(params[:team])\n head :no_content\n else\n render json: @team.errors, status: :unprocessable_entity\n end\n end", "def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to(teams_url, :notice => 'Team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @opposition_team = OppositionTeam.find(params[:id])\n\n respond_to do |format|\n if @opposition_team.update_attributes(params[:opposition_team])\n format.html { redirect_to(@opposition_team, :notice => 'Opposition team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @opposition_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @unknown_team = UnknownTeam.find(params[:id])\n if params[:commit] == \"Update\"\n team = Team.find(params[:team][:team_id])\n unless team.nil?\n synonym = TeamSynonym.new\n synonym.synonym = @unknown_team.name\n synonym.team_id = team.id\n synonym.sport_id = team.sport_id\n if synonym.save\n @unknown_team.destroy\n respond_to do |format|\n format.html { redirect_to(unknown_teams_url) } \n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unknown_team.errors, :status => :unprocessable_entity }\n end\n end\n elsif (params[:commit] == \"Create New Team\")\n team = Team.new\n team.sport_id = @unknown_team.sport_id\n team.name = @unknown_team.name\n if team.save\n @unknown_team.destroy\n respond_to do |format|\n format.html { redirect_to(unknown_teams_url) } \n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unknown_team.errors, :status => :unprocessable_entity }\n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unknown_team.errors, :status => :unprocessable_entity }\n end\n end", "def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to(@team, :notice => 'Team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n flash[:notice] = 'Team was successfully updated.'\n format.html { redirect_to(team_path(@team)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @newhope_team = NewhopeTeam.find(params[:id])\n @newhope_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(newhope_teams_url) }\n format.xml { head :ok }\n end\n end", "def new\n @newhope_team = NewhopeTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newhope_team }\n end\n end", "def update\n team_name = params[:name]\n team_description = params[:description]\n team_id = params[:id]\n\n respond_to do |format|\n if OkrTeam.where(id: team_id).update_all(name: team_name, description: team_description)\n format.json { render json: 'Team is updated successfully!', status: :ok }\n else\n format.json { render json: 'Error!', status: :unprocessable_entity }\n end\n end\n end", "def update\n @team = subdomain.teams.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to(@team, :notice => 'Team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ultimate_team = UltimateTeam.find(params[:id])\n\n respond_to do |format|\n if @ultimate_team.update_attributes(params[:ultimate_team])\n format.html { redirect_to @ultimate_team, notice: 'Ultimate team was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ultimate_team.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to(teams_url, :notice => 'Team was successfully created.') }\n format.xml { render :xml => @team, :status => :created, :location => @team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @users_team = UsersTeam.find(params[:id])\n\n respond_to do |format|\n if @users_team.update_attributes(params[:users_team])\n format.html { redirect_to(@users_team, :notice => 'Users team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @users_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @persona_team = PersonaTeam.find(params[:id])\n\n respond_to do |format|\n if @persona_team.update_attributes(params[:persona_team])\n flash[:notice] = 'Persona team was successfully updated.'\n format.html { redirect_to(@persona_team) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @persona_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @league = League.find(params[:league_id])\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_team = UserTeam.find(params[:id])\n\n respond_to do |format|\n if @user_team.update_attributes(params[:user_team])\n format.html { redirect_to(@user_team, :notice => 'User team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n flash[:notice] = 'Team was successfully created.'\n format.html { redirect_to(team_path(@team)) }\n format.xml { render :xml => @team, :status => :created, :location => @team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @teams_test = TeamsTest.find(params[:id])\n\n respond_to do |format|\n if @teams_test.update_attributes(params[:teams_test])\n format.html { redirect_to @teams_test, notice: 'Teams test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @teams_test.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /newhope_teams/1 DELETE /newhope_teams/1.xml
def destroy @newhope_team = NewhopeTeam.find(params[:id]) @newhope_team.destroy respond_to do |format| format.html { redirect_to(newhope_teams_url) } format.xml { head :ok } end end
[ "def removeFromTournament\n @tournament = Tournament.find(params[:tournament_id])\n \t@team = Team.find(params[:id])\n \t@tournament.teams.delete(@team)\n\t\n respond_to do |format|\n format.html { redirect_to(tournament_path(@tournament)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @afl_team = AflTeam.find(params[:id])\n @afl_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(afl_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @team = subdomain.teams.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(team_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sim_team = SimTeam.find(params[:id])\n @sim_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(sim_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @opposition_team = OppositionTeam.find(params[:id])\n @opposition_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(opposition_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @users_team = UsersTeam.find(params[:id])\n @users_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @real_team = RealTeam.find(params[:id])\n @real_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(real_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_team = UserTeam.find(params[:id])\n @user_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @unknown_team = UnknownTeam.find(params[:id])\n @unknown_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(unknown_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @vteam = Vteam.find(params[:id])\n @vteam.destroy\n\n respond_to do |format|\n format.html { redirect_to(vteams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tfl_team = TflTeam.find(params[:id])\n @tfl_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(tfl_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @teammember = Teammember.find(params[:id])\n @teammember.destroy\n\n respond_to do |format|\n format.html { redirect_to(season_teams_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @teammate = Teammate.find(params[:id])\n @teammate.destroy\n\n respond_to do |format|\n format.html { redirect_to(teammates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pro_team = ProTeam.find(params[:id])\n @pro_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(pro_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @league = League.find(params[:id])\n @league.destroy\n\n respond_to do |format|\n format.html { redirect_to(leagues_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ncaa_team = NcaaTeam.find(params[:id])\n @ncaa_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_ncaa_teams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @mm_team = MmTeam.find(params[:id])\n @mm_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(mm_teams_url) }\n format.xml { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /car_type_rates/new GET /car_type_rates/new.json
def new @car_type_rate = CarTypeRate.new respond_to do |format| format.html # new.html.erb format.json { render json: @car_type_rate } end end
[ "def new\n @rate = Rate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rate }\n end\n end", "def new\n @crate_type = CrateType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @crate_type }\n end\n end", "def create\n @car_type_rate = CarTypeRate.new(params[:car_type_rate])\n\n respond_to do |format|\n if @car_type_rate.save\n format.html { redirect_to @car_type_rate, notice: '车型价格生成成功!' }\n format.json { render json: @car_type_rate, status: :created, location: @car_type_rate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @car_type_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @tax_rate = TaxRate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tax_rate }\n end\n end", "def new\n @rate_category = RateCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rate_category }\n end\n end", "def new\n @rate_type = RateType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rate_type }\n end\n end", "def new\n @recurrency = Recurrency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recurrency }\n end\n end", "def new\n @rate = Rate.new\n\n respond_to do |format|\n format.html { render :template => 'rates/new', :layout => false}\n format.xml { render :xml => @rate }\n end\n end", "def new\n @costtype = Costtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @costtype }\n end\n end", "def new\n\n # get the client & contract\n @client, @contract = get_client_and_contract(params[:client_id],params[:contract_id])\n\n # create the new rate\n @rate = Rate.new\n\n # set the default ni_rate and hol_accrual_rate\n @ni_rate = Settings.get_setting('ni_rate', Date.today).value\n @hol_accrual_rate = Settings.get_setting('hol_accrual_rate', Date.today).value\n\n # define a list of rates for the drop down\n @rates_list = {'Overtime' => 'Overtime', 'Bank Holiday' => 'Bank Holiday', 'Sickness' => 'Sickness', 'Other' => 'Other'}\n\n end", "def new\n @cost_type = CostType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cost_type }\n end\n end", "def create\n @rate = Rate.new(rate_params)\n\n if @rate.save\n render json: @rate, status: :created, location: @rate\n else\n render json: @rate.errors, status: :unprocessable_entity\n end\n end", "def new\n @car = Car.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @car }\n\t \n end\n end", "def new\n @carrier_type = CarrierType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carrier_type }\n end\n end", "def new\n @new_car = NewCar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_car }\n end\n end", "def new\n @price_type = PriceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @price_type }\n end\n end", "def new\n @car = Car.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @car }\n end\n end", "def new\n @shipping_rate = ShippingRate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shipping_rate }\n end\n end", "def create\n @rate = Rate.new(rate_params)\n\n respond_to do |format|\n if @rate.save\n format.html { redirect_to @rate, notice: 'Rate was successfully created.' }\n format.json { render :show, status: :created, location: @rate }\n else\n format.html { render :new }\n format.json { render json: @rate.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /car_type_rates POST /car_type_rates.json
def create @car_type_rate = CarTypeRate.new(params[:car_type_rate]) respond_to do |format| if @car_type_rate.save format.html { redirect_to @car_type_rate, notice: '车型价格生成成功!' } format.json { render json: @car_type_rate, status: :created, location: @car_type_rate } else format.html { render action: "new" } format.json { render json: @car_type_rate.errors, status: :unprocessable_entity } end end end
[ "def new\n @car_type_rate = CarTypeRate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @car_type_rate }\n end\n end", "def create\n @rate = Rate.new(rate_params)\n\n if @rate.save\n render json: @rate, status: :created, location: @rate\n else\n render json: @rate.errors, status: :unprocessable_entity\n end\n end", "def create\n @rate = Rate.new(rate_params)\n\n respond_to do |format|\n if @rate.save\n format.html { redirect_to @rate, notice: 'Rate was successfully created.' }\n format.json { render :show, status: :created, location: @rate }\n else\n format.html { render :new }\n format.json { render json: @rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ratetype = Ratetype.new(ratetype_params)\n\n respond_to do |format|\n if @ratetype.save\n format.html { redirect_to ratetypes_path, notice: 'Clase de elemento creada exitosamente' }\n format.json { render :show, status: :created, location: @ratetype }\n else\n format.html { render :new }\n format.json { render json: @ratetype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @currency_rate = RateSaver.new(currency_rate_params)\n respond_to do |format|\n if @currency_rate.save\n format.html { redirect_to '/', notice: 'Currency rate was successfully created.' }\n @usd_rate = @currency_rate.object.formated_rate\n format.json { render :index }\n else\n @currency_rate = @currency_rate.object\n format.html { render :new }\n format.json { render json: @currency_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tax_rate = TaxRate.new(params[:tax_rate])\n\n respond_to do |format|\n if @tax_rate.save\n format.html { redirect_to @tax_rate, :notice => t('controller.successfully_created', :model => t('activerecord.models.tax_rate')) }\n\tformat.json { render :json => @tax_rate, :status => :created, :location => @tax_rate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tax_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rate_type = RateType.new(params[:rate_type])\n\n respond_to do |format|\n if @rate_type.save\n format.html { redirect_to(@rate_type, :notice => 'Rate type was successfully created.') }\n format.xml { render :xml => @rate_type, :status => :created, :location => @rate_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rate_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tax_rate = TaxRate.new(params[:tax_rate])\n\n respond_to do |format|\n if @tax_rate.save\n format.html { redirect_to @tax_rate, notice: 'Tax rate was successfully created.' }\n format.json { render json: @tax_rate, status: :created, location: @tax_rate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tax_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reference_rate = ReferenceRate.new(reference_rate_params)\n\n respond_to do |format|\n if @reference_rate.save\n format.html { redirect_to @reference_rate, notice: 'Reference rate was successfully created.' }\n format.json { render action: 'show', status: :created, location: @reference_rate }\n else\n format.html { render action: 'new' }\n format.json { render json: @reference_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room_type_rate = RoomTypeRate.new(room_type_rate_params)\n\n respond_to do |format|\n if @room_type_rate.save\n format.html { redirect_to @room_type_rate, notice: 'Room type rate was successfully created.' }\n format.json { render :show, status: :created, location: @room_type_rate }\n else\n format.html { render :new }\n format.json { render json: @room_type_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @car_type = CarType.new(car_type_params)\n\n respond_to do |format|\n if @car_type.save\n format.html { redirect_to car_types_path, notice: 'Car type was successfully created.' }\n format.json { render :index, status: :created }\n else\n format.html { render :new }\n format.json { render json: @car_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def nbg_rates\n data = { valid: true } # assume that at start it is failing\n # http://localhost:3000/en/api/v1/nbg_rates?currency=EUR&start_date=1461758741831&end_date=1457870734966\n params[:currency] ||= 'USD'\n flag = true\n @errors = []\n start_date = to_date('start_date', true)\n end_date = to_date('end_date', true)\n validate_dates(start_date, end_date)\n\n if !@errors.any?\n result = []\n @currencies = Currency.data\n flag = false\n\n params[:currency].split(',').each{|cur_item|\n if @currency_codes.has_key?(cur_item)\n cur = @currencies.select{|c| c[0] == cur_item }.first\n x = Rate.nbg_rates(cur_item,{from: start_date,to: end_date})\n if x.present?\n result << {code: cur[0], name: cur[1], ratio: cur[2], rates: x}\n flag = true\n end\n else\n error(\"currency_does_not_exist\", { pars: [cur_item]})\n end\n }\n end\n\n if !flag\n error(\"missing_data_currency\")\n end\n\n\n if @errors.any?\n data['errors'] = @errors\n data['valid'] = false\n else\n data['result'] = result\n end\n\n respond_to do |format|\n format.json { render json: data, :callback => params[:callback] }\n end\n end", "def update\n @car_type_rate = CarTypeRate.find(params[:id])\n\n respond_to do |format|\n if @car_type_rate.update_attributes(params[:car_type_rate])\n format.html { redirect_to @car_type_rate, notice: 'Car type rate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @car_type_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_rates_table(options = {})\n post(:rates_tables, rates_tables: [options]).pop\n end", "def rates(date)\n build_rates(date)\n end", "def create\n @rate = Rate.new(params[:rate])\n\n respond_to do |format|\n if @rate.save\n format.html { redirect_to(@rate, :notice => 'Rate was successfully created.') }\n format.xml { render :xml => @rate, :status => :created, :location => @rate }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rate.errors, :status => :unprocessable_entity }\n end\n end\n end", "def list_rate_types_by_country(country, options={}) path = \"/api/v2/definitions/countries/#{country}/ratetypes\"\n get(path, options, AvaTax::VERSION) end", "def create\n @rate_service = RateService.new(rate_service_params)\n if @rate_service.save\n render json: @rate_service, status: :created, location: @rate_service\n else \n render json: @rate_service.errors, status: :unprocessable_entity\n end \n end", "def create\n @car_rating = CarRating.new(car_rating_params)\n\n respond_to do |format|\n if @car_rating.save\n format.html { redirect_to @car_rating, notice: 'Car rating was successfully created.' }\n format.json { render :show, status: :created, location: @car_rating }\n else\n format.html { render :new }\n format.json { render json: @car_rating.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /car_type_rates/1 PUT /car_type_rates/1.json
def update @car_type_rate = CarTypeRate.find(params[:id]) respond_to do |format| if @car_type_rate.update_attributes(params[:car_type_rate]) format.html { redirect_to @car_type_rate, notice: 'Car type rate was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @car_type_rate.errors, status: :unprocessable_entity } end end end
[ "def update\n respond_to do |format|\n if @ratetype.update(ratetype_params)\n format.html { redirect_to ratetypes_path, notice: 'Ratetype was successfully updated.' }\n format.json { render :show, status: :ok, location: @ratetype }\n else\n format.html { render :edit }\n format.json { render json: ratetypes_path.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @rate = Rate.find(params[:id])\n\n if @rate.update(rate_params)\n #head :no_content\n render json: @rate, status: :accepted, location: @rate #sera? status accepted? \n else\n render json: @rate.errors, status: :unprocessable_entity\n end\n end", "def update_rates\n \n Updaterete.update_single_rate(params)\n @get_rates = Updaterete.get_rates(params)\n render :layout=>\"gds\"\n end", "def update\n respond_to do |format|\n if @rate.update(rate_params)\n format.html { redirect_to @rate, notice: 'Rate was successfully updated.' }\n format.json { render :show, status: :ok, location: @rate }\n else\n format.html { render :edit }\n format.json { render json: @rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @rate_type = RateType.find(params[:id])\n\n respond_to do |format|\n if @rate_type.update_attributes(params[:rate_type])\n format.html { redirect_to(@rate_type, :notice => 'Rate type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rate_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @car_type_rate = CarTypeRate.new(params[:car_type_rate])\n\n respond_to do |format|\n if @car_type_rate.save\n format.html { redirect_to @car_type_rate, notice: '车型价格生成成功!' }\n format.json { render json: @car_type_rate, status: :created, location: @car_type_rate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @car_type_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @car_type.update(car_type_params)\n respond_with(@car_type, location: car_types_url, notice: 'Car type was successfully updated.')\n else\n respond_with(@car_type)\n end\n end", "def update\n @tax_rate = @shop.tax_rates.find params[:id]\n\n respond_to do |format|\n if @tax_rate.update_attributes(params[:tax_rate])\n format.html { redirect_to shop_tax_rates_path(@tax_rate.shop), notice: 'Tax was successfully updated.' }\n format.json { render json: @tax_rate }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tax_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @rate.update(rate_params)\n format.html { redirect_to @rate, notice: 'Rate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @car_type.update(car_type_params)\n format.html { redirect_to car_types_path, notice: 'Car type was successfully updated.' }\n format.json { render :show, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @car_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @rate_service.update(rate_service_params)\n render json: @rate_service, status: :ok, location: @rate_service\n else\n render json: @rate_service.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @car_type_rate = CarTypeRate.find(params[:id])\n @car_type_rate.destroy\n\n respond_to do |format|\n format.html { redirect_to car_type_rates_url }\n format.json { head :no_content }\n end\n end", "def new\n @car_type_rate = CarTypeRate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @car_type_rate }\n end\n end", "def rate(args = {})\n make_request(\n http_method: :put,\n endpoint: path_for(:rating, ride_id: args.delete(:ride_id)),\n access_token: args.delete(:access_token),\n options: { body: args.to_json }\n )\n end", "def update\n respond_to do |format|\n if @car_rating.update(car_rating_params)\n format.html { redirect_to @car_rating, notice: 'Car rating was successfully updated.' }\n format.json { render :show, status: :ok, location: @car_rating }\n else\n format.html { render :edit }\n format.json { render json: @car_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tax_rate = TaxRate.find(params[:id])\n\n respond_to do |format|\n if @tax_rate.update_attributes(params[:tax_rate])\n format.html { redirect_to @tax_rate, :notice => t('controller.successfully_updated', :model => t('activerecord.models.tax_rate')) }\n\tformat.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tax_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tax_rate = TaxRate.find(params[:id])\n\n respond_to do |format|\n if @tax_rate.update_attributes(params[:tax_rate])\n format.html { redirect_to @tax_rate, notice: 'Tax rate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tax_rate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @carrier_type = CarrierType.find(params[:id])\n\n respond_to do |format|\n if @carrier_type.update_attributes(params[:carrier_type])\n format.html { redirect_to @carrier_type, notice: 'Carrier type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @carrier_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # logger.debug (\"tmp.class: \" + interest_rate_params[:rate].class.to_s)\n respond_to do |format|\n if @interest_rate.update(interest_rate_params)\n # format.html { redirect_to @interest_rate, notice: 'Interest rate was successfully updated.' }\n format.html { redirect_to interest_rates_path, notice: 'Interest rate was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @interest_rate.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /car_type_rates/1 DELETE /car_type_rates/1.json
def destroy @car_type_rate = CarTypeRate.find(params[:id]) @car_type_rate.destroy respond_to do |format| format.html { redirect_to car_type_rates_url } format.json { head :no_content } end end
[ "def destroy\n @rate.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @ratetype.destroy\n respond_to do |format|\n format.html { redirect_to ratetypes_url, notice: 'Ratetype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tax_rate = TaxRate.find(params[:id])\n @tax_rate.destroy\n\n respond_to do |format|\n format.html { redirect_to tax_rates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reference_rate.destroy\n respond_to do |format|\n format.html { redirect_to reference_rates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rate.destroy\n respond_to do |format|\n format.html { redirect_to rates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rate = Rate.find(params[:id])\n @rate.destroy\n\n respond_to do |format|\n format.html { redirect_to rates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tax_rate = @shop.tax_rates.find params[:id]\n @tax_rate.destroy\n\n respond_to do |format|\n format.html { redirect_to shop_tax_rates_path(@shop) }\n format.json { render json: @tax_rate }\n end\n end", "def destroy\n @rate_type = RateType.find(params[:id])\n @rate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(rate_types_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recurrency = Recurrency.find(params[:id])\n @recurrency.destroy\n\n respond_to do |format|\n format.html { redirect_to recurrencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rate.destroy\n respond_to do |format|\n format.html { redirect_to admin_rates_url, notice: 'Rate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @accruel_rate.destroy\n respond_to do |format|\n format.html { redirect_to accruel_rates_url, notice: 'Accruel rate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @flat_rate_price = FlatRatePrice.find(params[:id])\n @flat_rate_price.destroy\n\n respond_to do |format|\n format.html { redirect_to flat_rate_prices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cars = Car.where(car_type_id: @car_type.id)\n @cars.each do |car|\n car.destroy\n end\n @car_type.destroy\n respond_to do |format|\n format.html { redirect_to car_types_url, notice: 'Car type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @car = Car.find(params[:id])\n \n if @car.destroy\n render json: @car, status: :ok \n else\n render json: @car.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @rate = Rate.find(params[:id])\n @rate.destroy\n\n respond_to do |format|\n format.html { redirect_to(rates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @fixed_rate.destroy\r\n respond_to do |format|\r\n format.html { redirect_to fixed_rates_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @vehicle_road_tax.destroy\n respond_to do |format|\n format.html { redirect_to vehicle_road_taxes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rate_corpo = RateCorpo.find(params[:id])\n @rate_corpo.destroy\n\n respond_to do |format|\n format.html { redirect_to rate_corpos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @red_packet_base_rate.destroy\n respond_to do |format|\n format.html { redirect_to admin_red_packet_base_rates_url, notice: 'Red packet base rate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function sets the highlight type of the buttons.
def setHighlight(button_highlight) @button_highlight = button_highlight end
[ "def setHighlight(highlight)\n @highlight = highlight\n end", "def highlight?; end", "def enable_highlight(align)\n @highlight[align] = true\n end", "def button_pressed (source)\n @delegate.tabletNavbarView(WeakRef.new(self), buttonPressed: source) if @delegate.respond_to? 'tabletNavbarView:buttonPressed:'\n\n if(source.tintColor != rmq.color.babbo_button_orange)\n source.tintColor = rmq.color.babbo_button_orange\n if(!@last_selected_button.nil? && @last_selected_button != source )\n @last_selected_button.tintColor = rmq.color.babbo_button_grey\n end\n else\n if(source.tag == 3)\n source.tintColor = rmq.color.babbo_button_grey\n end\n end\n\n if source.tag == 4\n source.tintColor = rmq.color.babbo_button_grey\n end\n\n @last_selected_button = source\n end", "def document_highlight; end", "def highlight=(value)\n @highlight = true && value\n end", "def highlighter=(_arg0); end", "def highlights_on\n @highlights_on ||= options[:highlights_on]\n end", "def settextcolorind(*)\n super\n end", "def syntax_highlight_class(content_type)\n case content_type\n when JSON\n \"highlight json\"\n when XML\n \"highlight xml\"\n end\n end", "def TreeView_SetInsertMarkColor(hwnd, clr) send_treeview_message(hwnd, :SETINSERTMARKCOLOR, lparam: clr) end", "def update_buttons\n @buttons.each_with_index { |button, index| button.selected = index == @index }\n end", "def document_highlight_provider; end", "def setClueHighlightColor(clueHighlightColor)\n\t\t@clueHighlightColor=clueHighlightColor\n\tend", "def TreeView_SetBkColor(hwnd, clr) send_treeview_message(hwnd, :SETBKCOLOR, lparam: clr) end", "def toggle_color_syntax_highlighting(buffer)\n mumble buffer, 'Toggle color syntax highlighting'\n end", "def default_button_background_color\n block_for('default_button_background_color', '#ffffff')\n end", "def highlighter_prefix; end", "def highlighter=(hl)\n $VERBOSE = false\n @@highlighter = case hl\n when Text::Highlighter\n hl\n when Text::Highlighter::NONE, \"NONE\", nil\n Text::NonHighlighter.new # unless @@highlighter.kind_of?(Text::NonHighlighter)\n when Text::Highlighter::HTML, \"HTML\"\n Text::HTMLHighlighter.new # unless @@highlighter.kind_of?(Text::HTMLHighlighter)\n when Text::Highlighter::ANSI, \"ANSI\"\n Text::ANSIHighlighter.new\n else\n Text::NonHighlighter.new\n end\n \n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This sets whether or not you wnat to set the viewer info line.
def setInfoLine(show_line_info) @show_line_info = show_line_info end
[ "def viewer?\n self.info.has_key? :views\n end", "def set_view_option(opts)\n opts = check_params(opts,[:view_infos])\n super(opts)\n end", "def show_marker\n @selected_story_marker.hidden = false\n end", "def show_entry=(val)\n set('show_entry', val ? 1 : 0)\n end", "def set_ShowDetailedGrid(value)\n set_input(\"ShowDetailedGrid\", value)\n end", "def visual_mode() @mode = 'Visual' end", "def set_show_detail\n @show_detail = true\n end", "def visible=(value)\n super(value)\n @reflection.visible = value if @reflection\n @ow_shadow.visible = value if @ow_shadow\n end", "def update_info_visibility\n compact = @compact_mode == :enabled\n @info_compact.visible = compact\n @info_wide.visible = !compact\n @bag_sprite.index = @socket_index\n @bag_sprite.visible = compact\n end", "def show_marker; end", "def setMarker\n # Set market for top bar\n @highlight_admin = true\n end", "def hide_info?\n @window_width < 81\n end", "def show_head_info\n false\n end", "def info=(value)\n @info = value\n end", "def setWaypointVisible _obj, _args\n \"_obj setWaypointVisible _args;\" \n end", "def use_hidden_layers=(setting)\n end", "def tracing= bool\n #This is a stub, used for indexing\n end", "def viewing_hint; end", "def additional_info=(value)\n @additional_info = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function destroys the viewer widget.
def destroy self.destroyInfo self.cleanTitle # Clean up the windows. CDK.deleteCursesWindow(@shadow_win) CDK.deleteCursesWindow(@win) # Clean the key bindings. self.cleanBindings(:VIEWER) # Unregister this object. CDK::SCREEN.unregister(:VIEWER, self) end
[ "def destroy\n RhodesNativeViewManager.destroy_native_view(@nv_id)\t\t\n end", "def destroy\n self.cleanTitle\n self.destroyInfo\n\n # Clean up the windows.\n CDK.deleteCursesWindow(@scrollbar_win)\n CDK.deleteCursesWindow(@shadow_win)\n CDK.deleteCursesWindow(@win)\n\n # Clean up the key bindings\n self.cleanBindings(:SELECTION)\n\n # Unregister this object.\n CDK::SCREEN.unregister(:SELECTION, self)\n end", "def destroy\n @viewer.destroy\n respond_to do |format|\n format.html { redirect_to viewers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n self.cleanTitle\n\n CDK.deleteCursesWindow(@field_win)\n CDK.deleteCursesWindow(@label_win)\n CDK.deleteCursesWindow(@shadow_win)\n CDK.deleteCursesWindow(@win)\n\n self.cleanBindings(:ENTRY)\n\n CDK::SCREEN.unregister(:ENTRY, self)\n end", "def destroy\n @viewer.destroy\n respond_to do |format|\n format.html { redirect_to viewers_url, notice: 'Viewer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n self.cleanTitle\n self.destroyInfo\n\n # Clean up the windows.\n CDK.deleteCursesWindow(@scrollbar_win)\n CDK.deleteCursesWindow(@shadow_win)\n CDK.deleteCursesWindow(@win)\n\n # Clean up the key bindings.\n self.cleanBindings(:RADIO)\n\n # Unregister this object.\n CDK::SCREEN.unregister(:RADIO, self)\n end", "def destroy\n @viewer = Viewer.find(params[:id])\n @viewer.destroy\n\n respond_to do |format|\n format.html { redirect_to(viewers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n # Clean up the windows.\n CDK.deleteCursesWindow(@win)\n CDK.deleteCursesWindow(@shadow_win)\n\n # Clean the key bindings\n self.cleanBindings(:DIALOG)\n\n # Unregister this object\n CDK::SCREEN.unregister(:DIALOG, self)\n end", "def destroy \n @viewer.destroy\n respond_to do |format|\n format.html { redirect_to viewers_url, notice: t('visor.alert_delete') }\n format.json { head :no_content }\n end\n end", "def destroy\n self.cleanTitle\n\n CDK.deleteCursesWindow(@label_win)\n CDK.deleteCursesWindow(@field_win)\n CDK.deleteCursesWindow(@shadow_win)\n CDK.deleteCursesWindow(@win)\n\n # Clean the key bindings.\n self.cleanBindings(:CALENDAR)\n\n # Unregister the object.\n CDK::SCREEN.unregister(:CALENDAR, self)\n end", "def remove widget\n \n end", "def destroy\n FFI::NCurses.del_panel(@panel) if @panel\n FFI::NCurses.delwin(@pointer) if @pointer\n @panel = @pointer = nil # prevent call twice\n end", "def destroy\n self.cleanTitle\n\n # Clear the matrix windows.\n CDK.deleteCursesWindow(@cell[0][0])\n (1..@vrows).each do |x|\n CDK.deleteCursesWindow(@cell[x][0])\n end\n (1..@vcols).each do |x|\n CDK.deleteCursesWindow(@cell[0][x])\n end\n (1..@vrows).each do |x|\n (1..@vcols).each do |y|\n CDK.deleteCursesWindow(@cell[x][y])\n end\n end\n\n CDK.deleteCursesWindow(@shadow_win)\n CDK.deleteCursesWindow(@win)\n\n # Clean the key bindings.\n self.cleanBindings(:MATRIX)\n\n # Unregister this object.\n CDK::SCREEN.unregister(:MATRIX, self)\n end", "def destroy\r\n @viewer = current_user.viewers.find(params[:id])\r\n @viewer.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to viewers_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def release!\n release_events()\n @properties.clear\n @properties = nil\n @parent = nil\n @window = nil\n nil\n end", "def destroy\n @gesture.destroy\n\n head :no_content\n end", "def close\n try{ @cube_view.close() }\n @cube_view = nil\n end", "def destroy_presentation\n presentation.purge if presentation.attached?\n end", "def destroy\n @viewer_access.destroy\n respond_to do |format|\n format.html { redirect_to viewer_accesses_url, notice: 'Viewer access was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This draws the viewer info lines.
def drawInfo temp = '' line_adjust = false # Clear the window. @win.werase self.drawTitle(@win) # Draw in the current line at the top. if @show_line_info == true # Set up the info line and draw it. if @in_progress temp = 'processing...' elsif @list_size != 0 temp = '%d/%d %2.0f%%' % [@current_top + 1, @list_size, ((1.0 * @current_top + 1) / (@list_size)) * 100] else temp = '%d/%d %2.0f%%' % [0, 0, 0.0] end # The list_adjust variable tells us if we have to shift down one line # because the person asked for the line X of Y line at the top of the # screen. We only want to set this to true if they asked for the info # line and there is no title or if the two items overlap. if @title_lines == '' || @title_pos[0] < temp.size + 2 list_adjust = true end Draw.writeChar(@win, 1, if list_adjust then @title_lines else 0 end + 1, temp, CDK::HORIZONTAL, 0, temp.size) end # Determine the last line to draw. last_line = [@list_size, @view_size].min last_line -= if list_adjust then 1 else 0 end # Redraw the list. (0...last_line).each do |x| if @current_top + x < @list_size screen_pos = @list_pos[@current_top + x] + 1 - @left_char Draw.writeChtype(@win, if screen_pos >= 0 then screen_pos else 1 end, x + @title_lines + if list_adjust then 1 else 0 end + 1, @list[x + @current_top], CDK::HORIZONTAL, if screen_pos >= 0 then 0 else @left_char - @list_pos[@current_top + x] end, @list_len[x + @current_top]) end end # Box it if we have to. if @box Draw.drawObjBox(@win, self) @win.wrefresh end # Draw the separation line. if @button_count > 0 boxattr = @BXAttr (1..@box_width).each do |x| @win.mvwaddch(@box_height - 3, x, @HZChar | boxattr) end @win.mvwaddch(@box_height - 3, 0, Ncurses::ACS_LTEE | boxattr) @win.mvwaddch(@box_height - 3, @win.getmaxx - 1, Ncurses::ACS_RTEE | boxattr) end # Draw the buttons. This will call refresh on the viewer win. self.drawButtons end
[ "def how_to_render_lines args\n # Render a horizontal line at the bottom\n args.nokia.lines << { x: 0, y: 0, x2: 83, y2: 0 }\n\n # Render a vertical line at the left\n args.nokia.lines << { x: 0, y: 0, x2: 0, y2: 47 }\n\n # Render a diagonal line starting from the bottom left and going to the top right\n args.nokia.lines << { x: 0, y: 0, x2: 83, y2: 47 }\nend", "def draw\n color = Gosu::Color::RED\n color = Gosu::Color::GREEN if @highlight\n $window.draw_line(self.origin.x,self.origin.y,color,@v2.x,@v2.y,color,Zorder::Dev)\n $window.draw_line(@v2.x,@v2.y,color,@v4.x,@v4.y,color,Zorder::Dev)\n $window.draw_line(@v4.x,@v4.y,color,@v3.x,@v3.y,color,Zorder::Dev)\n $window.draw_line(@v3.x,@v3.y,color,self.origin.x,self.origin.y,color,Zorder::Dev)\n $window.draw_line(@left_foot.x,@left_foot.y+3,color,@right_foot.x,@right_foot.y+3,color,Zorder::Dev)\n end", "def draw_line_preview(view)\n plane = [@compass_position, Z_AXIS]\n projected = @input_point.position.project_to_plane(plane)\n\n # Copying visual style from Rotate tool.\n view.set_color_from_line(projected, @compass_position)\n view.line_stipple = \"_\"\n view.draw(GL_LINES, [@compass_position, projected])\n\n view.line_stipple = \"-\"\n view.drawing_color = \"gray\"\n view.draw(GL_LINES, [@input_point.position, projected])\n end", "def draw\n @grid.draw\n show_info\n end", "def draw_lines\n extract_pixelmap\n lines = segmentize\n puts lines.count\n MiniMagick::Tool::Convert.new do |convert|\n convert << @master_file.path\n lines.each { |num| convert.merge! red_line(num, @image.width) }\n convert << working_path(\"#{@column.number}_lined.png\")\n end\n @column.update!(lined_img_count: lines.count)\n save_lined_image\n end", "def draw_line\n print H_SEP * columns\n end", "def show_volume_lines(view, entities)\n # get rays to the 4 corners of the viewing area\n transform = CameraRep.get_transform_from_view(view).inverse\n #length = self.distance_to_back(view)\n #pts = []\n for i in 0..3\n ray = view.pickray(view.corner(i))\n dir = ray[1].transform(transform)\n line = entities.add_cline ORIGIN, dir, \"...\"\n line.start = ORIGIN\n #pts[i] = ORIGIN.offset dir, length\n #entities.add_cline ORIGIN, pts[i], \"...\"\n #if( i > 0 )\n # entities.add_cline pts[i-1], pts[i], \"...\"\n #end\n end\n #entities.add_cline pts[3], pts[0], \"...\"\nend", "def info_graphics(*args)\n @p.info_graphics(self, *args)\n end", "def draw_alt_line\n @dim.times do |i|\n if i.even?\n print draw_x\n else\n if @type == \"allx\"\n print draw_x\n elsif @type == \"alt\"\n print draw_dot\n end\n end\n end\n end", "def draw_lines\n @dim.times do |i|\n if @type.nil?\n draw_line(i+1)\n draw_edge\n puts\n elsif @type == \"allx\" || @type == \"alt\"\n draw_alt_line\n draw_edge\n puts\n end\n end\n end", "def show_lines\n puts TEXT_LINES_HEADLINE\n \n y = 0;\n while (y < @field.height)\n act_line = \"\"\n x = 0\n while (x < @field.width)\n active = @field.assignment[x][y]\n act_part = (active == nil) ? \" - \" : (active == true) ? \" X \" : \" O \";\n act_line += act_part\n x += 1;\n end\n puts act_line;\n y += 1\n end\n self.show_empty_row\n \n 1.upto(@field.width) { |x| print \" #{x} \" }\n \n self.show_empty_row\n end", "def draw_line(index)\n rect = Rect.new(0, 0, 0, 0)\n rect.x += 4\n rect.y += index * WLH\n rect.width = contents.width - 8\n rect.height = WLH\n self.contents.clear_rect(rect)\n self.contents.font.color = normal_color\n self.contents.draw_text(rect, @lines[index])\n end", "def draw_track_info\n heading = @song[:title].titleize\n if @track_credits\n heading += \" by \" + @track_credits.first(3).join(', ')\n end\n\n text(heading, 10, 16)\n # TODO: Make album spine look realistic:\n stroke_weight(1)\n stroke(123, 100, 100)\n line(X_SPLIT, 0, X_SPLIT, height)\n stroke(255)\n end", "def draw_info_header_text(x, y)\n if current_page == :ingredients\n draw_ingredients_header_text(x, y)\n else\n super\n end\n end", "def draw_lines(*args)\n end", "def drawLines\n\t\t#Set inital text height and change per line.\n\t\tif @lines.length == 4\n\t\t\tdrawPosY = 292\n\t\telsif @lines.length == 3\n\t\t\tdrawPosY = 300\n\t\telsif @lines.length == 2\n\t\t\tdrawPosY = 310\n\t\telse\n\t\t\tdrawPosY = 322\n\t\tend\n\t\tdrawPosX = DRAW_POS_X\n\n\t\t@lines.each { |line|\n\t\t\tline.line.each { |word|\n\t\t\t\tword.word.each { |c|\n\t\t\t\t\tc[0].blit(@screen, [drawPosX, drawPosY], nil)\n\t\t\t\t\tdrawPosX = drawPosX + c[1]\n\t\t\t\t}\n\t\t\t\tdrawPosX = drawPosX + SPACE_SIZE\n\t\t\t}\n\t\tdrawPosX = DRAW_POS_X\n\t\tdrawPosY = drawPosY + LINE_HEIGHT\n\t\t}\n\tend", "def plot_line; end", "def visualize\n end", "def draw\n @viewport.draw content, Size([0,0]), header, footer\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the base portion of the URL for connecting to SOLR based on the current Cassandra server.
def solr_base_url DatastaxRails::Base.establish_connection unless connection port = DatastaxRails::Base.config[:solr][:port] path = DatastaxRails::Base.config[:solr][:path] protocol = ssl_type ? 'https' : 'http' "#{protocol}://#{current_server}:#{port}#{path}" end
[ "def core_url\n @blacklight_context.default_index.connection.uri.to_s.gsub(%r{^.*\\/solr}, '/solr')\n end", "def endpointURL\n return request.scheme + '://' + request.host_with_port + '/'\n end", "def raplet_base_url\n \"#{request.scheme}://#{request.host}:#{request.port}\"\n end", "def base_url(operation = nil)\n index = server_operation_index.fetch(operation, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])\n end", "def get_request_base\n \"#{request.protocol}#{request.host}:#{request.port}\"\n end", "def solr_url\n @solr_url ||= endpoint_url.gsub(/\\/select$/, '')\n end", "def base_url(operation = nil)\n index = server_operation_index.fetch(operation.to_sym, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation.to_sym, server_variables), operation_server_settings[operation.to_sym])\n end", "def base_url\n @base_url ||= File.join(JsonApiServer.configuration.base_url, request.path)\n end", "def crowdflower_base\n uri = URI.parse(domain_base)\n \"#{uri.host.gsub(\"api.\", \"\")}\"\n end", "def url\n \"http://#{host}:#{port}/solr/\"\n end", "def base_url(operation = nil)\n if operation_server_settings.key?(operation) then\n index = server_operation_index.fetch(operation, server_index)\n server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])\n else\n server_index.nil? ? \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') : server_url(server_index, server_variables, nil)\n end\n end", "def base_url\n \"#{config['protocol']}://#{config['host']}/\"\n end", "def blacklight_url\n blacklight_connection.base_uri\n rescue StandardError\n ENV[\"SOLR_URL\"] || \"http://127.0.0.1:8983/solr/blacklight-core\"\n end", "def url\n protocol + host_with_port + request_uri\n end", "def server_url\n @uri\n end", "def get_base_url\n Config.base_url @deployment\n end", "def endpoint\n \"#{@scheme}://#{@host}#{@path}\"\n end", "def get_base_uri(server = Server::DEFAULT)\n parameters = {\n 'port' => { 'value' => port, 'encode' => false },\n 'suites' => { 'value' => suites, 'encode' => false }\n }\n APIHelper.append_url_with_template_parameters(\n ENVIRONMENTS[environment][server], parameters\n )\n end", "def base_url_path; end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /keyword_ignores GET /keyword_ignores.json
def index @keyword_ignores = KeywordIgnore.all end
[ "def destroy\n @keyword_ignore.destroy\n respond_to do |format|\n format.html { redirect_to keyword_ignores_url, notice: 'Keyword ignore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def unkeyword(flag)\n return add_params(UNKEYWORD, flag)\n end", "def get_unsearched_keywords(keywords)\n keywords = [keywords] if keywords.class != [].class\n return (keywords - @searched_keywords)\n end", "def keywords(keyword)\r\n JSON.parse(api_get('AutoKeywords.egg', nil, nil, keyword: keyword).body)\r\n end", "def index\n @suspicious_keywords = SuspiciousKeyword.all\n end", "def keywords\n get_keywords.flatten.uniq\n end", "def keyword_to_skip(keyword_name)\n\tkw = Keyword.find_by_name(keyword_name)\nend", "def filter(keywords)\n keywords.delete_if do |key, value|\n include?(key.downcase)\n end\n end", "def search_all\n # Delete keywords from the list as we find them\n @keywords.delete_if {|keyword| search(keyword)}\n end", "def keyword_tweets\n\t\ttweets.select{|t| !t.contextual}\n\tend", "def keywords_to_specify\n keywords = keywords_by_type\n return keywords.select { |key| ![\"USER\", \"FRIEND\", \"IMAGE\"].include?(key) }\n end", "def optional_keywords; end", "def destroy\n @suspicious_keyword.destroy\n respond_to do |format|\n format.html { redirect_to suspicious_keywords_url }\n format.json { head :no_content }\n end\n end", "def delete\n self.keywords.each do |keyword|\n keyword.delete\n end\n \n super\n end", "def with_any_keywords; end", "def dull_keywords\n (@@dull_keywords ||= Defaults.dull_keywords).flatten.uniq\n end", "def ignore(ignores = [])\n ignore_array = ignores.is_a?(Array) ? ignores : [ignores]\n ignore_array.each do |item|\n raise ArgumentError, \"Argument #{item.inspect} to ignore is not a hash\" unless item.is_a?(Hash)\n unless item.key?(:type) || item.key?(:title) || item.key?(:attr)\n raise ArgumentError, \"Argument #{item.inspect} does not contain :type, :title, or :attr\"\n end\n item[:type] ||= '*'\n item[:title] ||= '*'\n item[:attr] ||= '*'\n\n # Support wildcards in title\n if item[:title].is_a?(String) && item[:title] != '*' && item[:title].include?('*')\n item[:title] = Regexp.new(\"\\\\A#{Regexp.escape(item[:title]).gsub('\\*', '.*')}\\\\Z\", 'i')\n end\n\n @ignore.add(item)\n end\n self\n end", "def keywords\n [self.keyword]\n end", "def keyword_autocomplete\n search_keyword = params[\"search\"]\n similar_keywords =\n Keyword.get_similar_keywords(search_keyword, [])\n similar_keywords.map! { |keyword| keyword.name }\n render json: similar_keywords\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /keyword_ignores/1 PATCH/PUT /keyword_ignores/1.json
def update respond_to do |format| if @keyword_ignore.update(keyword_ignore_params) format.html { redirect_to @keyword_ignore, notice: 'Keyword ignore was successfully updated.' } format.json { render :show, status: :ok, location: @keyword_ignore } else format.html { render :edit } format.json { render json: @keyword_ignore.errors, status: :unprocessable_entity } end end end
[ "def update\n respond_to do |format|\n if @suspicious_keyword.update(suspicious_keyword_params)\n format.html { redirect_to @suspicious_keyword, notice: 'Suspicious keyword was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @suspicious_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @keyword_ignores = KeywordIgnore.all\n end", "def update_keyword(id, data)\n # FIXME: Keyword controller doesnt receive data\n @client.raw('put', \"/content/keywords/#{id}\", nil, data)\n end", "def update\n respond_to do |format|\n if @keyword.update(keyword_params)\n format.html { redirect_to @keyword, notice: 'Keyword was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @keyword_ignore.destroy\n respond_to do |format|\n format.html { redirect_to keyword_ignores_url, notice: 'Keyword ignore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update_keyword(id, data)\n #FIXME: Keyword controller doesnt receive data\n return @client.raw(\"put\", \"/content/keywords/#{id}\", nil, data)\n end", "def update\n @keyword = Keyword.find(params[:id])\n\n respond_to do |format|\n if @keyword.update_attributes(params[:keyword])\n format.html { redirect_to @keyword, notice: 'Keyword was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pickup_keyword.update(pickup_keyword_params)\n format.html { redirect_to [:admin, @pickup_keyword], notice: 'Excluded twitter user was successfully updated.' }\n format.json { render :show, status: :ok, location: @pickup_keyword }\n else\n format.html { render :edit }\n format.json { render json: @pickup_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def unkeyword(flag)\n return add_params(UNKEYWORD, flag)\n end", "def update\n respond_to do |format|\n if @idea_keyword.update(idea_keyword_params)\n format.html { redirect_to @idea_keyword, notice: 'Idea keyword was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @idea_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def delete\n self.keywords.each do |keyword|\n keyword.delete\n end\n \n super\n end", "def update\n respond_to do |format|\n if @market_keyword.update(market_keyword_params)\n format.html { redirect_to @market_keyword, notice: 'Keyword was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @market_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def reset_allintitle\n @keyword = Keyword.find(params[:id])\n \n respond_to do |format|\n if @keyword.reset_allintitle\n format.html { redirect_to '/', notice: 'Allintitle number for keyword successfully removed.'}\n format.json { head :no_content }\n else\n format.html { render action: \"show\" }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_keyword\n \n end", "def update\n respond_to do |format|\n if @answer_keyword.update(answer_keyword_params)\n format.html { redirect_to @answer_keyword, notice: 'Answer keyword was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer_keyword }\n else\n format.html { render :edit }\n format.json { render json: @answer_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @alert_keyword = AlertKeyword.find(params[:id])\n\n respond_to do |format|\n if @alert_keyword.update_attributes(alert_keyword_params)\n format.html { redirect_to @alert_keyword, notice: 'Alert keyword was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @alert_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @problem_keyword.update(problem_keyword_params)\n format.html { redirect_to @problem_keyword, notice: 'Problem keyword was successfully updated.' }\n format.json { render :show, status: :ok, location: @problem_keyword }\n else\n format.html { render :edit }\n format.json { render json: @problem_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @suggested_keyword = SuggestedKeyword.find(params[:id])\n\n respond_to do |format|\n if @suggested_keyword.update_attributes(params[:suggested_keyword])\n format.html { redirect_to @suggested_keyword, :notice => 'Suggested keyword was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @suggested_keyword.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hot_keyword.update(hot_keyword_params)\n format.html { redirect_to @hot_keyword, notice: 'Hot keyword was successfully updated.' }\n format.json { render :show, status: :ok, location: @hot_keyword }\n else\n format.html { render :edit }\n format.json { render json: @hot_keyword.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /keyword_ignores/1 DELETE /keyword_ignores/1.json
def destroy @keyword_ignore.destroy respond_to do |format| format.html { redirect_to keyword_ignores_url, notice: 'Keyword ignore was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete\n self.keywords.each do |keyword|\n keyword.delete\n end\n \n super\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @suspicious_keyword.destroy\n respond_to do |format|\n format.html { redirect_to suspicious_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword = @project.keywords.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to project_keywords_url(@project) }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to query_url(admin_keywords_url, Keyword, @current_user.uid) }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to keywords_url }\n format.json { head :no_content }\n end\n end", "def delete_keywords(params, additional_headers = {})\n perform_request(self, @token, 'keywords', 'delete', params, additional_headers)\n end", "def destroy\n @search_keyword.destroy\n respond_to do |format|\n format.html { redirect_to search_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @idea_keyword.destroy\n respond_to do |format|\n format.html { redirect_to idea_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @source_keyword.destroy\n respond_to do |format|\n format.html { redirect_to source_keywords_url, notice: 'Source keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_target_keyword(id)\n if id.nil?\n raise LinkemperorCustomerException.new('id should not be empty')\n end\n parameters = {}\n exec_post(parameters, 'delete', \"#{@base_path}/api/v2/customers/target_keywords/#{id}.json?api_key=#{@api_key}\")\n end", "def destroy\n @alert_keyword = AlertKeyword.find(params[:id])\n @alert_keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to alert_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @market_keyword.destroy\n respond_to do |format|\n format.html { redirect_to market_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to(keywords_url) }\n format.xml { head :ok }\n end\n end", "def destroy_keyword\n @question.keywords.delete( @keyword )\n @keyword.delete\n redirect_to edit_admin_question_path( @question )\n end", "def destroy\n @keyword_index.destroy\n respond_to do |format|\n format.html { redirect_to keyword_indices_url, notice: 'Keyword index was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plead_keyword = PleadKeyword.find(params[:id])\n @plead_keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to plead_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @answer_keyword.destroy\n respond_to do |format|\n format.html { redirect_to answer_keywords_url, notice: 'Answer keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @suggested_keyword = SuggestedKeyword.find(params[:id])\n @suggested_keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to suggested_keywords_url }\n format.json { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a new target to the config
def add_target(target) # If there are no targets yet, use this one as the default if @active_target == nil #@targets.empty? target.active = true @active_target = target end # Push the new target @targets[target.name] = target #write out the config dump_settings puts "Target Added" target.print end
[ "def add_target(target)\n\t\treturn if has_target?(target)\n\t\t@list << target\n\t\twrite_list_to_file\n\tend", "def <<(target)\n @targets << target\n end", "def add_target(target_name, target_type, options={})\n targets[target_name.to_sym] = Target.new(target_name.to_sym,\n target_type.to_sym, options.merge(:project => self))\n end", "def add_target(target, _opts = [])\n profile = Inspec::Profile.for_target(target,\n vendor_cache: @cache,\n backend: @backend,\n controls: @controls,\n runner_conf: @conf)\n raise \"Could not resolve #{target} to valid input.\" if profile.nil?\n\n @target_profiles << profile if supports_profile?(profile)\n end", "def add(object)\n begin\n target = Target.new(object, self)\n rescue\n error \"Error parsing target '#{object[Bee::Target::KEY]}': #{$!}\"\n end\n error \"Duplicate target definition: '#{target.name}'\" if\n @hash.has_key?(target.name)\n @hash[target.name] = [target]\n # record first target for default\n end", "def add_target(cmd)\n value = new_resource.to_target\n cmd << \"--to-target @#{value}\" if value\n cmd\nend", "def add_target(target)\n key = Event.target_key(target)\n event = events[key]\n if event\n # If event exists, extend it with the id of the target.\n event << target.id\n policy.update_event(event)\n else\n # The event doesn't exists so create a new one.\n event = Event.from_target(target)\n events[key] = event\n event << target.id\n policy.add_event(event)\n end\n end", "def target=(new_value)\n @target = new_value unless const_defined?(:Target)\n end", "def attach(target)\n fail \"Cannot add invalid target: #{ target }\" unless target.is_a?(Hash)\n @targets.merge!(target)\n end", "def addTarget(name=nil, note=nil)\n @addTargetBtn.click\n return EditTarget.new.enterTargetInformation(name)\n end", "def target=(value)\n @target = value\n end", "def add_target!(details)\n r = if details.is_a?(UpstreamTarget)\n details\n else\n UpstreamTarget.from_hash(details, api_client: api_client)\n end\n\n r.upstream = self\n r.save\n end", "def addTarget(target, result, usableItems)\n t = self[target]\n if t.nil?\n t = Target.new(target.to_s)\n (@targets ||= []) << t\n @targets.sort!\n end\n t.addResult(result, usableItems)\n end", "def target=(value)\n @target = value\n end", "def add_targets args\n args.each { |t|\n raise \"Bad object (expected Target): #{t.class.name}\" if !t.is_a? Target\n raise \"Duplicate target: #{t.path}\" if @all_targets.key? t.path\n @all_targets[ t.path ] = t\n Build.logger.debug \"Added target: %s\" % t.path\n }\n end", "def configure_with_targets(runnable_target, test_target, launch_target: false)\n if runnable_target\n add_build_target(runnable_target)\n set_launch_target(runnable_target) if launch_target\n end\n if test_target\n add_build_target(test_target, false) if test_target != runnable_target\n add_test_target(test_target)\n end\n end", "def target=(target)\n @target = target\n loaded!\n end", "def add_file_target &block\n target = FileTarget.new\n configure_target target, &block\n end", "def target(name, &block)\n t = TargetDef.new(name)\n @targets.push(t)\n\n block.call(t)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prepares the transaction for hashing. Each input has to be handled separately. For hasing each scriptSig in has to be first filled with scriptPubKey.
def signature_form(tx, i, scriptPubKey, hashcode=SIGHASH_ALL) i, hashcode = i.to_i, hashcode.to_i raise ArgumentError, "i > #inputs" if i > tx[:ins].size # if tx.respond_to? :each_char # return serialize(signature_form(deserialize(tx), i, scriptPubKey, hashcode)) # end newtx = tx.clone newtx[:ins].each do |input| input[:scriptSig] = "" end newtx[:ins][i][:scriptSig] = scriptPubKey if hashcode & 0x1f == SIGHASH_NONE newtx[:outs] = [] elsif hashcode & 0x1f == SIGHASH_SINGLE newtx[:outs].each_index do |index| next if index == i newtx[:outs][index][:value] = 2**64 - 1 newtx[:outs][index][:scriptPubKey] = "" #newtx[:ins][index][:sequence] = '00000000' end end if hashcode & SIGHASH_ANYONECANPAY == SIGHASH_ANYONECANPAY newtx[:ins] = [newtx[:ins][i]] end newtx end
[ "def signature_hash(input_index: nil, output_script: nil, hash_type: BTC::SIGHASH_ALL, version: 0, amount: 0)\n\n raise ArgumentError, \"Should specify input_index in Transaction#signature_hash.\" if !input_index\n raise ArgumentError, \"Should specify output_script in Transaction#signature_hash.\" if !output_script\n raise ArgumentError, \"Should specify hash_type in Transaction#signature_hash.\" if !hash_type\n\n # Create a temporary copy of the transaction to apply modifications to it.\n tx = self.dup\n\n # Note: BitcoinQT returns a 256-bit little-endian number 1 in such case,\n # but it does not matter because it would crash before that in CScriptCheck::operator()().\n # We normally won't enter this condition if script machine is instantiated\n # with transaction and input index, but it's better to check anyway.\n if (input_index >= tx.inputs.size)\n raise ArgumentError, \"Input index is out of bounds for transaction: #{input_index} >= #{tx.inputs.size}\"\n end\n\n # In case concatenating two scripts ends up with two codeseparators,\n # or an extra one at the end, this prevents all those possible incompatibilities.\n # Note: this normally never happens because there is no use for OP_CODESEPARATOR.\n # But we have to do that cleanup anyway to not break on rare transaction that use that for lulz.\n # Also: we modify the same subscript which is used several times for multisig check,\n # but that's what BitcoinQT does as well.\n output_script.delete_opcode(BTC::OP_CODESEPARATOR)\n\n # Blank out other inputs' signature scripts\n # and replace our input script with a subscript (which is typically a full\n # output script from the previous transaction).\n tx.inputs.each do |txin|\n txin.signature_script = BTC::Script.new\n end\n tx.inputs[input_index].signature_script = output_script\n\n # Blank out some of the outputs depending on BTCSignatureHashType\n # Default is SIGHASH_ALL - all inputs and outputs are signed.\n if (hash_type & BTC::SIGHASH_OUTPUT_MASK) == BTC::SIGHASH_NONE\n # Wildcard payee - we can pay anywhere.\n tx.remove_all_outputs\n\n # Blank out others' input sequence numbers to let others update transaction at will.\n tx.inputs.each_with_index do |txin, i|\n if i != input_index\n tx.inputs[i].sequence = 0\n end\n end\n\n # Single mode assumes we sign an output at the same index as an input.\n # Outputs before the one we need are blanked out. All outputs after are simply removed.\n elsif (hash_type & BTC::SIGHASH_OUTPUT_MASK) == BTC::SIGHASH_SINGLE\n # Only lock-in the txout payee at same index as txin.\n output_index = input_index;\n\n # If output_index is out of bounds, BitcoinQT is returning a 256-bit little-endian 0x01 instead of failing with error.\n # We should do the same to stay compatible.\n if output_index >= tx.outputs.size\n return \"\\x01\" + \"\\x00\"*31\n end\n\n # All outputs before the one we need are blanked out. All outputs after are simply removed.\n # This is equivalent to replacing outputs with (i-1) empty outputs and a i-th original one.\n my_output = tx.outputs[output_index]\n tx.remove_all_outputs\n (0...output_index).each do |i|\n tx.add_output(BTC::TransactionOutput.new)\n end\n tx.add_output(my_output)\n\n # Blank out others' input sequence numbers to let others update transaction at will.\n tx.inputs.each_with_index do |txin, i|\n if i != input_index\n txin.sequence = 0\n end\n end\n end # if hashtype is none or single\n\n # Blank out other inputs completely. This is not recommended for open transactions.\n if (hash_type & BTC::SIGHASH_ANYONECANPAY) != 0\n input = tx.inputs[input_index]\n tx.remove_all_inputs\n tx.add_input(input)\n end\n\n # Important: we have to hash transaction together with its hash type.\n # Hash type is appended as a little endian uint32 unlike 1-byte suffix of the signature.\n data = tx.data + BTC::WireFormat.encode_uint32le(hash_type)\n hash = BTC.hash256(data)\n # puts \"\"\n # puts \"SIGHASH[#{self.transaction_id}, input #{input_index}, hashtype 0x#{hash_type.to_s(16)}]: hash = #{BTC.id_from_hash(hash)}; tx = \" + tx.inspect\n # puts \"\"\n return hash\n end", "def signature_hash_for_input(input_idx, outpoint_tx, script_pubkey=nil, hash_type=nil, drop_sigs=nil, script=nil)\n # https://github.com/bitcoin/bitcoin/blob/e071a3f6c06f41068ad17134189a4ac3073ef76b/script.cpp#L834\n # http://code.google.com/p/bitcoinj/source/browse/trunk/src/com/google/bitcoin/core/Script.java#318\n # https://en.bitcoin.it/wiki/OP_CHECKSIG#How_it_works\n # https://github.com/bitcoin/bitcoin/blob/c2e8c8acd8ae0c94c70b59f55169841ad195bb99/src/script.cpp#L1058\n\n hash_type ||= 1 # 1: ALL, 2: NONE, 3: SINGLE\n\n pin = @in.map.with_index{|i,idx|\n if idx == input_idx\n script_pubkey ||= outpoint_tx.out[ i.prev_out_index ].pk_script\n script_pubkey = Bitcoin::Script.binary_from_string(script) if script # force this string a script\n script_pubkey = Bitcoin::Script.drop_signatures(script_pubkey, drop_sigs) if drop_sigs # array of signature to drop\n length = script_pubkey.bytesize\n [ i.prev_out, i.prev_out_index, length, script_pubkey, i.sequence || \"\\xff\\xff\\xff\\xff\" ].pack(\"a32ICa#{length}a4\")\n else\n case hash_type\n when 2\n [ i.prev_out, i.prev_out_index, 0, \"\\x00\\x00\\x00\\x00\" ].pack(\"a32ICa4\")\n else\n [ i.prev_out, i.prev_out_index, 0, i.sequence || \"\\xff\\xff\\xff\\xff\" ].pack(\"a32ICa4\")\n end\n end\n }.join\n pout = @out.map{|o|\n [ o.value, o.pk_script_length, o.pk_script ].pack(\"QCa#{o.pk_script_length}\")\n }.join\n\n case hash_type\n when 2\n pout = \"\"\n in_size, out_size = Protocol.pack_var_int(@in.size), Protocol.pack_var_int(0)\n else\n in_size, out_size = Protocol.pack_var_int(@in.size), Protocol.pack_var_int(@out.size)\n end\n buf = [[@ver].pack(\"I\"), in_size, pin, out_size, pout, [@lock_time].pack(\"I\")].join + [hash_type].pack(\"I\")\n Digest::SHA256.digest( Digest::SHA256.digest( buf ) )\n end", "def handle_assemble_tx params = {}\n # tx_hex, sig_pubs\n tx = Bitcoin::P::Tx.new(params[:tx].htb)\n params[:sig_pubs].each.with_index do |sig_pub, idx|\n sig, pub = *sig_pub.map(&:htb)\n script_sig = Bitcoin::Script.to_signature_pubkey_script(sig, pub)\n tx.in[idx].script_sig_length = script_sig.bytesize\n tx.in[idx].script_sig = script_sig\n end\n tx = Bitcoin::P::Tx.new(tx.to_payload)\n tx.validator(@node.store).validate(raise_errors: true)\n { hash: tx.hash, hex: tx.to_payload.hth }\n rescue\n { error: \"Error assembling tx: #{$!.message}\" }\n p $!; puts *$@\n end", "def handle_assemble_tx tx_hex, sig_pubs\n tx = Bitcoin::P::Tx.new(tx_hex.htb)\n sig_pubs.each.with_index do |sig_pub, idx|\n sig, pub = *sig_pub.map(&:htb)\n script_sig = Bitcoin::Script.to_signature_pubkey_script(sig, pub)\n tx.in[idx].script_sig_length = script_sig.bytesize\n tx.in[idx].script_sig = script_sig\n end\n tx = Bitcoin::P::Tx.new(tx.to_payload)\n tx.validator(@node.store).validate(raise_errors: true)\n tx.to_payload.hth\n rescue\n { error: \"Error assembling tx: #{$!.message}\" }\n end", "def set_script_sigs(*input_args, &block)\n # No sense trying to authorize when the transaction isn't usable.\n report = validate_syntax\n unless report[:valid] == true\n raise \"Invalid syntax: #{report[:errors].to_json}\"\n end\n\n # Array#zip here allows us to iterate over the inputs in lockstep with any\n # number of sets of values.\n self.inputs.zip(*input_args) do |input, *input_arg|\n input.script_sig = yield input, *input_arg\n end\n end", "def signature_hash_for_witness_input(input_idx, witness_program, prev_out_value, witness_script = nil, hash_type=nil, skip_separator_index = 0)\n return \"\\x01\".ljust(32, \"\\x00\") if input_idx >= @in.size # ERROR: SignatureHash() : input_idx=%d out of range\n\n hash_type ||= SIGHASH_TYPE[:all]\n\n script = Bitcoin::Script.new(witness_program)\n raise \"ScriptPubkey does not contain witness program.\" unless script.is_witness?\n\n hash_prevouts = Digest::SHA256.digest(Digest::SHA256.digest(@in.map{|i| [i.prev_out_hash, i.prev_out_index].pack(\"a32V\")}.join))\n hash_sequence = Digest::SHA256.digest(Digest::SHA256.digest(@in.map{|i|i.sequence}.join))\n outpoint = [@in[input_idx].prev_out_hash, @in[input_idx].prev_out_index].pack(\"a32V\")\n amount = [prev_out_value].pack(\"Q\")\n nsequence = @in[input_idx].sequence\n\n if script.is_witness_v0_keyhash?\n script_code = [[\"1976a914\", script.get_hash160, \"88ac\"].join].pack(\"H*\")\n elsif script.is_witness_v0_scripthash?\n raise \"witness script does not match script pubkey\" unless Bitcoin::Script.to_witness_p2sh_script(Digest::SHA256.digest(witness_script).bth) == witness_program\n script = skip_separator_index > 0 ? Bitcoin::Script.new(witness_script).subscript_codeseparator(skip_separator_index) : witness_script\n script_code = Bitcoin::Protocol.pack_var_string(script)\n end\n\n hash_outputs = Digest::SHA256.digest(Digest::SHA256.digest(@out.map{|o|o.to_payload}.join))\n\n case (hash_type & 0x1f)\n when SIGHASH_TYPE[:single]\n hash_outputs = input_idx >= @out.size ? \"\\x00\".ljust(32, \"\\x00\") : Digest::SHA256.digest(Digest::SHA256.digest(@out[input_idx].to_payload))\n hash_sequence = \"\\x00\".ljust(32, \"\\x00\")\n when SIGHASH_TYPE[:none]\n hash_sequence = hash_outputs = \"\\x00\".ljust(32, \"\\x00\")\n end\n\n if (hash_type & SIGHASH_TYPE[:anyonecanpay]) != 0\n hash_prevouts = hash_sequence =\"\\x00\".ljust(32, \"\\x00\")\n end\n\n buf = [ [@ver].pack(\"V\"), hash_prevouts, hash_sequence, outpoint,\n script_code, amount, nsequence, hash_outputs, [@lock_time, hash_type].pack(\"VV\")].join\n\n Digest::SHA256.digest( Digest::SHA256.digest( buf ) )\n end", "def signature_script(index)\n i = inputs[index]\n if i.non_witness_utxo\n i.redeem_script ? i.redeem_script : i.non_witness_utxo.out[tx.in[index].out_point.index].script_pubkey\n else\n i.witness_script ? i.witness_script : i.witness_utxo\n end\n end", "def sighash_for_legacy(index, script_code, hash_type)\n ins =\n inputs.map.with_index do |i, idx|\n if idx == index\n i.to_payload(script_code.delete_opcode(Tapyrus::Opcodes::OP_CODESEPARATOR))\n else\n case hash_type & 0x1f\n when SIGHASH_TYPE[:none], SIGHASH_TYPE[:single]\n i.to_payload(Tapyrus::Script.new, 0)\n else\n i.to_payload(Tapyrus::Script.new)\n end\n end\n end\n\n outs = outputs.map(&:to_payload)\n out_size = Tapyrus.pack_var_int(outputs.size)\n\n case hash_type & 0x1f\n when SIGHASH_TYPE[:none]\n outs = ''\n out_size = Tapyrus.pack_var_int(0)\n when SIGHASH_TYPE[:single]\n return \"\\x01\".ljust(32, \"\\x00\") if index >= outputs.size\n outs =\n outputs[0...(index + 1)].map.with_index { |o, idx| (idx == index) ? o.to_payload : o.to_empty_payload }.join\n out_size = Tapyrus.pack_var_int(index + 1)\n end\n\n ins = [ins[index]] if hash_type & SIGHASH_TYPE[:anyonecanpay] != 0\n\n buf = [\n [features].pack('V'),\n Tapyrus.pack_var_int(ins.size),\n ins,\n out_size,\n outs,\n [lock_time, hash_type].pack('VV')\n ].join\n\n Tapyrus.double_sha256(buf)\n end", "def apply_multisignatures(tx, i, script, *sigs)\r\n\t\t#txobj = deserialize(tx)\r\n\t\tscriptSig = \"00\" # Push byte 0x0 due to bug in multisig\r\n\t\tpushdata = '' # In case transaction > 150 bytes.\r\n\r\n\t\t# In case sigs is an array * puts it inside another array\r\n\t\t# so that outter array size is 1.\r\n\t\tsigs = sigs[0] if sigs.length == 1\r\n\r\n\t\tsigs.each do |sig|\r\n\t\t\tscriptSig += (sig.length / 2).to_s(16) + sig\r\n\t\tend\r\n\r\n\t\tpushdata = case script.length\r\n\t\t\t\twhen 151..255 then '4c'\r\n\t\t\t\twhen 256..65535 then '4d'\r\n\t\t\t\twhen 65546..0xFFFFFFFF then '4e'\r\n\t\t\tend\r\n\t\t\t\t\r\n\r\n\t\tscriptSig += pushdata #'4c' if (script.length / 2) > 150 # OP_PUSHDATA1\r\n\t\tscriptSig += (script.length / 2).to_s(16) + script\r\n\r\n\t\ttx[:ins][i][:scriptSig] = scriptSig\r\n\r\n\t\ttx\r\n\tend", "def wrap_txin(input)\n return nil unless input\n data = { :id => input[:id], :tx_id => input[:tx_id], :tx_idx => input[:tx_idx],\n :p2sh_type => input[:p2sh_type] ? SCRIPT_TYPES[input[:p2sh_type]] : nil }\n txin = Bitcoin::Storage::Models::TxIn.new(self, data)\n txin.prev_out = input[:prev_out]\n txin.prev_out_index = input[:prev_out_index]\n txin.script_sig_length = input[:script_sig].bytesize\n txin.script_sig = input[:script_sig]\n txin.sequence = [input[:sequence]].pack(\"V\")\n txin\n end", "def verify_witness_input_signature(in_idx, outpoint_tx_or_script, prev_out_amount, block_timestamp=Time.now.to_i, opts={})\n if @enable_bitcoinconsensus\n return bitcoinconsensus_verify_script(in_idx, outpoint_tx_or_script, block_timestamp, opts)\n end\n\n outpoint_idx = @in[in_idx].prev_out_index\n script_sig = ''\n\n # If given an entire previous transaction, take the script from it\n script_pubkey = if outpoint_tx_or_script.respond_to?(:out)\n Bitcoin::Script.new(outpoint_tx_or_script.out[outpoint_idx].pk_script)\n else\n # Otherwise, it's already a script.\n Bitcoin::Script.new(outpoint_tx_or_script)\n end\n\n if script_pubkey.is_p2sh?\n redeem_script = Bitcoin::Script.new(@in[in_idx].script_sig).get_pubkey\n script_pubkey = Bitcoin::Script.new(redeem_script.htb) if Bitcoin.hash160(redeem_script) == script_pubkey.get_hash160 # P2SH-P2WPKH or P2SH-P2WSH\n end\n\n witness.tx_in_wit[in_idx].stack.each{|s|script_sig << Bitcoin::Script.pack_pushdata(s.htb)}\n code_separator_index = 0\n\n if script_pubkey.is_witness_v0_keyhash? # P2WPKH\n @scripts[in_idx] = Bitcoin::Script.new(script_sig, Bitcoin::Script.to_hash160_script(script_pubkey.get_hash160))\n elsif script_pubkey.is_witness_v0_scripthash? # P2WSH\n witness_hex = witness.tx_in_wit[in_idx].stack.last\n witness_script = Bitcoin::Script.new(witness_hex.htb)\n return false unless Bitcoin.sha256(witness_hex) == script_pubkey.get_hash160\n @scripts[in_idx] = Bitcoin::Script.new(script_sig, Bitcoin::Script.to_p2sh_script(Bitcoin.hash160(witness_hex)))\n else\n return false\n end\n\n return false if opts[:verify_sigpushonly] && !@scripts[in_idx].is_push_only?(script_sig)\n return false if opts[:verify_minimaldata] && !@scripts[in_idx].pushes_are_canonical?\n sig_valid = @scripts[in_idx].run(block_timestamp, opts) do |pubkey,sig,hash_type,subscript|\n if script_pubkey.is_witness_v0_keyhash?\n hash = signature_hash_for_witness_input(in_idx, script_pubkey.to_payload, prev_out_amount, nil, hash_type)\n elsif script_pubkey.is_witness_v0_scripthash?\n hash = signature_hash_for_witness_input(in_idx, script_pubkey.to_payload, prev_out_amount, witness_hex.htb, hash_type, code_separator_index)\n code_separator_index += 1 if witness_script.codeseparator_count > code_separator_index\n end\n Bitcoin.verify_signature( hash, sig, pubkey.unpack(\"H*\")[0] )\n end\n # BIP62 rule #6\n return false if opts[:verify_cleanstack] && !@scripts[in_idx].stack.empty?\n\n return sig_valid\n end", "def p2sh_script\n Script.new << OP_HASH160 << BTC.hash160(self.data) << OP_EQUAL\n end", "def create_tx(tx, prev_tx, prev_out_index, outputs, key = @key)\n tx.input {|i| i.prev_out prev_tx; i.prev_out_index prev_out_index; i.signature_key key }\n outputs.each do |value, key|\n tx.output {|o| o.value value; o.script {|s| s.recipient key.addr } }\n end\nend", "def hash_transaction\n dig = Digest::SHA256.new\n [user_id, merchant, currency, amount, created_at, image_hash ].each do |thing|\n dig << thing.to_s\n end\n \n self.transaction_hash = dig.to_s\n save\n end", "def parse_script txout, i, tx_hash = \"\", tx_idx\n addrs, names = [], []\n\n script = Bitcoin::Script.new(txout.pk_script) rescue nil\n if script\n if script.is_hash160? || script.is_pubkey? || script.is_p2sh?\n addrs << [i, script.get_address]\n elsif script.is_multisig?\n script.get_multisig_addresses.map do |address|\n addrs << [i, address]\n end\n elsif Bitcoin.namecoin? && script.is_namecoin?\n addrs << [i, script.get_address]\n names << [i, script]\n elsif script.is_op_return?\n log.info { \"Ignoring OP_RETURN script: #{script.get_op_return_data}\" }\n else\n log.info { \"Unknown script type in txout #{tx_hash}:#{tx_idx}\" }\n log.debug { script.to_string }\n end\n script_type = SCRIPT_TYPES.index(script.type)\n else\n log.error { \"Error parsing script #{tx_hash}:#{tx_idx}\" }\n script_type = SCRIPT_TYPES.index(:unknown)\n end\n [script_type, addrs, names]\n end", "def script\n raise ArgumentError, \"BTC::PublicKeyAddress: invalid data length (must be 20 bytes)\" if self.data.bytesize != 20\n BTC::Script.new << OP_DUP << OP_HASH160 << self.data << OP_EQUALVERIFY << OP_CHECKSIG\n end", "def txin_data tx_id, txin, idx, p2sh_type = nil\n data = {\n tx_id: tx_id, tx_idx: idx,\n script_sig: txin.script_sig.blob,\n prev_out: txin.prev_out.blob,\n prev_out_index: txin.prev_out_index,\n sequence: txin.sequence.unpack(\"V\")[0],\n }\n data[:p2sh_type] = SCRIPT_TYPES.index(p2sh_type) if @config[:index_p2sh_type]\n data\n end", "def prepare_for_signature\n prepare\n end", "def setup_hash(options)\n raise unless options[:transaction_key]\n raise unless options[:order_timestamp]\n amount = @fields['x_amount']\n data = \"#{@fields['x_login']}^#{@fields['x_fp_sequence']}^#{options[:order_timestamp].to_i}^#{amount}^#{@fields['x_currency_code']}\"\n hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('md5'), options[:transaction_key], data)\n add_field 'x_fp_hash', hmac\n add_field 'x_fp_timestamp', options[:order_timestamp].to_i\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def bin_txhash(tx, hashcode='None') if hashcode == 'None'
def bin_txhash(tx, hashcode=SIGHASH_ALL) tx = @sp.changebase(tx, 16, 256) hashcode = @sp.encode(hashcode, 256, 4) #hashcode.to_s.rjust(8, '0') hashcode.reverse! # = @sp.change_endianness(hashcode) result = @h.bin_dbl_sha256(tx + hashcode) result end
[ "def hash_function\n @hash_function ||= 'sha256'\n end", "def tx(hash)\n val = self[hash]\n return nil if val.nil?\n parse_tx(val)\n end", "def hash expr, algo = 'SHA1'\n Expression.new(\"CONVERT(BINARY(32), HASHBYTES('#{algo}', #{expr}), 2)\", MM::DataType::TYPE_Binary, expr.is_mandatory)\n end", "def pack_hexdigest(bin); end", "def get_tx(tx_hash)\n wrap_tx(@db[:tx][:hash => tx_hash.htb.blob])\n end", "def get_tx(tx_hash)\n raise \"Not implemented\"\n end", "def hash expr, algo = nil\n Expression.new(\"UNHEX(SHA1(#{expr}))\", MM::DataType::TYPE_Binary, expr.is_mandatory)\n end", "def hexhash\n hash.to_s(16)\n end", "def quick_xor_hash\n return @quick_xor_hash\n end", "def signature_hash_for_input(input_idx, outpoint_tx, script_pubkey=nil, hash_type=nil, drop_sigs=nil, script=nil)\n # https://github.com/bitcoin/bitcoin/blob/e071a3f6c06f41068ad17134189a4ac3073ef76b/script.cpp#L834\n # http://code.google.com/p/bitcoinj/source/browse/trunk/src/com/google/bitcoin/core/Script.java#318\n # https://en.bitcoin.it/wiki/OP_CHECKSIG#How_it_works\n # https://github.com/bitcoin/bitcoin/blob/c2e8c8acd8ae0c94c70b59f55169841ad195bb99/src/script.cpp#L1058\n\n hash_type ||= 1 # 1: ALL, 2: NONE, 3: SINGLE\n\n pin = @in.map.with_index{|i,idx|\n if idx == input_idx\n script_pubkey ||= outpoint_tx.out[ i.prev_out_index ].pk_script\n script_pubkey = Bitcoin::Script.binary_from_string(script) if script # force this string a script\n script_pubkey = Bitcoin::Script.drop_signatures(script_pubkey, drop_sigs) if drop_sigs # array of signature to drop\n length = script_pubkey.bytesize\n [ i.prev_out, i.prev_out_index, length, script_pubkey, i.sequence || \"\\xff\\xff\\xff\\xff\" ].pack(\"a32ICa#{length}a4\")\n else\n case hash_type\n when 2\n [ i.prev_out, i.prev_out_index, 0, \"\\x00\\x00\\x00\\x00\" ].pack(\"a32ICa4\")\n else\n [ i.prev_out, i.prev_out_index, 0, i.sequence || \"\\xff\\xff\\xff\\xff\" ].pack(\"a32ICa4\")\n end\n end\n }.join\n pout = @out.map{|o|\n [ o.value, o.pk_script_length, o.pk_script ].pack(\"QCa#{o.pk_script_length}\")\n }.join\n\n case hash_type\n when 2\n pout = \"\"\n in_size, out_size = Protocol.pack_var_int(@in.size), Protocol.pack_var_int(0)\n else\n in_size, out_size = Protocol.pack_var_int(@in.size), Protocol.pack_var_int(@out.size)\n end\n buf = [[@ver].pack(\"I\"), in_size, pin, out_size, pout, [@lock_time].pack(\"I\")].join + [hash_type].pack(\"I\")\n Digest::SHA256.digest( Digest::SHA256.digest( buf ) )\n end", "def txid\n tx_hash.rhex\n end", "def has_tx(tx_hash)\n raise \"Not implemented\"\n end", "def hash_bytes(blob)\n tlsh_hash(blob)\n end", "def compute_hash(text, bits)\n\tsha = Digest::SHA2.new(bits)\n\treturn sha.reset.update(text).to_s\nend", "def transaction_verification tx_hash\n \n trans = [tx_hash]\n \n result = Hash.new \n \n trans.each do |t|\n trans = @block.get_tx_by_hash tx_hash \n \n result = result.merge trans_addr_verify(@data_provider, trans.hash, trans.inputs)\n result = result.merge trans_addr_verify(@data_provider, trans.hash, trans.outputs)\n \n \n end\n \n result \n end", "def transaction_hash\n if @transaction\n @transaction.hex_hash\n elsif @transaction_hash\n @transaction_hash\n else\n \"\"\n end\n end", "def hash_check(block)\r\n unpacked_string = block.line_num + '|' + block.last_hash + '|' + block.transactions + '|' + block.time_val\r\n unpacked_string = unpacked_string.unpack('U*')\r\n sum = 0\r\n unpacked_string.each do |x|\r\n temp = (x**2000) * ((x + 2)**21) - ((x + 5)**3)\r\n sum += temp\r\n end\r\n sum = sum % 655_36\r\n return sum.to_s(16) != block.end_hash\r\n end", "def generate_hash!(use_hex_string=true)\r\n\r\n # generate hash and @digest reset.\r\n hash = use_hex_string ? @digest.hexdigest! : @digest.digest!\r\n @base_str = nil\r\n hash\r\n end", "def default_hash_function(plain_token)\n ::Digest::SHA256.hexdigest plain_token\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Signs the transaction, appends the hashcode and encodes it into DER format.
def ecdsa_tx_sign(tx, priv, hashcode=SIGHASH_ALL) rawsig = @dsa.ecdsa_raw_sign(bin_txhash(tx, hashcode), priv) @dsa.encode_sig(*rawsig) + hashcode.to_s.rjust(2, '0') #@sp.encode(hashcode, 16, 2) end
[ "def sign(transaction)\n raise TypeError \"transaction must be a Transaction, but #{transaction.class} given.\" unless transaction.is_a? Transaction\n raise NotMyTransactionError.new 'tx not yours!' unless transaction.wallet == self\n raise Transaction::TransactionAlreadyLockedError.new 'locked transaction' if transaction.locked?\n\n hash_orig = transaction.to_hash\n\n hash_values = hash_orig[:input_size].times.map do |index|\n hash = hash_orig.dup\n hash[:inputs][index][:script] = {\n address: Blockchain::Digest.hash160(self.public_key)\n }\n # calculate hash value\n hash_input = Blockchain::Digest.sha256d hash.to_json\n hash_value = Blockchain::Wallet::Signature.sign(hash_input, self.private_key)\n hash_value.encode\n end\n\n transaction.refers_tos.each_rel do |ref|\n ref.update!({\n signature: hash_values[ref.index],\n public_key: self.public_key\n })\n end\n\n transaction_hash_value = Blockchain::Digest.sha256d transaction.to_json\n transaction.update!(hash_value: transaction_hash_value)\n\n transaction.lock!\n\n return transaction\n end", "def sign(wallet)\n tx = Arweave::Transaction.new(data: @commit.message.to_s)\n @commit.to_tags.each do |name, value|\n tx.add_tag(name: name, value: value)\n end\n tx.sign(wallet)\n end", "def signrawtransaction(hexstring, transaction = nil, privatekey =nil, sighashtype = \"ALL\")\n @api.request 'signrawtransaction', hexstring, transaction, privatekey, sighashtype\n end", "def sign_tx(raw_tx, private_key)\n request 'sign_tx', unsigned_tx_hex: raw_tx, privkey: private_key\n end", "def sign(data, hash_type = \"SHA3_384\")\n __getobj__.sign(data.force_encoding('binary'), hash_type)\n end", "def sign(data)\n post(path: 'transactions/sign', body: data)\n end", "def send_transaction(tx)\n stx = sign_transaction(tx)\n send_raw_transaction(stx)\n end", "def sign(private_key, chain_id)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(Chains.to_v(recovery_id, chain_id))\n result.pack('c*')\n end", "def sign(data, digest = SHA256.new)\n key.sign digest, data\n end", "def sign(data)\n @key.sign(@algo.new, data)\n end", "def sign(parameters)\n phrase = []\n parameters.sort.to_h.each do |k, v|\n phrase << [k, v].join('=')\n end\n phrase.push(@options[:signature_phrase])\n phrase.unshift(@options[:signature_phrase])\n Digest::SHA256.hexdigest(phrase.join)\n end", "def sign(payload)\n hash = @digest.digest(payload)\n asn1_sig = @key.dsa_sign_asn1(hash)\n r, s = self.class.decode_asn1_signature(asn1_sig)\n self.class.encode_jws_signature(r, s, @prime_size)\n end", "def sign(data)\n key.dsa_sign_asn1(data)\n end", "def to_signed_tx(private_key)\n sign_tx to_raw_tx, private_key\n end", "def sign(payload)\n @key.sign(@digest, payload)\n end", "def sign data\n return unless @key\n\n @key.sign @digest_algorithm.new, data\n end", "def sign!(ha)\n ha[:sig] = compute_checksum(ha)\n end", "def signature_base\n tx = Stellar::Transaction.from_xdr(\n # TransactionV0 is a transaction with the AccountID discriminant\n # stripped off, we need to put it back to build a valid transaction\n # which we can use to build a TransactionSignaturePayloadTaggedTransaction\n Stellar::PublicKeyType.to_xdr(Stellar::PublicKeyType.public_key_type_ed25519) + to_xdr\n )\n\n tagged_tx = Stellar::TransactionSignaturePayload::TaggedTransaction.new(:envelope_type_tx, tx)\n\n Stellar::TransactionSignaturePayload.new(\n network_id: Stellar.current_network_id,\n tagged_transaction: tagged_tx\n ).to_xdr\n end", "def sign(string)\n @key.sign OpenSSL::Digest::SHA256.new, string\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }