query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Get the complete workflow history.
def get_history events = [] # Get the first page of the workflow history page = get_history_page page["events"].each { |x| events << x } # Get the remaining pages of the workflow history until page["nextPageToken"].nil? page = get_history_page(pag...
[ "def history\n return @history\n end", "def history\n History\n end", "def workflow_histories(starttime, endtime)\n histories = []\n json_data = get(url: \"#{@url}workflows/history/#{starttime}/#{endtime}\")\n json_data.each do |wf|\n # Initialize Workflow...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetches a page of workflow history.
def get_history_page(page_token = nil) # Generate the request options for the service call. Optionally merge # next_page_token to the hash if the page_token value is not nil. request_opts = { domain: @domain, execution: @execution, }.merge(page_token ? { n...
[ "def get_history\n events = []\n # Get the first page of the workflow history\n page = get_history_page\n page[\"events\"].each { |x| events << x }\n\n # Get the remaining pages of the workflow history\n until page[\"nextPageToken\"].nil?\n page = get...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Call AWS Simple Workflow Service to get workflow execution information.
def get_execution_info execution = @swf.describe_workflow_execution( domain: @domain, execution: @execution ) execution["executionInfo"] end
[ "def workflow\n if @workflow == \"\"\n @workflow = @server.get_run_attribute(@uuid, @links[:workflow])\n end\n @workflow\n end", "def workflow_execution\n @task.workflow_execution\n end", "def workflow(id)\n make_json_api_request :get, \"v2/#{account_id}/workflows/#{i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current url. Provide :params => true to include request params.
def current_url(options = {}) path = (options[:params] == true) ? request.fullpath : request.path "#{current_host}#{path}" end
[ "def current_url\n @current_url ||= [request.path, (request.query_parameters.to_query if request.query_parameters.present?)].compact.join(\"?\")\n end", "def current_url(new_params)\n url_for :params => params.merge(new_params)\n end", "def current_url( opts = {} )\n url = URI.unescape( request.path_in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this makes the css and js organized
def set_assets @custom_csses = [] @custom_javascripts = [] action_hash = {"create" => "new", "update" => "edit"} file_name = action_hash[action_name] ? action_hash[action_name] : action_name root = Rails.root.to_s @custom_csses << "compiled/application.css" # always include the layout css ...
[ "def load_css\n AssetManager.include_css [:blog_home, :home]\n end", "def assets\n unless IO.read(\"app/assets/stylesheets/application.css\").include?(\"Required by SULChrome\")\n insert_into_file \"app/assets/stylesheets/application.css\", :after => \"/*\" do\n %q{\n * Required by SULChrome:\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /lb30s/1 GET /lb30s/1.xml
def show @lb30 = Lb30.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @lb30 } end end
[ "def show\n @lb40 = Lb40.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lb40 }\n end\n end", "def lbs\n lb = client.get(:loadbalancers)\n msg = \"Status: #{lb.status}\"\n raise Idcf::Cli::CliError, ms...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /lb30s/new GET /lb30s/new.xml
def new @lb30 = Lb30.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @lb30 } end end
[ "def new\n @lb202556 = Lb202556.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end", "def new\n @lb202554 = Lb202554.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb202...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /lb30s POST /lb30s.xml
def create @lb30 = Lb30.new(params[:lb30]) respond_to do |format| if @lb30.save format.html { redirect_to(@lb30, :notice => 'Lb30 was successfully created.') } format.xml { render :xml => @lb30, :status => :created, :location => @lb30 } else format.html { render :action => ...
[ "def create\n @lb40 = Lb40.new(params[:lb40])\n\n respond_to do |format|\n if @lb40.save\n format.html { redirect_to(@lb40, :notice => 'Lb40 was successfully created.') }\n format.xml { render :xml => @lb40, :status => :created, :location => @lb40 }\n else\n format.html { rende...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /lb30s/1 PUT /lb30s/1.xml
def update @lb30 = Lb30.find(params[:id]) respond_to do |format| if @lb30.update_attributes(params[:lb30]) format.html { redirect_to(@lb30, :notice => 'Lb30 was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xm...
[ "def update\n @lb202554 = Lb202554.find(params[:id])\n\n respond_to do |format|\n if @lb202554.update_attributes(params[:lb202554])\n format.html { redirect_to(@lb202554, :notice => 'Lb202554 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /lb30s/1 DELETE /lb30s/1.xml
def destroy @lb30 = Lb30.find(params[:id]) @lb30.destroy respond_to do |format| format.html { redirect_to(lb30s_url) } format.xml { head :ok } end end
[ "def destroy\n @lb202556 = Lb202556.find(params[:id])\n @lb202556.destroy\n\n respond_to do |format|\n format.html { redirect_to(lb202556s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lb202554 = Lb202554.find(params[:id])\n @lb202554.destroy\n\n respond_to do |fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Encodes parameters for passing them to GD execution platform. Core types are kept and complex types (arrays, structures, etc) are JSON encoded into key hash "gd_encoded_params" or "gd_encoded_hidden_params", depending on the 'hidden' method param. The two different keys are used because the params and hidden params are...
def encode_params(params, hidden = false) res = {} nested = {} core_types = [FalseClass, Fixnum, Float, NilClass, TrueClass, String] params.each do |k, v| if core_types.include?(v.class) res[k] = v else nested[k] = v end end ...
[ "def jsonify_parameters(params)\n encoded_params = {}\n params.each_pair do |key, val|\n if val.is_a?(String)\n encoded_params[key] = val\n elsif val.is_a?(Integer)\n encoded_params[key] = val.to_s\n else\n encoded_params[key] = JSON.generate(val)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Decodes params as they came from the platform The "data" key is supposed to be json and it's parsed if this
def decode_params(params) key = ENCODED_PARAMS_KEY.to_s hidden_key = ENCODED_HIDDEN_PARAMS_KEY.to_s data_params = params[key] || '{}' hidden_data_params = params[hidden_key] || '{}' begin parsed_data_params = JSON.parse(data_params) parsed_hidden_data_params ...
[ "def parse(params)\n Marshal.load(Base64.decode64(params))\n end", "def drda_parse_parameter(data)\n\t\tparam = {\n\t\t\t:length => data.slice!(0,2).unpack(\"n\")[0],\n\t\t\t:codepoint => data.slice!(0,2).unpack(\"n\")[0],\n\t\t\t:data => \"\"\n\t\t}\n\t\tparam[:data] = drda_ebdic_to_ascii(data.slice!(0,p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
benchmarks every method that contains "generate_"
def benchmark_generate generateMethods = self.methods.grep(/generate_/).sort bmbm(0) do |bench| generateMethods.each {|aMethodName| bench.report(aMethodName) {instance_eval(aMethodName)} } end end
[ "def generate_comprehensive\n\n end", "def bench_my_algorithm\r\n assert_performance_linear 0.9999 do |n| # n is a range value\r\n n.times do\r\n @obj.my_algorithm\r\n end\r\n end\r\n end", "def generate_alltest\n\n end", "def randomize_base\n #Check that base was...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Serialize all Venues w/camera for app.
def venues_as_json ::Venue.includes(:cameras).map do |v| Hash( id: v.id, drinkcommand_id: v.drinkcommand_id, name: v.name, cameras: cameras_as_json( v ) ) end end
[ "def to_s\n \"<Camera: #{ @model } (#{ @vendor })>\"\n end", "def get_all\n @config['camera']\n end", "def serialize_vehicle(vehicle)\n return if session[:new_payment][:details].keys.include?(vehicle.vrn)\n\n session[:new_payment][:details][vehicle.vrn] = vehicle.serialize\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Pass Bridge Pay config to mobile client
def bridgepay_config Hash( username: ::BridgePay.username, password: ::BridgePay.password, merchant_code: ::BridgePay.code, merchant_account: ::BridgePay.account ) end
[ "def paypal_client\n\tPaypal::Express::Request.new Rails.configuration.paypal \nend", "def pay_request_data\n {\n \"returnUrl\" => return_url,\n \"requestEnvelope\" => {\"errorLanguage\" => \"en_US\"},\n \"currencyCode\" => \"USD\",\n \"receiverList\" => { \"receiver\" => re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a name, scan should an array with 0 or more Packages matching the name.
def scan(name) raise NotImplementedError, "Repositories must return an Array of matching packages." end
[ "def find_package_by_name(name)\n @packages[name]\n end", "def search(args={})\n results = []\n if args[:name]\n info.each do |package|\n # TODO: probbaly change this to an extact match\n # or add a new args modifier to change behavior.\n if args[:name...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Inputs: A number, n Returns: A string representing the input, with commas inserted into the correct position. Prints: Nothing For example, commas(123) == "123" commas(1234) == "1,234" commas(12345) == "12,345" commas(1234567) == "1,234,567" Note 1 If it's too much, don't worry about handling negative numbers at first. ...
def commas(num) string_with_commas = num.abs.to_s.chars.reverse.each_slice(3).map { |part| part.join }.join(",").reverse if num < 0 string_with_commas.prepend("-") end string_with_commas end
[ "def separate_comma(number)\n if(number < 1000) # if number is 3 digits return number else move on to computation\n return number.to_s\n else\n # create variables one to hold copy of argument being passed, empty integer array,\n # empty number string, a counter for array value starting backwards, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method for sending email, receives two parameters user for who can be sent and daily for the answer
def reply_send(user, daily) @user = user @daily = daily mail({ :to => @user.email, :subject => "Responda a Daily - #{daily.data} - #{daily.team.nome}" }) end
[ "def send_emails\n if request.post?\n tomorrow = Time.now + 1.day\n day = Day.first(:conditions => ['date = ?', tomorrow.strftime('%Y-%m-%d')])\n\n day.assigned_users.each do |user|\n SupportNotifier.deliver_support_notification(user) # sends the email\n end\n end\n end", "def da...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method to create a daily to all the team and sends email to all requesting the answer parameter tipo M equals the daily morning and T equal daily afternoon
def enviar(tipo) team = Team.all team.each do |t| d = Daily.new d.tipo = tipo d.data = Time.now.to_date d.team = t d.save t.members.each do |m| RepliesMailer.reply_send(User.find(m.id),d).deliver_now end end end
[ "def reminder(attendance_id, type)\n sendgrid_category \"Tea Time Reminder\"\n\n @attendance = Attendance.includes(:tea_time, :user).find(attendance_id)\n @user = @attendance.user\n @type = type\n @tea_time = @attendance.tea_time\n\n mail.attachments['event.ics'] = {\n mime_type: \"text/calen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Discards the recorded file. Useful in automated testing when a test passes and the recorded file is no longer needed.
def discard FileUtils.rm options.output end
[ "def discard\n File.delete options.output\n end", "def erase\n @f = nil\n File.delete(@file_name) if File.exist?(@file_name)\n reset_counters\n end", "def clear_example_file\n example_file.unlink\n\n @example_file = nil\n end", "def detach_file\n @file = nil\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Launches the ffmpeg binary using a generated command based on the given options.
def start_ffmpeg raise Errors::DependencyNotFound, 'ffmpeg binary not found.' unless ffmpeg_exists? ScreenRecorder.logger.debug "Command: #{command}" process = build_command @log_file = File.new(options.log, 'w+') process.io.stdout = process.io.stderr = @log_file @...
[ "def generate_command(options = {})\n options = Miniatura::Options.new(options)\n %Q(ffmpeg #{options.to_options} #{output_path} -i #{input_path})\n end", "def command_line(options = {})\n if options.empty? || options.keys == [:output_path]\n # when there are no clip options, the sour...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sends 'q' to the ffmpeg binary to gracefully stop the process. Forcefully terminates it if it takes more than 5s.
def stop_ffmpeg @process.io.stdin.puts 'q' # Gracefully exit ffmpeg @process.io.stdin.close @log_file.close @process.poll_for_exit(PROCESS_TIMEOUT) @process.exit_code rescue ChildProcess::TimeoutError ScreenRecorder.logger.error 'FFmpeg failed to stop. Force killing it...' ...
[ "def stop_ffmpeg\n @process.io.stdin.puts 'q' # Gracefully exit ffmpeg\n @process.io.stdin.close\n @log_file.close\n wait_for_process_exit(@process)\n end", "def stop_ffmpeg\n @process.puts 'q' # Gracefully exit ffmpeg\n elapsed = wait_for_io_eof(10)\n @process.close_write # ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if ffmpeg binary is found.
def ffmpeg_exists? return !`which ffmpeg`.empty? if OS.linux? # "" if not found return !`where ffmpeg`.empty? if OS.windows? # If the user does not use ScreenRecorder.ffmpeg_binary=() to set the binary path, # ScreenRecorder.ffmpeg_binary returns 'ffmpeg' assuming it must be in ENV. However, ...
[ "def ffmpeg_exists?\n return true if FFMPEG.ffmpeg_binary\n\n false\n rescue Errno::ENOENT # Raised when binary is not set in project or found in ENV\n false\n end", "def ffmpeg_exists?\n return !`which ffmpeg`.empty? if OS.linux? # \"\" if not found\n\n return !`where ffmpeg`.empty...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extract version number from the SQL script path name Version is text between last '/' and '_' File path must end with '.sql'
def version(path) path.gsub(%r{.*/}, '').gsub(/_.*\.sql/, '') end
[ "def extractVersion(filename)\n firstUnderscoreInd = filename.index(\"_\")\n return nil unless !firstUnderscoreInd.nil? \n\n secondUnderscoreInd = filename.index(\"_\", firstUnderscoreInd + 1)\n return nil unless !secondUnderscoreInd.nil?\n return filename[firstUnderscoreInd + 1...secondUnderscoreInd...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Login with resource owner password credentials
def login_with_resource_owner_password_credentials(client, username, password) client.password.get_token(username, password) rescue OAuth2::Error => e fail_with_oauth_error( "Failed to acquire token with resource owner credentials (code=#{e.response.body})", e.response ...
[ "def login\n client.login(\n params[:user],\n params[:password],\n authParams: {\n scope: 'openid name email'\n },\n connection: 'Username-Password-Authentication'\n )\n end", "def login_with_pds borid, pass\n login do\n pds_login borid, pass\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Exchange auth_code for a access token
def exchange_code_for_token(api, client, auth_code) client.auth_code.get_token(auth_code, redirect_uri: api.oauth_redirect) rescue OAuth2::Error => e fail_with_oauth_error( "Failed to exchange auth_code for token (code=#{e.response.status})", e.response ) end
[ "def exchange_o_auth_code_for_access_token(code, client_id, client_secret, redirect_uri)\n body = {\n \"code\" => code,\n \"client_id\" => client_id,\n \"client_secret\" => client_secret,\n \"grant_type\" => \"authorization_code\",\n \"redirect_uri\" => redirect_uri\n }\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
rebuild the base vagrant.nix configuration
def prepare! cleanup_hostname! cleanup_network! imports = '' # Find all /etc/nixos/vagrant-*.nix files machine.communicate.tap do |c| c.execute('find /etc/nixos -maxdepth 1 -type f -name "vagrant-*.nix"') do |type, data| imports << data end ...
[ "def create_vagrantfile\n output << bold(color(\"localhost$\", :green)) << \" cd #{@vagrant_path}\\n\"\n FileUtils.mkdir_p(@vagrant_path)\n File.open(File.expand_path(File.join(@vagrant_path, \"Vagrantfile\")), 'w') do |f|\n f.write('Vagrant.configure(\"2\") do |c|' + \"\\n\")\n nodes.e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Cleanup the hostname file if it hasn't been configured in the Vagrantfile.
def cleanup_hostname! return unless machine.config.vm.hostname.nil? machine.communicate.sudo("rm -f /etc/nixos/vagrant-hostname.nix") end
[ "def hostname_fix(boxdef)\n # Vagrant's \"change host name\" sets the short host name.\n # Before we undo the /etc/hosts silliness (see below) let's\n # reset /etc/hostname to the *full* host name\n #\n boxdef.vm.provision \"shell\",\n inline: \"hostname --fqdn > /etc/hostname && hostname -F /et...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Cleanup the network file if it hasn't been set in the Vagrantfile
def cleanup_network! # Abort if a private network has been defined machine.config.vm.networks.each do |cfg| return if cfg[0] == :private_network end machine.communicate.sudo("rm -f /etc/nixos/vagrant-network.nix") end
[ "def cleanup_networks\n # Get list of NICs\n domain = @conn.lookup_domain_by_uuid(@uuid)\n definition = Util::VmDefinition.new(domain.xml_desc)\n nics = definition.get_all_nics\n nics.each do |nic|\n # for each nic remove dhcp entry from network\n n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
General translation key based on the klass of the association.
def association_klass_key(assoc, key) k = 'activerecord.associations.' k << assoc.klass.model_name.singular k << '.' k << key.to_s end
[ "def association_key_name\n reflection.join_primary_key(klass)\n end", "def association_key_name\n reflection.join_primary_key(klass)\n end", "def i18n_key\n [subject, kind].join('.')\n end", "def i18n_key; end", "def association_key_name; end", "def make_ke...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Specific translation key based on the owner model and the name of the association.
def association_owner_key(assoc, key) k = 'activerecord.associations.models.' k << assoc.active_record.model_name.singular k << '.' k << assoc.name.to_s k << '.' k << key.to_s end
[ "def association_key_name; end", "def i18n_key\n [subject, kind].join('.')\n end", "def determine_key\n return name.to_s if relation.embedded?\n relation.stores_foreign_key? ? foreign_key : \"_id\"\n end", "def localized_key(name, serializer)\n serializer&.localized? ? ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
utility logic Wraps the given error inside the given message, while preserving its original stack trace, and raises it.
def raise_error aMessage, aError = $! raise aError.class, "#{aMessage}:\n#{aError}", aError.backtrace end
[ "def wrap_error(message)\n { error: message }\nend", "def raise_use_case_error(use_case, error)\n name = error.class.name.split('::').last\n\n klass = define_use_case_error(use_case, name)\n wrapped = klass.new(error.message)\n wrapped.set_backtrace(error.backtrace)\n\n raise wrapped\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Notify the user about some action being performed.
def notify aAction, aMessage printf "%12s %s\n", aAction, aMessage end
[ "def notify action, message\n printf \"%16s %s\\n\", action, message\n end", "def notify(event, *arguments)\n action.call(*arguments) if trigger?(event)\n end", "def action\n @subscriber.partial_notify(@filename)\n end", "def process_action(...)\n send_action(...)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a hyperlink to the given URL of the given name and mousehover title.
def link aUrl, aName = nil, aTitle = nil aName ||= aUrl %{<a href="#{aUrl}"#{%{ title="#{aTitle}"} if aTitle}>#{aName}</a>} end
[ "def link(url, title) # :nodoc:\n \"[#{title}](#{url})\"\n end", "def hyperlink(url, class_name)\n hyper_a = @doc.at_css \"div[@class='row title #{class_name}']//a\"\n hyper_a['href'] = url\n end", "def hover_over_link(text)\n find(\"a\", text: text).hover\n end", "def link(url, title) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a safe file name that is composed of the given words and has the given file extension.
def make_file_name aExtension, *aWords #:nodoc: aWords.join(' ').to_file_name.ext(aExtension) end
[ "def ten_chr_wd_filename(word)\n word[0..2] + FILE_EXT\n end", "def create_file_name(ext = nil)\n ext ||= self.ext\n return name unless ext\n \"#{unique_key}.#{ext}\"\n end", "def friendly_file_name( file_name )\n\t\t[ [\"æ\",\"ae\"], [\"ø\",\"oe\"], [\"å\",\"aa\"] ].each do |int|\n\t\t\tf...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Transforms this UTF8 string into HTML entities.
def to_html_entities unpack('U*').map! {|c| "&##{c};"}.join end
[ "def escape_entities(str)\n # Haml 6 does escaping\n return str if Haml.const_defined?(:Template)\n CGI.escapeHTML(str).gsub(/[\\n\\r]/) {|c| '&#x' + c.unpack('h').first + ';'}\n end", "def add_entities(str)\r\n str.to_s.gsub(/\\\"/n, '&quot;').gsub(/>/n, '&gt;').gsub(/</n, '&lt;').gsub(/...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Transforms this string into a valid URI fragment. See
def to_uri_fragment # remove HTML tags from the input buf = gsub(/<.*?>/, '') # The first or only character must be a letter. buf.insert(0, 'a') unless buf[0,1] =~ /[[:alpha:]]/ # The remaining characters must be letters, digits, hyphens (-), # underscores (_), colons (:), or perio...
[ "def uri_fragment\n url.to_uri_fragment\n end", "def to_fragment\n fragment = @uri.fragment\n fragment ? Wgit::Url.new(fragment) : nil\n end", "def traditional_url_from_fragment(url)\n url_host(url) + ('/' + (encode_and_parse_url(url).fragment || '')).gsub(/\\/\\//, '/')\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Builds a table of contents from XHTML headings (, , etc.) found in this string and returns an array containing [toc, html] where: toc:: the generated table of contents html:: a modified version of this string which contains anchors for the hyperlinks in the table of contents (so that the TOC can link to the content in ...
def table_of_contents toc = '<ul>' prevDepth = 0 prevIndex = '' html = gsub %r{<h(\d)(.*?)>(.*?)</h\1>$}m do depth, atts, title = $1.to_i, $2, $3.strip # generate a LaTeX-style index (section number) for the heading depthDiff = (depth - prevDepth).abs index...
[ "def mdtoc(markdown)\n titles = []\n lines = markdown.split($/)\n start = nil\n\n # First pass: Scan the Markdown source looking for titles of the\n # format: `### Title ###`. Record the line number, header level\n # (number of octothorpes), and text of each matching title.\n lines.each_with_index do |line, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Registers a new Rake task for generating a HTML file and returns the path of the output file.
def generate_html_task aTask, aPage, aDeps, aRenderOpts = {} #:nodoc: dst = File.join('output', aPage.url) # register subdirs as task deps dst.split('/').inject do |base, ext| directory base aDeps << base File.join(base, ext) end file dst => aDeps + COMMON_DEPS do notify a...
[ "def define_weave_task\n desc \"Weave chunks into HTML\" unless ::Rake.application.last_comment\n ::Rake::Task.define_task(\"codnar_weave\" => @output)\n ::Rake::FileTask.define_task(@output => Rake.chunk_files + Rake.configuration_files(@configurations)) do\n run_weave_application\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Registers a new Rake task for generating a feed. aFile:: path of the output file relative to the output/ directory aItems:: array containing Chapter, Section, Listing, and Entry objects aName:: title of the feed aInfo:: description of the feed aSummarize:: summarize blog entries in the feed?
def feed aFile, aItems, aName, aInfo = nil, aSummarize = true dst = File.join('output', aFile) entries = [aItems].flatten.uniq feedObj = Feed.new(aFile, entries, aName, aInfo, aSummarize) FEEDS << feedObj file dst => COMMON_DEPS + entries.map {|e| e.input_file} do |t| notify :feed, t.name ...
[ "def file(*args, &block) # :doc:\n Rake::FileTask.define_task(*args, &block)\n end", "def file(*args, &block)\n Rake::FileTask.define_task(*args, &block)\n end", "def file(*args, &block)\n Rake::FileTask.define_task(*args, &block)\nend", "def create_task_file\n template_file = File.join(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a URI fragment for this object.
def uri_fragment url.to_uri_fragment end
[ "def to_fragment\n fragment = @uri.fragment\n fragment ? Wgit::Url.new(fragment) : nil\n end", "def uri_fragment\n @uri.fragment || self.class.default_template_ref(self)\n end", "def full_uri_for(fragment)\n case fragment\n when /^http:\\/\\//\n # The fragment is a complete U...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a URL to the parent page which takes you directly to this item inside the parent page.
def parent_url parent.url + '#' + self.uri_fragment end
[ "def parent\n page\n end", "def parent\n navigation.pages.find(parent_id)\n end", "def parent_url(options = {})\n @page_object.page_url + (options.empty? ? '' : \"?#{options.to_query}\" )\n end", "def parent_url\n parent? ? ( \"/\" + parent_class.to_s.pluralize.underscore + \"/%...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a relative link to this object, customized by the following options: frag:: a URI fragment that is appended to the URL, if given. body:: sets the body of the link (the tag), if given. nbsp:: makes spaces in the link body nonbreaking, if true.
def to_link aOpts = {} frag = aOpts[:frag] frag = frag.uri_fragment if frag.respond_to? :uri_fragment addr = [self.url, frag].compact.join('#') body = aOpts[:body] || self.name body = body.gsub(/\s/, '&nbsp;') if aOpts[:nbsp] body = body.to_inline_html # reveal default link ...
[ "def link_to(title, path, opts={}, base=true)\n unless is_uri?(path) || base == false\n path = url(path)\n end\n \n return \"<a href=\\\"#{path}\\\"#{parse_options(opts)}>#{title}</a>\"\n end", "def as_href(from_path)\n RDoc::Markup::ToHtml.gen_relative_url from_path, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if this entry is hidden (the 'hide' parameter is enabled).
def hide? @hide end
[ "def hidden?\n !visible?\n end", "def hidden?\n !visible?\n end", "def hidden?\n not visible?\n end", "def hidden?()\n not visible?()\n end", "def is_hidden\n return @is_hidden\n end", "def hidden?\n @field.widget.hidden?\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the summarized HTML content of this blog entry. If there is no summary or summarization is not possible, then returns nil.
def summary if key? 'summary' self['summary'].to_s.thru_erb.to_html else case html.gsub(%r{<(h\d).*?>.*?</\1>}m, '') # omit headings from summary # the first HTML block-level element when %r{\A\s*<(\w+).*?>.*?</\1>}m $& # the first paragraph (a run of text...
[ "def summary\n return summary_extension_output if respond_to?(:summary_extension_output)\n\n content.to_s.strip.lines.first.to_s.strip.html_safe\n end", "def summary\n if summary?\n body.match(/<summary>(.*)<\\/summary>/m)[1].strip\n end\n end", "def summarise\n headerless = se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the absolute URL to this entry.
def absolute_url File.join(BLOG.url, url) end
[ "def absolute_url\n end", "def url\n begin\n URI.join(self.resource.root, self.href.to_s).to_s\n rescue StandardError\n nil\n end\n end", "def url\n begin\n URI.join(self.root, (self.href || '')).to_s\n rescue StandardError\n nil\n end\n end", "def to_r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a URL for submiting comments about this entry.
def comment_url BLOG.email.to_url(name, File.join(BLOG.url, url)) end
[ "def comment_url(comment_id=nil)\n comment_id = context.comment_id if comment_id.nil?\n \"https://github.com/#{context.repo}/issues/#{context.issue_id}#issuecomment-#{comment_id}\"\n end", "def url\n new? ? '#' : post.url + \"#comment-#{id}\"\n end", "def commentable_url(comment)\n url_for(com...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
hooks up the given entry with the given section (by name) and chapter. then returns the section object.
def hookup aEntry, aSectionByName, aName, aChapter #:nodoc: unless s = aSectionByName[aName] s = Section.new(aName, aChapter) aChapter << s aSectionByName[aName] = s end s << aEntry end
[ "def process_section(section_name, doc)\n entries = doc.xpath(@sections[section_name])\n if(entries.size == 0)\n return\n end\n @ccr_hash[section_name] = []\n entries.each do | e |\n entry = QME::Importer::Entry.new\n process_codes(e, entry)\n @ccr_hash[section_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the version of the IP packet.
def version self[:ip_vhl] >> 4 end
[ "def ip_version\n @ip_version\n end", "def ip_version; end", "def version\n bytes[0] >> 4\n end", "def do_version(packet); end", "def ip_version=(value)\n @ip_version = value\n end", "def protocol_version\n @protocol_version\n end", "def get_version\r\n formats = [\r\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the header length of the packet.
def header_length self[:ip_vhl] & 0x0f end
[ "def header_length\n @header_length ||= @data[20, 4].unpack('N*')[0]\n end", "def len_header\n return @len_header unless @len_header.nil?\n _pos = @_io.pos\n @_io.seek(88)\n @len_header = @_io.read_u8le\n @_io.seek(_pos)\n @len_header\n end", "def header_length\n @header_leng...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the total packet length.
def packet_length self[:ip_len] end
[ "def total_length\n Utils.word16(bytes[2], bytes[3])\n end", "def udp_calc_len\n body.to_s.size + 8\n end", "def packet_buffer_size\n instance.packet_buffer.size\n rescue NoMethodError\n 0\n end", "def size_packets_all\n self.size_packets_incoming + self.size_packets_out...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the Time to Live (TTL).
def ttl self[:ip_ttl] end
[ "def ttl\n @plist['TimeToLive'].to_i\n end", "def ttl\n return @ttl\n end", "def ttl\n self.getsockopt(::Socket::IPPROTO_IP, ::Socket::IP_TTL)\n .data.unpack('i').first\n end", "def ttl\n return @rrs[0].ttl\n end", "def lease_time\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the destination IP address.
def dest self[:ip_dest] end
[ "def dest_ip\n self[:dest_ip]\n end", "def destination_ip_address\n bytes[16, 4].join('.')\n end", "def destination_service_ip\n return @destination_service_ip\n end", "def destination_address\n return @destination_address\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET params: experiment_id: (optional) experiment_id
def index validate( experiment_id: [:optional, :security_default] ) render 'infrastructure/index', locals: { experiment_id: params[:experiment_id].to_s } end
[ "def fetch_experiment(id)\n url = @base + \"experiments/#{id}.json?token=#{@token}\"\n puts url\n response = JSON.parse(RestClient.get(url))\nend", "def show\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exper...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get Simulation Manager nodes for Infrastructure Tree for given infrastructure and current user. GET params: infrastructure_name: name of Infrastructure experiment_id: (optional) experiment_id infrastructure_params: (optional) hash with special params for infrastructure (e.g. filtering options)
def simulation_manager_records begin facade = InfrastructureFacadeFactory.get_facade_for(params[:infrastructure_name]) hash = facade.sm_record_hashes(current_user.id, params[:experiment_id], (params[:infrastructure_params] or {})) render json: hash rescue NoSuchInfrastructureError => e R...
[ "def nodes\r\n params = {\r\n method: :get,\r\n url: '/project/nodes',\r\n params: { prjUUID: @uuid }\r\n }\r\n @session.request(**params).perform!['nodes']\r\n end", "def nodes\r\n params = {\r\n method: :get,\r\n url: '/project/nodes',\r\n params:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO: WARNING: DEPRECATED this method will be removed both from GUI and API GET params infrastructure_name All params will be passed to simulation_managers_info in view
def simulation_managers_summary render html: 'Please use Computational Resources Summary in Experiment view.' #validate( # infrastructure_name: :security_default #) #infrastructure_name = params[:infrastructure_name] #facade = InfrastructureFacadeFactory.get_facade_for(infrastructure_name) ...
[ "def simulation_manager_records\n begin\n facade = InfrastructureFacadeFactory.get_facade_for(params[:infrastructure_name])\n hash = facade.sm_record_hashes(current_user.id, params[:experiment_id], (params[:infrastructure_params] or {}))\n render json: hash\n rescue NoSuchInfrastructureError =>...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get single SimulationManagerRecord with priviliges check
def get_sm_record(record_id, facade) record = facade.get_sm_record_by_id(record_id) raise NoSuchSimulationManagerError if record.nil? raise AccessDeniedError if record.user_id.to_s != current_user.id.to_s record end
[ "def simulation_user\n return @simulation_user\n end", "def fetch_manager_validation_hash_details\n\n mvh_record = ManagerValidationHash.where(\n manager_id: @manager_id,\n kind: GlobalConstant::ManagerValidationHash.secure_data_access_kind).order('created_at desc').li...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yield single SimulationManager with priviliges check This method automatically clean up infrastructure facade resources
def yield_simulation_manager(record_id, infrastructure_name, &block) facade = InfrastructureFacadeFactory.get_facade_for(infrastructure_name) facade.yield_simulation_manager(get_sm_record(record_id, facade)) {|sm| yield sm} end
[ "def yield_simulation_manager(record, &block)\n begin\n init_resources\n yield create_simulation_manager(record)\n ensure\n clean_up_resources\n end\n end", "def unit_of_work\n begin\n yield if block_given?\n ensure\n IdentityMap.clear\n end\n end", "def teardown\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /legal_record_types GET /legal_record_types.json
def index @legal_record_types = LegalRecordType.all end
[ "def index\n @record_types = RecordType.all\n end", "def types\n types = JSON.parse(connection.get(\"/Contact/Types\").body )\n end", "def payment_types\n url = \"#{@url}reference/payment-types\"\n make_request(url)\n end", "def record_types\n @record_types.each\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /legal_record_types POST /legal_record_types.json
def create @legal_record_type = LegalRecordType.new(legal_record_type_params) respond_to do |format| if @legal_record_type.save format.html { redirect_to @legal_record_type, notice: 'Legal record type was successfully created.' } format.json { render :show, status: :created, location: @le...
[ "def index\n @legal_record_types = LegalRecordType.all\n end", "def create\n @record_type = RecordType.new(record_type_params)\n\n respond_to do |format|\n if @record_type.save\n format.html { redirect_to @record_type, notice: 'Record type was successfully created.' }\n format.json { ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /legal_record_types/1 PATCH/PUT /legal_record_types/1.json
def update respond_to do |format| if @legal_record_type.update(legal_record_type_params) format.html { redirect_to @legal_record_type, notice: 'Legal record type was successfully updated.' } format.json { render :show, status: :ok, location: @legal_record_type } else format.html ...
[ "def update\n respond_to do |format|\n if @record_type.update(record_type_params)\n format.html { redirect_to @record_type, notice: 'Record type was successfully updated.' }\n format.json { render :show, status: :ok, location: @record_type }\n else\n format.html { render :edit }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /legal_record_types/1 DELETE /legal_record_types/1.json
def destroy @legal_record_type.destroy respond_to do |format| format.html { redirect_to legal_record_types_url, notice: 'Legal record type was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @recital_ad_type.destroy\n\n respond_to do |format|\n format.html { redirect_to recital_ad_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @awon_record_type.destroy\n respond_to do |format|\n format.html { redirect_to awon_record_types_url ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls wait repeatedly while the given block yields a truthy value.
def wait_while while yield wait end end
[ "def wait_while\n while yield\n\twait\n end\n end", "def wait block = true\n if block\n guard = block_given? ? yield : true\n while Time.now < @gate_time && guard do\n sleep 0.5\n end\n else\n Time.now < @gate_time\n end\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls wait repeatedly until the given block yields a truthy value.
def wait_until until yield wait end end
[ "def wait_until\n until yield\n\twait\n end\n end", "def wait block = true\n if block\n guard = block_given? ? yield : true\n while Time.now < @gate_time && guard do\n sleep 0.5\n end\n else\n Time.now < @gate_time\n end\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new MonitorMixin::ConditionVariable associated with the Monitor object.
def new_cond unless defined?(@mon_data) mon_initialize @mon_initialized_by_new_cond = true end return ConditionVariable.new(@mon_data) end
[ "def new_cond\n return ConditionVariable.new(self)\n end", "def new_cond\n FiberedConditionVariable.new(self)\n end", "def make_condition(condition)\n if condition.instance_of?(String)\n condition = c(condition)\n end\n raise MetaformException \"condition must be defined\" if !...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is called when weak warning is produced by the parser. +fmt+ and +args+ is printf style.
def warn(fmt, *args) end
[ "def warning(fmt, *args)\n end", "def warning(*args)\n RubyBase.one_time_alert(\"warning\",0, *args)\nend", "def warning(string); end", "def warn *words\n $stderr.puts(Rib.prepare(words))\n end", "def say_warning(*args)\n args.each do |arg|\n say HighLine.default_instance.color(arg, :yello...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is called when strong warning is produced by the parser. +fmt+ and +args+ is printf style.
def warning(fmt, *args) end
[ "def warn(fmt, *args)\n end", "def warning(*args)\n RubyBase.one_time_alert(\"warning\",0, *args)\nend", "def warning(string); end", "def warning(warning_message, *args)\n STDERR.puts(\"#{warning_message} - #{args.join(',')}\")\n end", "def say_warning(*args)\n args.each do |arg|\n say Hig...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Starts the parser. +init+ is a data accumulator and is passed to the next event handler (as of Enumerableinject).
def parse(init = nil) data = init @__lexer.lex.each do |pos, event, tok, state| @__line, @__col = *pos @__state = state data = if respond_to?(event, true) then __send__(event, tok, data) else on_default(event, tok, data) end end ...
[ "def start_parse()\n @handlers.each { |h| h.start_parse(self) if h&.respond_to? :start_parse }\n end", "def start(&block)\n if not @curs.nil?\n if @curs.alive?\n stop\n end\n end\n\n @parsed = Parser.new(block)\n @cursor = Cursor.new(@parsed.banner nil)\n @curs = Thread...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is called when some event handler is undefined. +event+ is :on_XXX, +token+ is the scanned token, and +data+ is a data accumulator. The return value of this method is passed to the next event handler (as of Enumerableinject).
def on_default(event, token, data) data end
[ "def event_handler_missing(event)\n # just a placeholder\n end", "def on_no_data_received(&block)\n on('no_data_received', &block)\n end", "def on_no_data_received &block\n @no_data_received_callback = block\n end", "def incoming_event(data)\n event_name = EVENT_LOOKUP_NAMES[data[:rpc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simple deprecation method that deprecates +name+ by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of +repl+ (unless +repl+ is :none) and the year/month that it is planned to go away.
def deprecate(name, repl, year, month) class_eval do old = "_deprecated_#{name}" alias_method old, name define_method name do |*args, &block| klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", ...
[ "def deprecate(name, repl, year, month)\n class_eval do\n old = \"_deprecated_#{name}\"\n alias_method old, name\n define_method name do |*args, &block|\n klass = self.kind_of? Module\n target = klass ? \"#{self}.\" : \"#{self.class}#\"\n msg = [ \"NOTE: #{target}#{name} is de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simple deprecation method that deprecates +name+ by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of +repl+ (unless +repl+ is :none) and the Rubygems version that it is planned to go away.
def rubygems_deprecate(name, replacement=:none) class_eval do old = "_deprecated_#{name}" alias_method old, name define_method name do |*args, &block| klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated",...
[ "def deprecate(name, repl, ver)\n class_eval do\n gem_ver = Gem::Version.new(ver)\n old = \"_deprecated_#{name}\"\n alias_method old, name\n define_method name do |*args, &block|\n mod = is_a? Module\n target = mod ? \"#{self}.\" : \"#{self.class}#\"\n tar...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deprecation method to deprecate Rubygems commands
def rubygems_deprecate_command class_eval do define_method "deprecated?" do true end define_method "deprecation_warning" do msg = [ "#{self.command} command is deprecated", ". It will be removed in Rubygems #{Gem::Deprecate.next_rubygems_major_version}.\n", ...
[ "def deprecated_commands\n []\n 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...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
append a platform to the list of mismatched platforms. Platforms are added via this instead of injected via the constructor so that we can loop over a list of mismatches and just add them rather than perform some kind of calculation mismatch summary before creation.
def add_platform(platform) @platforms << platform end
[ "def platform_list\n if platform.blank?\n list = Msf::Module::PlatformList.new\n else\n begin\n list = ::Msf::Module::PlatformList.transform(platform)\n rescue\n list = Msf::Module::PlatformList.new\n end\n end\n list\n end", "def platforms_to_l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The name of the unresolved dependency
def name @dependency.name end
[ "def name_for(dependency)\n dependency.name\n end", "def dependency\n @dependency ||= Bundler.load.gems.find { |dep| dep.name == @name }\n end", "def dependent_name(dep)\n return unless dep\n Job.find(dep).name\n end", "def gem_deps_file # :nodoc:\n File.basename @path\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The Requirement of the unresolved dependency (not Version).
def version @dependency.requirement end
[ "def requirement\n Gem::Requirement.new('~>' + pharos_version.segments.first(2).join('.') + (pharos_version.prerelease? ? '.0-a' : '.0'))\n end", "def dependency\n @dependency ||= Bundler.load.gems.find { |dep| dep.name == @name }\n end", "def ensure_dependency!(spec, dependency)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The path to the gem.build_complete file within the extension install directory.
def gem_build_complete_path # :nodoc: File.join extension_dir, 'gem.build_complete' end
[ "def full_gem_path\n File.join(installation_path, \"gems\", full_name)\n end", "def full_gem_path\n # TODO: This is a heavily used method by gems, so we'll need\n # to aleast just alias it to #gem_dir rather than remove it.\n @full_gem_path ||= find_full_gem_path\n end", "def gemfile_location\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns full path to the directory where gem's extensions are installed.
def extension_dir @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).tap(&Gem::UNTAINT) end
[ "def extensions_dir\n Gem.default_ext_dir_for(base_dir) ||\n File.join(base_dir, 'extensions', Gem::Platform.local.to_s,\n Gem.extension_api_version)\n end", "def extension_path(name = nil)\n path = File.join(RAILS_ROOT, 'extensions')\n path = File.join(path, name.to_s) if name\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns path to the extensions directory.
def extensions_dir Gem.default_ext_dir_for(base_dir) || File.join(base_dir, 'extensions', Gem::Platform.local.to_s, Gem.extension_api_version) end
[ "def extension_path(name = nil)\n path = File.join(RAILS_ROOT, 'extensions')\n path = File.join(path, name.to_s) if name\n path\n end", "def extension_dir\n @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).tap(&Gem::UNTAINT)\n end", "def extension_paths; end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The full path to the gem (install path + full name).
def full_gem_path # TODO: This is a heavily used method by gems, so we'll need # to aleast just alias it to #gem_dir rather than remove it. @full_gem_path ||= find_full_gem_path end
[ "def full_gem_path\n File.join(installation_path, \"gems\", full_name)\n end", "def gem_path\n File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))\n end", "def install_path\n File.join(Config.gems_path, @gem_spec.gem_dirname)\n end", "def gem_path\n @path || downlo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the full name (nameversion) of this Gem. Platform information is included (nameversionplatform) if it is specified and not the default Ruby platform.
def full_name if platform == Gem::Platform::RUBY or platform.nil? "#{name}-#{version}".dup.tap(&Gem::UNTAINT) else "#{name}-#{version}-#{platform}".dup.tap(&Gem::UNTAINT) end end
[ "def full_name\n if platform == Gem::Platform::RUBY || platform.nil?\n \"#{@name}-#{@version}\"\n else\n \"#{@name}-#{@version}-#{platform}\"\n end \n end", "def full_name\n if platform == Gem::Platform::RUBY or platform.nil? then\n \"#{name}-#{version}\".untaint\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Full paths in the gem to add to $LOAD_PATH when this gem is activated.
def full_require_paths @full_require_paths ||= begin full_paths = raw_require_paths.map do |path| File.join full_gem_path, path.tap(&Gem::UNTAINT) end full_paths << extension_dir if have_extensions? full_paths end end
[ "def add_gem_paths; end", "def gem_lib_paths\n @gemspec.require_paths.join Config::CONFIG['PATH_SEPARATOR']\n end", "def gem_paths\n @_gem_paths ||= (ENV['GEM_PATH'] || ENV['GEM_HOME']).split(/[:;]/)\n end", "def gem_paths\n @_gem_paths ||= (ENV['GEM_PATH'] || ENV['GEM_HOME']).split(/[:;]/)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return all files in this gem that match for +glob+.
def matches_for_glob(glob) # TODO: rename? glob = File.join(self.lib_dirs_glob, glob) Dir[glob].map {|f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1 end
[ "def find_all(glob)\n # HACK violation of encapsulation\n @gemspecs.select do |spec|\n # TODO: inverted responsibility\n matching_file? spec, glob\n end || []\n end", "def glob_files(glob)\n absolute = Pathname.new(glob).absolute?\n Dir[absolute ? glob : File.join(ASSET_ROOT, glob)]....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
True when this gem has been activated
def activated? @activated ||= begin loaded = Gem.loaded_specs[name] loaded && loaded.version == version end end
[ "def activated?\n loaded = Gem.loaded_specs[name]\n loaded && loaded.version == version\n end", "def activated?\n true\n end", "def activate\n other = Gem.loaded_specs[self.name]\n if other\n check_version_conflict other\n return false\n end\n\n raise_if_conflict...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is there a stub line present for this StubSpecification?
def stubbed? data.is_a? StubLine end
[ "def stub?\n self.status == :stub\n end", "def stubbed?\n !@stubs.empty?\n end", "def spec_stubs?\n @config.files.copy.any? { |f, _| f.start_with?(STUBS_FOLDER) } \\\n || @config.files.compile.any? { |f, _| f.start_with?(STUBS_FOLDER) }\n end", "def header_line?(hash)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Displays an alert +statement+. Asks a +question+ if given.
def alert(statement, question = nil) ui.alert statement, question end
[ "def alert(statement, question=nil)\n @outs.puts \"INFO: #{statement}\"\n ask(question) if question\n end", "def alert_warning(statement, question=nil)\n @errs.puts \"WARNING: #{statement}\"\n ask(question) if question\n end", "def alert_error(statement, question=nil)\n @errs.puts \"ERROR: #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Displays an error +statement+ to the error output location. Asks a +question+ if given.
def alert_error(statement, question = nil) ui.alert_error statement, question end
[ "def alert_error(statement, question=nil)\n @errs.puts \"ERROR: #{statement}\"\n ask(question) if question\n end", "def alert_warning(statement, question=nil)\n @errs.puts \"WARNING: #{statement}\"\n ask(question) if question\n end", "def alert(statement, question=nil)\n @outs.puts \"INFO: #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Displays a warning +statement+ to the warning output location. Asks a +question+ if given.
def alert_warning(statement, question = nil) ui.alert_warning statement, question end
[ "def alert_warning(statement, question=nil)\n @errs.puts \"WARNING: #{statement}\"\n ask(question) if question\n end", "def alert_error(statement, question=nil)\n @errs.puts \"ERROR: #{statement}\"\n ask(question) if question\n end", "def alert(statement, question=nil)\n @outs.puts \"INFO: #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Asks for a password with a +prompt+
def ask_for_password(prompt) ui.ask_for_password prompt end
[ "def password_prompt(prompt=\"Password: \")\n ui.ask(prompt) { |q| q.echo = false }\n end", "def get_password(prompt=\"Enter Password:\")\n \task(prompt) {|q| q.echo = false}\nend", "def password_prompt(user)\n prompt = TTY::Prompt.new\n user_input = prompt.mask('What is your pas...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Asks the user to answer +question+ with an answer from the given +list+.
def choose_from_list(question, list) ui.choose_from_list question, list end
[ "def choose_from_list(question, list)\n @outs.puts question\n list.each_with_index do |item, index|\n @outs.puts \" #{index+1}. #{item}\"\n end\n @outs.print \"> \"\n @outs.flush\n\n result = @ins.gets\n\n return nil, nil unless result\n\n result = result.strip.to_i - ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls +say+ with +msg+ or the results of the block if really_verbose is true.
def verbose(msg = nil) say(clean_text(msg || yield)) if Gem.configuration.really_verbose end
[ "def say(message)\n puts message unless quiet?\n end", "def verbose(msg)\n return unless @opts.verbose?\n info msg\n end", "def l_say(level, *msg)\n say(*msg) if verbosity >= level\n end", "def verbose(&block)\n with_verbose(true, &block)\n end", "def say_ok(message=\"\", op...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new StreamUI wrapping +in_stream+ for user input, +out_stream+ for standard output, +err_stream+ for error output. If +usetty+ is true then special operations (like asking for passwords) will use the TTY commands to disable character echo.
def initialize(in_stream, out_stream, err_stream=STDERR, usetty=true) @ins = in_stream @outs = out_stream @errs = err_stream @usetty = usetty end
[ "def set_default_testrunner_stream(io)\n require 'test/unit/ui/console/testrunner'\n \n Test::Unit::UI::Console::TestRunner.class_eval do\n alias_method :old_initialize, :initialize\n def initialize(suite, output_level, io=Thread.current[\"test_runner_io\"])\n old_initialize(su...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints a formatted backtrace to the errors stream if backtraces are enabled.
def backtrace(exception) return unless Gem.configuration.backtrace @errs.puts "\t#{exception.backtrace.join "\n\t"}" end
[ "def trace_errors\n getErrors.each { |e|\n puts \"(#{e.object || ''}): #{e.error}\"\n }\n end", "def backtrace_formatter; end", "def print_error(e)\n puts e.message\n puts e.backtrace if(trace)\n end", "def show_backtraces=(_arg0); end", "def formatted_backtrace; end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Choose from a list of options. +question+ is a prompt displayed above the list. +list+ is a list of option strings. Returns the pair [option_name, option_index].
def choose_from_list(question, list) @outs.puts question list.each_with_index do |item, index| @outs.puts " #{index + 1}. #{item}" end @outs.print "> " @outs.flush result = @ins.gets return nil, nil unless result result = result.strip.to_i - 1 return list[result], result ...
[ "def choose_from_list(question, list)\n ui.choose_from_list question, list\n end", "def choose_from_list(question, list)\n @outs.puts question\n list.each_with_index do |item, index|\n @outs.puts \" #{index+1}. #{item}\"\n end\n @outs.print \"> \"\n @outs.flush\n\n result ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ask a question. Returns a true for yes, false for no. If not connected to a tty, raises an exception if default is nil, otherwise returns default.
def ask_yes_no(question, default=nil) unless tty? if default.nil? raise Gem::OperationNotSupportedError, "Not connected to a tty and no default specified" else return default end end default_answer = case default when nil 'yn' when true 'Y...
[ "def ask_yes_no(question, default=nil)\n if not @ins.tty? then\n if default.nil? then\n raise(\n Gem::OperationNotSupportedError,\n \"Not connected to a tty and no default specified\")\n else\n return default\n end\n end\n qstr = case d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ask a question. Returns an answer if connected to a tty, nil otherwise.
def ask(question) return nil if not tty? @outs.print(question + " ") @outs.flush result = @ins.gets result.chomp! if result result end
[ "def ask(question)\n return nil if not @ins.tty?\n @outs.print(question + \" \")\n @outs.flush\n result = @ins.gets\n result.chomp! if result\n result\n end", "def ask(question, answer_type = String, non_interactive_value = nil, &continuation)\n if interactive?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Display an informational alert. Will ask +question+ if it is not nil.
def alert(statement, question=nil) @outs.puts "INFO: #{statement}" ask(question) if question end
[ "def alert(statement, question = nil)\n ui.alert statement, question\n end", "def alert_warning(statement, question=nil)\n @errs.puts \"WARNING: #{statement}\"\n ask(question) if question\n end", "def alert_error(statement, question=nil)\n @errs.puts \"ERROR: #{statement}\"\n ask(question) if...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Display a warning on stderr. Will ask +question+ if it is not nil.
def alert_warning(statement, question=nil) @errs.puts "WARNING: #{statement}" ask(question) if question end
[ "def alert_error(statement, question=nil)\n @errs.puts \"ERROR: #{statement}\"\n ask(question) if question\n end", "def warning(msg, ask_continue: true)\n tell(colorize(\"☞ \", :magenta) + colorize(msg, :yellow))\n exit(-1) if ask_continue && !quiz(\"continue\")\n end", "def alert_warning(stateme...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Display an error message in a location expected to get error messages. Will ask +question+ if it is not nil.
def alert_error(statement, question=nil) @errs.puts "ERROR: #{statement}" ask(question) if question end
[ "def alert_error(statement, question = nil)\n ui.alert_error statement, question\n end", "def display_input_error\n puts \"Please enter a valid input\"\n end", "def displayinvalidinputerror\n\t\t\t@output.puts \"Invalid input.\"\n\t\tend", "def error\n print \"That is not a valid input. \\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a progress reporter object chosen from the current verbosity.
def progress_reporter(*args) case Gem.configuration.verbose when nil, false SilentProgressReporter.new(@outs, *args) when true SimpleProgressReporter.new(@outs, *args) else VerboseProgressReporter.new(@outs, *args) end end
[ "def progress_reporter(*args)\n case Gem.configuration.verbose\n when nil, false\n SilentProgressReporter.new(@outs, *args)\n when true\n SimpleProgressReporter.new(@outs, *args)\n else\n VerboseProgressReporter.new(@outs, *args)\n end\n end", "def progress_printer...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new progress reporter that will write to +out_stream+ for +size+ items. Shows the given +initial_message+ when progress starts and the +terminal_message+ when it is complete.
def initialize(out_stream, size, initial_message, terminal_message = "complete") @out = out_stream @total = size @count = 0 @terminal_message = terminal_message @out.puts initial_message end
[ "def initialize(out_stream, size, initial_message,\n terminal_message = 'complete')\n @out = out_stream\n @total = size\n @count = 0\n @terminal_message = terminal_message\n\n @out.puts initial_message\n end", "def run_with_progress(message, size, progr = nil, &block)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }