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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
kyrylo/pry-theme | lib/pry-theme/hex.rb | PryTheme.HEX.validate_value | def validate_value(value)
unless value.is_a?(String)
raise TypeError, "can't convert #{ value.class } into PryTheme::HEX"
end
if value !~ PryTheme::HEX::PATTERN
fail ArgumentError, %|invalid value for PryTheme::HEX#new(): "#{value}"|
end
true
end | ruby | def validate_value(value)
unless value.is_a?(String)
raise TypeError, "can't convert #{ value.class } into PryTheme::HEX"
end
if value !~ PryTheme::HEX::PATTERN
fail ArgumentError, %|invalid value for PryTheme::HEX#new(): "#{value}"|
end
true
end | [
"def",
"validate_value",
"(",
"value",
")",
"unless",
"value",
".",
"is_a?",
"(",
"String",
")",
"raise",
"TypeError",
",",
"\"can't convert #{ value.class } into PryTheme::HEX\"",
"end",
"if",
"value",
"!~",
"PryTheme",
"::",
"HEX",
"::",
"PATTERN",
"fail",
"Argu... | Validates whether +value+ is a valid hex colour value.
@param [String] value
@raise [TypeError] if +value+ isn't String
@raise [ArgumentError] if +value+ is malformed
@return [void] | [
"Validates",
"whether",
"+",
"value",
"+",
"is",
"a",
"valid",
"hex",
"colour",
"value",
"."
] | db99825ff4438b04ce8b808b0303200350fe551b | https://github.com/kyrylo/pry-theme/blob/db99825ff4438b04ce8b808b0303200350fe551b/lib/pry-theme/hex.rb#L65-L73 | train |
kyrylo/pry-theme | lib/pry-theme/when_started_hook.rb | PryTheme.WhenStartedHook.recreate_user_themes_from_default_ones | def recreate_user_themes_from_default_ones
FileUtils.mkdir_p(USER_THEMES_DIR) unless File.exist?(USER_THEMES_DIR)
default_themes = Dir.entries(DEF_THEMES_DIR) - %w(. ..)
default_themes.each do |theme|
user_theme_path = File.join(USER_THEMES_DIR, theme)
next if File.exist?(user_theme_p... | ruby | def recreate_user_themes_from_default_ones
FileUtils.mkdir_p(USER_THEMES_DIR) unless File.exist?(USER_THEMES_DIR)
default_themes = Dir.entries(DEF_THEMES_DIR) - %w(. ..)
default_themes.each do |theme|
user_theme_path = File.join(USER_THEMES_DIR, theme)
next if File.exist?(user_theme_p... | [
"def",
"recreate_user_themes_from_default_ones",
"FileUtils",
".",
"mkdir_p",
"(",
"USER_THEMES_DIR",
")",
"unless",
"File",
".",
"exist?",
"(",
"USER_THEMES_DIR",
")",
"default_themes",
"=",
"Dir",
".",
"entries",
"(",
"DEF_THEMES_DIR",
")",
"-",
"%w(",
".",
".."... | Copy a default theme to theme directory, but only if it isn't there yet. | [
"Copy",
"a",
"default",
"theme",
"to",
"theme",
"directory",
"but",
"only",
"if",
"it",
"isn",
"t",
"there",
"yet",
"."
] | db99825ff4438b04ce8b808b0303200350fe551b | https://github.com/kyrylo/pry-theme/blob/db99825ff4438b04ce8b808b0303200350fe551b/lib/pry-theme/when_started_hook.rb#L27-L37 | train |
cldwalker/bond | lib/bond/rc.rb | Bond.Rc.files | def files(input)
(::Readline::FILENAME_COMPLETION_PROC.call(input) || []).map {|f|
f =~ /^~/ ? File.expand_path(f) : f
}
end | ruby | def files(input)
(::Readline::FILENAME_COMPLETION_PROC.call(input) || []).map {|f|
f =~ /^~/ ? File.expand_path(f) : f
}
end | [
"def",
"files",
"(",
"input",
")",
"(",
"::",
"Readline",
"::",
"FILENAME_COMPLETION_PROC",
".",
"call",
"(",
"input",
")",
"||",
"[",
"]",
")",
".",
"map",
"{",
"|",
"f",
"|",
"f",
"=~",
"/",
"/",
"?",
"File",
".",
"expand_path",
"(",
"f",
")",
... | Action method with search which returns array of files that match current input. | [
"Action",
"method",
"with",
"search",
"which",
"returns",
"array",
"of",
"files",
"that",
"match",
"current",
"input",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/rc.rb#L27-L31 | train |
cldwalker/bond | lib/bond/rc.rb | Bond.Rc.objects_of | def objects_of(klass)
object = []
ObjectSpace.each_object(klass) {|e| object.push(e) }
object
end | ruby | def objects_of(klass)
object = []
ObjectSpace.each_object(klass) {|e| object.push(e) }
object
end | [
"def",
"objects_of",
"(",
"klass",
")",
"object",
"=",
"[",
"]",
"ObjectSpace",
".",
"each_object",
"(",
"klass",
")",
"{",
"|",
"e",
"|",
"object",
".",
"push",
"(",
"e",
")",
"}",
"object",
"end"
] | Helper method which returns objects of a given class. | [
"Helper",
"method",
"which",
"returns",
"objects",
"of",
"a",
"given",
"class",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/rc.rb#L34-L38 | train |
cldwalker/bond | lib/bond/mission.rb | Bond.Mission.call_search | def call_search(search, input, list)
Rc.send("#{search}_search", input || '', list)
rescue
message = $!.is_a?(NoMethodError) && !Rc.respond_to?("#{search}_search") ?
"Completion search '#{search}' doesn't exist." :
"Failed during completion search with '#{$!.message}'."
raise Faile... | ruby | def call_search(search, input, list)
Rc.send("#{search}_search", input || '', list)
rescue
message = $!.is_a?(NoMethodError) && !Rc.respond_to?("#{search}_search") ?
"Completion search '#{search}' doesn't exist." :
"Failed during completion search with '#{$!.message}'."
raise Faile... | [
"def",
"call_search",
"(",
"search",
",",
"input",
",",
"list",
")",
"Rc",
".",
"send",
"(",
"\"#{search}_search\"",
",",
"input",
"||",
"''",
",",
"list",
")",
"rescue",
"message",
"=",
"$!",
".",
"is_a?",
"(",
"NoMethodError",
")",
"&&",
"!",
"Rc",
... | Searches possible completions from the action which match the input. | [
"Searches",
"possible",
"completions",
"from",
"the",
"action",
"which",
"match",
"the",
"input",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/mission.rb#L85-L92 | train |
cldwalker/bond | lib/bond/mission.rb | Bond.Mission.call_action | def call_action(input)
@action.respond_to?(:call) ? @action.call(input) : Rc.send(@action, input)
rescue StandardError, SyntaxError
message = $!.is_a?(NoMethodError) && !@action.respond_to?(:call) &&
!Rc.respond_to?(@action) ? "Completion action '#{@action}' doesn't exist." :
"Failed dur... | ruby | def call_action(input)
@action.respond_to?(:call) ? @action.call(input) : Rc.send(@action, input)
rescue StandardError, SyntaxError
message = $!.is_a?(NoMethodError) && !@action.respond_to?(:call) &&
!Rc.respond_to?(@action) ? "Completion action '#{@action}' doesn't exist." :
"Failed dur... | [
"def",
"call_action",
"(",
"input",
")",
"@action",
".",
"respond_to?",
"(",
":call",
")",
"?",
"@action",
".",
"call",
"(",
"input",
")",
":",
"Rc",
".",
"send",
"(",
"@action",
",",
"input",
")",
"rescue",
"StandardError",
",",
"SyntaxError",
"message"... | Calls the action to generate an array of possible completions. | [
"Calls",
"the",
"action",
"to",
"generate",
"an",
"array",
"of",
"possible",
"completions",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/mission.rb#L95-L102 | train |
zverok/magic_cloud | lib/magic_cloud/spriter.rb | MagicCloud.Spriter.ensure_position | def ensure_position(rect)
# no place in current row -> go to next row
if cur_x + rect.width > canvas.width
@cur_x = 0
@cur_y += row_height
@row_height = 0
end
# no place in current canvas -> restart canvas
restart_canvas! if cur_y + rect.height > canvas.height
... | ruby | def ensure_position(rect)
# no place in current row -> go to next row
if cur_x + rect.width > canvas.width
@cur_x = 0
@cur_y += row_height
@row_height = 0
end
# no place in current canvas -> restart canvas
restart_canvas! if cur_y + rect.height > canvas.height
... | [
"def",
"ensure_position",
"(",
"rect",
")",
"if",
"cur_x",
"+",
"rect",
".",
"width",
">",
"canvas",
".",
"width",
"@cur_x",
"=",
"0",
"@cur_y",
"+=",
"row_height",
"@row_height",
"=",
"0",
"end",
"restart_canvas!",
"if",
"cur_y",
"+",
"rect",
".",
"heig... | ensure this rect can be drawn at current position
or shift position of it can't | [
"ensure",
"this",
"rect",
"can",
"be",
"drawn",
"at",
"current",
"position",
"or",
"shift",
"position",
"of",
"it",
"can",
"t"
] | 3c5d2dd19306c0fd557ba46556dc750931b3966f | https://github.com/zverok/magic_cloud/blob/3c5d2dd19306c0fd557ba46556dc750931b3966f/lib/magic_cloud/spriter.rb#L64-L74 | train |
oasic/nbayes | lib/nbayes.rb | NBayes.Data.remove_token_from_category | def remove_token_from_category(category, token)
cat_data(category)[:tokens][token] -= 1
delete_token_from_category(category, token) if cat_data(category)[:tokens][token] < 1
cat_data(category)[:total_tokens] -= 1
delete_category(category) if cat_data(category)[:total_tokens] < 1
end | ruby | def remove_token_from_category(category, token)
cat_data(category)[:tokens][token] -= 1
delete_token_from_category(category, token) if cat_data(category)[:tokens][token] < 1
cat_data(category)[:total_tokens] -= 1
delete_category(category) if cat_data(category)[:total_tokens] < 1
end | [
"def",
"remove_token_from_category",
"(",
"category",
",",
"token",
")",
"cat_data",
"(",
"category",
")",
"[",
":tokens",
"]",
"[",
"token",
"]",
"-=",
"1",
"delete_token_from_category",
"(",
"category",
",",
"token",
")",
"if",
"cat_data",
"(",
"category",
... | Decrement the token counter in a category
If the counter is 0, delete the token.
If the total number of tokens is 0, delete the category. | [
"Decrement",
"the",
"token",
"counter",
"in",
"a",
"category",
"If",
"the",
"counter",
"is",
"0",
"delete",
"the",
"token",
".",
"If",
"the",
"total",
"number",
"of",
"tokens",
"is",
"0",
"delete",
"the",
"category",
"."
] | 3dd46bd2c8a2258ccdb69ee9ceff7d2fb5d62ed5 | https://github.com/oasic/nbayes/blob/3dd46bd2c8a2258ccdb69ee9ceff7d2fb5d62ed5/lib/nbayes.rb#L126-L131 | train |
oasic/nbayes | lib/nbayes.rb | NBayes.Base.load | def load(yml)
if yml.nil?
nbayes = NBayes::Base.new
elsif yml[0..2] == "---"
nbayes = self.class.from_yml(yml)
else
nbayes = self.class.from(yml)
end
nbayes
end | ruby | def load(yml)
if yml.nil?
nbayes = NBayes::Base.new
elsif yml[0..2] == "---"
nbayes = self.class.from_yml(yml)
else
nbayes = self.class.from(yml)
end
nbayes
end | [
"def",
"load",
"(",
"yml",
")",
"if",
"yml",
".",
"nil?",
"nbayes",
"=",
"NBayes",
"::",
"Base",
".",
"new",
"elsif",
"yml",
"[",
"0",
"..",
"2",
"]",
"==",
"\"---\"",
"nbayes",
"=",
"self",
".",
"class",
".",
"from_yml",
"(",
"yml",
")",
"else",... | Load class instance | [
"Load",
"class",
"instance"
] | 3dd46bd2c8a2258ccdb69ee9ceff7d2fb5d62ed5 | https://github.com/oasic/nbayes/blob/3dd46bd2c8a2258ccdb69ee9ceff7d2fb5d62ed5/lib/nbayes.rb#L328-L337 | train |
cldwalker/bond | lib/bond/agent.rb | Bond.Agent.complete | def complete(options={}, &block)
if (mission = create_mission(options, &block)).is_a?(Mission)
mission.place.is_a?(Integer) ? @missions.insert(mission.place - 1, mission).compact! : @missions << mission
sort_last_missions
end
mission
end | ruby | def complete(options={}, &block)
if (mission = create_mission(options, &block)).is_a?(Mission)
mission.place.is_a?(Integer) ? @missions.insert(mission.place - 1, mission).compact! : @missions << mission
sort_last_missions
end
mission
end | [
"def",
"complete",
"(",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"if",
"(",
"mission",
"=",
"create_mission",
"(",
"options",
",",
"&",
"block",
")",
")",
".",
"is_a?",
"(",
"Mission",
")",
"mission",
".",
"place",
".",
"is_a?",
"(",
"Inte... | Creates a mission. | [
"Creates",
"a",
"mission",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/agent.rb#L20-L26 | train |
cldwalker/bond | lib/bond/agent.rb | Bond.Agent.recomplete | def recomplete(options={}, &block)
if (mission = create_mission(options, &block)).is_a?(Mission)
if (existing_mission = @missions.find {|e| e.name == mission.name })
@missions[@missions.index(existing_mission)] = mission
sort_last_missions
else
return "No existing mis... | ruby | def recomplete(options={}, &block)
if (mission = create_mission(options, &block)).is_a?(Mission)
if (existing_mission = @missions.find {|e| e.name == mission.name })
@missions[@missions.index(existing_mission)] = mission
sort_last_missions
else
return "No existing mis... | [
"def",
"recomplete",
"(",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"if",
"(",
"mission",
"=",
"create_mission",
"(",
"options",
",",
"&",
"block",
")",
")",
".",
"is_a?",
"(",
"Mission",
")",
"if",
"(",
"existing_mission",
"=",
"@missions",
... | Creates a mission and replaces the mission it matches if possible. | [
"Creates",
"a",
"mission",
"and",
"replaces",
"the",
"mission",
"it",
"matches",
"if",
"possible",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/agent.rb#L29-L39 | train |
cldwalker/bond | lib/bond/agent.rb | Bond.Agent.spy | def spy(input)
if (mission = find_mission(input))
puts mission.match_message, "Possible completions: #{mission.execute.inspect}",
"Matches for #{mission.condition.inspect} are #{mission.matched.to_a.inspect}"
else
puts "Doesn't match a completion."
end
rescue FailedMissio... | ruby | def spy(input)
if (mission = find_mission(input))
puts mission.match_message, "Possible completions: #{mission.execute.inspect}",
"Matches for #{mission.condition.inspect} are #{mission.matched.to_a.inspect}"
else
puts "Doesn't match a completion."
end
rescue FailedMissio... | [
"def",
"spy",
"(",
"input",
")",
"if",
"(",
"mission",
"=",
"find_mission",
"(",
"input",
")",
")",
"puts",
"mission",
".",
"match_message",
",",
"\"Possible completions: #{mission.execute.inspect}\"",
",",
"\"Matches for #{mission.condition.inspect} are #{mission.matched.t... | Given a hypothetical user input, reports back what mission it would have
found and executed. | [
"Given",
"a",
"hypothetical",
"user",
"input",
"reports",
"back",
"what",
"mission",
"it",
"would",
"have",
"found",
"and",
"executed",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/agent.rb#L56-L66 | train |
cldwalker/bond | lib/bond/m.rb | Bond.M.debrief | def debrief(options={})
config.merge! options
config[:readline] ||= default_readline
if !config[:readline].is_a?(Module) &&
Bond.const_defined?(config[:readline].to_s.capitalize)
config[:readline] = Bond.const_get(config[:readline].to_s.capitalize)
end
unless %w{setup line_... | ruby | def debrief(options={})
config.merge! options
config[:readline] ||= default_readline
if !config[:readline].is_a?(Module) &&
Bond.const_defined?(config[:readline].to_s.capitalize)
config[:readline] = Bond.const_get(config[:readline].to_s.capitalize)
end
unless %w{setup line_... | [
"def",
"debrief",
"(",
"options",
"=",
"{",
"}",
")",
"config",
".",
"merge!",
"options",
"config",
"[",
":readline",
"]",
"||=",
"default_readline",
"if",
"!",
"config",
"[",
":readline",
"]",
".",
"is_a?",
"(",
"Module",
")",
"&&",
"Bond",
".",
"cons... | Validates and sets values in M.config. | [
"Validates",
"and",
"sets",
"values",
"in",
"M",
".",
"config",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/m.rb#L49-L59 | train |
cldwalker/bond | lib/bond/m.rb | Bond.M.find_gem_file | def find_gem_file(rubygem, file)
begin gem(rubygem); rescue Exception; end
(dir = $:.find {|e| File.exist?(File.join(e, file)) }) && File.join(dir, file)
end | ruby | def find_gem_file(rubygem, file)
begin gem(rubygem); rescue Exception; end
(dir = $:.find {|e| File.exist?(File.join(e, file)) }) && File.join(dir, file)
end | [
"def",
"find_gem_file",
"(",
"rubygem",
",",
"file",
")",
"begin",
"gem",
"(",
"rubygem",
")",
";",
"rescue",
"Exception",
";",
"end",
"(",
"dir",
"=",
"$:",
".",
"find",
"{",
"|",
"e",
"|",
"File",
".",
"exist?",
"(",
"File",
".",
"join",
"(",
"... | Finds the full path to a gem's file relative it's load path directory.
Returns nil if not found. | [
"Finds",
"the",
"full",
"path",
"to",
"a",
"gem",
"s",
"file",
"relative",
"it",
"s",
"load",
"path",
"directory",
".",
"Returns",
"nil",
"if",
"not",
"found",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/m.rb#L83-L86 | train |
cldwalker/bond | lib/bond/m.rb | Bond.M.load_file | def load_file(file)
Rc.module_eval File.read(file)
rescue Exception => e
$stderr.puts "Bond Error: Completion file '#{file}' failed to load with:", e.message
end | ruby | def load_file(file)
Rc.module_eval File.read(file)
rescue Exception => e
$stderr.puts "Bond Error: Completion file '#{file}' failed to load with:", e.message
end | [
"def",
"load_file",
"(",
"file",
")",
"Rc",
".",
"module_eval",
"File",
".",
"read",
"(",
"file",
")",
"rescue",
"Exception",
"=>",
"e",
"$stderr",
".",
"puts",
"\"Bond Error: Completion file '#{file}' failed to load with:\"",
",",
"e",
".",
"message",
"end"
] | Loads a completion file in Rc namespace. | [
"Loads",
"a",
"completion",
"file",
"in",
"Rc",
"namespace",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/m.rb#L89-L93 | train |
cldwalker/bond | lib/bond/m.rb | Bond.M.load_dir | def load_dir(base_dir)
if File.exist?(dir = File.join(base_dir, 'completions'))
Dir[dir + '/*.rb'].each {|file| load_file(file) }
true
end
end | ruby | def load_dir(base_dir)
if File.exist?(dir = File.join(base_dir, 'completions'))
Dir[dir + '/*.rb'].each {|file| load_file(file) }
true
end
end | [
"def",
"load_dir",
"(",
"base_dir",
")",
"if",
"File",
".",
"exist?",
"(",
"dir",
"=",
"File",
".",
"join",
"(",
"base_dir",
",",
"'completions'",
")",
")",
"Dir",
"[",
"dir",
"+",
"'/*.rb'",
"]",
".",
"each",
"{",
"|",
"file",
"|",
"load_file",
"(... | Loads completion files in given directory. | [
"Loads",
"completion",
"files",
"in",
"given",
"directory",
"."
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/m.rb#L96-L101 | train |
cldwalker/bond | lib/bond/m.rb | Bond.M.home | def home
['HOME', 'USERPROFILE'].each {|e| return ENV[e] if ENV[e] }
return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
File.expand_path("~")
rescue
File::ALT_SEPARATOR ? "C:/" : "/"
end | ruby | def home
['HOME', 'USERPROFILE'].each {|e| return ENV[e] if ENV[e] }
return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
File.expand_path("~")
rescue
File::ALT_SEPARATOR ? "C:/" : "/"
end | [
"def",
"home",
"[",
"'HOME'",
",",
"'USERPROFILE'",
"]",
".",
"each",
"{",
"|",
"e",
"|",
"return",
"ENV",
"[",
"e",
"]",
"if",
"ENV",
"[",
"e",
"]",
"}",
"return",
"\"#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}\"",
"if",
"ENV",
"[",
"'HOMEDRIVE'",
"]",
"&&",
... | Find a user's home in a cross-platform way | [
"Find",
"a",
"user",
"s",
"home",
"in",
"a",
"cross",
"-",
"platform",
"way"
] | 19b0a9af11c59b1542f200f7288308315c47fda8 | https://github.com/cldwalker/bond/blob/19b0a9af11c59b1542f200f7288308315c47fda8/lib/bond/m.rb#L109-L115 | train |
kost/nessus_rest-ruby | lib/nessus_rest.rb | NessusREST.Client.user_add | def user_add(username, password, permissions, type)
payload = {
:username => username,
:password => password,
:permissions => permissions,
:type => type,
:json => 1
}
http_post(:uri=>"/users", :fields=>x_cookie, :data=>payload)
end | ruby | def user_add(username, password, permissions, type)
payload = {
:username => username,
:password => password,
:permissions => permissions,
:type => type,
:json => 1
}
http_post(:uri=>"/users", :fields=>x_cookie, :data=>payload)
end | [
"def",
"user_add",
"(",
"username",
",",
"password",
",",
"permissions",
",",
"type",
")",
"payload",
"=",
"{",
":username",
"=>",
"username",
",",
":password",
"=>",
"password",
",",
":permissions",
"=>",
"permissions",
",",
":type",
"=>",
"type",
",",
":... | Add user to server
returns: JSON parsed object
Usage:
n=NessusREST::Client.new (:url=>'https://localhost:8834', :username=>'user', :password=> 'password')
pp n.user_add('user','password','16','local')
Reference:
https://localhost:8834/api#/resources/users/create | [
"Add",
"user",
"to",
"server"
] | 841c20eeea3bbd4154f74ef442ddd4d3e0224770 | https://github.com/kost/nessus_rest-ruby/blob/841c20eeea3bbd4154f74ef442ddd4d3e0224770/lib/nessus_rest.rb#L203-L212 | train |
kost/nessus_rest-ruby | lib/nessus_rest.rb | NessusREST.Client.user_chpasswd | def user_chpasswd(user_id, password)
payload = {
:password => password,
:json => 1
}
res = http_put(:uri=>"/users/#{user_id}/chpasswd", :data=>payload, :fields=>x_cookie)
return res.code
end | ruby | def user_chpasswd(user_id, password)
payload = {
:password => password,
:json => 1
}
res = http_put(:uri=>"/users/#{user_id}/chpasswd", :data=>payload, :fields=>x_cookie)
return res.code
end | [
"def",
"user_chpasswd",
"(",
"user_id",
",",
"password",
")",
"payload",
"=",
"{",
":password",
"=>",
"password",
",",
":json",
"=>",
"1",
"}",
"res",
"=",
"http_put",
"(",
":uri",
"=>",
"\"/users/#{user_id}/chpasswd\"",
",",
":data",
"=>",
"payload",
",",
... | change password for user_id
returns: result code
Usage:
n=NessusREST::Client.new (:url=>'https://localhost:8834', :username=>'user', :password=> 'password')
puts n.user_chpasswd(1,'newPassword') | [
"change",
"password",
"for",
"user_id"
] | 841c20eeea3bbd4154f74ef442ddd4d3e0224770 | https://github.com/kost/nessus_rest-ruby/blob/841c20eeea3bbd4154f74ef442ddd4d3e0224770/lib/nessus_rest.rb#L235-L242 | train |
kost/nessus_rest-ruby | lib/nessus_rest.rb | NessusREST.Client.http_delete | def http_delete(opts={})
ret=http_delete_low(opts)
if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then
authdefault
ret=http_delete_low(opts)
return ret
else
return ret
end
end | ruby | def http_delete(opts={})
ret=http_delete_low(opts)
if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then
authdefault
ret=http_delete_low(opts)
return ret
else
return ret
end
end | [
"def",
"http_delete",
"(",
"opts",
"=",
"{",
"}",
")",
"ret",
"=",
"http_delete_low",
"(",
"opts",
")",
"if",
"ret",
".",
"is_a?",
"(",
"Hash",
")",
"and",
"ret",
".",
"has_key?",
"(",
"'error'",
")",
"and",
"ret",
"[",
"'error'",
"]",
"==",
"'Inva... | Perform HTTP delete method with uri, data and fields
returns: HTTP result object
Usage:
n=NessusREST::Client.new (:url=>'https://localhost:8834', :username=>'user', :password=> 'password')
res = n.http_delete(:uri=>"/session", :fields=>n.x_cookie)
puts res.code | [
"Perform",
"HTTP",
"delete",
"method",
"with",
"uri",
"data",
"and",
"fields"
] | 841c20eeea3bbd4154f74ef442ddd4d3e0224770 | https://github.com/kost/nessus_rest-ruby/blob/841c20eeea3bbd4154f74ef442ddd4d3e0224770/lib/nessus_rest.rb#L658-L667 | train |
kost/nessus_rest-ruby | lib/nessus_rest.rb | NessusREST.Client.http_get | def http_get(opts={})
raw_content = opts[:raw_content] || false
ret=http_get_low(opts)
if !raw_content then
if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then
authdefault
ret=http_get_low(opts)
return ret
else
retu... | ruby | def http_get(opts={})
raw_content = opts[:raw_content] || false
ret=http_get_low(opts)
if !raw_content then
if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then
authdefault
ret=http_get_low(opts)
return ret
else
retu... | [
"def",
"http_get",
"(",
"opts",
"=",
"{",
"}",
")",
"raw_content",
"=",
"opts",
"[",
":raw_content",
"]",
"||",
"false",
"ret",
"=",
"http_get_low",
"(",
"opts",
")",
"if",
"!",
"raw_content",
"then",
"if",
"ret",
".",
"is_a?",
"(",
"Hash",
")",
"and... | Perform HTTP get method with uri and fields
returns: JSON parsed object (if JSON parseable)
Usage:
n=NessusREST::Client.new (:url=>'https://localhost:8834', :username=>'user', :password=> 'password')
pp n.http_get(:uri=>"/users", :fields=>n.x_cookie) | [
"Perform",
"HTTP",
"get",
"method",
"with",
"uri",
"and",
"fields"
] | 841c20eeea3bbd4154f74ef442ddd4d3e0224770 | https://github.com/kost/nessus_rest-ruby/blob/841c20eeea3bbd4154f74ef442ddd4d3e0224770/lib/nessus_rest.rb#L706-L720 | train |
kost/nessus_rest-ruby | lib/nessus_rest.rb | NessusREST.Client.http_post | def http_post(opts={})
if opts.has_key?(:authenticationmethod) then
# i know authzmethod = opts.delete(:authorizationmethod) is short, but not readable
authzmethod = opts[:authenticationmethod]
opts.delete(:authenticationmethod)
end
ret=http_post_low(opts)
if ret.is_a?(Ha... | ruby | def http_post(opts={})
if opts.has_key?(:authenticationmethod) then
# i know authzmethod = opts.delete(:authorizationmethod) is short, but not readable
authzmethod = opts[:authenticationmethod]
opts.delete(:authenticationmethod)
end
ret=http_post_low(opts)
if ret.is_a?(Ha... | [
"def",
"http_post",
"(",
"opts",
"=",
"{",
"}",
")",
"if",
"opts",
".",
"has_key?",
"(",
":authenticationmethod",
")",
"then",
"authzmethod",
"=",
"opts",
"[",
":authenticationmethod",
"]",
"opts",
".",
"delete",
"(",
":authenticationmethod",
")",
"end",
"re... | Perform HTTP post method with uri, data, body and fields
returns: JSON parsed object (if JSON parseable)
Usage:
n=NessusREST::Client.new (:url=>'https://localhost:8834', :username=>'user', :password=> 'password')
pp n.http_post(:uri=>"/scans/#{scan_id}/launch", :fields=>n.x_cookie) | [
"Perform",
"HTTP",
"post",
"method",
"with",
"uri",
"data",
"body",
"and",
"fields"
] | 841c20eeea3bbd4154f74ef442ddd4d3e0224770 | https://github.com/kost/nessus_rest-ruby/blob/841c20eeea3bbd4154f74ef442ddd4d3e0224770/lib/nessus_rest.rb#L762-L778 | train |
kost/nessus_rest-ruby | lib/nessus_rest.rb | NessusREST.Client.parse_json | def parse_json(body)
buf = {}
begin
buf = JSON.parse(body)
rescue JSON::ParserError
end
buf
end | ruby | def parse_json(body)
buf = {}
begin
buf = JSON.parse(body)
rescue JSON::ParserError
end
buf
end | [
"def",
"parse_json",
"(",
"body",
")",
"buf",
"=",
"{",
"}",
"begin",
"buf",
"=",
"JSON",
".",
"parse",
"(",
"body",
")",
"rescue",
"JSON",
"::",
"ParserError",
"end",
"buf",
"end"
] | Perform JSON parsing of body
returns: JSON parsed object (if JSON parseable) | [
"Perform",
"JSON",
"parsing",
"of",
"body"
] | 841c20eeea3bbd4154f74ef442ddd4d3e0224770 | https://github.com/kost/nessus_rest-ruby/blob/841c20eeea3bbd4154f74ef442ddd4d3e0224770/lib/nessus_rest.rb#L818-L827 | train |
tiabas/oauth2-client | lib/oauth2-client/helper.rb | OAuth2Client.UrlHelper.build_url | def build_url(uri, opts={})
path = opts[:path] || ''
query = opts[:params] || {}
fragment = opts[:fragment] || {}
url = Addressable::URI.parse uri
url.path = path
url.query_values = query unless query.empty?
url.fragment = Addressable::URI.form_encode(fragment) unless fr... | ruby | def build_url(uri, opts={})
path = opts[:path] || ''
query = opts[:params] || {}
fragment = opts[:fragment] || {}
url = Addressable::URI.parse uri
url.path = path
url.query_values = query unless query.empty?
url.fragment = Addressable::URI.form_encode(fragment) unless fr... | [
"def",
"build_url",
"(",
"uri",
",",
"opts",
"=",
"{",
"}",
")",
"path",
"=",
"opts",
"[",
":path",
"]",
"||",
"''",
"query",
"=",
"opts",
"[",
":params",
"]",
"||",
"{",
"}",
"fragment",
"=",
"opts",
"[",
":fragment",
"]",
"||",
"{",
"}",
"url... | convenience method to build response URI | [
"convenience",
"method",
"to",
"build",
"response",
"URI"
] | 1fbc5851427ab9290769a080c61a53d94f552def | https://github.com/tiabas/oauth2-client/blob/1fbc5851427ab9290769a080c61a53d94f552def/lib/oauth2-client/helper.rb#L7-L16 | train |
tiabas/oauth2-client | lib/oauth2-client/helper.rb | OAuth2Client.UrlHelper.generate_urlsafe_key | def generate_urlsafe_key(size=48)
seed = Time.now.to_i
size = size - seed.to_s.length
Base64.encode64("#{ OpenSSL::Random.random_bytes(size) }#{ seed }").gsub(/\W/, '')
end | ruby | def generate_urlsafe_key(size=48)
seed = Time.now.to_i
size = size - seed.to_s.length
Base64.encode64("#{ OpenSSL::Random.random_bytes(size) }#{ seed }").gsub(/\W/, '')
end | [
"def",
"generate_urlsafe_key",
"(",
"size",
"=",
"48",
")",
"seed",
"=",
"Time",
".",
"now",
".",
"to_i",
"size",
"=",
"size",
"-",
"seed",
".",
"to_s",
".",
"length",
"Base64",
".",
"encode64",
"(",
"\"#{ OpenSSL::Random.random_bytes(size) }#{ seed }\"",
")",... | generates a random key of up to +size+ bytes. The value returned is Base64 encoded with non-word
characters removed. | [
"generates",
"a",
"random",
"key",
"of",
"up",
"to",
"+",
"size",
"+",
"bytes",
".",
"The",
"value",
"returned",
"is",
"Base64",
"encoded",
"with",
"non",
"-",
"word",
"characters",
"removed",
"."
] | 1fbc5851427ab9290769a080c61a53d94f552def | https://github.com/tiabas/oauth2-client/blob/1fbc5851427ab9290769a080c61a53d94f552def/lib/oauth2-client/helper.rb#L20-L24 | train |
tiabas/oauth2-client | lib/oauth2-client/helper.rb | OAuth2Client.UrlHelper.to_query | def to_query(params)
unless params.is_a?(Hash)
raise "Expected Hash but got #{params.class.name}"
end
Addressable::URI.form_encode(params)
end | ruby | def to_query(params)
unless params.is_a?(Hash)
raise "Expected Hash but got #{params.class.name}"
end
Addressable::URI.form_encode(params)
end | [
"def",
"to_query",
"(",
"params",
")",
"unless",
"params",
".",
"is_a?",
"(",
"Hash",
")",
"raise",
"\"Expected Hash but got #{params.class.name}\"",
"end",
"Addressable",
"::",
"URI",
".",
"form_encode",
"(",
"params",
")",
"end"
] | converts a hash to a URI query string
@params [Hash] params URI parameters | [
"converts",
"a",
"hash",
"to",
"a",
"URI",
"query",
"string"
] | 1fbc5851427ab9290769a080c61a53d94f552def | https://github.com/tiabas/oauth2-client/blob/1fbc5851427ab9290769a080c61a53d94f552def/lib/oauth2-client/helper.rb#L39-L44 | train |
ruby-odata/odata | lib/odata/entity.rb | OData.Entity.[] | def [](property_name)
if get_property(property_name).is_a?(::OData::ComplexType)
get_property(property_name)
else
get_property(property_name).value
end
rescue NoMethodError
raise ArgumentError, "Unknown property: #{property_name}"
end | ruby | def [](property_name)
if get_property(property_name).is_a?(::OData::ComplexType)
get_property(property_name)
else
get_property(property_name).value
end
rescue NoMethodError
raise ArgumentError, "Unknown property: #{property_name}"
end | [
"def",
"[]",
"(",
"property_name",
")",
"if",
"get_property",
"(",
"property_name",
")",
".",
"is_a?",
"(",
"::",
"OData",
"::",
"ComplexType",
")",
"get_property",
"(",
"property_name",
")",
"else",
"get_property",
"(",
"property_name",
")",
".",
"value",
"... | Get property value
@param property_name [to_s]
@return [*] | [
"Get",
"property",
"value"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/entity.rb#L40-L48 | train |
ruby-odata/odata | lib/odata/entity.rb | OData.Entity.[]= | def []=(property_name, value)
properties[property_name.to_s].value = value
rescue NoMethodError
raise ArgumentError, "Unknown property: #{property_name}"
end | ruby | def []=(property_name, value)
properties[property_name.to_s].value = value
rescue NoMethodError
raise ArgumentError, "Unknown property: #{property_name}"
end | [
"def",
"[]=",
"(",
"property_name",
",",
"value",
")",
"properties",
"[",
"property_name",
".",
"to_s",
"]",
".",
"value",
"=",
"value",
"rescue",
"NoMethodError",
"raise",
"ArgumentError",
",",
"\"Unknown property: #{property_name}\"",
"end"
] | Set property value
@param property_name [to_s]
@param value [*] | [
"Set",
"property",
"value"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/entity.rb#L53-L57 | train |
ruby-odata/odata | lib/odata/entity.rb | OData.Entity.to_xml | def to_xml
builder = Nokogiri::XML::Builder.new do |xml|
xml.entry('xmlns' => 'http://www.w3.org/2005/Atom',
'xmlns:data' => 'http://schemas.microsoft.com/ado/2007/08/dataservices',
'xmlns:metadata' => 'http://schemas.microsoft.com/ado/2007/08/dataservic... | ruby | def to_xml
builder = Nokogiri::XML::Builder.new do |xml|
xml.entry('xmlns' => 'http://www.w3.org/2005/Atom',
'xmlns:data' => 'http://schemas.microsoft.com/ado/2007/08/dataservices',
'xmlns:metadata' => 'http://schemas.microsoft.com/ado/2007/08/dataservic... | [
"def",
"to_xml",
"builder",
"=",
"Nokogiri",
"::",
"XML",
"::",
"Builder",
".",
"new",
"do",
"|",
"xml",
"|",
"xml",
".",
"entry",
"(",
"'xmlns'",
"=>",
"'http://www.w3.org/2005/Atom'",
",",
"'xmlns:data'",
"=>",
"'http://schemas.microsoft.com/ado/2007/08/dataservic... | Converts Entity to its XML representation.
@return [String] | [
"Converts",
"Entity",
"to",
"its",
"XML",
"representation",
"."
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/entity.rb#L112-L135 | train |
ruby-odata/odata | lib/odata/service_registry.rb | OData.ServiceRegistry.add | def add(service)
initialize_instance_variables
@services << service if service.is_a?(OData::Service) && !@services.include?(service)
@services_by_name[service.name] = @services.find_index(service)
@services_by_url[service.service_url] = @services.find_index(service)
end | ruby | def add(service)
initialize_instance_variables
@services << service if service.is_a?(OData::Service) && !@services.include?(service)
@services_by_name[service.name] = @services.find_index(service)
@services_by_url[service.service_url] = @services.find_index(service)
end | [
"def",
"add",
"(",
"service",
")",
"initialize_instance_variables",
"@services",
"<<",
"service",
"if",
"service",
".",
"is_a?",
"(",
"OData",
"::",
"Service",
")",
"&&",
"!",
"@services",
".",
"include?",
"(",
"service",
")",
"@services_by_name",
"[",
"servic... | Add a service to the Registry
@param service [OData::Service] service to add to the registry | [
"Add",
"a",
"service",
"to",
"the",
"Registry"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service_registry.rb#L11-L16 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.entity_sets | def entity_sets
@entity_sets ||= Hash[metadata.xpath('//EntityContainer/EntitySet').collect {|entity|
[
entity.attributes['EntityType'].value.gsub("#{namespace}.", ''),
entity.attributes['Name'].value
]
}]
end | ruby | def entity_sets
@entity_sets ||= Hash[metadata.xpath('//EntityContainer/EntitySet').collect {|entity|
[
entity.attributes['EntityType'].value.gsub("#{namespace}.", ''),
entity.attributes['Name'].value
]
}]
end | [
"def",
"entity_sets",
"@entity_sets",
"||=",
"Hash",
"[",
"metadata",
".",
"xpath",
"(",
"'//EntityContainer/EntitySet'",
")",
".",
"collect",
"{",
"|",
"entity",
"|",
"[",
"entity",
".",
"attributes",
"[",
"'EntityType'",
"]",
".",
"value",
".",
"gsub",
"("... | Returns a hash of EntitySet names keyed to their respective EntityType name | [
"Returns",
"a",
"hash",
"of",
"EntitySet",
"names",
"keyed",
"to",
"their",
"respective",
"EntityType",
"name"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L49-L56 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.associations | def associations
@associations ||= Hash[metadata.xpath('//Association').collect do |association_definition|
[
association_definition.attributes['Name'].value,
build_association(association_definition)
]
end]
end | ruby | def associations
@associations ||= Hash[metadata.xpath('//Association').collect do |association_definition|
[
association_definition.attributes['Name'].value,
build_association(association_definition)
]
end]
end | [
"def",
"associations",
"@associations",
"||=",
"Hash",
"[",
"metadata",
".",
"xpath",
"(",
"'//Association'",
")",
".",
"collect",
"do",
"|",
"association_definition",
"|",
"[",
"association_definition",
".",
"attributes",
"[",
"'Name'",
"]",
".",
"value",
",",
... | Returns the associations defined by the service
@return [Hash<OData::Association>] | [
"Returns",
"the",
"associations",
"defined",
"by",
"the",
"service"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L65-L72 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.execute | def execute(url_chunk, additional_options = {})
request = ::Typhoeus::Request.new(
URI.escape("#{service_url}/#{url_chunk}"),
options[:typhoeus].merge({ method: :get
})
.merge(additional_options)
)
request.run
res... | ruby | def execute(url_chunk, additional_options = {})
request = ::Typhoeus::Request.new(
URI.escape("#{service_url}/#{url_chunk}"),
options[:typhoeus].merge({ method: :get
})
.merge(additional_options)
)
request.run
res... | [
"def",
"execute",
"(",
"url_chunk",
",",
"additional_options",
"=",
"{",
"}",
")",
"request",
"=",
"::",
"Typhoeus",
"::",
"Request",
".",
"new",
"(",
"URI",
".",
"escape",
"(",
"\"#{service_url}/#{url_chunk}\"",
")",
",",
"options",
"[",
":typhoeus",
"]",
... | Execute a request against the service
@param url_chunk [to_s] string to append to service url
@param additional_options [Hash] options to pass to Typhoeus
@return [Typhoeus::Response] | [
"Execute",
"a",
"request",
"against",
"the",
"service"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L126-L137 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.find_node | def find_node(results, node_name)
document = ::Nokogiri::XML(results.body)
document.remove_namespaces!
document.xpath("//#{node_name}").first
end | ruby | def find_node(results, node_name)
document = ::Nokogiri::XML(results.body)
document.remove_namespaces!
document.xpath("//#{node_name}").first
end | [
"def",
"find_node",
"(",
"results",
",",
"node_name",
")",
"document",
"=",
"::",
"Nokogiri",
"::",
"XML",
"(",
"results",
".",
"body",
")",
"document",
".",
"remove_namespaces!",
"document",
".",
"xpath",
"(",
"\"//#{node_name}\"",
")",
".",
"first",
"end"
... | Find a specific node in the given result set
@param results [Typhoeus::Response]
@return [Nokogiri::XML::Element] | [
"Find",
"a",
"specific",
"node",
"in",
"the",
"given",
"result",
"set"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L143-L147 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.find_entities | def find_entities(results)
document = ::Nokogiri::XML(results.body)
document.remove_namespaces!
document.xpath('//entry')
end | ruby | def find_entities(results)
document = ::Nokogiri::XML(results.body)
document.remove_namespaces!
document.xpath('//entry')
end | [
"def",
"find_entities",
"(",
"results",
")",
"document",
"=",
"::",
"Nokogiri",
"::",
"XML",
"(",
"results",
".",
"body",
")",
"document",
".",
"remove_namespaces!",
"document",
".",
"xpath",
"(",
"'//entry'",
")",
"end"
] | Find entity entries in a result set
@param results [Typhoeus::Response]
@return [Nokogiri::XML::NodeSet] | [
"Find",
"entity",
"entries",
"in",
"a",
"result",
"set"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L153-L157 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.get_title_property_name | def get_title_property_name(entity_name)
node = metadata.xpath("//EntityType[@Name='#{entity_name}']/Property[@FC_TargetPath='SyndicationTitle']").first
node.nil? ? nil : node.attributes['Name'].value
end | ruby | def get_title_property_name(entity_name)
node = metadata.xpath("//EntityType[@Name='#{entity_name}']/Property[@FC_TargetPath='SyndicationTitle']").first
node.nil? ? nil : node.attributes['Name'].value
end | [
"def",
"get_title_property_name",
"(",
"entity_name",
")",
"node",
"=",
"metadata",
".",
"xpath",
"(",
"\"//EntityType[@Name='#{entity_name}']/Property[@FC_TargetPath='SyndicationTitle']\"",
")",
".",
"first",
"node",
".",
"nil?",
"?",
"nil",
":",
"node",
".",
"attribut... | Get the property used as the title for an entity from metadata.
@param entity_name [to_s] the name of the relevant entity
@return [String] the name of the property used as the entity title | [
"Get",
"the",
"property",
"used",
"as",
"the",
"title",
"for",
"an",
"entity",
"from",
"metadata",
"."
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L172-L175 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.properties_for_entity | def properties_for_entity(entity_name)
type_definition = metadata.xpath("//EntityType[@Name='#{entity_name}']").first
raise ArgumentError, "Unknown EntityType: #{entity_name}" if type_definition.nil?
properties_to_return = {}
type_definition.xpath('./Property').each do |property_xml|
pro... | ruby | def properties_for_entity(entity_name)
type_definition = metadata.xpath("//EntityType[@Name='#{entity_name}']").first
raise ArgumentError, "Unknown EntityType: #{entity_name}" if type_definition.nil?
properties_to_return = {}
type_definition.xpath('./Property').each do |property_xml|
pro... | [
"def",
"properties_for_entity",
"(",
"entity_name",
")",
"type_definition",
"=",
"metadata",
".",
"xpath",
"(",
"\"//EntityType[@Name='#{entity_name}']\"",
")",
".",
"first",
"raise",
"ArgumentError",
",",
"\"Unknown EntityType: #{entity_name}\"",
"if",
"type_definition",
"... | Get the list of properties and their various options for the supplied
Entity name.
@param entity_name [to_s]
@return [Hash]
@api private | [
"Get",
"the",
"list",
"of",
"properties",
"and",
"their",
"various",
"options",
"for",
"the",
"supplied",
"Entity",
"name",
"."
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L200-L209 | train |
ruby-odata/odata | lib/odata/service.rb | OData.Service.properties_for_complex_type | def properties_for_complex_type(type_name)
type_definition = metadata.xpath("//ComplexType[@Name='#{type_name}']").first
raise ArgumentError, "Unknown ComplexType: #{type_name}" if type_definition.nil?
properties_to_return = {}
type_definition.xpath('./Property').each do |property_xml|
p... | ruby | def properties_for_complex_type(type_name)
type_definition = metadata.xpath("//ComplexType[@Name='#{type_name}']").first
raise ArgumentError, "Unknown ComplexType: #{type_name}" if type_definition.nil?
properties_to_return = {}
type_definition.xpath('./Property').each do |property_xml|
p... | [
"def",
"properties_for_complex_type",
"(",
"type_name",
")",
"type_definition",
"=",
"metadata",
".",
"xpath",
"(",
"\"//ComplexType[@Name='#{type_name}']\"",
")",
".",
"first",
"raise",
"ArgumentError",
",",
"\"Unknown ComplexType: #{type_name}\"",
"if",
"type_definition",
... | Get list of properties and their various options for the supplied
ComplexType name.
@param type_name [to_s]
@return [Hash]
@api private | [
"Get",
"list",
"of",
"properties",
"and",
"their",
"various",
"options",
"for",
"the",
"supplied",
"ComplexType",
"name",
"."
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/service.rb#L216-L225 | train |
ruby-odata/odata | lib/odata/entity_set.rb | OData.EntitySet.each | def each(&block)
per_page = @each_batch_size
page = 0
loop do
entities = get_paginated_entities(per_page, page)
break if entities.empty?
entities.each do |entity|
block_given? ? block.call(entity) : yield(entity)
end
page += 1
end
end | ruby | def each(&block)
per_page = @each_batch_size
page = 0
loop do
entities = get_paginated_entities(per_page, page)
break if entities.empty?
entities.each do |entity|
block_given? ? block.call(entity) : yield(entity)
end
page += 1
end
end | [
"def",
"each",
"(",
"&",
"block",
")",
"per_page",
"=",
"@each_batch_size",
"page",
"=",
"0",
"loop",
"do",
"entities",
"=",
"get_paginated_entities",
"(",
"per_page",
",",
"page",
")",
"break",
"if",
"entities",
".",
"empty?",
"entities",
".",
"each",
"do... | Sets up the EntitySet to permit querying for the resources in the set.
@param options [Hash] the options to setup the EntitySet
@return [OData::EntitySet] an instance of the EntitySet
Provided for Enumerable functionality
@param block [block] a block to evaluate
@return [OData::Entity] each entity in turn from t... | [
"Sets",
"up",
"the",
"EntitySet",
"to",
"permit",
"querying",
"for",
"the",
"resources",
"in",
"the",
"set",
"."
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/entity_set.rb#L43-L57 | train |
ruby-odata/odata | lib/odata/entity_set.rb | OData.EntitySet.first | def first(count = 1)
query = OData::Query.new(self).limit(count)
result = service.execute(query)
entities = service.find_entities(result)
res = count == 1 ? single_entity_from_xml(entities) : multiple_entities_from_xml(entities)
res
end | ruby | def first(count = 1)
query = OData::Query.new(self).limit(count)
result = service.execute(query)
entities = service.find_entities(result)
res = count == 1 ? single_entity_from_xml(entities) : multiple_entities_from_xml(entities)
res
end | [
"def",
"first",
"(",
"count",
"=",
"1",
")",
"query",
"=",
"OData",
"::",
"Query",
".",
"new",
"(",
"self",
")",
".",
"limit",
"(",
"count",
")",
"result",
"=",
"service",
".",
"execute",
"(",
"query",
")",
"entities",
"=",
"service",
".",
"find_en... | Return the first n Entities for the set.
If count is 1 it returns the single entity, otherwise its an array of entities
@return [OData::EntitySet] | [
"Return",
"the",
"first",
"n",
"Entities",
"for",
"the",
"set",
".",
"If",
"count",
"is",
"1",
"it",
"returns",
"the",
"single",
"entity",
"otherwise",
"its",
"an",
"array",
"of",
"entities"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/entity_set.rb#L62-L68 | train |
ruby-odata/odata | lib/odata/entity_set.rb | OData.EntitySet.[] | def [](key)
entity = new_entity
key_property = entity.get_property(entity.primary_key)
key_property.value = key
result = service.execute("#{name}(#{key_property.url_value})")
entities = service.find_entities(result)
single_entity_from_xml(entities)
end | ruby | def [](key)
entity = new_entity
key_property = entity.get_property(entity.primary_key)
key_property.value = key
result = service.execute("#{name}(#{key_property.url_value})")
entities = service.find_entities(result)
single_entity_from_xml(entities)
end | [
"def",
"[]",
"(",
"key",
")",
"entity",
"=",
"new_entity",
"key_property",
"=",
"entity",
".",
"get_property",
"(",
"entity",
".",
"primary_key",
")",
"key_property",
".",
"value",
"=",
"key",
"result",
"=",
"service",
".",
"execute",
"(",
"\"#{name}(#{key_p... | Find the Entity with the supplied key value.
@param key [to_s] primary key to lookup
@return [OData::Entity,nil] | [
"Find",
"the",
"Entity",
"with",
"the",
"supplied",
"key",
"value",
"."
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/entity_set.rb#L93-L101 | train |
markburns/numbers_in_words | lib/numbers_in_words/number_group.rb | NumbersInWords.NumberGroup.groups | def groups size
#1234567 => %w(765 432 1)
@array = in_groups_of(@number.to_s.reverse.split(""), size)
#%w(765 432 1) => %w(1 432 765)
@array.reverse!
#%w(1 432 765) => [1, 234, 567]
@array.map! {|group| group.reverse.join("").to_i}
@array.reverse! # put in ascending order of... | ruby | def groups size
#1234567 => %w(765 432 1)
@array = in_groups_of(@number.to_s.reverse.split(""), size)
#%w(765 432 1) => %w(1 432 765)
@array.reverse!
#%w(1 432 765) => [1, 234, 567]
@array.map! {|group| group.reverse.join("").to_i}
@array.reverse! # put in ascending order of... | [
"def",
"groups",
"size",
"@array",
"=",
"in_groups_of",
"(",
"@number",
".",
"to_s",
".",
"reverse",
".",
"split",
"(",
"\"\"",
")",
",",
"size",
")",
"@array",
".",
"reverse!",
"@array",
".",
"map!",
"{",
"|",
"group",
"|",
"group",
".",
"reverse",
... | split into groups this gives us 1234567 => 123 456 7
so we need to reverse first
in stages | [
"split",
"into",
"groups",
"this",
"gives",
"us",
"1234567",
"=",
">",
"123",
"456",
"7",
"so",
"we",
"need",
"to",
"reverse",
"first",
"in",
"stages"
] | dc0ce29fb82b31c877afdc149111fa6ed3d1ed72 | https://github.com/markburns/numbers_in_words/blob/dc0ce29fb82b31c877afdc149111fa6ed3d1ed72/lib/numbers_in_words/number_group.rb#L17-L35 | train |
ruby-odata/odata | lib/odata/query.rb | OData.Query.[] | def [](property)
property_instance = @entity_set.new_entity.get_property(property)
property_instance = property if property_instance.nil?
OData::Query::Criteria.new(property: property_instance)
end | ruby | def [](property)
property_instance = @entity_set.new_entity.get_property(property)
property_instance = property if property_instance.nil?
OData::Query::Criteria.new(property: property_instance)
end | [
"def",
"[]",
"(",
"property",
")",
"property_instance",
"=",
"@entity_set",
".",
"new_entity",
".",
"get_property",
"(",
"property",
")",
"property_instance",
"=",
"property",
"if",
"property_instance",
".",
"nil?",
"OData",
"::",
"Query",
"::",
"Criteria",
".",... | Create a new Query for the provided EntitySet
@param entity_set [OData::EntitySet]
Instantiates an OData::Query::Criteria for the named property.
@param property [to_s] | [
"Create",
"a",
"new",
"Query",
"for",
"the",
"provided",
"EntitySet"
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/query.rb#L16-L20 | train |
ruby-odata/odata | lib/odata/query.rb | OData.Query.execute | def execute
response = entity_set.service.execute(self.to_s)
OData::Query::Result.new(self, response)
end | ruby | def execute
response = entity_set.service.execute(self.to_s)
OData::Query::Result.new(self, response)
end | [
"def",
"execute",
"response",
"=",
"entity_set",
".",
"service",
".",
"execute",
"(",
"self",
".",
"to_s",
")",
"OData",
"::",
"Query",
"::",
"Result",
".",
"new",
"(",
"self",
",",
"response",
")",
"end"
] | Execute the query.
@return [OData::Query::Result] | [
"Execute",
"the",
"query",
"."
] | be4626bebea595dab2250ae4442e59e94b5fd4c6 | https://github.com/ruby-odata/odata/blob/be4626bebea595dab2250ae4442e59e94b5fd4c6/lib/odata/query.rb#L110-L113 | train |
nwops/puppet-retrospec | lib/retrospec/plugins/v1/plugin/generators/provider_generator.rb | Retrospec::Puppet::Generators.ProviderGenerator.template_dir | def template_dir
external_templates = File.expand_path(File.join(config_data[:template_dir], 'providers', 'provider_template.rb.retrospec.erb'))
if File.exist?(external_templates)
File.join(config_data[:template_dir], 'providers')
else
File.expand_path(File.join(File.dirname(File.dirna... | ruby | def template_dir
external_templates = File.expand_path(File.join(config_data[:template_dir], 'providers', 'provider_template.rb.retrospec.erb'))
if File.exist?(external_templates)
File.join(config_data[:template_dir], 'providers')
else
File.expand_path(File.join(File.dirname(File.dirna... | [
"def",
"template_dir",
"external_templates",
"=",
"File",
".",
"expand_path",
"(",
"File",
".",
"join",
"(",
"config_data",
"[",
":template_dir",
"]",
",",
"'providers'",
",",
"'provider_template.rb.retrospec.erb'",
")",
")",
"if",
"File",
".",
"exist?",
"(",
"e... | retrospec will initaialize this class so its up to you
to set any additional variables you need in the context in feed the templates.
returns the path to the templates
first looks inside the external templates directory for specific file
then looks inside the gem path templates directory, which is really only usefu... | [
"retrospec",
"will",
"initaialize",
"this",
"class",
"so",
"its",
"up",
"to",
"you",
"to",
"set",
"any",
"additional",
"variables",
"you",
"need",
"in",
"the",
"context",
"in",
"feed",
"the",
"templates",
".",
"returns",
"the",
"path",
"to",
"the",
"templa... | 89289ec0e86df39dc283a3cb4c392239e5166ec4 | https://github.com/nwops/puppet-retrospec/blob/89289ec0e86df39dc283a3cb4c392239e5166ec4/lib/retrospec/plugins/v1/plugin/generators/provider_generator.rb#L26-L33 | train |
nwops/puppet-retrospec | lib/retrospec/plugins/v1/plugin/generators/provider_generator.rb | Retrospec::Puppet::Generators.ProviderGenerator.type_file | def type_file(p_type = provider_type)
if TypeGenerator::CORE_TYPES.include?(p_type)
type_file = "puppet/type/#{p_type}.rb"
else
type_file = File.join(type_dir, "#{p_type}.rb")
end
type_file
end | ruby | def type_file(p_type = provider_type)
if TypeGenerator::CORE_TYPES.include?(p_type)
type_file = "puppet/type/#{p_type}.rb"
else
type_file = File.join(type_dir, "#{p_type}.rb")
end
type_file
end | [
"def",
"type_file",
"(",
"p_type",
"=",
"provider_type",
")",
"if",
"TypeGenerator",
"::",
"CORE_TYPES",
".",
"include?",
"(",
"p_type",
")",
"type_file",
"=",
"\"puppet/type/#{p_type}.rb\"",
"else",
"type_file",
"=",
"File",
".",
"join",
"(",
"type_dir",
",",
... | returns the type file that the provider uses
if the type file does not exist it assumes a core puppet type
because we could potentially dealing with multiple | [
"returns",
"the",
"type",
"file",
"that",
"the",
"provider",
"uses",
"if",
"the",
"type",
"file",
"does",
"not",
"exist",
"it",
"assumes",
"a",
"core",
"puppet",
"type",
"because",
"we",
"could",
"potentially",
"dealing",
"with",
"multiple"
] | 89289ec0e86df39dc283a3cb4c392239e5166ec4 | https://github.com/nwops/puppet-retrospec/blob/89289ec0e86df39dc283a3cb4c392239e5166ec4/lib/retrospec/plugins/v1/plugin/generators/provider_generator.rb#L68-L75 | train |
nwops/puppet-retrospec | lib/retrospec/plugins/v1/plugin/puppet_module.rb | Utilities.PuppetModule.create_tmp_module_path | def create_tmp_module_path(module_path)
fail 'ModulePathNotFound' unless module_path
path = File.join(tmp_modules_dir, module_dir_name)
unless File.exist?(path) # only create if it doesn't already exist
# create a link where source is the current repo and dest is /tmp/modules/module_name
... | ruby | def create_tmp_module_path(module_path)
fail 'ModulePathNotFound' unless module_path
path = File.join(tmp_modules_dir, module_dir_name)
unless File.exist?(path) # only create if it doesn't already exist
# create a link where source is the current repo and dest is /tmp/modules/module_name
... | [
"def",
"create_tmp_module_path",
"(",
"module_path",
")",
"fail",
"'ModulePathNotFound'",
"unless",
"module_path",
"path",
"=",
"File",
".",
"join",
"(",
"tmp_modules_dir",
",",
"module_dir_name",
")",
"unless",
"File",
".",
"exist?",
"(",
"path",
")",
"FileUtils"... | puts a symlink in that module directory that points back to the user supplied module path | [
"puts",
"a",
"symlink",
"in",
"that",
"module",
"directory",
"that",
"points",
"back",
"to",
"the",
"user",
"supplied",
"module",
"path"
] | 89289ec0e86df39dc283a3cb4c392239e5166ec4 | https://github.com/nwops/puppet-retrospec/blob/89289ec0e86df39dc283a3cb4c392239e5166ec4/lib/retrospec/plugins/v1/plugin/puppet_module.rb#L103-L111 | train |
nwops/puppet-retrospec | lib/retrospec/plugins/v1/plugin/puppet_module.rb | Utilities.PuppetModule.tmp_modules_dir | def tmp_modules_dir
if @tmp_modules_dir.nil? || !File.exist?(@tmp_modules_dir)
tmp_path = File.expand_path(File.join(temporary_environment_path, 'modules'))
FileUtils.mkdir_p(tmp_path)
@tmp_modules_dir = tmp_path
end
@tmp_modules_dir
end | ruby | def tmp_modules_dir
if @tmp_modules_dir.nil? || !File.exist?(@tmp_modules_dir)
tmp_path = File.expand_path(File.join(temporary_environment_path, 'modules'))
FileUtils.mkdir_p(tmp_path)
@tmp_modules_dir = tmp_path
end
@tmp_modules_dir
end | [
"def",
"tmp_modules_dir",
"if",
"@tmp_modules_dir",
".",
"nil?",
"||",
"!",
"File",
".",
"exist?",
"(",
"@tmp_modules_dir",
")",
"tmp_path",
"=",
"File",
".",
"expand_path",
"(",
"File",
".",
"join",
"(",
"temporary_environment_path",
",",
"'modules'",
")",
")... | creates a tmp module directory so puppet can work correctly | [
"creates",
"a",
"tmp",
"module",
"directory",
"so",
"puppet",
"can",
"work",
"correctly"
] | 89289ec0e86df39dc283a3cb4c392239e5166ec4 | https://github.com/nwops/puppet-retrospec/blob/89289ec0e86df39dc283a3cb4c392239e5166ec4/lib/retrospec/plugins/v1/plugin/puppet_module.rb#L148-L155 | train |
nwops/puppet-retrospec | lib/retrospec/plugins/v1/plugin/puppet_module.rb | Utilities.PuppetModule.request | def request(key, method)
instance = ::Puppet::Indirector::Indirection.instance(:resource_type)
indirection_name = 'test'
@request = ::Puppet::Indirector::Request.new(indirection_name, method, key, instance)
@request.environment = puppet_environment
@request
end | ruby | def request(key, method)
instance = ::Puppet::Indirector::Indirection.instance(:resource_type)
indirection_name = 'test'
@request = ::Puppet::Indirector::Request.new(indirection_name, method, key, instance)
@request.environment = puppet_environment
@request
end | [
"def",
"request",
"(",
"key",
",",
"method",
")",
"instance",
"=",
"::",
"Puppet",
"::",
"Indirector",
"::",
"Indirection",
".",
"instance",
"(",
":resource_type",
")",
"indirection_name",
"=",
"'test'",
"@request",
"=",
"::",
"Puppet",
"::",
"Indirector",
"... | creates a puppet resource request to be used indirectly | [
"creates",
"a",
"puppet",
"resource",
"request",
"to",
"be",
"used",
"indirectly"
] | 89289ec0e86df39dc283a3cb4c392239e5166ec4 | https://github.com/nwops/puppet-retrospec/blob/89289ec0e86df39dc283a3cb4c392239e5166ec4/lib/retrospec/plugins/v1/plugin/puppet_module.rb#L178-L184 | train |
airbnb/stemcell | lib/stemcell/launcher.rb | Stemcell.Launcher.render_template | def render_template(opts={})
template_file_path = File.expand_path(TEMPLATE_PATH, __FILE__)
template_file = File.read(template_file_path)
erb_template = ERB.new(template_file)
last_bootstrap_line = LAST_BOOTSTRAP_LINE
generated_template = erb_template.result(binding)
@log.debug "gene... | ruby | def render_template(opts={})
template_file_path = File.expand_path(TEMPLATE_PATH, __FILE__)
template_file = File.read(template_file_path)
erb_template = ERB.new(template_file)
last_bootstrap_line = LAST_BOOTSTRAP_LINE
generated_template = erb_template.result(binding)
@log.debug "gene... | [
"def",
"render_template",
"(",
"opts",
"=",
"{",
"}",
")",
"template_file_path",
"=",
"File",
".",
"expand_path",
"(",
"TEMPLATE_PATH",
",",
"__FILE__",
")",
"template_file",
"=",
"File",
".",
"read",
"(",
"template_file_path",
")",
"erb_template",
"=",
"ERB",... | this is made public for ec2admin usage | [
"this",
"is",
"made",
"public",
"for",
"ec2admin",
"usage"
] | 8427f6a1aad80c85393c0fb7d3f52ac8400b8207 | https://github.com/airbnb/stemcell/blob/8427f6a1aad80c85393c0fb7d3f52ac8400b8207/lib/stemcell/launcher.rb#L245-L253 | train |
airbnb/stemcell | lib/stemcell/launcher.rb | Stemcell.Launcher.get_vpc_security_group_ids | def get_vpc_security_group_ids(vpc_id, group_names)
group_map = {}
@log.info "resolving security groups #{group_names} in #{vpc_id}"
vpc = AWS::EC2::VPC.new(vpc_id, :ec2_endpoint => "ec2.#{@region}.amazonaws.com")
vpc.security_groups.each do |sg|
next if sg.vpc_id != vpc_id
group... | ruby | def get_vpc_security_group_ids(vpc_id, group_names)
group_map = {}
@log.info "resolving security groups #{group_names} in #{vpc_id}"
vpc = AWS::EC2::VPC.new(vpc_id, :ec2_endpoint => "ec2.#{@region}.amazonaws.com")
vpc.security_groups.each do |sg|
next if sg.vpc_id != vpc_id
group... | [
"def",
"get_vpc_security_group_ids",
"(",
"vpc_id",
",",
"group_names",
")",
"group_map",
"=",
"{",
"}",
"@log",
".",
"info",
"\"resolving security groups #{group_names} in #{vpc_id}\"",
"vpc",
"=",
"AWS",
"::",
"EC2",
"::",
"VPC",
".",
"new",
"(",
"vpc_id",
",",
... | Resolve security group names to their ids in the given VPC | [
"Resolve",
"security",
"group",
"names",
"to",
"their",
"ids",
"in",
"the",
"given",
"VPC"
] | 8427f6a1aad80c85393c0fb7d3f52ac8400b8207 | https://github.com/airbnb/stemcell/blob/8427f6a1aad80c85393c0fb7d3f52ac8400b8207/lib/stemcell/launcher.rb#L315-L329 | train |
logicminds/rubyipmi | lib/rubyipmi/commands/basecommand.rb | Rubyipmi.BaseCommand.runcmd | def runcmd
@success = false
@success = run
logger.debug(@lastcall.inspect) unless @lastcall.nil? if logger
logger.debug(@result) unless @result.nil? if logger
@success
end | ruby | def runcmd
@success = false
@success = run
logger.debug(@lastcall.inspect) unless @lastcall.nil? if logger
logger.debug(@result) unless @result.nil? if logger
@success
end | [
"def",
"runcmd",
"@success",
"=",
"false",
"@success",
"=",
"run",
"logger",
".",
"debug",
"(",
"@lastcall",
".",
"inspect",
")",
"unless",
"@lastcall",
".",
"nil?",
"if",
"logger",
"logger",
".",
"debug",
"(",
"@result",
")",
"unless",
"@result",
".",
"... | Use this function to run the command line tool, it will inherently use the options hash for all options
That need to be specified on the command line | [
"Use",
"this",
"function",
"to",
"run",
"the",
"command",
"line",
"tool",
"it",
"will",
"inherently",
"use",
"the",
"options",
"hash",
"for",
"all",
"options",
"That",
"need",
"to",
"be",
"specified",
"on",
"the",
"command",
"line"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/commands/basecommand.rb#L50-L56 | train |
logicminds/rubyipmi | lib/rubyipmi/commands/basecommand.rb | Rubyipmi.BaseCommand.find_fix | def find_fix(result)
return unless result
# The errorcode code hash contains the fix
begin
fix = ErrorCodes.search(result)
@options.merge_notify!(fix)
rescue
Rubyipmi.logger.debug("Could not find fix for error code: \n#{result}") if logger
raise "Could not find fi... | ruby | def find_fix(result)
return unless result
# The errorcode code hash contains the fix
begin
fix = ErrorCodes.search(result)
@options.merge_notify!(fix)
rescue
Rubyipmi.logger.debug("Could not find fix for error code: \n#{result}") if logger
raise "Could not find fi... | [
"def",
"find_fix",
"(",
"result",
")",
"return",
"unless",
"result",
"begin",
"fix",
"=",
"ErrorCodes",
".",
"search",
"(",
"result",
")",
"@options",
".",
"merge_notify!",
"(",
"fix",
")",
"rescue",
"Rubyipmi",
".",
"logger",
".",
"debug",
"(",
"\"Could n... | The findfix method acts like a recursive method and applies fixes defined in the errorcodes
If a fix is found it is applied to the options hash, and then the last run command is retried
until all the fixes are exhausted or a error not defined in the errorcodes is found
this must be overrided in the subclass, as ther... | [
"The",
"findfix",
"method",
"acts",
"like",
"a",
"recursive",
"method",
"and",
"applies",
"fixes",
"defined",
"in",
"the",
"errorcodes",
"If",
"a",
"fix",
"is",
"found",
"it",
"is",
"applied",
"to",
"the",
"options",
"hash",
"and",
"then",
"the",
"last",
... | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/commands/basecommand.rb#L93-L103 | train |
logicminds/rubyipmi | lib/rubyipmi/ipmitool/commands/basecommand.rb | Rubyipmi::Ipmitool.BaseCommand.find_fix | def find_fix(result)
return unless result
# The errorcode code hash contains the fix
begin
fix = ErrorCodes.search(result)
@options.merge_notify!(fix)
rescue
raise "Could not find fix for error code: \n#{result}"
end
end | ruby | def find_fix(result)
return unless result
# The errorcode code hash contains the fix
begin
fix = ErrorCodes.search(result)
@options.merge_notify!(fix)
rescue
raise "Could not find fix for error code: \n#{result}"
end
end | [
"def",
"find_fix",
"(",
"result",
")",
"return",
"unless",
"result",
"begin",
"fix",
"=",
"ErrorCodes",
".",
"search",
"(",
"result",
")",
"@options",
".",
"merge_notify!",
"(",
"fix",
")",
"rescue",
"raise",
"\"Could not find fix for error code: \\n#{result}\"",
... | The findfix method acts like a recursive method and applies fixes defined in the errorcodes
If a fix is found it is applied to the options hash, and then the last run command is retried
until all the fixes are exhausted or a error not defined in the errorcodes is found | [
"The",
"findfix",
"method",
"acts",
"like",
"a",
"recursive",
"method",
"and",
"applies",
"fixes",
"defined",
"in",
"the",
"errorcodes",
"If",
"a",
"fix",
"is",
"found",
"it",
"is",
"applied",
"to",
"the",
"options",
"hash",
"and",
"then",
"the",
"last",
... | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/ipmitool/commands/basecommand.rb#L36-L46 | train |
logicminds/rubyipmi | lib/rubyipmi/freeipmi/commands/chassis.rb | Rubyipmi::Freeipmi.Chassis.bootdevice | def bootdevice(device, reboot = false, persistent = false)
if config.bootdevices.include?(device)
bootstatus = config.bootdevice(device, persistent)
power.cycle if reboot && bootstatus
else
logger.error("Device with name: #{device} is not a valid boot device for host #{options['hostn... | ruby | def bootdevice(device, reboot = false, persistent = false)
if config.bootdevices.include?(device)
bootstatus = config.bootdevice(device, persistent)
power.cycle if reboot && bootstatus
else
logger.error("Device with name: #{device} is not a valid boot device for host #{options['hostn... | [
"def",
"bootdevice",
"(",
"device",
",",
"reboot",
"=",
"false",
",",
"persistent",
"=",
"false",
")",
"if",
"config",
".",
"bootdevices",
".",
"include?",
"(",
"device",
")",
"bootstatus",
"=",
"config",
".",
"bootdevice",
"(",
"device",
",",
"persistent"... | set boot device from given boot device | [
"set",
"boot",
"device",
"from",
"given",
"boot",
"device"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/freeipmi/commands/chassis.rb#L35-L43 | train |
logicminds/rubyipmi | lib/rubyipmi/freeipmi/commands/chassis.rb | Rubyipmi::Freeipmi.Chassis.bootpxe | def bootpxe(reboot = false, persistent = false)
bootstatus = config.bootpxe(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
end | ruby | def bootpxe(reboot = false, persistent = false)
bootstatus = config.bootpxe(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
end | [
"def",
"bootpxe",
"(",
"reboot",
"=",
"false",
",",
"persistent",
"=",
"false",
")",
"bootstatus",
"=",
"config",
".",
"bootpxe",
"(",
"persistent",
")",
"power",
".",
"cycle",
"if",
"reboot",
"&&",
"bootstatus",
"end"
] | set boot device to pxe with option to reboot | [
"set",
"boot",
"device",
"to",
"pxe",
"with",
"option",
"to",
"reboot"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/freeipmi/commands/chassis.rb#L46-L50 | train |
logicminds/rubyipmi | lib/rubyipmi/freeipmi/commands/chassis.rb | Rubyipmi::Freeipmi.Chassis.bootdisk | def bootdisk(reboot = false, persistent = false)
bootstatus = config.bootdisk(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
end | ruby | def bootdisk(reboot = false, persistent = false)
bootstatus = config.bootdisk(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
end | [
"def",
"bootdisk",
"(",
"reboot",
"=",
"false",
",",
"persistent",
"=",
"false",
")",
"bootstatus",
"=",
"config",
".",
"bootdisk",
"(",
"persistent",
")",
"power",
".",
"cycle",
"if",
"reboot",
"&&",
"bootstatus",
"end"
] | set boot device to disk with option to reboot | [
"set",
"boot",
"device",
"to",
"disk",
"with",
"option",
"to",
"reboot"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/freeipmi/commands/chassis.rb#L53-L57 | train |
logicminds/rubyipmi | lib/rubyipmi/freeipmi/commands/chassis.rb | Rubyipmi::Freeipmi.Chassis.bootcdrom | def bootcdrom(reboot = false, persistent = false)
bootstatus = config.bootcdrom(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
end | ruby | def bootcdrom(reboot = false, persistent = false)
bootstatus = config.bootcdrom(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
end | [
"def",
"bootcdrom",
"(",
"reboot",
"=",
"false",
",",
"persistent",
"=",
"false",
")",
"bootstatus",
"=",
"config",
".",
"bootcdrom",
"(",
"persistent",
")",
"power",
".",
"cycle",
"if",
"reboot",
"&&",
"bootstatus",
"end"
] | set boot device to cdrom with option to reboot | [
"set",
"boot",
"device",
"to",
"cdrom",
"with",
"option",
"to",
"reboot"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/freeipmi/commands/chassis.rb#L60-L64 | train |
logicminds/rubyipmi | lib/rubyipmi/ipmitool/commands/chassis.rb | Rubyipmi::Ipmitool.Chassis.bootbios | def bootbios(reboot = false, persistent = false)
bootstatus = config.bootbios(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
bootstatus
end | ruby | def bootbios(reboot = false, persistent = false)
bootstatus = config.bootbios(persistent)
# Only reboot if setting the boot flag was successful
power.cycle if reboot && bootstatus
bootstatus
end | [
"def",
"bootbios",
"(",
"reboot",
"=",
"false",
",",
"persistent",
"=",
"false",
")",
"bootstatus",
"=",
"config",
".",
"bootbios",
"(",
"persistent",
")",
"power",
".",
"cycle",
"if",
"reboot",
"&&",
"bootstatus",
"bootstatus",
"end"
] | boot into bios setup with option to reboot | [
"boot",
"into",
"bios",
"setup",
"with",
"option",
"to",
"reboot"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/ipmitool/commands/chassis.rb#L72-L77 | train |
logicminds/rubyipmi | lib/rubyipmi/ipmitool/commands/chassis.rb | Rubyipmi::Ipmitool.Chassis.identifystatus | def identifystatus
options["cmdargs"] = "chassis identify status"
value = runcmd
options.delete_notify("cmdargs")
@result.chomp.split(":").last.strip if value
end | ruby | def identifystatus
options["cmdargs"] = "chassis identify status"
value = runcmd
options.delete_notify("cmdargs")
@result.chomp.split(":").last.strip if value
end | [
"def",
"identifystatus",
"options",
"[",
"\"cmdargs\"",
"]",
"=",
"\"chassis identify status\"",
"value",
"=",
"runcmd",
"options",
".",
"delete_notify",
"(",
"\"cmdargs\"",
")",
"@result",
".",
"chomp",
".",
"split",
"(",
"\":\"",
")",
".",
"last",
".",
"stri... | A currently unsupported method to retrieve the led status | [
"A",
"currently",
"unsupported",
"method",
"to",
"retrieve",
"the",
"led",
"status"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/ipmitool/commands/chassis.rb#L87-L92 | train |
logicminds/rubyipmi | lib/rubyipmi/freeipmi/commands/fru.rb | Rubyipmi::Freeipmi.FruData.parse | def parse(data)
return unless data
data.each do |line|
key, value = line.split(':', 2)
if key =~ /^FRU.*/
if value =~ /([\w\s]*)\(.*\)/
self[:name] = $~[1].strip.gsub(/\ /, '_').downcase
end
else
key = key.strip.gsub(/\ /, '_').downcase.gsub(... | ruby | def parse(data)
return unless data
data.each do |line|
key, value = line.split(':', 2)
if key =~ /^FRU.*/
if value =~ /([\w\s]*)\(.*\)/
self[:name] = $~[1].strip.gsub(/\ /, '_').downcase
end
else
key = key.strip.gsub(/\ /, '_').downcase.gsub(... | [
"def",
"parse",
"(",
"data",
")",
"return",
"unless",
"data",
"data",
".",
"each",
"do",
"|",
"line",
"|",
"key",
",",
"value",
"=",
"line",
".",
"split",
"(",
"':'",
",",
"2",
")",
"if",
"key",
"=~",
"/",
"/",
"if",
"value",
"=~",
"/",
"\\w",
... | parse the fru information that should be an array of lines | [
"parse",
"the",
"fru",
"information",
"that",
"should",
"be",
"an",
"array",
"of",
"lines"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/freeipmi/commands/fru.rb#L112-L125 | train |
dmarcotte/github-markdown-preview | lib/github-markdown-preview/html_preview.rb | GithubMarkdownPreview.HtmlPreview.pipeline_filters | def pipeline_filters(options)
filters = [
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::SanitizationFilter,
HTML::Pipeline::ImageMaxWidthFilter,
HTML::Pipeline::HttpsFilter,
HTML::Pipeline::EmojiFilter,
GithubMarkdownPreview::Pipeline::TaskListFilter
... | ruby | def pipeline_filters(options)
filters = [
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::SanitizationFilter,
HTML::Pipeline::ImageMaxWidthFilter,
HTML::Pipeline::HttpsFilter,
HTML::Pipeline::EmojiFilter,
GithubMarkdownPreview::Pipeline::TaskListFilter
... | [
"def",
"pipeline_filters",
"(",
"options",
")",
"filters",
"=",
"[",
"HTML",
"::",
"Pipeline",
"::",
"MarkdownFilter",
",",
"HTML",
"::",
"Pipeline",
"::",
"SanitizationFilter",
",",
"HTML",
"::",
"Pipeline",
"::",
"ImageMaxWidthFilter",
",",
"HTML",
"::",
"Pi... | Compute the filters to use in the html-pipeline based on the given options | [
"Compute",
"the",
"filters",
"to",
"use",
"in",
"the",
"html",
"-",
"pipeline",
"based",
"on",
"the",
"given",
"options"
] | 88ea17d08a563fe7e2e867cd1e3f27ca4a2a7d00 | https://github.com/dmarcotte/github-markdown-preview/blob/88ea17d08a563fe7e2e867cd1e3f27ca4a2a7d00/lib/github-markdown-preview/html_preview.rb#L68-L89 | train |
dmarcotte/github-markdown-preview | lib/github-markdown-preview/html_preview.rb | GithubMarkdownPreview.HtmlPreview.update | def update
unless File.exist?(@source_file)
raise FileNotFoundError.new("Source file deleted")
end
markdown_render = @preview_pipeline.call(IO.read(@source_file), @pipeline_context, {})[:output].to_s
preview_html = wrap_preview(markdown_render)
File.open(@preview_file, 'w') do |f... | ruby | def update
unless File.exist?(@source_file)
raise FileNotFoundError.new("Source file deleted")
end
markdown_render = @preview_pipeline.call(IO.read(@source_file), @pipeline_context, {})[:output].to_s
preview_html = wrap_preview(markdown_render)
File.open(@preview_file, 'w') do |f... | [
"def",
"update",
"unless",
"File",
".",
"exist?",
"(",
"@source_file",
")",
"raise",
"FileNotFoundError",
".",
"new",
"(",
"\"Source file deleted\"",
")",
"end",
"markdown_render",
"=",
"@preview_pipeline",
".",
"call",
"(",
"IO",
".",
"read",
"(",
"@source_file... | Update the preview file | [
"Update",
"the",
"preview",
"file"
] | 88ea17d08a563fe7e2e867cd1e3f27ca4a2a7d00 | https://github.com/dmarcotte/github-markdown-preview/blob/88ea17d08a563fe7e2e867cd1e3f27ca4a2a7d00/lib/github-markdown-preview/html_preview.rb#L93-L106 | train |
logicminds/rubyipmi | lib/rubyipmi/freeipmi/commands/bmcdevice.rb | Rubyipmi::Freeipmi.BmcDevice.reset | def reset(type = 'cold')
if ['cold', 'warm'].include?(type)
key = "#{type}-reset"
command(key)
else
logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger
raise "reset type: #{type} is not a valid choice, use warm or cold"
end
end | ruby | def reset(type = 'cold')
if ['cold', 'warm'].include?(type)
key = "#{type}-reset"
command(key)
else
logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger
raise "reset type: #{type} is not a valid choice, use warm or cold"
end
end | [
"def",
"reset",
"(",
"type",
"=",
"'cold'",
")",
"if",
"[",
"'cold'",
",",
"'warm'",
"]",
".",
"include?",
"(",
"type",
")",
"key",
"=",
"\"#{type}-reset\"",
"command",
"(",
"key",
")",
"else",
"logger",
".",
"error",
"(",
"\"reset type: #{type} is not a v... | reset the bmc device, useful for debugging and troubleshooting | [
"reset",
"the",
"bmc",
"device",
"useful",
"for",
"debugging",
"and",
"troubleshooting"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/freeipmi/commands/bmcdevice.rb#L16-L24 | train |
logicminds/rubyipmi | lib/rubyipmi/ipmitool/commands/bmc.rb | Rubyipmi::Ipmitool.Bmc.reset | def reset(type = 'cold')
if ['cold', 'warm'].include?(type)
@options["cmdargs"] = "bmc reset #{type}"
value = runcmd
@options.delete_notify("cmdargs")
return value
else
logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger
raise... | ruby | def reset(type = 'cold')
if ['cold', 'warm'].include?(type)
@options["cmdargs"] = "bmc reset #{type}"
value = runcmd
@options.delete_notify("cmdargs")
return value
else
logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger
raise... | [
"def",
"reset",
"(",
"type",
"=",
"'cold'",
")",
"if",
"[",
"'cold'",
",",
"'warm'",
"]",
".",
"include?",
"(",
"type",
")",
"@options",
"[",
"\"cmdargs\"",
"]",
"=",
"\"bmc reset #{type}\"",
"value",
"=",
"runcmd",
"@options",
".",
"delete_notify",
"(",
... | reset the bmc device, useful for troubleshooting | [
"reset",
"the",
"bmc",
"device",
"useful",
"for",
"troubleshooting"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/ipmitool/commands/bmc.rb#L30-L40 | train |
logicminds/rubyipmi | lib/rubyipmi/ipmitool/commands/bmc.rb | Rubyipmi::Ipmitool.Bmc.retrieve | def retrieve
@options["cmdargs"] = "bmc info"
status = runcmd
@options.delete_notify("cmdargs")
subkey = nil
if !status
raise @result
else
@result.lines.each do |line|
# clean up the data from spaces
item = line.split(':')
key = item.firs... | ruby | def retrieve
@options["cmdargs"] = "bmc info"
status = runcmd
@options.delete_notify("cmdargs")
subkey = nil
if !status
raise @result
else
@result.lines.each do |line|
# clean up the data from spaces
item = line.split(':')
key = item.firs... | [
"def",
"retrieve",
"@options",
"[",
"\"cmdargs\"",
"]",
"=",
"\"bmc info\"",
"status",
"=",
"runcmd",
"@options",
".",
"delete_notify",
"(",
"\"cmdargs\"",
")",
"subkey",
"=",
"nil",
"if",
"!",
"status",
"raise",
"@result",
"else",
"@result",
".",
"lines",
"... | This function will get the bmcinfo and return a hash of each item in the info | [
"This",
"function",
"will",
"get",
"the",
"bmcinfo",
"and",
"return",
"a",
"hash",
"of",
"each",
"item",
"in",
"the",
"info"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/ipmitool/commands/bmc.rb#L54-L82 | train |
logicminds/rubyipmi | lib/rubyipmi/commands/mixins/sensors_mixin.rb | Rubyipmi.SensorsMixin.fanlist | def fanlist(refreshdata = false)
refresh if refreshdata
list.each_with_object({}) { |(name, sensor), flist| flist[name] = sensor if name =~ /.*fan.*/ }
end | ruby | def fanlist(refreshdata = false)
refresh if refreshdata
list.each_with_object({}) { |(name, sensor), flist| flist[name] = sensor if name =~ /.*fan.*/ }
end | [
"def",
"fanlist",
"(",
"refreshdata",
"=",
"false",
")",
"refresh",
"if",
"refreshdata",
"list",
".",
"each_with_object",
"(",
"{",
"}",
")",
"{",
"|",
"(",
"name",
",",
"sensor",
")",
",",
"flist",
"|",
"flist",
"[",
"name",
"]",
"=",
"sensor",
"if"... | returns a hash of fan sensors where the key is fan name and value is the sensor | [
"returns",
"a",
"hash",
"of",
"fan",
"sensors",
"where",
"the",
"key",
"is",
"fan",
"name",
"and",
"value",
"is",
"the",
"sensor"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/commands/mixins/sensors_mixin.rb#L21-L24 | train |
logicminds/rubyipmi | lib/rubyipmi/commands/mixins/sensors_mixin.rb | Rubyipmi.SensorsMixin.templist | def templist(refreshdata = false)
refresh if refreshdata
list.each_with_object({}) do |(name, sensor), tlist|
tlist[name] = sensor if (sensor[:unit] =~ /.*degree.*/ || name =~ /.*temp.*/)
end
end | ruby | def templist(refreshdata = false)
refresh if refreshdata
list.each_with_object({}) do |(name, sensor), tlist|
tlist[name] = sensor if (sensor[:unit] =~ /.*degree.*/ || name =~ /.*temp.*/)
end
end | [
"def",
"templist",
"(",
"refreshdata",
"=",
"false",
")",
"refresh",
"if",
"refreshdata",
"list",
".",
"each_with_object",
"(",
"{",
"}",
")",
"do",
"|",
"(",
"name",
",",
"sensor",
")",
",",
"tlist",
"|",
"tlist",
"[",
"name",
"]",
"=",
"sensor",
"i... | returns a hash of sensors where each key is the name of the sensor and the value is the sensor | [
"returns",
"a",
"hash",
"of",
"sensors",
"where",
"each",
"key",
"is",
"the",
"name",
"of",
"the",
"sensor",
"and",
"the",
"value",
"is",
"the",
"sensor"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/commands/mixins/sensors_mixin.rb#L27-L32 | train |
logicminds/rubyipmi | lib/rubyipmi/freeipmi/commands/chassisconfig.rb | Rubyipmi::Freeipmi.ChassisConfig.checkout | def checkout(section = nil)
@options["checkout"] = false
@options["section"] = section if section
value = runcmd
@options.delete_notify("checkout")
@options.delete_notify("section") if section
value
end | ruby | def checkout(section = nil)
@options["checkout"] = false
@options["section"] = section if section
value = runcmd
@options.delete_notify("checkout")
@options.delete_notify("section") if section
value
end | [
"def",
"checkout",
"(",
"section",
"=",
"nil",
")",
"@options",
"[",
"\"checkout\"",
"]",
"=",
"false",
"@options",
"[",
"\"section\"",
"]",
"=",
"section",
"if",
"section",
"value",
"=",
"runcmd",
"@options",
".",
"delete_notify",
"(",
"\"checkout\"",
")",
... | This is the raw command to get the entire ipmi chassis configuration
If you pass in a section you will get just the section | [
"This",
"is",
"the",
"raw",
"command",
"to",
"get",
"the",
"entire",
"ipmi",
"chassis",
"configuration",
"If",
"you",
"pass",
"in",
"a",
"section",
"you",
"will",
"get",
"just",
"the",
"section"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/freeipmi/commands/chassisconfig.rb#L17-L24 | train |
logicminds/rubyipmi | lib/rubyipmi/ipmitool/commands/fru.rb | Rubyipmi::Ipmitool.Fru.parse | def parse(data)
return unless data
parsed_data = []
data.lines.each do |line|
if line =~ /^FRU.*/
# this is the either the first line of of the fru or another fru
if parsed_data.count != 0
# we have reached a new fru device so lets record the previous fru
... | ruby | def parse(data)
return unless data
parsed_data = []
data.lines.each do |line|
if line =~ /^FRU.*/
# this is the either the first line of of the fru or another fru
if parsed_data.count != 0
# we have reached a new fru device so lets record the previous fru
... | [
"def",
"parse",
"(",
"data",
")",
"return",
"unless",
"data",
"parsed_data",
"=",
"[",
"]",
"data",
".",
"lines",
".",
"each",
"do",
"|",
"line",
"|",
"if",
"line",
"=~",
"/",
"/",
"if",
"parsed_data",
".",
"count",
"!=",
"0",
"new_fru",
"=",
"FruD... | parse the fru information | [
"parse",
"the",
"fru",
"information"
] | 516dfb0d5f8aa126159a5f5c25d60ab5c98f862f | https://github.com/logicminds/rubyipmi/blob/516dfb0d5f8aa126159a5f5c25d60ab5c98f862f/lib/rubyipmi/ipmitool/commands/fru.rb#L61-L83 | train |
seratch/rspec-kickstarter | lib/rspec_kickstarter/generator.rb | RSpecKickstarter.Generator.write_spec | def write_spec(file_path, force_write = false, dry_run = false, rails_mode = false)
class_or_module = RSpecKickstarter::RDocFactory.get_rdoc_class_or_module(file_path)
if class_or_module
spec_path = get_spec_path(file_path)
if force_write && File.exist?(spec_path)
append_to_existin... | ruby | def write_spec(file_path, force_write = false, dry_run = false, rails_mode = false)
class_or_module = RSpecKickstarter::RDocFactory.get_rdoc_class_or_module(file_path)
if class_or_module
spec_path = get_spec_path(file_path)
if force_write && File.exist?(spec_path)
append_to_existin... | [
"def",
"write_spec",
"(",
"file_path",
",",
"force_write",
"=",
"false",
",",
"dry_run",
"=",
"false",
",",
"rails_mode",
"=",
"false",
")",
"class_or_module",
"=",
"RSpecKickstarter",
"::",
"RDocFactory",
".",
"get_rdoc_class_or_module",
"(",
"file_path",
")",
... | Writes new spec or appends to the existing spec. | [
"Writes",
"new",
"spec",
"or",
"appends",
"to",
"the",
"existing",
"spec",
"."
] | 969d85fb9d702908ab0c6f2acc014b72a91c17e9 | https://github.com/seratch/rspec-kickstarter/blob/969d85fb9d702908ab0c6f2acc014b72a91c17e9/lib/rspec_kickstarter/generator.rb#L27-L39 | train |
seratch/rspec-kickstarter | lib/rspec_kickstarter/generator.rb | RSpecKickstarter.Generator.create_new_spec | def create_new_spec(class_or_module, dry_run, rails_mode, file_path, spec_path)
# These names are used in ERB template, don't delete.
# rubocop:disable Lint/UselessAssignment
methods_to_generate = class_or_module.method_list.select { |m| m.visibility == :public }
c = class_or_module
self_p... | ruby | def create_new_spec(class_or_module, dry_run, rails_mode, file_path, spec_path)
# These names are used in ERB template, don't delete.
# rubocop:disable Lint/UselessAssignment
methods_to_generate = class_or_module.method_list.select { |m| m.visibility == :public }
c = class_or_module
self_p... | [
"def",
"create_new_spec",
"(",
"class_or_module",
",",
"dry_run",
",",
"rails_mode",
",",
"file_path",
",",
"spec_path",
")",
"methods_to_generate",
"=",
"class_or_module",
".",
"method_list",
".",
"select",
"{",
"|",
"m",
"|",
"m",
".",
"visibility",
"==",
":... | Creates new spec.
rubocop:disable Metrics/AbcSize | [
"Creates",
"new",
"spec",
"."
] | 969d85fb9d702908ab0c6f2acc014b72a91c17e9 | https://github.com/seratch/rspec-kickstarter/blob/969d85fb9d702908ab0c6f2acc014b72a91c17e9/lib/rspec_kickstarter/generator.rb#L104-L127 | train |
seratch/rspec-kickstarter | lib/rspec_kickstarter/erb_factory.rb | RSpecKickstarter.ERBFactory.get_instance_for_new_spec | def get_instance_for_new_spec(rails_mode, target_path)
template = get_erb_template(@custom_template, true, rails_mode, target_path)
ERB.new(template, nil, '-', '_new_spec_code')
end | ruby | def get_instance_for_new_spec(rails_mode, target_path)
template = get_erb_template(@custom_template, true, rails_mode, target_path)
ERB.new(template, nil, '-', '_new_spec_code')
end | [
"def",
"get_instance_for_new_spec",
"(",
"rails_mode",
",",
"target_path",
")",
"template",
"=",
"get_erb_template",
"(",
"@custom_template",
",",
"true",
",",
"rails_mode",
",",
"target_path",
")",
"ERB",
".",
"new",
"(",
"template",
",",
"nil",
",",
"'-'",
"... | Returns ERB instance for creating new spec | [
"Returns",
"ERB",
"instance",
"for",
"creating",
"new",
"spec"
] | 969d85fb9d702908ab0c6f2acc014b72a91c17e9 | https://github.com/seratch/rspec-kickstarter/blob/969d85fb9d702908ab0c6f2acc014b72a91c17e9/lib/rspec_kickstarter/erb_factory.rb#L20-L23 | train |
seratch/rspec-kickstarter | lib/rspec_kickstarter/erb_factory.rb | RSpecKickstarter.ERBFactory.get_instance_for_appending | def get_instance_for_appending(rails_mode, target_path)
template = get_erb_template(@custom_template, false, rails_mode, target_path)
ERB.new(template, nil, '-', '_additional_spec_code')
end | ruby | def get_instance_for_appending(rails_mode, target_path)
template = get_erb_template(@custom_template, false, rails_mode, target_path)
ERB.new(template, nil, '-', '_additional_spec_code')
end | [
"def",
"get_instance_for_appending",
"(",
"rails_mode",
",",
"target_path",
")",
"template",
"=",
"get_erb_template",
"(",
"@custom_template",
",",
"false",
",",
"rails_mode",
",",
"target_path",
")",
"ERB",
".",
"new",
"(",
"template",
",",
"nil",
",",
"'-'",
... | Returns ERB instance for appeding lacking tests | [
"Returns",
"ERB",
"instance",
"for",
"appeding",
"lacking",
"tests"
] | 969d85fb9d702908ab0c6f2acc014b72a91c17e9 | https://github.com/seratch/rspec-kickstarter/blob/969d85fb9d702908ab0c6f2acc014b72a91c17e9/lib/rspec_kickstarter/erb_factory.rb#L28-L31 | train |
seratch/rspec-kickstarter | lib/rspec_kickstarter/erb_factory.rb | RSpecKickstarter.ERBFactory.get_erb_template | def get_erb_template(custom_template, is_full, rails_mode, target_path)
if custom_template
custom_template
elsif rails_mode && target_path.match(/controllers/)
get_rails_controller_template(is_full)
elsif rails_mode && target_path.match(/helpers/)
get_rails_helper_template(is_f... | ruby | def get_erb_template(custom_template, is_full, rails_mode, target_path)
if custom_template
custom_template
elsif rails_mode && target_path.match(/controllers/)
get_rails_controller_template(is_full)
elsif rails_mode && target_path.match(/helpers/)
get_rails_helper_template(is_f... | [
"def",
"get_erb_template",
"(",
"custom_template",
",",
"is_full",
",",
"rails_mode",
",",
"target_path",
")",
"if",
"custom_template",
"custom_template",
"elsif",
"rails_mode",
"&&",
"target_path",
".",
"match",
"(",
"/",
"/",
")",
"get_rails_controller_template",
... | Returns ERB template | [
"Returns",
"ERB",
"template"
] | 969d85fb9d702908ab0c6f2acc014b72a91c17e9 | https://github.com/seratch/rspec-kickstarter/blob/969d85fb9d702908ab0c6f2acc014b72a91c17e9/lib/rspec_kickstarter/erb_factory.rb#L38-L48 | train |
redbooth/departure | lib/active_record/connection_adapters/percona_adapter.rb | ActiveRecord.ConnectionHandling.percona_connection | def percona_connection(config)
mysql2_connection = mysql2_connection(config)
config[:username] = 'root' if config[:username].nil?
connection_details = Departure::ConnectionDetails.new(config)
verbose = ActiveRecord::Migration.verbose
sanitizers = [
Departure::LogSanitizers::Passw... | ruby | def percona_connection(config)
mysql2_connection = mysql2_connection(config)
config[:username] = 'root' if config[:username].nil?
connection_details = Departure::ConnectionDetails.new(config)
verbose = ActiveRecord::Migration.verbose
sanitizers = [
Departure::LogSanitizers::Passw... | [
"def",
"percona_connection",
"(",
"config",
")",
"mysql2_connection",
"=",
"mysql2_connection",
"(",
"config",
")",
"config",
"[",
":username",
"]",
"=",
"'root'",
"if",
"config",
"[",
":username",
"]",
".",
"nil?",
"connection_details",
"=",
"Departure",
"::",
... | Establishes a connection to the database that's used by all Active
Record objects. | [
"Establishes",
"a",
"connection",
"to",
"the",
"database",
"that",
"s",
"used",
"by",
"all",
"Active",
"Record",
"objects",
"."
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/active_record/connection_adapters/percona_adapter.rb#L11-L38 | train |
redbooth/departure | lib/lhm/adapter.rb | Lhm.Adapter.add_index | def add_index(columns, index_name = nil)
options = { name: index_name } if index_name
migration.add_index(table_name, columns, options || {})
end | ruby | def add_index(columns, index_name = nil)
options = { name: index_name } if index_name
migration.add_index(table_name, columns, options || {})
end | [
"def",
"add_index",
"(",
"columns",
",",
"index_name",
"=",
"nil",
")",
"options",
"=",
"{",
"name",
":",
"index_name",
"}",
"if",
"index_name",
"migration",
".",
"add_index",
"(",
"table_name",
",",
"columns",
",",
"options",
"||",
"{",
"}",
")",
"end"
... | Adds an index in the specified columns through ActiveRecord. Note you
can provide a name as well
@param columns [Array<String>, Array<Symbol>, String, Symbol]
@param index_name [String] | [
"Adds",
"an",
"index",
"in",
"the",
"specified",
"columns",
"through",
"ActiveRecord",
".",
"Note",
"you",
"can",
"provide",
"a",
"name",
"as",
"well"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/adapter.rb#L39-L42 | train |
redbooth/departure | lib/lhm/adapter.rb | Lhm.Adapter.remove_index | def remove_index(columns, index_name = nil)
options = if index_name
{ name: index_name }
else
{ column: columns }
end
migration.remove_index(table_name, options)
end | ruby | def remove_index(columns, index_name = nil)
options = if index_name
{ name: index_name }
else
{ column: columns }
end
migration.remove_index(table_name, options)
end | [
"def",
"remove_index",
"(",
"columns",
",",
"index_name",
"=",
"nil",
")",
"options",
"=",
"if",
"index_name",
"{",
"name",
":",
"index_name",
"}",
"else",
"{",
"column",
":",
"columns",
"}",
"end",
"migration",
".",
"remove_index",
"(",
"table_name",
",",... | Removes the index in the given columns or by its name
@param columns [Array<String>, Array<Symbol>, String, Symbol]
@param index_name [String] | [
"Removes",
"the",
"index",
"in",
"the",
"given",
"columns",
"or",
"by",
"its",
"name"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/adapter.rb#L48-L55 | train |
redbooth/departure | lib/lhm/adapter.rb | Lhm.Adapter.change_column | def change_column(column_name, definition)
attributes = column_attributes(column_name, definition)
migration.change_column(*attributes)
end | ruby | def change_column(column_name, definition)
attributes = column_attributes(column_name, definition)
migration.change_column(*attributes)
end | [
"def",
"change_column",
"(",
"column_name",
",",
"definition",
")",
"attributes",
"=",
"column_attributes",
"(",
"column_name",
",",
"definition",
")",
"migration",
".",
"change_column",
"(",
"*",
"attributes",
")",
"end"
] | Change the column to use the provided definition, through ActiveRecord
@param column_name [String, Symbol]
@param definition [String, Symbol] | [
"Change",
"the",
"column",
"to",
"use",
"the",
"provided",
"definition",
"through",
"ActiveRecord"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/adapter.rb#L61-L64 | train |
redbooth/departure | lib/lhm/adapter.rb | Lhm.Adapter.add_unique_index | def add_unique_index(columns, index_name = nil)
options = { unique: true }
options.merge!(name: index_name) if index_name # rubocop:disable Performance/RedundantMerge
migration.add_index(table_name, columns, options)
end | ruby | def add_unique_index(columns, index_name = nil)
options = { unique: true }
options.merge!(name: index_name) if index_name # rubocop:disable Performance/RedundantMerge
migration.add_index(table_name, columns, options)
end | [
"def",
"add_unique_index",
"(",
"columns",
",",
"index_name",
"=",
"nil",
")",
"options",
"=",
"{",
"unique",
":",
"true",
"}",
"options",
".",
"merge!",
"(",
"name",
":",
"index_name",
")",
"if",
"index_name",
"migration",
".",
"add_index",
"(",
"table_na... | Adds a unique index on the given columns, with the provided name if passed
@param columns [Array<String>, Array<Symbol>, String, Symbol]
@param index_name [String] | [
"Adds",
"a",
"unique",
"index",
"on",
"the",
"given",
"columns",
"with",
"the",
"provided",
"name",
"if",
"passed"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/adapter.rb#L78-L83 | train |
redbooth/departure | lib/lhm/adapter.rb | Lhm.Adapter.column | def column(name, definition)
@column ||= if definition.is_a?(Symbol)
ColumnWithType.new(name, definition)
else
ColumnWithSql.new(name, definition)
end
end | ruby | def column(name, definition)
@column ||= if definition.is_a?(Symbol)
ColumnWithType.new(name, definition)
else
ColumnWithSql.new(name, definition)
end
end | [
"def",
"column",
"(",
"name",
",",
"definition",
")",
"@column",
"||=",
"if",
"definition",
".",
"is_a?",
"(",
"Symbol",
")",
"ColumnWithType",
".",
"new",
"(",
"name",
",",
"definition",
")",
"else",
"ColumnWithSql",
".",
"new",
"(",
"name",
",",
"defin... | Returns the instance of ActiveRecord column with the given name and
definition
@param name [String, Symbol]
@param definition [String] | [
"Returns",
"the",
"instance",
"of",
"ActiveRecord",
"column",
"with",
"the",
"given",
"name",
"and",
"definition"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/adapter.rb#L94-L100 | train |
redbooth/departure | lib/lhm/column_with_sql.rb | Lhm.ColumnWithSql.column | def column
cast_type = ActiveRecord::Base.connection.lookup_cast_type(definition)
@column ||= self.class.column_factory.new(
name,
default_value,
cast_type,
definition,
null_value
)
end | ruby | def column
cast_type = ActiveRecord::Base.connection.lookup_cast_type(definition)
@column ||= self.class.column_factory.new(
name,
default_value,
cast_type,
definition,
null_value
)
end | [
"def",
"column",
"cast_type",
"=",
"ActiveRecord",
"::",
"Base",
".",
"connection",
".",
"lookup_cast_type",
"(",
"definition",
")",
"@column",
"||=",
"self",
".",
"class",
".",
"column_factory",
".",
"new",
"(",
"name",
",",
"default_value",
",",
"cast_type",... | Returns the column instance with the provided data
@return [column_factory] | [
"Returns",
"the",
"column",
"instance",
"with",
"the",
"provided",
"data"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/column_with_sql.rb#L54-L63 | train |
redbooth/departure | lib/lhm/column_with_sql.rb | Lhm.ColumnWithSql.default_value | def default_value
match = if definition =~ /timestamp|datetime/i
/default '?(.+[^'])'?/i.match(definition)
else
/default '?(\w+)'?/i.match(definition)
end
return unless match
match[1].downcase != 'null' ? match[1] : nil
end | ruby | def default_value
match = if definition =~ /timestamp|datetime/i
/default '?(.+[^'])'?/i.match(definition)
else
/default '?(\w+)'?/i.match(definition)
end
return unless match
match[1].downcase != 'null' ? match[1] : nil
end | [
"def",
"default_value",
"match",
"=",
"if",
"definition",
"=~",
"/",
"/i",
"/",
"/i",
".",
"match",
"(",
"definition",
")",
"else",
"/",
"\\w",
"/i",
".",
"match",
"(",
"definition",
")",
"end",
"return",
"unless",
"match",
"match",
"[",
"1",
"]",
".... | Gets the DEFAULT value the column takes as specified in the
definition, if any
@return [String, NilClass] | [
"Gets",
"the",
"DEFAULT",
"value",
"the",
"column",
"takes",
"as",
"specified",
"in",
"the",
"definition",
"if",
"any"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/column_with_sql.rb#L69-L79 | train |
redbooth/departure | lib/lhm/column_with_sql.rb | Lhm.ColumnWithSql.null_value | def null_value
match = /((\w*) NULL)/i.match(definition)
return true unless match
match[2].downcase == 'not' ? false : true
end | ruby | def null_value
match = /((\w*) NULL)/i.match(definition)
return true unless match
match[2].downcase == 'not' ? false : true
end | [
"def",
"null_value",
"match",
"=",
"/",
"\\w",
"/i",
".",
"match",
"(",
"definition",
")",
"return",
"true",
"unless",
"match",
"match",
"[",
"2",
"]",
".",
"downcase",
"==",
"'not'",
"?",
"false",
":",
"true",
"end"
] | Checks whether the column accepts NULL as specified in the definition
@return [Boolean] | [
"Checks",
"whether",
"the",
"column",
"accepts",
"NULL",
"as",
"specified",
"in",
"the",
"definition"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/lhm/column_with_sql.rb#L84-L89 | train |
redbooth/departure | lib/departure/command.rb | Departure.Command.run_in_process | def run_in_process
Open3.popen3(full_command) do |_stdin, stdout, _stderr, waith_thr|
begin
loop do
IO.select([stdout])
data = stdout.read_nonblock(8)
logger.write_no_newline(data)
end
rescue EOFError # rubocop:disable Lint/HandleExceptions
... | ruby | def run_in_process
Open3.popen3(full_command) do |_stdin, stdout, _stderr, waith_thr|
begin
loop do
IO.select([stdout])
data = stdout.read_nonblock(8)
logger.write_no_newline(data)
end
rescue EOFError # rubocop:disable Lint/HandleExceptions
... | [
"def",
"run_in_process",
"Open3",
".",
"popen3",
"(",
"full_command",
")",
"do",
"|",
"_stdin",
",",
"stdout",
",",
"_stderr",
",",
"waith_thr",
"|",
"begin",
"loop",
"do",
"IO",
".",
"select",
"(",
"[",
"stdout",
"]",
")",
"data",
"=",
"stdout",
".",
... | Runs the command in a separate process, capturing its stdout and
execution status | [
"Runs",
"the",
"command",
"in",
"a",
"separate",
"process",
"capturing",
"its",
"stdout",
"and",
"execution",
"status"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/departure/command.rb#L42-L56 | train |
redbooth/departure | lib/departure/command.rb | Departure.Command.validate_status! | def validate_status!
raise SignalError.new(status) if status.signaled? # rubocop:disable Style/RaiseArgs
raise CommandNotFoundError if status.exitstatus == COMMAND_NOT_FOUND
raise Error, error_message unless status.success?
end | ruby | def validate_status!
raise SignalError.new(status) if status.signaled? # rubocop:disable Style/RaiseArgs
raise CommandNotFoundError if status.exitstatus == COMMAND_NOT_FOUND
raise Error, error_message unless status.success?
end | [
"def",
"validate_status!",
"raise",
"SignalError",
".",
"new",
"(",
"status",
")",
"if",
"status",
".",
"signaled?",
"raise",
"CommandNotFoundError",
"if",
"status",
".",
"exitstatus",
"==",
"COMMAND_NOT_FOUND",
"raise",
"Error",
",",
"error_message",
"unless",
"s... | Validates the status of the execution
@raise [NoStatusError] if the spawned process' status can't be retrieved
@raise [SignalError] if the spawned process received a signal
@raise [CommandNotFoundError] if pt-online-schema-change can't be found | [
"Validates",
"the",
"status",
"of",
"the",
"execution"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/departure/command.rb#L71-L75 | train |
redbooth/departure | lib/departure/cli_generator.rb | Departure.CliGenerator.all_options | def all_options
env_variable_options = UserOptions.new
global_configuration_options = UserOptions.new(Departure.configuration.global_percona_args)
options = env_variable_options.merge(global_configuration_options).merge(DEFAULT_OPTIONS)
options.to_a.join(' ')
end | ruby | def all_options
env_variable_options = UserOptions.new
global_configuration_options = UserOptions.new(Departure.configuration.global_percona_args)
options = env_variable_options.merge(global_configuration_options).merge(DEFAULT_OPTIONS)
options.to_a.join(' ')
end | [
"def",
"all_options",
"env_variable_options",
"=",
"UserOptions",
".",
"new",
"global_configuration_options",
"=",
"UserOptions",
".",
"new",
"(",
"Departure",
".",
"configuration",
".",
"global_percona_args",
")",
"options",
"=",
"env_variable_options",
".",
"merge",
... | Returns all the arguments to execute pt-online-schema-change with
@return [String] | [
"Returns",
"all",
"the",
"arguments",
"to",
"execute",
"pt",
"-",
"online",
"-",
"schema",
"-",
"change",
"with"
] | 6ffaf1c298a741d10c2832dfbc5a1f62a39a7695 | https://github.com/redbooth/departure/blob/6ffaf1c298a741d10c2832dfbc5a1f62a39a7695/lib/departure/cli_generator.rb#L77-L82 | train |
mmriis/simpleidn | lib/simpleidn.rb | SimpleIDN.Punycode.adapt | def adapt(delta, numpoints, firsttime)
delta = firsttime ? (delta / DAMP) : (delta >> 1)
delta += (delta / numpoints)
k = 0
while delta > (((BASE - TMIN) * TMAX) / 2)
delta /= BASE - TMIN
k += BASE
end
k + (BASE - TMIN + 1) * delta / (delta + SKEW)
end | ruby | def adapt(delta, numpoints, firsttime)
delta = firsttime ? (delta / DAMP) : (delta >> 1)
delta += (delta / numpoints)
k = 0
while delta > (((BASE - TMIN) * TMAX) / 2)
delta /= BASE - TMIN
k += BASE
end
k + (BASE - TMIN + 1) * delta / (delta + SKEW)
end | [
"def",
"adapt",
"(",
"delta",
",",
"numpoints",
",",
"firsttime",
")",
"delta",
"=",
"firsttime",
"?",
"(",
"delta",
"/",
"DAMP",
")",
":",
"(",
"delta",
">>",
"1",
")",
"delta",
"+=",
"(",
"delta",
"/",
"numpoints",
")",
"k",
"=",
"0",
"while",
... | Bias adaptation function | [
"Bias",
"adaptation",
"function"
] | 1b3accb22c4afc88257af1d08dd0a0920f13f88f | https://github.com/mmriis/simpleidn/blob/1b3accb22c4afc88257af1d08dd0a0920f13f88f/lib/simpleidn.rb#L44-L54 | train |
mmriis/simpleidn | lib/simpleidn.rb | SimpleIDN.Punycode.encode | def encode(input)
input_encoding = input.encoding
input = input.encode(Encoding::UTF_8).codepoints.to_a
output = []
# Initialize the state:
n = INITIAL_N
delta = 0
bias = INITIAL_BIAS
# Handle the basic code points:
output = input.select { |char| char <= ASCII_MAX... | ruby | def encode(input)
input_encoding = input.encoding
input = input.encode(Encoding::UTF_8).codepoints.to_a
output = []
# Initialize the state:
n = INITIAL_N
delta = 0
bias = INITIAL_BIAS
# Handle the basic code points:
output = input.select { |char| char <= ASCII_MAX... | [
"def",
"encode",
"(",
"input",
")",
"input_encoding",
"=",
"input",
".",
"encoding",
"input",
"=",
"input",
".",
"encode",
"(",
"Encoding",
"::",
"UTF_8",
")",
".",
"codepoints",
".",
"to_a",
"output",
"=",
"[",
"]",
"n",
"=",
"INITIAL_N",
"delta",
"="... | Main encode function | [
"Main",
"encode",
"function"
] | 1b3accb22c4afc88257af1d08dd0a0920f13f88f | https://github.com/mmriis/simpleidn/blob/1b3accb22c4afc88257af1d08dd0a0920f13f88f/lib/simpleidn.rb#L129-L196 | train |
savonrb/akami | lib/akami/wsse.rb | Akami.WSSE.to_xml | def to_xml
if signature? and signature.have_document?
Gyoku.xml wsse_signature.merge!(hash)
elsif username_token? && timestamp?
Gyoku.xml wsse_username_token.merge!(wsu_timestamp) {
|key, v1, v2| v1.merge!(v2) {
|key, v1, v2| v1.merge!(v2)
}
}
el... | ruby | def to_xml
if signature? and signature.have_document?
Gyoku.xml wsse_signature.merge!(hash)
elsif username_token? && timestamp?
Gyoku.xml wsse_username_token.merge!(wsu_timestamp) {
|key, v1, v2| v1.merge!(v2) {
|key, v1, v2| v1.merge!(v2)
}
}
el... | [
"def",
"to_xml",
"if",
"signature?",
"and",
"signature",
".",
"have_document?",
"Gyoku",
".",
"xml",
"wsse_signature",
".",
"merge!",
"(",
"hash",
")",
"elsif",
"username_token?",
"&&",
"timestamp?",
"Gyoku",
".",
"xml",
"wsse_username_token",
".",
"merge!",
"("... | Returns the XML for a WSSE header. | [
"Returns",
"the",
"XML",
"for",
"a",
"WSSE",
"header",
"."
] | e2f21b05eb6661bbd4faf04a481511e6a53ff510 | https://github.com/savonrb/akami/blob/e2f21b05eb6661bbd4faf04a481511e6a53ff510/lib/akami/wsse.rb#L93-L109 | train |
savonrb/akami | lib/akami/wsse.rb | Akami.WSSE.digest_password | def digest_password
token = nonce + timestamp + password
Base64.encode64(Digest::SHA1.digest(token)).chomp!
end | ruby | def digest_password
token = nonce + timestamp + password
Base64.encode64(Digest::SHA1.digest(token)).chomp!
end | [
"def",
"digest_password",
"token",
"=",
"nonce",
"+",
"timestamp",
"+",
"password",
"Base64",
".",
"encode64",
"(",
"Digest",
"::",
"SHA1",
".",
"digest",
"(",
"token",
")",
")",
".",
"chomp!",
"end"
] | Returns the WSSE password, encrypted for digest authentication. | [
"Returns",
"the",
"WSSE",
"password",
"encrypted",
"for",
"digest",
"authentication",
"."
] | e2f21b05eb6661bbd4faf04a481511e6a53ff510 | https://github.com/savonrb/akami/blob/e2f21b05eb6661bbd4faf04a481511e6a53ff510/lib/akami/wsse.rb#L175-L178 | train |
phallguy/shog | lib/shog/formatter.rb | Shog.Formatter.call | def call( severity, time, progname, msg )
return if msg.blank? || _silence?( msg )
msg = [
_tagged( time, :timestamp ),
_tagged( progname, :progname ),
formatted_severity_tag( severity ),
formatted_message( severity, msg )
].compact.join(" ")
super severity, tim... | ruby | def call( severity, time, progname, msg )
return if msg.blank? || _silence?( msg )
msg = [
_tagged( time, :timestamp ),
_tagged( progname, :progname ),
formatted_severity_tag( severity ),
formatted_message( severity, msg )
].compact.join(" ")
super severity, tim... | [
"def",
"call",
"(",
"severity",
",",
"time",
",",
"progname",
",",
"msg",
")",
"return",
"if",
"msg",
".",
"blank?",
"||",
"_silence?",
"(",
"msg",
")",
"msg",
"=",
"[",
"_tagged",
"(",
"time",
",",
":timestamp",
")",
",",
"_tagged",
"(",
"progname",... | Called by the logger to prepare a message for output.
@return [String] | [
"Called",
"by",
"the",
"logger",
"to",
"prepare",
"a",
"message",
"for",
"output",
"."
] | 294637aa2103d93a82e6f1df74ea35deb0dc04eb | https://github.com/phallguy/shog/blob/294637aa2103d93a82e6f1df74ea35deb0dc04eb/lib/shog/formatter.rb#L21-L32 | train |
phallguy/shog | lib/shog/formatter.rb | Shog.Formatter.formatted_severity_tag | def formatted_severity_tag( severity )
length = configuration[:severity_tags][:_length] ||= begin
configuration[:severity_tags].reduce(0){ |l,(k,_)| [k.length,l].max }
end
return if length == 0
padded_severity = severity.ljust length
formatted = if proc = configuration[:severity... | ruby | def formatted_severity_tag( severity )
length = configuration[:severity_tags][:_length] ||= begin
configuration[:severity_tags].reduce(0){ |l,(k,_)| [k.length,l].max }
end
return if length == 0
padded_severity = severity.ljust length
formatted = if proc = configuration[:severity... | [
"def",
"formatted_severity_tag",
"(",
"severity",
")",
"length",
"=",
"configuration",
"[",
":severity_tags",
"]",
"[",
":_length",
"]",
"||=",
"begin",
"configuration",
"[",
":severity_tags",
"]",
".",
"reduce",
"(",
"0",
")",
"{",
"|",
"l",
",",
"(",
"k"... | Formats the severity indicator prefixed before each line when writing to
the log.
@param [String] the severity of the message (ex DEBUG, WARN, etc.)
@return [String] formatted version of the severity | [
"Formats",
"the",
"severity",
"indicator",
"prefixed",
"before",
"each",
"line",
"when",
"writing",
"to",
"the",
"log",
"."
] | 294637aa2103d93a82e6f1df74ea35deb0dc04eb | https://github.com/phallguy/shog/blob/294637aa2103d93a82e6f1df74ea35deb0dc04eb/lib/shog/formatter.rb#L55-L70 | train |
phallguy/shog | lib/shog/formatter.rb | Shog.Formatter.format_time | def format_time( time, expected = 30 )
timef = time.uncolorize.to_f
case
when timef > expected * 2 then time.to_s.uncolorize.red
when timef > expected then time.to_s.uncolorize.yellow
else time
end
end | ruby | def format_time( time, expected = 30 )
timef = time.uncolorize.to_f
case
when timef > expected * 2 then time.to_s.uncolorize.red
when timef > expected then time.to_s.uncolorize.yellow
else time
end
end | [
"def",
"format_time",
"(",
"time",
",",
"expected",
"=",
"30",
")",
"timef",
"=",
"time",
".",
"uncolorize",
".",
"to_f",
"case",
"when",
"timef",
">",
"expected",
"*",
"2",
"then",
"time",
".",
"to_s",
".",
"uncolorize",
".",
"red",
"when",
"timef",
... | Formats a time value expressed in ms, adding color to highlight times
outside the expected range.
If `time` is more than `expected` it's highlighted yellow. If it's more
than double it's highlighted red.
@param [String] time in ms.
@param [Float] expected maximum amount of time it should have taken.
@return [St... | [
"Formats",
"a",
"time",
"value",
"expressed",
"in",
"ms",
"adding",
"color",
"to",
"highlight",
"times",
"outside",
"the",
"expected",
"range",
"."
] | 294637aa2103d93a82e6f1df74ea35deb0dc04eb | https://github.com/phallguy/shog/blob/294637aa2103d93a82e6f1df74ea35deb0dc04eb/lib/shog/formatter.rb#L81-L88 | train |
c7/hazel | lib/hazel/cli.rb | Hazel.CLI.create_empty_directories | def create_empty_directories
%w{config/initializers lib spec}.each do |dir|
empty_directory File.join(@app_path, dir)
end
empty_directory File.join(@app_path, 'db/migrate') unless @database.empty?
create_file File.join(@app_path, "lib", ".gitkeep")
end | ruby | def create_empty_directories
%w{config/initializers lib spec}.each do |dir|
empty_directory File.join(@app_path, dir)
end
empty_directory File.join(@app_path, 'db/migrate') unless @database.empty?
create_file File.join(@app_path, "lib", ".gitkeep")
end | [
"def",
"create_empty_directories",
"%w{",
"config/initializers",
"lib",
"spec",
"}",
".",
"each",
"do",
"|",
"dir",
"|",
"empty_directory",
"File",
".",
"join",
"(",
"@app_path",
",",
"dir",
")",
"end",
"empty_directory",
"File",
".",
"join",
"(",
"@app_path",... | Create empty directories | [
"Create",
"empty",
"directories"
] | 51de275b8066371f460a499eb2f1c5a1ea7cfc9c | https://github.com/c7/hazel/blob/51de275b8066371f460a499eb2f1c5a1ea7cfc9c/lib/hazel/cli.rb#L34-L42 | train |
pboling/gem_bench | lib/gem_bench/gemfile_line_tokenizer.rb | GemBench.GemfileLineTokenizer.following_non_gem_lines | def following_non_gem_lines
all_lines[(index+1)..(-1)].
reject {|x| x.strip.empty? || x.match(GemBench::TRASH_REGEX) }.
map(&:strip).
inject([]) do |following_lines, next_line|
break following_lines if next_line.match(GEM_REGEX)
following_lines << next_line
... | ruby | def following_non_gem_lines
all_lines[(index+1)..(-1)].
reject {|x| x.strip.empty? || x.match(GemBench::TRASH_REGEX) }.
map(&:strip).
inject([]) do |following_lines, next_line|
break following_lines if next_line.match(GEM_REGEX)
following_lines << next_line
... | [
"def",
"following_non_gem_lines",
"all_lines",
"[",
"(",
"index",
"+",
"1",
")",
"..",
"(",
"-",
"1",
")",
"]",
".",
"reject",
"{",
"|",
"x",
"|",
"x",
".",
"strip",
".",
"empty?",
"||",
"x",
".",
"match",
"(",
"GemBench",
"::",
"TRASH_REGEX",
")",... | returns an array with each line following the current line, which is not a gem line | [
"returns",
"an",
"array",
"with",
"each",
"line",
"following",
"the",
"current",
"line",
"which",
"is",
"not",
"a",
"gem",
"line"
] | b686b1517187a5beecd1d4ac63417b91bd2929cc | https://github.com/pboling/gem_bench/blob/b686b1517187a5beecd1d4ac63417b91bd2929cc/lib/gem_bench/gemfile_line_tokenizer.rb#L164-L172 | train |
yaauie/cliver | lib/cliver/filter.rb | Cliver.Filter.requirements | def requirements(requirements)
requirements.map do |requirement|
req_parts = requirement.split(/\b(?=\d)/, 2)
version = req_parts.last
version.replace apply(version)
req_parts.join
end
end | ruby | def requirements(requirements)
requirements.map do |requirement|
req_parts = requirement.split(/\b(?=\d)/, 2)
version = req_parts.last
version.replace apply(version)
req_parts.join
end
end | [
"def",
"requirements",
"(",
"requirements",
")",
"requirements",
".",
"map",
"do",
"|",
"requirement",
"|",
"req_parts",
"=",
"requirement",
".",
"split",
"(",
"/",
"\\b",
"\\d",
"/",
",",
"2",
")",
"version",
"=",
"req_parts",
".",
"last",
"version",
".... | Apply to a list of requirements
@param requirements [Array<String>]
@return [Array<String>] | [
"Apply",
"to",
"a",
"list",
"of",
"requirements"
] | 3d72e99af19c273a3f88adcd4b96c4b65b1b6d4b | https://github.com/yaauie/cliver/blob/3d72e99af19c273a3f88adcd4b96c4b65b1b6d4b/lib/cliver/filter.rb#L12-L19 | train |
yaauie/cliver | lib/cliver/dependency.rb | Cliver.Dependency.installed_versions | def installed_versions
return enum_for(:installed_versions) unless block_given?
find_executables.each do |executable_path|
version = detect_version(executable_path)
break(2) if yield(executable_path, version)
end
end | ruby | def installed_versions
return enum_for(:installed_versions) unless block_given?
find_executables.each do |executable_path|
version = detect_version(executable_path)
break(2) if yield(executable_path, version)
end
end | [
"def",
"installed_versions",
"return",
"enum_for",
"(",
":installed_versions",
")",
"unless",
"block_given?",
"find_executables",
".",
"each",
"do",
"|",
"executable_path",
"|",
"version",
"=",
"detect_version",
"(",
"executable_path",
")",
"break",
"(",
"2",
")",
... | Get all the installed versions of the api-compatible executables.
If a block is given, it yields once per found executable, lazily.
@yieldparam executable_path [String]
@yieldparam version [String]
@yieldreturn [Boolean] - true if search should stop.
@return [Hash<String,String>] executable_path, version | [
"Get",
"all",
"the",
"installed",
"versions",
"of",
"the",
"api",
"-",
"compatible",
"executables",
".",
"If",
"a",
"block",
"is",
"given",
"it",
"yields",
"once",
"per",
"found",
"executable",
"lazily",
"."
] | 3d72e99af19c273a3f88adcd4b96c4b65b1b6d4b | https://github.com/yaauie/cliver/blob/3d72e99af19c273a3f88adcd4b96c4b65b1b6d4b/lib/cliver/dependency.rb#L83-L91 | train |
yaauie/cliver | lib/cliver/dependency.rb | Cliver.Dependency.detect! | def detect!
installed = {}
installed_versions.each do |path, version|
installed[path] = version
return path if ENV['CLIVER_NO_VERIFY']
return path if requirement_satisfied_by?(version)
strict?
end
# dependency not met. raise the appropriate error.
raise_not... | ruby | def detect!
installed = {}
installed_versions.each do |path, version|
installed[path] = version
return path if ENV['CLIVER_NO_VERIFY']
return path if requirement_satisfied_by?(version)
strict?
end
# dependency not met. raise the appropriate error.
raise_not... | [
"def",
"detect!",
"installed",
"=",
"{",
"}",
"installed_versions",
".",
"each",
"do",
"|",
"path",
",",
"version",
"|",
"installed",
"[",
"path",
"]",
"=",
"version",
"return",
"path",
"if",
"ENV",
"[",
"'CLIVER_NO_VERIFY'",
"]",
"return",
"path",
"if",
... | Detects an installed version of the executable that matches the
requirements.
@return [String] path to an executable that meets the requirements
@raise [Cliver::Dependency::NotMet] if no match found | [
"Detects",
"an",
"installed",
"version",
"of",
"the",
"executable",
"that",
"matches",
"the",
"requirements",
"."
] | 3d72e99af19c273a3f88adcd4b96c4b65b1b6d4b | https://github.com/yaauie/cliver/blob/3d72e99af19c273a3f88adcd4b96c4b65b1b6d4b/lib/cliver/dependency.rb#L106-L118 | train |
shortdudey123/yamllint | lib/yamllint/linter.rb | YamlLint.Linter.check | def check(path)
raise FileNotFoundError, "#{path}: no such file" unless File.exist?(path)
valid = false
unless disable_extension_check
unless check_filename(path)
errors[path] = ['File extension must be .yaml or .yml']
return valid
end
end
File.open(pa... | ruby | def check(path)
raise FileNotFoundError, "#{path}: no such file" unless File.exist?(path)
valid = false
unless disable_extension_check
unless check_filename(path)
errors[path] = ['File extension must be .yaml or .yml']
return valid
end
end
File.open(pa... | [
"def",
"check",
"(",
"path",
")",
"raise",
"FileNotFoundError",
",",
"\"#{path}: no such file\"",
"unless",
"File",
".",
"exist?",
"(",
"path",
")",
"valid",
"=",
"false",
"unless",
"disable_extension_check",
"unless",
"check_filename",
"(",
"path",
")",
"errors",... | Check a single file | [
"Check",
"a",
"single",
"file"
] | aa8e0538882eddcd2996f6f62fabaafda3fdb942 | https://github.com/shortdudey123/yamllint/blob/aa8e0538882eddcd2996f6f62fabaafda3fdb942/lib/yamllint/linter.rb#L35-L53 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.