_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 66
10.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q2800
|
TableSetter.Table.web_modification_time
|
train
|
def web_modification_time(local_url)
resp = nil
Net::HTTP.start(local_url.host, 80) do |http|
resp = http.head(local_url.path)
end
resp['Last-Modified'].nil? ? Time.at(0) : Time.parse(resp['Last-Modified'])
end
|
ruby
|
{
"resource": ""
}
|
q2801
|
TableSetter.Table.modification_time
|
train
|
def modification_time(path)
is_uri = URI.parse(path)
if !is_uri.host.nil?
return web_modification_time is_uri
end
File.new(path).mtime
end
|
ruby
|
{
"resource": ""
}
|
q2802
|
EPP.Request.to_xml
|
train
|
def to_xml
doc = XML::Document.new('1.0')
doc.root = XML::Node.new('epp')
root = doc.root
epp_ns = XML::Namespace.new(root, nil, 'urn:ietf:params:xml:ns:epp-1.0')
root.namespaces.namespace = epp_ns
xsi_ns = XML::Namespace.new(root, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
xsi_sL = XML::Attr.new(root, 'schemaLocation', 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd')
xsi_sL.namespaces.namespace = xsi_ns
@namespaces = {'epp' => epp_ns, 'xsi' => xsi_ns}
@request.set_namespaces(@namespaces) if @request.respond_to?(:set_namespaces)
root << @request.to_xml
doc
end
|
ruby
|
{
"resource": ""
}
|
q2803
|
EPP.Response.extension
|
train
|
def extension
@extension ||= begin
list = @xml.find('/e:epp/e:response/e:extension/node()').reject { |n| n.empty? }
list.size > 1 ? list : list[0]
end
end
|
ruby
|
{
"resource": ""
}
|
q2804
|
Jekyll.MarkdownBlock.render
|
train
|
def render(context)
site = context.registers[:site]
converter = site.getConverterImpl(::Jekyll::Converters::Markdown)
converter.convert(render_block(context))
end
|
ruby
|
{
"resource": ""
}
|
q2805
|
KQueue.Queue.watch_socket_for_read
|
train
|
def watch_socket_for_read(fd, low_water = nil, &callback)
Watcher::SocketReadWrite.new(self, fd, :read, low_water, callback)
end
|
ruby
|
{
"resource": ""
}
|
q2806
|
KQueue.Queue.watch_file
|
train
|
def watch_file(path, *flags, &callback)
Watcher::File.new(self, path, flags, callback)
end
|
ruby
|
{
"resource": ""
}
|
q2807
|
KQueue.Queue.watch_process
|
train
|
def watch_process(pid, *flags, &callback)
Watcher::Process.new(self, pid, flags, callback)
end
|
ruby
|
{
"resource": ""
}
|
q2808
|
NbaStats.CommonTeamRoster.common_team_roster
|
train
|
def common_team_roster(
team_id,
season,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonTeamRoster.new(
get(COMMON_TEAM_ROSTER_PATH, {
:Season => season,
:LeagueID => league_id,
:TeamID => team_id
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2809
|
RSpec::TagMatchers.HasInput.build_name
|
train
|
def build_name(*args)
args.extend(DeepFlattening)
args = args.deep_flatten
name = args.shift.to_s
name + args.map {|piece| "[#{piece}]"}.join
end
|
ruby
|
{
"resource": ""
}
|
q2810
|
NbaStats.BoxScoreAdvanced.box_score_advanced
|
train
|
def box_score_advanced(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreAdvanced.new(
get(BOX_SCORE_ADVANCED_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2811
|
NbaStats.CommonAllPlayers.common_all_players
|
train
|
def common_all_players(
season,
is_only_current_season=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonAllPlayers.new(
get(COMMON_ALL_PLAYERS_PATH, {
:LeagueID => league_id,
:Season => season,
:IsOnlyCurrentSeason => is_only_current_season
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2812
|
NbaStats.TeamInfoCommon.team_info_common
|
train
|
def team_info_common(
team_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamInfoCommon.new(
get(TEAM_INFO_COMMON_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2813
|
NbaStats.TeamYearByYearStats.team_year_by_year_stats
|
train
|
def team_year_by_year_stats(
team_id,
season,
per_mode=NbaStats::Constants::PER_MODE_TOTALS,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamYearByYearStats.new(
get(TEAM_YEAR_BY_YEAR_STATS_PATH, {
:LeagueID => league_id,
:PerMode => per_mode,
:SeasonType => season_type,
:TeamID => team_id,
:Season => season
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2814
|
NbaStats.BoxScoreUsage.box_score_usage
|
train
|
def box_score_usage(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreUsage.new(
get(BOX_SCORE_USAGE_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2815
|
NbaStats.DraftCombinePlayerAnthro.draft_combine_player_anthro
|
train
|
def draft_combine_player_anthro(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombinePlayerAnthro.new(
get(DRAFT_COMBINE_PLAYER_ANTHRO_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2816
|
Wagons.Installer.available
|
train
|
def available
return @available if defined?(@available)
# only keep most recent version in @available
@available = []
load_available_specs.each do |spec|
if prev = @available.find { |w| w.name == spec.name }
if prev.version < spec.version
@available.delete(prev)
@available << spec
end
else
@available << spec
end
end
@available
end
|
ruby
|
{
"resource": ""
}
|
q2817
|
Wagons.Installer.wagonfile_update
|
train
|
def wagonfile_update(specs)
wagonfile_edit(specs) do |spec, content|
declaration = "gem '#{spec.name}'"
declaration += ", '#{spec.version}'" if include_version_in_wagonfile
unless content.sub!(gem_declaration_regexp(spec.name), declaration)
content += "\n#{declaration}"
end
content
end
end
|
ruby
|
{
"resource": ""
}
|
q2818
|
Wagons.Installer.wagonfile_remove
|
train
|
def wagonfile_remove(specs)
wagonfile_edit(specs) do |spec, content|
content.sub(gem_declaration_regexp(spec.name), '')
end
end
|
ruby
|
{
"resource": ""
}
|
q2819
|
Wagons.Installer.check_dependencies
|
train
|
def check_dependencies(specs)
missing = check_app_requirement(specs)
present = exclude_specs(installed, specs)
future = present + specs
check_all_dependencies(specs, future, missing)
end
|
ruby
|
{
"resource": ""
}
|
q2820
|
Wagons.Installer.check_app_requirement
|
train
|
def check_app_requirement(specs)
missing = []
specs.each do |spec|
if wagon = wagon_class(spec)
unless wagon.app_requirement.satisfied_by?(Wagons.app_version)
missing << "#{spec} requires application version #{wagon.app_requirement}"
end
end
end
missing
end
|
ruby
|
{
"resource": ""
}
|
q2821
|
Wagons.Installer.check_protected
|
train
|
def check_protected(specs)
protected = []
specs.each do |spec|
msg = Wagons.find(spec.name).protect?
protected << msg if msg.is_a?(String)
end
protected.join("\n").presence
end
|
ruby
|
{
"resource": ""
}
|
q2822
|
Wagons.Installer.specs_from_names
|
train
|
def specs_from_names(names)
names.map do |name|
spec = available_spec(name)
fail "#{name} was not found" if spec.nil?
spec
end
end
|
ruby
|
{
"resource": ""
}
|
q2823
|
Wagons.Installer.exclude_specs
|
train
|
def exclude_specs(full, to_be_excluded)
full.clone.delete_if { |s| to_be_excluded.find { |d| s.name == d.name } }
end
|
ruby
|
{
"resource": ""
}
|
q2824
|
Wagons.Installer.wagon_class
|
train
|
def wagon_class(spec)
@wagon_classes ||= {}
return @wagon_classes[spec] if @wagon_classes.key?(spec)
clazz = nil
file = File.join(spec.gem_dir, 'lib', spec.name, 'wagon.rb')
if File.exist?(file)
require file
clazz = "#{spec.name.camelize}::Wagon".constantize
else
fail "#{spec.name} wagon class not found in #{file}"
end
@wagon_classes[spec] = clazz
end
|
ruby
|
{
"resource": ""
}
|
q2825
|
NbaStats.CommonPlayerInfo.common_player_info
|
train
|
def common_player_info(
player_id,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonPlayerInfo.new(
get(COMMON_PLAYER_INFO_PATH, {
:PlayerID => player_id,
:SeasonType => season_type,
:LeagueID => league_id
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2826
|
NbaStats.FranchiseHistory.franchise_history
|
train
|
def franchise_history(
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::FranchiseHistory.new(
get(FRANCHISE_HISTORY_PATH, {
:LeagueID => league_id
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2827
|
NbaStats.LeagueDashLineups.league_dash_lineups
|
train
|
def league_dash_lineups(
season,
group_quantity=5,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
per_mode=NbaStats::Constants::PER_MODE_GAME,
plus_minus=NbaStats::Constants::NO,
pace_adjust=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
outcome='',
location='',
month=0,
season_segment='',
date_from='',
date_to='',
opponent_team_id=0,
vs_conference='',
vs_division='',
game_segment='',
period=0,
last_n_games=0,
game_id='',
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil? or date_from.empty?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil? or date_to.empty?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::LeagueDashLineups.new(
get(LEAGUE_DASH_LINEUPS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameID => game_id,
:GameSegment => game_segment,
:GroupQuantity => group_quantity,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2828
|
Rails.Application.ordered_railties_with_wagons
|
train
|
def ordered_railties_with_wagons
@ordered_railties ||= ordered_railties_without_wagons.tap do |ordered|
flat = Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('4.1.6')
Wagons.all.each do |w|
if flat
ordered.push(ordered.delete(w))
else
ordered.unshift(array_deep_delete(ordered, w))
end
end
end
end
|
ruby
|
{
"resource": ""
}
|
q2829
|
NbaStats.HomePageLeaders.home_page_leaders
|
train
|
def home_page_leaders(
season,
game_scope=NbaStats::Constants::GAME_SCOPE_SEASON,
stat_category=NbaStats::Constants::STAT_CATEGORY_POINTS,
player_scope=NbaStats::Constants::PLAYER_SCOPE_ALL_PLAYERS,
player_or_team=NbaStats::Constants::PLAYER_OR_TEAM_PLAYER,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::HomePageLeaders.new(
get(HOME_PAGE_LEADERS_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:GameScope => game_scope,
:StatCategory => stat_category,
:PlayerScope => player_scope,
:PlayerOrTeam => player_or_team
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2830
|
NbaStats.TeamGameLog.team_game_log
|
train
|
def team_game_log(
team_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::TeamGameLog.new(
get(TEAM_GAME_LOG_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2831
|
NbaStats.BoxScoreScoring.box_score_scoring
|
train
|
def box_score_scoring(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreScoring.new(
get(BOX_SCORE_SCORING_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2832
|
NbaStats.DraftCombineSpotShooting.draft_combine_spot_shooting
|
train
|
def draft_combine_spot_shooting(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineSpotShooting.new(
get(DRAFT_COMBINE_SPOT_SHOOTING_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2833
|
NbaStats.CommonTeamYears.common_team_years
|
train
|
def common_team_years(
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::CommonTeamYears.new(
get(COMMON_TEAM_YEARS_PATH, {
:LeagueID => league_id
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2834
|
DeskApi.Client.request
|
train
|
def request(method, path, params = {}, &block)
connection.send(method, path, params, &block)
rescue Faraday::Error::ClientError => err
raise DeskApi::Error::ClientError.new(err)
rescue JSON::ParserError => err
raise DeskApi::Error::ParserError.new(err)
end
|
ruby
|
{
"resource": ""
}
|
q2835
|
NbaStats.ShotChartDetail.shot_chart_detail
|
train
|
def shot_chart_detail(
season,
team_id,
player_id,
game_id=nil,
outcome=nil,
location=nil,
month=0,
season_segment=nil,
date_from=nil,
date_to=nil,
opponent_team_id=0,
vs_conference=nil,
vs_division=nil,
position=nil,
rookie_year=nil,
game_segment=nil,
period=0,
last_n_games=0,
context_filter=nil,
context_measure=NbaStats::Constants::CONTEXT_MEASURE_FG_PCT,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::ShotChartDetail.new(
get(SHOT_CHART_DETAIL_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:TeamID => team_id,
:PlayerID => player_id,
:GameID => game_id,
:Outcome => outcome,
:Location => location,
:Month => month,
:SeasonSegment => season_segment,
:DateFrom => date_from,
:DateTo => date_to,
:OpponentTeamID => opponent_team_id,
:VsConference => vs_conference,
:VsDivision => vs_division,
:Position => position,
:RookieYear => rookie_year,
:GameSegment => game_segment,
:Period => period,
:LastNGames => last_n_games,
:ContextFilter => context_filter,
:ContextMeasure => context_measure
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2836
|
DeskApi.Configuration.middleware
|
train
|
def middleware
@middleware ||= proc do |builder|
builder.request(:desk_encode_dates)
builder.request(:desk_encode_json)
builder.request(*authorize_request)
builder.request(:desk_retry)
builder.response(:desk_parse_dates)
builder.response(:desk_follow_redirects)
builder.response(:desk_raise_error, DeskApi::Error::ClientError)
builder.response(:desk_raise_error, DeskApi::Error::ServerError)
builder.response(:desk_parse_json)
builder.adapter(Faraday.default_adapter)
end
end
|
ruby
|
{
"resource": ""
}
|
q2837
|
DeskApi.Configuration.reset!
|
train
|
def reset!
DeskApi::Configuration.keys.each do |key|
send("#{key}=", DeskApi::Default.options[key])
end
self
end
|
ruby
|
{
"resource": ""
}
|
q2838
|
DeskApi.Configuration.validate_credentials!
|
train
|
def validate_credentials!
fail(
DeskApi::Error::ConfigurationError, 'Invalid credentials: ' \
'Either username/password or OAuth credentials must be specified.'
) unless credentials?
validate_oauth! if oauth.values.all?
validate_basic_auth! if basic_auth.values.all?
end
|
ruby
|
{
"resource": ""
}
|
q2839
|
Mikon.DataFrame.pivot
|
train
|
def pivot(args={})
args = {
column: nil,
row: nil,
value: nil,
fill_value: Float::NAN
}.merge(args)
raise ArgumentError unless [:column, :row, :value].all?{|sym| args[sym].is_a?(Symbol)}
column = self[args[:column]].factors
index = self[args[:row]].factors
source = column.reduce({}) do |memo, label|
arr = []
df = self.select{|row| row[args[:column]] == label}
index.each do |i|
unless df.any?{|row| row[args[:row]] == i}
arr.push(args[:fill_value])
else
column = df.select{|row| row[args[:row]] == i}[args[:value]]
arr.push(column.to_a[0])
end
end
memo[label] = arr
memo
end
Mikon::DataFrame.new(source, index: index)
end
|
ruby
|
{
"resource": ""
}
|
q2840
|
Eden.BasicTokenizer.translate_keyword_tokens
|
train
|
def translate_keyword_tokens( token )
keywords = ["__LINE__", "__ENCODING__", "__FILE__", "BEGIN",
"END", "alias", "and", "begin", "break", "case",
"class", "def", "defined?", "do", "else", "elsif",
"end", "ensure", "false", "for", "if", "in",
"module", "next", "nil", "not", "or", "redo",
"rescue", "retry", "return", "self", "super",
"then", "true", "undef", "unless", "until",
"when", "while", "yield"]
if keywords.include?( token.content )
token.type = token.content.downcase.to_sym
# Change the state if we match a keyword
@expr_state = :beg
end
# A couple of exceptions
if token.content == "BEGIN"
token.type = :begin_global
@expr_state = :beg
elsif token.content == "END"
token.type = :end_global
@expr_state = :beg
end
token
end
|
ruby
|
{
"resource": ""
}
|
q2841
|
NbaStats.Client.get
|
train
|
def get(path='/', params={})
uri = Addressable::URI.new
uri.query_values = params
# Build the path with + instead of %20 because nba.com is flaky
full_path = "#{path}?#{uri.query.gsub(/%20/,'+')}"
request(:get, full_path)
end
|
ruby
|
{
"resource": ""
}
|
q2842
|
NbaStats.Client.request
|
train
|
def request(method, path)
resource[path].send(method.to_sym, request_headers) { |response, request, result, &block|
case response.code
when 200
response
when 400
if response.include? ' is required'
raise ArgumentError.new(response)
else
raise BadRequestError.new(response)
end
else
response.return!(request, result, &block)
end
}
end
|
ruby
|
{
"resource": ""
}
|
q2843
|
NbaStats.DraftCombineStats.draft_combine_stats
|
train
|
def draft_combine_stats(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineStats.new(
get(DRAFT_COMBINE_STATS_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2844
|
NbaStats.PlayerDashboardByGeneralSplits.player_dashboard_by_general_splits
|
train
|
def player_dashboard_by_general_splits(
season,
player_id,
date_from=nil,
date_to=nil,
game_segment=nil,
last_n_games=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA,
location=nil,
measure_type=NbaStats::Constants::MEASURE_TYPE_USAGE,
month=0,
opponent_team_id=0,
outcome=nil,
pace_adjust=NbaStats::Constants::NO,
per_mode=NbaStats::Constants::PER_MODE_GAME,
period=0,
plus_minus=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
season_segment=nil,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
vs_conference=nil,
vs_division=nil
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::PlayerDashboardByGeneralSplits.new(
get(PLAYER_DASHBOARD_BY_GENERAL_SPLITS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameSegment => game_segment,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlayerID => player_id,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2845
|
RSpec::TagMatchers::Helpers.SentenceHelper.make_sentence
|
train
|
def make_sentence(*strings)
options = strings.last.is_a?(Hash) ? strings.pop : {}
strings = strings.flatten.map(&:to_s).reject(&:empty?)
conjunction = options[:conjunction] || "and"
case strings.count
when 0
""
when 1
strings.first
else
last = strings.pop
puncuation = strings.count > 1 ? ", " : " "
[strings, "#{conjunction} #{last}"].flatten.join(puncuation)
end
end
|
ruby
|
{
"resource": ""
}
|
q2846
|
Drape.AutomaticDelegation.method_missing
|
train
|
def method_missing(method, *args, &block)
return super unless delegatable?(method)
self.class.delegate method
send(method, *args, &block)
end
|
ruby
|
{
"resource": ""
}
|
q2847
|
NbaStats.BoxScoreFourFactors.box_score_four_factors
|
train
|
def box_score_four_factors(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreFourFactors.new(
get(BOX_SCORE_FOUR_FACTORS_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2848
|
RSpec::TagMatchers.HasTag.matches?
|
train
|
def matches?(rendered)
@rendered = rendered
matches = Nokogiri::HTML::Document.parse(@rendered.to_s).css(@name).select do |element|
matches_attributes?(element) && matches_content?(element) && matches_criteria?(element)
end
matches_count?(matches)
end
|
ruby
|
{
"resource": ""
}
|
q2849
|
RSpec::TagMatchers.HasTag.grouped_attributes_description
|
train
|
def grouped_attributes_description(attributes)
make_sentence(
attributes.sort_by{ |key, value| key.to_s }.map do |key, value|
attribute_description(key, value)
end
)
end
|
ruby
|
{
"resource": ""
}
|
q2850
|
NbaStats.PlayerProfile.player_profile
|
train
|
def player_profile(
player_id,
season,
graph_start_season,
graph_end_season,
graph_stat=NbaStats::Constants::GRAPH_STAT_POINTS,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerProfile.new(
get(PLAYER_PROFILE_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:PlayerID => player_id,
:GraphStartSeason => graph_start_season,
:GraphEndSeason => graph_end_season,
:GraphStat => graph_stat
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2851
|
NbaStats.PlayerCareerStats.player_career_stats
|
train
|
def player_career_stats(
player_id,
per_mode=NbaStats::Constants::PER_MODE_TOTALS,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerCareerStats.new(
get(PLAYER_CAREER_STATS_PATH, {
:PlayerID => player_id,
:LeagueID => league_id,
:PerMode => per_mode
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2852
|
Eden.StringTokenizer.tokenize_non_expanded_string
|
train
|
def tokenize_non_expanded_string( start_delimiter )
delimiter_depth = 0
matched_delimiter = is_matched_delimiter?( start_delimiter )
end_delimiter = find_matching_delimiter( start_delimiter )
advance # Pass the opening delimiter
until((cchar == end_delimiter && delimiter_depth == 0) || @i >= @length)
if matched_delimiter
delimiter_depth += 1 if cchar == start_delimiter
delimiter_depth -= 1 if cchar == end_delimiter
end
if cchar == '\\'
advance(2) # Pass the escaped character
else
advance
end
end
advance # Pass the closing quote
if @state == :regex
advance if ['i', 'm'].include?( cchar )
end
@expr_state = :end
capture_token( @state )
end
|
ruby
|
{
"resource": ""
}
|
q2853
|
Eden.StringTokenizer.tokenize_heredoc_delimiter
|
train
|
def tokenize_heredoc_delimiter
offset = 2
if cchar == '-'
advance
offset = 3
end
if cchar =~ /[A-Za-z_]/
advance
advance until /[A-Za-z0-9_]/.match( cchar ).nil?
elsif /['"`]/.match(cchar)
advance_through_quoted_delimiter(cchar)
else
return nil
end
@heredoc_delimiter = thunk[offset..-1]
capture_token( :heredoc_delimiter )
end
|
ruby
|
{
"resource": ""
}
|
q2854
|
DeskApi.Resource.to_hash
|
train
|
def to_hash
load
{}.tap do |hash|
@_definition.each do |k, v|
hash[k] = v
end
end
end
|
ruby
|
{
"resource": ""
}
|
q2855
|
DeskApi.Resource.respond_to?
|
train
|
def respond_to?(method)
load
meth = method.to_s
return true if is_embedded?(meth)
return true if is_link?(meth)
return true if meth.end_with?('=') and is_field?(meth[0...-1])
return true if is_field?(meth)
super
end
|
ruby
|
{
"resource": ""
}
|
q2856
|
DeskApi.Resource.get_embedded_resource
|
train
|
def get_embedded_resource(method)
return @_embedded[method] if @_embedded.key?(method)
@_embedded[method] = @_definition['_embedded'][method]
if @_embedded[method].kind_of?(Array)
@_embedded[method].tap do |ary|
ary.map!{ |definition| new_resource(definition, true) } unless ary.first.kind_of?(self.class)
end
else
@_embedded[method] = new_resource(@_embedded[method], true)
end
end
|
ruby
|
{
"resource": ""
}
|
q2857
|
DeskApi.Resource.get_linked_resource
|
train
|
def get_linked_resource(method)
return @_links[method] if @_links.key?(method)
@_links[method] = @_definition['_links'][method]
if @_links[method] and not @_links[method].kind_of?(self.class)
@_links[method] = new_resource(self.class.build_self_link(@_links[method]))
end
end
|
ruby
|
{
"resource": ""
}
|
q2858
|
DeskApi.Resource.method_missing
|
train
|
def method_missing(method, *args, &block)
load
meth = method.to_s
return get_embedded_resource(meth) if is_embedded?(meth)
return get_linked_resource(meth) if is_link?(meth)
return @_changed[meth[0...-1]] = args.first if meth.end_with?('=') and is_field?(meth[0...-1])
return get_field_value(meth) if is_field?(meth)
super(method, *args, &block)
end
|
ruby
|
{
"resource": ""
}
|
q2859
|
NbaStats.LeagueDashPlayerStats.league_dash_player_stats
|
train
|
def league_dash_player_stats(
season,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
per_mode=NbaStats::Constants::PER_MODE_GAME,
plus_minus=NbaStats::Constants::NO,
pace_adjust=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
outcome=nil,
location=nil,
month=0,
season_segment=nil,
date_from=nil,
date_to=nil,
opponent_team_id=0,
vs_conference=nil,
vs_division=nil,
game_segment=nil,
period=0,
last_n_games=0,
game_scope=nil,
player_experience=nil,
player_position=nil,
starter_bench=nil,
conf=NbaStats::Constants::CONF_BOTH,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
unless date_from.nil?
date_from = date_from.strftime('%m-%d-%Y')
end
unless date_to.nil?
date_to = date_to.strftime('%m-%d-%Y')
end
NbaStats::Resources::LeagueDashPlayerStats.new(
get(LEAGUE_DASH_PLAYER_STATS_PATH, {
:Season => season,
:SeasonType => season_type,
:LeagueID => league_id,
:MeasureType => measure_type,
:PerMode => per_mode,
:PlusMinus => plus_minus,
:PaceAdjust => pace_adjust,
:Rank => rank,
:Outcome => outcome,
:Location => location,
:Month => month,
:SeasonSegment => season_segment,
:DateFrom => date_from,
:DateTo => date_to,
:OpponentTeamID => opponent_team_id,
:VsConference => vs_conference,
:VsDivision => vs_division,
:GameSegment => game_segment,
:Period => period,
:LastNGames => last_n_games,
:GameScope => game_scope,
:PlayerExperience => player_experience,
:PlayerPosition => player_position,
:StarterBench => starter_bench,
:Conf => conf
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2860
|
NbaStats.BoxScore.box_score
|
train
|
def box_score(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScore.new(
get(BOX_SCORE_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2861
|
Rarbac.UserHelper.has_roles?
|
train
|
def has_roles?(*args)
throw Exception.new("Must supply at least one role.") if args.empty?
roles.where(name: args).count == args.count
end
|
ruby
|
{
"resource": ""
}
|
q2862
|
Rarbac.UserHelper.has_permission?
|
train
|
def has_permission?(action)
return true if Action.where(name: action).count == 0
actions.where(name: action).count > 0
end
|
ruby
|
{
"resource": ""
}
|
q2863
|
NbaStats.Scoreboard.scoreboard
|
train
|
def scoreboard(
game_date=Date.today,
day_offset=0,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::Scoreboard.new(
get(SCOREBOARD_PATH, {
:LeagueID => league_id,
:GameDate => game_date.strftime('%m-%d-%Y'),
:DayOffset => day_offset
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2864
|
AdMan.ApplicationHelper.get_keyword_from_url
|
train
|
def get_keyword_from_url
if request.env["REQUEST_PATH"]
req_url = request.env["REQUEST_PATH"].split("/")
keyword_names = Keyword.all.map(&:name)
keyword = req_url & keyword_names
end
end
|
ruby
|
{
"resource": ""
}
|
q2865
|
Entangled.Helpers.redis
|
train
|
def redis
if defined?($redis) && $redis
Redis.new($redis.client.options)
elsif defined?(REDIS) && REDIS
Redis.new(REDIS.client.options)
else
Redis.new
end
end
|
ruby
|
{
"resource": ""
}
|
q2866
|
NbaStats.DraftCombineDrillResults.draft_combine_drill_results
|
train
|
def draft_combine_drill_results(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineDrillResults.new(
get(DRAFT_COMBINE_DRILL_RESULTS_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2867
|
NbaStats.PlayByPlay.play_by_play
|
train
|
def play_by_play(
game_id,
start_period=0,
end_period=0
)
NbaStats::Resources::PlayByPlay.new(
get(PLAY_BY_PLAY_PATH, {
:GameID => game_id,
:StartPeriod => start_period,
:EndPeriod => end_period
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2868
|
KQueue.Watcher.native
|
train
|
def native(flags)
native = Native::KEvent.new
native[:ident] = @ident
native[:filter] = Native::Flags.to_flag("EVFILT", @filter)
native[:flags] = Native::Flags.to_mask("EV", @flags | flags)
native[:fflags] = Native::Flags.to_mask("NOTE_#{@filter.to_s.upcase}", @fflags)
native[:data] = @data if @data
native
end
|
ruby
|
{
"resource": ""
}
|
q2869
|
KQueue.Watcher.kevent!
|
train
|
def kevent!(*flags)
if Native.kevent(@queue.fd, native(flags).pointer, 1, nil, 0, nil) < 0
KQueue.handle_error
end
end
|
ruby
|
{
"resource": ""
}
|
q2870
|
NbaStats.DraftCombineNonStationaryShooting.draft_combine_non_stationary_shooting
|
train
|
def draft_combine_non_stationary_shooting(
season_year,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::DraftCombineNonStationaryShooting.new(
get(DRAFT_COMBINE_NON_STATIONARY_SHOOTING_PATH, {
:LeagueID => league_id,
:SeasonYear => season_year
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2871
|
WalmartOpen.Request.convert_param_keys
|
train
|
def convert_param_keys(underscored_params)
pairs = underscored_params.map do |key, value|
key = key.to_s.gsub(/_([a-z])/i) { $1.upcase }
[key, value]
end
Hash[pairs]
end
|
ruby
|
{
"resource": ""
}
|
q2872
|
NbaStats.BoxScoreMisc.box_score_misc
|
train
|
def box_score_misc(
game_id,
range_type=0,
start_period=0,
end_period=0,
start_range=0,
end_range=0
)
NbaStats::Resources::BoxScoreMisc.new(
get(BOX_SCORE_MISC_PATH, {
:GameID => game_id,
:RangeType => range_type,
:StartPeriod => start_period,
:EndPeriod => end_period,
:StartRange => start_range,
:EndRange => end_range
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2873
|
NbaStats.LeagueDashTeamStats.league_dash_team_stats
|
train
|
def league_dash_team_stats(
season,
date_from=nil,
date_to=nil,
game_scope=nil,
game_segment=nil,
last_n_games=0,
location=nil,
measure_type=NbaStats::Constants::MEASURE_TYPE_BASE,
month=0,
opponent_team_id=0,
outcome=nil,
pace_adjust=NbaStats::Constants::NO,
per_mode=NbaStats::Constants::PER_MODE_GAME,
period=0,
player_experience=nil,
player_position=nil,
plus_minus=NbaStats::Constants::NO,
rank=NbaStats::Constants::NO,
season_segment=nil,
starter_bench=nil,
vs_conference=nil,
vs_division=nil,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::LeagueDashTeamStats.new(
get(LEAGUE_DASH_TEAM_STATS_PATH, {
:DateFrom => date_from,
:DateTo => date_to,
:GameScope => game_scope,
:GameSegment => game_segment,
:LastNGames => last_n_games,
:LeagueID => league_id,
:Location => location,
:MeasureType => measure_type,
:Month => month,
:OpponentTeamID => opponent_team_id,
:Outcome => outcome,
:PaceAdjust => pace_adjust,
:PerMode => per_mode,
:Period => period,
:PlayerExperience => player_experience,
:PlayerPosition => player_position,
:PlusMinus => plus_minus,
:Rank => rank,
:Season => season,
:SeasonSegment => season_segment,
:SeasonType => season_type,
:StarterBench => starter_bench,
:VsConference => vs_conference,
:VsDivision => vs_division
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2874
|
NbaStats.PlayerGameLog.player_game_log
|
train
|
def player_game_log(
player_id,
season,
season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,
league_id=NbaStats::Constants::LEAGUE_ID_NBA
)
NbaStats::Resources::PlayerGameLog.new(
get(PLAYER_GAME_LOG_PATH, {
:Season => season,
:LeagueID => league_id,
:PlayerID => player_id,
:SeasonType => season_type
})
)
end
|
ruby
|
{
"resource": ""
}
|
q2875
|
RSpec::TagMatchers.MultipleInputMatcher.matches?
|
train
|
def matches?(rendered)
@rendered = rendered
@failures = matchers.reject do |matcher|
matcher.matches?(rendered)
end
@failures.empty?
end
|
ruby
|
{
"resource": ""
}
|
q2876
|
RSpec::TagMatchers.MultipleInputMatcher.for
|
train
|
def for(*args)
@for = args.dup
@for.extend(DeepFlattening)
@for = @for.deep_flatten
@components.each do |index, matcher|
delegated_for(index, matcher, @for)
end
self
end
|
ruby
|
{
"resource": ""
}
|
q2877
|
RSpec::TagMatchers.MultipleInputMatcher.delegated_for
|
train
|
def delegated_for(key, matcher, args)
args = args.dup
args[-1] = args[-1].to_s
args[-1] += "(#{key})"
matcher.for(*args)
end
|
ruby
|
{
"resource": ""
}
|
q2878
|
Dco.CLI.assert_repo!
|
train
|
def assert_repo!
begin
# Check if the repo fails to load at all.
repo
rescue Exception
raise Thor::Error.new("#{repo_path} does not appear to be a git repository")
end
unless repo.repo.writable?
raise Thor::Error.new("Git repository at #{repo.repo.path} is read-only")
end
end
|
ruby
|
{
"resource": ""
}
|
q2879
|
Dco.CLI.current_branch
|
train
|
def current_branch
repo.current_branch.tap {|b| raise Thor::Error.new("No explicit branch passed and current head looks detached: #{b}") if b[0] == '(' }
end
|
ruby
|
{
"resource": ""
}
|
q2880
|
Dco.CLI.has_sign_off?
|
train
|
def has_sign_off?(commit_or_message)
message = commit_or_message.is_a?(String) ? commit_or_message : commit_or_message.message
if message =~ /^Signed-off-by: (.+)$/
$1
else
nil
end
end
|
ruby
|
{
"resource": ""
}
|
q2881
|
BinaryParser.AbstractBinary.alt
|
train
|
def alt(binary_or_uint)
case binary_or_uint
when Integer
alt_uint(binary_or_uint)
when String
alt_binary(binary_or_uint)
else
raise BadManipulationError, "Argument shouled be Integer or binary-encoded String."
end
end
|
ruby
|
{
"resource": ""
}
|
q2882
|
Mikon.DataFrame.[]
|
train
|
def [](arg)
case
when arg.is_a?(Range)
index = @index.select{|i| arg.include?(i)}
Mikon::DataFrame.new(index.map{|i| self.row(i)}, {index: index})
when arg.is_a?(Symbol)
self.column(arg)
end
end
|
ruby
|
{
"resource": ""
}
|
q2883
|
Mikon.DataFrame.column
|
train
|
def column(label)
pos = @labels.index(label)
raise "There is no column named " + label if pos.nil?
Mikon::Series.new(label, @data[pos], index: @index)
end
|
ruby
|
{
"resource": ""
}
|
q2884
|
Mikon.DataFrame.to_html
|
train
|
def to_html(threshold=50)
html = "<html><table><tr><td></td>"
html += @labels.map{|label| "<th>" + label.to_s + "</th>"}.join
html += "</tr>"
self.each_row.with_index do |row, pos|
next if pos > threshold && pos != self.length-1
html += "<tr><th>" + @index[pos].to_s + "</th>"
html += @labels.map{|label| "<td>" + row[label].to_s + "</td>"}.join
html += "</tr>"
html += "<tr><th>...</th>" + "<td>...</td>"*@labels.length + "</tr>" if pos == threshold
end
html += "</table>"
end
|
ruby
|
{
"resource": ""
}
|
q2885
|
Mikon.DataFrame.sort
|
train
|
def sort(label, ascending=true)
i = @labels.index(label)
raise "No column named" + label.to_s if i.nil?
order = @data[i].sorted_indices
order.reverse! unless ascending
self.sort_by.with_index{|val, i| order.index(i)}
end
|
ruby
|
{
"resource": ""
}
|
q2886
|
Mikon.DataFrame.row
|
train
|
def row(index)
pos = @index.index(index)
arr = @data.map{|column| column[pos]}
Mikon::Row.new(@labels, arr, index)
end
|
ruby
|
{
"resource": ""
}
|
q2887
|
Opulent.Parser.block_yield
|
train
|
def block_yield(parent, indent)
return unless accept :yield
# Consume the newline from the end of the element
error :yield unless accept(:line_feed).strip.empty?
# Create a new node
yield_node = [:yield, nil, {}, [], indent]
parent[@children] << yield_node
end
|
ruby
|
{
"resource": ""
}
|
q2888
|
Faalis::Dashboard::Sections.ResourceCreate.create
|
train
|
def create
authorize model
@resource = model.new(creation_params)
@resource.assign_attributes(**reflections_hash) unless reflections_hash.nil?
# Customize the create behaviour
before_create_hook(@resource)
# TODO: Handle M2M relations in here
if @resource.save
after_create_hook(@resource)
successful_response(:create)
else
errorful_resopnse(:create, @resource.errors) do
redirect_to Rails.application.routes.url_helpers.send(@new_route)
end
end
end
|
ruby
|
{
"resource": ""
}
|
q2889
|
Faalis::Dashboard::Sections.ResourceCreate.is_reflection?
|
train
|
def is_reflection?(c)
has_many = ActiveRecord::Reflection::HasManyReflection
has_and_belongs_to_many = ActiveRecord::Reflection::HasAndBelongsToManyReflection
has_many_through = ActiveRecord::Reflection::ThroughReflection
result = c.is_a?(has_many) || c.is_a?(has_and_belongs_to_many)
result || c.is_a?(has_many_through)
end
|
ruby
|
{
"resource": ""
}
|
q2890
|
Dialers.Transformable.transform_to_one
|
train
|
def transform_to_one(entity_class_or_decider, root: nil)
object = root ? raw_data[root] : raw_data
transform_attributes_to_object(entity_class_or_decider, object)
end
|
ruby
|
{
"resource": ""
}
|
q2891
|
Dialers.Transformable.transform_to_many
|
train
|
def transform_to_many(entity_class_or_decider, root: nil)
items = get_rooted_items(root)
unless items.is_a?(Array)
fail Dialers::ImpossibleTranformationError.new(response)
end
items.map { |item| transform_attributes_to_object(entity_class_or_decider, item) }
end
|
ruby
|
{
"resource": ""
}
|
q2892
|
Polipus.PolipusCrawler.add_url
|
train
|
def add_url(url, params = {})
page = Page.new(url, params)
yield(page) if block_given?
internal_queue << page.to_json
end
|
ruby
|
{
"resource": ""
}
|
q2893
|
Polipus.PolipusCrawler.should_be_visited?
|
train
|
def should_be_visited?(url, with_tracker = true)
case
# robots.txt
when !allowed_by_robot?(url)
false
# Check against whitelist pattern matching
when !@follow_links_like.empty? && @follow_links_like.none? { |p| url.path =~ p }
false
# Check against blacklist pattern matching
when @skip_links_like.any? { |p| url.path =~ p }
false
# Page is marked as expired
when page_expired?(Page.new(url))
true
# Check against url tracker
when with_tracker && url_tracker.visited?(@options[:include_query_string_in_saved_page] ? url.to_s : url.to_s.gsub(/\?.*$/, ''))
false
else
true
end
end
|
ruby
|
{
"resource": ""
}
|
q2894
|
Polipus.PolipusCrawler.links_for
|
train
|
def links_for(page)
page.domain_aliases = domain_aliases
@focus_crawl_block.nil? ? page.links : @focus_crawl_block.call(page)
end
|
ruby
|
{
"resource": ""
}
|
q2895
|
Polipus.PolipusCrawler.page_expired?
|
train
|
def page_expired?(page)
return false if @options[:ttl_page].nil?
stored_page = @storage.get(page)
r = stored_page && stored_page.expired?(@options[:ttl_page])
@logger.debug { "Page #{page.url} marked as expired" } if r
r
end
|
ruby
|
{
"resource": ""
}
|
q2896
|
Polipus.PolipusCrawler.page_exists?
|
train
|
def page_exists?(page)
return false if page.user_data && page.user_data.p_seeded
@storage.exists?(page) && !page_expired?(page)
end
|
ruby
|
{
"resource": ""
}
|
q2897
|
Polipus.PolipusCrawler.enqueue
|
train
|
def enqueue(url_to_visit, current_page)
page_to_visit = Page.new(url_to_visit.to_s, referer: current_page.url.to_s, depth: current_page.depth + 1)
internal_queue << page_to_visit.to_json
to_track = @options[:include_query_string_in_saved_page] ? url_to_visit.to_s : url_to_visit.to_s.gsub(/\?.*$/, '')
url_tracker.visit to_track
@logger.debug { "Added (#{url_to_visit}) to the queue" }
end
|
ruby
|
{
"resource": ""
}
|
q2898
|
Polipus.PolipusCrawler.execute_plugin
|
train
|
def execute_plugin(method)
Polipus::Plugin.plugins.each do |k, p|
next unless p.respond_to?(method)
@logger.info { "Running plugin method #{method} on #{k}" }
ret_val = p.send(method, self)
instance_eval(&ret_val) if ret_val.is_a? Proc
end
end
|
ruby
|
{
"resource": ""
}
|
q2899
|
RailsLocaleDetection.DetectionMethods.set_default_url_option_for_request?
|
train
|
def set_default_url_option_for_request?
RailsLocaleDetection.set_default_url_option === true || RailsLocaleDetection.set_default_url_option == :always || RailsLocaleDetection.set_default_url_option == :explicitly && params[locale_key].present?
end
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.