id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,000 | whazzmaster/fitgem | lib/fitgem/notifications.rb | Fitgem.Client.remove_subscription | def remove_subscription(opts)
resp = raw_delete make_subscription_url(opts.merge({:use_subscription_id => true})), make_headers(opts)
[resp.status, extract_response_body(resp)]
end | ruby | def remove_subscription(opts)
resp = raw_delete make_subscription_url(opts.merge({:use_subscription_id => true})), make_headers(opts)
[resp.status, extract_response_body(resp)]
end | [
"def",
"remove_subscription",
"(",
"opts",
")",
"resp",
"=",
"raw_delete",
"make_subscription_url",
"(",
"opts",
".",
"merge",
"(",
"{",
":use_subscription_id",
"=>",
"true",
"}",
")",
")",
",",
"make_headers",
"(",
"opts",
")",
"[",
"resp",
".",
"status",
... | Removes a notification subscription
@note You must check the HTTP response code to check the status of the request to remove a subscription. See {https://wiki.fitbit.com/display/API/Fitbit+Subscriptions+API} for information about what the codes mean.
@param [Hash] opts The notification subscription data
@option o... | [
"Removes",
"a",
"notification",
"subscription"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/notifications.rb#L50-L53 |
20,001 | whazzmaster/fitgem | lib/fitgem/notifications.rb | Fitgem.Client.validate_subscription_type | def validate_subscription_type(subscription_type)
unless subscription_type && SUBSCRIBABLE_TYPES.include?(subscription_type)
raise Fitgem::InvalidArgumentError, "Invalid subscription type (valid values are #{SUBSCRIBABLE_TYPES.join(', ')})"
end
true
end | ruby | def validate_subscription_type(subscription_type)
unless subscription_type && SUBSCRIBABLE_TYPES.include?(subscription_type)
raise Fitgem::InvalidArgumentError, "Invalid subscription type (valid values are #{SUBSCRIBABLE_TYPES.join(', ')})"
end
true
end | [
"def",
"validate_subscription_type",
"(",
"subscription_type",
")",
"unless",
"subscription_type",
"&&",
"SUBSCRIBABLE_TYPES",
".",
"include?",
"(",
"subscription_type",
")",
"raise",
"Fitgem",
"::",
"InvalidArgumentError",
",",
"\"Invalid subscription type (valid values are #{... | Ensures that the type supplied is valid
@param [Symbol] subscription_type The type of subscription;
valid values are (:sleep, :body, :activities, :foods, and
:all)
@raise [Fitgem::InvalidArgumentError] Raised if the supplied type
is not valid
@return [Boolean] | [
"Ensures",
"that",
"the",
"type",
"supplied",
"is",
"valid"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/notifications.rb#L65-L70 |
20,002 | whazzmaster/fitgem | lib/fitgem/notifications.rb | Fitgem.Client.make_subscription_url | def make_subscription_url(opts)
validate_subscription_type opts[:type]
path = if opts[:type] == :all
""
else
"/"+opts[:type].to_s
end
url = "/user/#{@user_id}#{path}/apiSubscriptions"
if opts[:use_subscription_id]
unless opts[:subscription_id]
raise ... | ruby | def make_subscription_url(opts)
validate_subscription_type opts[:type]
path = if opts[:type] == :all
""
else
"/"+opts[:type].to_s
end
url = "/user/#{@user_id}#{path}/apiSubscriptions"
if opts[:use_subscription_id]
unless opts[:subscription_id]
raise ... | [
"def",
"make_subscription_url",
"(",
"opts",
")",
"validate_subscription_type",
"opts",
"[",
":type",
"]",
"path",
"=",
"if",
"opts",
"[",
":type",
"]",
"==",
":all",
"\"\"",
"else",
"\"/\"",
"+",
"opts",
"[",
":type",
"]",
".",
"to_s",
"end",
"url",
"="... | Create the subscription management API url
@param [Hash] opts The options on how to construct the
subscription API url
@option opts [Symbol] :type The type of subscription;
valid values are (:sleep, :body, :activities, :foods, and
:all)
@option opts [Symbol] :use_subscription_id If true, then
opts[:subs... | [
"Create",
"the",
"subscription",
"management",
"API",
"url"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/notifications.rb#L103-L118 |
20,003 | whazzmaster/fitgem | lib/fitgem/body_measurements.rb | Fitgem.Client.log_weight | def log_weight(weight, date, opts={})
opts[:time] = format_time(opts[:time]) if opts[:time]
post("/user/#{@user_id}/body/log/weight.json", opts.merge(:weight => weight, :date => format_date(date)))
end | ruby | def log_weight(weight, date, opts={})
opts[:time] = format_time(opts[:time]) if opts[:time]
post("/user/#{@user_id}/body/log/weight.json", opts.merge(:weight => weight, :date => format_date(date)))
end | [
"def",
"log_weight",
"(",
"weight",
",",
"date",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"[",
":time",
"]",
"=",
"format_time",
"(",
"opts",
"[",
":time",
"]",
")",
"if",
"opts",
"[",
":time",
"]",
"post",
"(",
"\"/user/#{@user_id}/body/log/weight.json\... | Log weight to fitbit for the current user
@param [Integer, String] weight The weight to log, as either
an integer or a string in "X.XX'" format
@param [DateTime, String] date The date the weight should be
logged, as either a DateTime or a String in 'yyyy-MM-dd' format
@options opts [DateTime, String] :time T... | [
"Log",
"weight",
"to",
"fitbit",
"for",
"the",
"current",
"user"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/body_measurements.rb#L121-L124 |
20,004 | whazzmaster/fitgem | lib/fitgem/body_measurements.rb | Fitgem.Client.log_body_fat | def log_body_fat(fatPercentage, date, opts={})
opts[:fat] = fatPercentage
opts[:date] = format_date(date)
opts[:time] = format_time(opts[:time]) if opts[:time]
post("/user/#{@user_id}/body/fat.json", opts)
end | ruby | def log_body_fat(fatPercentage, date, opts={})
opts[:fat] = fatPercentage
opts[:date] = format_date(date)
opts[:time] = format_time(opts[:time]) if opts[:time]
post("/user/#{@user_id}/body/fat.json", opts)
end | [
"def",
"log_body_fat",
"(",
"fatPercentage",
",",
"date",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"[",
":fat",
"]",
"=",
"fatPercentage",
"opts",
"[",
":date",
"]",
"=",
"format_date",
"(",
"date",
")",
"opts",
"[",
":time",
"]",
"=",
"format_time",
... | Log body fat percentage
@param [Decimal, Integer, String] fatPercentage Body fat percentage to log,
in format "X.XX" if a string
@param [DateTime, Date, String] date The date to log body fat percentage on,
in format "yyyy-MM-dd" if a string
@param [Hash] opts
@option opts [DateTime, Time, String] :time The t... | [
"Log",
"body",
"fat",
"percentage"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/body_measurements.rb#L137-L142 |
20,005 | whazzmaster/fitgem | lib/fitgem/body_measurements.rb | Fitgem.Client.create_or_update_body_weight_goal | def create_or_update_body_weight_goal(startDate, startWeight, goalWeight)
opts = {startDate: format_date(startDate), startWeight: startWeight, weight: goalWeight}
post("/user/#{@user_id}/body/log/weight/goal.json", opts)
end | ruby | def create_or_update_body_weight_goal(startDate, startWeight, goalWeight)
opts = {startDate: format_date(startDate), startWeight: startWeight, weight: goalWeight}
post("/user/#{@user_id}/body/log/weight/goal.json", opts)
end | [
"def",
"create_or_update_body_weight_goal",
"(",
"startDate",
",",
"startWeight",
",",
"goalWeight",
")",
"opts",
"=",
"{",
"startDate",
":",
"format_date",
"(",
"startDate",
")",
",",
"startWeight",
":",
"startWeight",
",",
"weight",
":",
"goalWeight",
"}",
"po... | Create or update a user's weight goal
@param [DateTime, Date, String] startDate Weight goal start date;
in the format "yyyy-MM-dd" if a string
@param [Decimal, Integer, String] startWeight Weight goal start weight;
in the format "X.XX" if a string
@param [Decimal, Integer, String] goalWeight Weight goal targe... | [
"Create",
"or",
"update",
"a",
"user",
"s",
"weight",
"goal"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/body_measurements.rb#L154-L157 |
20,006 | whazzmaster/fitgem | lib/fitgem/body_measurements.rb | Fitgem.Client.determine_body_uri | def determine_body_uri(base_uri, opts = {})
if opts[:date]
date = format_date opts[:date]
"#{base_uri}/date/#{date}.json"
elsif opts[:base_date] && (opts[:period] || opts[:end_date])
date_range = construct_date_range_fragment opts
"#{base_uri}/#{date_range}.json"
else
... | ruby | def determine_body_uri(base_uri, opts = {})
if opts[:date]
date = format_date opts[:date]
"#{base_uri}/date/#{date}.json"
elsif opts[:base_date] && (opts[:period] || opts[:end_date])
date_range = construct_date_range_fragment opts
"#{base_uri}/#{date_range}.json"
else
... | [
"def",
"determine_body_uri",
"(",
"base_uri",
",",
"opts",
"=",
"{",
"}",
")",
"if",
"opts",
"[",
":date",
"]",
"date",
"=",
"format_date",
"opts",
"[",
":date",
"]",
"\"#{base_uri}/date/#{date}.json\"",
"elsif",
"opts",
"[",
":base_date",
"]",
"&&",
"(",
... | Determine the URI for the body_weight or body_fat method
@params [String] base_uri the base URI for the body weight or body fat method
@params [Hash] opts body weight/fat options
@option opts [Date] date The date in the format YYYY-mm-dd.
@option opts [Date] base-date The end date when period is provided, in the
... | [
"Determine",
"the",
"URI",
"for",
"the",
"body_weight",
"or",
"body_fat",
"method"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/body_measurements.rb#L206-L216 |
20,007 | whazzmaster/fitgem | lib/fitgem/activities.rb | Fitgem.Client.create_or_update_weekly_goal | def create_or_update_weekly_goal(opts)
unless opts[:type] && [:steps, :distance, :floors].include?(opts[:type])
raise InvalidArgumentError, 'Must specify type in order to create or update a weekly goal. One of (:steps, :distance, or :floors) is required.'
end
unless opts[:value]
raise... | ruby | def create_or_update_weekly_goal(opts)
unless opts[:type] && [:steps, :distance, :floors].include?(opts[:type])
raise InvalidArgumentError, 'Must specify type in order to create or update a weekly goal. One of (:steps, :distance, or :floors) is required.'
end
unless opts[:value]
raise... | [
"def",
"create_or_update_weekly_goal",
"(",
"opts",
")",
"unless",
"opts",
"[",
":type",
"]",
"&&",
"[",
":steps",
",",
":distance",
",",
":floors",
"]",
".",
"include?",
"(",
"opts",
"[",
":type",
"]",
")",
"raise",
"InvalidArgumentError",
",",
"'Must speci... | Create or update a user's weekly goal
@param [Hash] :opts
@option opts [Symbol] :type The type of goal to create or update; must be one of
:steps, :distance, or :floors. REQUIRED
@option opts [Decimal, Integer, String] :value The goal value; in the format 'X.XX'
if a string. REQUIRED
@since v0.9.0 | [
"Create",
"or",
"update",
"a",
"user",
"s",
"weekly",
"goal"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/activities.rb#L192-L202 |
20,008 | whazzmaster/fitgem | lib/fitgem/alarms.rb | Fitgem.Client.update_alarm | def update_alarm(alarm_id, device_id, opts)
opts[:time] = format_time opts[:time], include_timezone: true
post("/user/#{@user_id}/devices/tracker/#{device_id}/alarms/#{alarm_id}.json", opts)
end | ruby | def update_alarm(alarm_id, device_id, opts)
opts[:time] = format_time opts[:time], include_timezone: true
post("/user/#{@user_id}/devices/tracker/#{device_id}/alarms/#{alarm_id}.json", opts)
end | [
"def",
"update_alarm",
"(",
"alarm_id",
",",
"device_id",
",",
"opts",
")",
"opts",
"[",
":time",
"]",
"=",
"format_time",
"opts",
"[",
":time",
"]",
",",
"include_timezone",
":",
"true",
"post",
"(",
"\"/user/#{@user_id}/devices/tracker/#{device_id}/alarms/#{alarm_... | Update an existing alarm
@param [Integer, String] alarm_id The id of the alarm
@param [Integer, String] device_id The id of the device you would like to
manage the alarm on
@param [Hash] opts Alarm settings
@option opts [DateTime, Time, String] :time Time of the alarm
@option opts [TrueClass, FalseClass] :enab... | [
"Update",
"an",
"existing",
"alarm"
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/alarms.rb#L61-L64 |
20,009 | whazzmaster/fitgem | lib/fitgem/helpers.rb | Fitgem.Client.format_time | def format_time(time, opts = {})
format = opts[:include_timezone] ? "%H:%M%:z" : "%H:%M"
if time.is_a? String
case time
when 'now'
return DateTime.now.strftime format
else
unless time =~ /^\d{2}\:\d{2}$/
raise Fitgem::InvalidTimeArgument, "In... | ruby | def format_time(time, opts = {})
format = opts[:include_timezone] ? "%H:%M%:z" : "%H:%M"
if time.is_a? String
case time
when 'now'
return DateTime.now.strftime format
else
unless time =~ /^\d{2}\:\d{2}$/
raise Fitgem::InvalidTimeArgument, "In... | [
"def",
"format_time",
"(",
"time",
",",
"opts",
"=",
"{",
"}",
")",
"format",
"=",
"opts",
"[",
":include_timezone",
"]",
"?",
"\"%H:%M%:z\"",
":",
"\"%H:%M\"",
"if",
"time",
".",
"is_a?",
"String",
"case",
"time",
"when",
"'now'",
"return",
"DateTime",
... | Format any of a variety of time-related types into the formatted string
required when using the fitbit API.
The time parameter can take several different kind of objects: a DateTime object,
a Time object, or a String Object. Furthermore, the string object may be either
the date in a preformatted string ("HH:mm"),... | [
"Format",
"any",
"of",
"a",
"variety",
"of",
"time",
"-",
"related",
"types",
"into",
"the",
"formatted",
"string",
"required",
"when",
"using",
"the",
"fitbit",
"API",
"."
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/helpers.rb#L51-L69 |
20,010 | whazzmaster/fitgem | lib/fitgem/helpers.rb | Fitgem.Client.label_for_measurement | def label_for_measurement(measurement_type, respect_user_unit_preferences=true)
unless [:duration, :distance, :elevation, :height, :weight, :measurements, :liquids, :blood_glucose].include?(measurement_type)
raise InvalidMeasurementType, "Supplied measurement_type parameter must be one of [:duration, :dis... | ruby | def label_for_measurement(measurement_type, respect_user_unit_preferences=true)
unless [:duration, :distance, :elevation, :height, :weight, :measurements, :liquids, :blood_glucose].include?(measurement_type)
raise InvalidMeasurementType, "Supplied measurement_type parameter must be one of [:duration, :dis... | [
"def",
"label_for_measurement",
"(",
"measurement_type",
",",
"respect_user_unit_preferences",
"=",
"true",
")",
"unless",
"[",
":duration",
",",
":distance",
",",
":elevation",
",",
":height",
",",
":weight",
",",
":measurements",
",",
":liquids",
",",
":blood_gluc... | Fetch the correct label for the desired measurement unit.
The general use case for this method is that you are using the client for
a specific user, and wish to get the correct labels for the unit measurements
returned for that user.
A secondary use case is that you wish to get the label for a measurement given a... | [
"Fetch",
"the",
"correct",
"label",
"for",
"the",
"desired",
"measurement",
"unit",
"."
] | c8c4fc908feee91bb138e518f6882507b3067ae1 | https://github.com/whazzmaster/fitgem/blob/c8c4fc908feee91bb138e518f6882507b3067ae1/lib/fitgem/helpers.rb#L96-L135 |
20,011 | grosser/gettext_i18n_rails | lib/gettext_i18n_rails/model_attributes_finder.rb | GettextI18nRails.ModelAttributesFinder.table_name_to_namespaced_model | def table_name_to_namespaced_model(table_name)
# First assume that there are no namespaces
model = to_class(table_name.singularize.camelcase)
return model if model != nil
# If you were wrong, assume that the model is in a namespace.
# Iterate over the underscores and try to substitute eac... | ruby | def table_name_to_namespaced_model(table_name)
# First assume that there are no namespaces
model = to_class(table_name.singularize.camelcase)
return model if model != nil
# If you were wrong, assume that the model is in a namespace.
# Iterate over the underscores and try to substitute eac... | [
"def",
"table_name_to_namespaced_model",
"(",
"table_name",
")",
"# First assume that there are no namespaces",
"model",
"=",
"to_class",
"(",
"table_name",
".",
"singularize",
".",
"camelcase",
")",
"return",
"model",
"if",
"model",
"!=",
"nil",
"# If you were wrong, ass... | Tries to find the model class corresponding to specified table name.
Takes into account that the model can be defined in a namespace.
Searches only up to one level deep - won't find models nested in two
or more modules.
Note that if we allow namespaces, the conversion can be ambiguous, i.e.
if the table is named ... | [
"Tries",
"to",
"find",
"the",
"model",
"class",
"corresponding",
"to",
"specified",
"table",
"name",
".",
"Takes",
"into",
"account",
"that",
"the",
"model",
"can",
"be",
"defined",
"in",
"a",
"namespace",
".",
"Searches",
"only",
"up",
"to",
"one",
"level... | decc53ed0f2084b77b82969e2275b37cd854eddb | https://github.com/grosser/gettext_i18n_rails/blob/decc53ed0f2084b77b82969e2275b37cd854eddb/lib/gettext_i18n_rails/model_attributes_finder.rb#L102-L123 |
20,012 | grosser/gettext_i18n_rails | lib/gettext_i18n_rails/model_attributes_finder.rb | GettextI18nRails.ModelAttributesFinder.to_class | def to_class(name)
# I wanted to use Module.const_defined?() here to avoid relying
# on exceptions for normal program flow but it's of no use.
# If class autoloading is enabled, the constant may be undefined
# but turn out to be present when we actually try to use it.
begin
constan... | ruby | def to_class(name)
# I wanted to use Module.const_defined?() here to avoid relying
# on exceptions for normal program flow but it's of no use.
# If class autoloading is enabled, the constant may be undefined
# but turn out to be present when we actually try to use it.
begin
constan... | [
"def",
"to_class",
"(",
"name",
")",
"# I wanted to use Module.const_defined?() here to avoid relying",
"# on exceptions for normal program flow but it's of no use.",
"# If class autoloading is enabled, the constant may be undefined",
"# but turn out to be present when we actually try to use it.",
... | Checks if there is a class of specified name and if so, returns
the class object. Otherwise returns nil. | [
"Checks",
"if",
"there",
"is",
"a",
"class",
"of",
"specified",
"name",
"and",
"if",
"so",
"returns",
"the",
"class",
"object",
".",
"Otherwise",
"returns",
"nil",
"."
] | decc53ed0f2084b77b82969e2275b37cd854eddb | https://github.com/grosser/gettext_i18n_rails/blob/decc53ed0f2084b77b82969e2275b37cd854eddb/lib/gettext_i18n_rails/model_attributes_finder.rb#L127-L142 |
20,013 | YorickPeterse/ruby-ll | lib/ll/compiled_grammar.rb | LL.CompiledGrammar.display_messages | def display_messages
[:errors, :warnings].each do |type|
send(type).each do |msg|
output.puts(msg.to_s)
end
end
end | ruby | def display_messages
[:errors, :warnings].each do |type|
send(type).each do |msg|
output.puts(msg.to_s)
end
end
end | [
"def",
"display_messages",
"[",
":errors",
",",
":warnings",
"]",
".",
"each",
"do",
"|",
"type",
"|",
"send",
"(",
"type",
")",
".",
"each",
"do",
"|",
"msg",
"|",
"output",
".",
"puts",
"(",
"msg",
".",
"to_s",
")",
"end",
"end",
"end"
] | Displays all warnings and errors. | [
"Displays",
"all",
"warnings",
"and",
"errors",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/compiled_grammar.rb#L152-L158 |
20,014 | YorickPeterse/ruby-ll | lib/ll/configuration_compiler.rb | LL.ConfigurationCompiler.generate_rules | def generate_rules(grammar)
rules = []
action_index = 0
rule_indices = grammar.rule_indices
term_indices = grammar.terminal_indices
grammar.rules.each_with_index do |rule, rule_index|
rule.branches.each do |branch|
row = [TYPES[:action], action_index]
a... | ruby | def generate_rules(grammar)
rules = []
action_index = 0
rule_indices = grammar.rule_indices
term_indices = grammar.terminal_indices
grammar.rules.each_with_index do |rule, rule_index|
rule.branches.each do |branch|
row = [TYPES[:action], action_index]
a... | [
"def",
"generate_rules",
"(",
"grammar",
")",
"rules",
"=",
"[",
"]",
"action_index",
"=",
"0",
"rule_indices",
"=",
"grammar",
".",
"rule_indices",
"term_indices",
"=",
"grammar",
".",
"terminal_indices",
"grammar",
".",
"rules",
".",
"each_with_index",
"do",
... | Builds the rules table of the parser. Each row is built in reverse order.
@param [LL::CompiledGrammar] grammar
@return [Array] | [
"Builds",
"the",
"rules",
"table",
"of",
"the",
"parser",
".",
"Each",
"row",
"is",
"built",
"in",
"reverse",
"order",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/configuration_compiler.rb#L149-L190 |
20,015 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.warn_for_unused_rules | def warn_for_unused_rules(compiled_grammar)
compiled_grammar.rules.each_with_index do |rule, index|
next if index == 0 || rule.references > 0
compiled_grammar.add_warning(
"Unused rule #{rule.name.inspect}",
rule.source_line
)
end
end | ruby | def warn_for_unused_rules(compiled_grammar)
compiled_grammar.rules.each_with_index do |rule, index|
next if index == 0 || rule.references > 0
compiled_grammar.add_warning(
"Unused rule #{rule.name.inspect}",
rule.source_line
)
end
end | [
"def",
"warn_for_unused_rules",
"(",
"compiled_grammar",
")",
"compiled_grammar",
".",
"rules",
".",
"each_with_index",
"do",
"|",
"rule",
",",
"index",
"|",
"next",
"if",
"index",
"==",
"0",
"||",
"rule",
".",
"references",
">",
"0",
"compiled_grammar",
".",
... | Adds warnings for any unused rules. The first defined rule is skipped
since it's the root rule.
@param [LL::CompiledGrammar] compiled_grammar | [
"Adds",
"warnings",
"for",
"any",
"unused",
"rules",
".",
"The",
"first",
"defined",
"rule",
"is",
"skipped",
"since",
"it",
"s",
"the",
"root",
"rule",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L42-L51 |
20,016 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.warn_for_unused_terminals | def warn_for_unused_terminals(compiled_grammar)
compiled_grammar.terminals.each do |terminal|
next if terminal.references > 0
compiled_grammar.add_warning(
"Unused terminal #{terminal.name.inspect}",
terminal.source_line
)
end
end | ruby | def warn_for_unused_terminals(compiled_grammar)
compiled_grammar.terminals.each do |terminal|
next if terminal.references > 0
compiled_grammar.add_warning(
"Unused terminal #{terminal.name.inspect}",
terminal.source_line
)
end
end | [
"def",
"warn_for_unused_terminals",
"(",
"compiled_grammar",
")",
"compiled_grammar",
".",
"terminals",
".",
"each",
"do",
"|",
"terminal",
"|",
"next",
"if",
"terminal",
".",
"references",
">",
"0",
"compiled_grammar",
".",
"add_warning",
"(",
"\"Unused terminal #{... | Adds warnings for any unused terminals.
@param [LL::CompiledGrammar] compiled_grammar | [
"Adds",
"warnings",
"for",
"any",
"unused",
"terminals",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L58-L67 |
20,017 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.on_grammar | def on_grammar(node, compiled_grammar)
# Create the prototypes for all rules since rules can be referenced before
# they are defined.
node.children.each do |child|
if child.type == :rule
on_rule_prototype(child, compiled_grammar)
end
end
node.children.each do |ch... | ruby | def on_grammar(node, compiled_grammar)
# Create the prototypes for all rules since rules can be referenced before
# they are defined.
node.children.each do |child|
if child.type == :rule
on_rule_prototype(child, compiled_grammar)
end
end
node.children.each do |ch... | [
"def",
"on_grammar",
"(",
"node",
",",
"compiled_grammar",
")",
"# Create the prototypes for all rules since rules can be referenced before",
"# they are defined.",
"node",
".",
"children",
".",
"each",
"do",
"|",
"child",
"|",
"if",
"child",
".",
"type",
"==",
":rule",... | Processes the root node of a grammar.
@param [LL::AST::Node] node
@param [LL::CompiledGrammar] compiled_grammar | [
"Processes",
"the",
"root",
"node",
"of",
"a",
"grammar",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L146-L158 |
20,018 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.on_name | def on_name(node, compiled_grammar)
if compiled_grammar.name
compiled_grammar.add_warning(
"Overwriting existing parser name #{compiled_grammar.name.inspect}",
node.source_line
)
end
parts = node.children.map { |child| process(child, compiled_grammar) }
comp... | ruby | def on_name(node, compiled_grammar)
if compiled_grammar.name
compiled_grammar.add_warning(
"Overwriting existing parser name #{compiled_grammar.name.inspect}",
node.source_line
)
end
parts = node.children.map { |child| process(child, compiled_grammar) }
comp... | [
"def",
"on_name",
"(",
"node",
",",
"compiled_grammar",
")",
"if",
"compiled_grammar",
".",
"name",
"compiled_grammar",
".",
"add_warning",
"(",
"\"Overwriting existing parser name #{compiled_grammar.name.inspect}\"",
",",
"node",
".",
"source_line",
")",
"end",
"parts",
... | Sets the name of the parser.
@param [LL::AST::Node] node
@param [LL::CompiledGrammar] compiled_grammar | [
"Sets",
"the",
"name",
"of",
"the",
"parser",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L166-L177 |
20,019 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.on_terminals | def on_terminals(node, compiled_grammar)
node.children.each do |child|
name = process(child, compiled_grammar)
if compiled_grammar.has_terminal?(name)
compiled_grammar.add_error(
"The terminal #{name.inspect} has already been defined",
child.source_line
... | ruby | def on_terminals(node, compiled_grammar)
node.children.each do |child|
name = process(child, compiled_grammar)
if compiled_grammar.has_terminal?(name)
compiled_grammar.add_error(
"The terminal #{name.inspect} has already been defined",
child.source_line
... | [
"def",
"on_terminals",
"(",
"node",
",",
"compiled_grammar",
")",
"node",
".",
"children",
".",
"each",
"do",
"|",
"child",
"|",
"name",
"=",
"process",
"(",
"child",
",",
"compiled_grammar",
")",
"if",
"compiled_grammar",
".",
"has_terminal?",
"(",
"name",
... | Processes the assignment of terminals.
@see [#process] | [
"Processes",
"the",
"assignment",
"of",
"terminals",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L184-L197 |
20,020 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.on_rule | def on_rule(node, compiled_grammar)
name = process(node.children[0], compiled_grammar)
if compiled_grammar.has_terminal?(name)
compiled_grammar.add_error(
"the rule name #{name.inspect} is already used as a terminal name",
node.source_line
)
end
if compiled_... | ruby | def on_rule(node, compiled_grammar)
name = process(node.children[0], compiled_grammar)
if compiled_grammar.has_terminal?(name)
compiled_grammar.add_error(
"the rule name #{name.inspect} is already used as a terminal name",
node.source_line
)
end
if compiled_... | [
"def",
"on_rule",
"(",
"node",
",",
"compiled_grammar",
")",
"name",
"=",
"process",
"(",
"node",
".",
"children",
"[",
"0",
"]",
",",
"compiled_grammar",
")",
"if",
"compiled_grammar",
".",
"has_terminal?",
"(",
"name",
")",
"compiled_grammar",
".",
"add_er... | Processes the assignment of a rule.
@see [#process] | [
"Processes",
"the",
"assignment",
"of",
"a",
"rule",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L252-L278 |
20,021 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.on_rule_prototype | def on_rule_prototype(node, compiled_grammar)
name = process(node.children[0], compiled_grammar)
return if compiled_grammar.has_rule?(name)
rule = Rule.new(name, node.source_line)
compiled_grammar.add_rule(rule)
end | ruby | def on_rule_prototype(node, compiled_grammar)
name = process(node.children[0], compiled_grammar)
return if compiled_grammar.has_rule?(name)
rule = Rule.new(name, node.source_line)
compiled_grammar.add_rule(rule)
end | [
"def",
"on_rule_prototype",
"(",
"node",
",",
"compiled_grammar",
")",
"name",
"=",
"process",
"(",
"node",
".",
"children",
"[",
"0",
"]",
",",
"compiled_grammar",
")",
"return",
"if",
"compiled_grammar",
".",
"has_rule?",
"(",
"name",
")",
"rule",
"=",
"... | Creates a basic prototype for a rule.
@see [#process] | [
"Creates",
"a",
"basic",
"prototype",
"for",
"a",
"rule",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L285-L293 |
20,022 | YorickPeterse/ruby-ll | lib/ll/grammar_compiler.rb | LL.GrammarCompiler.on_branch | def on_branch(node, compiled_grammar)
steps = process(node.children[0], compiled_grammar)
if node.children[1]
code = process(node.children[1], compiled_grammar)
else
code = nil
end
return Branch.new(steps, node.source_line, code)
end | ruby | def on_branch(node, compiled_grammar)
steps = process(node.children[0], compiled_grammar)
if node.children[1]
code = process(node.children[1], compiled_grammar)
else
code = nil
end
return Branch.new(steps, node.source_line, code)
end | [
"def",
"on_branch",
"(",
"node",
",",
"compiled_grammar",
")",
"steps",
"=",
"process",
"(",
"node",
".",
"children",
"[",
"0",
"]",
",",
"compiled_grammar",
")",
"if",
"node",
".",
"children",
"[",
"1",
"]",
"code",
"=",
"process",
"(",
"node",
".",
... | Processes a single rule branch.
@see [#process]
@return [LL::Branch] | [
"Processes",
"a",
"single",
"rule",
"branch",
"."
] | 23f98a807c0bad24c10630818e955750b4cb2a63 | https://github.com/YorickPeterse/ruby-ll/blob/23f98a807c0bad24c10630818e955750b4cb2a63/lib/ll/grammar_compiler.rb#L301-L311 |
20,023 | hallidave/ruby-snmp | lib/snmp/pdu.rb | SNMP.SNMPv2_Trap.sys_up_time | def sys_up_time
varbind = @varbind_list[0]
if varbind && (varbind.name == SYS_UP_TIME_OID)
return varbind.value
else
raise InvalidTrapVarbind, "Expected sysUpTime.0, found " + varbind.to_s
end
end | ruby | def sys_up_time
varbind = @varbind_list[0]
if varbind && (varbind.name == SYS_UP_TIME_OID)
return varbind.value
else
raise InvalidTrapVarbind, "Expected sysUpTime.0, found " + varbind.to_s
end
end | [
"def",
"sys_up_time",
"varbind",
"=",
"@varbind_list",
"[",
"0",
"]",
"if",
"varbind",
"&&",
"(",
"varbind",
".",
"name",
"==",
"SYS_UP_TIME_OID",
")",
"return",
"varbind",
".",
"value",
"else",
"raise",
"InvalidTrapVarbind",
",",
"\"Expected sysUpTime.0, found \"... | Returns the value of the mandatory sysUpTime varbind for this trap.
Throws InvalidTrapVarbind if the sysUpTime varbind is not present. | [
"Returns",
"the",
"value",
"of",
"the",
"mandatory",
"sysUpTime",
"varbind",
"for",
"this",
"trap",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/pdu.rb#L286-L293 |
20,024 | hallidave/ruby-snmp | lib/snmp/pdu.rb | SNMP.SNMPv2_Trap.trap_oid | def trap_oid
varbind = @varbind_list[1]
if varbind && (varbind.name == SNMP_TRAP_OID_OID)
return varbind.value
else
raise InvalidTrapVarbind, "Expected snmpTrapOID.0, found " + varbind.to_s
end
end | ruby | def trap_oid
varbind = @varbind_list[1]
if varbind && (varbind.name == SNMP_TRAP_OID_OID)
return varbind.value
else
raise InvalidTrapVarbind, "Expected snmpTrapOID.0, found " + varbind.to_s
end
end | [
"def",
"trap_oid",
"varbind",
"=",
"@varbind_list",
"[",
"1",
"]",
"if",
"varbind",
"&&",
"(",
"varbind",
".",
"name",
"==",
"SNMP_TRAP_OID_OID",
")",
"return",
"varbind",
".",
"value",
"else",
"raise",
"InvalidTrapVarbind",
",",
"\"Expected snmpTrapOID.0, found \... | Returns the value of the mandatory snmpTrapOID varbind for this trap.
Throws InvalidTrapVarbind if the snmpTrapOID varbind is not present. | [
"Returns",
"the",
"value",
"of",
"the",
"mandatory",
"snmpTrapOID",
"varbind",
"for",
"this",
"trap",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/pdu.rb#L300-L307 |
20,025 | hallidave/ruby-snmp | lib/snmp/varbind.rb | SNMP.ObjectId.subtree_of? | def subtree_of?(parent_tree)
parent_tree = make_object_id(parent_tree)
if parent_tree.length > self.length
false
else
parent_tree.each_index do |i|
return false if parent_tree[i] != self[i]
end
true
end
end | ruby | def subtree_of?(parent_tree)
parent_tree = make_object_id(parent_tree)
if parent_tree.length > self.length
false
else
parent_tree.each_index do |i|
return false if parent_tree[i] != self[i]
end
true
end
end | [
"def",
"subtree_of?",
"(",
"parent_tree",
")",
"parent_tree",
"=",
"make_object_id",
"(",
"parent_tree",
")",
"if",
"parent_tree",
".",
"length",
">",
"self",
".",
"length",
"false",
"else",
"parent_tree",
".",
"each_index",
"do",
"|",
"i",
"|",
"return",
"f... | Returns true if this ObjectId is a subtree of the provided parent tree
ObjectId. For example, "1.3.6.1.5" is a subtree of "1.3.6.1". | [
"Returns",
"true",
"if",
"this",
"ObjectId",
"is",
"a",
"subtree",
"of",
"the",
"provided",
"parent",
"tree",
"ObjectId",
".",
"For",
"example",
"1",
".",
"3",
".",
"6",
".",
"1",
".",
"5",
"is",
"a",
"subtree",
"of",
"1",
".",
"3",
".",
"6",
"."... | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/varbind.rb#L226-L236 |
20,026 | hallidave/ruby-snmp | lib/snmp/varbind.rb | SNMP.ObjectId.index | def index(parent_tree)
parent_tree = make_object_id(parent_tree)
if not subtree_of?(parent_tree)
raise ArgumentError, "#{self.to_s} not a subtree of #{parent_tree.to_s}"
elsif self.length == parent_tree.length
raise ArgumentError, "OIDs are the same"
else
ObjectId.new(sel... | ruby | def index(parent_tree)
parent_tree = make_object_id(parent_tree)
if not subtree_of?(parent_tree)
raise ArgumentError, "#{self.to_s} not a subtree of #{parent_tree.to_s}"
elsif self.length == parent_tree.length
raise ArgumentError, "OIDs are the same"
else
ObjectId.new(sel... | [
"def",
"index",
"(",
"parent_tree",
")",
"parent_tree",
"=",
"make_object_id",
"(",
"parent_tree",
")",
"if",
"not",
"subtree_of?",
"(",
"parent_tree",
")",
"raise",
"ArgumentError",
",",
"\"#{self.to_s} not a subtree of #{parent_tree.to_s}\"",
"elsif",
"self",
".",
"... | Returns an index based on the difference between this ObjectId
and the provided parent ObjectId.
For example, ObjectId.new("1.3.6.1.5").index("1.3.6.1") returns an
ObjectId of "5". | [
"Returns",
"an",
"index",
"based",
"on",
"the",
"difference",
"between",
"this",
"ObjectId",
"and",
"the",
"provided",
"parent",
"ObjectId",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/varbind.rb#L245-L254 |
20,027 | hallidave/ruby-snmp | lib/snmp/mib.rb | SNMP.MIB.varbind_list | def varbind_list(object_list, option=:KeepValue)
raise ArgumentError, "A list of ObjectId or VarBind objects is NilClass" if object_list.nil?
vb_list = VarBindList.new
if object_list.respond_to? :to_str
vb_list << oid(object_list).to_varbind
elsif object_list.respond_to? :to_varbind
... | ruby | def varbind_list(object_list, option=:KeepValue)
raise ArgumentError, "A list of ObjectId or VarBind objects is NilClass" if object_list.nil?
vb_list = VarBindList.new
if object_list.respond_to? :to_str
vb_list << oid(object_list).to_varbind
elsif object_list.respond_to? :to_varbind
... | [
"def",
"varbind_list",
"(",
"object_list",
",",
"option",
"=",
":KeepValue",
")",
"raise",
"ArgumentError",
",",
"\"A list of ObjectId or VarBind objects is NilClass\"",
"if",
"object_list",
".",
"nil?",
"vb_list",
"=",
"VarBindList",
".",
"new",
"if",
"object_list",
... | Returns a VarBindList for the provided list of objects. If a
string is provided it is interpretted as a symbolic OID.
This method accepts many different kinds of objects:
- single string object IDs e.g. "1.3.6.1" or "IF-MIB::ifTable.1.1"
- single ObjectId
- list of string object IDs
- list of ObjectIds
- list ... | [
"Returns",
"a",
"VarBindList",
"for",
"the",
"provided",
"list",
"of",
"objects",
".",
"If",
"a",
"string",
"is",
"provided",
"it",
"is",
"interpretted",
"as",
"a",
"symbolic",
"OID",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/mib.rb#L186-L204 |
20,028 | hallidave/ruby-snmp | lib/snmp/mib.rb | SNMP.MIB.name | def name(oid)
current_oid = ObjectId.new(oid)
index = []
while current_oid.size > 1
name = @by_oid[current_oid.to_s]
if name
return index.empty? ? name : "#{name}.#{index.join('.')}"
end
index.unshift current_oid.slice!(-1)
end
ObjectId.new(oid).to... | ruby | def name(oid)
current_oid = ObjectId.new(oid)
index = []
while current_oid.size > 1
name = @by_oid[current_oid.to_s]
if name
return index.empty? ? name : "#{name}.#{index.join('.')}"
end
index.unshift current_oid.slice!(-1)
end
ObjectId.new(oid).to... | [
"def",
"name",
"(",
"oid",
")",
"current_oid",
"=",
"ObjectId",
".",
"new",
"(",
"oid",
")",
"index",
"=",
"[",
"]",
"while",
"current_oid",
".",
"size",
">",
"1",
"name",
"=",
"@by_oid",
"[",
"current_oid",
".",
"to_s",
"]",
"if",
"name",
"return",
... | Returns the symbolic name of the given OID.
e.g. OID "1.3.6.1.2.1.1.0" returns symbol "SNMPv2-MIB::system.0" | [
"Returns",
"the",
"symbolic",
"name",
"of",
"the",
"given",
"OID",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/mib.rb#L261-L272 |
20,029 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.get_next | def get_next(object_list)
varbind_list = @mib.varbind_list(object_list, :NullValue)
request = GetNextRequest.new(@@request_id.next, varbind_list)
try_request(request)
end | ruby | def get_next(object_list)
varbind_list = @mib.varbind_list(object_list, :NullValue)
request = GetNextRequest.new(@@request_id.next, varbind_list)
try_request(request)
end | [
"def",
"get_next",
"(",
"object_list",
")",
"varbind_list",
"=",
"@mib",
".",
"varbind_list",
"(",
"object_list",
",",
":NullValue",
")",
"request",
"=",
"GetNextRequest",
".",
"new",
"(",
"@@request_id",
".",
"next",
",",
"varbind_list",
")",
"try_request",
"... | Sends a get-next request for the supplied list of ObjectId or VarBind
objects.
Returns a Response PDU with the results of the request. | [
"Sends",
"a",
"get",
"-",
"next",
"request",
"for",
"the",
"supplied",
"list",
"of",
"ObjectId",
"or",
"VarBind",
"objects",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L280-L284 |
20,030 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.get_bulk | def get_bulk(non_repeaters, max_repetitions, object_list)
varbind_list = @mib.varbind_list(object_list, :NullValue)
request = GetBulkRequest.new(
@@request_id.next,
varbind_list,
non_repeaters,
max_repetitions)
try_request(request)
end | ruby | def get_bulk(non_repeaters, max_repetitions, object_list)
varbind_list = @mib.varbind_list(object_list, :NullValue)
request = GetBulkRequest.new(
@@request_id.next,
varbind_list,
non_repeaters,
max_repetitions)
try_request(request)
end | [
"def",
"get_bulk",
"(",
"non_repeaters",
",",
"max_repetitions",
",",
"object_list",
")",
"varbind_list",
"=",
"@mib",
".",
"varbind_list",
"(",
"object_list",
",",
":NullValue",
")",
"request",
"=",
"GetBulkRequest",
".",
"new",
"(",
"@@request_id",
".",
"next"... | Sends a get-bulk request. The non_repeaters parameter specifies
the number of objects in the object_list to be retrieved once. The
remaining objects in the list will be retrieved up to the number of
times specified by max_repetitions. | [
"Sends",
"a",
"get",
"-",
"bulk",
"request",
".",
"The",
"non_repeaters",
"parameter",
"specifies",
"the",
"number",
"of",
"objects",
"in",
"the",
"object_list",
"to",
"be",
"retrieved",
"once",
".",
"The",
"remaining",
"objects",
"in",
"the",
"list",
"will"... | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L292-L300 |
20,031 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.set | def set(object_list)
varbind_list = @mib.varbind_list(object_list, :KeepValue)
request = SetRequest.new(@@request_id.next, varbind_list)
try_request(request, @write_community)
end | ruby | def set(object_list)
varbind_list = @mib.varbind_list(object_list, :KeepValue)
request = SetRequest.new(@@request_id.next, varbind_list)
try_request(request, @write_community)
end | [
"def",
"set",
"(",
"object_list",
")",
"varbind_list",
"=",
"@mib",
".",
"varbind_list",
"(",
"object_list",
",",
":KeepValue",
")",
"request",
"=",
"SetRequest",
".",
"new",
"(",
"@@request_id",
".",
"next",
",",
"varbind_list",
")",
"try_request",
"(",
"re... | Sends a set request using the supplied list of VarBind objects.
Returns a Response PDU with the results of the request. | [
"Sends",
"a",
"set",
"request",
"using",
"the",
"supplied",
"list",
"of",
"VarBind",
"objects",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L307-L311 |
20,032 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.trap_v1 | def trap_v1(enterprise, agent_addr, generic_trap, specific_trap, timestamp, object_list=[])
vb_list = @mib.varbind_list(object_list, :KeepValue)
ent_oid = @mib.oid(enterprise)
agent_ip = IpAddress.new(agent_addr)
specific_int = Integer(specific_trap)
ticks = TimeTicks.new(timestamp)
... | ruby | def trap_v1(enterprise, agent_addr, generic_trap, specific_trap, timestamp, object_list=[])
vb_list = @mib.varbind_list(object_list, :KeepValue)
ent_oid = @mib.oid(enterprise)
agent_ip = IpAddress.new(agent_addr)
specific_int = Integer(specific_trap)
ticks = TimeTicks.new(timestamp)
... | [
"def",
"trap_v1",
"(",
"enterprise",
",",
"agent_addr",
",",
"generic_trap",
",",
"specific_trap",
",",
"timestamp",
",",
"object_list",
"=",
"[",
"]",
")",
"vb_list",
"=",
"@mib",
".",
"varbind_list",
"(",
"object_list",
",",
":KeepValue",
")",
"ent_oid",
"... | Sends an SNMPv1 style trap.
enterprise: The enterprise OID from the IANA assigned numbers
(http://www.iana.org/assignments/enterprise-numbers) as a String or
an ObjectId.
agent_addr: The IP address of the SNMP agent as a String or IpAddress.
generic_trap: The generic trap identifier. One of :coldStart,
:warmS... | [
"Sends",
"an",
"SNMPv1",
"style",
"trap",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L346-L354 |
20,033 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.trap_v2 | def trap_v2(sys_up_time, trap_oid, object_list=[])
vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
trap = SNMPv2_Trap.new(@@request_id.next, vb_list)
send_request(trap, @community, @host, @trap_port)
end | ruby | def trap_v2(sys_up_time, trap_oid, object_list=[])
vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
trap = SNMPv2_Trap.new(@@request_id.next, vb_list)
send_request(trap, @community, @host, @trap_port)
end | [
"def",
"trap_v2",
"(",
"sys_up_time",
",",
"trap_oid",
",",
"object_list",
"=",
"[",
"]",
")",
"vb_list",
"=",
"create_trap_vb_list",
"(",
"sys_up_time",
",",
"trap_oid",
",",
"object_list",
")",
"trap",
"=",
"SNMPv2_Trap",
".",
"new",
"(",
"@@request_id",
"... | Sends an SNMPv2c style trap.
sys_up_time: An integer respresenting the number of hundredths of
a second that this system has been up.
trap_oid: An ObjectId or String with the OID identifier for this
trap.
object_list: A list of additional varbinds to send with the trap. | [
"Sends",
"an",
"SNMPv2c",
"style",
"trap",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L367-L371 |
20,034 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.inform | def inform(sys_up_time, trap_oid, object_list=[])
vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
request = InformRequest.new(@@request_id.next, vb_list)
try_request(request, @community, @host, @trap_port)
end | ruby | def inform(sys_up_time, trap_oid, object_list=[])
vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
request = InformRequest.new(@@request_id.next, vb_list)
try_request(request, @community, @host, @trap_port)
end | [
"def",
"inform",
"(",
"sys_up_time",
",",
"trap_oid",
",",
"object_list",
"=",
"[",
"]",
")",
"vb_list",
"=",
"create_trap_vb_list",
"(",
"sys_up_time",
",",
"trap_oid",
",",
"object_list",
")",
"request",
"=",
"InformRequest",
".",
"new",
"(",
"@@request_id",... | Sends an inform request using the supplied varbind list.
sys_up_time: An integer respresenting the number of hundredths of
a second that this system has been up.
trap_oid: An ObjectId or String with the OID identifier for this
inform request.
object_list: A list of additional varbinds to send with the inform. | [
"Sends",
"an",
"inform",
"request",
"using",
"the",
"supplied",
"varbind",
"list",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L384-L388 |
20,035 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.create_trap_vb_list | def create_trap_vb_list(sys_up_time, trap_oid, object_list)
vb_args = @mib.varbind_list(object_list, :KeepValue)
uptime_vb = VarBind.new(SNMP::SYS_UP_TIME_OID, TimeTicks.new(sys_up_time.to_int))
trap_vb = VarBind.new(SNMP::SNMP_TRAP_OID_OID, @mib.oid(trap_oid))
VarBindList.new([uptime_vb, trap_v... | ruby | def create_trap_vb_list(sys_up_time, trap_oid, object_list)
vb_args = @mib.varbind_list(object_list, :KeepValue)
uptime_vb = VarBind.new(SNMP::SYS_UP_TIME_OID, TimeTicks.new(sys_up_time.to_int))
trap_vb = VarBind.new(SNMP::SNMP_TRAP_OID_OID, @mib.oid(trap_oid))
VarBindList.new([uptime_vb, trap_v... | [
"def",
"create_trap_vb_list",
"(",
"sys_up_time",
",",
"trap_oid",
",",
"object_list",
")",
"vb_args",
"=",
"@mib",
".",
"varbind_list",
"(",
"object_list",
",",
":KeepValue",
")",
"uptime_vb",
"=",
"VarBind",
".",
"new",
"(",
"SNMP",
"::",
"SYS_UP_TIME_OID",
... | Helper method for building VarBindList for trap and inform requests. | [
"Helper",
"method",
"for",
"building",
"VarBindList",
"for",
"trap",
"and",
"inform",
"requests",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L393-L398 |
20,036 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.walk | def walk(object_list, index_column=0)
raise ArgumentError, "expected a block to be given" unless block_given?
vb_list = @mib.varbind_list(object_list, :NullValue)
raise ArgumentError, "index_column is past end of varbind list" if index_column >= vb_list.length
is_single_vb = object_list.respond_... | ruby | def walk(object_list, index_column=0)
raise ArgumentError, "expected a block to be given" unless block_given?
vb_list = @mib.varbind_list(object_list, :NullValue)
raise ArgumentError, "index_column is past end of varbind list" if index_column >= vb_list.length
is_single_vb = object_list.respond_... | [
"def",
"walk",
"(",
"object_list",
",",
"index_column",
"=",
"0",
")",
"raise",
"ArgumentError",
",",
"\"expected a block to be given\"",
"unless",
"block_given?",
"vb_list",
"=",
"@mib",
".",
"varbind_list",
"(",
"object_list",
",",
":NullValue",
")",
"raise",
"A... | Walks a list of ObjectId or VarBind objects using get_next until
the response to the first OID in the list reaches the end of its
MIB subtree.
The varbinds from each get_next are yielded to the given block as
they are retrieved. The result is yielded as a VarBind when walking
a single object or as a VarBindList ... | [
"Walks",
"a",
"list",
"of",
"ObjectId",
"or",
"VarBind",
"objects",
"using",
"get_next",
"until",
"the",
"response",
"to",
"the",
"first",
"OID",
"in",
"the",
"list",
"reaches",
"the",
"end",
"of",
"its",
"MIB",
"subtree",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L433-L460 |
20,037 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.validate_row | def validate_row(vb_list, start_list, index_column)
start_vb = start_list[index_column]
index_vb = vb_list[index_column]
row_index = index_vb.name.index(start_vb.name)
vb_list.each_index do |i|
if i != index_column
expected_oid = start_list[i].name + row_index
if vb_l... | ruby | def validate_row(vb_list, start_list, index_column)
start_vb = start_list[index_column]
index_vb = vb_list[index_column]
row_index = index_vb.name.index(start_vb.name)
vb_list.each_index do |i|
if i != index_column
expected_oid = start_list[i].name + row_index
if vb_l... | [
"def",
"validate_row",
"(",
"vb_list",
",",
"start_list",
",",
"index_column",
")",
"start_vb",
"=",
"start_list",
"[",
"index_column",
"]",
"index_vb",
"=",
"vb_list",
"[",
"index_column",
"]",
"row_index",
"=",
"index_vb",
".",
"name",
".",
"index",
"(",
"... | Helper method for walk. Checks all of the VarBinds in vb_list to
make sure that the row indices match. If the row index does not
match the index column, then that varbind is replaced with a varbind
with a value of NoSuchInstance. | [
"Helper",
"method",
"for",
"walk",
".",
"Checks",
"all",
"of",
"the",
"VarBinds",
"in",
"vb_list",
"to",
"make",
"sure",
"that",
"the",
"row",
"indices",
"match",
".",
"If",
"the",
"row",
"index",
"does",
"not",
"match",
"the",
"index",
"column",
"then",... | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L468-L481 |
20,038 | hallidave/ruby-snmp | lib/snmp/manager.rb | SNMP.Manager.get_response | def get_response(request)
begin
data = @transport.recv(@max_bytes)
message = Message.decode(data, @mib)
response = message.pdu
end until request.request_id == response.request_id
response
end | ruby | def get_response(request)
begin
data = @transport.recv(@max_bytes)
message = Message.decode(data, @mib)
response = message.pdu
end until request.request_id == response.request_id
response
end | [
"def",
"get_response",
"(",
"request",
")",
"begin",
"data",
"=",
"@transport",
".",
"recv",
"(",
"@max_bytes",
")",
"message",
"=",
"Message",
".",
"decode",
"(",
"data",
",",
"@mib",
")",
"response",
"=",
"message",
".",
"pdu",
"end",
"until",
"request... | Wait until response arrives. Ignore responses with mismatched IDs;
these responses are typically from previous requests that timed out
or almost timed out. | [
"Wait",
"until",
"response",
"arrives",
".",
"Ignore",
"responses",
"with",
"mismatched",
"IDs",
";",
"these",
"responses",
"are",
"typically",
"from",
"previous",
"requests",
"that",
"timed",
"out",
"or",
"almost",
"timed",
"out",
"."
] | 4b9deda96f14f5a216e9743313cf100f9ed1da45 | https://github.com/hallidave/ruby-snmp/blob/4b9deda96f14f5a216e9743313cf100f9ed1da45/lib/snmp/manager.rb#L531-L538 |
20,039 | saucelabs/sauce_ruby | lib/sauce/config.rb | Sauce.Config.is_defined? | def is_defined? (top_mod, sub_mod = nil)
return_value = Object.const_defined? top_mod
unless !return_value || sub_mod.nil?
return_value = Object.const_get(top_mod).const_defined? sub_mod
end
return_value
end | ruby | def is_defined? (top_mod, sub_mod = nil)
return_value = Object.const_defined? top_mod
unless !return_value || sub_mod.nil?
return_value = Object.const_get(top_mod).const_defined? sub_mod
end
return_value
end | [
"def",
"is_defined?",
"(",
"top_mod",
",",
"sub_mod",
"=",
"nil",
")",
"return_value",
"=",
"Object",
".",
"const_defined?",
"top_mod",
"unless",
"!",
"return_value",
"||",
"sub_mod",
".",
"nil?",
"return_value",
"=",
"Object",
".",
"const_get",
"(",
"top_mod"... | Only here to be stubbed for testing. Gross. | [
"Only",
"here",
"to",
"be",
"stubbed",
"for",
"testing",
".",
"Gross",
"."
] | b1c4dab8516fb5e9c75ef16fb72b59b72c0ff0b0 | https://github.com/saucelabs/sauce_ruby/blob/b1c4dab8516fb5e9c75ef16fb72b59b72c0ff0b0/lib/sauce/config.rb#L325-L332 |
20,040 | saucelabs/sauce_ruby | lib/sauce/job.rb | Sauce.Job.build! | def build!(options)
# Massage JSON
options.each { |key,value| options[key] = false if options[key] == "false" }
@id = options["id"]
@owner = options["owner"]
@status = options["status"]
@error = options["error"]
@name = opti... | ruby | def build!(options)
# Massage JSON
options.each { |key,value| options[key] = false if options[key] == "false" }
@id = options["id"]
@owner = options["owner"]
@status = options["status"]
@error = options["error"]
@name = opti... | [
"def",
"build!",
"(",
"options",
")",
"# Massage JSON",
"options",
".",
"each",
"{",
"|",
"key",
",",
"value",
"|",
"options",
"[",
"key",
"]",
"=",
"false",
"if",
"options",
"[",
"key",
"]",
"==",
"\"false\"",
"}",
"@id",
"=",
"options",
"[",
"\"id\... | Sets all internal variables from a hash | [
"Sets",
"all",
"internal",
"variables",
"from",
"a",
"hash"
] | b1c4dab8516fb5e9c75ef16fb72b59b72c0ff0b0 | https://github.com/saucelabs/sauce_ruby/blob/b1c4dab8516fb5e9c75ef16fb72b59b72c0ff0b0/lib/sauce/job.rb#L134-L157 |
20,041 | ndbroadbent/turbo-sprockets-rails3 | lib/sprockets/static_non_digest_generator.rb | Sprockets.StaticNonDigestGenerator.generate | def generate
start_time = Time.now.to_f
env.each_logical_path do |logical_path|
if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
logical_path.sub!(/\/index\./, '.')
end
next unless compile_path?(logical_path)
if digest_path = @digests[logical_path]
... | ruby | def generate
start_time = Time.now.to_f
env.each_logical_path do |logical_path|
if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
logical_path.sub!(/\/index\./, '.')
end
next unless compile_path?(logical_path)
if digest_path = @digests[logical_path]
... | [
"def",
"generate",
"start_time",
"=",
"Time",
".",
"now",
".",
"to_f",
"env",
".",
"each_logical_path",
"do",
"|",
"logical_path",
"|",
"if",
"File",
".",
"basename",
"(",
"logical_path",
")",
"[",
"/",
"\\.",
"/",
",",
"0",
"]",
"==",
"'index'",
"logi... | Generate non-digest assets by making a copy of the digest asset,
with digests stripped from js and css. The new files are also gzipped.
Other assets are copied verbatim. | [
"Generate",
"non",
"-",
"digest",
"assets",
"by",
"making",
"a",
"copy",
"of",
"the",
"digest",
"asset",
"with",
"digests",
"stripped",
"from",
"js",
"and",
"css",
".",
"The",
"new",
"files",
"are",
"also",
"gzipped",
".",
"Other",
"assets",
"are",
"copi... | 17fc5c88c4616746811d0e82f9394db1011f27fe | https://github.com/ndbroadbent/turbo-sprockets-rails3/blob/17fc5c88c4616746811d0e82f9394db1011f27fe/lib/sprockets/static_non_digest_generator.rb#L26-L88 |
20,042 | ndbroadbent/turbo-sprockets-rails3 | lib/sprockets/asset_with_dependencies.rb | Sprockets.AssetWithDependencies.init_with | def init_with(environment, coder, asset_options = {})
asset_options[:bundle] = false
super(environment, coder)
@source = coder['source']
@dependency_digest = coder['dependency_digest']
@required_assets = coder['required_paths'].map { |p|
p = expand_root_path(p)
unless e... | ruby | def init_with(environment, coder, asset_options = {})
asset_options[:bundle] = false
super(environment, coder)
@source = coder['source']
@dependency_digest = coder['dependency_digest']
@required_assets = coder['required_paths'].map { |p|
p = expand_root_path(p)
unless e... | [
"def",
"init_with",
"(",
"environment",
",",
"coder",
",",
"asset_options",
"=",
"{",
"}",
")",
"asset_options",
"[",
":bundle",
"]",
"=",
"false",
"super",
"(",
"environment",
",",
"coder",
")",
"@source",
"=",
"coder",
"[",
"'source'",
"]",
"@dependency_... | Initialize asset from serialized hash | [
"Initialize",
"asset",
"from",
"serialized",
"hash"
] | 17fc5c88c4616746811d0e82f9394db1011f27fe | https://github.com/ndbroadbent/turbo-sprockets-rails3/blob/17fc5c88c4616746811d0e82f9394db1011f27fe/lib/sprockets/asset_with_dependencies.rb#L13-L33 |
20,043 | ndbroadbent/turbo-sprockets-rails3 | lib/sprockets/asset_with_dependencies.rb | Sprockets.AssetWithDependencies.encode_with | def encode_with(coder)
super
coder['source'] = source
coder['dependency_digest'] = dependency_digest
coder['required_paths'] = required_assets.map { |a|
relativize_root_path(a.pathname).to_s
}
coder['dependency_paths'] = dependency_paths.map { |d|
{ 'path' => relati... | ruby | def encode_with(coder)
super
coder['source'] = source
coder['dependency_digest'] = dependency_digest
coder['required_paths'] = required_assets.map { |a|
relativize_root_path(a.pathname).to_s
}
coder['dependency_paths'] = dependency_paths.map { |d|
{ 'path' => relati... | [
"def",
"encode_with",
"(",
"coder",
")",
"super",
"coder",
"[",
"'source'",
"]",
"=",
"source",
"coder",
"[",
"'dependency_digest'",
"]",
"=",
"dependency_digest",
"coder",
"[",
"'required_paths'",
"]",
"=",
"required_assets",
".",
"map",
"{",
"|",
"a",
"|",... | Serialize custom attributes. | [
"Serialize",
"custom",
"attributes",
"."
] | 17fc5c88c4616746811d0e82f9394db1011f27fe | https://github.com/ndbroadbent/turbo-sprockets-rails3/blob/17fc5c88c4616746811d0e82f9394db1011f27fe/lib/sprockets/asset_with_dependencies.rb#L36-L50 |
20,044 | saucelabs/sauce_ruby | gems/sauce-connect/lib/sauce/connect.rb | Sauce.Connect.extract_config | def extract_config options
@username = options[:username]
@access_key = options[:access_key]
@cli_options = options[:connect_options]
@sc4_executable = options[:sauce_connect_4_executable]
@skip_connection_test = options[:skip_connection_test]
@quiet = options[:quiet]
@timeout ... | ruby | def extract_config options
@username = options[:username]
@access_key = options[:access_key]
@cli_options = options[:connect_options]
@sc4_executable = options[:sauce_connect_4_executable]
@skip_connection_test = options[:skip_connection_test]
@quiet = options[:quiet]
@timeout ... | [
"def",
"extract_config",
"options",
"@username",
"=",
"options",
"[",
":username",
"]",
"@access_key",
"=",
"options",
"[",
":access_key",
"]",
"@cli_options",
"=",
"options",
"[",
":connect_options",
"]",
"@sc4_executable",
"=",
"options",
"[",
":sauce_connect_4_ex... | extract options from the options hash with highest priority over Sauce.config
but fall back on Sauce.config otherwise | [
"extract",
"options",
"from",
"the",
"options",
"hash",
"with",
"highest",
"priority",
"over",
"Sauce",
".",
"config",
"but",
"fall",
"back",
"on",
"Sauce",
".",
"config",
"otherwise"
] | b1c4dab8516fb5e9c75ef16fb72b59b72c0ff0b0 | https://github.com/saucelabs/sauce_ruby/blob/b1c4dab8516fb5e9c75ef16fb72b59b72c0ff0b0/gems/sauce-connect/lib/sauce/connect.rb#L27-L45 |
20,045 | ulfurinn/wongi-engine | lib/wongi-engine/token.rb | Wongi::Engine.Token.generated? | def generated? wme
return true if generated_wmes.any? { |w| w == wme }
return children.any? { |t| t.generated? wme }
end | ruby | def generated? wme
return true if generated_wmes.any? { |w| w == wme }
return children.any? { |t| t.generated? wme }
end | [
"def",
"generated?",
"wme",
"return",
"true",
"if",
"generated_wmes",
".",
"any?",
"{",
"|",
"w",
"|",
"w",
"==",
"wme",
"}",
"return",
"children",
".",
"any?",
"{",
"|",
"t",
"|",
"t",
".",
"generated?",
"wme",
"}",
"end"
] | for neg feedback loop protection | [
"for",
"neg",
"feedback",
"loop",
"protection"
] | 5251e6f41208568906cfd261a3513f883ac129e6 | https://github.com/ulfurinn/wongi-engine/blob/5251e6f41208568906cfd261a3513f883ac129e6/lib/wongi-engine/token.rb#L92-L95 |
20,046 | zenaton/zenaton-ruby | lib/zenaton/client.rb | Zenaton.Client.website_url | def website_url(resource = '', params = {})
api_url = ENV['ZENATON_API_URL'] || ZENATON_API_URL
url = "#{api_url}/#{resource}"
if params.is_a?(Hash)
params[API_TOKEN] = @api_token
append_params_to_url(url, params)
else
add_app_env("#{url}?#{API_TOKEN}=#{@api_token}&", pa... | ruby | def website_url(resource = '', params = {})
api_url = ENV['ZENATON_API_URL'] || ZENATON_API_URL
url = "#{api_url}/#{resource}"
if params.is_a?(Hash)
params[API_TOKEN] = @api_token
append_params_to_url(url, params)
else
add_app_env("#{url}?#{API_TOKEN}=#{@api_token}&", pa... | [
"def",
"website_url",
"(",
"resource",
"=",
"''",
",",
"params",
"=",
"{",
"}",
")",
"api_url",
"=",
"ENV",
"[",
"'ZENATON_API_URL'",
"]",
"||",
"ZENATON_API_URL",
"url",
"=",
"\"#{api_url}/#{resource}\"",
"if",
"params",
".",
"is_a?",
"(",
"Hash",
")",
"p... | Gets the url for zenaton api
@param resource [String] the endpoint for the api
@param params [Hash|String] query params to be url encoded
@return [String] the api url with parameters | [
"Gets",
"the",
"url",
"for",
"zenaton",
"api"
] | b80badb6919482e7cf78722c5c3cc94f2bb18fc6 | https://github.com/zenaton/zenaton-ruby/blob/b80badb6919482e7cf78722c5c3cc94f2bb18fc6/lib/zenaton/client.rb#L85-L95 |
20,047 | zenaton/zenaton-ruby | lib/zenaton/client.rb | Zenaton.Client.start_task | def start_task(task)
max_processing_time = if task.respond_to?(:max_processing_time)
task.max_processing_time
end
@http.post(
worker_url('tasks'),
ATTR_PROG => PROG,
ATTR_NAME => class_name(task),
ATTR_DATA => @seriali... | ruby | def start_task(task)
max_processing_time = if task.respond_to?(:max_processing_time)
task.max_processing_time
end
@http.post(
worker_url('tasks'),
ATTR_PROG => PROG,
ATTR_NAME => class_name(task),
ATTR_DATA => @seriali... | [
"def",
"start_task",
"(",
"task",
")",
"max_processing_time",
"=",
"if",
"task",
".",
"respond_to?",
"(",
":max_processing_time",
")",
"task",
".",
"max_processing_time",
"end",
"@http",
".",
"post",
"(",
"worker_url",
"(",
"'tasks'",
")",
",",
"ATTR_PROG",
"=... | Start a single task
@param task [Zenaton::Interfaces::Task] | [
"Start",
"a",
"single",
"task"
] | b80badb6919482e7cf78722c5c3cc94f2bb18fc6 | https://github.com/zenaton/zenaton-ruby/blob/b80badb6919482e7cf78722c5c3cc94f2bb18fc6/lib/zenaton/client.rb#L99-L110 |
20,048 | zenaton/zenaton-ruby | lib/zenaton/client.rb | Zenaton.Client.start_workflow | def start_workflow(flow)
@http.post(
instance_worker_url,
ATTR_PROG => PROG,
ATTR_CANONICAL => canonical_name(flow),
ATTR_NAME => class_name(flow),
ATTR_DATA => @serializer.encode(@properties.from(flow)),
ATTR_ID => parse_custom_id_from(flow)
)
end | ruby | def start_workflow(flow)
@http.post(
instance_worker_url,
ATTR_PROG => PROG,
ATTR_CANONICAL => canonical_name(flow),
ATTR_NAME => class_name(flow),
ATTR_DATA => @serializer.encode(@properties.from(flow)),
ATTR_ID => parse_custom_id_from(flow)
)
end | [
"def",
"start_workflow",
"(",
"flow",
")",
"@http",
".",
"post",
"(",
"instance_worker_url",
",",
"ATTR_PROG",
"=>",
"PROG",
",",
"ATTR_CANONICAL",
"=>",
"canonical_name",
"(",
"flow",
")",
",",
"ATTR_NAME",
"=>",
"class_name",
"(",
"flow",
")",
",",
"ATTR_D... | Start the specified workflow
@param flow [Zenaton::Interfaces::Workflow] | [
"Start",
"the",
"specified",
"workflow"
] | b80badb6919482e7cf78722c5c3cc94f2bb18fc6 | https://github.com/zenaton/zenaton-ruby/blob/b80badb6919482e7cf78722c5c3cc94f2bb18fc6/lib/zenaton/client.rb#L114-L123 |
20,049 | zenaton/zenaton-ruby | lib/zenaton/client.rb | Zenaton.Client.find_workflow | def find_workflow(workflow_name, custom_id)
params = { ATTR_ID => custom_id, ATTR_NAME => workflow_name }
params[ATTR_PROG] = PROG
data = @http.get(instance_website_url(params))['data']
data && @properties.object_from(
data['name'],
@serializer.decode(data['properties'])
)
... | ruby | def find_workflow(workflow_name, custom_id)
params = { ATTR_ID => custom_id, ATTR_NAME => workflow_name }
params[ATTR_PROG] = PROG
data = @http.get(instance_website_url(params))['data']
data && @properties.object_from(
data['name'],
@serializer.decode(data['properties'])
)
... | [
"def",
"find_workflow",
"(",
"workflow_name",
",",
"custom_id",
")",
"params",
"=",
"{",
"ATTR_ID",
"=>",
"custom_id",
",",
"ATTR_NAME",
"=>",
"workflow_name",
"}",
"params",
"[",
"ATTR_PROG",
"]",
"=",
"PROG",
"data",
"=",
"@http",
".",
"get",
"(",
"insta... | Finds a workflow
@param workflow_name [String] the class name of the workflow
@param custom_id [String] the custom ID of the workflow
@return [Zenaton::Interfaces::Workflow, nil] | [
"Finds",
"a",
"workflow"
] | b80badb6919482e7cf78722c5c3cc94f2bb18fc6 | https://github.com/zenaton/zenaton-ruby/blob/b80badb6919482e7cf78722c5c3cc94f2bb18fc6/lib/zenaton/client.rb#L153-L164 |
20,050 | zenaton/zenaton-ruby | lib/zenaton/client.rb | Zenaton.Client.send_event | def send_event(workflow_name, custom_id, event)
body = {
ATTR_PROG => PROG,
ATTR_NAME => workflow_name,
ATTR_ID => custom_id,
EVENT_NAME => event.class.name,
EVENT_INPUT => @serializer.encode(@properties.from(event))
}
@http.post(send_event_url, body)
end | ruby | def send_event(workflow_name, custom_id, event)
body = {
ATTR_PROG => PROG,
ATTR_NAME => workflow_name,
ATTR_ID => custom_id,
EVENT_NAME => event.class.name,
EVENT_INPUT => @serializer.encode(@properties.from(event))
}
@http.post(send_event_url, body)
end | [
"def",
"send_event",
"(",
"workflow_name",
",",
"custom_id",
",",
"event",
")",
"body",
"=",
"{",
"ATTR_PROG",
"=>",
"PROG",
",",
"ATTR_NAME",
"=>",
"workflow_name",
",",
"ATTR_ID",
"=>",
"custom_id",
",",
"EVENT_NAME",
"=>",
"event",
".",
"class",
".",
"n... | Sends an event to a workflow
@param workflow_name [String] the class name of the workflow
@param custom_id [String] the custom ID of the workflow (if any)
@param event [Zenaton::Interfaces::Event] the event to send
@return [NilClass] | [
"Sends",
"an",
"event",
"to",
"a",
"workflow"
] | b80badb6919482e7cf78722c5c3cc94f2bb18fc6 | https://github.com/zenaton/zenaton-ruby/blob/b80badb6919482e7cf78722c5c3cc94f2bb18fc6/lib/zenaton/client.rb#L171-L180 |
20,051 | zenaton/zenaton-ruby | lib/zenaton/engine.rb | Zenaton.Engine.dispatch | def dispatch(jobs)
jobs.map(&method(:check_argument))
jobs.map(&method(:local_dispatch)) if process_locally?(jobs)
@processor&.process(jobs, false) unless jobs.length.zero?
nil
end | ruby | def dispatch(jobs)
jobs.map(&method(:check_argument))
jobs.map(&method(:local_dispatch)) if process_locally?(jobs)
@processor&.process(jobs, false) unless jobs.length.zero?
nil
end | [
"def",
"dispatch",
"(",
"jobs",
")",
"jobs",
".",
"map",
"(",
"method",
"(",
":check_argument",
")",
")",
"jobs",
".",
"map",
"(",
"method",
"(",
":local_dispatch",
")",
")",
"if",
"process_locally?",
"(",
"jobs",
")",
"@processor",
"&.",
"process",
"(",... | Executes jobs asynchronously
@param jobs [Array<Zenaton::Interfaces::Job>]
@return nil | [
"Executes",
"jobs",
"asynchronously"
] | b80badb6919482e7cf78722c5c3cc94f2bb18fc6 | https://github.com/zenaton/zenaton-ruby/blob/b80badb6919482e7cf78722c5c3cc94f2bb18fc6/lib/zenaton/engine.rb#L39-L44 |
20,052 | PhilipCastiglione/clubhouse_ruby | lib/clubhouse_ruby/path_builder.rb | ClubhouseRuby.PathBuilder.method_missing | def method_missing(name, *args)
if known_action?(name)
execute_request(ACTIONS[name], args.first)
elsif known_resource?(name)
build_path(name, args.first)
elsif known_exception?(name)
build_path(EXCEPTIONS[name][:path], nil)
execute_request(EXCEPTIONS[name][:action], ar... | ruby | def method_missing(name, *args)
if known_action?(name)
execute_request(ACTIONS[name], args.first)
elsif known_resource?(name)
build_path(name, args.first)
elsif known_exception?(name)
build_path(EXCEPTIONS[name][:path], nil)
execute_request(EXCEPTIONS[name][:action], ar... | [
"def",
"method_missing",
"(",
"name",
",",
"*",
"args",
")",
"if",
"known_action?",
"(",
"name",
")",
"execute_request",
"(",
"ACTIONS",
"[",
"name",
"]",
",",
"args",
".",
"first",
")",
"elsif",
"known_resource?",
"(",
"name",
")",
"build_path",
"(",
"n... | Uh oh! This will allow the class including this module to "build a path"
by chaining calls to resources, terminated with a method linked to an
action that will execute the api call.
For example:
`foo.stories(story_id).comments.update(id: comment_id, text: "comment text")`
This example will execute a call to:
... | [
"Uh",
"oh!",
"This",
"will",
"allow",
"the",
"class",
"including",
"this",
"module",
"to",
"build",
"a",
"path",
"by",
"chaining",
"calls",
"to",
"resources",
"terminated",
"with",
"a",
"method",
"linked",
"to",
"an",
"action",
"that",
"will",
"execute",
"... | dd51319a436bb5486e746df1dff854a5ef15e7af | https://github.com/PhilipCastiglione/clubhouse_ruby/blob/dd51319a436bb5486e746df1dff854a5ef15e7af/lib/clubhouse_ruby/path_builder.rb#L25-L36 |
20,053 | PhilipCastiglione/clubhouse_ruby | lib/clubhouse_ruby/path_builder.rb | ClubhouseRuby.PathBuilder.respond_to_missing? | def respond_to_missing?(name, include_private = false)
known_action?(name) ||
known_resource?(name) ||
known_exception?(name) ||
super
end | ruby | def respond_to_missing?(name, include_private = false)
known_action?(name) ||
known_resource?(name) ||
known_exception?(name) ||
super
end | [
"def",
"respond_to_missing?",
"(",
"name",
",",
"include_private",
"=",
"false",
")",
"known_action?",
"(",
"name",
")",
"||",
"known_resource?",
"(",
"name",
")",
"||",
"known_exception?",
"(",
"name",
")",
"||",
"super",
"end"
] | We'd better not lie when asked. | [
"We",
"d",
"better",
"not",
"lie",
"when",
"asked",
"."
] | dd51319a436bb5486e746df1dff854a5ef15e7af | https://github.com/PhilipCastiglione/clubhouse_ruby/blob/dd51319a436bb5486e746df1dff854a5ef15e7af/lib/clubhouse_ruby/path_builder.rb#L52-L57 |
20,054 | PhilipCastiglione/clubhouse_ruby | lib/clubhouse_ruby/request.rb | ClubhouseRuby.Request.fetch | def fetch
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |https|
req = Net::HTTP.const_get(action).new(uri)
set_body(req)
set_format_header(req)
wrap_response(https.request(req))
end
end | ruby | def fetch
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |https|
req = Net::HTTP.const_get(action).new(uri)
set_body(req)
set_format_header(req)
wrap_response(https.request(req))
end
end | [
"def",
"fetch",
"Net",
"::",
"HTTP",
".",
"start",
"(",
"uri",
".",
"host",
",",
"uri",
".",
"port",
",",
"use_ssl",
":",
"true",
")",
"do",
"|",
"https",
"|",
"req",
"=",
"Net",
"::",
"HTTP",
".",
"const_get",
"(",
"action",
")",
".",
"new",
"... | Prepares a fancy request object and ensures the inputs make as much sense
as possible. It's still totally possible to just provide a path that
doesn't match a real url though.
Executes the http(s) request and provides the response with some
additional decoration in a Hash. | [
"Prepares",
"a",
"fancy",
"request",
"object",
"and",
"ensures",
"the",
"inputs",
"make",
"as",
"much",
"sense",
"as",
"possible",
".",
"It",
"s",
"still",
"totally",
"possible",
"to",
"just",
"provide",
"a",
"path",
"that",
"doesn",
"t",
"match",
"a",
"... | dd51319a436bb5486e746df1dff854a5ef15e7af | https://github.com/PhilipCastiglione/clubhouse_ruby/blob/dd51319a436bb5486e746df1dff854a5ef15e7af/lib/clubhouse_ruby/request.rb#L23-L32 |
20,055 | elevation/event_calendar | lib/event_calendar/calendar_helper.rb | EventCalendar.CalendarHelper.day_link | def day_link(text, date, day_action)
link_to(text, params.merge(:action => day_action, :year => date.year, :month => date.month, :day => date.day), :class => 'ec-day-link')
end | ruby | def day_link(text, date, day_action)
link_to(text, params.merge(:action => day_action, :year => date.year, :month => date.month, :day => date.day), :class => 'ec-day-link')
end | [
"def",
"day_link",
"(",
"text",
",",
"date",
",",
"day_action",
")",
"link_to",
"(",
"text",
",",
"params",
".",
"merge",
"(",
":action",
"=>",
"day_action",
",",
":year",
"=>",
"date",
".",
"year",
",",
":month",
"=>",
"date",
".",
"month",
",",
":d... | override this in your own helper for greater control | [
"override",
"this",
"in",
"your",
"own",
"helper",
"for",
"greater",
"control"
] | 131d6dee147f4d515daa77d4acc7fa77f369bfcc | https://github.com/elevation/event_calendar/blob/131d6dee147f4d515daa77d4acc7fa77f369bfcc/lib/event_calendar/calendar_helper.rb#L292-L294 |
20,056 | elevation/event_calendar | lib/event_calendar/calendar_helper.rb | EventCalendar.CalendarHelper.cal_row_heights | def cal_row_heights(options)
# number of rows is the number of days in the event strips divided by 7
num_cal_rows = options[:event_strips].first.size / 7
# the row will be at least this big
min_height = (options[:height] - options[:day_names_height]) / num_cal_rows
row_heights = []
n... | ruby | def cal_row_heights(options)
# number of rows is the number of days in the event strips divided by 7
num_cal_rows = options[:event_strips].first.size / 7
# the row will be at least this big
min_height = (options[:height] - options[:day_names_height]) / num_cal_rows
row_heights = []
n... | [
"def",
"cal_row_heights",
"(",
"options",
")",
"# number of rows is the number of days in the event strips divided by 7",
"num_cal_rows",
"=",
"options",
"[",
":event_strips",
"]",
".",
"first",
".",
"size",
"/",
"7",
"# the row will be at least this big",
"min_height",
"=",
... | calculate the height of each row
by default, it will be the height option minus the day names height,
divided by the total number of calendar rows
this gets tricky, however, if there are too many event rows to fit into the row's height
then we need to add additional height | [
"calculate",
"the",
"height",
"of",
"each",
"row",
"by",
"default",
"it",
"will",
"be",
"the",
"height",
"option",
"minus",
"the",
"day",
"names",
"height",
"divided",
"by",
"the",
"total",
"number",
"of",
"calendar",
"rows",
"this",
"gets",
"tricky",
"how... | 131d6dee147f4d515daa77d4acc7fa77f369bfcc | https://github.com/elevation/event_calendar/blob/131d6dee147f4d515daa77d4acc7fa77f369bfcc/lib/event_calendar/calendar_helper.rb#L325-L351 |
20,057 | elevation/event_calendar | lib/event_calendar.rb | EventCalendar.ClassMethods.event_strips_for_month | def event_strips_for_month(shown_date, first_day_of_week=0, find_options = {})
if first_day_of_week.is_a?(Hash)
find_options.merge!(first_day_of_week)
first_day_of_week = 0
end
strip_start, strip_end = get_start_and_end_dates(shown_date, first_day_of_week)
events = events_for_da... | ruby | def event_strips_for_month(shown_date, first_day_of_week=0, find_options = {})
if first_day_of_week.is_a?(Hash)
find_options.merge!(first_day_of_week)
first_day_of_week = 0
end
strip_start, strip_end = get_start_and_end_dates(shown_date, first_day_of_week)
events = events_for_da... | [
"def",
"event_strips_for_month",
"(",
"shown_date",
",",
"first_day_of_week",
"=",
"0",
",",
"find_options",
"=",
"{",
"}",
")",
"if",
"first_day_of_week",
".",
"is_a?",
"(",
"Hash",
")",
"find_options",
".",
"merge!",
"(",
"first_day_of_week",
")",
"first_day_o... | For the given month, find the start and end dates
Find all the events within this range, and create event strips for them | [
"For",
"the",
"given",
"month",
"find",
"the",
"start",
"and",
"end",
"dates",
"Find",
"all",
"the",
"events",
"within",
"this",
"range",
"and",
"create",
"event",
"strips",
"for",
"them"
] | 131d6dee147f4d515daa77d4acc7fa77f369bfcc | https://github.com/elevation/event_calendar/blob/131d6dee147f4d515daa77d4acc7fa77f369bfcc/lib/event_calendar.rb#L21-L30 |
20,058 | elevation/event_calendar | lib/event_calendar.rb | EventCalendar.ClassMethods.get_start_and_end_dates | def get_start_and_end_dates(shown_date, first_day_of_week=0)
# start with the first day of the given month
start_of_month = Date.civil(shown_date.year, shown_date.month, 1)
# the end of last month
strip_start = beginning_of_week(start_of_month, first_day_of_week)
# the beginning of next mo... | ruby | def get_start_and_end_dates(shown_date, first_day_of_week=0)
# start with the first day of the given month
start_of_month = Date.civil(shown_date.year, shown_date.month, 1)
# the end of last month
strip_start = beginning_of_week(start_of_month, first_day_of_week)
# the beginning of next mo... | [
"def",
"get_start_and_end_dates",
"(",
"shown_date",
",",
"first_day_of_week",
"=",
"0",
")",
"# start with the first day of the given month",
"start_of_month",
"=",
"Date",
".",
"civil",
"(",
"shown_date",
".",
"year",
",",
"shown_date",
".",
"month",
",",
"1",
")"... | Expand start and end dates to show the previous month and next month's days,
that overlap with the shown months display | [
"Expand",
"start",
"and",
"end",
"dates",
"to",
"show",
"the",
"previous",
"month",
"and",
"next",
"month",
"s",
"days",
"that",
"overlap",
"with",
"the",
"shown",
"months",
"display"
] | 131d6dee147f4d515daa77d4acc7fa77f369bfcc | https://github.com/elevation/event_calendar/blob/131d6dee147f4d515daa77d4acc7fa77f369bfcc/lib/event_calendar.rb#L34-L48 |
20,059 | elevation/event_calendar | lib/event_calendar.rb | EventCalendar.ClassMethods.events_for_date_range | def events_for_date_range(start_d, end_d, find_options = {})
self.scoped(find_options).find(
:all,
:conditions => [ "(? <= #{self.quoted_table_name}.#{self.end_at_field}) AND (#{self.quoted_table_name}.#{self.start_at_field}< ?)", start_d.to_time.utc, end_d.to_time.utc ],
:order => "#{self... | ruby | def events_for_date_range(start_d, end_d, find_options = {})
self.scoped(find_options).find(
:all,
:conditions => [ "(? <= #{self.quoted_table_name}.#{self.end_at_field}) AND (#{self.quoted_table_name}.#{self.start_at_field}< ?)", start_d.to_time.utc, end_d.to_time.utc ],
:order => "#{self... | [
"def",
"events_for_date_range",
"(",
"start_d",
",",
"end_d",
",",
"find_options",
"=",
"{",
"}",
")",
"self",
".",
"scoped",
"(",
"find_options",
")",
".",
"find",
"(",
":all",
",",
":conditions",
"=>",
"[",
"\"(? <= #{self.quoted_table_name}.#{self.end_at_field}... | Get the events overlapping the given start and end dates | [
"Get",
"the",
"events",
"overlapping",
"the",
"given",
"start",
"and",
"end",
"dates"
] | 131d6dee147f4d515daa77d4acc7fa77f369bfcc | https://github.com/elevation/event_calendar/blob/131d6dee147f4d515daa77d4acc7fa77f369bfcc/lib/event_calendar.rb#L51-L57 |
20,060 | elevation/event_calendar | lib/event_calendar.rb | EventCalendar.ClassMethods.create_event_strips | def create_event_strips(strip_start, strip_end, events)
# create an inital event strip, with a nil entry for every day of the displayed days
event_strips = [[nil] * (strip_end - strip_start + 1)]
events.each do |event|
cur_date = event.start_at.to_date
end_date = event.end_at.to_d... | ruby | def create_event_strips(strip_start, strip_end, events)
# create an inital event strip, with a nil entry for every day of the displayed days
event_strips = [[nil] * (strip_end - strip_start + 1)]
events.each do |event|
cur_date = event.start_at.to_date
end_date = event.end_at.to_d... | [
"def",
"create_event_strips",
"(",
"strip_start",
",",
"strip_end",
",",
"events",
")",
"# create an inital event strip, with a nil entry for every day of the displayed days",
"event_strips",
"=",
"[",
"[",
"nil",
"]",
"*",
"(",
"strip_end",
"-",
"strip_start",
"+",
"1",
... | Create the various strips that show events. | [
"Create",
"the",
"various",
"strips",
"that",
"show",
"events",
"."
] | 131d6dee147f4d515daa77d4acc7fa77f369bfcc | https://github.com/elevation/event_calendar/blob/131d6dee147f4d515daa77d4acc7fa77f369bfcc/lib/event_calendar.rb#L60-L89 |
20,061 | elevation/event_calendar | lib/event_calendar.rb | EventCalendar.InstanceMethods.clip_range | def clip_range(start_d, end_d)
# make sure we are comparing date objects to date objects,
# otherwise timezones can cause problems
start_at_d = start_at.to_date
end_at_d = end_at.to_date
# Clip start date, make sure it also ends on or after the start range
if (start_at_d < start_d an... | ruby | def clip_range(start_d, end_d)
# make sure we are comparing date objects to date objects,
# otherwise timezones can cause problems
start_at_d = start_at.to_date
end_at_d = end_at.to_date
# Clip start date, make sure it also ends on or after the start range
if (start_at_d < start_d an... | [
"def",
"clip_range",
"(",
"start_d",
",",
"end_d",
")",
"# make sure we are comparing date objects to date objects,",
"# otherwise timezones can cause problems",
"start_at_d",
"=",
"start_at",
".",
"to_date",
"end_at_d",
"=",
"end_at",
".",
"to_date",
"# Clip start date, make s... | start_d - start of the month, or start of the week
end_d - end of the month, or end of the week | [
"start_d",
"-",
"start",
"of",
"the",
"month",
"or",
"start",
"of",
"the",
"week",
"end_d",
"-",
"end",
"of",
"the",
"month",
"or",
"end",
"of",
"the",
"week"
] | 131d6dee147f4d515daa77d4acc7fa77f369bfcc | https://github.com/elevation/event_calendar/blob/131d6dee147f4d515daa77d4acc7fa77f369bfcc/lib/event_calendar.rb#L155-L174 |
20,062 | langalex/couch_potato | lib/couch_potato/database.rb | CouchPotato.Database.view | def view(spec)
results = CouchPotato::View::ViewQuery.new(
couchrest_database,
spec.design_document,
{spec.view_name => {
:map => spec.map_function,
:reduce => spec.reduce_function
}
},
({spec.list_name => spec.list_function} unless spec.list_nam... | ruby | def view(spec)
results = CouchPotato::View::ViewQuery.new(
couchrest_database,
spec.design_document,
{spec.view_name => {
:map => spec.map_function,
:reduce => spec.reduce_function
}
},
({spec.list_name => spec.list_function} unless spec.list_nam... | [
"def",
"view",
"(",
"spec",
")",
"results",
"=",
"CouchPotato",
"::",
"View",
"::",
"ViewQuery",
".",
"new",
"(",
"couchrest_database",
",",
"spec",
".",
"design_document",
",",
"{",
"spec",
".",
"view_name",
"=>",
"{",
":map",
"=>",
"spec",
".",
"map_fu... | executes a view and return the results. you pass in a view spec
which is usually a result of a SomePersistentClass.some_view call.
Example:
class User
include CouchPotato::Persistence
property :age
view :all, key: :age
end
db = CouchPotato.database
db.view(User.all) # => [user1, user2]
... | [
"executes",
"a",
"view",
"and",
"return",
"the",
"results",
".",
"you",
"pass",
"in",
"a",
"view",
"spec",
"which",
"is",
"usually",
"a",
"result",
"of",
"a",
"SomePersistentClass",
".",
"some_view",
"call",
"."
] | cd1de222029ac88be7fd9263625d489cb7f715a7 | https://github.com/langalex/couch_potato/blob/cd1de222029ac88be7fd9263625d489cb7f715a7/lib/couch_potato/database.rb#L39-L57 |
20,063 | viseztrance/rails-sitemap | lib/sitemap/generator.rb | Sitemap.Generator.load | def load(options = {}, &block)
options.each do |k, v|
self.send("#{k}=", v)
end
self.routes = block
end | ruby | def load(options = {}, &block)
options.each do |k, v|
self.send("#{k}=", v)
end
self.routes = block
end | [
"def",
"load",
"(",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"options",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"self",
".",
"send",
"(",
"\"#{k}=\"",
",",
"v",
")",
"end",
"self",
".",
"routes",
"=",
"block",
"end"
] | Instantiates a new object.
Should never be called directly.
Sets the urls to be indexed.
The +host+, or any other global option can be set here:
Sitemap::Generator.instance.load :host => "mywebsite.com" do
...
end
Literal paths can be added as follows:
Sitemap::Generator.instance.load :host => "my... | [
"Instantiates",
"a",
"new",
"object",
".",
"Should",
"never",
"be",
"called",
"directly",
".",
"Sets",
"the",
"urls",
"to",
"be",
"indexed",
"."
] | 3c99256d131a753079a78fb9deac1f7703ebe4d9 | https://github.com/viseztrance/rails-sitemap/blob/3c99256d131a753079a78fb9deac1f7703ebe4d9/lib/sitemap/generator.rb#L61-L66 |
20,064 | viseztrance/rails-sitemap | lib/sitemap/generator.rb | Sitemap.Generator.resources | def resources(type, options = {})
path(type) unless options[:skip_index]
link_params = options.reject { |k, v| k == :objects }
get_objects = lambda {
options[:objects] ? options[:objects].call : type.to_s.classify.constantize
}
get_objects.call.find_each(:batch_size => Sitemap.conf... | ruby | def resources(type, options = {})
path(type) unless options[:skip_index]
link_params = options.reject { |k, v| k == :objects }
get_objects = lambda {
options[:objects] ? options[:objects].call : type.to_s.classify.constantize
}
get_objects.call.find_each(:batch_size => Sitemap.conf... | [
"def",
"resources",
"(",
"type",
",",
"options",
"=",
"{",
"}",
")",
"path",
"(",
"type",
")",
"unless",
"options",
"[",
":skip_index",
"]",
"link_params",
"=",
"options",
".",
"reject",
"{",
"|",
"k",
",",
"v",
"|",
"k",
"==",
":objects",
"}",
"ge... | Adds the associated object types.
The following will map all Activity entries, as well as the index (<tt>/activities</tt>) page:
resources :activities
You can also specify which entries are being mapped:
resources :articles, :objects => proc { Article.published }
To skip the index action and map only the ... | [
"Adds",
"the",
"associated",
"object",
"types",
"."
] | 3c99256d131a753079a78fb9deac1f7703ebe4d9 | https://github.com/viseztrance/rails-sitemap/blob/3c99256d131a753079a78fb9deac1f7703ebe4d9/lib/sitemap/generator.rb#L137-L146 |
20,065 | viseztrance/rails-sitemap | lib/sitemap/generator.rb | Sitemap.Generator.render | def render(object = "fragment")
xml = Builder::XmlMarkup.new(:indent => 2)
file = File.read(File.expand_path("../../views/#{object}.xml.builder", __FILE__))
instance_eval file
end | ruby | def render(object = "fragment")
xml = Builder::XmlMarkup.new(:indent => 2)
file = File.read(File.expand_path("../../views/#{object}.xml.builder", __FILE__))
instance_eval file
end | [
"def",
"render",
"(",
"object",
"=",
"\"fragment\"",
")",
"xml",
"=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"(",
":indent",
"=>",
"2",
")",
"file",
"=",
"File",
".",
"read",
"(",
"File",
".",
"expand_path",
"(",
"\"../../views/#{object}.xml.builder\"",
... | Parses the loaded data and returns the xml entries. | [
"Parses",
"the",
"loaded",
"data",
"and",
"returns",
"the",
"xml",
"entries",
"."
] | 3c99256d131a753079a78fb9deac1f7703ebe4d9 | https://github.com/viseztrance/rails-sitemap/blob/3c99256d131a753079a78fb9deac1f7703ebe4d9/lib/sitemap/generator.rb#L149-L153 |
20,066 | viseztrance/rails-sitemap | lib/sitemap/generator.rb | Sitemap.Generator.process_fragment! | def process_fragment!
file = Tempfile.new("sitemap.xml")
file.write(render)
file.close
self.fragments << file
end | ruby | def process_fragment!
file = Tempfile.new("sitemap.xml")
file.write(render)
file.close
self.fragments << file
end | [
"def",
"process_fragment!",
"file",
"=",
"Tempfile",
".",
"new",
"(",
"\"sitemap.xml\"",
")",
"file",
".",
"write",
"(",
"render",
")",
"file",
".",
"close",
"self",
".",
"fragments",
"<<",
"file",
"end"
] | Creates a temporary file from the existing entries. | [
"Creates",
"a",
"temporary",
"file",
"from",
"the",
"existing",
"entries",
"."
] | 3c99256d131a753079a78fb9deac1f7703ebe4d9 | https://github.com/viseztrance/rails-sitemap/blob/3c99256d131a753079a78fb9deac1f7703ebe4d9/lib/sitemap/generator.rb#L156-L161 |
20,067 | viseztrance/rails-sitemap | lib/sitemap/generator.rb | Sitemap.Generator.file_url | def file_url(path = "sitemap.xml")
if context
file_path = File.join("/", context, path)
else
file_path = File.join("/", path)
end
URI::HTTP.build(:host => host, :path => file_path).to_s
end | ruby | def file_url(path = "sitemap.xml")
if context
file_path = File.join("/", context, path)
else
file_path = File.join("/", path)
end
URI::HTTP.build(:host => host, :path => file_path).to_s
end | [
"def",
"file_url",
"(",
"path",
"=",
"\"sitemap.xml\"",
")",
"if",
"context",
"file_path",
"=",
"File",
".",
"join",
"(",
"\"/\"",
",",
"context",
",",
"path",
")",
"else",
"file_path",
"=",
"File",
".",
"join",
"(",
"\"/\"",
",",
"path",
")",
"end",
... | URL to the sitemap file.
Defaults to <tt>sitemap.xml</tt>. | [
"URL",
"to",
"the",
"sitemap",
"file",
"."
] | 3c99256d131a753079a78fb9deac1f7703ebe4d9 | https://github.com/viseztrance/rails-sitemap/blob/3c99256d131a753079a78fb9deac1f7703ebe4d9/lib/sitemap/generator.rb#L192-L200 |
20,068 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.build | def build(steps)
raise ArgumentError, "Must provide scenario steps" unless steps
steps.each_with_index do |step, index|
begin
instruction, args = step.split ' ', 2
args = split_quoted_string args
if args && !args.empty?
self.__send__ instruction, *args
... | ruby | def build(steps)
raise ArgumentError, "Must provide scenario steps" unless steps
steps.each_with_index do |step, index|
begin
instruction, args = step.split ' ', 2
args = split_quoted_string args
if args && !args.empty?
self.__send__ instruction, *args
... | [
"def",
"build",
"(",
"steps",
")",
"raise",
"ArgumentError",
",",
"\"Must provide scenario steps\"",
"unless",
"steps",
"steps",
".",
"each_with_index",
"do",
"|",
"step",
",",
"index",
"|",
"begin",
"instruction",
",",
"args",
"=",
"step",
".",
"split",
"' '"... | Build the scenario steps provided
@param [Array<String>] steps A collection of steps to build the scenario | [
"Build",
"the",
"scenario",
"steps",
"provided"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L131-L146 |
20,069 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.register | def register(user, password = nil, opts = {})
send_opts = opts.dup
send_opts[:retrans] ||= DEFAULT_RETRANS
user, domain = parse_user user
if password
send register_message(domain, user), send_opts
recv opts.merge(response: 401, auth: true, optional: false)
send register_a... | ruby | def register(user, password = nil, opts = {})
send_opts = opts.dup
send_opts[:retrans] ||= DEFAULT_RETRANS
user, domain = parse_user user
if password
send register_message(domain, user), send_opts
recv opts.merge(response: 401, auth: true, optional: false)
send register_a... | [
"def",
"register",
"(",
"user",
",",
"password",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"send_opts",
"=",
"opts",
".",
"dup",
"send_opts",
"[",
":retrans",
"]",
"||=",
"DEFAULT_RETRANS",
"user",
",",
"domain",
"=",
"parse_user",
"user",
"if",
"pa... | Send a REGISTER message with the specified credentials
@param [String] user the user to register as. May be given as a full SIP URI (sip:user@domain.com), in email-address format (user@domain.com) or as a simple username ('user'). If no domain is supplied, the source IP from SIPp will be used.
@param [optional, Stri... | [
"Send",
"a",
"REGISTER",
"message",
"with",
"the",
"specified",
"credentials"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L217-L229 |
20,070 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.receive_invite | def receive_invite(opts = {})
recv(opts.merge(request: 'INVITE', rrs: true)) do |recv|
action = doc.create_element('action') do |action|
action << doc.create_element('ereg') do |ereg|
ereg['regexp'] = '<sip:(.*)>.*;tag=([^;]*)'
ereg['search_in'] = 'hdr'
ereg['... | ruby | def receive_invite(opts = {})
recv(opts.merge(request: 'INVITE', rrs: true)) do |recv|
action = doc.create_element('action') do |action|
action << doc.create_element('ereg') do |ereg|
ereg['regexp'] = '<sip:(.*)>.*;tag=([^;]*)'
ereg['search_in'] = 'hdr'
ereg['... | [
"def",
"receive_invite",
"(",
"opts",
"=",
"{",
"}",
")",
"recv",
"(",
"opts",
".",
"merge",
"(",
"request",
":",
"'INVITE'",
",",
"rrs",
":",
"true",
")",
")",
"do",
"|",
"recv",
"|",
"action",
"=",
"doc",
".",
"create_element",
"(",
"'action'",
"... | Expect to receive a SIP INVITE
@param [Hash] opts A set of options containing SIPp <recv> element attributes | [
"Expect",
"to",
"receive",
"a",
"SIP",
"INVITE"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L236-L260 |
20,071 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.receive_answer | def receive_answer(opts = {})
options = {
rrs: true, # Record Record Set: Make the Route headers available via [routes] later
rtd: true # Response Time Duration: Record the response time
}
receive_200(options.merge(opts)) do |recv|
recv << doc.create_element('action') do |acti... | ruby | def receive_answer(opts = {})
options = {
rrs: true, # Record Record Set: Make the Route headers available via [routes] later
rtd: true # Response Time Duration: Record the response time
}
receive_200(options.merge(opts)) do |recv|
recv << doc.create_element('action') do |acti... | [
"def",
"receive_answer",
"(",
"opts",
"=",
"{",
"}",
")",
"options",
"=",
"{",
"rrs",
":",
"true",
",",
"# Record Record Set: Make the Route headers available via [routes] later",
"rtd",
":",
"true",
"# Response Time Duration: Record the response time",
"}",
"receive_200",
... | Sets an expectation for a SIP 200 message from the remote party
as well as storing the record set and the response time duration
@param [Hash] opts A set of options to modify the expectation
@option opts [true, false] :optional Whether or not receipt of the message is optional. Defaults to false. | [
"Sets",
"an",
"expectation",
"for",
"a",
"SIP",
"200",
"message",
"from",
"the",
"remote",
"party",
"as",
"well",
"as",
"storing",
"the",
"record",
"set",
"and",
"the",
"response",
"time",
"duration"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L394-L412 |
20,072 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.wait_for_answer | def wait_for_answer(opts = {})
receive_trying opts
receive_ringing opts
receive_progress opts
receive_answer opts
ack_answer opts
end | ruby | def wait_for_answer(opts = {})
receive_trying opts
receive_ringing opts
receive_progress opts
receive_answer opts
ack_answer opts
end | [
"def",
"wait_for_answer",
"(",
"opts",
"=",
"{",
"}",
")",
"receive_trying",
"opts",
"receive_ringing",
"opts",
"receive_progress",
"opts",
"receive_answer",
"opts",
"ack_answer",
"opts",
"end"
] | Convenience method to wait for an answer from the called party
This sets expectations for optional SIP 100, 180 and 183,
followed by a required 200 and sending the acknowledgement.
@param [Hash] opts A set of options to modify the expectations | [
"Convenience",
"method",
"to",
"wait",
"for",
"an",
"answer",
"from",
"the",
"called",
"party"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L433-L439 |
20,073 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.receive_message | def receive_message(regexp = nil)
recv = Nokogiri::XML::Node.new 'recv', doc
recv['request'] = 'MESSAGE'
scenario_node << recv
if regexp
action = Nokogiri::XML::Node.new 'action', doc
ereg = Nokogiri::XML::Node.new 'ereg', doc
ereg['regexp'] = regexp
ereg['searc... | ruby | def receive_message(regexp = nil)
recv = Nokogiri::XML::Node.new 'recv', doc
recv['request'] = 'MESSAGE'
scenario_node << recv
if regexp
action = Nokogiri::XML::Node.new 'action', doc
ereg = Nokogiri::XML::Node.new 'ereg', doc
ereg['regexp'] = regexp
ereg['searc... | [
"def",
"receive_message",
"(",
"regexp",
"=",
"nil",
")",
"recv",
"=",
"Nokogiri",
"::",
"XML",
"::",
"Node",
".",
"new",
"'recv'",
",",
"doc",
"recv",
"[",
"'request'",
"]",
"=",
"'MESSAGE'",
"scenario_node",
"<<",
"recv",
"if",
"regexp",
"action",
"=",... | Expect to receive a MESSAGE message
@param [String] regexp A regular expression (as a String) to match the message body against | [
"Expect",
"to",
"receive",
"a",
"MESSAGE",
"message"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L532-L554 |
20,074 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.call_length_repartition | def call_length_repartition(min, max, interval)
partition_table 'CallLengthRepartition', min.to_i, max.to_i, interval.to_i
end | ruby | def call_length_repartition(min, max, interval)
partition_table 'CallLengthRepartition', min.to_i, max.to_i, interval.to_i
end | [
"def",
"call_length_repartition",
"(",
"min",
",",
"max",
",",
"interval",
")",
"partition_table",
"'CallLengthRepartition'",
",",
"min",
".",
"to_i",
",",
"max",
".",
"to_i",
",",
"interval",
".",
"to_i",
"end"
] | Create partition table for Call Length
@param [Integer] min An value specifying the minimum time in milliseconds for the table
@param [Integer] max An value specifying the maximum time in milliseconds for the table
@param [Integer] interval An value specifying the interval in milliseconds for the table | [
"Create",
"partition",
"table",
"for",
"Call",
"Length"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L637-L639 |
20,075 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.response_time_repartition | def response_time_repartition(min, max, interval)
partition_table 'ResponseTimeRepartition', min.to_i, max.to_i, interval.to_i
end | ruby | def response_time_repartition(min, max, interval)
partition_table 'ResponseTimeRepartition', min.to_i, max.to_i, interval.to_i
end | [
"def",
"response_time_repartition",
"(",
"min",
",",
"max",
",",
"interval",
")",
"partition_table",
"'ResponseTimeRepartition'",
",",
"min",
".",
"to_i",
",",
"max",
".",
"to_i",
",",
"interval",
".",
"to_i",
"end"
] | Create partition table for Response Time
@param [Integer] min An value specifying the minimum time in milliseconds for the table
@param [Integer] max An value specifying the maximum time in milliseconds for the table
@param [Integer] interval An value specifying the interval in milliseconds for the table | [
"Create",
"partition",
"table",
"for",
"Response",
"Time"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L646-L648 |
20,076 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.to_xml | def to_xml(options = {})
pcap_path = options[:pcap_path]
docdup = doc.dup
# Not removing in reverse would most likely remove the wrong
# nodes because of changing indices.
@media_nodes.reverse.each do |nop|
nopdup = docdup.xpath(nop.path)
if pcap_path.nil? or @media.blank... | ruby | def to_xml(options = {})
pcap_path = options[:pcap_path]
docdup = doc.dup
# Not removing in reverse would most likely remove the wrong
# nodes because of changing indices.
@media_nodes.reverse.each do |nop|
nopdup = docdup.xpath(nop.path)
if pcap_path.nil? or @media.blank... | [
"def",
"to_xml",
"(",
"options",
"=",
"{",
"}",
")",
"pcap_path",
"=",
"options",
"[",
":pcap_path",
"]",
"docdup",
"=",
"doc",
".",
"dup",
"# Not removing in reverse would most likely remove the wrong",
"# nodes because of changing indices.",
"@media_nodes",
".",
"reve... | Dump the scenario to a SIPp XML string
@return [String] the SIPp XML scenario | [
"Dump",
"the",
"scenario",
"to",
"a",
"SIPp",
"XML",
"string"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L654-L679 |
20,077 | mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.compile! | def compile!
unless @media.blank?
print "Compiling media to #{@filename}.pcap..."
compile_media.to_file filename: "#{@filename}.pcap"
puts "done."
end
scenario_filename = "#{@filename}.xml"
print "Compiling scenario to #{scenario_filename}..."
File.open scenario_fi... | ruby | def compile!
unless @media.blank?
print "Compiling media to #{@filename}.pcap..."
compile_media.to_file filename: "#{@filename}.pcap"
puts "done."
end
scenario_filename = "#{@filename}.xml"
print "Compiling scenario to #{scenario_filename}..."
File.open scenario_fi... | [
"def",
"compile!",
"unless",
"@media",
".",
"blank?",
"print",
"\"Compiling media to #{@filename}.pcap...\"",
"compile_media",
".",
"to_file",
"filename",
":",
"\"#{@filename}.pcap\"",
"puts",
"\"done.\"",
"end",
"scenario_filename",
"=",
"\"#{@filename}.xml\"",
"print",
"\... | Compile the scenario and its media to disk
Writes the SIPp scenario file to disk at {filename}.xml, and the PCAP media to {filename}.pcap if applicable.
{filename} is taken from the :filename option when creating the scenario, or falls back to a down-snake-cased version of the scenario name.
@return [String] the p... | [
"Compile",
"the",
"scenario",
"and",
"its",
"media",
"to",
"disk"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L697-L712 |
20,078 | mojolingo/sippy_cup | lib/sippy_cup/xml_scenario.rb | SippyCup.XMLScenario.to_tmpfiles | def to_tmpfiles
scenario_file = Tempfile.new 'scenario'
scenario_file.write @xml
scenario_file.rewind
if @media
media_file = Tempfile.new 'media'
media_file.write @media
media_file.rewind
else
media_file = nil
end
{scenario: scenario_file, medi... | ruby | def to_tmpfiles
scenario_file = Tempfile.new 'scenario'
scenario_file.write @xml
scenario_file.rewind
if @media
media_file = Tempfile.new 'media'
media_file.write @media
media_file.rewind
else
media_file = nil
end
{scenario: scenario_file, medi... | [
"def",
"to_tmpfiles",
"scenario_file",
"=",
"Tempfile",
".",
"new",
"'scenario'",
"scenario_file",
".",
"write",
"@xml",
"scenario_file",
".",
"rewind",
"if",
"@media",
"media_file",
"=",
"Tempfile",
".",
"new",
"'media'",
"media_file",
".",
"write",
"@media",
"... | Create a scenario instance
@param [String] name The scenario's name
@param [String] xml The XML document representing the scenario
@param [String] media The media to be invoked by the scenario in PCAP format
@param [Hash] args options to customise the scenario. @see Scenario#initialize.
Write compiled Scenario ... | [
"Create",
"a",
"scenario",
"instance"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/xml_scenario.rb#L34-L48 |
20,079 | mojolingo/sippy_cup | lib/sippy_cup/runner.rb | SippyCup.Runner.wait | def wait
exit_status = Process.wait2 @sipp_pid.to_i
@err_rd.close if @err_rd
@stdout_rd.close if @stdout_rd
final_result = process_exit_status exit_status, @stderr_buffer
if final_result
@logger.info "Test completed successfully!"
else
@logger.info "Test completed suc... | ruby | def wait
exit_status = Process.wait2 @sipp_pid.to_i
@err_rd.close if @err_rd
@stdout_rd.close if @stdout_rd
final_result = process_exit_status exit_status, @stderr_buffer
if final_result
@logger.info "Test completed successfully!"
else
@logger.info "Test completed suc... | [
"def",
"wait",
"exit_status",
"=",
"Process",
".",
"wait2",
"@sipp_pid",
".",
"to_i",
"@err_rd",
".",
"close",
"if",
"@err_rd",
"@stdout_rd",
".",
"close",
"if",
"@stdout_rd",
"final_result",
"=",
"process_exit_status",
"exit_status",
",",
"@stderr_buffer",
"if",
... | Waits for the runner to finish execution
@raises Errno::ENOENT when the SIPp executable cannot be found
@raises SippyCup::ExitOnInternalCommand when SIPp exits on an internal command. Calls may have been processed
@raises SippyCup::NoCallsProcessed when SIPp exit normally, but has processed no calls
@raises SippyC... | [
"Waits",
"for",
"the",
"runner",
"to",
"finish",
"execution"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/runner.rb#L70-L85 |
20,080 | notahat/machinist | lib/machinist/machinable.rb | Machinist.Machinable.blueprint | def blueprint(name = :master, &block)
@blueprints ||= {}
if block_given?
parent = (name == :master ? superclass : self) # Where should we look for the parent blueprint?
@blueprints[name] = blueprint_class.new(self, :parent => parent, &block)
end
@blueprints[name]
end | ruby | def blueprint(name = :master, &block)
@blueprints ||= {}
if block_given?
parent = (name == :master ? superclass : self) # Where should we look for the parent blueprint?
@blueprints[name] = blueprint_class.new(self, :parent => parent, &block)
end
@blueprints[name]
end | [
"def",
"blueprint",
"(",
"name",
"=",
":master",
",",
"&",
"block",
")",
"@blueprints",
"||=",
"{",
"}",
"if",
"block_given?",
"parent",
"=",
"(",
"name",
"==",
":master",
"?",
"superclass",
":",
"self",
")",
"# Where should we look for the parent blueprint?",
... | Define a blueprint with the given name for this class.
e.g.
Post.blueprint do
title { "A Post" }
body { "Lorem ipsum..." }
end
If you provide the +name+ argument, a named blueprint will be created.
See the +blueprint_name+ argument to the make method. | [
"Define",
"a",
"blueprint",
"with",
"the",
"given",
"name",
"for",
"this",
"class",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/machinable.rb#L15-L22 |
20,081 | notahat/machinist | lib/machinist/machinable.rb | Machinist.Machinable.make! | def make!(*args)
decode_args_to_make(*args) do |blueprint, attributes|
raise BlueprintCantSaveError.new(blueprint) unless blueprint.respond_to?(:make!)
blueprint.make!(attributes)
end
end | ruby | def make!(*args)
decode_args_to_make(*args) do |blueprint, attributes|
raise BlueprintCantSaveError.new(blueprint) unless blueprint.respond_to?(:make!)
blueprint.make!(attributes)
end
end | [
"def",
"make!",
"(",
"*",
"args",
")",
"decode_args_to_make",
"(",
"args",
")",
"do",
"|",
"blueprint",
",",
"attributes",
"|",
"raise",
"BlueprintCantSaveError",
".",
"new",
"(",
"blueprint",
")",
"unless",
"blueprint",
".",
"respond_to?",
"(",
":make!",
")... | Construct and save an object from a blueprint, if the class allows saving.
:call-seq:
make!([count], [blueprint_name], [attributes = {}])
Arguments are the same as for make. | [
"Construct",
"and",
"save",
"an",
"object",
"from",
"a",
"blueprint",
"if",
"the",
"class",
"allows",
"saving",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/machinable.rb#L49-L54 |
20,082 | notahat/machinist | lib/machinist/machinable.rb | Machinist.Machinable.decode_args_to_make | def decode_args_to_make(*args) #:nodoc:
shift_arg = lambda {|klass| args.shift if args.first.is_a?(klass) }
count = shift_arg[Fixnum]
name = shift_arg[Symbol] || :master
attributes = shift_arg[Hash] || {}
raise ArgumentError.new("Couldn't understand arguments") unless args.emp... | ruby | def decode_args_to_make(*args) #:nodoc:
shift_arg = lambda {|klass| args.shift if args.first.is_a?(klass) }
count = shift_arg[Fixnum]
name = shift_arg[Symbol] || :master
attributes = shift_arg[Hash] || {}
raise ArgumentError.new("Couldn't understand arguments") unless args.emp... | [
"def",
"decode_args_to_make",
"(",
"*",
"args",
")",
"#:nodoc:",
"shift_arg",
"=",
"lambda",
"{",
"|",
"klass",
"|",
"args",
".",
"shift",
"if",
"args",
".",
"first",
".",
"is_a?",
"(",
"klass",
")",
"}",
"count",
"=",
"shift_arg",
"[",
"Fixnum",
"]",
... | Parses the arguments to make.
Yields a blueprint and an attributes hash to the block, which should
construct an object from them. The block may be called multiple times to
construct multiple objects. | [
"Parses",
"the",
"arguments",
"to",
"make",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/machinable.rb#L76-L92 |
20,083 | notahat/machinist | lib/machinist/blueprint.rb | Machinist.Blueprint.make | def make(attributes = {})
lathe = lathe_class.new(@klass, new_serial_number, attributes)
lathe.instance_eval(&@block)
each_ancestor {|blueprint| lathe.instance_eval(&blueprint.block) }
lathe.object
end | ruby | def make(attributes = {})
lathe = lathe_class.new(@klass, new_serial_number, attributes)
lathe.instance_eval(&@block)
each_ancestor {|blueprint| lathe.instance_eval(&blueprint.block) }
lathe.object
end | [
"def",
"make",
"(",
"attributes",
"=",
"{",
"}",
")",
"lathe",
"=",
"lathe_class",
".",
"new",
"(",
"@klass",
",",
"new_serial_number",
",",
"attributes",
")",
"lathe",
".",
"instance_eval",
"(",
"@block",
")",
"each_ancestor",
"{",
"|",
"blueprint",
"|",
... | Generate an object from this blueprint.
Pass in attributes to override values defined in the blueprint. | [
"Generate",
"an",
"object",
"from",
"this",
"blueprint",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/blueprint.rb#L23-L30 |
20,084 | zk-ruby/zookeeper | lib/zookeeper/request_registry.rb | Zookeeper.RequestRegistry.get_watcher | def get_watcher(req_id, opts={})
@mutex.synchronize do
if Constants::ZKRB_GLOBAL_CB_REQ == req_id
{ :watcher => @default_watcher, :watcher_context => nil }
elsif opts[:keep]
@watcher_reqs[req_id]
else
@watcher_reqs.delete(req_id)
end
... | ruby | def get_watcher(req_id, opts={})
@mutex.synchronize do
if Constants::ZKRB_GLOBAL_CB_REQ == req_id
{ :watcher => @default_watcher, :watcher_context => nil }
elsif opts[:keep]
@watcher_reqs[req_id]
else
@watcher_reqs.delete(req_id)
end
... | [
"def",
"get_watcher",
"(",
"req_id",
",",
"opts",
"=",
"{",
"}",
")",
"@mutex",
".",
"synchronize",
"do",
"if",
"Constants",
"::",
"ZKRB_GLOBAL_CB_REQ",
"==",
"req_id",
"{",
":watcher",
"=>",
"@default_watcher",
",",
":watcher_context",
"=>",
"nil",
"}",
"el... | Return the watcher hash associated with the req_id. If the req_id
is the ZKRB_GLOBAL_CB_REQ, then does not clear the req from the internal
store, otherwise the req_id is removed. | [
"Return",
"the",
"watcher",
"hash",
"associated",
"with",
"the",
"req_id",
".",
"If",
"the",
"req_id",
"is",
"the",
"ZKRB_GLOBAL_CB_REQ",
"then",
"does",
"not",
"clear",
"the",
"req",
"from",
"the",
"internal",
"store",
"otherwise",
"the",
"req_id",
"is",
"r... | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/lib/zookeeper/request_registry.rb#L82-L92 |
20,085 | zk-ruby/zookeeper | ext/c_zookeeper.rb | Zookeeper.CZookeeper.wait_until_connected | def wait_until_connected(timeout=10)
time_to_stop = timeout ? Time.now + timeout : nil
return false unless wait_until_running(timeout)
@state_mutex.synchronize do
while true
if timeout
now = Time.now
break if (@state == ZOO_CONNECTED_STATE) || unhealthy? || (now > time_t... | ruby | def wait_until_connected(timeout=10)
time_to_stop = timeout ? Time.now + timeout : nil
return false unless wait_until_running(timeout)
@state_mutex.synchronize do
while true
if timeout
now = Time.now
break if (@state == ZOO_CONNECTED_STATE) || unhealthy? || (now > time_t... | [
"def",
"wait_until_connected",
"(",
"timeout",
"=",
"10",
")",
"time_to_stop",
"=",
"timeout",
"?",
"Time",
".",
"now",
"+",
"timeout",
":",
"nil",
"return",
"false",
"unless",
"wait_until_running",
"(",
"timeout",
")",
"@state_mutex",
".",
"synchronize",
"do"... | this implementation is gross, but i don't really see another way of doing it
without more grossness
returns true if we're connected, false if we're not
if timeout is nil, we never time out, and wait forever for CONNECTED state | [
"this",
"implementation",
"is",
"gross",
"but",
"i",
"don",
"t",
"really",
"see",
"another",
"way",
"of",
"doing",
"it",
"without",
"more",
"grossness"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/c_zookeeper.rb#L178-L198 |
20,086 | zk-ruby/zookeeper | ext/c_zookeeper.rb | Zookeeper.CZookeeper.submit_and_block | def submit_and_block(meth, *args)
@mutex.synchronize do
raise Exceptions::NotConnected if unhealthy?
end
cnt = Continuation.new(meth, *args)
@reg.synchronize do |r|
if meth == :state
r.state_check << cnt
else
r.pending << cnt
end
end
... | ruby | def submit_and_block(meth, *args)
@mutex.synchronize do
raise Exceptions::NotConnected if unhealthy?
end
cnt = Continuation.new(meth, *args)
@reg.synchronize do |r|
if meth == :state
r.state_check << cnt
else
r.pending << cnt
end
end
... | [
"def",
"submit_and_block",
"(",
"meth",
",",
"*",
"args",
")",
"@mutex",
".",
"synchronize",
"do",
"raise",
"Exceptions",
"::",
"NotConnected",
"if",
"unhealthy?",
"end",
"cnt",
"=",
"Continuation",
".",
"new",
"(",
"meth",
",",
"args",
")",
"@reg",
".",
... | submits a job for processing
blocks the caller until result has returned | [
"submits",
"a",
"job",
"for",
"processing",
"blocks",
"the",
"caller",
"until",
"result",
"has",
"returned"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/c_zookeeper.rb#L217-L232 |
20,087 | zk-ruby/zookeeper | lib/zookeeper/continuation.rb | Zookeeper.Continuation.call | def call(hash)
logger.debug { "continuation req_id #{req_id}, got hash: #{hash.inspect}" }
@rval = hash.values_at(*METH_TO_ASYNC_RESULT_KEYS.fetch(meth))
logger.debug { "delivering result #{@rval.inspect}" }
deliver!
end | ruby | def call(hash)
logger.debug { "continuation req_id #{req_id}, got hash: #{hash.inspect}" }
@rval = hash.values_at(*METH_TO_ASYNC_RESULT_KEYS.fetch(meth))
logger.debug { "delivering result #{@rval.inspect}" }
deliver!
end | [
"def",
"call",
"(",
"hash",
")",
"logger",
".",
"debug",
"{",
"\"continuation req_id #{req_id}, got hash: #{hash.inspect}\"",
"}",
"@rval",
"=",
"hash",
".",
"values_at",
"(",
"METH_TO_ASYNC_RESULT_KEYS",
".",
"fetch",
"(",
"meth",
")",
")",
"logger",
".",
"debug"... | receive the response from the server, set @rval, notify caller | [
"receive",
"the",
"response",
"from",
"the",
"server",
"set"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/lib/zookeeper/continuation.rb#L141-L146 |
20,088 | zk-ruby/zookeeper | ext/zookeeper_base.rb | Zookeeper.ZookeeperBase.close | def close
sd_thread = nil
@mutex.synchronize do
return unless @czk
inst, @czk = @czk, nil
sd_thread = Thread.new(inst) do |_inst|
stop_dispatch_thread!
_inst.close
end
end
# if we're on the event dispatch thread for some stupid reason, then don't join
u... | ruby | def close
sd_thread = nil
@mutex.synchronize do
return unless @czk
inst, @czk = @czk, nil
sd_thread = Thread.new(inst) do |_inst|
stop_dispatch_thread!
_inst.close
end
end
# if we're on the event dispatch thread for some stupid reason, then don't join
u... | [
"def",
"close",
"sd_thread",
"=",
"nil",
"@mutex",
".",
"synchronize",
"do",
"return",
"unless",
"@czk",
"inst",
",",
"@czk",
"=",
"@czk",
",",
"nil",
"sd_thread",
"=",
"Thread",
".",
"new",
"(",
"inst",
")",
"do",
"|",
"_inst",
"|",
"stop_dispatch_threa... | close the connection normally, stops the dispatch thread and closes the
underlying connection cleanly | [
"close",
"the",
"connection",
"normally",
"stops",
"the",
"dispatch",
"thread",
"and",
"closes",
"the",
"underlying",
"connection",
"cleanly"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/zookeeper_base.rb#L129-L151 |
20,089 | zk-ruby/zookeeper | ext/zookeeper_base.rb | Zookeeper.ZookeeperBase.create | def create(*args)
# since we don't care about the inputs, just glob args
rc, new_path = czk.create(*args)
[rc, @req_registry.strip_chroot_from(new_path)]
end | ruby | def create(*args)
# since we don't care about the inputs, just glob args
rc, new_path = czk.create(*args)
[rc, @req_registry.strip_chroot_from(new_path)]
end | [
"def",
"create",
"(",
"*",
"args",
")",
"# since we don't care about the inputs, just glob args",
"rc",
",",
"new_path",
"=",
"czk",
".",
"create",
"(",
"args",
")",
"[",
"rc",
",",
"@req_registry",
".",
"strip_chroot_from",
"(",
"new_path",
")",
"]",
"end"
] | the C lib doesn't strip the chroot path off of returned path values, which
is pretty damn annoying. this is used to clean things up. | [
"the",
"C",
"lib",
"doesn",
"t",
"strip",
"the",
"chroot",
"path",
"off",
"of",
"returned",
"path",
"values",
"which",
"is",
"pretty",
"damn",
"annoying",
".",
"this",
"is",
"used",
"to",
"clean",
"things",
"up",
"."
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/zookeeper_base.rb#L155-L159 |
20,090 | zk-ruby/zookeeper | ext/zookeeper_base.rb | Zookeeper.ZookeeperBase.strip_chroot_from | def strip_chroot_from(path)
return path unless (chrooted? and path and path.start_with?(chroot_path))
path[chroot_path.length..-1]
end | ruby | def strip_chroot_from(path)
return path unless (chrooted? and path and path.start_with?(chroot_path))
path[chroot_path.length..-1]
end | [
"def",
"strip_chroot_from",
"(",
"path",
")",
"return",
"path",
"unless",
"(",
"chrooted?",
"and",
"path",
"and",
"path",
".",
"start_with?",
"(",
"chroot_path",
")",
")",
"path",
"[",
"chroot_path",
".",
"length",
"..",
"-",
"1",
"]",
"end"
] | if we're chrooted, this method will strip the chroot prefix from +path+ | [
"if",
"we",
"re",
"chrooted",
"this",
"method",
"will",
"strip",
"the",
"chroot",
"prefix",
"from",
"+",
"path",
"+"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/zookeeper_base.rb#L227-L230 |
20,091 | zk-ruby/zookeeper | spec/support/zookeeper_spec_helpers.rb | Zookeeper.SpecHelpers.rm_rf | def rm_rf(z, path)
z.get_children(:path => path).tap do |h|
if h[:rc].zero?
h[:children].each do |child|
rm_rf(z, File.join(path, child))
end
elsif h[:rc] == ZNONODE
# no-op
else
raise "Oh noes! unexpected return value! #{h.inspect}"
... | ruby | def rm_rf(z, path)
z.get_children(:path => path).tap do |h|
if h[:rc].zero?
h[:children].each do |child|
rm_rf(z, File.join(path, child))
end
elsif h[:rc] == ZNONODE
# no-op
else
raise "Oh noes! unexpected return value! #{h.inspect}"
... | [
"def",
"rm_rf",
"(",
"z",
",",
"path",
")",
"z",
".",
"get_children",
"(",
":path",
"=>",
"path",
")",
".",
"tap",
"do",
"|",
"h",
"|",
"if",
"h",
"[",
":rc",
"]",
".",
"zero?",
"h",
"[",
":children",
"]",
".",
"each",
"do",
"|",
"child",
"|"... | this is not as safe as the one in ZK, just to be used to clean up
when we're the only one adjusting a particular path | [
"this",
"is",
"not",
"as",
"safe",
"as",
"the",
"one",
"in",
"ZK",
"just",
"to",
"be",
"used",
"to",
"clean",
"up",
"when",
"we",
"re",
"the",
"only",
"one",
"adjusting",
"a",
"particular",
"path"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/spec/support/zookeeper_spec_helpers.rb#L37-L57 |
20,092 | cubesystems/releaf | releaf-content/lib/releaf/content/route.rb | Releaf::Content.Route.params | def params(method_or_path, options = {})
method_or_path = method_or_path.to_s
[
path_for(method_or_path, options),
options_for(method_or_path, options)
]
end | ruby | def params(method_or_path, options = {})
method_or_path = method_or_path.to_s
[
path_for(method_or_path, options),
options_for(method_or_path, options)
]
end | [
"def",
"params",
"(",
"method_or_path",
",",
"options",
"=",
"{",
"}",
")",
"method_or_path",
"=",
"method_or_path",
".",
"to_s",
"[",
"path_for",
"(",
"method_or_path",
",",
"options",
")",
",",
"options_for",
"(",
"method_or_path",
",",
"options",
")",
"]"... | Return node route params which can be used in Rails route options
@param method_or_path [String] string with action and controller for route (Ex. home#index)
@param options [Hash] options to merge with internally built params. Passed params overrides route params.
@return [Hash] route options. Will return at least ... | [
"Return",
"node",
"route",
"params",
"which",
"can",
"be",
"used",
"in",
"Rails",
"route",
"options"
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/route.rb#L18-L24 |
20,093 | cubesystems/releaf | releaf-content/lib/releaf/content/node.rb | Releaf::Content.Node.maintain_name | def maintain_name
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, name: "#{name}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "(#{total_count})"
end
if postfix
self.name = "#{name}#{postfix}... | ruby | def maintain_name
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, name: "#{name}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "(#{total_count})"
end
if postfix
self.name = "#{name}#{postfix}... | [
"def",
"maintain_name",
"postfix",
"=",
"nil",
"total_count",
"=",
"0",
"while",
"self",
".",
"class",
".",
"where",
"(",
"parent_id",
":",
"parent_id",
",",
"name",
":",
"\"#{name}#{postfix}\"",
")",
".",
"where",
"(",
"\"id != ?\"",
",",
"id",
".",
"to_i... | Maintain unique name within parent_id scope.
If name is not unique add numeric postfix. | [
"Maintain",
"unique",
"name",
"within",
"parent_id",
"scope",
".",
"If",
"name",
"is",
"not",
"unique",
"add",
"numeric",
"postfix",
"."
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/node.rb#L73-L85 |
20,094 | cubesystems/releaf | releaf-content/lib/releaf/content/node.rb | Releaf::Content.Node.maintain_slug | def maintain_slug
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, slug: "#{slug}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "-#{total_count}"
end
if postfix
self.slug = "#{slug}#{postfix}"... | ruby | def maintain_slug
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, slug: "#{slug}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "-#{total_count}"
end
if postfix
self.slug = "#{slug}#{postfix}"... | [
"def",
"maintain_slug",
"postfix",
"=",
"nil",
"total_count",
"=",
"0",
"while",
"self",
".",
"class",
".",
"where",
"(",
"parent_id",
":",
"parent_id",
",",
"slug",
":",
"\"#{slug}#{postfix}\"",
")",
".",
"where",
"(",
"\"id != ?\"",
",",
"id",
".",
"to_i... | Maintain unique slug within parent_id scope.
If slug is not unique add numeric postfix. | [
"Maintain",
"unique",
"slug",
"within",
"parent_id",
"scope",
".",
"If",
"slug",
"is",
"not",
"unique",
"add",
"numeric",
"postfix",
"."
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/node.rb#L89-L101 |
20,095 | cubesystems/releaf | releaf-content/lib/releaf/content/acts_as_node.rb | ActsAsNode.ClassMethods.acts_as_node | def acts_as_node(params: nil, fields: nil)
configuration = {params: params, fields: fields}
ActsAsNode.register_class(self.name)
# Store acts_as_node configuration
cattr_accessor :acts_as_node_configuration
self.acts_as_node_configuration = configuration
end | ruby | def acts_as_node(params: nil, fields: nil)
configuration = {params: params, fields: fields}
ActsAsNode.register_class(self.name)
# Store acts_as_node configuration
cattr_accessor :acts_as_node_configuration
self.acts_as_node_configuration = configuration
end | [
"def",
"acts_as_node",
"(",
"params",
":",
"nil",
",",
"fields",
":",
"nil",
")",
"configuration",
"=",
"{",
"params",
":",
"params",
",",
"fields",
":",
"fields",
"}",
"ActsAsNode",
".",
"register_class",
"(",
"self",
".",
"name",
")",
"# Store acts_as_no... | There are no configuration options yet. | [
"There",
"are",
"no",
"configuration",
"options",
"yet",
"."
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/acts_as_node.rb#L15-L23 |
20,096 | rr/rr | lib/rr/space.rb | RR.Space.verify_ordered_double | def verify_ordered_double(double)
unless double.terminal?
raise RR::Errors.build_error(:DoubleOrderError,
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation")
end
unless @ordered_doubles.first == double
message = Double.formatted_name(double.method_name, double... | ruby | def verify_ordered_double(double)
unless double.terminal?
raise RR::Errors.build_error(:DoubleOrderError,
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation")
end
unless @ordered_doubles.first == double
message = Double.formatted_name(double.method_name, double... | [
"def",
"verify_ordered_double",
"(",
"double",
")",
"unless",
"double",
".",
"terminal?",
"raise",
"RR",
"::",
"Errors",
".",
"build_error",
"(",
":DoubleOrderError",
",",
"\"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation\"",
")",
"end",
"unless",
"@orde... | Verifies that the passed in ordered Double is being called
in the correct position. | [
"Verifies",
"that",
"the",
"passed",
"in",
"ordered",
"Double",
"is",
"being",
"called",
"in",
"the",
"correct",
"position",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/lib/rr/space.rb#L38-L51 |
20,097 | rr/rr | lib/rr/space.rb | RR.Space.reset | def reset
RR.trim_backtrace = false
RR.overridden_error_class = nil
reset_ordered_doubles
Injections::DoubleInjection.reset
reset_method_missing_injections
reset_singleton_method_added_injections
reset_recorded_calls
reset_bound_objects
end | ruby | def reset
RR.trim_backtrace = false
RR.overridden_error_class = nil
reset_ordered_doubles
Injections::DoubleInjection.reset
reset_method_missing_injections
reset_singleton_method_added_injections
reset_recorded_calls
reset_bound_objects
end | [
"def",
"reset",
"RR",
".",
"trim_backtrace",
"=",
"false",
"RR",
".",
"overridden_error_class",
"=",
"nil",
"reset_ordered_doubles",
"Injections",
"::",
"DoubleInjection",
".",
"reset",
"reset_method_missing_injections",
"reset_singleton_method_added_injections",
"reset_recor... | Resets the registered Doubles and ordered Doubles | [
"Resets",
"the",
"registered",
"Doubles",
"and",
"ordered",
"Doubles"
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/lib/rr/space.rb#L61-L70 |
20,098 | rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.load_gems_in | def load_gems_in(*spec_dirs)
@gems.clear
spec_dirs.reverse_each do |spec_dir|
spec_files = Dir.glob File.join(spec_dir, '*.gemspec')
spec_files.each do |spec_file|
gemspec = self.class.load_specification spec_file.untaint
add_spec gemspec if gemspec
end
en... | ruby | def load_gems_in(*spec_dirs)
@gems.clear
spec_dirs.reverse_each do |spec_dir|
spec_files = Dir.glob File.join(spec_dir, '*.gemspec')
spec_files.each do |spec_file|
gemspec = self.class.load_specification spec_file.untaint
add_spec gemspec if gemspec
end
en... | [
"def",
"load_gems_in",
"(",
"*",
"spec_dirs",
")",
"@gems",
".",
"clear",
"spec_dirs",
".",
"reverse_each",
"do",
"|",
"spec_dir",
"|",
"spec_files",
"=",
"Dir",
".",
"glob",
"File",
".",
"join",
"(",
"spec_dir",
",",
"'*.gemspec'",
")",
"spec_files",
".",... | Reconstruct the source index from the specifications in +spec_dirs+. | [
"Reconstruct",
"the",
"source",
"index",
"from",
"the",
"specifications",
"in",
"+",
"spec_dirs",
"+",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L119-L132 |
20,099 | rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.index_signature | def index_signature
require 'digest'
Digest::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
end | ruby | def index_signature
require 'digest'
Digest::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
end | [
"def",
"index_signature",
"require",
"'digest'",
"Digest",
"::",
"SHA256",
".",
"new",
".",
"hexdigest",
"(",
"@gems",
".",
"keys",
".",
"sort",
".",
"join",
"(",
"','",
")",
")",
".",
"to_s",
"end"
] | The signature for the source index. Changes in the signature indicate a
change in the index. | [
"The",
"signature",
"for",
"the",
"source",
"index",
".",
"Changes",
"in",
"the",
"signature",
"indicate",
"a",
"change",
"in",
"the",
"index",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L228-L232 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.