_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q12600 | I18n.Config.missing_interpolation_argument_handler | train | def missing_interpolation_argument_handler
@@missing_interpolation_argument_handler ||= lambda do |missing_key, provided_hash, string|
| ruby | {
"resource": ""
} |
q12601 | I18n.Base.translate | train | def translate(key = nil, *, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
locale ||= config.locale
raise Disabled.new('t') if locale == false
enforce_available_locales!(locale)
backend = config.backend
result = catch(:exception) do
if key.is_a?(Array... | ruby | {
"resource": ""
} |
q12602 | I18n.Base.exists? | train | def exists?(key, _locale = nil, locale: _locale)
locale ||= config.locale
raise Disabled.new('exists?') if locale == false
| ruby | {
"resource": ""
} |
q12603 | I18n.Base.localize | train | def localize(object, locale: nil, format: nil, **options)
locale ||= config.locale
raise Disabled.new('l') if locale == false
enforce_available_locales!(locale)
| ruby | {
"resource": ""
} |
q12604 | I18n.Base.normalize_keys | train | def normalize_keys(locale, key, scope, separator = nil)
separator ||= I18n.default_separator
keys = []
| ruby | {
"resource": ""
} |
q12605 | I18n.Base.enforce_available_locales! | train | def enforce_available_locales!(locale)
if locale != false && config.enforce_available_locales
raise | ruby | {
"resource": ""
} |
q12606 | JekyllFeed.Generator.generate | train | def generate(site)
@site = site
collections.each do |name, meta|
Jekyll.logger.info "Jekyll Feed:", "Generating feed for #{name}"
(meta["categories"] + [nil]).each | ruby | {
"resource": ""
} |
q12607 | JekyllFeed.Generator.normalize_posts_meta | train | def normalize_posts_meta(hash)
hash["posts"] ||= {}
hash["posts"]["path"] ||= config["path"] | ruby | {
"resource": ""
} |
q12608 | Hashie.Rash.all | train | def all(query)
return to_enum(:all, query) unless block_given?
if @hash.include? query
yield @hash[query]
return
end
case query
when String
optimize_if_necessary!
# see if any of the regexps match the string
@regexes.each do |regex|
matc... | ruby | {
"resource": ""
} |
q12609 | Hashie.Mash.custom_reader | train | def custom_reader(key)
default_proc.call(self, key) if default_proc && !key?(key)
value = | ruby | {
"resource": ""
} |
q12610 | Hashie.Mash.custom_writer | train | def custom_writer(key, value, convert = true) #:nodoc:
key_as_symbol = (key = convert_key(key)).to_sym
log_built_in_message(key_as_symbol) if | ruby | {
"resource": ""
} |
q12611 | Hashie.Mash.initializing_reader | train | def initializing_reader(key)
ck = convert_key(key)
| ruby | {
"resource": ""
} |
q12612 | Hashie.Mash.underbang_reader | train | def underbang_reader(key)
ck = convert_key(key)
if key?(ck) | ruby | {
"resource": ""
} |
q12613 | Hashie.Mash.deep_update | train | def deep_update(other_hash, &blk)
other_hash.each_pair do |k, v|
key = convert_key(k)
if v.is_a?(::Hash) && key?(key) && regular_reader(key).is_a?(Mash)
custom_reader(key).deep_update(v, &blk)
else
value = convert_value(v, true)
| ruby | {
"resource": ""
} |
q12614 | CounterCulture.Extensions._update_counts_after_update | train | def _update_counts_after_update
self.class.after_commit_counter_cache.each do |counter|
# figure out whether the applicable counter cache changed (this can happen
# with dynamic column names)
counter_cache_name_was = counter.counter_cache_name_for(counter.previous_model(self))
coun... | ruby | {
"resource": ""
} |
q12615 | CounterCulture.Extensions.destroyed_for_counter_culture? | train | def destroyed_for_counter_culture?
if respond_to?(:paranoia_destroyed?)
paranoia_destroyed?
elsif defined?(Discard::Model) && | ruby | {
"resource": ""
} |
q12616 | CounterCulture.Counter.change_counter_cache | train | def change_counter_cache(obj, options)
change_counter_column = options.fetch(:counter_column) { counter_cache_name_for(obj) }
# default to the current foreign key value
id_to_change = foreign_key_value(obj, relation, options[:was])
# allow overwriting of foreign key value by the caller
id... | ruby | {
"resource": ""
} |
q12617 | CounterCulture.Counter.foreign_key_value | train | def foreign_key_value(obj, relation, was = false)
relation = relation.is_a?(Enumerable) ? relation.dup : [relation]
first_relation = relation.first
if was
first = relation.shift
foreign_key_value = attribute_was(obj, relation_foreign_key(first))
klass = relation_klass(first, so... | ruby | {
"resource": ""
} |
q12618 | CounterCulture.Counter.relation_reflect | train | def relation_reflect(relation)
relation = relation.is_a?(Enumerable) ? relation.dup : [relation]
# go from one relation to the next until we hit the last reflect object
klass = model
while relation.size > 0
cur_relation = relation.shift
reflect = klass.reflect_on_association(cur... | ruby | {
"resource": ""
} |
q12619 | CounterCulture.Counter.relation_klass | train | def relation_klass(relation, source: nil, was: false)
reflect = relation_reflect(relation)
if reflect.options.key?(:polymorphic)
raise "Can't work out relation's class without being passed object (relation: #{relation}, reflect: #{reflect})" if source.nil?
raise "Can't work out polymorhpic r... | ruby | {
"resource": ""
} |
q12620 | CounterCulture.Counter.relation_primary_key | train | def relation_primary_key(relation, source: nil, was: false)
reflect = relation_reflect(relation)
klass = nil
if reflect.options.key?(:polymorphic)
raise "can't handle multiple keys with polymorphic associations" unless (relation.is_a?(Symbol) || relation.length == 1)
raise "must | ruby | {
"resource": ""
} |
q12621 | EraJa.Conversion.to_era | train | def to_era(format = "%o%E.%m.%d", era_names: ERA_NAME_DEFAULTS)
raise EraJa::DateOutOfRangeError unless era_convertible?
@era_format = format.gsub(/%J/, "%J%")
str_time = strftime(@era_format)
if @era_format =~ /%([EOo]|1O)/
case
when self.to_time < ::Time.mktime(1912,7,30)
... | ruby | {
"resource": ""
} |
q12622 | IStats.Utils.abs_thresholds | train | def abs_thresholds(scale, max_value)
at = []
| ruby | {
"resource": ""
} |
q12623 | Cliver.Dependency.open? | train | def open?
ProcTable.ps.any? { |p| p.comm == path }
# See | ruby | {
"resource": ""
} |
q12624 | Google.Auth.get_application_default | train | def get_application_default scope = nil, options = {}
creds = DefaultCredentials.from_env(scope, options) ||
DefaultCredentials.from_well_known_path(scope, options) ||
DefaultCredentials.from_system_default_path(scope, options)
return creds unless creds.nil?
unless | ruby | {
"resource": ""
} |
q12625 | Sprockets.DirectiveProcessor.extract_directives | train | def extract_directives(header)
processed_header = String.new("")
directives = []
header.lines.each_with_index do |line, index|
if directive = line[DIRECTIVE_PATTERN, 1]
name, *args = Shellwords.shellwords(directive)
if respond_to?("process_#{name}_directive", t... | ruby | {
"resource": ""
} |
q12626 | Rake.SprocketsTask.log_level= | train | def log_level=(level)
if level.is_a?(Integer)
@logger.level = level
else
@logger.level | ruby | {
"resource": ""
} |
q12627 | Rake.SprocketsTask.with_logger | train | def with_logger
if env = manifest.environment
old_logger = env.logger
| ruby | {
"resource": ""
} |
q12628 | Sprockets.Processing.register_pipeline | train | def register_pipeline(name, proc = nil, &block)
proc ||= block
self.config = hash_reassoc(config, :pipeline_exts) do |pipeline_exts|
pipeline_exts.merge(".#{name}".freeze => name.to_sym)
end | ruby | {
"resource": ""
} |
q12629 | Sprockets.Paths.prepend_path | train | def prepend_path(path)
self.config = hash_reassoc(config, :paths) do |paths|
path | ruby | {
"resource": ""
} |
q12630 | Sprockets.Paths.append_path | train | def append_path(path)
self.config = hash_reassoc(config, :paths) do |paths|
| ruby | {
"resource": ""
} |
q12631 | Sprockets.Context.depend_on | train | def depend_on(path)
if environment.absolute_path?(path) && environment.stat(path)
@dependencies | ruby | {
"resource": ""
} |
q12632 | Sprockets.Context.base64_asset_data_uri | train | def base64_asset_data_uri(asset)
data = Rack::Utils.escape(EncodingUtils.base64(asset.source))
| ruby | {
"resource": ""
} |
q12633 | Sprockets.Context.optimize_svg_for_uri_escaping! | train | def optimize_svg_for_uri_escaping!(svg)
# Remove comments, xml meta, and doctype
svg.gsub!(/<!--.*?-->|<\?.*?\?>|<!.*?>/m, '')
# Replace consecutive whitespace and | ruby | {
"resource": ""
} |
q12634 | Sprockets.Context.optimize_quoted_uri_escapes! | train | def optimize_quoted_uri_escapes!(escaped)
escaped.gsub!('%3D', '=')
escaped.gsub!('%3A', ':') | ruby | {
"resource": ""
} |
q12635 | Sprockets.Manifest.compile | train | def compile(*args)
unless environment
raise Error, "manifest requires environment for compilation"
end
filenames = []
concurrent_exporters = []
assets_to_export = Concurrent::Array.new
find(*args) do |asset|
assets_to_export << asset
end
asse... | ruby | {
"resource": ""
} |
q12636 | Sprockets.Manifest.remove | train | def remove(filename)
path = File.join(dir, filename)
gzip = "#{path}.gz"
logical_path = files[filename]['logical_path']
if assets[logical_path] == filename | ruby | {
"resource": ""
} |
q12637 | Sprockets.Manifest.clean | train | def clean(count = 2, age = 3600)
asset_versions = files.group_by { |_, attrs| attrs['logical_path'] }
asset_versions.each do |logical_path, versions|
current = assets[logical_path]
versions.reject { |path, _|
path == current
}.sort_by { |_, attrs|
# Sort by time... | ruby | {
"resource": ""
} |
q12638 | Sprockets.Manifest.save | train | def save
data = json_encode(@data)
FileUtils.mkdir_p File.dirname(@filename)
| ruby | {
"resource": ""
} |
q12639 | Sprockets.Manifest.exporters_for_asset | train | def exporters_for_asset(asset)
exporters = [Exporters::FileExporter]
environment.exporters.each do |mime_type, exporter_list|
next unless asset.content_type
next unless environment.match_mime_type? asset.content_type, mime_type
exporter_list.each do |exporter|
... | ruby | {
"resource": ""
} |
q12640 | Sprockets.Server.call | train | def call(env)
start_time = Time.now.to_f
time_elapsed = lambda { ((Time.now.to_f - start_time) * 1000).to_i }
unless ALLOWED_REQUEST_METHODS.include? env['REQUEST_METHOD']
return method_not_allowed_response
end
msg = "Served asset #{env['PATH_INFO']} -"
# Extract the path ... | ruby | {
"resource": ""
} |
q12641 | Sprockets.Server.ok_response | train | def ok_response(asset, env)
if head_request?(env)
[ 200, headers(env, asset, 0), [] ]
else
| ruby | {
"resource": ""
} |
q12642 | Refinery.Image.thumbnail | train | def thumbnail(options = {})
options = { geometry: nil, strip: false }.merge(options)
geometry = convert_to_geometry(options[:geometry])
| ruby | {
"resource": ""
} |
q12643 | Refinery.Image.thumbnail_dimensions | train | def thumbnail_dimensions(geometry)
dimensions = ThumbnailDimensions.new(geometry, image.width, image.height)
{ | ruby | {
"resource": ""
} |
q12644 | Refinery.Page.reposition_parts! | train | def reposition_parts!
reload.parts.each_with_index do |part, index|
| ruby | {
"resource": ""
} |
q12645 | Refinery.Page.path | train | def path(path_separator: ' - ', ancestors_first: true)
return title if root?
chain = ancestors_first ? self_and_ancestors : | ruby | {
"resource": ""
} |
q12646 | Refinery.SiteBarHelper.site_bar_switch_link | train | def site_bar_switch_link
link_to_if(admin?, t('.switch_to_your_website', site_bar_translate_locale_args),
refinery.root_path(site_bar_translate_locale_args),
'data-turbolinks' => false) do
| ruby | {
"resource": ""
} |
q12647 | Refinery.ImageHelper.image_fu | train | def image_fu(image, geometry = nil, options = {})
return nil if image.blank?
thumbnail_args = options.slice(:strip)
thumbnail_args[:geometry] = geometry if geometry
image_tag_args = (image.thumbnail_dimensions(geometry) rescue {})
| ruby | {
"resource": ""
} |
q12648 | Draper.Factory.decorate | train | def decorate(object, options = {})
return nil if object.nil? | ruby | {
"resource": ""
} |
q12649 | Draper.QueryMethods.method_missing | train | def method_missing(method, *args, &block)
return super unless strategy.allowed? method
| ruby | {
"resource": ""
} |
q12650 | FriendlyId.Configuration.use | train | def use(*modules)
modules.to_a.flatten.compact.map do |object|
mod = get_module(object)
mod.setup(@model_class) if mod.respond_to?(:setup)
| ruby | {
"resource": ""
} |
q12651 | FriendlyId.Slugged.normalize_friendly_id | train | def normalize_friendly_id(value)
value = value.to_s.parameterize
| ruby | {
"resource": ""
} |
q12652 | FriendlyId.Base.friendly_id | train | def friendly_id(base = nil, options = {}, &block)
yield friendly_id_config if block_given?
friendly_id_config.dependent = options.delete :dependent
friendly_id_config.use options.delete :use
| ruby | {
"resource": ""
} |
q12653 | FriendlyId.FinderMethods.find | train | def find(*args)
id = args.first
return super if args.count != 1 || id.unfriendly_id?
first_by_friendly_id(id).tap {|result| return result unless result.nil?}
| ruby | {
"resource": ""
} |
q12654 | NameEntity.PermitAlterations.valid_for_deletion? | train | def valid_for_deletion?
return false if(id.nil? || sync_token.nil?)
id.to_i > 0 | ruby | {
"resource": ""
} |
q12655 | Typhoeus.EasyFactory.get | train | def get
begin
easy.http_request(
request.base_url.to_s,
request.options.fetch(:method, :get),
sanitize(request.options)
)
rescue Ethon::Errors::InvalidOption => | ruby | {
"resource": ""
} |
q12656 | Typhoeus.EasyFactory.set_callback | train | def set_callback
if request.streaming?
response = nil
easy.on_headers do |easy|
response = Response.new(Ethon::Easy::Mirror.from_easy(easy).options)
request.execute_headers_callbacks(response)
end
request.on_body.each do |callback|
easy.on_body do |chu... | ruby | {
"resource": ""
} |
q12657 | Typhoeus.Request.url | train | def url
easy = EasyFactory.new(self).get
url = easy.url
| ruby | {
"resource": ""
} |
q12658 | Typhoeus.Request.fuzzy_hash_eql? | train | def fuzzy_hash_eql?(left, right)
return true if (left == right)
(left.count == right.count) && left.inject(true) | ruby | {
"resource": ""
} |
q12659 | Typhoeus.Request.set_defaults | train | def set_defaults
default_user_agent = Config.user_agent || Typhoeus::USER_AGENT
options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})
options[:headers]['Expect'] ||= ''
options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.... | ruby | {
"resource": ""
} |
q12660 | Typhoeus.Expectation.and_return | train | def and_return(response=nil, &block)
new_response = (response.nil? ? block : response)
| ruby | {
"resource": ""
} |
q12661 | Typhoeus.Expectation.response | train | def response(request)
response = responses.fetch(@response_counter, responses.last)
if response.respond_to?(:call)
response = response.call(request)
end | ruby | {
"resource": ""
} |
q12662 | Typhoeus.Expectation.options_match? | train | def options_match?(request)
(options ? options.all?{ |k,v| request.original_options[k] == v | ruby | {
"resource": ""
} |
q12663 | Typhoeus.Expectation.url_match? | train | def url_match?(request_url)
case base_url
when String
base_url == request_url
when Regexp
base_url === | ruby | {
"resource": ""
} |
q12664 | Fae.FormHelper.list_order | train | def list_order(f, attribute, options)
if is_association?(f, attribute) && !options[:collection]
begin
options[:collection] = to_class(attribute).for_fae_index
rescue NameError
| ruby | {
"resource": ""
} |
q12665 | Fae.FormHelper.set_prompt | train | def set_prompt(f, attribute, options)
options[:prompt] = 'Select One' if is_association?(f, attribute) && | ruby | {
"resource": ""
} |
q12666 | Fae.FormHelper.language_support | train | def language_support(f, attribute, options)
return if Fae.languages.blank?
attribute_array = attribute.to_s.split('_')
language_suffix = attribute_array.pop
return unless Fae.languages.has_key?(language_suffix.to_sym) || Fae.languages.has_key?(language_suffix)
label = attribute_array.pus... | ruby | {
"resource": ""
} |
q12667 | Fae.Cloneable.update_cloneable_associations | train | def update_cloneable_associations
associations_for_cloning.each do |association|
type = @klass.reflect_on_association(association)
through_record = type.through_reflection
if through_record.present?
clone_join_relationships(through_record.plural_name)
else
| ruby | {
"resource": ""
} |
q12668 | Savon.GlobalOptions.log_level | train | def log_level(level)
levels = { :debug => 0, :info => 1, :warn => 2, :error => 3, :fatal => 4 }
unless levels.include? level
raise ArgumentError, "Invalid log level: #{level.inspect}\n" \
| ruby | {
"resource": ""
} |
q12669 | Sunspot.Session.new_search | train | def new_search(*types, &block)
types.flatten!
search = Search::StandardSearch.new(
connection,
setup_for_types(types),
Query::StandardQuery.new(types), | ruby | {
"resource": ""
} |
q12670 | Sunspot.Session.new_more_like_this | train | def new_more_like_this(object, *types, &block)
types[0] ||= object.class
mlt = Search::MoreLikeThisSearch.new(
connection,
setup_for_types(types), | ruby | {
"resource": ""
} |
q12671 | Sunspot.Session.more_like_this | train | def more_like_this(object, *types, &block)
mlt = new_more_like_this(object, | ruby | {
"resource": ""
} |
q12672 | Sunspot.Session.atomic_update | train | def atomic_update(clazz, updates = {})
@adds += | ruby | {
"resource": ""
} |
q12673 | Sunspot.Session.remove | train | def remove(*objects, &block)
if block
types = objects
conjunction = Query::Connective::Conjunction.new
if types.length == 1
conjunction.add_positive_restriction(TypeField.instance, Query::Restriction::EqualTo, types.first)
else
conjunction.add_positive_restricti... | ruby | {
"resource": ""
} |
q12674 | Sunspot.Session.remove_by_id | train | def remove_by_id(clazz, *ids)
class_name =
if clazz.is_a?(Class)
| ruby | {
"resource": ""
} |
q12675 | Sunspot.Session.remove_all | train | def remove_all(*classes)
classes.flatten!
if classes.empty?
@deletes += 1
indexer.remove_all
else
| ruby | {
"resource": ""
} |
q12676 | Sunspot.Session.connection | train | def connection
@connection ||= self.class.connection_class.connect(
url: config.solr.url,
read_timeout: config.solr.read_timeout,
open_timeout: config.solr.open_timeout,
| ruby | {
"resource": ""
} |
q12677 | Sunspot.Schema.dynamic_fields | train | def dynamic_fields
fields = []
variant_combinations.each do |field_variants|
FIELD_TYPES.each do |type|
| ruby | {
"resource": ""
} |
q12678 | Sunspot.Schema.to_xml | train | def to_xml
template_path = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'schema.xml.erb')
template_text = File.read(template_path)
erb = if RUBY_VERSION >= '2.6'
| ruby | {
"resource": ""
} |
q12679 | Sunspot.Schema.variant_combinations | train | def variant_combinations
combinations = []
0.upto(2 ** FIELD_VARIANTS.length - 1) do |b|
combinations << combination = []
FIELD_VARIANTS.each_with_index do |variant, i|
| ruby | {
"resource": ""
} |
q12680 | Sunspot.CompositeSetup.text_fields | train | def text_fields(field_name)
if text_fields = text_fields_hash[field_name.to_sym]
text_fields.to_a
else
raise(
UnrecognizedFieldError,
"No | ruby | {
"resource": ""
} |
q12681 | Sunspot.CompositeSetup.text_fields_hash | train | def text_fields_hash
@text_fields_hash ||=
setups.inject({}) do |hash, setup|
setup.all_text_fields.each do |text_field|
| ruby | {
"resource": ""
} |
q12682 | Sunspot.CompositeSetup.fields_hash | train | def fields_hash
@fields_hash ||=
begin
field_sets_hash = Hash.new { |h, k| h[k] = Set.new }
@types.each do |type|
Setup.for(type).fields.each do |field|
field_sets_hash[field.name.to_sym] << field
end
end
| ruby | {
"resource": ""
} |
q12683 | Sunspot.Setup.add_text_field_factory | train | def add_text_field_factory(name, options = {}, &block)
stored, more_like_this = options[:stored], options[:more_like_this]
field_factory = FieldFactory::Static.new(name, Type::TextType.instance, options, &block)
@text_field_factories[name] = field_factory
@text_field_factories_cache[field_factor... | ruby | {
"resource": ""
} |
q12684 | Sunspot.Setup.add_dynamic_field_factory | train | def add_dynamic_field_factory(name, type, options = {}, &block)
stored, more_like_this = options[:stored], options[:more_like_this]
field_factory = FieldFactory::Dynamic.new(name, type, options, &block)
@dynamic_field_factories[field_factory.signature] = field_factory
@dynamic_field_factories_ca... | ruby | {
"resource": ""
} |
q12685 | Sunspot.Setup.all_more_like_this_fields | train | def all_more_like_this_fields
@more_like_this_field_factories_cache.values.map do |field_factories|
| ruby | {
"resource": ""
} |
q12686 | Sunspot.Setup.all_field_factories | train | def all_field_factories
all_field_factories = []
all_field_factories.concat(field_factories).concat(tex | ruby | {
"resource": ""
} |
q12687 | Sunspot.Indexer.add_atomic_update | train | def add_atomic_update(clazz, updates={})
documents = updates.map { |id, m| prepare_atomic_update(clazz, | ruby | {
"resource": ""
} |
q12688 | Sunspot.Indexer.remove | train | def remove(*models)
@connection.delete_by_id(
models.map { |model| | ruby | {
"resource": ""
} |
q12689 | Sunspot.Indexer.remove_by_id | train | def remove_by_id(class_name, *ids)
ids.flatten!
@connection.delete_by_id(
ids.map | ruby | {
"resource": ""
} |
q12690 | Sunspot.Indexer.prepare_full_update | train | def prepare_full_update(model)
document = document_for_full_update(model)
setup = setup_for_object(model)
if boost = setup.document_boost_for(model)
document.attrs[:boost] = boost
end | ruby | {
"resource": ""
} |
q12691 | Sunspot.Indexer.document_for_full_update | train | def document_for_full_update(model)
RSolr::Xml::Document.new(
id: Adapters::InstanceAdapter.adapt(model).index_id,
type: | ruby | {
"resource": ""
} |
q12692 | Phonelib.PhoneAnalyzer.analyze | train | def analyze(phone, passed_country)
country = country_or_default_country passed_country
result = parse_country(phone, country)
d_result = case
when result && result.values.find { |e| e[:valid].any? }
# all is good, return result
when passed_country.... | ruby | {
"resource": ""
} |
q12693 | Phonelib.PhoneAnalyzer.better_result | train | def better_result(base_result, result = nil)
base_result ||= {}
return base_result unless result
return result unless base_result.values.find { |e| e[:possible].any? }
| ruby | {
"resource": ""
} |
q12694 | Phonelib.PhoneAnalyzer.with_replaced_national_prefix | train | def with_replaced_national_prefix(phone, data)
return phone unless data[Core::NATIONAL_PREFIX_TRANSFORM_RULE]
pattern = cr("^(?:#{data[Core::NATIONAL_PREFIX_FOR_PARSING]})")
match = phone.match pattern
if match | ruby | {
"resource": ""
} |
q12695 | Phonelib.PhoneAnalyzer.parse_country | train | def parse_country(phone, country)
data = Phonelib.phone_data[country]
return nil unless data
# if country was provided and it's a valid country, trying to
# create e164 representation of phone number,
# kind of normalization for parsing
e164 = convert_to_e164 with_replaced_national_... | ruby | {
"resource": ""
} |
q12696 | Phonelib.PhoneAnalyzer.parse_single_country | train | def parse_single_country(e164, data)
valid_match = phone_match_data?(e164, data)
if valid_match
national_and_data(data, valid_match)
else
possible_match = | ruby | {
"resource": ""
} |
q12697 | Phonelib.PhoneAnalyzer.detect_and_parse | train | def detect_and_parse(phone, country)
result = {}
Phonelib.phone_data.each do |key, data|
parsed = parse_single_country(phone, data)
if (!Phonelib.strict_double_prefix_check || key == country) && double_prefix_allowed?(data, phone, parsed && parsed[key])
| ruby | {
"resource": ""
} |
q12698 | Phonelib.PhoneAnalyzer.convert_to_e164 | train | def convert_to_e164(phone, data)
match = phone.match full_regex_for_data(data, Core::VALID_PATTERN, !original_starts_with_plus?)
case
when match
"#{data[Core::COUNTRY_CODE]}#{match.to_a.last}"
when phone.match(cr("^#{data[Core::INTERNATIONAL_PREFIX]}"))
phone.sub(cr("^#{data[Core... | ruby | {
"resource": ""
} |
q12699 | Phonelib.PhoneAnalyzer.national_and_data | train | def national_and_data(data, country_match, not_valid = false)
result = data.select { |k, _v| k != :types && k != :formats }
phone = country_match.to_a.last
result[:national] = phone
result[:format] = number_format(phone, | ruby | {
"resource": ""
} |
Subsets and Splits
SQL Console for CoIR-Retrieval/CodeSearchNet-ccr-ruby-queries-corpus
Retrieves a large number of entries in the 'ruby' language, providing basic information but limited analytical value.