query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
PUT /fault_books/1 PUT /fault_books/1.json | def update
@fault_book = FaultBook.find(params[:id])
respond_to do |format|
if @fault_book.update_attributes(params[:fault_book])
format.html { redirect_to @fault_book, notice: 'Fault book was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @fault_book.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @api_book = Api::Book.find(params[:id])\n\n if @api_book.update(api_book_params)\n head :no_content\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book... | [
"0.637154",
"0.6333977",
"0.63282835",
"0.6258963",
"0.62080014",
"0.61578",
"0.6074195",
"0.59866476",
"0.5945467",
"0.5931477",
"0.5911134",
"0.58998066",
"0.5891074",
"0.5872732",
"0.58627915",
"0.585701",
"0.5834952",
"0.5825856",
"0.5819932",
"0.5819932",
"0.5819932",
... | 0.7264373 | 0 |
DELETE /fault_books/1 DELETE /fault_books/1.json | def destroy
@fault_book = FaultBook.find(params[:id])
@fault_book.destroy
if (params[:from_calendar])
UserMailer.cancel_service(current_user, @fault_book.fleet, "Fault Book Service", @fault_book.fault_date).deliver
redirect_to controller: :calendar, action: :index
else
respond_to do |format|
format.html { redirect_to fault_books_url }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @api_book.destroy\n\n head :no_content\n end",
"def destroy\n book = Book.find(params[:id])\n book.destroy\n \n render json: {}, status: 204\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n \n ... | [
"0.73746705",
"0.7044132",
"0.7023974",
"0.69840664",
"0.69713706",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.6962778",
"0.69505024",
"0.69505024",
"0.69491005",
"0.6934477... | 0.0 | -1 |
number: Accepts 3 parameters name, twilio, and area code. twilio determines if Twilio will be used to generate a real phone number. Name is used when setting the friendly name of a Twilio phone number. Area code is used when search for local Twilio numbers. End result a phone number. | def number(twilio=false, name=nil, area_code=nil)
if twilio
# Check if twilio configuration exists. If not throw and errors because twilio was passed as true.
if !@config[:configuration][:twilio].blank? and (!@config[:configuration][:twilio][:account_id].blank? and !@config[:configuration][:twilio][:api_key].blank?)
account = @config[:configuration][:twilio][:account_id]
key = @config[:configuration][:twilio][:api_key]
# Initialize twilio client.
twilio = Twilio::REST::Client.new account, key
# If any area code is provide look for local numbers, if not get a toll free.
if area_code.blank?
available_numbers = twilio.account.available_phone_numbers.get('US').toll_free.list
else
available_numbers = twilio.account.available_phone_numbers.get('US').local.list(area_code: area_code) unless area_code.blank?
end
# Select the first number available.
available_number = available_numbers.first
# If available numbers is blank throw an error because something went wrong.
if available_numbers.blank?
raise StandardError, "No Available Numbers"
else
# Convert the phone number into something a artificial voice can say.
phone_number = available_number.phone_number.gsub("+1","")
phone_number = "#{phone_number[0..2]}-#{phone_number[3..5]}-#{phone_number[6..10]}"
# Setting the transciption email
# email = @config[:configuration][:twilio][:transcription_email].blank? ? "developers%40level.agency" : @config[:configuration][:twilio][:transcription_email]
email = "developers%40level.agency"
# Put together the voicemail Twimil.
voice_message = "http://twimlets.com/voicemail?Email=#{email}&Message=You%20reached%20the%20voicemail%20box%20of%20#{phone_number}.%20%20Please%20leave%20a%20message%20after%20the%20beep.&Transcribe=true&"
# Here we buy the number, set the voice_url to the voicemail Twimil and set the
# sms_url to echo so Twilio will capture the message but not reply to it.
number = twilio.account.incoming_phone_numbers.create({
phone_number: available_number.phone_number,
friendly_name: name,
voice_url: voice_message,
voice_method: "GET",
sms_url: "http://twimlets.com/echo?Twiml=%3CResponse%3E%3C%2FResponse%3E",
sms_method: "GET"
})
# If number is blank throw and error because something went wrong.
if number.blank?
raise StandardError, "Unable to allocate Twilio number"
else
number.phone_number
end
end
else
raise ArgumentError, "Cannot find Twilio Account ID and API key in configuration"
end
else
Faker::PhoneNumber.phone_number
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @number = Number.new(number_params)\n\n if !@number.business_number.blank?\n @number.business_number = \"+1\"+Phony.normalize(@number.business_number) \n end\n\n begin \n @client = Twilio::REST::Client.new BwCallTracking::Application.config.account_sid, BwCallTracking:... | [
"0.727347",
"0.7182441",
"0.7126095",
"0.710153",
"0.7060691",
"0.6984639",
"0.6861804",
"0.68602294",
"0.68159324",
"0.68159324",
"0.6781796",
"0.6754689",
"0.6709373",
"0.6684381",
"0.66806006",
"0.6673164",
"0.6603824",
"0.6558685",
"0.6544645",
"0.64883184",
"0.6467116",
... | 0.81615365 | 0 |
Return 1st 3 words of content and ellipsis | def preview
self.content.split(' ')[0...5].join(' ') + '...'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def excerpt\n return content if content.length <= 120\n content[0..116] + '...'\n end",
"def first_n_words( n , text )\n words = text.split[0...n]\n words.join(' ') + if words.size == n then '...' else '' end\n end",
"def first_20(post_text = '') \n \tshort_text = post_text.sp... | [
"0.7057888",
"0.7000038",
"0.6959024",
"0.6905326",
"0.6837792",
"0.68131495",
"0.6607022",
"0.6546468",
"0.65408176",
"0.6535372",
"0.65225637",
"0.65146345",
"0.6496327",
"0.64756733",
"0.6463349",
"0.6419969",
"0.6384793",
"0.6380042",
"0.6349158",
"0.6307467",
"0.6292589"... | 0.7083525 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_acuerdo_acceso_interconexion
@acuerdo_acceso_interconexion = AcuerdoAccesoInterconexion.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def acuerdo_acceso_interconexion_params
unless params[:acuerdo_acceso_interconexion].empty?
params.require(:acuerdo_acceso_interconexion).permit(:titulo_acuerdo, :fecha_validez_acuerdo, :anexos, :adendas, :nota, asiento_attributes: [:id, :acto_id, :acto_type, :_destroy, :num_asiento, :num_asiento_original, :acto_inscribible, :tipo_asiento, :tipo_inscripcion, :numero_resolucion, :nombre_resolucion,:titulo_resolucion, :fecha_resolucion, :fecha_solicitud, :nombre_operador, :identificacion_operador, :cedula_representante_legal, :nombre_representante_legal, :usuario, :enlace_documento, :num_expediente_sutel, :operadorregulado_id, :vigencia2 ], servicios_interconexion_attributes: [:servicio, :precio_interconexion, :sci_servicios_id, :id], operadores_acuerdo_acceso_interconexions_attributes: [:operador_regulados_id, :nombre_operador, :identificacion_operador, :nombre_representante_legal, :cedula_representante_legal, servicios_operadores_acuerdo_acceso_interconexions_attributes: [:precio_interconexion, :sci_servicios_id]])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
print documentation, use like this; ri 'Arraypop' Array.ri Array.ri :pop arr.ri :pop | def ri(method = nil)
unless method && method =~ /^[A-Z]/ # if class isn't specified
klass = self.kind_of?(Class) ? name : self.class.name
method = [klass, method].compact.join('#')
end
system 'ri', method.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def \n \n using_pop(array)\n \n\n array.pop()\n \nend",
"def using_pop(array)\n array.pop()\nend",
"def using_pop(arr)\n arr.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def pop\r\n @arr.shift\r\n end",
"def using_pop(array)\n array.pop\... | [
"0.7563825",
"0.73930633",
"0.7309735",
"0.73064196",
"0.7291879",
"0.72710735",
"0.72372276",
"0.72372276",
"0.72372276",
"0.72372276",
"0.72372276",
"0.72372276",
"0.72372276",
"0.72372276",
"0.72372276",
"0.7197551",
"0.7041456",
"0.6908693",
"0.68627924",
"0.68513554",
"0... | 0.0 | -1 |
general Postfix server options: c master.cf chroot is y, so this process should chroot to queue_directory. d not daemon mode D debug mode i set max_idle= l master.cf maxproc is 1 m set max_use= n name master.cf service name o param=value param=value s number of server sockets S stdin stream mode t type master.cf service type (inet, unix, pass) u master.cf unpriv is y, so this process should setuid to mail_owner. v verbose mode V message to stderr z master.cf maxproc is 0 This library support only 's', 'i', 'm' option. | def parse_args
@args.extend OptionParser::Arguable
opts = @args.getopts('cdDi:lm:n:o:s:St:uvVz')
@nsocks = opts['s'] ? opts['s'].to_i : 1
@max_idle = opts['i'] ? opts['i'].to_i : DEFAULT_MAX_IDLE
@max_use = opts['m'] ? opts['m'].to_i : DEFAULT_MAX_USE
$VERBOSE = true if opts['v']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_options\n @options = {\n :min_threads => 0,\n :max_threads => 16,\n :quiet => false,\n :debug => false,\n :binds => [],\n :workers => 0,\n :daemon => false,\n :before_worker_shutdown => [],\n :before_worker_boot => [],\n :before_w... | [
"0.60628885",
"0.59429365",
"0.58650863",
"0.58417577",
"0.5769326",
"0.5734786",
"0.5601387",
"0.55294394",
"0.5472042",
"0.5432906",
"0.54265237",
"0.5419419",
"0.53925216",
"0.5384949",
"0.53476393",
"0.5342322",
"0.5341511",
"0.53003466",
"0.5296648",
"0.5295062",
"0.5282... | 0.499497 | 46 |
This blocks anyone posting a link from paypal in chat | def no_paypal_content
errors.add_to_base("Please, no thirdparty websites.") if content =~ /paypal/i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_mails_from_merchant\n end",
"def reject(deal)\n @deal, @merchant = deal, deal.merchant\n @deal_url = merchant_promo_url(@merchant, @deal)\n \n mail :to => deal.merchant.email\n end",
"def garantir_link\n if link.present?\n link_params = link\n _link = link_params.spli... | [
"0.6167413",
"0.58691263",
"0.5775323",
"0.5612665",
"0.55139744",
"0.54867",
"0.54698706",
"0.54659456",
"0.5429437",
"0.5427524",
"0.53761524",
"0.5370299",
"0.53551006",
"0.53113556",
"0.5285021",
"0.5284297",
"0.5276118",
"0.52563554",
"0.5246471",
"0.5239043",
"0.5232328... | 0.6136085 | 1 |
yields self to block | def test_yields_self_to_block
inner = nil
outer = Crd::Flex::Command.new 'mxmlc' do |c|
inner = c
end
assert_same( outer, inner )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454",
"0.76818454"... | 0.0 | -1 |
provides access to command name passed in constructor | def test_provides_access_to_command_name_passed_in_constructor
Crd::Flex::Command.new 'mxmlc' do |c|
assert_equal( 'mxmlc', c.command )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command_name; end",
"def command_name=(_arg0); end",
"def initialize(name)\n super \"Unknown command: #{name}\"\n @command = name\n end",
"def initialize(name, command)\r\n super(name)\r\n @command = command\r\n end",
"def command_name\n self.class.command_name\n ... | [
"0.799135",
"0.7973865",
"0.780604",
"0.7767644",
"0.7766731",
"0.7740175",
"0.7721307",
"0.765618",
"0.765618",
"0.765618",
"0.7375512",
"0.73577493",
"0.7343512",
"0.7323733",
"0.73176956",
"0.7291462",
"0.72361875",
"0.7211687",
"0.71776646",
"0.7099506",
"0.7099506",
"0... | 0.71030843 | 19 |
assembles only command name in to cmd method | def test_assembles_only_command_name_in_to_cmd_method
Crd::Flex::Command.new 'mxmlc' do |c|
assert_equal( 'mxmlc', c.to_cmd )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command_name(cmd)\n cmd\n end",
"def command_name; end",
"def command_name=(_arg0); end",
"def command(cmd)\n \"do_#{cmd}\".intern\n end",
"def command_name\n @command_name ||= if command = name.to_s.split(\"::\").last\n command.chomp!(\"Command\")\n c... | [
"0.81547135",
"0.8104025",
"0.7954934",
"0.7653976",
"0.76478624",
"0.76413333",
"0.7641055",
"0.7602003",
"0.7551413",
"0.7513772",
"0.7442354",
"0.73648196",
"0.72745186",
"0.7255864",
"0.7251457",
"0.72260815",
"0.7100213",
"0.7100213",
"0.7100213",
"0.7057975",
"0.7028563... | 0.6643471 | 53 |
has can tell whether or not an argument has been set | def test_has_can_tell_whether_or_not_an_argument_has_been_set
Crd::Flex::Command.new 'mxmlc' do |s|
assert_equal( false, s.has?( :output ) )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_argument?(key)\n self.arguments.set?(key)\n end",
"def has_argument?(key)\n self.arguments.set?(key)\n end",
"def hasArg?(arg); argSet.member?(arg) end",
"def has_missing_required_arg?\n !missing_required_arguments.empty?\n end",
"def ha... | [
"0.77382064",
"0.77382064",
"0.75720257",
"0.7095822",
"0.6820216",
"0.6815802",
"0.6775533",
"0.670544",
"0.6649012",
"0.6568362",
"0.6560428",
"0.6560428",
"0.65445143",
"0.6537804",
"0.64999115",
"0.64767843",
"0.64767843",
"0.64741063",
"0.6472226",
"0.6444105",
"0.644056... | 0.62424856 | 35 |
assignment creates a string argument | def test_assignment_creates_a_string_argument
Crd::Flex::Command.new 'mxmlc' do |s|
s.output = 'Main.swf'
assert_equal( true, s.has?( :output ) )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string=(_arg0); end",
"def string=(arg0)\n end",
"def assign_name(string = \"Bob\")\n return string\nend",
"def string= string\n #This is a stub, used for indexing\n end",
"def assign_name(name='Bob')\n name \nend",
"def assign_name(name='Bob')\n name\nend",
"def SAC02=(arg)",
"def ... | [
"0.78299844",
"0.759605",
"0.7013762",
"0.69193244",
"0.69103163",
"0.6846448",
"0.67807674",
"0.6771822",
"0.6756093",
"0.6751129",
"0.6737686",
"0.67169243",
"0.66909933",
"0.6684321",
"0.66791296",
"0.6667396",
"0.66613805",
"0.6642231",
"0.6623453",
"0.65958595",
"0.65943... | 0.6180683 | 83 |
can retrieve argument set through assignment | def test_can_retrieve_argument_set_through_assignment
Crd::Flex::Command.new 'mxmlc' do |s|
s.output = 'Main.swf'
assert_equal( 'Main.swf', s.output )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set=(_arg0); end",
"def arguments=(_arg0); end",
"def mset(*_arg0); end",
"def mset(*args); end",
"def set!(*args)\n end",
"def set_arguments (args)\n end",
"def assign args={}\n args.keys.each{ |name| instance_variable_set(\"@#{name}\", args[name]) }\n end",
"def set(*args)\n ... | [
"0.7623902",
"0.6948813",
"0.67751545",
"0.6765537",
"0.667659",
"0.6569326",
"0.65015066",
"0.64867926",
"0.64867926",
"0.64597017",
"0.6448581",
"0.64435154",
"0.6398204",
"0.63960326",
"0.6370653",
"0.6364791",
"0.63464034",
"0.6337062",
"0.6300145",
"0.6300145",
"0.630014... | 0.0 | -1 |
argument can be overwritten through assignment | def test_argument_can_be_overwritten_through_assignment
Crd::Flex::Command.new 'mxmlc' do |s|
s.output = 'Main.swf'
assert_equal( 'Main.swf', s.output )
s.output = 'App.swf'
assert_equal( 'App.swf', s.output )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def old_value=(_arg0); end",
"def PO114=(arg)",
"def explicit=(_arg0); end",
"def set=(_arg0); end",
"def extra=(_arg0); end",
"def safe_by_default=(_arg0); end",
"def PO106=(arg)",
"def PO107=(arg)",
"def PO101=(arg)",
"def PO113=(arg)",
"def SE02=(arg)",
"def PO109=(arg)",
"def cop=(_); e... | [
"0.78870517",
"0.7604563",
"0.7567148",
"0.7550401",
"0.753814",
"0.74575424",
"0.74496603",
"0.7446322",
"0.7388597",
"0.7372473",
"0.73535234",
"0.7309903",
"0.7277173",
"0.7277173",
"0.7276303",
"0.72646135",
"0.7263914",
"0.72597873",
"0.723266",
"0.72235733",
"0.72213906... | 0.0 | -1 |
retrieving new argument before assignment gives empty array | def test_retrieving_new_argument_before_assignment_gives_empty_array
Crd::Flex::Command.new 'mxmlc' do |s|
assert_equal( [ ], s.library_path )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def old_value=(_arg0); end",
"def probers=(_arg0); end",
"def extra=(_arg0); end",
"def arguments=(_arg0); end",
"def PO114=(arg)",
"def []=(*args); end",
"def y=(_arg0); end",
"def PRF02=(arg)",
"def x=(_arg0); end",
"def x=(_arg0); end",
"def x=(_arg0); end",
"def set=(_arg0); end",
"def ... | [
"0.6616945",
"0.6561144",
"0.6530753",
"0.64734846",
"0.6375704",
"0.6318633",
"0.62615925",
"0.62433445",
"0.6227827",
"0.6227827",
"0.6227827",
"0.6221699",
"0.6206022",
"0.6206022",
"0.62057215",
"0.6202669",
"0.61804014",
"0.6177529",
"0.6177462",
"0.6177462",
"0.6177462"... | 0.0 | -1 |
can easily build arrays when accessing by default | def test_can_easily_build_arrays_when_accessing_by_default
Crd::Flex::Command.new 'mxmlc' do |s|
s.library_path << 'lib/bin'
s.library_path << 'lib/swc'
assert_equal( [ 'lib/bin', 'lib/swc' ], s.library_path )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Array(p0) end",
"def __array__; self; end",
"def build_array(param1, param2, param3)\n\t[param1, param2, param3]\nend",
"def array\n raise \"Not implemented\"\n end",
"def make_array\n [@name, @author, @deviation_url, @views, @favs, @comments]\n end",
"def build_array(it1, it2, it3)\n\tne... | [
"0.70760995",
"0.70729804",
"0.6957557",
"0.6777844",
"0.6753968",
"0.67352843",
"0.66489214",
"0.661263",
"0.660413",
"0.6595286",
"0.657325",
"0.65664274",
"0.65545654",
"0.6505749",
"0.6501083",
"0.6496304",
"0.6495435",
"0.6477869",
"0.64571416",
"0.6437",
"0.6430427",
... | 0.0 | -1 |
assembles one string argument into cmd | def test_assembles_one_string_argument_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.output = 'Main.swf'
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-output=Main.swf' ), 'Could not find argument in to_cmd' )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_command(cmd)\n cmd\n end",
"def add_cmd_args(str)\n @cmd_args << \" #{str} \"\n end",
"def add_cmd_args(str)\n @cmd_args << \" #{str} \"\n end",
"def command_str_for(*args)\n args.collect{|arg|\n case arg\n when Array\n arg.join(' ')\n when Hash\n ... | [
"0.7068323",
"0.69636685",
"0.69636685",
"0.69366765",
"0.6899672",
"0.68419486",
"0.6755255",
"0.6755255",
"0.6755255",
"0.6679324",
"0.6585226",
"0.6529333",
"0.6517605",
"0.64571357",
"0.6444411",
"0.6444411",
"0.6444411",
"0.642966",
"0.64284426",
"0.6351566",
"0.63457745... | 0.72035694 | 0 |
converts argument names with underscores to hyphens | def test_converts_argument_names_with_underscores_to_hyphens
Crd::Flex::Command.new 'mxmlc' do |s|
s.static_link_runtime_shared_libraries = true
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-static-link-runtime-shared-libraries=true' ), 'Could not find argument in to_cmd' )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def argument_name_without_leading_underscore\n name = if argument_name_string[FIRST_CHARACTER] == UNDERSCORE\n argument_name_string.reverse.chop.reverse\n else\n argument_name_string\n end\n name.to_sym\n end",
"def dasherize(underscored_word)\n ... | [
"0.7434346",
"0.72641337",
"0.71720374",
"0.71720374",
"0.71594393",
"0.7124182",
"0.7042182",
"0.69382614",
"0.690875",
"0.6860738",
"0.685133",
"0.67673415",
"0.6739195",
"0.67330974",
"0.66992426",
"0.6673833",
"0.66623104",
"0.66041684",
"0.66023517",
"0.65758485",
"0.656... | 0.6508206 | 23 |
assembles two string arguments into cmd | def test_assembles_two_string_arguments_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.output = 'Main.swf'
s.static_link_runtime_shared_libraries = true
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-output=Main.swf' ), 'Could not find argument in to_cmd' )
assert( cmd.include?( '-static-link-runtime-shared-libraries=true' ), 'Could not find argument in to_cmd' )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run2(*args)\n args.map!(&:to_s)\n command = args.join(' ')\n if include_meta_character?(command)\n run(command)\n else\n run(*args)\n end\n end",
"def command_str_for(*args)\n args.collect{|arg|\n case arg\n when Array\n arg.join(' ')\n when ... | [
"0.6640243",
"0.6495583",
"0.63996524",
"0.6379334",
"0.63629115",
"0.63383967",
"0.622787",
"0.6225234",
"0.6225234",
"0.6205089",
"0.6166615",
"0.61398673",
"0.61373705",
"0.6002811",
"0.5957732",
"0.5872808",
"0.5845634",
"0.58316904",
"0.5812553",
"0.5812553",
"0.5812553"... | 0.67715317 | 0 |
assembles one array argument into cmd | def test_assembles_one_array_argument_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.source_path << 'src'
s.source_path << 'lib/src'
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-source-path+=src,lib/src' ), 'Could not find argument in to_cmd' )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n cmd = ''\n @arr.each do |arg|\n if arg == @arr.first\n cmd << arg\n elsif arg.is_a?(Array)\n param, value = arg.first.to_s, arg.last.to_s\n\n if param =~ /^\\-{1,2}(.*)/\n param = $1\n end\n\n if param.le... | [
"0.7245188",
"0.71567416",
"0.70673466",
"0.6924166",
"0.66781735",
"0.66477025",
"0.6617469",
"0.6565068",
"0.65550244",
"0.6526354",
"0.6498005",
"0.646884",
"0.6440869",
"0.6423733",
"0.63962555",
"0.63503236",
"0.6326912",
"0.63247424",
"0.62887",
"0.6288465",
"0.6280191"... | 0.72121495 | 1 |
assembles two array arguments into cmd | def test_assembles_two_array_arguments_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.source_path << 'src'
s.source_path << 'lib/src'
s.library_path << 'lib/bin'
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-source-path+=src,lib/src' ), 'Could not find argument in to_cmd' )
assert( cmd.include?( '-library-path+=lib/bin' ), 'Could not find argument in to_cmd' )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_cmd_ary(opts={arguments:[],separator:\"=\"})\n # [program, sub_program, normalize_params(opts[:separator]), opts[:arguments]].flatten.compact\n [program, sub_program, normalize_params(opts[:separator]), opts[:arguments].map{|a| a.split}].flatten.compact\n end",
"def create_commands args\n ... | [
"0.6598915",
"0.6512753",
"0.6512354",
"0.64623946",
"0.64417624",
"0.63631356",
"0.63423735",
"0.6336858",
"0.63310724",
"0.6313476",
"0.6311418",
"0.6306207",
"0.6300613",
"0.6294837",
"0.6264264",
"0.6176318",
"0.60607445",
"0.60588604",
"0.6000599",
"0.589969",
"0.5860555... | 0.7290355 | 0 |
run runs the command and returns the output | def test_run_runs_the_command_and_returns_the_output
Crd::Flex::Command.new 'echo' do |s|
s.output = 'Main.swf'
assert_equal( '-output=Main.swf', s.run! )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_and_output(cmd)\n run(cmd).output\n end",
"def run\n system(command)\n $?\n end",
"def run\n system(command)\n $?\n end",
"def run_command(*command)\n\t\t\t#stdout, stderr, status\n\t\t\treturn Open3.capture3(*command)\n\t\tend",
"def run\n begin\n IO.popen... | [
"0.726669",
"0.72159886",
"0.72159886",
"0.6970422",
"0.6970309",
"0.69441235",
"0.69344425",
"0.69065624",
"0.6840741",
"0.6840741",
"0.6839807",
"0.683495",
"0.6832714",
"0.68320477",
"0.681404",
"0.68090266",
"0.6796596",
"0.6790829",
"0.67811906",
"0.6745228",
"0.6728954"... | 0.0 | -1 |
found returns true for commands found in path | def test_found_returns_true_for_commands_found_in_path
Crd::Flex::Command.new 'mxmlc' do |s|
assert_equal( true, s.found? )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmds_in_path? commands = provides, custom_cmd_dir = nil\n present, missing = [*commands].partition {|cmd_name| cmd_dir(cmd_name) }\n ours, other = if custom_cmd_dir\n present.partition {|cmd_name| cmd_dir(cmd_name) == custom_cmd_dir }\n else\n present.partition {|cmd_name| pkg_mana... | [
"0.734286",
"0.72677845",
"0.7204347",
"0.7204347",
"0.71495306",
"0.68601066",
"0.68000686",
"0.67995626",
"0.67675847",
"0.6755701",
"0.66697246",
"0.6572039",
"0.6554533",
"0.6524722",
"0.6480451",
"0.645957",
"0.6427544",
"0.6405467",
"0.64004755",
"0.63667154",
"0.635104... | 0.75232357 | 0 |
found returns false for commands not found in path | def test_found_returns_false_for_commands_not_found_in_path
Crd::Flex::Command.new 'madeupcommandname' do |s|
assert_equal( false, s.found? )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmds_in_path? commands = provides, custom_cmd_dir = nil\n present, missing = [*commands].partition {|cmd_name| cmd_dir(cmd_name) }\n ours, other = if custom_cmd_dir\n present.partition {|cmd_name| cmd_dir(cmd_name) == custom_cmd_dir }\n else\n present.partition {|cmd_name| pkg_mana... | [
"0.75767535",
"0.7559685",
"0.7533789",
"0.7528143",
"0.7427609",
"0.7412547",
"0.7412547",
"0.73862094",
"0.71920097",
"0.7176774",
"0.7171674",
"0.71709985",
"0.715777",
"0.7150228",
"0.71192884",
"0.7086153",
"0.7013274",
"0.69986874",
"0.6954254",
"0.6953138",
"0.6944452"... | 0.7704929 | 0 |
can pass hash to constructor and have arguments be created before passing to block | def test_can_pass_hash_to_constructor_and_have_arguments_be_created_before_passing_to_block
opts = { :output => 'Main.swf', :library_path => [ 'libs/bin', 'libs/swc' ] }
Crd::Flex::Command.new 'mxmlc', opts do |s|
assert_equal( 'Main.swf', s.output )
assert_equal( [ 'libs/bin', 'libs/swc' ], s.library_path )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize args = {}\n hash_make args, Block::ARG_SPECS\n @initial_params = collect_params\n end",
"def initialize args\n hash_make args, BlockState::ARG_SPECS\n end",
"def create_hash(&block); end",
"def create_hash(&block); end",
"def initialize\n @block_args = []\n end",
"de... | [
"0.77099276",
"0.75982904",
"0.75966257",
"0.75966257",
"0.6932157",
"0.6859926",
"0.68573457",
"0.68573457",
"0.6842839",
"0.67864305",
"0.6779723",
"0.67660934",
"0.67637604",
"0.6755913",
"0.67214763",
"0.6702719",
"0.6694621",
"0.66620964",
"0.6642057",
"0.66334885",
"0.6... | 0.6223613 | 79 |
does not print argument for empty array | def test_does_not_print_argument_for_empty_array
Crd::Flex::Command.new 'echo' do |s|
s.library_path = [ ]
assert_equal( [ ], s.library_path )
assert_no_match( /-library-path/, s.to_cmd )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_array(array)\n raise NotImplementedError\nend",
"def print_array(array)\n p array\nend",
"def print_elements(input_array)\n # TODO\nend",
"def test1(array)\n\tputs \"Test1: Should take an array as argument -> \"\n\tarray.class == Array ? true : false\nend",
"def test1(array)\n\tputs \"Test1:... | [
"0.6761435",
"0.66365284",
"0.64765215",
"0.64585656",
"0.64585656",
"0.6400779",
"0.6395051",
"0.6389489",
"0.6338984",
"0.6210894",
"0.6171471",
"0.61523604",
"0.61470485",
"0.61461955",
"0.61439544",
"0.6120291",
"0.61198926",
"0.61198926",
"0.6103999",
"0.6047667",
"0.604... | 0.5859915 | 35 |
GET /transfers GET /transfers.json | def index
@transfers = Transfer.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transfers\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/transfers/list').transfers\n end",
"def index\n @transfers = Transfer.all\n render json: @transfers\n end",
"def index\n @transfers = Transfer.all\n\n ... | [
"0.8085029",
"0.76260304",
"0.73241717",
"0.72007954",
"0.7198779",
"0.7133896",
"0.7062837",
"0.7012793",
"0.67484874",
"0.6748145",
"0.6654107",
"0.6601119",
"0.656075",
"0.6546354",
"0.6531464",
"0.649038",
"0.6358053",
"0.63124937",
"0.62614787",
"0.6250275",
"0.62478787"... | 0.71721023 | 8 |
GET /transfers/1 GET /transfers/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @transfers = Transfer.all\n render json: @transfers\n end",
"def transfers\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/transfers/list').transfers\n end",
"def index\n @transfers = Transfer.all\n\n ... | [
"0.741434",
"0.74059945",
"0.72151774",
"0.7011247",
"0.7011247",
"0.7011247",
"0.7011247",
"0.6941883",
"0.6936286",
"0.68959785",
"0.6847237",
"0.67529625",
"0.67234665",
"0.64557207",
"0.645324",
"0.6319211",
"0.6294915",
"0.6253235",
"0.62481064",
"0.62369657",
"0.6228708... | 0.0 | -1 |
DELETE /transfers/1 DELETE /transfers/1.json | def destroy
@transfer.destroy
respond_to do |format|
format.html { redirect_to transfers_url, notice: 'Transfer was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @transfer = Transfer.find(params[:id])\n @transfer.destroy\n\n respond_to do |format|\n format.html { redirect_to transfers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transfer.destroy\n respond_to do |format|\n format.html { redirect_to ... | [
"0.7729923",
"0.76982164",
"0.742149",
"0.742149",
"0.742149",
"0.74167866",
"0.74125475",
"0.7403977",
"0.7242137",
"0.7179308",
"0.7122767",
"0.7081196",
"0.7007919",
"0.6901883",
"0.67975754",
"0.67509127",
"0.6718018",
"0.67002594",
"0.6688077",
"0.6675711",
"0.6661923",
... | 0.7457703 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_transfer
@transfer = Transfer.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def transfer_params
params.require(:tranfers_trancase).permit(:type, :date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
GET /latstraps1s GET /latstraps1s.json | def index
@latstraps1s = Latstraps1.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_latstraps1\n @latstraps1 = Latstraps1.find(params[:id])\n end",
"def create\n @latstraps1 = Latstraps1.new(latstraps1_params)\n\n respond_to do |format|\n if @latstraps1.save\n format.html { redirect_to @latstraps1, notice: 'Latstraps1 was successfully created.' }\n forma... | [
"0.71037024",
"0.6500376",
"0.6446585",
"0.5903811",
"0.5833954",
"0.5670466",
"0.5579053",
"0.55710405",
"0.55571175",
"0.55066556",
"0.5506401",
"0.54144996",
"0.5412773",
"0.5410335",
"0.54012185",
"0.53753346",
"0.5348309",
"0.5330392",
"0.53043866",
"0.53006077",
"0.5297... | 0.7809883 | 0 |
GET /latstraps1s/1 GET /latstraps1s/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @latstraps1s = Latstraps1.all\n end",
"def set_latstraps1\n @latstraps1 = Latstraps1.find(params[:id])\n end",
"def create\n @latstraps1 = Latstraps1.new(latstraps1_params)\n\n respond_to do |format|\n if @latstraps1.save\n format.html { redirect_to @latstraps1, notice... | [
"0.745412",
"0.71234393",
"0.64603186",
"0.6256377",
"0.6194292",
"0.5827636",
"0.5821374",
"0.5758407",
"0.5692765",
"0.5672097",
"0.5651511",
"0.5640348",
"0.55883646",
"0.5578611",
"0.55353594",
"0.55040306",
"0.54781944",
"0.54655915",
"0.54646647",
"0.54426885",
"0.54358... | 0.0 | -1 |
POST /latstraps1s POST /latstraps1s.json | def create
@latstraps1 = Latstraps1.new(latstraps1_params)
respond_to do |format|
if @latstraps1.save
format.html { redirect_to @latstraps1, notice: 'Latstraps1 was successfully created.' }
format.json { render :show, status: :created, location: @latstraps1 }
else
format.html { render :new }
format.json { render json: @latstraps1.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_latstraps1\n @latstraps1 = Latstraps1.find(params[:id])\n end",
"def latstraps1_params\n params.require(:latstraps1).permit(:exercise, :reps, :sets)\n end",
"def index\n @latstraps1s = Latstraps1.all\n end",
"def create\n @latstrapshome4 = Latstrapshome4.new(latstrapshome4_para... | [
"0.66604346",
"0.66254866",
"0.66133755",
"0.6069491",
"0.6048444",
"0.5418844",
"0.5394696",
"0.5307771",
"0.5144165",
"0.5112531",
"0.50980717",
"0.50695324",
"0.5038042",
"0.4962604",
"0.49588573",
"0.49386764",
"0.49221656",
"0.4905619",
"0.48861098",
"0.48747998",
"0.485... | 0.75690776 | 0 |
PATCH/PUT /latstraps1s/1 PATCH/PUT /latstraps1s/1.json | def update
respond_to do |format|
if @latstraps1.update(latstraps1_params)
format.html { redirect_to "/latstraps1s"}
format.json { render :show, status: :ok, location: @latstraps1 }
else
format.html { render :edit }
format.json { render json: @latstraps1.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @latstrapshome4.update(latstrapshome4_params)\n format.html { redirect_to \"/latstrapshome4s\"}\n format.json { render :show, status: :ok, location: @latstrapshome4 }\n else\n format.html { render :edit }\n format.json { render json:... | [
"0.6500646",
"0.6395387",
"0.6019283",
"0.59084517",
"0.58681554",
"0.58584225",
"0.5825715",
"0.5747448",
"0.569428",
"0.56253445",
"0.56252116",
"0.56232136",
"0.56171966",
"0.5595198",
"0.5593387",
"0.55838746",
"0.5581199",
"0.5561473",
"0.5542931",
"0.5542158",
"0.553270... | 0.7481019 | 0 |
DELETE /latstraps1s/1 DELETE /latstraps1s/1.json | def destroy
@latstraps1.destroy
respond_to do |format|
format.html { redirect_to latstraps1s_url, notice: 'Latstraps1 was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @latstrapshome4.destroy\n respond_to do |format|\n format.html { redirect_to latstrapshome4s_url, notice: 'Latstrapshome4 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:... | [
"0.69022757",
"0.66501516",
"0.6634008",
"0.6574002",
"0.65542793",
"0.65452856",
"0.65343595",
"0.6502773",
"0.64843994",
"0.64838105",
"0.64605963",
"0.6454735",
"0.6451193",
"0.64439267",
"0.6434023",
"0.6434023",
"0.64280146",
"0.6426783",
"0.64247596",
"0.63847095",
"0.6... | 0.7599374 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_latstraps1
@latstraps1 = Latstraps1.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def latstraps1_params
params.require(:latstraps1).permit(:exercise, :reps, :sets)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Your code here too! | def initialize
@headers = {
"Authorization" => "token #{ENV["AUTH_TOKEN"]}",
"User-Agent" => "HTTParty"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom; end",
"def custom; end",
"def private; end",
"def probers; end",
"def terpene; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def weber; end",
"def r; end",
"def r; en... | [
"0.6580489",
"0.6580489",
"0.65659624",
"0.6527405",
"0.63056856",
"0.6290495",
"0.6290495",
"0.6290495",
"0.6290495",
"0.6290495",
"0.6290495",
"0.6290495",
"0.6290495",
"0.6290495",
"0.62183774",
"0.6036351",
"0.6036351",
"0.6029153",
"0.6012837",
"0.6006934",
"0.600459",
... | 0.0 | -1 |
Returns unique array in which records are sorted by occurrence within array (Descending) | def sort_by_occurrence(records)
count = Hash.new(0)
records.each {|element| count[element] += 1}
records = records.uniq.sort {|x,y| count[y] <=> count[x]}
return records
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consolidate_by_frequency(array)\n array.group_by{|x| x}.values.sort_by{|group| group.count}.reverse.flatten(1).uniq\nend",
"def duplicates_subarray3(arr)\n arr.uniq.map { |elm| [elm] * arr.count(elm)}.sort_by {|subarr| subarr[0].ord }\nend",
"def duplicates_subarray(arr)\n new_arr = []\n arr.each do |e... | [
"0.7063057",
"0.6824201",
"0.6536194",
"0.6355298",
"0.6288329",
"0.628811",
"0.62750524",
"0.62489647",
"0.6234922",
"0.6226262",
"0.6209989",
"0.61989325",
"0.6162273",
"0.61431766",
"0.6141335",
"0.6113254",
"0.6107327",
"0.60924834",
"0.6060285",
"0.6058193",
"0.60489273"... | 0.73379296 | 0 |
Returns unique hash in which records are sorted by "record" => "occurrence" (Descending) | def sort_by_occurrence_h(input)
output = input.each_with_object(Hash.new(0)){ |tag, counts| counts[tag] += 1 }
output = Hash[output.sort_by{ |tags, counts| counts}.reverse]
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_occurrence(records)\n count = Hash.new(0)\n records.each {|element| count[element] += 1}\n records = records.uniq.sort {|x,y| count[y] <=> count[x]}\n return records\n end",
"def unique_visit\n parsed_result.each do |result|\n visit_hash[result.first] = result.last.uniq.count\n ... | [
"0.7349603",
"0.6310041",
"0.60507303",
"0.5988765",
"0.5862194",
"0.57976025",
"0.57502365",
"0.573817",
"0.56708723",
"0.56055963",
"0.55808556",
"0.55299145",
"0.54731566",
"0.5435659",
"0.5425528",
"0.54028034",
"0.5380501",
"0.5372697",
"0.53653216",
"0.53632504",
"0.535... | 0.6573945 | 1 |
Register this class for the given +id+. Example: class MyPlugin < PluginHost::BaseClass register_for :my_id ... end See PluginHost.register. | def register_for id
@plugin_id = id
plugin_host.register self, id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_for(id); end",
"def register(plugin, id); end",
"def register(id, &block)\n ref = __get id\n return ref.__getobj__ if ref && ref.weakref_alive?\n item = block.call\n return nil unless item\n __register id, item\n end",
"def register_identifier(klass, identifier)\n ... | [
"0.79022527",
"0.7580181",
"0.6201312",
"0.6178429",
"0.60646737",
"0.5949389",
"0.5910501",
"0.5895015",
"0.58876175",
"0.58158946",
"0.579344",
"0.5780836",
"0.57418346",
"0.56677276",
"0.5660178",
"0.5608928",
"0.5604907",
"0.55784726",
"0.55784726",
"0.55784726",
"0.55784... | 0.8400942 | 0 |
Returns the title of the plugin, or sets it to the optional argument +title+. | def title title = nil
if title
@title = title.to_s
else
@title ||= name[/([^:]+)$/, 1]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title(*arguments, &block)\n @plugin_title = arguments.first if arguments.length > 0\n @plugin_title\n end",
"def title(title = nil)\n @title = title if title\n @title\n end",
"def title(*args)\n @title = args[0] if args.present?\n @title\n end",
"def title(value = n... | [
"0.827292",
"0.77353597",
"0.74677324",
"0.746107",
"0.7440639",
"0.7274582",
"0.7173406",
"0.71016496",
"0.7076894",
"0.7061905",
"0.7049378",
"0.6987112",
"0.6980184",
"0.69477916",
"0.6937665",
"0.69361824",
"0.69222254",
"0.6899044",
"0.6823574",
"0.6799184",
"0.67820907"... | 0.74146956 | 5 |
The PluginHost for this Plugin class. | def plugin_host host = nil
if host.is_a? PluginHost
const_set :PLUGIN_HOST, host
end
self::PLUGIN_HOST
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host\n return @host if defined?(@host)\n\n # Attempt to figure out the host class. Note that the order\n # matters here, so please don't touch. Specifically: The symbol\n # check is done after the detect check because the symbol check\n # will return nil, and we don't want to trigger a... | [
"0.7118239",
"0.6551484",
"0.6373922",
"0.6296605",
"0.6230977",
"0.6203719",
"0.6161976",
"0.60743886",
"0.6065132",
"0.6065132",
"0.60633695",
"0.6018984",
"0.6001991",
"0.58915067",
"0.58776146",
"0.58461607",
"0.58461607",
"0.5799273",
"0.5792682",
"0.57743007",
"0.574111... | 0.7474413 | 0 |
GET /stories/1 GET /stories/1.json | def show
@story = Story.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n story = Story.find(params[:id])\n render json: story\n end",
"def index\n @stories = Story.all\n render json: @stories, root: false\n end",
"def show\n @story = Story.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:... | [
"0.77517796",
"0.7708573",
"0.7525053",
"0.7514882",
"0.7487153",
"0.7486738",
"0.7486738",
"0.746419",
"0.7455591",
"0.7455591",
"0.736725",
"0.736725",
"0.736725",
"0.736725",
"0.736725",
"0.736725",
"0.7365923",
"0.7325072",
"0.73073804",
"0.7269669",
"0.7202681",
"0.718... | 0.70238024 | 29 |
POST /stories POST /stories.json | def create
@story = Story.new(story_params)
if @story.save
redirect_to new_story_path, notice: 'Спасибо за вашу историю! Скоро мы ее проверим и опубликуем.'
else
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @story = Story.new(story_params)\n if @story.save\n render json: @story, status: :ok\n else\n render json: @story.errors, status: :unprocessable_entity\n end\n end",
"def create\n @story = Story.new(params[:story])\n\n respond_to do |format|\n if @story.save\n ... | [
"0.772964",
"0.76415455",
"0.7610398",
"0.7505145",
"0.74521095",
"0.7439946",
"0.7439946",
"0.73842067",
"0.73842067",
"0.73842067",
"0.7328209",
"0.7292121",
"0.7206045",
"0.69638777",
"0.6957411",
"0.692288",
"0.6892234",
"0.68875116",
"0.6872017",
"0.6849194",
"0.6840574"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def story_params
params.require(:story).permit(:name, :city, :age, :content, :allow_public_read, :is_published)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
def self.set_recipient(recipients) recipient_no_wspace = recipients.gsub(/(\s+, +|,\s+|\s+,)/,',')remove whitespace result :"Saa, Sul ,Ali , Abu" become "Saa,Sul,Ali,Abu" | def filedocer
suid = file_id
Cofile.find(:all, :select => "name", :conditions => {:id => suid}).map(&:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipients_list\n to.split(/\\s*,\\s*/)\n end",
"def email_parser(str) \n str.gsub(/, /,\" \").gsub(/,/,\" \").split.uniq\nend",
"def recipient_list(r)\n @recipients = []\n @failed_recipients = []\n r.gsub(\",\", \" \").split(\" \").each do |a|\n a.strip!\n ... | [
"0.64692605",
"0.629338",
"0.6267356",
"0.6130372",
"0.61203367",
"0.59117895",
"0.5890575",
"0.58064044",
"0.5755295",
"0.5749679",
"0.57486653",
"0.57418704",
"0.5733811",
"0.57319254",
"0.5708853",
"0.5678166",
"0.56615",
"0.5645077",
"0.5642386",
"0.5627158",
"0.5625485",... | 0.0 | -1 |
POST /public_channels POST /public_channels.json | def create
@main_thread = MessageThread.new
@channel = PublicChannel.new(channel_params.merge main_thread: @main_thread)
@memebership = ChannelMembership.new(user: current_user, channel: @channel)
ThreadMembership.create message_thread: @main_thread, channel: @channel
respond_to do |format|
if @main_thread.save and @channel.save and @memebership.save
format.html { redirect_to @channel }
format.json { render :show, status: :created, location: @channel }
else
format.html { render :new }
format.json { render json: @channel.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @universal_channel = UniversalChannel.new(universal_channel_params)\n\n respond_to do |format|\n if @universal_channel.save\n format.html { redirect_to @universal_channel, notice: 'Universal channel was successfully created.' }\n format.json { render :show, status: :created, l... | [
"0.6960062",
"0.6919562",
"0.6829159",
"0.6677903",
"0.6661259",
"0.6661259",
"0.6650474",
"0.6621106",
"0.65518177",
"0.65156364",
"0.6491725",
"0.6481573",
"0.6462334",
"0.6442045",
"0.6376603",
"0.63719517",
"0.6329773",
"0.6310013",
"0.62715197",
"0.6236849",
"0.6235597",... | 0.5627308 | 84 |
Add more helper methods to be used by all tests here... | def fixture_file_path(filename)
Rails.root.join('test', 'fixtures', 'files', filename).to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end",
"def helpers; end",
"def... | [
"0.7330966",
"0.701972",
"0.701972",
"0.701972",
"0.6772961",
"0.6679903",
"0.6679903",
"0.6583205",
"0.65507036",
"0.6377433",
"0.63762784",
"0.632961",
"0.6280821",
"0.6280821",
"0.6249786",
"0.6142927",
"0.6137607",
"0.6121912",
"0.6108209",
"0.60972595",
"0.60949636",
"... | 0.0 | -1 |
Using this for the review query. | def book_title
self.title
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def review; end",
"def review\n end",
"def review\n @review\n end",
"def review\n fetch('restaurant.review')\n end",
"def show\n @search = Review.where(book_id: @book.id).search(params[:q])\n @reviews = @search.result.paginate(:page => params[:page]).order(rating: :desc)\n @se... | [
"0.6924698",
"0.68394214",
"0.65308785",
"0.63406754",
"0.6249963",
"0.62260455",
"0.6172125",
"0.6141527",
"0.60832494",
"0.6059209",
"0.60572183",
"0.60331154",
"0.6030414",
"0.6015279",
"0.6011027",
"0.6005913",
"0.5973382",
"0.59686726",
"0.5963196",
"0.59597284",
"0.5951... | 0.0 | -1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
lowvalue = 0
lowkey = nil
name_hash.each do |k, v|
if lowvalue == 0 || v < lowvalue
lowvalue = v
lowkey = k
end
end
lowkey
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585... | 0.0 | -1 |
Calculates the zone outdoor airflow requirement and divides by the zone area. | def outdoor_airflow_rate_per_area()
tot_oa_flow_rate_per_area = 0.0
# Find total area of the zone
sum_floor_area = 0.0
self.spaces.sort.each do |space|
sum_floor_area += space.floorArea
end
# Get the OA flow rate
tot_oa_flow_rate = outdoor_airflow_rate
# Calculate the per-area value
tot_oa_flow_rate_per_area = tot_oa_flow_rate / sum_floor_area
OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "For #{self.name}, OA per area = #{tot_oa_flow_rate_per_area.round(8)} m^3/s*m^2.")
return tot_oa_flow_rate_per_area
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_wrt_ground ()\n \n end",
"def zone_data\n @zone_data ||= ComplianceCheckerApi.clean_air_zones\n end",
"def calculate_area\n\n \tarea = 3.14*@radius*@radius\n\n end",
"def zone_for(px, pz, sz_bot, sz_top)\n # puts \"calculating zone: #{px}, #{pz}, #{sz_bot}, #{sz_top}\"\n zo... | [
"0.5946686",
"0.57066447",
"0.5657436",
"0.5652678",
"0.5532186",
"0.548349",
"0.5475536",
"0.54697883",
"0.5463417",
"0.5409423",
"0.54061574",
"0.53949296",
"0.53713185",
"0.53558147",
"0.5306924",
"0.5298165",
"0.52961504",
"0.5287804",
"0.52870107",
"0.5281989",
"0.525088... | 0.69650036 | 0 |
send internal stats to statsd Pass the request on to host given in config[:forwarder] | def response(env)
env.trace :response_beg
result_set = fetch_twitter_search(env.params['q'])
fetch_trstrank(result_set)
body = JSON.pretty_generate(result_set)
env.trace :response_end
[200, {}, body]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_stats\n first_time = @prev_stat.empty?\n stats = build_request\n @stat.keys.each { |k| stats[k] = @stat[k] - @prev_stat[k] }\n @prev_stat.replace(@stat)\n # These should be reported as absolute values\n [:mt, :ma, :mc].each {|k| @prev_stat[k] = 0}\n return if first_time\... | [
"0.6045585",
"0.5724333",
"0.5568101",
"0.55668396",
"0.5530404",
"0.54056144",
"0.532206",
"0.5266261",
"0.52397865",
"0.5228196",
"0.5218105",
"0.51749706",
"0.5154118",
"0.51450944",
"0.5140531",
"0.51368475",
"0.510697",
"0.50928515",
"0.5076645",
"0.5064666",
"0.5050981"... | 0.0 | -1 |
Function for testing a preprocessor | def test_preprocessor(preprocessor,input,expected)
# Prepare the output and the input streams
puts "Preparing the input and ouput streams..."
output = StringIO.new("")
# Process the input and exepected arguments.
if !input.respond_to?(:each_line) or input.is_a?(String) then
# input is actually a file name, open it.
input = File.open(input.to_s,"r")
end
if !expected.respond_to?(:each_line) or expected.is_a?(String) then
# expected is actually a file name, open it.
expected = StringIO.new(File.read(expected.to_s))
end
# Apply the preprocessor
puts "Applying the preprocessor..."
preprocessor.preprocess(input,output)
# Check the result
puts "Checking the result..."
output.rewind
check = output.string == expected.read
unless check
puts "*Error*: invalid expansion result."
iline = output.string.each_line
expected.rewind
expected.each_line.with_index do |exp_line,i|
line = iline.next
puts "exp_line=#{exp_line}"
puts "line=#{line}"
if exp_line != line then
puts "Expected line #{i+1}:\n#{exp_line}"
puts "got:\n#{line}"
end
end
return false
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(text, defines={})\n defines = defines.dup\n result = []\n active_stack = []\n active = true\n text.each_line do |line|\n case line\n when /^#\\s*define\\s+(\\w+)\\s+(\\w*)\\s*$/\n defines[$1] = $2 if active\n when /^#\\s*if\\s+(\\w+)\\s*$/\n active_stack.p... | [
"0.6495349",
"0.62951356",
"0.5799275",
"0.56953293",
"0.56180805",
"0.5600965",
"0.55765927",
"0.55765927",
"0.5574427",
"0.54751796",
"0.5471518",
"0.544628",
"0.5399563",
"0.5360098",
"0.5319129",
"0.52851754",
"0.5283044",
"0.52365017",
"0.5230837",
"0.52171445",
"0.51958... | 0.73244786 | 0 |
Function for testing a preprocessor on +string+ which should raise an +exception+ string. | def test_preprocessor_exception(preprocessor,string,exception)
input = StringIO.new(string)
output = StringIO.new("")
begin
$ppr.preprocess(input,output)
puts "*Error*: preprocessed without exception."
return false
rescue Exception => e
if e.to_s.include?(exception.to_s) then
puts "Got exception: <#{e}> as expected."
return true
else
puts "*Error*: unexpected exception.",
"Got <#{e}> but expecting <#{exception}>."
return false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected(s)\n abort \"#{s} Expected\"\nend",
"def expected(s)\n abort \"#{s} Expected\"\nend",
"def expected(s)\n abort \"#{s} Expected\"\nend",
"def expected(s)\n abort(\"#{s} Expected\")\nend",
"def check_and_raise_error(exception, message)\n fail exception unless exception.message.include?(... | [
"0.6391079",
"0.6391079",
"0.6391079",
"0.62662095",
"0.61464554",
"0.59670454",
"0.59539443",
"0.57638824",
"0.56721777",
"0.5646018",
"0.56321967",
"0.5612933",
"0.5612933",
"0.5597484",
"0.55878466",
"0.55815697",
"0.5571182",
"0.55111945",
"0.5491926",
"0.5490103",
"0.547... | 0.79451984 | 0 |
Write a statement that allows a member to be updated by their name and age. This should take in the attributes of name, age and id. | def update()
sql = "UPDATE members SET (name, age) = ($1, $2) WHERE id = $3"
values = [@name, @age, @id]
SqlRunner.run(sql, values)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @id = args[:id] ... | [
"0.68316185",
"0.68316185",
"0.68316185",
"0.68316185",
"0.68316185",
"0.68316185",
"0.68316185",
"0.68316185",
"0.68316185",
"0.6823033",
"0.66379356",
"0.6610382",
"0.6575947",
"0.6575947",
"0.6575947",
"0.6575947",
"0.6575947",
"0.6546459",
"0.6511765",
"0.6500765",
"0.648... | 0.83937657 | 0 |
GET /layers GET /layers.json | def index
@layers = Layer.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def layers\n @layers ||= GeoIQ.get(\"#{path}/layers.json\")#.parsed_response#.map {|layer| GeoIQ::Layer.new(layer.merge('map_id' => id)) }\n end",
"def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n # example output:\n # {\"layers\":[{\... | [
"0.7279001",
"0.72497946",
"0.7154866",
"0.7126919",
"0.7081883",
"0.69295835",
"0.6829735",
"0.680823",
"0.67551494",
"0.6469824",
"0.63476837",
"0.63476837",
"0.63476837",
"0.63358384",
"0.63241506",
"0.62927425",
"0.62418884",
"0.6232961",
"0.6230768",
"0.6151616",
"0.6119... | 0.69002324 | 6 |
GET /layers/1 GET /layers/1.json | def show; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @layers = Layer.where(:soil_id => params[:id])\n respond_to do |format|\n\t redirect_to @layers\n format.json { render json: @layers }\n end\n end",
"def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n # example output:\n ... | [
"0.7235129",
"0.7104609",
"0.7030094",
"0.68151236",
"0.680925",
"0.680925",
"0.680925",
"0.6799517",
"0.6769139",
"0.6747782",
"0.67386323",
"0.6706228",
"0.65614843",
"0.6478981",
"0.6474849",
"0.64008576",
"0.6391028",
"0.6255259",
"0.6249205",
"0.6248825",
"0.623721",
"... | 0.0 | -1 |
POST /layers POST /layers.json | def create
@layer = Layer.new(layer_params)
respond_to do |format|
if @layer.save
format.html { redirect_to @layer, notice: 'Layer was successfully created.' }
format.json { render :show, status: :created, location: @layer }
else
format.html { render :new }
format.json { render json: @layer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id,... | [
"0.72677904",
"0.6310305",
"0.62798345",
"0.614472",
"0.61137336",
"0.6094828",
"0.59819156",
"0.5915292",
"0.58255464",
"0.573704",
"0.5651584",
"0.5592616",
"0.558824",
"0.55731547",
"0.5570241",
"0.55668676",
"0.55303186",
"0.5524599",
"0.5389199",
"0.5388985",
"0.5377295"... | 0.6837488 | 1 |
PATCH/PUT /layers/1 PATCH/PUT /layers/1.json | def update
respond_to do |format|
if @layer.update(layer_params)
format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }
format.json { render :show, status: :ok, location: @layer }
else
format.html { render :edit }
format.json { render json: @layer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id... | [
"0.68992466",
"0.6510969",
"0.62880987",
"0.6225763",
"0.6203721",
"0.6189952",
"0.6153676",
"0.6041475",
"0.6029222",
"0.5970276",
"0.5939183",
"0.592965",
"0.5904634",
"0.58304435",
"0.58304435",
"0.5784704",
"0.57788324",
"0.57726455",
"0.575167",
"0.5747367",
"0.5741912",... | 0.67589664 | 1 |
DELETE /layers/1 DELETE /layers/1.json | def destroy
@layer.destroy
respond_to do |format|
format.html { redirect_to layers_url, notice: 'Layer was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @layer = Layer.find(params[:id])\n @layer.destroy\n\n respond_to do |format|\n format.html { redirect_to layers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@ru = request.original_url\n @ru = request.protocol + request.host_with_port + \"/layer... | [
"0.78472996",
"0.7678238",
"0.7382796",
"0.71779114",
"0.69176686",
"0.6854449",
"0.6821357",
"0.6779829",
"0.67483616",
"0.6718837",
"0.666472",
"0.6647262",
"0.66078705",
"0.65818965",
"0.64834356",
"0.6472717",
"0.6464855",
"0.6459053",
"0.64284456",
"0.6367784",
"0.636331... | 0.74983555 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_layer
@layer = Layer.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def layer_params
params.require(:layer).permit(:name, :category_id, :url, :params, :ckan_id, style: [:color])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
, :only=> [:index], :except=> [:index] GET /itineraries GET /itineraries.xml | def index
@travel = Travel.find(params[:travel_id])
@itineraries = Itinerary.order("updated_at DESC").page(params[:page])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @itineraries }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @itineraries = Itinerary.all\n end",
"def index\n @itineraries = Itinerary.all\n end",
"def index\n if current_user.admin?\n @itineraries = Itinerary.all\n else\n @itineraries = current_user.itineraries.where(user_id: current_user)\n end\n end",
"def index\... | [
"0.7479249",
"0.7479249",
"0.6942369",
"0.685942",
"0.677032",
"0.6704545",
"0.66994184",
"0.6650342",
"0.659711",
"0.65869355",
"0.6518687",
"0.65094143",
"0.6483438",
"0.64079654",
"0.64033204",
"0.63903254",
"0.6349762",
"0.63488084",
"0.6333364",
"0.6329936",
"0.6328428",... | 0.71393585 | 2 |
GET /itineraries/1 GET /itineraries/1.xml | def show
@travel = Travel.find(params[:travel_id])
@itinerary = Itinerary.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @itinerary }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @itineraries = Itinerary.all\n end",
"def index\n @itineraries = Itinerary.all\n end",
"def show\n @itinerary = Itinerary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @itinerary }\n end\n end",
"def index\n ... | [
"0.65740645",
"0.65740645",
"0.6447323",
"0.6446343",
"0.5797915",
"0.5753039",
"0.57413757",
"0.5699008",
"0.5695427",
"0.564668",
"0.5640403",
"0.5637766",
"0.5636691",
"0.5635733",
"0.56323534",
"0.561782",
"0.5585485",
"0.5582536",
"0.5530655",
"0.551377",
"0.5512706",
... | 0.60442054 | 4 |
GET /itineraries/new GET /itineraries/new.xml | def new
@travel = Travel.find(params[:travel_id])
@itinerary = Itinerary.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @itinerary }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @itinerary = Itinerary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @itinerary }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"de... | [
"0.7140163",
"0.6606518",
"0.6575284",
"0.65515393",
"0.65328044",
"0.6504189",
"0.64822537",
"0.6465794",
"0.64607304",
"0.6457424",
"0.64493275",
"0.6442685",
"0.6440516",
"0.6440371",
"0.6435936",
"0.64218444",
"0.64212686",
"0.64111525",
"0.64109015",
"0.64109015",
"0.641... | 0.7006599 | 1 |
POST /itineraries POST /itineraries.xml | def create
@travel = Travel.find(params[:travel_id])
@itinerary = @travel.itineraries.new(itinerary_param)
respond_to do |format|
if @itinerary.save
format.html { redirect_to(admin_travel_itineraries_url(@travel), :notice => 'Itinerary was successfully created.') }
format.xml { render :xml => @itinerary, :status => :created, :location => @itinerary }
else
format.html { render :action => "new" }
format.xml { render :xml => @itinerary.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @itinerary = Itinerary.new(params[:itinerary])\n\n respond_to do |format|\n if @itinerary.save\n format.html { redirect_to(@itinerary, :notice => 'Itinerary was successfully created.') }\n format.xml { render :xml => @itinerary, :status => :created, :location => @itinerary }\... | [
"0.6235668",
"0.61945355",
"0.608299",
"0.60691816",
"0.59933305",
"0.5863178",
"0.55561763",
"0.5553015",
"0.5519354",
"0.5519354",
"0.5433427",
"0.54239833",
"0.53787416",
"0.5376048",
"0.5360561",
"0.53298366",
"0.527455",
"0.52580273",
"0.52373093",
"0.5227974",
"0.522279... | 0.63862324 | 0 |
PUT /itineraries/1 PUT /itineraries/1.xml | def update
@travel = Travel.find(params[:travel_id])
@itinerary = @travel.itineraries.find(params[:id])
respond_to do |format|
if @itinerary.update_attributes(itinerary_param)
format.html { redirect_to([:admin, @travel, @itinerary], :notice => 'Itinerary was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @itinerary.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @itinerary = Itinerary.find(params[:id])\n\n respond_to do |format|\n if @itinerary.update_attributes(params[:itinerary])\n format.html { redirect_to(@itinerary, :notice => 'Itinerary was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { r... | [
"0.6382612",
"0.6382612",
"0.60382825",
"0.5923111",
"0.5890764",
"0.5890764",
"0.5890764",
"0.5890764",
"0.5890764",
"0.58807003",
"0.58211637",
"0.58105433",
"0.5786504",
"0.5738078",
"0.5725107",
"0.5702062",
"0.56957644",
"0.5679039",
"0.56260663",
"0.561253",
"0.5588719"... | 0.63508064 | 2 |
DELETE /itineraries/1 DELETE /itineraries/1.xml | def destroy
@itinerary = Itinerary.find(params[:id])
@itinerary.destroy
respond_to do |format|
format.html {
if params[:travel_id]
redirect_to admin_travels_path
else
redirect_to(admin_itineraries_url)
end
}
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @itinerary = Itinerary.find(params[:id])\n @itinerary.destroy\n\n respond_to do |format|\n format.html { redirect_to(itineraries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @itinerary = Itinerary.find(params[:id])\n @itinerary.destroy\n\n respond_t... | [
"0.69956183",
"0.69956183",
"0.6743824",
"0.65382975",
"0.6467187",
"0.63320094",
"0.6329817",
"0.6221559",
"0.61887836",
"0.6125579",
"0.6121814",
"0.6095245",
"0.60870564",
"0.6049358",
"0.60270804",
"0.60270804",
"0.60229075",
"0.60191625",
"0.6019059",
"0.60128295",
"0.60... | 0.61605877 | 9 |
private means that the methods defined here are internal to the object. (You can feed your dragon, but you can't ask him whether he's hungry) | def hungry?
@stuff_in_belly <= 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_method; end",
"def a_private_method\n\tend",
"def internal_methods; end",
"def private_method\n\tend",
"def private_method\n\tend",
"def a_private_method\n end",
"def private_method\n end",
"def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n ... | [
"0.75709295",
"0.75308",
"0.72926515",
"0.7290792",
"0.7290792",
"0.7256204",
"0.7248194",
"0.7180161",
"0.71619576",
"0.7072332",
"0.70420307",
"0.6957299",
"0.6957299",
"0.6957299",
"0.6957299",
"0.6798932",
"0.6791247",
"0.6764664",
"0.6747954",
"0.66750795",
"0.6612455",
... | 0.0 | -1 |
use a ? if the method returns true or false | def poopy?
@stuff_in_intestine >= 8
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def returns_something?; @return_type || !@returned_arguments.empty? end",
"def none?; end",
"def none?; end",
"def none?; end",
"def explicit?; end",
"def maybe; end",
"def result?; end",
"def success?(*) end",
"def ok? \n @funct == nil ? (return false) : (return true)\n end",
"def no? ; fals... | [
"0.7117324",
"0.70962876",
"0.70962876",
"0.70962876",
"0.703515",
"0.69747925",
"0.693275",
"0.6927996",
"0.6867952",
"0.6851343",
"0.6778832",
"0.6769453",
"0.6763325",
"0.6715651",
"0.67096716",
"0.6693344",
"0.66787106",
"0.66787106",
"0.66654265",
"0.66654265",
"0.664020... | 0.0 | -1 |
Confirms a loggedin user. | def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Please log in."
redirect_to login_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n ... | [
"0.70087826",
"0.6982988",
"0.6919373",
"0.688131",
"0.6845446",
"0.68326277",
"0.67944413",
"0.67929715",
"0.6642435",
"0.6624581",
"0.66114175",
"0.66022736",
"0.6589018",
"0.65539706",
"0.65349805",
"0.65303934",
"0.6512816",
"0.650312",
"0.64878744",
"0.6487622",
"0.64804... | 0.0 | -1 |
Confirms the correct user. | def correct_user
@user = User.find(params[:id])
redirect_to(root_url) unless current_user?(@user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n msg = \"You do not have permission to update another user's information\"\n require_correct_user(@user, msg)\n end",
"def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n... | [
"0.7474259",
"0.73411936",
"0.7317917",
"0.7183303",
"0.7174887",
"0.7049758",
"0.70130193",
"0.7012358",
"0.7006517",
"0.7006201",
"0.7003461",
"0.69663024",
"0.69136065",
"0.6911695",
"0.690295",
"0.6892608",
"0.68439376",
"0.6842948",
"0.68397075",
"0.683463",
"0.6826711",... | 0.6658565 | 86 |
Confirms an admin user. | def admin_user
redirect_to(root_url) unless current_user.admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm_admin\n \tunless session[:admin]\n \t\tflash[:notice] = \"You are not an admin.\"\n \t\tredirect_to(user_path( :id => session[:user_id]))\n \tend\n end",
"def admin_user\n\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless cu... | [
"0.79044944",
"0.767215",
"0.76483077",
"0.76210374",
"0.7605678",
"0.7605678",
"0.75945777",
"0.7588445",
"0.7588445",
"0.7503662",
"0.74675834",
"0.7451482",
"0.7424005",
"0.7411313",
"0.74107665",
"0.7402138",
"0.73993605",
"0.7358812",
"0.7329228",
"0.73179626",
"0.731276... | 0.0 | -1 |
This is where we pull the route out of the submitted slack command eg /tram 96 or tram route 96 will pull out '96' defaults to Route 109 (Montague St) | def determine_requested_route(slack_query)
submitted_text = slack_query.to_s
return STOP_INFO[:'96'] if submitted_text.include? '96'
STOP_INFO[:'109']
rescue NoMethodError
STOP_INFO[:'109']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route\n @route\n end",
"def get_route\n data = {\n visits: visits,\n fleet: fleet\n }\n\n data[:options] = options if options\n result = Util.send_request(\"POST\", \"vrp\", Routific.token, data)\n RoutificApi::Route.parse(result)\n end",
"def extract_route\n Xhiv... | [
"0.6169135",
"0.61304724",
"0.60252565",
"0.60091335",
"0.59387463",
"0.58733886",
"0.5801675",
"0.5563011",
"0.55381125",
"0.55105025",
"0.54996836",
"0.5484865",
"0.5476752",
"0.5425237",
"0.5415232",
"0.5413466",
"0.53956914",
"0.53589046",
"0.5357034",
"0.5327657",
"0.530... | 0.71136016 | 0 |
Complete the getMoneySpent function below. | def getMoneySpent(keyboards, drives, budget)
#
# Write your code here.
#
highest_combination = -1
keyboards.each do |keyboard|
drives.each do |drive|
sum = keyboard + drive
highest_combination = sum if sum <= budget && sum > highest_combination
end
end
highest_combination;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spent\n @spent ||= calculate_spent\n @spent.round(2)\n end",
"def calculate_total_money_spent\n return @trips.inject(0.0) { |sum, trip|\n trip.is_in_progress? ? sum + 0 : sum + trip.cost }\n end",
"def money_spent\n self.purchases.map { |p| p.price }.sum\n end",
"def spent... | [
"0.7412486",
"0.69516444",
"0.6569346",
"0.65418947",
"0.64871365",
"0.6442926",
"0.6400391",
"0.63180745",
"0.6279987",
"0.62655973",
"0.62361443",
"0.6215522",
"0.62104845",
"0.6206831",
"0.62035567",
"0.61856353",
"0.6165371",
"0.6160469",
"0.612236",
"0.6104932",
"0.60986... | 0.0 | -1 |
calls 'choose_hero' to display all the cards to the user, and assigns their choice to 'card' TTY prompt for the yes/no menu if 'yes', creates a new row in the card table for that specific user_id, assigning them that card_id asks if user wants to select another card, if they do it calls on itself to offer the choices again (and so on) | def choose_and_add_card_to_user_deck
prompt = TTY::Prompt.new
card = choose_hero
response = prompt.select('Do you want to add this card to your collection?', %w(Yes No))
if response == "Yes"
added_card = UserCard.create(user_id: self.id, card_id: card.id)
puts "#{added_card.card.name.upcase} was added to your collection."
sleep(1)
end
system('clear')
title
response = prompt.select('Do you want to look for another card?', %w(Yes No))
if response == "Yes"
self.choose_and_add_card_to_user_deck
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_hero\n prompt = TTY::Prompt.new\n names = Cards.all.map {|cards| cards[\"name\"]}\n selected_name = prompt.select('Choose a character', names, filter: true, cycle: true, help: \"(Start typing to filter results)\",help_color: :green, active_color: :yellow)\n hero = Cards.find_by(name: selected_name)\... | [
"0.7150788",
"0.6612205",
"0.62899435",
"0.61564034",
"0.6040731",
"0.5967543",
"0.5849028",
"0.5836454",
"0.5829843",
"0.58213675",
"0.57313234",
"0.5695235",
"0.5665268",
"0.5647897",
"0.5610488",
"0.557705",
"0.5571621",
"0.55615777",
"0.5554705",
"0.5548276",
"0.55435485"... | 0.7984649 | 0 |
get 5 random cards from the cards table, add them to the user's collection | def open_pack
cards = Card.all.sample(5)
cards.each { |card| UserCard.create(user_id: self.id, card_id: card.id)}
names = cards.map { |card| card.name }
puts "#{names.join(", ").upcase} ...were added to your collection!"
sleep(3)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_random\n @card_list.pick_random\n end",
"def pick_random\n @card_list.pick_random\n end",
"def pick_random\r\n @card_list.pick_random\r\n end",
"def get_random_user_list \n @users = user_list.sample(5).insert(rand(5), {name: \"ME\", bot: false})\n end",
"def pick_player_card\n # T... | [
"0.6734276",
"0.6734276",
"0.66865104",
"0.6645731",
"0.6640976",
"0.6620047",
"0.6483026",
"0.64768994",
"0.64655495",
"0.6432756",
"0.6413382",
"0.6413295",
"0.63901496",
"0.63281554",
"0.63027066",
"0.6283214",
"0.6276174",
"0.62429744",
"0.62324756",
"0.61876684",
"0.6175... | 0.6795567 | 0 |
gets all the users cards and displays them in number order also displays count message, depending on whether they have some or none had to use 'reload' because rails was using cached array, had to force to go back to db and refresh the card for the user. | def check_collection
system('clear')
title
your_cards = self.reload.cards.sort
if your_cards == []
puts "====================================================================="
puts "Your collection is empty"
puts "====================================================================="
else
puts "====================================================================="
puts "----- YOU HAVE #{your_cards.length} CARD(S) IN YOUR COLLECTION ------"
puts "====================================================================="
your_cards.each do |card|
puts "|NUMBER: #{card["id"]} |NAME: #{card["name"].upcase} |INTELLIGENCE: #{card["intelligence"]} |STRENGTH: #{card["strength"]} |SPEED: #{card["speed"]} |DURABILITY: #{card["durability"]} |POWER: #{card["power"]} |COMBAT: #{card["combat"]}"
end
puts "====================================================================="
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_cards(user)\n user.cards.count\n end",
"def user_list\n current_user_cards = current_user.cards\n if !current_user_cards || current_user_cards.size.to_i == 0\n flash[:notice] = _('You_have_no_view_permission')\n redirect_to(:root) && (return false)\n end\n\n @page_title = _('Car... | [
"0.73596275",
"0.69653857",
"0.68645096",
"0.68645096",
"0.6731877",
"0.672236",
"0.66587573",
"0.6658604",
"0.65686303",
"0.6558864",
"0.6306203",
"0.6298849",
"0.6282824",
"0.6282824",
"0.6262068",
"0.6242672",
"0.6233264",
"0.62326777",
"0.6229537",
"0.622274",
"0.622274",... | 0.57744557 | 54 |
iterates over all the cards for that user, passes resulting array of names to TTY prompt to display choices. choice from the list of names is stored in selected_card_name the card object for that choice is stored in selected_card the UserCard object from that specific user's collection is stored in choice choice is destroyed if the user chooses yes, confirmation message displayed. if user decides not to delete, check_collection is called to return to users card list | def delete_card
prompt = TTY::Prompt.new
your_cards = self.cards
card_names = your_cards.map { |card| card["name"] }
selected_card_name = prompt.select('Choose a character to delete', card_names, filter: true, cycle: true, help: "(Start typing to filter results)", help_color: :green, active_color: :yellow)
selected_card = Card.find_by(name: selected_card_name)
choice = UserCard.find_by user_id: self.id, card_id: selected_card.id
response = prompt.select("Are you sure you want to delete #{selected_card_name.upcase}?", %w(Yes No))
if response == "Yes"
choice.destroy
bar = TTY::ProgressBar.new("Deleting #{selected_card_name.upcase} [:bar]", total: 30)
30.times do
sleep(0.05)
bar.advance(1)
end
puts "#{choice.card.name.upcase} was deleted from your collection!"
sleep(1)
system('clear')
title
else
check_collection
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_hand_cards(card_array) \n user_choice = \"\"\n while user_choice != \"⬅️ BACK ⬅️\" && user_choice != \"🗑 DELETE READING 🗑\" do\n user_choice = prompt.select(\"🔮 #{self.user.name}, Select a card to see more details.\") do |menu|\n card_emoji_string = \... | [
"0.7013456",
"0.6899509",
"0.640083",
"0.616436",
"0.60829204",
"0.58941877",
"0.5840707",
"0.5636257",
"0.56241745",
"0.5516593",
"0.5497286",
"0.5464719",
"0.53647786",
"0.53544223",
"0.5337183",
"0.53226656",
"0.53090215",
"0.53084224",
"0.5281249",
"0.52529925",
"0.524259... | 0.7135518 | 0 |
finds the users cards, removes any duplicates and subtracts that number from total cards (160) Displays message showing how many cards user still needs to complete colletion. | def cards_left_to_collect
card_ids = UserCard.select {|card| card["user_id"] == self.id}
remaining = Card.all.count - card_ids.map { |card| card["card_id"] }.uniq.count
if remaining == 0
puts "====================================================================="
puts "Congratulations, you have completed the Superhero card album!!"
puts "====================================================================="
else
puts "====================================================================="
puts "You still have #{remaining} cards left to collect..."
puts "====================================================================="
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_cards(to_remove)\n to_remove.each { |num| @cards.delete_at(num - 1) }\n end",
"def full_dance_card\n\t\tif @card.length > 5\n\t\t\tputs \"Your dance card is full! You have to dance with #{@card[0]} before you can add #{@card[-1]}\"\n\t\t\t@card.delete_at(-1)\n\t\tend\n\t\t@card\n\tend",
"def rem... | [
"0.63603973",
"0.628325",
"0.6102922",
"0.6093756",
"0.60720515",
"0.60661525",
"0.60602164",
"0.6051767",
"0.60204136",
"0.5976792",
"0.59513927",
"0.5942144",
"0.5912989",
"0.59125614",
"0.59082735",
"0.59044975",
"0.5869017",
"0.5859576",
"0.5817744",
"0.5808296",
"0.58017... | 0.76203895 | 0 |
Sin definicion de autoridad por ser requerido por no autenticados | def atributos_index
[ :id,
:nusuario,
:nombre,
:email,
:grupo_ids,
:foto,
:habilitado,
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth\n end",
"def auth\n end",
"def set_usuario\n \n end",
"def auth\n {}\n end",
"def force_authn?\n force_authn == true\n end",
"def verificar_autenticado_admin\n unless session[:usuario_admin] #else if,tiene quer ser falso\n bitacora \"Intento de accceso... | [
"0.67458934",
"0.67458934",
"0.67062426",
"0.6643799",
"0.66048145",
"0.6585316",
"0.65173703",
"0.65037376",
"0.6490919",
"0.64673775",
"0.6428895",
"0.6423133",
"0.6423133",
"0.64113796",
"0.6404891",
"0.6384968",
"0.63591146",
"0.63507587",
"0.6345943",
"0.6340451",
"0.633... | 0.0 | -1 |
Parse JSON object using version 1 formatting | def build_balances(balance_hashes, updated_at, config, user)
balances = []
balance_hashes.each do |balance|
balance = balance.to_h.compact.symbolize_keys
config = config.to_h.compact.symbolize_keys
next unless user == balance[:user]
balances << Balance.new(
user: balance.fetch(:user).to_s,
project: balance.fetch(:project, nil).to_s,
value: balance.fetch(:value).to_i,
project_type: config.fetch(:project_type, nil).to_s,
unit: config[:unit].to_s,
updated_at: Time.at(updated_at.to_i),
)
end
balances
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reparsed_from_json\n self.is_a?(String) ? JSON.parse(self) : JSON.parse(self.to_json)\n end",
"def parse_json(json)\n ::JSON.parse(json, :create_additions => false)\n end",
"def parse json; return JSON.parse File.read json end",
"def parse json; return JSON.parse File.read json end",
"d... | [
"0.6935208",
"0.6877814",
"0.6757478",
"0.6757478",
"0.6548818",
"0.6495447",
"0.6486765",
"0.6416369",
"0.6413831",
"0.6337644",
"0.63295853",
"0.62641597",
"0.6240166",
"0.62400115",
"0.6239351",
"0.62240165",
"0.62106436",
"0.62076354",
"0.6179142",
"0.6171906",
"0.6166485... | 0.0 | -1 |
Unit + balance text | def units_balance
return "#{@unit} balance" if @unit.present?
'Balance'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance_inquiry\n \"$#{'%.2f' % @balance}\"\n end",
"def acc_balance\n @page.css(\"span[data-semantic = 'header-available-balance-amount']\").text.to_money.to_f\n end",
"def display_balance\n \"Your balance is $#{self.balance}.\"\n end",
"def print_balance\n # $50.00\n # \"$\" + bal... | [
"0.69723725",
"0.6871718",
"0.6818697",
"0.6796447",
"0.67860216",
"0.67765105",
"0.66903144",
"0.6674578",
"0.66383916",
"0.66375893",
"0.6589841",
"0.65782994",
"0.64387417",
"0.6420365",
"0.6417079",
"0.63910955",
"0.63707876",
"0.635426",
"0.6338826",
"0.6311554",
"0.6288... | 0.80642486 | 0 |
GET /purchase_templates/1 GET /purchase_templates/1.json | def show
@purchase_template = PurchaseTemplate.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @purchase_template }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end",
"def details\n response = get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end",
"def details\n response = CreateSend.get \"/templates/#{template_id}.json\",... | [
"0.7033742",
"0.6797822",
"0.6760187",
"0.6628869",
"0.6519792",
"0.6475918",
"0.6446626",
"0.6438746",
"0.6418988",
"0.64068156",
"0.6380155",
"0.63623977",
"0.6353484",
"0.63275087",
"0.6316209",
"0.6314859",
"0.6303227",
"0.62912726",
"0.6265755",
"0.61693954",
"0.61551005... | 0.7163538 | 0 |
GET /purchase_templates/new GET /purchase_templates/new.json | def new
@purchase_template = PurchaseTemplate.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @purchase_template }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @template = Template.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @template }\n end\n end",
"def new\n @template = Template.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json... | [
"0.7423524",
"0.73924184",
"0.7304808",
"0.7259726",
"0.7040678",
"0.6951944",
"0.6935729",
"0.6935729",
"0.6934248",
"0.6933504",
"0.6931821",
"0.69216204",
"0.6919294",
"0.68666327",
"0.68563426",
"0.6841217",
"0.6820332",
"0.6755063",
"0.6751302",
"0.67326474",
"0.66989315... | 0.7994639 | 0 |
POST /purchase_templates POST /purchase_templates.json | def create
@purchase_template = PurchaseTemplate.new(params[:purchase_template])
respond_to do |format|
if @purchase_template.save
format.html { redirect_to @purchase_template, notice: 'Purchase template was successfully created.' }
format.json { render json: @purchase_template, status: :created, location: @purchase_template }
else
format.html { render action: "new" }
format.json { render json: @purchase_template.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(values)\n @client.call(method: :post, path: 'templates', body_values: values)\n end",
"def new\n @purchase_template = PurchaseTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase_template }\n end\n end",
"def crea... | [
"0.6356242",
"0.6261244",
"0.6189218",
"0.61683726",
"0.60694146",
"0.60101485",
"0.59717405",
"0.5919194",
"0.5919087",
"0.59183186",
"0.5911822",
"0.5900967",
"0.5896168",
"0.5880846",
"0.58708686",
"0.5852473",
"0.5828609",
"0.5827926",
"0.5781348",
"0.5766396",
"0.5756258... | 0.70198846 | 0 |
PUT /purchase_templates/1 PUT /purchase_templates/1.json | def update
@purchase_template = PurchaseTemplate.find(params[:id])
respond_to do |format|
if @purchase_template.update_attributes(params[:purchase_template])
format.html { redirect_to @purchase_template, notice: 'Purchase template was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @purchase_template.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @purchase_template = PurchaseTemplate.new(params[:purchase_template])\n\n respond_to do |format|\n if @purchase_template.save\n format.html { redirect_to @purchase_template, notice: 'Purchase template was successfully created.' }\n format.json { render json: @purchase_template... | [
"0.63873535",
"0.621092",
"0.61192244",
"0.6111065",
"0.5955919",
"0.5936143",
"0.5934081",
"0.59271586",
"0.5885969",
"0.5873962",
"0.58681446",
"0.58678555",
"0.5860224",
"0.5846383",
"0.582313",
"0.5819126",
"0.58014965",
"0.5798079",
"0.57956415",
"0.578678",
"0.5750142",... | 0.68874705 | 0 |
DELETE /purchase_templates/1 DELETE /purchase_templates/1.json | def destroy
@purchase_template = PurchaseTemplate.find(params[:id])
@purchase_template.destroy
respond_to do |format|
format.html { redirect_to purchase_templates_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n super \"/templates/#{template_id}.json\", {}\n end",
"def delete\n response = CreateSend.delete \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @invoice_template = InvoiceTemplate.find(params[:id])\n @invoice_template.destroy\n\n respond_to do |format|\n ... | [
"0.7832097",
"0.74690986",
"0.7395878",
"0.71783584",
"0.7145888",
"0.7102929",
"0.7047544",
"0.6977394",
"0.69690007",
"0.6961701",
"0.69601715",
"0.69389844",
"0.6924059",
"0.6904915",
"0.6900637",
"0.68830615",
"0.6869523",
"0.6860889",
"0.68577814",
"0.6842971",
"0.684057... | 0.7988417 | 0 |
A callback initiated after successfully authenticating. This can be used to insert your own logic that is only run after the user successfully authenticates. | def after_custom_authentication
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_custom_authentication; end",
"def callback\n rpx_auth\n after_auth(params[:on_complete_url])\n end",
"def callback\n # This stores all the user information that came from Auth0\n # and the IdP\n userinfo = request.env['omniauth.auth']\n\n begin\n result = SessionService.proces... | [
"0.71794266",
"0.7014709",
"0.6980848",
"0.6835151",
"0.6830764",
"0.6717308",
"0.65840584",
"0.65593106",
"0.6554135",
"0.65537554",
"0.6539213",
"0.6475947",
"0.64705765",
"0.64536464",
"0.64536464",
"0.64243644",
"0.63222504",
"0.6286123",
"0.6268505",
"0.6256627",
"0.6246... | 0.7001163 | 2 |
returns two arrays that contain first half and second half of OG array, respectively if OG array conatins odd no. of elements, middle element should be placed in first array | def halvsies(array)
first_half = array.slice(0, (array.size / 2.0).ceil)
second_half = array.slice(first_half.size, array.size - first_half.size)
[first_half, second_half]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def halvsies(arr)\n \n left_array = []\n right_array = []\n middle_index = arr.size / 2\n if arr.size.even?\n left_array = arr[0...middle_index]\n right_array = arr[middle_index..-1]\n elsif\n left_array = arr[0..middle_index]\n right_array = arr[(middle_index + 1)..-1]\n end\n [left_array, rig... | [
"0.6855742",
"0.6705341",
"0.66929805",
"0.6681913",
"0.66708577",
"0.65822643",
"0.65669787",
"0.6526818",
"0.6522265",
"0.6495019",
"0.649468",
"0.64913523",
"0.64705855",
"0.6461506",
"0.64570683",
"0.6455686",
"0.6454684",
"0.6453713",
"0.64503366",
"0.6422796",
"0.639496... | 0.64413697 | 23 |
Called after every ftp_test method runs. Can be used to tear down fixture information. | def teardown
@browser.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_teardown; end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n fakefs_original_teardown\n FakeFS.deactivate!\n end",
"def teardown\n end",
"def teardown\n FakeFS::FileSystem.clear # wipe file system for new test\n end",
"def teardown\... | [
"0.7567953",
"0.7354274",
"0.7354274",
"0.7322123",
"0.7277413",
"0.72636205",
"0.72574455",
"0.72574455",
"0.72574455",
"0.72574455",
"0.72574455",
"0.72574455",
"0.72574455",
"0.72574455",
"0.72409624",
"0.7187585",
"0.7187585",
"0.71751785",
"0.7147212",
"0.7147212",
"0.71... | 0.0 | -1 |
GET /serie_detalles GET /serie_detalles.json | def index
respond_to do |format|
format.html
format.json { render json: SerieDetallesDatatable.new(view_context) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findreg\n @detalles = Detalle.find(params[:id])\n render json: @detalles\n end",
"def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end",
"def set_serie_... | [
"0.7128526",
"0.7099706",
"0.6770504",
"0.6636597",
"0.65761757",
"0.6518643",
"0.64323765",
"0.63998795",
"0.6349028",
"0.63182974",
"0.63060415",
"0.6298451",
"0.628591",
"0.62137115",
"0.6195701",
"0.61908156",
"0.61678743",
"0.6145121",
"0.6142647",
"0.6125281",
"0.612405... | 0.63816386 | 8 |
GET /serie_detalles/1 GET /serie_detalles/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findreg\n @detalles = Detalle.find(params[:id])\n render json: @detalles\n end",
"def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end",
"def set_serie_... | [
"0.72496206",
"0.70748633",
"0.6994998",
"0.6764214",
"0.672888",
"0.6720816",
"0.6486747",
"0.64737076",
"0.64347637",
"0.64201534",
"0.64161104",
"0.6398771",
"0.63864684",
"0.63847935",
"0.63584846",
"0.6349591",
"0.63480693",
"0.6347247",
"0.6310564",
"0.6308767",
"0.6294... | 0.0 | -1 |
POST /serie_detalles POST /serie_detalles.json | def create
@serie_detalle = SerieDetalle.new(serie_detalle_params)
respond_to do |format|
if @serie_detalle.save
format.html { redirect_to @serie_detalle, notice: 'Serie detalle was successfully created.' }
format.json { render :show, status: :created, location: @serie_detalle }
else
format.html { render :new }
format.json { render json: @serie_detalle.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_serie_detalle\n @serie_detalle = SerieDetalle.find(params[:id])\n end",
"def create\n @detalle = Detalle.new(params[:detalle])\n\n respond_to do |format|\n if @detalle.save\n format.html { redirect_to @detalle, notice: 'Detalle was successfully created.' }\n format.json {... | [
"0.66736126",
"0.65056723",
"0.64361787",
"0.64031804",
"0.6363406",
"0.6248238",
"0.612041",
"0.6109776",
"0.6064104",
"0.6048287",
"0.60350007",
"0.60214967",
"0.6021142",
"0.6006228",
"0.5938662",
"0.5898981",
"0.5842851",
"0.5834577",
"0.5831961",
"0.58063686",
"0.577489"... | 0.72542274 | 0 |
PATCH/PUT /serie_detalles/1 PATCH/PUT /serie_detalles/1.json | def update
respond_to do |format|
if @serie_detalle.update(serie_detalle_params)
format.html { redirect_to @serie_detalle, notice: 'Serie detalle was successfully updated.' }
format.json { render :show, status: :ok, location: @serie_detalle }
else
format.html { render :edit }
format.json { render json: @serie_detalle.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @detalle = Detalle.find(params[:id])\n\n respond_to do |format|\n if @detalle.update_attributes(params[:detalle])\n format.html { redirect_to @detalle, notice: 'Detalle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | [
"0.64240843",
"0.64024067",
"0.63983446",
"0.6395097",
"0.632229",
"0.6239431",
"0.6237358",
"0.6223793",
"0.62021613",
"0.6168096",
"0.6162601",
"0.6157188",
"0.61179274",
"0.60848266",
"0.6072449",
"0.6063843",
"0.6060373",
"0.60560036",
"0.6037477",
"0.6009106",
"0.6006241... | 0.7083026 | 0 |
DELETE /serie_detalles/1 DELETE /serie_detalles/1.json | def destroy
@serie_detalle.destroy
respond_to do |format|
format.html { redirect_to serie_detalles_url, notice: 'Serie detalle was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @detalle = Detalle.find(params[:id])\n @detalle.destroy\n\n respond_to do |format|\n format.html { redirect_to detalles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @detalle.destroy\n respond_to do |format|\n format.html { redirect_to detal... | [
"0.73147297",
"0.718174",
"0.7150113",
"0.7145443",
"0.7134422",
"0.7033046",
"0.70142925",
"0.70011634",
"0.6989134",
"0.6988446",
"0.6988412",
"0.6986596",
"0.6984534",
"0.69602686",
"0.69504493",
"0.69421995",
"0.6934067",
"0.6932513",
"0.69140375",
"0.6913419",
"0.6912214... | 0.7530127 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.