query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Protected setter for the path component +v+. See also URI::Generic.path=. | def set_path(v)
@path = v
end | [
"def path=(v)\n check_path(v)\n set_path(v)\n v\n end",
"def path=(v)\n @path = Pathname.new(v)\n @spec_path = nil\n end",
"def path=(value)\n @path = value\n end",
"def path=(value)\n @path = (value.nil? || value == \"\") ? \"/\" : value\n end",
"def path=( va... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Args +v+:: String == Description Public setter for the path component +v+ (with validation). See also URI::Generic.check_path. == Usage require 'uri' uri = URI.parse(" uri.path = "/faq/" uri.to_s => " | def path=(v)
check_path(v)
set_path(v)
v
end | [
"def set_path(v)\n @path = v\n end",
"def path=(value)\n @path = (value.nil? || value == \"\") ? \"/\" : value\n end",
"def path=(v)\n @path = Pathname.new(v)\n @spec_path = nil\n end",
"def path=( value )\n self.path_matcher = self.class.compile_matcher value\n super( value... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Args +v+:: String == Description Public setter for the query component +v+. == Usage require 'uri' uri = URI.parse(" uri.query = "id=1" uri.to_s => " | def query=(v)
return @query = nil unless v
raise InvalidURIError, "query conflicts with opaque" if @opaque
x = v.to_str
v = x.dup if x.equal? v
v.encode!(Encoding::UTF_8) rescue nil
v.delete!("\t\r\n")
v.force_encoding(Encoding::ASCII_8BIT)
raise InvalidURIError, "invali... | [
"def query=(v); self[:query]=v end",
"def query_set(name, value)\n query = uri.query ? \"&#{uri.query}&\" : ''\n parameter = Regexp.new(\"&#{Regexp.escape name}=.+?&\")\n if query =~ parameter\n new_query = value.nil? ?\n query.gsub(parameter, '&') :\n query.gsu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks the opaque +v+ component for RFC2396 compliance and against the URI::Parser Regexp for :OPAQUE. Can not have a host, port, user, or path component defined, with an opaque component defined. | def check_opaque(v)
return v unless v
# raise if both hier and opaque are not nil, because:
# absoluteURI = scheme ":" ( hier_part | opaque_part )
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @host || @port || @user || @path # userinfo = @user + ':' + @password
ra... | [
"def check_host(v)\n return v unless v\n\n if @opaque\n raise InvalidURIError,\n \"can not set host with registry or opaque\"\n elsif parser.regexp[:HOST] !~ v\n raise InvalidComponentError,\n \"bad component(expected host component): #{v}\"\n end\n\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Protected setter for the opaque component +v+. See also URI::Generic.opaque=. | def set_opaque(v)
@opaque = v
end | [
"def opaque=(v)\n check_opaque(v)\n set_opaque(v)\n v\n end",
"def check_opaque(v)\n return v unless v\n\n # raise if both hier and opaque are not nil, because:\n # absoluteURI = scheme \":\" ( hier_part | opaque_part )\n # hier_part = ( net_path | abs_path ) [ \"?\" qu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Args +v+:: String == Description Public setter for the opaque component +v+ (with validation). See also URI::Generic.check_opaque. | def opaque=(v)
check_opaque(v)
set_opaque(v)
v
end | [
"def check_opaque(v)\n return v unless v\n\n # raise if both hier and opaque are not nil, because:\n # absoluteURI = scheme \":\" ( hier_part | opaque_part )\n # hier_part = ( net_path | abs_path ) [ \"?\" query ]\n if @host || @port || @user || @path # userinfo = @user + ':' + @pass... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT. == Args +v+:: String == Description Public setter for the fragment component +v+ (with validation). == Usage require 'uri' uri = URI.parse(" uri.fragment = "time=1305212086" uri.to_s => " | def fragment=(v)
return @fragment = nil unless v
x = v.to_str
v = x.dup if x.equal? v
v.encode!(Encoding::UTF_8) rescue nil
v.delete!("\t\r\n")
v.force_encoding(Encoding::ASCII_8BIT)
v.gsub!(/(?!%\h\h|[!-~])./n){'%%%02X' % $&.ord}
v.force_encoding(Encoding::US_ASCII)
... | [
"def fragment=(v); self[:fragment]=v end",
"def parse_fragment_definition\n expect_keyword('fragment')\n ASTNode.new(kind: Kinds::FRAGMENT_DEFINITION, params: {\n name: parse_fragment_name,\n type_condition: (expect_keyword('on') && parse_named_type),\n directives: parse_directives(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if URI is hierarchical. == Description URI has components listed in order of decreasing significance from left to right, see RFC3986 1.2.3. == Usage require 'uri' uri = URI.parse(" uri.hierarchical? => true | def hierarchical?
if @path
true
else
false
end
end | [
"def hierarchical?\n return @def.hierarchical?\n end",
"def hierarchical?\n @hierarchical ||= !klass.fact_model.hierarchical_levels.empty?\n end",
"def hierarchical?()\n return self.id =~ /\\Ahl_/i\n end",
"def hierarchical?\n return self.base? || self.types?\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merges a base path +base+, with relative path +rel+, returns a modified base path. | def merge_path(base, rel)
# RFC2396, Section 5.2, 5)
# RFC2396, Section 5.2, 6)
base_path = split_path(base)
rel_path = split_path(rel)
# RFC2396, Section 5.2, 6), a)
base_path << '' if base_path.last == '..'
while i = base_path.index('..')
base_path.slice!(i - 1, 2)... | [
"def relative(base, path)\n dir = base.rindex(\"/\") ? base[0..base.rindex(\"/\")] : \"\"\n no_slash(path[dir.length..-1])\nend",
"def relative_path path, base\n (root? path) && (offset = descends_from? path, base) ? (path.slice offset, path.length) : path\n end",
"def join(base, path); end",
"def join(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Args +oth+:: URI or String == Description Merges two URIs. == Usage require 'uri' uri = URI.parse(" uri.merge("/main.rbx?page=1") => " | def merge(oth)
rel = parser.__send__(:convert_to_uri, oth)
if rel.absolute?
#raise BadURIError, "both URI are absolute" if absolute?
# hmm... should return oth for usability?
return rel
end
unless self.absolute?
raise BadURIError, "both URI are relative"
e... | [
"def merge(oth)\n rel = parser.send(:convert_to_uri, oth)\n\n if rel.absolute?\n #raise BadURIError, \"both URI are absolute\" if absolute?\n # hmm... should return oth for usability?\n return rel\n end\n\n unless self.absolute?\n raise BadURIError, \"both URI are rel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:startdoc: == Args +oth+:: URI or String == Description Calculates relative path from oth to self. == Usage require 'uri' uri = URI.parse(' uri.route_from(' => | def route_from(oth)
# you can modify `rel', but can not `oth'.
begin
oth, rel = route_from0(oth)
rescue
raise $!.class, $!.message
end
if oth == rel
return rel
end
rel.set_path(route_from_path(oth.path, self.path))
if rel.path == './' && self.quer... | [
"def route_to(oth)\n parser.__send__(:convert_to_uri, oth).route_from(self)\n end",
"def route_to(oth)\n case oth\n when Generic\n when String\n oth = parser.parse(oth)\n else\n raise ArgumentError,\n \"bad argument(expected URI object or URI string)\"\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Args +oth+:: URI or String == Description Calculates relative path to oth from self. == Usage require 'uri' uri = URI.parse(' uri.route_to(' => | def route_to(oth)
parser.__send__(:convert_to_uri, oth).route_from(self)
end | [
"def route_from(oth)\n # you can modify `rel', but can not `oth'.\n begin\n oth, rel = route_from0(oth)\n rescue\n raise $!.class, $!.message\n end\n if oth == rel\n return rel\n end\n\n rel.set_path(route_from_path(oth.path, self.path))\n if rel.path == ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a proxy URI. The proxy URI is obtained from environment variables such as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper proxy, nil is returned. If the optional parameter +env+ is specified, it is used instead of ENV. Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are exami... | def find_proxy(env=ENV)
raise BadURIError, "relative URI: #{self}" if self.relative?
name = self.scheme.downcase + '_proxy'
proxy_uri = nil
if name == 'http_proxy' && env.include?('REQUEST_METHOD') # CGI?
# HTTP_PROXY conflicts with *_proxy for proxy settings and
# HTTP_* for hea... | [
"def proxy_from_env\n env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']\n\n return nil if env_proxy.nil? or env_proxy.empty?\n\n uri = URI.parse(normalize_uri(env_proxy))\n\n unless uri.user or uri.password then\n uri.user = escape ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER']\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Description Creates a new URI::FTP object from generic URL components with no syntax checking. Unlike build(), this method does not escape the path component as required by RFC1738; instead it is treated as per RFC2396. Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+, +opaque+, +query+, and +f... | def initialize(scheme,
userinfo, host, port, registry,
path, opaque,
query,
fragment,
parser = nil,
arg_check = false)
raise InvalidURIError unless path
path = path.sub(/^\//,'')
path.sub!... | [
"def initialize(scheme,\n userinfo, host, port, registry,\n path, opaque,\n query,\n fragment,\n parser = DEFAULT_PARSER,\n arg_check = false)\n @scheme = nil\n @user = nil\n @password = nil\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validates typecode +v+, returns +true+ or +false+. | def check_typecode(v)
if TYPECODE.include?(v)
return true
else
raise InvalidComponentError,
"bad typecode(expected #{TYPECODE.join(', ')}): #{v}"
end
end | [
"def validate_data_validation_type(v); end",
"def validate( value )\n @base_type ? @base_type.validate(internalize(value)) : true\n end",
"def validate_type(type, context:); end",
"def valid_code? code\n valid_codes.include? code\n end",
"def valid?\n case @thing\n when Integer,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private setter for the typecode +v+. See also URI::FTP.typecode=. | def set_typecode(v)
@typecode = v
end | [
"def vfs_type=(value)\n @vfs_type = value\n end",
"def set_type(v)\n self.type = v\n self\n end",
"def typecode=(typecode)\n check_typecode(typecode)\n set_typecode(typecode)\n typecode\n end",
"def set_server_type(server_type)\n if (server_type.casecmp('filer') == 0)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Args +v+:: String == Description Public setter for the typecode +v+ (with validation). See also URI::FTP.check_typecode. == Usage require 'uri' | def typecode=(typecode)
check_typecode(typecode)
set_typecode(typecode)
typecode
end | [
"def set_typecode(v)\n @typecode = v\n end",
"def authen_type=(val)\n if (val.kind_of?(Integer))\n @authen_type = val & 0xff\n elsif(val.kind_of?(String))\n raise ArgumentError, \"Value must be 1-byte, but was #{val.length}.\" if (val.length != 1) \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Description Returns the full path for an HTTP request, as required by Net::HTTP::Get. If the URI contains a query, the full path is URIpath + '?' + URIquery. Otherwise, the path is simply URIpath. Example: uri = URI::HTTP.build(path: '/foo/bar', query: 'test=true') uri.request_uri => "/foo/bar?test=true" | def request_uri
return unless @path
url = @query ? "#@path?#@query" : @path.dup
url.start_with?(?/.freeze) ? url : ?/ + url
end | [
"def request_uri\n return nil if absolute? && scheme !~ /^https?$/\n res = path.to_s.empty? ? \"/\" : path\n res += \"?#{self.query}\" if self.query\n return res\n end",
"def request_fullpath\n if request.query_parameters.present?\n \"#{request_path}?#{request_url_query_para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Description Returns the origin for an HTTP uri, as defined in Example: URI::HTTP.build(host: ' path: '/foo/bar').origin => " URI::HTTP.build(host: ' port: 8000, path: '/foo/bar').origin => " URI::HTTP.build(host: ' port: 80, path: '/foo/bar').origin => " URI::HTTPS.build(host: ' path: '/foo/bar').origin => " | def origin
"#{scheme}://#{authority}"
end | [
"def origin\n\t\tunless @origin\n\t\t\torigin_uri = self.headers.origin or return nil\n\t\t\t@origin = URI( origin_uri )\n\t\tend\n\n\t\treturn @origin\n\tend",
"def origin_host\n begin\n URI.parse(URI.encode(origin.strip)).host\n rescue URI::InvalidURIError\n origin\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Description Creates a new URI::LDAP object from generic URI components as per RFC 2396. No LDAPspecific syntax checking is performed. Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+, +opaque+, +query+, and +fragment+, in that order. Example: uri = URI::LDAP.new("ldap", nil, "ldap.example.com",... | def initialize(*arg)
super(*arg)
if @fragment
raise InvalidURIError, 'bad LDAP URL'
end
parse_dn
parse_query
end | [
"def initialize(scheme,\n userinfo, host, port, registry,\n path, opaque,\n query,\n fragment,\n parser = DEFAULT_PARSER,\n arg_check = false)\n @scheme = nil\n @user = nil\n @password = nil\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private method to cleanup +dn+ from using the +path+ component attribute. | def parse_dn
raise InvalidURIError, 'bad LDAP URL' unless @path
@dn = @path[1..-1]
end | [
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def reset_paths_to_cleanup\n @paths_to_cleanup = nil\n end",
"def clear_paths; end",
"def clean_dir\n\n path = self.get_dir\n _clean_dir(path)\n end",
"def normalize_dn(dn)\n return dn unless dn.st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private setter for dn +val+. | def set_dn(val)
@dn = val
build_path_query
@dn
end | [
"def dn=(val)\n set_dn(val)\n val\n end",
"def dn=( newdn )\n\t\tself.clear_caches\n\t\t@dn = newdn\n\tend",
"def distinguished=(value)\n @distinguished = value\n end",
"def fqdn=(value)\n @fqdn = value\n end",
"def fqdn=(value)\n @fqdn = value\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for dn +val+. | def dn=(val)
set_dn(val)
val
end | [
"def set_dn(val)\n @dn = val\n build_path_query\n @dn\n end",
"def dn=( newdn )\n\t\tself.clear_caches\n\t\t@dn = newdn\n\tend",
"def fqdn=(value)\n @fqdn = value\n end",
"def dn\n dn_value = id\n if dn_value.nil?\n raise DistinguishedNameNotSetError.new,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for attributes +val+. | def attributes=(val)
set_attributes(val)
val
end | [
"def set_attr!(attr, val)\n self.attrs[attr] = val\n end",
"def set_attribute(name, value); end",
"def set_int(attr, val); end",
"def assign(attr, val)\n return unless respond_to? attr\n\n public_send attr, val\n end",
"def attr=(val) @records.set(GRT_PROPATTR,val); end",
"def s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for scope +val+. | def scope=(val)
set_scope(val)
val
end | [
"def scope=( val )\n @scope = val\n end",
"def set_value= val\n @value = val\n @evaluated = true\n end",
"def set_value_for(scope_type, model, value); end",
"def scope=(value)\n @scope = value\n end",
"def set_value_for(scope_type, mod... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for filter +val+. | def filter=(val)
set_filter(val)
val
end | [
"def filter=(value)\n @filter = value\n end",
"def filter=(value)\n @filter = value\n end",
"def filter=(value)\n @filter = value\n end",
"def set_FilterValue(value)\n set_input(\"FilterValue\", value)\n end",
"def set_F... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for extensions +val+. | def extensions=(val)
set_extensions(val)
val
end | [
"def set(value)\n case value\n when DateTime\n set(value.to_time)\n when Time\n set(value.to_i)\n when Integer\n self.val = value\n else\n self.val = value.to_i\n end\n val\n end",
"def try_value=(val)\n\t\t@value = val\n\te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== Description Creates a new URI::MailTo object from generic URL components with no syntax checking. This method is usually called from URI::parse, which checks the validity of each component. | def initialize(*arg)
super(*arg)
@to = nil
@headers = []
# The RFC3986 parser does not normally populate opaque
@opaque = "?#{@query}" if @query && !@opaque
unless @opaque
raise InvalidComponentError,
"missing opaque part for mailto URL"
end
to, heade... | [
"def initialize(*arg)\n super(*arg)\n\n @to = nil\n @headers = []\n\n if MAILTO_REGEXP =~ @opaque\n if arg[-1]\n self.to = $1\n self.headers = $2\n else\n set_to($1)\n set_headers($2)\n end\n\n else\n raise InvalidComponentErro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks the headers +v+ component against either HEADER_REGEXP | def check_headers(v)
return true unless v
return true if v.size == 0
if HEADER_REGEXP !~ v
raise InvalidComponentError,
"bad component(expected opaque component): #{v}"
end
true
end | [
"def check_headers(v)\n return true unless v\n return true if v.size == 0\n\n if parser.regexp[:OPAQUE] !~ v ||\n /\\A(#{HEADER_PATTERN}(?:\\&#{HEADER_PATTERN})*)\\z/o !~ v\n raise InvalidComponentError,\n \"bad component(expected opaque component): #{v}\"\n end\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for headers +v+. | def headers=(v)
check_headers(v)
set_headers(v)
v
end | [
"def headers=(val)\n @headers = val.is_a?(String) ? JSON.parse(val) : val\n end",
"def []= k, v\n @headers[k].value = v\n end",
"def headers=(hash)\n if headers\n headers.replace hash\n else\n super\n end\n end",
"def header(k, v)\r\n @message_headers[k... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a local cache repository for the git gem. | def cache # :nodoc:
return unless @remote
if File.exist? repo_cache_dir
Dir.chdir repo_cache_dir do
system @git, 'fetch', '--quiet', '--force', '--tags',
@repository, 'refs/heads/*:refs/heads/*'
end
else
system @git, 'clone', '--quiet', '--bare', '--no-hardlinks',
... | [
"def cache # :nodoc:\n if File.exist? repo_cache_dir then\n Dir.chdir repo_cache_dir do\n system @git, 'fetch', '--quiet', '--force', '--tags',\n @repository, 'refs/heads/*:refs/heads/*'\n end\n else\n system @git, 'clone', '--quiet', '--bare', '--no-hardlinks',\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Loads all gemspecs in the repository | def specs
checkout
return [] unless install_dir
Dir.chdir install_dir do
Dir['{,*,*/*}.gemspec'].map do |spec_file|
directory = File.dirname spec_file
file = File.basename spec_file
Dir.chdir directory do
spec = Gem::Specification.load file
if spec
... | [
"def with_each_gemspec\n Dir[\"**/*.gemspec\"].each do |file|\n yield(file, Gem::Specification.load(file)) if block_given?\n end\nend",
"def gemspecs\n @gemspecs ||= if Gem::Specification.respond_to?(:latest_specs)\n Gem::Specification.latest_specs\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A hash for the git gem based on the git repository URI. | def uri_hash # :nodoc:
require_relative '../openssl'
normalized =
if @repository =~ %r{^\w+://(\w+@)?}
uri = URI(@repository).normalize.to_s.sub %r{/$},''
uri.sub(/\A(\w+)/) { $1.downcase }
else
@repository
end
OpenSSL::Digest::SHA1.hexdigest normalized
end | [
"def uri_hash # :nodoc:\n normalized =\n if @repository =~ %r%^\\w+://(\\w+@)?% then\n uri = URI(@repository).normalize.to_s.sub %r%/$%,''\n uri.sub(/\\A(\\w+)/) { $1.downcase }\n else\n @repository\n end\n\n Digest::SHA1.hexdigest normalized\n end",
"def git_sha_for(pat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Orders this source against +other+. If +other+ is a SpecificFile from a different gem name +nil+ is returned. If +other+ is a SpecificFile from the same gem name the versions are compared using Gem::Version Otherwise Gem::Source is used. | def <=>(other)
case other
when Gem::Source::SpecificFile then
return nil if @spec.name != other.spec.name
@spec.version <=> other.spec.version
else
super
end
end | [
"def <=>(other)\n case other\n when Gem::Source::SpecificFile then\n return nil if @package.spec.name != other.package.spec.name\n\n @package.spec.version <=> other.package.spec.version\n else\n super\n end\n end",
"def merge(other)\n unless name == other.name\n raise Argum... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new Source which will use the index located at +uri+. | def initialize(uri)
begin
unless uri.kind_of? URI
uri = URI.parse(uri.to_s)
end
rescue URI::InvalidURIError
raise if Gem::Source == self.class
end
@uri = uri
@update_cache = nil
end | [
"def create_source(uri)\n TaliaCore::Source.create!(uri)\n end",
"def uri=(uri)\n @uri = uri\n @source ||= uri\n end",
"def source=(uri)\n @source = uri\n @prefix ||= uri\n end",
"def source=(uri)\n @source = uri\n @uri ||= uri\n end",
"def uri= uri\n ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true when it is possible and safe to update the cache directory. | def update_cache?
return @update_cache unless @update_cache.nil?
@update_cache =
begin
File.stat(Gem.user_home).uid == Process.uid
rescue Errno::ENOENT
false
end
end | [
"def installer_cached?\n File.exist?(installer_path) and File.zero?(installer_path) == false\nend",
"def cache_valid?\n return false unless File.exist?(cache_path)\n return true if checksum.nil?\n checksum == file_digest(cache_path)\n end",
"def production_up_to_date?\n working_dir.updat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches a specification for the given +name_tuple+. | def fetch_spec(name_tuple)
fetcher = Gem::RemoteFetcher.fetcher
spec_file_name = name_tuple.spec_name
source_uri = enforce_trailing_slash(uri) + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
cache_dir = cache_dir source_uri
local_spec = File.join cache_dir, spec_file_name
if File.exist? local... | [
"def spec(name)\n specs = if Gem::Specification.respond_to?(:each)\n Gem::Specification.find_all_by_name(name)\n else\n Gem.source_index.find_name(name)\n end\n\n spec = specs.sort_by{ |spec| Gem::Version.new(spec.version) }.first\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Downloads +spec+ and writes it to +dir+. See also Gem::RemoteFetcherdownload. | def download(spec, dir=Dir.pwd)
fetcher = Gem::RemoteFetcher.fetcher
fetcher.download spec, uri.to_s, dir
end | [
"def download(path)\n Gem.ensure_gem_subdirectories path\n\n if @spec.respond_to? :sources\n exception = nil\n path = @spec.sources.find do |source|\n begin\n source.download full_spec, path\n rescue exception\n end\n end\n return path if path\n rais... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: def_single_delegator(accessor, method, new_name=method) Defines a method _method_ which delegates to _accessor_ (i.e. it calls the method of the same name in _accessor_). If _new_name_ is provided, it is used as the name for the delegate method. Returns the name of the method defined. | def def_single_delegator(accessor, method, ali = method)
gen = Forwardable._delegator_method(self, accessor, method, ali)
ret = instance_eval(&gen)
singleton_class.__send__(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
ret
end | [
"def define_delegator(method_name)\n target_name = @target_name\n @scope.send(:define_method, method_name) do |*args|\n send(target_name).public_send(method_name, *args)\n end\n end",
"def make_method_delegator( delegate, name )\n\t\t\terror_frame = caller(5)[0]\n\t\t\tfile, line = error_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:method: freeze Freeze both the object returned by \_\_getobj\_\_ and self. | def freeze
__getobj__.freeze
super()
end | [
"def freeze() end",
"def __getobj__\n end",
"def __getobj__\n\n @_imitated_object\n\n end",
"def freeze\n each_item(&:freeze)\n super\n end",
"def freeze\n @args.freeze if @args\n super\n end",
"def freeze\n @properties.freeze; self\n end",
"def __g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes the current directory to the directory +dir+. If this method is called with block, resumes to the previous working directory after the block execution has finished. FileUtils.cd('/') change directory FileUtils.cd('/', verbose: true) change directory and report it FileUtils.cd('/') do change directory ... do som... | def cd(dir, verbose: nil, &block) # :yield: dir
fu_output_message "cd #{dir}" if verbose
result = Dir.chdir(dir, &block)
fu_output_message 'cd -' if verbose and block
result
end | [
"def cd(dir, options = {}, &block) # :yield: dir\r\n fu_check_options options, :noop, :verbose\r\n fu_output_message \"cd #{dir}\" if options[:verbose]\r\n Dir.chdir(dir, &block) unless options[:noop]\r\n fu_output_message 'cd -' if options[:verbose] and block\r\n end",
"def within_dir dir, &blk\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes one or more directories. FileUtils.rmdir 'somedir' FileUtils.rmdir %w(somedir anydir otherdir) Does not really remove directory; outputs message. FileUtils.rmdir 'somedir', verbose: true, noop: true | def rmdir(list, parents: nil, noop: nil, verbose: nil)
list = fu_list(list)
fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if verbose
return if noop
list.each do |dir|
Dir.rmdir(dir = remove_trailing_slash(dir))
if parents
begin
until (parent = File.dirna... | [
"def rmdir(list, options = {})\r\n fu_check_options options, :noop, :verbose\r\n list = fu_list(list)\r\n fu_output_message \"rmdir #{list.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n list.each do |dir|\r\n Dir.rmdir dir.sub(%r</\\z>, '')\r\n end\r\n end",
"def rmd... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: FileUtils.ln(target, link, force: nil, noop: nil, verbose: nil) FileUtils.ln(target, dir, force: nil, noop: nil, verbose: nil) FileUtils.ln(targets, dir, force: nil, noop: nil, verbose: nil) In the first form, creates a hard link +link+ which points to +target+. If +link+ already exists, raises Errno::EEXIST.... | def ln(src, dest, force: nil, noop: nil, verbose: nil)
fu_output_message "ln#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
fu_each_src_dest0(src, dest) do |s,d|
remove_file d, true if force
File.link s, d
end
end | [
"def symlink(path, target); end",
"def link(source, target)\n @component.install << \"#{@component.platform.install} -d '#{File.dirname(target)}'\"\n # Use a bash conditional to only create the link if it doesn't already point to the correct source.\n # This allows rerunning the install step ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hard link +src+ to +dest+. If +src+ is a directory, this method links all its contents recursively. If +dest+ is a directory, links +src+ to +dest/src+. +src+ can be a list of files. If +dereference_root+ is true, this method dereference tree root. If +remove_destination+ is true, this method removes each destination f... | def cp_lr(src, dest, noop: nil, verbose: nil,
dereference_root: true, remove_destination: false)
fu_output_message "cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
fu_each_src_dest(src, dest) do |s, d|
link_entry s, d, de... | [
"def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)\n options = \"#{force ? 'f' : ''}#{target_directory ? '' : 'T'}\"\n dest = File.path(dest)\n srcs = Array(src)\n link = proc do |s, target_dir_p = true|\n s = File.path(s)\n if target_dir_p\n d = File.joi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: FileUtils.ln_s(target, link, force: nil, noop: nil, verbose: nil) FileUtils.ln_s(target, dir, force: nil, noop: nil, verbose: nil) FileUtils.ln_s(targets, dir, force: nil, noop: nil, verbose: nil) In the first form, creates a symbolic link +link+ which points to +target+. If +link+ already exists, raises Errn... | def ln_s(src, dest, force: nil, noop: nil, verbose: nil)
fu_output_message "ln -s#{force ? 'f' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
fu_each_src_dest0(src, dest) do |s,d|
remove_file d, true if force
File.symlink s, d
end
end | [
"def ln_s( src, dest, options={} )\n Lucie::Logger.instance.info( sh_msg(\"ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}\") )\n return FileUtils.ln_s( src, dest, options )\nend",
"def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)\n options = \"#{force ? 'f'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hard links a file system entry +src+ to +dest+. If +src+ is a directory, this method links its contents recursively. Both of +src+ and +dest+ must be a path name. +src+ must exist, +dest+ must not exist. If +dereference_root+ is true, this method dereferences the tree root. If +remove_destination+ is true, this method ... | def link_entry(src, dest, dereference_root = false, remove_destination = false)
Entry_.new(src, nil, dereference_root).traverse do |ent|
destent = Entry_.new(dest, ent.rel, false)
File.unlink destent.path if remove_destination && File.file?(destent.path)
ent.link destent.path
end
end | [
"def link_entry(src, dest, dereference_root = false, force = false)\n Entry_.new(src, nil, dereference_root).traverse do |ent|\n destent = Entry_.new(dest, ent.rel, false)\n File.unlink destent.path if force && File.file?(destent.path)\n ent.link destent.path\n end\n end",
"def copy_entry(sr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copies +src+ to +dest+. If +src+ is a directory, this method copies all its contents recursively. If +dest+ is a directory, copies +src+ to +dest/src+. +src+ can be a list of files. If +dereference_root+ is true, this method dereference tree root. If +remove_destination+ is true, this method removes each destination fi... | def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,
dereference_root: true, remove_destination: nil)
fu_output_message "cp -r#{preserve ? 'p' : ''}#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
fu_each_src_dest(src, dest) do ... | [
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copies a file system entry +src+ to +dest+. If +src+ is a directory, this method copies its contents recursively. This method preserves file types, c.f. symlink, directory... (FIFO, device files and etc. are not supported yet) Both of +src+ and +dest+ must be a path name. +src+ must exist, +dest+ must not exist. If +pr... | def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
if dereference_root
src = File.realpath(src)
end
Entry_.new(src, nil, false).wrap_traverse(proc do |ent|
destent = Entry_.new(dest, ent.rel, false)
File.unlink destent.path if remove_destinat... | [
"def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)\r\n Entry_.new(src, nil, dereference_root).traverse do |ent|\r\n destent = Entry_.new(dest, ent.rel, false)\r\n File.unlink destent.path if remove_destination && File.file?(destent.path)\r\n ent.copy... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copies stream +src+ to +dest+. +src+ must respond to read(n) and +dest+ must respond to write(str). | def copy_stream(src, dest)
IO.copy_stream(src, dest)
end | [
"def copy_stream(src, dest)\n begin\n while s = src.readpartial(1024)\n dest.write(s)\n end\n rescue EOFError\n end\n end",
"def copy_stream(src, dest)\r\n bsize = fu_stream_blksize(src, dest)\r\n begin\r\n while true\r\n dest.syswrite src.sysread(bsize)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Equivalent to FileUtils.rm(list, force: true) | def rm_f(list, noop: nil, verbose: nil)
rm list, force: true, noop: noop, verbose: verbose
end | [
"def rm(list, options = {})\r\n fu_check_options options, :force, :noop, :verbose\r\n list = fu_list(list)\r\n fu_output_message \"rm#{options[:force] ? ' -f' : ''} #{list.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n list.each do |fname|\r\n remove_file fname, options[:f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the contents of a file +a+ and a file +b+ are identical. FileUtils.compare_file('somefile', 'somefile') => true FileUtils.compare_file('/dev/null', '/dev/urandom') => false | def compare_file(a, b)
return false unless File.size(a) == File.size(b)
File.open(a, 'rb') {|fa|
File.open(b, 'rb') {|fb|
return compare_stream(fa, fb)
}
}
end | [
"def compare_file(a, b)\r\n return false unless File.size(a) == File.size(b)\r\n File.open(a, 'rb') {|fa|\r\n File.open(b, 'rb') {|fb|\r\n return compare_stream(fa, fb)\r\n }\r\n }\r\n end",
"def files_are_same(file1, file2)\n begin\n File.open(file1, 'rb').read == File.open(file1, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the contents of a stream +a+ and +b+ are identical. | def compare_stream(a, b)
bsize = fu_stream_blksize(a, b)
sa = String.new(capacity: bsize)
sb = String.new(capacity: bsize)
begin
a.read(bsize, sa)
b.read(bsize, sb)
return true if sa.empty? && sb.empty?
end while sa == sb
false
end | [
"def compare_stream(a, b)\r\n bsize = fu_stream_blksize(a, b)\r\n sa = sb = nil\r\n while sa == sb\r\n sa = a.read(bsize)\r\n sb = b.read(bsize)\r\n unless sa and sb\r\n if sa.nil? and sb.nil?\r\n return true\r\n end\r\n end\r\n end\r\n false\r\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If +src+ is not same as +dest+, copies it and changes the permission mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+. This method removes destination before copy. FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby',... | def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
noop: nil, verbose: nil)
if verbose
msg = +"install -c"
msg << ' -p' if preserve
msg << ' -m ' << mode_to_s(mode) if mode
msg << " -o #{owner}" if owner
msg << " -g #{group}" if group
msg << ' ... | [
"def install(src, dest, options = {})\r\n fu_check_options options, :mode, :preserve, :noop, :verbose\r\n fu_output_message \"install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes permission bits on the named files (in +list+) to the bit pattern represented by +mode+. +mode+ is the symbolic and absolute mode can be used. Absolute mode is FileUtils.chmod 0755, 'somecommand' FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb) FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true Symbolic ... | def chmod(mode, list, noop: nil, verbose: nil)
list = fu_list(list)
fu_output_message sprintf('chmod %s %s', mode_to_s(mode), list.join(' ')) if verbose
return if noop
list.each do |path|
Entry_.new(path).chmod(fu_mode(mode, path))
end
end | [
"def chmod(mode, list, options = {})\r\n fu_check_options options, :noop, :verbose\r\n list = fu_list(list)\r\n fu_output_message sprintf('chmod %o %s', mode, list.join(' ')) if options[:verbose]\r\n return if options[:noop]\r\n File.chmod mode, *list\r\n end",
"def chmod_list(list, flags)\n list... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes owner and group on the named files (in +list+) to the user +user+ and the group +group+. +user+ and +group+ may be an ID (Integer/String) or a name (String). If +user+ or +group+ is nil, this method does not change the attribute. FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby' FileUtils.chown nil, 'bin',... | def chown(user, group, list, noop: nil, verbose: nil)
list = fu_list(list)
fu_output_message sprintf('chown %s %s',
(group ? "#{user}:#{group}" : user || ':'),
list.join(' ')) if verbose
return if noop
uid = fu_get_uid(user)
gid = fu_get_gi... | [
"def oo_chown_R(user, group, list, options = {})\n user = pu_get_uid(user)\n group = pu_get_gid(group)\n\n FileUtils.chown_R(user, group, list, options)\n end",
"def chown(user_and_group)\n return unless user_and_group\n user, group = user_and_group.split(':').map {|s| s == '' ? nil : s}\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates modification time (mtime) and access time (atime) of file(s) in +list+. Files are created if they don't exist. FileUtils.touch 'timestamp' FileUtils.touch Dir.glob('.c'); system 'make' | def touch(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)
list = fu_list(list)
t = mtime
if verbose
fu_output_message "touch #{nocreate ? '-c ' : ''}#{t ? t.strftime('-t %Y%m%d%H%M.%S ') : ''}#{list.join ' '}"
end
return if noop
list.each do |path|
created = nocreate
... | [
"def touch(list, options = {})\r\n fu_check_options options, :noop, :verbose\r\n list = fu_list(list)\r\n fu_output_message \"touch #{list.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n t = Time.now\r\n list.each do |fname|\r\n begin\r\n File.utime(t, t, fname)\r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Closes the file. If +unlink_now+ is true, then the file will be unlinked (deleted) after closing. Of course, you can choose to later call unlink if you do not unlink it now. If you don't explicitly unlink the temporary file, the removal will be delayed until the object is finalized. | def close(unlink_now=false)
_close
unlink if unlink_now
end | [
"def close(unlink_now=false)\n if unlink_now\n close!\n else\n _close\n end\n end",
"def close(unlink_now=false)\n if unlink_now\n close!\n else\n _close\n end\n end",
"def close\n if @temp_file\n @temp_file.close\n @temp_file = nil\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unlinks (deletes) the file from the filesystem. One should always unlink the file after using it, as is explained in the "Explicit close" good practice section in the Tempfile overview: file = Tempfile.new('foo') begin ...do something with file... ensure file.close file.unlink deletes the temp file end === Unlinkbefore... | def unlink
return if @unlinked
begin
File.unlink(@tmpfile.path)
rescue Errno::ENOENT
rescue Errno::EACCES
# may not be able to unlink on Windows; just ignore
return
end
ObjectSpace.undefine_finalizer(self)
@unlinked = true
end | [
"def unlink\n # keep this order for thread safeness\n begin\n File.unlink(@tmpname) if File.exist?(@tmpname)\n @@cleanlist.delete(@tmpname)\n @data = @tmpname = nil\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::EACCES\n # may not be able to unlink on Window... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full path name of the temporary file. This will be nil if unlink has been called. | def path
@unlinked ? nil : @tmpfile.path
end | [
"def file_name\n Pathname(\"#{dir_name}temporaryfile\")\n end",
"def temporary_filename\n @iotmp ? @iotmp.path : nil\n end",
"def tmp_path\n @tmpfile.path\n end",
"def tmpfile_pathname(name)\n tmpfile_dir_pathname.join(name)\n end",
"def path\n tempfile.path\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the size of the temporary file. As a side effect, the IO buffer is flushed before determining the size. | def size
if !@tmpfile.closed?
@tmpfile.size # File#size calls rb_io_flush_raw()
else
File.size(@tmpfile.path)
end
end | [
"def size\n @mutex.synchronize do\n if @tmpfile\n @tmpfile.flush\n @tmpfile.stat.size\n else\n 0\n end\n end\n end",
"def size\n if @tmpfile\n @tmpfile.flush\n @tmpfile.stat.size\n else\n 0\n end\n end",
"def tempfile_length(io)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluate the given +statements+ within the context of this workspace. | def evaluate(context, statements, file = __FILE__, line = __LINE__)
eval(statements, @binding, file, line)
end | [
"def interpret(statements)\n statements.each do |statement|\n execute(statement)\n end\n rescue Ringo::Errors::RuntimeError => error\n Ringo.runtime_error(error)\n end",
"def eval\n results = []\n\n @statements.each do |s|\n st_res = eval_statement(s)\n results ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether this input method is still readable when there is no more data to read. See IOeof for more information. | def readable_after_eof?
false
end | [
"def readable?\n ! __io_like__closed_read? && respond_to?(:unbuffered_read, true)\n end",
"def closed_read?\n !@readable\n end",
"def readable?\n return false if @read_io.closed?\n r,w,e = Kernel.select([@read_io], nil, nil, @timeout)\n return !(r.nil? or r.empty?)\n end",
"def readable?... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints the given +opts+, with a newline delimiter. | def printn(*opts)
print opts.join(" "), "\n"
end | [
"def initialize(opts = {})\n @opts =\n {\n :print_lines => false\n }.merge!(opts)\n end",
"def print(*args,**opts)\n stdout = opts.fetch(:out, $stdout)\n t = args.map{|a|apply(a)}\n stdout.print *t\n end",
"def add_options_on_tail(opts)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extends IOprintf to format the given +opts+ for Kernelsprintf using parse_printf_format | def printf(format, *opts)
if /(%*)%I/ =~ format
format, opts = parse_printf_format(format, opts)
end
print sprintf(format, *opts)
end | [
"def printf(format, *opts); end",
"def parse_printf_format(format, opts)\n return format, opts if $1.size % 2 == 1\n end",
"def sprintf(fmt, *rest) end",
"def format(fmt, *rest) end",
"def smart_printf(opts={})\n printf_template = ''\n # assret its a AoA\n width=self[0].size\n deb width\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of the given +format+ and +opts+ to be used by Kernelsprintf, if there was a successful Regexp match in the given +format+ from printf % [0 +] (\|\[19][09]\$|[19][09]) .(\|\[19][09]\$|[19][09]|)? (hh|h|l|ll|L|q|j|z|t) [diouxXeEfgGcsb%] | def parse_printf_format(format, opts)
return format, opts if $1.size % 2 == 1
end | [
"def printf(format, *opts)\n if /(%*)%I/ =~ format\n format, opts = parse_printf_format(format, opts)\n end\n print sprintf(format, *opts)\n end",
"def printf(format, *opts); end",
"def allowed_format(fmt = nil, note = nil, only:)\n fmt, note = [nil, fmt] if fmt.is_a?(String)\n on... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls print on each element in the given +objs+, followed by a newline character. | def puts(*objs)
for obj in objs
print(*obj)
print "\n"
end
end | [
"def puts(*objs); end",
"def pp(*objs)\n puts(*objs.collect{|obj| obj.inspect})\n end",
"def printObjectArray(objsArr)\n i = 1\n objsArr.each do |x|\n puts(\"#{i}.\")\n puts(\"=====================================================\")\n x.print\n puts(\"==============... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints the given +objs+ calling Objectinspect on each. See puts for more detail. | def pp(*objs)
puts(*objs.collect{|obj| obj.inspect})
end | [
"def puts(*objs)\n for obj in objs\n print(*obj)\n print \"\\n\"\n end\n end",
"def puts(*objs); end",
"def printObjectArray(objsArr)\n i = 1\n objsArr.each do |x|\n puts(\"#{i}.\")\n puts(\"=====================================================\")\n x.pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints the given +objs+ calling Objectinspect on each and appending the given +prefix+. See puts for more detail. | def ppx(prefix, *objs)
puts(*objs.collect{|obj| prefix+obj.inspect})
end | [
"def puts(*objs)\n for obj in objs\n print(*obj)\n print \"\\n\"\n end\n end",
"def pp(*objs)\n puts(*objs.collect{|obj| obj.inspect})\n end",
"def puts(*objs); end",
"def op5PrintObjects(type,objects)\n logIt(\"* Entering: #{thisMethod()}\", DEBUG)\n# pp objects\n object... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The toplevel workspace, see WorkSpacemain | def main
@workspace.main
end | [
"def my_workspace\n @browser.link(:text=>\"My Workspace\").click\n $frame_index=0\n MyWorkspace.new(@browser)\n end",
"def toplevel\n\t\t\td=infos[:toplevel] and ShellHelpers::Pathname.new(d)\n\t\tend",
"def workspace\n FilePath.new(@native.getWorkspace())\n end",
"def public_workspace\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether verbose? is +true+, and +input_method+ is either StdioInputMethod or ReidlineInputMethod or ReadlineInputMethod, see io for more information. | def prompting?
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
@io.kind_of?(ReidlineInputMethod) ||
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
end | [
"def file_input?\n @io.class == FileInputMethod\n end",
"def useinputmethods(boolean = None, window = None)\n if None == window\n Tk.execute(:tk, :useinputmethods, boolean ? true : false)\n else\n Tk.execute(:tk, :useinputmethods, '-displayof', window, boolean ? true : false)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the return value from the last statement evaluated in this context to last_value. | def set_last_value(value)
@last_value = value
@workspace.local_variable_set :_, value
end | [
"def set_last_result(result, code = T.unsafe(nil)); end",
"def last_block=(val)\n self[@cfunction][:last_block] = val\n end",
"def last_execution=(value)\n @last_execution = value\n end",
"def last_value exp\n case exp.node_type\n when :rlist, :block, :scope, Sexp\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the +mode+ of the prompt in this context. | def prompt_mode=(mode)
@prompt_mode = mode
pconf = IRB.conf[:PROMPT][mode]
@prompt_i = pconf[:PROMPT_I]
@prompt_s = pconf[:PROMPT_S]
@prompt_c = pconf[:PROMPT_C]
@prompt_n = pconf[:PROMPT_N]
@return_format = pconf[:RETURN]
@return_format = "%s\n" if @return_format == nil
... | [
"def prompt_mode=(mode); end",
"def set_mode(mode)\n @opts[:interactive] = mode.to_s == \"interactive\" ? true : false\n get_mode\n end",
"def set_mode(m)\n @mode = m\n end",
"def set_mode(mode)\n case mode\n # when \"+s\"\n # when \"-s\"\n when \"+i\"\n room.lock\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether inspect_mode is set or not, see inspect_mode= for more detail. | def inspect?
@inspect_mode.nil? or @inspect_mode
end | [
"def inspect_mode; end",
"def inspect_mode=(opt); end",
"def inspect_mode=(opt)\n\n if i = Inspector::INSPECTORS[opt]\n @inspect_mode = opt\n @inspect_method = i\n i.init\n else\n case opt\n when nil\n if Inspector.keys_with_inspector(Inspector::INSPECTORS[t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether io uses a File for the +input_method+ passed when creating the current context, see ::new | def file_input?
@io.class == FileInputMethod
end | [
"def open_file(io)\n io.kind_of?(File) ? io : File.open(io)\n end",
"def file_input?; end",
"def open(io)\n return open_file(io) if file\n \n case io\n when String\n StringIO.new(io)\n when Integer\n IO.open(io)\n else \n io\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specifies the inspect mode with +opt+: +true+:: display +inspect+ +false+:: display +to_s+ +nil+:: inspect mode in nonmath mode, noninspect mode in math mode See IRB::Inspector for more information. Can also be set using the +inspect+ and +noinspect+ command line options. | def inspect_mode=(opt)
if i = Inspector::INSPECTORS[opt]
@inspect_mode = opt
@inspect_method = i
i.init
else
case opt
when nil
if Inspector.keys_with_inspector(Inspector::INSPECTORS[true]).include?(@inspect_mode)
self.inspect_mode = false
... | [
"def inspect_mode=(opt); end",
"def toggle_inspect\n case @inspect_style\n when :hex, :pretty\n @inspect_style = :dissect\n when :dissect, :verbose\n @inspect_style = :default\n when :default, :ugly\n @inspect_style = :hex\n else\n @inspect_style = :dissect\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Quits the current irb context +ret+ is the optional signal or message to send to Contextexit Same as IRB.CurrentContext.exit. | def irb_exit(ret = 0)
irb_context.exit(ret)
end | [
"def exit(ret)\n @exit_status = ret\n if defined? Rbkb::Cli::TESTING\n throw(((ret==0)? :exit_zero : :exit_err), ret)\n else\n Kernel.exit(ret)\n end\n end",
"def exit(res=0) end",
"def exit!(res=0) end",
"def exit\n Call.libusb_exit(@ctx)\n end",
"def quit\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extends the given +base_method+ with a postfix call to the given +extend_method+. | def def_post_proc(base_method, extend_method)
base_method = base_method.to_s
extend_method = extend_method.to_s
alias_name = new_alias_name(base_method)
module_eval %[
alias_method alias_name, base_method
def #{base_method}(*opts)
__send__ :#{alias_name}, *opts
... | [
"def extend_operand\n unwrap_operand.extend(new_extensions)\n end",
"def add_super_method(field_key, method_name)\n default_resolve_module = @_default_resolve\n if default_resolve_module.nil?\n # This should have been set up in one of the inherited or included hook... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluates the given block using the given +path+ as the Contextirb_path and +name+ as the Contextirb_name. | def suspend_name(path = nil, name = nil)
@context.irb_path, back_path = path, @context.irb_path if path
@context.irb_name, back_name = name, @context.irb_name if name
begin
yield back_path, back_name
ensure
@context.irb_path = back_path if path
@context.irb_name = back_na... | [
"def named_block(block_name, *args, &block)\n # dup the output so far and save it\n original_output = __erbb_get_rendered_template.dup\n\n # wipe the template output ivar\n __erbb_set_rendered_template(\"\")\n\n # render the block, populating the ivar with the result\n yield(*args)\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluates the given block using the given +input_method+ as the Contextio. | def suspend_input_method(input_method)
back_io = @context.io
@context.instance_eval{@io = input_method}
begin
yield back_io
ensure
@context.instance_eval{@io = back_io}
end
end | [
"def evaluate(input)\n if input.operator?\n perform_operation(input)\n else\n input\n end\n end",
"def process(input, context=nil, filename=nil)\n code = convert(input)\n filename ||= '(erubis)'\n if context.is_a?(Binding)\n return eval(code, context, filename... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is similar to breakable except the decision to break or not is determined individually. Two fill_breakable under a group may cause 4 results: (break,break), (break,nonbreak), (nonbreak,break), (nonbreak,nonbreak). This is different to breakable because two breakable under a group may cause 2 results: (break,break)... | def fill_breakable(sep=' ', width=sep.length)
group { breakable sep, width }
end | [
"def breakable(sep=' ', width=nil)\n @output << sep\n end",
"def breakable(separator = T.unsafe(nil), width = T.unsafe(nil), indent: T.unsafe(nil), force: T.unsafe(nil)); end",
"def comma_breakable\n text ','\n breakable\n end",
"def break_to_newline\n end",
"def comma_breakable; end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Makes a break for this Group, and returns true | def break
@break = true
end | [
"def break?\n @break\n end",
"def break\n\t\t# Jump back into the outer loop of #each \n\t\tthrow( :break ) if @iterating\n\tend",
"def add_break\n\t\tcheck_if_myself\n\t\t@break = Break.new\n\tend",
"def break!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Boolean of whether this Group has made a break | def break?
@break
end | [
"def last_of_group?\n current_step == steps_in_current_group.last\n end",
"def first_of_group?\n current_step == steps_in_current_group.first\n end",
"def group_entry?\n !default_entry? && flag == :group\n end",
"def erg_leader?\r\n group_leaders.count > 0\r\n end",
"def accept... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Boolean of whether this Group has been queried for being first This is used as a predicate, and ought to be called first. | def first?
if defined? @first
false
else
@first = false
true
end
end | [
"def first?\n not first.nil?\n end",
"def acts_as_ordered_is_first?\n\t\tif self.class.count( :conditions => acts_as_ordered_exclusivity_conditions.and( [\"#{self.class.table_name}.#{self.class.acts_as_ordered_order_attribute_name} < ?\",self.send( self.class.acts_as_ordered_order_attribute_name )] ).... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Enqueue +group+ This does not strictly append the group to the end of the queue, but instead adds it in line, base on the +group.depth+ | def enq(group)
depth = group.depth
@queue << [] until depth < @queue.length
@queue[depth] << group
end | [
"def push(*items, group: 'default')\n key = key_for(group)\n items = items.map(&:to_json)\n multi do |conn|\n # Add the follow to the queue\n conn.lpush(key, items)\n # Increment our queue length in the list\n conn.zincrby(groups_key, items.count, key)\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the outer group of the queue | def deq
@queue.each {|gs|
(gs.length-1).downto(0) {|i|
unless gs[i].breakables.empty?
group = gs.slice!(i, 1).first
group.break
return group
end
}
gs.each {|group| group.break}
gs.clear
}
return nil
end | [
"def enq(group)\n depth = group.depth\n @queue << [] until depth < @queue.length\n @queue[depth] << group\n end",
"def get_next_grouping_for_collection\n priority_queue.first || regular_queue.first\n end",
"def get_queues_in_group(group_name)\n group_queues[group_name]\n end",
"def c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add +obj+ to the text to be output. +width+ argument is here for compatibility. It is a noop argument. | def text(obj, width=nil)
@output << obj
end | [
"def text(obj, width=obj.length)\n if @buffer.empty?\n @output << obj\n @output_width += width\n else\n text = @buffer.last\n unless Text === text\n text = Text.new\n @buffer << text\n end\n text.add(obj, width)\n @buffer_width += width\n break_outmost_gro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Appends +sep+ to the text to be output. By default +sep+ is ' ' +width+ argument is here for compatibility. It is a noop argument. | def breakable(sep=' ', width=nil)
@output << sep
end | [
"def _print_separator_line(sep = '*', title = '')\n line_len = 80\n half_width = (line_len - title.to_s.length) / 2.0\n puts sep.to_s * half_width.floor + title.to_s + sep.to_s * half_width.ceil\n end",
"def print_line_separator(width, filling='-')\n width.times do\n print fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Opens a block for grouping objects to be pretty printed. Arguments: +indent+ noop argument. Present for compatibility. +open_obj+ text appended before the &blok. Default is '' +close_obj+ text appended after the &blok. Default is '' +open_width+ noop argument. Present for compatibility. +close_width+ noop argument. Pre... | def group(indent=nil, open_obj='', close_obj='', open_width=nil, close_width=nil)
@first.push true
@output << open_obj
yield
@output << close_obj
@first.pop
end | [
"def group(_indent = T.unsafe(nil), open_object = T.unsafe(nil), close_object = T.unsafe(nil), _open_width = T.unsafe(nil), _close_width = T.unsafe(nil)); end",
"def open_bracket\n @output << \" {\\n\" << indent \n end",
"def process_simple_block_opener(tk)\n return unless [TkLBRACE, TkDO, TkBEGIN, T... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the sharing detection flag to b. | def sharing_detection=(b)
Ractor.current[:pp_sharing_detection] = b
end | [
"def is_shared=(value)\n @is_shared = value\n end",
"def allow_sample_sharing=(value)\n @allow_sample_sharing = value\n end",
"def can_share=(value)\n @can_share = value\n end",
"def sharing_capability=(value)\n @shar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check whether the object_id +id+ is in the current buffer of objects to be pretty printed. Used to break cycles in chains of objects to be pretty printed. | def check_inspect_key(id)
Thread.current[:__recursive_key__] &&
Thread.current[:__recursive_key__][:inspect] &&
Thread.current[:__recursive_key__][:inspect].include?(id)
end | [
"def check_inspect_key(id)\n if Object.const_defined?(:Thread)\n Thread.current[:__recursive_key__] &&\n Thread.current[:__recursive_key__][:inspect] &&\n Thread.current[:__recursive_key__][:inspect].include?(id)\n else\n $__recursive_key__ &&\n $__recursive_key__[:inspe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +obj+ to the pretty printing buffer using Objectpretty_print or Objectpretty_print_cycle. Objectpretty_print_cycle is used when +obj+ is already printed, a.k.a the object reference chain has a cycle. | def pp(obj)
# If obj is a Delegator then use the object being delegated to for cycle
# detection
obj = obj.__getobj__ if defined?(::Delegator) and obj.is_a?(::Delegator)
if check_inspect_key(obj)
group {obj.pretty_print_cycle self}
return
end
begin
push_insp... | [
"def pp(obj)\n id = obj.object_id\n\n if check_inspect_key(id)\n group {obj.pretty_print_cycle self}\n return\n end\n\n begin\n push_inspect_key(id)\n group {obj.pretty_print self}\n ensure\n pop_inspect_key(id) unless PP.sharing_detection\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A convenience method which is same as follows: text ',' breakable | def comma_breakable
text ','
breakable
end | [
"def comma_breakable; end",
"def separator(text); end",
"def on_comma(value); end",
"def breakable(sep=' ', width=nil)\n @output << sep\n end",
"def split_field(text, separator = DocTemplate::Tables::Base::SPLIT_REGEX)\n text.to_s\n .split(separator)\n .map(&:squish).r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A copy of the default IRB.conf[:SAVE_HISTORY] | def save_history
IRB.conf[:SAVE_HISTORY]
end | [
"def save_history=(val)\n IRB.conf[:SAVE_HISTORY] = val\n if val\n main_context = IRB.conf[:MAIN_CONTEXT]\n main_context = self unless main_context\n main_context.init_save_history\n end\n end",
"def history_file\n IRB.conf[:HISTORY_FILE]\n end",
"def history_file=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets IRB.conf[:SAVE_HISTORY] to the given +val+ and calls init_save_history with this context. Will store the number of +val+ entries of history in the history_file Add the following to your +.irbrc+ to change the number of history entries stored to 1000: IRB.conf[:SAVE_HISTORY] = 1000 | def save_history=(val)
IRB.conf[:SAVE_HISTORY] = val
if val
main_context = IRB.conf[:MAIN_CONTEXT]
main_context = self unless main_context
main_context.init_save_history
end
end | [
"def save_history\n IRB.conf[:SAVE_HISTORY]\n end",
"def history_file=(hist)\n IRB.conf[:HISTORY_FILE] = hist\n end",
"def save_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tlines = Readline::HISTORY.to_a.reverse.uniq.reverse\n\t\tlines = lines[ -DEFAULT_HISTORY_SIZE, DEFAULT_HISTORY_S... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A copy of the default IRB.conf[:HISTORY_FILE] | def history_file
IRB.conf[:HISTORY_FILE]
end | [
"def history_file=(hist)\n IRB.conf[:HISTORY_FILE] = hist\n end",
"def history_file\n File.expand_path(HISTORY_FILE, File.dirname($PROGRAM_NAME))\n end",
"def history_file_init\n\n self.history_file = \"#{FRAMEWORKDIR}/.history\"\n\n if ! ::File.exists?(\"#{self.history_file}\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set IRB.conf[:HISTORY_FILE] to the given +hist+. | def history_file=(hist)
IRB.conf[:HISTORY_FILE] = hist
end | [
"def history_file\n IRB.conf[:HISTORY_FILE]\n end",
"def history_file_init\n\n self.history_file = \"#{FRAMEWORKDIR}/.history\"\n\n if ! ::File.exists?(\"#{self.history_file}\")\n File.new(\"#{self.history_file}\", 'w+')\n end\n\n hist_file\n end",
"def history_file\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:category: Extensions Is the extension `name` enabled? | def extension? name
@extensions.include? name
end | [
"def extension_enabled?( name )\n\t\treturn self.extension_versions.key?( name.to_sym )\n\tend",
"def has_extension?(name)\n get_extension(name)\n end",
"def available_extension?(name)\n @__available_extensions__.key?(name)\n end",
"def extension name, enable\n if enable then\n @extens... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:category: Extensions Enables or disables the extension with `name` | def extension name, enable
if enable then
@extensions |= [name]
else
@extensions -= [name]
end
end | [
"def extension_enabled?( name )\n\t\treturn self.extension_versions.key?( name.to_sym )\n\tend",
"def enable\n authorize! @extension, :disable?\n @extension.update_attribute(:enabled, true)\n redirect_to owner_scoped_extension_url(@extension), notice: t(\"extension.enabled\", extension: @extension.name)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses `text` in a clone of this parser. This is used for handling nested lists the same way as markdown_parser. | def inner_parse text # :nodoc:
parser = clone
parser.setup_parser text, @debug
parser.peg_parse
doc = parser.result
doc.accept @formatter
doc.parts
end | [
"def parse_list(text)\n text.split(self.class.list_split).collect do |str|\n next if str.blank?\n \n str.gsub!(self.class.list_clean, \"\")\n item, str = $1, $2 if str =~ self.class.nested_block\n \n struct = parse_blocks(str, :p => !!(str =~ /\\n\\n/)) unless str.blan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a link reference for `label` and creates a new link to it with `content` as the link text. If `label` was not encountered in the referencegathering parser pass the label and content are reconstructed with the linking `text` (usually whitespace). | def link_to content, label = content, text = nil
raise ParseError, 'enable notes extension' if
content.start_with? '^' and label.equal? content
if ref = @references[label] then
"{#{content}}[#{ref}]"
elsif label.equal? content then
"[#{content}]#{text}"
else
"[#{content}]#{text}... | [
"def set_reference_labels content, labels\n content.gsub! %r{(<a href=\"#([^\"]+)\">)(</a>)} do |match|\n if labels.key? $2\n \"#{$1}#{h labels[$2]}#{$3}\"\n else\n match\n end\n end\nend",
"def set_reference_labels content, labels\n content.gsub! %r{(<a href=\"#([^\"]+)\">)(</a>)} do |mat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.