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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2,700 | siong1987/mongoid_shortener | app/controllers/mongoid_shortener/shortened_urls_controller.rb | MongoidShortener.ShortenedUrlsController.translate | def translate
# pull the link out of the db
sl = ShortenedUrl.where(:unique_key => params[:unique_key][1..-1]).first
if sl
sl.inc(:use_count, 1)
# do a 301 redirect to the destination url
head :moved_permanently, :location => sl.url
else
# if we don't find the sh... | ruby | def translate
# pull the link out of the db
sl = ShortenedUrl.where(:unique_key => params[:unique_key][1..-1]).first
if sl
sl.inc(:use_count, 1)
# do a 301 redirect to the destination url
head :moved_permanently, :location => sl.url
else
# if we don't find the sh... | [
"def",
"translate",
"# pull the link out of the db",
"sl",
"=",
"ShortenedUrl",
".",
"where",
"(",
":unique_key",
"=>",
"params",
"[",
":unique_key",
"]",
"[",
"1",
"..",
"-",
"1",
"]",
")",
".",
"first",
"if",
"sl",
"sl",
".",
"inc",
"(",
":use_count",
... | find the real link for the shortened link key and redirect | [
"find",
"the",
"real",
"link",
"for",
"the",
"shortened",
"link",
"key",
"and",
"redirect"
] | 32888cef58d9980d01d04d2ef42ad49ae5d06d04 | https://github.com/siong1987/mongoid_shortener/blob/32888cef58d9980d01d04d2ef42ad49ae5d06d04/app/controllers/mongoid_shortener/shortened_urls_controller.rb#L4-L17 |
2,701 | jkraemer/acts_as_ferret | lib/acts_as_ferret/act_methods.rb | ActsAsFerret.ActMethods.acts_as_ferret | def acts_as_ferret(options={})
extend ClassMethods
include InstanceMethods
include MoreLikeThis::InstanceMethods
if options[:rdig]
cattr_accessor :rdig_configuration
self.rdig_configuration = options[:rdig]
require 'rdig_adapter'
include ActsAsFerret::RdigAdapt... | ruby | def acts_as_ferret(options={})
extend ClassMethods
include InstanceMethods
include MoreLikeThis::InstanceMethods
if options[:rdig]
cattr_accessor :rdig_configuration
self.rdig_configuration = options[:rdig]
require 'rdig_adapter'
include ActsAsFerret::RdigAdapt... | [
"def",
"acts_as_ferret",
"(",
"options",
"=",
"{",
"}",
")",
"extend",
"ClassMethods",
"include",
"InstanceMethods",
"include",
"MoreLikeThis",
"::",
"InstanceMethods",
"if",
"options",
"[",
":rdig",
"]",
"cattr_accessor",
":rdig_configuration",
"self",
".",
"rdig_c... | declares a class as ferret-searchable.
====options:
fields:: names all fields to include in the index. If not given,
all attributes of the class will be indexed. You may also give
symbols pointing to instance methods of your model here, i.e.
to retrieve and index data from a related mod... | [
"declares",
"a",
"class",
"as",
"ferret",
"-",
"searchable",
"."
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/act_methods.rb#L60-L106 |
2,702 | jkraemer/acts_as_ferret | lib/acts_as_ferret/act_methods.rb | ActsAsFerret.ActMethods.define_to_field_method | def define_to_field_method(field, options = {})
method_name = "#{field}_to_ferret"
return if instance_methods.include?(method_name) # already defined
aaf_configuration[:defined_fields] ||= {}
aaf_configuration[:defined_fields][field] = options
dynamic_boost = options[:boost] if options[:bo... | ruby | def define_to_field_method(field, options = {})
method_name = "#{field}_to_ferret"
return if instance_methods.include?(method_name) # already defined
aaf_configuration[:defined_fields] ||= {}
aaf_configuration[:defined_fields][field] = options
dynamic_boost = options[:boost] if options[:bo... | [
"def",
"define_to_field_method",
"(",
"field",
",",
"options",
"=",
"{",
"}",
")",
"method_name",
"=",
"\"#{field}_to_ferret\"",
"return",
"if",
"instance_methods",
".",
"include?",
"(",
"method_name",
")",
"# already defined",
"aaf_configuration",
"[",
":defined_fiel... | helper to defines a method which adds the given field to a ferret
document instance | [
"helper",
"to",
"defines",
"a",
"method",
"which",
"adds",
"the",
"given",
"field",
"to",
"a",
"ferret",
"document",
"instance"
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/act_methods.rb#L114-L131 |
2,703 | nicholasjackson/minke | lib/minke/command.rb | Minke.Command.create_dependencies | def create_dependencies task
project_name = "minke#{SecureRandom.urlsafe_base64(12)}".downcase.gsub(/[^0-9a-z ]/i, '')
network_name = ENV['DOCKER_NETWORK'] ||= "#{project_name}_default"
ENV['DOCKER_PROJECT'] = project_name
ENV['DOCKER_NETWORK'] = network_name
logger = Minke::Logging.creat... | ruby | def create_dependencies task
project_name = "minke#{SecureRandom.urlsafe_base64(12)}".downcase.gsub(/[^0-9a-z ]/i, '')
network_name = ENV['DOCKER_NETWORK'] ||= "#{project_name}_default"
ENV['DOCKER_PROJECT'] = project_name
ENV['DOCKER_NETWORK'] = network_name
logger = Minke::Logging.creat... | [
"def",
"create_dependencies",
"task",
"project_name",
"=",
"\"minke#{SecureRandom.urlsafe_base64(12)}\"",
".",
"downcase",
".",
"gsub",
"(",
"/",
"/i",
",",
"''",
")",
"network_name",
"=",
"ENV",
"[",
"'DOCKER_NETWORK'",
"]",
"||=",
"\"#{project_name}_default\"",
"ENV... | Creates dependencies for minke | [
"Creates",
"dependencies",
"for",
"minke"
] | 56de4de0bcc2eebc72583fedf4fe812b6f519ffb | https://github.com/nicholasjackson/minke/blob/56de4de0bcc2eebc72583fedf4fe812b6f519ffb/lib/minke/command.rb#L13-L60 |
2,704 | holman/rapinoe | lib/rapinoe/slide.rb | Rapinoe.Slide.write_preview_to_file | def write_preview_to_file(path)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'wb') do |out|
out.write(preview_data)
end
end | ruby | def write_preview_to_file(path)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'wb') do |out|
out.write(preview_data)
end
end | [
"def",
"write_preview_to_file",
"(",
"path",
")",
"FileUtils",
".",
"mkdir_p",
"(",
"File",
".",
"dirname",
"(",
"path",
")",
")",
"File",
".",
"open",
"(",
"path",
",",
"'wb'",
")",
"do",
"|",
"out",
"|",
"out",
".",
"write",
"(",
"preview_data",
")... | Writes the preview for this slide to disk. | [
"Writes",
"the",
"preview",
"for",
"this",
"slide",
"to",
"disk",
"."
] | 6e76d8e2f16f5e7af859c4b16417c442166f19e6 | https://github.com/holman/rapinoe/blob/6e76d8e2f16f5e7af859c4b16417c442166f19e6/lib/rapinoe/slide.rb#L35-L40 |
2,705 | gemnasium/gemnasium-gem | lib/gemnasium/configuration.rb | Gemnasium.Configuration.is_valid? | def is_valid?
site_option_valid = !site.nil? && !site.empty?
api_key_option_valid = !api_key.nil? && !api_key.empty?
use_ssl_option_valid = !use_ssl.nil? && !!use_ssl == use_ssl # Check this is a boolean
api_version_option_valid = !api_version.nil? && !... | ruby | def is_valid?
site_option_valid = !site.nil? && !site.empty?
api_key_option_valid = !api_key.nil? && !api_key.empty?
use_ssl_option_valid = !use_ssl.nil? && !!use_ssl == use_ssl # Check this is a boolean
api_version_option_valid = !api_version.nil? && !... | [
"def",
"is_valid?",
"site_option_valid",
"=",
"!",
"site",
".",
"nil?",
"&&",
"!",
"site",
".",
"empty?",
"api_key_option_valid",
"=",
"!",
"api_key",
".",
"nil?",
"&&",
"!",
"api_key",
".",
"empty?",
"use_ssl_option_valid",
"=",
"!",
"use_ssl",
".",
"nil?",... | Check that mandatory parameters are not nil and contain valid values
@return [Boolean] if configuration is valid | [
"Check",
"that",
"mandatory",
"parameters",
"are",
"not",
"nil",
"and",
"contain",
"valid",
"values"
] | 882b43337b4f483cdd0f93fff2e3db96d94998e0 | https://github.com/gemnasium/gemnasium-gem/blob/882b43337b4f483cdd0f93fff2e3db96d94998e0/lib/gemnasium/configuration.rb#L87-L97 |
2,706 | postmodern/gscraper | lib/gscraper/sponsored_links.rb | GScraper.SponsoredLinks.ads_with_title | def ads_with_title(title)
return enum_for(:ads_with_title,title) unless block_given?
comparitor = if title.kind_of?(Regexp)
lambda { |ad| ad.title =~ title }
else
lambda { |ad| ad.title == title }
end
return ads_with do ... | ruby | def ads_with_title(title)
return enum_for(:ads_with_title,title) unless block_given?
comparitor = if title.kind_of?(Regexp)
lambda { |ad| ad.title =~ title }
else
lambda { |ad| ad.title == title }
end
return ads_with do ... | [
"def",
"ads_with_title",
"(",
"title",
")",
"return",
"enum_for",
"(",
":ads_with_title",
",",
"title",
")",
"unless",
"block_given?",
"comparitor",
"=",
"if",
"title",
".",
"kind_of?",
"(",
"Regexp",
")",
"lambda",
"{",
"|",
"ad",
"|",
"ad",
".",
"title",... | Selects the ads with the matching title.
@param [String, Regexp] title
The title to search for.
@yield [ad]
Each matching ad will be passed to the given block.
@yieldparam [SponsoredAd] ad
A sponsored ad with the matching title.
@return [Array, Enumerator]
The sponsored ads with the matching title. ... | [
"Selects",
"the",
"ads",
"with",
"the",
"matching",
"title",
"."
] | 8370880a7b0c03b3c12a5ba3dfc19a6230187d6a | https://github.com/postmodern/gscraper/blob/8370880a7b0c03b3c12a5ba3dfc19a6230187d6a/lib/gscraper/sponsored_links.rb#L126-L142 |
2,707 | postmodern/gscraper | lib/gscraper/sponsored_links.rb | GScraper.SponsoredLinks.ads_with_url | def ads_with_url(url)
return enum_for(:ads_with_url,url) unless block_given?
comparitor = if url.kind_of?(Regexp)
lambda { |ad| ad.url =~ url }
else
lambda { |ad| ad.url == url }
end
return ads_with do |ad|
if co... | ruby | def ads_with_url(url)
return enum_for(:ads_with_url,url) unless block_given?
comparitor = if url.kind_of?(Regexp)
lambda { |ad| ad.url =~ url }
else
lambda { |ad| ad.url == url }
end
return ads_with do |ad|
if co... | [
"def",
"ads_with_url",
"(",
"url",
")",
"return",
"enum_for",
"(",
":ads_with_url",
",",
"url",
")",
"unless",
"block_given?",
"comparitor",
"=",
"if",
"url",
".",
"kind_of?",
"(",
"Regexp",
")",
"lambda",
"{",
"|",
"ad",
"|",
"ad",
".",
"url",
"=~",
"... | Selects the ads with the matching URL.
@param [String, Regexp] url
The URL to search for.
@yield [ad]
Each matching ad will be passed to the given block.
@yieldparam [SponsoredAd] ad
A sponsored ad with the matching URL.
@return [Array, Enumerator]
The sponsored ads with the matching URL. If no bloc... | [
"Selects",
"the",
"ads",
"with",
"the",
"matching",
"URL",
"."
] | 8370880a7b0c03b3c12a5ba3dfc19a6230187d6a | https://github.com/postmodern/gscraper/blob/8370880a7b0c03b3c12a5ba3dfc19a6230187d6a/lib/gscraper/sponsored_links.rb#L164-L180 |
2,708 | postmodern/gscraper | lib/gscraper/sponsored_links.rb | GScraper.SponsoredLinks.ads_with_direct_url | def ads_with_direct_url(direct_url)
return enum_for(:ads_with_direct_url,direct_url) unless block_given?
comparitor = if direct_url.kind_of?(Regexp)
lambda { |ad| ad.direct_url =~ direct_url }
else
lambda { |ad| ad.direct_url == direct_url }
... | ruby | def ads_with_direct_url(direct_url)
return enum_for(:ads_with_direct_url,direct_url) unless block_given?
comparitor = if direct_url.kind_of?(Regexp)
lambda { |ad| ad.direct_url =~ direct_url }
else
lambda { |ad| ad.direct_url == direct_url }
... | [
"def",
"ads_with_direct_url",
"(",
"direct_url",
")",
"return",
"enum_for",
"(",
":ads_with_direct_url",
",",
"direct_url",
")",
"unless",
"block_given?",
"comparitor",
"=",
"if",
"direct_url",
".",
"kind_of?",
"(",
"Regexp",
")",
"lambda",
"{",
"|",
"ad",
"|",
... | Selects the ads with the matching direct URL.
@param [String, Regexp] direct_url
The direct URL to search for.
@yield [ad]
Each matching ad will be passed to the given block.
@yieldparam [SponsoredAd] ad
A sponsored ad with the matching direct URL.
@return [Array, Enumerator]
The sponsored ads with ... | [
"Selects",
"the",
"ads",
"with",
"the",
"matching",
"direct",
"URL",
"."
] | 8370880a7b0c03b3c12a5ba3dfc19a6230187d6a | https://github.com/postmodern/gscraper/blob/8370880a7b0c03b3c12a5ba3dfc19a6230187d6a/lib/gscraper/sponsored_links.rb#L202-L218 |
2,709 | holman/rapinoe | lib/rapinoe/keynote.rb | Rapinoe.Keynote.aspect_ratio | def aspect_ratio
path = "/tmp/rapinoe-aspect"
write_preview_to_file(path)
dimensions = FastImage.size(path)
widescreen = (16/9.0)
if widescreen == (dimensions[0] / dimensions[1].to_f)
:widescreen
else
:standard
end
end | ruby | def aspect_ratio
path = "/tmp/rapinoe-aspect"
write_preview_to_file(path)
dimensions = FastImage.size(path)
widescreen = (16/9.0)
if widescreen == (dimensions[0] / dimensions[1].to_f)
:widescreen
else
:standard
end
end | [
"def",
"aspect_ratio",
"path",
"=",
"\"/tmp/rapinoe-aspect\"",
"write_preview_to_file",
"(",
"path",
")",
"dimensions",
"=",
"FastImage",
".",
"size",
"(",
"path",
")",
"widescreen",
"=",
"(",
"16",
"/",
"9.0",
")",
"if",
"widescreen",
"==",
"(",
"dimensions",... | The aspect ratio of the deck.
Returns a Symbol, either :widescreen or :standard (4:3). | [
"The",
"aspect",
"ratio",
"of",
"the",
"deck",
"."
] | 6e76d8e2f16f5e7af859c4b16417c442166f19e6 | https://github.com/holman/rapinoe/blob/6e76d8e2f16f5e7af859c4b16417c442166f19e6/lib/rapinoe/keynote.rb#L31-L43 |
2,710 | holman/rapinoe | lib/rapinoe/keynote.rb | Rapinoe.Keynote.colors | def colors
return @colors if @colors
path = "/tmp/rapinoe-aspect"
write_preview_to_file(path)
colors = Miro::DominantColors.new(path)
by_percentage = colors.by_percentage
hash = {}
colors.to_rgb.each_with_index do |hex, i|
hash[hex] = by_percentage[i]
end
... | ruby | def colors
return @colors if @colors
path = "/tmp/rapinoe-aspect"
write_preview_to_file(path)
colors = Miro::DominantColors.new(path)
by_percentage = colors.by_percentage
hash = {}
colors.to_rgb.each_with_index do |hex, i|
hash[hex] = by_percentage[i]
end
... | [
"def",
"colors",
"return",
"@colors",
"if",
"@colors",
"path",
"=",
"\"/tmp/rapinoe-aspect\"",
"write_preview_to_file",
"(",
"path",
")",
"colors",
"=",
"Miro",
"::",
"DominantColors",
".",
"new",
"(",
"path",
")",
"by_percentage",
"=",
"colors",
".",
"by_percen... | The top colors present in the title slide.
This returns a Hash of the color (in RGB) and its percentage in the frame.
For example:
{
[1, 1, 1] => 0.7296031746031746,
[8, 12, 15] => 0.13706349206349205,
[ … ]
} | [
"The",
"top",
"colors",
"present",
"in",
"the",
"title",
"slide",
"."
] | 6e76d8e2f16f5e7af859c4b16417c442166f19e6 | https://github.com/holman/rapinoe/blob/6e76d8e2f16f5e7af859c4b16417c442166f19e6/lib/rapinoe/keynote.rb#L60-L75 |
2,711 | xcres/xcres | lib/xcres/model/xcassets/resource_image.rb | XCRes::XCAssets.ResourceImage.read | def read(hash)
self.scale = hash.delete('scale').sub(/x$/, '').to_i unless hash['scale'].nil?
KNOWN_KEYS.each do |key|
value = hash.delete(key.to_s.dasherize)
next if value.nil?
self.send "#{key}=".to_sym, value
end
self.attributes = hash
return self
end | ruby | def read(hash)
self.scale = hash.delete('scale').sub(/x$/, '').to_i unless hash['scale'].nil?
KNOWN_KEYS.each do |key|
value = hash.delete(key.to_s.dasherize)
next if value.nil?
self.send "#{key}=".to_sym, value
end
self.attributes = hash
return self
end | [
"def",
"read",
"(",
"hash",
")",
"self",
".",
"scale",
"=",
"hash",
".",
"delete",
"(",
"'scale'",
")",
".",
"sub",
"(",
"/",
"/",
",",
"''",
")",
".",
"to_i",
"unless",
"hash",
"[",
"'scale'",
"]",
".",
"nil?",
"KNOWN_KEYS",
".",
"each",
"do",
... | Initialize a new ResourceImage
@param [Hash]
the initial attribute values
Read from hash
@param [Hash]
the hash to deserialize
@return [ResourceImage] | [
"Initialize",
"a",
"new",
"ResourceImage"
] | 4747b072ab316e7c6f389db9a3cad584e814fe43 | https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/model/xcassets/resource_image.rb#L90-L102 |
2,712 | xcres/xcres | lib/xcres/model/xcassets/resource_image.rb | XCRes::XCAssets.ResourceImage.to_hash | def to_hash
hash = {}
hash['scale'] = "#{scale}x" unless scale.nil?
(KNOWN_KEYS - [:scale]).each do |key|
value = self.send(key)
hash[key.to_s.dasherize] = value.to_s unless value.nil?
end
attributes.each do |key, value|
hash[key.to_s] = value
end
ha... | ruby | def to_hash
hash = {}
hash['scale'] = "#{scale}x" unless scale.nil?
(KNOWN_KEYS - [:scale]).each do |key|
value = self.send(key)
hash[key.to_s.dasherize] = value.to_s unless value.nil?
end
attributes.each do |key, value|
hash[key.to_s] = value
end
ha... | [
"def",
"to_hash",
"hash",
"=",
"{",
"}",
"hash",
"[",
"'scale'",
"]",
"=",
"\"#{scale}x\"",
"unless",
"scale",
".",
"nil?",
"(",
"KNOWN_KEYS",
"-",
"[",
":scale",
"]",
")",
".",
"each",
"do",
"|",
"key",
"|",
"value",
"=",
"self",
".",
"send",
"(",... | Serialize to hash
@return [Hash{String => String}] | [
"Serialize",
"to",
"hash"
] | 4747b072ab316e7c6f389db9a3cad584e814fe43 | https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/model/xcassets/resource_image.rb#L108-L123 |
2,713 | xcres/xcres | lib/xcres/analyzer/aggregate_analyzer.rb | XCRes.AggregateAnalyzer.add_with_class | def add_with_class(analyzer_class, options={})
analyzer = analyzer_class.new(target, self.options.merge(options))
analyzer.exclude_file_patterns = exclude_file_patterns
analyzer.logger = logger
self.analyzers << analyzer
analyzer
end | ruby | def add_with_class(analyzer_class, options={})
analyzer = analyzer_class.new(target, self.options.merge(options))
analyzer.exclude_file_patterns = exclude_file_patterns
analyzer.logger = logger
self.analyzers << analyzer
analyzer
end | [
"def",
"add_with_class",
"(",
"analyzer_class",
",",
"options",
"=",
"{",
"}",
")",
"analyzer",
"=",
"analyzer_class",
".",
"new",
"(",
"target",
",",
"self",
".",
"options",
".",
"merge",
"(",
"options",
")",
")",
"analyzer",
".",
"exclude_file_patterns",
... | Instantiate and add an analyzer by its class.
All properties will be copied to the child analyzer.
@param [Class] analyzer_class
the class of the analyzer to instantiate and add
@param [Hash] options
options which will be passed on initialization
@return [Analyzer] | [
"Instantiate",
"and",
"add",
"an",
"analyzer",
"by",
"its",
"class",
".",
"All",
"properties",
"will",
"be",
"copied",
"to",
"the",
"child",
"analyzer",
"."
] | 4747b072ab316e7c6f389db9a3cad584e814fe43 | https://github.com/xcres/xcres/blob/4747b072ab316e7c6f389db9a3cad584e814fe43/lib/xcres/analyzer/aggregate_analyzer.rb#L38-L44 |
2,714 | sush/lieu | lib/lieu/request.rb | Lieu.Request.post | def post(path, options={})
response = request(:post, path, options)
response.delete(:status) if response.respond_to?(:status)
response
end | ruby | def post(path, options={})
response = request(:post, path, options)
response.delete(:status) if response.respond_to?(:status)
response
end | [
"def",
"post",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"request",
"(",
":post",
",",
"path",
",",
"options",
")",
"response",
".",
"delete",
"(",
":status",
")",
"if",
"response",
".",
"respond_to?",
"(",
":status",
")",
"re... | Make a HTTP POST request.
@param path [String] The path, relative to api_endpoint
@param options [Hash] body params for request
@return [Hashie::Mash] | [
"Make",
"a",
"HTTP",
"POST",
"request",
"."
] | b6bb5e82931308c80ed52bd7969df48fbafe8668 | https://github.com/sush/lieu/blob/b6bb5e82931308c80ed52bd7969df48fbafe8668/lib/lieu/request.rb#L18-L24 |
2,715 | siong1987/mongoid_shortener | app/helpers/mongoid_shortener/shortened_urls_helper.rb | MongoidShortener.ShortenedUrlsHelper.shortened_url | def shortened_url(url)
raise "Only String accepted: #{url}" unless url.class == String
short_url = MongoidShortener::ShortenedUrl.generate(url)
short_url
end | ruby | def shortened_url(url)
raise "Only String accepted: #{url}" unless url.class == String
short_url = MongoidShortener::ShortenedUrl.generate(url)
short_url
end | [
"def",
"shortened_url",
"(",
"url",
")",
"raise",
"\"Only String accepted: #{url}\"",
"unless",
"url",
".",
"class",
"==",
"String",
"short_url",
"=",
"MongoidShortener",
"::",
"ShortenedUrl",
".",
"generate",
"(",
"url",
")",
"short_url",
"end"
] | generate a url from either a url string, or a shortened url object | [
"generate",
"a",
"url",
"from",
"either",
"a",
"url",
"string",
"or",
"a",
"shortened",
"url",
"object"
] | 32888cef58d9980d01d04d2ef42ad49ae5d06d04 | https://github.com/siong1987/mongoid_shortener/blob/32888cef58d9980d01d04d2ef42ad49ae5d06d04/app/helpers/mongoid_shortener/shortened_urls_helper.rb#L4-L8 |
2,716 | jkraemer/acts_as_ferret | lib/acts_as_ferret/local_index.rb | ActsAsFerret.LocalIndex.ferret_index | def ferret_index
ensure_index_exists
(@ferret_index ||= Ferret::Index::Index.new(index_definition[:ferret])).tap do |idx|
idx.batch_size = index_definition[:reindex_batch_size]
idx.logger = logger
end
end | ruby | def ferret_index
ensure_index_exists
(@ferret_index ||= Ferret::Index::Index.new(index_definition[:ferret])).tap do |idx|
idx.batch_size = index_definition[:reindex_batch_size]
idx.logger = logger
end
end | [
"def",
"ferret_index",
"ensure_index_exists",
"(",
"@ferret_index",
"||=",
"Ferret",
"::",
"Index",
"::",
"Index",
".",
"new",
"(",
"index_definition",
"[",
":ferret",
"]",
")",
")",
".",
"tap",
"do",
"|",
"idx",
"|",
"idx",
".",
"batch_size",
"=",
"index_... | The 'real' Ferret Index instance | [
"The",
"real",
"Ferret",
"Index",
"instance"
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/local_index.rb#L17-L23 |
2,717 | jkraemer/acts_as_ferret | lib/acts_as_ferret/local_index.rb | ActsAsFerret.LocalIndex.rebuild_index | def rebuild_index
models = index_definition[:registered_models]
logger.debug "rebuild index with models: #{models.inspect}"
close
index = Ferret::Index::Index.new(index_definition[:ferret].dup.update(:auto_flush => false,
... | ruby | def rebuild_index
models = index_definition[:registered_models]
logger.debug "rebuild index with models: #{models.inspect}"
close
index = Ferret::Index::Index.new(index_definition[:ferret].dup.update(:auto_flush => false,
... | [
"def",
"rebuild_index",
"models",
"=",
"index_definition",
"[",
":registered_models",
"]",
"logger",
".",
"debug",
"\"rebuild index with models: #{models.inspect}\"",
"close",
"index",
"=",
"Ferret",
"::",
"Index",
"::",
"Index",
".",
"new",
"(",
"index_definition",
"... | rebuilds the index from all records of the model classes associated with this index | [
"rebuilds",
"the",
"index",
"from",
"all",
"records",
"of",
"the",
"model",
"classes",
"associated",
"with",
"this",
"index"
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/local_index.rb#L45-L56 |
2,718 | jkraemer/acts_as_ferret | lib/acts_as_ferret/local_index.rb | ActsAsFerret.LocalIndex.process_query | def process_query(query, options = {})
return query unless String === query
ferret_index.synchronize do
if options[:analyzer]
# use per-query analyzer if present
qp = Ferret::QueryParser.new ferret_index.instance_variable_get('@options').merge(options)
reader = ferret_i... | ruby | def process_query(query, options = {})
return query unless String === query
ferret_index.synchronize do
if options[:analyzer]
# use per-query analyzer if present
qp = Ferret::QueryParser.new ferret_index.instance_variable_get('@options').merge(options)
reader = ferret_i... | [
"def",
"process_query",
"(",
"query",
",",
"options",
"=",
"{",
"}",
")",
"return",
"query",
"unless",
"String",
"===",
"query",
"ferret_index",
".",
"synchronize",
"do",
"if",
"options",
"[",
":analyzer",
"]",
"# use per-query analyzer if present",
"qp",
"=",
... | Parses the given query string into a Ferret Query object. | [
"Parses",
"the",
"given",
"query",
"string",
"into",
"a",
"Ferret",
"Query",
"object",
"."
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/local_index.rb#L63-L79 |
2,719 | jkraemer/acts_as_ferret | lib/acts_as_ferret/local_index.rb | ActsAsFerret.LocalIndex.total_hits | def total_hits(query, options = {})
ferret_index.search(process_query(query, options), options).total_hits
end | ruby | def total_hits(query, options = {})
ferret_index.search(process_query(query, options), options).total_hits
end | [
"def",
"total_hits",
"(",
"query",
",",
"options",
"=",
"{",
"}",
")",
"ferret_index",
".",
"search",
"(",
"process_query",
"(",
"query",
",",
"options",
")",
",",
"options",
")",
".",
"total_hits",
"end"
] | Total number of hits for the given query. | [
"Total",
"number",
"of",
"hits",
"for",
"the",
"given",
"query",
"."
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/local_index.rb#L82-L84 |
2,720 | jkraemer/acts_as_ferret | lib/acts_as_ferret/local_index.rb | ActsAsFerret.LocalIndex.highlight | def highlight(key, query, options = {})
logger.debug("highlight: #{key} query: #{query}")
options.reverse_merge! :num_excerpts => 2, :pre_tag => '<em>', :post_tag => '</em>'
highlights = []
ferret_index.synchronize do
doc_num = document_number(key)
if options[:field]
h... | ruby | def highlight(key, query, options = {})
logger.debug("highlight: #{key} query: #{query}")
options.reverse_merge! :num_excerpts => 2, :pre_tag => '<em>', :post_tag => '</em>'
highlights = []
ferret_index.synchronize do
doc_num = document_number(key)
if options[:field]
h... | [
"def",
"highlight",
"(",
"key",
",",
"query",
",",
"options",
"=",
"{",
"}",
")",
"logger",
".",
"debug",
"(",
"\"highlight: #{key} query: #{query}\"",
")",
"options",
".",
"reverse_merge!",
":num_excerpts",
"=>",
"2",
",",
":pre_tag",
"=>",
"'<em>'",
",",
"... | highlight search terms for the record with the given id. | [
"highlight",
"search",
"terms",
"for",
"the",
"record",
"with",
"the",
"given",
"id",
"."
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/local_index.rb#L115-L134 |
2,721 | jkraemer/acts_as_ferret | lib/acts_as_ferret/local_index.rb | ActsAsFerret.LocalIndex.document_number | def document_number(key)
docnum = ferret_index.doc_number(key)
# hits = ferret_index.search query_for_record(key)
# return hits.hits.first.doc if hits.total_hits == 1
raise "cannot determine document number for record #{key}" if docnum.nil?
docnum
end | ruby | def document_number(key)
docnum = ferret_index.doc_number(key)
# hits = ferret_index.search query_for_record(key)
# return hits.hits.first.doc if hits.total_hits == 1
raise "cannot determine document number for record #{key}" if docnum.nil?
docnum
end | [
"def",
"document_number",
"(",
"key",
")",
"docnum",
"=",
"ferret_index",
".",
"doc_number",
"(",
"key",
")",
"# hits = ferret_index.search query_for_record(key)",
"# return hits.hits.first.doc if hits.total_hits == 1",
"raise",
"\"cannot determine document number for record #{key}\"... | retrieves the ferret document number of the record with the given key. | [
"retrieves",
"the",
"ferret",
"document",
"number",
"of",
"the",
"record",
"with",
"the",
"given",
"key",
"."
] | 1c3330c51a4d07298e6b89347077742636d9e3cf | https://github.com/jkraemer/acts_as_ferret/blob/1c3330c51a4d07298e6b89347077742636d9e3cf/lib/acts_as_ferret/local_index.rb#L137-L143 |
2,722 | mwlang/social_media | lib/social_media/service/facebook.rb | SocialMedia::Service.Facebook.get_app_access_token | def get_app_access_token
return connection_params[:app_access_token] if connection_params.has_key? :app_access_token
@oauth = Koala::Facebook::OAuth.new(connection_params[:app_id], connection_params[:app_secret], callback_url)
connection_params[:app_access_token] = @oauth.get_app_access_token
end | ruby | def get_app_access_token
return connection_params[:app_access_token] if connection_params.has_key? :app_access_token
@oauth = Koala::Facebook::OAuth.new(connection_params[:app_id], connection_params[:app_secret], callback_url)
connection_params[:app_access_token] = @oauth.get_app_access_token
end | [
"def",
"get_app_access_token",
"return",
"connection_params",
"[",
":app_access_token",
"]",
"if",
"connection_params",
".",
"has_key?",
":app_access_token",
"@oauth",
"=",
"Koala",
"::",
"Facebook",
"::",
"OAuth",
".",
"new",
"(",
"connection_params",
"[",
":app_id",... | A long-term app_access_token might be supplied on connection parameters
If not, we fetch a short-term one here. | [
"A",
"long",
"-",
"term",
"app_access_token",
"might",
"be",
"supplied",
"on",
"connection",
"parameters",
"If",
"not",
"we",
"fetch",
"a",
"short",
"-",
"term",
"one",
"here",
"."
] | 44c431701fb6ff9c1618e3194a1a1d89c6494f92 | https://github.com/mwlang/social_media/blob/44c431701fb6ff9c1618e3194a1a1d89c6494f92/lib/social_media/service/facebook.rb#L98-L103 |
2,723 | EvidentSecurity/esp_sdk | lib/esp/resources/suppression.rb | ESP.Suppression.regions | def regions
# When regions come back in an include, the method still gets called, to return the object from the attributes.
return attributes['regions'] if attributes['regions'].present?
return [] unless respond_to? :region_ids
ESP::Region.where(id_in: region_ids)
end | ruby | def regions
# When regions come back in an include, the method still gets called, to return the object from the attributes.
return attributes['regions'] if attributes['regions'].present?
return [] unless respond_to? :region_ids
ESP::Region.where(id_in: region_ids)
end | [
"def",
"regions",
"# When regions come back in an include, the method still gets called, to return the object from the attributes.",
"return",
"attributes",
"[",
"'regions'",
"]",
"if",
"attributes",
"[",
"'regions'",
"]",
".",
"present?",
"return",
"[",
"]",
"unless",
"respond... | The regions affected by this suppression.
@return [ActiveResource::PaginatedCollection<ESP::Region>] | [
"The",
"regions",
"affected",
"by",
"this",
"suppression",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/suppression.rb#L20-L25 |
2,724 | EvidentSecurity/esp_sdk | lib/esp/resources/suppression.rb | ESP.Suppression.external_accounts | def external_accounts
# When external_accounts come back in an include, the method still gets called, to return the object from the attributes.
return attributes['external_accounts'] if attributes['external_accounts'].present?
return [] unless respond_to? :external_account_ids
ESP::ExternalAccou... | ruby | def external_accounts
# When external_accounts come back in an include, the method still gets called, to return the object from the attributes.
return attributes['external_accounts'] if attributes['external_accounts'].present?
return [] unless respond_to? :external_account_ids
ESP::ExternalAccou... | [
"def",
"external_accounts",
"# When external_accounts come back in an include, the method still gets called, to return the object from the attributes.",
"return",
"attributes",
"[",
"'external_accounts'",
"]",
"if",
"attributes",
"[",
"'external_accounts'",
"]",
".",
"present?",
"retur... | The external accounts affected by this suppression.
@return [ActiveResource::PaginatedCollection<ESP::ExternalAccount>] | [
"The",
"external",
"accounts",
"affected",
"by",
"this",
"suppression",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/suppression.rb#L30-L35 |
2,725 | EvidentSecurity/esp_sdk | lib/esp/resources/suppression.rb | ESP.Suppression.signatures | def signatures
# When signatures come back in an include, the method still gets called, to return the object from the attributes.
return attributes['signatures'] if attributes['signatures'].present?
return [] unless respond_to? :signature_ids
ESP::Signature.where(id_in: signature_ids)
end | ruby | def signatures
# When signatures come back in an include, the method still gets called, to return the object from the attributes.
return attributes['signatures'] if attributes['signatures'].present?
return [] unless respond_to? :signature_ids
ESP::Signature.where(id_in: signature_ids)
end | [
"def",
"signatures",
"# When signatures come back in an include, the method still gets called, to return the object from the attributes.",
"return",
"attributes",
"[",
"'signatures'",
"]",
"if",
"attributes",
"[",
"'signatures'",
"]",
".",
"present?",
"return",
"[",
"]",
"unless"... | The signatures being suppressed.
@return [ActiveResource::PaginatedCollection<ESP::Signature>] | [
"The",
"signatures",
"being",
"suppressed",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/suppression.rb#L40-L45 |
2,726 | EvidentSecurity/esp_sdk | lib/esp/resources/suppression.rb | ESP.Suppression.custom_signatures | def custom_signatures
# When custom_signatures come back in an include, the method still gets called, to return the object from the attributes.
return attributes['custom_signatures'] if attributes['custom_signatures'].present?
return [] unless respond_to? :custom_signature_ids
ESP::CustomSignatu... | ruby | def custom_signatures
# When custom_signatures come back in an include, the method still gets called, to return the object from the attributes.
return attributes['custom_signatures'] if attributes['custom_signatures'].present?
return [] unless respond_to? :custom_signature_ids
ESP::CustomSignatu... | [
"def",
"custom_signatures",
"# When custom_signatures come back in an include, the method still gets called, to return the object from the attributes.",
"return",
"attributes",
"[",
"'custom_signatures'",
"]",
"if",
"attributes",
"[",
"'custom_signatures'",
"]",
".",
"present?",
"retur... | The custom signatures being suppressed.
@return [ActiveResource::PaginatedCollection<ESP::CustomSignature>] | [
"The",
"custom",
"signatures",
"being",
"suppressed",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/suppression.rb#L50-L55 |
2,727 | EvidentSecurity/esp_sdk | lib/esp/resources/region.rb | ESP.Region.suppress | def suppress(arguments = {})
arguments = arguments.with_indifferent_access
ESP::Suppression::Region.create(regions: [code], external_account_ids: Array(arguments[:external_account_ids]), reason: arguments[:reason])
end | ruby | def suppress(arguments = {})
arguments = arguments.with_indifferent_access
ESP::Suppression::Region.create(regions: [code], external_account_ids: Array(arguments[:external_account_ids]), reason: arguments[:reason])
end | [
"def",
"suppress",
"(",
"arguments",
"=",
"{",
"}",
")",
"arguments",
"=",
"arguments",
".",
"with_indifferent_access",
"ESP",
"::",
"Suppression",
"::",
"Region",
".",
"create",
"(",
"regions",
":",
"[",
"code",
"]",
",",
"external_account_ids",
":",
"Array... | Create a suppression for this region.
@param arguments [Hash] Required hash of region suppression attributes.
===== Valid Arguments
See {API documentation}[http://api-docs.evident.io?ruby#suppression-create] for valid arguments
@return [ESP::Suppression::Region]
@example
suppress(external_account_ids: [5]... | [
"Create",
"a",
"suppression",
"for",
"this",
"region",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/region.rb#L26-L29 |
2,728 | Threespot/tolaria | lib/tolaria/help_links.rb | Tolaria.HelpLink.validate! | def validate!
if title.blank?
raise RuntimeError, "HelpLinks must provide a string title"
end
file_configured = (slug.present? && markdown_file.present?)
link_configured = link_to.present?
unless file_configured || link_configured
raise RuntimeError, "Incomplete HelpLink... | ruby | def validate!
if title.blank?
raise RuntimeError, "HelpLinks must provide a string title"
end
file_configured = (slug.present? && markdown_file.present?)
link_configured = link_to.present?
unless file_configured || link_configured
raise RuntimeError, "Incomplete HelpLink... | [
"def",
"validate!",
"if",
"title",
".",
"blank?",
"raise",
"RuntimeError",
",",
"\"HelpLinks must provide a string title\"",
"end",
"file_configured",
"=",
"(",
"slug",
".",
"present?",
"&&",
"markdown_file",
".",
"present?",
")",
"link_configured",
"=",
"link_to",
... | Raises RuntimeError if this HelpLink is incorrectly configured. | [
"Raises",
"RuntimeError",
"if",
"this",
"HelpLink",
"is",
"incorrectly",
"configured",
"."
] | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/help_links.rb#L62-L79 |
2,729 | brettstimmerman/jabber-bot | lib/jabber/bot.rb | Jabber.Bot.presence | def presence(presence=nil, status=nil, priority=nil)
@config[:presence] = presence
@config[:status] = status
@config[:priority] = priority
status_message = Presence.new(presence, status, priority)
@jabber.send!(status_message) if @jabber.connected?
end | ruby | def presence(presence=nil, status=nil, priority=nil)
@config[:presence] = presence
@config[:status] = status
@config[:priority] = priority
status_message = Presence.new(presence, status, priority)
@jabber.send!(status_message) if @jabber.connected?
end | [
"def",
"presence",
"(",
"presence",
"=",
"nil",
",",
"status",
"=",
"nil",
",",
"priority",
"=",
"nil",
")",
"@config",
"[",
":presence",
"]",
"=",
"presence",
"@config",
"[",
":status",
"]",
"=",
"status",
"@config",
"[",
":priority",
"]",
"=",
"prior... | Sets the bot presence, status message and priority. | [
"Sets",
"the",
"bot",
"presence",
"status",
"message",
"and",
"priority",
"."
] | d3501dcca043b5ade71b99664d5664e2b03f1539 | https://github.com/brettstimmerman/jabber-bot/blob/d3501dcca043b5ade71b99664d5664e2b03f1539/lib/jabber/bot.rb#L237-L244 |
2,730 | brettstimmerman/jabber-bot | lib/jabber/bot.rb | Jabber.Bot.add_command_alias | def add_command_alias(command_name, alias_command, callback) #:nodoc:
original_command = @commands[:meta][command_name]
original_command[:syntax] << alias_command[:syntax]
alias_name = command_name(alias_command[:syntax])
alias_command[:is_public] = original_command[:is_public]
add_comm... | ruby | def add_command_alias(command_name, alias_command, callback) #:nodoc:
original_command = @commands[:meta][command_name]
original_command[:syntax] << alias_command[:syntax]
alias_name = command_name(alias_command[:syntax])
alias_command[:is_public] = original_command[:is_public]
add_comm... | [
"def",
"add_command_alias",
"(",
"command_name",
",",
"alias_command",
",",
"callback",
")",
"#:nodoc:",
"original_command",
"=",
"@commands",
"[",
":meta",
"]",
"[",
"command_name",
"]",
"original_command",
"[",
":syntax",
"]",
"<<",
"alias_command",
"[",
":synta... | Add a command alias for the given original +command_name+ | [
"Add",
"a",
"command",
"alias",
"for",
"the",
"given",
"original",
"+",
"command_name",
"+"
] | d3501dcca043b5ade71b99664d5664e2b03f1539 | https://github.com/brettstimmerman/jabber-bot/blob/d3501dcca043b5ade71b99664d5664e2b03f1539/lib/jabber/bot.rb#L277-L287 |
2,731 | brettstimmerman/jabber-bot | lib/jabber/bot.rb | Jabber.Bot.add_command_meta | def add_command_meta(name, command, is_alias=false) #:nodoc:
syntax = command[:syntax]
@commands[:meta][name] = {
:syntax => syntax.is_a?(Array) ? syntax : [syntax],
:description => command[:description],
:is_public => command[:is_public] || false,
:is_alias => is_... | ruby | def add_command_meta(name, command, is_alias=false) #:nodoc:
syntax = command[:syntax]
@commands[:meta][name] = {
:syntax => syntax.is_a?(Array) ? syntax : [syntax],
:description => command[:description],
:is_public => command[:is_public] || false,
:is_alias => is_... | [
"def",
"add_command_meta",
"(",
"name",
",",
"command",
",",
"is_alias",
"=",
"false",
")",
"#:nodoc:",
"syntax",
"=",
"command",
"[",
":syntax",
"]",
"@commands",
"[",
":meta",
"]",
"[",
"name",
"]",
"=",
"{",
":syntax",
"=>",
"syntax",
".",
"is_a?",
... | Add a command meta | [
"Add",
"a",
"command",
"meta"
] | d3501dcca043b5ade71b99664d5664e2b03f1539 | https://github.com/brettstimmerman/jabber-bot/blob/d3501dcca043b5ade71b99664d5664e2b03f1539/lib/jabber/bot.rb#L290-L299 |
2,732 | brettstimmerman/jabber-bot | lib/jabber/bot.rb | Jabber.Bot.help_message | def help_message(sender, command_name) #:nodoc:
if command_name.nil? || command_name.length == 0
# Display help for all commands
help_message = "I understand the following commands:\n\n"
@commands[:meta].sort.each do |command|
# Thank you, Hash.sort
command = command[1... | ruby | def help_message(sender, command_name) #:nodoc:
if command_name.nil? || command_name.length == 0
# Display help for all commands
help_message = "I understand the following commands:\n\n"
@commands[:meta].sort.each do |command|
# Thank you, Hash.sort
command = command[1... | [
"def",
"help_message",
"(",
"sender",
",",
"command_name",
")",
"#:nodoc:",
"if",
"command_name",
".",
"nil?",
"||",
"command_name",
".",
"length",
"==",
"0",
"# Display help for all commands",
"help_message",
"=",
"\"I understand the following commands:\\n\\n\"",
"@comma... | Returns the default help message describing the bot's command repertoire.
Commands are sorted alphabetically by name, and are displayed according
to the bot's and the commands's _public_ attribute. | [
"Returns",
"the",
"default",
"help",
"message",
"describing",
"the",
"bot",
"s",
"command",
"repertoire",
".",
"Commands",
"are",
"sorted",
"alphabetically",
"by",
"name",
"and",
"are",
"displayed",
"according",
"to",
"the",
"bot",
"s",
"and",
"the",
"commands... | d3501dcca043b5ade71b99664d5664e2b03f1539 | https://github.com/brettstimmerman/jabber-bot/blob/d3501dcca043b5ade71b99664d5664e2b03f1539/lib/jabber/bot.rb#L322-L351 |
2,733 | brettstimmerman/jabber-bot | lib/jabber/bot.rb | Jabber.Bot.start_listener_thread | def start_listener_thread #:nodoc:
listener_thread = Thread.new do
loop do
if @jabber.received_messages?
@jabber.received_messages do |message|
# Remove the Jabber resourse, if any
sender = message.from.to_s.sub(/\/.+$/, '')
if message.type ... | ruby | def start_listener_thread #:nodoc:
listener_thread = Thread.new do
loop do
if @jabber.received_messages?
@jabber.received_messages do |message|
# Remove the Jabber resourse, if any
sender = message.from.to_s.sub(/\/.+$/, '')
if message.type ... | [
"def",
"start_listener_thread",
"#:nodoc:",
"listener_thread",
"=",
"Thread",
".",
"new",
"do",
"loop",
"do",
"if",
"@jabber",
".",
"received_messages?",
"@jabber",
".",
"received_messages",
"do",
"|",
"message",
"|",
"# Remove the Jabber resourse, if any",
"sender",
... | Creates a new Thread dedicated to listening for incoming chat messages.
When a chat message is received, the bot checks if the sender is its
master. If so, it is tested for the presence commands, and processed
accordingly. If the bot itself or the command issued is not made public,
a message sent by anyone other th... | [
"Creates",
"a",
"new",
"Thread",
"dedicated",
"to",
"listening",
"for",
"incoming",
"chat",
"messages",
".",
"When",
"a",
"chat",
"message",
"is",
"received",
"the",
"bot",
"checks",
"if",
"the",
"sender",
"is",
"its",
"master",
".",
"If",
"so",
"it",
"i... | d3501dcca043b5ade71b99664d5664e2b03f1539 | https://github.com/brettstimmerman/jabber-bot/blob/d3501dcca043b5ade71b99664d5664e2b03f1539/lib/jabber/bot.rb#L405-L428 |
2,734 | m247/epp-client | lib/epp-client/server.rb | EPP.Server.prepare_request | def prepare_request(command, extension = nil)
cmd = EPP::Requests::Command.new(req_tid, command, extension)
EPP::Request.new(cmd)
end | ruby | def prepare_request(command, extension = nil)
cmd = EPP::Requests::Command.new(req_tid, command, extension)
EPP::Request.new(cmd)
end | [
"def",
"prepare_request",
"(",
"command",
",",
"extension",
"=",
"nil",
")",
"cmd",
"=",
"EPP",
"::",
"Requests",
"::",
"Command",
".",
"new",
"(",
"req_tid",
",",
"command",
",",
"extension",
")",
"EPP",
"::",
"Request",
".",
"new",
"(",
"cmd",
")",
... | Send request to server
@overload request(command, payload)
@param [String, #to_s] command EPP Command to call
@param [XML::Node, XML::Document, String] payload EPP XML Payload
@overload request(command)
@param [String, #to_s] command EPP Command to call
@yield [xml] block to construct payload
@yieldpa... | [
"Send",
"request",
"to",
"server"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/server.rb#L106-L109 |
2,735 | m247/epp-client | lib/epp-client/server.rb | EPP.Server.connection | def connection
@connection_errors = []
addrinfo.each do |_,port,_,addr,_,_,_|
retried = false
begin
@conn = TCPSocket.new(addr, port)
rescue Errno::EINVAL => e
if retried
message = e.message.split(" - ")[1]
@connection_errors << Errno::EINV... | ruby | def connection
@connection_errors = []
addrinfo.each do |_,port,_,addr,_,_,_|
retried = false
begin
@conn = TCPSocket.new(addr, port)
rescue Errno::EINVAL => e
if retried
message = e.message.split(" - ")[1]
@connection_errors << Errno::EINV... | [
"def",
"connection",
"@connection_errors",
"=",
"[",
"]",
"addrinfo",
".",
"each",
"do",
"|",
"_",
",",
"port",
",",
"_",
",",
"addr",
",",
"_",
",",
"_",
",",
"_",
"|",
"retried",
"=",
"false",
"begin",
"@conn",
"=",
"TCPSocket",
".",
"new",
"(",
... | EPP Server Connection
@yield connected session
@example typical usage
connection do
# .. do stuff with logged in session ..
end
@example usage with with_login
connection do
with_login do
# .. do stuff with logged in session ..
end
end | [
"EPP",
"Server",
"Connection"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/server.rb#L181-L232 |
2,736 | m247/epp-client | lib/epp-client/server.rb | EPP.Server.send_frame | def send_frame(xml)
xml = xml.to_s if xml.kind_of?(Request)
@sock.write([xml.size + HEADER_LEN].pack("N") + xml)
end | ruby | def send_frame(xml)
xml = xml.to_s if xml.kind_of?(Request)
@sock.write([xml.size + HEADER_LEN].pack("N") + xml)
end | [
"def",
"send_frame",
"(",
"xml",
")",
"xml",
"=",
"xml",
".",
"to_s",
"if",
"xml",
".",
"kind_of?",
"(",
"Request",
")",
"@sock",
".",
"write",
"(",
"[",
"xml",
".",
"size",
"+",
"HEADER_LEN",
"]",
".",
"pack",
"(",
"\"N\"",
")",
"+",
"xml",
")",... | Send XML frame
@param [String,Request] xml Payload to send
@return [Integer] number of bytes written | [
"Send",
"XML",
"frame"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/server.rb#L308-L311 |
2,737 | m247/epp-client | lib/epp-client/server.rb | EPP.Server.recv_frame | def recv_frame
header = @sock.read(HEADER_LEN)
if header.nil? && @sock.eof?
raise ServerError, "Connection terminated by remote host"
elsif header.nil?
raise ServerError, "Failed to read header from remote host"
else
len = header.unpack('N')[0]
r... | ruby | def recv_frame
header = @sock.read(HEADER_LEN)
if header.nil? && @sock.eof?
raise ServerError, "Connection terminated by remote host"
elsif header.nil?
raise ServerError, "Failed to read header from remote host"
else
len = header.unpack('N')[0]
r... | [
"def",
"recv_frame",
"header",
"=",
"@sock",
".",
"read",
"(",
"HEADER_LEN",
")",
"if",
"header",
".",
"nil?",
"&&",
"@sock",
".",
"eof?",
"raise",
"ServerError",
",",
"\"Connection terminated by remote host\"",
"elsif",
"header",
".",
"nil?",
"raise",
"ServerEr... | Receive XML frame
@return [String] XML response | [
"Receive",
"XML",
"frame"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/server.rb#L315-L328 |
2,738 | Threespot/tolaria | lib/tolaria/markdown.rb | Tolaria.MarkdownRendererProxy.render | def render(document)
if Tolaria.config.markdown_renderer.nil?
return simple_format(document)
else
@markdown_renderer ||= Tolaria.config.markdown_renderer.constantize
return @markdown_renderer.render(document)
end
end | ruby | def render(document)
if Tolaria.config.markdown_renderer.nil?
return simple_format(document)
else
@markdown_renderer ||= Tolaria.config.markdown_renderer.constantize
return @markdown_renderer.render(document)
end
end | [
"def",
"render",
"(",
"document",
")",
"if",
"Tolaria",
".",
"config",
".",
"markdown_renderer",
".",
"nil?",
"return",
"simple_format",
"(",
"document",
")",
"else",
"@markdown_renderer",
"||=",
"Tolaria",
".",
"config",
".",
"markdown_renderer",
".",
"constant... | Calls the configured Markdown renderer, if none exists
then uses `simple_format` to return more than nothing. | [
"Calls",
"the",
"configured",
"Markdown",
"renderer",
"if",
"none",
"exists",
"then",
"uses",
"simple_format",
"to",
"return",
"more",
"than",
"nothing",
"."
] | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/markdown.rb#L11-L18 |
2,739 | benbalter/problem_child | lib/problem_child/helpers.rb | ProblemChild.Helpers.base_sha | def base_sha
default_branch = client.repo(repo)[:default_branch]
branches.find { |branch| branch[:name] == default_branch }[:commit][:sha]
end | ruby | def base_sha
default_branch = client.repo(repo)[:default_branch]
branches.find { |branch| branch[:name] == default_branch }[:commit][:sha]
end | [
"def",
"base_sha",
"default_branch",
"=",
"client",
".",
"repo",
"(",
"repo",
")",
"[",
":default_branch",
"]",
"branches",
".",
"find",
"{",
"|",
"branch",
"|",
"branch",
"[",
":name",
"]",
"==",
"default_branch",
"}",
"[",
":commit",
"]",
"[",
":sha",
... | Head SHA of default branch, used for creating new branches | [
"Head",
"SHA",
"of",
"default",
"branch",
"used",
"for",
"creating",
"new",
"branches"
] | cd06f0f174c37a5a5ee3cc655a0f0e824b362ce6 | https://github.com/benbalter/problem_child/blob/cd06f0f174c37a5a5ee3cc655a0f0e824b362ce6/lib/problem_child/helpers.rb#L61-L64 |
2,740 | benbalter/problem_child | lib/problem_child/helpers.rb | ProblemChild.Helpers.patch_branch | def patch_branch
num = 1
branch_name = form_data['title'].parameterize
return branch_name unless branch_exists?(branch_name)
branch = "#{branch_name}-#{num}"
while branch_exists?(branch)
num += 1
branch = "#{branch_name}-#{num}"
end
branch
end | ruby | def patch_branch
num = 1
branch_name = form_data['title'].parameterize
return branch_name unless branch_exists?(branch_name)
branch = "#{branch_name}-#{num}"
while branch_exists?(branch)
num += 1
branch = "#{branch_name}-#{num}"
end
branch
end | [
"def",
"patch_branch",
"num",
"=",
"1",
"branch_name",
"=",
"form_data",
"[",
"'title'",
"]",
".",
"parameterize",
"return",
"branch_name",
"unless",
"branch_exists?",
"(",
"branch_name",
")",
"branch",
"=",
"\"#{branch_name}-#{num}\"",
"while",
"branch_exists?",
"(... | Name of branch to submit pull request from
Starts with patch-1 and keeps going until it finds one not taken | [
"Name",
"of",
"branch",
"to",
"submit",
"pull",
"request",
"from",
"Starts",
"with",
"patch",
"-",
"1",
"and",
"keeps",
"going",
"until",
"it",
"finds",
"one",
"not",
"taken"
] | cd06f0f174c37a5a5ee3cc655a0f0e824b362ce6 | https://github.com/benbalter/problem_child/blob/cd06f0f174c37a5a5ee3cc655a0f0e824b362ce6/lib/problem_child/helpers.rb#L72-L82 |
2,741 | benbalter/problem_child | lib/problem_child/helpers.rb | ProblemChild.Helpers.create_pull_request | def create_pull_request
unless uploads.empty?
branch = patch_branch
create_branch(branch)
uploads.each do |key, upload|
client.create_contents(
repo,
upload[:filename],
"Create #{upload[:filename]}",
branch: branch,
file... | ruby | def create_pull_request
unless uploads.empty?
branch = patch_branch
create_branch(branch)
uploads.each do |key, upload|
client.create_contents(
repo,
upload[:filename],
"Create #{upload[:filename]}",
branch: branch,
file... | [
"def",
"create_pull_request",
"unless",
"uploads",
".",
"empty?",
"branch",
"=",
"patch_branch",
"create_branch",
"(",
"branch",
")",
"uploads",
".",
"each",
"do",
"|",
"key",
",",
"upload",
"|",
"client",
".",
"create_contents",
"(",
"repo",
",",
"upload",
... | Create a pull request with the form contents | [
"Create",
"a",
"pull",
"request",
"with",
"the",
"form",
"contents"
] | cd06f0f174c37a5a5ee3cc655a0f0e824b362ce6 | https://github.com/benbalter/problem_child/blob/cd06f0f174c37a5a5ee3cc655a0f0e824b362ce6/lib/problem_child/helpers.rb#L90-L107 |
2,742 | DannyBen/runfile | lib/runfile/exec.rb | Runfile.ExecHandler.run | def run(cmd)
cmd = @before_run_block.call(cmd) if @before_run_block
return false unless cmd
say "!txtgrn!> #{cmd}" unless Runfile.quiet
system cmd
@after_run_block.call(cmd) if @after_run_block
end | ruby | def run(cmd)
cmd = @before_run_block.call(cmd) if @before_run_block
return false unless cmd
say "!txtgrn!> #{cmd}" unless Runfile.quiet
system cmd
@after_run_block.call(cmd) if @after_run_block
end | [
"def",
"run",
"(",
"cmd",
")",
"cmd",
"=",
"@before_run_block",
".",
"call",
"(",
"cmd",
")",
"if",
"@before_run_block",
"return",
"false",
"unless",
"cmd",
"say",
"\"!txtgrn!> #{cmd}\"",
"unless",
"Runfile",
".",
"quiet",
"system",
"cmd",
"@after_run_block",
... | Run a command, wait until it is done and continue | [
"Run",
"a",
"command",
"wait",
"until",
"it",
"is",
"done",
"and",
"continue"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/exec.rb#L13-L19 |
2,743 | DannyBen/runfile | lib/runfile/exec.rb | Runfile.ExecHandler.run! | def run!(cmd)
cmd = @before_run_block.call(cmd) if @before_run_block
return false unless cmd
say "!txtgrn!> #{cmd}" unless Runfile.quiet
exec cmd
end | ruby | def run!(cmd)
cmd = @before_run_block.call(cmd) if @before_run_block
return false unless cmd
say "!txtgrn!> #{cmd}" unless Runfile.quiet
exec cmd
end | [
"def",
"run!",
"(",
"cmd",
")",
"cmd",
"=",
"@before_run_block",
".",
"call",
"(",
"cmd",
")",
"if",
"@before_run_block",
"return",
"false",
"unless",
"cmd",
"say",
"\"!txtgrn!> #{cmd}\"",
"unless",
"Runfile",
".",
"quiet",
"exec",
"cmd",
"end"
] | Run a command, wait until it is done, then exit | [
"Run",
"a",
"command",
"wait",
"until",
"it",
"is",
"done",
"then",
"exit"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/exec.rb#L22-L27 |
2,744 | DannyBen/runfile | lib/runfile/exec.rb | Runfile.ExecHandler.run_bg | def run_bg(cmd, pid: nil, log: '/dev/null')
cmd = @before_run_block.call(cmd) if @before_run_block
return false unless cmd
full_cmd = "exec #{cmd} >#{log} 2>&1"
say "!txtgrn!> #{full_cmd}" unless Runfile.quiet
process = IO.popen "exec #{cmd} >#{log} 2>&1"
File.write pidfile(pid), pro... | ruby | def run_bg(cmd, pid: nil, log: '/dev/null')
cmd = @before_run_block.call(cmd) if @before_run_block
return false unless cmd
full_cmd = "exec #{cmd} >#{log} 2>&1"
say "!txtgrn!> #{full_cmd}" unless Runfile.quiet
process = IO.popen "exec #{cmd} >#{log} 2>&1"
File.write pidfile(pid), pro... | [
"def",
"run_bg",
"(",
"cmd",
",",
"pid",
":",
"nil",
",",
"log",
":",
"'/dev/null'",
")",
"cmd",
"=",
"@before_run_block",
".",
"call",
"(",
"cmd",
")",
"if",
"@before_run_block",
"return",
"false",
"unless",
"cmd",
"full_cmd",
"=",
"\"exec #{cmd} >#{log} 2>... | Run a command in the background, optionally log to a log file and save
the process ID in a pid file | [
"Run",
"a",
"command",
"in",
"the",
"background",
"optionally",
"log",
"to",
"a",
"log",
"file",
"and",
"save",
"the",
"process",
"ID",
"in",
"a",
"pid",
"file"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/exec.rb#L31-L40 |
2,745 | DannyBen/runfile | lib/runfile/exec.rb | Runfile.ExecHandler.stop_bg | def stop_bg(pid)
file = pidfile(pid)
if File.exist? file
pid = File.read file
File.delete file
run "kill -s TERM #{pid}"
else
say "!txtred!PID file not found." unless Runfile.quiet
end
end | ruby | def stop_bg(pid)
file = pidfile(pid)
if File.exist? file
pid = File.read file
File.delete file
run "kill -s TERM #{pid}"
else
say "!txtred!PID file not found." unless Runfile.quiet
end
end | [
"def",
"stop_bg",
"(",
"pid",
")",
"file",
"=",
"pidfile",
"(",
"pid",
")",
"if",
"File",
".",
"exist?",
"file",
"pid",
"=",
"File",
".",
"read",
"file",
"File",
".",
"delete",
"file",
"run",
"\"kill -s TERM #{pid}\"",
"else",
"say",
"\"!txtred!PID file no... | Stop a command started with 'run_bg'. Provide the name of he pid file you
used in 'run_bg' | [
"Stop",
"a",
"command",
"started",
"with",
"run_bg",
".",
"Provide",
"the",
"name",
"of",
"he",
"pid",
"file",
"you",
"used",
"in",
"run_bg"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/exec.rb#L44-L53 |
2,746 | EvidentSecurity/esp_sdk | lib/esp/commands/console.rb | ESP.Console.start | def start # rubocop:disable Metrics/MethodLength
ARGV.clear
IRB.setup nil
IRB.conf[:PROMPT] = {}
IRB.conf[:IRB_NAME] = 'espsdk'
IRB.conf[:PROMPT][:ESPSDK] = {
PROMPT_I: '%N:%03n:%i> ',
PROMPT_N: '%N:%03n:%i> ',
PROMPT_S: '%N:%03n:%i%l ',
PRO... | ruby | def start # rubocop:disable Metrics/MethodLength
ARGV.clear
IRB.setup nil
IRB.conf[:PROMPT] = {}
IRB.conf[:IRB_NAME] = 'espsdk'
IRB.conf[:PROMPT][:ESPSDK] = {
PROMPT_I: '%N:%03n:%i> ',
PROMPT_N: '%N:%03n:%i> ',
PROMPT_S: '%N:%03n:%i%l ',
PRO... | [
"def",
"start",
"# rubocop:disable Metrics/MethodLength",
"ARGV",
".",
"clear",
"IRB",
".",
"setup",
"nil",
"IRB",
".",
"conf",
"[",
":PROMPT",
"]",
"=",
"{",
"}",
"IRB",
".",
"conf",
"[",
":IRB_NAME",
"]",
"=",
"'espsdk'",
"IRB",
".",
"conf",
"[",
":PRO... | Start a console
@return [void] | [
"Start",
"a",
"console"
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/commands/console.rb#L29-L70 |
2,747 | m247/epp-client | lib/epp-client/xml_helper.rb | EPP.XMLHelpers.epp_namespace | def epp_namespace(node, name = nil, namespaces = {})
return namespaces['epp'] if namespaces.has_key?('epp')
xml_namespace(node, name, 'urn:ietf:params:xml:ns:epp-1.0')
end | ruby | def epp_namespace(node, name = nil, namespaces = {})
return namespaces['epp'] if namespaces.has_key?('epp')
xml_namespace(node, name, 'urn:ietf:params:xml:ns:epp-1.0')
end | [
"def",
"epp_namespace",
"(",
"node",
",",
"name",
"=",
"nil",
",",
"namespaces",
"=",
"{",
"}",
")",
"return",
"namespaces",
"[",
"'epp'",
"]",
"if",
"namespaces",
".",
"has_key?",
"(",
"'epp'",
")",
"xml_namespace",
"(",
"node",
",",
"name",
",",
"'ur... | Creates and returns an instance of the EPP 1.0 namespace
@param [XML::Node] node to create the namespace on
@param [String, nil] Name to give the namespace
@return [XML::Namespace] EPP 1.0 namespace | [
"Creates",
"and",
"returns",
"an",
"instance",
"of",
"the",
"EPP",
"1",
".",
"0",
"namespace"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/xml_helper.rb#L8-L11 |
2,748 | m247/epp-client | lib/epp-client/xml_helper.rb | EPP.XMLHelpers.epp_node | def epp_node(name, value = nil, namespaces = {})
value, namespaces = nil, value if value.kind_of?(Hash)
node = xml_node(name, value)
node.namespaces.namespace = epp_namespace(node, nil, namespaces)
node
end | ruby | def epp_node(name, value = nil, namespaces = {})
value, namespaces = nil, value if value.kind_of?(Hash)
node = xml_node(name, value)
node.namespaces.namespace = epp_namespace(node, nil, namespaces)
node
end | [
"def",
"epp_node",
"(",
"name",
",",
"value",
"=",
"nil",
",",
"namespaces",
"=",
"{",
"}",
")",
"value",
",",
"namespaces",
"=",
"nil",
",",
"value",
"if",
"value",
".",
"kind_of?",
"(",
"Hash",
")",
"node",
"=",
"xml_node",
"(",
"name",
",",
"val... | Creates and returns a new node in the EPP 1.0 namespace
@param [String] name of the node to create
@param [String,XML::Node,nil] value of the node
@return [XML::Node] | [
"Creates",
"and",
"returns",
"a",
"new",
"node",
"in",
"the",
"EPP",
"1",
".",
"0",
"namespace"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/xml_helper.rb#L18-L24 |
2,749 | m247/epp-client | lib/epp-client/xml_helper.rb | EPP.XMLHelpers.xml_namespace | def xml_namespace(node, name, uri, namespaces = {})
XML::Namespace.new(node, name, uri)
end | ruby | def xml_namespace(node, name, uri, namespaces = {})
XML::Namespace.new(node, name, uri)
end | [
"def",
"xml_namespace",
"(",
"node",
",",
"name",
",",
"uri",
",",
"namespaces",
"=",
"{",
"}",
")",
"XML",
"::",
"Namespace",
".",
"new",
"(",
"node",
",",
"name",
",",
"uri",
")",
"end"
] | Creates and returns a new XML namespace
@param [XML::Node] node XML node to add the namespace to
@param [String] name Name of the namespace to create
@param [String] uri URI of the namespace to create
@return [XML::Namespace] | [
"Creates",
"and",
"returns",
"a",
"new",
"XML",
"namespace"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/xml_helper.rb#L41-L43 |
2,750 | m247/epp-client | lib/epp-client/xml_helper.rb | EPP.XMLHelpers.xml_document | def xml_document(obj)
case obj
when XML::Document
XML::Document.document(obj)
else
XML::Document.new('1.0')
end
end | ruby | def xml_document(obj)
case obj
when XML::Document
XML::Document.document(obj)
else
XML::Document.new('1.0')
end
end | [
"def",
"xml_document",
"(",
"obj",
")",
"case",
"obj",
"when",
"XML",
"::",
"Document",
"XML",
"::",
"Document",
".",
"document",
"(",
"obj",
")",
"else",
"XML",
"::",
"Document",
".",
"new",
"(",
"'1.0'",
")",
"end",
"end"
] | Creates and returns a new XML document
@param [XML::Document,String] obj Object to create the document with
@return [XML::Document] | [
"Creates",
"and",
"returns",
"a",
"new",
"XML",
"document"
] | 72227e57d248f215d842e3dd37e72432d2a79270 | https://github.com/m247/epp-client/blob/72227e57d248f215d842e3dd37e72432d2a79270/lib/epp-client/xml_helper.rb#L49-L56 |
2,751 | mbj/vanguard | lib/vanguard/dsl.rb | Vanguard.DSL.method_missing | def method_missing(method_name, *arguments)
klass = REGISTRY.fetch(method_name) { super }
Evaluator.new(klass, arguments).rules.each do |rule|
add(rule)
end
self
end | ruby | def method_missing(method_name, *arguments)
klass = REGISTRY.fetch(method_name) { super }
Evaluator.new(klass, arguments).rules.each do |rule|
add(rule)
end
self
end | [
"def",
"method_missing",
"(",
"method_name",
",",
"*",
"arguments",
")",
"klass",
"=",
"REGISTRY",
".",
"fetch",
"(",
"method_name",
")",
"{",
"super",
"}",
"Evaluator",
".",
"new",
"(",
"klass",
",",
"arguments",
")",
".",
"rules",
".",
"each",
"do",
... | Hook called when method is missing
@param [Symbol] method_name
@return [self]
@api private | [
"Hook",
"called",
"when",
"method",
"is",
"missing"
] | 1babf0b4b08712f22da0c44f0f72f9651c714aae | https://github.com/mbj/vanguard/blob/1babf0b4b08712f22da0c44f0f72f9651c714aae/lib/vanguard/dsl.rb#L32-L40 |
2,752 | anshulverma/cliqr | lib/cliqr/interface.rb | Cliqr.Interface.execute | def execute(args = [], **options)
execute_internal(args, options)
Executor::ExitCode.code(:success)
rescue Cliqr::Error::CliqrError => e
puts e.message
Executor::ExitCode.code(e)
end | ruby | def execute(args = [], **options)
execute_internal(args, options)
Executor::ExitCode.code(:success)
rescue Cliqr::Error::CliqrError => e
puts e.message
Executor::ExitCode.code(e)
end | [
"def",
"execute",
"(",
"args",
"=",
"[",
"]",
",",
"**",
"options",
")",
"execute_internal",
"(",
"args",
",",
"options",
")",
"Executor",
"::",
"ExitCode",
".",
"code",
"(",
":success",
")",
"rescue",
"Cliqr",
"::",
"Error",
"::",
"CliqrError",
"=>",
... | Execute a command
@param [Array<String>] args Arguments that will be used to execute the command
@param [Hash] options Options for command execution
@return [Integer] Exit code of the command execution | [
"Execute",
"a",
"command"
] | 8e3e7d7d7ce129b29744ca65f9331c814f74756b | https://github.com/anshulverma/cliqr/blob/8e3e7d7d7ce129b29744ca65f9331c814f74756b/lib/cliqr/interface.rb#L38-L44 |
2,753 | anshulverma/cliqr | lib/cliqr/interface.rb | Cliqr.Interface.execute_internal | def execute_internal(args = [], **options)
options = {
output: :default,
environment: :cli
}.merge(options)
@runner.execute(args, options)
end | ruby | def execute_internal(args = [], **options)
options = {
output: :default,
environment: :cli
}.merge(options)
@runner.execute(args, options)
end | [
"def",
"execute_internal",
"(",
"args",
"=",
"[",
"]",
",",
"**",
"options",
")",
"options",
"=",
"{",
"output",
":",
":default",
",",
"environment",
":",
":cli",
"}",
".",
"merge",
"(",
"options",
")",
"@runner",
".",
"execute",
"(",
"args",
",",
"o... | Executes a command without handling error conditions
@return [Integer] Exit code | [
"Executes",
"a",
"command",
"without",
"handling",
"error",
"conditions"
] | 8e3e7d7d7ce129b29744ca65f9331c814f74756b | https://github.com/anshulverma/cliqr/blob/8e3e7d7d7ce129b29744ca65f9331c814f74756b/lib/cliqr/interface.rb#L49-L55 |
2,754 | anshulverma/cliqr | lib/cliqr/interface.rb | Cliqr.InterfaceBuilder.build | def build
raise Cliqr::Error::ConfigNotFound, 'a valid config should be defined' if @config.nil?
unless @config.valid?
raise Cliqr::Error::ValidationError, \
"invalid Cliqr interface configuration - [#{@config.errors}]"
end
Interface.new(@config)
end | ruby | def build
raise Cliqr::Error::ConfigNotFound, 'a valid config should be defined' if @config.nil?
unless @config.valid?
raise Cliqr::Error::ValidationError, \
"invalid Cliqr interface configuration - [#{@config.errors}]"
end
Interface.new(@config)
end | [
"def",
"build",
"raise",
"Cliqr",
"::",
"Error",
"::",
"ConfigNotFound",
",",
"'a valid config should be defined'",
"if",
"@config",
".",
"nil?",
"unless",
"@config",
".",
"valid?",
"raise",
"Cliqr",
"::",
"Error",
"::",
"ValidationError",
",",
"\"invalid Cliqr inte... | Start building a command line interface
@param [Cliqr::CLI::Config] config the configuration options for the
interface (validated using CLI::Validator)
@return [Cliqr::CLI::ConfigBuilder]
Validate and build a cli interface based on the configuration options
@return [Cliqr::CLI::Interface]
@throws [Cliqr::Erro... | [
"Start",
"building",
"a",
"command",
"line",
"interface"
] | 8e3e7d7d7ce129b29744ca65f9331c814f74756b | https://github.com/anshulverma/cliqr/blob/8e3e7d7d7ce129b29744ca65f9331c814f74756b/lib/cliqr/interface.rb#L87-L95 |
2,755 | DannyBen/runfile | lib/runfile/runner.rb | Runfile.Runner.execute | def execute(argv, filename='Runfile')
@ignore_settings = !filename
argv = expand_shortcuts argv
filename and File.file?(filename) or handle_no_runfile argv
begin
load settings.helper if settings.helper
load filename
rescue => ex
abort "Runfile error:\n#{ex.message}... | ruby | def execute(argv, filename='Runfile')
@ignore_settings = !filename
argv = expand_shortcuts argv
filename and File.file?(filename) or handle_no_runfile argv
begin
load settings.helper if settings.helper
load filename
rescue => ex
abort "Runfile error:\n#{ex.message}... | [
"def",
"execute",
"(",
"argv",
",",
"filename",
"=",
"'Runfile'",
")",
"@ignore_settings",
"=",
"!",
"filename",
"argv",
"=",
"expand_shortcuts",
"argv",
"filename",
"and",
"File",
".",
"file?",
"(",
"filename",
")",
"or",
"handle_no_runfile",
"argv",
"begin",... | Initialize all variables to sensible defaults.
Load and execute a Runfile call. | [
"Initialize",
"all",
"variables",
"to",
"sensible",
"defaults",
".",
"Load",
"and",
"execute",
"a",
"Runfile",
"call",
"."
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runner.rb#L35-L47 |
2,756 | DannyBen/runfile | lib/runfile/runner.rb | Runfile.Runner.add_action | def add_action(name, altname=nil, &block)
if @last_usage.nil?
@last_usage = altname ? "(#{name}|#{altname})" : name
end
[@namespace, @superspace].each do |prefix|
prefix or next
name = "#{prefix}_#{name}"
@last_usage = "#{prefix} #{last_usage}" unless @last_usage == fa... | ruby | def add_action(name, altname=nil, &block)
if @last_usage.nil?
@last_usage = altname ? "(#{name}|#{altname})" : name
end
[@namespace, @superspace].each do |prefix|
prefix or next
name = "#{prefix}_#{name}"
@last_usage = "#{prefix} #{last_usage}" unless @last_usage == fa... | [
"def",
"add_action",
"(",
"name",
",",
"altname",
"=",
"nil",
",",
"&",
"block",
")",
"if",
"@last_usage",
".",
"nil?",
"@last_usage",
"=",
"altname",
"?",
"\"(#{name}|#{altname})\"",
":",
"name",
"end",
"[",
"@namespace",
",",
"@superspace",
"]",
".",
"ea... | Add an action to the @actions array, and use the last known
usage and help messages sent by the DSL. | [
"Add",
"an",
"action",
"to",
"the"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runner.rb#L51-L68 |
2,757 | DannyBen/runfile | lib/runfile/runner.rb | Runfile.Runner.add_option | def add_option(flag, text, scope=nil)
scope or scope = 'Options'
@options[scope] ||= {}
@options[scope][flag] = text
end | ruby | def add_option(flag, text, scope=nil)
scope or scope = 'Options'
@options[scope] ||= {}
@options[scope][flag] = text
end | [
"def",
"add_option",
"(",
"flag",
",",
"text",
",",
"scope",
"=",
"nil",
")",
"scope",
"or",
"scope",
"=",
"'Options'",
"@options",
"[",
"scope",
"]",
"||=",
"{",
"}",
"@options",
"[",
"scope",
"]",
"[",
"flag",
"]",
"=",
"text",
"end"
] | Add an option flag and its help text. | [
"Add",
"an",
"option",
"flag",
"and",
"its",
"help",
"text",
"."
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runner.rb#L71-L75 |
2,758 | DannyBen/runfile | lib/runfile/runner.rb | Runfile.Runner.add_param | def add_param(name, text, scope=nil)
scope or scope = 'Parameters'
@params[scope] ||= {}
@params[scope][name] = text
end | ruby | def add_param(name, text, scope=nil)
scope or scope = 'Parameters'
@params[scope] ||= {}
@params[scope][name] = text
end | [
"def",
"add_param",
"(",
"name",
",",
"text",
",",
"scope",
"=",
"nil",
")",
"scope",
"or",
"scope",
"=",
"'Parameters'",
"@params",
"[",
"scope",
"]",
"||=",
"{",
"}",
"@params",
"[",
"scope",
"]",
"[",
"name",
"]",
"=",
"text",
"end"
] | Add a patameter and its help text. | [
"Add",
"a",
"patameter",
"and",
"its",
"help",
"text",
"."
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runner.rb#L78-L82 |
2,759 | DannyBen/runfile | lib/runfile/runner.rb | Runfile.Runner.run | def run(*argv)
begin
docopt_exec argv
rescue Docopt::Exit => ex
puts ex.message
exit 2
end
end | ruby | def run(*argv)
begin
docopt_exec argv
rescue Docopt::Exit => ex
puts ex.message
exit 2
end
end | [
"def",
"run",
"(",
"*",
"argv",
")",
"begin",
"docopt_exec",
"argv",
"rescue",
"Docopt",
"::",
"Exit",
"=>",
"ex",
"puts",
"ex",
".",
"message",
"exit",
"2",
"end",
"end"
] | Run the command. This is a wrapper around docopt. It will
generate the docopt document on the fly, using all the
information collected so far. | [
"Run",
"the",
"command",
".",
"This",
"is",
"a",
"wrapper",
"around",
"docopt",
".",
"It",
"will",
"generate",
"the",
"docopt",
"document",
"on",
"the",
"fly",
"using",
"all",
"the",
"information",
"collected",
"so",
"far",
"."
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runner.rb#L92-L99 |
2,760 | EvidentSecurity/esp_sdk | lib/esp/extensions/active_resource/validations.rb | ActiveResource.Validations.load_remote_errors | def load_remote_errors(remote_errors, save_cache = false)
if self.class.format == ActiveResource::Formats::JsonAPIFormat
errors.from_json_api(remote_errors.response.body, save_cache)
elsif self.class.format == ActiveResource::Formats[:json]
super
end
end | ruby | def load_remote_errors(remote_errors, save_cache = false)
if self.class.format == ActiveResource::Formats::JsonAPIFormat
errors.from_json_api(remote_errors.response.body, save_cache)
elsif self.class.format == ActiveResource::Formats[:json]
super
end
end | [
"def",
"load_remote_errors",
"(",
"remote_errors",
",",
"save_cache",
"=",
"false",
")",
"if",
"self",
".",
"class",
".",
"format",
"==",
"ActiveResource",
"::",
"Formats",
"::",
"JsonAPIFormat",
"errors",
".",
"from_json_api",
"(",
"remote_errors",
".",
"respon... | Loads the set of remote errors into the object's Errors based on the
content-type of the error-block received. | [
"Loads",
"the",
"set",
"of",
"remote",
"errors",
"into",
"the",
"object",
"s",
"Errors",
"based",
"on",
"the",
"content",
"-",
"type",
"of",
"the",
"error",
"-",
"block",
"received",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/extensions/active_resource/validations.rb#L6-L12 |
2,761 | RISCfuture/slugalicious | lib/slugalicious.rb | Slugalicious.ClassMethods.find_from_slug_path | def find_from_slug_path(path)
slug = path.split('/').last
scope = path[0..(-(slug.size + 1))]
find_from_slug slug, scope
end | ruby | def find_from_slug_path(path)
slug = path.split('/').last
scope = path[0..(-(slug.size + 1))]
find_from_slug slug, scope
end | [
"def",
"find_from_slug_path",
"(",
"path",
")",
"slug",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
".",
"last",
"scope",
"=",
"path",
"[",
"0",
"..",
"(",
"-",
"(",
"slug",
".",
"size",
"+",
"1",
")",
")",
"]",
"find_from_slug",
"slug",
",",
"sc... | Locates a record from a given path, that consists of a slug and its scope,
as would appear in a URL path component.
@param [String] path The scope and slug concatenated together.
@return [ActiveRecord::Base] The object with that slug.
@raise [ActiveRecord::RecordNotFound] If no object with that slug is
found. | [
"Locates",
"a",
"record",
"from",
"a",
"given",
"path",
"that",
"consists",
"of",
"a",
"slug",
"and",
"its",
"scope",
"as",
"would",
"appear",
"in",
"a",
"URL",
"path",
"component",
"."
] | db95f204451c8942cb065ebd70acc610bdb6370c | https://github.com/RISCfuture/slugalicious/blob/db95f204451c8942cb065ebd70acc610bdb6370c/lib/slugalicious.rb#L61-L65 |
2,762 | etehtsea/oxblood | lib/oxblood/pipeline.rb | Oxblood.Pipeline.sync | def sync
serialized_commands = @commands.map { |c| Protocol.build_command(*c) }
connection.socket.write(serialized_commands.join)
Array.new(@commands.size) { connection.read_response }
ensure
@commands.clear
end | ruby | def sync
serialized_commands = @commands.map { |c| Protocol.build_command(*c) }
connection.socket.write(serialized_commands.join)
Array.new(@commands.size) { connection.read_response }
ensure
@commands.clear
end | [
"def",
"sync",
"serialized_commands",
"=",
"@commands",
".",
"map",
"{",
"|",
"c",
"|",
"Protocol",
".",
"build_command",
"(",
"c",
")",
"}",
"connection",
".",
"socket",
".",
"write",
"(",
"serialized_commands",
".",
"join",
")",
"Array",
".",
"new",
"(... | Sends all commands at once and reads responses
@return [Array] of responses | [
"Sends",
"all",
"commands",
"at",
"once",
"and",
"reads",
"responses"
] | 0bfc3f6114a6eb5716a9cd44ecea914b273dc268 | https://github.com/etehtsea/oxblood/blob/0bfc3f6114a6eb5716a9cd44ecea914b273dc268/lib/oxblood/pipeline.rb#L28-L34 |
2,763 | tongueroo/lono-cfn | lib/lono-cfn/base.rb | LonoCfn.Base.get_source_path | def get_source_path(path, type)
default_convention_path = convention_path(@stack_name, type)
return default_convention_path if path.nil?
# convention path based on the input from the user
convention_path(path, type)
end | ruby | def get_source_path(path, type)
default_convention_path = convention_path(@stack_name, type)
return default_convention_path if path.nil?
# convention path based on the input from the user
convention_path(path, type)
end | [
"def",
"get_source_path",
"(",
"path",
",",
"type",
")",
"default_convention_path",
"=",
"convention_path",
"(",
"@stack_name",
",",
"type",
")",
"return",
"default_convention_path",
"if",
"path",
".",
"nil?",
"# convention path based on the input from the user",
"convent... | if existing in params path then use that
if it doesnt assume it is a full path and check that
else fall back to convention, which also eventually gets checked in check_for_errors
Type - :params or :template | [
"if",
"existing",
"in",
"params",
"path",
"then",
"use",
"that",
"if",
"it",
"doesnt",
"assume",
"it",
"is",
"a",
"full",
"path",
"and",
"check",
"that",
"else",
"fall",
"back",
"to",
"convention",
"which",
"also",
"eventually",
"gets",
"checked",
"in",
... | 17bb48f40d5eb0441117bf14b4fbd09a057ff8f1 | https://github.com/tongueroo/lono-cfn/blob/17bb48f40d5eb0441117bf14b4fbd09a057ff8f1/lib/lono-cfn/base.rb#L80-L86 |
2,764 | tongueroo/lono-cfn | lib/lono-cfn/base.rb | LonoCfn.Base.detect_format | def detect_format
formats = Dir.glob("#{@project_root}/output/**/*").map { |path| path }.
reject { |s| s =~ %r{/params/} }. # reject output/params folder
map { |path| File.extname(path) }.
reject { |s| s.empty? }. # reject ""
uniq
if fo... | ruby | def detect_format
formats = Dir.glob("#{@project_root}/output/**/*").map { |path| path }.
reject { |s| s =~ %r{/params/} }. # reject output/params folder
map { |path| File.extname(path) }.
reject { |s| s.empty? }. # reject ""
uniq
if fo... | [
"def",
"detect_format",
"formats",
"=",
"Dir",
".",
"glob",
"(",
"\"#{@project_root}/output/**/*\"",
")",
".",
"map",
"{",
"|",
"path",
"|",
"path",
"}",
".",
"reject",
"{",
"|",
"s",
"|",
"s",
"=~",
"%r{",
"}",
"}",
".",
"# reject output/params folder",
... | Returns String with value of "yml" or "json". | [
"Returns",
"String",
"with",
"value",
"of",
"yml",
"or",
"json",
"."
] | 17bb48f40d5eb0441117bf14b4fbd09a057ff8f1 | https://github.com/tongueroo/lono-cfn/blob/17bb48f40d5eb0441117bf14b4fbd09a057ff8f1/lib/lono-cfn/base.rb#L102-L115 |
2,765 | EvidentSecurity/esp_sdk | lib/esp/extensions/active_resource/paginated_collection.rb | ActiveResource.PaginatedCollection.page | def page(page_number = nil)
fail ArgumentError, "You must supply a page number." unless page_number.present?
fail ArgumentError, "Page number cannot be less than 1." if page_number.to_i < 1
fail ArgumentError, "Page number cannot be greater than the last page number." if page_number.to_i > last_page_n... | ruby | def page(page_number = nil)
fail ArgumentError, "You must supply a page number." unless page_number.present?
fail ArgumentError, "Page number cannot be less than 1." if page_number.to_i < 1
fail ArgumentError, "Page number cannot be greater than the last page number." if page_number.to_i > last_page_n... | [
"def",
"page",
"(",
"page_number",
"=",
"nil",
")",
"fail",
"ArgumentError",
",",
"\"You must supply a page number.\"",
"unless",
"page_number",
".",
"present?",
"fail",
"ArgumentError",
",",
"\"Page number cannot be less than 1.\"",
"if",
"page_number",
".",
"to_i",
"<... | Returns the +page_number+ page of data.
Returns +self+ when +page_number+ == +#current_page_number+
@param page_number [Integer] The page number of the data wanted. Must be between 1 and +#last_page_number+.
@return [PaginatedCollection, self]
@raise [ArgumentError] if no page number or an out-of-bounds page numb... | [
"Returns",
"the",
"+",
"page_number",
"+",
"page",
"of",
"data",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/extensions/active_resource/paginated_collection.rb#L137-L142 |
2,766 | DannyBen/runfile | lib/runfile/runfile_helper.rb | Runfile.RunfileHelper.make_runfile | def make_runfile(name=nil)
name = 'Runfile' if name.nil?
template = File.expand_path("../templates/Runfile", __FILE__)
name += ".runfile" unless name == 'Runfile'
dest = "#{Dir.pwd}/#{name}"
begin
File.write(dest, File.read(template))
puts "#{name} created."
rescue =>... | ruby | def make_runfile(name=nil)
name = 'Runfile' if name.nil?
template = File.expand_path("../templates/Runfile", __FILE__)
name += ".runfile" unless name == 'Runfile'
dest = "#{Dir.pwd}/#{name}"
begin
File.write(dest, File.read(template))
puts "#{name} created."
rescue =>... | [
"def",
"make_runfile",
"(",
"name",
"=",
"nil",
")",
"name",
"=",
"'Runfile'",
"if",
"name",
".",
"nil?",
"template",
"=",
"File",
".",
"expand_path",
"(",
"\"../templates/Runfile\"",
",",
"__FILE__",
")",
"name",
"+=",
"\".runfile\"",
"unless",
"name",
"=="... | Create a new runfile in the current directory. We can either
create a standard 'Runfile' or a 'named.runfile'. | [
"Create",
"a",
"new",
"runfile",
"in",
"the",
"current",
"directory",
".",
"We",
"can",
"either",
"create",
"a",
"standard",
"Runfile",
"or",
"a",
"named",
".",
"runfile",
"."
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runfile_helper.rb#L49-L60 |
2,767 | DannyBen/runfile | lib/runfile/runfile_helper.rb | Runfile.RunfileHelper.show_make_help | def show_make_help(runfiles, compact=false)
say "!txtpur!Runfile engine v#{Runfile::VERSION}" unless compact
if runfiles.size < 3 and !compact
say "\nTip: Type '!txtblu!run new!txtrst!' or '!txtblu!run new name!txtrst!' to create a runfile.\nFor global access, place !txtblu!named.runfiles!txtrst! in... | ruby | def show_make_help(runfiles, compact=false)
say "!txtpur!Runfile engine v#{Runfile::VERSION}" unless compact
if runfiles.size < 3 and !compact
say "\nTip: Type '!txtblu!run new!txtrst!' or '!txtblu!run new name!txtrst!' to create a runfile.\nFor global access, place !txtblu!named.runfiles!txtrst! in... | [
"def",
"show_make_help",
"(",
"runfiles",
",",
"compact",
"=",
"false",
")",
"say",
"\"!txtpur!Runfile engine v#{Runfile::VERSION}\"",
"unless",
"compact",
"if",
"runfiles",
".",
"size",
"<",
"3",
"and",
"!",
"compact",
"say",
"\"\\nTip: Type '!txtblu!run new!txtrst!' o... | Show some helpful tips, and a list of available runfiles | [
"Show",
"some",
"helpful",
"tips",
"and",
"a",
"list",
"of",
"available",
"runfiles"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runfile_helper.rb#L74-L85 |
2,768 | DannyBen/runfile | lib/runfile/runfile_helper.rb | Runfile.RunfileHelper.say_runfile_list | def say_runfile_list(runfiles)
runfile_paths = runfiles.map { |f| File.dirname f }
max = runfile_paths.max_by(&:length).size
width = detect_terminal_size[0]
runfiles.each do |f|
f[/([^\/]+).runfile$/]
command = "run #{$1}"
spacer_size = width - max - command.size - 6
... | ruby | def say_runfile_list(runfiles)
runfile_paths = runfiles.map { |f| File.dirname f }
max = runfile_paths.max_by(&:length).size
width = detect_terminal_size[0]
runfiles.each do |f|
f[/([^\/]+).runfile$/]
command = "run #{$1}"
spacer_size = width - max - command.size - 6
... | [
"def",
"say_runfile_list",
"(",
"runfiles",
")",
"runfile_paths",
"=",
"runfiles",
".",
"map",
"{",
"|",
"f",
"|",
"File",
".",
"dirname",
"f",
"}",
"max",
"=",
"runfile_paths",
".",
"max_by",
"(",
":length",
")",
".",
"size",
"width",
"=",
"detect_termi... | Output the list of available runfiles | [
"Output",
"the",
"list",
"of",
"available",
"runfiles"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runfile_helper.rb#L110-L122 |
2,769 | DannyBen/runfile | lib/runfile/runfile_helper.rb | Runfile.RunfileHelper.say_runfile_usage | def say_runfile_usage(runfiles)
runfiles_as_columns = get_runfiles_as_columns runfiles
say "#{settings.intro}\n" if settings.intro
say "Usage: run <file>"
say runfiles_as_columns
show_shortcuts if settings.shortcuts
end | ruby | def say_runfile_usage(runfiles)
runfiles_as_columns = get_runfiles_as_columns runfiles
say "#{settings.intro}\n" if settings.intro
say "Usage: run <file>"
say runfiles_as_columns
show_shortcuts if settings.shortcuts
end | [
"def",
"say_runfile_usage",
"(",
"runfiles",
")",
"runfiles_as_columns",
"=",
"get_runfiles_as_columns",
"runfiles",
"say",
"\"#{settings.intro}\\n\"",
"if",
"settings",
".",
"intro",
"say",
"\"Usage: run <file>\"",
"say",
"runfiles_as_columns",
"show_shortcuts",
"if",
"set... | Output the list of available runfiles without filename | [
"Output",
"the",
"list",
"of",
"available",
"runfiles",
"without",
"filename"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runfile_helper.rb#L125-L133 |
2,770 | DannyBen/runfile | lib/runfile/runfile_helper.rb | Runfile.RunfileHelper.show_shortcuts | def show_shortcuts
say "\nShortcuts:"
max = settings.shortcuts.keys.max_by(&:length).length
settings.shortcuts.each_pair do |shortcut, command|
say " #{shortcut.rjust max} : #{command}"
end
end | ruby | def show_shortcuts
say "\nShortcuts:"
max = settings.shortcuts.keys.max_by(&:length).length
settings.shortcuts.each_pair do |shortcut, command|
say " #{shortcut.rjust max} : #{command}"
end
end | [
"def",
"show_shortcuts",
"say",
"\"\\nShortcuts:\"",
"max",
"=",
"settings",
".",
"shortcuts",
".",
"keys",
".",
"max_by",
"(",
":length",
")",
".",
"length",
"settings",
".",
"shortcuts",
".",
"each_pair",
"do",
"|",
"shortcut",
",",
"command",
"|",
"say",
... | Prints a friendly output of the shortcut list | [
"Prints",
"a",
"friendly",
"output",
"of",
"the",
"shortcut",
"list"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runfile_helper.rb#L136-L142 |
2,771 | DannyBen/runfile | lib/runfile/runfile_helper.rb | Runfile.RunfileHelper.get_runfiles_as_columns | def get_runfiles_as_columns(runfiles)
namelist = runfile_names runfiles
width = detect_terminal_size[0]
max = namelist.max_by(&:length).length
message = " " + namelist.map {|f| f.ljust max+1 }.join(' ')
word_wrap message, width
end | ruby | def get_runfiles_as_columns(runfiles)
namelist = runfile_names runfiles
width = detect_terminal_size[0]
max = namelist.max_by(&:length).length
message = " " + namelist.map {|f| f.ljust max+1 }.join(' ')
word_wrap message, width
end | [
"def",
"get_runfiles_as_columns",
"(",
"runfiles",
")",
"namelist",
"=",
"runfile_names",
"runfiles",
"width",
"=",
"detect_terminal_size",
"[",
"0",
"]",
"max",
"=",
"namelist",
".",
"max_by",
"(",
":length",
")",
".",
"length",
"message",
"=",
"\" \"",
"+",... | Returns the list of runfiles, organized as columns based on the
current terminal width | [
"Returns",
"the",
"list",
"of",
"runfiles",
"organized",
"as",
"columns",
"based",
"on",
"the",
"current",
"terminal",
"width"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/runfile_helper.rb#L146-L152 |
2,772 | EvidentSecurity/esp_sdk | lib/esp/resources/resource.rb | ESP.Resource.serializable_hash | def serializable_hash(*)
h = attributes.extract!('included')
h['data'] = { 'type' => self.class.to_s.underscore.sub('esp/', '').pluralize,
'attributes' => changed_attributes.except('id', 'type', 'created_at', 'updated_at', 'relationships') }
h['data'... | ruby | def serializable_hash(*)
h = attributes.extract!('included')
h['data'] = { 'type' => self.class.to_s.underscore.sub('esp/', '').pluralize,
'attributes' => changed_attributes.except('id', 'type', 'created_at', 'updated_at', 'relationships') }
h['data'... | [
"def",
"serializable_hash",
"(",
"*",
")",
"h",
"=",
"attributes",
".",
"extract!",
"(",
"'included'",
")",
"h",
"[",
"'data'",
"]",
"=",
"{",
"'type'",
"=>",
"self",
".",
"class",
".",
"to_s",
".",
"underscore",
".",
"sub",
"(",
"'esp/'",
",",
"''",... | Pass a json api compliant hash to the api. | [
"Pass",
"a",
"json",
"api",
"compliant",
"hash",
"to",
"the",
"api",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/resource.rb#L17-L23 |
2,773 | etehtsea/oxblood | lib/oxblood/pool.rb | Oxblood.Pool.with | def with
conn = @pool.checkout
session = Session.new(conn)
yield(session)
ensure
if conn
session.discard if conn.in_transaction?
@pool.checkin
end
end | ruby | def with
conn = @pool.checkout
session = Session.new(conn)
yield(session)
ensure
if conn
session.discard if conn.in_transaction?
@pool.checkin
end
end | [
"def",
"with",
"conn",
"=",
"@pool",
".",
"checkout",
"session",
"=",
"Session",
".",
"new",
"(",
"conn",
")",
"yield",
"(",
"session",
")",
"ensure",
"if",
"conn",
"session",
".",
"discard",
"if",
"conn",
".",
"in_transaction?",
"@pool",
".",
"checkin",... | Initialize connection pool
@param [Hash] options Connection options
@option options [Float] :timeout (1.0) Connection acquisition timeout.
@option options [Integer] :size Pool size.
@option options [Hash] :connection see {Connection#initialize}
Run commands on a connection from pool.
Connection is wrapped to th... | [
"Initialize",
"connection",
"pool"
] | 0bfc3f6114a6eb5716a9cd44ecea914b273dc268 | https://github.com/etehtsea/oxblood/blob/0bfc3f6114a6eb5716a9cd44ecea914b273dc268/lib/oxblood/pool.rb#L40-L49 |
2,774 | DannyBen/runfile | lib/runfile/docopt_helper.rb | Runfile.DocoptHelper.docopt_usage | def docopt_usage
doc = ["\nUsage:"];
@actions.each do |_name, action|
doc << " run #{action.usage}" unless action.usage == false
end
basic_flags = @version ? "(-h|--help|--version)" : "(-h|--help)"
if @superspace
doc << " run #{@superspace} #{basic_flags}\n"
else
... | ruby | def docopt_usage
doc = ["\nUsage:"];
@actions.each do |_name, action|
doc << " run #{action.usage}" unless action.usage == false
end
basic_flags = @version ? "(-h|--help|--version)" : "(-h|--help)"
if @superspace
doc << " run #{@superspace} #{basic_flags}\n"
else
... | [
"def",
"docopt_usage",
"doc",
"=",
"[",
"\"\\nUsage:\"",
"]",
";",
"@actions",
".",
"each",
"do",
"|",
"_name",
",",
"action",
"|",
"doc",
"<<",
"\" run #{action.usage}\"",
"unless",
"action",
".",
"usage",
"==",
"false",
"end",
"basic_flags",
"=",
"@versio... | Return all docopt lines for the 'Usage' section | [
"Return",
"all",
"docopt",
"lines",
"for",
"the",
"Usage",
"section"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/docopt_helper.rb#L45-L57 |
2,775 | DannyBen/runfile | lib/runfile/docopt_helper.rb | Runfile.DocoptHelper.docopt_commands | def docopt_commands(width)
doc = []
caption_printed = false
@actions.each do |_name, action|
action.help or next
doc << "Commands:" unless caption_printed
caption_printed = true
helpline = " #{action.help}"
wrapped = word_wrap helpline, width
doc <... | ruby | def docopt_commands(width)
doc = []
caption_printed = false
@actions.each do |_name, action|
action.help or next
doc << "Commands:" unless caption_printed
caption_printed = true
helpline = " #{action.help}"
wrapped = word_wrap helpline, width
doc <... | [
"def",
"docopt_commands",
"(",
"width",
")",
"doc",
"=",
"[",
"]",
"caption_printed",
"=",
"false",
"@actions",
".",
"each",
"do",
"|",
"_name",
",",
"action",
"|",
"action",
".",
"help",
"or",
"next",
"doc",
"<<",
"\"Commands:\"",
"unless",
"caption_print... | Return all docopt lines for the 'Commands' section | [
"Return",
"all",
"docopt",
"lines",
"for",
"the",
"Commands",
"section"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/docopt_helper.rb#L60-L72 |
2,776 | DannyBen/runfile | lib/runfile/docopt_helper.rb | Runfile.DocoptHelper.docopt_examples | def docopt_examples(width)
return [] if @examples.empty?
doc = ["Examples:"]
base_command = @superspace ? "run #{@superspace}" : "run"
@examples.each do |command|
helpline = " #{base_command} #{command}"
wrapped = word_wrap helpline, width
doc << "#{wrapped}"
end... | ruby | def docopt_examples(width)
return [] if @examples.empty?
doc = ["Examples:"]
base_command = @superspace ? "run #{@superspace}" : "run"
@examples.each do |command|
helpline = " #{base_command} #{command}"
wrapped = word_wrap helpline, width
doc << "#{wrapped}"
end... | [
"def",
"docopt_examples",
"(",
"width",
")",
"return",
"[",
"]",
"if",
"@examples",
".",
"empty?",
"doc",
"=",
"[",
"\"Examples:\"",
"]",
"base_command",
"=",
"@superspace",
"?",
"\"run #{@superspace}\"",
":",
"\"run\"",
"@examples",
".",
"each",
"do",
"|",
... | Return all docopt lines for the 'Examples' section | [
"Return",
"all",
"docopt",
"lines",
"for",
"the",
"Examples",
"section"
] | 2e9da12766c88f27981f0b7b044a26ee724cfda5 | https://github.com/DannyBen/runfile/blob/2e9da12766c88f27981f0b7b044a26ee724cfda5/lib/runfile/docopt_helper.rb#L88-L99 |
2,777 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.hint | def hint(hint_text, options = {})
css_class = "hint #{options.delete(:class)}"
content_tag(:p, content_tag(:span, hint_text.chomp), class:css_class, **options)
end | ruby | def hint(hint_text, options = {})
css_class = "hint #{options.delete(:class)}"
content_tag(:p, content_tag(:span, hint_text.chomp), class:css_class, **options)
end | [
"def",
"hint",
"(",
"hint_text",
",",
"options",
"=",
"{",
"}",
")",
"css_class",
"=",
"\"hint #{options.delete(:class)}\"",
"content_tag",
"(",
":p",
",",
"content_tag",
"(",
":span",
",",
"hint_text",
".",
"chomp",
")",
",",
"class",
":",
"css_class",
",",... | Returns a `p.hint` used to explain a nearby form field containing
the given `hint_text`. | [
"Returns",
"a",
"p",
".",
"hint",
"used",
"to",
"explain",
"a",
"nearby",
"form",
"field",
"containing",
"the",
"given",
"hint_text",
"."
] | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L6-L9 |
2,778 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.image_association_select | def image_association_select(method, collection, value_method, text_method, preview_url_method, options = {})
render(partial:"admin/shared/forms/image_association_select", locals: {
f: self,
method: method,
collection: collection,
value_method: value_method,
text_method: te... | ruby | def image_association_select(method, collection, value_method, text_method, preview_url_method, options = {})
render(partial:"admin/shared/forms/image_association_select", locals: {
f: self,
method: method,
collection: collection,
value_method: value_method,
text_method: te... | [
"def",
"image_association_select",
"(",
"method",
",",
"collection",
",",
"value_method",
",",
"text_method",
",",
"preview_url_method",
",",
"options",
"=",
"{",
"}",
")",
"render",
"(",
"partial",
":",
"\"admin/shared/forms/image_association_select\"",
",",
"locals"... | Creates a `searchable_select` that also shows a dynamic image preview of the selected record.
Useful for previewing images or avatars chosen by name.
`preview_url_method` should be a method name to call on the associated model instance
that returns a fully-qualified URL to the image preview. | [
"Creates",
"a",
"searchable_select",
"that",
"also",
"shows",
"a",
"dynamic",
"image",
"preview",
"of",
"the",
"selected",
"record",
".",
"Useful",
"for",
"previewing",
"images",
"or",
"avatars",
"chosen",
"by",
"name",
".",
"preview_url_method",
"should",
"be",... | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L35-L46 |
2,779 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.markdown_composer | def markdown_composer(method, options = {})
render(partial:"admin/shared/forms/markdown_composer", locals: {
f: self,
method: method,
options: options,
})
end | ruby | def markdown_composer(method, options = {})
render(partial:"admin/shared/forms/markdown_composer", locals: {
f: self,
method: method,
options: options,
})
end | [
"def",
"markdown_composer",
"(",
"method",
",",
"options",
"=",
"{",
"}",
")",
"render",
"(",
"partial",
":",
"\"admin/shared/forms/markdown_composer\"",
",",
"locals",
":",
"{",
"f",
":",
"self",
",",
"method",
":",
"method",
",",
"options",
":",
"options",... | Renders a Markdown composer element for editing `method`,
with fullscreen previewing and some text assistance tools.
Requires that you set `Tolaria.config.markdown_renderer`.
Options are forwarded to `text_area`. | [
"Renders",
"a",
"Markdown",
"composer",
"element",
"for",
"editing",
"method",
"with",
"fullscreen",
"previewing",
"and",
"some",
"text",
"assistance",
"tools",
".",
"Requires",
"that",
"you",
"set",
"Tolaria",
".",
"config",
".",
"markdown_renderer",
".",
"Opti... | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L52-L58 |
2,780 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.attachment_field | def attachment_field(method, options = {})
render(partial:"admin/shared/forms/attachment_field", locals: {
f: self,
method: method,
options: options,
})
end | ruby | def attachment_field(method, options = {})
render(partial:"admin/shared/forms/attachment_field", locals: {
f: self,
method: method,
options: options,
})
end | [
"def",
"attachment_field",
"(",
"method",
",",
"options",
"=",
"{",
"}",
")",
"render",
"(",
"partial",
":",
"\"admin/shared/forms/attachment_field\"",
",",
"locals",
":",
"{",
"f",
":",
"self",
",",
"method",
":",
"method",
",",
"options",
":",
"options",
... | Returns a file upload field with a more pleasant interface than browser
file inputs. Changes messaging if the `method` already exists.
Options are forwarded to the hidden `file_field`. | [
"Returns",
"a",
"file",
"upload",
"field",
"with",
"a",
"more",
"pleasant",
"interface",
"than",
"browser",
"file",
"inputs",
".",
"Changes",
"messaging",
"if",
"the",
"method",
"already",
"exists",
".",
"Options",
"are",
"forwarded",
"to",
"the",
"hidden",
... | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L63-L69 |
2,781 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.image_field | def image_field(method, options = {})
render(partial:"admin/shared/forms/image_field", locals: {
f: self,
method: method,
options: options,
preview_url: options[:preview_url]
})
end | ruby | def image_field(method, options = {})
render(partial:"admin/shared/forms/image_field", locals: {
f: self,
method: method,
options: options,
preview_url: options[:preview_url]
})
end | [
"def",
"image_field",
"(",
"method",
",",
"options",
"=",
"{",
"}",
")",
"render",
"(",
"partial",
":",
"\"admin/shared/forms/image_field\"",
",",
"locals",
":",
"{",
"f",
":",
"self",
",",
"method",
":",
"method",
",",
"options",
":",
"options",
",",
"p... | Returns an image upload field with a more pleasant interface than browser
file inputs. Changes messaging if the `method` already exists.
#### Special Options
- `:preview_url` If the file already exists, provide a URL to a 42×42px
version of the image, and it will be displayed to the user in a preview
box to ... | [
"Returns",
"an",
"image",
"upload",
"field",
"with",
"a",
"more",
"pleasant",
"interface",
"than",
"browser",
"file",
"inputs",
".",
"Changes",
"messaging",
"if",
"the",
"method",
"already",
"exists",
"."
] | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L81-L88 |
2,782 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.timestamp_field | def timestamp_field(method, options = {})
render(partial:"admin/shared/forms/timestamp_field", locals: {
f: self,
method: method,
options: options,
})
end | ruby | def timestamp_field(method, options = {})
render(partial:"admin/shared/forms/timestamp_field", locals: {
f: self,
method: method,
options: options,
})
end | [
"def",
"timestamp_field",
"(",
"method",
",",
"options",
"=",
"{",
"}",
")",
"render",
"(",
"partial",
":",
"\"admin/shared/forms/timestamp_field\"",
",",
"locals",
":",
"{",
"f",
":",
"self",
",",
"method",
":",
"method",
",",
"options",
":",
"options",
"... | Returns a text field that allows the user to input a date and time.
Automatically validates itself and recovers to a template if blanked out.
This field uses moment.js to parse the date and set the values on a
set of hidden Rails `datetime_select` fields.
Options are forwarded to the hidden `datetime_select` group. | [
"Returns",
"a",
"text",
"field",
"that",
"allows",
"the",
"user",
"to",
"input",
"a",
"date",
"and",
"time",
".",
"Automatically",
"validates",
"itself",
"and",
"recovers",
"to",
"a",
"template",
"if",
"blanked",
"out",
".",
"This",
"field",
"uses",
"momen... | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L95-L101 |
2,783 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.slug_field | def slug_field(method, options = {})
pattern = options.delete(:pattern)
preview_value = self.object.send(method).try(:parameterize).presence || "*"
render(partial:"admin/shared/forms/slug_field", locals: {
f: self,
method: method,
options: options,
preview_value: previe... | ruby | def slug_field(method, options = {})
pattern = options.delete(:pattern)
preview_value = self.object.send(method).try(:parameterize).presence || "*"
render(partial:"admin/shared/forms/slug_field", locals: {
f: self,
method: method,
options: options,
preview_value: previe... | [
"def",
"slug_field",
"(",
"method",
",",
"options",
"=",
"{",
"}",
")",
"pattern",
"=",
"options",
".",
"delete",
"(",
":pattern",
")",
"preview_value",
"=",
"self",
".",
"object",
".",
"send",
"(",
"method",
")",
".",
"try",
"(",
":parameterize",
")",... | Returns a text field that parameterizes its input as users type
and renders it into the given preview template. Useful for
demonstrating the value of a URL or other sluggified text.
#### Special Options
- `:pattern` - Should be a string that includes an asterisk (`*`)
character. As the user types, the asterisk... | [
"Returns",
"a",
"text",
"field",
"that",
"parameterizes",
"its",
"input",
"as",
"users",
"type",
"and",
"renders",
"it",
"into",
"the",
"given",
"preview",
"template",
".",
"Useful",
"for",
"demonstrating",
"the",
"value",
"of",
"a",
"URL",
"or",
"other",
... | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L116-L126 |
2,784 | Threespot/tolaria | lib/tolaria/form_buildable.rb | Tolaria.FormBuildable.swatch_field | def swatch_field(method, options = {})
render(partial:"admin/shared/forms/swatch_field", locals: {
f: self,
method: method,
options: options,
})
end | ruby | def swatch_field(method, options = {})
render(partial:"admin/shared/forms/swatch_field", locals: {
f: self,
method: method,
options: options,
})
end | [
"def",
"swatch_field",
"(",
"method",
",",
"options",
"=",
"{",
"}",
")",
"render",
"(",
"partial",
":",
"\"admin/shared/forms/swatch_field\"",
",",
"locals",
":",
"{",
"f",
":",
"self",
",",
"method",
":",
"method",
",",
"options",
":",
"options",
",",
... | Returns a text field that expects to be given a 3 or 6-digit
hexadecimal color value. A preview block near the field
demonstrates the provided color to the user.
Options are forwarded to `text_field`. | [
"Returns",
"a",
"text",
"field",
"that",
"expects",
"to",
"be",
"given",
"a",
"3",
"or",
"6",
"-",
"digit",
"hexadecimal",
"color",
"value",
".",
"A",
"preview",
"block",
"near",
"the",
"field",
"demonstrates",
"the",
"provided",
"color",
"to",
"the",
"u... | e60c5e330f7b423879433e35ec01ee2263e41c2c | https://github.com/Threespot/tolaria/blob/e60c5e330f7b423879433e35ec01ee2263e41c2c/lib/tolaria/form_buildable.rb#L132-L138 |
2,785 | etehtsea/oxblood | lib/oxblood/rsocket.rb | Oxblood.RSocket.gets | def gets(separator, timeout = @timeout)
while (crlf = @buffer.index(separator)).nil?
@buffer << readpartial(1024, timeout)
end
@buffer.slice!(0, crlf + separator.bytesize)
end | ruby | def gets(separator, timeout = @timeout)
while (crlf = @buffer.index(separator)).nil?
@buffer << readpartial(1024, timeout)
end
@buffer.slice!(0, crlf + separator.bytesize)
end | [
"def",
"gets",
"(",
"separator",
",",
"timeout",
"=",
"@timeout",
")",
"while",
"(",
"crlf",
"=",
"@buffer",
".",
"index",
"(",
"separator",
")",
")",
".",
"nil?",
"@buffer",
"<<",
"readpartial",
"(",
"1024",
",",
"timeout",
")",
"end",
"@buffer",
".",... | Read until separator
@param [String] separator separator
@return [String] read result | [
"Read",
"until",
"separator"
] | 0bfc3f6114a6eb5716a9cd44ecea914b273dc268 | https://github.com/etehtsea/oxblood/blob/0bfc3f6114a6eb5716a9cd44ecea914b273dc268/lib/oxblood/rsocket.rb#L59-L65 |
2,786 | etehtsea/oxblood | lib/oxblood/rsocket.rb | Oxblood.RSocket.write | def write(data, timeout = @timeout)
full_size = data.bytesize
while data.bytesize > 0
written = socket.write_nonblock(data, exception: false)
if written == :wait_writable
socket.wait_writable(timeout) or fail_with_timeout!
else
data = data.byteslice(written..-1)... | ruby | def write(data, timeout = @timeout)
full_size = data.bytesize
while data.bytesize > 0
written = socket.write_nonblock(data, exception: false)
if written == :wait_writable
socket.wait_writable(timeout) or fail_with_timeout!
else
data = data.byteslice(written..-1)... | [
"def",
"write",
"(",
"data",
",",
"timeout",
"=",
"@timeout",
")",
"full_size",
"=",
"data",
".",
"bytesize",
"while",
"data",
".",
"bytesize",
">",
"0",
"written",
"=",
"socket",
".",
"write_nonblock",
"(",
"data",
",",
"exception",
":",
"false",
")",
... | Write data to socket
@param [String] data given
@return [Integer] the number of bytes written | [
"Write",
"data",
"to",
"socket"
] | 0bfc3f6114a6eb5716a9cd44ecea914b273dc268 | https://github.com/etehtsea/oxblood/blob/0bfc3f6114a6eb5716a9cd44ecea914b273dc268/lib/oxblood/rsocket.rb#L70-L84 |
2,787 | wilg/laundry | lib/laundry/lib/soap_model.rb | Laundry.SOAPModel.instance_action_module | def instance_action_module
@instance_action_module ||= Module.new do
# Returns the <tt>Savon::Client</tt> from the class instance.
def client(&block)
self.class.client(&block)
end
private
def merged_default_body(body = {})
default = self.respond_to?(:... | ruby | def instance_action_module
@instance_action_module ||= Module.new do
# Returns the <tt>Savon::Client</tt> from the class instance.
def client(&block)
self.class.client(&block)
end
private
def merged_default_body(body = {})
default = self.respond_to?(:... | [
"def",
"instance_action_module",
"@instance_action_module",
"||=",
"Module",
".",
"new",
"do",
"# Returns the <tt>Savon::Client</tt> from the class instance.",
"def",
"client",
"(",
"&",
"block",
")",
"self",
".",
"class",
".",
"client",
"(",
"block",
")",
"end",
"pri... | Instance methods. | [
"Instance",
"methods",
"."
] | 50f02dcc8e9cc7006f4a5dbaa3a1149c2f56a471 | https://github.com/wilg/laundry/blob/50f02dcc8e9cc7006f4a5dbaa3a1149c2f56a471/lib/laundry/lib/soap_model.rb#L94-L110 |
2,788 | mbj/vanguard | lib/vanguard/result.rb | Vanguard.Result.violations | def violations
validator.rules.each_with_object(Set.new) do |rule, violations|
violations.merge(rule.violations(resource))
end
end | ruby | def violations
validator.rules.each_with_object(Set.new) do |rule, violations|
violations.merge(rule.violations(resource))
end
end | [
"def",
"violations",
"validator",
".",
"rules",
".",
"each_with_object",
"(",
"Set",
".",
"new",
")",
"do",
"|",
"rule",
",",
"violations",
"|",
"violations",
".",
"merge",
"(",
"rule",
".",
"violations",
"(",
"resource",
")",
")",
"end",
"end"
] | Return violations for resource
@param [Resource] resource
@api private | [
"Return",
"violations",
"for",
"resource"
] | 1babf0b4b08712f22da0c44f0f72f9651c714aae | https://github.com/mbj/vanguard/blob/1babf0b4b08712f22da0c44f0f72f9651c714aae/lib/vanguard/result.rb#L31-L35 |
2,789 | lwoggardner/rfuse | lib/rfuse.rb | RFuse.Fuse.run | def run(signals=Signal.list.keys)
if mounted?
begin
traps = trap_signals(*signals)
self.loop()
ensure
traps.each { |t| Signal.trap(t,"DEFAULT") }
unmount()
end
end
... | ruby | def run(signals=Signal.list.keys)
if mounted?
begin
traps = trap_signals(*signals)
self.loop()
ensure
traps.each { |t| Signal.trap(t,"DEFAULT") }
unmount()
end
end
... | [
"def",
"run",
"(",
"signals",
"=",
"Signal",
".",
"list",
".",
"keys",
")",
"if",
"mounted?",
"begin",
"traps",
"=",
"trap_signals",
"(",
"signals",
")",
"self",
".",
"loop",
"(",
")",
"ensure",
"traps",
".",
"each",
"{",
"|",
"t",
"|",
"Signal",
"... | Convenience method to run a mounted filesystem to completion.
@param [Array<String|Integer>] signals list of signals to handle.
Default is all available signals. See {#trap_signals}
@return [void]
@since 1.1.0
@see RFuse.main | [
"Convenience",
"method",
"to",
"run",
"a",
"mounted",
"filesystem",
"to",
"completion",
"."
] | 16e0a36c6cd69afb9a9c2a709766cf6177129e9c | https://github.com/lwoggardner/rfuse/blob/16e0a36c6cd69afb9a9c2a709766cf6177129e9c/lib/rfuse.rb#L289-L299 |
2,790 | lwoggardner/rfuse | lib/rfuse.rb | RFuse.Fuse.loop | def loop()
raise RFuse::Error, "Already running!" if @running
raise RFuse::Error, "FUSE not mounted" unless mounted?
@running = true
while @running do
begin
ready, ignore, errors = IO.select([@fuse_io,@pr],[],[@fuse_io])
... | ruby | def loop()
raise RFuse::Error, "Already running!" if @running
raise RFuse::Error, "FUSE not mounted" unless mounted?
@running = true
while @running do
begin
ready, ignore, errors = IO.select([@fuse_io,@pr],[],[@fuse_io])
... | [
"def",
"loop",
"(",
")",
"raise",
"RFuse",
"::",
"Error",
",",
"\"Already running!\"",
"if",
"@running",
"raise",
"RFuse",
"::",
"Error",
",",
"\"FUSE not mounted\"",
"unless",
"mounted?",
"@running",
"=",
"true",
"while",
"@running",
"do",
"begin",
"ready",
"... | Main processing loop
Use {#exit} to stop processing (or externally call fusermount -u)
Other ruby threads can continue while loop is running, however
no thread can operate on the filesystem itself (ie with File or Dir methods)
@return [void]
@raise [RFuse::Error] if already running or not mounted | [
"Main",
"processing",
"loop"
] | 16e0a36c6cd69afb9a9c2a709766cf6177129e9c | https://github.com/lwoggardner/rfuse/blob/16e0a36c6cd69afb9a9c2a709766cf6177129e9c/lib/rfuse.rb#L310-L344 |
2,791 | lwoggardner/rfuse | lib/rfuse.rb | RFuse.FuseDelegator.debug= | def debug=(value)
value = value ? true : false
if @debug && !value
$stderr.puts "=== #{ self }.debug=false"
elsif !@debug && value
$stderr.puts "=== #{ self }.debug=true"
end
@debug = value
end | ruby | def debug=(value)
value = value ? true : false
if @debug && !value
$stderr.puts "=== #{ self }.debug=false"
elsif !@debug && value
$stderr.puts "=== #{ self }.debug=true"
end
@debug = value
end | [
"def",
"debug",
"=",
"(",
"value",
")",
"value",
"=",
"value",
"?",
"true",
":",
"false",
"if",
"@debug",
"&&",
"!",
"value",
"$stderr",
".",
"puts",
"\"=== #{ self }.debug=false\"",
"elsif",
"!",
"@debug",
"&&",
"value",
"$stderr",
".",
"puts",
"\"=== #{ ... | Set debugging on or off
@param [Boolean] value enable or disable debugging
@return [Boolean] the new debug value
@since 1.1.0 | [
"Set",
"debugging",
"on",
"or",
"off"
] | 16e0a36c6cd69afb9a9c2a709766cf6177129e9c | https://github.com/lwoggardner/rfuse/blob/16e0a36c6cd69afb9a9c2a709766cf6177129e9c/lib/rfuse.rb#L503-L511 |
2,792 | p0deje/watir-dom-wait | lib/watir/dom/elements/element.rb | Watir.Element.dom_changed? | def dom_changed?(delay: 1.1)
element_call do
begin
driver.manage.timeouts.script_timeout = delay + 1
driver.execute_async_script(DOM_WAIT_JS, wd, delay)
rescue Selenium::WebDriver::Error::JavascriptError => error
# sometimes we start script execution before new page i... | ruby | def dom_changed?(delay: 1.1)
element_call do
begin
driver.manage.timeouts.script_timeout = delay + 1
driver.execute_async_script(DOM_WAIT_JS, wd, delay)
rescue Selenium::WebDriver::Error::JavascriptError => error
# sometimes we start script execution before new page i... | [
"def",
"dom_changed?",
"(",
"delay",
":",
"1.1",
")",
"element_call",
"do",
"begin",
"driver",
".",
"manage",
".",
"timeouts",
".",
"script_timeout",
"=",
"delay",
"+",
"1",
"driver",
".",
"execute_async_script",
"(",
"DOM_WAIT_JS",
",",
"wd",
",",
"delay",
... | Returns true if DOM is changed within the element.
@example Wait until DOM is changed inside element with default delay
browser.div(id: 'test').wait_until(&:dom_changed?).click
@example Wait until DOM is changed inside element with default delay
browser.div(id: 'test').wait_until do |element|
element.dom... | [
"Returns",
"true",
"if",
"DOM",
"is",
"changed",
"within",
"the",
"element",
"."
] | 1337c446f106748810b3e8cc1e16d02eeba25745 | https://github.com/p0deje/watir-dom-wait/blob/1337c446f106748810b3e8cc1e16d02eeba25745/lib/watir/dom/elements/element.rb#L19-L35 |
2,793 | EvidentSecurity/esp_sdk | lib/esp/resources/signature.rb | ESP.Signature.run! | def run!(arguments = {})
result = run(arguments)
return result if result.is_a?(ActiveResource::Collection)
result.message = result.errors.full_messages.join(' ')
fail(ActiveResource::ResourceInvalid.new(result)) # rubocop:disable Style/RaiseArgs
end | ruby | def run!(arguments = {})
result = run(arguments)
return result if result.is_a?(ActiveResource::Collection)
result.message = result.errors.full_messages.join(' ')
fail(ActiveResource::ResourceInvalid.new(result)) # rubocop:disable Style/RaiseArgs
end | [
"def",
"run!",
"(",
"arguments",
"=",
"{",
"}",
")",
"result",
"=",
"run",
"(",
"arguments",
")",
"return",
"result",
"if",
"result",
".",
"is_a?",
"(",
"ActiveResource",
"::",
"Collection",
")",
"result",
".",
"message",
"=",
"result",
".",
"errors",
... | Run this signature.
Returns a collection of alerts.
Throws an error if not successful.
@param (see #run)
@return [ActiveResource::PaginatedCollection<ESP::Alert>]
@raise [ActiveResource::ResourceInvalid] if not successful.
@example
signature = ESP::Signature.find(3)
alerts = signature.run!(external_account... | [
"Run",
"this",
"signature",
".",
"Returns",
"a",
"collection",
"of",
"alerts",
".",
"Throws",
"an",
"error",
"if",
"not",
"successful",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/signature.rb#L32-L37 |
2,794 | EvidentSecurity/esp_sdk | lib/esp/resources/signature.rb | ESP.Signature.run | def run(arguments = {})
arguments = arguments.with_indifferent_access
attributes['external_account_id'] ||= arguments[:external_account_id]
attributes['region'] ||= arguments[:region]
response = connection.post("#{self.class.prefix}signatures/#{id}/run.json", to_json)
ESP::Alert.send(:ins... | ruby | def run(arguments = {})
arguments = arguments.with_indifferent_access
attributes['external_account_id'] ||= arguments[:external_account_id]
attributes['region'] ||= arguments[:region]
response = connection.post("#{self.class.prefix}signatures/#{id}/run.json", to_json)
ESP::Alert.send(:ins... | [
"def",
"run",
"(",
"arguments",
"=",
"{",
"}",
")",
"arguments",
"=",
"arguments",
".",
"with_indifferent_access",
"attributes",
"[",
"'external_account_id'",
"]",
"||=",
"arguments",
"[",
":external_account_id",
"]",
"attributes",
"[",
"'region'",
"]",
"||=",
"... | Run this signature.
Returns a collection of alerts.
If not successful, returns a Signature object with the errors object populated.
@param arguments [Hash] Required hash of run arguments.
===== Valid Arguments
See {API documentation}[http://api-docs.evident.io?ruby#signature-run] for valid arguments
@return... | [
"Run",
"this",
"signature",
".",
"Returns",
"a",
"collection",
"of",
"alerts",
".",
"If",
"not",
"successful",
"returns",
"a",
"Signature",
"object",
"with",
"the",
"errors",
"object",
"populated",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/signature.rb#L51-L62 |
2,795 | EvidentSecurity/esp_sdk | lib/esp/resources/signature.rb | ESP.Signature.suppress | def suppress(arguments = {})
arguments = arguments.with_indifferent_access
ESP::Suppression::Signature.create(signature_ids: [id], regions: Array(arguments[:regions]), external_account_ids: Array(arguments[:external_account_ids]), reason: arguments[:reason])
end | ruby | def suppress(arguments = {})
arguments = arguments.with_indifferent_access
ESP::Suppression::Signature.create(signature_ids: [id], regions: Array(arguments[:regions]), external_account_ids: Array(arguments[:external_account_ids]), reason: arguments[:reason])
end | [
"def",
"suppress",
"(",
"arguments",
"=",
"{",
"}",
")",
"arguments",
"=",
"arguments",
".",
"with_indifferent_access",
"ESP",
"::",
"Suppression",
"::",
"Signature",
".",
"create",
"(",
"signature_ids",
":",
"[",
"id",
"]",
",",
"regions",
":",
"Array",
"... | Create a suppression for this signature.
@param arguments [Hash] Required hash of signature suppression attributes.
===== Valid Arguments
See {API documentation}[http://api-docs.evident.io?ruby#suppression-create] for valid arguments
@return [ESP::Suppression::Signature]
@example
suppress(regions: ['us_ea... | [
"Create",
"a",
"suppression",
"for",
"this",
"signature",
"."
] | feb1740a8e8849bdeb967a22358f9bcfaa99d215 | https://github.com/EvidentSecurity/esp_sdk/blob/feb1740a8e8849bdeb967a22358f9bcfaa99d215/lib/esp/resources/signature.rb#L73-L76 |
2,796 | propublica/table-setter | lib/table_setter/table.rb | TableSetter.Table.csv_data | def csv_data
case
when google_key || url then Curl::Easy.perform(uri).body_str
when file then File.open(uri).read
end
end | ruby | def csv_data
case
when google_key || url then Curl::Easy.perform(uri).body_str
when file then File.open(uri).read
end
end | [
"def",
"csv_data",
"case",
"when",
"google_key",
"||",
"url",
"then",
"Curl",
"::",
"Easy",
".",
"perform",
"(",
"uri",
")",
".",
"body_str",
"when",
"file",
"then",
"File",
".",
"open",
"(",
"uri",
")",
".",
"read",
"end",
"end"
] | The csv_data for the table fu instance is loaded either from the remote source or from a local
file, depending on the keys present in the yaml file. | [
"The",
"csv_data",
"for",
"the",
"table",
"fu",
"instance",
"is",
"loaded",
"either",
"from",
"the",
"remote",
"source",
"or",
"from",
"a",
"local",
"file",
"depending",
"on",
"the",
"keys",
"present",
"in",
"the",
"yaml",
"file",
"."
] | 11e14dc3359be7cb78400e8a70e0bb0a199daf72 | https://github.com/propublica/table-setter/blob/11e14dc3359be7cb78400e8a70e0bb0a199daf72/lib/table_setter/table.rb#L41-L46 |
2,797 | propublica/table-setter | lib/table_setter/table.rb | TableSetter.Table.updated_at | def updated_at
csv_time = google_key.nil? ? modification_time(uri) : google_modification_time
(csv_time > yaml_time ? csv_time : yaml_time).to_s
end | ruby | def updated_at
csv_time = google_key.nil? ? modification_time(uri) : google_modification_time
(csv_time > yaml_time ? csv_time : yaml_time).to_s
end | [
"def",
"updated_at",
"csv_time",
"=",
"google_key",
".",
"nil?",
"?",
"modification_time",
"(",
"uri",
")",
":",
"google_modification_time",
"(",
"csv_time",
">",
"yaml_time",
"?",
"csv_time",
":",
"yaml_time",
")",
".",
"to_s",
"end"
] | The real +updated_at+ of a Table instance is the newer modification time of the csv file or
the yaml file. Updates to either resource should break the cache. | [
"The",
"real",
"+",
"updated_at",
"+",
"of",
"a",
"Table",
"instance",
"is",
"the",
"newer",
"modification",
"time",
"of",
"the",
"csv",
"file",
"or",
"the",
"yaml",
"file",
".",
"Updates",
"to",
"either",
"resource",
"should",
"break",
"the",
"cache",
"... | 11e14dc3359be7cb78400e8a70e0bb0a199daf72 | https://github.com/propublica/table-setter/blob/11e14dc3359be7cb78400e8a70e0bb0a199daf72/lib/table_setter/table.rb#L59-L62 |
2,798 | propublica/table-setter | lib/table_setter/table.rb | TableSetter.Table.paginate! | def paginate!(curr_page)
return if !hard_paginate?
@page = curr_page.to_i
raise ArgumentError if @page < 1 || @page > total_pages
adj_page = @page - 1 > 0 ? @page - 1 : 0
@prev_page = adj_page > 0 ? adj_page : nil
@next_page = page < total_pages ? (@page + 1) : nil
@data.only!(... | ruby | def paginate!(curr_page)
return if !hard_paginate?
@page = curr_page.to_i
raise ArgumentError if @page < 1 || @page > total_pages
adj_page = @page - 1 > 0 ? @page - 1 : 0
@prev_page = adj_page > 0 ? adj_page : nil
@next_page = page < total_pages ? (@page + 1) : nil
@data.only!(... | [
"def",
"paginate!",
"(",
"curr_page",
")",
"return",
"if",
"!",
"hard_paginate?",
"@page",
"=",
"curr_page",
".",
"to_i",
"raise",
"ArgumentError",
"if",
"@page",
"<",
"1",
"||",
"@page",
">",
"total_pages",
"adj_page",
"=",
"@page",
"-",
"1",
">",
"0",
... | paginate uses TableFu's only! method to batch the table. It also computes the page attributes
which are nil and meaningless otherwise. | [
"paginate",
"uses",
"TableFu",
"s",
"only!",
"method",
"to",
"batch",
"the",
"table",
".",
"It",
"also",
"computes",
"the",
"page",
"attributes",
"which",
"are",
"nil",
"and",
"meaningless",
"otherwise",
"."
] | 11e14dc3359be7cb78400e8a70e0bb0a199daf72 | https://github.com/propublica/table-setter/blob/11e14dc3359be7cb78400e8a70e0bb0a199daf72/lib/table_setter/table.rb#L85-L93 |
2,799 | propublica/table-setter | lib/table_setter/table.rb | TableSetter.Table.sort_array | def sort_array
if @data.sorted_by
@data.sorted_by.inject([]) do |memo, (key, value)|
memo << [@data.columns.index(key), value == 'descending' ? 1 : 0]
end
end
end | ruby | def sort_array
if @data.sorted_by
@data.sorted_by.inject([]) do |memo, (key, value)|
memo << [@data.columns.index(key), value == 'descending' ? 1 : 0]
end
end
end | [
"def",
"sort_array",
"if",
"@data",
".",
"sorted_by",
"@data",
".",
"sorted_by",
".",
"inject",
"(",
"[",
"]",
")",
"do",
"|",
"memo",
",",
"(",
"key",
",",
"value",
")",
"|",
"memo",
"<<",
"[",
"@data",
".",
"columns",
".",
"index",
"(",
"key",
... | A convienence method to return the sort array for table setter. | [
"A",
"convienence",
"method",
"to",
"return",
"the",
"sort",
"array",
"for",
"table",
"setter",
"."
] | 11e14dc3359be7cb78400e8a70e0bb0a199daf72 | https://github.com/propublica/table-setter/blob/11e14dc3359be7cb78400e8a70e0bb0a199daf72/lib/table_setter/table.rb#L103-L109 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.