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 |
|---|---|---|---|---|---|---|
Only allow a list of trusted parameters through. | def question_option_selection_params
params.require(:question_option_selection).permit(:question_answer_id, :question_option_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Single traces larger than +max_size+ will be discarded. | def initialize(encoder, max_size: DEFAULT_MAX_PAYLOAD_SIZE)
@encoder = encoder
@max_size = max_size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop\n traces = @traces.pop(VERY_LARGE_INTEGER)\n\n measure_pop(traces)\n\n traces\n end",
"def push(trace)\n return if @closed\n len = @traces.length\n if len < @max_size || @max_size <= 0\n @traces << trace\n else\n # we should replace a random trace with ... | [
"0.61693555",
"0.57163584",
"0.57105595",
"0.54114175",
"0.53919816",
"0.52930886",
"0.528617",
"0.5285338",
"0.5233599",
"0.5205406",
"0.51650554",
"0.51444846",
"0.514387",
"0.51410484",
"0.51288825",
"0.5065652",
"0.50645363",
"0.5055123",
"0.5051021",
"0.5035188",
"0.5033... | 0.0 | -1 |
Encodes a list of traces in chunks. Before serializing, all traces are normalized. Trace nesting is not changed. | def encode_in_chunks(traces)
encoded_traces = if traces.respond_to?(:filter_map)
# DEV Supported since Ruby 2.7, saves an intermediate object creation
traces.filter_map { |t| encode_one(t) }
else
traces.map { |t| encode_one(t) }.reject(&:nil?)
end
Datadog::Chunker.chunk_by_size(encoded_traces, max_size).map do |chunk|
[encoder.join(chunk), chunk.size]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_traces(traces)\n to_send = []\n traces.each do |trace|\n to_send << trace.map(&:to_hash)\n end\n encode(to_send)\n end",
"def batch(requests)\n data = requests.map { |request| Request.new(*request).data }\n RPC.log \"CLIENT ENCODE BATCH #{dat... | [
"0.6498665",
"0.5217285",
"0.4876195",
"0.48170498",
"0.47569302",
"0.47521403",
"0.46824327",
"0.4678066",
"0.46687075",
"0.46402425",
"0.46326843",
"0.460194",
"0.4559601",
"0.4554241",
"0.45117408",
"0.44863996",
"0.44578606",
"0.44557407",
"0.44481462",
"0.44431496",
"0.4... | 0.7816375 | 0 |
The alphabet is a series of characters used to create the bijection E.g: "wrdcuyjpbiflaqzesgmhvtknxo" The booster is used to avoid generating sequences that are too short E.g: If booster is zero then encoding an id close to zero will produce only one character. If you want a minimum of three then you should set your booster to ~1000 (depending on your alphabet) | def initialize(alphabet, booster = 0)
raise ArgumentError, "You must provide an alphabet" if alphabet.blank?
@alphabet = alphabet
@booster = booster
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(number)\n i = number + @booster\n return @alphabet[0] if i == 0\n s = StringIO.new\n base = @alphabet.length\n while i > 0\n s << @alphabet[i.modulo(base)]\n i /= base\n end\n s.string.reverse\n end",
"def bijective_encode\n \t# from http://refactormycode.com/codes/124... | [
"0.6529132",
"0.6510735",
"0.6432002",
"0.6418563",
"0.6315762",
"0.63018644",
"0.6275429",
"0.6214931",
"0.6181105",
"0.6165188",
"0.608075",
"0.60632944",
"0.6007543",
"0.5968244",
"0.5968244",
"0.5946893",
"0.5932772",
"0.59119284",
"0.5905748",
"0.58660555",
"0.58632106",... | 0.6587932 | 0 |
Transform an integer into a unique string using the engine alphabet and booster | def encode(number)
i = number + @booster
return @alphabet[0] if i == 0
s = StringIO.new
base = @alphabet.length
while i > 0
s << @alphabet[i.modulo(base)]
i /= base
end
s.string.reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obfuscate_id_default_spin\n alphabet = Array(\"a\"..\"z\")\n number = name.split(\"\").collect do |char|\n alphabet.index(char)\n end\n\n number.shift(12).join.to_i\n end",
"def id_to_code(id)\n (id.to_i * factor + pad).to_s(26).tr('0-9a-p', 'a-z')\n end",
"def bijecti... | [
"0.6958512",
"0.6827479",
"0.67895436",
"0.6759214",
"0.6696846",
"0.6667088",
"0.66527086",
"0.66306525",
"0.6624921",
"0.66217595",
"0.6428974",
"0.6424408",
"0.6417241",
"0.6383967",
"0.6349206",
"0.6348904",
"0.6312951",
"0.630796",
"0.63047916",
"0.6278765",
"0.62694585"... | 0.7293493 | 0 |
Transform a string into a number using the engine alphabet and booster | def decode(sentence)
i = 0
base = @alphabet.length
sentence.each_char { |c| i = i * base + @alphabet.index(c) }
i - @booster
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate_string_to_number(input)\n\n #take the input\n #break it up into individual letters\n #map the letters to a dictionary (a = 1) or\n #map the input to a placement in an array\n\nend",
"def numberfy(string)\n message = string.downcase.split(//)\n message.each do |char|\n (ALPHA.include?... | [
"0.7554814",
"0.74018365",
"0.7214068",
"0.6957951",
"0.6938035",
"0.6919406",
"0.6909402",
"0.6904871",
"0.6886612",
"0.68702227",
"0.68528515",
"0.6846937",
"0.6729191",
"0.6694879",
"0.6689013",
"0.66629046",
"0.66570514",
"0.66152585",
"0.66128427",
"0.65814877",
"0.65486... | 0.0 | -1 |
You can pass a set of Rools::Rules with a block parameter, or you can pass a filepath to evaluate. | def initialize(file = nil, &b)
@rules = {}
@facts = {}
@dependencies = {}
if block_given?
instance_eval(&b)
elsif file
# loading a file, check extension
name,ext = file.split(".")
logger.debug("loading ext: #{name}.#{ext}") if logger
case ext
when 'csv'
load_csv( file )
when 'xml'
load_xml( file )
when 'rb'
load_rb( file )
when 'rules' # for backwards compatibility
load_rb(file)
else
raise RuleLoadingError, "invalid file extension: #{ext}"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rule(expression, &block); end",
"def rule(expression, &block); end",
"def process_rules *args, &block\n Shotshare::ProcessRuleContainer.instance.rules = \\\n Docile.dsl_eval(Shotshare::Dsl::ProcessRuleBuilder.new, &block).build\nend",
"def evaluate\n ::File.open path, 'r' do |file|\n self.ins... | [
"0.6878293",
"0.6878293",
"0.6278457",
"0.62452257",
"0.6171773",
"0.6100549",
"0.60940397",
"0.58921695",
"0.58468896",
"0.5838046",
"0.5811137",
"0.57737714",
"0.5721038",
"0.5721038",
"0.5629911",
"0.5594984",
"0.5594359",
"0.55670804",
"0.54709446",
"0.5458658",
"0.544644... | 0.55607903 | 18 |
XML File format loading | def load_xml( fileName )
begin
str = IO.read(fileName)
load_xml_rules_as_string(str)
rescue Exception => e
raise RuleLoadingError, "loading xml file"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml\n File.read(\"#{@file_path}.xml\")\n end",
"def load_xml file\n f = File.open file\n doc = Nokogiri::XML f\n f.close\n doc\n end",
"def load_xml(file_path)\n # Read the source XML file.\n puts \"file_path: #{file_path}\"\n raw_xml = File.read(file_path)\n\n # Parse raw_xml usin... | [
"0.7083245",
"0.6956713",
"0.69328636",
"0.6878722",
"0.67321295",
"0.67237556",
"0.6714798",
"0.66518545",
"0.6639957",
"0.6627784",
"0.660921",
"0.6597494",
"0.65765256",
"0.6517185",
"0.6513018",
"0.6509384",
"0.6416764",
"0.6402708",
"0.63981956",
"0.639698",
"0.6383532",... | 0.63386256 | 21 |
load xml rules as a string | def load_xml_rules_as_string( str )
begin
doc = REXML::Document.new str
doc.elements.each( "rule-set") { |rs|
facts = rs.elements.each( "facts") { |f|
facts( f.attributes["name"] ) do f.text.strip end
}
rules = rs.elements.each( "rule") { |rule_node|
rule_name = rule_node.attributes["name"]
priority = rule_node.attributes["priority"]
rule = Rule.new(self, rule_name, priority, nil)
parameters = rule_node.elements.each("parameter") { |param|
#logger.debug "xml parameter: #{param.text.strip}"
rule.parameters(eval(param.text.strip))
}
conditions = rule_node.elements.each("condition") { |cond|
#logger.debug "xml condition #{cond}"
rule.condition do eval(cond.text.strip) end
}
consequences = rule_node.elements.each("consequence") { |cons|
#logger.debug "xml consequence #{cons}"
rule.consequence do eval(cons.text.strip) end
}
@rules[rule_name] = rule
}
logger.debug( "loaded #{rules.size} rules") if logger
}
rescue Exception => e
raise RuleLoadingError, "loading xml file"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_rb_rules_as_string( str )\r\n instance_eval(str) \r\n end",
"def load_xml( fileName )\r\n begin\r\n str = IO.read(fileName)\r\n load_xml_rules_as_string(str)\r\n rescue Exception => e\r\n raise RuleLoadingError, \"loading xml file\"\r\n end\r\n end",
"... | [
"0.6614879",
"0.6465752",
"0.62848926",
"0.5847496",
"0.58037853",
"0.57882994",
"0.5785168",
"0.5785168",
"0.57822543",
"0.5594589",
"0.55761635",
"0.553359",
"0.55334383",
"0.5523808",
"0.5498931",
"0.54329294",
"0.5421628",
"0.5413334",
"0.5360488",
"0.5326475",
"0.5317063... | 0.8187123 | 0 |
Ruby File format loading | def load_rb( file )
begin
str = IO.read(file)
load_rb_rules_as_string(str)
rescue Exception => e
raise RuleLoadingError, "loading ruby file"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(file); end",
"def load(file_path); end",
"def load(file_path); end",
"def load_file(file); end",
"def load_file(filename); end",
"def load_file(filename); end",
"def load(path); end",
"def load_rb(filename); end",
"def load(filename)\n end",
"def parse_file(filename); end",
"def loa... | [
"0.7755398",
"0.76378787",
"0.76378787",
"0.7594539",
"0.74882066",
"0.74882066",
"0.740394",
"0.72689676",
"0.7105456",
"0.69953686",
"0.69162524",
"0.68671757",
"0.678695",
"0.6743152",
"0.67321265",
"0.66591966",
"0.66520256",
"0.6648247",
"0.6588965",
"0.65884817",
"0.656... | 0.0 | -1 |
load ruby rules as a string | def load_rb_rules_as_string( str )
instance_eval(str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_rules; end",
"def load_cop_rules(rules); end",
"def load_rb( file )\r\n begin\r\n str = IO.read(file)\r\n load_rb_rules_as_string(str)\r\n rescue Exception => e\r\n raise RuleLoadingError, \"loading ruby file\"\r\n end\r\n end",
"def load_rules(rules)\n se... | [
"0.71179456",
"0.6813576",
"0.67687064",
"0.6730322",
"0.64818746",
"0.64786035",
"0.6327589",
"0.6291419",
"0.62018955",
"0.6122252",
"0.60696495",
"0.60696495",
"0.5879198",
"0.57756126",
"0.5710738",
"0.56699216",
"0.5638297",
"0.5631757",
"0.56191456",
"0.56005305",
"0.55... | 0.7973769 | 0 |
returns an array of facts | def get_facts
@facts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def facts\n @facts ||= {}\n end",
"def list\n load_all\n return @facts.keys\n end",
"def list\n load_all\n @facts.keys\n end",
"def all_facts\n @facts.values.collect { |property_facts| property_facts.values }.flatten\n end",
"def facts_for(entity, property)\n ... | [
"0.7494817",
"0.7268276",
"0.7104335",
"0.7043786",
"0.67014706",
"0.66596556",
"0.6551511",
"0.6504118",
"0.63914436",
"0.6369102",
"0.62914336",
"0.62493324",
"0.61840606",
"0.6106346",
"0.60129654",
"0.60018766",
"0.5938833",
"0.5759471",
"0.57307464",
"0.57307464",
"0.570... | 0.77920645 | 0 |
returns all the rules defined for that set | def get_rules
@rules
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n @rules\n end",
"def rules\n return @rules\n end",
"def rules\n @rules.map{|r| [r.name, r.rule]}.to_h\n end",
"def rules\n @rules ||= []\n end",
"def rules\n @rules ||= []\n end",
"def ruleset_rules\n @rulesets.collect do |r|\n ... | [
"0.7793942",
"0.7636718",
"0.7592193",
"0.75142276",
"0.75142276",
"0.7487639",
"0.72660935",
"0.72660935",
"0.72660935",
"0.72629726",
"0.72176915",
"0.72176915",
"0.72176915",
"0.72176915",
"0.72176915",
"0.72176915",
"0.72176915",
"0.71722114",
"0.7149962",
"0.7121508",
"0... | 0.7439468 | 6 |
A single fact can be an single object of a particular class type or a collection of objects of a particular type | def fact( obj )
#begin
# check if facts already exist for that class
# if so, we need to add it to the existing list
cls = obj.class.to_s.downcase
cls.gsub!(/:/, '_')
if @facts.key? cls
logger.debug( "adding to facts: #{cls}") if logger
@facts[cls].fact_value << obj
else
logger.debug( "creating facts: #{cls}") if logger
arr = Array.new
arr << obj
proc = Proc.new { arr }
@facts[cls] = Facts.new(self, cls, proc )
end
#rescue Exception=> e
# logger.error e if logger
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fact_class\r\n owning_class\r\n end",
"def fact_class\n cube.class.fact_class\n end",
"def extract_feature_object_types(doc, feature)\n # Tie this feature to a FeatureObjectType and through it an ObjectType\n admin_thesaurus_term = doc.at(\"/feature/fheader/fclass\")['term']\n... | [
"0.61535436",
"0.6050221",
"0.57339996",
"0.5546405",
"0.5408621",
"0.53951824",
"0.53747165",
"0.5359557",
"0.53043044",
"0.5302296",
"0.5268773",
"0.52346116",
"0.51863056",
"0.51644444",
"0.5158612",
"0.5130518",
"0.51115173",
"0.510841",
"0.51074904",
"0.5098112",
"0.5089... | 0.6582 | 0 |
Delete all existing facts | def delete_facts
@facts = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all\n @configuration = nil\n end",
"def delete_all\n @configuration = nil\n end",
"def delete_all\n target.clear\n end",
"def destroy_all\n all.each(&:destroy)\n end",
"def delete_all\n self.store.delete_keys(find_keys)\n end",
... | [
"0.72164387",
"0.72164387",
"0.7179863",
"0.7125613",
"0.7121009",
"0.71049255",
"0.7014218",
"0.6972486",
"0.6937076",
"0.6912945",
"0.6873016",
"0.68672895",
"0.6845922",
"0.6832502",
"0.6822878",
"0.68077195",
"0.6805079",
"0.6805079",
"0.6787817",
"0.67664945",
"0.6731538... | 0.84084576 | 0 |
Use in conjunction with Rools::RuleSetwith to create a Rools::Rule dependent on another. Dependencies are created through names (converted to strings and downcased), so lax naming can get you into trouble with creating dependencies or overwriting rules you didn't mean to. | def extend(name, &b)
name.to_s.downcase!
@extend_rule_name = name
instance_eval(&b) if block_given?
return self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rule!(name, opts = {}, &definition)\n rule(name, opts) { self.instance_eval(&definition).as(name) }\n end",
"def set_dependency(res_name1, res_name2)\n check_freeze\n validate_arg = proc {|o|\n o = Util.build_const(o) if o.is_a? String\n raise ArgumentError unless o.is_a?(... | [
"0.58839417",
"0.57827204",
"0.5732911",
"0.5719083",
"0.5440427",
"0.5427264",
"0.5355852",
"0.5355065",
"0.53180116",
"0.5304991",
"0.53002656",
"0.52963644",
"0.5271722",
"0.52603656",
"0.5222042",
"0.5222042",
"0.5214741",
"0.5207046",
"0.5179739",
"0.51741356",
"0.517413... | 0.0 | -1 |
Stops the current assertion. Does not indicate failure. | def stop(message = nil)
@assert = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop\n msg = \"guard-self_test is stopped...\"\n UI.info msg\n Notifier.notify(msg)\n end",
"def stop_test(test)\n puts \"Test was stopped mid execution: #{test.uri}\"\n end",
"def stop_test_case\n return logger.error { \"Could not stop test case, no test case is running\" } unle... | [
"0.67832035",
"0.6547782",
"0.651686",
"0.63943756",
"0.63706154",
"0.6355129",
"0.6264343",
"0.6263689",
"0.6251894",
"0.6166021",
"0.6166021",
"0.6126806",
"0.61249775",
"0.61223114",
"0.61156374",
"0.6082949",
"0.60592645",
"0.60485375",
"0.6011075",
"0.600784",
"0.5971989... | 0.7875146 | 0 |
Stops the current assertion and change status to :fail | def fail(message = nil)
@status = FAIL
@assert = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(message = nil)\r\n @assert = false\r\n end",
"def fail_now\n fail\n raise TestFail\n end",
"def fail(message = nil)\n if @__assert_pending__ == 0\n if halt_on_fail?\n raise Result::TestFailure, message || \"\"\n else\n capture_result(Assert::Re... | [
"0.72820985",
"0.7252399",
"0.6899079",
"0.6854849",
"0.67692125",
"0.67598766",
"0.67290473",
"0.67276686",
"0.67276686",
"0.6621376",
"0.6612223",
"0.6586547",
"0.6563205",
"0.6563205",
"0.65092444",
"0.648474",
"0.6470521",
"0.64400804",
"0.641346",
"0.6382244",
"0.6360785... | 0.7579891 | 0 |
an assert has been made within a rule | def rule_assert( obj )
# add object as a new fact
f = fact(obj)
# get_relevant_rules
logger.debug( "Check if we need to add more rules") if logger
add_relevant_rules_for_fact(f)
sort_relevant_rules
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert(obj)\r\n @rule_set.rule_assert(obj)\r\n end",
"def assertions; end",
"def assertions; end",
"def assert(expr)\n fail 'Assertion failed' unless expr\n end",
"def assert(expr)\n raise 'Assertion failed' unless (expr)\n end",
"def assert\n\tyield\nend",
"def assert\n\tyi... | [
"0.74538875",
"0.71891856",
"0.71891856",
"0.66735715",
"0.66657466",
"0.6636732",
"0.6636732",
"0.6584969",
"0.6566555",
"0.65412253",
"0.6539189",
"0.65313923",
"0.65313923",
"0.6529663",
"0.6525103",
"0.6520264",
"0.6517361",
"0.6517361",
"0.6514503",
"0.6506171",
"0.64896... | 0.7101034 | 3 |
Turn passed object into facts and evaluate all relevant rules Previous facts of same type are removed | def assert( *objs )
objs.each { |obj|
fact(obj)
}
return evaluate()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rule_assert( obj )\r\n # add object as a new fact\r\n f = fact(obj)\r\n # get_relevant_rules\r\n logger.debug( \"Check if we need to add more rules\") if logger\r\n add_relevant_rules_for_fact(f)\r\n sort_relevant_rules\r\n end",
"def assert_facts_from_rule(rule_object)\n\n ... | [
"0.60669965",
"0.5695625",
"0.5545631",
"0.53663915",
"0.53335416",
"0.5318605",
"0.53155166",
"0.5298187",
"0.52801955",
"0.5274887",
"0.5251812",
"0.523486",
"0.5233228",
"0.52292717",
"0.52231187",
"0.5217648",
"0.5211928",
"0.5203749",
"0.5196249",
"0.51700497",
"0.516967... | 0.0 | -1 |
for a particular fact, we need to retrieve the relevant rules and add them to the relevant list | def add_relevant_rules_for_fact fact
@rules.values.select { |rule|
if !@relevant_rules.include?( rule)
if rule.parameters_match?(fact.value)
@relevant_rules << rule
logger.debug "#{rule} is relevant" if logger
else
logger.debug "#{rule} is not relevant" if logger
end
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_relevant_rules\r\n @relevant_rules = Array.new\r\n @facts.each { |k,f| \r\n add_relevant_rules_for_fact f\r\n }\r\n sort_relevant_rules\r\n end",
"def rules_by_name; end",
"def rules_from_step_content\n @rules_from_step_content ||= content_items.each_with_object({}) do ... | [
"0.7580315",
"0.6833116",
"0.677695",
"0.67665654",
"0.6523524",
"0.6523524",
"0.6523524",
"0.6523524",
"0.6523524",
"0.6523524",
"0.6523524",
"0.6519024",
"0.64688337",
"0.64688337",
"0.6444558",
"0.6444558",
"0.6444558",
"0.6357586",
"0.6325273",
"0.62844115",
"0.6251636",
... | 0.7809773 | 0 |
relevant rules need to be sorted in priority order | def sort_relevant_rules
# sort array in rule priority order
@relevant_rules = @relevant_rules.sort do |r1, r2|
r2.priority <=> r1.priority
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_if_needed\n @rules.sort! unless @sorted\n @sorted = true\n end",
"def optimize_order!(rules)\n first_can_in_group = -1\n rules.each_with_index do |rule, i|\n (first_can_in_group = -1) && next unless rule.base_behavior\n (first_can_in_group = i) && next ... | [
"0.77348995",
"0.7692838",
"0.71726584",
"0.70538974",
"0.6967807",
"0.6660927",
"0.66408473",
"0.66164094",
"0.66164094",
"0.66164094",
"0.66164094",
"0.66164094",
"0.66164094",
"0.66164094",
"0.6531411",
"0.64810646",
"0.6457969",
"0.6288312",
"0.6256381",
"0.62449473",
"0.... | 0.8185103 | 0 |
get all relevant rules for all specified facts | def get_relevant_rules
@relevant_rules = Array.new
@facts.each { |k,f|
add_relevant_rules_for_fact f
}
sort_relevant_rules
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n @rules\n end",
"def rules_by_name; end",
"def rules\n @rules.map{|r| [r.name, r.rule]}.to_h\n end",
"def add_relevant_rules_for_fact fact\r\n @rules.values.select { |rule| \r\n if !@relevant_rules.include?( rule)\r\n if rule.parameters_match?(fact.value) \r\n ... | [
"0.7097032",
"0.6890875",
"0.6853133",
"0.6829951",
"0.6672312",
"0.6652536",
"0.66160196",
"0.6602752",
"0.65246457",
"0.65246457",
"0.650818",
"0.6499943",
"0.6499943",
"0.6499943",
"0.6499943",
"0.6499943",
"0.6499943",
"0.6499943",
"0.6449105",
"0.6449105",
"0.6449105",
... | 0.8081455 | 0 |
evaluate all relevant rules for specified facts | def evaluate
@status = PASS
@assert = true
@num_executed = 0;
@num_evaluated = 0;
get_relevant_rules()
logger.debug("no relevant rules") if logger && @relevant_rules.size==0
#begin #rescue
# loop through the available_rules, evaluating each one,
# until there are no more matching rules available
begin # loop
# the loop condition is reset to break by default after every iteration
matches = false
obj = nil #deprecated
#logger.debug("available rules: #{available_rules.size.to_s}") if logger
@relevant_rules.each do |rule|
# RuleCheckErrors are caught and swallowed and the rule that
# raised the error is removed from the working-set.
logger.debug("evaluating: #{rule}") if logger
begin
@num_evaluated += 1
if rule.conditions_match?(obj)
logger.debug("rule #{rule} matched") if logger
matches = true
# remove the rule from the working-set so it's not re-evaluated
@relevant_rules.delete(rule)
# find all parameter-matching dependencies of this rule and
# add them to the working-set.
if @dependencies.has_key?(rule.name)
logger.debug( "found dependant rules to #{rule}") if logger
@relevant_rules += @dependencies[rule.name].select do |dependency|
dependency.parameters_match?(obj)
end
end
# execute this rule
logger.debug("executing rule #{rule}") if logger
rule.call(obj)
@num_executed += 1
# break the current iteration and start back from the first rule defined.
break
end # if rule.conditions_match?(obj)
rescue RuleConsequenceError
fail
rescue RuleCheckError => e
fail
end # begin/rescue
end # available_rules.each
end while(matches && @assert)
#rescue RuleConsequenceError => rce
# RuleConsequenceErrors are allowed to break out of the current assertion,
# then the inner error is bubbled-up to the asserting code.
# @status = FAIL
# raise rce.inner_error
#end
@assert = false
return @status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_relevant_rules\r\n @relevant_rules = Array.new\r\n @facts.each { |k,f| \r\n add_relevant_rules_for_fact f\r\n }\r\n sort_relevant_rules\r\n end",
"def add_relevant_rules_for_fact fact\r\n @rules.values.select { |rule| \r\n if !@relevant_rules.include?( rule)\r\n ... | [
"0.6823999",
"0.67219603",
"0.6701946",
"0.6554284",
"0.650058",
"0.650058",
"0.632449",
"0.6275201",
"0.6275201",
"0.62481976",
"0.62459016",
"0.62459016",
"0.62459016",
"0.62459016",
"0.62459016",
"0.62459016",
"0.62459016",
"0.62030774",
"0.6162582",
"0.6126606",
"0.610612... | 0.7222914 | 0 |
def test_round_has_feedback redundant end | def test_correct_number_user_answer_1
assert_equal @round.number_correct, 0
result = @round.record_guess("Juneau")
assert_equal @round.number_correct, 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def test_unranked_recall\n\n add_test_judgements \n add_unranked_query_result\n assert_equal(1.0, @query_result.statistics[:recall])\n \n end",
"def test_truth\n end",
"def test_guess_feedback_is_incorrect\n card_1 = Card.new(\"3\", \"Hearts\")\n ca... | [
"0.6857681",
"0.6695703",
"0.6685089",
"0.6537783",
"0.64951515",
"0.6463348",
"0.6463348",
"0.6459506",
"0.6459506",
"0.645235",
"0.6426935",
"0.6404251",
"0.6402619",
"0.639003",
"0.6372724",
"0.6367403",
"0.6343219",
"0.6342789",
"0.63336694",
"0.63307756",
"0.6317173",
... | 0.59586006 | 71 |
lookup app name either in the file or if already cached look in the metadata variable | def lookup(app_name)
unless @metadata.key?(app_name)
data = YAML.load_file("./data/applications/#{app_name}.yaml")
@metadata[app_name] = data['cots::app_metadata']
end
@metadata[app_name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_app_name(app_name)\n app_file = $pkg_dir+\"/\"+app_name.downcase.gsub(/ |-/,'_')+\".rb\"\n if File.exist?(app_file)\n app_name = eval(\"get_#{app_name.downcase.gsub(/ |-/,'_')}_app_name()\")\n else\n app_list = Dir.entries($pkg_dir)\n tmp_name = app_list.grep(/^#{app_name.downcase.gsub(/ |-/,'_... | [
"0.72688407",
"0.6998888",
"0.6632529",
"0.66260004",
"0.6625991",
"0.6451284",
"0.6280447",
"0.6277652",
"0.6266911",
"0.6266208",
"0.6180625",
"0.6162862",
"0.6134059",
"0.6134059",
"0.6116541",
"0.6106713",
"0.60854656",
"0.6083655",
"0.607067",
"0.6051834",
"0.6045461",
... | 0.81205225 | 0 |
Renders an with the given options | def share_button(options={})
%(
<fb:share-button class="meta">
#{SHARE_META_OPTIONS.select {|o| options.keys.include?(o) }.collect {|o| %(<meta name="#{o}" content="#{options[o]}" />)}.join("\n") }
#{SHARE_LINK_OPTIONS.select {|o| options.keys.include?(o) }.collect {|o| %(<link rel="#{o}" href="#{options[o]}" />)}.join("\n")}
</fb:share-button>
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(context, options); end",
"def render(options = {})\n raise double_render! if rendered?\n @render_opts = options\n end",
"def render(opts={})\n opts\n end",
"def options\n render plain: ''\n end",
"def options\n render plain: ''\n end",
"def options\n ren... | [
"0.7419733",
"0.7415207",
"0.7281017",
"0.71469915",
"0.7122455",
"0.7122455",
"0.7122455",
"0.7008976",
"0.69250953",
"0.69250953",
"0.68507",
"0.66892415",
"0.6665263",
"0.65970784",
"0.65567183",
"0.6540503",
"0.6526751",
"0.6505733",
"0.65030396",
"0.6449255",
"0.63260764... | 0.0 | -1 |
Defini 2 variables de la fonction soustraction | def subtract (num1, num2)
num1 - num2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suivre; end",
"def probers=(_arg0); end",
"def mi_carrera\n\n\tend",
"def operations; end",
"def operations; end",
"def terpene; end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def schubert; end",
"def zuruecksetzen()\n end",
"def SE02=(arg)",
"def prober... | [
"0.7078675",
"0.65198433",
"0.63651127",
"0.6354521",
"0.6354521",
"0.6345544",
"0.632831",
"0.632831",
"0.632831",
"0.63188225",
"0.62680763",
"0.62598956",
"0.62519693",
"0.62454736",
"0.62454736",
"0.62033784",
"0.61968815",
"0.6189542",
"0.61565644",
"0.61467534",
"0.6146... | 0.0 | -1 |
Defini la variable Array(input) pour la fonction Somme | def sum (arr)
somme = 0 # initialiser la variable la somme à 0 #
arr.each do |x| # utilisation de l'itérateur each qui va prendre chaque valeur de cette variable #
somme += x # (somme = somme + x )chaque valeur de l'array est ajouter a la variable somme #
end
return somme #
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_method(input)\n\treturn \"thanks for the sweet array!\"\nend",
"def Array(p0) end",
"def input\r\n\t\t@input.map{|i| i}\t\r\n\tend",
"def getArray _args\n \"getArray _args;\" \n end",
"def array()\n\t\t@array\n\tend",
"def converted_arrays; end",
"def array\n raise \"Not implemen... | [
"0.7308989",
"0.717847",
"0.6574854",
"0.6253808",
"0.6248152",
"0.62263083",
"0.62097806",
"0.6200058",
"0.61489546",
"0.6116126",
"0.6084882",
"0.60466164",
"0.6031486",
"0.6031486",
"0.6031486",
"0.6011125",
"0.5981597",
"0.59698737",
"0.5938714",
"0.59287256",
"0.5919278"... | 0.0 | -1 |
s.request(link) do|success,body| body if success end | def request(link, &blk)
link = hook(link)
log "request: #{link} -> #{blk.inspect}"
@multi.add( Curl::Easy.new(link) do|c|
c.follow_location = true
c.headers["User-Agent"] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.20"
c.on_success{|curl| yield(true, curl.body_str) ; @active_requests -= 1 ; log("request:#{link} success") }
c.on_failure{|curl,code| yield(false, curl.body_str) ; @active_requests -= 1 ; log("request:#{link} failure with curl code: #{code}") }
end )
# returns active request count
@active_requests += 1
@active_requests
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_request(method, url, body, headers); end",
"def request(*args, &block); end",
"def get_response(uri, req)\n Net::HTTP.start(uri.hostname, uri.port){|http| http.request(req) }\nend",
"def request(endpoint, request, &block); end",
"def make_get_request(uri)\n response = Net::HTTP.get_response(ur... | [
"0.6746118",
"0.6691358",
"0.65664744",
"0.656512",
"0.6539215",
"0.6491686",
"0.63756734",
"0.63609964",
"0.63474333",
"0.63073367",
"0.6291987",
"0.62752783",
"0.62700534",
"0.62659705",
"0.626111",
"0.62349266",
"0.6214002",
"0.6188199",
"0.61848915",
"0.61757624",
"0.6171... | 0.7164632 | 0 |
c = Crawl::Extract.new(session, feed_obj, 'url..',Feed::Atom) | def initialize(dir_root,session, feed, feed_url, feed_klass)
@dir_root = dir_root
@post_cb = lambda{|p,fo| nil }
@feed_url = feed_url
@session = session
@feed_klass = feed_klass
@feed = feed
@dup_check = lambda{|ptitle,plink| false }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_feed(url)\n source = URI.open(url, 'User-Agent' => 'Mozilla/5.0')\n feed = RSS::Parser.parse(source)\nend",
"def parse_by_rss_feed(url,rss_link_id)\n feeds = RssFeed::RssFeed.parse_rss_url(url)\n feeds.entries.each do |item|\n params = {\n :title => item.title,\n :des... | [
"0.64352965",
"0.6323135",
"0.62857777",
"0.6271508",
"0.62419844",
"0.61828256",
"0.6113405",
"0.6035113",
"0.60275364",
"0.6024494",
"0.6024494",
"0.6014455",
"0.59951246",
"0.59930396",
"0.5975961",
"0.5970141",
"0.5934416",
"0.59123224",
"0.5911166",
"0.58972096",
"0.5888... | 0.0 | -1 |
override this to extract specific elements, e.g. a post image | def extract(body,uri,item_content={})
{:body => normalize((Hpricot(body)/'body').inner_html), :thumb_path=>nil, :has_video=>false }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_body(article)\n out_html = \"\"\n elem = article.at('.news-image').next_element\n\n while true do\n break if elem.attribute(\"class\") && elem.attribute(\"class\").text == \"news-single-rightbox\"\n out_html << elem.to_html\n elem = elem.next_element\n # Let it cras... | [
"0.62659484",
"0.6106848",
"0.6067401",
"0.60529053",
"0.5922791",
"0.5860852",
"0.5851947",
"0.5839287",
"0.58313787",
"0.5827338",
"0.5778406",
"0.57426995",
"0.57204425",
"0.57093227",
"0.56891894",
"0.56310445",
"0.55962515",
"0.55898577",
"0.5572398",
"0.55665094",
"0.55... | 0.60957813 | 2 |
c.posts do|post| post.source_url post.title post.link post.thumb post.summary post.body post.tags post.author end | def posts # proxy the posts struct
@post_cb = lambda{|post,fobj| yield post,fobj }
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def posts; end",
"def getPosts()\n\t\tself.post\n\tend",
"def view_posts()\n posts = @db.execute(\"SELECT * FROM posts\")\n @categories = @db.execute(\"SELECT * FROM categories\")\n\n comments = @db.execute(\"SELECT * FROM comments\").each do |comment|\n comment = comment[\"user... | [
"0.7035623",
"0.6527618",
"0.64957213",
"0.645495",
"0.6439085",
"0.63842607",
"0.6325334",
"0.6231727",
"0.6226449",
"0.6223985",
"0.6223985",
"0.6198908",
"0.6194824",
"0.617871",
"0.6150881",
"0.6150881",
"0.61096644",
"0.6045314",
"0.6037336",
"0.6037199",
"0.60022485",
... | 0.5796785 | 54 |
The tree name is the same for any genealogy tree, so it doesn't make sense to load the selected node from the session. | def active_node_set(tree_nodes)
# Find the right node to be selected based on the @root.id
selected = tree_nodes.first[:nodes].find do |node|
self.class.extract_node_model_and_id(node[:key])[1] == @root.id.to_s
end
# If no node has been found, just select the root node
selected ||= tree_nodes.first
# Set it as the active node in the tree state
@tree_state.x_node_set(selected[:key], @name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name\n\n tree[0]\n end",
"def default_tree_name\n ''\n end",
"def set_tree\n\t\t@tree = Tree.find(params[:id])\n\tend",
"def set_tree\n @tree = Tree.find(params[:id])\n end",
"def set_tree\n @tree = Tree.find(params[:id])\n end",
"def set_tree\n @tree = Tree.find(... | [
"0.64836603",
"0.6103375",
"0.60930496",
"0.60095096",
"0.6008018",
"0.6008018",
"0.6008018",
"0.6008018",
"0.59673995",
"0.59000236",
"0.59000236",
"0.58977807",
"0.5787297",
"0.5723056",
"0.57167554",
"0.5714791",
"0.5699579",
"0.5693705",
"0.5688577",
"0.56785065",
"0.5655... | 0.53079295 | 44 |
End point: (POST) Usage: FundAmerica::Entity.create(options) Output: Creates a new entity person or company | def create(options)
API::request(:post, 'entities', options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n entity_data = entity_params\n entity_data[:uid] = Services::UniqueIdGenerator.new.call\n cmd = Commands::Entities::CreateEntity.new(entity_data)\n execute(cmd)\n redirect_to entities_url, success: 'Entity was successfully created.'\n rescue => error\n redirect_to new_entity_url, war... | [
"0.80050886",
"0.75879395",
"0.7370819",
"0.734434",
"0.7215701",
"0.72090715",
"0.7173726",
"0.69844687",
"0.6907714",
"0.68506914",
"0.68433094",
"0.68350613",
"0.6777085",
"0.67148036",
"0.6704023",
"0.6653209",
"0.66500217",
"0.66299933",
"0.65896857",
"0.6578828",
"0.656... | 0.7351618 | 3 |
End point: (PATCH) Usage: FundAmerica::Entity.update(entity_id, options) Output: Updates an entity person or company Uses test_mode update when used in sandbox mode | def update(entity_id, options)
API::request(:patch, "entities/#{entity_id}", options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n entity_data = entity_params\n entity_data[:uid] = @entity.uid\n cmd = Commands::Entities::EditEntity.new(entity_data)\n execute(cmd)\n redirect_to entities_url, success: 'Entity was successfully updated.'\n rescue => error\n redirect_to edit_entity_url, warning: error_messages(error... | [
"0.6717854",
"0.66933495",
"0.6560759",
"0.6522267",
"0.6510602",
"0.6475136",
"0.6429616",
"0.64248943",
"0.6417863",
"0.63421935",
"0.62995476",
"0.62362045",
"0.620672",
"0.6189223",
"0.6152925",
"0.6125904",
"0.61234576",
"0.6115374",
"0.6100337",
"0.60869914",
"0.6070025... | 0.69770414 | 0 |
End point: (GET) Usage: FundAmerica::Entity.details(entity_id), request options &_expand[]=1 Output: Returns the details of an entity with matching id | def details(entity_id, request_options = "")
API::request(:get, "entities/#{entity_id}" + request_options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def details(entity)\n details_by_type_and_name(entity.properties[:type], entity.properties[:name])\n end",
"def _get_entity_detail(detail_name)\n @entity.get_detail(detail_name)\n end",
"def show\n @entity = Entity.find(params[:id])\n \n respond_to do |format|\n format.html # show.htm... | [
"0.72119665",
"0.6698045",
"0.66664255",
"0.6545143",
"0.63418263",
"0.6329604",
"0.63291484",
"0.6324539",
"0.623237",
"0.6170544",
"0.6044367",
"0.6018698",
"0.6010537",
"0.5982401",
"0.5978084",
"0.5972607",
"0.5950019",
"0.59452444",
"0.59263295",
"0.58793914",
"0.5872412... | 0.8206718 | 0 |
End point: (GET) Usage: FundAmerica::Entity.ach_authorizations(entity_id) Output: Returns ACH authorizations of an entity | def ach_authorizations(entity_id)
API::request(:get, "entities/#{entity_id}/ach_authorizations")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(*args)\n require_authentication\n arguments(args, required: [:authorization_id])\n\n get_request(\"/authorizations/#{authorization_id}\", arguments.params)\n end",
"def get(*args)\n raise_authentication_error unless authenticated?\n arguments(args, required: [:id])\n\n... | [
"0.62420696",
"0.61521333",
"0.6116939",
"0.60832816",
"0.6021224",
"0.58773667",
"0.58773667",
"0.58372104",
"0.58047384",
"0.5767842",
"0.5491542",
"0.5472516",
"0.54503995",
"0.5433435",
"0.54077476",
"0.54077476",
"0.5384407",
"0.5365944",
"0.5354341",
"0.53037167",
"0.53... | 0.8727051 | 0 |
End point: (GET) Usage: FundAmerica::Entity.cash_blotter(entity_id) | def cash_blotter(entity_id)
API::request(:get, "entities/#{entity_id}/cash_blotter")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bank_transfer_method(entity_id)\n API::request(:get, \"entities/#{entity_id}/bank_transfer_methods\")\n end",
"def get_marketplace_bank_account\n Balanced::BankAccount.find(\"/v1/bank_accounts/BAj6sNNBdMp5WmY6PJ7sAu3\")\n end",
"def balance\n rest.get(:getbalance)['data']\n end",
... | [
"0.59842044",
"0.5824421",
"0.5668388",
"0.56333244",
"0.55924106",
"0.5484383",
"0.5412799",
"0.54103756",
"0.53989995",
"0.53522265",
"0.53488004",
"0.5310438",
"0.52722174",
"0.5244552",
"0.5244552",
"0.5240701",
"0.5240025",
"0.52253515",
"0.5205345",
"0.5200413",
"0.5194... | 0.8980167 | 0 |
End point: (GET) Usage: FundAmerica::Entity.investor_suitability_details(entity_id) | def investor_suitability_details(entity_id)
API::request(:get, "entities/#{entity_id}/investor_suitability")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def investor_suitability_update(entity_id, options)\n API::request(:patch, \"entities/#{entity_id}/investor_suitability\", options)\n end",
"def platform_investor(entity_id )\n API::request(:get, \"entities/#{entity_id}/platform_investor\")\n end",
"def investor_accreditation(entity_id)... | [
"0.6998489",
"0.6399165",
"0.6215873",
"0.6044461",
"0.585896",
"0.5697527",
"0.5684516",
"0.56791675",
"0.5670156",
"0.5600503",
"0.5551321",
"0.5544604",
"0.54723734",
"0.5462545",
"0.5383733",
"0.5380635",
"0.5367114",
"0.5365481",
"0.53644514",
"0.5361769",
"0.53519493",
... | 0.91116935 | 0 |
End point: (PATCH) Usage: FundAmerica::Entity.investor_suitability_update(entity_id, options) | def investor_suitability_update(entity_id, options)
API::request(:patch, "entities/#{entity_id}/investor_suitability", options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @investable.update(investable_params)\n format.html { redirect_to @investable, notice: 'Investable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render ... | [
"0.61958325",
"0.6139761",
"0.6139761",
"0.61195874",
"0.6080244",
"0.6074975",
"0.60582757",
"0.6056857",
"0.60435456",
"0.6018325",
"0.5944545",
"0.5940642",
"0.59330267",
"0.5920518",
"0.5919287",
"0.5899449",
"0.58973444",
"0.58935493",
"0.58935493",
"0.5892438",
"0.58921... | 0.91313285 | 0 |
End point: (GET) Usage: FundAmerica::Entity.investor_payments(entity_id) | def investor_payments(entity_id)
API::request(:get, "entities/#{entity_id}/investor_payments")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def investor_payments(distribution_id, options = {})\n \tAPI::request(:get, \"distributions/#{distribution_id}/investor_payments\", options)\n end",
"def details(investor_payment_id)\n API::request(:get, \"investor_payments/#{investor_payment_id}\")\n end",
"def platform_investor(entity_i... | [
"0.7399831",
"0.71451336",
"0.6653049",
"0.6325131",
"0.61442256",
"0.6138229",
"0.61257666",
"0.608291",
"0.6082504",
"0.6043077",
"0.5973801",
"0.5928625",
"0.5903708",
"0.58889884",
"0.58496696",
"0.58375543",
"0.58262527",
"0.5823262",
"0.5806376",
"0.57893664",
"0.578936... | 0.9108992 | 0 |
(GET) Usage: FundAmerica::Entity.bank_transfer_methods Output: Returns Bank Transfer Method informations of an entity | def bank_transfer_method(entity_id)
API::request(:get, "entities/#{entity_id}/bank_transfer_methods")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list_payments_methods\n PaymentMethod.get_list_payment_methods\n end",
"def payment_methods\n request = payment_methods_request\n response = PaybywayConnector.payment_methods(request).parsed_response\n response['payment_methods'].map { |method|\n PaymentGateway::PaymentMethod.ne... | [
"0.5956884",
"0.5890792",
"0.56654423",
"0.56563747",
"0.5655339",
"0.5598423",
"0.54417044",
"0.5439406",
"0.54236805",
"0.5367508",
"0.53532326",
"0.53519887",
"0.53212625",
"0.5315025",
"0.5314124",
"0.52899677",
"0.52863175",
"0.5276744",
"0.52473",
"0.5228038",
"0.522061... | 0.7770543 | 0 |
(GET) Usage: FundAmerica::Entity.child_entities Output: Returns child entities of an entity | def child_entities(entity_id)
API::request(:get, "entities/#{entity_id}/child_entities")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n \n TapirLogger.instance.log \"Finding children for #{self}\"\n children = []\n EntityMapping.all.each do |mapping| \n\n # Go through each associated entity mapping, and find mappings where the parent_id is us\n # which means that the child_id is some other entity, a... | [
"0.765579",
"0.7173872",
"0.6570733",
"0.6468988",
"0.6445736",
"0.64158887",
"0.6405631",
"0.63433325",
"0.63402075",
"0.63110346",
"0.62899095",
"0.6242696",
"0.6242367",
"0.62389827",
"0.6235504",
"0.6229664",
"0.62037414",
"0.61976635",
"0.6181472",
"0.6181472",
"0.617183... | 0.83970994 | 0 |
(GET) Usage: FundAmerica::Entity.parent_entities Output: Returns parent entities of an entity | def parent_entities(entity_id)
API::request(:get, "entities/#{entity_id}/parent_entities")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parents\n\n TapirLogger.instance.log \"Finding parents for #{self}\"\n parents = []\n self.entity_mappings.each do |mapping|\n\n # Go through each associated entity mapping, and find mappings where the child_id is us \n # which means that the parent_id is some other entity, and it'... | [
"0.75979745",
"0.69744354",
"0.67214084",
"0.67011464",
"0.66702175",
"0.6664577",
"0.66317075",
"0.6625622",
"0.6621742",
"0.6619721",
"0.66195494",
"0.65879583",
"0.6553942",
"0.65360856",
"0.6527843",
"0.65220916",
"0.65112406",
"0.65030134",
"0.6486122",
"0.6484184",
"0.6... | 0.8341452 | 0 |
(GET) Usage: FundAmerica::Entity.relationships_as_child Output: Returns relationships_as_child details for entity | def relationships_as_child(entity_id)
API::request(:get, "entities/#{entity_id}/relationships_as_child")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def child_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:children).uniq\n Relationship.filter_by_resource_type(rels, options)\n end",
"def child_ontology_relationships(options = {}) # :yields: Array of OntologyRelationships\n opt = {\n :relationship_type => 'all... | [
"0.68723017",
"0.67878765",
"0.67123616",
"0.66907215",
"0.6463459",
"0.64422923",
"0.6315922",
"0.6296345",
"0.6279918",
"0.62655675",
"0.62571764",
"0.6204106",
"0.61376524",
"0.6126914",
"0.6126365",
"0.6091054",
"0.6062718",
"0.6042653",
"0.6013718",
"0.60027623",
"0.6001... | 0.82127106 | 0 |
(GET) Usage: FundAmerica::Entity.relationships_as_parent Output: Returns relationships_as_parent details for entity | def relationships_as_parent(entity_id)
API::request(:get, "entities/#{entity_id}/relationships_as_parent")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships_as_child(entity_id)\n API::request(:get, \"entities/#{entity_id}/relationships_as_child\")\n end",
"def relation_to_parent\n _response_word.fetch(\"relationToParent\", nil)\n end",
"def parent_association\n @parent_object=parent_object # ResourceController normally sets... | [
"0.6867059",
"0.68645024",
"0.68537843",
"0.68079203",
"0.66850704",
"0.66231835",
"0.653668",
"0.63679206",
"0.63075554",
"0.6287161",
"0.6252998",
"0.62123406",
"0.62040347",
"0.61899227",
"0.6185197",
"0.6164521",
"0.61608934",
"0.60555655",
"0.60405403",
"0.60341173",
"0.... | 0.8172773 | 0 |
(GET) Usage: FundAmerica::Entity.investor_accreditation Output: Returns entity specific investor accreditation information | def investor_accreditation(entity_id)
API::request(:get, "entities/#{entity_id}/investor_accreditation")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @accreditations = Accreditation.all\n end",
"def course_accreditations(institution, course, kismode, options={})\n self.class.get(\"/Institution/#{institution}/Course/#{course}/#{kismode}/Accreditation.json\", options).parsed_response\n end",
"def set_accreditation\n @accreditation = A... | [
"0.6375594",
"0.631185",
"0.6070619",
"0.6020426",
"0.58813727",
"0.5757024",
"0.5688349",
"0.5610942",
"0.55743665",
"0.55384356",
"0.5400432",
"0.5380218",
"0.53247374",
"0.5320955",
"0.5313606",
"0.52836007",
"0.5274664",
"0.5230283",
"0.5230283",
"0.5218429",
"0.5217475",... | 0.8595916 | 0 |
(GET) Usage: FundAmerica::Entity.platform_investor Output: Returns entity specific platform_investor information Note: FA platform investor information will also be included with investor information | def platform_investor(entity_id )
API::request(:get, "entities/#{entity_id}/platform_investor")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def platform_details\n data[:platform_details]\n end",
"def platform\n data.platform\n end",
"def platform\n data[:platform]\n end",
"def platform\n @platform ||= data.platform\n end",
"def details(investor_payment_id)\n API::request(:get, \"investor_payments/#{investor_payme... | [
"0.57086205",
"0.5593016",
"0.5556217",
"0.5524725",
"0.55160904",
"0.5444372",
"0.5386671",
"0.53793293",
"0.5313509",
"0.5310424",
"0.52907485",
"0.5262005",
"0.5236569",
"0.5176087",
"0.5169001",
"0.5163113",
"0.51555544",
"0.5147681",
"0.5143245",
"0.5126595",
"0.5118084"... | 0.82584137 | 0 |
GET /items GET /items.json | def index
@items = Item.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @items =... | [
"0.79562956",
"0.7546286",
"0.74375594",
"0.7434485",
"0.73975587",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7357372",
"0.7313286",
"0.73129123",
"0.7311041",
"0.7306297",
"0.7281173",
"0.7273615",
"0.72629416",
"0.72484964",
"0.72301924",
"0.71767205",
"0.71181... | 0.66965467 | 88 |
GET /items/1 GET /items/1.json | def show
@item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n item = I... | [
"0.7736526",
"0.7547988",
"0.74948645",
"0.73696035",
"0.7328169",
"0.7293223",
"0.7287578",
"0.71326286",
"0.71247333",
"0.71196556",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_item
@item = Item.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 item_params
params.permit(:name, :image, :price)
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.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
Copyright (c) 2013 University of Manchester and the University of Southampton. See license.txt for details. | def user_count(opts)
users = User.find(:all).select do |user| user.activated? end
root = LibXML::XML::Node.new('user-count')
root << users.length.to_s
doc = LibXML::XML::Document.new
doc.root = root
{ :xml => doc }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def jack_handey; end",
"def berlioz; end",
"def terpene; end",
"def probers; end",
"def dh; end",
"def herald; end",
"def implementation; end",
"def implementation; end",
"def romeo_and_juliet; end",
"def weber; end",
"def verdi; end",
"def rossini... | [
"0.69005716",
"0.6438806",
"0.60554034",
"0.60428625",
"0.60218155",
"0.59697175",
"0.59491414",
"0.59254086",
"0.591527",
"0.591527",
"0.5869077",
"0.58599955",
"0.58562696",
"0.58432084",
"0.5840115",
"0.5836691",
"0.58361673",
"0.5811101",
"0.58104956",
"0.58104956",
"0.58... | 0.0 | -1 |
POST /characters or /characters.json | def create
@character = Character.new(character_params)
if @character.save
render json: {
status: :created,
character: @character
}
else
render json: {
status: 500,
errors: @character.errors.full_messages
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n respond_to do |format|\n if @character = Character.create_with_char_data(character_params, current_user, game)\n format.json { render json: {redirect: character_path(@character).to_s} }\n else\n format.json { render json: @character.errors, status: :unprocessable_entity }\n ... | [
"0.7032093",
"0.69848734",
"0.6749904",
"0.67271125",
"0.6703533",
"0.6703533",
"0.6702623",
"0.6659725",
"0.6653624",
"0.6573103",
"0.6530796",
"0.6356317",
"0.63393587",
"0.6327022",
"0.6302442",
"0.62911755",
"0.62860197",
"0.62803817",
"0.6278441",
"0.6258732",
"0.6247548... | 0.65818584 | 9 |
PATCH/PUT /characters/1 or /characters/1.json | def update
# @character.update character_params
if @character.update character_params
render json: {
status: :updated,
character: @character
}
else
render json: {
status: 500,
errors: @character.errors.full_messages
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @character.update(character_params)\n render json: @character, status: 201, location: @character\n else\n render json: @character.errors, status: :unprocessable_entity\n end\n end",
"def update\n @character = Character.find_or_initialize_by_id(params[:id])\n @character.i... | [
"0.73686284",
"0.7264158",
"0.72210175",
"0.7219515",
"0.71518743",
"0.71482867",
"0.70970494",
"0.7087913",
"0.7087913",
"0.7087913",
"0.7087913",
"0.7087913",
"0.7059671",
"0.70459145",
"0.689109",
"0.6842334",
"0.67528176",
"0.6752583",
"0.6735688",
"0.6606013",
"0.6571712... | 0.6968864 | 14 |
DELETE /characters/1 or /characters/1.json | def destroy
if @character.destroy
render json: {
status: :deleted,
character: @character
}
else
render json: {
status: 500,
errors: @character.errors.full_messages
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @character.destroy\n respond_to do |format|\n format.html { redirect_to characters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @character = current_user.characters.find(params[:id])\n @character.destroy\n\n respond_to do |format|\n format.... | [
"0.76540786",
"0.760725",
"0.754414",
"0.7495764",
"0.7400891",
"0.737048",
"0.7356787",
"0.73550606",
"0.73502165",
"0.73347586",
"0.7326574",
"0.73041016",
"0.73041016",
"0.73041016",
"0.73041016",
"0.73041016",
"0.73041016",
"0.73041016",
"0.73041016",
"0.72824466",
"0.726... | 0.71448565 | 24 |
Logs an incoming GET WEBrick request. | def do_GET(request, _response)
log_request(request)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_request\n logger.info \"HTTP request received => #{request.fullpath} , params => #{params} \"\n end",
"def request_log(request); end",
"def global_request_logging \n http_request_header_keys = request.headers.keys.select{|header_name| header_name.match(\"^HTTP.*\")}\n http_request_headers = r... | [
"0.7249485",
"0.66672456",
"0.6576395",
"0.6541875",
"0.650456",
"0.6396007",
"0.63442284",
"0.6265159",
"0.6238006",
"0.6198399",
"0.61395216",
"0.6074319",
"0.6055724",
"0.6044398",
"0.60287374",
"0.6004636",
"0.59969664",
"0.58921576",
"0.58873487",
"0.5884792",
"0.5882792... | 0.76082915 | 0 |
Logs and parses an incoming POST request. Parses `multipart/formdata` and `application/json` contenttypes. Parsed requests are added to the requests list. | def do_POST(request, response)
@aspecto_repeater.repeat request
@bugsnag_repeater.repeat request
# Turn the WEBrick HttpRequest into our internal HttpRequest delegate
request = Maze::HttpRequest.new(request)
content_type = request['Content-Type']
if %r{^multipart/form-data; boundary=([^;]+)}.match(content_type)
boundary = WEBrick::HTTPUtils::dequote($1)
body = WEBrick::HTTPUtils.parse_form_data(request.body, boundary)
hash = {
body: body,
request: request,
response: response
}
else
# "content-type" is assumed to be JSON (which mimics the behaviour of
# the actual API). This supports browsers that can't set this header for
# cross-domain requests (IE8/9)
digests = check_digest request
hash = {
body: JSON.parse(request.body),
request: request,
response: response,
digests: digests
}
end
if @schema
schema_errors = @schema.validate(hash[:body])
hash[:schema_errors] = schema_errors.to_a
end
add_request(hash)
# For the response, delaying if configured to do so
response_delay_ms = Server.response_delay_ms
if response_delay_ms.positive?
$logger.info "Waiting #{response_delay_ms} milliseconds before responding"
sleep response_delay_ms / 1000.0
end
set_response_header response.header
response.status = post_status_code
rescue JSON::ParserError => e
msg = "Unable to parse request as JSON: #{e.message}"
if Maze.config.captured_invalid_requests.include? @request_type
$logger.error msg
Server.invalid_requests.add({
reason: msg,
request: request,
body: request.body
})
else
$logger.warn msg
end
rescue StandardError => e
if Maze.config.captured_invalid_requests.include? @request_type
$logger.error "Invalid request: #{e.message}"
Server.invalid_requests.add({
invalid: true,
reason: e.message,
request: {
request_uri: request.request_uri,
header: request.header,
body: request.inspect
}
})
else
$logger.warn "Invalid request: #{e.message}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_request\n p request.body.string\n case request.content_type\n when JSON_TYPE then parse_json_request\n else parse_http_request\n end\n end",
"def do_POST(request, response)\n\n content_type = request['Content-Type']\n\n # For JSON, pull the instructions from the body. Oth... | [
"0.6545395",
"0.5963483",
"0.55991495",
"0.5574359",
"0.55533445",
"0.5462949",
"0.5462149",
"0.54360974",
"0.5372931",
"0.53600377",
"0.5332685",
"0.53058684",
"0.5238747",
"0.5226314",
"0.52043146",
"0.51962805",
"0.51959217",
"0.5192757",
"0.5180439",
"0.51752496",
"0.5164... | 0.6051569 | 1 |
Logs and returns a set of valid headers for this servlet. | def do_OPTIONS(request, response)
super
response.header['Access-Control-Allow-Methods'] = 'POST, OPTIONS'
response.status = Server.status_code('OPTIONS')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def headers\n request.headers\n end",
"def headers\n @headers ||= rack_environment.select{|k,v| k.start_with? 'HTTP_'}\n end",
"def headers\n @request_headers\n end",
"def headers\n @headers ||={}\n end",
"def request_headers\n @request_headers.map do |header, value... | [
"0.72490066",
"0.70971054",
"0.7063392",
"0.7019687",
"0.701265",
"0.6970555",
"0.69419813",
"0.6934873",
"0.6882566",
"0.6859779",
"0.68371296",
"0.67774206",
"0.67688537",
"0.67610246",
"0.67550164",
"0.6750252",
"0.6750252",
"0.6701811",
"0.6669271",
"0.6661552",
"0.665955... | 0.0 | -1 |
Checks the BugsnagIntegrity header, if present, against the request and based on configuration. If the header is present, if the digest must be correct. However, the header need only be present if configuration says so. | def check_digest(request)
header = request['Bugsnag-Integrity']
if header.nil? && Maze.config.enforce_bugsnag_integrity && %i[sessions errors traces].include?(@request_type)
raise "Bugsnag-Integrity header must be present for #{@request_type} according to Maze.config.enforce_bugsnag_integrity"
end
return if header.nil?
# Header must have type and digest
parts = header.split ' '
raise "Invalid Bugsnag-Integrity header: #{header}" unless parts.size == 2
# Both digest types are stored whatever
sha1 = Digest::SHA1.hexdigest(request.body)
simple = request.body.bytesize
$logger.trace "DIGESTS computed: sha1=#{sha1} simple=#{simple}"
# Check digests match
case parts[0]
when 'sha1'
raise "Given sha1 #{parts[1]} does not match the computed #{sha1}" unless parts[1] == sha1
when 'simple'
raise "Given simple digest #{parts[1].inspect} does not match the computed #{simple.inspect}" unless parts[1].to_i == simple
else
raise "Invalid Bugsnag-Integrity digest type: #{parts[0]}"
end
{
sha1: sha1,
simple: simple
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_bugsnag_integrity_header(request)\n header = request[:request]['Bugsnag-Integrity']\n return !Maze.config.enforce_bugsnag_integrity if header.nil?\n\n digests = request[:digests]\n if header.start_with?('sha1')\n computed_digest = \"sha1 #{digests[:sha1]}\"\n e... | [
"0.84788775",
"0.6341355",
"0.5908636",
"0.5726542",
"0.56392556",
"0.5546962",
"0.5540966",
"0.54677624",
"0.54632944",
"0.54522043",
"0.5434323",
"0.5423803",
"0.5255678",
"0.5238328",
"0.52139276",
"0.5202434",
"0.5173209",
"0.5131942",
"0.51319253",
"0.51316965",
"0.51316... | 0.7928696 | 1 |
Instantiate a new OAuth 2.0 client using the client ID and client secret registered to your application. Options: :site :: Specify a base URL for your OAuth 2.0 client. :authorize_path :: Specify the path to the authorization endpoint. :authorize_url :: Specify a full URL of the authorization endpoint. :access_token_path :: Specify the path to the access token endpoint. :access_token_method :: Specify the method to use for token endpoints, can be :get or :post (note: for Facebook this should be :get and for Google this should be :post) :access_token_url :: Specify the full URL of the access token endpoint. :parse_json :: If true, application/json responses will be automatically parsed. :ssl :: Specify SSL options for the connection. :adapter :: The name of the Faraday::Adapter:: class to use, e.g. :net_http. To pass arguments to the adapter pass an array here, e.g. [:action_dispatch, my_test_session] :raise_errors :: Default true. When false it will then return the error status and response instead of raising an exception. | def initialize(client_id, client_secret, opts={})
self.options = opts.dup
self.token_method = self.options.delete(:access_token_method) || :post
adapter = self.options.delete(:adapter)
ssl_opts = self.options.delete(:ssl) || {}
connection_opts = ssl_opts ? {:ssl => ssl_opts} : {}
self.id = client_id
self.secret = client_secret
self.site = self.options.delete(:site) if self.options[:site]
self.connection = Faraday::Connection.new(site, connection_opts)
self.json = self.options.delete(:parse_json)
self.raise_errors = !(self.options.delete(:raise_errors) == false)
if adapter && adapter != :test
connection.build do |b|
b.adapter(*[adapter].flatten)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client\n # Merge in authorize url if supplied\n options.authorize_params[:clientId] = options.client_id\n options.authorize_params[:redirect] = callback_url\n options.client_options[:authorize_url] = options.authorize_url if options.authorize_url.present?\n options.client_opt... | [
"0.8370947",
"0.8020362",
"0.7842813",
"0.7813421",
"0.73801476",
"0.73321974",
"0.7285559",
"0.72095394",
"0.7179878",
"0.7059197",
"0.7019579",
"0.7009983",
"0.70041424",
"0.6980361",
"0.69428194",
"0.6905466",
"0.6892612",
"0.6875788",
"0.6860583",
"0.6819266",
"0.6746509"... | 0.7034905 | 10 |
Makes a request relative to the specified site root. | def request(verb, url, params={}, headers={})
if (verb == :get) || (verb == :delete)
resp = connection.run_request(verb, url, nil, headers) do |req|
req.params.update(params)
end
else
resp = connection.run_request(verb, url, params, headers)
end
if raise_errors
case resp.status
when 200...299
return response_for(resp)
when 302
return request(verb, resp.headers['location'], params, headers)
when 401
e = OAuth2::AccessDenied.new("Received HTTP 401 during request.")
e.response = resp
raise e
when 409
e = OAuth2::Conflict.new("Received HTTP 409 during request.")
e.response = resp
raise e
else
e = OAuth2::HTTPError.new("Received HTTP #{resp.status} during request.")
e.response = resp
raise e
end
else
response_for resp
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_url_root=(_arg0); end",
"def relative_url_root=(_arg0); end",
"def relative_url_root; end",
"def relative_url_root; end",
"def relative_url_root; end",
"def hack_relative_url_root\n begin\n update_relative_url_root!\n yield\n ensure\n ActionController::Base.relative_url_... | [
"0.6318264",
"0.6318264",
"0.6166546",
"0.6166546",
"0.6166546",
"0.61545336",
"0.6134428",
"0.603789",
"0.59271103",
"0.59029037",
"0.58683074",
"0.5865835",
"0.58563954",
"0.57968074",
"0.57932216",
"0.578357",
"0.5699139",
"0.5698113",
"0.5697869",
"0.5689201",
"0.5684515"... | 0.0 | -1 |
add planet to array | def planet_add(planet)
@planets.push(planet)
return @planets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_planet(planet)\n @planet << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet_to_add)\n @planets << planet_to_add\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add... | [
"0.7932559",
"0.78777885",
"0.7816552",
"0.7790386",
"0.7790386",
"0.7790386",
"0.7790386",
"0.7790386",
"0.7786768",
"0.77813804",
"0.77813804",
"0.77813804",
"0.77813804",
"0.7590277",
"0.7590277",
"0.7590277",
"0.7590277",
"0.75370526",
"0.74905616",
"0.7486492",
"0.742266... | 0.80549 | 1 |
=begin ================================================================================ Ruby 1.8 Methods Author: N/A Version: 1.2 [ Description ] Contains methods for existing classes that may have not made its transition over to Ruby 1.9 (RGSS3). This list is ongoing as people report them. [ Instructions ] There is nothing to do here. Please keep this script in its current location. [ Version History] Ver. Date Notes 1.2 17 Apr 2018 Added: + XP's Input module (constants return ints, not symbols) 1.1 26 Mar 2017 Added: + Arrayto_s + Stringdelete/delete! + String[] 1.0 28 Feb 2016 First implemented ================================================================================ =end Object p | def p(*args)
Kernel.p(args)
msgbox_p(*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect(input); end",
"def String(p0) end",
"def pstring(input)\n p = PascalString.new\n p.input = input\n p.parse\n p.value\nend",
"def resolveU(input)\r\n #first up some integer parsing\r\n if(input.length < 3)\r\n puts 'Cannot resolve command. Returning to menu.'\r\n else\r\n te... | [
"0.55995196",
"0.55424875",
"0.5381544",
"0.5305539",
"0.5301502",
"0.5289951",
"0.5258814",
"0.5258814",
"0.5258814",
"0.52157754",
"0.5120218",
"0.5120218",
"0.5093947",
"0.5093626",
"0.5093626",
"0.5027182",
"0.4956686",
"0.4953168",
"0.49506795",
"0.49506795",
"0.49506795... | 0.0 | -1 |
In Ruby 1.9, the returned string would include the square brackets []. Ruby 1.8 does not. | def to_s
self.join('')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mutate_empty_bracket(_)\n '[]'\n end",
"def to_string_no_brackets\n self.to_s.gsub(/[\\[\\]]/,'')\n end",
"def to_string_no_brackets_or_quotes\n self.to_s.gsub(/[\\\"\\[\\]]/,'')\n end",
"def s(string)\n string.to_s.gsub('[].:', '')\nend",
"def sub_brackets(nline)\n ... | [
"0.71191454",
"0.70444703",
"0.6589663",
"0.6450777",
"0.5868274",
"0.58544254",
"0.56687564",
"0.5657786",
"0.56164676",
"0.5583472",
"0.55287397",
"0.5476206",
"0.54682785",
"0.5452847",
"0.5448699",
"0.5432115",
"0.54155993",
"0.54155993",
"0.54155993",
"0.54155993",
"0.54... | 0.49990317 | 80 |
return the sum of all of the multiples found input: an integer > 1 output: sum of all multiples of 3 and 5 between and and the given number Includes the given number in the list of multiples summed if it is a multiple of 3 or 5 store multiples in array iterate through range, if current number is multiple of 3 || 5 << multiple_array reduce sum multiple_array | def multisum(range_end)
multiples = []
for i in 1..range_end
multiples << i if i % 3 == 0 || i % 5 == 0
end
multiples.reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.sum\nend",
"def find_multiples(number)\n sum_of_multiples = (3...number).each_with_object([]) do ... | [
"0.803105",
"0.7904115",
"0.7838052",
"0.7818846",
"0.7752806",
"0.7744883",
"0.76772016",
"0.76477814",
"0.7621858",
"0.76169044",
"0.7610242",
"0.7596771",
"0.7596756",
"0.7566219",
"0.7563507",
"0.7506362",
"0.7498923",
"0.7490373",
"0.7445057",
"0.74284554",
"0.74141574",... | 0.7262475 | 41 |
Set the URL of the associated work on the web site of the original repository if not already present. | def normalize_title_url!(data = nil, field: :emma_webPageLink)
url = get_field_values(data, *field).first
return unless url.blank?
set_field_value!(data, field, generate_title_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_git_urls\n self.url = GitHosting.repository_path(self) if self.url.blank?\n self.root_url = self.url if self.root_url.blank?\n end",
"def set_git_urls\n self.url = GitHosting.repository_path(self) if url.blank?\n self.root_url = url if root_url.blank?\n end",
... | [
"0.6942858",
"0.6841633",
"0.6583025",
"0.6547299",
"0.6513899",
"0.6361469",
"0.63150156",
"0.63075256",
"0.6256537",
"0.6189582",
"0.61830795",
"0.6156341",
"0.61458796",
"0.61110634",
"0.6105617",
"0.60160905",
"0.5992066",
"0.59823495",
"0.59641",
"0.5933893",
"0.58997023... | 0.0 | -1 |
Set the original repository content download URL if not already present. | def normalize_download_url!(data = nil, field: :emma_retrievalLink)
url = get_field_values(data, *field).first
return unless url.blank? || url.start_with?(BOOKSHARE_API_URL)
set_field_value!(data, field, generate_download_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_uri=(value)\n @download_uri = value\n 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... | [
"0.67339295",
"0.6572786",
"0.6572786",
"0.6403448",
"0.63788337",
"0.63288647",
"0.62757987",
"0.62326235",
"0.6197232",
"0.61001754",
"0.59821767",
"0.59808016",
"0.5957649",
"0.5956879",
"0.59562373",
"0.59362316",
"0.5912086",
"0.58589727",
"0.58091724",
"0.5803031",
"0.5... | 0.565957 | 32 |
pp get_mystates_from_highstate('module','chocolatey','bootstrap') pp get_mystates_from_highstate('module','user','current') pp get_mystates_from_highstate('state','system','hostname') | def get_highstate_from_minion
if defined?(@cache_highstate_from_minion)
Inspec::Log.debug('Returning cached @cache_highstate_from_minion.')
return @cache_highstate_from_minion
end
# ingest_from_minion('yaml', 'C:\salt\salt-call.bat --config-dir=C:\Users\vagrant\AppData\Local\Temp\kitchen\etc\salt state.show_highstate --out yaml |Select-String -Pattern "__sls__", "__env__", "- run", "- order:" -NotMatch')
highstate_from_minion = ingest_from_minion('json', 'C:\salt\salt-call.bat --config-dir=C:\Users\vagrant\AppData\Local\Temp\kitchen\etc\salt state.show_highstate --out json')
if highstate_from_minion != []
Inspec::Log.debug('Saving highstate to cache @cache_highstate_from_minion.')
@cache_highstate_from_minion = highstate_from_minion['local']
@cache_highstate_from_minion
else
Inspec::Log.error('Failed to get highstate.')
abort 'Failed to get highstate.'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def states; @_hegemon_states.keys; end",
"def print_state(machine)\n puts \"[#{machine[:stack]}, #{machine[:register]}]\"\nend",
"def known_states; end",
"def known_states; end",
"def known_states; end",
"def get_state\n@state.keys\nend",
"def get_state\n get_yarn_application_apptem... | [
"0.61121684",
"0.6091551",
"0.5943058",
"0.5943058",
"0.5943058",
"0.5818758",
"0.56549346",
"0.56186575",
"0.55920625",
"0.55516225",
"0.5538549",
"0.5525389",
"0.5467259",
"0.5465247",
"0.54560184",
"0.5447231",
"0.5428945",
"0.54145753",
"0.53945524",
"0.5363011",
"0.53596... | 0.71150595 | 0 |
example: get_saltstack_package_full_name('7zip') = '7Zip' | def get_saltstack_package_full_name(package)
# pillar = YAML.safe_load(File.read('test/salt/pillar/windows.sls'))
url = 'https://raw.githubusercontent.com/saltstack/salt-winrepo-ng/master/'
files = [package + '.sls', package + '/init.sls']
# example: package = "7zip"=>{"version"=>"18.06.00.0", "refresh_minion_env_path"=>false}
saltstack_package_full_name = files.find do |checkme|
ps = "$f = (((Get-ChildItem -Path $env:LOCALAPPDATA -Filter 'salt-winrepo-ng' -Recurse -Directory).Fullname[0]) + '\\#{checkme.sub('/', '\\')}'); if (Test-Path $f -PathType Leaf) {Get-Content -Path $f}"
begin
file = (open(url + checkme) & :read)
rescue
begin
file = (powershell(ps).stdout)
rescue
next
end
end
unless file.nil? || file.empty?
candidate = file.match(/full_name: '([\S]+).*'/).captures[0]
end
break candidate unless candidate.nil?
end
Inspec::Log.debug('[get_saltstack_package_full_name] found candidate: ' + saltstack_package_full_name)
saltstack_package_full_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_name\n name = package_drop_last(slug_parts)\n name.empty? ? '_root_' : name\n end",
"def package_name\n # TODO: verify renamed packages\n resource['title']\n end",
"def full_name\n \"#{@package}.#{parameterized_name}\"\n end",
"def package_name\n @ve... | [
"0.758345",
"0.7460569",
"0.72973734",
"0.7297259",
"0.727296",
"0.7171976",
"0.68556035",
"0.682097",
"0.6756436",
"0.67478067",
"0.6664091",
"0.6590872",
"0.6589945",
"0.6572884",
"0.6560001",
"0.6554045",
"0.6530854",
"0.65306455",
"0.643837",
"0.6425542",
"0.6397732",
"... | 0.8239686 | 0 |
Override in your tests if needed | def modulepath
[RSpec.configuration.module_path]
rescue NoMethodError
raise "RSpec.configuration.module_path not defined set up rspec puppet or define modulepath for this test"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spec; end",
"def spec; end",
"def testing\n # ...\n end",
"def should; super end",
"def self_test; end",
"def self_test; end",
"def private; end",
"def __dummy_test__\n end",
"def before_setup; end",
"def default_test\r\n end",
"def before_test(test); end",
"def before_t... | [
"0.70830095",
"0.70830095",
"0.6994145",
"0.693958",
"0.69186485",
"0.69186485",
"0.69038844",
"0.6884993",
"0.6625571",
"0.65979177",
"0.65878195",
"0.65878195",
"0.6540236",
"0.6529807",
"0.6529807",
"0.6529807",
"0.6529807",
"0.6515239",
"0.6511668",
"0.65021324",
"0.65021... | 0.0 | -1 |
Overrides inventory for tests. | def inventory_data
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inventory=(value)\n @inventory = value\n end",
"def expected_inventory\n result = @inventory.dup\n # TODO DRY this up with `Person#eat`\n result[:fish] -= @daily_appetite = 10\n result\n end",
"def available_inventory\n return self.inventory\n end",
"def initial... | [
"0.6951753",
"0.6739306",
"0.6636184",
"0.65454704",
"0.65146106",
"0.6502555",
"0.6481087",
"0.64170563",
"0.6403549",
"0.63148105",
"0.6306859",
"0.630202",
"0.62828773",
"0.62807155",
"0.6265003",
"0.62622",
"0.61740416",
"0.616278",
"0.6145893",
"0.6144996",
"0.6112049",
... | 0.66573733 | 3 |
Overrides configuration for tests. | def config_data
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_config\n # To be Extended\n end",
"def test_with_overrides\n config = load_config('test_configs/good-config.conf', ['ubuntu', :production, 'itscript'])\n\n assert_equal(26214400, config.common.basic_size_limit)\n assert_equal(52428800, config.common.student_size_limit)\n assert_equa... | [
"0.7411844",
"0.725997",
"0.6969892",
"0.6915207",
"0.68550247",
"0.677388",
"0.674662",
"0.67151976",
"0.6668239",
"0.66563845",
"0.6639244",
"0.6562396",
"0.65493923",
"0.6542717",
"0.6536379",
"0.6525121",
"0.6513968",
"0.6509291",
"0.6505835",
"0.6465914",
"0.6448059",
... | 0.0 | -1 |
Override in your tests | def config
@config ||= begin
conf = Bolt::Config.new(Bolt::Project.default_project, config_data)
conf.modulepath = [modulepath].flatten
conf
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def spec; end",
"def spec; end",
"def self_test; end",
"def self_test; end",
"def should; super end",
"def __dummy_test__\n end",
"def before_setup; end",
"def private; end",
"def before_test(test); end",
"def before_test(test); end",
"def default_t... | [
"0.7342287",
"0.7246639",
"0.7246639",
"0.70462036",
"0.70462036",
"0.702796",
"0.70184964",
"0.68830997",
"0.6862838",
"0.6850526",
"0.6850526",
"0.68221325",
"0.6805791",
"0.67525995",
"0.67525995",
"0.67525995",
"0.67525995",
"0.67525995",
"0.67525995",
"0.67525995",
"0.67... | 0.0 | -1 |
Does this belong here? | def allow_out_message
executor.stub_out_message.add_stub
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def used?; end",
"def placebo?; false end",
"def internal?; end",
"def refutal()\n end",
"def internal; end",
"def called_from; end",
"def called_from; end",
"def implementation; end",
"def implementation; end",
"def who_we_are... | [
"0.7674449",
"0.6736215",
"0.6619357",
"0.65748215",
"0.64430016",
"0.64017403",
"0.63982075",
"0.63916016",
"0.6357952",
"0.6357952",
"0.63525283",
"0.63525283",
"0.6279837",
"0.6263549",
"0.6219576",
"0.6219576",
"0.6219576",
"0.6219576",
"0.6216418",
"0.6210288",
"0.621028... | 0.0 | -1 |
Performs applicationlevel initialization functions. | def initialize(params={})
name = init_collection_name params[:define_collection_name]
@@_collection[self.class.name] ||= Schema.instance.get_collection(name)
@id = params[:id] if params[:id]
@__ref_value__ = '"*"'
# @event_types = params[:event_types] ? params[:event_types] : []
# @relation_kinds = params[:graphs] ? params[:graphs] : []
@@_cache[self.class.name] ||= SimpleCacheRequest.new(ocollection)
@@cache_store ||= SimpleCacheStore.instance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bootstrap_init\n end",
"def init!\n @logger = @config = @database_config = nil\n\n load_application_config\n load_database_config\n note \"Loading #{env} environment (#{Ajaila::VERSION})\"\n load_classes\n note \"Establishing database connection\"\n establish_database_... | [
"0.7670302",
"0.7613924",
"0.6924146",
"0.6807468",
"0.6807468",
"0.6774053",
"0.66600984",
"0.66397446",
"0.66210735",
"0.66168916",
"0.660155",
"0.6524836",
"0.6519737",
"0.65060496",
"0.65060496",
"0.65060496",
"0.64863914",
"0.64827174",
"0.6482114",
"0.64802104",
"0.6480... | 0.0 | -1 |
Instance methods collection/key Fetches the data associated with this id from the collection. | def orchio_get
if cache.enabled? and response = cache_request.get(id)
if response.header.status == :cache
doc = response.body.document
end
else
response = client.send_request :get, inst_args if response.nil?
doc = Document.new(
response.body.to_hash,
Metadata.new(
:collection => ocollection,
:key => @id,
:ref => response.header.etag
))
end
Result.new(
status: orchio_status(response, 200),
response: response,
results: [ doc ]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](key)\n return nil if @collection.nil?\n return_item_value key\n end",
"def get(key)\n @collection.deserialize(\n [@dataset.get(key)].compact\n ).first\n end",
"def find(collection, *key)\n command(collection).get(key)\n end",
"de... | [
"0.67267466",
"0.6711809",
"0.66536564",
"0.6619721",
"0.65680754",
"0.650593",
"0.64997953",
"0.64969677",
"0.6496539",
"0.6477692",
"0.64555687",
"0.6440232",
"0.6440232",
"0.6440232",
"0.64079565",
"0.63917506",
"0.6359318",
"0.63499117",
"0.63336873",
"0.62765396",
"0.627... | 0.0 | -1 |
Updates the collection with the data associated with this instance. | def orchio_put(jdoc)
response = client.send_request :put, inst_args(json: jdoc)
if cache.enabled?
simple_cache.save(
Document.new(
response.body.to_hash,
Metadata.new(
:collection => ocollection,
:key => @id,
:ref => response.header.etag
)))
end
set_ref_value response
orchio_status response, 201
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update attributes, collection #:nodoc:\n 0\n end",
"def reload_data\n reset_collection_data\n reload_collection_data\n end",
"def update\n # TODO: implement update\n end",
"def reload\n requires :instance, :identity\n\n data = collection.get(self.ins... | [
"0.7060871",
"0.68224174",
"0.6822334",
"0.6797786",
"0.6758891",
"0.67026854",
"0.66997886",
"0.6696904",
"0.66311073",
"0.6617713",
"0.6393991",
"0.6373759",
"0.6328539",
"0.6275938",
"0.6268717",
"0.6268717",
"0.62546086",
"0.62546086",
"0.6201978",
"0.6201978",
"0.6137299... | 0.0 | -1 |
Deletes the primary_key and data associated with this instance from the collection. | def orchio_delete
response = client.send_request :delete, inst_args
orchio_status response, 204
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_primary_key\n @attributes[self.primary_key_attribute] = nil\n end",
"def destroy\n unless new_record?\n self.class.collection.remove({:_id => self.id})\n end\n freeze\n end",
"def delete\n data.delete( self ); self\n end",
"def destroy\n result = databa... | [
"0.7554091",
"0.7028249",
"0.68953925",
"0.6870763",
"0.67941034",
"0.665962",
"0.66100174",
"0.6609745",
"0.6572196",
"0.65106255",
"0.64929336",
"0.64929336",
"0.6480663",
"0.64711666",
"0.6460154",
"0.6446744",
"0.6444225",
"0.6444225",
"0.6415732",
"0.6394174",
"0.6360242... | 0.0 | -1 |
Deletes the primary_key and purges all of its immutable data from the collection. | def orchio_purge
response = client.send_request :delete, inst_args(path: "?purge=true")
orchio_status response, 204
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_primary_key\n @attributes[self.primary_key_attribute] = nil\n end",
"def delete _key\n store.transaction() { |s| s.delete(prepare_key(_key)) }\n end",
"def delete\n open\n returning db.delete(self.key) do |result|\n close\n end\n end",
"def prepared_delete\n... | [
"0.7623547",
"0.676074",
"0.6566118",
"0.6549186",
"0.6468959",
"0.6446538",
"0.6420802",
"0.63993037",
"0.6375594",
"0.63721424",
"0.63721424",
"0.6358281",
"0.6340975",
"0.63345057",
"0.632127",
"0.6305836",
"0.6294877",
"0.6271532",
"0.62414324",
"0.6227867",
"0.62187403",... | 0.0 | -1 |
Instance methods collection/key/ref Gets the key/value pair by its 'ref' value. | def orchio_get_by_ref(ref)
response = client.send_request :get, inst_args(ref: ref)
Result.new(
status: orchio_status(response, 200),
response: response,
results: [ Document.new(
response.body.to_hash,
Metadata.new(
:collection => ocollection,
:key => @id,
:ref => response.header.etag
))]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(ref)\n @map[ref]\n end",
"def [](ref_id)\n response = @key_value.perform(:get, ref_id)\n Ref.new(@key_value.collection, @key_value.key, response)\n end",
"def [](key)\n @lock.synchronize do\n ref = @references[key]\n value = ref.object if ref\n value\n... | [
"0.7826067",
"0.7462541",
"0.74113953",
"0.674426",
"0.6606954",
"0.6471712",
"0.6433135",
"0.64103717",
"0.64073086",
"0.64073086",
"0.64073086",
"0.64073086",
"0.63824517",
"0.63783306",
"0.63783306",
"0.63009024",
"0.62873846",
"0.6264352",
"0.6228431",
"0.6218758",
"0.621... | 0.0 | -1 |
Updates the key/value if the send'ref' value matches the 'ref' value for the latest version in the collection. | def orchio_put_if_match(document, ref)
response = client.send_request :put, inst_args(json: document, ref: ref)
set_ref_value response
orchio_status response, 201
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_refs\n return true if self.user_id or changes.has_key? :user_id\n fields = self.attributes.select {|k,v| changes.has_key? k}\n self.references.update_all(fields) unless self.user_id\n end",
"def update\n true until @ref.compare_and_set(old_value = @ref.get, new_value = yield(old_value))\n... | [
"0.63141763",
"0.6120266",
"0.56230164",
"0.5622656",
"0.5598712",
"0.55957043",
"0.5541096",
"0.55383784",
"0.5528501",
"0.5486105",
"0.5469642",
"0.53991294",
"0.53391457",
"0.5332891",
"0.5240216",
"0.52378434",
"0.52194005",
"0.51729226",
"0.51292145",
"0.51165825",
"0.51... | 0.5423326 | 11 |
Updates the key/value if the key does not already exist in the collection. | def orchio_put_if_none_match(document)
orchio_put_if_match(document, '"*"')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put (key, value)\n !table.include?(key)\n end",
"def process_collection!(name, key, value, remote)\n if collection.key?(name)\n existing_remote = collection[name.to_s][:remote]\n # skip if the existing item is local and the new item is remote\n return if remote && !existing_remo... | [
"0.64563084",
"0.6449862",
"0.63330483",
"0.62448895",
"0.6155126",
"0.60978067",
"0.6078446",
"0.60400426",
"0.59903085",
"0.5903193",
"0.5891571",
"0.58890986",
"0.5849512",
"0.58259314",
"0.58197373",
"0.5816852",
"0.5816465",
"0.58128405",
"0.5790125",
"0.57883614",
"0.57... | 0.0 | -1 |
Instance methods collection/key/graph Gets the graph for the specified kind of relation. | def orchio_get_graph(kind)
# add_relation_kind kind
if cache.enabled? and response = cache_request.get_graph(id, kind)
if response.header.status == :cache
docs = response.body.documents
count = docs.length
end
else
response = client.send_request :get, inst_args(kind: kind)
docs = response.body.results.map { |result|
Document.new(
result['value'].merge(id: result['path']['key']),
Metadata.new(
:collection => result['path']['collection'],
:key => result['path']['key'],
:ref => result['path']['ref'],
:kind => kind,
:from_collection => ocollection,
:from_key => @id,
))}
cache.save_graph(id, kind) if cache.enabled? and count == 0
end
Result.new(
status: orchio_status(response, 200),
response: response,
count: response.body.count,
results: docs
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def graph(kind)\n res = orchio_get_graph(kind)\n (res.success?) ? res.results.map { |odoc| odoc.to_rails } : false\n end",
"def graph_class\n RDF::Graph\n end",
"def relation\n relation = nodes.reduce(root) do |a, e|\n a.associations[e.name.key].join(:join, a, e)\n e... | [
"0.657574",
"0.6241088",
"0.6199209",
"0.5996835",
"0.597931",
"0.59746987",
"0.59539104",
"0.5948078",
"0.5869207",
"0.58680755",
"0.58326524",
"0.5809189",
"0.57714933",
"0.57552767",
"0.57509476",
"0.57392704",
"0.5719115",
"0.5715314",
"0.5705366",
"0.5705366",
"0.5705366... | 0.7672522 | 0 |
Add a graph/relation to the collection. Store the to_key's 'ref' value if caching is enabled. | def orchio_put_graph(kind, to_collection, to_key)
# add_relation_kind kind
if cache.enabled?
ref = simple_cache.get_ref to_collection, to_key
simple_cache.get_cc(ocollection).save_graph Metadata.new(
{ from_key: @id, kind: kind, ref: ref }
)
end
response = client.send_request(
:put,
inst_args(kind: kind, to_collection: to_collection, to_key: to_key)
)
orchio_status response, 204
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_reference key, target, opts = {}, &blk\n\t\tadd_reference_set(key,target,opts) if target.is_a? Array\n\t\tadd_to_db(target, nil, :if_in_use => opts[:add_then_reference]) if opts[:add_then_reference]\n\t\tadd_to_db Database::Reference.new(self, target, :proc => blk), key, :if_in_use => opts[:if_in_use]\n\te... | [
"0.6182365",
"0.6182044",
"0.6178859",
"0.6128831",
"0.603533",
"0.5910233",
"0.5817467",
"0.57893527",
"0.57568485",
"0.57426685",
"0.573746",
"0.5715629",
"0.5675938",
"0.56750786",
"0.56678474",
"0.5661373",
"0.5653564",
"0.5631272",
"0.5629847",
"0.5629258",
"0.5624438",
... | 0.6775267 | 0 |
Delete a graph/relation from the collection. | def orchio_delete_graph(kind, to_collection, to_key)
response = client.send_request(
:delete,
inst_args(
kind: kind,
to_collection: to_collection,
to_key: to_key,
path: "?purge=true"
))
orchio_status response, 204
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(rel)\n @relations.delete_if do |x|\n x === rel\n end\n @graph[rel.from].delete(rel.to)\n @graph[rel.to].delete(rel.from) if @undirected\n end",
"def delete!\n graph.remove_vertex self\n end",
"def delete!\n graph.remove_edge element\n end",
"def delete!\n gra... | [
"0.7398699",
"0.73630047",
"0.7266474",
"0.7266474",
"0.72542584",
"0.7244137",
"0.7128334",
"0.7120606",
"0.6999951",
"0.69869655",
"0.69194967",
"0.69048387",
"0.68649715",
"0.68160367",
"0.6667667",
"0.6652384",
"0.6650596",
"0.6558151",
"0.655143",
"0.6485748",
"0.6468044... | 0.7154822 | 6 |
Public instance methods JMC Returns the collection name for the current instance. | def orchestrate_collection_name
ocollection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collection_name\n @collection_name ||= self.to_s.tableize.gsub(/\\//, '.')\n end",
"def collection_name\n\t\t\t\t\"#{klass.model_name.to_s.classify.pluralize}Collection\".constantize\n\t\t\tend",
"def collection_name; end",
"def collection_name; end",
"def collection_name; end",
"def get_... | [
"0.79024315",
"0.7801493",
"0.7775891",
"0.7775891",
"0.7775891",
"0.76895154",
"0.7650322",
"0.76499206",
"0.75549334",
"0.7468139",
"0.74520445",
"0.73105454",
"0.72635525",
"0.72388476",
"0.7229683",
"0.72220194",
"0.7183079",
"0.7117808",
"0.707675",
"0.7059667",
"0.69695... | 0.7381959 | 12 |
Returns the ref value for the current instance. The ref value is an immutable value assigned to each version of primary_key data in an orchestrate.io collection. | def orchestrate_ref_value
__ref_value__
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reference\n value_for('reference')\n end",
"def ref\n @id\n end",
"def ref\n @ref ||= self.node.attributes.to_h[\"ref\"]\n end",
"def reference\n @data['reference']\n end",
"def ref\n reference(@id, @revision)\n end",
"def ref\n @ref ||= ... | [
"0.69407225",
"0.6844483",
"0.6630032",
"0.66170686",
"0.6571058",
"0.6551984",
"0.6502058",
"0.6470157",
"0.6365831",
"0.62379277",
"0.62237215",
"0.61483204",
"0.61453617",
"0.6140024",
"0.60695076",
"0.6066563",
"0.60533196",
"0.60533196",
"0.60437137",
"0.60432917",
"0.60... | 0.73137236 | 1 |
Returns the primary_key for the current instance. | def orchestrate_primary_key
id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_key\n @primary_key ||= @klass.primary_key.to_s\n end",
"def primary_key\n self.class.primary_key\n end",
"def primary_key\n self.class.primary_key\n end",
"def primary_key\n self.class.primary_key\n end",
"def primary_key\n self[:primary_key]\n ... | [
"0.8849925",
"0.8763709",
"0.8763709",
"0.8763709",
"0.8683593",
"0.8665001",
"0.86636704",
"0.8647868",
"0.84087783",
"0.8392324",
"0.8299841",
"0.827642",
"0.8207471",
"0.819137",
"0.819137",
"0.8162177",
"0.8132812",
"0.81269324",
"0.80376863",
"0.79836744",
"0.7947221",
... | 0.7858645 | 23 |
Returns the client handle. | def orchestrate_client
client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client\n @client || Client.connection\n end",
"def client\n @client ||= self.class.client\n end",
"def client\n Thread.current[:client]\n end",
"def client\n @client ||= Client.current\n end",
"def client\n set_connection unless @client\n @client\n end",
"def cl... | [
"0.75452",
"0.73574746",
"0.73489094",
"0.7344137",
"0.7295097",
"0.72854346",
"0.72854346",
"0.72854346",
"0.723161",
"0.72150177",
"0.72028685",
"0.7184067",
"0.7097447",
"0.7097447",
"0.70913494",
"0.7085543",
"0.7085543",
"0.68839234",
"0.684399",
"0.6831283",
"0.67919487... | 0.59196246 | 72 |
After a successful PUT request, updates the current instance's ref value (also referred to as the etag) and calls orchio_update_ref_table. | def set_ref_value(response)
unless response.header.code != 201 || response.header.etag.blank?
@__ref_value__ = response.header.etag
orchio_update_ref_table response.header.timestamp
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orchio_update_ref_table(timestamp)\n return if ocollection == RefTable.get_collection_name\n\n if RefTable.enabled?\n primary_key = __ref_value__.gsub(/\"/, '')\n doc = {\n xcollection: ocollection,\n xkey: id,\n xref: primary_key,\... | [
"0.60518837",
"0.5905862",
"0.57425874",
"0.53495914",
"0.5342749",
"0.52888364",
"0.5202367",
"0.5183367",
"0.5146458",
"0.5125581",
"0.50779533",
"0.50746596",
"0.50360227",
"0.5031999",
"0.5016165",
"0.5004753",
"0.49825615",
"0.49766934",
"0.4958231",
"0.49519026",
"0.495... | 0.62973815 | 0 |
Updates the ref table collection with key/value data consisting of the current instance's collection, key, timestamp and ref values , using the ref value as the primary key. When the ref table feature is enabled, the ref table is updated after each sucessful put_key request. | def orchio_update_ref_table(timestamp)
return if ocollection == RefTable.get_collection_name
if RefTable.enabled?
primary_key = __ref_value__.gsub(/"/, '')
doc = {
xcollection: ocollection,
xkey: id,
xref: primary_key,
timestamp: timestamp
}.to_json
RefTable.new(:id => primary_key).orchio_put doc
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](ref_id)\n response = @key_value.perform(:get, ref_id)\n Ref.new(@key_value.collection, @key_value.key, response)\n end",
"def []=(key, value)\n ObjectSpace.define_finalizer(value, @reference_cleanup)\n key = key.dup if key.is_a?(String)\n @lock.synchronize do\n @referenc... | [
"0.5803649",
"0.5662252",
"0.5499384",
"0.54875493",
"0.5399688",
"0.5387158",
"0.53680176",
"0.5276618",
"0.5271424",
"0.5255198",
"0.52550596",
"0.5187772",
"0.5175624",
"0.5142534",
"0.5048935",
"0.503664",
"0.503664",
"0.5031836",
"0.5026367",
"0.5008508",
"0.49969405",
... | 0.7107745 | 0 |
:startdoc: Returns the client handle for requests to the orchestrate.io api. | def client
@@client ||= Orchestrate::Application::Connect.client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orchestrate_client\n client\n end",
"def orchestrator_client\n @orchestrator ||= Orchestrator.new(master.uri.to_s, username: 'admin', password: 'pie', ssl_verify: false)\nend",
"def client\r\n @client ||= APIController.new config\r\n end",
"def doorkeeper_client\n doorkeeper... | [
"0.7770018",
"0.6813021",
"0.6468379",
"0.6243656",
"0.6196577",
"0.616108",
"0.616108",
"0.616108",
"0.6159669",
"0.61101985",
"0.6074567",
"0.60618055",
"0.60618055",
"0.60547",
"0.6049865",
"0.6049865",
"0.60364646",
"0.60264724",
"0.60033923",
"0.5948854",
"0.5933244",
... | 0.67314106 | 2 |
Returns the collection name associated with the current instance's class. | def ocollection
@@_collection[self.class.name].name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collection_name\n\t\t\t\t\"#{klass.model_name.to_s.classify.pluralize}Collection\".constantize\n\t\t\tend",
"def collection_name\n @collection_name ||= self.to_s.tableize.gsub(/\\//, '.')\n end",
"def collection_name\n self.to_s.tableize\n end",
"def collection_name_from_class_name(cl... | [
"0.8395584",
"0.8322516",
"0.8047097",
"0.79113543",
"0.7585694",
"0.7529532",
"0.75034964",
"0.7494685",
"0.7436805",
"0.7406892",
"0.73804134",
"0.7366862",
"0.7366862",
"0.7366862",
"0.73289126",
"0.73289126",
"0.731209",
"0.7301634",
"0.72815853",
"0.7159421",
"0.715592",... | 0.72106934 | 19 |
Returns hash that merges additional arguments with the everpresent collection and key args. | def inst_args(args={})
args.merge(collection: ocollection, key: id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_method_arg_hash(args)\n # SEQUEL5: Remove\n h = {}\n prepare_method_args('a', args.length).zip(args).each{|k, v| h[k] = v}\n h\n end",
"def hash\n [name, args].hash\n end",
"def hash\n hash_args.hash\n end",
"def hashed_key_and_args(key, *args)... | [
"0.686136",
"0.66113806",
"0.6460353",
"0.6459943",
"0.64443856",
"0.6351106",
"0.6026337",
"0.6011251",
"0.60047877",
"0.59954244",
"0.5991559",
"0.59628654",
"0.59418786",
"0.59189785",
"0.5915888",
"0.5874264",
"0.58566463",
"0.5802745",
"0.57890964",
"0.5787585",
"0.57680... | 0.59801024 | 11 |
Returns handle to the SimpleCacheCollection instance for this class. | def cache
@@_cache[self.class.name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simple_cache\n @@cache_store\n end",
"def collection\n @collection ||= Collection.load(self.collection_url)\n end",
"def cache\n @__cache ||= Cache.new self\n end",
"def getCollection\n return @coll\n end",
"def cache\n @cache ||= Flareshow::Cache.new\n end",... | [
"0.6766352",
"0.62372154",
"0.6154042",
"0.6026701",
"0.6015287",
"0.59810215",
"0.5913124",
"0.5864374",
"0.58624977",
"0.5841348",
"0.5778938",
"0.5768889",
"0.57607627",
"0.5755973",
"0.57548344",
"0.5700296",
"0.56876427",
"0.5684823",
"0.5671278",
"0.56704986",
"0.563061... | 0.60143065 | 5 |
Calls cache. Explain! Used for clarity? JMC | def cache_request
cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache=(_arg0); end",
"def cache=(_arg0); end",
"def cache=(_arg0); end",
"def cache=(_arg0); end",
"def cached?; end",
"def cache!\n @@cache\n end",
"d... | [
"0.8610231",
"0.8610231",
"0.8610231",
"0.8610231",
"0.8610231",
"0.8610231",
"0.8610231",
"0.80098027",
"0.80098027",
"0.80098027",
"0.80098027",
"0.7966051",
"0.7725617",
"0.77210045",
"0.77095777",
"0.77095777",
"0.758299",
"0.7553271",
"0.7504092",
"0.7504092",
"0.7422502... | 0.6805519 | 55 |
Returns handle to the SimpleCacheStore singleton instance. | def simple_cache
@@cache_store
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_store\n Cache.new\n end",
"def cache_store\n return nil if context.environment.cache.nil?\n\n CacheStore.new context.environment\n end",
"def cache; shrine_class.new(cache_key); end",
"def store\n @store ||= storage.new self\n end",
"def singleton_cache; end",
"def ... | [
"0.6644324",
"0.65349",
"0.6361972",
"0.63534564",
"0.6315308",
"0.6243158",
"0.61991364",
"0.61588085",
"0.6147739",
"0.61404",
"0.61287725",
"0.61287725",
"0.61124194",
"0.61002916",
"0.60885304",
"0.60814565",
"0.6072397",
"0.60501343",
"0.60280156",
"0.6013275",
"0.599786... | 0.7578753 | 0 |
The code does not execute properly. Try to figure out why. Original: | def multiply(a b)
a * b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def suivre; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def probers; end",
"def schubert; end",
"def run() end",
"def zuruecksetzen()\n end",
"def code; end"... | [
"0.6102568",
"0.59635013",
"0.59587896",
"0.59587896",
"0.59587896",
"0.59587896",
"0.59587896",
"0.59587896",
"0.59587896",
"0.59587896",
"0.59587896",
"0.592695",
"0.58857346",
"0.57640874",
"0.56410444",
"0.5631545",
"0.5631545",
"0.5631545",
"0.5631545",
"0.5631545",
"0.5... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.