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 |
|---|---|---|---|---|---|---|
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/MethodLength Return stdin | def stdin(*); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stdin; end",
"def stdin\n raise \"Not implemented\"\n end",
"def stdin\n $stdin\n end",
"def gets\n return $stdin.gets\n end",
"def stdin_pipe\n @stdin\n end",
"def get_stdin(message)\n print message\n STDIN.gets.chomp\nend",
"def read_stdin\n open_connection\... | [
"0.83643186",
"0.8096218",
"0.7991921",
"0.7720399",
"0.76294756",
"0.75246465",
"0.74861115",
"0.7483898",
"0.7402509",
"0.73938453",
"0.7348837",
"0.7348837",
"0.7321067",
"0.7318852",
"0.7306027",
"0.7302038",
"0.72705203",
"0.72202075",
"0.71417606",
"0.71417606",
"0.7092... | 0.78862923 | 4 |
the statement from exercise 3 in a method and wrap the new case statement in a method | def num_between_if number
if number >= 0 && number <= 50
puts "#{number} is between 0 and 50"
elsif number >= 51 && number <= 100
puts "#{number} is between 51 and 100"
elsif number > 100
puts "Hey, wait a minute, #{number} is greater than 100!"
else
puts "Hey, what's the big deal, #{number} is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cases()\n \n end",
"def case!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = CASE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 144:8: 'case'\n match( \"case\" )\n\... | [
"0.7380496",
"0.6968513",
"0.6867336",
"0.6764057",
"0.657653",
"0.65407264",
"0.64948165",
"0.64097106",
"0.630841",
"0.62841976",
"0.621587",
"0.6195972",
"0.6180181",
"0.61216426",
"0.6120508",
"0.6082053",
"0.606463",
"0.6047626",
"0.6030995",
"0.6016295",
"0.60154593",
... | 0.0 | -1 |
GET /tuhu/products GET /tuhu/products.json | def index
# @tuhu_products = Tuhu::Product.all
per_page = params[:per_page] || 100
if params[:detail_id].present?
@tuhu_detail = Tuhu::Detail.find(params[:detail_id])
@tuhu_products = @tuhu_detail.products.paginate(:page => params[:page], :per_page => per_page)
else
@q = Tuhu::Prod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def products\n request :public, :get, :products\n end",
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def user_products\n @products = current_user.products\n\n respond_to do |format|\n format.html\n for... | [
"0.7832771",
"0.7747772",
"0.75537175",
"0.7489661",
"0.74208707",
"0.7414456",
"0.73174715",
"0.7291248",
"0.72327155",
"0.72280216",
"0.720447",
"0.72026366",
"0.7202395",
"0.7202395",
"0.7202395",
"0.71885073",
"0.71608144",
"0.71608144",
"0.71608144",
"0.71608144",
"0.715... | 0.0 | -1 |
GET /tuhu/products/1 GET /tuhu/products/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end",
"def products\n ... | [
"0.757172",
"0.7526342",
"0.7424074",
"0.7352822",
"0.72374594",
"0.72364944",
"0.7176978",
"0.7173357",
"0.7155844",
"0.7148352",
"0.7137486",
"0.71245843",
"0.707588",
"0.706099",
"0.7053565",
"0.70519125",
"0.7045701",
"0.7039324",
"0.70244044",
"0.7024193",
"0.7024193",
... | 0.0 | -1 |
POST /tuhu/products POST /tuhu/products.json | def create
@tuhu_product = Tuhu::Product.new(tuhu_product_params)
respond_to do |format|
if @tuhu_product.save
format.html { redirect_to @tuhu_product, notice: 'Product was successfully created.' }
format.json { render :show, status: :created, location: @tuhu_product }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n if params[:products]\n params[:products].each do |product|\n @product = Product.new(name: product[:name],\n brand: product[:brand],\n model: product[:model],\n sku: product[:sku],\n ... | [
"0.7215345",
"0.71647197",
"0.7108526",
"0.70605594",
"0.70391554",
"0.69894654",
"0.69710493",
"0.69618016",
"0.6882492",
"0.6810066",
"0.68027186",
"0.67850286",
"0.67763263",
"0.6770949",
"0.6770942",
"0.6767039",
"0.67512655",
"0.6750045",
"0.6725521",
"0.6693707",
"0.667... | 0.7239297 | 0 |
PATCH/PUT /tuhu/products/1 PATCH/PUT /tuhu/products/1.json | def update
respond_to do |format|
if @tuhu_product.update(tuhu_product_params)
format.html { redirect_to @tuhu_product, notice: 'Product was successfully updated.' }
format.json { render :show, status: :ok, location: @tuhu_product }
else
format.html { render :edit }
forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def update\n updateProduct = Product.find_by_id(params[:id])\n updateProduct.update(products_params)\n ... | [
"0.73219967",
"0.6970398",
"0.6917868",
"0.69010246",
"0.6894449",
"0.68242395",
"0.68131024",
"0.67952406",
"0.6725487",
"0.6712762",
"0.670971",
"0.6683415",
"0.6678409",
"0.66767925",
"0.666498",
"0.6661566",
"0.6655332",
"0.6647394",
"0.6642006",
"0.6637489",
"0.66287607"... | 0.66940767 | 11 |
DELETE /tuhu/products/1 DELETE /tuhu/products/1.json | def destroy
@tuhu_product.destroy
respond_to do |format|
format.html { redirect_to tuhu_products_url, notice: 'Product was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(options = nil)\n request = Request.new(@client)\n path = \"/products/\" + CGI.escape(@id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.delete(path, data, options))\n return_values = Array.new\n \n return_values.push(response.success)\n\n ... | [
"0.73900855",
"0.7360286",
"0.7320688",
"0.7279071",
"0.7242234",
"0.72023135",
"0.7168319",
"0.7132087",
"0.71238965",
"0.7063353",
"0.7063353",
"0.7063353",
"0.7061265",
"0.7057552",
"0.7053102",
"0.70518583",
"0.7047025",
"0.7039778",
"0.70369905",
"0.703197",
"0.7031201",... | 0.71515954 | 7 |
Use callbacks to share common setup or constraints between actions. | def set_tuhu_product
@tuhu_product = Tuhu::Product.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 tuhu_product_params
params.require(:tuhu_product).permit(:kind_id, :img, :name, :price, :category, :url, :remark)
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.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
GET /hosts GET /hosts.json | def index
@page = params[:page].nil? ? 1 : params[:page].to_i
@page_max = Host.count / PAGE_SIZE
@all_hosts = Host.order('name ASC')
@count = @all_hosts.count
@hosts = @all_hosts.offset((@page - 1) * PAGE_SIZE).limit(PAGE_SIZE)
respond_to do |format|
format.html
format.json { render... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @host = Host.find_by(hostname: params[:id])\n\n render json: @host\n end",
"def show\n @host = Host.find(params[:id])\n\n render json: @host\n end",
"def index_hosts\n load_service\n return if (@service.blank?)\n\n # Preload hosts\n @hosts = Host.where(:_id.in => @service.h... | [
"0.7088033",
"0.70378006",
"0.6944941",
"0.6874096",
"0.67734486",
"0.67717105",
"0.669724",
"0.6679633",
"0.66324914",
"0.66318154",
"0.66227007",
"0.65361637",
"0.6499985",
"0.6450964",
"0.64043474",
"0.63485855",
"0.6337234",
"0.63046414",
"0.63046414",
"0.63046414",
"0.62... | 0.6917857 | 3 |
GET /hosts/1 GET /hosts/1.xml | def show
@host = Host.find(params[:id])
@stages = @host.stages.uniq.sort_by{|x| x.project.name}
respond_to do |format|
format.html
format.xml { render :xml => @host.to_xml }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_host( host_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Zerigo::DNS::GetHost.new,\n :path => \"/api/1.1/hosts/#{host_id}.xml\"\n )\n end",
"def index\n @hosts = Host.find(:all)\n\n resp... | [
"0.6853675",
"0.681206",
"0.6649823",
"0.64610934",
"0.63096195",
"0.5975651",
"0.59374",
"0.5811812",
"0.57539123",
"0.5726929",
"0.5721294",
"0.56879216",
"0.56728065",
"0.56728065",
"0.56728065",
"0.5645241",
"0.5611194",
"0.5611194",
"0.5591727",
"0.5590334",
"0.55885506"... | 0.5220701 | 50 |
POST /hosts POST /hosts.xml | def create
@host = Host.new(params[:host])
respond_to do |format|
if @host.save
flash[:notice] = 'Host was successfully created.'
format.html { redirect_to host_url(@host) }
format.xml { head :created, location: host_url(@host) }
else
format.html { render action: 'n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_v11_hosts_post(opts = {})\n api_v11_hosts_post_with_http_info(opts)\n return nil\n end",
"def create\n @host = Host.new(params[:host])\n\n respond_to do |format|\n if @host.save\n flash[:notice] = 'Host was successfully created.'\n format.html { redirect_to host_url(... | [
"0.6217583",
"0.5977078",
"0.5868913",
"0.5861055",
"0.5791446",
"0.57794714",
"0.57728463",
"0.5711244",
"0.56862915",
"0.55999106",
"0.5591323",
"0.55620235",
"0.55283296",
"0.5446096",
"0.5394443",
"0.537676",
"0.53762126",
"0.53716004",
"0.5367647",
"0.5367453",
"0.535827... | 0.5948608 | 2 |
PUT /hosts/1 PUT /hosts/1.xml | def update
@host = Host.find(params[:id])
respond_to do |format|
if @host.update_attributes(params[:host])
flash[:notice] = 'Host was successfully updated.'
format.html { redirect_to host_url(@host) }
format.xml { head :ok }
else
format.html { render action: 'edit' ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def upd... | [
"0.6893303",
"0.65440434",
"0.59790087",
"0.59780055",
"0.5976133",
"0.5951151",
"0.59372437",
"0.5901447",
"0.5810048",
"0.57922465",
"0.57342803",
"0.57201606",
"0.5706062",
"0.564316",
"0.56045896",
"0.55910385",
"0.5580823",
"0.5580823",
"0.5580823",
"0.5580574",
"0.55691... | 0.59002805 | 8 |
DELETE /hosts/1 DELETE /hosts/1.xml | def destroy
@host = Host.find(params[:id])
@host.destroy
respond_to do |format|
flash[:notice] = 'Host was successfully deleted.'
format.html { redirect_to hosts_url }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @host = Host.find(params[:id])\n @host.destroy\n\n respond_to do |format|\n format.html { redirect_to(hosts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @host = Host.find(params[:id])\n @host.destroy\n\n respond_to do |format|\n format.html { r... | [
"0.7046929",
"0.7046929",
"0.6974969",
"0.69042426",
"0.6683111",
"0.6647115",
"0.65220726",
"0.6491406",
"0.6460072",
"0.6409267",
"0.64051956",
"0.63846856",
"0.63651687",
"0.6360165",
"0.6357054",
"0.6351542",
"0.6348323",
"0.6342605",
"0.63017976",
"0.6295608",
"0.6288578... | 0.6729028 | 5 |
Creates instance from .sln file Initializes solution's semantic version and absolute path to it's file +file+:: absolute or relative path to .sln file | def initialize(file)
@file = File.expand_path(file)
@dir = File.dirname(@file)
@semver = Versioning.find(@dir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init solution\n FileUtils.touch(file_path(solution))\n end",
"def initialize(file)\n @file = File.expand_path(file)\n fail \"Can't find file #{@file}\" unless File.exist?(@file)\n @dir = File.dirname(@file)\n IO.readlines(@file).each { |line| initialize_data line }\n @configurati... | [
"0.6720702",
"0.6078939",
"0.57380956",
"0.5322824",
"0.52744585",
"0.52573806",
"0.5256799",
"0.52380085",
"0.5211382",
"0.51994985",
"0.5194608",
"0.5189537",
"0.515106",
"0.51377666",
"0.5125425",
"0.5107505",
"0.5090274",
"0.50178355",
"0.5000943",
"0.50003916",
"0.497914... | 0.61109054 | 1 |
Overrides string representation. Spawned to multiple lines | def to_s
s = '------------'
s += "\nFile: #{@file}"
s += "\nVersion: #{build_version}"
s += "\nProjects:" unless projects.empty?
projects.each { |p| s += "\n\t#{p}" }
s + "\n------------"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n [\n self.line_01,\n self.line_02,\n self.line_03,\n ].join(\"\\n\")\n end",
"def to_s\n join(\"\\n\")\n end",
"def to_s\n render().join \"\\n\"\n end",
"def serialize\n lf = \"\\n\"\n (@cmds.join lf) + lf\n end",
"def to_string\n render().join \"... | [
"0.69638944",
"0.6505917",
"0.64636785",
"0.6427679",
"0.6408353",
"0.6385116",
"0.6359396",
"0.633937",
"0.63330823",
"0.63141495",
"0.62897706",
"0.61779475",
"0.6151049",
"0.61337173",
"0.61308885",
"0.61035043",
"0.60885054",
"0.6080796",
"0.6069682",
"0.6069682",
"0.6063... | 0.0 | -1 |
Returns Configuration object for current solution (initialized only once) | def configuration
@configuration ||= Configuration.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config\n @configuration ||= Configuration.new\n end",
"def config\n @configuration ||= Configuration.new\n end",
"def config\n @config ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Confi... | [
"0.7529056",
"0.7529056",
"0.74632263",
"0.73958105",
"0.73958105",
"0.73958105",
"0.73958105",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7367471",
"0.7365125",
"0.73130053",
"0.73130053",
"0.731300... | 0.73556775 | 18 |
Returns array of it's projects (initialized only once) | def projects
return @projects if @projects
@projects = []
IO.readlines(@file).each do |line|
@projects << Project.new(line, @dir) if /^Project.*\.csproj/ =~ line
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def projects\n @projects ||= Project.all\n end",
"def projects\n return [] unless basecamp\n @projects ||= basecamp.projects\n end",
"def projects\n result = []\n load_attributes\n @attributes['projects'].each do |project|\n result << project['name']\n end\n puts \"Wo... | [
"0.8414754",
"0.8320944",
"0.8260625",
"0.8142629",
"0.80449253",
"0.7953245",
"0.7953245",
"0.7942737",
"0.79208994",
"0.79010904",
"0.7887731",
"0.78273845",
"0.7814551",
"0.77965796",
"0.7772231",
"0.7769503",
"0.7746572",
"0.7735677",
"0.7724076",
"0.7700608",
"0.7673698"... | 0.7733978 | 18 |
Returns specific project by it's name +name+:: project's name | def project(name)
@projects.find { |p| p.name == name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_by_name(project_name)\n projects.find { |project| project['name'].casecmp(project_name) == 0 }\n end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def find_project_by_project_n... | [
"0.8479601",
"0.8200583",
"0.8200583",
"0.7678629",
"0.76557523",
"0.7545649",
"0.7494998",
"0.7374896",
"0.7374896",
"0.7181828",
"0.7140059",
"0.71348745",
"0.7045155",
"0.7038858",
"0.69983125",
"0.6946581",
"0.683628",
"0.6782434",
"0.6756816",
"0.6720249",
"0.67146534",
... | 0.8486255 | 0 |
Updates all projects AssemblyInfo.cs files with specific version +version+:: version to be stored in AssemblyInfo.cs files | def update_projects_version(version)
projects.each do |project|
project.update_version version
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_project_versions proj_files\r\n\r\n begin\r\n # iterate each package file, replace version numbers and save\r\n proj_files.each{ |file|\r\n puts \"Updating references in: #{file}...\"\r\n doc = Nokogiri::XML File.read file\r\n nodes = doc.search 'Reference'\r\n ... | [
"0.6794615",
"0.6541548",
"0.63339067",
"0.62395126",
"0.6032137",
"0.5993367",
"0.59605837",
"0.5843126",
"0.5834816",
"0.5811709",
"0.5749442",
"0.56377286",
"0.55501705",
"0.54986626",
"0.547751",
"0.54675907",
"0.5445223",
"0.5444458",
"0.542551",
"0.5401057",
"0.5361601"... | 0.6130637 | 4 |
Returns array of projects that correspondes to specific type +type+:: type of project defined in configuration project_types | def specific_projects(type)
types = configuration['project_types'].dup
types.select! { |t| t['type'] == type } unless type == 'all'
projects.select do |project|
types.any? { |t| project.name.include? t['name'] }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def projects\n where(:_type => ProjectCategory.name)\n end",
"def all_projects(type:)\n if type == :admin\n GitlabService.get_all_projects(self)\n else\n GitlabService.get_visible_projects(self)\n end\n end",
"def getProjArrays(parent_id, parent_type)\t\t\n\t\tsqlStr = \"left outer ... | [
"0.7284235",
"0.7098162",
"0.6948178",
"0.6864321",
"0.6716445",
"0.66823643",
"0.63565385",
"0.6348529",
"0.6180601",
"0.6164882",
"0.612732",
"0.6007563",
"0.5954154",
"0.5917036",
"0.5895581",
"0.58811295",
"0.5875428",
"0.5870578",
"0.5860975",
"0.5831528",
"0.5804584",
... | 0.87210405 | 0 |
Returns true if solution is marked as nobuild | def no_build?
solution_name = File.basename(@file, '.*')
(configuration['no_build'] || []).each do |tag|
return true if solution_name.include?(tag)
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def without_autobuild?\n Threaded.executing?(:without_autobuild)\n end",
"def build?\n config[:mode] == :build\n end",
"def building?\n !build_stack.empty?\n end",
"def same_build_in_progress?\n !Rails.env.development? &&\n !Rails.cache.write(\"build-service-#{@build.id}\"... | [
"0.6765969",
"0.65726125",
"0.6412579",
"0.64047897",
"0.6392276",
"0.6316595",
"0.6297998",
"0.6269209",
"0.62628657",
"0.6244801",
"0.6230089",
"0.6177785",
"0.6148922",
"0.61410767",
"0.6127925",
"0.6120384",
"0.61053437",
"0.61047125",
"0.6098778",
"0.6056722",
"0.604673"... | 0.8524702 | 0 |
Returns current build version | def build_version
@semver.to_s '%M.%m.%p'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_version\n version_number rev\n end",
"def get_version_build\n version = self.peers_version\n if version[\"success\"]\n return version[\"build\"]\n else\n return nil\n end\n end",
"def current_version\n @version\n end",
"def version\n build_string\n ... | [
"0.7965115",
"0.7897748",
"0.7791946",
"0.7735882",
"0.7707941",
"0.7634324",
"0.7611565",
"0.75522524",
"0.75449085",
"0.7526221",
"0.7434935",
"0.7405443",
"0.738733",
"0.73840106",
"0.7354285",
"0.7336944",
"0.73347",
"0.73302734",
"0.7328242",
"0.7323487",
"0.73220044",
... | 0.69257396 | 75 |
Returns current package version | def package_version
@semver.to_s '%M.%m.%p%s'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_version\n @version\n end",
"def version\n return @version if defined?(@version)\n \n @version = JSON.parse(File.read('package.json'))['version']\nend",
"def version\n @version ||= if token.nil? || Array(packages).empty?\n '0.1.0'\n else\n ... | [
"0.8047893",
"0.7956809",
"0.78758025",
"0.7790995",
"0.77493256",
"0.77077574",
"0.76321226",
"0.7592502",
"0.75894904",
"0.7540542",
"0.7512595",
"0.7501365",
"0.7454702",
"0.7453764",
"0.742811",
"0.7427701",
"0.7425811",
"0.7424403",
"0.73853165",
"0.7378493",
"0.7366397"... | 0.76490974 | 6 |
decode directory information text TODO accept an array of lines as the argument, make a special from_string(string="") | def initialize(string = "")
raise "expected a string but found #{string.inspect}, a #{string.class}" unless string.is_a? String
@lines = LineFolding::unfold_and_split(string).map do |line|
ContentLine.parse(line)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_dir(path)\n path.gsub(\".d.hg/\",\".d/\").gsub(\".i.hg/\",\".i/\").gsub(\".hg.hg/\",\".hg/\")\n end",
"def decode(text); end",
"def initialize(raw)\n super(raw)\n match = REGEXP.match(raw.strip) or raise ParserError\n\n if match[1] == 'd'\n @dir ... | [
"0.5701861",
"0.544453",
"0.53733134",
"0.53045094",
"0.5263641",
"0.52391964",
"0.5205391",
"0.51350176",
"0.507038",
"0.50117767",
"0.49806377",
"0.496269",
"0.4922954",
"0.4909862",
"0.48849022",
"0.48842344",
"0.48610172",
"0.48581457",
"0.4839067",
"0.48281264",
"0.48232... | 0.0 | -1 |
remove only this exact content line identified by its objectid | def delete_content_line(cl)
lines.delete_if { |line| line.object_id == cl.object_id }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_id(object_id)\n\t\ti = @docs.index { |doc| doc.object_id == object_id }\n\t\tdestroy_tab(i) if @docs[i].try_to_save()\n\t\t # remove_tab(i) #if not i.nil?\n\tend",
"def remove_content(id)\n delete(\"/#{id}\")\n end",
"def remove_line(line)\n\t\t@lines.delete(line)\n\tend",
"def delete_cont... | [
"0.66698354",
"0.6582506",
"0.65565574",
"0.6353022",
"0.6277803",
"0.6152429",
"0.6068509",
"0.6049367",
"0.59974164",
"0.58451587",
"0.58225346",
"0.5820567",
"0.5802882",
"0.57983094",
"0.57731795",
"0.5763466",
"0.57559395",
"0.5751273",
"0.5749212",
"0.57211167",
"0.5718... | 0.78310096 | 0 |
equallity is defined as having the same lines | def ==(other)
return false if other.class != self.class
# checking for lines.size is an optimisation
@lines.size == other.lines.size and @lines.sort == other.lines.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eq_of_equinox() \r\n cos( Celes.nut06a(@ajd, 0)[ 1 ] + Celes.obl06(@ajd, 0) ) * Celes.nut06a(@ajd, 0)[ 0 ]\r\n end",
"def eccentricity\n (\"0.\"+@line2[26...33]).to_f\n end",
"def eccentricity_Earth()\r\n # [-0.0000001235, -0.000042037, 0.016708617].inject(0.0) {|p, a| p * @ta + a}\r... | [
"0.60328025",
"0.58509415",
"0.56008554",
"0.53848886",
"0.5356974",
"0.53478265",
"0.5339644",
"0.52788424",
"0.52779484",
"0.5259825",
"0.52493304",
"0.5235575",
"0.5186938",
"0.5186938",
"0.5165654",
"0.5136504",
"0.51139945",
"0.5106771",
"0.5106771",
"0.5101159",
"0.5098... | 0.0 | -1 |
eql? is defined as being of the same class (not a descendent class like Vcard) and having the same lines | def eql?(other)
self.class == other.class and self == other
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eql?(ct); end",
"def eql?(ct); end",
"def eql?(*) end",
"def equal?(other); end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(other); end",
"def eql?(other); end",
"def eql?(other... | [
"0.74385303",
"0.74385303",
"0.7399678",
"0.7237402",
"0.70331",
"0.70331",
"0.70331",
"0.7032427",
"0.7032427",
"0.7032427",
"0.7032427",
"0.701964",
"0.701964",
"0.701964",
"0.701964",
"0.701964",
"0.701964",
"0.701964",
"0.69648236",
"0.69648236",
"0.69333136",
"0.692906... | 0.0 | -1 |
make a hash of all the translations that are new or changed in the current yml | def diff( previous, current )
diff = {}
current.each do |key, value|
next if Vocab::Translator::Base.ignore_key?( key )
previous_value = previous[ key ]
if( previous_value.nil? || previous_value != value )
diff[ key ] = value
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translations_hash; end",
"def translations\n @translations ||= {}\n end",
"def list\n @@translatable ||= Hash.new\n end",
"def find_main_translations\n find_main_cached.translations.inject({}) { |memo, tr| memo[\"#{tr.namespace}/#{tr.tr_key}\"] = tr; memo }\n end",
"def tran... | [
"0.7735885",
"0.7107583",
"0.6603415",
"0.6260881",
"0.62530535",
"0.622664",
"0.6174067",
"0.61690605",
"0.6159581",
"0.6153926",
"0.6145125",
"0.61028844",
"0.6098082",
"0.6081807",
"0.6072345",
"0.6015292",
"0.6007643",
"0.5933681",
"0.5924065",
"0.5922551",
"0.58807784",
... | 0.0 | -1 |
Constructor. Constructs a file, initially closed. | def initialize(block_size)
block_size = [block_size, HDR_SIZE_BYTES_].max
@block_size = block_size
@header_data = nil
@recycle_data = nil
@header_modified = false
# for in-memory version only:
@mem_file = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(in_file)\n @file = File.new(in_file, \"a+\")\n @filename = in_file\n end",
"def initialize(name)\n @fh = File.open(name, 'r')\n end",
"def initialize(file)\n @file = file\n end",
"def initialize(file)\n @file = file\n end",
"def initialize(file)\n ... | [
"0.7891339",
"0.74083877",
"0.71737045",
"0.71737045",
"0.71737045",
"0.7170356",
"0.7170356",
"0.7144793",
"0.7131524",
"0.713023",
"0.713023",
"0.713023",
"0.7128468",
"0.7117351",
"0.7006172",
"0.6869331",
"0.6865186",
"0.68525845",
"0.6822588",
"0.6808935",
"0.6794673",
... | 0.0 | -1 |
Determine if file is open | def open?
return @header_data != nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_file_open?\n (@file_handle != nil)\n end",
"def is_file_open?\n (@file_handle != nil)\n end",
"def open?(filename); end",
"def open?\n is_open\n end",
"def open?\n end",
"def open?\n @open\n end",
"def open?\n @open\n end",
"def open?\n type ==... | [
"0.8775521",
"0.8775402",
"0.83160764",
"0.8026709",
"0.7778517",
"0.7627811",
"0.7627811",
"0.7597635",
"0.7527655",
"0.7486211",
"0.7483467",
"0.74319726",
"0.7400048",
"0.73955846",
"0.72459",
"0.72173715",
"0.7172162",
"0.7146243",
"0.71411955",
"0.7136581",
"0.71245897",... | 0.6656349 | 43 |
Open file. Creates underlying storage if necessary. File must not already be open. | def open
!open? || raise(IllegalStateException)
existed = open_storage
if !existed
@header_data = alloc_buffer
@header_data.write_int(HDR_VERSION_, VERSION_)
@header_data.write_int(HDR_BLOCKSIZE_, block_size)
@header_data.write_int(HDR_RECYCLEINDEX_, 1)
append_or_replace(0, @he... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open(filename)\n clearpath = clear_filepath(filename)\n check_file_is_in_safe_dir(clearpath) if options[:portable]\n\n @lock.decrypt(clearpath, secure_filepath(clearpath))\n\n info = files.fetch(clearpath, {}).merge(\n secure_file: secure_filepath(clearpath),\n last_opened: Ti... | [
"0.6954864",
"0.6813365",
"0.6800415",
"0.67665166",
"0.6762263",
"0.6751101",
"0.6725418",
"0.6725418",
"0.67091113",
"0.66893995",
"0.6645687",
"0.6613099",
"0.6529714",
"0.65217066",
"0.6510979",
"0.6506726",
"0.64920795",
"0.64670575",
"0.63876057",
"0.63711053",
"0.63689... | 0.6450366 | 18 |
Allocate a new block. First block allocated will have name = FIRST_BLOCK_ID. | def alloc(src = nil)
ensure_open
src ||= alloc_buffer
# get index of last recycle block directory
r_index = rdir_head_name
# any entries remain in this directory?
n_ent = get_rdir_slots_used
if n_ent == 0
prev_rb_block = get_rdir_next_name
if prev_rb_block > 0
# use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_block blk\n time = Time.now\n res = store_block(blk)\n log.info { \"block #{blk.hash} \" +\n \"[#{res[0]}, #{['main', 'side', 'orphan'][res[1]]}] \" +\n \"(#{\"%.4fs, %3dtx, %.3fkb\" % [(Time.now - time), blk.tx.size, blk.payload.bytesize.to_f/1000]})\" } if res && r... | [
"0.7017505",
"0.6714201",
"0.6609706",
"0.65182585",
"0.6312814",
"0.62847924",
"0.61386055",
"0.61239237",
"0.6012634",
"0.59714067",
"0.5939924",
"0.5934297",
"0.5912297",
"0.5858753",
"0.5804463",
"0.5796277",
"0.5744267",
"0.573038",
"0.56881595",
"0.56595695",
"0.5654180... | 0.0 | -1 |
Free up a block | def free(block_name)
ensure_open
raise(ArgumentError,"no such block: #{block_name}") if block_name >= name_max
slot = get_rdir_slots_used()
# if there is a free slot in the current recycle block, use it
if slot < get_rdir_capacity
set_rdir_slot(slot,block_name)
set_rdir_slots_used(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def free\n\n self.class.free(@pointer)\n @pointer = nil\n end",
"def free\n Tidylib.buf_free(@struct)\n end",
"def destroy()\n return unless @ptr\n self_p = __ptr_give_ref\n result = ::Sprk::FFI.sprk_block_manager_destroy(self_p)\n result\n end",
"def free_bu... | [
"0.68479675",
"0.66712284",
"0.66471606",
"0.66055727",
"0.6575796",
"0.6494822",
"0.64825344",
"0.6418308",
"0.6414618",
"0.6403961",
"0.6397393",
"0.6341646",
"0.6292137",
"0.6276869",
"0.62604845",
"0.61974645",
"0.6184879",
"0.6176436",
"0.6172486",
"0.61201996",
"0.61142... | 0.6694564 | 1 |
Read one of the user values from the header | def read_user(int_index)
ensure_open
raise ArgumentError if !(int_index >= 0 && int_index < USER_HEADER_INTS)
@header_data.read_int(HDR_USERSTART_ + int_index)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHeader() @header1 end",
"def parse_header(io)\n\t variable_name = nil\n\t parse_pairs io do |code, value|\n\t\tcase code\n\t\t when '0' then next\n\t\t when '9'\n\t\t\tvariable_name = value\n\t\t else\n\t\t\theader[variable_name] = value\n\t\tend\n\t end\n\tend",
"def read_header\n @c... | [
"0.65330714",
"0.6522615",
"0.63692033",
"0.62523913",
"0.61400837",
"0.61131173",
"0.6102788",
"0.6077673",
"0.60179245",
"0.6013539",
"0.5996629",
"0.59945357",
"0.5948877",
"0.59362197",
"0.5885209",
"0.5833638",
"0.5831314",
"0.58137846",
"0.58089644",
"0.58055127",
"0.57... | 0.60283726 | 8 |
Write a user value | def write_user(int_index, value)
ensure_open
raise ArgumentError if !(int_index >= 0 && int_index < USER_HEADER_INTS)
@header_data.write_int(HDR_USERSTART_ + int_index, value)
@header_modified = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(value)\n # pass\n end",
"def write(value)\n record.send(\"#{name}_data=\", value)\n end",
"def write!(value = nil)\n @changed = true if value != @value\n @value = value if value\n @ssm.put_parameter(\n name: @name, value: @value, type: @type,\n des... | [
"0.7798362",
"0.72713375",
"0.70629776",
"0.6937177",
"0.6821023",
"0.676425",
"0.675348",
"0.675348",
"0.675348",
"0.675348",
"0.675348",
"0.675348",
"0.675348",
"0.67534584",
"0.67423254",
"0.66643304",
"0.65399015",
"0.6451166",
"0.6448152",
"0.6403747",
"0.63702464",
"0... | 0.67916876 | 5 |
Create an array of bytes, all zeros, of length equal to this block file's block length | def alloc_buffer
ByteArray.new(@block_size)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_bytes\n end",
"def blockinate(bytes)\n tmp = bytes.each_slice(4).to_a\n if tmp.last.size < 4\n n = 4 - tmp.last.size\n n.times { |n| tmp.last << 0 }\n end\n @blocks = tmp.each_slice(2).to_a\n if @blocks.last.size == 1\n @blocks.last << [0] * 4\n end\n end",
"def r... | [
"0.61653984",
"0.6126149",
"0.5939628",
"0.59300274",
"0.5901761",
"0.58566606",
"0.5823764",
"0.5674626",
"0.5668929",
"0.5667273",
"0.56552315",
"0.56199133",
"0.5619427",
"0.5546993",
"0.5546993",
"0.5541088",
"0.55176413",
"0.55003506",
"0.54597217",
"0.5428481",
"0.54128... | 0.67836106 | 0 |
These methods should be overridden by subclasses for block files that are not to be memoryonly (as the default implementations assume) Read block from storage. | def read(block_name, dest_buffer = nil)
dest_buffer ||= alloc_buffer
if block_name >= @mem_file.size
raise ArgumentError,"No such block name #{block_name} exists (size=#{@mem_file.size})"
end
src = @mem_file[block_name]
ByteArray.copy(src,0,@block_size,dest_buffer,0)
dest_buffer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file(block=0)\n Rula.log(Logger::DEBUG,\"Reading file #{filename} block #{block}\",self)\n return nil if(block >= @file_size)\n return nil if(block < 0)\n file_handle = File.open(@filename,'rb')\n file_handle.pos = block\n @previous_block_read = file_handle.pos\n data = ... | [
"0.6865752",
"0.6790627",
"0.6589328",
"0.625031",
"0.6224564",
"0.62171376",
"0.62126476",
"0.6195049",
"0.61471164",
"0.61324996",
"0.6117922",
"0.6104172",
"0.60979724",
"0.60582244",
"0.6042796",
"0.6042796",
"0.60211265",
"0.601364",
"0.5912883",
"0.5904169",
"0.5904169"... | 0.62339354 | 4 |
Write block to storage. Name is either index of existing block, or number of existing blocks (to append to end of existing ones) | def write(block_name, src_buffer)
if block_name == @mem_file.size
@mem_file << alloc_buffer
end
dest = @mem_file[block_name]
ByteArray.copy(src_buffer,0,@block_size,dest,0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_or_replace(block_name, src)\n if (block_name < 0 || block_name > name_max)\n raise ArgumentError,\"write to nonexistent block #{block_name}; only #{name_max} in file\"\n end\n\n if block_name == name_max\n write_hdr(HDR_MAXINDEX_, block_name+1)\n end\n\n write(block_name, src)\n... | [
"0.71221626",
"0.66261935",
"0.63884777",
"0.625626",
"0.61734855",
"0.60957605",
"0.6075437",
"0.6047876",
"0.60428",
"0.5995219",
"0.59015924",
"0.58559954",
"0.58110446",
"0.58001965",
"0.5778065",
"0.5725255",
"0.5648351",
"0.5616976",
"0.5607411",
"0.55647916",
"0.556119... | 0.70736265 | 1 |
Open underlying storage; create it if necessary | def open_storage
@mem_file = []
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open\n !open? || raise(IllegalStateException)\n existed = open_storage\n if !existed\n @header_data = alloc_buffer\n @header_data.write_int(HDR_VERSION_, VERSION_)\n @header_data.write_int(HDR_BLOCKSIZE_, block_size)\n @header_data.write_int(HDR_RECYCLEINDEX_, 1)\n append_or_r... | [
"0.7215007",
"0.6637065",
"0.6377384",
"0.6371139",
"0.63629097",
"0.63371354",
"0.6326267",
"0.6307959",
"0.62993234",
"0.6263911",
"0.62082046",
"0.6188016",
"0.61023706",
"0.60563666",
"0.60094",
"0.59679824",
"0.5957559",
"0.5953688",
"0.5949169",
"0.59080505",
"0.5902695... | 0.7421756 | 0 |
Get 1 + name of highest block ever created | def name_max
@header_data.read_int(HDR_MAXINDEX_)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_index\n blocks.max(:index) || 0\n end",
"def last_block\n\t\t(self.track_count*8)-1\n\tend",
"def open_block\n blocks(limit: 1, sort: :desc).first\n end",
"def latest_block(blockchain)\n blockchain[-1]\n end",
"def anonymous_block_name\n self.anonymous_block_number += 1\n ... | [
"0.7055264",
"0.68787336",
"0.6826667",
"0.6744199",
"0.6644703",
"0.6517675",
"0.64552903",
"0.6368041",
"0.6282793",
"0.61327314",
"0.6106324",
"0.6003054",
"0.59588325",
"0.59583175",
"0.5938013",
"0.5890598",
"0.587342",
"0.5847394",
"0.58339816",
"0.5813921",
"0.57996386... | 0.56880134 | 27 |
Determine how many names can be stored in a single recycle directory block | def get_rdir_capacity
(@block_size / INT_BYTES_) - RC_ENTRIES_START_
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive_file_count\n Dir.glob('*', base: mounted_path).length\n end",
"def actual_path_length\n folders.count\n end",
"def volume_count\n return unless exists?\n Dir.glob(folder_pathname.join(\"**\")).count do |file|\n File.directory?(file)\n end\n end",
"def misc_direc... | [
"0.6403489",
"0.62176627",
"0.618666",
"0.60190785",
"0.59258115",
"0.59230685",
"0.5855724",
"0.5788389",
"0.5775304",
"0.57738906",
"0.5738328",
"0.5711315",
"0.570307",
"0.566738",
"0.5664551",
"0.5597932",
"0.5575502",
"0.5574968",
"0.55706817",
"0.55673575",
"0.5564112",... | 0.53432196 | 37 |
Get name of next recycle directory block | def get_rdir_next_name
@recycle_data.read_int(RC_PREV_DIR_NAME_)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rdir_head_name\n @header_data.read_int(HDR_RECYCLEINDEX_)\n end",
"def free(block_name)\n ensure_open\n\n raise(ArgumentError,\"no such block: #{block_name}\") if block_name >= name_max\n\n slot = get_rdir_slots_used()\n\n # if there is a free slot in the current recycle block, use it\n\n ... | [
"0.6483051",
"0.6038255",
"0.59620255",
"0.59615916",
"0.58926725",
"0.58924806",
"0.58276945",
"0.5759972",
"0.568988",
"0.56874365",
"0.5683388",
"0.56384426",
"0.5619534",
"0.55843544",
"0.55688184",
"0.55453855",
"0.55332243",
"0.55270314",
"0.550666",
"0.5484506",
"0.546... | 0.7400054 | 0 |
Get name of first recycle directory block (they are connected as a singlylinked list) | def rdir_head_name
@header_data.read_int(HDR_RECYCLEINDEX_)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rdir_next_name\n @recycle_data.read_int(RC_PREV_DIR_NAME_)\n end",
"def dir_name\n @dir_name ||= @node.search('dirName/listEntry').map(&:inner_text)\n end",
"def next_uniq_child_name(item)\n taken_names = contents_names(item).map(&:downcase)\n name_generator = FileName.new(ite... | [
"0.61641735",
"0.6023059",
"0.57847416",
"0.5768132",
"0.5737944",
"0.57128775",
"0.56989",
"0.564805",
"0.562896",
"0.5600516",
"0.5587077",
"0.5581808",
"0.55609757",
"0.5558801",
"0.5558343",
"0.5558343",
"0.5558221",
"0.55542135",
"0.5553512",
"0.5517387",
"0.5511215",
... | 0.6428606 | 0 |
Write a block; if we're appending a new block, increment the name_max field | def append_or_replace(block_name, src)
if (block_name < 0 || block_name > name_max)
raise ArgumentError,"write to nonexistent block #{block_name}; only #{name_max} in file"
end
if block_name == name_max
write_hdr(HDR_MAXINDEX_, block_name+1)
end
write(block_name, src)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_file\n File.open(config.block_list_path, 'a') do |f|\n block_count = old_newest_block ? (block_list.size - old_newest_block.height - 1) : block_list.size\n block_list = self.block_list.sort{|(k1, v1), (k2, v2)| v1.height <=> v2.height}\n block_list = block_list[(old_n... | [
"0.5990615",
"0.59165025",
"0.5908915",
"0.5876327",
"0.58095235",
"0.57764006",
"0.5765618",
"0.56884515",
"0.5669542",
"0.5618778",
"0.56151533",
"0.5578607",
"0.55726707",
"0.5535129",
"0.5523565",
"0.551824",
"0.54586697",
"0.5449879",
"0.54422444",
"0.54200786",
"0.53892... | 0.7322817 | 0 |
Write a value to a header field, mark header as modified | def write_hdr(field, value)
@header_data.write_int(field, value)
@header_modified = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_header( header, value, index=1 )\n index = [index].pack('N')\n RESPONSE[:chgheader] + \"#{index}#{header}\\0#{value}\" + \"\\0\"\n end",
"def change_header( header, value, index=1 )\n index = [index].pack('N')\n RESPONSE[\"CHGHEADER\"] + \"#{index}#{header}\\... | [
"0.7567752",
"0.7540005",
"0.72711897",
"0.7255919",
"0.7248987",
"0.71956766",
"0.71956766",
"0.703628",
"0.69448805",
"0.692856",
"0.6835292",
"0.6835263",
"0.6752801",
"0.6719021",
"0.6676328",
"0.6662723",
"0.6612412",
"0.6605288",
"0.6573566",
"0.65631783",
"0.6561386",
... | 0.8317917 | 0 |
Get authentication token and save when this token will expire. | def authenticate
raise 'Sierra API key not present' unless ENV['SIERRA_API_KEY']
raise 'Sierra API secret not present' unless ENV['SIERRA_API_SECRET']
if authentication_expired?
credentials = Base64.strict_encode64(ENV['SIERRA_API_KEY'] + ':' + ENV['SIERRA_API_SECRET'])
# throw error if api key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_token\n return regenerate_auth_token if expired?\n\n authentication.auth_token\n end",
"def token\n Rails.cache.read(AUTH_TOKEN_CACHE_KEY) || retrieve_token!\n end",
"def authentication_token\n @authentication_token ||= OohAuth::Token.first(:token_key=>token)\n ... | [
"0.8216096",
"0.80102414",
"0.7485626",
"0.74426895",
"0.7388181",
"0.7383203",
"0.7358326",
"0.734582",
"0.7336797",
"0.7311512",
"0.7235357",
"0.7205013",
"0.7204848",
"0.7202127",
"0.71956646",
"0.71913075",
"0.71785057",
"0.7111573",
"0.7102355",
"0.709716",
"0.7088005",
... | 0.0 | -1 |
Public: Get a string representation of this object Examples serie = Serie.new(name: "Sample Series", value: "SS").to_s Invoice.new(serie: serie).to_s => "SS(1)" invoice.number = 10 invoice.to_s => "SS10" Returns a string. | def to_s
label = draft ? '[draft]' : number? ? number: "(#{serie.next_number})"
"#{serie.value}-#{label}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @string ||= Builder::ToString.new(self).string\n end",
"def to_s\n toString\n end",
"def to_s\n\t\t\t@string\n\t\tend",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\... | [
"0.74310696",
"0.7422682",
"0.73968613",
"0.7380818",
"0.7380818",
"0.7380818",
"0.7380818",
"0.7380742",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
"0.7374817",
... | 0.0 | -1 |
Public: Returns the status of the invoice based on certain conditions. Returns a symbol. | def get_status
if draft
:draft
elsif closed || gross_amount <= paid_amount
:closed
elsif due_date and due_date > Date.today
:opened
else
:overdue
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_invoice_status\n params_hash = {\n # Mandatory\n 'x_login' => @x_login_for_webpaystatus,\n 'x_trans_key' => @x_trans_key_for_webpaystatus,\n 'x_invoice' => invoice,\n 'x_response_format' => response_type\n }\n\n astro_curl(@astro_urls['status'], params_hash... | [
"0.7280923",
"0.6894758",
"0.67047536",
"0.65590525",
"0.63192284",
"0.6214725",
"0.6199603",
"0.6158996",
"0.61211485",
"0.60792357",
"0.6058431",
"0.59939694",
"0.594798",
"0.58833516",
"0.58507717",
"0.57802856",
"0.5763614",
"0.5762949",
"0.5755597",
"0.57239205",
"0.5708... | 0.63538307 | 4 |
Public: Returns the amount that has not been already paid. Returns a double. | def unpaid_amount
draft ? nil : gross_amount - paid_amount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpaid_amount\n gross_amount - paid_amount\n end",
"def unpaid_grace_period_amount\n total_grace_period_amount - paid_grace_period_amount\n end",
"def amount_owed\n total_price - amount_paid\n end",
"def damt_paid\n\tamt_paid/100.0 rescue 0.0 \nend",
"def outstanding_amount\n if pa... | [
"0.75124663",
"0.67891186",
"0.6729563",
"0.6625465",
"0.6585586",
"0.6581203",
"0.63933814",
"0.6364086",
"0.6357067",
"0.63477916",
"0.6340822",
"0.633085",
"0.62815344",
"0.626498",
"0.62582403",
"0.624956",
"0.62442875",
"0.62418175",
"0.6233003",
"0.6229759",
"0.6221567"... | 0.71402395 | 1 |
Public: Calculate totals for this invoice by iterating items and payments. Returns nothing. | def set_amounts
super
self.paid_amount = 0
payments.each do |payment|
self.paid_amount += payment.amount
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total\n total_invoice_items_price(invoice_items)\n end",
"def calculate_invoice_total\n res = [ ]\n self.line_items.each do |item|\n res.push(item.qty * item.price)\n end\n # Return the sum of the items\n self.total = res.inject(:+) \n end",
"def update_totals\n # update_... | [
"0.7044879",
"0.7003252",
"0.6979521",
"0.6857455",
"0.68203235",
"0.6788933",
"0.66435087",
"0.65915036",
"0.6574219",
"0.6554919",
"0.6554104",
"0.65470904",
"0.65418756",
"0.6533038",
"0.64925104",
"0.6482497",
"0.6466058",
"0.6422813",
"0.6419176",
"0.63937175",
"0.631726... | 0.56566966 | 98 |
Protected: Decide whether this invoice needs an invoice number. It's true when the invoice is not a draft and has no invoice number. Returns a boolean. | def needs_invoice_number
!draft and number.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoiced?\n !invoice_number.blank?\n end",
"def has_invoice?\n !self.freshbooks_invoice_id.nil?\n end",
"def sales_invoice?\n false\n end",
"def pdf_invoice?\n Object.const_defined?('TradoPdfInvoiceModule') ? true : false\n end",
"def invoice?\n (payment_on_acco... | [
"0.74691856",
"0.73131025",
"0.65456694",
"0.65213704",
"0.64551306",
"0.63693565",
"0.6311098",
"0.6310562",
"0.6310562",
"0.6221093",
"0.6151382",
"0.6080937",
"0.6038065",
"0.59780604",
"0.59282297",
"0.5871828",
"0.5857086",
"0.58053297",
"0.5787047",
"0.57392406",
"0.573... | 0.8759832 | 1 |
Protected: Sets the invoice number to the series next number and updates the series by incrementing the next_number counter. Returns nothing. | def ensure_invoice_number
self.number = serie.next_number
yield
serie.update_attribute :next_number, number + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_invoice_number\n self.number = series.next_number\n yield\n series.update_attribute :next_number, number + 1\n end",
"def update_invoice_number!\n return unless Spree::PrintInvoice::Config.use_sequential_number?\n return if invoice_number.present?\n\n update_columns(invoice_... | [
"0.8227566",
"0.6961387",
"0.6598621",
"0.6201239",
"0.61293286",
"0.6087277",
"0.6054298",
"0.5863833",
"0.5854583",
"0.5753017",
"0.5605311",
"0.5449919",
"0.54414093",
"0.5385848",
"0.53806037",
"0.53773504",
"0.53413916",
"0.53108627",
"0.53088856",
"0.52852875",
"0.52409... | 0.73336804 | 1 |
Protected: Update instance's status digit to reflect its status | def set_status
if !draft
self.status = STATUS[get_status]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sdk_update_status(instance)\n if raw_power_state != instance.status\n update!(:raw_power_state => instance.status) if raw_power_state != instance.status\n $ibm_cloud_log.info(\"VM instance #{instance.id} state is #{raw_power_state}\")\n end\n end",
"def sdk_update_status(instance)\n if ra... | [
"0.7481171",
"0.7481171",
"0.69524026",
"0.6851478",
"0.682308",
"0.6776565",
"0.66684866",
"0.6630945",
"0.662898",
"0.6625636",
"0.6616364",
"0.65463465",
"0.6528815",
"0.6499375",
"0.6499375",
"0.6499375",
"0.6499375",
"0.6499375",
"0.6499375",
"0.6499375",
"0.6499375",
... | 0.0 | -1 |
print component to console (remove later) | def display()
puts "method: #{@method}"
puts "identifier: #{@identifier}"
puts "query: #{@query}"
puts "version: #{@version}"
puts "---------------- headers ----------------"
puts @headers
puts "---------------- body -------------------"
puts @body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checked_print object = ''\n print object\n @prev_printed = true\n end",
"def print_temp\n print to_string\n end",
"def print\n Kernel.print(self)\n end",
"def display\n puts self\n end",
"def print\r\n puts self.output\r\n end",
"def display!\n escaped = se... | [
"0.6703503",
"0.660264",
"0.6550992",
"0.63658696",
"0.62683547",
"0.62328565",
"0.6217897",
"0.62038386",
"0.61909455",
"0.61760867",
"0.61691296",
"0.61474067",
"0.6144504",
"0.61377615",
"0.61377615",
"0.61377615",
"0.61289066",
"0.61257285",
"0.61257017",
"0.6124519",
"0.... | 0.0 | -1 |
breaks and return body from stream | def seperate_body()
@stream.split("\n\n", 2)[1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def body(&block)\n call_once\n @body ||= begin\n if entity = @response.get_entity\n EntityConverter.new.read_entity(entity, &block)\n end\n rescue Java::JavaIo::IOException, Java::JavaNet::SocketException, IOError => e\n ... | [
"0.6971631",
"0.6970583",
"0.6771122",
"0.6644162",
"0.6630876",
"0.66060513",
"0.66060513",
"0.65710616",
"0.6547795",
"0.64318347",
"0.6412316",
"0.6382403",
"0.6373455",
"0.6334775",
"0.6298956",
"0.62717175",
"0.6243526",
"0.622448",
"0.62158567",
"0.62114394",
"0.6184968... | 0.70448107 | 0 |
breaks and return 1st line from stream | def seperate_request_line()
@stream.split("\n", 2)[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line\n line_from_ip(0)\n end",
"def get_line\... | [
"0.68887085",
"0.68887085",
"0.68887085",
"0.68887085",
"0.68887085",
"0.68887085",
"0.68887085",
"0.68887085",
"0.68887085",
"0.68887085",
"0.67393315",
"0.67348015",
"0.65397346",
"0.64919853",
"0.64860725",
"0.63852173",
"0.6371101",
"0.6360896",
"0.6353233",
"0.6352424",
... | 0.6604709 | 12 |
breaks and return headers from stream | def seperate_headers()
@stream.split("\n\n")[0].split("\n", 2)[1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_headers!; end",
"def raw_headers; end",
"def processed_headers; end",
"def read_headers!\n until @parser.headers?\n result = read_more(BUFFER_SIZE)\n raise ConnectionError, \"couldn't read response headers\" if result == :eof\n end\n\n set_keep_alive\n end",
"def re... | [
"0.7334617",
"0.68616015",
"0.6810514",
"0.66333556",
"0.6553146",
"0.64693147",
"0.64693147",
"0.64693147",
"0.64693147",
"0.64693147",
"0.64693147",
"0.64693147",
"0.64693147",
"0.64693147",
"0.64693147",
"0.6464768",
"0.641209",
"0.63771445",
"0.63771445",
"0.63313025",
"0... | 0.70719045 | 1 |
This method is used to set the map to the specifications set out in requirements.md | def initialize_map
@locations.set_map
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(map)\n end",
"def set_map\n # Sets locations on the map\n @map = [\n ['Enumerable Canyon', 'Duck Type Beach', 'Monkey Patch City'],\n ['Duck Type Beach', 'Enumerable Canyon', 'Matzburg'],\n ['Monkey Patch City', 'Nil Town', 'Enumerable Canyon', 'Matzburg'],\n ['Nil Town', '... | [
"0.68928754",
"0.6716163",
"0.6509731",
"0.6357312",
"0.6290588",
"0.6280193",
"0.6016577",
"0.59096605",
"0.5907002",
"0.56657714",
"0.56563365",
"0.564347",
"0.5642433",
"0.56172705",
"0.56155294",
"0.55966914",
"0.5564537",
"0.55564606",
"0.55538017",
"0.55206805",
"0.5513... | 0.5564377 | 17 |
This block does not count for total number of unit tests, only makes sure the map is initialized correctly UNIT TESTS FOR METHOD set_enumerable_canyon, set_duck_type_beach...... Equivalence classes: These methods set the connections for their own location according to requirements This test tests the initialization of ... | def test_enumerable_canyon
initialize_map
enumerable_canyon = @locations.get_location 'Enumerable Canyon'
assert_equal 'Enumerable Canyon', enumerable_canyon.name_reader
assert_equal 1, enumerable_canyon.max_real_reader
assert_equal 1, enumerable_canyon.max_fake_reader
assert_equal 'Duck Type ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_enumerable_canyon_neighbors\n loc = Locations.new\n assert_equal ({ 'neighbors' =>\n ['Duck Type Beach', 'Monkey Patch City'],\n 'maxRubes' => 1,\n 'maxFakes' => 1 }), loc.enumerable_canyon\n end",
"def test_setup_map\n map = [\n ['Enumerable Canyo... | [
"0.7047213",
"0.6889451",
"0.677586",
"0.63673025",
"0.6317644",
"0.6093651",
"0.60703707",
"0.6006423",
"0.5895045",
"0.5856486",
"0.58564276",
"0.5833588",
"0.5806563",
"0.5756558",
"0.5695644",
"0.56500214",
"0.5612868",
"0.55991244",
"0.5580749",
"0.5568989",
"0.55676895"... | 0.7369961 | 0 |
This test tests the initialization of the "Duck Type Beach" location object | def test_duck_type_beach
initialize_map
duck_type_beach = @locations.get_location 'Duck Type Beach'
assert_equal 'Duck Type Beach', duck_type_beach.name_reader
assert_equal 2, duck_type_beach.max_real_reader
assert_equal 2, duck_type_beach.max_fake_reader
assert_equal 'Enumerable Canyon', duck... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_driver_get_place\n\t\tloc = Location::new(\"Location\", [\"Place\"])\n\t\tdriv = Driver::new(1, loc)\n\t\tassert_equal loc, driv.get_place\n\tend",
"def test_location_0\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital... | [
"0.7174811",
"0.7132046",
"0.705293",
"0.70245445",
"0.69362223",
"0.6889419",
"0.6854397",
"0.6799376",
"0.67904234",
"0.67826235",
"0.6780795",
"0.677752",
"0.6768194",
"0.6737332",
"0.6723188",
"0.668764",
"0.6660397",
"0.66153324",
"0.65213746",
"0.65092367",
"0.6497559",... | 0.7280508 | 0 |
This method tests the initialization of the "Monkey Patch City" location object | def test_monkey_patch_city
initialize_map
monkey_patch_city = @locations.get_location 'Monkey Patch City'
assert_equal 'Monkey Patch City', monkey_patch_city.name_reader
assert_equal 1, monkey_patch_city.max_real_reader
assert_equal 1, monkey_patch_city.max_fake_reader
assert_equal 'Enumerable... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fun_city_locs\n\t@city = GoldRush::new\n\tassert_equal \"El Dorado Canyon\", @city.dorado.location\n\tassert_equal \"Midas\", @city.midas.location\n\tassert_equal \"Virginia City\", @city.virginia.location\n\tassert_equal \"Nevada City\", @city.nevada.location\n\tassert_equal \"Coloma\", @city.coloma.loca... | [
"0.7368075",
"0.705792",
"0.7013632",
"0.6905544",
"0.68935746",
"0.6892401",
"0.6879875",
"0.68762755",
"0.68155295",
"0.6813046",
"0.6792289",
"0.6788902",
"0.6786324",
"0.6763273",
"0.6701115",
"0.6676776",
"0.6625488",
"0.6623697",
"0.6569012",
"0.6567364",
"0.65633476",
... | 0.78930706 | 0 |
This method tests the initialization of the "Nil Town" location object | def test_nil_town
initialize_map
nil_town = @locations.get_location 'Nil Town'
assert_equal 'Nil Town', nil_town.name_reader
assert_equal 0, nil_town.max_real_reader
assert_equal 3, nil_town.max_fake_reader
assert_equal 'Monkey Patch City', nil_town.neighbors_reader[0].name_reader
assert_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nil_location\n\t\t@new_driver.location 'Cathedral'\n\t\tassert_equal 'Cathedral', @new_driver.location(nil)\n\tend",
"def test_location_new_not_nil\r\n library = Location::new(\"Library\", nil, nil)\r\n refute_nil library\r\n end",
"def test_one_way_is_location\r\n \thillman = Location::new(... | [
"0.7283041",
"0.7172792",
"0.6960196",
"0.6854468",
"0.6813992",
"0.6794017",
"0.67504406",
"0.67280024",
"0.6717079",
"0.6679329",
"0.66719824",
"0.6645242",
"0.6623001",
"0.6554343",
"0.65348506",
"0.6517094",
"0.6510581",
"0.6464476",
"0.64557546",
"0.6440381",
"0.64056164... | 0.7133595 | 2 |
This method test the initialization of the "Matzburg" location object | def test_matzburg
initialize_map
matzburg = @locations.get_location 'Matzburg'
assert_equal 'Matzburg', matzburg.name_reader
assert_equal 3, matzburg.max_real_reader
assert_equal 0, matzburg.max_fake_reader
assert_equal 'Duck Type Beach', matzburg.neighbors_reader[0].name_reader
assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_maps\r\n test = Prospect.new(0)\r\n assert_equal test.loc.name, 'Matzburg'\r\n end",
"def test_museum_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 1; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_lo... | [
"0.7383456",
"0.7196061",
"0.70767546",
"0.7036952",
"0.70159775",
"0.7013403",
"0.6976324",
"0.6908215",
"0.6900392",
"0.68606293",
"0.68507916",
"0.68139786",
"0.67842823",
"0.67632",
"0.67173404",
"0.67142665",
"0.6706678",
"0.6703852",
"0.66978246",
"0.66684914",
"0.66660... | 0.7948458 | 0 |
This method tests the initialization of the "Hash Crossing" location object | def test_hash_crossing
initialize_map
hash_crossing = @locations.get_location 'Hash Crossing'
assert_equal 'Hash Crossing', hash_crossing.name_reader
assert_equal 2, hash_crossing.max_real_reader
assert_equal 2, hash_crossing.max_fake_reader
assert_equal 'Matzburg', hash_crossing.neighbors_rea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_initialize_hash\n assert_equal '00210', @zipcode.zip\n assert_equal -5, @zipcode.timezone\n assert_equal 43.005895, @zipcode.latitude\n assert_in_delta(43.0059, @zipcode.latitude, 0.001)\n end",
"def test_initialize_current_location\n simulator = Sim.new(nil, nil, nil)\n assert_equal ... | [
"0.6902051",
"0.677778",
"0.6692819",
"0.6654403",
"0.6647497",
"0.65840703",
"0.65618825",
"0.65590763",
"0.65455985",
"0.6518424",
"0.64920634",
"0.648567",
"0.64626324",
"0.6447898",
"0.6422981",
"0.6414957",
"0.6334309",
"0.6293296",
"0.62670237",
"0.62550026",
"0.6228101... | 0.6891099 | 1 |
This method tests the initialization of the "Dynamic Palisades" location object | def test_dynamic_palisades
initialize_map
dynamic_palisades = @locations.get_location 'Dynamic Palisades'
assert_equal 'Dynamic Palisades', dynamic_palisades.name_reader
assert_equal 2, dynamic_palisades.max_real_reader
assert_equal 2, dynamic_palisades.max_fake_reader
assert_equal 'Matzburg',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_location\n\t\t@new_driver.location 'Cathedral'\n\t\tassert_equal 'Hillman', @new_driver.location('Hillman')\n\tend",
"def test_construct_location_simple\n count = Location.count\n params = barton_flats_params\n display_name = params[:display_name]\n post_requires_login(:create_location, ... | [
"0.6699254",
"0.66674477",
"0.661919",
"0.65818655",
"0.6512883",
"0.6451414",
"0.64131874",
"0.64026254",
"0.63766026",
"0.6344763",
"0.63392836",
"0.63350034",
"0.62993157",
"0.6282611",
"0.6282052",
"0.6259762",
"0.6224798",
"0.61987054",
"0.61945343",
"0.6190998",
"0.6168... | 0.7375213 | 0 |
UNIT TESTS FOR METHOD add_location(location) Equivalence classes: | def test_add_location_to_empty
locations = LocationRelation.new
locations.add_location Location.new('add_location', 0, 0)
assert_equal 1, locations.locations_reader.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_location\n\t\t@new_driver.location 'Cathedral'\n\t\tassert_equal 'Hillman', @new_driver.location('Hillman')\n\tend",
"def test_location_1\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\... | [
"0.72715664",
"0.71477723",
"0.711343",
"0.708233",
"0.6823373",
"0.67813087",
"0.6746918",
"0.67329943",
"0.66969603",
"0.6627057",
"0.6625659",
"0.6620057",
"0.6584543",
"0.6565708",
"0.6530424",
"0.6528959",
"0.6505615",
"0.6496386",
"0.6475066",
"0.64692307",
"0.646738",
... | 0.6714062 | 8 |
If bad input is passed into the add_location method, then raise an error message EDGE CASE | def test_add_location_bad_input
assert_raises 'Improper typing of location input in method add_location' do
locations = LocationRelation.new
locations.add_location Location.new('test_location_1')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_location_error(params)\n location_error(:create_location, params)\n end",
"def update_location_error(params)\n location_error(:edit_location, params)\n end",
"def test_location_nil\n assert_raises StandardError do\n @loc1.add_neighbor nil\n end\n end",
"def test_get_location... | [
"0.7061517",
"0.66164947",
"0.65540266",
"0.6510196",
"0.63343734",
"0.63343734",
"0.63113207",
"0.6186266",
"0.61762327",
"0.61040235",
"0.60767925",
"0.6034948",
"0.59930605",
"0.5988209",
"0.5983579",
"0.59149384",
"0.5898558",
"0.588668",
"0.5847577",
"0.5812348",
"0.5801... | 0.72138345 | 0 |
UNIT TESTS FOR METHOD get_location(location) Equivalence classes: | def test_get_location_contains
locations = LocationRelation.new
locations.add_location Location.new('test_location_2', 0, 0)
assert_equal 'test_location_2', locations.get_location('test_location_2').name_reader
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_location_2\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.ne... | [
"0.7531948",
"0.7487967",
"0.7442846",
"0.7435198",
"0.7323669",
"0.72481847",
"0.7127319",
"0.7108021",
"0.7099291",
"0.709697",
"0.70762056",
"0.70296955",
"0.7021965",
"0.70155215",
"0.7004098",
"0.6966483",
"0.6919286",
"0.69014657",
"0.6893015",
"0.68635106",
"0.6853941"... | 0.72213817 | 6 |
If the input to the get_location method is a non string, then throw an error EDGE CASE | def test_get_location_bad_input
assert_raises 'Improper typing of location input argument in method get_location' do
locations = LocationRelation.new
locations.get_location 55
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_getLocation_neg_invalid\n\t\td = Driver::new(\"Driver 1\",0);\n\t\tdef d.getLocation; d.location=-999,-999; end\n\t\tassert_raises (\"Invalid location\") {d.getLocation}\n\tend",
"def location_invalid?\n @response.nil? || \n @response[\"weather\"] && @response[\"weather\"].is_a?(Array) && @res... | [
"0.63447237",
"0.63280874",
"0.632449",
"0.63192075",
"0.63113415",
"0.6297521",
"0.62464505",
"0.6243506",
"0.62407565",
"0.6159615",
"0.6159615",
"0.6103665",
"0.6073821",
"0.59782547",
"0.5970917",
"0.5962477",
"0.59487045",
"0.5922903",
"0.58688396",
"0.58688396",
"0.5865... | 0.6708 | 0 |
the share able version of the gallery handles all loaded slideshow options uses a different layout view options: 2 (default) a homemde Jquery click through gallery 3 color box 4 Bootstrap gallery | def shareview
# set default
@template = 'slideshow_customv3'
if @view_options.has_key?(params[:v].to_i)
@template = 'slideshow_customv'+ params[:v]
end
# the main share view
# pulls in the child view
render 'shareshow'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_custom_gallery_layout\n @custom_gallery_layout = CustomGalleryLayout.includes(:gallery).find(params[:id])\n end",
"def index\n @custom_gallery_layouts = CustomGalleryLayout.all\n end",
"def set_gallery_layout\n @gallery_layout = GalleryLayout.find(params[:id])\n end",
"def edit_ga... | [
"0.6572105",
"0.6434013",
"0.64071244",
"0.6335001",
"0.61738694",
"0.57940537",
"0.57734025",
"0.5714842",
"0.5696586",
"0.56079865",
"0.5595246",
"0.55518544",
"0.5521605",
"0.55101585",
"0.55067056",
"0.54873884",
"0.54688084",
"0.54567015",
"0.54518473",
"0.5432044",
"0.5... | 0.59819245 | 5 |
for use on sorting of assets called via ajax from the gallery edit form | def sort
order = params[:asset]
if order.nil?
render json: {:kind => 'error', message: 'missing order' }
end
gid = params[:id]
if gid.nil?
render json: {:kind => 'error', order: 'missing gid' } unless gid.nil?
end
if Gallery.find(gid).update_attributes(:asset_order => order.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort\r\n ContentImage.sort(params[:content_image])\r\n render :nothing => true\r\n end",
"def index\n @sortable = SortIndex::Sortable.new(params, INDEX_SORT)\n @assets = Asset.find(:all, :order => (params[:sort_by] || \"TRIM(LOWER(tag))\") + \" \" + (params[:sort_direction] || \"asc\"))\n # ... | [
"0.72720325",
"0.704482",
"0.67985195",
"0.673777",
"0.6582928",
"0.6581432",
"0.6574663",
"0.6474469",
"0.6382383",
"0.6357996",
"0.63364017",
"0.6305623",
"0.62972844",
"0.62960565",
"0.62430483",
"0.62366754",
"0.6229339",
"0.62198466",
"0.62190264",
"0.61722845",
"0.61597... | 0.7700539 | 0 |
REQUEST_UPDATE_URL = ' DOWNLOAD_URL = ' | def pack_clone
cached = extension.cached_extension
raise NoCacheDataFoundError if cached.nil?
data = nil
retry_count = 4
exception = nil
while retry_count > 0
# Let's try more then once due to some
# weird JRuby reflection errors.
begin
@packer = cached.packer
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def original_url; end",
"def the_update_redirect; {:action => 'index'}; end",
"def update!(**args)\n @download_url = args[:download_url] if args.key?(:download_url)\n end",
"def update!(**args)\n @download_url = args[:download_url] if args.key?(:download_url)\n end",
"def de... | [
"0.6443138",
"0.6409104",
"0.63274336",
"0.63274336",
"0.626543",
"0.625269",
"0.6047755",
"0.6036368",
"0.59504133",
"0.59504133",
"0.59504133",
"0.59317756",
"0.59306055",
"0.5929881",
"0.59135985",
"0.58895355",
"0.58895355",
"0.58895355",
"0.5888446",
"0.5878807",
"0.5865... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_log
@log = Log.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
GET /account/emails GET /account/emails.json | def index
@emails = @job_application.emails.order(created_at: :desc)
@email = @job_application.emails.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emails\n respond_with_entity(api.get('/api/v1/profile/emails'),\n NexaasID::Entities::Profile::Emails)\n end",
"def emails(params={})\n @api.get(\"#{@api.path}/User/Emails\", params: params)\n end",
"def emails(params = {})\n @api.get(\"#{@api.path}/List/#{@id}... | [
"0.8425555",
"0.83056295",
"0.8068479",
"0.7728475",
"0.7728475",
"0.76029164",
"0.7543599",
"0.75286263",
"0.75068206",
"0.74531513",
"0.7386214",
"0.73391765",
"0.73260546",
"0.72535586",
"0.72535586",
"0.7125856",
"0.6969714",
"0.6924366",
"0.6817604",
"0.6811006",
"0.6800... | 0.0 | -1 |
POST /account/emails POST /account/emails.json | def create
@email = @job_application.emails.build(email_params)
@email.sender = current_user
@email.job_application = @job_application
respond_to do |format|
if @email.save
format.html { redirect_to @email, notice: t('.success') }
format.js {
@email = Email.new
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @email = @user.emails.new(email_params)\n\n respond_to do |format|\n if @email.save\n format.html { redirect_to @email, notice: 'Email was successfully created.' }\n format.json { render json: @email, status: :created, location: @email }\n else\n format.html { rend... | [
"0.67769635",
"0.6693649",
"0.66288054",
"0.6599711",
"0.6599032",
"0.65322214",
"0.65230304",
"0.6335358",
"0.63199496",
"0.6317502",
"0.62854266",
"0.62511224",
"0.62436026",
"0.6232595",
"0.61838454",
"0.6148495",
"0.6141446",
"0.60192686",
"0.6002277",
"0.5988156",
"0.596... | 0.5643759 | 48 |
Never trust parameters from the scary internet, only allow the white list through. | def email_params
params.require(:email).permit(:subject, :body)
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.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
GET /meal_postings GET /meal_postings.json | def index
@meal_postings = MealPosting.all
if params[:category]
@meal_postings = MealPosting.where("category_id = #{params[:id].to_i}")
end
if current_user_latitude
m_lat = current_user_latitude.to_f
m_lng = current_user_longitude.to_f
else
m_lat = 43.644881
m_lng = -7... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @postings = Posting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postings }\n end\n end",
"def meals\n get(\"/user/#{@user_id}/meals.json\")\n end",
"def index\n # get meals from the user\n @meals = @user.meals\n # ... | [
"0.70522827",
"0.6535552",
"0.64928573",
"0.6487145",
"0.64205307",
"0.6307551",
"0.62767184",
"0.62691754",
"0.6244019",
"0.62210685",
"0.61719835",
"0.6166923",
"0.61641943",
"0.6160813",
"0.6154207",
"0.61121005",
"0.6098336",
"0.60972977",
"0.603737",
"0.6034025",
"0.6021... | 0.59803 | 23 |
GET /meal_postings/1 GET /meal_postings/1.json | def show
@user = User.find(@meal_posting.user_id)
@usermeals = @user.meal_postings
@reservation = Reservation.new
@other_meal_ids = MealPosting.where("user_id = ? AND id != ?", @meal_posting.user_id, @meal_posting.id).ids
@ordered_meal_ids = @other_meal_ids.unshift(@meal_posting.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @postings = Posting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postings }\n end\n end",
"def set_meal_posting\n @meal_posting = MealPosting.find(params[:id])\n end",
"def show\n @meal = Meal.find(params[:id])\n\n res... | [
"0.6819854",
"0.6805924",
"0.65801305",
"0.65753675",
"0.65225846",
"0.6482386",
"0.645843",
"0.6442822",
"0.64175993",
"0.62506825",
"0.6241492",
"0.6241492",
"0.6195736",
"0.61741143",
"0.6166835",
"0.61477304",
"0.6126338",
"0.61005604",
"0.6066437",
"0.6045954",
"0.604595... | 0.6323743 | 9 |
POST /meal_postings POST /meal_postings.json | def create
@meal_posting = MealPosting.new(meal_posting_params)
@meal_posting.user = current_user
respond_to do |format|
if @meal_posting.save
format.html { redirect_to @meal_posting }#, notice: 'Meal posting was successfully created.' }
format.json { render :show, status: :created, l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meal_posting_params\n params.require(:meal_posting).permit(\n :base_time,\n :end_time,\n :title,\n :description,\n :allergy_notice,\n :servings,\n :cost,\n :image,\n :category_id,\n :date\n )\n end",
"def set_meal_posting\n ... | [
"0.6669151",
"0.6626104",
"0.63314104",
"0.6235877",
"0.6080736",
"0.607344",
"0.6043762",
"0.6033931",
"0.6026458",
"0.6024097",
"0.6003002",
"0.6001135",
"0.6000565",
"0.5985364",
"0.5984093",
"0.5936961",
"0.5906672",
"0.59041315",
"0.5892968",
"0.58695805",
"0.5862339",
... | 0.6583925 | 2 |
PATCH/PUT /meal_postings/1 PATCH/PUT /meal_postings/1.json | def update
respond_to do |format|
if @meal_posting.update(meal_posting_params)
format.html { redirect_to @meal_posting }#, notice: 'Meal posting was successfully updated.' }
format.json { render :show, status: :ok, location: @meal_posting }
else
format.html { render :edit }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @meal = Meal.find(params[:id])\n\n respond_to do |format|\n if @meal.update_attributes(params[:meal])\n format.html { redirect_to @meal, notice: 'Meal was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n ... | [
"0.6950256",
"0.6905296",
"0.66824234",
"0.6558555",
"0.6548742",
"0.6481511",
"0.6474261",
"0.64730376",
"0.6455844",
"0.645428",
"0.6440837",
"0.63924515",
"0.6377593",
"0.63349706",
"0.6309384",
"0.63084656",
"0.6307813",
"0.627951",
"0.6277522",
"0.6260983",
"0.6256802",
... | 0.6951255 | 0 |
DELETE /meal_postings/1 DELETE /meal_postings/1.json | def destroy
@meal_posting.destroy
redirect_to user_path(current_user.id)
# respond_to do |format|
# format.html { redirect_to meal_postings_url } #, notice: 'Meal posting was successfully destroyed.' }
# format.json { head :no_content }
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meal = Meal.find(params[:id])\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n ... | [
"0.7484094",
"0.73954177",
"0.72079843",
"0.713616",
"0.71062714",
"0.7083029",
"0.6982526",
"0.6981195",
"0.69770956",
"0.6971099",
"0.69513077",
"0.6930712",
"0.6926526",
"0.69067854",
"0.68865347",
"0.6882428",
"0.68744904",
"0.68304396",
"0.6820703",
"0.6798366",
"0.67886... | 0.71710634 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_meal_posting
@meal_posting = MealPosting.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 meal_posting_params
params.require(:meal_posting).permit(
:base_time,
:end_time,
:title,
:description,
:allergy_notice,
:servings,
:cost,
:image,
:category_id,
: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.6980244",
"0.6782812",
"0.6745103",
"0.6741142",
"0.6733961",
"0.65925",
"0.6503602",
"0.64967257",
"0.64822173",
"0.64796996",
"0.6456357",
"0.6439594",
"0.63803256",
"0.6376499",
"0.63644457",
"0.6319286",
"0.6299465",
"0.6298051",
"0.62935406",
"0.62923044",
"0.6291212"... | 0.0 | -1 |
Accepts two hashes representing pacts, outputs a merged hash Does not make any guarantees about order of interactions | def merge original, additional
new_pact = JSON.parse(original.to_json, symbolize_names: true)
merge_interactions_or_messages(new_pact, original, additional, :interactions)
merge_interactions_or_messages(new_pact, original, additional, :messages)
new_pact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(other_hash); end",
"def merge(hash_1, hash_2)\n\nend",
"def merge(hash_1, hash_2)\n merged = {}\n hash_1.each { |key, val| merged[key] = val }\n hash_2.each { |key, val| merged[key] = val }\n merged \nend",
"def deep_merge_hashes(master_hash, other_hash); end",
"def merge(hash); end",
"def ... | [
"0.724998",
"0.71176976",
"0.6880579",
"0.6845023",
"0.68224806",
"0.68224806",
"0.68224806",
"0.6792051",
"0.67894834",
"0.6774225",
"0.67683244",
"0.6752347",
"0.6739274",
"0.6714413",
"0.6643759",
"0.6643759",
"0.6530185",
"0.65210134",
"0.6465055",
"0.64481413",
"0.643355... | 0.57336646 | 75 |
letters that appear more than once in the string. You may assume the string contains only lowercase letters. Count the number of letters that repeat, not the number of times they repeat in the string. Difficulty: hard. | def num_repeats(string)
nums = Hash.new(0)
count = 0
string.each_char do |letter| nums[letter] += 1 end
nums.keys.each do |key|
if nums[key] > 1
count += 1
end
end
count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_repeats(string)\n i = 0 \n count = 0\n check = nil\n \n while i < string.length\n letter = string[i]\n i2 = 1 \n while i2 < string.length\n letter2 = string[i2]\n \n if i < i2\n if letter == letter2\n if ... | [
"0.845297",
"0.84511554",
"0.84294367",
"0.8401538",
"0.8346424",
"0.83328146",
"0.83195287",
"0.8304585",
"0.82560426",
"0.82437444",
"0.8177138",
"0.8172279",
"0.8164754",
"0.8148065",
"0.8141779",
"0.81121546",
"0.8093723",
"0.8070819",
"0.8057315",
"0.8051048",
"0.8027230... | 0.8121686 | 15 |
Converts the receipt to hash. | def to_hash
{
kind: @kind,
purchase_time_millis: @purchase_time_millis,
purchase_state: @purchase_state,
consumption_state: @consumption_state,
developer_payload: @developer_payload,
order_id: @order_id,
purchase_type: @purchase_type
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receipt\n receipt = {\n checkin: {\n id: self.id,\n checkin_at: self.checkin_at,\n client: {\n current_alias: self.client_current_alias\n }\n }\n }\n return receipt\n end",
"def hash\r\n return to_s.hash\r\n end",
"def to_hash() end",... | [
"0.61034805",
"0.60457736",
"0.60374385",
"0.6037283",
"0.59685266",
"0.59319824",
"0.5927868",
"0.59190387",
"0.59035605",
"0.58680767",
"0.58653635",
"0.5792722",
"0.5734073",
"0.5714879",
"0.5700355",
"0.5700355",
"0.5684686",
"0.5684686",
"0.5679435",
"0.5673042",
"0.5662... | 0.0 | -1 |
Converts the receipt to json. | def to_json
to_hash.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json\n json_object = {}\n\n json_object[:giftFrom] = @gift_from unless @gift_from.nil?\n json_object[:giftTo] = @gift_to unless @gift_to.nil?\n json_object[:giftMessage] = @gift_message unless @gift_message.nil?\n json_object[:giftAmount] = @gift_amount\n json_objec... | [
"0.66388696",
"0.6609762",
"0.6601247",
"0.6339184",
"0.63157284",
"0.6235999",
"0.62318265",
"0.62279457",
"0.6212542",
"0.6076281",
"0.6050476",
"0.602358",
"0.6004731",
"0.5999741",
"0.59972996",
"0.5978451",
"0.59556216",
"0.58878696",
"0.5877877",
"0.58648175",
"0.585667... | 0.56710273 | 57 |
Get things started by opening a pipe to mentos (the freshmaker), a Python process that talks to the Pygments library. We'll talk back and forth across this pipe. | def start(pygments_path = File.expand_path('../../../vendor/pygments-main/', __FILE__))
is_windows = RUBY_PLATFORM =~ /mswin|mingw/
begin
@log = Logger.new(ENV['MENTOS_LOG'] ||= is_windows ? 'NUL:' : '/dev/null')
@log.level = Logger::INFO
@log.datetime_format = "%Y-%m-%d %H:%M "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n @cmd.parse\n end",
"def start_repl\n require 'readline'\n\n loop do\n line = Readline.readline '>> ', true\n puts \"=> #{eval_ruby line, '(opal)'}\"\n end\n end",
"def new_pipe\n IO.popen(@cmdline, 'r+')\n end",
"def handle_pipe\n @html = RDoc::M... | [
"0.5742189",
"0.57261187",
"0.5694106",
"0.5645695",
"0.56386375",
"0.5632367",
"0.5591815",
"0.55593914",
"0.5491365",
"0.54399145",
"0.5423727",
"0.53573734",
"0.5330466",
"0.53169364",
"0.5279663",
"0.5271347",
"0.52413535",
"0.5182579",
"0.51821905",
"0.5168163",
"0.51652... | 0.68791664 | 0 |
Detect a suitable Python binary to use. We can't just use `python2` because apparently some old versions of Debian only have `python` or something like that. | def python_binary
@python_binary ||= begin
`which python2`
$?.success? ? "python2" : "python"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def python_binary\n ::File.join('', 'usr', 'bin', system_package_name)\n end",
"def ruby_platform\n case RUBY_PLATFORM\n when /win32|mswin|mingw/\n # Works on Windows XP, 2003, 7, 8 running Ruby 1.8.6 & 1.8.7, 1.9.2, 1.9.3 & 2.0.0 installed from RubyInstaller\n # Can't match for just 'w... | [
"0.6701546",
"0.6602228",
"0.6580553",
"0.6429678",
"0.63630134",
"0.61555034",
"0.61459076",
"0.61326444",
"0.6043095",
"0.60182005",
"0.59935975",
"0.5982502",
"0.5950971",
"0.59502363",
"0.5906662",
"0.58799654",
"0.5867814",
"0.58606654",
"0.58592105",
"0.5816778",
"0.581... | 0.7888845 | 0 |
Stop the child process by issuing a kill 9. We then call waitpid() with the pid, which waits for that particular child and reaps it. kill() can set errno to ESRCH if, for some reason, the file is gone; regardless the final outcome of this method | def stop(reason)
if @pid
begin
Process.kill('KILL', @pid)
Process.waitpid(@pid)
rescue Errno::ESRCH, Errno::ECHILD
end
end
@log.info "[#{Time.now.iso8601}] Killing pid: #{@pid.to_s}. Reason: #{reason}"
@pid = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kill\n ck_valid\n Process.kill 9, @pid if running?\n\n invalidate\n end",
"def stop \n logger.debug \"Instance stop method called for pid '#{pid}'\"\n if pid\n if @process\n @process.stop\n else\n Process.kill(\"KILL\", pid) rescue nil\n end\n\n Dir... | [
"0.6872095",
"0.68143153",
"0.68039554",
"0.6666287",
"0.6665016",
"0.6639633",
"0.6623792",
"0.6568069",
"0.6519124",
"0.6446459",
"0.6422976",
"0.6422976",
"0.63643485",
"0.6312217",
"0.62813914",
"0.6264704",
"0.6247214",
"0.61711574",
"0.61551434",
"0.6144981",
"0.6077158... | 0.58614504 | 30 |
Public: Get an array of available Pygments formatters Returns an array of formatters. | def formatters
mentos(:get_all_formatters).inject(Hash.new) do | hash, (name, desc, aliases) |
# Remove the long-winded and repetitive 'Formatter' suffix
name.sub!(/Formatter$/, '')
hash[name] = {
:name => name,
:description => desc,
:aliases => aliases
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatters\n @formatters ||= {}\n end",
"def registered_formats\n @@registered_formats\n end",
"def load_formatters\n @formatters_loaded ||= formatter_loader.load_formatters\n end",
"def formats\n @formats ||= Dir[File.join(path, \"#{name}.{otf,svg,ttf,woff,woff2,eot}\"... | [
"0.6540183",
"0.62686926",
"0.619354",
"0.58973736",
"0.589132",
"0.5837915",
"0.5795817",
"0.56955075",
"0.56666255",
"0.5590104",
"0.55382305",
"0.5397541",
"0.5367512",
"0.5326198",
"0.51450926",
"0.5116389",
"0.5112715",
"0.50685537",
"0.5031634",
"0.5027532",
"0.49842376... | 0.6941674 | 0 |
Public: Get all lexers from a serialized array. This avoids needing to spawn mentos when it's not really needed (e.g,. oneoff jobs, loading the Rails env, etc). Should be preferred to lexers! Returns an array of lexers | def lexers
begin
lexer_file = File.expand_path('../../../lexers', __FILE__)
raw = File.open(lexer_file, "r").read
Marshal.load(raw)
rescue Errno::ENOENT
raise MentosError, "Error loading lexer file. Was it created and vendored?"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lexers!\n mentos(:get_all_lexers).inject(Hash.new) do |hash, lxr|\n name = lxr[0]\n hash[name] = {\n :name => name,\n :aliases => lxr[1],\n :filenames => lxr[2],\n :mimetypes => lxr[3]\n }\n hash[\"dasm16\"] = {:name=>\"dasm16\", :aliases=>[\... | [
"0.67320645",
"0.6164363",
"0.5254804",
"0.5241521",
"0.5238476",
"0.5238476",
"0.5140343",
"0.511673",
"0.5108841",
"0.50321466",
"0.49398756",
"0.49263924",
"0.49168772",
"0.48905525",
"0.4885815",
"0.48664665",
"0.48413295",
"0.48345014",
"0.47873017",
"0.4780514",
"0.4774... | 0.66655296 | 1 |
Public: Get back all available lexers from mentos itself Returns an array of lexers | def lexers!
mentos(:get_all_lexers).inject(Hash.new) do |hash, lxr|
name = lxr[0]
hash[name] = {
:name => name,
:aliases => lxr[1],
:filenames => lxr[2],
:mimetypes => lxr[3]
}
hash["dasm16"] = {:name=>"dasm16", :aliases=>["DASM16"], :filenam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lexers\n begin\n lexer_file = File.expand_path('../../../lexers', __FILE__)\n raw = File.open(lexer_file, \"r\").read\n Marshal.load(raw)\n rescue Errno::ENOENT\n raise MentosError, \"Error loading lexer file. Was it created and vendored?\"\n end\n end",
"def lex... | [
"0.6885947",
"0.63904315",
"0.5938553",
"0.59332967",
"0.58677334",
"0.57099706",
"0.5630463",
"0.5563667",
"0.5533521",
"0.5527734",
"0.5489",
"0.5489",
"0.5489",
"0.5489",
"0.54663384",
"0.5420045",
"0.54042786",
"0.54042786",
"0.5338769",
"0.5313651",
"0.52789825",
"0.52... | 0.76063734 | 0 |
Public: Return an array of all available filters | def filters
mentos(:get_all_filters)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n @filters\n end",
"def list_filters\n if @filters.empty?\n fetch_configuration()\n end\n return @filters.keys\n end",
"def filters\n if metaclass.method_defined? :_filters\n self._filters\n else\n []\n end\n end",
"def avai... | [
"0.8036067",
"0.8028817",
"0.7818182",
"0.7743912",
"0.77258676",
"0.7668423",
"0.7668423",
"0.76011485",
"0.74664146",
"0.74646974",
"0.74490184",
"0.7412735",
"0.74028337",
"0.73002315",
"0.73002315",
"0.7222411",
"0.72193193",
"0.7208392",
"0.7208392",
"0.7179257",
"0.7168... | 0.8357021 | 0 |
Public: Return an array of all available styles | def styles
mentos(:get_all_styles)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def style_names\n styles.keys\n end",
"def styles\n return if @styles.empty?\n @styles.uniq.sort\n end",
"def styles\n return @metadata[:styles]\n end",
"def styles\n @styles ||= DEFAULT_STYLES\n end",
"def get_styles &block\n response = self.search :styles => nil\n ... | [
"0.80583775",
"0.7782728",
"0.7628489",
"0.7523441",
"0.7428694",
"0.7411489",
"0.7024396",
"0.70092267",
"0.69730496",
"0.69270605",
"0.6919429",
"0.6888362",
"0.6873544",
"0.68618697",
"0.6791133",
"0.67234826",
"0.66171616",
"0.6604849",
"0.66048056",
"0.6591996",
"0.65627... | 0.83108354 | 0 |
Public: Return css for highlighted code | def css(klass='', opts={})
if klass.is_a?(Hash)
opts = klass
klass = ''
end
mentos(:css, ['html', klass], opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highlight(code)\n CodeRay.scan(code, :ruby).div(:css => :class)\n end",
"def highlights; end",
"def highlights; end",
"def highlights; end",
"def syntax_highlight(html)\n line_numbers = config.line_numbers ? :table : nil\n opts = { css: :style, wrap: nil, line_numbers: line_numbers }\n ... | [
"0.80051976",
"0.7761386",
"0.7761386",
"0.7761386",
"0.73270196",
"0.73054844",
"0.73054844",
"0.725215",
"0.7231481",
"0.71437943",
"0.712061",
"0.6944744",
"0.69425654",
"0.69425654",
"0.69112086",
"0.6909204",
"0.68594164",
"0.6851947",
"0.68485",
"0.6799256",
"0.6742038"... | 0.0 | -1 |
Public: Return the name of a lexer. | def lexer_name_for(*args)
# Pop off the last arg if it's a hash, which becomes our opts
if args.last.is_a?(Hash)
opts = args.pop
else
opts = {}
end
if args.last.is_a?(String)
code = args.pop
else
code = nil
end
mentos(:lexer_name_for, arg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filename\n @__lexer.filename\n end",
"def lexer_for(language)\n self.lexers.find {|short, lang| language == lang}\n end",
"def lexer(op=nil)\n return @lexer if op.nil?\n @lexers[op.to_sym]\n end",
"def __name__() @__grammar__.name end",
"def get_token_name\n @@token_list[@state - ... | [
"0.70776075",
"0.68004054",
"0.66962093",
"0.662011",
"0.657607",
"0.6398756",
"0.63316065",
"0.63106585",
"0.6174714",
"0.6174714",
"0.5990275",
"0.5964485",
"0.59317976",
"0.5754384",
"0.5754384",
"0.5754384",
"0.57115674",
"0.57074845",
"0.57074845",
"0.57074845",
"0.57074... | 0.7682606 | 0 |
Public: Highlight code. Takes a firstposition argument of the code to be highlighted, and a secondposition hash of various arguments specifiying highlighting properties. | def highlight(code, opts={})
# If the caller didn't give us any code, we have nothing to do,
# so return right away.
return code if code.nil? || code.empty?
# Callers pass along options in the hash
opts[:options] ||= {}
# Default to utf-8 for the output encoding, if not given.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highlight(code, options = T.unsafe(nil)); end",
"def highlight\n return unless Config.live_highlight\n\n code = CodeRay.scan(line, :ruby).html\n\n cursor = text_cursor\n\n pos = cursor.position\n cursor.move_position Qt::TextCursor::End\n cursor.set_position @min_position, Qt::T... | [
"0.6783951",
"0.66417694",
"0.6533277",
"0.64814353",
"0.642166",
"0.62920815",
"0.6276742",
"0.62748015",
"0.61567134",
"0.6144134",
"0.61439776",
"0.61025304",
"0.61025304",
"0.61025304",
"0.6035483",
"0.60090464",
"0.60090464",
"0.59952736",
"0.59889627",
"0.5980565",
"0.5... | 0.61206007 | 11 |
Our 'rpc'ish request to mentos. Requires a method name, and then optional args, kwargs, code. | def mentos(method, args=[], kwargs={}, original_code=nil)
# Open the pipe if necessary
start unless alive?
begin
# Timeout requests that take too long.
timeout_time = ENV["MENTOS_TIMEOUT"] || 8
Timeout::timeout(timeout_time) do
# For sanity checking on both sides of... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request(rpc_method, attributes)\n self.class.request(rpc_method, attributes)\n end",
"def call_rpc(method, params: [])\n @api.send(method, *params)\n end",
"def request(rpc_method, request_args)\n return request_args unless request_args.is_a?(Hash)\n\n message_class = request_... | [
"0.730132",
"0.71731097",
"0.6959281",
"0.6946555",
"0.6879663",
"0.6729296",
"0.66433597",
"0.6509494",
"0.64779043",
"0.6399612",
"0.638149",
"0.63760865",
"0.63611513",
"0.632356",
"0.6323478",
"0.6320979",
"0.6296647",
"0.6281257",
"0.6268121",
"0.6259086",
"0.6232223",
... | 0.56459236 | 82 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.