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 |
|---|---|---|---|---|---|---|
edit a project, only can edit the name for now | def change_project(name)
update!(name: name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n\t\t@project = Project.find(params[:id])\n\tend",
"def edit_project\n \t\t@project = Project.find(params[:id])\n\tend",
"def edit\n\t\t@project = Project.find(params[:id])\n have_no_rights('project.no_rights') if cannot? :update, @project\n\t\tself.bread\n\t\tadd_crumb(@project.name, project_path(... | [
"0.82658494",
"0.8244542",
"0.8234349",
"0.8135928",
"0.8135928",
"0.8135928",
"0.81011224",
"0.80913043",
"0.79264313",
"0.7885756",
"0.77817166",
"0.7734935",
"0.76238596",
"0.76187426",
"0.753784",
"0.7417402",
"0.73384035",
"0.72958535",
"0.7295659",
"0.7277552",
"0.72715... | 0.7391452 | 16 |
save the configuration and if it has errors | def save_project_config(yaml, repo_name, ready)
update!(configuration: yaml, ready: ready)
update!(repo_name: repo_name) unless repo_name.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n return unless dirty? && config.respond_to?(:write)\n\n config.write\n clean_up\n end",
"def save\n return unless self.class.configured?\n\n report_exception\n end",
"def save_configuration\n create_config_dir_if_needed\n\n if configuration_w... | [
"0.72164524",
"0.7203572",
"0.7079953",
"0.6943096",
"0.6919893",
"0.67993754",
"0.67965764",
"0.67258036",
"0.662889",
"0.6620822",
"0.6562989",
"0.64193004",
"0.6406571",
"0.6354254",
"0.6354254",
"0.63449347",
"0.63291836",
"0.632232",
"0.63084763",
"0.6295206",
"0.6289135... | 0.0 | -1 |
Private Instance method Format name field, lowercase and '_' by space Admitted only alphanumeric characters | def name_format
self.name.gsub!(/[^0-9a-z\-_ ]/i, '_') unless self.name.nil?
self.name.gsub!(/\s+/, '-') unless self.name.nil?
self.name = self.name.downcase unless self.name.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_name(name)\n name.split(' ').join('_')\n end",
"def format_name(name)\n name.split(' ').join('_')\n end",
"def underscore_name(name)\n name.to_s.sub(/.*::/, \"\").\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z... | [
"0.8313217",
"0.8313217",
"0.7857185",
"0.7844298",
"0.7792013",
"0.7737691",
"0.7625872",
"0.76209885",
"0.7612938",
"0.7607058",
"0.755867",
"0.75008225",
"0.74700236",
"0.74647677",
"0.7392575",
"0.73890287",
"0.7362086",
"0.7359948",
"0.734377",
"0.7342925",
"0.7332259",
... | 0.8728622 | 1 |
Add more helper methods to be used by all tests here... | def generate_feed(title='Rails 程序测试指南', link='http://guides.ruby-china.org/testing.html',
source = 'http://guides.ruby-china.org/testing.html', author='MasterQiu')
feed = Feed.new
feed.title = title
feed.link=link
feed.source = source
feed.author = author
return feed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end",
"def helpers; end",
"def... | [
"0.7330966",
"0.701972",
"0.701972",
"0.701972",
"0.6772961",
"0.6679903",
"0.6679903",
"0.6583205",
"0.65507036",
"0.6377433",
"0.63762784",
"0.632961",
"0.6280821",
"0.6280821",
"0.6249786",
"0.6142927",
"0.6137607",
"0.6121912",
"0.6108209",
"0.60972595",
"0.60949636",
"... | 0.0 | -1 |
GET /meetups def index | def new
@meetup = Meetup.new
@recipient = User.find_by_id(params[:recipient_id])
@recipient_meetups = []
@recipient.upcoming_meetups.each do |m|
@recipient_meetups.push({:title=> @recipient.name, :start=> m.date.strftime('%m-%d-%Y %H:%M:%S'), :end=> (m.date + 1.hour).strftime('%m-%d-%Y %H:%M:%S'), :allDay=> false})
end
@my_meetups = []
current_user.upcoming_meetups.each do |m|
@my_meetups.push({:title=> current_user.name, :start=> m.date.strftime('%m-%d-%Y %H:%M:%S'), :end=> (m.date + 1.hour).strftime('%m-%d-%Y %H:%M:%S'), :allDay=> false})
end
gon.recipient = @recipient
gon.me = current_user
gon.recipient_meetups = @recipient_meetups
gon.my_meetups = @my_meetups
@current_user = current_user
@prev_meetup_id = params[:prev_meetup_id]
respond_to do |format|
format.html # new.html.erb
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @meetusers = Meetuser.all\n end",
"def index\n @users_meetings = UsersMeeting.all\n end",
"def index\n @meetings = Meeting.all\n end",
"def index\n @meetings = Meeting.all\n end",
"def index\n @meetings = Meeting.all\n end",
"def index\n @meetings = Meeting.all\n end",... | [
"0.7994148",
"0.7747344",
"0.77233213",
"0.77233213",
"0.77233213",
"0.77233213",
"0.77233213",
"0.77233213",
"0.7624753",
"0.7609745",
"0.7587258",
"0.7536974",
"0.7475273",
"0.7366135",
"0.7331087",
"0.72259057",
"0.72257704",
"0.71786004",
"0.71710026",
"0.7155079",
"0.709... | 0.0 | -1 |
GET /child_developments GET /child_developments.json | def index
@child_developments = ChildDevelopment.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @depts = Dept.roots.includes(:children)\n render json: @depts, each_serializer: V1::DeptSerializer, root: false\n end",
"def index\n @child_development_periods = ChildDevelopmentPeriod.all\n end",
"def create\n @child_development = ChildDevelopment.new(child_development_params)\n\n ... | [
"0.64086324",
"0.64003617",
"0.62068826",
"0.61626613",
"0.6114959",
"0.6089671",
"0.607171",
"0.6047032",
"0.60284823",
"0.59733933",
"0.59157395",
"0.58785695",
"0.584249",
"0.5799482",
"0.57622606",
"0.5757852",
"0.5739985",
"0.57388085",
"0.5726212",
"0.5659041",
"0.56526... | 0.7779167 | 0 |
GET /child_developments/1 GET /child_developments/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @child_developments = ChildDevelopment.all\n end",
"def show\n @dec_form_child = DecFormChild.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dec_form_child }\n end\n end",
"def show\n @child = Child.find(params[:id... | [
"0.7494669",
"0.6488831",
"0.6470898",
"0.6335473",
"0.63175094",
"0.6304147",
"0.6225572",
"0.6120757",
"0.6096537",
"0.6060573",
"0.6039699",
"0.6003745",
"0.5944195",
"0.5888484",
"0.5844497",
"0.57861316",
"0.5782509",
"0.5770053",
"0.5764848",
"0.57434773",
"0.5731476",
... | 0.0 | -1 |
POST /child_developments POST /child_developments.json | def create
@child_development = ChildDevelopment.new(child_development_params)
respond_to do |format|
if @child_development.save
format.html { redirect_to @child_development, notice: 'Child development was successfully created.' }
format.json { render :show, status: :created, location: @child_development }
else
format.html { render :new }
format.json { render json: @child_development.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @child_developments = ChildDevelopment.all\n end",
"def create\n @child_development_period = ChildDevelopmentPeriod.new(child_development_period_params)\n\n respond_to do |format|\n if @child_development_period.save\n format.html { redirect_to @child_development_period, notice: ... | [
"0.6609431",
"0.6491109",
"0.6347813",
"0.6168127",
"0.6153938",
"0.61445624",
"0.6117569",
"0.6103718",
"0.60723877",
"0.6071781",
"0.60514915",
"0.6009939",
"0.60050434",
"0.6002946",
"0.5991567",
"0.59818506",
"0.597364",
"0.59473366",
"0.5922054",
"0.5889878",
"0.5852679"... | 0.7337008 | 0 |
PATCH/PUT /child_developments/1 PATCH/PUT /child_developments/1.json | def update
respond_to do |format|
if @child_development.update(child_development_params)
format.html { redirect_to @child_development, notice: 'Child development was successfully updated.' }
format.json { render :show, status: :ok, location: @child_development }
else
format.html { render :edit }
format.json { render json: @child_development.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: 'Child was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @child.errors,... | [
"0.6606419",
"0.65528923",
"0.65132487",
"0.65132487",
"0.65094864",
"0.6508828",
"0.64458364",
"0.63052046",
"0.63012964",
"0.62542397",
"0.621978",
"0.6212393",
"0.6194703",
"0.6190255",
"0.61257887",
"0.6061816",
"0.60572755",
"0.60446405",
"0.60396916",
"0.6024798",
"0.60... | 0.7007827 | 0 |
DELETE /child_developments/1 DELETE /child_developments/1.json | def destroy
@child_development.destroy
respond_to do |format|
format.html { redirect_to child_developments_url, notice: 'Child development was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @condominium_child.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n en... | [
"0.69409883",
"0.69406825",
"0.68776184",
"0.679911",
"0.6794346",
"0.67937267",
"0.6699351",
"0.66941893",
"0.66509986",
"0.66509986",
"0.6643953",
"0.6643953",
"0.6617989",
"0.66107166",
"0.6608842",
"0.65629166",
"0.65621984",
"0.6559342",
"0.6547585",
"0.65386224",
"0.652... | 0.7390668 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_child_development
@child_development = ChildDevelopment.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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def child_development_params
params.require(:child_development).permit(:name, :months)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
Checks to make sure an parameter is a format that supports a noun (uuid, etc)) | def validate_parameter(*param)
param.each do |a|
return false unless a && (a.to_s =~ /^\{.*\}$/) == nil && a != '' && a != {}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_uuid_format?(uuid)\n !!(uuid =~ /^[A-Za-z0-9_\\-]{16,}$/)\n end",
"def check_acceptable_format\n if [\"txt\", \"png\"].include?(params[:format])\n params[:format] = nil\n raise ActiveRecord::RecordNotFound.new\n end\n end",
"def check_acceptable_format\n raise ActiveRe... | [
"0.60265094",
"0.5837604",
"0.5794198",
"0.57814485",
"0.5769844",
"0.57156533",
"0.56513536",
"0.5579838",
"0.5576649",
"0.5561409",
"0.5527679",
"0.5527057",
"0.548753",
"0.548488",
"0.54786813",
"0.54718393",
"0.5451835",
"0.5446428",
"0.5411582",
"0.53989726",
"0.5393131"... | 0.56934506 | 6 |
gets a reference to the ProjectHanlon::Data instance (and checks to make sure it is working before returning the result) | def get_data
data = ProjectHanlon::Data.instance
data.check_init
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data() @data ||= Data.new( self ); end",
"def data\n self.load if @data.nil?\n @data\n end",
"def data\n DataProxy.new(self)\n end",
"def data\n @data ||= @_data.respond_to?(:call) ? @_data.call() : @_data\n end",
"def data\n self.reload if @should_reload\n return @data\n... | [
"0.70406675",
"0.6658268",
"0.64851516",
"0.6301352",
"0.62855124",
"0.62564677",
"0.61786556",
"0.61742264",
"0.6119687",
"0.6086298",
"0.6017053",
"0.60100263",
"0.5991795",
"0.5966257",
"0.59188217",
"0.59060156",
"0.58990955",
"0.5863579",
"0.5863579",
"0.5855554",
"0.584... | 0.8162885 | 0 |
used to parse the filter_string argument so that comparisons of names and values can be made in the 'filter_hnl_response' method, below note there is no attempt made here to parse the names or values further; that is left as a task that must be performed later (during the comparison with the response objects being filtered); this method simply transforms the '+' and '=' separated set of namevalue pairs in the filter_string to a hash map that can be used to filter response objects, and it is that hash map that is returned from this method | def parse_filter_string(filter_string)
name_val_pairs = filter_string.split('+')
comparison_hash = {}
name_val_pairs.each { |name_val|
comparison_pair = Hash[*name_val.split('=').flatten]
comparison_hash.merge!(comparison_pair)
}
comparison_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_filter_string(string)\n hash = {}\n \n x = string.strip.split(/[\\s]+&&[\\s]+/i)\n t = x.map{|s| s.match(/^([a-zA-Z0-9_]+)[\\s]*(<>|<=>|<=|>=|<|>|=|!=)[\\s]*(.+)$/i).to_a}.compact\n\n t.each do |v|\n key, operator, value = v[1..3]\n value.tr!(\"'\", \"... | [
"0.7066726",
"0.69138235",
"0.62990135",
"0.6111555",
"0.6105148",
"0.60389143",
"0.5918112",
"0.5824792",
"0.5666274",
"0.56520677",
"0.5605459",
"0.55393493",
"0.5484768",
"0.54777175",
"0.5464047",
"0.53984183",
"0.53860795",
"0.53676367",
"0.536179",
"0.53304756",
"0.5326... | 0.7958842 | 0 |
used to obtain the value from the input response object that corresponds to the input fieldname; if a matching field in the response object cannot be found, then a nil will be returned (and the field will be ignored for purposes of matching), otherwise the corresponding value from the response object will be returned. note that the fieldname can take one of two forms, either a 'dot separated' form or a 'string value' form in the 'dot separated' case, the assumption is that the fieldname being used for comparison is embedded in a hash map (or in multiple, nested hash maps) in the response object; an example of this form would be a fieldname like 'attributes_hash.macaddress' in the 'string value' case, the assumption is that the fieldname is directly accessible as a fieldname of the response object; an example of this form would be a fieldname like 'status' in either case failing to find a corresponding field at the declared location in the response will result in an error being thrown from this method | def get_object_value(object, fieldname)
# first, attempt to split the fieldname based on the '.' character
# (if it exists in the string)
dot_split = fieldname.split('.')
if dot_split.size > 1
# if it's a dot-separated form, then drill down until we find the
# value that the dot-separated form refers to and return that value
value = object
prev_key = dot_split[0]
dot_split.each { |keyname|
# throw an error if the 'value' is not a hash (before attempting to retrieve the next 'value')
raise ProjectHanlon::Error::Slice::InputError, "Parsing of '#{fieldname}' failed; field '#{prev_key}' is not a Hash value" unless value.is_a?(Hash)
# if get here, then just retrieve the next element from nested hash maps referred
# to in the dot-separated form (note that for top-level fields the keys will be
# prefixed with an '@' character but for lower-level fields that will not be the
# case, this line will retrieve one or the other)
value = value["@#{keyname}"] || value[keyname]
# throw an error if a field with the key 'keyname' was not found (it's an illegal reference in that case)
raise ProjectHanlon::Error::Slice::InputError, "Parsing of '#{fieldname}' failed; field '#{keyname}' cannot be found" unless value
# otherwise, save this keyname for the next time through the loop and continue
prev_key = keyname
}
return value
end
# otherwise, retrieve the field referred to by the fieldname and return
# that value (note that for top-level fields the keys will be prefixed
# with an '@' character but for lower-level fields that will not be the
# case, this line will retrieve one or the other)
object["@#{fieldname}"] || object[fieldname]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_response_field(field, target)\n return unless @response\n return @response[field] if target == 'header'\n return @response.body if field.nil? || field.empty?\n json = JSON.load(@response.body) rescue nil\n res = nil\n if json\n res = json_field(json, field)\n else\... | [
"0.65683883",
"0.65519595",
"0.64964986",
"0.64657617",
"0.622487",
"0.62056625",
"0.61956805",
"0.6183251",
"0.61350495",
"0.6065811",
"0.6053469",
"0.60524946",
"0.5985195",
"0.59756804",
"0.59661525",
"0.5959245",
"0.59383225",
"0.592082",
"0.5910471",
"0.586275",
"0.58627... | 0.7439743 | 0 |
used to compare the value retrieved from the response object with the input comparison_value, which can take several forms: if the comparison value is prefixed by the 'regex:' string, then that comparison value will be converted into a regular expression and a regex comparison will be made with the object_value if the comparison value contains a set of strings separated by either the '&' or '|' character, then that comparison value will be further broken down into an array of strings that will be used for comparison > if the object_value is an array, it will be checked to see if all (in the the '&' case) or at least 1 (in the '|' case) of those strings are elements of the array; only string comparisons are supported in this case > if the object_value is a string, then it can be matched against a comparison value containing one or more strings separated by the '|' character; in that case the value will be considered to match the comparison value if at least one of those strings from the comparison value matches the value boolean object_values will be converted to strings before attempting to match against the comparison value, and the match will be made based on a simple string comparison against the values 'true' or 'false' | def object_value_matches?(comparison_value, object_value)
# first, test to see if the comparison value is a regular expression or
# if it is a set of strings separated by '&' or '|' characters
comparison_regex = Regexp.new(comparison_value.gsub(/^regex\:/,'')) if /^regex\:/.match(comparison_value)
or_sep_substrings = comparison_value.split('|') if comparison_value.include?('|')
and_sep_substrings = comparison_value.split('&') if comparison_value.include?('&')
# throw an error if both '&' and '|' characters were used in the declared comparison_value string
# (this method will match based on either a logical AND or a logical OR against the substrings in
# the comparison_value string, but not both)
raise ProjectHanlon::Error::Slice::InputError, "Illegal comparison_value; the declared value contains both '&' and '|' separated Strings" if and_sep_substrings && or_sep_substrings
# throw an error if the comparison_value contains a set of '&' or '|' separated substrings
# but also contains the string 'regex:' (we don't support logical AND or logical OR matching
# via substrings that are, themselves, regular expressions)
regex_in_and_substrings = and_sep_substrings.select { |val| /^regex\:/.match(val) }.size > 0 if and_sep_substrings
regex_in_or_substrings = or_sep_substrings.select { |val| /^regex\:/.match(val) }.size > 0 if or_sep_substrings
raise ProjectHanlon::Error::Slice::InputError, "Illegal comparison_value; the declared value contains regular expressions as substrings" if regex_in_and_substrings || regex_in_or_substrings
# throw an error if we're using an '&' separated set of substrings for our comparison_value
# but the object_value is not an array (the '&' separated substring construct only makes
# sense in the case of array comparisons)
raise ProjectHanlon::Error::Slice::InputError, "Illegal comparison_value; '&' separated strings cannot be compared to a non-Array object" if and_sep_substrings && !(object_value.is_a?(Array))
# Ensure that the elements of the object_value are converted to a string (if the
# object_value is an Array)
object_value.map! { |val| val.to_s } if object_value.is_a?(Array)
if or_sep_substrings
# if we found a set of strings separated by '|' characters, then check for
# a match; in this case the rules for a match depend on whether the
# object_value is an Array or a String; if it's an Array, then check the
# intersection between our two arrays (the 'or_sep_substrings' array and
# the 'object_value' array) to make sure that at least one string matches
# between the two
return ((or_sep_substrings & object_value).size > 0) if object_value.is_a?(Array)
# otherwise, it's a String, so just check to make sure that one of the
# strings in the 'or_sep_substrings' Array matches
return or_sep_substrings.include?(object_value)
elsif and_sep_substrings
# if we found a set of strings separated by '&' characters, then check for
# a match; in this case the rules for a match are quite simple, just check
# to make sure that all elements of the 'and_sep_substrings' array also
# appear in the 'object_value' array (that the difference between them is
# the empty set)
return (and_sep_substrings - object_value).empty?
elsif object_value.is_a?(Array)
# if the object_value is an Array, then look for a match within that array;
# first, if the comparison value was a regular expression, just check to make
# sure that at least one of the elements in the object_value array matches
# that regular expression
return object_value.select { |val| comparison_regex.match(val) }.size > 0 if comparison_regex
# otherwise, just check to see if the comparison value (assumed to be String
# at this point) can be found in the object_value array
return object_value.include?(comparison_value)
end
# if we got this far, we're looking at a simple comparison of a String or
# Regexp against our object_value; if the comparison value passed in is a
# regular expression, then simply return a regular expression match
return comparison_regex.match(object_value.to_s) if comparison_regex
# otherwise, return a simple string comparison
comparison_value.to_s == object_value.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_object_matches?(object, comparison_hash)\n # loop through the fieldname/comparison_value pairs in the comparison hash,\n # searching for a match between the comparison value and the corresponding\n # value for the field in the response object that corresponds to that\n # fi... | [
"0.65133804",
"0.5949916",
"0.5887908",
"0.58551115",
"0.56858253",
"0.54979277",
"0.5436636",
"0.54111075",
"0.53592116",
"0.53393406",
"0.53329986",
"0.5325905",
"0.5325905",
"0.5323037",
"0.5292022",
"0.52460957",
"0.52383596",
"0.5216842",
"0.5211148",
"0.5199042",
"0.519... | 0.7450474 | 0 |
determines if an input response object is a match according to the rules spelled out in the comparison_hash, returning true for a match and false if a match is not found | def response_object_matches?(object, comparison_hash)
# loop through the fieldname/comparison_value pairs in the comparison hash,
# searching for a match between the comparison value and the corresponding
# value for the field in the response object that corresponds to that
# fieldname; if any of the fieldname/comparison_value pairs do not match
# return false, else return true
comparison_hash.each { |fieldname, comparison_value|
object_value = get_object_value(object, fieldname)
return false unless object_value_matches?(comparison_value, object_value)
}
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matches?(response)\n return false unless valid_response?(response)\n\n @parsed_response = JSON.parse(response.body)\n\n return false if response_is_error?\n return false unless valid_data_section?\n if JsonapiRspec.configuration.meta_required\n return false unless valid_meta_section?\n e... | [
"0.7380986",
"0.7044212",
"0.6709604",
"0.6494677",
"0.6392215",
"0.63247347",
"0.62650543",
"0.60589474",
"0.6011657",
"0.59589356",
"0.5939418",
"0.59070307",
"0.5807287",
"0.5789035",
"0.5769281",
"0.5751515",
"0.571991",
"0.5712379",
"0.570431",
"0.57015634",
"0.56963974"... | 0.8156229 | 0 |
used to filter the generic GET responses based on a 'filter_str' containing a set of name/value pairs (where the names are fieldnames in the response to match against and the values are comparisonvalues that the values from those fieldnames must match for an object in the response to pass through the filter). The filtering done by this method supports a fairly complex syntax for the input 'filter_string' argument. In cases where the parsing fails or a comparison cannot be made, errors will be thrown. In all cases, attempts are made to make the error as selfexplanatory as possible | def filter_hnl_response(response, filter_string)
# if response is not an array or if all of the elements in the array are not hashes,
# then throw an error
raise ProjectHanlon::Error::Slice::InputError, "Can only filter response arrays" unless response.is_a?(Array) && response.select { |elem| elem.is_a?(Hash) }.size > 0
raise ProjectHanlon::Error::Slice::InputError, "Can only filter responses that are arrays of hash maps" unless response.select { |elem| elem.is_a?(Hash) }.size == response.size
# if the response is of the right type, then parse the filter_string
# to construct a comparison hash
comparison_hash = parse_filter_string(filter_string)
# then, expand the response values to construct a corresponding array
# of objects that we can test for matches to the comparison hash
expanded_response = response.map { |response_elem|
if response_elem.has_key?("@uri")
uri = URI.parse response_elem["@uri"]
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
lcl_response = http.request(request)
JSON.parse(lcl_response.body)["response"]
else
# if get here, it's an error...should only be used for responses
# that are a collection of objects (which will be a collection
# of objects containing URIs that refer to specific instances
# of the object in the input collection)
raise ProjectHanlon::Error::Slice::InputError, "Can only filter response arrays that contain URIs that reference response objects"
end
}
# determine which objects match based on the comparison hash constructed
# from the filter_string (above)
matching_indexes = response.each_index.select { |index|
response_object_matches?(expanded_response[index], comparison_hash)
}
# and use the list of indexes that matched to filter the response array
# to only include the elements that matched
response.values_at(*matching_indexes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_filter_string(filter_string)\n name_val_pairs = filter_string.split('+')\n comparison_hash = {}\n name_val_pairs.each { |name_val|\n comparison_pair = Hash[*name_val.split('=').flatten]\n comparison_hash.merge!(comparison_pair)\n }\n comparison_hash\n ... | [
"0.6626165",
"0.6533827",
"0.586387",
"0.586387",
"0.58550876",
"0.58244985",
"0.5793462",
"0.572733",
"0.56872976",
"0.5673731",
"0.5670261",
"0.5581364",
"0.55765504",
"0.5550098",
"0.55445904",
"0.551765",
"0.544505",
"0.540768",
"0.539587",
"0.53891647",
"0.535354",
"0.... | 0.63020056 | 2 |
used to construct a response to a RESTful request that is similar to the "slice_success" response used previously by Hanlon | def hnl_slice_success_response(slice, command, response, options = {})
mk_response = options[:mk_response] ? options[:mk_response] : false
type = options[:success_type] ? options[:success_type] : :generic
# Slice Success types
# Created, Updated, Removed, Retrieved. Generic
return_hash = {}
return_hash["resource"] = slice.class.to_s
return_hash["command"] = command.to_s
return_hash["result"] = slice.success_types[type][:message]
return_hash["http_err_code"] = slice.success_types[type][:http_code]
return_hash["errcode"] = 0
return_hash["response"] = response
return_hash["client_config"] = ProjectHanlon.config.get_client_config_hash if mk_response
return_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_response\n { status: :success, data: {} }\n end",
"def format_response(payload); end",
"def format_response(payload); end",
"def to_response\n slice(:id, :username, :cash, :referrals).to_json\n end",
"def build_response(connection, request); end",
"def response\n response... | [
"0.6501734",
"0.6476638",
"0.6476638",
"0.6404488",
"0.6348793",
"0.62869954",
"0.6210621",
"0.61196053",
"0.6074664",
"0.59564584",
"0.5926889",
"0.59033906",
"0.58882457",
"0.5877567",
"0.5834933",
"0.58132523",
"0.5810121",
"0.5805749",
"0.5791099",
"0.5781804",
"0.5739316... | 0.6930464 | 0 |
a method similar hnl_slice_success_response method (above) that properly returns a Hanlon object (or array of Hanlon objects) as part of the response | def hnl_slice_success_object(slice, command, hnl_object, options = { })
if hnl_object.respond_to?(:collect)
# if here, it's a collection
if slice.uri_root
# if here, then we can reduce the details down and just show a URI to access
# each element of the collection
hnl_object = hnl_object.collect do |element|
elem_hash = element.to_hash
if element.respond_to?("is_template") && element.is_template
key_field = ""
additional_uri_str = ""
if slice.class.to_s == 'ProjectHanlon::Slice::Broker'
key_field = "@plugin"
additional_uri_str = "plugins"
elsif slice.class.to_s == 'ProjectHanlon::Slice::Model'
key_field = "@name"
additional_uri_str = "templates"
elsif slice.class.to_s == 'ProjectHanlon::Slice::Policy'
key_field = "@template"
additional_uri_str = "templates"
end
# filter down to just the #{key_field}, @classname, and @noun fields and add a URI
# (based on the name fo the template) to the element we're returning that can
# be used to access the details for that element
test_array = [key_field, "@classname", "@noun"]
elem_hash = Hash[elem_hash.reject { |k, v| !test_array.include?(k) }]
slice.add_uri_to_object_hash(elem_hash, key_field, additional_uri_str)
else
# filter down to just the @uuid, @classname, and @noun fields and add a URI
# to the element we're returning that can be used to access the details for
# that element
temp_fields = %w(@uuid @classname @noun) + class_from_string(slice.class.to_s).additional_fields
elem_hash = Hash[elem_hash.reject { |k, v| !temp_fields.include?(k) }]
slice.add_uri_to_object_hash(elem_hash)
end
elem_hash
end
else
# if here, then there is no way to reference each element using
# a URI, so show the full details for each
hnl_object = hnl_object.collect { |element| element.to_hash }
end
else
# if here, then we're dealing with a single object, not a collection
# so show the full details
hnl_object = hnl_object.to_hash
end
hnl_slice_success_response(slice, command, hnl_object, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hnl_slice_success_response(slice, command, response, options = {})\n mk_response = options[:mk_response] ? options[:mk_response] : false\n type = options[:success_type] ? options[:success_type] : :generic\n # Slice Success types\n # Created, Updated, Removed, Retrieved. Generic\n ... | [
"0.7162488",
"0.5989483",
"0.59069407",
"0.5902355",
"0.5886108",
"0.58509326",
"0.58509326",
"0.58376086",
"0.57667893",
"0.5720304",
"0.5707941",
"0.5672057",
"0.5636102",
"0.55557436",
"0.5487309",
"0.545887",
"0.5450516",
"0.54349655",
"0.5434496",
"0.54292285",
"0.538968... | 0.6968512 | 1 |
The username if environmental variable is set | def username
ENV['DESK_USERNAME']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username\n ENV['USER']\n end",
"def username\n ENV.fetch(\"USERNAME\")\nend",
"def username\n ENV.fetch(\"USERNAME\")\nend",
"def get_local_user\n return ENV['USER'] || ENV['USERNAME']\n end",
"def username\n config['couch_username_key'] ? \"#{ENV[config['couch_username_key']]}\" : \... | [
"0.85678786",
"0.8265825",
"0.8265825",
"0.80955577",
"0.78128445",
"0.76306427",
"0.76198846",
"0.7572673",
"0.75468636",
"0.75286907",
"0.7519037",
"0.751479",
"0.74928343",
"0.7464992",
"0.7434715",
"0.7198995",
"0.7198995",
"0.7140798",
"0.7132005",
"0.7116823",
"0.710778... | 0.81165105 | 3 |
The password if environmental variable is set | def password
ENV['DESK_PASSWORD']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password\n raise \"TEST_PASSWORD env var should be set to dashboard user's password\" unless ENV['TEST_PASSWORD']\n ENV['TEST_PASSWORD']\n end",
"def password\n ENV['NEARMISS_PASSWORD'] || config['password']\n end",
"def get_password\n if Rails.env == \"development\"\n return \... | [
"0.7744032",
"0.7517271",
"0.74302626",
"0.7384526",
"0.72861093",
"0.716515",
"0.7079198",
"0.70588756",
"0.70383316",
"0.7025076",
"0.6997391",
"0.6995938",
"0.6961894",
"0.69448054",
"0.6911098",
"0.6894907",
"0.6865347",
"0.68435353",
"0.6828332",
"0.6827456",
"0.6781998"... | 0.7939066 | 0 |
The consumer key if environmental variable is set | def consumer_key
ENV['DESK_CONSUMER_KEY']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consumer_key\n ENV[CONSUMER_KEY_NAME]\n end",
"def consumer_key\n ENV['WHCC_CONSUMER_KEY']\n end",
"def consumer_key; config[:consumer_key]; end",
"def consumer_secret\n ENV['DESK_CONSUMER_SECRET']\n end",
"def require_key\n return if ENV['CONSUMER_KEY']\n puts... | [
"0.86605334",
"0.8234537",
"0.7788333",
"0.75287145",
"0.74835974",
"0.7379181",
"0.7291602",
"0.7146981",
"0.71432143",
"0.7129456",
"0.7119866",
"0.7099366",
"0.68979925",
"0.68979925",
"0.68979925",
"0.68979925",
"0.68979925",
"0.68979925",
"0.68979925",
"0.68979925",
"0.6... | 0.8462137 | 1 |
The consumer secret if environmental variable is set | def consumer_secret
ENV['DESK_CONSUMER_SECRET']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consumer_secret\n ENV[CONSUMER_SECRET_NAME]\n end",
"def consumer_secret\n ENV['WHCC_CONSUMER_SECRET']\n end",
"def consumer_secret; config[:consumer_secret]; end",
"def secret\n # ````'badbreathbuffalo'\n\n # Hide in React Auth pt2 1:20:00 \n # ```ENV['jwt_secret']\n ... | [
"0.8207925",
"0.805402",
"0.75509423",
"0.7504327",
"0.7449811",
"0.74384695",
"0.74280083",
"0.7414948",
"0.74054694",
"0.73216903",
"0.72967756",
"0.7283245",
"0.72733116",
"0.7267295",
"0.7267025",
"0.7237016",
"0.71954024",
"0.71506935",
"0.71305794",
"0.71203",
"0.71203"... | 0.81729865 | 1 |
The access token if environmental variable is set | def token
ENV['DESK_TOKEN']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def access_token\n ENV[ACCESS_TOKEN_KEY_NAME]\n end",
"def access_token\n ENV['KARATEKIT_ACCESS_TOKEN']\n end",
"def access_token\n ENV['NAVITIA_ACCESS_TOKEN']\n end",
"def personal_access_token\n ENV['PERSONAL_ACCESS_TOKEN']\n end",
"def personal_access_toke... | [
"0.84467727",
"0.7989247",
"0.79024625",
"0.7853425",
"0.784318",
"0.7775813",
"0.7773196",
"0.75083286",
"0.7487377",
"0.73990065",
"0.7383165",
"0.7383165",
"0.7352651",
"0.7345204",
"0.7330971",
"0.7329132",
"0.7319353",
"0.7298215",
"0.7290334",
"0.7276769",
"0.72704464",... | 0.67176354 | 65 |
The access token secret if environmental variable is set | def token_secret
ENV['DESK_TOKEN_SECRET']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def access_token_secret\n ENV[ACCESS_TOKEN_SECRET_NAME]\n end",
"def access_token_secret\n credentials['secret']\n end",
"def access_token\n ENV[ACCESS_TOKEN_KEY_NAME]\n end",
"def token_secret; config[:token_secret]; end",
"def secret\n # EDITOR='code --wait' rai... | [
"0.8630139",
"0.8025427",
"0.7743697",
"0.75252974",
"0.74906415",
"0.7475681",
"0.7475681",
"0.7475681",
"0.74220234",
"0.7413488",
"0.7282883",
"0.7232609",
"0.72105837",
"0.716808",
"0.71275723",
"0.71230483",
"0.7113068",
"0.711095",
"0.7065924",
"0.7065924",
"0.7065924",... | 0.7753283 | 2 |
The subdomain if environmental variable is set | def subdomain
ENV['DESK_SUBDOMAIN']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subdomain\n host.split(\".\").first\n end",
"def subdomain\n #for debug at localhost\n return self.class.system_top_domain if self.class.system_top_domain == 'localhost'\n short_name + '.' + self.class.system_top_domain\n end",
"def subdomain\n get()[\"app\"][\"subdomain\"]\n end"... | [
"0.78333145",
"0.77747416",
"0.7706539",
"0.7506919",
"0.74009943",
"0.72581655",
"0.7241127",
"0.7210112",
"0.7184755",
"0.71522623",
"0.71284294",
"0.7117602",
"0.7117602",
"0.70734304",
"0.70450217",
"0.703169",
"0.7030202",
"0.69747186",
"0.6914382",
"0.6885045",
"0.68598... | 0.8560693 | 0 |
The endpoint if environmental variable is set | def endpoint
ENV['DESK_ENDPOINT']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def endpoint\n ENV[\"CHEF_API_ENDPOINT\"] || config[\"CHEF_API_ENDPOINT\"] || ENDPOINT\n end",
"def set_endpoint\n if ambiente == :producao\n return GetnetApi::Configure::URL[:producao]\n elsif ambiente == :homologacao\n return GetnetApi::Configure::URL[:homologacao]\n el... | [
"0.71379673",
"0.7135766",
"0.7087587",
"0.69172436",
"0.67690235",
"0.6756318",
"0.6651049",
"0.6578425",
"0.6576665",
"0.65157515",
"0.6512738",
"0.6512738",
"0.6512738",
"0.64504176",
"0.64357185",
"0.64357185",
"0.6408692",
"0.64082223",
"0.6392076",
"0.638476",
"0.636922... | 0.70715344 | 3 |
The connection options hash | def connection_options
CONNECTION_OPTIONS
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_options(data)\n opts = {\n logger: logger,\n user_known_hosts_file: \"/dev/null\",\n hostname: data[:hostname],\n port: data[:port],\n username: data[:username],\n compression: data[:compression],\n compression_level: data[:compre... | [
"0.73972666",
"0.7349264",
"0.7293159",
"0.72624785",
"0.72582567",
"0.72582567",
"0.72582567",
"0.7247758",
"0.72242004",
"0.72242004",
"0.72242004",
"0.7211478",
"0.7211478",
"0.72014314",
"0.71946156",
"0.7167679",
"0.7154745",
"0.7154745",
"0.71390826",
"0.7134853",
"0.70... | 0.7930808 | 0 |
test if object actually is a triangle | def test
@a+@b > @c && @a+@c > @b && @b+@c > @a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_triangle\n if @side1.eql?(@side2) && @side2.eql?(@side3)\n \"It's an equilateral\"\n elsif @side1.eql?(@side2) || @side2.eql?(@side3)\n \"It's an isosceles\"\n elsif @side1.eql?(@side2) == false && @side2.eql?(@side3) == false\n \"It's a scalene triangle\"\n else\n \"Not a ... | [
"0.74802154",
"0.7078525",
"0.6965503",
"0.69470227",
"0.6934475",
"0.69274986",
"0.69164383",
"0.69100535",
"0.6898144",
"0.67704195",
"0.6703974",
"0.66595215",
"0.66216606",
"0.6590309",
"0.65657437",
"0.65630186",
"0.65590733",
"0.65527517",
"0.65527517",
"0.65527517",
"0... | 0.0 | -1 |
check if object is NOT a triangle | def not
self.test != true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_triangle\n if @side1.eql?(@side2) && @side2.eql?(@side3)\n \"It's an equilateral\"\n elsif @side1.eql?(@side2) || @side2.eql?(@side3)\n \"It's an isosceles\"\n elsif @side1.eql?(@side2) == false && @side2.eql?(@side3) == false\n \"It's a scalene triangle\"\n else\n \"Not a ... | [
"0.69231987",
"0.6897584",
"0.68716294",
"0.6760007",
"0.66631174",
"0.6617441",
"0.6575074",
"0.6541499",
"0.6522661",
"0.64927167",
"0.6475507",
"0.64575464",
"0.6420317",
"0.63484067",
"0.6314899",
"0.63033056",
"0.63033056",
"0.63033056",
"0.6298932",
"0.6232877",
"0.6220... | 0.0 | -1 |
i know sorting an array is probably the most inefficient way of doing things but this really looks pretty | def sorted?
ary = self.dup
original = self.dup
ary.sort!
if (ary == original)then return 1 end
ary.reverse!
if (ary == original) then return -1 end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort1(array)\n\nend",
"def orderly(array)\n p array.sort\nend",
"def mothrah_sort (an_array)\n\tdef move_to_end (value, array)\n\t\tarray.delete(value)\n\t\tarray.push(value)\n\tend\n\tpos = 0\n\twhile pos < an_array.length \n\t\tif an_array[pos] > an_array[pos + 1]\n\t\t\tmove_to_end(an_array[pos], an_... | [
"0.7716106",
"0.76538754",
"0.757512",
"0.7472227",
"0.7464848",
"0.745923",
"0.7451313",
"0.7433028",
"0.7433028",
"0.7428379",
"0.73997676",
"0.7399573",
"0.7389937",
"0.73636156",
"0.7342703",
"0.7333278",
"0.7304334",
"0.7300568",
"0.7295988",
"0.7294379",
"0.7287007",
... | 0.0 | -1 |
=begin Expected XML: boshjenkinsartifacts release/bosh1639.tgz 1000 false release/bosh1644.tgz 20131225T07:01:23.000Z "302e3c1f30d571efc150c37b7442aaea" 129786667 STANDARD ... ListBucketResult.Marker is empty unless marker query param is specified. =end | def parse
hash = Hash.from_xml(@xml)
contents = hash["ListBucketResult"]["Contents"]
# In cases when there is only one item returned,
# Contents key is parsed as a Hash; make it into an array
unless contents.is_a?(Array)
if contents.is_a?(Hash)
contents = [contents]
else
raise StandardError,
"Expected 'ListBucketResult/Contents' " +
"key to be an Array, was '#{contents.class}'"
end
end
files = contents.map do |content|
S3::File.new(
content["Key"],
content["Size"],
content["ETag"].gsub('"', ''),
Time.parse(content["LastModified"]),
@logger,
)
end
max_keys = hash["ListBucketResult"]["MaxKeys"].to_i
is_truncated = hash["ListBucketResult"]["IsTruncated"] == "true"
S3::BucketPage.new(@bucket_url, files, max_keys, is_truncated, @logger)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bucket(bucket_name, options={})\n resp = get(bucket_name, '/', options)\n resp_obj = Crack::XML.parse(resp.body)\n if resp.code == \"200\"\n resp_obj[:success] = true\n resp_obj[:bucket_name] = bucket_name\n resp_obj[:message] = \"Bucket retrieved successfully\"\n ... | [
"0.5188094",
"0.50745714",
"0.50745714",
"0.50650954",
"0.49558416",
"0.478328",
"0.47828466",
"0.47734925",
"0.47717038",
"0.47144228",
"0.4706749",
"0.46696234",
"0.46227217",
"0.46087474",
"0.46026132",
"0.4600514",
"0.4571196",
"0.45575565",
"0.45561028",
"0.4528213",
"0.... | 0.566688 | 0 |
GET /projects/1 GET /projects/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n get 'projects'\n end",
"def listprojects\n get('listprojects.json')['projects']\n end",
"def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def projects\n... | [
"0.7869598",
"0.76979095",
"0.7681025",
"0.76118535",
"0.7534173",
"0.7526569",
"0.74935675",
"0.74935675",
"0.74935675",
"0.74935675",
"0.74935675",
"0.74935675",
"0.74935675",
"0.74933344",
"0.74841154",
"0.74793714",
"0.7444658",
"0.74304754",
"0.7423396",
"0.7415693",
"0.... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_project
@project = Project.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def project_params
params.require(:project).permit(:name, :status, :plan_start_time, :plan_end_time, :start_time, :end_time, :charge)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Ignore labels for equality | def eql?(other) self.class == other.class and target==other.target and source==other.source; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n other.class == self.class && other.labels == labels\n end",
"def compare_labels(edge1, edge2)\n if(((!edge1.label.nil? && !edge2.label.nil?) &&(edge1.label.downcase == edge2.label.downcase)) ||\n (edge1.label.nil? and edge2.label.nil?))\n result = EQUAL\n else\n result ... | [
"0.69902694",
"0.68554336",
"0.6778593",
"0.6739562",
"0.6561473",
"0.6272186",
"0.6150418",
"0.6048599",
"0.59421754",
"0.5841671",
"0.58218837",
"0.5803645",
"0.57522833",
"0.5697476",
"0.56924504",
"0.5672062",
"0.5667747",
"0.56518257",
"0.5637452",
"0.5618728",
"0.558700... | 0.0 | -1 |
Returns (v,u) if self == (u,v). | def reverse() self.class.new(target, source, label); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same(u, p)\n u == p\nend",
"def bothV\n [outV, inV]\n end",
"def ==(comp)\n comp.x === x && comp.y === y\n end",
"def compare(vertex)\n (vertex == @from) ? @to : @from\n end",
"def eql?(other)\n (@x == other.x) && (@y == other.y)\n end",
"def ==(other)\n other.x == @x && other.y =... | [
"0.5992264",
"0.59026444",
"0.52976876",
"0.5295574",
"0.5216094",
"0.51872665",
"0.51825225",
"0.517919",
"0.517919",
"0.517919",
"0.51689535",
"0.5142019",
"0.5130805",
"0.512352",
"0.507615",
"0.50711685",
"0.5011824",
"0.49781027",
"0.49725777",
"0.4966229",
"0.49638543",... | 0.0 | -1 |
Arc.new[1,2].to_s => "(12 'label')" | def to_s
l = label ? " '#{label.to_s}'" : ''
"(#{source}-#{target}#{l})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n circle.to_s\n end",
"def circle_to_s(c)\n get_circle(c).collect { |p| p.to_abrv }.join(',')\n end",
"def to_s\n label\n end",
"def to_s\n# res = \"Feld #{@x} x #{@y}\\n\"\n res = \"\"\n for y in 0...@y\n for x in 0...@x\n case @elemente[x][y].art\n when -1: ... | [
"0.65073496",
"0.60800856",
"0.6041313",
"0.59975564",
"0.5933314",
"0.592045",
"0.5919477",
"0.59166026",
"0.58718836",
"0.5849038",
"0.58320445",
"0.58299315",
"0.58220553",
"0.5803571",
"0.5792244",
"0.5790359",
"0.5773344",
"0.5746825",
"0.57447124",
"0.5743427",
"0.57281... | 0.0 | -1 |
Hash is defined in such a way that label is not part of the hash value | def hash() source.hash ^ (target.hash+1); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n @label.hash\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash(*) end",
"def hash(key); end",
"def hash_function_label\n hash_function.nil? ? '' : HASH_FUNCTION_LABELS[ hash_function ]... | [
"0.7381467",
"0.6758087",
"0.6758087",
"0.6758087",
"0.6758087",
"0.6758087",
"0.6758087",
"0.6758087",
"0.6723354",
"0.6723043",
"0.6699828",
"0.6678983",
"0.6597963",
"0.6548724",
"0.6527113",
"0.6435636",
"0.64256424",
"0.6381098",
"0.63743436",
"0.6369574",
"0.6361641",
... | 0.6354119 | 22 |
def preencher_usuario nome.set 'Zava' sobrenome.set 'QA' | def preencher_usuario2 (nome, sobrenome, email, endereco, universidade, profissao, genero, idade)
self.nome.set nome
self.sobrenome.set sobrenome
self.email.set email
self.endereco.set endereco
self.universidade.set universidade
self.profissao.set profissao
self.genero.set genero
self.idade.set idade
self.btn_criar.click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preencher\n nome.set 'leticia'\n \n end",
"def set_usuario\n \n end",
"def form_preencher(login, senha)\n txt_username.set login\n txt_password.set senha\n end",
"def modificare_carte\n\t\tputs \">>>MODIFICARE CARTE<<<\"\n\t\tputs \"Introduceti noul titlu: \... | [
"0.8104062",
"0.7520149",
"0.67194074",
"0.66236097",
"0.6530027",
"0.65287757",
"0.6506426",
"0.6504976",
"0.64180017",
"0.63401026",
"0.63242847",
"0.627201",
"0.6246721",
"0.6108808",
"0.6048569",
"0.60371774",
"0.60254025",
"0.60254025",
"0.60215306",
"0.5959677",
"0.5940... | 0.7568297 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_placement
@placement = Placement.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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def placement_params
params.require(:placement).permit(:locale_id, :collection_id, :title, :msg, :radius)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
GET /yas_tasks GET /yas_tasks.json | def index
@yas_tasks = YasTask.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end",
"def get_user_tasks\n render json: get_current_user.tasks\n end",
"def tasks\n @todos = Todo.all\n render json: @todos\n end",
"def index\n render json: {\n tasks: tasks.map(&:to_hash)\n }\n end",
"... | [
"0.7450629",
"0.70757604",
"0.7029156",
"0.7005986",
"0.69949627",
"0.69549525",
"0.6939916",
"0.685488",
"0.67882323",
"0.6779082",
"0.676842",
"0.6759684",
"0.67526793",
"0.6737415",
"0.67307234",
"0.67064184",
"0.6688523",
"0.6686207",
"0.66693074",
"0.66626835",
"0.665318... | 0.7662466 | 0 |
GET /yas_tasks/1 GET /yas_tasks/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @yas_tasks = YasTask.all\n end",
"def getTask(response)\r\n\t\t\t\ttasks_json = JSON.parse response\r\n\t\t\t\ttasks_array = tasks_json[\"tasks\"]\r\n\t\t\t\treturn jsonToTask(tasks_array[0])\r\n\t\t\tend",
"def task(name)\n get \"#{base_url}/tasks/#{name}\"\n end",
"def tasks\n ... | [
"0.7441774",
"0.7089856",
"0.7049392",
"0.70376277",
"0.70280886",
"0.6932154",
"0.6914484",
"0.69026726",
"0.68973106",
"0.6859786",
"0.6829119",
"0.6707517",
"0.67046595",
"0.6704328",
"0.66644245",
"0.6663766",
"0.66600835",
"0.6651453",
"0.6648422",
"0.66321766",
"0.66266... | 0.0 | -1 |
POST /yas_tasks POST /yas_tasks.json | def create
@yas_task = YasTask.new(yas_task_params)
respond_to do |format|
if @yas_task.save
format.html { redirect_to @yas_task, notice: 'Yas task was successfully created.' }
format.json { render :show, status: :created, location: @yas_task }
else
format.html { render :new }
format.json { render json: @yas_task.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_task(options = {})\n request(:post, \"tasks\", options)\n end",
"def add task_details\n\n #prepare payload\n now = Time.now.to_i \n defaults = {\n \"method\" => \"task.save\",\n \"id\" => UUID.generate,\n \"type\" => 0,\n \"_type\" => now,\n \"state\" =... | [
"0.6779021",
"0.6735027",
"0.6720806",
"0.6621785",
"0.6569465",
"0.6552298",
"0.65324897",
"0.64810157",
"0.64806736",
"0.6435763",
"0.64259386",
"0.63720775",
"0.63428545",
"0.6330483",
"0.6312587",
"0.6264551",
"0.6263937",
"0.6235873",
"0.6234906",
"0.62267315",
"0.622369... | 0.7416245 | 0 |
PATCH/PUT /yas_tasks/1 PATCH/PUT /yas_tasks/1.json | def update
respond_to do |format|
if @yas_task.update(yas_task_params)
format.html { redirect_to @yas_task, notice: 'Yas task was successfully updated.' }
format.json { render :show, status: :ok, location: @yas_task }
else
format.html { render :edit }
format.json { render json: @yas_task.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\r\n @tasks = Task.find(params[:id])\r\n if @tasks.update(task_params)\r\n render json: @tasks\r\n else\r\n render json: @tasks.errors, status: :unprocessable_entity\r\n end\r\n end",
"def update\n respond_to do |format|\n if @api_task.update(a... | [
"0.7250327",
"0.7124831",
"0.7100243",
"0.7100243",
"0.6994408",
"0.69573075",
"0.6907991",
"0.6801403",
"0.67081785",
"0.6692608",
"0.66906446",
"0.6677974",
"0.6655464",
"0.66549826",
"0.66538376",
"0.664677",
"0.66466624",
"0.6638409",
"0.66382855",
"0.6612962",
"0.6606117... | 0.7393462 | 0 |
DELETE /yas_tasks/1 DELETE /yas_tasks/1.json | def destroy
@yas_task.destroy
respond_to do |format|
format.html { redirect_to yas_tasks_url, notice: 'Yas task was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_task id\n request :delete, \"tasks/#{id}\"\n nil\n end",
"def destroy\n @task.destroy\n \n head :no_content\n end",
"def destroy\n @api_task.destroy\n respond_to do |format|\n format.html { redirect_to api_tasks_url, notice: 'Task was successfully destroyed.' }\n ... | [
"0.72282904",
"0.717907",
"0.71728575",
"0.71278244",
"0.71278244",
"0.71278244",
"0.71278244",
"0.71278244",
"0.71278244",
"0.7107261",
"0.7105942",
"0.70982414",
"0.7094057",
"0.7086178",
"0.70811653",
"0.7074088",
"0.7074088",
"0.7074088",
"0.7074088",
"0.7074088",
"0.7074... | 0.75793326 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_yas_task
@yas_task = YasTask.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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def yas_task_params
params.require(:yas_task).permit(:Period, :Hours, :Description)
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
GET /posts GET /posts.json The index action retrieves all posts from the database. | def index
@posts = Post.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html ... | [
"0.8373813",
"0.8277642",
"0.8230541",
"0.82063377",
"0.82063377",
"0.82063377",
"0.8201059",
"0.8201059",
"0.81860703",
"0.81841433",
"0.81687635",
"0.80887526",
"0.8083779",
"0.8010096",
"0.7989269",
"0.7960652",
"0.7960652",
"0.7960652",
"0.7960652",
"0.7957116",
"0.794063... | 0.77733153 | 73 |
GET /posts/1 GET /posts/1.json The show action retrieves a single post from the database, but the show method contains no code at all. This method relies on the Rails before_action [TOP OF THIS PAGE]. | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n # when you go to http://localhost:3000/posts/1, rails interprets this\n # as a call to the show action for the resource and passes 1 to the \n # :id paramater. Using this blog app you can do that by clicking the \n # show link for a post on the index page.\n\n @post = Post.find(params[:id... | [
"0.7807705",
"0.778252",
"0.7737601",
"0.77308494",
"0.77176815",
"0.76870596",
"0.76853454",
"0.7680877",
"0.76696247",
"0.7668444",
"0.7659018",
"0.7647368",
"0.7636859",
"0.76232743",
"0.7608025",
"0.759612",
"0.759612",
"0.759612",
"0.759612",
"0.759612",
"0.759612",
"0... | 0.0 | -1 |
GET /posts/1/edit The edit action displays a form for editing an existing post. This form uses the set_post method [BOTTOM OF THIS PAGE]. | def edit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit # Showing edit form\n @post = Post.find(params[:id])\n end",
"def edit\n \t\t@post = Post.find(params[:id])\n\tend",
"def edit\n\t\t@post = Post.find(params[:id])\n\tend",
"def edit\n\t\t@post = Post.find(params[:id])\n\tend",
"def edit\r\n @post = Post.find(params[:id])\r\n end",
"def ... | [
"0.8683253",
"0.8577379",
"0.8572364",
"0.8572364",
"0.85393214",
"0.8534716",
"0.8485054",
"0.8485054",
"0.8485054",
"0.8415185",
"0.84071356",
"0.84071356",
"0.84071356",
"0.84071356",
"0.84071356",
"0.84071356",
"0.84071356",
"0.83886886",
"0.8375564",
"0.83717865",
"0.836... | 0.0 | -1 |
POST /posts POST /posts.json The create method is responsible for creating a post using the params from the new post form. | def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n title = params[:title]\n body = params[:body]\n\n @post = current_user.posts.create(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n ... | [
"0.8402929",
"0.822754",
"0.8032365",
"0.8026727",
"0.7958874",
"0.795562",
"0.79548115",
"0.79138106",
"0.7842574",
"0.7829636",
"0.7810923",
"0.7780225",
"0.77802235",
"0.7779257",
"0.7767285",
"0.7764211",
"0.7764211",
"0.7744895",
"0.7706539",
"0.7698667",
"0.7667274",
... | 0.76252615 | 48 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json The update method is similiar to the create method but it checks the | def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.json { render :show, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n respond_with post.update(params[:id], params[:post])\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n for... | [
"0.74958557",
"0.7319223",
"0.72980773",
"0.7175294",
"0.71109134",
"0.70941204",
"0.70905083",
"0.70850396",
"0.70712686",
"0.706516",
"0.70471126",
"0.7038426",
"0.70089126",
"0.69942164",
"0.69768584",
"0.6972805",
"0.6966598",
"0.6955234",
"0.69538385",
"0.69446295",
"0.6... | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json The destroy method destroys the post and redirects user back to the index page. | def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n # The destroy method of an Active Record model instance \n # ... | [
"0.8744745",
"0.8613685",
"0.86086565",
"0.8608017",
"0.8586221",
"0.8586221",
"0.8586221",
"0.8586221",
"0.85656214",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
"0.8557876",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. The set_post method calls the post.find method to retrieve the post with an id corresponding to a parameter passed to the controller. | def set_post
@post = Post.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_post\r\n @post = Post.find(params[:post_id])\r\n end",
"def set_post\n @post = Post.find(params[:post_id])\n end",
"def set_post\n @post = Post.find(params[:post_id])\n end",
"def set_post\n @post = Post.find(params[:post_id])\n end",
"def set_post\n @post = Pos... | [
"0.7286657",
"0.72660154",
"0.72660154",
"0.72660154",
"0.72660154",
"0.72660154",
"0.72481567",
"0.72425634",
"0.72425634",
"0.722536",
"0.722536",
"0.72145087",
"0.71990716",
"0.71990716",
"0.7177812",
"0.71760285",
"0.717137",
"0.71648055",
"0.7158981",
"0.7158981",
"0.715... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def post_params
params.require(:post).permit(:title, :author, :body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
num the integer Examples next_number(6) => 7 Returns the next integer | def next_number(num)
return num + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_number(num)\n num + 1\n end",
"def next_num(num)\n return num + 1\nend",
"def next_number(number)\n output = number + 1\n return output\nend",
"def next_number(number)\n number.to_i\n return number+=1\nend",
"def next_number(num)\n return num += 1\nend",
"def next_number(nu... | [
"0.83968395",
"0.8000112",
"0.77918476",
"0.77909803",
"0.77592695",
"0.7737653",
"0.7497092",
"0.7441813",
"0.6922521",
"0.6801489",
"0.67735636",
"0.6742392",
"0.66786706",
"0.65459216",
"0.6437422",
"0.63978124",
"0.63392735",
"0.63207304",
"0.62648475",
"0.6238774",
"0.62... | 0.79223335 | 5 |
Set the default values | def set_defaults
# puts 'call set_defaults!'
# Set status to default value
self.status ||= "uploaded"
self.last_parsed_line ||= 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n end",
"def set_defaults\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_default\n end",
"def set_default_values\n self.class.d... | [
"0.85495275",
"0.85495275",
"0.8486815",
"0.8486815",
"0.8486815",
"0.8486815",
"0.8486815",
"0.8486815",
"0.80636317",
"0.8004",
"0.80020106",
"0.7976188",
"0.790936",
"0.7892618",
"0.7892618",
"0.7890477",
"0.7890477",
"0.7890477",
"0.7890477",
"0.7890477",
"0.7890477",
"... | 0.0 | -1 |
Create options necessary for readin, parsing, storing | def make_options
options = Hash.new
options[:file_type] = self.file_type
options[:filepath] = self.file.path
options[:compressed] = self.compressed
options[:device_id] = self.device_id
options[:file_ext] = File.extname(self.file.path) # Create extname lile ".gz"
options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_options; end",
"def parse_options; end",
"def setup_options\n @parser.banner = BANNER\n\n @parser.on('-V', '--version', 'display version and exit') { show_version }\n @parser.on('-h', '--help', 'display help and exit') { show_help }\n @parser.on('-f', '--files=[file1.txt file2.txt ...]', ... | [
"0.7072255",
"0.7072255",
"0.70286375",
"0.68665165",
"0.68286467",
"0.676442",
"0.67574435",
"0.6666738",
"0.6618566",
"0.6617355",
"0.66091275",
"0.6606197",
"0.65976924",
"0.65615845",
"0.65455675",
"0.6531794",
"0.6530392",
"0.65181863",
"0.65139157",
"0.65042406",
"0.648... | 0.66752344 | 7 |
This method will read the file from storage, parse the file, store the file in the database. | def parse
logger.debug "Reading stoage file from: #{self.file.path}"
if self.status != 'finished'
last_parsed_line = self.last_parsed_line
# make_options
begin
# Match the proper parser and build options
case self.file_type
when "1"
@parser = Wms::Input::Filetype1
else
raise "Undefined storage type #{file_type}"
end
# when "wifilocation"
# @parser = Wms::Input::AndroidWifiLocation
# when "sensor"
# @parser = Wms::Input::AndroidSensor
# when "audio"
# raise "Not Supported yet storage type #{file_type}"
# else
# raise "Undefined storage type #{file_type}"
# end
@processor = @parser.new
options = make_options
@processor.register(options=options)
@processor.run do |data|
begin
create_event data
rescue Exception => e
logger.error "ERROR #{self.class.name}: #{e} for #{data}"
end
last_parsed_line += 1
end
self.last_parsed_line = last_parsed_line
self.status = "finished"
self.save
rescue Exception => e
logger.error "ERROR: [#{e}]"
self.last_parsed_line = last_parsed_line
self.status = "error"
self.save
end # end begin
end #end if self.status != 'finished'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform\n check_file # checks if the file uploaded is valid\n save_file_entry # Uploads the file to the server and saves a entry to database\n end",
"def import_file(file)\n records = IO.readlines(file)\n Vocabulary::DB.transaction do\n records.each { |record| string_processing record... | [
"0.6283027",
"0.6163318",
"0.6008698",
"0.5950042",
"0.5909342",
"0.58177",
"0.5780407",
"0.5771151",
"0.5761638",
"0.57520425",
"0.5693356",
"0.5683303",
"0.5673945",
"0.56555355",
"0.56294143",
"0.56261045",
"0.56209606",
"0.56128496",
"0.56089085",
"0.5595765",
"0.5577347"... | 0.639762 | 0 |
end parse method Create an event an update it into database | def create_event(doc)
attach_user_id doc
attach_storage_id doc
new_event = Event.new(doc)
new_event.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_events\n end",
"def store_event_in_db(event_hash)\n newEvent = Event.new(name: event_hash[\"name\"], date: event_hash[\"dates\"][\"start\"][\"localDate\"], city: event_hash[\"_embedded\"][\"venues\"][0][\"city\"][\"name\"], state: event_hash[\"_embedded\"][\"venues\"][0][\"state\"][\"name\"], venu... | [
"0.7284981",
"0.71897197",
"0.7121182",
"0.7100005",
"0.69776356",
"0.6873525",
"0.6865513",
"0.6809405",
"0.6789909",
"0.67147774",
"0.6700631",
"0.66417",
"0.65964943",
"0.65832376",
"0.6575074",
"0.6511161",
"0.64968425",
"0.6476672",
"0.6462386",
"0.64504725",
"0.6449606"... | 0.6592917 | 13 |
This method will insert the attribute "user_id" to the document | def attach_user_id(doc)
doc["user_id"] = self.user.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_user_id(user)\n\t\t@id = user\n\tend",
"def generate_user_id\n # ap(generate_user_id: {})\n @user_data.insert({}).to_s\n end",
"def user_id=(value)\n @user_id = value\n end",
"def user_id=(value)\n @user_id = value\n end",
"def user... | [
"0.7023673",
"0.67776847",
"0.6625366",
"0.6625366",
"0.6625366",
"0.6625366",
"0.6625366",
"0.6625366",
"0.65546453",
"0.61878914",
"0.61833435",
"0.6182133",
"0.61723006",
"0.6168599",
"0.6146062",
"0.6146062",
"0.6146062",
"0.6146062",
"0.6146062",
"0.6146062",
"0.6146062"... | 0.82438123 | 0 |
Delete all events that are correlated with this user. | def delete_all_events
doc = {}
attach_user_id doc
attach_storage_id doc
Event.delete_all(doc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_all_confirmation_events\n ConfirmationEvent.find_each(&:destroy)\n end",
"def destroy_all\n unless current_user.nil?\n #current_user.events.delete_all # why this line doesn't work on production, seriously?\n Event.delete_all(user_id: current_user.id)\n redirect_to :back, notice:... | [
"0.6940655",
"0.6612969",
"0.65215933",
"0.6506648",
"0.6498977",
"0.64210093",
"0.62988055",
"0.6137477",
"0.6125428",
"0.61034703",
"0.601386",
"0.59992546",
"0.5994362",
"0.59858024",
"0.5985379",
"0.59284",
"0.59118146",
"0.5903665",
"0.59012467",
"0.58800846",
"0.5865212... | 0.71124905 | 0 |
GET /remote_image_contents GET /remote_image_contents.xml | def index
@remote_image_contents = RemoteImageContent.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @remote_image_contents }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @remote_image_content = RemoteImageContent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @remote_image_content }\n end\n end",
"def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n ... | [
"0.74942005",
"0.68939143",
"0.6841543",
"0.67660767",
"0.65532637",
"0.6466284",
"0.64611447",
"0.64579946",
"0.6438887",
"0.63694483",
"0.6285649",
"0.6260744",
"0.62137806",
"0.6191742",
"0.6161053",
"0.6132051",
"0.61288226",
"0.6121208",
"0.611502",
"0.61131954",
"0.6070... | 0.7575609 | 0 |
GET /remote_image_contents/1 GET /remote_image_contents/1.xml | def show
@remote_image_content = RemoteImageContent.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @remote_image_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @remote_image_contents = RemoteImageContent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @remote_image_contents }\n end\n end",
"def get_image(image_id)\n request(\n :expects => 200,\n :method => 'GE... | [
"0.76422817",
"0.6971092",
"0.6868825",
"0.65804327",
"0.6448596",
"0.63769525",
"0.63741255",
"0.633257",
"0.6322017",
"0.6264257",
"0.6206901",
"0.62027025",
"0.61918926",
"0.6169182",
"0.6147171",
"0.6147171",
"0.6147171",
"0.612711",
"0.61097",
"0.61051923",
"0.60891086",... | 0.75503147 | 1 |
GET /remote_image_contents/new GET /remote_image_contents/new.xml | def new
@remote_image_content = RemoteImageContent.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @remote_image_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @console_image }\n end\n end",
"def index\n @remote_image_contents = RemoteImageContent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xm... | [
"0.6851879",
"0.6843239",
"0.67981607",
"0.67880684",
"0.6736723",
"0.6706929",
"0.6612324",
"0.6585639",
"0.653127",
"0.6467184",
"0.64162534",
"0.6341941",
"0.63053566",
"0.6298041",
"0.6290647",
"0.6290102",
"0.6289646",
"0.6289646",
"0.62454563",
"0.6219787",
"0.62168115"... | 0.7872885 | 0 |
POST /remote_image_contents POST /remote_image_contents.xml | def create
@remote_image_content = RemoteImageContent.new(params[:remote_image_content])
order_num = @strategy_guide.strategy_items.size || 0
@strategy_item = @strategy_guide.strategy_items.build(:order => order_num, :phase => 0)
if @remote_image_content.save and @strategy_item.content = @remote_image_content and @strategy_item.save
redirect_to(strategy_items_strategy_guide_path(@strategy_guide))
else
@strategy_items = @strategy_guide.strategy_items
render :action => "strategy_guides/strategy_items"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @remote_image_content = RemoteImageContent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @remote_image_content }\n end\n end",
"def post_file_to_server id, content, size, page_count, extension = \".jpg\"\n\n @s.execute_file_post @s.url_f... | [
"0.66587126",
"0.6561751",
"0.6385976",
"0.6155711",
"0.61211115",
"0.6099951",
"0.6067045",
"0.60665786",
"0.5962093",
"0.5936126",
"0.59352595",
"0.59206986",
"0.59124917",
"0.5892254",
"0.58834",
"0.57422054",
"0.5706526",
"0.5660139",
"0.56132543",
"0.5601374",
"0.5598394... | 0.0 | -1 |
PUT /remote_image_contents/1 PUT /remote_image_contents/1.xml | def update
@remote_image_content = RemoteImageContent.find(params[:id])
if @remote_image_content.update_attributes(params[:remote_image_content])
redirect_to(strategy_items_strategy_guide_path(@strategy_guide))
else
@strategy_items = @strategy_guide.strategy_items
render :action => "strategy_guides/strategy_items"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @remote_image_content = RemoteImageContent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @remote_image_content }\n end\n end",
"def push_remote_image_1_to_server\n if image_1_google_main.present?\n remote_image_1_u... | [
"0.6030203",
"0.6017343",
"0.59742916",
"0.596679",
"0.5960971",
"0.59575766",
"0.5926405",
"0.5897461",
"0.5887427",
"0.58860344",
"0.5867696",
"0.58573025",
"0.5823364",
"0.581211",
"0.57877946",
"0.5731735",
"0.5724348",
"0.57170665",
"0.5714332",
"0.56834334",
"0.56547534... | 0.5718703 | 17 |
DELETE /remote_image_contents/1 DELETE /remote_image_contents/1.xml | def destroy
@remote_image_content = RemoteImageContent.find(params[:id])
@remote_image_content.destroy
respond_to do |format|
format.html { redirect_to(remote_image_contents_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @image_path = ImagePath.find(params[:id])\n @image_path.destroy\n\n respond_to do |format|\n format.html { redirect_to(image_paths_url) }\n format.xml { head :ok }\n end\n end",
... | [
"0.69904953",
"0.6864226",
"0.6810399",
"0.6798015",
"0.6773507",
"0.6773507",
"0.6773507",
"0.6762407",
"0.67533684",
"0.6737689",
"0.6732015",
"0.66882396",
"0.6682068",
"0.6644984",
"0.66445696",
"0.66440415",
"0.66372067",
"0.66007566",
"0.65998054",
"0.6585366",
"0.65812... | 0.77104145 | 0 |
PATCH/PUT /coupons/1 PATCH/PUT /coupons/1.json | def update
respond_to do |format|
if @coupon.nil?
format.html {
flash.now[:alert] = I18n.t('coupons.update.coupon_not_found')
render action: 'find'
}
format.json { render json: @coupon.errors, status: :not_found }
else
if current_user.use_coupon(@coupon)
format.html { redirect_to root_path, notice: I18n.t('coupons.update.coupon_use_success') }
format.json { head :no_content }
else
format.html {
flash.now[:alert] = I18n.t('coupons.update.coupon_not_available')
render action: 'find'
}
format.json { render json: @coupon.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @coupone.update(coupone_params)\n format.html { redirect_to admin_coupones_path, notice: 'Coupone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render j... | [
"0.70729274",
"0.69253284",
"0.6699822",
"0.6478899",
"0.64782244",
"0.6358536",
"0.6334699",
"0.6314795",
"0.6314795",
"0.630045",
"0.6287655",
"0.62539",
"0.621703",
"0.61170834",
"0.61170834",
"0.6101269",
"0.609336",
"0.6081077",
"0.60653317",
"0.6057695",
"0.59785813",
... | 0.5986614 | 20 |
NOTE: `update_columns` won't run validations nor update the `updated_at` timestamp. This is what we want here, thus we disable Rubocop for this migration. rubocop:disable Rails/SkipsModelValidations | def up
ActiveRecord::Base.transaction do
migrate_cause
migrate_messages
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_columns(columns)\n @columns_updated ||= DeprecatedColumnsUpdated.new(columns) # SEQUEL5: Remove\n _update(columns) unless columns.empty?\n end",
"def _update_without_checking(columns)\n if use_prepared_statements_for?(:update)\n _set_prepared_statement_server(mo... | [
"0.7402798",
"0.71005285",
"0.70166385",
"0.70166385",
"0.69251835",
"0.6901736",
"0.6776597",
"0.6665259",
"0.66643053",
"0.6530157",
"0.63285255",
"0.63285255",
"0.6196152",
"0.6185266",
"0.60968393",
"0.6088858",
"0.6071337",
"0.6052452",
"0.6032808",
"0.6032808",
"0.60280... | 0.0 | -1 |
the current job (see Rufus::Scheduler) Initially +time+ is set to :forever and +timed_out+ to false. There are no subscribers at the beginning. | def initialize
@time = :forever
@timed_out = false
@subscribers = Array.new
@scheduler = Rufus::Scheduler.start_new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job\n @job\n end",
"def job\n @job\n end",
"def current_job\n return @job_current\n end",
"def job\n @job\n end",
"def job \n @job\n end",
"def wait_for_job\n\t\tloop {\n\t\t\tputs \":: #{self.feedback['job_desc']}: #{self.job_state}\" if ENV['LKP_VERBOSE']\n\n\t... | [
"0.6684499",
"0.6684499",
"0.6585506",
"0.6509896",
"0.64861137",
"0.6239542",
"0.6091317",
"0.6074452",
"0.60558033",
"0.59983134",
"0.59380233",
"0.5912877",
"0.5900935",
"0.5888122",
"0.5888122",
"0.58167344",
"0.5677862",
"0.5658793",
"0.56436783",
"0.56387484",
"0.560223... | 0.5557322 | 24 |
Adds an object to this timed event. If the timed event reaches the specified +time+ this object performs his timed_out method Each object that shall be time must implement a timed_out method. A TimedEvent can have multiple subscribers. +object_to_time+:: object to be timed by this TimedEvent | def subscribe(object_to_time)
fail "Should have method #timed_out implemented" unless object_to_time.respond_to?(:timed_out)
@subscribers.push(object_to_time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_oneshot_at exact_time, timer_proc\n return nil unless timer_proc\n\n timer = Timer.new :timers => self, :exact_time => exact_time, :periodical => false, :timer_proc => timer_proc\n add timer\n timer\n end",
"def insert(timer)\n @timers.add(timer)\n end",
"def add(time)\n n... | [
"0.56954503",
"0.5529514",
"0.5501798",
"0.5448506",
"0.53937334",
"0.5383025",
"0.5288802",
"0.51845276",
"0.5159392",
"0.5153026",
"0.51368695",
"0.51127",
"0.50972456",
"0.50972456",
"0.50940067",
"0.50750846",
"0.50694776",
"0.5067055",
"0.5049909",
"0.50392514",
"0.49953... | 0.7863374 | 0 |
Reschedules the time when the method timed_out is called on all subscribers . To set the time to :forever use unschedule +time+:: New time to be scheduled. Can be Time (Can't be nil) | def reschedule(time)
"missing time" if time.nil?
time_rufus = Rufus.to_datetime time
@job.unschedule unless (self.time == :forever)
@job = @scheduler.at time_rufus.to_s do
@timed_out = true
@subscribers.each { |object| object.timed_out }
end
@time = time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reschedule(time)\n assert_kind_of(Time, time)\n fail \"Time should not be in past\" if time < Time.now\n\n time = Rufus.to_datetime time\n\n self.job.unschedule\n\n self.job = self.scheduler.at time.to_s do\n self.timed_out = true\n self.subscribers.each { |object| object... | [
"0.81462675",
"0.6876034",
"0.6627097",
"0.6383293",
"0.62995017",
"0.6255682",
"0.61676466",
"0.6081834",
"0.5993231",
"0.58813596",
"0.58601356",
"0.5828668",
"0.5828668",
"0.58213556",
"0.5665811",
"0.56507283",
"0.5631778",
"0.555899",
"0.5517288",
"0.54656154",
"0.546168... | 0.82911885 | 0 |
Removes the specified time, so that the TimedEvent never triggers(unless a new time is set in reschedule(time)) Sets +time+ to :forever and +timed_out+ to false | def unschedule
if (self.time != :forever)
@job.unschedule
@time = :forever
@timed_out = false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reschedule(time)\n assert_kind_of(Time, time)\n fail \"Time should not be in past\" if time < Time.now\n\n time = Rufus.to_datetime time\n\n self.job.unschedule\n\n self.job = self.scheduler.at time.to_s do\n self.timed_out = true\n self.subscribers.each { |object| object... | [
"0.7640371",
"0.738225",
"0.59793",
"0.596501",
"0.59109443",
"0.5788694",
"0.57340497",
"0.5682071",
"0.56484306",
"0.5631988",
"0.56123865",
"0.55643463",
"0.5497291",
"0.5474398",
"0.54477143",
"0.5386039",
"0.53721553",
"0.53684306",
"0.5364515",
"0.53531826",
"0.5337326"... | 0.6716559 | 2 |
Checks if an event is scheduled Returns true if it is. False otherwise. | def scheduled?
@time != :forever
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_scheduling?\n\t\t!self.scheduled_at.blank?\n\tend",
"def scheduled?\n status == Status[:scheduled]\n end",
"def scheduled?\n @current_state == Psc::ScheduledActivity::SCHEDULED\n end",
"def scheduled?(starting, ending)\n schedule.scheduled?(self, starting, ending)\n end",
"def schedu... | [
"0.8067153",
"0.78356063",
"0.7794429",
"0.77044076",
"0.7512573",
"0.7512573",
"0.7512573",
"0.7501611",
"0.72971666",
"0.709332",
"0.7036299",
"0.702125",
"0.70092684",
"0.69636905",
"0.6946452",
"0.6930062",
"0.69122154",
"0.68595254",
"0.6812932",
"0.6733684",
"0.67089045... | 0.7626399 | 4 |
Returns an array of all subscribers of this timed event. Changes on this array don't affect the TimedEvent | def subscribers
@subscribers.clone
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subscribers\n @subscriptions = subscribers(@nodename)\n end",
"def subscribers\n store[name].map { |r| r.contents } \n end",
"def subscribers_for(event)\n @subscribers.select { |subscriber| subscriber.subscribed_to?(event) }\n end",
"def default_event_subscriptions()\n... | [
"0.68370914",
"0.6700857",
"0.6600524",
"0.63353324",
"0.6248245",
"0.62397605",
"0.62175053",
"0.6196321",
"0.61712897",
"0.6128447",
"0.60650784",
"0.60606885",
"0.60233676",
"0.5977289",
"0.5964978",
"0.5958904",
"0.59416574",
"0.5940823",
"0.5930793",
"0.5913099",
"0.5871... | 0.706704 | 0 |
TODO: This can be cleaned up. It's used in _header.html.erb to determine whether or not the 'Edit Profile' link/button should show up. | def belongs_to_current_profile_user?
!!(@current_user.id == @user.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @help = PageContent.find_by_name(\"profile-help\") # \"What to include in profile\" Content\n @presenter = find_presenter\n @presenter_profile = @presenter.presenter_profile\n if @presenter_profile.nil?\n redirect_to new_presenter_profile_path(@presenter)\n end\n #displays current... | [
"0.70208037",
"0.6701995",
"0.6644052",
"0.66131794",
"0.6558387",
"0.6551359",
"0.6551018",
"0.65484214",
"0.6470653",
"0.6441204",
"0.64285046",
"0.64285046",
"0.6386825",
"0.6351806",
"0.6194968",
"0.6194968",
"0.61927086",
"0.6175267",
"0.60865086",
"0.60685873",
"0.60496... | 0.0 | -1 |
Give us the title of the current page | def get_page_name
if controller_name == "profiles"
"About"
else
controller_name.titleize
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n @global_page.title\n end",
"def page_title\n page.title\n end",
"def page_title( this_title = nil )\n content_for( :title ) { \"#{ SITE_ID }: #{ this_title.nil? ? I18n.t( controller.controller_name + '.title' ) : this_title }\" }\n end",
"def pageTitle\n (self || ... | [
"0.8446392",
"0.84156287",
"0.83483464",
"0.8291638",
"0.82796127",
"0.8253785",
"0.81935376",
"0.8176769",
"0.8166907",
"0.8166126",
"0.81454754",
"0.8125917",
"0.8117434",
"0.81105596",
"0.81064856",
"0.81014043",
"0.80880266",
"0.808356",
"0.80616504",
"0.8049361",
"0.8043... | 0.0 | -1 |
QUESTION: While implimenting view testing I discovered that the controller_name changed to "test". This resulted in me needing to create some new logic to show the 'Edit Profile' button on the profile pages. | def profile_show_page?
controller_name == "profiles"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ID_25837_edit_profile_name\n login_as_user1\n go_to_edit_profile_page\n verify_user_name_populated \"Jame Smith\"\n end",
"def test_controller_name_and_action_name_for_2_dot_ooh_views\n rp = RailsPath.new(FIXTURE_PATH + '/app/views/users/new.html.erb')\n assert_equal \"users\", rp.contro... | [
"0.669008",
"0.66528326",
"0.6627453",
"0.6591978",
"0.65314096",
"0.6402314",
"0.6287984",
"0.62798935",
"0.62798935",
"0.6259469",
"0.6255595",
"0.6198829",
"0.61980355",
"0.61973655",
"0.6192892",
"0.61497986",
"0.61456496",
"0.61204135",
"0.6120201",
"0.6120201",
"0.61176... | 0.6083186 | 27 |
Using the Ruby language, have the function WordCount(str) take the str string parameter being passed and return the number of words the string contains (ie. "Never eat shredded wheat" would return 4). Words will be separated by single spaces. Sample Test Cases Solution (1) : | def WordCount(string)
string.scan(/\w+/).count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def WordCount(str)\n str.split(\" \").count\nend",
"def wordCounter(inputString)\n inputString.scan(/\\w+/).length\nend",
"def WordCount(str)\n\twords = str.split(\" \").count\n\treturn words\nend",
"def word_count(string)\n words = string.split(/\\W+/) #split on any non-word char. Thanks Rubular.com!\n ... | [
"0.86262435",
"0.8536214",
"0.85143095",
"0.8447824",
"0.8430885",
"0.83786446",
"0.8281264",
"0.82640064",
"0.82058007",
"0.82027924",
"0.8172368",
"0.81524396",
"0.81405926",
"0.808723",
"0.80176157",
"0.80149597",
"0.7968163",
"0.7967575",
"0.789884",
"0.7888437",
"0.78671... | 0.8390933 | 5 |
GET /eventos GET /eventos.json | def index
@eventos = Evento.all.page(params[:page]).per(PER_PAGE)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end",
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON... | [
"0.7332292",
"0.72978824",
"0.72160923",
"0.7209713",
"0.7027631",
"0.7014996",
"0.6944647",
"0.69200736",
"0.68932575",
"0.68896455",
"0.6877577",
"0.687057",
"0.6852186",
"0.68242764",
"0.6820427",
"0.6804404",
"0.6783208",
"0.67627424",
"0.6756405",
"0.67481333",
"0.674741... | 0.64529437 | 61 |
GET /eventos/1 GET /eventos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end",
"def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n ... | [
"0.7082675",
"0.7053356",
"0.7019002",
"0.69375014",
"0.693692",
"0.69229734",
"0.69124365",
"0.6890872",
"0.6832607",
"0.68245465",
"0.68020225",
"0.67860943",
"0.6785939",
"0.6783269",
"0.6771234",
"0.6766057",
"0.6749105",
"0.6707954",
"0.6701155",
"0.6686871",
"0.6683968"... | 0.0 | -1 |
POST /eventos POST /eventos.json | def create
@evento = Evento.new(evento_params)
respond_to do |format|
if @evento.save
format.html { redirect_to @evento, notice: 'Evento criado com sucesso.' }
format.json { render :show, status: :created, location: @evento }
else
format.html { render :new }
format.json { render json: @evento.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_event event, data={}\n data[:event] = event\n post '/event', data\n end",
"def create\n megam_rest.post_event(to_hash)\n end",
"def create\n request.format = :json\n event = params[:event]\n ActiveSupport::Notifications.instrument(\"closeio.#{event[:ac... | [
"0.69481313",
"0.6830814",
"0.67670804",
"0.6718989",
"0.6630041",
"0.6628074",
"0.65233314",
"0.6481014",
"0.6457532",
"0.64144266",
"0.63871145",
"0.6385129",
"0.63688326",
"0.6348284",
"0.63439935",
"0.6330729",
"0.6320951",
"0.6320951",
"0.62744385",
"0.6270619",
"0.62552... | 0.6201186 | 23 |
PATCH/PUT /eventos/1 PATCH/PUT /eventos/1.json | def update
respond_to do |format|
if @evento.update(evento_params)
format.html { redirect_to @evento, notice: 'Evento atualizado com sucesso.' }
format.json { render :show, status: :ok, location: @evento }
else
format.html { render :edit }
format.json { render json: @evento.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(j... | [
"0.7073407",
"0.6971425",
"0.68557817",
"0.6794632",
"0.67642313",
"0.6742171",
"0.6717988",
"0.67032874",
"0.66991115",
"0.667787",
"0.66714174",
"0.6650794",
"0.6650794",
"0.66453815",
"0.6617517",
"0.66049904",
"0.65946877",
"0.6587859",
"0.6586789",
"0.65823996",
"0.65760... | 0.0 | -1 |
DELETE /eventos/1 DELETE /eventos/1.json | def destroy
@evento.destroy
respond_to do |format|
format.html { redirect_to eventos_url, notice: 'Evento apagado com sucesso.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_... | [
"0.74668354",
"0.74270344",
"0.74270344",
"0.74270344",
"0.7418892",
"0.7257821",
"0.71920234",
"0.71869063",
"0.7166582",
"0.7157072",
"0.7155662",
"0.71538675",
"0.7145266",
"0.7144221",
"0.7144221",
"0.7144221",
"0.7144221",
"0.7144221",
"0.7144221",
"0.7144221",
"0.714422... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_evento
@evento = Evento.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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def evento_params
params.require(:evento).permit(:sintoma)
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Method to make post published! Warn: it doesnt check if it is time to publish! Just do that. | def publish_now!
self.status = Micropost::PUBLISHED
self.published_at = self.publish_at
save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish_now!\n puts 'publish noew...'\n self.status = Post::PUBLISHED\n self.published_at = self.publish_at\n save!\n end",
"def publish!\n self.published = true\n if self.respond_to?(:publish_on)\n self.publish_on ||= Date.today\n end\n self.save\n end"... | [
"0.81784546",
"0.8048528",
"0.78215355",
"0.77933055",
"0.77933055",
"0.77794534",
"0.772689",
"0.77207786",
"0.7714595",
"0.77095574",
"0.7689196",
"0.7689196",
"0.7689196",
"0.76853925",
"0.76514685",
"0.76239187",
"0.761804",
"0.76101136",
"0.76018906",
"0.75754094",
"0.75... | 0.76129806 | 17 |
uncrackable code by simply taking each letter of a message and incrementing it by a fixed number, so "abc" by 2 would look like "cde", wrapping around back to "a" when you pass "z". Write a function, `caesar_cipher(str, shift)` which will take a message and an increment amount and outputs the encoded message. Assume lowercase and no punctuation. Preserve spaces. To get an array of letters "a" to "z", you may use `("a".."z").to_a`. To find the position of a letter in the array, you may use `Arrayfind_index`. | def caesar_cipher(str, shift)
alphabet = ('a'..'z').to_a
arr = []
words = str.split
words.each do |word|
newword = ''
word.each_char do |chr|
idx = alphabet.index(chr) + shift
newword += alphabet[idx % alphabet.length]
end
arr << newword
end
arr.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.split('').each do |char|\n if char == \" \"\n encoded_str << \" \"\n next\n end\n\n old_idx = letters.find_index(char)\n new_idx = (old_idx + shift) % letters.count\n\n encoded_str << letters[new_... | [
"0.857758",
"0.8570076",
"0.85590655",
"0.8544224",
"0.85209453",
"0.85032237",
"0.84662735",
"0.8446577",
"0.84434086",
"0.8433163",
"0.8424541",
"0.8413406",
"0.8402679",
"0.83979714",
"0.83849305",
"0.8383016",
"0.83738023",
"0.8365088",
"0.8358994",
"0.83540094",
"0.83382... | 0.8391196 | 14 |
Write a method, `digital_root(num)`. It should Sum the digits of a positive integer. If it is greater than 10, sum the digits of the resulting number. Keep repeating until there is only one digit in the result, called the "digital root". Do not use string conversion within your method. You may wish to use a helper function, `digital_root_step(num)` which performs one step of the process. Example: digital_root(4322) => digital_root(11) => (2) | def digital_root(num)
return num if num < 11
n = num % 10
k = num / 10
ans = n + k
digital_root(ans)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def digital_root(num)\n digits = []\n until num == 0\n digits << num % 10\n num /= 10\n end\n sum = digits.reduce(0, :+)\n sum < 10 ? sum : digital_root(sum)\nend",
"def digital_root(num)\n while num >= 10\n num = digit_sum(digits(num))\n end\n num\nend",
"def digital_root(num)\n return num... | [
"0.8787345",
"0.87406963",
"0.87166363",
"0.8703975",
"0.86864245",
"0.8610953",
"0.85999537",
"0.85987896",
"0.845477",
"0.8446044",
"0.84267884",
"0.8399704",
"0.836633",
"0.8364811",
"0.8345838",
"0.8343507",
"0.8236514",
"0.82030374",
"0.81838644",
"0.81838644",
"0.818386... | 0.8546962 | 8 |
Jumble sort takes a string and an alphabet. It returns a copy of the string with the letters reordered according to their positions in the alphabet. If no alphabet is passed in, it defaults to normal alphabetical order (az). Example: jumble_sort("hello") => "ehllo" jumble_sort("hello", ['o', 'l', 'h', 'e']) => 'ollhe' | def jumble_sort(str, alphabet = nil)
alphabet ||= ('a'..'z').to_a
arr = str.chars
sorting = true
while sorting
sorting = false
arr.each_with_index do |el, i|
next if i == (arr.length - 1)
if alphabet.index(el) > alphabet.index(arr[i+1])
arr[i], arr[i + 1] = arr[i +1], arr[i]
sorting = true
end
end
end
arr.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jumble_sort(str, alphabet = nil)\n alphabet ||= (\"a\"..\"z\").to_a\n\n new_string = str.split(\"\").sort do |letter_a, letter_b|\n alphabet.find_index(letter_a) <=> alphabet.find_index(letter_b)\n end\n new_string.join\nend",
"def jumble_sort(str, alphabet = nil)\n return str.split(\"\").sort.join i... | [
"0.8716778",
"0.86002505",
"0.85803974",
"0.85373616",
"0.85373616",
"0.85373616",
"0.8506492",
"0.8495764",
"0.8443351",
"0.84380877",
"0.8431051",
"0.8388748",
"0.8361555",
"0.82351476",
"0.8063981",
"0.80577826",
"0.6717025",
"0.658386",
"0.6539504",
"0.6474471",
"0.646457... | 0.84638274 | 8 |
Write a method that returns the factors of a number in ascending order. | def factors(num)
arr = []
(1..num).each do |el|
arr << el if num % el == 0
end
arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(num)\n\t((1..num).select {|n| num % n == 0 } ).sort\nend",
"def factors(num)\n factors = []\n for factor in 1..num\n factors << factor if num % factor == 0\n end\n factors.sort\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n ... | [
"0.85758615",
"0.85330606",
"0.84817195",
"0.84817195",
"0.84817195",
"0.8478726",
"0.8478156",
"0.83793145",
"0.83773017",
"0.8347476",
"0.8344957",
"0.834128",
"0.8340562",
"0.83371884",
"0.83362776",
"0.83300614",
"0.8317901",
"0.8310348",
"0.8310105",
"0.83083487",
"0.830... | 0.0 | -1 |
Enter your code here. Read input from STDIN. Print output to STDOUT UnComment lines below for the working solution in HackerRank input = [] counter = 0 a = gets.to_i until counter == a counter += 1 input << gets end | def splitter(input)
input.each do |word|
arr = word.split('').map(&:to_s)
new_arr_even = []
new_arr_odd = []
arr.each_with_index do |item, index|
if index.even?
new_arr_even << item
end
end
arr.each_with_index do |item, index|
if index.odd?
new_arr_odd << item
end
end
str_even = new_arr_even.join('')
str_odd = new_arr_odd.join('')
final = str_even + " " + str_odd
## Unsure of why final adds a \n
## Add gsub to remove it
puts final.gsub(/\n/, "")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_stdin\n n, c = gets.chomp.split(' ').map(&:to_i)\n sushis = []\n n.times do\n sushis << gets.chomp.split(' ').map(&:to_i)\n end\n [n, c, sushis]\nend",
"def main\n input = STDIN.read.each_line.to_a\n input.shift # Discard first line\n while input.any?\n a, b = input.first.split.map{ |i| i... | [
"0.7175846",
"0.66098994",
"0.6444382",
"0.6374928",
"0.6332235",
"0.6317962",
"0.62900436",
"0.62569535",
"0.6235401",
"0.61236006",
"0.6047667",
"0.60422146",
"0.6033559",
"0.60242254",
"0.6015322",
"0.60112387",
"0.6000426",
"0.59828025",
"0.59767413",
"0.59594256",
"0.595... | 0.0 | -1 |
GET /page_layouts GET /page_layouts.json | def index
@page_layouts = PageLayout.order("id ASC")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @page_layouts }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_with @layouts\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html {render :layout => \"layout_1\"}\n format.json { render json: @pages }\n end\n end",
"def render_all_layouts(layouts, payload, info); end",
"def show\n @page_la... | [
"0.68719995",
"0.68597823",
"0.68564785",
"0.6632711",
"0.65897983",
"0.654454",
"0.6518712",
"0.6459813",
"0.64217925",
"0.6372344",
"0.6334747",
"0.6283144",
"0.6235607",
"0.61790353",
"0.6147648",
"0.6111267",
"0.6088816",
"0.60856575",
"0.6065329",
"0.6050327",
"0.6050327... | 0.7667839 | 0 |
GET /page_layouts/1 GET /page_layouts/1.json | def show
@page_layout = PageLayout.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @page_layout }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @page_layouts = PageLayout.order(\"id ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @page_layouts }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html {render :layout => \"layout_1\"}\n ... | [
"0.7669436",
"0.6968923",
"0.6762861",
"0.6683656",
"0.65179455",
"0.63806194",
"0.6345485",
"0.6310529",
"0.6278667",
"0.6269565",
"0.6232592",
"0.62274224",
"0.6213457",
"0.6173224",
"0.6146841",
"0.61274827",
"0.6114519",
"0.5983584",
"0.59306186",
"0.5930287",
"0.5898601"... | 0.7164578 | 1 |
GET /page_layouts/new GET /page_layouts/new.json | def new
@page_layout = PageLayout.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @page_layout }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page_layout = PageLayout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_layout }\n end\n end",
"def new\n\n # check if params[:layout_id] is present\n if not params[:layout_id]\n\n # if not redirect to layout page\n ... | [
"0.7321161",
"0.7261763",
"0.7187311",
"0.7036709",
"0.6994113",
"0.68907046",
"0.6785056",
"0.6747781",
"0.6747781",
"0.6747781",
"0.6747781",
"0.6747781",
"0.6724167",
"0.6717076",
"0.6717038",
"0.6706874",
"0.6685301",
"0.6667871",
"0.66642946",
"0.6649103",
"0.6633541",
... | 0.80773723 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.