query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
:callseq: define_head(params, &block) :include: ../doc/optparse/creates_option.rdoc | def define_head(*opts, &block)
top.prepend(*(sw = make_switch(opts, block)))
sw[0]
end | [
"def build_option(objects, &block); end",
"def initialize ( sname, lname, brief = '', param = false )\r\n raise TypeError, 'Incorrectly types for option constructor.' unless\r\n\tsname.instance_of? String and\r\n\tlname.instance_of? String and\r\n\tbrief.instance_of? String and\r\n\tsname.length == 1 and lna... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: on_head(params, &block) :include: ../doc/optparse/creates_option.rdoc The new option is added at the head of the summary. | def on_head(*opts, &block)
define_head(*opts, &block)
self
end | [
"def create_tail_options\n @cl_parser.on_tail\n @cl_parser.on_tail 'Other options:'\n option_help_tail\n option_version_tail\n end",
"def add_options_on_tail(opts)\n opts.on_tail('-h', '--help', 'Print this message.') do\n puts opts\n exit 0\n end\n\n opts.on_ta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: define_tail(params, &block) :include: ../doc/optparse/creates_option.rdoc | def define_tail(*opts, &block)
base.append(*(sw = make_switch(opts, block)))
sw[0]
end | [
"def create_tail_options\n @cl_parser.on_tail\n @cl_parser.on_tail 'Other options:'\n option_help_tail\n option_version_tail\n end",
"def add_options_on_tail(opts)\n opts.on_tail('-h', '--help', 'Print this message.') do\n puts opts\n exit 0\n end\n\n opts.on_ta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Same as permute, but removes switches destructively. Nonoption arguments remain in +argv+. | def permute!(argv = default_argv, into: nil)
nonopts = []
order!(argv, into: into, &nonopts.method(:<<))
argv[0, 0] = nonopts
argv
end | [
"def permute!() options.permute!(self) end",
"def process_argv!\n options[:all_args] = []\n args = ARGV.dup\n while args do\n arg = args.shift\n case\n when arg == '--'\n break\n when arg =~ /\\A--(\\w+)(?:=(.+))?\\z/\n opt, val = [$1, $2]\n op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses command line arguments +argv+ in order when environment variable POSIXLY_CORRECT is set, and in permutation mode otherwise. When optional +into+ keyword argument is provided, the parsed option values are stored there via []= method (so it can be Hash, or OpenStruct, or other similar object). | def parse(*argv, into: nil)
argv = argv[0].dup if argv.size == 1 and Array === argv[0]
parse!(argv, into: into)
end | [
"def parse!(argv=ARGV, options={})\n argv = Shellwords.shellwords(argv) if argv.kind_of?(String)\n \n args = []\n remainder = scan(argv, options) {|arg| args << arg}\n args.concat(remainder)\n argv.replace(args)\n \n argv\n end",
"def process_argv!\n options[:all_args] = []\n ar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wrapper method for getopts.rb. params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option") params["a"] = true a params["b"] = "1" b1 params["foo"] = "1" foo params["bar"] = "x" bar x params["zot"] = "z" zot Z | def getopts(*args)
argv = Array === args.first ? args.shift : default_argv
single_options, *long_options = *args
result = {}
single_options.scan(/(.)(:)?/) do |opt, val|
if val
result[opt] = nil
define("-#{opt} VAL")
else
result[opt] = false
define("-#{opt}"... | [
"def getopts opts \n#--{{{\n self.class.getopts opts \n#--}}}\n end",
"def opts\n params = {}\n @opts.each { |opt, opts| params[opt.to_sym] = opt_value(opt, *opts[0, 2]) }\n params\n end",
"def parse_options()\n\n options = {}\n\n ARGV.each_index do |index|\n case $*[index]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Completes shortened long style option switch and returns pair of canonical switch and switch descriptor OptionParser::Switch. +typ+:: Searching table. +opt+:: Searching key. +icase+:: Search case insensitive if true. +pat+:: Optional pattern for completion. | def complete(typ, opt, icase = false, *pat) # :nodoc:
if pat.empty?
search(typ, opt) {|sw| return [sw, opt]} # exact match or...
end
ambiguous = catch(:ambiguous) {
visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}
}
exc = ambiguous ? AmbiguousOption : InvalidOption
raise ... | [
"def option_for(switch)\n if @options.has_key?(switch)\n @options[switch]\n elsif @shorts.has_key?(switch)\n @shorts[switch]\n elsif switch =~ /^--no-(\\S+)$/\n found = @options[\"--#{$1}\"]\n (found.boolean? && \"--#{$1}\" == found.long) ? found : nil\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Loads options from file names as +filename+. Does nothing when the file is not present. Returns whether successfully loaded. +filename+ defaults to basename of the program without suffix in a directory ~/.options, then the basename with '.options' suffix under XDG and Haiku standard places. | def load(filename = nil)
unless filename
basename = File.basename($0, '.*')
return true if load(File.expand_path(basename, '~/.options')) rescue nil
basename << ".options"
return [
# XDG
ENV['XDG_CONFIG_HOME'],
'~/.config',
*ENV['XDG_CONFIG_DIRS']&.split(File:... | [
"def load(filename = nil)\n begin\n filename ||= File.expand_path(File.basename($0, '.*'), '~/.options')\n rescue\n return false\n end\n begin\n parse(*IO.readlines(filename).each {|s| s.chomp!})\n true\n rescue Errno::ENOENT, Errno::ENOTDIR\n false\n end\n end",
"def c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses environment variable +env+ or its uppercase with splitting like a shell. +env+ defaults to the basename of the program. | def environment(env = File.basename($0, '.*'))
env = ENV[env] || ENV[env.upcase] or return
require 'shellwords'
parse(*Shellwords.shellwords(env))
end | [
"def environment(env = File.basename($0, '.*'))\n env = ENV[env] || ENV[env.upcase] or return\n parse(*Shellwords.shellwords(env))\n end",
"def parse_env(env)\n env.split('=').last\n end",
"def parse(env); env; end",
"def get_env(env)\n case session.type\n when /meterpreter/\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pushes back erred argument(s) to +argv+. | def recover(argv)
argv[0, 0] = @args
argv
end | [
"def hack_argv\n if ARGV.include? '--'\n @saved_args = ARGV.slice! 0..ARGV.index('--')\n end\n end",
"def process_argv!\n options[:all_args] = []\n args = ARGV.dup\n while args do\n arg = args.shift\n case\n when arg == '--'\n break\n when ar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses +self+ destructively in permutation mode and returns +self+ containing the rest arguments left unparsed. | def permute!() options.permute!(self) end | [
"def arguments\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 58 )\n return_value = ArgumentsReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n arguments_start_index = @input.index\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the number of seconds the specified time zone differs from UTC. Numeric time zones that include minutes, such as 10:00 or +1330 will work, as will simpler houronly time zones like 10 or +13. Textual time zones listed in ZoneOffset are also supported. If the time zone does not match any of the above, +zone_offset... | def zone_offset(zone, year=self.now.year)
off = nil
zone = zone.upcase
if /\A([+-])(\d\d)(:?)(\d\d)(?:\3(\d\d))?\z/ =~ zone
off = ($1 == '-' ? -1 : 1) * (($2.to_i * 60 + $4.to_i) * 60 + $5.to_i)
elsif zone.match?(/\A[+-]\d\d\z/)
off = zone.to_i * 3600
elsif ZoneOffset.inclu... | [
"def zone_offset_hours\n zone = ActiveSupport::TimeZone.new(self.time_zone || \"UTC\")\n (zone.utc_offset / 60) / 60\n end",
"def tz\n # logger.debug(\"CHC: customer tz called from #{caller.join(\"\\n\")}\")\n if tzb = time_zone_binary\n tzb.to_r / MINS_PER_DAY\n else\n nil\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new compiler for ERB. See ERB::Compiler.new for details | def make_compiler(trim_mode)
ERB::Compiler.new(trim_mode)
end | [
"def compile\n template.compile(compilation_context)\n end",
"def mkcompiler source=''\n VishCompiler.new source\nend",
"def compile(context)\n if template_content\n ERB.new(template_content, 0, '-').result(context)\n else\n raise TemplateNotFound.new(@file, @path.absolute_paths... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets optional filename and line number that will be used in ERB code evaluation and error reporting. See also filename= and lineno= erb = ERB.new('') erb.render undefined local variable or method `some_x' from (erb):1 erb.location = ['file.erb', 3] All subsequent error reporting would use new location erb.render undefi... | def location=((filename, lineno))
@filename = filename
@lineno = lineno if lineno
end | [
"def set_template_line(lineno)\n @lineno = lineno\n update_repr\n end",
"def lineno= integer\n #This is a stub, used for indexing\n end",
"def set_line(line_number)\n @line_number = line_number\n end",
"def lineno=(line_number)\n ensure_open\n\n raise TypeError if line_number.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Can be used to set _eoutvar_ as described in ERB::new. It's probably easier to just use the constructor though, since calling this method requires the setup of an ERB _compiler_ object. | def set_eoutvar(compiler, eoutvar = '_erbout')
compiler.put_cmd = "#{eoutvar}.<<"
compiler.insert_cmd = "#{eoutvar}.<<"
compiler.pre_cmd = ["#{eoutvar} = +''"]
compiler.post_cmd = [eoutvar]
end | [
"def _erbout=(input)\n @_erbout = input\n end",
"def set_eoutvar compiler, io_variable\n compiler.put_cmd = \"#{io_variable}.write\"\n compiler.insert_cmd = \"#{io_variable}.write\"\n compiler.pre_cmd = []\n compiler.post_cmd = []\n end",
"def initialize(erb)\n @erb = erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Executes the generated ERB code to produce a completed template, returning the results of that code. (See ERB::new for details on how this process can be affected by _safe_level_.) _b_ accepts a Binding object which is used to set the context of code evaluation. | def result(b=new_toplevel)
unless @_init.equal?(self.class.singleton_class)
raise ArgumentError, "not initialized"
end
eval(@src, b, (@filename || '(erb)'), @lineno)
end | [
"def run_erb(in_binding = binding)\n require 'erb'\n ERB.new(self.to_s, nil, '>').result(in_binding)\n end",
"def execute_template(string, b)\n ERB.new(string).result b\n end",
"def _erb_buffer( the_binding )\n eval(\"_erbout\", the_binding, __FILE__, __LINE__)\n end",
"def evaluate_erb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define _methodname_ as instance method of _mod_ from compiled Ruby source. example: filename = 'example.rhtml' 'arg1' and 'arg2' are used in example.rhtml erb = ERB.new(File.read(filename)) erb.def_method(MyClass, 'render(arg1, arg2)', filename) print MyClass.new.render('foo', 123) | def def_method(mod, methodname, fname='(ERB)')
src = self.src.sub(/^(?!#|$)/) {"def #{methodname}\n"} << "\nend\n"
mod.module_eval do
eval(src, binding, fname, -1)
end
end | [
"def def_module(methodname='erb')\n mod = Module.new\n def_method(mod, methodname, @filename || '(ERB)')\n mod\n end",
"def compile_method block, source, options\n body_block = CompiledBlock.new\n body_block.name = source['name']\n\n # Arguments & default values\n args = source[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create unnamed module, define _methodname_ as instance method of it, and return it. example: filename = 'example.rhtml' 'arg1' and 'arg2' are used in example.rhtml erb = ERB.new(File.read(filename)) erb.filename = filename MyModule = erb.def_module('render(arg1, arg2)') class MyClass include MyModule end | def def_module(methodname='erb')
mod = Module.new
def_method(mod, methodname, @filename || '(ERB)')
mod
end | [
"def def_method(mod, methodname, fname='(ERB)')\n src = self.src.sub(/^(?!#|$)/) {\"def #{methodname}\\n\"} << \"\\nend\\n\"\n mod.module_eval do\n eval(src, binding, fname, -1)\n end\n end",
"def new_method(mod, name, *args)\n m = Method.new(gensym(name), mod, name, *args)\n add_method(m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A utility method for encoding the String _s_ as a URL. require "erb" include ERB::Util puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide") _Generates_ Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide | def url_encode(s)
s.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m|
sprintf("%%%02X", m.unpack1("C"))
}
end | [
"def url_encode(string)\n CGI.escape(string.to_s)\n end",
"def url_encode(str)\n URI::encode str.to_s\n end",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set whether the Cookie is a secure cookie or not. +val+ must be a boolean. | def secure=(val)
@secure = val if val == true or val == false
@secure
end | [
"def secure=(val)\n @secure = val == true\n end",
"def secure=(secure)\n\t\t# {{{\n\t\tunless secure == true || secure == false\n\t\t\traise TypeError, \"The secure field of a cookie must be true or false\", caller\n\t\tend\n\t\t@secure = secure\n\t\t# }}}\n\tend",
"def set_cookie_secure_flag(secure=ni... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set whether the Cookie is a httponly cookie or not. +val+ must be a boolean. | def httponly=(val)
@httponly = !!val
end | [
"def http_only=(val)\n @http_only = val == true\n end",
"def set_cookie_http_only_flag(httpOnly=nil)\n if (httpOnly.class == TrueClass || httpOnly.class == FalseClass) && !block_given?\n @j_del.java_method(:setCookieHttpOnlyFlag, [Java::boolean.java_class]).call(httpOnly)\n return self\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A summary of cookie string. | def inspect
"#<CGI::Cookie: #{self.to_s.inspect}>"
end | [
"def cookie_string\n cookies.collect { |name, val| \"#{name}=#{val}\" }.join(', ')\n end",
"def cookie_value\n \"#{@name}=#{Scanner.quote(@value.to_s)}\"\n end",
"def inspect\n \"#<Cookie: @key=#{self.key.inspect} @value=#{self.value.inspect}>\"\n end",
"def cookie_value\n \"#{@name}=#{... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the raw cookies as a string. | def raw_cookie
env_table["HTTP_COOKIE"]
end | [
"def raw_cookie\n return env_table['HTTP_COOKIE']\n end",
"def cookie_string\n cookies.collect { |name, val| \"#{name}=#{val}\" }.join(', ')\n end",
"def raw_cookie\n (response['Set-Cookie'] || '')\n end",
"def raw_cookie\n (@response['Set-Cookie'] || '')\n end",
"def cookies_to_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
offline mode. read name=value pairs on standard input. | def read_from_cmdline
require "shellwords"
string = unless ARGV.empty?
ARGV.join(' ')
else
if STDIN.tty?
STDERR.print(
%|(offline mode: enter name=value pairs on standard input)\n|
)
end
array = readlines rescue nil
if not array.... | [
"def read_from_cmdline\n require \"shellwords\"\n\n string = unless ARGV.empty?\n ARGV.join(' ')\n else\n if STDIN.tty?\n STDERR.print(\n %|(offline mode: enter name=value pairs on standard input)\\n|\n )\n end\n readlines.join(' ').gsub(/\\n/n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A wrapper class to use a StringIO object as the body and switch to a TempFile when the passed threshold is passed. Initialize the data from the query. Handles multipart forms (in particular, forms that involve file uploads). | def initialize_query()
if ("POST" == env_table['REQUEST_METHOD']) and
%r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?| =~ env_table['CONTENT_TYPE']
current_max_multipart_length = @max_multipart_length.respond_to?(:call) ? @max_multipart_length.call : @max_multipart_length
raise Standar... | [
"def initialize_query()\n if (\"POST\" == env_table['REQUEST_METHOD']) and\n %r|\\Amultipart/form-data.*boundary=\\\"?([^\\\";,]+)\\\"?|n.match(env_table['CONTENT_TYPE'])\n boundary = $1.dup\n @multipart = true\n @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate code for an element for which the end (and possibly the start) tag is optional. O O or O | def nO_element(element, attributes = {})
s = nOE_element(element, attributes)
if block_given?
s << yield.to_s
s << "</#{element.upcase}>"
end
s
end | [
"def nO_element_def(element)\n nOE_element_def(element, <<-END)\n if block_given?\n yield.to_s + \"</#{element.upcase}>\"\n else\n \"\"\n end\n END\n end",
"def _start_tag(sym, attrs, end_too = T.unsafe(nil)); end",
"def end_tag\n \"</#{element.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a Document Base URI element as a String. +href+ can either by a string, giving the base URL for the HREF attribute, or it can be a has of the element's attributes. The passedin noargument block is ignored. base(" => "<BASE HREF=\" | def base(href = "") # :yield:
attributes = if href.kind_of?(String)
{ "HREF" => href }
else
href
end
super(attributes)
end | [
"def baseURI\n base = at('.//base')\n base ? base['href'] : document.documentURI\n end",
"def base\n @base = if doc\n href = doc.search('//head/base/@href')\n URI(href.to_s) unless href.nil? rescue nil\n end unless @base\n \n return nil if @base && @base.to_s()... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a Checkbox Input element as a string. The attributes of the element can be specified as three arguments, +name+, +value+, and +checked+. +checked+ is a boolean value; if true, the CHECKED attribute will be included in the element. Alternatively, the attributes can be specified as a hash. checkbox("name") = che... | def checkbox(name = "", value = nil, checked = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "checkbox", "NAME" => name,
"VALUE" => value, "CHECKED" => checked }
else
name["TYPE"] = "checkbox"
name
... | [
"def check_box_tag(name, attrs = {}) \n attrs.reverse_merge!(name: name, type: :checkbox, checked: false, value: 1)\n attrs = add_css_id(attrs, name)\n attrs = add_css_class(attrs, :checkbox)\n attrs = add_ui_hint(attrs)\n tag(:input, attrs)\n end",
"def checkbo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a sequence of checkbox elements, as a String. The checkboxes will all have the same +name+ attribute. Each checkbox is followed by a label. There will be one checkbox for each value. Each value can be specified as a String, which will be used both as the value of the VALUE attribute and as the label for that c... | def checkbox_group(name = "", *values)
if name.kind_of?(Hash)
values = name["VALUES"]
name = name["NAME"]
end
values.collect{|value|
if value.kind_of?(String)
checkbox(name, value) + value
else
if value[-1] == true || value[-1] == false
c... | [
"def checkbox_group(name = \"\", *values)\n if name.kind_of?(Hash)\n values = name[\"VALUES\"]\n name = name[\"NAME\"]\n end\n values.collect{|value|\n if value.kind_of?(String)\n checkbox(name, value) + value\n else\n if value[value.size - 1] == true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate an File Upload Input element as a string. The attributes of the element can be specified as three arguments, +name+, +size+, and +maxlength+. +maxlength+ is the maximum length of the file's _name_, not of the file's _contents_. Alternatively, the attributes can be specified as a hash. See multipart_form() for ... | def file_field(name = "", size = 20, maxlength = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "file", "NAME" => name,
"SIZE" => size.to_s }
else
name["TYPE"] = "file"
name
end
... | [
"def file_field(name, attributes = {})\n attributes[:accept] = Array(attributes[:accept]).join(ACCEPT_SEPARATOR) if attributes.key?(:accept)\n attributes = {type: :file, name: _displayed_input_name(name), id: _input_id(name)}.merge(attributes)\n\n input(attributes)\n end",
"def f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a Hidden Input element as a string. The attributes of the element can be specified as two arguments, +name+ and +value+. Alternatively, the attributes can be specified as a hash. hidden("name") hidden("name", "value") hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") | def hidden(name = "", value = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "hidden", "NAME" => name, "VALUE" => value }
else
name["TYPE"] = "hidden"
name
end
input(attributes)
end | [
"def build_hidden(type, value)\n tag(:input, {\n :type => \"hidden\",\n :id => input_id_from_type(type),\n :name => input_name_from_type(type),\n :value => value\n }) + \"\\n\"\n end",
"def build_hidden(type, value)\r\n tag(:input, {\r\n :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate an Image Button Input element as a string. +src+ is the URL of the image to use for the button. +name+ is the input name. +alt+ is the alternative text for the image. Alternatively, the attributes can be specified as a hash. image_button("url") image_button("url", "name", "string") image_button("SRC" => "url",... | def image_button(src = "", name = nil, alt = nil)
attributes = if src.kind_of?(String)
{ "TYPE" => "image", "SRC" => src, "NAME" => name,
"ALT" => alt }
else
src["TYPE"] = "image"
src["SRC"] ||= ""
... | [
"def css_button_image_submit_tag(source, options = {})\n return tag(:input, { :type => 'image', :alt => options[:alt] })\n end",
"def image_tag(input, *args)\n image_options = inline_options(args_to_options(args))\n\n %{<img src=\"#{get_url_from_asset(input)}\" #{image_options}>}\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate an Image element as a string. +src+ is the URL of the image. +alt+ is the alternative text for the image. +width+ is the width of the image, and +height+ is its height. Alternatively, the attributes can be specified as a hash. img("src", "alt", 100, 50) img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIG... | def img(src = "", alt = "", width = nil, height = nil)
attributes = if src.kind_of?(String)
{ "SRC" => src, "ALT" => alt }
else
src
end
attributes["WIDTH"] = width.to_s if width
attributes["HEIGHT"] = height.to_s if height... | [
"def xf_image_tag (src, attrs = {})\n attrs = attrs.symbolize_keys()\n content = \"\"\n caption = attrs.delete(:caption)\n unless caption.nil?\n content += typeWithAttrs(\"caption\", caption, nil, xhtml2prefix)\n end\n width = attrs.de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a Password Input element as a string. +name+ is the name of the input field. +value+ is its default value. +size+ is the size of the input field display. +maxlength+ is the maximum length of the inputted password. Alternatively, attributes can be specified as a hash. password_field("name") password_field("name... | def password_field(name = "", value = nil, size = 40, maxlength = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "password", "NAME" => name,
"VALUE" => value, "SIZE" => size.to_s }
else
name["TYPE"] = "password"
... | [
"def fe_password(name, attribs = {})\n v = attribs[:showvalue] ? get_value(name, attribs) : ''\n attribs.delete(:showvalue)\n \"<input type='password' name='#{name}' value='#{v}' #{a2p(attribs)}>\\n\"\n end",
"def password_field(attrs = {})\n attrs.delete(:value)\n attrs.merge!(:type => 'pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a Select element as a string. +name+ is the name of the element. The +values+ are the options that can be selected from the Select menu. Each value can be a String or a one, two, or threeelement Array. If a String or a oneelement Array, this is both the value of that option and the text displayed for it. If a ... | def popup_menu(name = "", *values)
if name.kind_of?(Hash)
values = name["VALUES"]
size = name["SIZE"].to_s if name["SIZE"]
multiple = name["MULTIPLE"]
name = name["NAME"]
else
size = nil
multiple = nil
end
select({ "NAME" => name, "SIZE... | [
"def popup_menu(name = \"\", *values)\n\n if name.kind_of?(Hash)\n values = name[\"VALUES\"]\n size = name[\"SIZE\"].to_s if name[\"SIZE\"]\n multiple = name[\"MULTIPLE\"]\n name = name[\"NAME\"]\n else\n size = nil\n multiple = nil\n end\n\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a radiobutton Input element. +name+ is the name of the input field. +value+ is the value of the field if checked. +checked+ specifies whether the field starts off checked. Alternatively, the attributes can be specified as a hash. radio_button("name", "value") radio_button("name", "value", true) radio_button("... | def radio_button(name = "", value = nil, checked = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "radio", "NAME" => name,
"VALUE" => value, "CHECKED" => checked }
else
name["TYPE"] = "radio"
name
... | [
"def radio_button_tag(name, attrs = {}) \n attrs.reverse_merge!(name: name, type: :radio, checked: false, value: 1)\n attrs = add_css_id(attrs, name)\n # id_value = [field.to_s,'_',value].join\n attrs[:id] = [attrs[:id], html_safe_id(attrs[:value])].compact.join('_')\n a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a sequence of radio button Input elements, as a String. This works the same as checkbox_group(). However, it is not valid to have more than one radiobutton in a group checked. radio_group("name", "foo", "bar", "baz") foo bar baz radio_group("name", ["foo"], ["bar", true], "baz") foo bar baz radio_group("name",... | def radio_group(name = "", *values)
if name.kind_of?(Hash)
values = name["VALUES"]
name = name["NAME"]
end
values.collect{|value|
if value.kind_of?(String)
radio_button(name, value) + value
else
if value[-1] == true || value[-1] == false
... | [
"def radio_group(name = \"\", *values)\n if name.kind_of?(Hash)\n values = name[\"VALUES\"]\n name = name[\"NAME\"]\n end\n values.collect{|value|\n if value.kind_of?(String)\n radio_button(name, value) + value\n else\n if value[value.size - 1] == true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a reset button Input element, as a String. This resets the values on a form to their initial values. +value+ is the text displayed on the button. +name+ is the name of this button. Alternatively, the attributes can be specified as a hash. reset reset("reset") reset("VALUE" => "reset", "ID" => "foo") | def reset(value = nil, name = nil)
attributes = if (not value) or value.kind_of?(String)
{ "TYPE" => "reset", "VALUE" => value, "NAME" => name }
else
value["TYPE"] = "reset"
value
end
input(attributes)
e... | [
"def draft_reset_button name, value, type\n data = { tooltip: translate(\"#{type}_tooltip\", scope: %i[admin action draft], value: name), value: value, position: 'top right', inverted: true }\n content = \"<i class=\\\"sync icon\\\"></i> #{translate type, scope: %i[admin action draft]}\".html_safe\n tag.di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a submit button Input element, as a String. +value+ is the text to display on the button. +name+ is the name of the input. Alternatively, the attributes can be specified as a hash. submit submit("ok") submit("ok", "button1") submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") | def submit(value = nil, name = nil)
attributes = if (not value) or value.kind_of?(String)
{ "TYPE" => "submit", "VALUE" => value, "NAME" => name }
else
value["TYPE"] = "submit"
value
end
input(attributes)
... | [
"def submit(attrs={})\n attrs.merge!(:value => 'Submit') unless attrs[:value]\n attrs.merge!(:type => 'submit')\n tag('input', attrs)\n end",
"def submit(value, attrs)\n attrs[:type] ||= \"submit\"\n attrs[:name] ||= \"submit\"\n attrs[:value] ||= value\n update_fields(attr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a text field Input element, as a String. +name+ is the name of the input field. +value+ is its initial value. +size+ is the size of the input area. +maxlength+ is the maximum length of input accepted. Alternatively, the attributes can be specified as a hash. text_field("name") text_field("name", "value") text_... | def text_field(name = "", value = nil, size = 40, maxlength = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "text", "NAME" => name, "VALUE" => value,
"SIZE" => size.to_s }
else
name["TYPE"] = "text"
n... | [
"def text_field_tag(name, attrs = {}) \n attrs.reverse_merge!(name: name, type: :text)\n attrs = add_css_id(attrs, name)\n attrs = add_css_class(attrs, :text)\n attrs = add_ui_hint(attrs)\n tag(:input, attrs)\n end",
"def generate_input_field(name, value, type =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a TextArea element, as a String. +name+ is the name of the textarea. +cols+ is the number of columns and +rows+ is the number of rows in the display. Alternatively, the attributes can be specified as a hash. The body is provided by the passedin noargument block textarea("name") = textarea("NAME" => "name", "CO... | def textarea(name = "", cols = 70, rows = 10) # :yield:
attributes = if name.kind_of?(String)
{ "NAME" => name, "COLS" => cols.to_s,
"ROWS" => rows.to_s }
else
name
end
super(attributes)
end | [
"def textarea(name = \"\", cols = 70, rows = 10) # :yield:\n attributes = if name.kind_of?(String)\n { \"NAME\" => name, \"COLS\" => cols.to_s,\n \"ROWS\" => rows.to_s }\n else\n name\n end\n if block_given?... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The DOCTYPE declaration for this version of HTML | def doctype
%|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">|
end | [
"def doctype\n %|<!DOCTYPE HTML>|\n end",
"def doctype(type) ; self << DOCTYPES[type||:html4_strict] ; end",
"def doctype_\n start_ht5\n ht5 << \"<!DOCTYPE html>\"\n end",
"def xhtml_doctype( doctype=:transitional )\n doctype = :transitional unless [:transitional, :strict, :frameset].include... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The DOCTYPE declaration for this version of HTML | def doctype
%|<!DOCTYPE HTML>|
end | [
"def doctype\n %|<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">|\n end",
"def doctype(type) ; self << DOCTYPES[type||:html4_strict] ; end",
"def doctype_\n start_ht5\n ht5 << \"<!DOCTYPE html>\"\n end",
"def xhtml_doctype( doctype=:transitional )\n doctype = :transitional unless [... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new session id. The session id is a secure random number by SecureRandom if possible, otherwise an SHA512 hash based upon the time, a random number, and a constant string. This routine is used internally for automatically generated session ids. | def create_new_id
require 'securerandom'
begin
# by OpenSSL, or system provided entropy pool
session_id = SecureRandom.hex(16)
rescue NotImplementedError
# never happens on modern systems
require 'digest'
d = Digest('SHA512').new
now = Time::now
... | [
"def create_session_id(weight)\n \"_#{weight}_#{SecureRandom.hex}\"\nend",
"def create_new_id\n @new_session = true\n self.class.generate_unique_id\n end",
"def create_new_id\r\n @new_session = true\r\n self.class.generate_unique_id\r\n end",
"def generate_unique_id\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new file to store the session data. This file will be created if it does not exist, or opened if it does. This path is generated under _tmpdir_ from _prefix_, the digested session id, and _suffix_. +option+ is a hash of options for the initializer. The following options are recognised: tmpdir:: the directory t... | def new_store_file(option={}) # :nodoc:
dir = option['tmpdir'] || Dir::tmpdir
prefix = option['prefix']
suffix = option['suffix']
require 'digest/md5'
md5 = Digest::MD5.hexdigest(session_id)[0,16]
path = dir+"/"
path << prefix if prefix
path << md5
path << suffix if... | [
"def session_file\n\t\treturn File.join( @dir, @id.to_s )\n\tend",
"def write_cache!(session)\n FileUtils.mkdir_p File.dirname(cached_file)\n File.open(cached_file, \"w\") do |cache_file|\n cache_file.write(session.serialize)\n end\n end",
"def store(filename, data, options = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Escape only the tags of certain HTML elements in +string+. Takes an element or elements or array of elements. Each element is specified by the name of the element, without angle brackets. This matches both the start and the end tag of that element. The attribute list of the open tag will also be escaped (for instance, ... | def escapeElement(string, *elements)
elements = elements[0] if elements[0].kind_of?(Array)
unless elements.empty?
string.gsub(/<\/?(?:#{elements.join("|")})(?!\w)(?:.|\n)*?>/i) do
CGI.escapeHTML($&)
end
else
string
end
end | [
"def escape_html( string )\n\t\t\treturn string.\n\t\t\t\tgsub( /&/n, '&' ).\n\t\t\t\tgsub( /\\\"/n, '"' ).\n\t\t\t\tgsub( />/n, '>' ).\n\t\t\t\tgsub( /</n, '<' )\n\t\tend",
"def html_escape(options={})\n except = options[:except] || %w()\n close_tags\n @modified_string.gsub!(/<\\/?([a-zA-... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Format a +Time+ object as a String using the format specified by RFC 1123. CGI.rfc1123_date(Time.now) Sat, 01 Jan 2000 00:00:00 GMT | def rfc1123_date(time)
time.getgm.strftime("%a, %d %b %Y %T GMT")
end | [
"def format_date(time); end",
"def rfc822(time)\n time.strftime(\"%a, %d %b %Y %H:%M:%S %z\")\n end",
"def format_datetime(time); end",
"def format_time(time, opts = {})\n format = opts[:include_timezone] ? \"%H:%M%:z\" : \"%H:%M\"\n if time.is_a? String\n case time\n when 'n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prettify (indent) an HTML string. +string+ is the HTML string to indent. +shift+ is the indentation unit to use; it defaults to two spaces. print CGI.pretty("") print CGI.pretty("", "\t") | def pretty(string, shift = " ")
lines = string.gsub(/(?!\A)<.*?>/m, "\n\\0").gsub(/<.*?>(?!\n)/m, "\\0\n")
end_pos = 0
while end_pos = lines.index(/^<\/(\w+)/, end_pos)
element = $1.dup
start_pos = lines.rindex(/^\s*<#{element}/i, end_pos)
lines[start_pos ... end_pos] = "__" + lines[start... | [
"def prettify(str)\n out, status = Open3.capture2('scripts/prettify', :stdin_data => str)\n return out.gsub(/^(\\s+)/, '\\1' * 2)\n end",
"def prettify(str)\n \"\\n\" + deindent(str) + \"\\n\"\n end",
"def prettify(str); end",
"def write(string)\n @indent_level > 0 ? @out.put... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns domain team list | def teams
parse_domain_top '/Teams/TeamList.aspx', 'lnkTeamInfo'
end | [
"def list()\n @client.team.list()\n end",
"def get_team_list ( page = 1 )\n get_api_resource \"#{@@api_base_url}teams/#{page}\"\n end",
"def nhl_team_list\n Team.all.each.with_index(1) do |team, i|\n puts \"#{i}. #{team.name}\"\n end\n nhl_team_selection\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
random unique serial number after product save | def generate_serial_number
self.serial_number = SecureRandom.uuid
generate_serial_number if Product.find_by(serial_number: serial_number)
end | [
"def get_unique_number; @unique_id ||= 0; @unique_id += 1; end",
"def generate_unique_id\n SecureRandom.hex(3) + Time.current.to_i.to_s\n end",
"def generate_uuid\n self.uuid = \"#{model_name.name}-\" + SecureRandom.uuid\n end",
"def generate_unique_name\n SecureRandom.uuid\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /topics_users/1 GET /topics_users/1.json | def show
@topics_user = TopicsUser.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @topics_user }
end
end | [
"def all_following_topics\n topics = User.find(params[:user_id]).following_topics\n render :json => topics\n end",
"def topics(usernames)\n get(\"/1/users/topics.json\", :users => [usernames].flatten).users\n end",
"def get_topics\n @chapter = Chapter.find(params[:id]) unless params[:id].blank... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /topics_users/new GET /topics_users/new.json | def new
@topics_user = TopicsUser.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @topics_user }
end
end | [
"def create\n @topics_user = TopicsUser.new(:topic_id=>params[:topic_id], :user_id=>params[:user_id])\n respond_to do |format|\n if @topics_user.save\n format.html { redirect_to find_topics_url, notice: 'Topic successfully added.' }\n format.json { render json: @topics_user, status: :create... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /topics_users POST /topics_users.json | def create
@topics_user = TopicsUser.new(:topic_id=>params[:topic_id], :user_id=>params[:user_id])
respond_to do |format|
if @topics_user.save
format.html { redirect_to find_topics_url, notice: 'Topic successfully added.' }
format.json { render json: @topics_user, status: :created, locatio... | [
"def create\n @user_topic = UserTopic.new(user_topic_params)\n\n if @user_topic.save\n render json: @user_topic\n else\n render json: @user_topic.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user_topic = UserTopic.new(user_topic_params)\n\n respond_to do |format|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /topics_users/1 PUT /topics_users/1.json | def update
@topics_user = TopicsUser.find(params[:id])
respond_to do |format|
if @topics_user.update_attributes(params[:topics_user])
format.html { redirect_to @topics_user, notice: 'Topics user was successfully updated.' }
format.json { head :no_content }
else
format.html {... | [
"def update\n if @user_topic.update(user_topic_params)\n render :show, status: :ok, location: @user_topic\n else\n render json: @user_topic.errors, status: :unprocessable_entity\n end\n end",
"def increment_user_topics\n user.increment_topics(1)\n end",
"def update_topics\n @topics ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /topics_users/1 DELETE /topics_users/1.json | def destroy
@topics_user = TopicsUser.find(params[:id])
@topics_user.destroy
respond_to do |format|
format.html { redirect_to my_topics_url, notice: 'Remove topic succeed!' }
format.json { head :no_content }
end
end | [
"def destroy\n @api_v1_topic.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redire... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Logic for column_headers for each export type | def export_column_headers(export_type = :addon_address)
unless self.accepted.include? export_type
raise ArgumentError, "Invalid export_type. Try one of these: \n \t #{self.accepted.join ' '}"
end
#todo make this private or add check for export_type
headers = self.parsed_content[0]
case expor... | [
"def column_headers\n use_column_headers ? columns.map(&:heading) : true\n end",
"def column_headers(header_style = :grid)\n headers = []\n if header_style == :file\n row = row_dimensions\n (0...column_count).each do |col_num|\n unless @su... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /termins/1 GET /termins/1.json | def show
@termin = Termin.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @termin }
end
end | [
"def index\n @terminy = Termin.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @terminy }\n end\n end",
"def new\n @termin = Termin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @termin }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /termins/new GET /termins/new.json | def new
@termin = Termin.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @termin }
end
end | [
"def create\n @termin = Termin.new(params[:termin])\n\n respond_to do |format|\n if @termin.save\n format.html { redirect_to @termin, notice: 'Termin was successfully created.' }\n format.json { render json: @termin, status: :created, location: @termin }\n else\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /termins POST /termins.json | def create
@termin = Termin.new(params[:termin])
respond_to do |format|
if @termin.save
format.html { redirect_to @termin, notice: 'Termin was successfully created.' }
format.json { render json: @termin, status: :created, location: @termin }
else
format.html { render action:... | [
"def create\n @termino = Termino.new(termino_params)\n\n respond_to do |format|\n if @termino.save\n format.html { redirect_to @termino, notice: 'Termino was successfully created.' }\n format.json { render :show, status: :created, location: @termino }\n else\n format.html { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /termins/1 PUT /termins/1.json | def update
@termin = Termin.find(params[:id])
respond_to do |format|
if @termin.update_attributes(params[:termin])
format.html { redirect_to @termin, notice: 'Termin was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
... | [
"def update\n respond_to do |format|\n if @termino.update(termino_params)\n format.html { redirect_to @termino, notice: 'Termino was successfully updated.' }\n format.json { render :show, status: :ok, location: @termino }\n else\n format.html { render :edit }\n format.json {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /termins/1 DELETE /termins/1.json | def destroy
@termin = Termin.find(params[:id])
@termin.destroy
respond_to do |format|
format.html { redirect_to termins_url }
format.json { head :no_content }
end
end | [
"def destroy\n @termin = Termin.find(params[:id])\n @termin.destroy\n\n respond_to do |format|\n format.html { redirect_to terminy_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @termino.destroy\n respond_to do |format|\n format.html { redirect_to terminos_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Transforms a module name for use in a file path | def module_name_for_path(module_name)
module_name.underscore
end | [
"def module_to_file_name(klass)\n klass.name.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/, '\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end",
"def normalize_module(module_name)\n mo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
included class can defined method notify_publishability_upchain!() to define additional notification chain and must define method check_publishing_rules() that add to publishing_errors | def check_publishing_rules
raise Exception.new("check_publishing_rules needs to be redefined by including class: #{self.class}")
end | [
"def enforce_publishing_validation!\n @enforce_publishing_validation = true\n end",
"def setup_check_request_publisher\n @logger.debug(\"scheduling check requests\")\n standard_checks = @settings.checks.reject do |check|\n check[:standalone] || check[:publish] == false\n end\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
validation: trigger by calling enforce_publishing_validation! on model | def enforce_publishing_validation!
@enforce_publishing_validation = true
end | [
"def valid_to_publish\n self.valid?\n end",
"def validate_publishing\n if self.changed? && self.published\n\n unpublish_place = false\n\n # Place must have 3 pictures\n if self.photos.blank? || self.photos.size < 3\n unpublish_place = true\n errors.add(:publish, \"123\") if pub... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If the line starts with A2P, call to_phonetic on the rest of the substring If the line starts with P2A, call from_phonetic on the rest of the substring Otherwise, return nothing. | def translate(line)
if line[0, 3].upcase == "A2P"
return to_phonetic(line[4..-1])
elsif line[0, 3].upcase == "P2A"
return from_phonetic(line[4..-1])
end
end | [
"def translate(line)\r\n if line[0,3] == \"A2P\"\r\n return to_phonetic(line[4,line.length])\r\n end\r\n if line[0,3] == \"P2A\"\r\n return from_phonetic(line[4,line.length])\r\n end\r\n \r\n return nil\r\n end",
"def auto_detect(line)\n\tnormal = true\n\tline.upcase!\n\tary = lin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /stories/1/tasks/new GET /stories/1/tasks/new.xml | def new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @task }
end
end | [
"def new_stories\n get('/newstories.json')\n end",
"def new\n @newtask = Newtask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newtask }\n end\n end",
"def new\n @task = Task.new\n \n respond_to do |format|\n format.html # new.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /teamcommitments/new GET /teamcommitments/new.xml | def new
@teamcommitment = Teamcommitment.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @teamcommitment }
end
end | [
"def new\n @commitment = Commitment.new\n @title = \"New Commitment\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @commitment }\n end\n end",
"def new\n @commit = Commit.new\n\n respond_to do |format|\n format.html # new.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /teamcommitments POST /teamcommitments.xml | def create
@teamcommitment = Teamcommitment.new(params[:teamcommitment])
respond_to do |format|
@teamcommitment.status = Teamcommitment::StatusProposed
if @teamcommitment.save
flash[:notice] = 'Commitment was successfully created.'
format.html { redirect_to(session[:original_uri]) ... | [
"def new\n @teamcommitment = Teamcommitment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teamcommitment }\n end\n end",
"def create\n @internship_committee = InternshipCommittee.new(internship_committee_params)\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /teamcommitments/1 PUT /teamcommitments/1.xml | def update
@teamcommitment = Teamcommitment.find(params[:id])
respond_to do |format|
if @teamcommitment.update_attributes(params[:teamcommitment])
flash[:notice] = 'Commitment was successfully updated.'
format.html { redirect_to(session[:original_uri]) }
format.xml { head :ok }
... | [
"def update\n @unknown_team = UnknownTeam.find(params[:id])\n if params[:commit] == \"Update\"\n team = Team.find(params[:team][:team_id])\n unless team.nil?\n synonym = TeamSynonym.new\n synonym.synonym = @unknown_team.name\n synonym.team_id = team.id\n synonym.sport_id ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /teamcommitments/1 DELETE /teamcommitments/1.xml | def destroy
@teamcommitment = Teamcommitment.find(params[:id])
@tasks = @teamcommitment.tasks
@teamcommitment.destroy
@tasks.each do |task|
task.destroy
end
respond_to do |format|
format.html { redirect_to(teamcommitments_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @executive_committee = ExecutiveCommittee.find(params[:id])\n @executive_committee.destroy\n\n respond_to do |format|\n format.html { redirect_to(executive_committees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @commit = Commit.find(params[:id])\n @co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /journals GET /journals.xml | def index
@journals = Journal.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @journals }
end
end | [
"def index\n @journals = @book.journals\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @journals }\n end\n end",
"def index\n @journals = Journal.all\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /journals/1 DELETE /journals/1.xml | def destroy
@journal = Journal.find(params[:id])
@journal.destroy
respond_to do |format|
format.html { redirect_to(journals_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @journal = @book.journals.find(params[:id])\n @journal.destroy\n\n respond_to do |format|\n format.html { redirect_to( @book ) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @journal.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(journals_u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Color used for creating the legend. Defaults to the marker_fill_color but will use the marker_border_color if marker_fill_color does not exist (for example for hollow circles). | def color
@marker_fill_color || @marker_border_color || :default
end | [
"def color= color\n @marker_fill_color = color\n @marker_border_color = color\n end",
"def legend_color_new_payer_list\n if @payer_ids_under_processing.include?@new_payer\n color = 'red'\n else\n color = 'white'\n end\n color\n end",
"def legend=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set both marker_fill_color and marker_border_color to the same color. | def color= color
@marker_fill_color = color
@marker_border_color = color
end | [
"def color\n @marker_fill_color || @marker_border_color || :default\n end",
"def setmarkercolorind(*)\n super\n end",
"def set_border_color(color)\n set_bottom_color(color)\n set_top_color(color)\n set_left_color(color)\n set_right_color(color)\n end",
"def setMarkerColorL... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Triggers a scheduled build for the job supplied | def trigger_build_for_job(job, params = {})
raise RuntimeError,
"No Jenkins client is available" if @jenkins_client.nil?
raise RuntimeError,
"Jenkins client is not ready" unless @jenkins_client.ready
response = @jenkins_client.trigger_build_for_job(job, params)
# HTTP 302 ... | [
"def trigger_build_for_job(job, params = {})\n uri = URI(uri_for_job(job))\n \n body = nil\n\n if params.size > 0\n method = :post\n body = compile_jenkins_json(params)\n else\n method = :get\n end\n\n execute_http_request(method, uri, body)\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
load config from the config.xml | def load_config
if @type == :upload
config_file = "ul_config.xml"
else
config_file = "dl_config.xml"
end
doc = Nokogiri::XML(open("config/#{config_file}"))
doc.search(@type.to_s).each do |config|
@config_map[:ip] = get_content config, "ip"
@config_map[:port]... | [
"def config_load(config); end",
"def load\n return unless configFile.file.exists?\n load_values_from_xml(File.read(configFile.file.canonicalPath))\n end",
"def load_config\n self.datastore.from_file(Msf::Config.config_file, self.refname)\n end",
"def xml_config_read!\r\n @ndev.rpc.ge... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If no one remembered the page title, no worries | def check_title
@page_title = "FauxTwitter"
end | [
"def check_title\n if self.title.blank? && st = (url && Site.by_link(self.url))\n self.title = (st.yield :Title, st.sampleURL)[:Title] || \"\"\n self.title = self.trimmed_title\n else\n self.title\n end\n end",
"def page_title?\n @_page_title.present?\n end",
"def page_title_set... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /category_programs GET /category_programs.json | def index
@category_programs = CategoryProgram.all
end | [
"def get_all_apps_with_categories \n get(\"/appcon.json/\")\nend",
"def get_apps_by_category(args = {}) \n get(\"/appcon.json/apps/#{args[:category]}\", args)\nend",
"def get_appcon_categories \n get(\"/appcon.json/categories\")\nend",
"def get_all_apps_with_categories \n get(\"/appcon.json/\")\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /category_programs POST /category_programs.json | def create
@category_program = CategoryProgram.new(category_program_params)
respond_to do |format|
if @category_program.save
format.html { redirect_to @category_program, notice: 'Category program was successfully created.' }
format.json { render :show, status: :created, location: @categor... | [
"def create\n @program = current_codabra.programs.new(params[:program])\n\n respond_to do |format|\n if @program.save\n format.html { redirect_to @program, notice: 'Program was successfully created.' }\n format.json { render json: @program, status: :created, location: @program }\n else... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /category_programs/1 PATCH/PUT /category_programs/1.json | def update
respond_to do |format|
if @category_program.update(category_program_params)
format.html { redirect_to @category_program, notice: 'Category program was successfully updated.' }
format.json { render :show, status: :ok, location: @category_program }
else
format.html { ren... | [
"def update\n @program_category = ProgramCategory.find(params[:id])\n\n respond_to do |format|\n if @program_category.update_attributes(params[:program_category])\n flash[:notice] = 'ProgramCategory was successfully updated.'\n format.html { redirect_to(@program_category) }\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /category_programs/1 DELETE /category_programs/1.json | def destroy
@category_program.destroy
respond_to do |format|
format.html { redirect_to category_programs_url, notice: 'Category program was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @program_category = ProgramCategory.find(params[:id])\n @program_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(program_categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @collection_program.destroy\n respond_to do |format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Registering this ORM lets the user choose sequel as a session store in merb.yml's session_store: option. | def register_session_type
Merb.register_session_type(
"sequel",
"merb/session/sequel_session",
"Using Sequel database sessions"
)
end | [
"def open_session(sequel, scope = nil)\n @container.register_instance(sequel, :sequel)\n\n register_session(scope)\n @container.resolve(:jet_set)\n end",
"def use_db_sessions\n remove_file \"config/initializers/session_store.rb\"\n create_file \"config/initializers/session_store.rb\", <<-E... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read the history from memory | def history
@memory.rewind
@memory.read
end | [
"def history_retrieve()\n lines = []\n open(HISTORY_FILENAME, 'a+') do |fh|\n while line = fh.gets\n lines.push line.strip\n end\n end\n limit = [ lines.length, MAX_HISTORY ].min\n lines[-limit .. -1].each { |line| Readline::HISTORY.push line }\nrescue => e\n STDERR.puts \"Error encountered when re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gives us the SVG transform() property, based on object's rotate value | def transform
if rotate
"rotate(#{rotate},#{x},#{y})"
else
nil
end
end | [
"def get_transform_attribute\n # transformations = [self.apply_scale, self.apply_translate, self.apply_rotate]\n transformations = []\n transformations += @transformations.dup\n transformations.push(\"scale(#{@xscale} #{@yscale})\")\n transformations.push(self.anchor_translate)\n attr ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
doing indicator.destroy takes a long time due to all the indciators and data this method will be quicker for it uses delete instead of destroy when there can be lots of records to delete | def destroy
puts "deleting event indicators and data"
Datum.where(indicator_id: self.id).delete_all
scales = IndicatorScale.where(indicator_id: self.id)
if scales.present?
IndicatorScaleTranslation.where(indicator_scale_id: scales.map{|x| x.id}).delete_all
scales.delete_all
end
puts... | [
"def remove_indicators\r\n @indicator1.destroy\r\n @indicator2.destroy\r\n @indicator3.destroy\r\n @indicator4.destroy\r\n @indicator5.destroy\r\n end",
"def remove_indicator_resources\r\n @indicator1_comm_dumm.destroy\r\n @indicator2_pub_speak.destroy\r\n @indicator3_pu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Publishes the database and awaits until it is fully available. If the table already exists, it only adjusts the read and write capacities upwards (it doesn't downgrade them to avoid a production environment being impacted with a default setting of an automated script). Arguments [table_name] The table name of the dynam... | def publish_database(table_name, attribute_definitions, key_schema, read_capacity, write_capacity)
has_updates = false
# figure out whether the table exists
begin
table_details = @client.describe_table(table_name: table_name).table
rescue Aws::DynamoDB::Errors::ResourceNotFoundException... | [
"def publish_database(\n table_name, attribute_definitions, key_schema, read_capacity, write_capacity, local_secondary_indexes = nil,\n global_secondary_indexes = nil\n )\n has_updates = false\n\n table_details = get_table_details(table_name)\n\n if !table_details.nil?\n wait_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin GOAL: For each director, find their :movies Array and stick it in a new Array INPUT: source: An Array of Hashes containing director info including :name and :movies RETURN: AoA's containing all of a director's movies. Each movie will need to have a :director_name key added to it. =end | def movies_with_directors_set(source)
result = []
i = 0
while i < source.length do
dir_name = source[i][:name]
dir_movies = source[i][:movies]
result << movies_with_director_key(dir_name, dir_movies)
end
result
end | [
"def movies_with_director_key(name, movies_collection)\n mwd_aoh = []\n index = 0\n while index < movies_collection.length do\n mindex = 0\n while mindex < movies_collection[index][:movies].length do\n movie_name = movies_collection[index][:movies][mindex]\n mwd_aoh << movie_with_director_name(na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use unix fortune by shelling out | def fortune(bot)
fortune = `#{@config[:fortune_cmd]}`
fortune.gsub!("\n", "; ")
fortune.gsub!("\t", " ")
bot.say(fortune)
end | [
"def fortune(m)\n db = \"fortunes\"\n fortune = nil\n [\"/usr/games/fortune\", \"/usr/bin/fortune\", \"/usr/local/bin/fortune\"].each {|f|\n if FileTest.executable? f\n fortune = f\n break\n end\n }\n m.reply \"fortune binary not found\" unless fortune\n ret = Utils.safe_ex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add Main Commands to List | def add_main_commands
add_command(Vocab::item, :item, main_commands_enabled)
add_command(Vocab::skill, :skill, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command(Vocab::status, :status, main_commands_enabled)
end | [
"def add_main_commands\n add_command(Vocab::item, :item, main_commands_enabled)\n add_command(Vocab::skill, :skill, main_commands_enabled)\n add_command(Vocab::equip, :equip, main_commands_enabled)\n add_command(Vocab::status, :status, main_commands_enabled)\n end",
"def make_command_list\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add Formation to Command List | def add_formation_command
add_command(Vocab::formation, :formation, formation_enabled)
end | [
"def make_command_list\n add_command(nil, :name)\n add_command(nil, :title)\n end",
"def add_command_list(command_list)\n command_list.each do |k, v|\n type = v[:type]\n providedby = v[:providedby] || 'app'\n if $abst_commands[k].nil?\n if type == 'transit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For Adding Original Commands | def add_original_commands
end | [
"def add_original_commands; end",
"def after_create_commands(lib, commands); end",
"def add_custom_commands\n CustomCommand.all.each do |command|\n add_custom_command(command)\n end\n end",
"def def_extend_command(cmd_name, cmd_class, load_file, *aliases); end",
"def process_commands; en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add Save to Command List | def add_save_command
add_command(Vocab::save, :save, save_enabled)
end | [
"def add_save_command\n add_command(Vocab::save, :save, \"Menu_Save\", save_enabled?, nil, Vocab::SaveDec)\n end",
"def save!\n @shell_file.exports = @commands\n @shell_file.write!\n end",
"def command_save\r\n @database.save\r\n @log.save\r\n end",
"def save_save_list\n save_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add Exit Game to Command List | def add_game_end_command
add_command(Vocab::game_end, :game_end)
end | [
"def add_game_end_command\n end",
"def add_game_end_command\n add_command(Vocab::game_end, :game_end, \"Menu_System\", true, nil, Vocab::SystemDec)\n end",
"def command_exit\n # Play decision SE\n $game_system.se_play($data_system.cancel_se)\n # Exit to menu\n $scene = Scene_Menu.new(5)\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
int binarySearch(int arr[], int l, int r, int x) | def binarySearch(arr, l, r, x)
if r >= l
mid = l + (r - l) / 2
# // If the element is present at the middle itself
return mid if (arr[mid] == x)
# // If element is smaller than mid, then it can only be present in left subarray
# // Else the element can only be present in right subarray
(arr[mi... | [
"def binary_search(arr, l, r, x)\n if r >= l\n mid = l + (r - l)\n\n # If the element is present\n # at the middle itself\n if arr[mid] == x\n return mid\n end\n\n # If element is smaller than\n # mid, then it can only be\n # present in left subarray\n\n if arr[mid] > x\n retur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def binary_search(arr, l, r, target) if l target) ? binary_search(arr, l, mid 1, target) : binary_search(arr, mid + 1, r, target) end 1 end def binary_search(arr, l, r, target) return 1 if l > r mid = l + (r l) / 2 return mid if (arr[mid] == target) Found match! (arr[mid] > target) ? binary_search(arr, l, mid 1, target... | def binary_search(arr, l, r, target)
return [-1, l, r] if l > r
mid = l + (r - l) / 2
return [mid, l, r] if (arr[mid] == target) # Found match!
(arr[mid] > target) ? binary_search(arr, l, mid - 1, target) : binary_search(arr, mid + 1, r, target)
end | [
"def binary_search(target, array)\r\n\t# index = 0\r\n\t# # mid = index\r\n\t# mid = array.length / 2\r\n\r\n\t# while array[mid] == target\r\n\t# \treturn mid\r\n\r\n\t# \tif target < array[mid]\r\n\t# \t\tmid2= (array[0..mid].length)/2\r\n\r\n\t# \t\tif array[mid2] == target\r\n\t# \t\t\treturn mid2\r\n\t# \t\tel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is the provision method called if Windows OpenSSH is what is running on the remote end, which assumes a nonPOSIXstyle host. | def provision_winssh(args)
with_script_file do |path|
# Upload the script to the machine
@machine.communicate.tap do |comm|
env = config.env.map{|k,v| comm.generate_environment_export(k, v)}.join
upload_path = config.upload_path.to_s
if File.extname(upload... | [
"def configure_ssh(vm)\n vm.provision \"shell\", inline: <<-SHELL\n mkdir -p /home/vagrant/.ssh\n rm -rf /home/vagrant/.ssh/id_rsa*\n chown vagrant:vagrant /home/vagrant/.ssh\n SHELL\n vm.provision \"file\", source: '~/.ssh/id_rsa', destination: '~/.ssh/id_rsa'\n vm.provision \"file\", source: '~/.ssh/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This provisions using WinRM, which assumes a PowerShell console on the other side. | def provision_winrm(args)
if @machine.guest.capability?(:wait_for_reboot)
@machine.guest.capability(:wait_for_reboot)
end
with_script_file do |path|
@machine.communicate.tap do |comm|
# Make sure that the upload path has an extension, since
# having a... | [
"def create_shell\n host_address = Helper.winrm_address(@machine)\n host_port = Helper.winrm_port(@machine)\n\n WinRMShell.new(\n host_address,\n @machine.config.winrm.username,\n @machine.config.winrm.password,\n port: host_port,\n timeout_in_sec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method yields the path to a script to upload and execute on the remote server. This method will properly clean up the script file if needed. | def with_script_file
ext = nil
script = nil
if config.remote?
download_path = @machine.env.tmp_path.join(
"#{@machine.id}-remote-script")
download_path.delete if download_path.file?
begin
Vagrant::Util::Downloader.new(
conf... | [
"def with_script_file\n script = nil\n\n if config.remote?\n download_path = @machine.env.tmp_path.join(\"#{@machine.id}-remote-script\")\n download_path.delete if download_path.file?\n\n Vagrant::Util::Downloader.new(config.path, download_path).download!\n script =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an image file, checks to see if the image exists in the filesystem. If it does, display the image. If not, suppress the generation of the image tag. Used to add modelspecific icons to the UI. If the icon does not exist, ensures no broken image tag or alternate text is rendered to the page. | def image_tag_if_exists(image, options = {})
image_tag(image, options) if(File.exist?File.join(STREAMLINED_RAILS_ROOT, 'public', 'images', image))
end | [
"def fq_show_icon(item)\n if item.file?\n image = \"fq_icons/\" + item.filetype + \".png\"\n if File.exists?(Rails.public_path + \"/images/\" + image)\n image_tag(image)\n else\n image_tag(\"fq_icons/_blank.png\")\n end\n elsif item.dir?\n image_tag(\"fq_icons/folder.png... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes an entry in the 'locale=' format and transforms it to a specific locale | def transform_to_locale(entry, locale)
# If the backing store already returned a localized entry, nothing to do
if entry_locale = entry.dig('sys', 'locale')
unless entry_locale == locale
raise WCC::Contentful::LocaleMismatchError,
"expected #{locale} but was #{entry_locale}"
end
... | [
"def apply_locale; end",
"def to_google_translate_compatible_locale(locale); end",
"def locale_from_params\n if params[:locale] && Utility.active_short_locales.include?(params[:locale].to_sym)\n return Utility.short_to_long_locale(params[:locale])\n end\n end",
"def localize(object, locale: T.unsa... | {
"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.