_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q18000 | Ooor.TypeCasting.cast_association | train | def cast_association(k)
if self.class.one2many_associations[k]
if @loaded_associations[k]
v = @loaded_associations[k].select {|i| i.changed?}
v = @associations[k] if v.empty?
else
v = @associations[k]
end
cast_o2m_association(v)
elsif self.class.... | ruby | {
"resource": ""
} |
q18001 | Ooor.Base.on_change | train | def on_change(on_change_method, field_name, field_value, *args)
# NOTE: OpenERP doesn't accept context systematically in on_change events unfortunately
ids = self.id ? [id] : []
| ruby | {
"resource": ""
} |
q18002 | Ooor.Base.wkf_action | train | def wkf_action(action, context={}, reload=true)
self.class.object_service(:exec_workflow, self.class.openerp_model, action, | ruby | {
"resource": ""
} |
q18003 | Ooor.Persistence.load | train | def load(attributes)
self.class.reload_fields_definition(false)
raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
| ruby | {
"resource": ""
} |
q18004 | Ooor.Persistence.copy | train | def copy(defaults={}, context={})
self.class.find(rpc_execute('copy', | ruby | {
"resource": ""
} |
q18005 | Ooor.Persistence.perform_validations | train | def perform_validations(options={}) # :nodoc:
if options.is_a?(Hash)
options[:validate] | ruby | {
"resource": ""
} |
q18006 | RSpec::ActiveModel::Mocks.Mocks.stub_model | train | def stub_model(model_class, stubs={})
model_class.new.tap do |m|
m.extend ActiveModelStubExtensions
if defined?(ActiveRecord) && model_class < ActiveRecord::Base && model_class.primary_key
m.extend ActiveRecordStubExtensions
primary_key = model_class.primary_key.to_sym
... | ruby | {
"resource": ""
} |
q18007 | Pygments.Popen.stop | train | def stop(reason)
if @pid
begin
Process.kill('KILL', @pid)
Process.waitpid(@pid)
| ruby | {
"resource": ""
} |
q18008 | Pygments.Popen.mentos | train | def mentos(method, args=[], kwargs={}, original_code=nil)
# Open the pipe if necessary
start unless alive?
begin
# Timeout requests that take too long.
# Invalid MENTOS_TIMEOUT results in just using default.
timeout_time = Integer(ENV["MENTOS_TIMEOUT"]) rescue 8
Timeo... | ruby | {
"resource": ""
} |
q18009 | Pygments.Popen.handle_header_and_return | train | def handle_header_and_return(header, id)
if header
header = header_to_json(header)
bytes = header[:bytes]
# Read more bytes (the actual response body)
res = @out.read(bytes.to_i)
if header[:method] == "highlight"
# Make sure we have a result back; else consider ... | ruby | {
"resource": ""
} |
q18010 | Pygments.Popen.get_header | train | def get_header
begin
size = @out.read(33)
size = size[0..-2]
# Sanity check the size
if not size_check(size)
@log.error "Size returned from mentos.py invalid."
stop "Size returned from mentos.py invalid."
raise MentosError, "Size returned from mentos.... | ruby | {
"resource": ""
} |
q18011 | Pygments.Popen.return_result | train | def return_result(res, method)
unless method == :lexer_name_for || method == :highlight || method == | ruby | {
"resource": ""
} |
q18012 | Pygments.Popen.header_to_json | train | def header_to_json(header)
@log.info "[In header: #{header} "
header = MultiJson.load(header, :symbolize_keys => true)
if header[:error]
# Raise this as a Ruby exception of the MentosError class.
# Stop so we don't leave the pipe in an inconsistent state.
@log.error "Failed to | ruby | {
"resource": ""
} |
q18013 | FlagShihTzu.ClassMethods.sql_in_for_flag | train | def sql_in_for_flag(flag, colmn)
val = flag_mapping[colmn][flag]
| ruby | {
"resource": ""
} |
q18014 | Dynflow.Action::Format.input_format | train | def input_format(&block)
case
when block && !@input_format_block
@input_format_block = block
when !block && @input_format_block
return @input_format ||= Apipie::Params::Description.define(&@input_format_block)
when block && @input_format_block
raise "The input_format has ... | ruby | {
"resource": ""
} |
q18015 | Dynflow.Serializable.recursive_to_hash | train | def recursive_to_hash(*values)
if values.size == 1
value = values.first
case value
when String, Numeric, Symbol, TrueClass, FalseClass, NilClass, Time
value
when Hash
value.inject({}) { |h, (k, v)| h.update k => recursive_to_hash(v) }
when Array
... | ruby | {
"resource": ""
} |
q18016 | Dynflow.Action::WithSubPlans.trigger | train | def trigger(action_class, *args)
if uses_concurrency_control
trigger_with_concurrency_control(action_class, *args)
else
world.trigger { | ruby | {
"resource": ""
} |
q18017 | Dynflow.Action::WithBulkSubPlans.current_batch | train | def current_batch
start_position = output[:planned_count]
size = start_position | ruby | {
"resource": ""
} |
q18018 | Dynflow.ExecutionPlan::DependencyGraph.add_dependencies | train | def add_dependencies(step, action)
action.required_step_ids.each do |required_step_id|
| ruby | {
"resource": ""
} |
q18019 | Dynflow.World.reload! | train | def reload!
# TODO what happens with newly loaded classes
@action_classes = @action_classes.map do |klass|
begin
| ruby | {
"resource": ""
} |
q18020 | Dynflow.Action::Rescue.rescue_strategy | train | def rescue_strategy
suggested_strategies = []
if self.steps.compact.any? { |step| step.state == :error }
suggested_strategies << SuggestedStrategy[self, rescue_strategy_for_self]
end
self.planned_actions.each do |planned_action| | ruby | {
"resource": ""
} |
q18021 | Dynflow.Action::Rescue.combine_suggested_strategies | train | def combine_suggested_strategies(suggested_strategies)
if suggested_strategies.empty?
nil
else
# TODO: Find the safest rescue strategy among the suggested ones
if suggested_strategies.all? { |suggested_strategy| suggested_strategy.strategy == Skip }
return Skip | ruby | {
"resource": ""
} |
q18022 | Csvlint.ErrorCollector.build_errors | train | def build_errors(type, category = nil, row = nil, column = nil, content = nil, constraints = {})
@errors | ruby | {
"resource": ""
} |
q18023 | Csvlint.Validator.parse_contents | train | def parse_contents(stream, line = nil)
# parse_contents will parse one line and apply headers, formats methods and error handle as appropriate
current_line = line.present? ? line : 1
all_errors = []
@csv_options[:encoding] = @encoding
begin
row = LineCSV.parse_line(stream, @csv_o... | ruby | {
"resource": ""
} |
q18024 | AmazonPay.Client.create_order_reference_for_id | train | def create_order_reference_for_id(
id,
id_type,
inherit_shipping_address: nil,
confirm_now: nil,
amount: nil,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
store_name: nil,
custom_information: nil,
supplem... | ruby | {
"resource": ""
} |
q18025 | AmazonPay.Client.get_billing_agreement_details | train | def get_billing_agreement_details(
amazon_billing_agreement_id,
address_consent_token: nil,
access_token: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetBillingAgreementDetails',
'SellerId' => merchant_id,
'AmazonBill... | ruby | {
"resource": ""
} |
q18026 | AmazonPay.Client.set_billing_agreement_details | train | def set_billing_agreement_details(
amazon_billing_agreement_id,
platform_id: nil,
seller_note: nil,
seller_billing_agreement_id: nil,
custom_information: nil,
store_name: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => '... | ruby | {
"resource": ""
} |
q18027 | AmazonPay.Client.confirm_billing_agreement | train | def confirm_billing_agreement(
amazon_billing_agreement_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ConfirmBillingAgreement',
'SellerId' => merchant_id,
| ruby | {
"resource": ""
} |
q18028 | AmazonPay.Client.validate_billing_agreement | train | def validate_billing_agreement(
amazon_billing_agreement_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ValidateBillingAgreement',
'SellerId' => merchant_id,
| ruby | {
"resource": ""
} |
q18029 | AmazonPay.Client.close_billing_agreement | train | def close_billing_agreement(
amazon_billing_agreement_id,
closure_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CloseBillingAgreement',
'SellerId' => merchant_id,
'AmazonBillingAgreementId' => amazon_billing_agreement... | ruby | {
"resource": ""
} |
q18030 | AmazonPay.Client.list_order_reference | train | def list_order_reference(
query_id,
query_id_type,
created_time_range_start: nil,
created_time_range_end: nil,
sort_order: nil,
page_size: nil,
order_reference_status_list_filter: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
payment_domain = paym... | ruby | {
"resource": ""
} |
q18031 | AmazonPay.Client.get_merchant_account_status | train | def get_merchant_account_status(
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetMerchantAccountStatus',
'SellerId' => merchant_id
| ruby | {
"resource": ""
} |
q18032 | AmazonPay.Client.get_order_reference_details | train | def get_order_reference_details(
amazon_order_reference_id,
address_consent_token: nil,
access_token: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetOrderReferenceDetails',
'SellerId' => merchant_id,
'AmazonOrderRefer... | ruby | {
"resource": ""
} |
q18033 | AmazonPay.Client.set_order_reference_details | train | def set_order_reference_details(
amazon_order_reference_id,
amount,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
request_payment_authorization: nil,
store_name: nil,
order_item_categories: nil,
custom_information: ni... | ruby | {
"resource": ""
} |
q18034 | AmazonPay.Client.set_order_attributes | train | def set_order_attributes(
amazon_order_reference_id,
amount: nil,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
payment_service_provider_id: nil,
payment_service_provider_order_id: nil,
request_payment_authorization: nil,
... | ruby | {
"resource": ""
} |
q18035 | AmazonPay.Client.confirm_order_reference | train | def confirm_order_reference(
amazon_order_reference_id,
success_url: nil,
failure_url: nil,
authorization_amount: nil,
currency_code: @currency_code,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ConfirmOrderReference',
... | ruby | {
"resource": ""
} |
q18036 | AmazonPay.Client.cancel_order_reference | train | def cancel_order_reference(
amazon_order_reference_id,
cancelation_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CancelOrderReference',
'SellerId' => merchant_id,
'AmazonOrderReferenceId' => amazon_order_reference_id
... | ruby | {
"resource": ""
} |
q18037 | AmazonPay.Client.get_authorization_details | train | def get_authorization_details(
amazon_authorization_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetAuthorizationDetails',
'SellerId' => merchant_id,
| ruby | {
"resource": ""
} |
q18038 | AmazonPay.Client.capture | train | def capture(
amazon_authorization_id,
capture_reference_id,
amount,
currency_code: @currency_code,
seller_capture_note: nil,
soft_descriptor: nil,
provider_credit_details: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Actio... | ruby | {
"resource": ""
} |
q18039 | AmazonPay.Client.get_capture_details | train | def get_capture_details(
amazon_capture_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetCaptureDetails', | ruby | {
"resource": ""
} |
q18040 | AmazonPay.Client.refund | train | def refund(
amazon_capture_id,
refund_reference_id,
amount,
currency_code: @currency_code,
seller_refund_note: nil,
soft_descriptor: nil,
provider_credit_reversal_details: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Actio... | ruby | {
"resource": ""
} |
q18041 | AmazonPay.Client.get_refund_details | train | def get_refund_details(
amazon_refund_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetRefundDetails', | ruby | {
"resource": ""
} |
q18042 | AmazonPay.Client.close_authorization | train | def close_authorization(
amazon_authorization_id,
closure_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CloseAuthorization',
'SellerId' => merchant_id,
'AmazonAuthorizationId' => amazon_authorization_id
}
| ruby | {
"resource": ""
} |
q18043 | AmazonPay.Client.set_provider_credit_details | train | def set_provider_credit_details(provider_credit_details)
member_details = {}
provider_credit_details.each_with_index do |val, index|
member = index + 1
member_details["ProviderCreditList.member.#{member}.ProviderId"] = val[:provider_id]
| ruby | {
"resource": ""
} |
q18044 | AmazonPay.Client.set_provider_credit_reversal_details | train | def set_provider_credit_reversal_details(provider_credit_reversal_details)
member_details = {}
provider_credit_reversal_details.each_with_index do |val, index|
member = index + 1
member_details["ProviderCreditReversalList.member.#{member}.ProviderId"] = val[:provider_id]
| ruby | {
"resource": ""
} |
q18045 | AmazonPay.Request.build_post_url | train | def build_post_url
@optional.map { |k, v| @parameters[k] = v unless v.nil? }
@parameters['Timestamp'] = Time.now.utc.iso8601 unless @parameters.key?('Timestamp')
@parameters = @default_hash.merge(@parameters)
post_url = @parameters.sort.map { |k, v| "#{k}=#{custom_escape(v)}" }.join('&')
p... | ruby | {
"resource": ""
} |
q18046 | AmazonPay.Request.sign | train | def sign(post_body)
custom_escape(Base64.strict_encode64(OpenSSL::HMAC.digest(OpenSSL::D | ruby | {
"resource": ""
} |
q18047 | AmazonPay.Request.post | train | def post(mws_endpoint, sandbox_str, post_url)
uri = URI("https://#{mws_endpoint}/#{sandbox_str}/#{AmazonPay::API_VERSION}")
https = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
user... | ruby | {
"resource": ""
} |
q18048 | AmazonPay.Client.charge | train | def charge(
amazon_reference_id,
authorization_reference_id,
charge_amount,
charge_currency_code: @currency_code,
charge_note: nil,
charge_order_id: nil,
store_name: nil,
custom_information: nil,
soft_descriptor: nil,
platform_id: nil,
merchant_id: @merc... | ruby | {
"resource": ""
} |
q18049 | Flame.Router.add | train | def add(routes_refine)
routes.deep_merge! routes_refine.routes | ruby | {
"resource": ""
} |
q18050 | Flame.Router.find_nearest_route | train | def find_nearest_route(path)
path_parts = path.parts.dup
loop do
route | ruby | {
"resource": ""
} |
q18051 | Flame.Router.path_of | train | def path_of(route_or_controller, action = nil)
if route_or_controller.is_a?(Flame::Router::Route)
route = route_or_controller
controller = route.controller
action = route.action
else | ruby | {
"resource": ""
} |
q18052 | Flame.Render.render | train | def render(cache: true, &block)
@cache = cache
## Compile Tilt to instance hash
return unless @filename | ruby | {
"resource": ""
} |
q18053 | Flame.Render.compile_file | train | def compile_file(filename = @filename)
cached = @controller.cached_tilts[filename]
return cached if | ruby | {
"resource": ""
} |
q18054 | Flame.Render.find_file | train | def find_file(path)
caller_path = caller_locations(4..4).first.path
caller_dir =
begin
File.dirname(caller_path).sub(views_dir, '') if Tilt[caller_path]
rescue LoadError
nil
| ruby | {
"resource": ""
} |
q18055 | Flame.Render.find_layouts | train | def find_layouts(path)
find_files(path, layout_dirs)
.select { |file| Tilt[file] }
.sort! | ruby | {
"resource": ""
} |
q18056 | Flame.Render.controller_dirs | train | def controller_dirs
parts = @controller.class.underscore.split('/').map do |part|
%w[_controller _ctrl]
.find { |suffix| part.chomp! suffix }
part
## Alternative, but slower by ~50%: | ruby | {
"resource": ""
} |
q18057 | Flame.Render.combine_parts | train | def combine_parts(parts)
parts.size.downto(1).with_object([]) do | ruby | {
"resource": ""
} |
q18058 | Flame.Render.layout_render | train | def layout_render(content)
return content unless @layout
layout_files = find_layouts(@layout)
return content if layout_files.empty?
layout_files.each_with_object(content.dup) do |layout_file, result|
| ruby | {
"resource": ""
} |
q18059 | Flame.Path.adapt | train | def adapt(ctrl, action)
parameters = ctrl.instance_method(action).parameters
parameters.map! do |parameter|
parameter_type, parameter_name = parameter
path_part = self.class::Part.new parameter_name, arg: parameter_type
path_part unless | ruby | {
"resource": ""
} |
q18060 | Flame.Path.to_routes_with_endpoint | train | def to_routes_with_endpoint
endpoint =
parts.reduce(result = Flame::Router::Routes.new) do |hash, part|
hash[part] | ruby | {
"resource": ""
} |
q18061 | Flame.Path.assign_argument | train | def assign_argument(part, args = {})
## Not argument
return part unless part.arg?
## Not required argument
return args.delete(part[2..-1].to_sym) if part.opt_arg?
## Required argument
param = args.delete(part[1..-1].to_sym)
## | ruby | {
"resource": ""
} |
q18062 | Flame.Dispatcher.status | train | def status(value = nil)
response.status ||= 200
response.headers['X-Cascade'] = 'pass' if value == 404
| ruby | {
"resource": ""
} |
q18063 | Flame.Dispatcher.params | train | def params
@params ||=
begin
request.params.symbolize_keys(deep: true)
| ruby | {
"resource": ""
} |
q18064 | Flame.Dispatcher.dump_error | train | def dump_error(error)
error_message = [
"#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} - " | ruby | {
"resource": ""
} |
q18065 | Flame.Dispatcher.try_options | train | def try_options
return unless request.http_method == :OPTIONS
| ruby | {
"resource": ""
} |
q18066 | Flame.Controller.redirect | train | def redirect(*args)
args[0] = args.first.to_s if args.first.is_a? URI
unless args.first.is_a? String
path_to_args_range = 0..(args.last.is_a?(Integer) ? -2 : -1)
| ruby | {
"resource": ""
} |
q18067 | Flame.Controller.attachment | train | def attachment(filename = nil, disposition = :attachment)
content_dis = 'Content-Disposition'
response[content_dis] = disposition.to_s
return unless filename
| ruby | {
"resource": ""
} |
q18068 | Flame.Controller.reroute | train | def reroute(*args)
add_controller_class(args)
ctrl, action = args[0..1]
ctrl_object = ctrl == self.class ? self | ruby | {
"resource": ""
} |
q18069 | Flame.Application.call | train | def call(env)
@app.call(env) if @app.respond_to? :call
| ruby | {
"resource": ""
} |
q18070 | Redd.Client.request | train | def request(verb, path, options = {})
# puts "#{verb.to_s.upcase} #{path}", ' ' + options.inspect
| ruby | {
"resource": ""
} |
q18071 | Redd.Middleware.redirect_to_reddit! | train | def redirect_to_reddit!
state = SecureRandom.urlsafe_base64
url = Redd.url(
client_id: @client_id,
redirect_uri: @redirect_uri,
| ruby | {
"resource": ""
} |
q18072 | Redd.Middleware.after_call | train | def after_call
env_session = @request.env['redd.session']
if env_session && env_session.client.access
# Make sure to flush any changes made to the Session client to | ruby | {
"resource": ""
} |
q18073 | Redd.Middleware.handle_token_error | train | def handle_token_error
message = nil
message = 'invalid_state' if @request.GET['state'] != @request.session[:redd_state]
message = @request.GET['error'] | ruby | {
"resource": ""
} |
q18074 | Redd.Middleware.create_session! | train | def create_session!
# Skip authorizing if there was an error from the authorization.
handle_token_error
# Try to get a code (the rescue block will also prevent crazy crashes)
access = @strategy.authenticate(@request.GET['code'])
| ruby | {
"resource": ""
} |
q18075 | Redd.APIClient.request | train | def request(verb, path, raw: false, params: {}, **options)
# Make sure @access is populated by a valid access
ensure_access_is_valid
# Setup base API params and make request
api_params = { api_type: 'json', raw_json: 1 }.merge(params)
# This loop is retried @max_retries number of times un... | ruby | {
"resource": ""
} |
q18076 | AnsibleTowerClient.HashModel.hash_to_model | train | def hash_to_model(klass_name, hash)
model_klass =
if self.class.const_defined?("#{self.class}::#{klass_name}")
self.class.const_get(klass_name)
| ruby | {
"resource": ""
} |
q18077 | Roma.Mkconfig.save_data | train | def save_data(res)
if res.key?("storage")
case res["storage"].value
when "Ruby Hash"
req = "rh_storage"
storage = "RubyHashStorage"
when "Tokyo Cabinet"
req = "tc_storage"
storage = "TCStorage"
bnum = Calculate.get_bnum(res)
bnum ... | ruby | {
"resource": ""
} |
q18078 | AnsibleTowerClient.BaseModel.update_attributes! | train | def update_attributes!(attributes)
@api.patch(url, attributes.to_json)
attributes.each do |method_name, value|
invoke_name = "#{override_raw_attributes[method_name] || method_name}="
if respond_to?(invoke_name)
send(invoke_name, value)
else
| ruby | {
"resource": ""
} |
q18079 | AnsibleTowerClient.BaseModel.hash_to_model | train | def hash_to_model(klass_name, hash)
model_klass =
if self.class.const_defined?(klass_name, false)
self.class.const_get(klass_name)
else
| ruby | {
"resource": ""
} |
q18080 | MLBStatsAPI.Stats.stats | train | def stats(options = {})
raise ArgumentError, '#stats requires a stats arg' unless options[:stats]
raise ArgumentError, '#stats | ruby | {
"resource": ""
} |
q18081 | MLBStatsAPI.Standings.standings | train | def standings(options = {})
options[:hydrate] = 'team' unless options.key?(:hydrate)
if options[:leagues] && !options[:leagueId]
league_ids = Leagues::LEAGUES.values_at(*options.delete(:leagues))
options[:leagueId] = league_ids
| ruby | {
"resource": ""
} |
q18082 | MLBStatsAPI.Leagues.all_star_ballot | train | def all_star_ballot(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
| ruby | {
"resource": ""
} |
q18083 | MLBStatsAPI.Leagues.all_star_write_ins | train | def all_star_write_ins(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
| ruby | {
"resource": ""
} |
q18084 | MLBStatsAPI.Leagues.all_star_final_vote | train | def all_star_final_vote(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
| ruby | {
"resource": ""
} |
q18085 | MLBStatsAPI.People.person | train | def person(person_ids, options = {})
ids = Array(person_ids)
result = get('/people', | ruby | {
"resource": ""
} |
q18086 | Gemika.RSpec.run_specs | train | def run_specs(options = nil)
options ||= {}
files = options.fetch(:files, 'spec')
rspec_options = options.fetch(:options, '--color')
# We need to override the gemfile explicitely, since we have a default Gemfile in the project root
gemfile = options.fetch(:gemfile, Gemika::Env.gemfile)
... | ruby | {
"resource": ""
} |
q18087 | Gemika.RSpec.configure_should_syntax | train | def configure_should_syntax
if Env.gem?('rspec', '>= 2.11')
configure do |config|
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
config.mock_with(:rspec) { |c| c.syntax | ruby | {
"resource": ""
} |
q18088 | Gemika.Database.adapter_config | train | def adapter_config
default_config = {}
default_config['database'] = guess_database_name
if Env.gem?('pg')
default_config['adapter'] = 'postgresql'
default_config['username'] = 'postgres' if Env.travis?
default_config['password'] = ''
user_config = @yaml_config['postgres... | ruby | {
"resource": ""
} |
q18089 | Gemika.Matrix.each | train | def each(&block)
@all_passed = true
rows.each do |row|
gemfile = row.gemfile
if row.compatible_with_ruby?(current_ruby)
@compatible_count += 1
print_title gemfile
gemfile_passed = Env.with_gemfile(gemfile, row, &block)
| ruby | {
"resource": ""
} |
q18090 | Gemika.Env.with_gemfile | train | def with_gemfile(path, *args, &block)
# Make sure that if block calls #gemfile we still return the gemfile for this
# process, regardless of what's in ENV temporarily
| ruby | {
"resource": ""
} |
q18091 | Gemika.Env.gem? | train | def gem?(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
name, requirement_string = args
if options[:gemfile] && !process_gemfile?(options[:gemfile])
| ruby | {
"resource": ""
} |
q18092 | FetcheableOnApi.Filterable.predicates | train | def predicates(predicate, collection, klass, column_name, value)
case predicate
when :between
klass.arel_table[column_name].between(value.first..value.last)
when :does_not_match
klass.arel_table[column_name].does_not_match("%#{value}%")
when :does_not_match_all
klass.arel... | ruby | {
"resource": ""
} |
q18093 | Systemd.JournalEntry.catalog | train | def catalog(opts = {})
return nil unless catalog?
opts[:replace] = true unless opts.key?(:replace)
cat = Systemd::Journal.catalog_for(self[:message_id])
# catalog_for does | ruby | {
"resource": ""
} |
q18094 | Systemd.Journal.query_unique | train | def query_unique(field)
results = []
Native.sd_journal_restart_unique(@ptr)
rc = Native.sd_journal_query_unique(@ptr, field.to_s.upcase)
raise JournalError, rc if rc < 0
| ruby | {
"resource": ""
} |
q18095 | Systemd.Journal.data_threshold | train | def data_threshold
size_ptr = FFI::MemoryPointer.new(:size_t, 1)
if (rc = Native.sd_journal_get_data_threshold(@ptr, size_ptr)) < 0
| ruby | {
"resource": ""
} |
q18096 | CloudCrowd.Action.download | train | def download(url, path)
if url.match(FILE_URL)
FileUtils.cp(url.sub(FILE_URL, ''), path)
else
File.open(path, 'w+') do |file|
Net::HTTP.get_response(URI(url)) do |response|
| ruby | {
"resource": ""
} |
q18097 | CloudCrowd.Action.` | train | def `(command)
result = super(command)
exit_code = $?.to_i | ruby | {
"resource": ""
} |
q18098 | CloudCrowd.Action.safe_filename | train | def safe_filename(url)
url = url.sub(/\?.*\Z/, '')
ext = File.extname(url)
name = URI.unescape(File.basename(url)).gsub(/[^a-zA-Z0-9_\-.]/, | ruby | {
"resource": ""
} |
q18099 | CloudCrowd.Action.download_input | train | def download_input
return unless input_is_url?
Dir.chdir(@work_directory) do
@input_path = File.join(@work_directory, safe_filename(@input))
| 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.