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
sequence
docstring
stringlengths
8
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
Kuniri/kuniri
lib/kuniri/core/kuniri.rb
Kuniri.Kuniri.run_analysis
def run_analysis @filesPathProject = get_project_file(@configurationInfo[:source]) unless @filesPathProject message = "Problem on source path: #{@configurationInfo[:source]}" Util::LoggerKuniri.error(message) return -1 end @parser = Parser::Parser.new(@filesPathProject, @configurationInfo[:language]) Util::LoggerKuniri.info('Start parse...') begin @parser.start_parser rescue Error::ConfigurationFileError => e puts e.message end end
ruby
def run_analysis @filesPathProject = get_project_file(@configurationInfo[:source]) unless @filesPathProject message = "Problem on source path: #{@configurationInfo[:source]}" Util::LoggerKuniri.error(message) return -1 end @parser = Parser::Parser.new(@filesPathProject, @configurationInfo[:language]) Util::LoggerKuniri.info('Start parse...') begin @parser.start_parser rescue Error::ConfigurationFileError => e puts e.message end end
[ "def", "run_analysis", "@filesPathProject", "=", "get_project_file", "(", "@configurationInfo", "[", ":source", "]", ")", "unless", "@filesPathProject", "message", "=", "\"Problem on source path: #{@configurationInfo[:source]}\"", "Util", "::", "LoggerKuniri", ".", "error", "(", "message", ")", "return", "-", "1", "end", "@parser", "=", "Parser", "::", "Parser", ".", "new", "(", "@filesPathProject", ",", "@configurationInfo", "[", ":language", "]", ")", "Util", "::", "LoggerKuniri", ".", "info", "(", "'Start parse...'", ")", "begin", "@parser", ".", "start_parser", "rescue", "Error", "::", "ConfigurationFileError", "=>", "e", "puts", "e", ".", "message", "end", "end" ]
Start Kuniri tasks based on configuration file. After read configuration file, find all files in source directory.
[ "Start", "Kuniri", "tasks", "based", "on", "configuration", "file", ".", "After", "read", "configuration", "file", "find", "all", "files", "in", "source", "directory", "." ]
8b840ab307dc6bec48edd272c732b28c98f93f45
https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/core/kuniri.rb#L52-L67
train
donaldpiret/github-pivotal-flow
lib/github_pivotal_flow/publish.rb
GithubPivotalFlow.Publish.run!
def run! story = @configuration.story fail("Could not find story associated with branch") unless story Git.clean_working_tree? Git.push(story.branch_name, set_upstream: true) unless story.release? print "Creating pull-request on Github... " pull_request_params = story.params_for_pull_request.merge(project: @configuration.project) @configuration.github_client.create_pullrequest(pull_request_params) puts 'OK' end return 0 end
ruby
def run! story = @configuration.story fail("Could not find story associated with branch") unless story Git.clean_working_tree? Git.push(story.branch_name, set_upstream: true) unless story.release? print "Creating pull-request on Github... " pull_request_params = story.params_for_pull_request.merge(project: @configuration.project) @configuration.github_client.create_pullrequest(pull_request_params) puts 'OK' end return 0 end
[ "def", "run!", "story", "=", "@configuration", ".", "story", "fail", "(", "\"Could not find story associated with branch\"", ")", "unless", "story", "Git", ".", "clean_working_tree?", "Git", ".", "push", "(", "story", ".", "branch_name", ",", "set_upstream", ":", "true", ")", "unless", "story", ".", "release?", "print", "\"Creating pull-request on Github... \"", "pull_request_params", "=", "story", ".", "params_for_pull_request", ".", "merge", "(", "project", ":", "@configuration", ".", "project", ")", "@configuration", ".", "github_client", ".", "create_pullrequest", "(", "pull_request_params", ")", "puts", "'OK'", "end", "return", "0", "end" ]
Publishes the branch and opens the pull request
[ "Publishes", "the", "branch", "and", "opens", "the", "pull", "request" ]
676436950b691f57ad793a9023a4765ab9420dd0
https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/publish.rb#L6-L18
train
payneteasy/ruby-library-payneteasy-api
lib/paynet_easy/paynet_easy_api/query/create_card_ref_query.rb
PaynetEasy::PaynetEasyApi::Query.CreateCardRefQuery.check_payment_transaction_status
def check_payment_transaction_status(payment_transaction) unless payment_transaction.finished? raise ValidationError, 'Only finished payment transaction can be used for create-card-ref-id' end unless payment_transaction.payment.paid? raise ValidationError, "Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first" end end
ruby
def check_payment_transaction_status(payment_transaction) unless payment_transaction.finished? raise ValidationError, 'Only finished payment transaction can be used for create-card-ref-id' end unless payment_transaction.payment.paid? raise ValidationError, "Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first" end end
[ "def", "check_payment_transaction_status", "(", "payment_transaction", ")", "unless", "payment_transaction", ".", "finished?", "raise", "ValidationError", ",", "'Only finished payment transaction can be used for create-card-ref-id'", "end", "unless", "payment_transaction", ".", "payment", ".", "paid?", "raise", "ValidationError", ",", "\"Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first\"", "end", "end" ]
Check, if payment transaction is finished and payment is not new. @param payment_transaction [PaymentTransaction] Payment transaction for validation
[ "Check", "if", "payment", "transaction", "is", "finished", "and", "payment", "is", "not", "new", "." ]
3200a447829b62e241fdc329f80fddb5f8d68cc0
https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/create_card_ref_query.rb#L68-L76
train
dceballos/roomer
lib/roomer/utils.rb
Roomer.Utils.current_tenant=
def current_tenant=(val) key = :"roomer_current_tenant" unless Thread.current[key].try(:url_identifier) == val.try(:url_identifier) Thread.current[key] = val ensure_tenant_model_reset end Thread.current[key] end
ruby
def current_tenant=(val) key = :"roomer_current_tenant" unless Thread.current[key].try(:url_identifier) == val.try(:url_identifier) Thread.current[key] = val ensure_tenant_model_reset end Thread.current[key] end
[ "def", "current_tenant", "=", "(", "val", ")", "key", "=", ":\"", "\"", "unless", "Thread", ".", "current", "[", "key", "]", ".", "try", "(", ":url_identifier", ")", "==", "val", ".", "try", "(", ":url_identifier", ")", "Thread", ".", "current", "[", "key", "]", "=", "val", "ensure_tenant_model_reset", "end", "Thread", ".", "current", "[", "key", "]", "end" ]
Sets current tenant from ApplicationController into a Thread local variable. Works only with thread-safe Rails as long as it gets set on every request @return [Symbol] the current tenant key in the thread
[ "Sets", "current", "tenant", "from", "ApplicationController", "into", "a", "Thread", "local", "variable", ".", "Works", "only", "with", "thread", "-", "safe", "Rails", "as", "long", "as", "it", "gets", "set", "on", "every", "request" ]
923908cc5f239578c322f0851720fb69a68353b7
https://github.com/dceballos/roomer/blob/923908cc5f239578c322f0851720fb69a68353b7/lib/roomer/utils.rb#L41-L48
train
dceballos/roomer
lib/roomer/utils.rb
Roomer.Utils.with_tenant
def with_tenant(tenant,&blk) orig = self.current_tenant begin self.current_tenant = tenant return blk.call(tenant) ensure self.current_tenant = orig end end
ruby
def with_tenant(tenant,&blk) orig = self.current_tenant begin self.current_tenant = tenant return blk.call(tenant) ensure self.current_tenant = orig end end
[ "def", "with_tenant", "(", "tenant", ",", "&", "blk", ")", "orig", "=", "self", ".", "current_tenant", "begin", "self", ".", "current_tenant", "=", "tenant", "return", "blk", ".", "call", "(", "tenant", ")", "ensure", "self", ".", "current_tenant", "=", "orig", "end", "end" ]
Replace current_tenant with @tenant during the execution of @blk
[ "Replace", "current_tenant", "with" ]
923908cc5f239578c322f0851720fb69a68353b7
https://github.com/dceballos/roomer/blob/923908cc5f239578c322f0851720fb69a68353b7/lib/roomer/utils.rb#L66-L74
train
bdurand/json_record
lib/json_record/field_definition.rb
JsonRecord.FieldDefinition.convert
def convert (val) return nil if val.blank? and val != false if @type == String return val.to_s elsif @type == Integer return Kernel.Integer(val) rescue val elsif @type == Float return Kernel.Float(val) rescue val elsif @type == Boolean v = BOOLEAN_MAPPING[val] v = val.to_s.downcase == 'true' if v.nil? # Check all mixed case spellings for true return v elsif @type == Date if val.is_a?(Date) return val elsif val.is_a?(Time) return val.to_date else return Date.parse(val.to_s) rescue val end elsif @type == Time if val.is_a?(Time) return Time.at((val.to_i / 60) * 60).utc else return Time.parse(val).utc rescue val end elsif @type == DateTime if val.is_a?(DateTime) return val.utc else return DateTime.parse(val).utc rescue val end elsif @type == Array val = [val] unless val.is_a?(Array) raise ArgumentError.new("#{name} must be an Array") unless val.is_a?(Array) return val elsif @type == Hash raise ArgumentError.new("#{name} must be a Hash") unless val.is_a?(Hash) return val elsif @type == BigDecimal return BigDecimal.new(val.to_s) else if val.is_a?(@type) val elsif val.is_a?(Hash) and (@type < EmbeddedDocument) return @type.new(val) else raise ArgumentError.new("#{name} must be a #{@type}") end end end
ruby
def convert (val) return nil if val.blank? and val != false if @type == String return val.to_s elsif @type == Integer return Kernel.Integer(val) rescue val elsif @type == Float return Kernel.Float(val) rescue val elsif @type == Boolean v = BOOLEAN_MAPPING[val] v = val.to_s.downcase == 'true' if v.nil? # Check all mixed case spellings for true return v elsif @type == Date if val.is_a?(Date) return val elsif val.is_a?(Time) return val.to_date else return Date.parse(val.to_s) rescue val end elsif @type == Time if val.is_a?(Time) return Time.at((val.to_i / 60) * 60).utc else return Time.parse(val).utc rescue val end elsif @type == DateTime if val.is_a?(DateTime) return val.utc else return DateTime.parse(val).utc rescue val end elsif @type == Array val = [val] unless val.is_a?(Array) raise ArgumentError.new("#{name} must be an Array") unless val.is_a?(Array) return val elsif @type == Hash raise ArgumentError.new("#{name} must be a Hash") unless val.is_a?(Hash) return val elsif @type == BigDecimal return BigDecimal.new(val.to_s) else if val.is_a?(@type) val elsif val.is_a?(Hash) and (@type < EmbeddedDocument) return @type.new(val) else raise ArgumentError.new("#{name} must be a #{@type}") end end end
[ "def", "convert", "(", "val", ")", "return", "nil", "if", "val", ".", "blank?", "and", "val", "!=", "false", "if", "@type", "==", "String", "return", "val", ".", "to_s", "elsif", "@type", "==", "Integer", "return", "Kernel", ".", "Integer", "(", "val", ")", "rescue", "val", "elsif", "@type", "==", "Float", "return", "Kernel", ".", "Float", "(", "val", ")", "rescue", "val", "elsif", "@type", "==", "Boolean", "v", "=", "BOOLEAN_MAPPING", "[", "val", "]", "v", "=", "val", ".", "to_s", ".", "downcase", "==", "'true'", "if", "v", ".", "nil?", "return", "v", "elsif", "@type", "==", "Date", "if", "val", ".", "is_a?", "(", "Date", ")", "return", "val", "elsif", "val", ".", "is_a?", "(", "Time", ")", "return", "val", ".", "to_date", "else", "return", "Date", ".", "parse", "(", "val", ".", "to_s", ")", "rescue", "val", "end", "elsif", "@type", "==", "Time", "if", "val", ".", "is_a?", "(", "Time", ")", "return", "Time", ".", "at", "(", "(", "val", ".", "to_i", "/", "60", ")", "*", "60", ")", ".", "utc", "else", "return", "Time", ".", "parse", "(", "val", ")", ".", "utc", "rescue", "val", "end", "elsif", "@type", "==", "DateTime", "if", "val", ".", "is_a?", "(", "DateTime", ")", "return", "val", ".", "utc", "else", "return", "DateTime", ".", "parse", "(", "val", ")", ".", "utc", "rescue", "val", "end", "elsif", "@type", "==", "Array", "val", "=", "[", "val", "]", "unless", "val", ".", "is_a?", "(", "Array", ")", "raise", "ArgumentError", ".", "new", "(", "\"#{name} must be an Array\"", ")", "unless", "val", ".", "is_a?", "(", "Array", ")", "return", "val", "elsif", "@type", "==", "Hash", "raise", "ArgumentError", ".", "new", "(", "\"#{name} must be a Hash\"", ")", "unless", "val", ".", "is_a?", "(", "Hash", ")", "return", "val", "elsif", "@type", "==", "BigDecimal", "return", "BigDecimal", ".", "new", "(", "val", ".", "to_s", ")", "else", "if", "val", ".", "is_a?", "(", "@type", ")", "val", "elsif", "val", ".", "is_a?", "(", "Hash", ")", "and", "(", "@type", "<", "EmbeddedDocument", ")", "return", "@type", ".", "new", "(", "val", ")", "else", "raise", "ArgumentError", ".", "new", "(", "\"#{name} must be a #{@type}\"", ")", "end", "end", "end" ]
Convert a value to the proper class for storing it in the field. If the value can't be converted, the original value will be returned. Blank values are always translated to nil. Hashes will be converted to EmbeddedDocument objects if the field type extends from EmbeddedDocument.
[ "Convert", "a", "value", "to", "the", "proper", "class", "for", "storing", "it", "in", "the", "field", ".", "If", "the", "value", "can", "t", "be", "converted", "the", "original", "value", "will", "be", "returned", ".", "Blank", "values", "are", "always", "translated", "to", "nil", ".", "Hashes", "will", "be", "converted", "to", "EmbeddedDocument", "objects", "if", "the", "field", "type", "extends", "from", "EmbeddedDocument", "." ]
463f4719d9618f6d2406c0aab6028e0156f7c775
https://github.com/bdurand/json_record/blob/463f4719d9618f6d2406c0aab6028e0156f7c775/lib/json_record/field_definition.rb#L42-L92
train
dapi/gritter_notices
lib/gritter_notices/active_record.rb
GritterNotices::ActiveRecord.InstanceMethods.method_missing
def method_missing(method_name, *args, &block) if level = ValidMethods[method_name.to_s] or level = ValidMethods["gritter_#{method_name}"] options = args.extract_options! options[:level] = level args << options gritter_notice *args else super(method_name, *args, &block) end end
ruby
def method_missing(method_name, *args, &block) if level = ValidMethods[method_name.to_s] or level = ValidMethods["gritter_#{method_name}"] options = args.extract_options! options[:level] = level args << options gritter_notice *args else super(method_name, *args, &block) end end
[ "def", "method_missing", "(", "method_name", ",", "*", "args", ",", "&", "block", ")", "if", "level", "=", "ValidMethods", "[", "method_name", ".", "to_s", "]", "or", "level", "=", "ValidMethods", "[", "\"gritter_#{method_name}\"", "]", "options", "=", "args", ".", "extract_options!", "options", "[", ":level", "]", "=", "level", "args", "<<", "options", "gritter_notice", "*", "args", "else", "super", "(", "method_name", ",", "*", "args", ",", "&", "block", ")", "end", "end" ]
notice_success notice_error notice_warning notice_progress notice_notice - default. An alias for `notice`
[ "notice_success", "notice_error", "notice_warning", "notice_progress", "notice_notice", "-", "default", ".", "An", "alias", "for", "notice" ]
739b49ac96ba733e5276677a04bd8c5e4a73716d
https://github.com/dapi/gritter_notices/blob/739b49ac96ba733e5276677a04bd8c5e4a73716d/lib/gritter_notices/active_record.rb#L41-L50
train
mikerodrigues/onkyo_eiscp_ruby
lib/eiscp/message.rb
EISCP.Message.get_human_readable_attrs
def get_human_readable_attrs @zone = Dictionary.zone_from_command(@command) @command_name = Dictionary.command_to_name(@command) @command_description = Dictionary.description_from_command(@command) @value_name = Dictionary.command_value_to_value_name(@command, @value) @value_description = Dictionary.description_from_command_value(@command, @value) end
ruby
def get_human_readable_attrs @zone = Dictionary.zone_from_command(@command) @command_name = Dictionary.command_to_name(@command) @command_description = Dictionary.description_from_command(@command) @value_name = Dictionary.command_value_to_value_name(@command, @value) @value_description = Dictionary.description_from_command_value(@command, @value) end
[ "def", "get_human_readable_attrs", "@zone", "=", "Dictionary", ".", "zone_from_command", "(", "@command", ")", "@command_name", "=", "Dictionary", ".", "command_to_name", "(", "@command", ")", "@command_description", "=", "Dictionary", ".", "description_from_command", "(", "@command", ")", "@value_name", "=", "Dictionary", ".", "command_value_to_value_name", "(", "@command", ",", "@value", ")", "@value_description", "=", "Dictionary", ".", "description_from_command_value", "(", "@command", ",", "@value", ")", "end" ]
Retrieves human readable attributes from the yaml file via Dictionary
[ "Retrieves", "human", "readable", "attributes", "from", "the", "yaml", "file", "via", "Dictionary" ]
c51f8b22c74decd88b1d1a91e170885c4ec2a0b0
https://github.com/mikerodrigues/onkyo_eiscp_ruby/blob/c51f8b22c74decd88b1d1a91e170885c4ec2a0b0/lib/eiscp/message.rb#L115-L121
train
razor-x/config_curator
lib/config_curator/package_lookup.rb
ConfigCurator.PackageLookup.installed?
def installed?(package) fail LookupFailed, 'No supported package tool found.' if tool.nil? cmd = tools[tool] fail LookupFailed, "Package tool '#{cmd}' not found." if command?(cmd).nil? send tool, package end
ruby
def installed?(package) fail LookupFailed, 'No supported package tool found.' if tool.nil? cmd = tools[tool] fail LookupFailed, "Package tool '#{cmd}' not found." if command?(cmd).nil? send tool, package end
[ "def", "installed?", "(", "package", ")", "fail", "LookupFailed", ",", "'No supported package tool found.'", "if", "tool", ".", "nil?", "cmd", "=", "tools", "[", "tool", "]", "fail", "LookupFailed", ",", "\"Package tool '#{cmd}' not found.\"", "if", "command?", "(", "cmd", ")", ".", "nil?", "send", "tool", ",", "package", "end" ]
Checks if package is installed. @param package [String] package name to check @return [Boolean] if package is installed
[ "Checks", "if", "package", "is", "installed", "." ]
b0c0742ba0c36acf66de3eafd23a7d17b210036b
https://github.com/razor-x/config_curator/blob/b0c0742ba0c36acf66de3eafd23a7d17b210036b/lib/config_curator/package_lookup.rb#L55-L62
train
razor-x/config_curator
lib/config_curator/package_lookup.rb
ConfigCurator.PackageLookup.dpkg
def dpkg(package) cmd = command? 'dpkg' Open3.popen3 cmd, '-s', package do |_, _, _, wait_thr| wait_thr.value.to_i == 0 end end
ruby
def dpkg(package) cmd = command? 'dpkg' Open3.popen3 cmd, '-s', package do |_, _, _, wait_thr| wait_thr.value.to_i == 0 end end
[ "def", "dpkg", "(", "package", ")", "cmd", "=", "command?", "'dpkg'", "Open3", ".", "popen3", "cmd", ",", "'-s'", ",", "package", "do", "|", "_", ",", "_", ",", "_", ",", "wait_thr", "|", "wait_thr", ".", "value", ".", "to_i", "==", "0", "end", "end" ]
Tool specific package lookup methods below.
[ "Tool", "specific", "package", "lookup", "methods", "below", "." ]
b0c0742ba0c36acf66de3eafd23a7d17b210036b
https://github.com/razor-x/config_curator/blob/b0c0742ba0c36acf66de3eafd23a7d17b210036b/lib/config_curator/package_lookup.rb#L70-L75
train
Fetcher/mongo-fixture
lib/mongo-fixture.rb
Mongo.Fixture.check
def check return @checked if @checked # If already checked, it's alright raise MissingFixtureError, "No fixture has been loaded, nothing to check" unless @data raise MissingConnectionError, "No connection has been provided, impossible to check" unless @connection @data.each_key do |collection| raise CollectionsNotEmptyError, "The collection '#{collection}' is not empty, all collections should be empty prior to testing" if @connection[collection].count != 0 end return @checked = true end
ruby
def check return @checked if @checked # If already checked, it's alright raise MissingFixtureError, "No fixture has been loaded, nothing to check" unless @data raise MissingConnectionError, "No connection has been provided, impossible to check" unless @connection @data.each_key do |collection| raise CollectionsNotEmptyError, "The collection '#{collection}' is not empty, all collections should be empty prior to testing" if @connection[collection].count != 0 end return @checked = true end
[ "def", "check", "return", "@checked", "if", "@checked", "raise", "MissingFixtureError", ",", "\"No fixture has been loaded, nothing to check\"", "unless", "@data", "raise", "MissingConnectionError", ",", "\"No connection has been provided, impossible to check\"", "unless", "@connection", "@data", ".", "each_key", "do", "|", "collection", "|", "raise", "CollectionsNotEmptyError", ",", "\"The collection '#{collection}' is not empty, all collections should be empty prior to testing\"", "if", "@connection", "[", "collection", "]", ".", "count", "!=", "0", "end", "return", "@checked", "=", "true", "end" ]
Assures that the collections are empty before proceeding
[ "Assures", "that", "the", "collections", "are", "empty", "before", "proceeding" ]
b03175529d7ffce060cfcbeea29fe17288d7b778
https://github.com/Fetcher/mongo-fixture/blob/b03175529d7ffce060cfcbeea29fe17288d7b778/lib/mongo-fixture.rb#L103-L113
train
Fetcher/mongo-fixture
lib/mongo-fixture.rb
Mongo.Fixture.rollback
def rollback begin check @data.each_key do |collection| @connection[collection].drop end rescue CollectionsNotEmptyError => e raise RollbackIllegalError, "The collections weren't empty to begin with, rollback aborted." end end
ruby
def rollback begin check @data.each_key do |collection| @connection[collection].drop end rescue CollectionsNotEmptyError => e raise RollbackIllegalError, "The collections weren't empty to begin with, rollback aborted." end end
[ "def", "rollback", "begin", "check", "@data", ".", "each_key", "do", "|", "collection", "|", "@connection", "[", "collection", "]", ".", "drop", "end", "rescue", "CollectionsNotEmptyError", "=>", "e", "raise", "RollbackIllegalError", ",", "\"The collections weren't empty to begin with, rollback aborted.\"", "end", "end" ]
Empties the collections, only if they were empty to begin with
[ "Empties", "the", "collections", "only", "if", "they", "were", "empty", "to", "begin", "with" ]
b03175529d7ffce060cfcbeea29fe17288d7b778
https://github.com/Fetcher/mongo-fixture/blob/b03175529d7ffce060cfcbeea29fe17288d7b778/lib/mongo-fixture.rb#L138-L148
train
r7kamura/altria
lib/altria/scheduler.rb
Altria.Scheduler.scheduled?
def scheduled? [:min, :hour, :day, :month, :wday].all? do |key| send(key).nil? || send(key) == now.send(key) end end
ruby
def scheduled? [:min, :hour, :day, :month, :wday].all? do |key| send(key).nil? || send(key) == now.send(key) end end
[ "def", "scheduled?", "[", ":min", ",", ":hour", ",", ":day", ",", ":month", ",", ":wday", "]", ".", "all?", "do", "|", "key", "|", "send", "(", "key", ")", ".", "nil?", "||", "send", "(", "key", ")", "==", "now", ".", "send", "(", "key", ")", "end", "end" ]
Takes a schedule as a String.
[ "Takes", "a", "schedule", "as", "a", "String", "." ]
d7743298b1cef2a839be6f6a3ce2a697dda44fda
https://github.com/r7kamura/altria/blob/d7743298b1cef2a839be6f6a3ce2a697dda44fda/lib/altria/scheduler.rb#L11-L15
train
RipTheJacker/auto_excerpt
lib/auto_excerpt/parser.rb
AutoExcerpt.Parser.close_tags
def close_tags(text) # Don't bother closing tags if html is stripped since there are no tags. if @settings[:strip_html] && @settings[:allowed_tags].empty? tagstoclose = nil else tagstoclose = "" tags = [] opentags = text.scan(OPENING_TAG).transpose[0] || [] opentags.reverse! closedtags = text.scan(CLOSING_TAG).transpose[0] || [] opentags.each do |ot| if closedtags.include?(ot) closedtags.delete_at(closedtags.index(ot)) else tags << ot end end tags.each do |tag| tagstoclose << "</#{tag.strip.downcase}>" unless NO_CLOSE.include?(tag) end end @excerpt = [text, @settings[:ending], tagstoclose].join end
ruby
def close_tags(text) # Don't bother closing tags if html is stripped since there are no tags. if @settings[:strip_html] && @settings[:allowed_tags].empty? tagstoclose = nil else tagstoclose = "" tags = [] opentags = text.scan(OPENING_TAG).transpose[0] || [] opentags.reverse! closedtags = text.scan(CLOSING_TAG).transpose[0] || [] opentags.each do |ot| if closedtags.include?(ot) closedtags.delete_at(closedtags.index(ot)) else tags << ot end end tags.each do |tag| tagstoclose << "</#{tag.strip.downcase}>" unless NO_CLOSE.include?(tag) end end @excerpt = [text, @settings[:ending], tagstoclose].join end
[ "def", "close_tags", "(", "text", ")", "if", "@settings", "[", ":strip_html", "]", "&&", "@settings", "[", ":allowed_tags", "]", ".", "empty?", "tagstoclose", "=", "nil", "else", "tagstoclose", "=", "\"\"", "tags", "=", "[", "]", "opentags", "=", "text", ".", "scan", "(", "OPENING_TAG", ")", ".", "transpose", "[", "0", "]", "||", "[", "]", "opentags", ".", "reverse!", "closedtags", "=", "text", ".", "scan", "(", "CLOSING_TAG", ")", ".", "transpose", "[", "0", "]", "||", "[", "]", "opentags", ".", "each", "do", "|", "ot", "|", "if", "closedtags", ".", "include?", "(", "ot", ")", "closedtags", ".", "delete_at", "(", "closedtags", ".", "index", "(", "ot", ")", ")", "else", "tags", "<<", "ot", "end", "end", "tags", ".", "each", "do", "|", "tag", "|", "tagstoclose", "<<", "\"</#{tag.strip.downcase}>\"", "unless", "NO_CLOSE", ".", "include?", "(", "tag", ")", "end", "end", "@excerpt", "=", "[", "text", ",", "@settings", "[", ":ending", "]", ",", "tagstoclose", "]", ".", "join", "end" ]
close html tags
[ "close", "html", "tags" ]
17514e21d5ee275e14d1596db387730d7ebb2b14
https://github.com/RipTheJacker/auto_excerpt/blob/17514e21d5ee275e14d1596db387730d7ebb2b14/lib/auto_excerpt/parser.rb#L79-L104
train
RipTheJacker/auto_excerpt
lib/auto_excerpt/parser.rb
AutoExcerpt.Parser.paragraphs
def paragraphs return non_excerpted_text if @pghcount < @settings[:paragraphs] text = @body.split("</p>").slice(@settings[:skip_paragraphs], @settings[:paragraphs]) @settings[:ending] = nil text = text.join("</p>") close_tags(text) end
ruby
def paragraphs return non_excerpted_text if @pghcount < @settings[:paragraphs] text = @body.split("</p>").slice(@settings[:skip_paragraphs], @settings[:paragraphs]) @settings[:ending] = nil text = text.join("</p>") close_tags(text) end
[ "def", "paragraphs", "return", "non_excerpted_text", "if", "@pghcount", "<", "@settings", "[", ":paragraphs", "]", "text", "=", "@body", ".", "split", "(", "\"</p>\"", ")", ".", "slice", "(", "@settings", "[", ":skip_paragraphs", "]", ",", "@settings", "[", ":paragraphs", "]", ")", "@settings", "[", ":ending", "]", "=", "nil", "text", "=", "text", ".", "join", "(", "\"</p>\"", ")", "close_tags", "(", "text", ")", "end" ]
limit by paragraphs
[ "limit", "by", "paragraphs" ]
17514e21d5ee275e14d1596db387730d7ebb2b14
https://github.com/RipTheJacker/auto_excerpt/blob/17514e21d5ee275e14d1596db387730d7ebb2b14/lib/auto_excerpt/parser.rb#L150-L156
train
RipTheJacker/auto_excerpt
lib/auto_excerpt/parser.rb
AutoExcerpt.Parser.strip_html
def strip_html(html) return @stripped_html if @stripped_html allowed = @settings[:allowed_tags] reg = if allowed.any? Regexp.new( %(<(?!(\\s|\\/)*(#{ allowed.map {|tag| Regexp.escape( tag )}.join( "|" ) })( |>|\\/|'|"|<|\\s*\\z))[^>]*(>+|\\s*\\z)), Regexp::IGNORECASE | Regexp::MULTILINE, 'u' ) else /<[^>]*(>+|\s*\z)/m end @stripped_html = html.gsub(reg,'') end
ruby
def strip_html(html) return @stripped_html if @stripped_html allowed = @settings[:allowed_tags] reg = if allowed.any? Regexp.new( %(<(?!(\\s|\\/)*(#{ allowed.map {|tag| Regexp.escape( tag )}.join( "|" ) })( |>|\\/|'|"|<|\\s*\\z))[^>]*(>+|\\s*\\z)), Regexp::IGNORECASE | Regexp::MULTILINE, 'u' ) else /<[^>]*(>+|\s*\z)/m end @stripped_html = html.gsub(reg,'') end
[ "def", "strip_html", "(", "html", ")", "return", "@stripped_html", "if", "@stripped_html", "allowed", "=", "@settings", "[", ":allowed_tags", "]", "reg", "=", "if", "allowed", ".", "any?", "Regexp", ".", "new", "(", "%(<(?!(\\\\s|\\\\/)*(#{ allowed.map {|tag| Regexp.escape( tag )}.join( \"|\" ) })( |>|\\\\/|'|\"|<|\\\\s*\\\\z))[^>]*(>+|\\\\s*\\\\z))", ",", "Regexp", "::", "IGNORECASE", "|", "Regexp", "::", "MULTILINE", ",", "'u'", ")", "else", "/", "\\s", "\\z", "/m", "end", "@stripped_html", "=", "html", ".", "gsub", "(", "reg", ",", "''", ")", "end" ]
Removes HTML tags from a string. Allows you to specify some tags to be kept. @see http://codesnippets.joyent.com/posts/show/1354#comment-293
[ "Removes", "HTML", "tags", "from", "a", "string", ".", "Allows", "you", "to", "specify", "some", "tags", "to", "be", "kept", "." ]
17514e21d5ee275e14d1596db387730d7ebb2b14
https://github.com/RipTheJacker/auto_excerpt/blob/17514e21d5ee275e14d1596db387730d7ebb2b14/lib/auto_excerpt/parser.rb#L165-L179
train
kunishi/algebra-ruby2
lib/algebra/gaussian-elimination.rb
Algebra.SquareMatrix.determinant_by_elimination_old
def determinant_by_elimination_old m = dup inv, k = m.left_eliminate! s = ground.unity (0...size).each do |i| s *= m[i, i] end s / k end
ruby
def determinant_by_elimination_old m = dup inv, k = m.left_eliminate! s = ground.unity (0...size).each do |i| s *= m[i, i] end s / k end
[ "def", "determinant_by_elimination_old", "m", "=", "dup", "inv", ",", "k", "=", "m", ".", "left_eliminate!", "s", "=", "ground", ".", "unity", "(", "0", "...", "size", ")", ".", "each", "do", "|", "i", "|", "s", "*=", "m", "[", "i", ",", "i", "]", "end", "s", "/", "k", "end" ]
def inverse_euclidian; left_inverse_euclidian; end
[ "def", "inverse_euclidian", ";", "left_inverse_euclidian", ";", "end" ]
8976fbaac14933d3206324c845b879bf67fa0cf7
https://github.com/kunishi/algebra-ruby2/blob/8976fbaac14933d3206324c845b879bf67fa0cf7/lib/algebra/gaussian-elimination.rb#L239-L247
train
kunishi/algebra-ruby2
lib/algebra/gaussian-elimination.rb
Algebra.SquareMatrix.determinant_by_elimination
def determinant_by_elimination m = dup det = ground.unity each_j do |d| if i = (d...size).find{|i| !m[i, d].zero?} if i != d m.sswap_r!(d, i) det = -det end c = m[d, d] det *= c (d+1...size).each do |i0| r = m.row!(i0) q = ground.unity * m[i0, d] / c #this lets the entries be in ground (d+1...size).each do |j0| r[j0] -= q * m[d, j0] end end else return ground.zero end end det end
ruby
def determinant_by_elimination m = dup det = ground.unity each_j do |d| if i = (d...size).find{|i| !m[i, d].zero?} if i != d m.sswap_r!(d, i) det = -det end c = m[d, d] det *= c (d+1...size).each do |i0| r = m.row!(i0) q = ground.unity * m[i0, d] / c #this lets the entries be in ground (d+1...size).each do |j0| r[j0] -= q * m[d, j0] end end else return ground.zero end end det end
[ "def", "determinant_by_elimination", "m", "=", "dup", "det", "=", "ground", ".", "unity", "each_j", "do", "|", "d", "|", "if", "i", "=", "(", "d", "...", "size", ")", ".", "find", "{", "|", "i", "|", "!", "m", "[", "i", ",", "d", "]", ".", "zero?", "}", "if", "i", "!=", "d", "m", ".", "sswap_r!", "(", "d", ",", "i", ")", "det", "=", "-", "det", "end", "c", "=", "m", "[", "d", ",", "d", "]", "det", "*=", "c", "(", "d", "+", "1", "...", "size", ")", ".", "each", "do", "|", "i0", "|", "r", "=", "m", ".", "row!", "(", "i0", ")", "q", "=", "ground", ".", "unity", "*", "m", "[", "i0", ",", "d", "]", "/", "c", "(", "d", "+", "1", "...", "size", ")", ".", "each", "do", "|", "j0", "|", "r", "[", "j0", "]", "-=", "q", "*", "m", "[", "d", ",", "j0", "]", "end", "end", "else", "return", "ground", ".", "zero", "end", "end", "det", "end" ]
ground ring must be a field
[ "ground", "ring", "must", "be", "a", "field" ]
8976fbaac14933d3206324c845b879bf67fa0cf7
https://github.com/kunishi/algebra-ruby2/blob/8976fbaac14933d3206324c845b879bf67fa0cf7/lib/algebra/gaussian-elimination.rb#L260-L283
train
jellybob/text_tractor
lib/text_tractor/projects.rb
TextTractor.Project.update_blurb
def update_blurb(state, locale, key, value, overwrite = false) id = key key = "projects:#{api_key}:#{state}_blurbs:#{key}" current_value = redis.sismember("projects:#{api_key}:#{state}_blurb_keys", id) ? JSON.parse(redis.get(key)) : {} phrase = Phrase.new(self, current_value) # A new value is only written if no previous translation was present, or overwriting is enabled. if overwrite || phrase[locale].text.nil? phrase[locale] = value redis.sadd "projects:#{api_key}:#{state}_blurb_keys", id redis.sadd "projects:#{api_key}:locales", locale redis.set key, phrase.to_hash.to_json redis.set "projects:#{api_key}:#{state}_blurbs_etag", Projects.random_key end end
ruby
def update_blurb(state, locale, key, value, overwrite = false) id = key key = "projects:#{api_key}:#{state}_blurbs:#{key}" current_value = redis.sismember("projects:#{api_key}:#{state}_blurb_keys", id) ? JSON.parse(redis.get(key)) : {} phrase = Phrase.new(self, current_value) # A new value is only written if no previous translation was present, or overwriting is enabled. if overwrite || phrase[locale].text.nil? phrase[locale] = value redis.sadd "projects:#{api_key}:#{state}_blurb_keys", id redis.sadd "projects:#{api_key}:locales", locale redis.set key, phrase.to_hash.to_json redis.set "projects:#{api_key}:#{state}_blurbs_etag", Projects.random_key end end
[ "def", "update_blurb", "(", "state", ",", "locale", ",", "key", ",", "value", ",", "overwrite", "=", "false", ")", "id", "=", "key", "key", "=", "\"projects:#{api_key}:#{state}_blurbs:#{key}\"", "current_value", "=", "redis", ".", "sismember", "(", "\"projects:#{api_key}:#{state}_blurb_keys\"", ",", "id", ")", "?", "JSON", ".", "parse", "(", "redis", ".", "get", "(", "key", ")", ")", ":", "{", "}", "phrase", "=", "Phrase", ".", "new", "(", "self", ",", "current_value", ")", "if", "overwrite", "||", "phrase", "[", "locale", "]", ".", "text", ".", "nil?", "phrase", "[", "locale", "]", "=", "value", "redis", ".", "sadd", "\"projects:#{api_key}:#{state}_blurb_keys\"", ",", "id", "redis", ".", "sadd", "\"projects:#{api_key}:locales\"", ",", "locale", "redis", ".", "set", "key", ",", "phrase", ".", "to_hash", ".", "to_json", "redis", ".", "set", "\"projects:#{api_key}:#{state}_blurbs_etag\"", ",", "Projects", ".", "random_key", "end", "end" ]
Set the overwrite option to true to force overwriting existing translations.
[ "Set", "the", "overwrite", "option", "to", "true", "to", "force", "overwriting", "existing", "translations", "." ]
8ffde8f505655c40614c523ff6b8d18b274d093c
https://github.com/jellybob/text_tractor/blob/8ffde8f505655c40614c523ff6b8d18b274d093c/lib/text_tractor/projects.rb#L39-L55
train
ArchimediaZerogroup/KonoUtils
lib/kono_utils/base_search.rb
KonoUtils.BaseSearch.get_query_params
def get_query_params out = {} search_attributes.each do |val| out[val.field]=self.send(val.field) unless self.send(val.field).blank? end out end
ruby
def get_query_params out = {} search_attributes.each do |val| out[val.field]=self.send(val.field) unless self.send(val.field).blank? end out end
[ "def", "get_query_params", "out", "=", "{", "}", "search_attributes", ".", "each", "do", "|", "val", "|", "out", "[", "val", ".", "field", "]", "=", "self", ".", "send", "(", "val", ".", "field", ")", "unless", "self", ".", "send", "(", "val", ".", "field", ")", ".", "blank?", "end", "out", "end" ]
Restituisce un hash con tutti i parametri da implementare sulla ricerca
[ "Restituisce", "un", "hash", "con", "tutti", "i", "parametri", "da", "implementare", "sulla", "ricerca" ]
a255a30b65e4e0f01cd6236d991da4fd13c64fc6
https://github.com/ArchimediaZerogroup/KonoUtils/blob/a255a30b65e4e0f01cd6236d991da4fd13c64fc6/lib/kono_utils/base_search.rb#L147-L154
train
ArchimediaZerogroup/KonoUtils
lib/kono_utils/base_search.rb
KonoUtils.BaseSearch.update_attributes
def update_attributes(datas) search_attributes.each do |val| self.send("#{val.field}=", val.cast_value(datas[val.field])) end end
ruby
def update_attributes(datas) search_attributes.each do |val| self.send("#{val.field}=", val.cast_value(datas[val.field])) end end
[ "def", "update_attributes", "(", "datas", ")", "search_attributes", ".", "each", "do", "|", "val", "|", "self", ".", "send", "(", "\"#{val.field}=\"", ",", "val", ".", "cast_value", "(", "datas", "[", "val", ".", "field", "]", ")", ")", "end", "end" ]
Si occupa di aggiornare i valori interni di ricerca
[ "Si", "occupa", "di", "aggiornare", "i", "valori", "interni", "di", "ricerca" ]
a255a30b65e4e0f01cd6236d991da4fd13c64fc6
https://github.com/ArchimediaZerogroup/KonoUtils/blob/a255a30b65e4e0f01cd6236d991da4fd13c64fc6/lib/kono_utils/base_search.rb#L158-L162
train
leshill/mongodoc
lib/mongoid/criteria.rb
Mongoid.Criteria.fuse
def fuse(criteria_conditions = {}) criteria_conditions.inject(self) do |criteria, (key, value)| criteria.send(key, value) end end
ruby
def fuse(criteria_conditions = {}) criteria_conditions.inject(self) do |criteria, (key, value)| criteria.send(key, value) end end
[ "def", "fuse", "(", "criteria_conditions", "=", "{", "}", ")", "criteria_conditions", ".", "inject", "(", "self", ")", "do", "|", "criteria", ",", "(", "key", ",", "value", ")", "|", "criteria", ".", "send", "(", "key", ",", "value", ")", "end", "end" ]
Merges the supplied argument hash into a single criteria Options: criteria_conditions: Hash of criteria keys, and parameter values Example: <tt>criteria.fuse(:where => { :field => "value"}, :limit => 20)</tt> Returns <tt>self</tt>
[ "Merges", "the", "supplied", "argument", "hash", "into", "a", "single", "criteria" ]
fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4
https://github.com/leshill/mongodoc/blob/fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4/lib/mongoid/criteria.rb#L112-L116
train
leshill/mongodoc
lib/mongoid/criteria.rb
Mongoid.Criteria.merge
def merge(other) @selector.update(other.selector) @options.update(other.options) @documents = other.documents end
ruby
def merge(other) @selector.update(other.selector) @options.update(other.options) @documents = other.documents end
[ "def", "merge", "(", "other", ")", "@selector", ".", "update", "(", "other", ".", "selector", ")", "@options", ".", "update", "(", "other", ".", "options", ")", "@documents", "=", "other", ".", "documents", "end" ]
Create the new +Criteria+ object. This will initialize the selector and options hashes, as well as the type of criteria. Options: type: One of :all, :first:, or :last klass: The class to execute on. Merges another object into this +Criteria+. The other object may be a +Criteria+ or a +Hash+. This is used to combine multiple scopes together, where a chained scope situation may be desired. Options: other: The +Criteria+ or +Hash+ to merge with. Example: <tt>criteria.merge({ :conditions => { :title => "Sir" } })</tt>
[ "Create", "the", "new", "+", "Criteria", "+", "object", ".", "This", "will", "initialize", "the", "selector", "and", "options", "hashes", "as", "well", "as", "the", "type", "of", "criteria", "." ]
fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4
https://github.com/leshill/mongodoc/blob/fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4/lib/mongoid/criteria.rb#L140-L144
train
leshill/mongodoc
lib/mongoid/criteria.rb
Mongoid.Criteria.filter_options
def filter_options page_num = @options.delete(:page) per_page_num = @options.delete(:per_page) if (page_num || per_page_num) @options[:limit] = limits = (per_page_num || 20).to_i @options[:skip] = (page_num || 1).to_i * limits - limits end end
ruby
def filter_options page_num = @options.delete(:page) per_page_num = @options.delete(:per_page) if (page_num || per_page_num) @options[:limit] = limits = (per_page_num || 20).to_i @options[:skip] = (page_num || 1).to_i * limits - limits end end
[ "def", "filter_options", "page_num", "=", "@options", ".", "delete", "(", ":page", ")", "per_page_num", "=", "@options", ".", "delete", "(", ":per_page", ")", "if", "(", "page_num", "||", "per_page_num", ")", "@options", "[", ":limit", "]", "=", "limits", "=", "(", "per_page_num", "||", "20", ")", ".", "to_i", "@options", "[", ":skip", "]", "=", "(", "page_num", "||", "1", ")", ".", "to_i", "*", "limits", "-", "limits", "end", "end" ]
Filters the unused options out of the options +Hash+. Currently this takes into account the "page" and "per_page" options that would be passed in if using will_paginate. Example: Given a criteria with a selector of { :page => 1, :per_page => 40 } <tt>criteria.filter_options</tt> # selector: { :skip => 0, :limit => 40 }
[ "Filters", "the", "unused", "options", "out", "of", "the", "options", "+", "Hash", "+", ".", "Currently", "this", "takes", "into", "account", "the", "page", "and", "per_page", "options", "that", "would", "be", "passed", "in", "if", "using", "will_paginate", "." ]
fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4
https://github.com/leshill/mongodoc/blob/fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4/lib/mongoid/criteria.rb#L214-L221
train
leshill/mongodoc
lib/mongoid/criteria.rb
Mongoid.Criteria.update_selector
def update_selector(attributes, operator) attributes.each { |key, value| @selector[key] = { operator => value } }; self end
ruby
def update_selector(attributes, operator) attributes.each { |key, value| @selector[key] = { operator => value } }; self end
[ "def", "update_selector", "(", "attributes", ",", "operator", ")", "attributes", ".", "each", "{", "|", "key", ",", "value", "|", "@selector", "[", "key", "]", "=", "{", "operator", "=>", "value", "}", "}", ";", "self", "end" ]
Update the selector setting the operator on the value for each key in the supplied attributes +Hash+. Example: <tt>criteria.update_selector({ :field => "value" }, "$in")</tt>
[ "Update", "the", "selector", "setting", "the", "operator", "on", "the", "value", "for", "each", "key", "in", "the", "supplied", "attributes", "+", "Hash", "+", "." ]
fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4
https://github.com/leshill/mongodoc/blob/fb2a4ec456d4c4ae1eb92e117dc73f55951fc3b4/lib/mongoid/criteria.rb#L235-L237
train
kjvarga/arid_cache
lib/arid_cache/framework.rb
AridCache.Framework.active_record?
def active_record?(*args) version, comparator = args.pop, (args.pop || :==) result = if version.nil? defined?(::ActiveRecord) elsif defined?(::ActiveRecord) ar_version = ::ActiveRecord::VERSION::STRING.to_f ar_version = ar_version.floor if version.is_a?(Integer) ar_version.send(comparator, version.to_f) else false end !!result end
ruby
def active_record?(*args) version, comparator = args.pop, (args.pop || :==) result = if version.nil? defined?(::ActiveRecord) elsif defined?(::ActiveRecord) ar_version = ::ActiveRecord::VERSION::STRING.to_f ar_version = ar_version.floor if version.is_a?(Integer) ar_version.send(comparator, version.to_f) else false end !!result end
[ "def", "active_record?", "(", "*", "args", ")", "version", ",", "comparator", "=", "args", ".", "pop", ",", "(", "args", ".", "pop", "||", ":==", ")", "result", "=", "if", "version", ".", "nil?", "defined?", "(", "::", "ActiveRecord", ")", "elsif", "defined?", "(", "::", "ActiveRecord", ")", "ar_version", "=", "::", "ActiveRecord", "::", "VERSION", "::", "STRING", ".", "to_f", "ar_version", "=", "ar_version", ".", "floor", "if", "version", ".", "is_a?", "(", "Integer", ")", "ar_version", ".", "send", "(", "comparator", ",", "version", ".", "to_f", ")", "else", "false", "end", "!", "!", "result", "end" ]
Return a boolean indicating whether the version of ActiveRecord matches the constraints in the args. == Arguments Optional comparator function as a symbol followed by a version number as an integer or float. If the version is an integer only the major version is compared. if the version is a float the major.minor version is compared. If called with no arguments returns a boolean indicating whether ActiveRecord is defined. == Example active_record?(3) => true if ActiveRecord major version is 3 active_record?(3.0) => true if ActiveRecord major.minor version is 3.0 active_record?(:>=, 3) => true if ActiveRecord major version is >= 3 active_record?(:>=, 3.1) => true if ActiveRecord major.minor version is >= 3.1
[ "Return", "a", "boolean", "indicating", "whether", "the", "version", "of", "ActiveRecord", "matches", "the", "constraints", "in", "the", "args", "." ]
8a1e21b970aae37a3206a4ee08efa6f1002fc9e0
https://github.com/kjvarga/arid_cache/blob/8a1e21b970aae37a3206a4ee08efa6f1002fc9e0/lib/arid_cache/framework.rb#L23-L36
train
securityroots/vulndbhq
lib/vulndbhq/client.rb
VulnDBHQ.Client.private_page
def private_page(id, options={}) response = get("/api/private_pages/#{id}", options) VulnDBHQ::PrivatePage.from_response(response) end
ruby
def private_page(id, options={}) response = get("/api/private_pages/#{id}", options) VulnDBHQ::PrivatePage.from_response(response) end
[ "def", "private_page", "(", "id", ",", "options", "=", "{", "}", ")", "response", "=", "get", "(", "\"/api/private_pages/#{id}\"", ",", "options", ")", "VulnDBHQ", "::", "PrivatePage", ".", "from_response", "(", "response", ")", "end" ]
Initializes a new Client object @param options [Hash] @return [VulnDBHQ::Client] ************************************************************* PrivatePage Returns a private page @see http://support.securityroots.com/vulndbhq_api_v2.html#model-private-page @authentication_required Yes @raise [VulnDBHQ::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [VulnDBHQ::PrivatePage] The requested messages. @param id [Integer] A VulnDB HQ private page ID. @param options [Hash] A customizable set of options. @example Return the private page with the id 87 VulnDBHQ.private_page(87)
[ "Initializes", "a", "new", "Client", "object" ]
14db8db3877498d16fce166017bd50301b71fb63
https://github.com/securityroots/vulndbhq/blob/14db8db3877498d16fce166017bd50301b71fb63/lib/vulndbhq/client.rb#L46-L49
train
snusnu/substation
lib/substation/environment.rb
Substation.Environment.inherit
def inherit(app_env = self.app_env, actions = Dispatcher.new_registry, &block) self.class.new(app_env, actions, merged_chain_dsl(&block)) end
ruby
def inherit(app_env = self.app_env, actions = Dispatcher.new_registry, &block) self.class.new(app_env, actions, merged_chain_dsl(&block)) end
[ "def", "inherit", "(", "app_env", "=", "self", ".", "app_env", ",", "actions", "=", "Dispatcher", ".", "new_registry", ",", "&", "block", ")", "self", ".", "class", ".", "new", "(", "app_env", ",", "actions", ",", "merged_chain_dsl", "(", "&", "block", ")", ")", "end" ]
Initialize a new instance @param [Chain::DSL] chain_dsl the chain dsl tailored for the environment @return [undefined] @api private Inherit a new instance from self, merging the {Chain::DSL} @param [Dispatcher::Registry] actions the mutable action registry @param [Proc] block a block to instance_eval inside a {DSL} instance @return [Environment] @api private
[ "Initialize", "a", "new", "instance" ]
fabf062a3640f5e82dae68597f0709b63f6b9027
https://github.com/snusnu/substation/blob/fabf062a3640f5e82dae68597f0709b63f6b9027/lib/substation/environment.rb#L91-L93
train
snusnu/substation
lib/substation/environment.rb
Substation.Environment.register
def register(name, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) actions[name] = chain(name, other, exception_chain, &block) self end
ruby
def register(name, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) actions[name] = chain(name, other, exception_chain, &block) self end
[ "def", "register", "(", "name", ",", "other", "=", "Chain", "::", "EMPTY", ",", "exception_chain", "=", "Chain", "::", "EMPTY", ",", "&", "block", ")", "actions", "[", "name", "]", "=", "chain", "(", "name", ",", "other", ",", "exception_chain", ",", "&", "block", ")", "self", "end" ]
Register a new chain under the given +name+ @param [#to_sym] name the new chain's name @param [Chain] other the chain to build on top of @param [Chain] exception_chain the chain to invoke in case of uncaught exceptions in handlers @return [Chain] the registered chain @api private
[ "Register", "a", "new", "chain", "under", "the", "given", "+", "name", "+" ]
fabf062a3640f5e82dae68597f0709b63f6b9027
https://github.com/snusnu/substation/blob/fabf062a3640f5e82dae68597f0709b63f6b9027/lib/substation/environment.rb#L131-L134
train
dwradcliffe/groupme
lib/groupme/messages.rb
GroupMe.Messages.create_message
def create_message(group_id, text, attachments = []) data = { :message => { :source_guid => SecureRandom.uuid, :text => text } } data[:message][:attachments] = attachments if attachments.any? post("/groups/#{group_id}/messages", data).message end
ruby
def create_message(group_id, text, attachments = []) data = { :message => { :source_guid => SecureRandom.uuid, :text => text } } data[:message][:attachments] = attachments if attachments.any? post("/groups/#{group_id}/messages", data).message end
[ "def", "create_message", "(", "group_id", ",", "text", ",", "attachments", "=", "[", "]", ")", "data", "=", "{", ":message", "=>", "{", ":source_guid", "=>", "SecureRandom", ".", "uuid", ",", ":text", "=>", "text", "}", "}", "data", "[", ":message", "]", "[", ":attachments", "]", "=", "attachments", "if", "attachments", ".", "any?", "post", "(", "\"/groups/#{group_id}/messages\"", ",", "data", ")", ".", "message", "end" ]
Create a message for a group @return [Hashie::Mash] Hash representing the message @see https://dev.groupme.com/docs/v3#messages_create @param group_id [String, Integer] Id of the group @param text [String] Text of the message @param attachments [Array<Hash>] Array of attachments
[ "Create", "a", "message", "for", "a", "group" ]
a306dbcf38cc4d9ed219e010783799b2ccb4f9a2
https://github.com/dwradcliffe/groupme/blob/a306dbcf38cc4d9ed219e010783799b2ccb4f9a2/lib/groupme/messages.rb#L12-L21
train
dwradcliffe/groupme
lib/groupme/messages.rb
GroupMe.Messages.messages
def messages(group_id, options = {}, fetch_all = false) if fetch_all get_all_messages(group_id) else get_messages(group_id, options) end end
ruby
def messages(group_id, options = {}, fetch_all = false) if fetch_all get_all_messages(group_id) else get_messages(group_id, options) end end
[ "def", "messages", "(", "group_id", ",", "options", "=", "{", "}", ",", "fetch_all", "=", "false", ")", "if", "fetch_all", "get_all_messages", "(", "group_id", ")", "else", "get_messages", "(", "group_id", ",", "options", ")", "end", "end" ]
List messages for a group @return [Array<Hashie::Mash>] Array of hashes representing the messages @see https://dev.groupme.com/docs/v3#messages_index @param group_id [String, Integer] Id of the group @param options [Hash] options hash that will be passed to the groupme call @param fetch_all [Boolean] if true, fetches all messages for the group
[ "List", "messages", "for", "a", "group" ]
a306dbcf38cc4d9ed219e010783799b2ccb4f9a2
https://github.com/dwradcliffe/groupme/blob/a306dbcf38cc4d9ed219e010783799b2ccb4f9a2/lib/groupme/messages.rb#L30-L36
train
razor-x/config_curator
lib/config_curator/units/symlink.rb
ConfigCurator.Symlink.install_symlink
def install_symlink FileUtils.mkdir_p File.dirname(destination_path) FileUtils.symlink source_path, destination_path, force: true end
ruby
def install_symlink FileUtils.mkdir_p File.dirname(destination_path) FileUtils.symlink source_path, destination_path, force: true end
[ "def", "install_symlink", "FileUtils", ".", "mkdir_p", "File", ".", "dirname", "(", "destination_path", ")", "FileUtils", ".", "symlink", "source_path", ",", "destination_path", ",", "force", ":", "true", "end" ]
Recursively creates the necessary directories and make the symlink.
[ "Recursively", "creates", "the", "necessary", "directories", "and", "make", "the", "symlink", "." ]
b0c0742ba0c36acf66de3eafd23a7d17b210036b
https://github.com/razor-x/config_curator/blob/b0c0742ba0c36acf66de3eafd23a7d17b210036b/lib/config_curator/units/symlink.rb#L39-L42
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__get_partials_for_module
def core__get_partials_for_module(module_name) module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_partials = [] if module_configs[:partials] module_configs[:partials].each do |key, value| module_partials.push(core__generate_partial(key, value, module_name)) end end # return module items module_partials end
ruby
def core__get_partials_for_module(module_name) module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_partials = [] if module_configs[:partials] module_configs[:partials].each do |key, value| module_partials.push(core__generate_partial(key, value, module_name)) end end # return module items module_partials end
[ "def", "core__get_partials_for_module", "(", "module_name", ")", "module_configs", "=", "core__get_module_configs", "(", "module_name", ")", "return", "[", "]", "unless", "module_configs", "module_partials", "=", "[", "]", "if", "module_configs", "[", ":partials", "]", "module_configs", "[", ":partials", "]", ".", "each", "do", "|", "key", ",", "value", "|", "module_partials", ".", "push", "(", "core__generate_partial", "(", "key", ",", "value", ",", "module_name", ")", ")", "end", "end", "module_partials", "end" ]
This function return the list of partials for a specific module.
[ "This", "function", "return", "the", "list", "of", "partials", "for", "a", "specific", "module", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L35-L47
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__generate_partial
def core__generate_partial(key, values, module_name) partial = {} partial[:key] = key partial[:path] = values[:path] ? values[:path] : '' partial[:position] = values[:position] ? values[:position] : 999 partial end
ruby
def core__generate_partial(key, values, module_name) partial = {} partial[:key] = key partial[:path] = values[:path] ? values[:path] : '' partial[:position] = values[:position] ? values[:position] : 999 partial end
[ "def", "core__generate_partial", "(", "key", ",", "values", ",", "module_name", ")", "partial", "=", "{", "}", "partial", "[", ":key", "]", "=", "key", "partial", "[", ":path", "]", "=", "values", "[", ":path", "]", "?", "values", "[", ":path", "]", ":", "''", "partial", "[", ":position", "]", "=", "values", "[", ":position", "]", "?", "values", "[", ":position", "]", ":", "999", "partial", "end" ]
This function create a correct partial object for the header.
[ "This", "function", "create", "a", "correct", "partial", "object", "for", "the", "header", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L50-L56
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__get_widgets_for_module
def core__get_widgets_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_widgets = [] if module_configs[:widgets] module_configs[:widgets].each do |key, value| module_widgets.push(core__generate_widget(key, value, module_name)) end end # return module items return module_widgets end
ruby
def core__get_widgets_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_widgets = [] if module_configs[:widgets] module_configs[:widgets].each do |key, value| module_widgets.push(core__generate_widget(key, value, module_name)) end end # return module items return module_widgets end
[ "def", "core__get_widgets_for_module", "module_name", "module_configs", "=", "core__get_module_configs", "(", "module_name", ")", "return", "[", "]", "unless", "module_configs", "module_widgets", "=", "[", "]", "if", "module_configs", "[", ":widgets", "]", "module_configs", "[", ":widgets", "]", ".", "each", "do", "|", "key", ",", "value", "|", "module_widgets", ".", "push", "(", "core__generate_widget", "(", "key", ",", "value", ",", "module_name", ")", ")", "end", "end", "return", "module_widgets", "end" ]
This function return the list of widgets for a specific module.
[ "This", "function", "return", "the", "list", "of", "widgets", "for", "a", "specific", "module", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L75-L87
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__generate_widget
def core__generate_widget key, values, module_name widget = {} widget[:key] = key widget[:icon] = values[:icon] ? values[:icon] : 'check-circle' widget[:path] = values[:path] ? values[:path] : '' widget[:position] = values[:position] ? values[:position] : 999 widget[:title] = values[:title] ? values[:title] : '' return widget end
ruby
def core__generate_widget key, values, module_name widget = {} widget[:key] = key widget[:icon] = values[:icon] ? values[:icon] : 'check-circle' widget[:path] = values[:path] ? values[:path] : '' widget[:position] = values[:position] ? values[:position] : 999 widget[:title] = values[:title] ? values[:title] : '' return widget end
[ "def", "core__generate_widget", "key", ",", "values", ",", "module_name", "widget", "=", "{", "}", "widget", "[", ":key", "]", "=", "key", "widget", "[", ":icon", "]", "=", "values", "[", ":icon", "]", "?", "values", "[", ":icon", "]", ":", "'check-circle'", "widget", "[", ":path", "]", "=", "values", "[", ":path", "]", "?", "values", "[", ":path", "]", ":", "''", "widget", "[", ":position", "]", "=", "values", "[", ":position", "]", "?", "values", "[", ":position", "]", ":", "999", "widget", "[", ":title", "]", "=", "values", "[", ":title", "]", "?", "values", "[", ":title", "]", ":", "''", "return", "widget", "end" ]
This function create a correct widget object for the header.
[ "This", "function", "create", "a", "correct", "widget", "object", "for", "the", "header", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L90-L98
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__get_menu_for_module
def core__get_menu_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_menu = [] if module_configs[:menu] module_configs[:menu].each do |key, value| module_menu.push(core__generate_menu_item(key, value, module_name)) end end # return module items return module_menu end
ruby
def core__get_menu_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_menu = [] if module_configs[:menu] module_configs[:menu].each do |key, value| module_menu.push(core__generate_menu_item(key, value, module_name)) end end # return module items return module_menu end
[ "def", "core__get_menu_for_module", "module_name", "module_configs", "=", "core__get_module_configs", "(", "module_name", ")", "return", "[", "]", "unless", "module_configs", "module_menu", "=", "[", "]", "if", "module_configs", "[", ":menu", "]", "module_configs", "[", ":menu", "]", ".", "each", "do", "|", "key", ",", "value", "|", "module_menu", ".", "push", "(", "core__generate_menu_item", "(", "key", ",", "value", ",", "module_name", ")", ")", "end", "end", "return", "module_menu", "end" ]
This function returns the list of the items for the menu for a specific module.
[ "This", "function", "returns", "the", "list", "of", "the", "items", "for", "the", "menu", "for", "a", "specific", "module", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L117-L129
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__generate_menu_item
def core__generate_menu_item key, values, module_name menu_item = {} menu_item[:key] = key menu_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined' menu_item[:icon] = values[:icon] ? values[:icon] : 'check-circle' menu_item[:url] = values[:url] ? values[:url] : '' menu_item[:position] = values[:position] ? values[:position] : 999 menu_item[:permission_min] = values[:permission_min] ? values[:permission_min] : 0 menu_item[:permission_max] = values[:permission_max] ? values[:permission_max] : 999 menu_item[:sub_items] = [] if values[:sub_items] values[:sub_items].each do |key, value| menu_item[:sub_items].push(core__generate_menu_sub_item(key, value, module_name)) end end return menu_item end
ruby
def core__generate_menu_item key, values, module_name menu_item = {} menu_item[:key] = key menu_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined' menu_item[:icon] = values[:icon] ? values[:icon] : 'check-circle' menu_item[:url] = values[:url] ? values[:url] : '' menu_item[:position] = values[:position] ? values[:position] : 999 menu_item[:permission_min] = values[:permission_min] ? values[:permission_min] : 0 menu_item[:permission_max] = values[:permission_max] ? values[:permission_max] : 999 menu_item[:sub_items] = [] if values[:sub_items] values[:sub_items].each do |key, value| menu_item[:sub_items].push(core__generate_menu_sub_item(key, value, module_name)) end end return menu_item end
[ "def", "core__generate_menu_item", "key", ",", "values", ",", "module_name", "menu_item", "=", "{", "}", "menu_item", "[", ":key", "]", "=", "key", "menu_item", "[", ":title", "]", "=", "values", "[", ":title", "]", "?", "core__get_menu_title_translation", "(", "values", "[", ":title", "]", ",", "module_name", ")", ":", "'Undefined'", "menu_item", "[", ":icon", "]", "=", "values", "[", ":icon", "]", "?", "values", "[", ":icon", "]", ":", "'check-circle'", "menu_item", "[", ":url", "]", "=", "values", "[", ":url", "]", "?", "values", "[", ":url", "]", ":", "''", "menu_item", "[", ":position", "]", "=", "values", "[", ":position", "]", "?", "values", "[", ":position", "]", ":", "999", "menu_item", "[", ":permission_min", "]", "=", "values", "[", ":permission_min", "]", "?", "values", "[", ":permission_min", "]", ":", "0", "menu_item", "[", ":permission_max", "]", "=", "values", "[", ":permission_max", "]", "?", "values", "[", ":permission_max", "]", ":", "999", "menu_item", "[", ":sub_items", "]", "=", "[", "]", "if", "values", "[", ":sub_items", "]", "values", "[", ":sub_items", "]", ".", "each", "do", "|", "key", ",", "value", "|", "menu_item", "[", ":sub_items", "]", ".", "push", "(", "core__generate_menu_sub_item", "(", "key", ",", "value", ",", "module_name", ")", ")", "end", "end", "return", "menu_item", "end" ]
This function create a correct menu item object for the menu.
[ "This", "function", "create", "a", "correct", "menu", "item", "object", "for", "the", "menu", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L132-L150
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__generate_menu_sub_item
def core__generate_menu_sub_item key, values, module_name menu_sub_item = {} menu_sub_item[:key] = key menu_sub_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined' menu_sub_item[:url] = values[:url] ? values[:url] : '' menu_sub_item[:permission_min] = values[:permission_min] ? values[:permission_min] : 0 menu_sub_item[:permission_max] = values[:permission_max] ? values[:permission_max] : 999 return menu_sub_item end
ruby
def core__generate_menu_sub_item key, values, module_name menu_sub_item = {} menu_sub_item[:key] = key menu_sub_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined' menu_sub_item[:url] = values[:url] ? values[:url] : '' menu_sub_item[:permission_min] = values[:permission_min] ? values[:permission_min] : 0 menu_sub_item[:permission_max] = values[:permission_max] ? values[:permission_max] : 999 return menu_sub_item end
[ "def", "core__generate_menu_sub_item", "key", ",", "values", ",", "module_name", "menu_sub_item", "=", "{", "}", "menu_sub_item", "[", ":key", "]", "=", "key", "menu_sub_item", "[", ":title", "]", "=", "values", "[", ":title", "]", "?", "core__get_menu_title_translation", "(", "values", "[", ":title", "]", ",", "module_name", ")", ":", "'Undefined'", "menu_sub_item", "[", ":url", "]", "=", "values", "[", ":url", "]", "?", "values", "[", ":url", "]", ":", "''", "menu_sub_item", "[", ":permission_min", "]", "=", "values", "[", ":permission_min", "]", "?", "values", "[", ":permission_min", "]", ":", "0", "menu_sub_item", "[", ":permission_max", "]", "=", "values", "[", ":permission_max", "]", "?", "values", "[", ":permission_max", "]", ":", "999", "return", "menu_sub_item", "end" ]
This function create a correct menu sub itam object for the menu.
[ "This", "function", "create", "a", "correct", "menu", "sub", "itam", "object", "for", "the", "menu", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L153-L161
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__get_menu_title_translation
def core__get_menu_title_translation title, module_name return title if (!title.start_with?('translate')) title_key = core__get_string_inside_strings(title, '[', ']') module_languages = core__get_module_languages(module_name) return title if !module_languages || !module_languages[:menu] || !module_languages[:menu][title_key] return module_languages[:menu][title_key] end
ruby
def core__get_menu_title_translation title, module_name return title if (!title.start_with?('translate')) title_key = core__get_string_inside_strings(title, '[', ']') module_languages = core__get_module_languages(module_name) return title if !module_languages || !module_languages[:menu] || !module_languages[:menu][title_key] return module_languages[:menu][title_key] end
[ "def", "core__get_menu_title_translation", "title", ",", "module_name", "return", "title", "if", "(", "!", "title", ".", "start_with?", "(", "'translate'", ")", ")", "title_key", "=", "core__get_string_inside_strings", "(", "title", ",", "'['", ",", "']'", ")", "module_languages", "=", "core__get_module_languages", "(", "module_name", ")", "return", "title", "if", "!", "module_languages", "||", "!", "module_languages", "[", ":menu", "]", "||", "!", "module_languages", "[", ":menu", "]", "[", "title_key", "]", "return", "module_languages", "[", ":menu", "]", "[", "title_key", "]", "end" ]
This function check the title name and, if it need a translaction, it return the value.
[ "This", "function", "check", "the", "title", "name", "and", "if", "it", "need", "a", "translaction", "it", "return", "the", "value", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L164-L172
train
ideonetwork/lato-core
lib/lato_core/interfaces/layout.rb
LatoCore.Interface::Layout.core__get_assets_for_module
def core__get_assets_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module assets module_assets = [] if module_configs[:assets] module_configs[:assets].each do |key, value| module_assets.push(value) end end # return module assets return module_assets end
ruby
def core__get_assets_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module assets module_assets = [] if module_configs[:assets] module_configs[:assets].each do |key, value| module_assets.push(value) end end # return module assets return module_assets end
[ "def", "core__get_assets_for_module", "module_name", "module_configs", "=", "core__get_module_configs", "(", "module_name", ")", "return", "[", "]", "unless", "module_configs", "module_assets", "=", "[", "]", "if", "module_configs", "[", ":assets", "]", "module_configs", "[", ":assets", "]", ".", "each", "do", "|", "key", ",", "value", "|", "module_assets", ".", "push", "(", "value", ")", "end", "end", "return", "module_assets", "end" ]
This function return the lists of assets for a specific module.
[ "This", "function", "return", "the", "lists", "of", "assets", "for", "a", "specific", "module", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/lib/lato_core/interfaces/layout.rb#L190-L202
train
murayama/azure_media_service_ruby
lib/azure_media_service/service.rb
AzureMediaService.Service.create_access_policy
def create_access_policy(name:'Policy', duration_minutes:300, permission:2) warn("DEPRECATION WARNING: Service#create_access_policy is deprecated. Use AzureMediaService::AccessPolicy.create() instead.") post_body = { "Name" => name, "DurationInMinutes" => duration_minutes, "Permissions" => permission } res = @request.post("AccessPolicies", post_body) AccessPolicy.new(res["d"]) end
ruby
def create_access_policy(name:'Policy', duration_minutes:300, permission:2) warn("DEPRECATION WARNING: Service#create_access_policy is deprecated. Use AzureMediaService::AccessPolicy.create() instead.") post_body = { "Name" => name, "DurationInMinutes" => duration_minutes, "Permissions" => permission } res = @request.post("AccessPolicies", post_body) AccessPolicy.new(res["d"]) end
[ "def", "create_access_policy", "(", "name", ":", "'Policy'", ",", "duration_minutes", ":", "300", ",", "permission", ":", "2", ")", "warn", "(", "\"DEPRECATION WARNING: Service#create_access_policy is deprecated. Use AzureMediaService::AccessPolicy.create() instead.\"", ")", "post_body", "=", "{", "\"Name\"", "=>", "name", ",", "\"DurationInMinutes\"", "=>", "duration_minutes", ",", "\"Permissions\"", "=>", "permission", "}", "res", "=", "@request", ".", "post", "(", "\"AccessPolicies\"", ",", "post_body", ")", "AccessPolicy", ".", "new", "(", "res", "[", "\"d\"", "]", ")", "end" ]
access policy create
[ "access", "policy", "create" ]
e6f84daefab685a2dd4fa1de759d115a0800a967
https://github.com/murayama/azure_media_service_ruby/blob/e6f84daefab685a2dd4fa1de759d115a0800a967/lib/azure_media_service/service.rb#L25-L34
train
Sharparam/chatrix
lib/chatrix/room.rb
Chatrix.Room.process_join
def process_join(data) @state.update data['state'] if data.key? 'state' @timeline.update data['timeline'] if data.key? 'timeline' end
ruby
def process_join(data) @state.update data['state'] if data.key? 'state' @timeline.update data['timeline'] if data.key? 'timeline' end
[ "def", "process_join", "(", "data", ")", "@state", ".", "update", "data", "[", "'state'", "]", "if", "data", ".", "key?", "'state'", "@timeline", ".", "update", "data", "[", "'timeline'", "]", "if", "data", ".", "key?", "'timeline'", "end" ]
Initializes a new Room instance. @param id [String] The room ID. @param users [Users] The User manager. @param matrix [Matrix] The Matrix API instance. Process join events for this room. @param data [Hash] Event data containing state and timeline events.
[ "Initializes", "a", "new", "Room", "instance", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/room.rb#L62-L65
train
Sharparam/chatrix
lib/chatrix/room.rb
Chatrix.Room.process_leave
def process_leave(data) @state.update data['state'] if data.key? 'state' @timeline.update data['timeline'] if data.key? 'timeline' end
ruby
def process_leave(data) @state.update data['state'] if data.key? 'state' @timeline.update data['timeline'] if data.key? 'timeline' end
[ "def", "process_leave", "(", "data", ")", "@state", ".", "update", "data", "[", "'state'", "]", "if", "data", ".", "key?", "'state'", "@timeline", ".", "update", "data", "[", "'timeline'", "]", "if", "data", ".", "key?", "'timeline'", "end" ]
Process leave events for this room. @param data [Hash] Event data containing state and timeline events up until the point of leaving the room.
[ "Process", "leave", "events", "for", "this", "room", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/room.rb#L76-L79
train
Sharparam/chatrix
lib/chatrix/room.rb
Chatrix.Room.process_invite_event
def process_invite_event(event) return unless event['type'] == 'm.room.member' return unless event['content']['membership'] == 'invite' @users.process_invite self, event sender = @users[event['sender']] invitee = @users[event['state_key']] # Return early if the user is already in the room return if @state.member? invitee broadcast(:invited, sender, invitee) end
ruby
def process_invite_event(event) return unless event['type'] == 'm.room.member' return unless event['content']['membership'] == 'invite' @users.process_invite self, event sender = @users[event['sender']] invitee = @users[event['state_key']] # Return early if the user is already in the room return if @state.member? invitee broadcast(:invited, sender, invitee) end
[ "def", "process_invite_event", "(", "event", ")", "return", "unless", "event", "[", "'type'", "]", "==", "'m.room.member'", "return", "unless", "event", "[", "'content'", "]", "[", "'membership'", "]", "==", "'invite'", "@users", ".", "process_invite", "self", ",", "event", "sender", "=", "@users", "[", "event", "[", "'sender'", "]", "]", "invitee", "=", "@users", "[", "event", "[", "'state_key'", "]", "]", "return", "if", "@state", ".", "member?", "invitee", "broadcast", "(", ":invited", ",", "sender", ",", "invitee", ")", "end" ]
Process an invite event for this room. @param event [Hash] Event data.
[ "Process", "an", "invite", "event", "for", "this", "room", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/room.rb#L93-L102
train
andrba/hungryform
lib/hungryform/resolver.rb
HungryForm.Resolver.get_value
def get_value(name, element = nil) return name.call(element) if name.respond_to? :call # We don't want to mess up elements names name = name.to_s.dup # Apply placeholders to the name. # A sample name string can look like this: page1_group[GROUP_NUMBER]_field # where [GROUP_NUMBER] is a placeholder. When an element is present # we get its placeholders and replace substrings in the name argument element.placeholders.each { |k, v| name[k] &&= v } if element elements[name].try(:value) || params[name] || name end
ruby
def get_value(name, element = nil) return name.call(element) if name.respond_to? :call # We don't want to mess up elements names name = name.to_s.dup # Apply placeholders to the name. # A sample name string can look like this: page1_group[GROUP_NUMBER]_field # where [GROUP_NUMBER] is a placeholder. When an element is present # we get its placeholders and replace substrings in the name argument element.placeholders.each { |k, v| name[k] &&= v } if element elements[name].try(:value) || params[name] || name end
[ "def", "get_value", "(", "name", ",", "element", "=", "nil", ")", "return", "name", ".", "call", "(", "element", ")", "if", "name", ".", "respond_to?", ":call", "name", "=", "name", ".", "to_s", ".", "dup", "element", ".", "placeholders", ".", "each", "{", "|", "k", ",", "v", "|", "name", "[", "k", "]", "&&=", "v", "}", "if", "element", "elements", "[", "name", "]", ".", "try", "(", ":value", ")", "||", "params", "[", "name", "]", "||", "name", "end" ]
Gets element value by element's name. If name is lambda - returns lambda's result If name is present in the resolvers' elements hash - returns element's value If name is present in the resolvers' params hash - returns params value Otherwise returns the argument without changes
[ "Gets", "element", "value", "by", "element", "s", "name", ".", "If", "name", "is", "lambda", "-", "returns", "lambda", "s", "result", "If", "name", "is", "present", "in", "the", "resolvers", "elements", "hash", "-", "returns", "element", "s", "value", "If", "name", "is", "present", "in", "the", "resolvers", "params", "hash", "-", "returns", "params", "value", "Otherwise", "returns", "the", "argument", "without", "changes" ]
d9d9dad9d8409323910372372c3c7672bd8bf478
https://github.com/andrba/hungryform/blob/d9d9dad9d8409323910372372c3c7672bd8bf478/lib/hungryform/resolver.rb#L18-L31
train
andrba/hungryform
lib/hungryform/resolver.rb
HungryForm.Resolver.resolve_dependency
def resolve_dependency(dependency) dependency.each do |operator, arguments| operator = operator.to_sym case operator when :and, :or return resolve_multi_dependency(operator, arguments) when :not return !resolve_dependency(arguments) end arguments = [arguments] unless arguments.is_a?(Array) values = arguments[0..1].map { |name| get_value(name) } return false if values.any?(&:nil?) case operator when :eq return values[0].to_s == values[1].to_s when :lt return values[0].to_f < values[1].to_f when :gt return values[0].to_f > values[1].to_f when :set return !values[0].empty? end end end
ruby
def resolve_dependency(dependency) dependency.each do |operator, arguments| operator = operator.to_sym case operator when :and, :or return resolve_multi_dependency(operator, arguments) when :not return !resolve_dependency(arguments) end arguments = [arguments] unless arguments.is_a?(Array) values = arguments[0..1].map { |name| get_value(name) } return false if values.any?(&:nil?) case operator when :eq return values[0].to_s == values[1].to_s when :lt return values[0].to_f < values[1].to_f when :gt return values[0].to_f > values[1].to_f when :set return !values[0].empty? end end end
[ "def", "resolve_dependency", "(", "dependency", ")", "dependency", ".", "each", "do", "|", "operator", ",", "arguments", "|", "operator", "=", "operator", ".", "to_sym", "case", "operator", "when", ":and", ",", ":or", "return", "resolve_multi_dependency", "(", "operator", ",", "arguments", ")", "when", ":not", "return", "!", "resolve_dependency", "(", "arguments", ")", "end", "arguments", "=", "[", "arguments", "]", "unless", "arguments", ".", "is_a?", "(", "Array", ")", "values", "=", "arguments", "[", "0", "..", "1", "]", ".", "map", "{", "|", "name", "|", "get_value", "(", "name", ")", "}", "return", "false", "if", "values", ".", "any?", "(", "&", ":nil?", ")", "case", "operator", "when", ":eq", "return", "values", "[", "0", "]", ".", "to_s", "==", "values", "[", "1", "]", ".", "to_s", "when", ":lt", "return", "values", "[", "0", "]", ".", "to_f", "<", "values", "[", "1", "]", ".", "to_f", "when", ":gt", "return", "values", "[", "0", "]", ".", "to_f", ">", "values", "[", "1", "]", ".", "to_f", "when", ":set", "return", "!", "values", "[", "0", "]", ".", "empty?", "end", "end", "end" ]
Gets dependency rules hash and returns true or false depending on the result of a recursive processing of the rules
[ "Gets", "dependency", "rules", "hash", "and", "returns", "true", "or", "false", "depending", "on", "the", "result", "of", "a", "recursive", "processing", "of", "the", "rules" ]
d9d9dad9d8409323910372372c3c7672bd8bf478
https://github.com/andrba/hungryform/blob/d9d9dad9d8409323910372372c3c7672bd8bf478/lib/hungryform/resolver.rb#L35-L62
train
andrba/hungryform
lib/hungryform/resolver.rb
HungryForm.Resolver.resolve_multi_dependency
def resolve_multi_dependency(type, arguments) if arguments.size == 0 fail HungryFormException, "No arguments for #{type.upcase} comparison: #{arguments}" end result = type == :and arguments.each do |argument| return !result unless resolve_dependency(argument) end result end
ruby
def resolve_multi_dependency(type, arguments) if arguments.size == 0 fail HungryFormException, "No arguments for #{type.upcase} comparison: #{arguments}" end result = type == :and arguments.each do |argument| return !result unless resolve_dependency(argument) end result end
[ "def", "resolve_multi_dependency", "(", "type", ",", "arguments", ")", "if", "arguments", ".", "size", "==", "0", "fail", "HungryFormException", ",", "\"No arguments for #{type.upcase} comparison: #{arguments}\"", "end", "result", "=", "type", "==", ":and", "arguments", ".", "each", "do", "|", "argument", "|", "return", "!", "result", "unless", "resolve_dependency", "(", "argument", ")", "end", "result", "end" ]
Method resolves AND or OR conditions. Walks through the arguments and resolves their dependencies.
[ "Method", "resolves", "AND", "or", "OR", "conditions", ".", "Walks", "through", "the", "arguments", "and", "resolves", "their", "dependencies", "." ]
d9d9dad9d8409323910372372c3c7672bd8bf478
https://github.com/andrba/hungryform/blob/d9d9dad9d8409323910372372c3c7672bd8bf478/lib/hungryform/resolver.rb#L68-L80
train
dolzenko/reflexive
lib/reflexive/methods.rb
Reflexive.Methods.append_ancestor_entry
def append_ancestor_entry(ancestors, ancestor, class_methods, instance_methods = nil) if class_methods || instance_methods ancestor_entry = {} ancestor_entry[:class] = class_methods if class_methods ancestor_entry[:instance] = instance_methods if instance_methods ancestors << {ancestor => ancestor_entry} end end
ruby
def append_ancestor_entry(ancestors, ancestor, class_methods, instance_methods = nil) if class_methods || instance_methods ancestor_entry = {} ancestor_entry[:class] = class_methods if class_methods ancestor_entry[:instance] = instance_methods if instance_methods ancestors << {ancestor => ancestor_entry} end end
[ "def", "append_ancestor_entry", "(", "ancestors", ",", "ancestor", ",", "class_methods", ",", "instance_methods", "=", "nil", ")", "if", "class_methods", "||", "instance_methods", "ancestor_entry", "=", "{", "}", "ancestor_entry", "[", ":class", "]", "=", "class_methods", "if", "class_methods", "ancestor_entry", "[", ":instance", "]", "=", "instance_methods", "if", "instance_methods", "ancestors", "<<", "{", "ancestor", "=>", "ancestor_entry", "}", "end", "end" ]
ancestor is included only when contributes some methods
[ "ancestor", "is", "included", "only", "when", "contributes", "some", "methods" ]
04a58ba2f45c15e2815b7ca04a78a5b6b89a52b9
https://github.com/dolzenko/reflexive/blob/04a58ba2f45c15e2815b7ca04a78a5b6b89a52b9/lib/reflexive/methods.rb#L111-L118
train
ideonetwork/lato-core
app/cells/lato_core/inputs/select/cell.rb
LatoCore.Inputs::Select::Cell.get_option_value_selected
def get_option_value_selected(option_value) if @args[:multiple] values = @args[:value].is_a?(Array) ? @args[:value] : @args[:value].split(',') return values.include?(option_value) ? "selected='selected'" : '' end @args[:value] == option_value ? "selected='selected'" : '' end
ruby
def get_option_value_selected(option_value) if @args[:multiple] values = @args[:value].is_a?(Array) ? @args[:value] : @args[:value].split(',') return values.include?(option_value) ? "selected='selected'" : '' end @args[:value] == option_value ? "selected='selected'" : '' end
[ "def", "get_option_value_selected", "(", "option_value", ")", "if", "@args", "[", ":multiple", "]", "values", "=", "@args", "[", ":value", "]", ".", "is_a?", "(", "Array", ")", "?", "@args", "[", ":value", "]", ":", "@args", "[", ":value", "]", ".", "split", "(", "','", ")", "return", "values", ".", "include?", "(", "option_value", ")", "?", "\"selected='selected'\"", ":", "''", "end", "@args", "[", ":value", "]", "==", "option_value", "?", "\"selected='selected'\"", ":", "''", "end" ]
This function return a string used on the HTML option to set a an option value selected or not.
[ "This", "function", "return", "a", "string", "used", "on", "the", "HTML", "option", "to", "set", "a", "an", "option", "value", "selected", "or", "not", "." ]
c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c
https://github.com/ideonetwork/lato-core/blob/c01fa585725c8e9992f25d8a7bd4ba2d0bfca08c/app/cells/lato_core/inputs/select/cell.rb#L39-L46
train
blahah/biopsy
lib/biopsy/target.rb
Biopsy.Target.load_by_name
def load_by_name name path = self.locate_definition name raise TargetLoadError.new("Target definition file does not exist for #{name}") if path.nil? config = YAML::load_file(path) raise TargetLoadError.new("Target definition file #{path} is not valid YAML") if config.nil? config = config.deep_symbolize self.store_config config self.check_constructor name self.load_constructor end
ruby
def load_by_name name path = self.locate_definition name raise TargetLoadError.new("Target definition file does not exist for #{name}") if path.nil? config = YAML::load_file(path) raise TargetLoadError.new("Target definition file #{path} is not valid YAML") if config.nil? config = config.deep_symbolize self.store_config config self.check_constructor name self.load_constructor end
[ "def", "load_by_name", "name", "path", "=", "self", ".", "locate_definition", "name", "raise", "TargetLoadError", ".", "new", "(", "\"Target definition file does not exist for #{name}\"", ")", "if", "path", ".", "nil?", "config", "=", "YAML", "::", "load_file", "(", "path", ")", "raise", "TargetLoadError", ".", "new", "(", "\"Target definition file #{path} is not valid YAML\"", ")", "if", "config", ".", "nil?", "config", "=", "config", ".", "deep_symbolize", "self", ".", "store_config", "config", "self", ".", "check_constructor", "name", "self", ".", "load_constructor", "end" ]
load target with +name+.
[ "load", "target", "with", "+", "name", "+", "." ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/target.rb#L23-L32
train
blahah/biopsy
lib/biopsy/target.rb
Biopsy.Target.locate_file
def locate_file name Settings.instance.target_dir.each do |dir| Dir.chdir File.expand_path(dir) do return File.expand_path(name) if File.exists? name end end raise TargetLoadError.new("Couldn't find file #{name}") nil end
ruby
def locate_file name Settings.instance.target_dir.each do |dir| Dir.chdir File.expand_path(dir) do return File.expand_path(name) if File.exists? name end end raise TargetLoadError.new("Couldn't find file #{name}") nil end
[ "def", "locate_file", "name", "Settings", ".", "instance", ".", "target_dir", ".", "each", "do", "|", "dir", "|", "Dir", ".", "chdir", "File", ".", "expand_path", "(", "dir", ")", "do", "return", "File", ".", "expand_path", "(", "name", ")", "if", "File", ".", "exists?", "name", "end", "end", "raise", "TargetLoadError", ".", "new", "(", "\"Couldn't find file #{name}\"", ")", "nil", "end" ]
Locate a file with name in one of the target_dirs
[ "Locate", "a", "file", "with", "name", "in", "one", "of", "the", "target_dirs" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/target.rb#L64-L72
train
blahah/biopsy
lib/biopsy/target.rb
Biopsy.Target.count_parameter_permutations
def count_parameter_permutations @parameters.each_pair.map{ |k, v| v }.reduce(1) { |n, arr| n * arr.size } end
ruby
def count_parameter_permutations @parameters.each_pair.map{ |k, v| v }.reduce(1) { |n, arr| n * arr.size } end
[ "def", "count_parameter_permutations", "@parameters", ".", "each_pair", ".", "map", "{", "|", "k", ",", "v", "|", "v", "}", ".", "reduce", "(", "1", ")", "{", "|", "n", ",", "arr", "|", "n", "*", "arr", ".", "size", "}", "end" ]
return the total number of possible permutations of
[ "return", "the", "total", "number", "of", "possible", "permutations", "of" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/target.rb#L141-L143
train
blahah/biopsy
lib/biopsy/target.rb
Biopsy.Target.method_missing
def method_missing(method, *args, &block) const_methods = @constructor.class.instance_methods(false) if const_methods.include? method return @constructor.send(method, *args, &block) else super end end
ruby
def method_missing(method, *args, &block) const_methods = @constructor.class.instance_methods(false) if const_methods.include? method return @constructor.send(method, *args, &block) else super end end
[ "def", "method_missing", "(", "method", ",", "*", "args", ",", "&", "block", ")", "const_methods", "=", "@constructor", ".", "class", ".", "instance_methods", "(", "false", ")", "if", "const_methods", ".", "include?", "method", "return", "@constructor", ".", "send", "(", "method", ",", "*", "args", ",", "&", "block", ")", "else", "super", "end", "end" ]
pass calls to missing methods to the constructor iff the constructor's class directly defines that method
[ "pass", "calls", "to", "missing", "methods", "to", "the", "constructor", "iff", "the", "constructor", "s", "class", "directly", "defines", "that", "method" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/target.rb#L147-L154
train
blahah/biopsy
lib/biopsy/target.rb
Biopsy.Target.respond_to?
def respond_to?(method, *args, &block) const_methods = @constructor.class.instance_methods(false) if const_methods.include? method true else super end end
ruby
def respond_to?(method, *args, &block) const_methods = @constructor.class.instance_methods(false) if const_methods.include? method true else super end end
[ "def", "respond_to?", "(", "method", ",", "*", "args", ",", "&", "block", ")", "const_methods", "=", "@constructor", ".", "class", ".", "instance_methods", "(", "false", ")", "if", "const_methods", ".", "include?", "method", "true", "else", "super", "end", "end" ]
accurately report ability to respond to methods passed to constructor
[ "accurately", "report", "ability", "to", "respond", "to", "methods", "passed", "to", "constructor" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/target.rb#L158-L165
train
brianmichel/BadFruit
lib/badfruit/base.rb
BadFruit.Base.get_movie_info
def get_movie_info(movie_id, action) url = nil case action when "details" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}.json?apikey=#{@api_key}" when "reviews" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}/reviews.json?apikey=#{@api_key}" when "cast" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}/cast.json?apikey=#{@api_key}" when "main" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}.json?apikey=#{@api_key}" else puts "Not a valid action" return end return get(url) end
ruby
def get_movie_info(movie_id, action) url = nil case action when "details" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}.json?apikey=#{@api_key}" when "reviews" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}/reviews.json?apikey=#{@api_key}" when "cast" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}/cast.json?apikey=#{@api_key}" when "main" url = "#{MOVIE_DETAIL_BASE_URL}/#{movie_id}.json?apikey=#{@api_key}" else puts "Not a valid action" return end return get(url) end
[ "def", "get_movie_info", "(", "movie_id", ",", "action", ")", "url", "=", "nil", "case", "action", "when", "\"details\"", "url", "=", "\"#{MOVIE_DETAIL_BASE_URL}/#{movie_id}.json?apikey=#{@api_key}\"", "when", "\"reviews\"", "url", "=", "\"#{MOVIE_DETAIL_BASE_URL}/#{movie_id}/reviews.json?apikey=#{@api_key}\"", "when", "\"cast\"", "url", "=", "\"#{MOVIE_DETAIL_BASE_URL}/#{movie_id}/cast.json?apikey=#{@api_key}\"", "when", "\"main\"", "url", "=", "\"#{MOVIE_DETAIL_BASE_URL}/#{movie_id}.json?apikey=#{@api_key}\"", "else", "puts", "\"Not a valid action\"", "return", "end", "return", "get", "(", "url", ")", "end" ]
Get various bits of info for a given movie id. @param [String] movie_id The id of the movie to get information for. @param [String] action The type of information to request. @note Valid action values are "details", "reviews", "cast", "main" @return [Hash] A hash of information for a specific movie id.
[ "Get", "various", "bits", "of", "info", "for", "a", "given", "movie", "id", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/base.rb#L83-L99
train
brianmichel/BadFruit
lib/badfruit/base.rb
BadFruit.Base.get_lists_action
def get_lists_action(action) url = nil case action when "new_releases" url = "#{LISTS_DETAIL_BASE_URL}/dvds/new_releases.json?apikey=#{@api_key}" when "opening" url = "#{LISTS_DETAIL_BASE_URL}/movies/opening.json?apikey=#{@api_key}" when "upcoming" url = "#{LISTS_DETAIL_BASE_URL}/movies/upcoming.json?apikey=#{@api_key}" when "in_theaters" url = "#{LISTS_DETAIL_BASE_URL}/movies/in_theaters.json?apikey=#{@api_key}" when "current_releases" url = "#{LISTS_DETAIL_BASE_URL}/dvds/current_releases.json?apikey=#{@api_key}" when "upcoming_dvds" url = "#{LISTS_DETAIL_BASE_URL}/dvds/upcoming.json?apikey=#{@api_key}" when "top_rentals" url = "#{LISTS_DETAIL_BASE_URL}/dvds/top_rentals.json?apikey=#{@api_key}" else puts "Not a valid action" return end return get(url) end
ruby
def get_lists_action(action) url = nil case action when "new_releases" url = "#{LISTS_DETAIL_BASE_URL}/dvds/new_releases.json?apikey=#{@api_key}" when "opening" url = "#{LISTS_DETAIL_BASE_URL}/movies/opening.json?apikey=#{@api_key}" when "upcoming" url = "#{LISTS_DETAIL_BASE_URL}/movies/upcoming.json?apikey=#{@api_key}" when "in_theaters" url = "#{LISTS_DETAIL_BASE_URL}/movies/in_theaters.json?apikey=#{@api_key}" when "current_releases" url = "#{LISTS_DETAIL_BASE_URL}/dvds/current_releases.json?apikey=#{@api_key}" when "upcoming_dvds" url = "#{LISTS_DETAIL_BASE_URL}/dvds/upcoming.json?apikey=#{@api_key}" when "top_rentals" url = "#{LISTS_DETAIL_BASE_URL}/dvds/top_rentals.json?apikey=#{@api_key}" else puts "Not a valid action" return end return get(url) end
[ "def", "get_lists_action", "(", "action", ")", "url", "=", "nil", "case", "action", "when", "\"new_releases\"", "url", "=", "\"#{LISTS_DETAIL_BASE_URL}/dvds/new_releases.json?apikey=#{@api_key}\"", "when", "\"opening\"", "url", "=", "\"#{LISTS_DETAIL_BASE_URL}/movies/opening.json?apikey=#{@api_key}\"", "when", "\"upcoming\"", "url", "=", "\"#{LISTS_DETAIL_BASE_URL}/movies/upcoming.json?apikey=#{@api_key}\"", "when", "\"in_theaters\"", "url", "=", "\"#{LISTS_DETAIL_BASE_URL}/movies/in_theaters.json?apikey=#{@api_key}\"", "when", "\"current_releases\"", "url", "=", "\"#{LISTS_DETAIL_BASE_URL}/dvds/current_releases.json?apikey=#{@api_key}\"", "when", "\"upcoming_dvds\"", "url", "=", "\"#{LISTS_DETAIL_BASE_URL}/dvds/upcoming.json?apikey=#{@api_key}\"", "when", "\"top_rentals\"", "url", "=", "\"#{LISTS_DETAIL_BASE_URL}/dvds/top_rentals.json?apikey=#{@api_key}\"", "else", "puts", "\"Not a valid action\"", "return", "end", "return", "get", "(", "url", ")", "end" ]
Provides access to the various lists that Rotten Tomatoes provides. @param [String] action The type of list to request. @return [Array<BadFruit::Movie>] An array of programs contains in the requested list.
[ "Provides", "access", "to", "the", "various", "lists", "that", "Rotten", "Tomatoes", "provides", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/base.rb#L121-L143
train
brianmichel/BadFruit
lib/badfruit/base.rb
BadFruit.Base.parse_movies_array
def parse_movies_array(hash) moviesArray = Array.new hash["movies"].each do |movie| moviesArray.push(Movie.new(movie, self)) end return moviesArray end
ruby
def parse_movies_array(hash) moviesArray = Array.new hash["movies"].each do |movie| moviesArray.push(Movie.new(movie, self)) end return moviesArray end
[ "def", "parse_movies_array", "(", "hash", ")", "moviesArray", "=", "Array", ".", "new", "hash", "[", "\"movies\"", "]", ".", "each", "do", "|", "movie", "|", "moviesArray", ".", "push", "(", "Movie", ".", "new", "(", "movie", ",", "self", ")", ")", "end", "return", "moviesArray", "end" ]
Parse the movies out of a hash. @param [Hash] hash The has to convert into an array of movies. @return [Array<BadFruit::Movie>] An array of BadFruit::Movie objects.
[ "Parse", "the", "movies", "out", "of", "a", "hash", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/base.rb#L152-L158
train
brianmichel/BadFruit
lib/badfruit/base.rb
BadFruit.Base.parse_actors_array
def parse_actors_array(hash) actorsArray = Array.new hash["cast"].each do |actor| actorsArray.push(Actor.new(actor)) end return actorsArray end
ruby
def parse_actors_array(hash) actorsArray = Array.new hash["cast"].each do |actor| actorsArray.push(Actor.new(actor)) end return actorsArray end
[ "def", "parse_actors_array", "(", "hash", ")", "actorsArray", "=", "Array", ".", "new", "hash", "[", "\"cast\"", "]", ".", "each", "do", "|", "actor", "|", "actorsArray", ".", "push", "(", "Actor", ".", "new", "(", "actor", ")", ")", "end", "return", "actorsArray", "end" ]
Parse the actors out of a movie hash. @param [Hash] hash The movie has to extract the actors out of. @return [Array<BadFruit::Actor>] An array of BadFruit::Actor objects.
[ "Parse", "the", "actors", "out", "of", "a", "movie", "hash", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/base.rb#L179-L185
train
brianmichel/BadFruit
lib/badfruit/base.rb
BadFruit.Base.get
def get(url) data = nil resp = HTTParty.get(url) if resp.code == 200 return resp.body end end
ruby
def get(url) data = nil resp = HTTParty.get(url) if resp.code == 200 return resp.body end end
[ "def", "get", "(", "url", ")", "data", "=", "nil", "resp", "=", "HTTParty", ".", "get", "(", "url", ")", "if", "resp", ".", "code", "==", "200", "return", "resp", ".", "body", "end", "end" ]
Get the response of a given URL. @param [String] url The URL to elicit a response from. @return [Hash] The response from the server, or nil if there is no response.
[ "Get", "the", "response", "of", "a", "given", "URL", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/base.rb#L194-L202
train
Sharparam/chatrix
lib/chatrix/client.rb
Chatrix.Client.sync!
def sync! events = @matrix.sync since: @since process_sync events rescue ApiError => err broadcast(:sync_error, err) end
ruby
def sync! events = @matrix.sync since: @since process_sync events rescue ApiError => err broadcast(:sync_error, err) end
[ "def", "sync!", "events", "=", "@matrix", ".", "sync", "since", ":", "@since", "process_sync", "events", "rescue", "ApiError", "=>", "err", "broadcast", "(", ":sync_error", ",", "err", ")", "end" ]
Syncs against the server. If an API error occurs during sync, it will be rescued and broadcasted as `:sync_error`.
[ "Syncs", "against", "the", "server", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/client.rb#L105-L110
train
Sharparam/chatrix
lib/chatrix/client.rb
Chatrix.Client.process_sync
def process_sync(events) return unless events.is_a? Hash @since = events['next_batch'] broadcast(:sync, events) @rooms.process_events events['rooms'] if events.key? 'rooms' end
ruby
def process_sync(events) return unless events.is_a? Hash @since = events['next_batch'] broadcast(:sync, events) @rooms.process_events events['rooms'] if events.key? 'rooms' end
[ "def", "process_sync", "(", "events", ")", "return", "unless", "events", ".", "is_a?", "Hash", "@since", "=", "events", "[", "'next_batch'", "]", "broadcast", "(", ":sync", ",", "events", ")", "@rooms", ".", "process_events", "events", "[", "'rooms'", "]", "if", "events", ".", "key?", "'rooms'", "end" ]
Process the sync result. @param events [Hash] The events to sync.
[ "Process", "the", "sync", "result", "." ]
6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34
https://github.com/Sharparam/chatrix/blob/6f2e9cf3a614ba7e8a9960f7d9b97092c0ce1e34/lib/chatrix/client.rb#L115-L121
train
wordjelly/Auth
app/helpers/auth/application_helper.rb
Auth.ApplicationHelper.get_signed_in_scope
def get_signed_in_scope if signed_in? Devise.mappings.keys.each do |res| l = send "#{res.to_s}_signed_in?" if send "#{res.to_s}_signed_in?" return res.to_s end end end return 'user' end
ruby
def get_signed_in_scope if signed_in? Devise.mappings.keys.each do |res| l = send "#{res.to_s}_signed_in?" if send "#{res.to_s}_signed_in?" return res.to_s end end end return 'user' end
[ "def", "get_signed_in_scope", "if", "signed_in?", "Devise", ".", "mappings", ".", "keys", ".", "each", "do", "|", "res", "|", "l", "=", "send", "\"#{res.to_s}_signed_in?\"", "if", "send", "\"#{res.to_s}_signed_in?\"", "return", "res", ".", "to_s", "end", "end", "end", "return", "'user'", "end" ]
returns the name in small case of the class of the currently signed in resource @example : will return 'user' or 'admin'
[ "returns", "the", "name", "in", "small", "case", "of", "the", "class", "of", "the", "currently", "signed", "in", "resource" ]
e1b6697a13c845f57b3cc83bfb79059a09541f47
https://github.com/wordjelly/Auth/blob/e1b6697a13c845f57b3cc83bfb79059a09541f47/app/helpers/auth/application_helper.rb#L9-L19
train
wordjelly/Auth
app/helpers/auth/application_helper.rb
Auth.ApplicationHelper.resource_in_navbar?
def resource_in_navbar?(resource) return false unless resource return (Auth.configuration.auth_resources[resource.class.name][:nav_bar] && Auth.configuration.enable_sign_in_modals) end
ruby
def resource_in_navbar?(resource) return false unless resource return (Auth.configuration.auth_resources[resource.class.name][:nav_bar] && Auth.configuration.enable_sign_in_modals) end
[ "def", "resource_in_navbar?", "(", "resource", ")", "return", "false", "unless", "resource", "return", "(", "Auth", ".", "configuration", ".", "auth_resources", "[", "resource", ".", "class", ".", "name", "]", "[", ":nav_bar", "]", "&&", "Auth", ".", "configuration", ".", "enable_sign_in_modals", ")", "end" ]
SHOULD THE RESOURCE SIGN IN OPTIONS BE SHOWN IN THE NAV BAR?
[ "SHOULD", "THE", "RESOURCE", "SIGN", "IN", "OPTIONS", "BE", "SHOWN", "IN", "THE", "NAV", "BAR?" ]
e1b6697a13c845f57b3cc83bfb79059a09541f47
https://github.com/wordjelly/Auth/blob/e1b6697a13c845f57b3cc83bfb79059a09541f47/app/helpers/auth/application_helper.rb#L39-L42
train
koraktor/rubikon
lib/rubikon/has_arguments.rb
Rubikon.HasArguments.<<
def <<(arg) raise ExtraArgumentError.new(@name) unless more_args? if @arg_names.size > @args.size name = @arg_names[@args.size] if @max_arg_count == -1 && @arg_names.size == @args.size + 1 @args[name] = [arg] else @args[name] = arg end elsif !@arg_names.empty? && @max_arg_count == -1 @args[@arg_names.last] << arg else @args[@args.size] = arg end end
ruby
def <<(arg) raise ExtraArgumentError.new(@name) unless more_args? if @arg_names.size > @args.size name = @arg_names[@args.size] if @max_arg_count == -1 && @arg_names.size == @args.size + 1 @args[name] = [arg] else @args[name] = arg end elsif !@arg_names.empty? && @max_arg_count == -1 @args[@arg_names.last] << arg else @args[@args.size] = arg end end
[ "def", "<<", "(", "arg", ")", "raise", "ExtraArgumentError", ".", "new", "(", "@name", ")", "unless", "more_args?", "if", "@arg_names", ".", "size", ">", "@args", ".", "size", "name", "=", "@arg_names", "[", "@args", ".", "size", "]", "if", "@max_arg_count", "==", "-", "1", "&&", "@arg_names", ".", "size", "==", "@args", ".", "size", "+", "1", "@args", "[", "name", "]", "=", "[", "arg", "]", "else", "@args", "[", "name", "]", "=", "arg", "end", "elsif", "!", "@arg_names", ".", "empty?", "&&", "@max_arg_count", "==", "-", "1", "@args", "[", "@arg_names", ".", "last", "]", "<<", "arg", "else", "@args", "[", "@args", ".", "size", "]", "=", "arg", "end", "end" ]
Adds an argument to this parameter. Arguments can be accessed inside the application code using the args method. @param [String] arg The argument to add to the supplied arguments of this parameter @raise [ExtraArgumentError] if the parameter has all required arguments supplied and does not take optional arguments @return [Array] The supplied arguments of this parameter @see #[] @see #args @since 0.3.0
[ "Adds", "an", "argument", "to", "this", "parameter", ".", "Arguments", "can", "be", "accessed", "inside", "the", "application", "code", "using", "the", "args", "method", "." ]
c5a09d2a6a0878bb4ae5bcf71fcb111646ed0b2b
https://github.com/koraktor/rubikon/blob/c5a09d2a6a0878bb4ae5bcf71fcb111646ed0b2b/lib/rubikon/has_arguments.rb#L173-L188
train
koraktor/rubikon
lib/rubikon/has_arguments.rb
Rubikon.HasArguments.check_args
def check_args raise MissingArgumentError.new(@name) unless args_full? unless @arg_values.empty? @args.each do |name, arg| if @arg_values.key? name arg = [arg] unless arg.is_a? Array arg.each do |a| unless a =~ @arg_values[name] raise UnexpectedArgumentError.new(a) end end end end end end
ruby
def check_args raise MissingArgumentError.new(@name) unless args_full? unless @arg_values.empty? @args.each do |name, arg| if @arg_values.key? name arg = [arg] unless arg.is_a? Array arg.each do |a| unless a =~ @arg_values[name] raise UnexpectedArgumentError.new(a) end end end end end end
[ "def", "check_args", "raise", "MissingArgumentError", ".", "new", "(", "@name", ")", "unless", "args_full?", "unless", "@arg_values", ".", "empty?", "@args", ".", "each", "do", "|", "name", ",", "arg", "|", "if", "@arg_values", ".", "key?", "name", "arg", "=", "[", "arg", "]", "unless", "arg", ".", "is_a?", "Array", "arg", ".", "each", "do", "|", "a", "|", "unless", "a", "=~", "@arg_values", "[", "name", "]", "raise", "UnexpectedArgumentError", ".", "new", "(", "a", ")", "end", "end", "end", "end", "end", "end" ]
Checks the arguments for this parameter @raise [MissingArgumentError] if there are not enough arguments for this parameter @since 0.3.0
[ "Checks", "the", "arguments", "for", "this", "parameter" ]
c5a09d2a6a0878bb4ae5bcf71fcb111646ed0b2b
https://github.com/koraktor/rubikon/blob/c5a09d2a6a0878bb4ae5bcf71fcb111646ed0b2b/lib/rubikon/has_arguments.rb#L220-L234
train
koraktor/rubikon
lib/rubikon/has_arguments.rb
Rubikon.HasArguments.method_missing
def method_missing(name, *args, &block) if args.empty? && !block_given? && @arg_names.include?(name) @args[name] else super end end
ruby
def method_missing(name, *args, &block) if args.empty? && !block_given? && @arg_names.include?(name) @args[name] else super end end
[ "def", "method_missing", "(", "name", ",", "*", "args", ",", "&", "block", ")", "if", "args", ".", "empty?", "&&", "!", "block_given?", "&&", "@arg_names", ".", "include?", "(", "name", ")", "@args", "[", "name", "]", "else", "super", "end", "end" ]
If a named argument with the specified method name exists, a call to that method will return the value of the argument. @param (see ClassMethods#method_missing) @see #args @see #[] @example option :user, [:name] do @user = name end
[ "If", "a", "named", "argument", "with", "the", "specified", "method", "name", "exists", "a", "call", "to", "that", "method", "will", "return", "the", "value", "of", "the", "argument", "." ]
c5a09d2a6a0878bb4ae5bcf71fcb111646ed0b2b
https://github.com/koraktor/rubikon/blob/c5a09d2a6a0878bb4ae5bcf71fcb111646ed0b2b/lib/rubikon/has_arguments.rb#L247-L253
train
gmalette/pubsubstub
lib/pubsubstub/subscription.rb
Pubsubstub.Subscription.fetch_scrollback
def fetch_scrollback(last_event_id) event_sent = false if last_event_id channels.each do |channel| channel.scrollback(since: last_event_id).each do |event| event_sent = true queue.push(event) end end end queue.push(Pubsubstub.heartbeat_event) unless event_sent end
ruby
def fetch_scrollback(last_event_id) event_sent = false if last_event_id channels.each do |channel| channel.scrollback(since: last_event_id).each do |event| event_sent = true queue.push(event) end end end queue.push(Pubsubstub.heartbeat_event) unless event_sent end
[ "def", "fetch_scrollback", "(", "last_event_id", ")", "event_sent", "=", "false", "if", "last_event_id", "channels", ".", "each", "do", "|", "channel", "|", "channel", ".", "scrollback", "(", "since", ":", "last_event_id", ")", ".", "each", "do", "|", "event", "|", "event_sent", "=", "true", "queue", ".", "push", "(", "event", ")", "end", "end", "end", "queue", ".", "push", "(", "Pubsubstub", ".", "heartbeat_event", ")", "unless", "event_sent", "end" ]
This method is not ideal as it doesn't guarantee order in case of multi-channel subscription
[ "This", "method", "is", "not", "ideal", "as", "it", "doesn", "t", "guarantee", "order", "in", "case", "of", "multi", "-", "channel", "subscription" ]
a445c4969f2a7a1fe0894320f1ecd1d7e362d611
https://github.com/gmalette/pubsubstub/blob/a445c4969f2a7a1fe0894320f1ecd1d7e362d611/lib/pubsubstub/subscription.rb#L42-L54
train
JulianNicholls/gosu_enhanced-gem
lib/gosu_enhanced/region.rb
GosuEnhanced.Region.contains?
def contains?(col, row = nil) return contains_point?(col) if col.respond_to? :x col.between?(left, left + width - 1) && row.between?(top, top + height - 1) end
ruby
def contains?(col, row = nil) return contains_point?(col) if col.respond_to? :x col.between?(left, left + width - 1) && row.between?(top, top + height - 1) end
[ "def", "contains?", "(", "col", ",", "row", "=", "nil", ")", "return", "contains_point?", "(", "col", ")", "if", "col", ".", "respond_to?", ":x", "col", ".", "between?", "(", "left", ",", "left", "+", "width", "-", "1", ")", "&&", "row", ".", "between?", "(", "top", ",", "top", "+", "height", "-", "1", ")", "end" ]
Create a new region with specified +pos+ as top left corner and +size+ as width and height. The stored positions are copies of the passed position and size to avoid aliasing. Alternatively, can be initialized with 2 +Point+s. Return whether the region contains the specified +row+ and +col+ Alternatively, can be passed a +Point+
[ "Create", "a", "new", "region", "with", "specified", "+", "pos", "+", "as", "top", "left", "corner", "and", "+", "size", "+", "as", "width", "and", "height", ".", "The", "stored", "positions", "are", "copies", "of", "the", "passed", "position", "and", "size", "to", "avoid", "aliasing", "." ]
07b5258458c4c3c315f697c8d5da839a93eb2c67
https://github.com/JulianNicholls/gosu_enhanced-gem/blob/07b5258458c4c3c315f697c8d5da839a93eb2c67/lib/gosu_enhanced/region.rb#L33-L38
train
JulianNicholls/gosu_enhanced-gem
lib/gosu_enhanced/region.rb
GosuEnhanced.Region.draw
def draw(surface, z_order, colour) surface.draw_rectangle(position, size, z_order, colour) end
ruby
def draw(surface, z_order, colour) surface.draw_rectangle(position, size, z_order, colour) end
[ "def", "draw", "(", "surface", ",", "z_order", ",", "colour", ")", "surface", ".", "draw_rectangle", "(", "position", ",", "size", ",", "z_order", ",", "colour", ")", "end" ]
Duplicate a Region, must be done explicitly to avoid aliasing. Draw a rectangle on the specified +surface+ at the specified +z_order+ and with the specified +colour+
[ "Duplicate", "a", "Region", "must", "be", "done", "explicitly", "to", "avoid", "aliasing", ".", "Draw", "a", "rectangle", "on", "the", "specified", "+", "surface", "+", "at", "the", "specified", "+", "z_order", "+", "and", "with", "the", "specified", "+", "colour", "+" ]
07b5258458c4c3c315f697c8d5da839a93eb2c67
https://github.com/JulianNicholls/gosu_enhanced-gem/blob/07b5258458c4c3c315f697c8d5da839a93eb2c67/lib/gosu_enhanced/region.rb#L57-L59
train
JulianNicholls/gosu_enhanced-gem
lib/gosu_enhanced/region.rb
GosuEnhanced.Region.contains_point?
def contains_point?(pt) pt.x.between?(left, left + width - 1) && pt.y.between?(top, top + height - 1) end
ruby
def contains_point?(pt) pt.x.between?(left, left + width - 1) && pt.y.between?(top, top + height - 1) end
[ "def", "contains_point?", "(", "pt", ")", "pt", ".", "x", ".", "between?", "(", "left", ",", "left", "+", "width", "-", "1", ")", "&&", "pt", ".", "y", ".", "between?", "(", "top", ",", "top", "+", "height", "-", "1", ")", "end" ]
Return whether the passed Point +pt+ is contained within the current Region.
[ "Return", "whether", "the", "passed", "Point", "+", "pt", "+", "is", "contained", "within", "the", "current", "Region", "." ]
07b5258458c4c3c315f697c8d5da839a93eb2c67
https://github.com/JulianNicholls/gosu_enhanced-gem/blob/07b5258458c4c3c315f697c8d5da839a93eb2c67/lib/gosu_enhanced/region.rb#L70-L73
train
blahah/biopsy
lib/biopsy/experiment.rb
Biopsy.Experiment.select_algorithm
def select_algorithm return if algorithm max = Settings.instance.sweep_cutoff n = @target.count_parameter_permutations if n < max @algorithm = ParameterSweeper.new(@target.parameters, @id) else @algorithm = TabuSearch.new(@target.parameters, @id) end end
ruby
def select_algorithm return if algorithm max = Settings.instance.sweep_cutoff n = @target.count_parameter_permutations if n < max @algorithm = ParameterSweeper.new(@target.parameters, @id) else @algorithm = TabuSearch.new(@target.parameters, @id) end end
[ "def", "select_algorithm", "return", "if", "algorithm", "max", "=", "Settings", ".", "instance", ".", "sweep_cutoff", "n", "=", "@target", ".", "count_parameter_permutations", "if", "n", "<", "max", "@algorithm", "=", "ParameterSweeper", ".", "new", "(", "@target", ".", "parameters", ",", "@id", ")", "else", "@algorithm", "=", "TabuSearch", ".", "new", "(", "@target", ".", "parameters", ",", "@id", ")", "end", "end" ]
select the optimisation algorithm to use
[ "select", "the", "optimisation", "algorithm", "to", "use" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/experiment.rb#L62-L71
train
blahah/biopsy
lib/biopsy/experiment.rb
Biopsy.Experiment.run
def run start_time = Time.now in_progress = true @algorithm.setup @start @current_params = @start max_scores = @target.count_parameter_permutations while in_progress run_iteration # update the best result best = @best @best = @algorithm.best ptext = @best[:parameters].each_pair.map{ |k, v| "#{k}:#{v}" }.join(", ") if @best && @best.key?(:score) && best && best.key?(:score) && @best[:score] > best[:score] unless @verbosity == :silent puts "found a new best score: #{@best[:score]} "+ "for parameters #{ptext}" end end # have we finished? in_progress = [email protected]? && @scores.size < max_scores if in_progress && !(@timelimit.nil?) in_progress = (Time.now - start_time < @timelimit) end end @algorithm.write_data if @algorithm.respond_to? :write_data unless @verbosity == :silent puts "found optimum score: #{@best[:score]} for parameters "+ "#{@best[:parameters]} in #{@iteration_count} iterations." end return @best end
ruby
def run start_time = Time.now in_progress = true @algorithm.setup @start @current_params = @start max_scores = @target.count_parameter_permutations while in_progress run_iteration # update the best result best = @best @best = @algorithm.best ptext = @best[:parameters].each_pair.map{ |k, v| "#{k}:#{v}" }.join(", ") if @best && @best.key?(:score) && best && best.key?(:score) && @best[:score] > best[:score] unless @verbosity == :silent puts "found a new best score: #{@best[:score]} "+ "for parameters #{ptext}" end end # have we finished? in_progress = [email protected]? && @scores.size < max_scores if in_progress && !(@timelimit.nil?) in_progress = (Time.now - start_time < @timelimit) end end @algorithm.write_data if @algorithm.respond_to? :write_data unless @verbosity == :silent puts "found optimum score: #{@best[:score]} for parameters "+ "#{@best[:parameters]} in #{@iteration_count} iterations." end return @best end
[ "def", "run", "start_time", "=", "Time", ".", "now", "in_progress", "=", "true", "@algorithm", ".", "setup", "@start", "@current_params", "=", "@start", "max_scores", "=", "@target", ".", "count_parameter_permutations", "while", "in_progress", "run_iteration", "best", "=", "@best", "@best", "=", "@algorithm", ".", "best", "ptext", "=", "@best", "[", ":parameters", "]", ".", "each_pair", ".", "map", "{", "|", "k", ",", "v", "|", "\"#{k}:#{v}\"", "}", ".", "join", "(", "\", \"", ")", "if", "@best", "&&", "@best", ".", "key?", "(", ":score", ")", "&&", "best", "&&", "best", ".", "key?", "(", ":score", ")", "&&", "@best", "[", ":score", "]", ">", "best", "[", ":score", "]", "unless", "@verbosity", "==", ":silent", "puts", "\"found a new best score: #{@best[:score]} \"", "+", "\"for parameters #{ptext}\"", "end", "end", "in_progress", "=", "!", "@algorithm", ".", "finished?", "&&", "@scores", ".", "size", "<", "max_scores", "if", "in_progress", "&&", "!", "(", "@timelimit", ".", "nil?", ")", "in_progress", "=", "(", "Time", ".", "now", "-", "start_time", "<", "@timelimit", ")", "end", "end", "@algorithm", ".", "write_data", "if", "@algorithm", ".", "respond_to?", ":write_data", "unless", "@verbosity", "==", ":silent", "puts", "\"found optimum score: #{@best[:score]} for parameters \"", "+", "\"#{@best[:parameters]} in #{@iteration_count} iterations.\"", "end", "return", "@best", "end" ]
Runs the experiment until the completion criteria are met. On completion, returns the best parameter set.
[ "Runs", "the", "experiment", "until", "the", "completion", "criteria", "are", "met", ".", "On", "completion", "returns", "the", "best", "parameter", "set", "." ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/experiment.rb#L82-L116
train
blahah/biopsy
lib/biopsy/experiment.rb
Biopsy.Experiment.create_tempdir
def create_tempdir token = loop do # generate random dirnames until we find one that # doesn't exist test_token = SecureRandom.hex break test_token unless File.exist? test_token end Dir.mkdir(token) @last_tempdir = token token end
ruby
def create_tempdir token = loop do # generate random dirnames until we find one that # doesn't exist test_token = SecureRandom.hex break test_token unless File.exist? test_token end Dir.mkdir(token) @last_tempdir = token token end
[ "def", "create_tempdir", "token", "=", "loop", "do", "test_token", "=", "SecureRandom", ".", "hex", "break", "test_token", "unless", "File", ".", "exist?", "test_token", "end", "Dir", ".", "mkdir", "(", "token", ")", "@last_tempdir", "=", "token", "token", "end" ]
create a guaranteed random temporary directory for storing outputs return the dirname
[ "create", "a", "guaranteed", "random", "temporary", "directory", "for", "storing", "outputs", "return", "the", "dirname" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/experiment.rb#L179-L189
train
blahah/biopsy
lib/biopsy/experiment.rb
Biopsy.Experiment.set_id
def set_id id @id = id if @id.nil? t = Time.now parts = %w[y m d H M S Z].map{ |p| t.strftime "%#{p}" } @id = "experiment_#{parts.join('_')}" end end
ruby
def set_id id @id = id if @id.nil? t = Time.now parts = %w[y m d H M S Z].map{ |p| t.strftime "%#{p}" } @id = "experiment_#{parts.join('_')}" end end
[ "def", "set_id", "id", "@id", "=", "id", "if", "@id", ".", "nil?", "t", "=", "Time", ".", "now", "parts", "=", "%w[", "y", "m", "d", "H", "M", "S", "Z", "]", ".", "map", "{", "|", "p", "|", "t", ".", "strftime", "\"%#{p}\"", "}", "@id", "=", "\"experiment_#{parts.join('_')}\"", "end", "end" ]
set experiment ID with either user provided value, or date-time as fallback
[ "set", "experiment", "ID", "with", "either", "user", "provided", "value", "or", "date", "-", "time", "as", "fallback" ]
e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2
https://github.com/blahah/biopsy/blob/e46f3d1c75de4da2ec47a377f7e4f0e16a8e03d2/lib/biopsy/experiment.rb#L193-L200
train
lasso/racket-registry
lib/racket/registry.rb
Racket.Registry.register
def register(key, proc = nil, &block) Helper.register(obj: self, key: key, proc: proc, block: block) end
ruby
def register(key, proc = nil, &block) Helper.register(obj: self, key: key, proc: proc, block: block) end
[ "def", "register", "(", "key", ",", "proc", "=", "nil", ",", "&", "block", ")", "Helper", ".", "register", "(", "obj", ":", "self", ",", "key", ":", "key", ",", "proc", ":", "proc", ",", "block", ":", "block", ")", "end" ]
Registers a new callback in the registry. This will add a new method matching +key+ to the registry that can be used both outside the registry and when registering other callbacks dependant of the current entry. Results from the callback will not be cached, meaning that the callback may return a different object every time. @param [String|Symbol] key @param [Proc|nil] proc @return [nil]
[ "Registers", "a", "new", "callback", "in", "the", "registry", ".", "This", "will", "add", "a", "new", "method", "matching", "+", "key", "+", "to", "the", "registry", "that", "can", "be", "used", "both", "outside", "the", "registry", "and", "when", "registering", "other", "callbacks", "dependant", "of", "the", "current", "entry", ".", "Results", "from", "the", "callback", "will", "not", "be", "cached", "meaning", "that", "the", "callback", "may", "return", "a", "different", "object", "every", "time", "." ]
d3413d822c297765d5a78bff0216f4cf0b2ace41
https://github.com/lasso/racket-registry/blob/d3413d822c297765d5a78bff0216f4cf0b2ace41/lib/racket/registry.rb#L73-L75
train
lasso/racket-registry
lib/racket/registry.rb
Racket.Registry.register_singleton
def register_singleton(key, proc = nil, &block) Helper.register_singleton(obj: self, key: key, proc: proc, block: block) end
ruby
def register_singleton(key, proc = nil, &block) Helper.register_singleton(obj: self, key: key, proc: proc, block: block) end
[ "def", "register_singleton", "(", "key", ",", "proc", "=", "nil", ",", "&", "block", ")", "Helper", ".", "register_singleton", "(", "obj", ":", "self", ",", "key", ":", "key", ",", "proc", ":", "proc", ",", "block", ":", "block", ")", "end" ]
Registers a new callback in the registry. This will add a new method matching +key+ to the registry that can be used both outside the registry and when registering other callbacks dependant of the current entry. Results from the callnack will be cached, meaning that the callback will return the same object every time. @param [String|Symbol] key @param [Proc|nil] proc @return [nil]
[ "Registers", "a", "new", "callback", "in", "the", "registry", ".", "This", "will", "add", "a", "new", "method", "matching", "+", "key", "+", "to", "the", "registry", "that", "can", "be", "used", "both", "outside", "the", "registry", "and", "when", "registering", "other", "callbacks", "dependant", "of", "the", "current", "entry", ".", "Results", "from", "the", "callnack", "will", "be", "cached", "meaning", "that", "the", "callback", "will", "return", "the", "same", "object", "every", "time", "." ]
d3413d822c297765d5a78bff0216f4cf0b2ace41
https://github.com/lasso/racket-registry/blob/d3413d822c297765d5a78bff0216f4cf0b2ace41/lib/racket/registry.rb#L86-L88
train
datamapper/dm-sweatshop
lib/dm-sweatshop/model.rb
DataMapper.Model.generate
def generate(name = default_fauxture_name, attributes = {}) name, attributes = default_fauxture_name, name if name.is_a? Hash Sweatshop.create(self, name, attributes) end
ruby
def generate(name = default_fauxture_name, attributes = {}) name, attributes = default_fauxture_name, name if name.is_a? Hash Sweatshop.create(self, name, attributes) end
[ "def", "generate", "(", "name", "=", "default_fauxture_name", ",", "attributes", "=", "{", "}", ")", "name", ",", "attributes", "=", "default_fauxture_name", ",", "name", "if", "name", ".", "is_a?", "Hash", "Sweatshop", ".", "create", "(", "self", ",", "name", ",", "attributes", ")", "end" ]
Creates an instance from hash of attributes, saves it and adds it to the record map. Attributes given as the second argument are merged into attributes from fixture. If record is valid because of duplicated property value, this method does a retry. @param name [Symbol] @param attributes [Hash] @api public @return [DataMapper::Resource] added instance
[ "Creates", "an", "instance", "from", "hash", "of", "attributes", "saves", "it", "and", "adds", "it", "to", "the", "record", "map", ".", "Attributes", "given", "as", "the", "second", "argument", "are", "merged", "into", "attributes", "from", "fixture", "." ]
25d6b2353973df329734801417e31709f6ff7686
https://github.com/datamapper/dm-sweatshop/blob/25d6b2353973df329734801417e31709f6ff7686/lib/dm-sweatshop/model.rb#L36-L39
train
datamapper/dm-sweatshop
lib/dm-sweatshop/model.rb
DataMapper.Model.make
def make(name = default_fauxture_name, attributes = {}) name, attributes = default_fauxture_name, name if name.is_a? Hash Sweatshop.make(self, name, attributes) end
ruby
def make(name = default_fauxture_name, attributes = {}) name, attributes = default_fauxture_name, name if name.is_a? Hash Sweatshop.make(self, name, attributes) end
[ "def", "make", "(", "name", "=", "default_fauxture_name", ",", "attributes", "=", "{", "}", ")", "name", ",", "attributes", "=", "default_fauxture_name", ",", "name", "if", "name", ".", "is_a?", "Hash", "Sweatshop", ".", "make", "(", "self", ",", "name", ",", "attributes", ")", "end" ]
Creates an instance from given hash of attributes and adds it to records map without saving. @param name [Symbol] name of the fauxture to use @param attributes [Hash] @api private @return [DataMapper::Resource] added instance
[ "Creates", "an", "instance", "from", "given", "hash", "of", "attributes", "and", "adds", "it", "to", "records", "map", "without", "saving", "." ]
25d6b2353973df329734801417e31709f6ff7686
https://github.com/datamapper/dm-sweatshop/blob/25d6b2353973df329734801417e31709f6ff7686/lib/dm-sweatshop/model.rb#L82-L85
train
postmodern/deployml
lib/deployml/project.rb
DeploYML.Project.environment
def environment(name=:production) name = name.to_sym unless @environments[name] raise(UnknownEnvironment,"unknown environment: #{name}",caller) end return @environments[name] end
ruby
def environment(name=:production) name = name.to_sym unless @environments[name] raise(UnknownEnvironment,"unknown environment: #{name}",caller) end return @environments[name] end
[ "def", "environment", "(", "name", "=", ":production", ")", "name", "=", "name", ".", "to_sym", "unless", "@environments", "[", "name", "]", "raise", "(", "UnknownEnvironment", ",", "\"unknown environment: #{name}\"", ",", "caller", ")", "end", "return", "@environments", "[", "name", "]", "end" ]
Creates a new project using the given configuration file. @param [String] root The root directory of the project. @raise [ConfigNotFound] The configuration file for the project could not be found in any of the common directories. @param [Symbol, String] name The name of the environment to use. @return [Environment] The environment with the given name. @raise [UnknownEnvironment] No environment was configured with the given name. @since 0.3.0
[ "Creates", "a", "new", "project", "using", "the", "given", "configuration", "file", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/project.rb#L64-L72
train
postmodern/deployml
lib/deployml/project.rb
DeploYML.Project.load_configuration
def load_configuration(path) config = YAML.load_file(path) unless config.kind_of?(Hash) raise(InvalidConfig,"DeploYML file #{path.dump} does not contain a Hash",caller) end return config end
ruby
def load_configuration(path) config = YAML.load_file(path) unless config.kind_of?(Hash) raise(InvalidConfig,"DeploYML file #{path.dump} does not contain a Hash",caller) end return config end
[ "def", "load_configuration", "(", "path", ")", "config", "=", "YAML", ".", "load_file", "(", "path", ")", "unless", "config", ".", "kind_of?", "(", "Hash", ")", "raise", "(", "InvalidConfig", ",", "\"DeploYML file #{path.dump} does not contain a Hash\"", ",", "caller", ")", "end", "return", "config", "end" ]
Loads configuration from a YAML file. @param [String] path The path to the configuration file. @return [Hash] The loaded configuration. @raise [InvalidConfig] The configuration file did not contain a YAML Hash. @since 0.4.1
[ "Loads", "configuration", "from", "a", "YAML", "file", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/project.rb#L297-L305
train
postmodern/deployml
lib/deployml/project.rb
DeploYML.Project.load_environments!
def load_environments! base_config = infer_configuration if File.file?(@config_file) base_config.merge!(load_configuration(@config_file)) end @environments = {} if File.directory?(@environments_dir) Dir.glob(File.join(@environments_dir,'*.yml')) do |path| config = base_config.merge(load_configuration(path)) name = File.basename(path).sub(/\.yml$/,'').to_sym @environments[name] = Environment.new(name,config) end else @environments[:production] = Environment.new(:production,base_config) end end
ruby
def load_environments! base_config = infer_configuration if File.file?(@config_file) base_config.merge!(load_configuration(@config_file)) end @environments = {} if File.directory?(@environments_dir) Dir.glob(File.join(@environments_dir,'*.yml')) do |path| config = base_config.merge(load_configuration(path)) name = File.basename(path).sub(/\.yml$/,'').to_sym @environments[name] = Environment.new(name,config) end else @environments[:production] = Environment.new(:production,base_config) end end
[ "def", "load_environments!", "base_config", "=", "infer_configuration", "if", "File", ".", "file?", "(", "@config_file", ")", "base_config", ".", "merge!", "(", "load_configuration", "(", "@config_file", ")", ")", "end", "@environments", "=", "{", "}", "if", "File", ".", "directory?", "(", "@environments_dir", ")", "Dir", ".", "glob", "(", "File", ".", "join", "(", "@environments_dir", ",", "'*.yml'", ")", ")", "do", "|", "path", "|", "config", "=", "base_config", ".", "merge", "(", "load_configuration", "(", "path", ")", ")", "name", "=", "File", ".", "basename", "(", "path", ")", ".", "sub", "(", "/", "\\.", "/", ",", "''", ")", ".", "to_sym", "@environments", "[", "name", "]", "=", "Environment", ".", "new", "(", "name", ",", "config", ")", "end", "else", "@environments", "[", ":production", "]", "=", "Environment", ".", "new", "(", ":production", ",", "base_config", ")", "end", "end" ]
Loads the project configuration. @since 0.3.0
[ "Loads", "the", "project", "configuration", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/project.rb#L312-L331
train
mose/cogbot
lib/cogbot.rb
Cogbot.Bot.start
def start # prepare config config = {} begin config = YAML::load_file(CONFIG_FILE) rescue Exception => e load 'lib/cogbot/setup.rb' config['main'] = Cogbot::Setup.init end # prepare daemon Daemons.daemonize( :app_name => 'cogbot', :dir_mode => :normal, :log_dir => LOG_DIR, :log_output => true, :dir => CONFIG_DIR ) # checkout plugins plugins = [] config['main']['plugins'].each do |p| if File.exists?(File.join(ROOT_DIR, 'plugins', "#{p}.rb")) require File.join(ROOT_DIR, 'plugins', p) plugins.push Cinch::Plugins.const_get(p.camelize) end end # create bot bot = Cinch::Bot.new do configure do |c| c.server = config['main']['server'] c.ssl.use = ( config['main']['ssl'] == 'true' ) c.nick = config['main']['nick'] c.user = config['main']['nick'] c.realname = config['main']['nick'] c.channels = config['main']['channels'] c.sasl.username = config['main']['sasl_user'] c.sasl.password = config['main']['sasl_pass'] c.options = { 'cogconf' => config } c.plugins.prefix = config['main']['prefix'] c.plugins.plugins = plugins end on :message, 'hi' do |m| m.reply "Hello, #{m.user.nick}" end end bot.loggers.debug(plugins.inspect) Signal.trap('TERM') { EM.stop } EM.run do EM.defer { bot.start } if config['server'] EM.add_timer(3) do EM.start_server( config['server']['ip'], config['server']['port'], Server, bot ) end end end bot.quit end
ruby
def start # prepare config config = {} begin config = YAML::load_file(CONFIG_FILE) rescue Exception => e load 'lib/cogbot/setup.rb' config['main'] = Cogbot::Setup.init end # prepare daemon Daemons.daemonize( :app_name => 'cogbot', :dir_mode => :normal, :log_dir => LOG_DIR, :log_output => true, :dir => CONFIG_DIR ) # checkout plugins plugins = [] config['main']['plugins'].each do |p| if File.exists?(File.join(ROOT_DIR, 'plugins', "#{p}.rb")) require File.join(ROOT_DIR, 'plugins', p) plugins.push Cinch::Plugins.const_get(p.camelize) end end # create bot bot = Cinch::Bot.new do configure do |c| c.server = config['main']['server'] c.ssl.use = ( config['main']['ssl'] == 'true' ) c.nick = config['main']['nick'] c.user = config['main']['nick'] c.realname = config['main']['nick'] c.channels = config['main']['channels'] c.sasl.username = config['main']['sasl_user'] c.sasl.password = config['main']['sasl_pass'] c.options = { 'cogconf' => config } c.plugins.prefix = config['main']['prefix'] c.plugins.plugins = plugins end on :message, 'hi' do |m| m.reply "Hello, #{m.user.nick}" end end bot.loggers.debug(plugins.inspect) Signal.trap('TERM') { EM.stop } EM.run do EM.defer { bot.start } if config['server'] EM.add_timer(3) do EM.start_server( config['server']['ip'], config['server']['port'], Server, bot ) end end end bot.quit end
[ "def", "start", "config", "=", "{", "}", "begin", "config", "=", "YAML", "::", "load_file", "(", "CONFIG_FILE", ")", "rescue", "Exception", "=>", "e", "load", "'lib/cogbot/setup.rb'", "config", "[", "'main'", "]", "=", "Cogbot", "::", "Setup", ".", "init", "end", "Daemons", ".", "daemonize", "(", ":app_name", "=>", "'cogbot'", ",", ":dir_mode", "=>", ":normal", ",", ":log_dir", "=>", "LOG_DIR", ",", ":log_output", "=>", "true", ",", ":dir", "=>", "CONFIG_DIR", ")", "plugins", "=", "[", "]", "config", "[", "'main'", "]", "[", "'plugins'", "]", ".", "each", "do", "|", "p", "|", "if", "File", ".", "exists?", "(", "File", ".", "join", "(", "ROOT_DIR", ",", "'plugins'", ",", "\"#{p}.rb\"", ")", ")", "require", "File", ".", "join", "(", "ROOT_DIR", ",", "'plugins'", ",", "p", ")", "plugins", ".", "push", "Cinch", "::", "Plugins", ".", "const_get", "(", "p", ".", "camelize", ")", "end", "end", "bot", "=", "Cinch", "::", "Bot", ".", "new", "do", "configure", "do", "|", "c", "|", "c", ".", "server", "=", "config", "[", "'main'", "]", "[", "'server'", "]", "c", ".", "ssl", ".", "use", "=", "(", "config", "[", "'main'", "]", "[", "'ssl'", "]", "==", "'true'", ")", "c", ".", "nick", "=", "config", "[", "'main'", "]", "[", "'nick'", "]", "c", ".", "user", "=", "config", "[", "'main'", "]", "[", "'nick'", "]", "c", ".", "realname", "=", "config", "[", "'main'", "]", "[", "'nick'", "]", "c", ".", "channels", "=", "config", "[", "'main'", "]", "[", "'channels'", "]", "c", ".", "sasl", ".", "username", "=", "config", "[", "'main'", "]", "[", "'sasl_user'", "]", "c", ".", "sasl", ".", "password", "=", "config", "[", "'main'", "]", "[", "'sasl_pass'", "]", "c", ".", "options", "=", "{", "'cogconf'", "=>", "config", "}", "c", ".", "plugins", ".", "prefix", "=", "config", "[", "'main'", "]", "[", "'prefix'", "]", "c", ".", "plugins", ".", "plugins", "=", "plugins", "end", "on", ":message", ",", "'hi'", "do", "|", "m", "|", "m", ".", "reply", "\"Hello, #{m.user.nick}\"", "end", "end", "bot", ".", "loggers", ".", "debug", "(", "plugins", ".", "inspect", ")", "Signal", ".", "trap", "(", "'TERM'", ")", "{", "EM", ".", "stop", "}", "EM", ".", "run", "do", "EM", ".", "defer", "{", "bot", ".", "start", "}", "if", "config", "[", "'server'", "]", "EM", ".", "add_timer", "(", "3", ")", "do", "EM", ".", "start_server", "(", "config", "[", "'server'", "]", "[", "'ip'", "]", ",", "config", "[", "'server'", "]", "[", "'port'", "]", ",", "Server", ",", "bot", ")", "end", "end", "end", "bot", ".", "quit", "end" ]
manages the start cli command
[ "manages", "the", "start", "cli", "command" ]
844dab70f9093aba13dd50a8e445483d790b868a
https://github.com/mose/cogbot/blob/844dab70f9093aba13dd50a8e445483d790b868a/lib/cogbot.rb#L20-L87
train
mose/cogbot
lib/cogbot.rb
Cogbot.Bot.stop
def stop pid_file = File.join(CONFIG_DIR, 'cogbot.pid') pid = File.read(pid_file).to_i if File.exist?(pid_file) Process.kill('TERM', pid) end
ruby
def stop pid_file = File.join(CONFIG_DIR, 'cogbot.pid') pid = File.read(pid_file).to_i if File.exist?(pid_file) Process.kill('TERM', pid) end
[ "def", "stop", "pid_file", "=", "File", ".", "join", "(", "CONFIG_DIR", ",", "'cogbot.pid'", ")", "pid", "=", "File", ".", "read", "(", "pid_file", ")", ".", "to_i", "if", "File", ".", "exist?", "(", "pid_file", ")", "Process", ".", "kill", "(", "'TERM'", ",", "pid", ")", "end" ]
manages the stop cli command
[ "manages", "the", "stop", "cli", "command" ]
844dab70f9093aba13dd50a8e445483d790b868a
https://github.com/mose/cogbot/blob/844dab70f9093aba13dd50a8e445483d790b868a/lib/cogbot.rb#L91-L95
train
ManageIQ/polisher
lib/polisher/mixins/versioned_dependencies.rb
Polisher.VersionedDependencies.dependency_versions
def dependency_versions(args = {}, &bl) versions = {} args = {:recursive => true, :dev_deps => true, :versions => versions}.merge(args) deps.each do |dep| gem = Polisher::Gem.retrieve(dep.name) versions.merge!(gem.versions(args, &bl)) end versions end
ruby
def dependency_versions(args = {}, &bl) versions = {} args = {:recursive => true, :dev_deps => true, :versions => versions}.merge(args) deps.each do |dep| gem = Polisher::Gem.retrieve(dep.name) versions.merge!(gem.versions(args, &bl)) end versions end
[ "def", "dependency_versions", "(", "args", "=", "{", "}", ",", "&", "bl", ")", "versions", "=", "{", "}", "args", "=", "{", ":recursive", "=>", "true", ",", ":dev_deps", "=>", "true", ",", ":versions", "=>", "versions", "}", ".", "merge", "(", "args", ")", "deps", ".", "each", "do", "|", "dep", "|", "gem", "=", "Polisher", "::", "Gem", ".", "retrieve", "(", "dep", ".", "name", ")", "versions", ".", "merge!", "(", "gem", ".", "versions", "(", "args", ",", "&", "bl", ")", ")", "end", "versions", "end" ]
Return list of versions of dependencies of component.
[ "Return", "list", "of", "versions", "of", "dependencies", "of", "component", "." ]
8c19023c72573999c9dc53ec2e2a3eef11a9531e
https://github.com/ManageIQ/polisher/blob/8c19023c72573999c9dc53ec2e2a3eef11a9531e/lib/polisher/mixins/versioned_dependencies.rb#L23-L31
train
ManageIQ/polisher
lib/polisher/mixins/versioned_dependencies.rb
Polisher.VersionedDependencies.dependency_tree
def dependency_tree(args = {}, &bl) dependencies = {} args = {:recursive => true, :dev_deps => true, :matching => :latest, :dependencies => dependencies}.merge(args) process = [] deps.each do |dep| resolved = nil begin resolved = Polisher::Gem.matching(dep, args[:matching]) rescue end yield self, dep, resolved process << resolved unless resolved.nil? end process.each { |dep| dependencies.merge!(dep.dependency_tree(args, &bl)) } dependencies end
ruby
def dependency_tree(args = {}, &bl) dependencies = {} args = {:recursive => true, :dev_deps => true, :matching => :latest, :dependencies => dependencies}.merge(args) process = [] deps.each do |dep| resolved = nil begin resolved = Polisher::Gem.matching(dep, args[:matching]) rescue end yield self, dep, resolved process << resolved unless resolved.nil? end process.each { |dep| dependencies.merge!(dep.dependency_tree(args, &bl)) } dependencies end
[ "def", "dependency_tree", "(", "args", "=", "{", "}", ",", "&", "bl", ")", "dependencies", "=", "{", "}", "args", "=", "{", ":recursive", "=>", "true", ",", ":dev_deps", "=>", "true", ",", ":matching", "=>", ":latest", ",", ":dependencies", "=>", "dependencies", "}", ".", "merge", "(", "args", ")", "process", "=", "[", "]", "deps", ".", "each", "do", "|", "dep", "|", "resolved", "=", "nil", "begin", "resolved", "=", "Polisher", "::", "Gem", ".", "matching", "(", "dep", ",", "args", "[", ":matching", "]", ")", "rescue", "end", "yield", "self", ",", "dep", ",", "resolved", "process", "<<", "resolved", "unless", "resolved", ".", "nil?", "end", "process", ".", "each", "{", "|", "dep", "|", "dependencies", ".", "merge!", "(", "dep", ".", "dependency_tree", "(", "args", ",", "&", "bl", ")", ")", "}", "dependencies", "end" ]
Return mapping of gems to dependency versions
[ "Return", "mapping", "of", "gems", "to", "dependency", "versions" ]
8c19023c72573999c9dc53ec2e2a3eef11a9531e
https://github.com/ManageIQ/polisher/blob/8c19023c72573999c9dc53ec2e2a3eef11a9531e/lib/polisher/mixins/versioned_dependencies.rb#L34-L57
train
ManageIQ/polisher
lib/polisher/mixins/versioned_dependencies.rb
Polisher.VersionedDependencies.missing_dependencies
def missing_dependencies missing = [] dependency_versions(:recursive => false).each do |pkg, target_versions| found = false target_versions.each do |_target, versions| dependency = dependency_for(pkg) found = versions.any? { |version| dependency.match?(pkg, version) } end missing << pkg unless found end missing end
ruby
def missing_dependencies missing = [] dependency_versions(:recursive => false).each do |pkg, target_versions| found = false target_versions.each do |_target, versions| dependency = dependency_for(pkg) found = versions.any? { |version| dependency.match?(pkg, version) } end missing << pkg unless found end missing end
[ "def", "missing_dependencies", "missing", "=", "[", "]", "dependency_versions", "(", ":recursive", "=>", "false", ")", ".", "each", "do", "|", "pkg", ",", "target_versions", "|", "found", "=", "false", "target_versions", ".", "each", "do", "|", "_target", ",", "versions", "|", "dependency", "=", "dependency_for", "(", "pkg", ")", "found", "=", "versions", ".", "any?", "{", "|", "version", "|", "dependency", ".", "match?", "(", "pkg", ",", "version", ")", "}", "end", "missing", "<<", "pkg", "unless", "found", "end", "missing", "end" ]
Return missing dependencies
[ "Return", "missing", "dependencies" ]
8c19023c72573999c9dc53ec2e2a3eef11a9531e
https://github.com/ManageIQ/polisher/blob/8c19023c72573999c9dc53ec2e2a3eef11a9531e/lib/polisher/mixins/versioned_dependencies.rb#L60-L71
train
ManageIQ/polisher
lib/polisher/mixins/versioned_dependencies.rb
Polisher.VersionedDependencies.dependency_states
def dependency_states states = {} deps.each do |dep| gem = Polisher::Gem.new :name => dep.name states.merge! dep.name => gem.state(:check => dep) end states end
ruby
def dependency_states states = {} deps.each do |dep| gem = Polisher::Gem.new :name => dep.name states.merge! dep.name => gem.state(:check => dep) end states end
[ "def", "dependency_states", "states", "=", "{", "}", "deps", ".", "each", "do", "|", "dep", "|", "gem", "=", "Polisher", "::", "Gem", ".", "new", ":name", "=>", "dep", ".", "name", "states", ".", "merge!", "dep", ".", "name", "=>", "gem", ".", "state", "(", ":check", "=>", "dep", ")", "end", "states", "end" ]
Return list of states which gem dependencies are in
[ "Return", "list", "of", "states", "which", "gem", "dependencies", "are", "in" ]
8c19023c72573999c9dc53ec2e2a3eef11a9531e
https://github.com/ManageIQ/polisher/blob/8c19023c72573999c9dc53ec2e2a3eef11a9531e/lib/polisher/mixins/versioned_dependencies.rb#L79-L86
train
cbot/push0r
lib/push0r/Queue.rb
Push0r.Queue.add
def add(message) @services.each do |service| if service.can_send?(message) if @queued_messages[service].nil? @queued_messages[service] = [] end @queued_messages[service] << message return true end end return false end
ruby
def add(message) @services.each do |service| if service.can_send?(message) if @queued_messages[service].nil? @queued_messages[service] = [] end @queued_messages[service] << message return true end end return false end
[ "def", "add", "(", "message", ")", "@services", ".", "each", "do", "|", "service", "|", "if", "service", ".", "can_send?", "(", "message", ")", "if", "@queued_messages", "[", "service", "]", ".", "nil?", "@queued_messages", "[", "service", "]", "=", "[", "]", "end", "@queued_messages", "[", "service", "]", "<<", "message", "return", "true", "end", "end", "return", "false", "end" ]
Adds a PushMessage to the queue @param message [PushMessage] the message to be added to the queue @return [Boolean] true if message was added to the queue (that is: if any of the registered services can handle the message), otherwise false @see PushMessage
[ "Adds", "a", "PushMessage", "to", "the", "queue" ]
07eb7bece1f251608529dea0d7a93af1444ffeb6
https://github.com/cbot/push0r/blob/07eb7bece1f251608529dea0d7a93af1444ffeb6/lib/push0r/Queue.rb#L44-L55
train
cbot/push0r
lib/push0r/Queue.rb
Push0r.Queue.flush
def flush failed_messages = [] new_token_messages = [] @queued_messages.each do |service, messages| service.init_push messages.each do |message| service.send(message) end (failed, new_token) = service.end_push failed_messages += failed new_token_messages += new_token end @queued_messages = {} return FlushResult.new(failed_messages, new_token_messages) end
ruby
def flush failed_messages = [] new_token_messages = [] @queued_messages.each do |service, messages| service.init_push messages.each do |message| service.send(message) end (failed, new_token) = service.end_push failed_messages += failed new_token_messages += new_token end @queued_messages = {} return FlushResult.new(failed_messages, new_token_messages) end
[ "def", "flush", "failed_messages", "=", "[", "]", "new_token_messages", "=", "[", "]", "@queued_messages", ".", "each", "do", "|", "service", ",", "messages", "|", "service", ".", "init_push", "messages", ".", "each", "do", "|", "message", "|", "service", ".", "send", "(", "message", ")", "end", "(", "failed", ",", "new_token", ")", "=", "service", ".", "end_push", "failed_messages", "+=", "failed", "new_token_messages", "+=", "new_token", "end", "@queued_messages", "=", "{", "}", "return", "FlushResult", ".", "new", "(", "failed_messages", ",", "new_token_messages", ")", "end" ]
Flushes the queue by transmitting the enqueued messages using the registered services @return [FlushResult] the result of the operation
[ "Flushes", "the", "queue", "by", "transmitting", "the", "enqueued", "messages", "using", "the", "registered", "services" ]
07eb7bece1f251608529dea0d7a93af1444ffeb6
https://github.com/cbot/push0r/blob/07eb7bece1f251608529dea0d7a93af1444ffeb6/lib/push0r/Queue.rb#L59-L74
train
postmodern/deployml
lib/deployml/configuration.rb
DeploYML.Configuration.normalize_hash
def normalize_hash(hash) new_hash = {} hash.each do |key,value| new_hash[key.to_sym] = normalize(value) end return new_hash end
ruby
def normalize_hash(hash) new_hash = {} hash.each do |key,value| new_hash[key.to_sym] = normalize(value) end return new_hash end
[ "def", "normalize_hash", "(", "hash", ")", "new_hash", "=", "{", "}", "hash", ".", "each", "do", "|", "key", ",", "value", "|", "new_hash", "[", "key", ".", "to_sym", "]", "=", "normalize", "(", "value", ")", "end", "return", "new_hash", "end" ]
Converts all the keys of a Hash to Symbols. @param [Hash{Object => Object}] hash The hash to be converted. @return [Hash{Symbol => Object}] The normalized Hash.
[ "Converts", "all", "the", "keys", "of", "a", "Hash", "to", "Symbols", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/configuration.rb#L185-L193
train
postmodern/deployml
lib/deployml/configuration.rb
DeploYML.Configuration.normalize
def normalize(value) case value when Hash normalize_hash(value) when Array normalize_array(value) else value end end
ruby
def normalize(value) case value when Hash normalize_hash(value) when Array normalize_array(value) else value end end
[ "def", "normalize", "(", "value", ")", "case", "value", "when", "Hash", "normalize_hash", "(", "value", ")", "when", "Array", "normalize_array", "(", "value", ")", "else", "value", "end", "end" ]
Normalizes a value. @param [Hash, Array, Object] value The value to normalize. @return [Hash, Array, Object] The normalized value. @since 0.5.0
[ "Normalizes", "a", "value", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/configuration.rb#L206-L215
train
postmodern/deployml
lib/deployml/configuration.rb
DeploYML.Configuration.parse_server
def parse_server(server) name = nil options = {} case server when Symbol, String name = server.to_sym when Hash unless server.has_key?(:name) raise(MissingOption,"the 'server' option must contain a 'name' option for which server to use",caller) end if server.has_key?(:name) name = server[:name].to_sym end if server.has_key?(:options) options.merge!(server[:options]) end end return [name, options] end
ruby
def parse_server(server) name = nil options = {} case server when Symbol, String name = server.to_sym when Hash unless server.has_key?(:name) raise(MissingOption,"the 'server' option must contain a 'name' option for which server to use",caller) end if server.has_key?(:name) name = server[:name].to_sym end if server.has_key?(:options) options.merge!(server[:options]) end end return [name, options] end
[ "def", "parse_server", "(", "server", ")", "name", "=", "nil", "options", "=", "{", "}", "case", "server", "when", "Symbol", ",", "String", "name", "=", "server", ".", "to_sym", "when", "Hash", "unless", "server", ".", "has_key?", "(", ":name", ")", "raise", "(", "MissingOption", ",", "\"the 'server' option must contain a 'name' option for which server to use\"", ",", "caller", ")", "end", "if", "server", ".", "has_key?", "(", ":name", ")", "name", "=", "server", "[", ":name", "]", ".", "to_sym", "end", "if", "server", ".", "has_key?", "(", ":options", ")", "options", ".", "merge!", "(", "server", "[", ":options", "]", ")", "end", "end", "return", "[", "name", ",", "options", "]", "end" ]
Parses the value for the `server` setting. @return [Array<Symbol, Hash>] The name of the server and additional options. @since 0.5.0
[ "Parses", "the", "value", "for", "the", "server", "setting", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/configuration.rb#L225-L247
train
postmodern/deployml
lib/deployml/configuration.rb
DeploYML.Configuration.parse_address
def parse_address(address) case address when Hash Addressable::URI.new(address) when String Addressable::URI.parse(address) else raise(InvalidConfig,"invalid address: #{address.inspect}",caller) end end
ruby
def parse_address(address) case address when Hash Addressable::URI.new(address) when String Addressable::URI.parse(address) else raise(InvalidConfig,"invalid address: #{address.inspect}",caller) end end
[ "def", "parse_address", "(", "address", ")", "case", "address", "when", "Hash", "Addressable", "::", "URI", ".", "new", "(", "address", ")", "when", "String", "Addressable", "::", "URI", ".", "parse", "(", "address", ")", "else", "raise", "(", "InvalidConfig", ",", "\"invalid address: #{address.inspect}\"", ",", "caller", ")", "end", "end" ]
Parses an address. @param [Hash, String] address The address to parse. @return [Addressable::URI] The parsed address. @since 0.5.0
[ "Parses", "an", "address", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/configuration.rb#L260-L269
train
postmodern/deployml
lib/deployml/configuration.rb
DeploYML.Configuration.parse_dest
def parse_dest(dest) case dest when Array dest.map { |address| parse_address(address) } else parse_address(dest) end end
ruby
def parse_dest(dest) case dest when Array dest.map { |address| parse_address(address) } else parse_address(dest) end end
[ "def", "parse_dest", "(", "dest", ")", "case", "dest", "when", "Array", "dest", ".", "map", "{", "|", "address", "|", "parse_address", "(", "address", ")", "}", "else", "parse_address", "(", "dest", ")", "end", "end" ]
Parses the value for the `dest` setting. @param [Array, Hash, String] dest The value of the `dest` setting. @return [Array<Addressable::URI>, Addressable::URI] The parsed `dest` value. @since 0.5.0
[ "Parses", "the", "value", "for", "the", "dest", "setting", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/configuration.rb#L282-L289
train
postmodern/deployml
lib/deployml/configuration.rb
DeploYML.Configuration.parse_commands
def parse_commands(command) case command when Array command.map { |line| line.to_s } when String command.enum_for(:each_line).map { |line| line.chomp } else raise(InvalidConfig,"commands must be an Array or a String") end end
ruby
def parse_commands(command) case command when Array command.map { |line| line.to_s } when String command.enum_for(:each_line).map { |line| line.chomp } else raise(InvalidConfig,"commands must be an Array or a String") end end
[ "def", "parse_commands", "(", "command", ")", "case", "command", "when", "Array", "command", ".", "map", "{", "|", "line", "|", "line", ".", "to_s", "}", "when", "String", "command", ".", "enum_for", "(", ":each_line", ")", ".", "map", "{", "|", "line", "|", "line", ".", "chomp", "}", "else", "raise", "(", "InvalidConfig", ",", "\"commands must be an Array or a String\"", ")", "end", "end" ]
Parses a command. @param [Array, String] command The command or commands to parse. @return [Array<String>] The individual commands. @raise [InvalidConfig] The command must be either an Array of a String. @since 0.5.0
[ "Parses", "a", "command", "." ]
4369d4ea719e41f0dc3aa6496e6422ad476b0dda
https://github.com/postmodern/deployml/blob/4369d4ea719e41f0dc3aa6496e6422ad476b0dda/lib/deployml/configuration.rb#L305-L314
train
brianmichel/BadFruit
lib/badfruit/Movies/movie.rb
BadFruit.Movie.reviews
def reviews data = JSON.parse(@badfruit.get_movie_info(@id, "reviews")) reviews = Array.new data["reviews"].each do |review| reviews.push(Review.new(review)) end return reviews end
ruby
def reviews data = JSON.parse(@badfruit.get_movie_info(@id, "reviews")) reviews = Array.new data["reviews"].each do |review| reviews.push(Review.new(review)) end return reviews end
[ "def", "reviews", "data", "=", "JSON", ".", "parse", "(", "@badfruit", ".", "get_movie_info", "(", "@id", ",", "\"reviews\"", ")", ")", "reviews", "=", "Array", ".", "new", "data", "[", "\"reviews\"", "]", ".", "each", "do", "|", "review", "|", "reviews", ".", "push", "(", "Review", ".", "new", "(", "review", ")", ")", "end", "return", "reviews", "end" ]
Get all of the reivews for a movie. @return [Array<BadFruit::Review>] A list of review for the movie.
[ "Get", "all", "of", "the", "reivews", "for", "a", "movie", "." ]
dab9c28d4bcd79d64829239abf6a816bbbcc73a6
https://github.com/brianmichel/BadFruit/blob/dab9c28d4bcd79d64829239abf6a816bbbcc73a6/lib/badfruit/Movies/movie.rb#L97-L104
train
razor-x/config_curator
lib/config_curator/collection.rb
ConfigCurator.Collection.units
def units @units ||= {}.tap do |u| UNIT_TYPES.each do |type| k = type.to_s.pluralize.to_sym u[k] = [] next unless manifest next if manifest[k].nil? manifest[k].each { |v| u[k] << create_unit(type, attributes: v) } end end end
ruby
def units @units ||= {}.tap do |u| UNIT_TYPES.each do |type| k = type.to_s.pluralize.to_sym u[k] = [] next unless manifest next if manifest[k].nil? manifest[k].each { |v| u[k] << create_unit(type, attributes: v) } end end end
[ "def", "units", "@units", "||=", "{", "}", ".", "tap", "do", "|", "u", "|", "UNIT_TYPES", ".", "each", "do", "|", "type", "|", "k", "=", "type", ".", "to_s", ".", "pluralize", ".", "to_sym", "u", "[", "k", "]", "=", "[", "]", "next", "unless", "manifest", "next", "if", "manifest", "[", "k", "]", ".", "nil?", "manifest", "[", "k", "]", ".", "each", "{", "|", "v", "|", "u", "[", "k", "]", "<<", "create_unit", "(", "type", ",", "attributes", ":", "v", ")", "}", "end", "end", "end" ]
Unit objects defined by the manifest and organized by type. @return [Hash] keys are pluralized unit types from {UNIT_TYPES}
[ "Unit", "objects", "defined", "by", "the", "manifest", "and", "organized", "by", "type", "." ]
b0c0742ba0c36acf66de3eafd23a7d17b210036b
https://github.com/razor-x/config_curator/blob/b0c0742ba0c36acf66de3eafd23a7d17b210036b/lib/config_curator/collection.rb#L49-L61
train
razor-x/config_curator
lib/config_curator/collection.rb
ConfigCurator.Collection.install
def install return false unless install? quiet: !(logger.level == Logger::DEBUG) UNIT_TYPES.each do |type| units[type.to_s.pluralize.to_sym].each do |unit| return nil unless install_unit(unit, type) end end true end
ruby
def install return false unless install? quiet: !(logger.level == Logger::DEBUG) UNIT_TYPES.each do |type| units[type.to_s.pluralize.to_sym].each do |unit| return nil unless install_unit(unit, type) end end true end
[ "def", "install", "return", "false", "unless", "install?", "quiet", ":", "!", "(", "logger", ".", "level", "==", "Logger", "::", "DEBUG", ")", "UNIT_TYPES", ".", "each", "do", "|", "type", "|", "units", "[", "type", ".", "to_s", ".", "pluralize", ".", "to_sym", "]", ".", "each", "do", "|", "unit", "|", "return", "nil", "unless", "install_unit", "(", "unit", ",", "type", ")", "end", "end", "true", "end" ]
Installs all units from the manifest. @return [Boolean, nil] if units were installed or nil if fails mid-install
[ "Installs", "all", "units", "from", "the", "manifest", "." ]
b0c0742ba0c36acf66de3eafd23a7d17b210036b
https://github.com/razor-x/config_curator/blob/b0c0742ba0c36acf66de3eafd23a7d17b210036b/lib/config_curator/collection.rb#L65-L74
train
razor-x/config_curator
lib/config_curator/collection.rb
ConfigCurator.Collection.install?
def install?(quiet: false) result = true UNIT_TYPES.each do |type| units[type.to_s.pluralize.to_sym].each do |unit| result = install_unit?(unit, type, quiet) ? result : false end end result end
ruby
def install?(quiet: false) result = true UNIT_TYPES.each do |type| units[type.to_s.pluralize.to_sym].each do |unit| result = install_unit?(unit, type, quiet) ? result : false end end result end
[ "def", "install?", "(", "quiet", ":", "false", ")", "result", "=", "true", "UNIT_TYPES", ".", "each", "do", "|", "type", "|", "units", "[", "type", ".", "to_s", ".", "pluralize", ".", "to_sym", "]", ".", "each", "do", "|", "unit", "|", "result", "=", "install_unit?", "(", "unit", ",", "type", ",", "quiet", ")", "?", "result", ":", "false", "end", "end", "result", "end" ]
Checks all units in the manifest for any detectable install issues. @param quiet [Boolean] suppress some {#logger} output @return [Boolean] if units can be installed
[ "Checks", "all", "units", "in", "the", "manifest", "for", "any", "detectable", "install", "issues", "." ]
b0c0742ba0c36acf66de3eafd23a7d17b210036b
https://github.com/razor-x/config_curator/blob/b0c0742ba0c36acf66de3eafd23a7d17b210036b/lib/config_curator/collection.rb#L79-L87
train