query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
POST /villagesummaryreports POST /villagesummaryreports.json
def create @villagesummaryreport = Villagesummaryreport.new(villagesummaryreport_params) respond_to do |format| if @villagesummaryreport.save format.html { redirect_to @villagesummaryreport, notice: 'Villagesummaryreport was successfully created.' } format.json { render action: 'show', st...
[ "def index\n @villagesummaryreports = Villagesummaryreport.all\n end", "def new\n @summary_report = SummaryReport.new\n @projects = Project.all\n @users = User.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @summary_report }\n end\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /villagesummaryreports/1 PATCH/PUT /villagesummaryreports/1.json
def update respond_to do |format| if @villagesummaryreport.update(villagesummaryreport_params) format.html { redirect_to @villagesummaryreport, notice: 'Villagesummaryreport was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } ...
[ "def update_report_template(args = {}) \n put(\"/reports.json/template/#{args[:templateId]}\", args)\nend", "def update\n @api_report = Report.find(params[:id])\n if @api_report.update(params[:api_report])\n render json: @api_report, status: :success\n else\n render json: @api_report.errors, sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /villagesummaryreports/1 DELETE /villagesummaryreports/1.json
def destroy @villagesummaryreport.destroy respond_to do |format| format.html { redirect_to villagesummaryreports_url } format.json { head :no_content } end end
[ "def destroy\n @statusreport = current_user.organization.statusreports.find(params[:id])\n @statusreport.destroy\n respond_to do |format|\n format.html { redirect_to statusreports_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @annual_summary_report.destroy\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieves the school's URL prefixed with '
def full_url if school_site.start_with? 'http://' school_site else "http://#{school_site}" end end
[ "def get_edit_url(student)\n \t\turi = URI.parse(edit_student_path(student))\n \t\turi.query = URI.encode_www_form( {'edithash' => student.edithash} )\n \t\turi.to_s\n \tend", "def get_url\n \"http://www.allabolag.se/#{self.identification_no.gsub(\"-\",\"\")}\"\n end", "def url\n # Some courses do no...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate imports for WSDL Service class
def service_imports(schema, service, package) list = [] # custom package provided during generation pkg = options[:namespace] pkg += "." if pkg.present? # import request and response of operations service.operations.each do |name, definition| ...
[ "def service_imports(schema, service, package)\n list = []\n\n # custom package provided during generation\n pkg = options[:namespace]\n pkg += \".\" if pkg.present?\n\n # import request and response of operations\n service.operations.each do |name, definition|\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a hash of arguments for wsdl operations including the request and header arguments hash is in the format of [name] = [type]
def get_wsdl_operation_arguments(operation_definition) argument_array = [] argument_array.push('$' + operation_definition.request.camelcase(:lower)) #argument_array.push('$' + operation_definition.header.camelcase(:lower)) argument_array end
[ "def get_wsdl_operation_arguments(operation_definition)\n argument_hash = {}\n argument_hash[validate_property_name(operation_definition.request_property.name)] = operation_definition.request\n argument_hash\n end", "def get_wsdl_operation_arguments(operation_definition)\n argum...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Assigns samples to specific well locations The order of the samples and the order of the association map should be the same
def add_samples_to_collection(samples, to_collection, association_map: nil) slots_left = to_collection.get_empty.length if samples.length > slots_left raise "Not enough space in in collection #{to_collection}" end unless association_map.present? to_collection.add_samples(samples) retu...
[ "def update_sample_locs\n self.samples.each do |k|\n k['storage_location_id'] = self.storage_location_id\n end\n end", "def save_sample_locs\n self.samples.each do |k|\n @sample = Sample.find(k[:id])\n @sample.storage_location_id = self.storage_location['id'] \n @samp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a 'to_assocation_map' for all parts that share the same item or sample
def to_association_map(collection:, item:) association_map = [] locations = collection.find(item) locations.each do |loc| association_map.push({ to_loc: loc }) end association_map end
[ "def associate_to_all(plate:, data:, key:)\n data_map = []\n parts.each do |part|\n loc = plate.find(part)\n loc[2] = data\n loc[3] = key\n data_map.push(loc)\n end\n associate_value_key_to_parts(plate: plate, data_map: data_map)\n end", "def transfer_part_associations(from_collec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a 'from_assocation_map' for all parts that share the same item or sample
def from_association_map(collection:, item:) association_map = [] locations = collection.find(item) locations.each do |loc| association_map.push({ from_loc: loc }) end association_map end
[ "def associate_to_all(plate:, data:, key:)\n data_map = []\n parts.each do |part|\n loc = plate.find(part)\n loc[2] = data\n loc[3] = key\n data_map.push(loc)\n end\n associate_value_key_to_parts(plate: plate, data_map: data_map)\n end", "def associate_value_to_parts(plate:, data_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DEPRECATED Instructions to tech to relabel plate TODO this should be deleted since this exists in Collection Actions
def relabel_plate(from_collection:, to_collection:) show do title 'Rename Plate' note "Relabel plate <b>#{from_collection.id}</b> with <b>#{to_collection.id}</b>" end end
[ "def relabel_plate(plate1, plate2)\n show do\n title \"Rename Plate\"\n note \"Relabel plate #{plate1.id} with #{plate2.id}\"\n end\n end", "def new_label (name, color, issue)\n newlab = [{:name => name, :color => color}]\n @client.update_issue(\"LingduoKong/final\", issue, :labels => newlab)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a one to one association map
def one_to_one_association_map(from_collection:, skip_nil: true) rows, cols = from_collection.dimensions association_map = [] rows.times do |row| cols.times do |col| next if from_collection.part(row, col).nil? && skip_nil loc = [row, col] association_map.push({ to_loc: loc, fr...
[ "def _many_to_one_hash\n @_many_to_one_hash ||= {}\n end", "def _one_to_one_hash\n @_one_to_one_hash ||= {}\n end", "def _one_to_many_hash\n @_one_to_many_hash ||= {}\n end", "def has_one_associations\n self.reflect_on_all_associations(:has_one).collect do ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
////////////////////////////////////////////////////////////////////////// Private Methods ////////////////////////////////////////////////////////////////////////// Create an item for the ShopItems list index : item index
def create_item(index) item = @data[index] rect = item_rect(index, true) shopItem = UCShopItem.new(self, item, rect, SHOP_CONFIG::ITEM_NUMBER_PATTERN) shopItem.cItemPrice.align = 2 shopItem.cItemPossess.align = 2 shopItem.cItemPo...
[ "def create_item(index)\n item = @data[index]\n rect = item_rect(index, true)\n \n shopItem = UCShopItem.new(self, item, rect,\n SHOP_CONFIG::ITEM_NUMBER_PATTERN)\n \n shopItem.cItemPrice.align = 2 \n shopItem.cItemPossess.align = 2 \n s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creates a package from the given assets location and upload it to s3
def upload_package_to_s3(sub_path) package = create_package(sub_path) raise "Generated different package for same contents" unless package_matches_download(package) upload_package(package) package end
[ "def put_package\n set :release_name, revision\n logger.debug \"#{package_name} already in bucket #{bucket_name}\" and return if bucket_includes_package\n logger.debug \"#{package_name} not found in bucket #{bucket_name} so ckout to add it\"\n \n # Do the checkout locall...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Unzips package into target location
def decompress_package(package) @logger.info "Decompressing #{package.path}\nto #{@target_location}" FileUtils.mkdir_p(@target_location) Dir.chdir(@target_location) do # Clear out existing package FileUtils.rm_rf Dir.glob("#{@target_location}/*") RakeUtils.system "tar -zxf #{package.path}"...
[ "def unzip\n cmd = \"unzip #{zip_folder} -d #{unzipped_target_folder}\"\n system cmd\n end", "def untar_downloaded_package\r\n pkg_name = @out_package_down\r\n dir_to_unpack = File.dirname(pkg_name)\r\n name_extr_folder = File.basename(pkg_name).split(\".\").first\r\n old_dir = Dir.pwd\r\n b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /store/manager/messages/1 GET /store/manager/messages/1.json
def show @store_manager_message = Store::Manager::Message.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @store_manager_message } end end
[ "def show\n @store_manager_messages_read = Store::Manager::Messages::Read.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store_manager_messages_read }\n end\n end", "def new\n @store_manager_message = Store::Manager::Message.new\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /store/manager/messages/new GET /store/manager/messages/new.json
def new @store_manager_message = Store::Manager::Message.new respond_to do |format| format.html # new.html.erb format.json { render json: @store_manager_message } end end
[ "def new\n @store_manager_messages_unread = Store::Manager::Messages::Unread.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store_manager_messages_unread }\n end\n end", "def new\n @store_manager_messages_read = Store::Manager::Messages::Read.new\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /store/manager/messages POST /store/manager/messages.json
def create @store_manager_message = Store::Manager::Message.new(params[:store_manager_message]) respond_to do |format| if @store_manager_message.save format.html { redirect_to @store_manager_message, notice: 'Message was successfully created.' } format.json { render json: @store_manager_m...
[ "def new\n @store_manager_message = Store::Manager::Message.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store_manager_message }\n end\n end", "def create\n @store_manager_messages_folders_message = Store::Manager::Messages::Folders::Message.new(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /store/manager/messages/1 PUT /store/manager/messages/1.json
def update @store_manager_message = Store::Manager::Message.find(params[:id]) respond_to do |format| if @store_manager_message.update_attributes(params[:store_manager_message]) format.html { redirect_to @store_manager_message, notice: 'Message was successfully updated.' } format.json { he...
[ "def update\n respond_to do |format|\n @message.update!(message_params)\n format.json { head :no_content }\n end\n end", "def update\n @store_manager_messages_read = Store::Manager::Messages::Read.find(params[:id])\n\n respond_to do |format|\n if @store_manager_messages_read.update_att...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /store/manager/messages/1 DELETE /store/manager/messages/1.json
def destroy @store_manager_message = Store::Manager::Message.find(params[:id]) @store_manager_message.destroy respond_to do |format| format.html { redirect_to store_manager_messages_url } format.json { head :no_content } end end
[ "def destroy\n @store_manager_messages_read = Store::Manager::Messages::Read.find(params[:id])\n @store_manager_messages_read.destroy\n\n respond_to do |format|\n format.html { redirect_to store_manager_messages_reads_url }\n format.json { head :no_content }\n end\n end", "def delete\n m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an image tag for the given user with one of his/her social profile image if any.
def social_image_for(user, options = { size: 80 }) image_urls = user.social_profiles.pluck(:image_url) border = 4 unless image_urls.empty? image_tag(image_urls.sample, size: options[:size] + border, alt: user.email, class: "gravatar") end end
[ "def profile_picture_for(user)\n if user.picture?\n image_tag(user.picture.url, alt: user.name, class: \"profile_picture\")\n else\n image_tag(random_default_image, alt: user.name, class: \"profile_picture\")\n end\n end", "def display_user_image(user)\n content_tag(:span, class: ['image'])...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Submissions must be excused upfront else once the first requirement check happens the all_met condition will fail on submissions not being excused yet content_tag where we want to place them context_module module of the place we want to place them
def custom_placement_at(content_tag) context_module = content_tag.context_module course = context_module.context new_placement_position = content_tag.position - 1 # get 'lower' module units in Course bypass_modules = course.context_modules .where('...
[ "def allow_late_submissions\n return @allow_late_submissions\n end", "def handle_content_exclusions\r\n @entry ||= Content.find(@content_id || params[:id])\r\n raise Kroogi::NotFound if @entry.class.name.to_s == 'ImageThumbnail'\r\n raise Kroogi::NotFound if @entry.feature...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /place_ratings GET /place_ratings.json
def index @place_ratings = PlaceRating.all end
[ "def statistics\n ratings = Restaurant.within(params[:latitude],\n params[:longitude],\n params[:radius]).pluck(:rating)\n render json: {\n count: ratings.length,\n avg: ratings.mean,\n std: ratings.standard_deviation\n }\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /place_ratings POST /place_ratings.json
def create @place_rating = PlaceRating.new(place_rating_params) respond_to do |format| if @place_rating.save format.html { redirect_to @place_rating, notice: 'Place rating was successfully created.' } format.json { render :show, status: :created, location: @place_rating } else ...
[ "def index\n @place_ratings = PlaceRating.all\n end", "def update\n respond_to do |format|\n if @place_rating.update(place_rating_params)\n format.html { redirect_to @place_rating, notice: 'Place rating was successfully updated.' }\n format.json { render :show, status: :ok, location: @pl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /place_ratings/1 PATCH/PUT /place_ratings/1.json
def update respond_to do |format| if @place_rating.update(place_rating_params) format.html { redirect_to @place_rating, notice: 'Place rating was successfully updated.' } format.json { render :show, status: :ok, location: @place_rating } else format.html { render :edit } ...
[ "def update\n user_id = decoded_token[0]['user_id'].to_i\n restaurant_id = Restaurant.find_by(yelp_id: rating_params[:yelp_id]).id\n rating = Rating.find_by(restaurant_id: restaurant_id, user_id: user_id)\n rating.value = rating_params[:value]\n if rating.save\n render json: RatingSerializer.new...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /place_ratings/1 DELETE /place_ratings/1.json
def destroy @place_rating.destroy respond_to do |format| format.html { redirect_to place_ratings_url, notice: 'Place rating was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @make_rating.destroy\n respond_to do |format|\n format.html { redirect_to make_ratings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rating.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reset response so redirect or render can be called again. This is an undocumented hack but it works.
def reset_response self.instance_variable_set(:@_response_body, nil) end
[ "def reset_response\n self.instance_variable_set(:@_response_body, nil)\n end", "def clearResponse()\n\t\t\t@response = false\n\t\tend", "def erase_redirect_results #:nodoc:\n @performed_redirect = false\n response.status = DEFAULT_RENDER_STATUS_CODE\n response.headers.delete('Location')\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Respond to uncaught exceptions with friendly error message during ajax requets
def handle_uncaught_exception(exception) if request.format == :js report_error(exception) flash.now[:error] = Rails.env.development? ? exception.message : I18n.t('errors.unknown') render 'layouts/uncaught_error.js' else raise end end
[ "def ajax_error_monitor\n \n end", "def render_500_with_ajax\n if request.xhr?\n render :update, :status => '500' do |page|\n page.alert(\"An internal error occurred, please report this to #{FEEDBACK_EMAIL}.\")\n end\n else\n render_500_without_ajax\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
private method with default configuration values for LDAP
def defaults { hostname: 'localhost', basedn: 'dc=domain,dc=tld', rootdn: '', passdn: '', auth: false, port: 389, scope: :subtree, username_ldap_attribute: 'uid', ldaps: false, starttls: false, tls_opti...
[ "def create_default_authentication_ldap_configuration(opts)\n opts = check_params(opts,[:search_base_dn,:servers])\n super(opts)\n end", "def create_default_authentication_ad_configuration(opts)\n opts = check_params(opts,[:search_base_dn,:servers])\n super(opts)\n end", "def config_cl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
read accessor on the first credentials, username
def username credentials.first end
[ "def username\n return @username\n end", "def user_details\n user_details_for(@qualified_username).first\n end", "def get_user(username)\n Chef::Log.info username\n user = @node[:users][username]\n Chef::Log.info user.inspect\n user\nend", "def get_user\n if !@settings[\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
read accessor on the last credentials, password
def password credentials.last end
[ "def password_credentials\n return @password_credentials\n end", "def password_credential\n return @password_credential\n end", "def credentials\n return @credentials\n end", "def get_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Matches a given regex to all of its occurrences within the text, yielding to the block with the matched text, the character offset and character length of the match.
def scan(regex) while @scanner.scan_until(regex) match = @scanner.matched position = @scanner.charpos - match.length yield match, position, match.length end end
[ "def scan(re, &block)\n results = []\n char_offset = 0\n re.scan(content) do |md|\n results << (yield [md, line_of(char_offset + md.begin(0))])\n \n char_offset += md[0].size + md.pre_match.size\n remaining = md.post_match\n end\n results\n end", "def each_match_range(range, re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Task B. Note that the answer to (A) is naturally an O(n) time algorithm to compute the optimal k for a given n. But if you repeat this for every n = 1, ... , N, it takes O(n^2) time to compute the optimal k for every n. Try to design an O(N log N) time algorithm or an O(N) time algorithm to compute the optimal k for al...
def calculate_optimal_k k=0 @k_optimal = Array.new(@size) (3..@size).each{|n| k+=1 while(cost(n,k)<cost(n,k+1)) @k_optimal[n]=k } end
[ "def solution(k, _m, a)\n min = a.max\n max = a.inject :+\n\n return max if a.size == 1\n return min if a.size <= k\n \n while min <= max do\n mid = (min+max)/2\n\n valid = a.inject([0,0]) do |(sum, count), el| \n sum + el > mid ? (sum=el and count +=1) : sum+=el\n break if count >= k\n [...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Lookup a running process by its PID
def [](pid) pid = pid.to_i @running_processes[pid] ||= find_by_pid(pid) end
[ "def find_process(bundle)\n process = @processes.find {|p| p.bundleIdentifier == bundle }\n Process.new(process) if process\n end", "def find_process_id(process_name)\n process = remote_processes.find { |p| p.cmd.include?(process_name) }\n process ? process.pid : nil\n end", "def get_pid\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
if a user should not be accepted, this function deletes that user unless he is already approved.
def reject! return false if self.approved == true self.destroy end
[ "def destroy_or_unaccept(user)\n if self.friendshipped_by_me == user\n self.destroy\n else\n self.update_attribute(:accepted_at, nil)\n end\n end", "def unconfirm_user(user)\n confirmed_interpreter_requests.find_by(user_id: user.id).destroy\n end", "def reject_user\n # set the enabled...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Download a team icon image
def download_team_icon(team_id) get("teams/#{team_id}/icon") end
[ "def download_project_icon(project_id_or_key)\n get(\"projects/#{project_id_or_key}/image\")\n end", "def png()\n\n filename = \"#{$MYDIR}/#{@z}-#{@x}-#{@y}.png\"\n\n if File.exist?(filename) then return filename end\n\n # if the file doesn't exist, use curl to pull the image\n\n url = \"h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the domain metadata.
def domain_metadata(domain_name) Adapter.domain_metadata(domain_name)\ ['DomainMetadataResponse']['DomainMetadataResult'] end
[ "def domain_metadata(domain_name)\n request(\n 'Action' => 'DomainMetadata',\n 'DomainName' => domain_name,\n :idempotent => true,\n :parser => Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string)\n )\n end", "def get_domai...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given an Array of Arrays of Integers ( [ [10, 11], [99, 50, 3, 4], [23, 41] ] ): Output all even values in each nested array We can see which values are even, and go straight to printing only those. What if we had this exact structure (an array of three arrays, each with three element), but we couldn't see the values c...
def find_even_values(src) x = 0 # This is going to count where we are in the array. while x < src.length # Amount of elements in the array y = 0 while y < src[x].length if src[x][y].even? puts src[x][y] end y += 1 #y = y + 1 end x += 1 # x++ end end
[ "def evenies(array)\n even_array = []\n array.each_with_index { |e, idx| even_array << e if idx.odd? }\n even_array\nend", "def find_even(array)\nend", "def select_every_even arr\n ans = []\n arr.each_with_index do |item, i|\n if i%2 == 0 \n ans.push item\n end\n end\n ans\nend", "def odditi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /logos POST /logos.json
def create @logo = Logo.new(logo_params) respond_to do |format| if @logo.save format.html { redirect_to @logo, notice: 'Logo was successfully created.' } format.json { render :show, status: :created, location: @logo } else format.html { render :new, alert: 'Error creating lo...
[ "def create\n @logo = Logo.new(params[:logo])\n\n respond_to do |format|\n if @logo.save\n format.html { redirect_to admin_logos_path, notice: t('app.msgs.success_created', :obj => t('activerecord.models.logo')) }\n format.json { render json: @logo, status: :created, location: @logo }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /logos/1 DELETE /logos/1.json
def destroy @logo.destroy respond_to do |format| format.html { redirect_to logos_url, notice: 'Logo was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @logo = Logo.find(params[:id])\n @logo.destroy\n\n respond_to do |format|\n format.html { redirect_to logos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @logo = Logo.find(params[:id])\n @logo.destroy\n\n respond_to do |format|\n format.h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the parse method will take the name arg and split it into an array and iterate over it and split it again at the "," and if it is a duplicate it will remove them
def parse name.split.collect do |address| address.split(',') end.flatten.uniq end
[ "def split_arg arg\n arry = []\n if arg.is_a?(Array)\n arry += arg\n elsif arg =~ /,/\n arry += arg.split(',')\n else\n arry << arg\n end\n arry\n end", "def parse\n csv_emails.split(/,?\\s/).uniq\n end", "def formatNameFromString( n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A Ruby ASCII string, used for representing names in code and Symbol objects.
def string(str) TYPE_STRING + word(str.length) + str.encode!("ASCII") end
[ "def to_s() name end", "def name\n [@n.to_s + character.to_s, symmetry].reject{|p| p == \"\"}.join(\"_\")\n end", "def inspect\n str = '\"'\n 0.upto(length - 1) do |i|\n chr = self[i].chr\n\n if isalnum chr then\n str << chr\n elsif chr == '\"' then\n str << '\\\"'\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Collect a user's tweets within the last 7 days
def recent_tweets @_recent_tweets ||= timeline.each_with_object([]) do |tweet, memo| age_of_tweet_in_days = (Time.now.to_date - tweet.created_at.to_date).to_i memo << tweet if age_of_tweet_in_days <= 7 end end
[ "def get_6_months_tweets(client, screen_name)\n # To not reach the rate limit of the Twitter API, we get 200 (the maximum) tweets in each request\n # until we have the tweets in the last 6 months or older.\n # As we can get older tweets, after the necessary request, we will get rid of that older tweets\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Custom namespaces used in EMIS SOAP request message
def custom_namespaces Settings.emis.military_information.v1.soap_namespaces end
[ "def custom_namespaces\n Settings.emis.military_information.v2.soap_namespaces\n end", "def custom_namespaces\n Settings.emis.payment.v1.soap_namespaces\n end", "def custom_namespaces\n Settings.emis.payment.v2.soap_namespaces\n end", "def on_response_document(doc)\n doc.add_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /ads POST /ads.json
def create @ad = Ad.new(ad_params) if @ad.save render :show, status: :created, location: @ad else render json: @ad.errors, status: :unprocessable_entity end end
[ "def create\n @ad = Ad.new(ad_params)\n\n if @ad.save\n render json: @ad, status: :created, location: @ad\n else\n render json: @ad.errors, status: :unprocessable_entity\n end\n end", "def create\n @ad = Ad.new(params[:ad])\n\n if @ad.save\n render json: @ad, status: :created, lo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /image_sets/1 GET /image_sets/1.json
def show @image_set = ImageSet.find(params[:id]) render json: @image_set end
[ "def index\n @image_sets = ImageSet.all\n end", "def index\n @image_sets = ImageSet.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @image_sets }\n end\n end", "def index\n @image_sets = ImageSet.all\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
used for sorting results, combined weighted averages for property/landlord
def update_combined_rating property_weight, landlord_weight = 1, 1 weighted_property_rating = property_weight * property.average_property_rating weighted_landlord_rating = landlord_weight * license.average_landlord_rating combined_avg = (weighted_property_rating + weighted_landlord_rating) / 2 prope...
[ "def apartments_by_average_credit_rating\n result = {excellent: [], great: [], good: [], mediocre: [], bad: []}\n @apartments.each_with_object(result) {|a,h| h[a.credit_rating] << a}\n end", "def calculate_average_from_hash(class_name,qualification, group_name,arr,compare_data)\n\t\tif compare_data == 'lp'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run a command in the background, optionally log to a log file and save the process ID in a pid file
def run_bg(cmd, pid: nil, log: '/dev/null') cmd = @before_run_block.call(cmd) if @before_run_block return false unless cmd full_cmd = "exec #{cmd} >#{log} 2>&1" say "!txtgrn!> #{full_cmd}" unless Runfile.quiet process = IO.popen "exec #{cmd} >#{log} 2>&1" File.write pidfile(pid), pro...
[ "def run_in_background\n FileUtils.rm_rf @options.log_folder\n FileUtils.mkdir_p @options.log_folder\n\n pid = spawn(*cli_command, %i[err out] => File.join(@options.log_folder, 'convert_videos.log'))\n nice_process pid\n report_process_priority pid\n pid\n end", "def run_bg(cmd)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Stop a command started with 'run_bg'. Provide the name of he pid file you used in 'run_bg'
def stop_bg(pid) file = pidfile(pid) if File.exist? file pid = File.read file File.delete file run "kill -s TERM #{pid}" else say "!txtred!PID file not found." unless Runfile.quiet end end
[ "def stop_bg(*args)\n ExecHandler.instance.stop_bg(*args)\n end", "def _stop_cmd\n exit_on_failure stop_cmd, STOP_FAILED_CODE,\n \"Could not kill #{@name} pid for #{@app.name}\"\n end", "def run_bg(cmd)\n job = fork { exec cmd }\n Process.detach job\n end", "def stop!\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set a block to be called before each run
def before_run(&block) @before_run_block = block end
[ "def pre_execute(&block)\n @hooks[:pre_execute] = block\n end", "def pre_block\n end", "def before(&block)\n opts[:before_hook] = if b = opts[:before_hook]\n proc do\n instance_exec(&block)\n instance_exec(&b)\n end\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set a block to be called after each run
def after_run(&block) @after_run_block = block end
[ "def after_configure(&block)\n @after_configure_blocks ||= []\n @after_configure_blocks << block\n end", "def after_execute(&block)\n config.after_callbacks = [*config.after_callbacks, block]\n end", "def block(&_block)\n @_block = _block\n end", "def after_perform=(block)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run the machine until it stops for some reason Returns the reason why it stopped: :halted Executed a HALT instruction :needs_input Executed an INPUT instruction, but the input buffer was empty, fill the input buffer and call run again to resume :pc_range_err PC was moved out of the valid memory range
def run while !@halted && !@needs_input && @pc < mem.size opcode, params = Opcode.get_opcode_and_params(self, pc) if opcode == nil end Intcode.log("%5i %05i: %s" % [pc, mem[pc], opcode.debug(self, params)]) opcode.exec(self, params) end if @halted retu...
[ "def run start=0\n self.bc.pc = start\n while self.bc.pc <= self.bc.length\n handle_interrupt { step }\n end\n\n rescue TypeError => err\n raise VishTypeError.new(err.message)\n rescue HaltState => state\n @last_exception = state\n# return state.exit_code\n return self.ctx.stack.peek\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read a value from the amps output buffer, or 0 if the buffer is empty
def read_output() if outputs.size > 0 outputs.shift else nil end end
[ "def read\n return nil if empty?\n\n value = @buffer[@read]\n @read = (@read + 1) % @buffer.size\n value\n end", "def read\n @output.seek(@last_read_pos)\n result = @output.read\n @last_read_pos = @output.pos\n result\n end", "def read\n synchronize do\n wait_full\n @value...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
whether users can change the name on their signup or not override in challenge class as appropriate
def allow_name_change? true end
[ "def needs_username_change?\n self.force_username_change? || !self.username.present?\n end", "def is_namecoin?\n is_name_new? || is_name_firstupdate? || is_name_update?\n end", "def check_create_user_name_is_valid\n return self.name != \"\" ? true : false\n end", "def needs_name_change...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Guesses the round number (starting from 0) from the maximum amount of matches any team has played. The guess will be wrong for long running competitions where teams are free to sign up and drop out at any time.
def guess_round(driver) driver.team_matches_hash.values.map(&:length).max || 0 end
[ "def guess_round(driver)\n Algorithm::SingleBracket.guess_round(driver.seeded_teams.length,\n driver.matches.length)\n end", "def guess_round(driver)\n Algorithm::PagePlayoff.guess_round(driver.matches.length)\n end", "def max_teams(rounds)\n 2**(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns a list of Extract objects (including position and value) matching predefined rules
def extract(from) rules.reduce([]) do |extracts, rule| new_extracts = rule.extract(from).select do |extract| # do not consider new extract if colliding with existing one !extracts.any? { |e| e.collides?(extract) } end extracts.concat(new_extracts) end end
[ "def extract!\n extractors.map { |e| e.extract }\n end", "def extractors\n @extractors ||= []\n end", "def extract(expr)\n result = []\n @metrics[\"values\"].each do |metric|\n if metric[\"name\"] =~ expr\n result << metric\n end\n end\n result\n end", "def extrac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
replaces parts of text by [REDACTED]. The replacement string can be customized by passing a block taking the Extract object as an argument
def format(text, &block) extract(text).each_with_object(text.clone) do |extract, redacted_text| sub = block_given? ? block.call(extract) : default_replacement redacted_text[extract.start..extract.finish] = sub end end
[ "def apply!(text)\n text.gsub!(@matcher, @replacement)\n end", "def mask_article(text, words)\n pattern = words.join(\"|\")\n text.gsub(/#{pattern}/) {|match| strike(match)}\nend", "def format(&block)\n block ||= proc { |word| \"<em>#{word}</em>\" }\n highlight.gsub(HIGHLIGHT...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
publish a message on the channel +msg+ the message to publish. It must implement to_s
def publish msg @conn.send_data :opcode => PUBLISH, :channel => @name, :data => msg.to_s end
[ "def publish_msg(msg)\n raise TypeError, \"nats: expected NATS::Msg, got #{msg.class.name}\" unless msg.is_a?(Msg)\n raise NATS::IO::BadSubject if !msg.subject or msg.subject.empty?\n\n msg.reply ||= ''\n msg.data ||= ''\n msg_size = msg.data.bytesize\n\n # Accounting\n @stats[:ou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
subscribe to the channel, by sending to the remote
def subscribe @conn.send_data :opcode => SUBSCRIBE, :channel => @name @subscribe_sent = true end
[ "def subscribe_to_channel; end", "def subscribe channel, &block\n @client.subscribe channel, &block\n end", "def subscribe\n conn = @cluster.connect\n conn.subscribe(ALL)\n conn.subscribe(SHARE)\n conn.subscribe(@channel)\n conn.on(:message) do |channel, message|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
authorize pub/sub on this channel
def authorize channel_key @conn.send_data :opcode => AUTHORIZE, :channel => @name, :data => channel_key.to_s end
[ "def authorize subscriber, node\n true\n end", "def authorize_secure_message\n channel_name = WebsocketRails[message[:channel]]\n broadcast_user = WebsocketRails[message[:user_id]] # The user that sent the message\n\n if broadcast_user.can_message?(current_user)\n authorize_secure_message\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /known_values GET /known_values.xml
def index @known_values = KnownValue.find(:all, :order => 'name') respond_to do |format| format.html # index.html.erb format.xml { render :xml => @known_values } end end
[ "def new\n @known_value = KnownValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @known_value }\n end\n end", "def show\n @country_known_value = CountryKnownValue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.er...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /known_values/new GET /known_values/new.xml
def new @known_value = KnownValue.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @known_value } end end
[ "def new\n @country_known_value = CountryKnownValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @country_known_value }\n end\n end", "def create\n @known_value = KnownValue.new(params[:known_value])\n\n respond_to do |format|\n if @know...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /known_values POST /known_values.xml
def create @known_value = KnownValue.new(params[:known_value]) respond_to do |format| if @known_value.save flash[:notice] = "Varible #{@known_value.name} was successfully created." format.html { redirect_to(@known_value) } format.xml { render :xml => @known_value, :status => :cre...
[ "def create\n @country_known_value = CountryKnownValue.new(params[:country_known_value])\n\n respond_to do |format|\n if @country_known_value.save\n flash[:notice] = 'CountryKnownValue was successfully created.'\n format.html { redirect_to(@country_known_value) }\n format.xml { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /known_values/1 DELETE /known_values/1.xml
def destroy @known_value.country_known_values.delete_all @known_value = KnownValue.find(params[:id]) @known_value.destroy respond_to do |format| format.html { redirect_to(known_values_url) } format.xml { head :ok } end end
[ "def destroy\n @country_known_value = CountryKnownValue.find(params[:id])\n @country_known_value.destroy\n\n respond_to do |format|\n format.html { redirect_to(country_known_values_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @config_value = ConfigValue.find(params[:id]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /notices POST /notices.json
def create @notice = Notice.new(notice_params) @notice.client = current_client if current_client @notice.order_num = 0 shuffle_notices(current_client.id) if current_client @notices = Notice.all.where(client_id: current_client.id) if current_client respond_to do |format| if @notice.save ...
[ "def create\n @notice = Notice.new(notice_params)\n\n respond_to do |format|\n if @notice.save\n format.html { redirect_to @notice, notice: 'Notice was successfully created.' }\n format.json { render :show, status: :created, location: @notice }\n else\n format.html { render :new...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /notices/1 PATCH/PUT /notices/1.json
def update @notice.update(notice_params) respond_to do |format| format.json { render action: 'show' } end end
[ "def update\n @notice = @person.notices.find(params[:id])\n\n respond_to do |format|\n if @notice.update_attributes(params[:notice])\n format.html { redirect_to person_notices_path( @person), notice: 'notice was successfully updated.' }\n format.json { head :no_content }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /notices/1 DELETE /notices/1.json
def destroy @notice.destroy reorder_notices(current_client.id, @notice.order_num) if current_client respond_to do |format| format.json { head :no_content } end end
[ "def destroy\n @notice = Notice.find(params[:id])\n @notice.destroy\n\n respond_to do |format|\n format.html { redirect_to notices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @notice = Notice.find(params[:id])\n @notice.destroy\n\n respond_to do |format|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates the following folders features/ features/step_definitions features/support And the file features/support/env.rb
def create_structure if File.exists?("features") && File.directory?("features") return else FileUtils.mkpath "features/step_definitions" FileUtils.mkdir "features/support" FileUtils.mkdir "features/screenshots" FileUtils.touch"features/support/env.rb" end end
[ "def create_standard_cucumber_dir\n in_test_dir do\n FileUtils.mkdir_p 'features/support'\n FileUtils.mkdir 'features/step_definitions'\n create_env_rb\n create_stepdefs\n end\n end", "def create_env_rb\n in_test_dir do\n File.open('features/support/env.rb', 'w') do |file|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create features from list in features.md
def create_bulk file = File.new("features.md", "r") while (line = file.gets) line = line.chomp.strip.gsub(' ', '_') FileUtils.touch "features/#{line}.feature" FileUtils.touch "features/step_definitions/#{line}.steps.rb" end file.close end
[ "def extract_features(filename, text)\n @section = nil\n in_literal_text = false\n literal_text = ''\n tags = []\n text.each do |line|\n s = line.strip\n #$stderr.puts \"DEBUG: LINE='#{s}'\"\n if s == '\"\"\"'\n if in_literal_text\n @section.add(lite...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates .feature and .steps.rb files
def write_feature File.open("features/""#{@feature.gsub(" ", "_")}.feature", "w") do |f| f.write("#{@tags}\n") f.write("Feature: #{@feature}\n") f.write("Description: #{@description}\n\n") f.write("\tScenario: #{@scenario}\n") end @steps.each do |steps| File.open("features/""#{@fea...
[ "def create_structure\n if File.exists?(\"features\") && File.directory?(\"features\")\n return\n else\n FileUtils.mkpath \"features/step_definitions\"\n FileUtils.mkdir \"features/support\"\n FileUtils.mkdir \"features/screenshots\"\n FileUtils.touch\"features/support/env.rb\"\n end\n \n\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Console based walkthrough for feature and step creation
def steps steps_keywords = %w(Given When Then And But) nsteps = 0 @steps = [] while true print "Add step [Y/n]: " choice = gets if choice.downcase.strip != "n" puts "Step #{nsteps +1}:" step = gets.capitalize init_step_word = step.split(' ').first if steps...
[ "def step_definition; end", "def test_steps; end", "def _announce_step step\n puts \"\\n**** #{step}\"\nend", "def to_gherkin\n feature = 'Feature: ' + @feature_name\n desc = @description.nil? ? '' : \"\\n\\t\" + @description.sub(\"\\n\", \"\\n\\t\")\n scenarios = ''\n\n @scenarios.each do |item|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
runs cucumber and generates contents of .step_definitions from cucumber output
def cucumber_wrapper cucumber = `cucumber features/#{@feature.gsub(" ", "_")}.feature` File.open("features/step_definitions/#{@feature.gsub(" ", "_")}.steps.rb", 'w') do |parsed_steps| parsed_steps.write cucumber.split("You can implement step definitions for undefined steps with these snippets:\n\n").last ...
[ "def step_definitions\n if File.file?(full_file_path)\n @steps = []\n @file_contents = File.read(full_file_path)\n @file_contents.gsub!(/^(include|require).*$/, \"\") # we just want the Given/When/Then steps processed\n eval(@file_contents)\n @steps\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Raises validation error if the model's effective_end_date is past
def effective_end_date_has_passed if effective_end_date.present? && (effective_end_date > Time.zone.now) errors.add(:effective_end_date, 'must be in the past') end end
[ "def effective_end_date_gt_effective_start_date\n if effective_end_date\n if effective_end_date < effective_start_date\n self.errors.add(:base, \"The effective end date should be earlier or equal to effective start date\")\n end\n end\n end", "def check_end_date\n if end_date < Date.tod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An adjustment is simply a line item with a special product ID However, it's wrapped in an Adjustment object to make it easier to manipulate
def get_adjustment_line prd = Product.get_adjustment_product raise "Missing adjustment product: please add using Maintain/Products function" unless prd @lines.find {|li| li.li_prd_id == prd.prd_id } end
[ "def to_line_item\n {:id => id, :type => \"Adjustments\", :name => @@reasons[reason.to_sym], :cost => amount}\n end", "def adjust!\n raise \"Adjustment is already created\" if adjustment\n\n amount = compute_amount(inventory_unit.line_item)\n\n self.adjustment = inventory_unit.line_item.adjustm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return the total affiliate fee for our line items
def total_affiliate_fee total = 0.0 @lines.each {|line| total += (line.li_aff_fee * line.li_qty) } total end
[ "def fulfillment_fee\n\t line_items.inject(0.0) {|charge, line_item| charge = charge + (line_item.fulfillment_fee)}\n end", "def indirect_cost_total\n total = 0.0\n\n self.line_items.each do |li|\n if li.service.one_time_fee\n total += li.indirect_costs_for_one_time_fee\n else\n tota...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the user id for an order, and extract that user's shipping address as our own
def set_user_id(user_id) @data_object.order_user_id = user_id user = User.with_id(user_id) if user contact = user.contact ship = contact.ship add = contact.con_name + "\r\n" + ship.to_s @data_object.order_ship_address = add end end
[ "def strip_order_address_users(order)\n order.bill_address.try(:update_attributes!, user_id: nil)\n order.ship_address.try(:update_attributes!, user_id: nil)\n order\n end", "def associate_address\n order = Spree::Order.where(\"email = ?\", @user.email).order(\"created_at\").last\n if order.presen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a new line item based on a product
def add(product, qty) l = LineItem.new l.set_from_product(product, qty) @lines << l end
[ "def add_product(product)\n current_item = line_items.find_by(product_id: product.id) # find the current item in the line items. find_by() returns an existing LineItem or nil.\n if current_item # if the current item is present...\n current_item.quantity += 1 ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
delete all line items
def delete_all_lines @deleted_lines.concat @lines @lines.clear end
[ "def clear_line_items\n @line_items = []\n end", "def clear_lines\n @items.each { |item| @scene.removeItem item }\n @items.clear\n end", "def purge!\n unless self.ordered?\n self.line_items.each do |line_item|\n remove_line_item(line_item) if line_item.invalid?\n end\n end\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return true if this order is already marked for shipping
def shipping? each_line do |line| # has it shipped? return true if line.li_date_shipped # or is it queued up for shipping? return true if Ship.for_line_item(line) end return false end
[ "def shipping?\n true\n end", "def has_shipping?\n return false unless customer_required?\n order_type.has_shipping?\n end", "def delivery_address_required?\n !(shipping_class && !shipping_class.requires_delivery_address?)\n end", "def shipped?\n !!self.shipped_at?\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
adjust the amount applied to this order by 'amount' This is used when HQ staff edit a payment and change the amount applied
def adjust_payment(user, payment, amount) o = @data_object o.order_amount_paid += amount if o.order_amount_paid < 0 raise "Cannot adjust payment to a negative amount" end if o.order_amount_paid > o.order_grand_total raise "Cannot apply more than pending amount to order" end if f...
[ "def reapply_to_order(user, order, amount, session)\n p = @data_object\n\n # find the original payment\n pays = Pays.for_order_and_payment(order, self)\n\n difference = amount - pays.pys_amount\n\n # adjust the order\n\n order.adjust_payment(user, self, difference)\n\n common_apply_processing(u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return an string containing a reason why this order can't be deleted, or nil if it can
def reason_not_to_delete d = @data_object if d.order_amount_paid > 0.0 return "Cannot delete an order after it has been partially paid" end pays = Pays.for_order(self) unless pays.empty? return "Cannot delete an order after payments have been applied" end each_line do |line| ...
[ "def reason_not_to_delete\n if @data_object.pay_amount_applied > 0.0\n \"Cannot delete a payment after it has been applied to an order\"\n elsif @data_object.pay_paying_check_doc_ref && \n !@data_object.pay_paying_check_doc_ref.empty?\n \"Cannot delete a purchase order after it has been paid\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return an string containing a reason why this order can't be edited, or nil if it can
def reason_not_to_edit d = @data_object if d.order_amount_paid > 0.0 return "Cannot edit an order after it has been partially paid" end pays = Pays.for_order(self) unless pays.empty? return "Cannot edit an order after payments have been applied" end each_line do |line| if...
[ "def reason_not_to_delete\n d = @data_object\n if d.order_amount_paid > 0.0\n return \"Cannot delete an order after it has been partially paid\"\n end\n\n pays = Pays.for_order(self)\n unless pays.empty?\n return \"Cannot delete an order after payments have been applied\"\n end\n\n ea...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
delete this order and its associated line items
def delete LineItem.delete_for_order(order_id) CreditCardTransaction.remove_references_to_order(order_id) super end
[ "def delete\n self.class.delete_order_line_item_by_id(self.id)\n end", "def delete_by_id(id)\n delete_order_line_item_by_id(id)\n end", "def destroy_old_line_items(order)\n known_ids = self.source[:items].map { |i| i[:item_id] }\n Gemgento::LineItem\n .where(itemizable: or...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Whether the partition was created for an execute_query/query operation.
def execute_query? !@execute.nil? end
[ "def has_partition_key?\n partition_key_columns.any?\n end", "def hive_partitioning?\n !@gapi.hive_partitioning_options.nil?\n end", "def partitioned?\n __boolean(OCI_ATTR_PARTITIONED)\n end", "def hive_partitioning?\n !@gapi.configuration.load.hive_partiti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Responsible for going through the list of available gems and loading any plugins requested. It keeps track of what it's loaded already and won't load them again. It accepts one parameter which is a hash of gem depends that should include or exclude a gem from being loaded. A gem must depend on zergrush to be considered...
def load(needs = {}) needs = needs.merge({"zergrush" => INCLUDE}) Gem::Specification.each { |gem| # don't load gems more than once next if @gems.has_key? gem.name check = needs.dup # rolls through the depends and...
[ "def load_gem_plugins; end", "def load_plugins(options={})\n ops = resolve_defaults(options)\n\n load_settings = {}\n if ops[:includes]\n ops[:includes].each do |plugin|\n load_settings[plugin] = GemPlugin::INCLUDE\n end\n end\n\n if ops[:excludes]\n ops[:exc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Resolves the given name (should include /category/name) to find the plugin class and create an instance. You can pass a second hash option that is then given to the Plugin to configure it.
def create(name, options = {}) last_slash = name.rindex("/") category = name[0 ... last_slash] plugin = name[last_slash .. -1] map = @plugins[category] if not map raise "Plugin category #{category} does not exist" elsif not map.has...
[ "def uhook_new_from_name name, options = {}\n ::Category.new(\n :name => name,\n :locale => (options[:locale] || :any).to_s,\n :parent_id => options[:parent_id]\n )\n end", "def create_strategy(name)\n class_name = Hadley::Utils.camelize(nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simply says whether the given gem has been loaded yet or not.
def loaded?(gem_name) @gems.has_key? gem_name end
[ "def loaded?( gem_name )\n \n gem_require_name = gem_name.to_s.gsub( '/', '-' )\n \n return @loaded_gems.has_key?( gem_require_name.to_sym )\n \n end", "def gem_available?(name)\n gem name\n true\n rescue Gem::LoadError\n false\n end", "def gem?\n @gem\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GemPlugins can have a 'resources' directory which is packaged with them and can hold any data resources the plugin may need. The main problem is that it's difficult to figure out where these resources are actually located on the file system. The resource method tries to locate the real path for a given resource path. L...
def resource(gem_name, path) if not loaded? gem_name raise PluginNotLoaded.new("Plugin #{gem_name} not loaded when getting resource #{path}") end file = File.join(@gems[gem_name], "resources", path) if File.exist? file return file ...
[ "def plugins_dir\n resource[:plugins_dir]\n end", "def load_gem_plugins; end", "def load_gems\n Bundler.require(:plugins)\n end", "def load\n # Plugin dependencies let you load a plugin before this one,\n # so we don't want to load that sucker twice, now do we?\n unless loaded?\n # Setup...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If navigationgame selected, redirect back to gameindex
def games redirect_to navigation_games_path end
[ "def index\n redirect_to play_game_path(@current_game)\n end", "def back_to_game\n @special_state = false\n end", "def game\n game_id = params[:game_id].to_i\n if game_id != 0\n @game = Game.find(game_id)\n unless @game.active?\n flash.notice = 'The game is over.'\n back_to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If navigationteams selected, redirect back to teamsindex
def teams redirect_to navigation_teams_path end
[ "def on_team\n\t redirect_to(root_url) unless current_account.user.is_a?(Participant) && current_participant.team == @team\n\tend", "def check_team_presence\n redirect_to root_path unless team_present?\n end", "def games\n redirect_to navigation_games_path\n end", "def showUserTeam\n redirect_to t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If navigationcontact selected, redirect back to contactcontact
def contact redirect_to navigation_contact_path end
[ "def load_current_contact_or_redirect\n unless self.current_contact\n redirect_to new_press_contact_path\n return false\n end\n true\n end", "def load_current_contact_or_redirect\n unless self.current_contact\n redirect_to new_corporate_contact_path\n return false\n end\n tr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If navigationshowUserTeam selected ('Subscription' label), redirect back to teamshowUserTeam
def showUserTeam redirect_to team_showUserTeam_path end
[ "def on_team\n\t redirect_to(root_url) unless current_account.user.is_a?(Participant) && current_participant.team == @team\n\tend", "def teams\n redirect_to navigation_teams_path\n end", "def user_belongs_to_team!\n if signed_in? && current_team.present?\n redirect_to root_app_url unless current_te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This can be used to skip test examples that require CZMQ draft API to be available.
def no_czmq_drafts? # NOTE: We use some function that is currently declared DRAFT. Another one # might be needed in future versions. ::CZMQ::FFI.zproc_czmq_version return false rescue NotImplementedError, NoMethodError # not defined or it was just a placeholder definition from czmq-ffi-gen "CZ...
[ "def skip\n 'skip spec until we find good way to implement it'.should.not.be.nil\n end", "def fail_if_no_examples; end", "def skip_if_api_down\n unless @azul_is_ok\n puts @skip_message; skip\n end\n end", "def no_zmq_drafts?\n # NOTE: We use some function that is currently declared DRAFT. A...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This can be used to skip test examples that require ZMQ draft API to be available.
def no_zmq_drafts? # NOTE: We use some function that is currently declared DRAFT. Another one # might be needed in future versions. CZTop::Poller::ZMQ.poller_destroy(FFI::Pointer::NULL) return false rescue NotImplementedError # not defined or it was just a placeholder definition from # CZTop::...
[ "def skip\n 'skip spec until we find good way to implement it'.should.not.be.nil\n end", "def no_czmq_drafts?\n # NOTE: We use some function that is currently declared DRAFT. Another one\n # might be needed in future versions.\n ::CZMQ::FFI.zproc_czmq_version\n return false\n rescue NotImplemente...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /replacements GET /replacements.json
def index @replacements = Replacement.all end
[ "def create\n @replacements = replacements_params.map do |replacement_params|\n Replacement.create(replacement_params)\n end\n\n respond_to do |format|\n if @replacements.all?(&:persisted?)\n format.json { render json: { success: true }, status: :created }\n else\n format.json ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /replacements/1 DELETE /replacements/1.json
def destroy @replacement.destroy respond_to do |format| format.html { redirect_to replacements_url, notice: 'Replacement was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @replace = Replace.find(params[:id])\n @replace.destroy\n\n respond_to do |format|\n format.html { redirect_to replaces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @incicent_replacement.destroy\n respond_to do |format|\n format.html { redi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /scout_masters/1 GET /scout_masters/1.xml
def show @scout_master = ScoutMaster.find(params[:id]) @scouts = Scouter.all respond_to do |format| format.html # show.html.erb format.xml { render :xml => @scout_master } end end
[ "def new\n @scout_master = ScoutMaster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scout_master }\n end\n end", "def show\n @mush_crawler = MushCrawler.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /scout_masters/new GET /scout_masters/new.xml
def new @scout_master = ScoutMaster.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @scout_master } end end
[ "def new\n @master = Master.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @master }\n end\n end", "def create\n @scout_master = ScoutMaster.new(params[:scout_master])\n\n respond_to do |format|\n if @scout_master.save\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /scout_masters POST /scout_masters.xml
def create @scout_master = ScoutMaster.new(params[:scout_master]) respond_to do |format| if @scout_master.save format.html { redirect_to(@scout_master, :notice => 'Scout master was successfully created.') } format.xml { render :xml => @scout_master, :status => :created, :location => @sco...
[ "def create\n @master = Master.new(params[:master])\n \n respond_to do |format|\n if @master.save\n flash[:notice] = 'Master was successfully created.'\n format.html { redirect_to(\"/proofs/?view=approved\") }\n format.xml { render :xml => @master, :status => :created, :location ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /scout_masters/1 PUT /scout_masters/1.xml
def update @scout_master = ScoutMaster.find(params[:id]) respond_to do |format| if @scout_master.update_attributes(params[:scout_master]) format.html { redirect_to(@scout_master, :notice => 'Scout master was successfully updated.') } format.xml { head :ok } else format.html...
[ "def create\n @scout_master = ScoutMaster.new(params[:scout_master])\n\n respond_to do |format|\n if @scout_master.save\n format.html { redirect_to(@scout_master, :notice => 'Scout master was successfully created.') }\n format.xml { render :xml => @scout_master, :status => :created, :locat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /scout_masters/1 DELETE /scout_masters/1.xml
def destroy @scout_master = ScoutMaster.find(params[:id]) @scout_master.destroy respond_to do |format| format.html { redirect_to(scout_masters_url) } format.xml { head :ok } end end
[ "def destroy\n @master = Master.find(params[:id])\n @master.destroy\n\n respond_to do |format|\n format.html { redirect_to(masters_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }