query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
DELETE /adversaires/1 DELETE /adversaires/1.json
def destroy @equipe = Equipe.find(params[:equipe_id]) @adversaire = Adversaire.find(params[:id]) @adversaire.destroy respond_to do |format| format.html { redirect_to @equipe } format.json { head :no_content } end end
[ "def destroy\n @serv_adicionale = ServAdicionale.find(params[:id])\n @serv_adicionale.destroy\n\n respond_to do |format|\n format.html { redirect_to serv_adicionales_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ventaunidad.destroy\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reconfigures the provided option, setting its value to `value`.
def call(value) Datadog.logger.debug { "Reconfigured tracer option `#{@setting_key}` with value `#{value}`" } if value.nil? # Restore the local configuration value configuration_object.unset_option( @setting_key, precedence: Core::Conf...
[ "def []=(config_option, value)\n internal_set(config_option,value)\n end", "def configure_setting(name, value)\n configure do |settings|\n settings.unset!(name)\n settings[name] = parse_setting(settings.setting(name), value)\n end\n end", "def update_option(opt, val)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
getter that will increment the next_bib value in the database and return the result
def next_bib self[:next_bib] = self[:next_bib] + 1 end
[ "def next_bib\n self.inc(:next_bib=>1)\n self[:next_bib]\n end", "def next_bib\n self[:next_bib] = self.inc(next_bib: 1)[:next_bib]\n\tend", "def next_bib\n #don't use next_bib to access use [:next_bib] as this would be a infinite recursive back into this method\n self.inc(next_bib:1)\n self[:next_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns a Placing instance with its name set to the name of the age group the racer will be competing in
def get_group racer if racer && racer.birth_year && racer.gender quotient=(date.year-racer.birth_year)/10 min_age=quotient*10 max_age=((quotient+1)*10)-1 gender=racer.gender name=min_age >= 60 ? "masters #{gender}" : "#{min_age} to #{max_age} (#{gender})" Placing.demongoize(:name...
[ "def get_group racer\n if racer && racer.birth_year && racer.gender\n quotient = (date.year-racer.birth_year)/10\n min_age = quotient*10\n max_age = ((quotient+1)*10)-1\n gender = racer.gender\n name = min_age >= 60 ? \"masters #{gender}\" : \"#{min_age} to #{max_age} (#{gender})\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create a new Entrant for the Race for a supplied Racer
def create_entrant racer # build a new Entrant entrant = Entrant.new { |r| # clone the relevant Race information within Entrant.race r.build_race(self.attributes.symbolize_keys.slice(:_id, :n, :date)) # clone the RaceInfo attributes within Entrant.racer r.build_racer(racer.info.attribut...
[ "def create_entrant racer\n e = Entrant.new\n e.build_race(self.attributes.symbolize_keys.slice(:_id, :n, :date))\n e.build_racer(racer.info.attributes)\n e.group = get_group(racer)\n\n # Create a result for every Race event\n DEFAULT_EVENTS.each do |name, attrs|\n e.send(\"#{name}=\", attrs)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /evaluaciones/1 GET /evaluaciones/1.xml
def show @evaluacione = Evaluacione.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @evaluacione } end end
[ "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def show\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /evaluaciones/new GET /evaluaciones/new.xml
def new @evaluacione = Evaluacione.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @evaluacione } end end
[ "def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def new\n @evaluacion = Evaluacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /evaluaciones POST /evaluaciones.xml
def create @evaluacione = Evaluacione.new(params[:evaluacione]) respond_to do |format| if @evaluacione.save format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') } format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacio...
[ "def create\n @evaluacion = Evaluacion.new(params[:evaluacion])\n\n respond_to do |format|\n if @evaluacion.save\n format.html { redirect_to @evaluacion, notice: 'Evaluacion was successfully created.' }\n format.json { render json: @evaluacion, status: :created, location: @evaluacion }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /evaluaciones/1 PUT /evaluaciones/1.xml
def update @evaluacione = Evaluacione.find(params[:id]) respond_to do |format| if @evaluacione.update_attributes(params[:evaluacione]) format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully updated.') } format.xml { head :ok } else format.html { re...
[ "def update\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n if @evaluacion.update_attributes(params[:evaluacion])\n format.html { redirect_to @evaluacion, notice: 'Evaluacion was successfully updated.' }\n format.json { head :no_content }\n else\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /evaluaciones/1 DELETE /evaluaciones/1.xml
def destroy @evaluacione = Evaluacione.find(params[:id]) @evaluacione.destroy respond_to do |format| format.html { redirect_to(evaluaciones_url) } format.xml { head :ok } end end
[ "def destroy\n @evaluacion = Evaluacion.find(params[:id])\n @evaluacion.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluaciones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluacion = Evaluacion.find(params[:id])\n @evaluacion.destroy\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
All the graph statements except hasModel and those with missing objects
def statements graph.statements.reject { |stmt| predicate_blacklist.include?(stmt.predicate) || missing_object?(stmt) } end
[ "def graphobj?; false end", "def graph_obj?() true end", "def graph_prerequisites\n end", "def local_graphs; end", "def task_relation_graph_for(model)\n task_relation_graphs.fetch(model)\n end", "def graph?\n false\n end", "def visualize\n graph = ::GraphViz.new(:G, :t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the number of items on the current page. page_index is zero based. this method should return 1 for page_index values that are out of range
def page_item_count(page_index) return -1 if page_index > @collection[-1] || page_index < 0 @collection.count {|v| v == page_index} end
[ "def page_item_count(page_index)\n return -1 if page_index < 0 || page_index >= self.page_count\n @pages[page_index].count\n end", "def page_item_count(page_index)\n page = @layout.pages[page_index]\n return -1 unless page && page_index >= 0\n page.items.length\n end", "def page_item_count(page...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determines what page an item is on. Zero based indexes. this method should return 1 for item_index values that are out of range
def page_index(item_index) return -1 if !(item_index < item_count) || item_index < 0 @collection[item_index] end
[ "def page_index(item_index) \n return -1 if !(item_index < item_count) || item_index < 0\n @collection[item_index]\n end", "def page_index(item_index)\n return -1 if item_index < 0 || item_index >= self.item_count\n location = item_index.divmod @items_per_page\n location[0]\n end", "def p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Implements the ids reader method, e.g. foo.item_ids for Foo.indirectly_contains :items, ...
def ids_reader predicate = reflection.options.fetch(:has_member_relation) if loaded? target.map(&:id) else owner.resource.query({ predicate: predicate }) .map { |s| ActiveFedora::Base.uri_to_id(s.object) } | target.map(&:id) end end
[ "def ids_reader; end", "def ids_reader\n reader\n @target.map(&:id)\n end", "def ids_getter(name, metadata)\n ids_method = \"#{name.to_s.singularize}_ids\"\n re_define_method(ids_method) do\n send(name).only(:id).map(&:id)\n end\n self\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Conditionals Checks to see if a TLVs meta type is equivalent to the meta type passed.
def meta_type?(meta) return (self.type & meta == meta) end
[ "def meta_type?(meta)\n return (self.type & meta == meta)\n end", "def has_tlv?(type)\n get_tlv(type) != nil\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def is_metatag?(name, value = nil)\n if value.nil?\n metatag? && has_metatag?(name)\n else\n metatag? && f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks to see if the TLVs value is equivalent to the value passed.
def value?(value) return self.value == value end
[ "def value?(value)\n return self.value == value\n end", "def value?(value)\n Vpim::Methods.casecmp?(@value, value.to_str)\n end", "def eq_packed(value)\n # Compare the bytes in each string.\n # Byte comparison *must* be used, since == uses character comparison.\n # Bytes != characters ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Serializers Converts the TLV to raw.
def to_r raw = value.to_s; if (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING) raw += "\x00" elsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT) raw = [value].pack("N") elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL) if (value == true) raw = [1].pack("c") else ...
[ "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Groupbased TLV accessors Enumerates TLVs of the supplied type.
def each(type = TLV_TYPE_ANY, &block) get_tlvs(type).each(&block) end
[ "def each(type = TLV_TYPE_ANY, &block)\n get_tlvs(type).each(&block)\n end", "def each_with_index(type = TLV_TYPE_ANY, &block)\n get_tlvs(type).each_with_index(&block)\n end", "def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend", "def get_tlvs(type)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Enumerates TLVs of a supplied type with indexes.
def each_with_index(type = TLV_TYPE_ANY, &block) get_tlvs(type).each_with_index(&block) end
[ "def each_with_index(type = TLV_TYPE_ANY, &block)\n get_tlvs(type).each_with_index(&block)\n end", "def each(type = TLV_TYPE_ANY, &block)\n get_tlvs(type).each(&block)\n end", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def get_tlv(type, index = 0)\n type_tlvs ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array of TLVs for the given type.
def get_tlvs(type) if (type == TLV_TYPE_ANY) return self.tlvs else type_tlvs = [] self.tlvs.each() { |tlv| if (tlv.type?(type)) type_tlvs << tlv end } return type_tlvs end end
[ "def get_tlvs(type)\n if type == TLV_TYPE_ANY\n self.tlvs\n else\n type_tlvs = []\n\n self.tlvs.each() { |tlv|\n if (tlv.type?(type))\n type_tlvs << tlv\n end\n }\n\n type_tlvs\n end\n end", "def get_tlv_values(type)\n get_tlvs(type).collect { |a| a.val...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the first TLV of a given type.
def get_tlv(type, index = 0) type_tlvs = get_tlvs(type) if (type_tlvs.length > index) return type_tlvs[index] end return nil end
[ "def get_tlv(type, index = 0)\n type_tlvs = get_tlvs(type)\n\n if type_tlvs.length > index\n type_tlvs[index]\n else\n nil\n end\n\n end", "def get_tlv_value(type, index = 0)\n tlv = get_tlv(type, index)\n\n (tlv != nil) ? tlv.value : nil\n end", "def get_tlv_value(type, index = 0)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the value of a TLV if it exists, otherwise nil.
def get_tlv_value(type, index = 0) tlv = get_tlv(type, index) return (tlv != nil) ? tlv.value : nil end
[ "def get_tlv_value(type, index = 0)\n tlv = get_tlv(type, index)\n\n (tlv != nil) ? tlv.value : nil\n end", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks to see if the container has a TLV of a given type.
def has_tlv?(type) return get_tlv(type) != nil end
[ "def has_tlv?(type)\n get_tlv(type) != nil\n end", "def has_encounter_type?(enc_type)\r\n return false if !enc_type\r\n return @encounter_tables[enc_type] && @encounter_tables[enc_type].length > 0\r\n end", "def check_type(type)\n %w{galera mysql}.each do |t|\n return true if t == type\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts the TLV group container from raw to all of the individual TLVs.
def from_r(raw) offset = 8 # Reset the TLVs array self.tlvs = [] self.type = raw.unpack("NN")[1] # Enumerate all of the TLVs while (offset < raw.length-1) tlv = nil # Get the length and type length, type = raw[offset..offset+8].unpack("NN") if (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GR...
[ "def from_r(raw)\n offset = HEADER_SIZE\n\n # Reset the TLVs array\n self.tlvs = []\n self.type = raw.unpack(\"NN\")[1]\n\n # Enumerate all of the TLVs\n while offset < raw.length-1\n\n tlv = nil\n\n # Get the length and type\n length, type = raw[offset..offset+HEADER_SIZE].unpack(\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Constructor Initializes the packet to the supplied packet type and method, if any. If the packet is a request, a request identifier is created.
def initialize(type = nil, method = nil) super(type) if (method) self.method = method end self.created_at = ::Time.now # If it's a request, generate a random request identifier if ((type == PACKET_TYPE_REQUEST) || (type == PACKET_TYPE_PLAIN_REQUEST)) rid = '' 32.times { |val| rid << rand(...
[ "def initialize(type = nil, method = nil)\n super(type)\n\n if method\n self.method = method\n end\n\n self.created_at = ::Time.now\n self.raw = ''\n\n # If it's a request, generate a random request identifier\n if ((type == PACKET_TYPE_REQUEST) ||\n (type == PACKET_TYPE_PLAIN_REQUE...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Conditionals Checks to see if the packet is a response.
def response? return ((self.type == PACKET_TYPE_RESPONSE) || (self.type == PACKET_TYPE_PLAIN_RESPONSE)) end
[ "def response?\n (self.type == PACKET_TYPE_RESPONSE || self.type == PACKET_TYPE_PLAIN_RESPONSE)\n end", "def response?\n @bytes[2] == Message::RESPONSE\n end", "def response_handler(client, packet)\n\t\treturn false\n\tend", "def command_response?\n type == :command_response\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Accessors Checks to see if the packet's method is equal to the supplied method.
def method?(method) return (get_tlv_value(TLV_TYPE_METHOD) == method) end
[ "def method?(method)\n (get_tlv_value(TLV_TYPE_COMMAND_ID) == method)\n end", "def method?(name)\n method_name == name.to_sym\n end", "def eql?(other_meth)\n #This is a stub, used for indexing\n end", "def method=(method)\n method = method.downcase.to_sym\n\n @method = meth...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the packet's method TLV to the method supplied.
def method=(method) add_tlv(TLV_TYPE_METHOD, method, true) end
[ "def method=(method)\n raise ArgumentError.new(\"Packet.method must be an integer. Current value is #{method}\") unless method.is_a?(Integer)\n add_tlv(TLV_TYPE_COMMAND_ID, method, true)\n end", "def method=(value)\n @method = value\n end", "def method=(meth)\n meth = meth....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the value of the packet's method TLV.
def method return get_tlv_value(TLV_TYPE_METHOD) end
[ "def method\n get_tlv_value(TLV_TYPE_COMMAND_ID)\n end", "def method=(method)\n\t\tadd_tlv(TLV_TYPE_METHOD, method, true)\n\tend", "def method\n return @method\n end", "def method=(method)\n raise ArgumentError.new(\"Packet.method must be an integer. Current value is #{method}...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks to see if the packet's result value is equal to the supplied result.
def result?(result) return (get_tlv_value(TLV_TYPE_RESULT) == result) end
[ "def result?(result)\n (get_tlv_value(TLV_TYPE_RESULT) == result)\n end", "def equals(result, value)\n status = 2\n status = 0 if result.to_f == value.to_f\n status\n end", "def is_perfect_guess?(gameResult)\n return true if self.result.present? and self.result == gameRe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the packet's result TLV.
def result=(result) add_tlv(TLV_TYPE_RESULT, result, true) end
[ "def result=(result)\n add_tlv(TLV_TYPE_RESULT, result, true)\n end", "def result\n get_tlv_value(TLV_TYPE_RESULT)\n end", "def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend", "def set_result(result) #:nodoc:\n @result = result\n end", "def result=( result )\n set_result( r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the value of the packet's result TLV.
def result return get_tlv_value(TLV_TYPE_RESULT) end
[ "def result\n get_tlv_value(TLV_TYPE_RESULT)\n end", "def read_result_packet\n ResultPacket.parse read\n end", "def get_result\n\n @attributes[FIELD_RESULT]\n end", "def result=(result)\n add_tlv(TLV_TYPE_RESULT, result, true)\n end", "def result=(result)\n\t\tadd_tlv(TLV_TYPE_RESULT...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the value of the packet's request identifier TLV.
def rid return get_tlv_value(TLV_TYPE_REQUEST_ID) end
[ "def rid\n get_tlv_value(TLV_TYPE_REQUEST_ID)\n end", "def request_id\n @error['request_id']\n end", "def get_request_id\n request_id = ''\n @id_lock.synchronize do\n request_id = @@current_request_id += 1\n end\n request_id\n end", "def request_id\n if metadata ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Predicate for the disable_rake_compiler attribute.
def disable_rake_compiler? return self.disable_rake_compiler ? true :false end
[ "def has_rakecompiler_dependency?\n\t\treturn self.dependencies.any? do |dep|\n\t\t\tdep.name == 'rake-compiler'\n\t\tend\n\tend", "def disable_should(syntax_host = T.unsafe(nil)); end", "def enable_should(syntax_host = T.unsafe(nil)); end", "def should_enabled?(syntax_host = T.unsafe(nil)); end", "def agen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns +true+ if there appear to be extensions as part of the current project.
def extensions_present? return !self.extensions.empty? end
[ "def missing_extensions?\n return false if extensions.empty?\n return false if default_gem?\n return false if File.exist? gem_build_complete_path\n\n true\n end", "def core_extensions?\n false\n end", "def extensions_installed?\n !@extensions.empty?\n end", "def extension?\n !e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set up the tasks to build extensions.
def define_extension_tasks ENV['RUBY_CC_VERSION'] ||= RUBY_VERSION[ /(\d+\.\d+)/ ] require 'rake/extensiontask' self.extensions.each do |extconf| Rake::ExtensionTask.new( extconf.pathmap('%{ext/,}d') ) end task :spec => :compile task :maint do ENV['V'] = '1' ENV['MAINTAINER_MODE'] = 'yes' end ...
[ "def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end", "def define_extensions\n desc \"Overwrite the ext/Setup file\"\n task :extensions => \"#{name}:patch\" do\n logger.info \"Rewriting ext/Setup file\"\n File.open( ext_setup_file, \"w\") do |f|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns +true+ if the projects dependencies include `rakecompiler`.
def has_rakecompiler_dependency? return self.dependencies.any? do |dep| dep.name == 'rake-compiler' end end
[ "def disable_rake_compiler?\n\t\treturn self.disable_rake_compiler ? true :false\n\tend", "def compilation?\n is_compilation\n end", "def depends_on?(project)\r\n depends_directly_on?(project) || depends_indirectly_on?(project)\r\n end", "def rake_installed?\n raise 'you haven\\'t installed...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Task function output debugging for extension tasks.
def do_extensions_debug( task, args ) self.prompt.say( "Extension config scripts:", color: :bright_green ) if self.extensions.empty? self.prompt.say "None." else self.extensions.uniq.each do |path| self.prompt.say "- %s" % [ path ] end end if self.has_rakecompiler_dependency? self.prompt.say...
[ "def print_task(task)\n puts format_task(task) if @verbose\n end", "def print_task(task)\n print \"==> \".info, task.bold, \"\\n\"\nend", "def print_task_info(task:)\n path = task.files.first['path'].chomp(\"/tasks/#{task.files.first['name']}\")\n module_dir = if path.start_with?(Bolt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Receives a view and update it accordingly with the given object id and the association cardinality.
def update(view, object) raise NotImplementedError end
[ "def record_view\n self.views += 1\n save\n end", "def update\n @view = View.find(params[:id])\n\n respond_to do |format|\n if @view.update_attributes(params[:view])\n format.html { redirect_to @view, notice: 'View was successfully updated.' }\n format.json { head :no_content }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Includes this module into a Class, and changes all public methods to protected. Examples: module MyCoolUtils def some_meth "hi" end self.include_safely_into(FooController) end or: MyCoolUtils.include_safely_into(FooController, SomeOtherClass)
def include_safely_into(*args) [args].flatten.each do |a| if a.is_a?(String) || a.is_a?(Symbol) a = a.to_s.constantize end a.send(:include, self.convert_security_of_methods) end end
[ "def inherited(klass)\n super\n klass.send :include, ::Henshin::Safety\n klass.instance_variable_set(:@unsafe_methods, @unsafe_methods)\n end", "def safely_include_module(*modules)\n [modules].flatten.each do |mod|\n mod.include_safely_into(self)\n end\n end", "def unsecure...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
... and delegate "everything else" via method_missing, taking care that a nil card template isn't a problem
def method_missing(name, *args, &block) respond_to_missing?(name) ? card_template.andand.send(name, *args, &block) : super end
[ "def method_missing(method, *args, &block)\n if CARD_METHODS.include?(method)\n @card.send(method, *args, &block)\n else\n super\n end\n end", "def card_detection\n end", "def play_card\n raise 'TODO: implement me!' # TODO: implement this\n end", "def hcard_for(object, opt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
By this point, we assume ScheduleMergeRequestDiffMigrations the first version of this has already run. On GitLab.com, we have ~220k unmigrated rows, but these rows will, in general, take a long time. With a gap of 10 minutes per batch, and 500 rows per batch, these migrations are scheduled over 220_000 / 500 / 6 ~= 74 ...
def up queue_background_migration_jobs_by_range_at_intervals(MergeRequestDiff, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) end
[ "def find_migration_tuples # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity\n up_mts = []\n down_mts = []\n files.each do |path|\n f = File.basename(path)\n fi = f.downcase\n if target\n if migration_version_from_file(f) > target\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a block to the BlockArgs object
def add(&block) @block_args << block end
[ "def on_args_add_block(args, block)\n ending = block || args\n\n args.merge(\n type: :args_add_block,\n body: [args, block],\n el: ending[:el],\n ec: ending[:ec]\n )\n end", "def on_args_add_block(arguments, block); end", "def define_block_argument(name)\n create_argument(:b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes a block to the BlockArgs object
def delete(&block) @block_args.delete(block) end
[ "def delete_hotel_block(hotel_block)\n hotel_blocks.delete(hotel_block)\n end", "def delete_block\n Block.destroy(params[:id])\n render :text => \"Block with ID #{params[:id]} was successfully destroyed.\"\n end", "def block_removed(block, data); end", "def destroy_block(&block)\n shrine_c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cpanel/tags GET /cpanel/tags.json
def index @cpanel_tags = Cpanel::Tag.all end
[ "def tagList()\n http, req = initReq(\"tags/\")\n JSON.parse(http.request(req).body)\nend", "def all_tags\n request(:get,\"/tags\")\n end", "def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end", "def tags\n\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /cpanel/tags/1 DELETE /cpanel/tags/1.json
def destroy @cpanel_tag.destroy respond_to do |format| format.html { redirect_to cpanel_tags_url } format.json { head :no_content } end end
[ "def delete_tag tag\n delete \"tag/#{tag}\"\n end", "def dropletDeleteByTag(tag)\n http, req = initReq(\"droplets?tag_name=#{tag}\", \"DELETE\")\n http.request(req).body\n tagCleanUp()\nend", "def destroy\n @tags_of_novel = TagsOfNovel.find(params[:id])\n @tags_of_novel.destroy\n\n respond_to do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /enrolls GET /enrolls.json
def index @enrolls = Enroll.all respond_to do |format| format.html # index.html.erb format.json { render json: @enrolls } end end
[ "def fetch_course_enrollments\n bad_request_error('Unauthorized Access to Course Enrollments') && return unless enrollment_course_tutor_or_admin?\n @enrollments = Enrollment.where(course_id: @course.id)\n # TODO: Add pagination, fetch only first 20 by default\n render json: @enrollments\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /enrolls/1 GET /enrolls/1.json
def show @enroll = Enroll.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @enroll } end end
[ "def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end", "def index\n @enrolls = Enroll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolls }\n end\n end", "def index\n @enrolls = Enroll.all\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /enrolls/1 DELETE /enrolls/1.json
def destroy @enroll = Enroll.find(params[:id]) @enroll.destroy respond_to do |format| format.html { redirect_to enrolls_url } format.json { head :no_content } end end
[ "def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end", "def destroy\n @enroll.destroy\n respond_to do |format|\n format.html { redirect_to enrolls_url, notice: 'Enroll was successfully destroyed.' }\n format.json {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the current fallbacks implementation. Use this to set a different fallbacks implementation. source://i18n//lib/i18n/backend/fallbacks.rb23
def fallbacks=(fallbacks); end
[ "def fallbacks=(fallbacks) \n @@fallbacks = fallbacks\n end", "def use_fallback(fallback)\n @fallback_to = fallback\n end", "def reset_i18n_fallbacks\n I18n.class_variable_set(:@@fallbacks, nil)\n end", "def languagefallback()\n merge(languagefallback: 'true')\n end", "def fa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Marks a key as reserved. Reserved keys are used internally, and can't also be used for interpolation. If you are using any extra keys as I18n options, you should call I18n.reserve_key before any I18n.translate (etc) calls are made. source://i18n//lib/i18n.rb45
def reserve_key(key); end
[ "def untrained_key_for(key)\n NO_VALID_KEY_PREFIX + key\n end", "def key_without_warning=(key)# :nodoc:\n @key = key\n end", "def i18n_key=(_arg0); end", "def negative_key\n @negative_key ||= 'losses'\n end", "def key=(new_key)\n new_key = nil if new_key.blank?\n super(new_key)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Accepts a list of paths to translation files. Loads translations from plain Ruby (.rb), YAML files (.yml), or JSON files (.json). See load_rb, load_yml, and load_json for details. source://i18n//lib/i18n/backend/base.rb14
def load_translations(*filenames); end
[ "def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n # rubocop:disable Style/StderrPuts\n $stderr.puts 'No valid translation file...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads a YAML translations file. The data must have locales as toplevel keys. source://i18n//lib/i18n/backend/base.rb251
def load_yml(filename); end
[ "def load_translations\n self.yaml_backend.load_translations\n end", "def load_translations\n @yaml_backend.load_translations\n end", "def load_yaml_locale(locale = I18n.locale, options = {})\n caching_options = ( ::ActionController::Base.perform_caching ? {} : { :force => true } )....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Resolves a translation. If the given subject is a Symbol, it will be translated with the given options. If it is a Proc then it will be evaluated. All other subjects will be returned directly. source://i18n//lib/i18n/backend/base.rb147
def resolve(locale, object, subject, options = T.unsafe(nil)); end
[ "def resolve_entry(locale, object, subject, options = T.unsafe(nil)); end", "def default(locale, object, subject, options = {})\n options = options.dup.reject { |key, value| key == :default }\n case subject\n when Array\n subject.count - 1\n subject.each do |item|\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Resolves a translation. If the given subject is a Symbol, it will be translated with the given options. If it is a Proc then it will be evaluated. All other subjects will be returned directly. source://i18n//lib/i18n/backend/base.rb147
def resolve_entry(locale, object, subject, options = T.unsafe(nil)); end
[ "def resolve(locale, object, subject, options = T.unsafe(nil)); end", "def default(locale, object, subject, options = {})\n options = options.dup.reject { |key, value| key == :default }\n case subject\n when Array\n subject.count - 1\n subject.each do |item|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Optionally provide path_roots array to normalize filename paths, to make the cached i18n data portable across environments. source://i18n//lib/i18n/backend/cache_file.rb11
def path_roots=(_arg0); end
[ "def relative_paths_cache=(_arg0); end", "def verify_locale_files!\n valid_cache = []\n new_cache = {}\n\n valid_cache.push cache_path.exist?\n valid_cache.push ::I18n.load_path.uniq.size == cache.size\n\n ::I18n.load_path.each do |path|\n changed_at = File.mtime(path)....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the value of attribute backends. source://i18n//lib/i18n/backend/chain.rb25
def backends; end
[ "def chain\n @chain ||= I18n.backend\n end", "def backends\n @backends ||= []\n end", "def backends\n @backends ||= Support::Registry.new\n end", "def backends=(_arg0); end", "def backends(service)\n out = Array.new\n # iterate the servers removing aggregates for FR...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the attribute backends
def backends=(_arg0); end
[ "def backend=(backend)\r\n @@backend = backend\r\n end", "def backend=(backend)\n @backend = backend&.to_sym\n set_encoder\n end", "def update_backend_attributes()\n backend = @attributes['backend']\n if BACKEND_ALIASES.has_key? backend\n backend = @attributes['backend'] = BACKEN...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Overwrite on_fallback to add specified logic when the fallback succeeds. source://i18n//lib/i18n/backend/fallbacks.rb110
def on_fallback(_original_locale, _fallback_locale, _key, _options); end
[ "def use_fallback(fallback)\n @fallback_to = fallback\n end", "def fallbacks=(fallbacks); end", "def languagefallback()\n merge(languagefallback: 'true')\n end", "def do_fallback action\n do_redirect fallback_path\n end", "def fallbacks=(fallbacks) \n @@fallbacks = fallbacks...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Receives a hash of translations (where the key is a locale and the value is another hash) and return a hash with all translations flattened. Nested hashes are included in the flattened hash just if subtree is true and Symbols are automatically stored as links. source://i18n//lib/i18n/backend/flatten.rb74
def flatten_translations(locale, data, escape, subtree); end
[ "def flatten_translations_for_all_locales(data)\n data.inject({}) do |result, key_value|\n begin\n key, value = key_value\n result.merge key => flatten_translations(key, value, true, false)\n rescue ArgumentError => ae\n log \"Error: #{ae}\", :error\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Shortcut to I18n::Backend::Flatten.normalize_flat_keys and then resolve_links. source://i18n//lib/i18n/backend/flatten.rb44
def normalize_flat_keys(locale, key, scope, separator); end
[ "def normalize_links!\n # TODO: normalize Array of Symbol, String, DM::Property 1-jump-away or DM::Query::Path\n end", "def flatten_translations(locale, data, escape, subtree); end", "def flatten_translations_for_all_locales(data)\n data.inject({}) do |result, key_value|\n begin\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
normalize_keys the flatten way. This method is significantly faster and creates way less objects than the one at I18n.normalize_keys. It also handles escaping the translation keys. source://i18n//lib/i18n/backend/flatten.rb20
def normalize_flat_keys(locale, key, scope, separator); end
[ "def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end", "def normalize_translation_keys(locale, key, scope) \n keys = [locale] + Array(scope) + [key] \n keys = keys.map do |k|\n k = k.to_s\n k['..'] ? ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if a filename is named in correspondence to the translations it loaded. The locale extracted from the path must be the single locale loaded in the translations.
def assert_file_named_correctly!(file, translations); end
[ "def translated?\n instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n end", "def has_file? name\n File.file? path / name\n end", "def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads each file supplied and asserts that the file only loads translations as expected by the name. The method returns a list of errors corresponding to offending files. source://i18n//lib/i18n/backend/lazy_loadable.rb152
def load_translations_and_collect_file_errors(files); end
[ "def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n # rubocop:disable Style/StderrPuts\n $stderr.puts 'No valid translation file...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Raises an InvalidLocale exception when the passed locale is not available. source://i18n//lib/i18n.rb349
def enforce_available_locales!(locale); end
[ "def validate_locale!(locale)\n raise Mobility::InvalidLocale.new(locale) unless Symbol === locale\n enforce_available_locales!(locale) if I18n.enforce_available_locales\n end", "def enforce_available_locales!(locale)\n raise Mobility::InvalidLocale.new(locale) unless (locale.nil? || available_l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the available locales. source://i18n//lib/i18n/config.rb57
def available_locales=(locales); end
[ "def setLocale\n if @lOptions.count\n @lOptions.each do | key, value |\n case key\n when :locale_group\n @lgrp = @@lOptions[:locale_group]\n when :locale_language\n @lang = @lOptions[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the available_locales have been initialized
def available_locales_initialized?; end
[ "def available?(locale)\n available.include?(locale.to_s)\n end", "def in_available_locales\n @tested_locales = I18n.available_locales\n self\n end", "def available_locales_set; end", "def available_locales\n init_names unless init_names?\n names.keys\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Caches the available locales list as both strings and symbols in a Set, so that we can have faster lookups to do the available locales enforce check. source://i18n//lib/i18n/config.rb50
def available_locales_set; end
[ "def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Clears the available locales set so it can be recomputed again after I18n gets reloaded. source://i18n//lib/i18n/config.rb70
def clear_available_locales_set; end
[ "def reset_locale_files\n @locale_files = []\n end", "def clear_missing_translations\n @missing_translations = []\n end", "def clear_all\n super\n\n @cache.each_pair do |name, entry|\n clear_entry(name, entry)\n end\n\n @cache = {}\n Puppet::Gettex...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current default scope separator. Defaults to '.' source://i18n//lib/i18n/config.rb75
def default_separator; end
[ "def separator\n @@default_separator\n end", "def current_scope\n !@scopes.empty? ? @scopes.join('/') : nil\n end", "def default_separator(value = nil)\n if value\n NamespaceMapper.invalidate\n NamespaceMapper.default_separator = Regexp.quote value\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the current default scope separator. source://i18n//lib/i18n/config.rb80
def default_separator=(separator); end
[ "def default_separator=(separator)\n @@default_separator = separator\n end", "def separator= separator\n @@default_separator = separator\n end", "def default_line_separator\n @def_line_sep ||= infer_line_separator\n end", "def default_separator(value = nil)\n if value\n Nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the exception handler. source://i18n//lib/i18n/config.rb91
def exception_handler=(exception_handler); end
[ "def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end", "def exception_handler=(exception_handler)\r\n @@exception_handler = ex...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current interpolation patterns. Defaults to I18n::DEFAULT_INTERPOLATION_PATTERNS. source://i18n//lib/i18n/config.rb151
def interpolation_patterns; end
[ "def interpolators()\n return @interpolators\n end", "def locales_pattern\n @@locales_pattern ||= %r(^/(#{self.locales.map { |l| Regexp.escape(l.to_s) }.join('|')})(?=/|$))\n end", "def patterns_for_file( file )\n Hash(config_file(file)[:patterns]).keys + \\\n Hash(defaults[:pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the load path instance. Custom implementations are expected to behave like a Ruby Array. source://i18n//lib/i18n/config.rb132
def load_path=(load_path); end
[ "def initialize_i18n\n configuration.i18n.each do |setting, value|\n if setting == :load_path\n I18n.load_path += value\n else\n I18n.send(\"#{setting}=\", value)\n end\n end\n end", "def load_translations\n super(@load_paths)\n end", "def configur...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current handler for situations when interpolation argument is missing. MissingInterpolationArgument will be raised by default. source://i18n//lib/i18n/config.rb97
def missing_interpolation_argument_handler; end
[ "def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end", "def call(missing_key, provided_hash, interpolated_string)\n exceptio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method signatures: npgettext('Fruits', 'apple', 'apples', 2) npgettext('Fruits', ['apple', 'apples'], 2) source://i18n//lib/i18n/gettext/helpers.rb61
def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end
[ "def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end", "def t(text);I18n.t(text);end", "def t(*args)\n I18n.translate(*args)\n end", "def t(...)\n ::I18n::t(...)\n end", "def translators_note; end", "def plural_keys(*args); end", "def localize(*args)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method signatures: nsgettext('Fruits|apple', 'apples', 2) nsgettext(['Fruits|apple', 'apples'], 2) source://i18n//lib/i18n/gettext/helpers.rb46
def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end
[ "def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end", "def t(text);I18n.t(text);end", "def t(*args)\n I18n.translate(*args)\n end", "def plural_keys(*args); end", "def lex_en_interp_words; end", "def translate_option_for( collection, db_value )\n collection.inject(\"\") do |tra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the value of attribute backend_klass. source://i18n//lib/i18n/exceptions.rb125
def backend_klass; end
[ "def backend_class\n @backend_class ||= begin\n return @backend.class if @backend.is_a?(::Specinfra::Backend::Base)\n ::Specinfra::Backend.const_get(@backend.to_s.to_camel_case)\n end\n end", "def backend_class(object)\n klazz = object.is_a?(Class) ? object : ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write a method called 'in_array' which will take two parameteres: One as a string and one as an array of strings Return a boolean indicationg whether or not the string is found in the array. Test your solution with: ruby tests/05_in_array_test.rb Example: "hello", ["hi","howdy","hello"] should return true. Defining met...
def in_array(needle, haystack) (string_in_array(needle, haystack) == true and needle.is_a? String) ? true : false end
[ "def in_array (mystring, myarray)\n\n if myarray.include?(mystring) == true\n return true\n else\n return false\n end\n \nend", "def is_it_in_the_array(array, string)\n if array.include?(string)\n return true\n\n elsif array.length == 0 && string.empty?\n return false\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
block caller until lock is aquired, then yield
def with_lock lock!(true) yield ensure unlock! end
[ "def with_lock\n begin\n lock! && yield\n ensure\n unlock!\n end\n end", "def try_lock() end", "def sync\n @mutex.synchronize{yield}\n end", "def blocking!\n if @_actable.dedicated\n yield\n else\n pool.expand(1)\n begin\n yield\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the basename of our lock path for the lock_path '/_zklocking/foobar/__blah/lock000000007' lock_basename is 'lock000000007' returns nil if lock_path is not set
def lock_basename lock_path and File.basename(lock_path) end
[ "def lock_basename\n synchronize { lock_path and File.basename(lock_path) }\n end", "def lockfile_basename\n \"sync-#{syncer_name}.lock\"\n end", "def format_restart_lock_path(root, lock_name)\n return \"/#{lock_name}\" if root.nil?\n return \"/#{lock_name}\" if root == '/'\n \"#{root...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the sequence number of the next lowest write lock node raises NoWriteLockFoundException when there are no write nodes with a sequence less than ours
def next_lowest_write_lock_num #:nodoc: digit_from(next_lowest_write_lock_name) end
[ "def next_lowest_write_lock_num\n digit_from(next_lowest_write_lock_name)\n end", "def next_lowest_write_lock_name\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename) # our idx would be 2\n\n ary[0..my_idx].reverse.find { |n| n.start_with?(EXCLUSIVE_LOCK_PREFIX) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Testing password complexity for dat securitayyy
def password_complexity return if password.blank? || password =~ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,20}$/ errors.add :password, 'Password complexity requirement not met.' end
[ "def password_complexity\n if password.present?\n if !password.match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\\$%\\^&\\*\\-+;:'\"])/)\n errors.add :password, \"must have a number, lowercase, uppercase and special character\"\n end\n end\n end", "def passwd_dtct(passwd)\n if passwd.len...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Escape bytea values. Uses historical format instead of hex format for maximum compatibility.
def escape_bytea(str) # each_byte used instead of [] for 1.9 compatibility str.gsub(/[\000-\037\047\134\177-\377]/n){|b| "\\#{sprintf('%o', b.each_byte{|x| break x}).rjust(3, '0')}"} end
[ "def escape_bytea_array(a)\n escape_bytea_quote(a) do |e|\n e.\n gsub(/\\\\/, '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\').\n gsub(/\\000/, \"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\000\")\n end\n end", "def escape8bit(str); end", "def unescape_bytea(original...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Escape strings by doubling apostrophes. This only works if standard conforming strings are used.
def escape_string(str) str.gsub("'", "''") end
[ "def sql_escape(str)\n\t\t\treturn str.gsub(/[']/,\"''\") # doubles apostrophes\n\t\tend", "def quote_string(s)\n escape s.gsub(/\\\\/, '\\&\\&').gsub(/\"/, \"\\\\\\\"\") # ' (for ruby-mode)\n end", "def shell_escape(s)\n s = s.to_s\n if s !~ /^[0-9A-Za-z+,.\\/:=@_-]+$/\n s = s.gsu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert given argument so that it can be used directly by pg. Currently, pg doesn't handle fractional seconds in Time/DateTime or blobs with "\0", and it won't ever handle Sequel::SQLTime values correctly. Only public for use by the adapter, shouldn't be used by external code.
def bound_variable_arg(arg, conn) case arg when Sequel::SQL::Blob {:value=>arg, :type=>17, :format=>1} when Sequel::SQLTime literal(arg) when DateTime, Time literal(arg) else arg end end
[ "def prepared_statement_arg(v)\n case v\n when Numeric\n v.to_s\n when Date, Time\n literal(v).gsub(\"'\", '')\n else\n v\n end\n end", "def timeToSql(time)\n time.strftime(\"%Y-%m-%d %H:%M:%S.\") + (\"%06d\" % time.usec)\n end", "def ti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Connects to the database. In addition to the standard database options, using the :encoding or :charset option changes the client encoding for the connection, :connect_timeout is a connection timeout in seconds, :sslmode sets whether postgres's sslmode, and :notice_receiver handles server notices in a proc. :connect_ti...
def connect(server) opts = server_opts(server) if USES_PG connection_params = { :host => opts[:host], :port => opts[:port] || 5432, :dbname => opts[:database], :user => opts[:user], :password => opts[:password], :connect_t...
[ "def connect_to_database(options)\n connection_hash = {:adapter => 'postgres',\n :database => options[:database_name],\n :user => options[:database_user],\n :password => options[:database_password],\n :test => t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set whether to allow infinite timestamps/dates. Make sure the conversion proc for date reflects that setting.
def convert_infinite_timestamps=(v) @convert_infinite_timestamps = case v when Symbol v when 'nil' :nil when 'string' :string when 'float' :float when String typecast_value_boolean(v) else false e...
[ "def convert_infinite_timestamps=(v)\n @convert_infinite_timestamps = case v\n when Symbol\n v\n when 'nil'\n :nil\n when 'string'\n :string\n when 'date'\n :date\n when 'float'\n :float\n when String, true\n type...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
+copy_into+ uses PostgreSQL's +COPY FROM STDIN+ SQL statement to do very fast inserts into a table using input preformatting in either CSV or PostgreSQL text format. This method is only supported if pg 0.14.0+ is the underlying ruby driver. This method should only be called if you want results returned to the client. I...
def copy_into(table, opts=OPTS) data = opts[:data] data = Array(data) if data.is_a?(String) if block_given? && data raise Error, "Cannot provide both a :data option and a block to copy_into" elsif !block_given? && !data raise Error, "Must provide either a...
[ "def copy_from path_or_io, options = {}\n options = { delimiter: \",\", format: :csv, header: true, quote: '\"' }.merge(options)\n options[:delimiter] = \"\\t\" if options[:format] == :tsv\n options_string = if options[:format] == :binary\n \"BINARY\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Listens on the given channel (or multiple channels if channel is an array), waiting for notifications. After a notification is received, or the timeout has passed, stops listening to the channel. Options: :after_listen :: An object that responds to +call+ that is called with the underlying connection after the LISTEN s...
def listen(channels, opts=OPTS, &block) check_database_errors do synchronize(opts[:server]) do |conn| begin channels = Array(channels) channels.each do |channel| sql = "LISTEN ".dup dataset.send(:identifier_append, s...
[ "def listen_to_channel(connection, channel, &block)\n connection.execute(\"LISTEN #{channel}\")\n\n loop do\n connection.raw_connection.wait_for_notify(10) do |event, pid, payload|\n return if yield payload\n end\n end\n ensure\n connection.execute(\"UNLISTEN *\")\n end", "def on_no...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Execute the given SQL string or prepared statement on the connection object.
def _execute(conn, sql, opts, &block) if sql.is_a?(Symbol) execute_prepared_statement(conn, sql, opts, &block) else conn.execute(sql, opts[:arguments], &block) end end
[ "def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Execute the prepared statement name with the given arguments on the connection.
def _execute_prepared_statement(conn, ps_name, args, opts) conn.exec_prepared(ps_name, args) end
[ "def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end", "def execute_prepared_statement(name, opts=OPTS)\n args = opts[:arguments]\n if name.is_a?(Dataset)\n ps = name\n name = ps.prepared_statement_name\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the DateStyle to ISO if configured, for faster date parsing.
def connection_configuration_sqls sqls = super sqls << "SET DateStyle = 'ISO'" if @use_iso_date_format sqls end
[ "def date_style\n @date_style if [:date, :date_range, :month_and_year, :only_year, :date_disabled].include? @date_style.to_sym\n end", "def datestyle(arg)\n @datestyle = arg\n end", "def use_euro_formats\n self.current_date_format = :euro\n end", "def iso=(value)\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Execute the prepared statement with the given name on an available connection, using the given args. If the connection has not prepared a statement with the given name yet, prepare it. If the connection has prepared a statement with the same name and different SQL, deallocate that statement first and then prepare this ...
def execute_prepared_statement(conn, name, opts=OPTS, &block) ps = prepared_statement(name) sql = ps.prepared_sql ps_name = name.to_s if args = opts[:arguments] args = args.map{|arg| bound_variable_arg(arg, conn)} end unless conn.prepared_statements[ps_name] =...
[ "def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end", "def execute_prepared_statement(name, opts=OPTS)\n args = opts[:arguments]\n if name.is_a?(Dataset)\n ps = name\n name = ps.prepared_statement_name\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return an appropriate value for the given infinite timestamp string.
def infinite_timestamp_value(value) case convert_infinite_timestamps when :nil nil when :string value else value == 'infinity' ? PLUS_INFINITY : MINUS_INFINITY end end
[ "def infinite_timestamp_value(value)\n case convert_infinite_timestamps\n when :nil\n nil\n when :string\n value\n when :date\n value == 'infinity' ? PLUS_DATE_INFINITY : MINUS_DATE_INFINITY\n else\n value == 'infinity' ? PLUS_INFINITY : MINUS_I...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replace the WHERE clause with one that uses CURRENT OF with the given cursor name (or the default cursor name). This allows you to update a large dataset by updating individual rows while processing the dataset via a cursor: DB[:huge_table].use_cursor(:rows_per_fetch=>1).each do |row| DB[:huge_table].where_current_of.u...
def where_current_of(cursor_name='sequel_cursor') clone(:where=>Sequel.lit(['CURRENT OF '], Sequel.identifier(cursor_name))) end
[ "def mutate(&block)\n old_block = @block\n Query.new(**@ctx) {\n instance_eval(&old_block)\n instance_eval(&block)\n }\n end", "def next_cursor_values_query\n cursor_values = order_by_columns.cursor_values(RECURSIVE_CTE_NAME)\n array_mapping_scope_columns = ar...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the columns based on the result set, and return the array of field numers, type conversion procs, and name symbol arrays.
def fetch_rows_set_cols(res) cols = [] procs = db.conversion_procs res.nfields.times do |fieldnum| cols << [fieldnum, procs[res.ftype(fieldnum)], output_identifier(res.fname(fieldnum))] end self.columns = cols.map{|c| c[2]} cols end
[ "def build_column_array\n @column_array =[]\n\n @columns.each do |field|\n begin\n column_array.push(field.name)\n rescue\n column_array.push(field)\n end\n end\n end", "def _get_column_definitions\n columns = []\n stop = len(self.column_data)\n\n end", "def set_col...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate the xml for this notice and sign with the given private key.
def to_xml private_key # Generate magic envelope magic_envelope = XML::Document.new magic_envelope.root = XML::Node.new 'env' me_ns = XML::Namespace.new(magic_envelope.root, 'me', 'http://salmon-protocol.org/ns/magic-env') magic_envelope.root.namespaces.namespace = me...
[ "def sign(private_key)\n signing_key = Ed25519::SigningKey.from_keypair(Base64.decode64(private_key))\n\n @request['body']['nonce'] = nonce\n @request['body']['timestamp'] = timestamp.to_s\n @request['proof'] = {}\n @request['proof']['type'] = PROOF_TYPE\n @request['proof']['verificati...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove all of the tags from the selected text.
def clear_clicked(txtvu) s, e = txtvu.buffer.selection_bounds txtvu.buffer.remove_all_tags(s, e) end
[ "def clear_selection(*tag_names)\n s_iter, e_iter, text_selected = selection_bounds\n if text_selected\n if tag_names.empty?\n clear_all(s_iter, e_iter)\n else\n tag_names.each { |tag_name| clear(tag_name, s_iter, e_iter) }\n end\n end\n end", "def remove_tags_html() self.gs...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /persona_punto_venta GET /persona_punto_venta.json
def index @persona_punto_venta = PersonaPuntoVentum.all end
[ "def show\n @punto_de_ventum = PuntoDeVentum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @punto_de_ventum }\n end\n end", "def create\n @persona_punto_ventum = PersonaPuntoVentum.new(persona_punto_ventum_params)\n\n respond_to d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }