repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.new_project_from_template_menu | def new_project_from_template_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " CREATE A NEW JUMPSTART PROJECT FROM AN EXISTING TEMPLATE\n\n".purple
puts " Type a number for the ... | ruby | def new_project_from_template_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " CREATE A NEW JUMPSTART PROJECT FROM AN EXISTING TEMPLATE\n\n".purple
puts " Type a number for the ... | [
"def",
"new_project_from_template_menu",
"puts",
"\"\\n\\n******************************************************************************************************************************************\\n\\n\"",
"puts",
"\" CREATE A NEW JUMPSTART PROJECT FROM AN EXISTING TEMPLATE\\n\\n\"",
".",
"purple",
... | Displays options for the "create a new jumpstart project from an existing template" menu | [
"Displays",
"options",
"for",
"the",
"create",
"a",
"new",
"jumpstart",
"project",
"from",
"an",
"existing",
"template",
"menu"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L210-L219 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.new_project_from_template_options | def new_project_from_template_options
input = gets.chomp.strip.downcase
case
when input.to_i <= JumpStart.existing_templates.count && input.to_i > 0
@template_name = JumpStart.existing_templates[(input.to_i - 1)]
check_project_name
project = JumpStart::Base.new([@pr... | ruby | def new_project_from_template_options
input = gets.chomp.strip.downcase
case
when input.to_i <= JumpStart.existing_templates.count && input.to_i > 0
@template_name = JumpStart.existing_templates[(input.to_i - 1)]
check_project_name
project = JumpStart::Base.new([@pr... | [
"def",
"new_project_from_template_options",
"input",
"=",
"gets",
".",
"chomp",
".",
"strip",
".",
"downcase",
"case",
"when",
"input",
".",
"to_i",
"<=",
"JumpStart",
".",
"existing_templates",
".",
"count",
"&&",
"input",
".",
"to_i",
">",
"0",
"@template_na... | Captures user input for the "create a new jumpstart project from an existing template" menu and calls the appropriate method.
When the input matches a template number a project will be created from that template | [
"Captures",
"user",
"input",
"for",
"the",
"create",
"a",
"new",
"jumpstart",
"project",
"from",
"an",
"existing",
"template",
"menu",
"and",
"calls",
"the",
"appropriate",
"method",
".",
"When",
"the",
"input",
"matches",
"a",
"template",
"number",
"a",
"pr... | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L223-L240 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.new_template_menu | def new_template_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " CREATE A NEW JUMPSTART TEMPLATE\n".purple
puts " Existing templates:\n"
display_existing_templates
... | ruby | def new_template_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " CREATE A NEW JUMPSTART TEMPLATE\n".purple
puts " Existing templates:\n"
display_existing_templates
... | [
"def",
"new_template_menu",
"puts",
"\"\\n\\n******************************************************************************************************************************************\\n\\n\"",
"puts",
"\" CREATE A NEW JUMPSTART TEMPLATE\\n\"",
".",
"purple",
"puts",
"\" Existing templates:\\n\"... | Displays output for the "create a new jumpstart template" menu | [
"Displays",
"output",
"for",
"the",
"create",
"a",
"new",
"jumpstart",
"template",
"menu"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L243-L251 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.new_template_options | def new_template_options
puts "\n Enter a unique name to create a new template, or enter an existing templates name (or number) to duplicate it.".yellow
input = gets.chomp.strip
case
when input.downcase == "b"
jumpstart_menu
when input.downcase == "x"
exit_no... | ruby | def new_template_options
puts "\n Enter a unique name to create a new template, or enter an existing templates name (or number) to duplicate it.".yellow
input = gets.chomp.strip
case
when input.downcase == "b"
jumpstart_menu
when input.downcase == "x"
exit_no... | [
"def",
"new_template_options",
"puts",
"\"\\n Enter a unique name to create a new template, or enter an existing templates name (or number) to duplicate it.\"",
".",
"yellow",
"input",
"=",
"gets",
".",
"chomp",
".",
"strip",
"case",
"when",
"input",
".",
"downcase",
"==",
"\"... | Captures user input for "create a new jumpstart template" menu and calls the appropriate action.
If the template name provided meets the methods requirements then a directory of that name containing a jumpstart_config dir and matching yaml file are created. | [
"Captures",
"user",
"input",
"for",
"create",
"a",
"new",
"jumpstart",
"template",
"menu",
"and",
"calls",
"the",
"appropriate",
"action",
".",
"If",
"the",
"template",
"name",
"provided",
"meets",
"the",
"methods",
"requirements",
"then",
"a",
"directory",
"o... | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L255-L281 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.set_default_template_menu | def set_default_template_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " SELECT A DEFAULT JUMPSTART TEMPLATE\n".purple
display_existing_templates
puts "\n b".yellow + "... | ruby | def set_default_template_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " SELECT A DEFAULT JUMPSTART TEMPLATE\n".purple
display_existing_templates
puts "\n b".yellow + "... | [
"def",
"set_default_template_menu",
"puts",
"\"\\n\\n******************************************************************************************************************************************\\n\\n\"",
"puts",
"\" SELECT A DEFAULT JUMPSTART TEMPLATE\\n\"",
".",
"purple",
"display_existing_templates... | Displays output for the "jumpstart default template options menu" | [
"Displays",
"output",
"for",
"the",
"jumpstart",
"default",
"template",
"options",
"menu"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L319-L327 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.set_default_template_options | def set_default_template_options
input = gets.chomp.strip
case
when input.to_i <= JumpStart.existing_templates.count && input.to_i > 0
JumpStart.default_template_name = JumpStart.existing_templates[(input.to_i - 1)]
JumpStart.dump_jumpstart_setup_yaml
puts " The de... | ruby | def set_default_template_options
input = gets.chomp.strip
case
when input.to_i <= JumpStart.existing_templates.count && input.to_i > 0
JumpStart.default_template_name = JumpStart.existing_templates[(input.to_i - 1)]
JumpStart.dump_jumpstart_setup_yaml
puts " The de... | [
"def",
"set_default_template_options",
"input",
"=",
"gets",
".",
"chomp",
".",
"strip",
"case",
"when",
"input",
".",
"to_i",
"<=",
"JumpStart",
".",
"existing_templates",
".",
"count",
"&&",
"input",
".",
"to_i",
">",
"0",
"JumpStart",
".",
"default_template... | Sets the default template to be used by JumpStart and writes it to a YAML file. | [
"Sets",
"the",
"default",
"template",
"to",
"be",
"used",
"by",
"JumpStart",
"and",
"writes",
"it",
"to",
"a",
"YAML",
"file",
"."
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L330-L346 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.templates_dir_menu | def templates_dir_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " JUMPSTART TEMPLATES DIRECTORY OPTIONS\n".purple
puts " The JumpStart template directory is currently: " + Jump... | ruby | def templates_dir_menu
puts "\n\n******************************************************************************************************************************************\n\n"
puts " JUMPSTART TEMPLATES DIRECTORY OPTIONS\n".purple
puts " The JumpStart template directory is currently: " + Jump... | [
"def",
"templates_dir_menu",
"puts",
"\"\\n\\n******************************************************************************************************************************************\\n\\n\"",
"puts",
"\" JUMPSTART TEMPLATES DIRECTORY OPTIONS\\n\"",
".",
"purple",
"puts",
"\" The JumpStart tem... | Displays output for the "jumpstart templates directory options" menu. | [
"Displays",
"output",
"for",
"the",
"jumpstart",
"templates",
"directory",
"options",
"menu",
"."
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L349-L359 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.templates_dir_options | def templates_dir_options
input = gets.chomp.strip.downcase
case
when input == "1"
puts " Please enter the absolute path for the directory that you would like to contain your jumpstart templates.".yellow
puts " e.g. /Users/your_name/projects/jumpstart_templates\n\n"
... | ruby | def templates_dir_options
input = gets.chomp.strip.downcase
case
when input == "1"
puts " Please enter the absolute path for the directory that you would like to contain your jumpstart templates.".yellow
puts " e.g. /Users/your_name/projects/jumpstart_templates\n\n"
... | [
"def",
"templates_dir_options",
"input",
"=",
"gets",
".",
"chomp",
".",
"strip",
".",
"downcase",
"case",
"when",
"input",
"==",
"\"1\"",
"puts",
"\" Please enter the absolute path for the directory that you would like to contain your jumpstart templates.\"",
".",
"yellow",
... | Captures user input for the "jumpstart templates directory options" menu and calls the appropriate method. | [
"Captures",
"user",
"input",
"for",
"the",
"jumpstart",
"templates",
"directory",
"options",
"menu",
"and",
"calls",
"the",
"appropriate",
"method",
"."
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L362-L379 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.set_templates_dir | def set_templates_dir
input = gets.chomp.strip
root_path = input.sub(/\/\w*\/*$/, '')
case
when input.downcase == "b"
jumpstart_menu
when input.downcase == "x"
exit_normal
when File.directory?(input)
puts "\n A directory of that name already... | ruby | def set_templates_dir
input = gets.chomp.strip
root_path = input.sub(/\/\w*\/*$/, '')
case
when input.downcase == "b"
jumpstart_menu
when input.downcase == "x"
exit_normal
when File.directory?(input)
puts "\n A directory of that name already... | [
"def",
"set_templates_dir",
"input",
"=",
"gets",
".",
"chomp",
".",
"strip",
"root_path",
"=",
"input",
".",
"sub",
"(",
"/",
"\\/",
"\\w",
"\\/",
"/",
",",
"''",
")",
"case",
"when",
"input",
".",
"downcase",
"==",
"\"b\"",
"jumpstart_menu",
"when",
... | Sets the path for templates to be used by JumpStart.
Copies templates in the existing template dir to the new location.
The folder specified must not exist yet, but it's parent should. | [
"Sets",
"the",
"path",
"for",
"templates",
"to",
"be",
"used",
"by",
"JumpStart",
".",
"Copies",
"templates",
"in",
"the",
"existing",
"template",
"dir",
"to",
"the",
"new",
"location",
".",
"The",
"folder",
"specified",
"must",
"not",
"exist",
"yet",
"but... | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L384-L416 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.set_templates_dir_to_existing_dir | def set_templates_dir_to_existing_dir(dir)
input = gets.chomp.strip.downcase
case
when input == "b"
jumpstart_menu
when input == "x"
exit_normal
when input == "y" || input == "yes"
JumpStart.templates_path = dir
JumpStart.dump_jumpstart_set... | ruby | def set_templates_dir_to_existing_dir(dir)
input = gets.chomp.strip.downcase
case
when input == "b"
jumpstart_menu
when input == "x"
exit_normal
when input == "y" || input == "yes"
JumpStart.templates_path = dir
JumpStart.dump_jumpstart_set... | [
"def",
"set_templates_dir_to_existing_dir",
"(",
"dir",
")",
"input",
"=",
"gets",
".",
"chomp",
".",
"strip",
".",
"downcase",
"case",
"when",
"input",
"==",
"\"b\"",
"jumpstart_menu",
"when",
"input",
"==",
"\"x\"",
"exit_normal",
"when",
"input",
"==",
"\"y... | TOOD set_templates_dir_to_existing_dir Needs tests | [
"TOOD",
"set_templates_dir_to_existing_dir",
"Needs",
"tests"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L419-L438 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.parse_template_dir | def parse_template_dir
@dir_list = []
file_list = []
@append_templates = []
@line_templates = []
@whole_templates = []
Find.find(@template_path) do |x|
case
when File.file?(x) && x !~ /\/jumpstart_config/ then
file_list << x.sub!(@template_... | ruby | def parse_template_dir
@dir_list = []
file_list = []
@append_templates = []
@line_templates = []
@whole_templates = []
Find.find(@template_path) do |x|
case
when File.file?(x) && x !~ /\/jumpstart_config/ then
file_list << x.sub!(@template_... | [
"def",
"parse_template_dir",
"@dir_list",
"=",
"[",
"]",
"file_list",
"=",
"[",
"]",
"@append_templates",
"=",
"[",
"]",
"@line_templates",
"=",
"[",
"]",
"@whole_templates",
"=",
"[",
"]",
"Find",
".",
"find",
"(",
"@template_path",
")",
"do",
"|",
"x",
... | Parses the contents of the @template_path and sorts ready for template creation. | [
"Parses",
"the",
"contents",
"of",
"the"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L485-L512 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.populate_files_from_whole_templates | def populate_files_from_whole_templates
@whole_templates.each {|x| FileUtils.cp(FileUtils.join_paths(@template_path, x), FileUtils.join_paths(@install_path, @project_name, x)) } unless @whole_templates.nil?
end | ruby | def populate_files_from_whole_templates
@whole_templates.each {|x| FileUtils.cp(FileUtils.join_paths(@template_path, x), FileUtils.join_paths(@install_path, @project_name, x)) } unless @whole_templates.nil?
end | [
"def",
"populate_files_from_whole_templates",
"@whole_templates",
".",
"each",
"{",
"|",
"x",
"|",
"FileUtils",
".",
"cp",
"(",
"FileUtils",
".",
"join_paths",
"(",
"@template_path",
",",
"x",
")",
",",
"FileUtils",
".",
"join_paths",
"(",
"@install_path",
",",
... | Create files from whole templates | [
"Create",
"files",
"from",
"whole",
"templates"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L520-L522 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.remove_unwanted_files | def remove_unwanted_files
file_array = []
root_path = FileUtils.join_paths(@install_path, @project_name)
unless @config_file[:remove_files].nil?
@config_file[:remove_files].each do |file|
file_array << FileUtils.join_paths(root_path, file)
end
FileUtils.... | ruby | def remove_unwanted_files
file_array = []
root_path = FileUtils.join_paths(@install_path, @project_name)
unless @config_file[:remove_files].nil?
@config_file[:remove_files].each do |file|
file_array << FileUtils.join_paths(root_path, file)
end
FileUtils.... | [
"def",
"remove_unwanted_files",
"file_array",
"=",
"[",
"]",
"root_path",
"=",
"FileUtils",
".",
"join_paths",
"(",
"@install_path",
",",
"@project_name",
")",
"unless",
"@config_file",
"[",
":remove_files",
"]",
".",
"nil?",
"@config_file",
"[",
":remove_files",
... | Removes files specified in templates YAML | [
"Removes",
"files",
"specified",
"in",
"templates",
"YAML"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L553-L562 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.run_scripts_from_yaml | def run_scripts_from_yaml(script_name)
unless @config_file[script_name].nil? || @config_file[script_name].empty?
begin
Dir.chdir(FileUtils.join_paths(@install_path, @project_name))
@config_file[script_name].each do |x|
puts "\nExecuting command: #{x.green}"
... | ruby | def run_scripts_from_yaml(script_name)
unless @config_file[script_name].nil? || @config_file[script_name].empty?
begin
Dir.chdir(FileUtils.join_paths(@install_path, @project_name))
@config_file[script_name].each do |x|
puts "\nExecuting command: #{x.green}"
... | [
"def",
"run_scripts_from_yaml",
"(",
"script_name",
")",
"unless",
"@config_file",
"[",
"script_name",
"]",
".",
"nil?",
"||",
"@config_file",
"[",
"script_name",
"]",
".",
"empty?",
"begin",
"Dir",
".",
"chdir",
"(",
"FileUtils",
".",
"join_paths",
"(",
"@ins... | Runs additional scripts specified in YAML. Runs one set after the install command has executed, another after the templates have been generated, and a final time after string replacement | [
"Runs",
"additional",
"scripts",
"specified",
"in",
"YAML",
".",
"Runs",
"one",
"set",
"after",
"the",
"install",
"command",
"has",
"executed",
"another",
"after",
"the",
"templates",
"have",
"been",
"generated",
"and",
"a",
"final",
"time",
"after",
"string",... | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L565-L577 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.check_for_strings_to_replace | def check_for_strings_to_replace
if @replace_strings.nil? || @replace_strings.empty?
return false
else
puts "\nChecking for strings to replace inside files...\n\n"
@replace_strings.each do |file|
if file[:target_path].nil? || file[:symbols].nil?
re... | ruby | def check_for_strings_to_replace
if @replace_strings.nil? || @replace_strings.empty?
return false
else
puts "\nChecking for strings to replace inside files...\n\n"
@replace_strings.each do |file|
if file[:target_path].nil? || file[:symbols].nil?
re... | [
"def",
"check_for_strings_to_replace",
"if",
"@replace_strings",
".",
"nil?",
"||",
"@replace_strings",
".",
"empty?",
"return",
"false",
"else",
"puts",
"\"\\nChecking for strings to replace inside files...\\n\\n\"",
"@replace_strings",
".",
"each",
"do",
"|",
"file",
"|",... | Looks for strings IN_CAPS that are specified for replacement in the templates YAML | [
"Looks",
"for",
"strings",
"IN_CAPS",
"that",
"are",
"specified",
"for",
"replacement",
"in",
"the",
"templates",
"YAML"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L580-L602 | train |
i0n/jumpstart | lib/jumpstart/base.rb | JumpStart.Base.exit_with_success | def exit_with_success
puts "\n\n Exiting JumpStart...".purple
puts "\n Success! ".green + @project_name.green_bold + " has been created at: ".green + FileUtils.join_paths(@install_path, @project_name).green_bold + "\n\n".green
puts "*************************************************************... | ruby | def exit_with_success
puts "\n\n Exiting JumpStart...".purple
puts "\n Success! ".green + @project_name.green_bold + " has been created at: ".green + FileUtils.join_paths(@install_path, @project_name).green_bold + "\n\n".green
puts "*************************************************************... | [
"def",
"exit_with_success",
"puts",
"\"\\n\\n Exiting JumpStart...\"",
".",
"purple",
"puts",
"\"\\n Success! \"",
".",
"green",
"+",
"@project_name",
".",
"green_bold",
"+",
"\" has been created at: \"",
".",
"green",
"+",
"FileUtils",
".",
"join_paths",
"(",
"@insta... | Exit after creating a project, dumping current setup information to YAML | [
"Exit",
"after",
"creating",
"a",
"project",
"dumping",
"current",
"setup",
"information",
"to",
"YAML"
] | e61beee175ba5a69796e00c2fb88097227c5ce9b | https://github.com/i0n/jumpstart/blob/e61beee175ba5a69796e00c2fb88097227c5ce9b/lib/jumpstart/base.rb#L605-L611 | train |
jage/elk | lib/elk/number.rb | Elk.Number.save | def save
attributes = {
sms_url: self.sms_url,
voice_start: self.voice_start_url
}
# If new URL, send country, otherwise not
unless self.number_id
attributes[:country] = self.country
end
response = @client.post("/Numbers/#{self.number_id}", attributes)
... | ruby | def save
attributes = {
sms_url: self.sms_url,
voice_start: self.voice_start_url
}
# If new URL, send country, otherwise not
unless self.number_id
attributes[:country] = self.country
end
response = @client.post("/Numbers/#{self.number_id}", attributes)
... | [
"def",
"save",
"attributes",
"=",
"{",
"sms_url",
":",
"self",
".",
"sms_url",
",",
"voice_start",
":",
"self",
".",
"voice_start_url",
"}",
"unless",
"self",
".",
"number_id",
"attributes",
"[",
":country",
"]",
"=",
"self",
".",
"country",
"end",
"respon... | Updates or allocates a number | [
"Updates",
"or",
"allocates",
"a",
"number"
] | 9e28155d1c270d7a21f5c009a4cdff9a0fff0808 | https://github.com/jage/elk/blob/9e28155d1c270d7a21f5c009a4cdff9a0fff0808/lib/elk/number.rb#L45-L57 | train |
jage/elk | lib/elk/number.rb | Elk.Number.deallocate! | def deallocate!
response = @client.post("/Numbers/#{self.number_id}", { active: "no" })
self.set_paramaters(Elk::Util.parse_json(response.body))
response.code == 200
end | ruby | def deallocate!
response = @client.post("/Numbers/#{self.number_id}", { active: "no" })
self.set_paramaters(Elk::Util.parse_json(response.body))
response.code == 200
end | [
"def",
"deallocate!",
"response",
"=",
"@client",
".",
"post",
"(",
"\"/Numbers/#{self.number_id}\"",
",",
"{",
"active",
":",
"\"no\"",
"}",
")",
"self",
".",
"set_paramaters",
"(",
"Elk",
"::",
"Util",
".",
"parse_json",
"(",
"response",
".",
"body",
")",
... | Deallocates a number, once deallocated, a number cannot be used again, ever! | [
"Deallocates",
"a",
"number",
"once",
"deallocated",
"a",
"number",
"cannot",
"be",
"used",
"again",
"ever!"
] | 9e28155d1c270d7a21f5c009a4cdff9a0fff0808 | https://github.com/jage/elk/blob/9e28155d1c270d7a21f5c009a4cdff9a0fff0808/lib/elk/number.rb#L60-L64 | train |
fuminori-ido/edgarj | app/helpers/edgarj/common_helper.rb | Edgarj.CommonHelper.datetime_fmt | def datetime_fmt(dt)
if dt.blank? then
''
else
I18n.l(dt, format: I18n.t('edgarj.time.format'))
end
end | ruby | def datetime_fmt(dt)
if dt.blank? then
''
else
I18n.l(dt, format: I18n.t('edgarj.time.format'))
end
end | [
"def",
"datetime_fmt",
"(",
"dt",
")",
"if",
"dt",
".",
"blank?",
"then",
"''",
"else",
"I18n",
".",
"l",
"(",
"dt",
",",
"format",
":",
"I18n",
".",
"t",
"(",
"'edgarj.time.format'",
")",
")",
"end",
"end"
] | Edgarj standard datetime format | [
"Edgarj",
"standard",
"datetime",
"format"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/common_helper.rb#L6-L12 | train |
fuminori-ido/edgarj | app/helpers/edgarj/common_helper.rb | Edgarj.CommonHelper.get_enum | def get_enum(model, col)
col_name = col.name
if model.const_defined?(col_name.camelize, false)
enum = model.const_get(col_name.camelize)
enum.is_a?(Module) ? enum : nil
else
nil
end
end | ruby | def get_enum(model, col)
col_name = col.name
if model.const_defined?(col_name.camelize, false)
enum = model.const_get(col_name.camelize)
enum.is_a?(Module) ? enum : nil
else
nil
end
end | [
"def",
"get_enum",
"(",
"model",
",",
"col",
")",
"col_name",
"=",
"col",
".",
"name",
"if",
"model",
".",
"const_defined?",
"(",
"col_name",
".",
"camelize",
",",
"false",
")",
"enum",
"=",
"model",
".",
"const_get",
"(",
"col_name",
".",
"camelize",
... | get enum Module.
When Col(camelized argument col name) module exists, the Col is
assumed enum definition. | [
"get",
"enum",
"Module",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/common_helper.rb#L27-L35 | train |
darbylabs/magma | lib/magma/templater.rb | Magma.Templater.render | def render(template)
template.render(config.variables.deep_merge(options[:globals]), strict_variables: true).tap do
if template.errors&.length&.positive?
puts template.errors
raise template.errors.map(&:to_s).join('; ')
end
end
end | ruby | def render(template)
template.render(config.variables.deep_merge(options[:globals]), strict_variables: true).tap do
if template.errors&.length&.positive?
puts template.errors
raise template.errors.map(&:to_s).join('; ')
end
end
end | [
"def",
"render",
"(",
"template",
")",
"template",
".",
"render",
"(",
"config",
".",
"variables",
".",
"deep_merge",
"(",
"options",
"[",
":globals",
"]",
")",
",",
"strict_variables",
":",
"true",
")",
".",
"tap",
"do",
"if",
"template",
".",
"errors",... | Pipeline
Renders a Liquid template | [
"Pipeline",
"Renders",
"a",
"Liquid",
"template"
] | 62da478396fb479786f109128b6f65dd85b7c04c | https://github.com/darbylabs/magma/blob/62da478396fb479786f109128b6f65dd85b7c04c/lib/magma/templater.rb#L49-L56 | train |
artursbraucs/banklink | lib/banklink/banklink.rb | Banklink.Common.parse | def parse(post)
@raw = post.to_s
for line in @raw.split('&')
key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
params[key] = CGI.unescape(value)
end
end | ruby | def parse(post)
@raw = post.to_s
for line in @raw.split('&')
key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
params[key] = CGI.unescape(value)
end
end | [
"def",
"parse",
"(",
"post",
")",
"@raw",
"=",
"post",
".",
"to_s",
"for",
"line",
"in",
"@raw",
".",
"split",
"(",
"'&'",
")",
"key",
",",
"value",
"=",
"*",
"line",
".",
"scan",
"(",
"%r{",
"\\=",
"}",
")",
".",
"flatten",
"params",
"[",
"key... | Take the posted data and move the relevant data into a hash | [
"Take",
"the",
"posted",
"data",
"and",
"move",
"the",
"relevant",
"data",
"into",
"a",
"hash"
] | 0b86b16797df6eb88e2ec72f4aaf73c6bb2eed7e | https://github.com/artursbraucs/banklink/blob/0b86b16797df6eb88e2ec72f4aaf73c6bb2eed7e/lib/banklink/banklink.rb#L54-L60 | train |
Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb | Languages.ManagerBasicStructureData.add_conditional | def add_conditional(pConditional)
return nil unless pConditional.is_a?(Languages::ConditionalData)
pConditional.level = @currentLevel
@basicStructure.push(pConditional)
end | ruby | def add_conditional(pConditional)
return nil unless pConditional.is_a?(Languages::ConditionalData)
pConditional.level = @currentLevel
@basicStructure.push(pConditional)
end | [
"def",
"add_conditional",
"(",
"pConditional",
")",
"return",
"nil",
"unless",
"pConditional",
".",
"is_a?",
"(",
"Languages",
"::",
"ConditionalData",
")",
"pConditional",
".",
"level",
"=",
"@currentLevel",
"@basicStructure",
".",
"push",
"(",
"pConditional",
")... | Add conditional to basicStructure
@param pConditional ConditionalData to add inside basicStructure | [
"Add",
"conditional",
"to",
"basicStructure"
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb#L27-L31 | train |
Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb | Languages.ManagerBasicStructureData.add_repetition | def add_repetition(pRepetition)
return nil unless pRepetition.is_a?(Languages::RepetitionData)
pRepetition.level = @currentLevel
@basicStructure.push(pRepetition)
end | ruby | def add_repetition(pRepetition)
return nil unless pRepetition.is_a?(Languages::RepetitionData)
pRepetition.level = @currentLevel
@basicStructure.push(pRepetition)
end | [
"def",
"add_repetition",
"(",
"pRepetition",
")",
"return",
"nil",
"unless",
"pRepetition",
".",
"is_a?",
"(",
"Languages",
"::",
"RepetitionData",
")",
"pRepetition",
".",
"level",
"=",
"@currentLevel",
"@basicStructure",
".",
"push",
"(",
"pRepetition",
")",
"... | Add repetition to basicStructure
@param pRepetition RepetitionData to add inside basicStrure | [
"Add",
"repetition",
"to",
"basicStructure"
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb#L35-L39 | train |
Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb | Languages.ManagerBasicStructureData.add_block | def add_block(pBlock)
return nil unless pBlock.is_a?(Languages::BlockData)
pBlock.level = @currentLevel
@basicStructure.push(pBlock)
end | ruby | def add_block(pBlock)
return nil unless pBlock.is_a?(Languages::BlockData)
pBlock.level = @currentLevel
@basicStructure.push(pBlock)
end | [
"def",
"add_block",
"(",
"pBlock",
")",
"return",
"nil",
"unless",
"pBlock",
".",
"is_a?",
"(",
"Languages",
"::",
"BlockData",
")",
"pBlock",
".",
"level",
"=",
"@currentLevel",
"@basicStructure",
".",
"push",
"(",
"pBlock",
")",
"end"
] | Add block to basicStructure
@param pBlock BlockData to add inside basicStructure | [
"Add",
"block",
"to",
"basicStructure"
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb#L43-L47 | train |
CITguy/xml-fu | lib/xml-fu/configuration.rb | XmlFu.Configuration.symbol_conversion_algorithm= | def symbol_conversion_algorithm=(algorithm)
raise(ArgumentError, "Missing symbol conversion algorithm") unless algorithm
if algorithm.respond_to?(:call)
@symbol_conversion_algorithm = algorithm
else
if algorithm == :default
@symbol_conversion_algorithm = ALGORITHMS[:lower_ca... | ruby | def symbol_conversion_algorithm=(algorithm)
raise(ArgumentError, "Missing symbol conversion algorithm") unless algorithm
if algorithm.respond_to?(:call)
@symbol_conversion_algorithm = algorithm
else
if algorithm == :default
@symbol_conversion_algorithm = ALGORITHMS[:lower_ca... | [
"def",
"symbol_conversion_algorithm",
"=",
"(",
"algorithm",
")",
"raise",
"(",
"ArgumentError",
",",
"\"Missing symbol conversion algorithm\"",
")",
"unless",
"algorithm",
"if",
"algorithm",
".",
"respond_to?",
"(",
":call",
")",
"@symbol_conversion_algorithm",
"=",
"a... | Set default values
initialize
Method for setting global Symbol-to-string conversion algorithm
@param [symbol, lambda] algorithm
Can be symbol corresponding to predefined algorithm or a lambda that accepts a symbol
as an argument and returns a string | [
"Set",
"default",
"values",
"initialize",
"Method",
"for",
"setting",
"global",
"Symbol",
"-",
"to",
"-",
"string",
"conversion",
"algorithm"
] | 2499571130ba2cac2e62f6e9d27d953a2f1e6ad7 | https://github.com/CITguy/xml-fu/blob/2499571130ba2cac2e62f6e9d27d953a2f1e6ad7/lib/xml-fu/configuration.rb#L41-L55 | train |
ruby-journal/cricos_scrape.rb | lib/cricos_scrape/importer/course_importer.rb | CricosScrape.CourseImporter.find_course_location | def find_course_location
location_ids = []
if location_results_paginated?
for page_number in 1..total_pages
jump_to_page(page_number)
location_ids += fetch_location_ids_from_current_page
end
else
location_ids += fetch_location_ids_from_current_page
en... | ruby | def find_course_location
location_ids = []
if location_results_paginated?
for page_number in 1..total_pages
jump_to_page(page_number)
location_ids += fetch_location_ids_from_current_page
end
else
location_ids += fetch_location_ids_from_current_page
en... | [
"def",
"find_course_location",
"location_ids",
"=",
"[",
"]",
"if",
"location_results_paginated?",
"for",
"page_number",
"in",
"1",
"..",
"total_pages",
"jump_to_page",
"(",
"page_number",
")",
"location_ids",
"+=",
"fetch_location_ids_from_current_page",
"end",
"else",
... | Get all locations of course | [
"Get",
"all",
"locations",
"of",
"course"
] | b0652e4b3f16e1cb813fa75644be5174ae73b559 | https://github.com/ruby-journal/cricos_scrape.rb/blob/b0652e4b3f16e1cb813fa75644be5174ae73b559/lib/cricos_scrape/importer/course_importer.rb#L214-L227 | train |
wvanbergen/sql_tree | tasks/github-gem.rb | GithubGem.RakeTasks.define_rspec_tasks! | def define_rspec_tasks!
require 'rspec/core/rake_task'
namespace(:spec) do
desc "Verify all RSpec examples for #{gemspec.name}"
RSpec::Core::RakeTask.new(:basic) do |t|
t.pattern = spec_pattern
end
desc "Verify all RSpec examples for #{gemspec.name} and output spe... | ruby | def define_rspec_tasks!
require 'rspec/core/rake_task'
namespace(:spec) do
desc "Verify all RSpec examples for #{gemspec.name}"
RSpec::Core::RakeTask.new(:basic) do |t|
t.pattern = spec_pattern
end
desc "Verify all RSpec examples for #{gemspec.name} and output spe... | [
"def",
"define_rspec_tasks!",
"require",
"'rspec/core/rake_task'",
"namespace",
"(",
":spec",
")",
"do",
"desc",
"\"Verify all RSpec examples for #{gemspec.name}\"",
"RSpec",
"::",
"Core",
"::",
"RakeTask",
".",
"new",
"(",
":basic",
")",
"do",
"|",
"t",
"|",
"t",
... | Defines RSpec tasks | [
"Defines",
"RSpec",
"tasks"
] | b45566c4c52962def5bfd376622a19697dd49969 | https://github.com/wvanbergen/sql_tree/blob/b45566c4c52962def5bfd376622a19697dd49969/tasks/github-gem.rb#L75-L100 | train |
wvanbergen/sql_tree | tasks/github-gem.rb | GithubGem.RakeTasks.define_tasks! | def define_tasks!
define_test_tasks! if has_tests?
define_rspec_tasks! if has_specs?
namespace(@task_namespace) do
desc "Updates the filelist in the gemspec file"
task(:manifest) { manifest_task }
desc "Builds the .gem package"
task(:build => :manifest) { build_task... | ruby | def define_tasks!
define_test_tasks! if has_tests?
define_rspec_tasks! if has_specs?
namespace(@task_namespace) do
desc "Updates the filelist in the gemspec file"
task(:manifest) { manifest_task }
desc "Builds the .gem package"
task(:build => :manifest) { build_task... | [
"def",
"define_tasks!",
"define_test_tasks!",
"if",
"has_tests?",
"define_rspec_tasks!",
"if",
"has_specs?",
"namespace",
"(",
"@task_namespace",
")",
"do",
"desc",
"\"Updates the filelist in the gemspec file\"",
"task",
"(",
":manifest",
")",
"{",
"manifest_task",
"}",
"... | Defines the rake tasks | [
"Defines",
"the",
"rake",
"tasks"
] | b45566c4c52962def5bfd376622a19697dd49969 | https://github.com/wvanbergen/sql_tree/blob/b45566c4c52962def5bfd376622a19697dd49969/tasks/github-gem.rb#L103-L167 | train |
wvanbergen/sql_tree | tasks/github-gem.rb | GithubGem.RakeTasks.version_task | def version_task
update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']
update_gemspec(:date, Date.today)
update_version_file(gemspec.version)
update_version_constant(gemspec.version)
end | ruby | def version_task
update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']
update_gemspec(:date, Date.today)
update_version_file(gemspec.version)
update_version_constant(gemspec.version)
end | [
"def",
"version_task",
"update_gemspec",
"(",
":version",
",",
"ENV",
"[",
"'VERSION'",
"]",
")",
"if",
"ENV",
"[",
"'VERSION'",
"]",
"update_gemspec",
"(",
":date",
",",
"Date",
".",
"today",
")",
"update_version_file",
"(",
"gemspec",
".",
"version",
")",
... | Updates the version number in the gemspec file, the VERSION constant in the main
include file and the contents of the VERSION file. | [
"Updates",
"the",
"version",
"number",
"in",
"the",
"gemspec",
"file",
"the",
"VERSION",
"constant",
"in",
"the",
"main",
"include",
"file",
"and",
"the",
"contents",
"of",
"the",
"VERSION",
"file",
"."
] | b45566c4c52962def5bfd376622a19697dd49969 | https://github.com/wvanbergen/sql_tree/blob/b45566c4c52962def5bfd376622a19697dd49969/tasks/github-gem.rb#L215-L221 | train |
wvanbergen/sql_tree | tasks/github-gem.rb | GithubGem.RakeTasks.update_version_file | def update_version_file(version)
if File.exists?('VERSION')
File.open('VERSION', 'w') { |f| f << version.to_s }
modified_files << 'VERSION'
end
end | ruby | def update_version_file(version)
if File.exists?('VERSION')
File.open('VERSION', 'w') { |f| f << version.to_s }
modified_files << 'VERSION'
end
end | [
"def",
"update_version_file",
"(",
"version",
")",
"if",
"File",
".",
"exists?",
"(",
"'VERSION'",
")",
"File",
".",
"open",
"(",
"'VERSION'",
",",
"'w'",
")",
"{",
"|",
"f",
"|",
"f",
"<<",
"version",
".",
"to_s",
"}",
"modified_files",
"<<",
"'VERSIO... | Updates the VERSION file with the new version | [
"Updates",
"the",
"VERSION",
"file",
"with",
"the",
"new",
"version"
] | b45566c4c52962def5bfd376622a19697dd49969 | https://github.com/wvanbergen/sql_tree/blob/b45566c4c52962def5bfd376622a19697dd49969/tasks/github-gem.rb#L297-L302 | train |
wvanbergen/sql_tree | tasks/github-gem.rb | GithubGem.RakeTasks.update_version_constant | def update_version_constant(version)
if main_include && File.exist?(main_include)
file_contents = File.read(main_include)
if file_contents.sub!(/^(\s+VERSION\s*=\s*)[^\s].*$/) { $1 + version.to_s.inspect }
File.open(main_include, 'w') { |f| f << file_contents }
modified_files <... | ruby | def update_version_constant(version)
if main_include && File.exist?(main_include)
file_contents = File.read(main_include)
if file_contents.sub!(/^(\s+VERSION\s*=\s*)[^\s].*$/) { $1 + version.to_s.inspect }
File.open(main_include, 'w') { |f| f << file_contents }
modified_files <... | [
"def",
"update_version_constant",
"(",
"version",
")",
"if",
"main_include",
"&&",
"File",
".",
"exist?",
"(",
"main_include",
")",
"file_contents",
"=",
"File",
".",
"read",
"(",
"main_include",
")",
"if",
"file_contents",
".",
"sub!",
"(",
"/",
"\\s",
"\\s... | Updates the VERSION constant in the main include file if it exists | [
"Updates",
"the",
"VERSION",
"constant",
"in",
"the",
"main",
"include",
"file",
"if",
"it",
"exists"
] | b45566c4c52962def5bfd376622a19697dd49969 | https://github.com/wvanbergen/sql_tree/blob/b45566c4c52962def5bfd376622a19697dd49969/tasks/github-gem.rb#L305-L313 | train |
bdurand/json_record | lib/json_record/embedded_document.rb | JsonRecord.EmbeddedDocument.attributes= | def attributes= (attrs)
attrs.each_pair do |name, value|
field = schema.fields[name.to_s] || FieldDefinition.new(name, :type => value.class)
setter = "#{name}=".to_sym
if respond_to?(setter)
send(setter, value)
else
write_attribute(field, value, self)
en... | ruby | def attributes= (attrs)
attrs.each_pair do |name, value|
field = schema.fields[name.to_s] || FieldDefinition.new(name, :type => value.class)
setter = "#{name}=".to_sym
if respond_to?(setter)
send(setter, value)
else
write_attribute(field, value, self)
en... | [
"def",
"attributes",
"=",
"(",
"attrs",
")",
"attrs",
".",
"each_pair",
"do",
"|",
"name",
",",
"value",
"|",
"field",
"=",
"schema",
".",
"fields",
"[",
"name",
".",
"to_s",
"]",
"||",
"FieldDefinition",
".",
"new",
"(",
"name",
",",
":type",
"=>",
... | Set all the attributes at once. | [
"Set",
"all",
"the",
"attributes",
"at",
"once",
"."
] | 463f4719d9618f6d2406c0aab6028e0156f7c775 | https://github.com/bdurand/json_record/blob/463f4719d9618f6d2406c0aab6028e0156f7c775/lib/json_record/embedded_document.rb#L49-L59 | train |
bdurand/json_record | lib/json_record/embedded_document.rb | JsonRecord.EmbeddedDocument.[]= | def []= (name, value)
field = schema.fields[name.to_s] || FieldDefinition.new(name, :type => value.class)
write_attribute(field, value, self)
end | ruby | def []= (name, value)
field = schema.fields[name.to_s] || FieldDefinition.new(name, :type => value.class)
write_attribute(field, value, self)
end | [
"def",
"[]=",
"(",
"name",
",",
"value",
")",
"field",
"=",
"schema",
".",
"fields",
"[",
"name",
".",
"to_s",
"]",
"||",
"FieldDefinition",
".",
"new",
"(",
"name",
",",
":type",
"=>",
"value",
".",
"class",
")",
"write_attribute",
"(",
"field",
","... | Set a field from the schema with the specified name. | [
"Set",
"a",
"field",
"from",
"the",
"schema",
"with",
"the",
"specified",
"name",
"."
] | 463f4719d9618f6d2406c0aab6028e0156f7c775 | https://github.com/bdurand/json_record/blob/463f4719d9618f6d2406c0aab6028e0156f7c775/lib/json_record/embedded_document.rb#L73-L76 | train |
efreesen/active_repository | lib/active_repository/base.rb | ActiveRepository.Base.reload | def reload
object = self.id.present? ?
persistence_class.where(id: self.id).first_or_initialize :
self
serialize! object.attributes
end | ruby | def reload
object = self.id.present? ?
persistence_class.where(id: self.id).first_or_initialize :
self
serialize! object.attributes
end | [
"def",
"reload",
"object",
"=",
"self",
".",
"id",
".",
"present?",
"?",
"persistence_class",
".",
"where",
"(",
"id",
":",
"self",
".",
"id",
")",
".",
"first_or_initialize",
":",
"self",
"serialize!",
"object",
".",
"attributes",
"end"
] | Gathers the persisted object from database and updates self with it's attributes. | [
"Gathers",
"the",
"persisted",
"object",
"from",
"database",
"and",
"updates",
"self",
"with",
"it",
"s",
"attributes",
"."
] | e134b0e02959ac7e745319a2d74398101dfc5900 | https://github.com/efreesen/active_repository/blob/e134b0e02959ac7e745319a2d74398101dfc5900/lib/active_repository/base.rb#L201-L207 | train |
efreesen/active_repository | lib/active_repository/base.rb | ActiveRepository.Base.serialize! | def serialize!(attributes)
unless attributes.nil?
attributes.each do |key, value|
key = "id" if key == "_id"
self.send("#{key}=", (value.dup rescue value))
end
end
self.dup
end | ruby | def serialize!(attributes)
unless attributes.nil?
attributes.each do |key, value|
key = "id" if key == "_id"
self.send("#{key}=", (value.dup rescue value))
end
end
self.dup
end | [
"def",
"serialize!",
"(",
"attributes",
")",
"unless",
"attributes",
".",
"nil?",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"key",
"=",
"\"id\"",
"if",
"key",
"==",
"\"_id\"",
"self",
".",
"send",
"(",
"\"#{key}=\"",
",",
"(",
"va... | Updates attributes from self with the attributes from the parameters | [
"Updates",
"attributes",
"from",
"self",
"with",
"the",
"attributes",
"from",
"the",
"parameters"
] | e134b0e02959ac7e745319a2d74398101dfc5900 | https://github.com/efreesen/active_repository/blob/e134b0e02959ac7e745319a2d74398101dfc5900/lib/active_repository/base.rb#L234-L243 | train |
efreesen/active_repository | lib/active_repository/base.rb | ActiveRepository.Base.convert | def convert(attribute="id")
klass = persistence_class
object = klass.where(attribute.to_sym => self.send(attribute)).first
object ||= persistence_class.new
attributes = self.attributes.select{ |key, value| self.class.serialized_attributes.include?(key.to_s) }
attributes.delete... | ruby | def convert(attribute="id")
klass = persistence_class
object = klass.where(attribute.to_sym => self.send(attribute)).first
object ||= persistence_class.new
attributes = self.attributes.select{ |key, value| self.class.serialized_attributes.include?(key.to_s) }
attributes.delete... | [
"def",
"convert",
"(",
"attribute",
"=",
"\"id\"",
")",
"klass",
"=",
"persistence_class",
"object",
"=",
"klass",
".",
"where",
"(",
"attribute",
".",
"to_sym",
"=>",
"self",
".",
"send",
"(",
"attribute",
")",
")",
".",
"first",
"object",
"||=",
"persi... | Find related object on the database and updates it with attributes in self, if it didn't
find it on database it creates a new one. | [
"Find",
"related",
"object",
"on",
"the",
"database",
"and",
"updates",
"it",
"with",
"attributes",
"in",
"self",
"if",
"it",
"didn",
"t",
"find",
"it",
"on",
"database",
"it",
"creates",
"a",
"new",
"one",
"."
] | e134b0e02959ac7e745319a2d74398101dfc5900 | https://github.com/efreesen/active_repository/blob/e134b0e02959ac7e745319a2d74398101dfc5900/lib/active_repository/base.rb#L248-L265 | train |
efreesen/active_repository | lib/active_repository/base.rb | ActiveRepository.Base.set_timestamps | def set_timestamps
if self.errors.empty?
self.created_at = DateTime.now.utc if self.respond_to?(:created_at=) && self.created_at.nil?
self.updated_at = DateTime.now.utc if self.respond_to?(:updated_at=)
end
end | ruby | def set_timestamps
if self.errors.empty?
self.created_at = DateTime.now.utc if self.respond_to?(:created_at=) && self.created_at.nil?
self.updated_at = DateTime.now.utc if self.respond_to?(:updated_at=)
end
end | [
"def",
"set_timestamps",
"if",
"self",
".",
"errors",
".",
"empty?",
"self",
".",
"created_at",
"=",
"DateTime",
".",
"now",
".",
"utc",
"if",
"self",
".",
"respond_to?",
"(",
":created_at=",
")",
"&&",
"self",
".",
"created_at",
".",
"nil?",
"self",
"."... | Updates created_at and updated_at | [
"Updates",
"created_at",
"and",
"updated_at"
] | e134b0e02959ac7e745319a2d74398101dfc5900 | https://github.com/efreesen/active_repository/blob/e134b0e02959ac7e745319a2d74398101dfc5900/lib/active_repository/base.rb#L290-L295 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atom.Element.set | def set(ns, element_name, value="", attributes=nil)
xpath = child_xpath(ns, element_name)
@elem.elements.delete_all(xpath)
add(ns, element_name, value, attributes)
end | ruby | def set(ns, element_name, value="", attributes=nil)
xpath = child_xpath(ns, element_name)
@elem.elements.delete_all(xpath)
add(ns, element_name, value, attributes)
end | [
"def",
"set",
"(",
"ns",
",",
"element_name",
",",
"value",
"=",
"\"\"",
",",
"attributes",
"=",
"nil",
")",
"xpath",
"=",
"child_xpath",
"(",
"ns",
",",
"element_name",
")",
"@elem",
".",
"elements",
".",
"delete_all",
"(",
"xpath",
")",
"add",
"(",
... | This method allows you to handle extra-element such as you can't represent
with elements defined in Atom namespace.
entry = Atom::Entry.new
entry.set('http://example/2007/mynamespace', 'foo', 'bar')
Now your entry includes new element.
<foo xmlns="http://example/2007/mynamespace">bar</foo>
You also can add... | [
"This",
"method",
"allows",
"you",
"to",
"handle",
"extra",
"-",
"element",
"such",
"as",
"you",
"can",
"t",
"represent",
"with",
"elements",
"defined",
"in",
"Atom",
"namespace",
"."
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L498-L502 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atom.Element.add | def add(ns, element_name, value, attributes={})
element = REXML::Element.new(element_name)
if ns.is_a?(Namespace)
unless ns.prefix.nil? || ns.prefix.empty?
element.name = "#{ns.prefix}:#{element_name}"
element.add_namespace ns.prefix, ns.uri unless @ns == ns || @ns == ns.uri
... | ruby | def add(ns, element_name, value, attributes={})
element = REXML::Element.new(element_name)
if ns.is_a?(Namespace)
unless ns.prefix.nil? || ns.prefix.empty?
element.name = "#{ns.prefix}:#{element_name}"
element.add_namespace ns.prefix, ns.uri unless @ns == ns || @ns == ns.uri
... | [
"def",
"add",
"(",
"ns",
",",
"element_name",
",",
"value",
",",
"attributes",
"=",
"{",
"}",
")",
"element",
"=",
"REXML",
"::",
"Element",
".",
"new",
"(",
"element_name",
")",
"if",
"ns",
".",
"is_a?",
"(",
"Namespace",
")",
"unless",
"ns",
".",
... | Same as 'set', but when a element-name confliction occurs,
append new element without overriding. | [
"Same",
"as",
"set",
"but",
"when",
"a",
"element",
"-",
"name",
"confliction",
"occurs",
"append",
"new",
"element",
"without",
"overriding",
"."
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L505-L540 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atom.Element.get_object | def get_object(ns, element_name, ext_class)
elements = getlist(ns, element_name)
return nil if elements.empty?
ext_class.new(:namespace => ns, :elem => elements.first)
end | ruby | def get_object(ns, element_name, ext_class)
elements = getlist(ns, element_name)
return nil if elements.empty?
ext_class.new(:namespace => ns, :elem => elements.first)
end | [
"def",
"get_object",
"(",
"ns",
",",
"element_name",
",",
"ext_class",
")",
"elements",
"=",
"getlist",
"(",
"ns",
",",
"element_name",
")",
"return",
"nil",
"if",
"elements",
".",
"empty?",
"ext_class",
".",
"new",
"(",
":namespace",
"=>",
"ns",
",",
":... | Get indicated elements as an object of the class you passed as thrid argument.
ns = Atom::Namespace.new(:uri => 'http://example.com/ns#')
obj = entry.get_object(ns, 'mytag', MyClass)
puts obj.class #MyClass
MyClass should inherit Atom::Element | [
"Get",
"indicated",
"elements",
"as",
"an",
"object",
"of",
"the",
"class",
"you",
"passed",
"as",
"thrid",
"argument",
"."
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L568-L572 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atom.Element.get_objects | def get_objects(ns, element_name, ext_class)
elements = getlist(ns, element_name)
return [] if elements.empty?
elements.collect do |e|
ext_class.new(:namespace => ns, :elem => e)
end
end | ruby | def get_objects(ns, element_name, ext_class)
elements = getlist(ns, element_name)
return [] if elements.empty?
elements.collect do |e|
ext_class.new(:namespace => ns, :elem => e)
end
end | [
"def",
"get_objects",
"(",
"ns",
",",
"element_name",
",",
"ext_class",
")",
"elements",
"=",
"getlist",
"(",
"ns",
",",
"element_name",
")",
"return",
"[",
"]",
"if",
"elements",
".",
"empty?",
"elements",
".",
"collect",
"do",
"|",
"e",
"|",
"ext_class... | Get all indicated elements as an object of the class you passed as thrid argument.
entry.get_objects(ns, 'mytag', MyClass).each{ |obj|
p obj.class #MyClass
} | [
"Get",
"all",
"indicated",
"elements",
"as",
"an",
"object",
"of",
"the",
"class",
"you",
"passed",
"as",
"thrid",
"argument",
"."
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L579-L585 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atom.Element.to_s | def to_s(*)
doc = REXML::Document.new
decl = REXML::XMLDecl.new("1.0", "utf-8")
doc.add decl
doc.add_element @elem
doc.to_s
end | ruby | def to_s(*)
doc = REXML::Document.new
decl = REXML::XMLDecl.new("1.0", "utf-8")
doc.add decl
doc.add_element @elem
doc.to_s
end | [
"def",
"to_s",
"(",
"*",
")",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"decl",
"=",
"REXML",
"::",
"XMLDecl",
".",
"new",
"(",
"\"1.0\"",
",",
"\"utf-8\"",
")",
"doc",
".",
"add",
"decl",
"doc",
".",
"add_element",
"@elem",
"doc",
".",
"t... | Convert to XML-Document and return it as string | [
"Convert",
"to",
"XML",
"-",
"Document",
"and",
"return",
"it",
"as",
"string"
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L595-L601 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atom.Element.child_xpath | def child_xpath(ns, element_name, attributes=nil)
ns_uri = ns.is_a?(Namespace) ? ns.uri : ns
unless !attributes.nil? && attributes.is_a?(Hash)
"child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}']"
else
attr_str = attributes.collect{|key, val| "@#{key.to_s}='#{val}'... | ruby | def child_xpath(ns, element_name, attributes=nil)
ns_uri = ns.is_a?(Namespace) ? ns.uri : ns
unless !attributes.nil? && attributes.is_a?(Hash)
"child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}']"
else
attr_str = attributes.collect{|key, val| "@#{key.to_s}='#{val}'... | [
"def",
"child_xpath",
"(",
"ns",
",",
"element_name",
",",
"attributes",
"=",
"nil",
")",
"ns_uri",
"=",
"ns",
".",
"is_a?",
"(",
"Namespace",
")",
"?",
"ns",
".",
"uri",
":",
"ns",
"unless",
"!",
"attributes",
".",
"nil?",
"&&",
"attributes",
".",
"... | Get a xpath string to traverse child elements with namespace and name. | [
"Get",
"a",
"xpath",
"string",
"to",
"traverse",
"child",
"elements",
"with",
"namespace",
"and",
"name",
"."
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L604-L612 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atompub.Client.get_media | def get_media(media_uri)
get_resource(media_uri)
if @rc.instance_of?(Atom::Entry)
raise ResponseError, "Response is not Media Resource"
end
return @rc, @res.content_type
end | ruby | def get_media(media_uri)
get_resource(media_uri)
if @rc.instance_of?(Atom::Entry)
raise ResponseError, "Response is not Media Resource"
end
return @rc, @res.content_type
end | [
"def",
"get_media",
"(",
"media_uri",
")",
"get_resource",
"(",
"media_uri",
")",
"if",
"@rc",
".",
"instance_of?",
"(",
"Atom",
"::",
"Entry",
")",
"raise",
"ResponseError",
",",
"\"Response is not Media Resource\"",
"end",
"return",
"@rc",
",",
"@res",
".",
... | Get media resource
Example:
resource, content_type = client.get_media(media_uri) | [
"Get",
"media",
"resource"
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L1413-L1419 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atompub.Client.create_entry | def create_entry(post_uri, entry, slug=nil)
unless entry.kind_of?(Atom::Entry)
entry = Atom::Entry.new :stream => entry
end
service = @service_info.get(post_uri)
unless entry.categories.all?{ |c| service.allows_category?(c) }
raise RequestError, "Forbidden Category"
end
... | ruby | def create_entry(post_uri, entry, slug=nil)
unless entry.kind_of?(Atom::Entry)
entry = Atom::Entry.new :stream => entry
end
service = @service_info.get(post_uri)
unless entry.categories.all?{ |c| service.allows_category?(c) }
raise RequestError, "Forbidden Category"
end
... | [
"def",
"create_entry",
"(",
"post_uri",
",",
"entry",
",",
"slug",
"=",
"nil",
")",
"unless",
"entry",
".",
"kind_of?",
"(",
"Atom",
"::",
"Entry",
")",
"entry",
"=",
"Atom",
"::",
"Entry",
".",
"new",
":stream",
"=>",
"entry",
"end",
"service",
"=",
... | Create new entry
Example:
entry = Atom::Entry.new
entry.title = 'foo'
author = Atom::Author.new
author.name = 'Lyo Kato'
author.email = 'lyo.kato@gmail.com'
entry.author = author
entry_uri = client.create_entry(post_uri, entry) | [
"Create",
"new",
"entry"
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L1432-L1442 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atompub.Client.create_media | def create_media(media_uri, file_path, content_type, slug=nil)
file_path = Pathname.new(file_path) unless file_path.is_a?(Pathname)
stream = file_path.open { |f| f.binmode; f.read }
service = @service_info.get(media_uri)
if service.nil?
raise RequestError, "Service information not found.... | ruby | def create_media(media_uri, file_path, content_type, slug=nil)
file_path = Pathname.new(file_path) unless file_path.is_a?(Pathname)
stream = file_path.open { |f| f.binmode; f.read }
service = @service_info.get(media_uri)
if service.nil?
raise RequestError, "Service information not found.... | [
"def",
"create_media",
"(",
"media_uri",
",",
"file_path",
",",
"content_type",
",",
"slug",
"=",
"nil",
")",
"file_path",
"=",
"Pathname",
".",
"new",
"(",
"file_path",
")",
"unless",
"file_path",
".",
"is_a?",
"(",
"Pathname",
")",
"stream",
"=",
"file_p... | Create new media resource
Example:
media_uri = client.create_media(post_media_uri, 'myimage.jpg', 'image/jpeg') | [
"Create",
"new",
"media",
"resource"
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L1449-L1461 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atompub.Client.update_media | def update_media(media_uri, file_path, content_type)
file_path = Pathname.new(file_path) unless file_path.is_a?(Pathname)
stream = file_path.open { |f| f.binmode; f.read }
update_resource(media_uri, stream, content_type)
end | ruby | def update_media(media_uri, file_path, content_type)
file_path = Pathname.new(file_path) unless file_path.is_a?(Pathname)
stream = file_path.open { |f| f.binmode; f.read }
update_resource(media_uri, stream, content_type)
end | [
"def",
"update_media",
"(",
"media_uri",
",",
"file_path",
",",
"content_type",
")",
"file_path",
"=",
"Pathname",
".",
"new",
"(",
"file_path",
")",
"unless",
"file_path",
".",
"is_a?",
"(",
"Pathname",
")",
"stream",
"=",
"file_path",
".",
"open",
"{",
"... | Update media resource
Example:
entry = client.get_entry(media_link_uri)
client.update_media(entry.edit_media_link, 'newimage.jpg', 'image/jpeg') | [
"Update",
"media",
"resource"
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L1483-L1487 | train |
lyokato/ruby-atomutil | lib/atomutil.rb | Atompub.Client.get_contents_except_resources | def get_contents_except_resources(uri, &block)
clear
uri = URI.parse(uri)
@req = Net::HTTP::Get.new uri.request_uri
set_common_info(@req)
@http_class.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
@res = http.request(@req)
case @res
when Ne... | ruby | def get_contents_except_resources(uri, &block)
clear
uri = URI.parse(uri)
@req = Net::HTTP::Get.new uri.request_uri
set_common_info(@req)
@http_class.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
@res = http.request(@req)
case @res
when Ne... | [
"def",
"get_contents_except_resources",
"(",
"uri",
",",
"&",
"block",
")",
"clear",
"uri",
"=",
"URI",
".",
"parse",
"(",
"uri",
")",
"@req",
"=",
"Net",
"::",
"HTTP",
"::",
"Get",
".",
"new",
"uri",
".",
"request_uri",
"set_common_info",
"(",
"@req",
... | Get contents, for example, service-document, categories, and feed. | [
"Get",
"contents",
"for",
"example",
"service",
"-",
"document",
"categories",
"and",
"feed",
"."
] | f4bb354bf56d1c0a85af38f6004eefacb44c336f | https://github.com/lyokato/ruby-atomutil/blob/f4bb354bf56d1c0a85af38f6004eefacb44c336f/lib/atomutil.rb#L1515-L1529 | train |
ndlib/rof | lib/rof/translators/osf_to_rof.rb | ROF::Translators.OsfToRof.fetch_from_ttl | def fetch_from_ttl(ttl_file)
graph = RDF::Turtle::Reader.open(ttl_file, prefixes: ROF::OsfPrefixList.dup)
JSON::LD::API.fromRdf(graph)
end | ruby | def fetch_from_ttl(ttl_file)
graph = RDF::Turtle::Reader.open(ttl_file, prefixes: ROF::OsfPrefixList.dup)
JSON::LD::API.fromRdf(graph)
end | [
"def",
"fetch_from_ttl",
"(",
"ttl_file",
")",
"graph",
"=",
"RDF",
"::",
"Turtle",
"::",
"Reader",
".",
"open",
"(",
"ttl_file",
",",
"prefixes",
":",
"ROF",
"::",
"OsfPrefixList",
".",
"dup",
")",
"JSON",
"::",
"LD",
"::",
"API",
".",
"fromRdf",
"(",... | reads a ttl file and makes it a JSON-LD file that we can parse | [
"reads",
"a",
"ttl",
"file",
"and",
"makes",
"it",
"a",
"JSON",
"-",
"LD",
"file",
"that",
"we",
"can",
"parse"
] | 18a8cc009540a868447952eed82de035451025e8 | https://github.com/ndlib/rof/blob/18a8cc009540a868447952eed82de035451025e8/lib/rof/translators/osf_to_rof.rb#L80-L83 | train |
ndlib/rof | lib/rof/translators/osf_to_rof.rb | ROF::Translators.OsfToRof.apply_previous_archived_version_if_applicable | def apply_previous_archived_version_if_applicable(rels_ext)
# If a previously archived pid was passed in, use it to set pav:previousVersion
# If not, check SOLR for one.
pid = previously_archived_pid_finder.call(archive_type, osf_project_identifier)
pid = ROF::Utility.check_solr_for_previous(con... | ruby | def apply_previous_archived_version_if_applicable(rels_ext)
# If a previously archived pid was passed in, use it to set pav:previousVersion
# If not, check SOLR for one.
pid = previously_archived_pid_finder.call(archive_type, osf_project_identifier)
pid = ROF::Utility.check_solr_for_previous(con... | [
"def",
"apply_previous_archived_version_if_applicable",
"(",
"rels_ext",
")",
"pid",
"=",
"previously_archived_pid_finder",
".",
"call",
"(",
"archive_type",
",",
"osf_project_identifier",
")",
"pid",
"=",
"ROF",
"::",
"Utility",
".",
"check_solr_for_previous",
"(",
"co... | For reference to the assumed RELS-EXT see the following spec in CurateND
@see https://github.com/ndlib/curate_nd/blob/115efec2e046257282a86fe2cd98c7d229d04cf9/spec/repository_models/osf_archive_spec.rb#L97 | [
"For",
"reference",
"to",
"the",
"assumed",
"RELS",
"-",
"EXT",
"see",
"the",
"following",
"spec",
"in",
"CurateND"
] | 18a8cc009540a868447952eed82de035451025e8 | https://github.com/ndlib/rof/blob/18a8cc009540a868447952eed82de035451025e8/lib/rof/translators/osf_to_rof.rb#L124-L131 | train |
ndlib/rof | lib/rof/translators/osf_to_rof.rb | ROF::Translators.OsfToRof.build_archive_record | def build_archive_record
this_rof = {}
this_rof['owner'] = project['owner']
this_rof['type'] = 'OsfArchive'
this_rof['rights'] = map_rights
this_rof['rels-ext'] = map_rels_ext
this_rof['metadata'] = map_metadata
this_rof['files'] = [source_slug + '.tar.gz']
this_rof
e... | ruby | def build_archive_record
this_rof = {}
this_rof['owner'] = project['owner']
this_rof['type'] = 'OsfArchive'
this_rof['rights'] = map_rights
this_rof['rels-ext'] = map_rels_ext
this_rof['metadata'] = map_metadata
this_rof['files'] = [source_slug + '.tar.gz']
this_rof
e... | [
"def",
"build_archive_record",
"this_rof",
"=",
"{",
"}",
"this_rof",
"[",
"'owner'",
"]",
"=",
"project",
"[",
"'owner'",
"]",
"this_rof",
"[",
"'type'",
"]",
"=",
"'OsfArchive'",
"this_rof",
"[",
"'rights'",
"]",
"=",
"map_rights",
"this_rof",
"[",
"'rels-... | Constructs OsfArchive Record from ttl_data, data from the UI form,
and task config data | [
"Constructs",
"OsfArchive",
"Record",
"from",
"ttl_data",
"data",
"from",
"the",
"UI",
"form",
"and",
"task",
"config",
"data"
] | 18a8cc009540a868447952eed82de035451025e8 | https://github.com/ndlib/rof/blob/18a8cc009540a868447952eed82de035451025e8/lib/rof/translators/osf_to_rof.rb#L135-L144 | train |
ndlib/rof | lib/rof/translators/osf_to_rof.rb | ROF::Translators.OsfToRof.map_creator | def map_creator
creator = []
ttl_data[0][@osf_map['hasContributor']].each do |contributor|
# Looping through the primary document and the contributors
ttl_data.each do |item|
next unless item['@id'] == contributor['@id']
if item[@osf_map['isBibliographic']][0]['@value'] =... | ruby | def map_creator
creator = []
ttl_data[0][@osf_map['hasContributor']].each do |contributor|
# Looping through the primary document and the contributors
ttl_data.each do |item|
next unless item['@id'] == contributor['@id']
if item[@osf_map['isBibliographic']][0]['@value'] =... | [
"def",
"map_creator",
"creator",
"=",
"[",
"]",
"ttl_data",
"[",
"0",
"]",
"[",
"@osf_map",
"[",
"'hasContributor'",
"]",
"]",
".",
"each",
"do",
"|",
"contributor",
"|",
"ttl_data",
".",
"each",
"do",
"|",
"item",
"|",
"next",
"unless",
"item",
"[",
... | sets the creator- needs to read another ttl for the User data
only contrubutors with isBibliographic true are considered | [
"sets",
"the",
"creator",
"-",
"needs",
"to",
"read",
"another",
"ttl",
"for",
"the",
"User",
"data",
"only",
"contrubutors",
"with",
"isBibliographic",
"true",
"are",
"considered"
] | 18a8cc009540a868447952eed82de035451025e8 | https://github.com/ndlib/rof/blob/18a8cc009540a868447952eed82de035451025e8/lib/rof/translators/osf_to_rof.rb#L171-L183 | train |
donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.api_token | def api_token
api_token = @options[:api_token] || Git.get_config(KEY_API_TOKEN, :inherited)
if api_token.blank?
api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip
Git.set_config(KEY_API_TOKEN, api_token, :local) unless api_token.blank?
put... | ruby | def api_token
api_token = @options[:api_token] || Git.get_config(KEY_API_TOKEN, :inherited)
if api_token.blank?
api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip
Git.set_config(KEY_API_TOKEN, api_token, :local) unless api_token.blank?
put... | [
"def",
"api_token",
"api_token",
"=",
"@options",
"[",
":api_token",
"]",
"||",
"Git",
".",
"get_config",
"(",
"KEY_API_TOKEN",
",",
":inherited",
")",
"if",
"api_token",
".",
"blank?",
"api_token",
"=",
"ask",
"(",
"'Pivotal API Token (found at https://www.pivotalt... | Returns the user's Pivotal Tracker API token. If this token has not been
configured, prompts the user for the value. The value is checked for in
the _inherited_ Git configuration, but is stored in the _global_ Git
configuration so that it can be used across multiple repositories.
@return [String] The user's Pivo... | [
"Returns",
"the",
"user",
"s",
"Pivotal",
"Tracker",
"API",
"token",
".",
"If",
"this",
"token",
"has",
"not",
"been",
"configured",
"prompts",
"the",
"user",
"for",
"the",
"value",
".",
"The",
"value",
"is",
"checked",
"for",
"in",
"the",
"_inherited_",
... | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L43-L53 | train |
donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.project_id | def project_id
project_id = @options[:project_id] || Git.get_config(KEY_PROJECT_ID, :inherited)
if project_id.empty?
project_id = choose do |menu|
menu.prompt = 'Choose project associated with this repository: '
PivotalTracker::Project.all.sort_by { |project| project.name }.eac... | ruby | def project_id
project_id = @options[:project_id] || Git.get_config(KEY_PROJECT_ID, :inherited)
if project_id.empty?
project_id = choose do |menu|
menu.prompt = 'Choose project associated with this repository: '
PivotalTracker::Project.all.sort_by { |project| project.name }.eac... | [
"def",
"project_id",
"project_id",
"=",
"@options",
"[",
":project_id",
"]",
"||",
"Git",
".",
"get_config",
"(",
"KEY_PROJECT_ID",
",",
":inherited",
")",
"if",
"project_id",
".",
"empty?",
"project_id",
"=",
"choose",
"do",
"|",
"menu",
"|",
"menu",
".",
... | Returns the Pivotal Tracker project id for this repository. If this id
has not been configuration, prompts the user for the value. The value is
checked for in the _inherited_ Git configuration, but is stored in the
_local_ Git configuration so that it is specific to this repository.
@return [String] The reposito... | [
"Returns",
"the",
"Pivotal",
"Tracker",
"project",
"id",
"for",
"this",
"repository",
".",
"If",
"this",
"id",
"has",
"not",
"been",
"configuration",
"prompts",
"the",
"user",
"for",
"the",
"value",
".",
"The",
"value",
"is",
"checked",
"for",
"in",
"the",... | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L79-L96 | train |
donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.story | def story
return @story if @story
story_id = Git.get_config(KEY_STORY_ID, :branch)
if story_id.blank? && (matchdata = /^[a-z0-9_\-]+\/(\d+)(-[a-z0-9_\-]+)?$/i.match(Git.current_branch))
story_id = matchdata[1]
Git.set_config(KEY_STORY_ID, story_id, :branch) unless story_id.blank?
... | ruby | def story
return @story if @story
story_id = Git.get_config(KEY_STORY_ID, :branch)
if story_id.blank? && (matchdata = /^[a-z0-9_\-]+\/(\d+)(-[a-z0-9_\-]+)?$/i.match(Git.current_branch))
story_id = matchdata[1]
Git.set_config(KEY_STORY_ID, story_id, :branch) unless story_id.blank?
... | [
"def",
"story",
"return",
"@story",
"if",
"@story",
"story_id",
"=",
"Git",
".",
"get_config",
"(",
"KEY_STORY_ID",
",",
":branch",
")",
"if",
"story_id",
".",
"blank?",
"&&",
"(",
"matchdata",
"=",
"/",
"\\-",
"\\/",
"\\d",
"\\-",
"/i",
".",
"match",
... | Returns the story associated with the branch
@return [Story] the story associated with the current development branch | [
"Returns",
"the",
"story",
"associated",
"with",
"the",
"branch"
] | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L105-L118 | train |
donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.ask_github_password | def ask_github_password(username = nil)
username ||= github_username
print "Github password for #{username} (never stored): "
if $stdin.tty?
password = askpass
puts ''
password
else
# in testing
$stdin.gets.chomp
end
rescue Interrupt
abort
... | ruby | def ask_github_password(username = nil)
username ||= github_username
print "Github password for #{username} (never stored): "
if $stdin.tty?
password = askpass
puts ''
password
else
# in testing
$stdin.gets.chomp
end
rescue Interrupt
abort
... | [
"def",
"ask_github_password",
"(",
"username",
"=",
"nil",
")",
"username",
"||=",
"github_username",
"print",
"\"Github password for #{username} (never stored): \"",
"if",
"$stdin",
".",
"tty?",
"password",
"=",
"askpass",
"puts",
"''",
"password",
"else",
"$stdin",
... | special prompt that has hidden input | [
"special",
"prompt",
"that",
"has",
"hidden",
"input"
] | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L260-L273 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/payment_processor.rb | PaynetEasy::PaynetEasyApi.PaymentProcessor.execute_query | def execute_query(query_name, payment_transaction)
query = query(query_name)
begin
request = query.create_request payment_transaction
response = make_request request
query.process_response payment_transaction, response
rescue Exception => error
handle_exception error, ... | ruby | def execute_query(query_name, payment_transaction)
query = query(query_name)
begin
request = query.create_request payment_transaction
response = make_request request
query.process_response payment_transaction, response
rescue Exception => error
handle_exception error, ... | [
"def",
"execute_query",
"(",
"query_name",
",",
"payment_transaction",
")",
"query",
"=",
"query",
"(",
"query_name",
")",
"begin",
"request",
"=",
"query",
".",
"create_request",
"payment_transaction",
"response",
"=",
"make_request",
"request",
"query",
".",
"pr... | Executes payment API query
@param query_name [String] Payment API query name
@param payment_transaction [PaymentTransaction] Payment transaction for processing
@return [Response] Query response | [
"Executes",
"payment",
"API",
"query"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/payment_processor.rb#L62-L77 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/payment_processor.rb | PaynetEasy::PaynetEasyApi.PaymentProcessor.process_paynet_easy_callback | def process_paynet_easy_callback(callback_response, payment_transaction)
begin
callback(callback_response.type).process_callback(payment_transaction, callback_response)
rescue Exception => error
handle_exception error, payment_transaction, callback_response
return
end
ha... | ruby | def process_paynet_easy_callback(callback_response, payment_transaction)
begin
callback(callback_response.type).process_callback(payment_transaction, callback_response)
rescue Exception => error
handle_exception error, payment_transaction, callback_response
return
end
ha... | [
"def",
"process_paynet_easy_callback",
"(",
"callback_response",
",",
"payment_transaction",
")",
"begin",
"callback",
"(",
"callback_response",
".",
"type",
")",
".",
"process_callback",
"(",
"payment_transaction",
",",
"callback_response",
")",
"rescue",
"Exception",
... | Executes payment gateway processor for PaynetEasy payment callback
@param callback_response [CallbackResponse] Callback object with data from payment gateway
@param payment_transaction [PaymentTransaction] Payment transaction for processing
@return [CallbackResponse] ... | [
"Executes",
"payment",
"gateway",
"processor",
"for",
"PaynetEasy",
"payment",
"callback"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/payment_processor.rb#L96-L107 | train |
kyohei8/inoreader-api | lib/inoreader/api/app.rb | InoreaderApi.Api.login | def login(un, pw)
response_body = Helper.auth_request un, pw
auth_token = Hash[*response_body.split.collect { |i| i.split('=') }.flatten]['Auth']
raise InoreaderApi::InoreaderApiError.new 'Bad Authentication' if auth_token.nil?
auth_token
rescue => e
raise InoreaderApi::InoreaderApiErr... | ruby | def login(un, pw)
response_body = Helper.auth_request un, pw
auth_token = Hash[*response_body.split.collect { |i| i.split('=') }.flatten]['Auth']
raise InoreaderApi::InoreaderApiError.new 'Bad Authentication' if auth_token.nil?
auth_token
rescue => e
raise InoreaderApi::InoreaderApiErr... | [
"def",
"login",
"(",
"un",
",",
"pw",
")",
"response_body",
"=",
"Helper",
".",
"auth_request",
"un",
",",
"pw",
"auth_token",
"=",
"Hash",
"[",
"*",
"response_body",
".",
"split",
".",
"collect",
"{",
"|",
"i",
"|",
"i",
".",
"split",
"(",
"'='",
... | Authenticate, to return authToken
@param un username or Email
@param pw Password
@return Hash
if success
{
:auth_token => xxxxxxxx
} | [
"Authenticate",
"to",
"return",
"authToken"
] | 4b894dc0fe3a663df5cf1bab0081aee616ac0305 | https://github.com/kyohei8/inoreader-api/blob/4b894dc0fe3a663df5cf1bab0081aee616ac0305/lib/inoreader/api/app.rb#L219-L226 | train |
imanel/libwebsocket | lib/libwebsocket/frame.rb | LibWebSocket.Frame.to_s | def to_s
ary = ["\x00", @buffer.dup, "\xff"]
ary.collect{ |s| s.force_encoding('UTF-8') if s.respond_to?(:force_encoding) }
return ary.join
end | ruby | def to_s
ary = ["\x00", @buffer.dup, "\xff"]
ary.collect{ |s| s.force_encoding('UTF-8') if s.respond_to?(:force_encoding) }
return ary.join
end | [
"def",
"to_s",
"ary",
"=",
"[",
"\"\\x00\"",
",",
"@buffer",
".",
"dup",
",",
"\"\\xff\"",
"]",
"ary",
".",
"collect",
"{",
"|",
"s",
"|",
"s",
".",
"force_encoding",
"(",
"'UTF-8'",
")",
"if",
"s",
".",
"respond_to?",
"(",
":force_encoding",
")",
"}... | Construct a WebSocket frame.
@example
frame = LibWebSocket::Frame.new('foo')
frame.to_s # => \x00foo\xff | [
"Construct",
"a",
"WebSocket",
"frame",
"."
] | 3e071439246f5a2c306e16fefc772d2f6f716f6b | https://github.com/imanel/libwebsocket/blob/3e071439246f5a2c306e16fefc772d2f6f716f6b/lib/libwebsocket/frame.rb#L59-L65 | train |
tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.add | def add(dn, attributes)
attributes = normalize_attributes(attributes)
log_dispatch(:add, dn, attributes)
adapter.add(dn, attributes)
end | ruby | def add(dn, attributes)
attributes = normalize_attributes(attributes)
log_dispatch(:add, dn, attributes)
adapter.add(dn, attributes)
end | [
"def",
"add",
"(",
"dn",
",",
"attributes",
")",
"attributes",
"=",
"normalize_attributes",
"(",
"attributes",
")",
"log_dispatch",
"(",
":add",
",",
"dn",
",",
"attributes",
")",
"adapter",
".",
"add",
"(",
"dn",
",",
"attributes",
")",
"end"
] | Performs an LDAP add. | [
"Performs",
"an",
"LDAP",
"add",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L251-L255 | train |
tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.modify | def modify(dn, attributes)
if attributes.kind_of?(Hash)
attributes = normalize_attributes(attributes)
else
attributes = attributes.map do |(action, key, values)|
[action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : [values].flatten.compact... | ruby | def modify(dn, attributes)
if attributes.kind_of?(Hash)
attributes = normalize_attributes(attributes)
else
attributes = attributes.map do |(action, key, values)|
[action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : [values].flatten.compact... | [
"def",
"modify",
"(",
"dn",
",",
"attributes",
")",
"if",
"attributes",
".",
"kind_of?",
"(",
"Hash",
")",
"attributes",
"=",
"normalize_attributes",
"(",
"attributes",
")",
"else",
"attributes",
"=",
"attributes",
".",
"map",
"do",
"|",
"(",
"action",
","... | Performs an LDAP modify. | [
"Performs",
"an",
"LDAP",
"modify",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L258-L268 | train |
tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.rename | def rename(dn, new_rdn, delete_old, *args)
log_dispatch(:rename, dn, new_rdn, delete_old, *args)
adapter.rename(dn, new_rdn.to_str, delete_old, *args)
end | ruby | def rename(dn, new_rdn, delete_old, *args)
log_dispatch(:rename, dn, new_rdn, delete_old, *args)
adapter.rename(dn, new_rdn.to_str, delete_old, *args)
end | [
"def",
"rename",
"(",
"dn",
",",
"new_rdn",
",",
"delete_old",
",",
"*",
"args",
")",
"log_dispatch",
"(",
":rename",
",",
"dn",
",",
"new_rdn",
",",
"delete_old",
",",
"*",
"args",
")",
"adapter",
".",
"rename",
"(",
"dn",
",",
"new_rdn",
".",
"to_s... | Performs an LDAP modrdn. | [
"Performs",
"an",
"LDAP",
"modrdn",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L277-L280 | train |
tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.compare | def compare(dn, key, value)
log_dispatch(:compare, dn, key, value)
adapter.compare(dn, Ldaptic.encode(key), Ldaptic.encode(value))
end | ruby | def compare(dn, key, value)
log_dispatch(:compare, dn, key, value)
adapter.compare(dn, Ldaptic.encode(key), Ldaptic.encode(value))
end | [
"def",
"compare",
"(",
"dn",
",",
"key",
",",
"value",
")",
"log_dispatch",
"(",
":compare",
",",
"dn",
",",
"key",
",",
"value",
")",
"adapter",
".",
"compare",
"(",
"dn",
",",
"Ldaptic",
".",
"encode",
"(",
"key",
")",
",",
"Ldaptic",
".",
"encod... | Performs an LDAP compare. | [
"Performs",
"an",
"LDAP",
"compare",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L283-L286 | train |
ronyv89/skydrive | lib/skydrive/operations.rb | Skydrive.Operations.upload | def upload folder_path, filename, file, options={}
response = put("/#{folder_path}/files/#{filename}", file.read, options)
end | ruby | def upload folder_path, filename, file, options={}
response = put("/#{folder_path}/files/#{filename}", file.read, options)
end | [
"def",
"upload",
"folder_path",
",",
"filename",
",",
"file",
",",
"options",
"=",
"{",
"}",
"response",
"=",
"put",
"(",
"\"/#{folder_path}/files/#{filename}\"",
",",
"file",
".",
"read",
",",
"options",
")",
"end"
] | Upload a file
@param [String] folder_path Either 'me/skydrive' or FOLDER_ID(id of the parent folder)
@param [String] filename Name of the new file
@param [File] The actual file to be uploaded
@param [Hash] options Any additional options to be passed
@option options [Boolean] :overwrite whether to overwrite the fil... | [
"Upload",
"a",
"file"
] | 6cf7b692f64c6f00a81bc7ca6fffca3020244072 | https://github.com/ronyv89/skydrive/blob/6cf7b692f64c6f00a81bc7ca6fffca3020244072/lib/skydrive/operations.rb#L189-L191 | train |
mamantoha/freshdesk_api_client_rb | lib/freshdesk_api/configuration.rb | FreshdeskAPI.Configuration.options | def options
{
headers: {
accept: :json,
content_type: :json,
accept_encoding: 'gzip ,deflate',
user_agent: "FreshdeskAPI API #{FreshdeskAPI::VERSION}"
},
read_timeout: nil,
open_timeout: nil,
base_url: @base_url
}.merge(client_o... | ruby | def options
{
headers: {
accept: :json,
content_type: :json,
accept_encoding: 'gzip ,deflate',
user_agent: "FreshdeskAPI API #{FreshdeskAPI::VERSION}"
},
read_timeout: nil,
open_timeout: nil,
base_url: @base_url
}.merge(client_o... | [
"def",
"options",
"{",
"headers",
":",
"{",
"accept",
":",
":json",
",",
"content_type",
":",
":json",
",",
"accept_encoding",
":",
"'gzip ,deflate'",
",",
"user_agent",
":",
"\"FreshdeskAPI API #{FreshdeskAPI::VERSION}\"",
"}",
",",
"read_timeout",
":",
"nil",
",... | Sets accept and user_agent headers, and url
@return [Hash] RestClient-formatted hash of options. | [
"Sets",
"accept",
"and",
"user_agent",
"headers",
"and",
"url"
] | 74367fe0dd31bd269197b3f419412ef600031e62 | https://github.com/mamantoha/freshdesk_api_client_rb/blob/74367fe0dd31bd269197b3f419412ef600031e62/lib/freshdesk_api/configuration.rb#L39-L51 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.create_request | def create_request(payment_transaction)
validate_payment_transaction payment_transaction
request = payment_transaction_to_request payment_transaction
request.api_method = @api_method
request.end_point = payment_transaction.query_config.end_point
request.gateway_url = payment_transacti... | ruby | def create_request(payment_transaction)
validate_payment_transaction payment_transaction
request = payment_transaction_to_request payment_transaction
request.api_method = @api_method
request.end_point = payment_transaction.query_config.end_point
request.gateway_url = payment_transacti... | [
"def",
"create_request",
"(",
"payment_transaction",
")",
"validate_payment_transaction",
"payment_transaction",
"request",
"=",
"payment_transaction_to_request",
"payment_transaction",
"request",
".",
"api_method",
"=",
"@api_method",
"request",
".",
"end_point",
"=",
"payme... | Create API gateway request from payment transaction data
@param payment_transaction [PaymentTransaction] Payment transaction for query
@return [Request] Request object | [
"Create",
"API",
"gateway",
"request",
"from",
"payment",
"transaction",
"data"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L45-L61 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.process_response | def process_response(payment_transaction, response)
if response.processing? || response.approved?
validate = :validate_response_on_success
update = :update_payment_transaction_on_success
else
validate = :validate_response_on_error
update = :update_payment_transaction_on_e... | ruby | def process_response(payment_transaction, response)
if response.processing? || response.approved?
validate = :validate_response_on_success
update = :update_payment_transaction_on_success
else
validate = :validate_response_on_error
update = :update_payment_transaction_on_e... | [
"def",
"process_response",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"processing?",
"||",
"response",
".",
"approved?",
"validate",
"=",
":validate_response_on_success",
"update",
"=",
":update_payment_transaction_on_success",
"else",
"valid... | Process API gateway response and update payment transaction
@param payment_transaction [PaymentTransaction] Payment transaction for update
@param response [Response] API gateway response
@return [Response] API gateway response | [
"Process",
"API",
"gateway",
"response",
"and",
"update",
"payment",
"transaction"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L69-L94 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_payment_transaction | def validate_payment_transaction(payment_transaction)
validate_query_config payment_transaction
error_message = ''
missed_fields = []
invalid_fields = []
request_fields_definition.each do |field_name, property_path, is_field_required, validation_rule|
field_value = PropertyA... | ruby | def validate_payment_transaction(payment_transaction)
validate_query_config payment_transaction
error_message = ''
missed_fields = []
invalid_fields = []
request_fields_definition.each do |field_name, property_path, is_field_required, validation_rule|
field_value = PropertyA... | [
"def",
"validate_payment_transaction",
"(",
"payment_transaction",
")",
"validate_query_config",
"payment_transaction",
"error_message",
"=",
"''",
"missed_fields",
"=",
"[",
"]",
"invalid_fields",
"=",
"[",
"]",
"request_fields_definition",
".",
"each",
"do",
"|",
"fie... | Validates payment transaction before request constructing
@param payment_transaction [PaymentTransaction] Payment transaction for validation | [
"Validates",
"payment",
"transaction",
"before",
"request",
"constructing"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L101-L133 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.payment_transaction_to_request | def payment_transaction_to_request(payment_transaction)
request_fields = {}
request_fields_definition.each do |field_name, property_path, _|
field_value = PropertyAccessor.get_value payment_transaction, property_path
if field_value
request_fields[field_name] = field_value
... | ruby | def payment_transaction_to_request(payment_transaction)
request_fields = {}
request_fields_definition.each do |field_name, property_path, _|
field_value = PropertyAccessor.get_value payment_transaction, property_path
if field_value
request_fields[field_name] = field_value
... | [
"def",
"payment_transaction_to_request",
"(",
"payment_transaction",
")",
"request_fields",
"=",
"{",
"}",
"request_fields_definition",
".",
"each",
"do",
"|",
"field_name",
",",
"property_path",
",",
"_",
"|",
"field_value",
"=",
"PropertyAccessor",
".",
"get_value",... | Creates request from payment transaction
@param payment_transaction [PaymentTransaction] Payment transaction for request constructing
@return [Request] Request object | [
"Creates",
"request",
"from",
"payment",
"transaction"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L140-L152 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_response_on_success | def validate_response_on_success(payment_transaction, response)
if response.type != success_response_type
raise ValidationError, "Response type '#{response.type}' does " +
"not match success response type '#{success_response_type}'"
end
missed_fields = []
... | ruby | def validate_response_on_success(payment_transaction, response)
if response.type != success_response_type
raise ValidationError, "Response type '#{response.type}' does " +
"not match success response type '#{success_response_type}'"
end
missed_fields = []
... | [
"def",
"validate_response_on_success",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"type",
"!=",
"success_response_type",
"raise",
"ValidationError",
",",
"\"Response type '#{response.type}' does \"",
"+",
"\"not match success response type '#{success... | Validates response before payment transaction updating
if payment transaction is processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for validating | [
"Validates",
"response",
"before",
"payment",
"transaction",
"updating",
"if",
"payment",
"transaction",
"is",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L175-L192 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_response_on_error | def validate_response_on_error(payment_transaction, response)
unless [success_response_type, 'error', 'validation-error'].include? response.type
raise ValidationError, "Unknown response type '#{response.type}'"
end
validate_client_id payment_transaction, response
end | ruby | def validate_response_on_error(payment_transaction, response)
unless [success_response_type, 'error', 'validation-error'].include? response.type
raise ValidationError, "Unknown response type '#{response.type}'"
end
validate_client_id payment_transaction, response
end | [
"def",
"validate_response_on_error",
"(",
"payment_transaction",
",",
"response",
")",
"unless",
"[",
"success_response_type",
",",
"'error'",
",",
"'validation-error'",
"]",
".",
"include?",
"response",
".",
"type",
"raise",
"ValidationError",
",",
"\"Unknown response ... | Validates response before payment transaction updating
if payment transaction is not processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for validating | [
"Validates",
"response",
"before",
"payment",
"transaction",
"updating",
"if",
"payment",
"transaction",
"is",
"not",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L199-L205 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.update_payment_transaction_on_success | def update_payment_transaction_on_success(payment_transaction, response)
payment_transaction.status = response.status
set_paynet_id payment_transaction, response
end | ruby | def update_payment_transaction_on_success(payment_transaction, response)
payment_transaction.status = response.status
set_paynet_id payment_transaction, response
end | [
"def",
"update_payment_transaction_on_success",
"(",
"payment_transaction",
",",
"response",
")",
"payment_transaction",
".",
"status",
"=",
"response",
".",
"status",
"set_paynet_id",
"payment_transaction",
",",
"response",
"end"
] | Updates payment transaction by query response data
if payment transaction is processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for payment transaction updating | [
"Updates",
"payment",
"transaction",
"by",
"query",
"response",
"data",
"if",
"payment",
"transaction",
"is",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L212-L215 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.update_payment_transaction_on_error | def update_payment_transaction_on_error(payment_transaction, response)
if response.declined?
payment_transaction.status = response.status
else
payment_transaction.status = PaymentTransaction::STATUS_ERROR
end
payment_transaction.add_error response.error
set_paynet_id payme... | ruby | def update_payment_transaction_on_error(payment_transaction, response)
if response.declined?
payment_transaction.status = response.status
else
payment_transaction.status = PaymentTransaction::STATUS_ERROR
end
payment_transaction.add_error response.error
set_paynet_id payme... | [
"def",
"update_payment_transaction_on_error",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"declined?",
"payment_transaction",
".",
"status",
"=",
"response",
".",
"status",
"else",
"payment_transaction",
".",
"status",
"=",
"PaymentTransacti... | Updates payment transaction by query response data
if payment transaction is not processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for payment transaction updating | [
"Updates",
"payment",
"transaction",
"by",
"query",
"response",
"data",
"if",
"payment",
"transaction",
"is",
"not",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L222-L231 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_query_definition | def validate_query_definition
raise RuntimeError, 'You must configure @request_fields_definition' if request_fields_definition.empty?
raise RuntimeError, 'You must configure @signature_definition' if signature_definition.empty?
raise RuntimeError, 'You must configure @response_fields_definition... | ruby | def validate_query_definition
raise RuntimeError, 'You must configure @request_fields_definition' if request_fields_definition.empty?
raise RuntimeError, 'You must configure @signature_definition' if signature_definition.empty?
raise RuntimeError, 'You must configure @response_fields_definition... | [
"def",
"validate_query_definition",
"raise",
"RuntimeError",
",",
"'You must configure @request_fields_definition'",
"if",
"request_fields_definition",
".",
"empty?",
"raise",
"RuntimeError",
",",
"'You must configure @signature_definition'",
"if",
"signature_definition",
".",
"emp... | Validates query object definition | [
"Validates",
"query",
"object",
"definition"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L243-L248 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_client_id | def validate_client_id(payment_transaction, response)
payment_id = payment_transaction.payment.client_id
response_id = response.payment_client_id
if response_id && payment_id.to_s != response_id.to_s # Different types with equal values must pass validation
raise ValidationError, "Response ... | ruby | def validate_client_id(payment_transaction, response)
payment_id = payment_transaction.payment.client_id
response_id = response.payment_client_id
if response_id && payment_id.to_s != response_id.to_s # Different types with equal values must pass validation
raise ValidationError, "Response ... | [
"def",
"validate_client_id",
"(",
"payment_transaction",
",",
"response",
")",
"payment_id",
"=",
"payment_transaction",
".",
"payment",
".",
"client_id",
"response_id",
"=",
"response",
".",
"payment_client_id",
"if",
"response_id",
"&&",
"payment_id",
".",
"to_s",
... | Check, is payment transaction client order id and query response client order id equal or not.
@param payment_transaction [PaymentTransaction] Payment transaction for update
@param response [Response] API gateway response | [
"Check",
"is",
"payment",
"transaction",
"client",
"order",
"id",
"and",
"query",
"response",
"client",
"order",
"id",
"equal",
"or",
"not",
"."
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L254-L261 | train |
payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.set_paynet_id | def set_paynet_id(payment_transaction, response)
if response.payment_paynet_id
payment_transaction.payment.paynet_id = response.payment_paynet_id
end
end | ruby | def set_paynet_id(payment_transaction, response)
if response.payment_paynet_id
payment_transaction.payment.paynet_id = response.payment_paynet_id
end
end | [
"def",
"set_paynet_id",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"payment_paynet_id",
"payment_transaction",
".",
"payment",
".",
"paynet_id",
"=",
"response",
".",
"payment_paynet_id",
"end",
"end"
] | Set PaynetEasy payment id to payment transaction Payment
@param payment_transaction [PaymentTransaction] Payment transaction for update
@param response [Response] API gateway response | [
"Set",
"PaynetEasy",
"payment",
"id",
"to",
"payment",
"transaction",
"Payment"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L267-L271 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.summary | def summary(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSummary'})
self.class.get("/", :query => options)
end | ruby | def summary(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSummary'})
self.class.get("/", :query => options)
end | [
"def",
"summary",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Provides summary fundraising information for specified politician.
See : http://www.opensecrets.org/api/?method=candSummary&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") blank values returns current cycle. | [
"Provides",
"summary",
"fundraising",
"information",
"for",
"specified",
"politician",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L66-L70 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.contributors | def contributors(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candContrib'})
self.class.get("/", :query => options)
end | ruby | def contributors(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candContrib'})
self.class.get("/", :query => options)
end | [
"def",
"contributors",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"... | Provides the top organizations contributing to specified politician.
See : http://www.opensecrets.org/api/?method=candContrib&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") 2008 or 2010. | [
"Provides",
"the",
"top",
"organizations",
"contributing",
"to",
"specified",
"politician",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L79-L83 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.industries | def industries(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candIndustry'})
self.class.get("/", :query => options)
end | ruby | def industries(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candIndustry'})
self.class.get("/", :query => options)
end | [
"def",
"industries",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{"... | Provides the top industries contributing to a specified politician.
See : http://www.opensecrets.org/api/?method=candIndustry&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") blank values returns current cycle. | [
"Provides",
"the",
"top",
"industries",
"contributing",
"to",
"a",
"specified",
"politician",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L92-L96 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.contributions_by_industry | def contributions_by_industry(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
raise ArgumentError, 'You must provide a :ind option' if options[:ind].nil? || options[:ind].empty?
options.merge!({:method => 'CandIndByInd'})
self.cla... | ruby | def contributions_by_industry(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
raise ArgumentError, 'You must provide a :ind option' if options[:ind].nil? || options[:ind].empty?
options.merge!({:method => 'CandIndByInd'})
self.cla... | [
"def",
"contributions_by_industry",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"raise",
"ArgumentError",... | Provides total contributed to specified candidate from specified industry for specified cycle.
See : http://www.opensecrets.org/api/?method=candIndByInd&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [String] :ind ("") a a 3-character industry code
@option options [optional, Strin... | [
"Provides",
"total",
"contributed",
"to",
"specified",
"candidate",
"from",
"specified",
"industry",
"for",
"specified",
"cycle",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L106-L111 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.sector | def sector(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSector'})
self.class.get("/", :query => options)
end | ruby | def sector(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSector'})
self.class.get("/", :query => options)
end | [
"def",
"sector",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Provides sector total of specified politician's receipts.
See : http://www.opensecrets.org/api/?method=candSector&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") blank values returns current cycle. | [
"Provides",
"sector",
"total",
"of",
"specified",
"politician",
"s",
"receipts",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L120-L124 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Committee.by_industry | def by_industry(options = {})
raise ArgumentError, 'You must provide a :cmte option' if options[:cmte].nil? || options[:cmte].empty?
raise ArgumentError, 'You must provide a :congno option' if options[:congno].nil? || options[:congno].empty?
raise ArgumentError, 'You must provide a :indus option' if o... | ruby | def by_industry(options = {})
raise ArgumentError, 'You must provide a :cmte option' if options[:cmte].nil? || options[:cmte].empty?
raise ArgumentError, 'You must provide a :congno option' if options[:congno].nil? || options[:congno].empty?
raise ArgumentError, 'You must provide a :indus option' if o... | [
"def",
"by_industry",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cmte option'",
"if",
"options",
"[",
":cmte",
"]",
".",
"nil?",
"||",
"options",
"[",
":cmte",
"]",
".",
"empty?",
"raise",
"ArgumentError",
",",
"... | Provides summary fundraising information for a specific committee, industry and Congress number.
See : http://www.opensecrets.org/api/?method=congCmteIndus&output=doc
@option options [String] :cmte ("") Committee ID in CQ format
@option options [String] :congno ("") Congress Number (like 110)
@option options [Str... | [
"Provides",
"summary",
"fundraising",
"information",
"for",
"a",
"specific",
"committee",
"industry",
"and",
"Congress",
"number",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L138-L144 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Organization.get_orgs | def get_orgs(options = {})
raise ArgumentError, 'You must provide a :org option' if options[:org].nil? || options[:org].empty?
options.merge!({:method => 'getOrgs'})
self.class.get("/", :query => options)
end | ruby | def get_orgs(options = {})
raise ArgumentError, 'You must provide a :org option' if options[:org].nil? || options[:org].empty?
options.merge!({:method => 'getOrgs'})
self.class.get("/", :query => options)
end | [
"def",
"get_orgs",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :org option'",
"if",
"options",
"[",
":org",
"]",
".",
"nil?",
"||",
"options",
"[",
":org",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Look up an organization by name.
See : https://www.opensecrets.org/api/?method=getOrgs&output=doc
@option options [String] :org ("") name or partial name of organization requested | [
"Look",
"up",
"an",
"organization",
"by",
"name",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L156-L160 | train |
grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Organization.org_summary | def org_summary(options = {})
raise ArgumentError, 'You must provide a :id option' if options[:id].nil? || options[:id].empty?
options.merge!({:method => 'orgSummary'})
self.class.get("/", :query => options)
end | ruby | def org_summary(options = {})
raise ArgumentError, 'You must provide a :id option' if options[:id].nil? || options[:id].empty?
options.merge!({:method => 'orgSummary'})
self.class.get("/", :query => options)
end | [
"def",
"org_summary",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :id option'",
"if",
"options",
"[",
":id",
"]",
".",
"nil?",
"||",
"options",
"[",
":id",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Provides summary fundraising information for the specified organization id.
See : https://www.opensecrets.org/api/?method=orgSummary&output=doc
@option options [String] :org ("") CRP orgid (available via 'get_orgs' method) | [
"Provides",
"summary",
"fundraising",
"information",
"for",
"the",
"specified",
"organization",
"id",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L168-L172 | train |
petebrowne/massimo | lib/massimo/config.rb | Massimo.Config.path_for | def path_for(resource_name)
if resource_path = send("#{resource_name}_path")
File.expand_path resource_path
else
File.join source_path, resource_name.to_s
end
end | ruby | def path_for(resource_name)
if resource_path = send("#{resource_name}_path")
File.expand_path resource_path
else
File.join source_path, resource_name.to_s
end
end | [
"def",
"path_for",
"(",
"resource_name",
")",
"if",
"resource_path",
"=",
"send",
"(",
"\"#{resource_name}_path\"",
")",
"File",
".",
"expand_path",
"resource_path",
"else",
"File",
".",
"join",
"source_path",
",",
"resource_name",
".",
"to_s",
"end",
"end"
] | Get a full, expanded path for the given resource name. This is either set
in the configuration or determined dynamically based on the name. | [
"Get",
"a",
"full",
"expanded",
"path",
"for",
"the",
"given",
"resource",
"name",
".",
"This",
"is",
"either",
"set",
"in",
"the",
"configuration",
"or",
"determined",
"dynamically",
"based",
"on",
"the",
"name",
"."
] | c450edc531ad358f011da0a47e5d0bc9a038d911 | https://github.com/petebrowne/massimo/blob/c450edc531ad358f011da0a47e5d0bc9a038d911/lib/massimo/config.rb#L131-L137 | train |
mooreryan/parse_fasta | lib/parse_fasta/seq_file.rb | ParseFasta.SeqFile.get_first_char | def get_first_char fname
if File.exists? fname
begin
f = Zlib::GzipReader.open fname
rescue Zlib::GzipFile::Error
f = File.open fname
end
begin
first_char = f.each.peek[0]
return first_char
ensure
f.close
end
... | ruby | def get_first_char fname
if File.exists? fname
begin
f = Zlib::GzipReader.open fname
rescue Zlib::GzipFile::Error
f = File.open fname
end
begin
first_char = f.each.peek[0]
return first_char
ensure
f.close
end
... | [
"def",
"get_first_char",
"fname",
"if",
"File",
".",
"exists?",
"fname",
"begin",
"f",
"=",
"Zlib",
"::",
"GzipReader",
".",
"open",
"fname",
"rescue",
"Zlib",
"::",
"GzipFile",
"::",
"Error",
"f",
"=",
"File",
".",
"open",
"fname",
"end",
"begin",
"firs... | Get the first char of the file whether it is gzip'd or not. No
need to rewind the stream afterwards. | [
"Get",
"the",
"first",
"char",
"of",
"the",
"file",
"whether",
"it",
"is",
"gzip",
"d",
"or",
"not",
".",
"No",
"need",
"to",
"rewind",
"the",
"stream",
"afterwards",
"."
] | 016272371be668addb29d3c92ec6a5d2e07332ad | https://github.com/mooreryan/parse_fasta/blob/016272371be668addb29d3c92ec6a5d2e07332ad/lib/parse_fasta/seq_file.rb#L214-L234 | train |
donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/github_api.rb | GithubPivotalFlow.GitHubAPI.create_pullrequest | def create_pullrequest options
project = options.fetch(:project)
params = {
:base => options.fetch(:base),
:head => options.fetch(:head)
}
if options[:issue]
params[:issue] = options[:issue]
else
params[:title] = options[:title] if options[:title]
... | ruby | def create_pullrequest options
project = options.fetch(:project)
params = {
:base => options.fetch(:base),
:head => options.fetch(:head)
}
if options[:issue]
params[:issue] = options[:issue]
else
params[:title] = options[:title] if options[:title]
... | [
"def",
"create_pullrequest",
"options",
"project",
"=",
"options",
".",
"fetch",
"(",
":project",
")",
"params",
"=",
"{",
":base",
"=>",
"options",
".",
"fetch",
"(",
":base",
")",
",",
":head",
"=>",
"options",
".",
"fetch",
"(",
":head",
")",
"}",
"... | Returns parsed data from the new pull request. | [
"Returns",
"parsed",
"data",
"from",
"the",
"new",
"pull",
"request",
"."
] | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/github_api.rb#L47-L66 | train |
petebrowne/massimo | lib/massimo/watcher.rb | Massimo.Watcher.process | def process
if config_changed?
Massimo::UI.say 'massimo is reloading your site'
@site.reload
@site.process
Massimo::UI.say 'massimo has built your site', :growl => true
elsif changed?
Massimo::UI.say 'massimo has noticed a change'
@site.process
Massimo... | ruby | def process
if config_changed?
Massimo::UI.say 'massimo is reloading your site'
@site.reload
@site.process
Massimo::UI.say 'massimo has built your site', :growl => true
elsif changed?
Massimo::UI.say 'massimo has noticed a change'
@site.process
Massimo... | [
"def",
"process",
"if",
"config_changed?",
"Massimo",
"::",
"UI",
".",
"say",
"'massimo is reloading your site'",
"@site",
".",
"reload",
"@site",
".",
"process",
"Massimo",
"::",
"UI",
".",
"say",
"'massimo has built your site'",
",",
":growl",
"=>",
"true",
"els... | Processes the Site if any of the files have changed. | [
"Processes",
"the",
"Site",
"if",
"any",
"of",
"the",
"files",
"have",
"changed",
"."
] | c450edc531ad358f011da0a47e5d0bc9a038d911 | https://github.com/petebrowne/massimo/blob/c450edc531ad358f011da0a47e5d0bc9a038d911/lib/massimo/watcher.rb#L29-L40 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_form_buttons | def draw_form_buttons(options = {})
content_tag(:table) do
content_tag(:tr) do
# save button
content_tag(:td) do
#cp_bitset = Edgarj::ModelPermission::FlagsBitset
#create_or_update = cp_bitset::CREATE + cp_bitset::UPDATE
tag(:input, {
... | ruby | def draw_form_buttons(options = {})
content_tag(:table) do
content_tag(:tr) do
# save button
content_tag(:td) do
#cp_bitset = Edgarj::ModelPermission::FlagsBitset
#create_or_update = cp_bitset::CREATE + cp_bitset::UPDATE
tag(:input, {
... | [
"def",
"draw_form_buttons",
"(",
"options",
"=",
"{",
"}",
")",
"content_tag",
"(",
":table",
")",
"do",
"content_tag",
"(",
":tr",
")",
"do",
"content_tag",
"(",
":td",
")",
"do",
"tag",
"(",
":input",
",",
"{",
"type",
":",
"'button'",
",",
"name",
... | Draw buttons for form.
When no CREATE/UPDATE permission, save button is disabled.
It can be overwritten by options[:save].
When no DELETE permission, delete button is disabled.
It can be overwritten by options[:delete].
options may have:
:save:: html options for 'save' button.
:search_form:: html opt... | [
"Draw",
"buttons",
"for",
"form",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L18-L73 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_field | def draw_field(f, col, options={})
case col.type
when :date
draw_date(f, col, options[:date] || {})
when :datetime
draw_datetime(f, col, options[:datetime] || {})
when :integer
f.text_field(col.name, options[:integer])
else
f.text_field(col.name, options[:te... | ruby | def draw_field(f, col, options={})
case col.type
when :date
draw_date(f, col, options[:date] || {})
when :datetime
draw_datetime(f, col, options[:datetime] || {})
when :integer
f.text_field(col.name, options[:integer])
else
f.text_field(col.name, options[:te... | [
"def",
"draw_field",
"(",
"f",
",",
"col",
",",
"options",
"=",
"{",
"}",
")",
"case",
"col",
".",
"type",
"when",
":date",
"draw_date",
"(",
"f",
",",
"col",
",",
"options",
"[",
":date",
"]",
"||",
"{",
"}",
")",
"when",
":datetime",
"draw_dateti... | draw default field for col.type
options[type] is passed to each rails helper. Following types are
supported:
* :date
* :datetime
* :integer
* :boolean
* :text
=== INPUTS
f:: FormBuilder object
col:: column info returned by AR.columns, or symbol
options:: options hash passed to each helper. | [
"draw",
"default",
"field",
"for",
"col",
".",
"type"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L122-L133 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_datetime | def draw_datetime(f, col_or_sym, options={})
col_name = get_column_name(col_or_sym)
f.text_field(col_name,
value: datetime_fmt(f.object.send(col_name)))
end | ruby | def draw_datetime(f, col_or_sym, options={})
col_name = get_column_name(col_or_sym)
f.text_field(col_name,
value: datetime_fmt(f.object.send(col_name)))
end | [
"def",
"draw_datetime",
"(",
"f",
",",
"col_or_sym",
",",
"options",
"=",
"{",
"}",
")",
"col_name",
"=",
"get_column_name",
"(",
"col_or_sym",
")",
"f",
".",
"text_field",
"(",
"col_name",
",",
"value",
":",
"datetime_fmt",
"(",
"f",
".",
"object",
".",... | draw calendar datetime select
=== INPUTS
f:: Form builder object.
col_or_sym:: column object returned by rec.class.columns, or symbol
options:: passed to calendar_date_select | [
"draw",
"calendar",
"datetime",
"select"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L165-L169 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_address | def draw_address(f, col_or_sym)
address_name = f.object.class.get_belongs_to_name(col_or_sym)
render('edgarj/address',
f: f,
rec: f.object,
address_name: address_name
)
end | ruby | def draw_address(f, col_or_sym)
address_name = f.object.class.get_belongs_to_name(col_or_sym)
render('edgarj/address',
f: f,
rec: f.object,
address_name: address_name
)
end | [
"def",
"draw_address",
"(",
"f",
",",
"col_or_sym",
")",
"address_name",
"=",
"f",
".",
"object",
".",
"class",
".",
"get_belongs_to_name",
"(",
"col_or_sym",
")",
"render",
"(",
"'edgarj/address'",
",",
"f",
":",
"f",
",",
"rec",
":",
"f",
".",
"object"... | draw 'edgarj_address' field
The column, which is declared as 'edgarj_address', can be
drawn by this helper.
=== INPUTS
f:: FormBuilder
col_or_sym:: column object returned by rec.class.columns, or symbol | [
"draw",
"edgarj_address",
"field"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L179-L186 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_bitset | def draw_bitset(f, col, bitset=nil, options={})
html = ''
bitset = model.const_get(col_name.to_s.camelize + 'Bitset') if !bitset
i = 0
id_array_var = sprintf('%s_%s_var', f.object_name, col.name)
ids = []
for flag in bitset.constants do
... | ruby | def draw_bitset(f, col, bitset=nil, options={})
html = ''
bitset = model.const_get(col_name.to_s.camelize + 'Bitset') if !bitset
i = 0
id_array_var = sprintf('%s_%s_var', f.object_name, col.name)
ids = []
for flag in bitset.constants do
... | [
"def",
"draw_bitset",
"(",
"f",
",",
"col",
",",
"bitset",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"html",
"=",
"''",
"bitset",
"=",
"model",
".",
"const_get",
"(",
"col_name",
".",
"to_s",
".",
"camelize",
"+",
"'Bitset'",
")",
"if",
"!",
... | draw bitset checkboxes.
When model class has integer field (e.g. 'flags') and
Flags module which defines 'bitflag' constant,
model.flags integer column is drawn as bitset checkboxes.
Constant name will be translated by config/locales/*.yml
See ModelPermission for example.
'flags' column value is calculated at c... | [
"draw",
"bitset",
"checkboxes",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L205-L232 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_enum | def draw_enum(f, col_or_sym, enum=nil, options={})
col_name = get_column_name(col_or_sym)
enum = model.const_get(col_name.to_s.camelize) if !enum
sorted_elements = enum.constants.sort{|a,b|
enum.const_get(a) <=> enum.const_get(b)}
op... | ruby | def draw_enum(f, col_or_sym, enum=nil, options={})
col_name = get_column_name(col_or_sym)
enum = model.const_get(col_name.to_s.camelize) if !enum
sorted_elements = enum.constants.sort{|a,b|
enum.const_get(a) <=> enum.const_get(b)}
op... | [
"def",
"draw_enum",
"(",
"f",
",",
"col_or_sym",
",",
"enum",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"col_name",
"=",
"get_column_name",
"(",
"col_or_sym",
")",
"enum",
"=",
"model",
".",
"const_get",
"(",
"col_name",
".",
"to_s",
".",
"cameli... | draw enum selection.
'Enum' in Edgarj is a module which integer constants are defined.
draw_enum() draws selection rather than simple integer text field.
Selection-option label is I18 supported by AR human_const_name API.
See lib/edgarj/model.rb rdoc.
=== EXAMPLE
Followings draws Question module's Priority sel... | [
"draw",
"enum",
"selection",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L267-L281 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_checkbox | def draw_checkbox(f, id, flag, bitset, id_array_var)
val = f.object.send(:flags) || 0
flag_val = bitset.const_get(flag)
tag(:input,
type: 'checkbox',
id: id,
name: id,
value: flag_val,
onChange: "Edgarj.sum_bitset(#{id_array_var... | ruby | def draw_checkbox(f, id, flag, bitset, id_array_var)
val = f.object.send(:flags) || 0
flag_val = bitset.const_get(flag)
tag(:input,
type: 'checkbox',
id: id,
name: id,
value: flag_val,
onChange: "Edgarj.sum_bitset(#{id_array_var... | [
"def",
"draw_checkbox",
"(",
"f",
",",
"id",
",",
"flag",
",",
"bitset",
",",
"id_array_var",
")",
"val",
"=",
"f",
".",
"object",
".",
"send",
"(",
":flags",
")",
"||",
"0",
"flag_val",
"=",
"bitset",
".",
"const_get",
"(",
"flag",
")",
"tag",
"("... | draw Edgarj flags specific checkbox | [
"draw",
"Edgarj",
"flags",
"specific",
"checkbox"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L359-L369 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.find_col | def find_col(rec, sym)
rec.class.columns.detect{|c| c.name == sym.to_s}
end | ruby | def find_col(rec, sym)
rec.class.columns.detect{|c| c.name == sym.to_s}
end | [
"def",
"find_col",
"(",
"rec",
",",
"sym",
")",
"rec",
".",
"class",
".",
"columns",
".",
"detect",
"{",
"|",
"c",
"|",
"c",
".",
"name",
"==",
"sym",
".",
"to_s",
"}",
"end"
] | find column info from name | [
"find",
"column",
"info",
"from",
"name"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L372-L374 | train |
fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.button_for_js | def button_for_js(label, js, html_options={})
tag(:input, {type: 'button', value: label, onClick: js}.merge(
html_options))
end | ruby | def button_for_js(label, js, html_options={})
tag(:input, {type: 'button', value: label, onClick: js}.merge(
html_options))
end | [
"def",
"button_for_js",
"(",
"label",
",",
"js",
",",
"html_options",
"=",
"{",
"}",
")",
"tag",
"(",
":input",
",",
"{",
"type",
":",
"'button'",
",",
"value",
":",
"label",
",",
"onClick",
":",
"js",
"}",
".",
"merge",
"(",
"html_options",
")",
"... | replacement of button_to_function to avoid DEPRECATION WARNING.
When the js is called just once, onClick is simpler than
unobtrusive-javascript approach. | [
"replacement",
"of",
"button_to_function",
"to",
"avoid",
"DEPRECATION",
"WARNING",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L398-L401 | train |
jwoertink/tourets | lib/tourets/utilities.rb | TouRETS.Utilities.map_search_params | def map_search_params(search_params)
Hash[search_params.map {|k, v| [key_map[k], v] }]
end | ruby | def map_search_params(search_params)
Hash[search_params.map {|k, v| [key_map[k], v] }]
end | [
"def",
"map_search_params",
"(",
"search_params",
")",
"Hash",
"[",
"search_params",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"[",
"key_map",
"[",
"k",
"]",
",",
"v",
"]",
"}",
"]",
"end"
] | This takes a hash of search parameters, and modifies
the hash to have the correct key types for the current RETS server | [
"This",
"takes",
"a",
"hash",
"of",
"search",
"parameters",
"and",
"modifies",
"the",
"hash",
"to",
"have",
"the",
"correct",
"key",
"types",
"for",
"the",
"current",
"RETS",
"server"
] | 1cf5b5b061702846d38a261ad256f1641d2553c1 | https://github.com/jwoertink/tourets/blob/1cf5b5b061702846d38a261ad256f1641d2553c1/lib/tourets/utilities.rb#L17-L19 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.