_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q17500 | Gibberish.RSA.decrypt | train | def decrypt(data, opts={})
data = data.to_s
raise "No private key set!" unless @key.private?
unless opts[:binary]
data | ruby | {
"resource": ""
} |
q17501 | ActsAsApi.Base.acts_as_api | train | def acts_as_api
class_eval do
include ActsAsApi::Base::InstanceMethods
extend ActsAsApi::Base::ClassMethods
end
| ruby | {
"resource": ""
} |
q17502 | ActsAsApi.ApiTemplate.add | train | def add(val, options = {})
item_key = (options[:as] || val).to_sym
| ruby | {
"resource": ""
} |
q17503 | ActsAsApi.ApiTemplate.allowed_to_render? | train | def allowed_to_render?(fieldset, field, model, options)
return true unless fieldset.is_a? ActsAsApi::ApiTemplate
fieldset_options = fieldset.options_for(field)
if fieldset_options[:unless]
!(condition_fulfilled?(model, | ruby | {
"resource": ""
} |
q17504 | ActsAsApi.ApiTemplate.to_response_hash | train | def to_response_hash(model, fieldset = self, options = {})
api_output = {}
fieldset.each do |field, value|
next unless allowed_to_render?(fieldset, field, model, options)
| ruby | {
"resource": ""
} |
q17505 | ActsAsApi.Rendering.render_for_api | train | def render_for_api(api_template_or_options, render_options)
if api_template_or_options.is_a?(Hash)
api_template = []
api_template << api_template_or_options.delete(:prefix)
api_template << api_template_or_options.delete(:template)
api_template << api_template_or_options.delete(:pos... | ruby | {
"resource": ""
} |
q17506 | ActsAsApi.Collection.as_api_response | train | def as_api_response(api_template, options = {})
collect do |item|
if item.respond_to?(:as_api_response)
| ruby | {
"resource": ""
} |
q17507 | RablRails.Compiler.condition | train | def condition(proc)
return unless block_given?
| ruby | {
"resource": ""
} |
q17508 | Jammit.CommandLine.ensure_configuration_file | train | def ensure_configuration_file
config = @options[:config_paths]
return true if File.exists?(config) && File.readable?(config)
puts | ruby | {
"resource": ""
} |
q17509 | Jammit.Packager.precache_all | train | def precache_all(output_dir=nil, base_url=nil)
output_dir ||= File.join(Jammit.public_root, Jammit.package_path)
cacheable(:js, output_dir).each {|p| cache(p, 'js', pack_javascripts(p), output_dir) }
cacheable(:css, output_dir).each do |p|
cache(p, 'css', pack_stylesheets(p), output_dir)
... | ruby | {
"resource": ""
} |
q17510 | Jammit.Packager.cache | train | def cache(package, extension, contents, output_dir, suffix=nil, mtime=nil)
FileUtils.mkdir_p(output_dir) unless File.exists?(output_dir)
raise OutputNotWritable, "Jammit doesn't have permission to write to \"#{output_dir}\"" unless File.writable?(output_dir)
mtime ||= latest_mtime package_for(package,... | ruby | {
"resource": ""
} |
q17511 | Jammit.Packager.pack_stylesheets | train | def pack_stylesheets(package, variant=nil, asset_url=nil)
| ruby | {
"resource": ""
} |
q17512 | Jammit.Packager.package_for | train | def package_for(package, extension)
pack = @packages[extension] | ruby | {
"resource": ""
} |
q17513 | Jammit.Controller.package | train | def package
parse_request
template_ext = Jammit.template_extension.to_sym
case @extension
when :js
render :js => (@contents = Jammit.packager.pack_javascripts(@package))
when template_ext
| ruby | {
"resource": ""
} |
q17514 | Jammit.Helper.include_stylesheets | train | def include_stylesheets(*packages)
options = packages.extract_options!
return html_safe(individual_stylesheets(packages, options)) unless should_package?
disabled = | ruby | {
"resource": ""
} |
q17515 | Jammit.Helper.include_javascripts | train | def include_javascripts(*packages)
options = packages.extract_options!
options.merge!(:extname=>false)
html_safe packages.map {|pack|
| ruby | {
"resource": ""
} |
q17516 | Jammit.Helper.individual_stylesheets | train | def individual_stylesheets(packages, options)
tags_with_options(packages, options) {|p| | ruby | {
"resource": ""
} |
q17517 | Jammit.Helper.packaged_stylesheets | train | def packaged_stylesheets(packages, options)
tags_with_options(packages, | ruby | {
"resource": ""
} |
q17518 | Jammit.Helper.embedded_image_stylesheets | train | def embedded_image_stylesheets(packages, options)
datauri_tags = tags_with_options(packages, options) {|p| Jammit.asset_url(p, :css, :datauri) }
ie_tags = Jammit.mhtml_enabled ?
tags_with_options(packages, options) {|p| Jammit.asset_url(p, :css, :mhtml) } :
| ruby | {
"resource": ""
} |
q17519 | Jammit.Helper.tags_with_options | train | def tags_with_options(packages, options)
packages.dup.map {|package|
yield package
}.flatten.map {|package|
| ruby | {
"resource": ""
} |
q17520 | Jammit.Compressor.compile_jst | train | def compile_jst(paths)
namespace = Jammit.template_namespace
paths = paths.grep(Jammit.template_extension_matcher).sort
base_path = find_base_path(paths)
compiled = paths.map do |path|
contents = read_binary_file(path)
contents = contents.gsub(/\r?\n/, "\\n").gsub(... | ruby | {
"resource": ""
} |
q17521 | Jammit.Compressor.find_base_path | train | def find_base_path(paths)
return nil if paths.length <= 1
paths.sort!
first = paths.first.split('/')
last = | ruby | {
"resource": ""
} |
q17522 | Jammit.Compressor.concatenate_and_tag_assets | train | def concatenate_and_tag_assets(paths, variant=nil)
stylesheets = [paths].flatten.map do |css_path|
contents = read_binary_file(css_path)
contents.gsub(EMBED_DETECTOR) do |url|
ipath, cpath = Pathname.new($1), Pathname.new(File.expand_path(css_path))
| ruby | {
"resource": ""
} |
q17523 | Jammit.Compressor.absolute_path | train | def absolute_path(asset_pathname, css_pathname)
(asset_pathname.absolute? ?
Pathname.new(File.join(Jammit.public_root, | ruby | {
"resource": ""
} |
q17524 | Jammit.Compressor.rails_asset_id | train | def rails_asset_id(path)
asset_id = ENV["RAILS_ASSET_ID"]
return asset_id if asset_id
| ruby | {
"resource": ""
} |
q17525 | Jammit.Compressor.embeddable? | train | def embeddable?(asset_path, variant)
font = EMBED_FONTS.include?(asset_path.extname)
return false unless variant
return false unless asset_path.to_s.match(EMBEDDABLE) && asset_path.exist?
return false unless EMBED_EXTS.include?(asset_path.extname)
| ruby | {
"resource": ""
} |
q17526 | Jammit.Compressor.encoded_contents | train | def encoded_contents(asset_path)
return @asset_contents[asset_path] if @asset_contents[asset_path]
| ruby | {
"resource": ""
} |
q17527 | Rubotnik.Helpers.say | train | def say(text, quick_replies: [], user: @user)
message_options = {
recipient: { id: user.id },
message: { text: text }
}
if quick_replies && !quick_replies.empty?
message_options[:message][:quick_replies] = UI::QuickReplies
| ruby | {
"resource": ""
} |
q17528 | MachO.FatFile.change_dylib_id | train | def change_dylib_id(new_id, options = {})
raise ArgumentError, "argument must be a String" unless new_id.is_a?(String)
return unless machos.all?(&:dylib?)
each_macho(options) do | ruby | {
"resource": ""
} |
q17529 | MachO.FatFile.change_install_name | train | def change_install_name(old_name, new_name, options = {})
each_macho(options) do |macho|
| ruby | {
"resource": ""
} |
q17530 | MachO.FatFile.change_rpath | train | def change_rpath(old_path, new_path, options = {})
each_macho(options) do |macho|
| ruby | {
"resource": ""
} |
q17531 | MachO.FatFile.add_rpath | train | def add_rpath(path, options = {})
each_macho(options) do |macho|
| ruby | {
"resource": ""
} |
q17532 | MachO.FatFile.delete_rpath | train | def delete_rpath(path, options = {})
each_macho(options) do |macho|
| ruby | {
"resource": ""
} |
q17533 | MachO.FatFile.populate_fat_header | train | def populate_fat_header
# the smallest fat Mach-O header is 8 bytes
raise TruncatedFileError if @raw_data.size < 8
fh = Headers::FatHeader.new_from_bin(:big, @raw_data[0, Headers::FatHeader.bytesize])
raise MagicError, fh.magic unless Utils.magic?(fh.magic)
raise MachOBinaryError unless ... | ruby | {
"resource": ""
} |
q17534 | MachO.FatFile.populate_fat_archs | train | def populate_fat_archs
archs = []
fa_klass = Utils.fat_magic32?(header.magic) ? Headers::FatArch : Headers::FatArch64
fa_off = Headers::FatHeader.bytesize
fa_len = fa_klass.bytesize
| ruby | {
"resource": ""
} |
q17535 | MachO.FatFile.populate_machos | train | def populate_machos
machos = []
fat_archs.each do |arch|
machos << | ruby | {
"resource": ""
} |
q17536 | MachO.FatFile.repopulate_raw_machos | train | def repopulate_raw_machos
machos.each_with_index do |macho, i|
arch = fat_archs[i]
| ruby | {
"resource": ""
} |
q17537 | MachO.FatFile.each_macho | train | def each_macho(options = {})
strict = options.fetch(:strict, true)
errors = []
machos.each_with_index do |macho, index|
begin
yield macho
rescue RecoverableModificationError => e
e.macho_slice = index
# Strict mode: Immediately re-raise. Otherwise: Retai... | ruby | {
"resource": ""
} |
q17538 | MachO.MachOFile.insert_command | train | def insert_command(offset, lc, options = {})
context = LoadCommands::LoadCommand::SerializationContext.context_for(self)
cmd_raw = lc.serialize(context)
fileoff = offset + cmd_raw.bytesize
raise OffsetInsertionError, offset if offset < header.class.bytesize || fileoff > low_fileoff
new_s... | ruby | {
"resource": ""
} |
q17539 | MachO.MachOFile.replace_command | train | def replace_command(old_lc, new_lc)
context = LoadCommands::LoadCommand::SerializationContext.context_for(self)
cmd_raw = new_lc.serialize(context)
new_sizeofcmds = sizeofcmds + cmd_raw.bytesize - old_lc.cmdsize
raise HeaderPadError, @filename | ruby | {
"resource": ""
} |
q17540 | MachO.MachOFile.delete_command | train | def delete_command(lc, options = {})
@raw_data.slice!(lc.view.offset, lc.cmdsize)
# update Mach-O header fields to account for deleted load command
update_ncmds(ncmds - 1)
| ruby | {
"resource": ""
} |
q17541 | MachO.MachOFile.segment_alignment | train | def segment_alignment
# special cases: 12 for x86/64/PPC/PP64, 14 for ARM/ARM64
return 12 if %i[i386 x86_64 ppc ppc64].include?(cputype)
return 14 if %i[arm arm64].include?(cputype)
cur_align = Sections::MAX_SECT_ALIGN
segments.each do |segment|
if filetype == :object
#... | ruby | {
"resource": ""
} |
q17542 | MachO.MachOFile.change_dylib_id | train | def change_dylib_id(new_id, _options = {})
raise ArgumentError, "new ID must be a String" unless new_id.is_a?(String)
return unless dylib?
old_lc = command(:LC_ID_DYLIB).first
raise DylibIdMissingError unless old_lc
new_lc = LoadCommands::LoadCommand.create(:LC_ID_DYLIB, new_id,
... | ruby | {
"resource": ""
} |
q17543 | MachO.MachOFile.change_install_name | train | def change_install_name(old_name, new_name, _options = {})
old_lc = dylib_load_commands.find { |d| d.name.to_s == old_name }
raise DylibUnknownError, old_name if old_lc.nil?
new_lc = LoadCommands::LoadCommand.create(old_lc.type, new_name,
old_lc.timesta... | ruby | {
"resource": ""
} |
q17544 | MachO.MachOFile.change_rpath | train | def change_rpath(old_path, new_path, _options = {})
old_lc = command(:LC_RPATH).find { |r| r.path.to_s == old_path }
raise RpathUnknownError, old_path if old_lc.nil?
raise RpathExistsError, new_path if rpaths.include?(new_path)
| ruby | {
"resource": ""
} |
q17545 | MachO.MachOFile.add_rpath | train | def add_rpath(path, _options = {})
raise RpathExistsError, path if rpaths.include?(path)
rpath_cmd = | ruby | {
"resource": ""
} |
q17546 | MachO.MachOFile.delete_rpath | train | def delete_rpath(path, _options = {})
rpath_cmds = command(:LC_RPATH).select { |r| r.path.to_s == path }
raise RpathUnknownError, path if rpath_cmds.empty?
# delete the commands in reverse order, offset descending. this
| ruby | {
"resource": ""
} |
q17547 | MachO.MachOFile.populate_mach_header | train | def populate_mach_header
# the smallest Mach-O header is 28 bytes
raise TruncatedFileError if @raw_data.size < 28
magic = populate_and_check_magic
mh_klass = Utils.magic32?(magic) ? Headers::MachHeader : Headers::MachHeader64
| ruby | {
"resource": ""
} |
q17548 | MachO.MachOFile.populate_and_check_magic | train | def populate_and_check_magic
magic = @raw_data[0..3].unpack("N").first
raise MagicError, magic unless Utils.magic?(magic)
raise FatBinaryError | ruby | {
"resource": ""
} |
q17549 | MachO.MachOFile.populate_load_commands | train | def populate_load_commands
permissive = options.fetch(:permissive, false)
offset = header.class.bytesize
load_commands = []
header.ncmds.times do
fmt = Utils.specialize_format("L=", endianness)
cmd = @raw_data.slice(offset, 4).unpack(fmt).first
cmd_sym = LoadCommands::LO... | ruby | {
"resource": ""
} |
q17550 | MachO.MachOFile.update_ncmds | train | def update_ncmds(ncmds)
fmt = Utils.specialize_format("L=", endianness)
ncmds_raw = | ruby | {
"resource": ""
} |
q17551 | MachO.MachOFile.update_sizeofcmds | train | def update_sizeofcmds(size)
fmt = Utils.specialize_format("L=", endianness)
size_raw = | ruby | {
"resource": ""
} |
q17552 | SandiMeter.Analyzer.number_of_arguments | train | def number_of_arguments(method_sexp)
arguments = method_sexp[2]
arguments = arguments[1] if arguments.first == :paren
| ruby | {
"resource": ""
} |
q17553 | Dnsimple.Client.execute | train | def execute(method, path, data = nil, options = {})
response = request(method, path, data, options)
case response.code
when 200..299
| ruby | {
"resource": ""
} |
q17554 | Dnsimple.Client.request | train | def request(method, path, data = nil, options = {})
request_options = request_options(options)
if data
request_options[:headers]["Content-Type"] = content_type(request_options[:headers])
| ruby | {
"resource": ""
} |
q17555 | Jpmobile.RequestWithMobile.remote_addr | train | def remote_addr
if respond_to?(:remote_ip)
__send__(:remote_ip) # for Rails
elsif respond_to?(:ip)
__send__(:ip) # for Rack
else
if env['HTTP_X_FORWARDED_FOR']
| ruby | {
"resource": ""
} |
q17556 | Jpmobile::Mobile.AbstractMobile.variants | train | def variants
return @_variants if @_variants
@_variants = self.class.ancestors.select {|c| c.to_s =~ /^Jpmobile/ && c.to_s !~ /Emoticon/ }.map do |klass|
klass = klass.to_s.
gsub(/Jpmobile::/, '').
gsub(/AbstractMobile::/, '').
gsub(/Mobile::Sma... | ruby | {
"resource": ""
} |
q17557 | Rapidfire.Question.validate_answer | train | def validate_answer(answer)
if rules[:presence] == "1"
answer.validates_presence_of :answer_text
end
if rules[:minimum].present? || rules[:maximum].present?
min_max = { minimum: rules[:minimum].to_i }
| ruby | {
"resource": ""
} |
q17558 | Category.Cache.replace_sections | train | def replace_sections(diary)
return if diary.nil? or !diary.categorizable?
categorized = categorize_diary(diary)
categories = restore_categories
deleted = []
ymd = diary.date.strftime('%Y%m%d')
@plugin.__send__(:transaction, 'category') do |db|
categories.each do |c|
cat = get(db, c) || {}
if di... | ruby | {
"resource": ""
} |
q17559 | Category.Cache.categorize | train | def categorize(category, years)
categories = category - ['ALL']
if categories.empty?
categories = restore_categories
else
categories &= restore_categories
end
categorized = {}
begin
categorized.clear
categories.each do |c|
@plugin.__send__(:transaction, 'category') do |db|
categorized[... | ruby | {
"resource": ""
} |
q17560 | Category.Cache.categorize_diary | train | def categorize_diary(diary)
categorized = {}
ymd = diary.date.strftime('%Y%m%d')
idx = 1
diary.each_section do |s|
shorten = begin
body = %Q|apply_plugin(#{s.body_to_html.dump}, true)|
@conf.shorten(eval(body, @binding))
| ruby | {
"resource": ""
} |
q17561 | TDiary.Dispatcher.dispatch_cgi | train | def dispatch_cgi(request, cgi)
result = @target.run( request, cgi )
| ruby | {
"resource": ""
} |
q17562 | TDiary.Dispatcher.fake_stdin_as_params | train | def fake_stdin_as_params
stdin_spy = StringIO.new
if $RACK_ENV && $RACK_ENV['rack.input']
| ruby | {
"resource": ""
} |
q17563 | TDiary.Configuration.load_cgi_conf | train | def load_cgi_conf
def_vars1 = ''
def_vars2 = ''
[
:tdiary_version,
:html_title, :author_name, :author_mail, :index_page, :hour_offset,
:description, :icon, :banner, :x_frame_options,
:header, :footer,
:section_anchor, :comment_anchor, :date_format, :latest_limit, :show_nyear,
:theme, :c... | ruby | {
"resource": ""
} |
q17564 | TDiary.Configuration.configure_attrs | train | def configure_attrs
@options = {}
eval( File::open( 'tdiary.conf' ) {|f| f.read }, nil, "(tdiary.conf)", 1 )
# language setup
@lang = 'ja' unless @lang
begin
instance_eval( File::open( "#{TDiary::PATH}/tdiary/lang/#{@lang}.rb" ){|f| f.read }, "(tdiary/lang/#{@lang}.rb)", 1 )
rescue Errno::ENOENT... | ruby | {
"resource": ""
} |
q17565 | Footnotes.Filter.close! | train | def close!(controller)
self.each_with_rescue(@@klasses) {|klass| klass.close!(controller)}
| ruby | {
"resource": ""
} |
q17566 | Footnotes.Filter.close | train | def close
javascript = ''
each_with_rescue(@notes) do |note|
next unless note.has_fieldset?
| ruby | {
"resource": ""
} |
q17567 | Footnotes.Filter.link_helper | train | def link_helper(note)
onclick = note.onclick
unless href = note.link
href = '#'
onclick ||= | ruby | {
"resource": ""
} |
q17568 | PredictionIO.Connection.request | train | def request(method, request)
response = AsyncResponse.new(request)
@packages.push(method: method, request: | ruby | {
"resource": ""
} |
q17569 | PredictionIO.EventClient.get_status | train | def get_status
status = @http.aget(PredictionIO::AsyncRequest.new('/')).get
| ruby | {
"resource": ""
} |
q17570 | EXIFR.JPEG.to_hash | train | def to_hash
h = {:width => width, :height => height, :bits => bits, :comment => comment}
| ruby | {
"resource": ""
} |
q17571 | EXIFR.JPEG.method_missing | train | def method_missing(method, *args)
super unless args.empty?
super unless methods.include?(method)
| ruby | {
"resource": ""
} |
q17572 | EXIFR.TIFF.method_missing | train | def method_missing(method, *args)
super unless args.empty?
if @ifds.first.respond_to?(method)
@ifds.first.send(method)
elsif TAGS.include?(method)
| ruby | {
"resource": ""
} |
q17573 | EXIFR.TIFF.gps | train | def gps
return nil unless gps_latitude && gps_longitude
altitude = gps_altitude.is_a?(Array) ? gps_altitude.first : gps_altitude
GPS.new(gps_latitude.to_f * (gps_latitude_ref == 'S' ? -1 : 1),
gps_longitude.to_f * (gps_longitude_ref == 'W' ? -1 : 1),
| ruby | {
"resource": ""
} |
q17574 | Authority.Controller.authorize_action_for | train | def authorize_action_for(authority_resource, *options)
# `action_name` comes from ActionController
authority_action = self.class.authority_action_map[action_name.to_sym]
if authority_action.nil?
raise MissingAction.new("No authority action | ruby | {
"resource": ""
} |
q17575 | Authority.Controller.authority_forbidden | train | def authority_forbidden(error)
Authority.logger.warn(error.message)
render :file => | ruby | {
"resource": ""
} |
q17576 | Authority.Controller.run_authorization_check | train | def run_authorization_check
if instance_authority_resource.is_a?(Array)
# Array includes options; pass as separate args
authorize_action_for(*instance_authority_resource, *authority_arguments)
else
# *resource would be interpreted as resource.to_a, which is wrong and
# | ruby | {
"resource": ""
} |
q17577 | Service.RegistryApi.search | train | def search(query)
get('/v1/search'.freeze, { q: query })
rescue => e
logger.warn | ruby | {
"resource": ""
} |
q17578 | Surveyor.ActsAsResponse.as | train | def as(type_symbol)
return case type_symbol.to_sym
when :string, :text, :integer, :float, :datetime
self.send("#{type_symbol}_value".to_sym)
when :date
self.datetime_value.nil? ? nil : self.datetime_value.to_date
when :time
| ruby | {
"resource": ""
} |
q17579 | Surveyor.Parser.method_missing | train | def method_missing(missing_method, *args, &block)
method_name, reference_identifier = missing_method.to_s.split("_", 2)
type = full(method_name)
Surveyor::Parser.raise_error( "\"#{type}\" is not a surveyor method." )if !%w(survey survey_translation survey_section question_group question dependency dep... | ruby | {
"resource": ""
} |
q17580 | Larch.Config.validate | train | def validate
['from', 'to'].each do |s|
raise Error, "'#{s}' must be a valid IMAP URI (e.g. imap://example.com)" unless fetch(s) =~ IMAP::REGEX_URI
end
unless Logger::LEVELS.has_key?(verbosity.to_sym)
raise Error, "'verbosity' must be one of: #{Logger::LEVELS.keys.join(', ')}"
end
if e... | ruby | {
"resource": ""
} |
q17581 | Larch.Config.cache_config | train | def cache_config
@cached = {}
@lookup.reverse.each do |c|
c.each {|k, | ruby | {
"resource": ""
} |
q17582 | Larch.IMAP.safely | train | def safely
safe_connect
retries = 0
begin
yield
rescue Errno::ECONNABORTED,
Errno::ECONNRESET,
Errno::ENOTCONN,
Errno::EPIPE,
Errno::ETIMEDOUT,
IOError,
Net::IMAP::ByeResponseError,
OpenSSL::SSL::SSLError => e
r... | ruby | {
"resource": ""
} |
q17583 | Larch.IMAP.uri_mailbox | train | def uri_mailbox
mb = @uri.path[1..-1] | ruby | {
"resource": ""
} |
q17584 | Larch.IMAP.check_quirks | train | def check_quirks
return unless @conn &&
@conn.greeting.kind_of?(Net::IMAP::UntaggedResponse) &&
@conn.greeting.data.kind_of?(Net::IMAP::ResponseText)
if @conn.greeting.data.text =~ /^Gimap ready/
@quirks[:gmail] = true
debug "looks like Gmail"
elsif host =~ /^imap(?:-ssl)?\.mai... | ruby | {
"resource": ""
} |
q17585 | Apicasso.CrudController.set_object | train | def set_object
id = params[:id]
@object = resource.friendly.find(id)
| ruby | {
"resource": ""
} |
q17586 | Apicasso.CrudController.set_records | train | def set_records
authorize! :read, resource.name.underscore.to_sym
@records = request_collection.ransack(parsed_query).result
@object = request_collection.new
key_scope_records
reorder_records if | ruby | {
"resource": ""
} |
q17587 | Apicasso.CrudController.index_json | train | def index_json
if params[:group].present?
@records.group(params[:group][:by].split(','))
.send(:calculate,
params[:group][:calculate],
| ruby | {
"resource": ""
} |
q17588 | Apicasso.ApplicationController.request_metadata | train | def request_metadata
{
uuid: request.uuid,
url: request.original_url,
headers: | ruby | {
"resource": ""
} |
q17589 | Apicasso.Ability.build_permissions | train | def build_permissions(opts = {})
permission = opts[:permission].to_sym
clearances = opts[:clearance]
# To have full read access to the whole APIcasso just set a
# true key scope operation.
# Usage:
# To have full read access to the system the scope would be:
# => `{read: true}`... | ruby | {
"resource": ""
} |
q17590 | ROM::Factory.Factories.define | train | def define(spec, **opts, &block)
name, parent = spec.is_a?(Hash) ? spec.flatten(1) : spec
if registry.key?(name)
raise ArgumentError, "#{name.inspect} factory has been already defined"
end
builder =
if parent
extend_builder(name, registry[parent], &block)
else... | ruby | {
"resource": ""
} |
q17591 | ROM::Factory.Factories.struct_namespace | train | def struct_namespace(namespace = Undefined)
if namespace.equal?(Undefined)
options[:struct_namespace]
else
| ruby | {
"resource": ""
} |
q17592 | Timerizer.WallClock.hour | train | def hour(system = :twenty_four_hour)
hour = self.to_duration.to_units(:hour, :minute, :second).fetch(:hour)
if system == :twelve_hour
if hour == 0
| ruby | {
"resource": ""
} |
q17593 | Timerizer.Duration.after | train | def after(time)
time = time.to_time
prev_day = time.mday
prev_month = time.month
prev_year = time.year
units = self.to_units(:years, :months, :days, :seconds)
date_in_month = self.class.build_date(
prev_year + units[:years],
prev_month + units[:months],
pre... | ruby | {
"resource": ""
} |
q17594 | Timerizer.Duration.to_unit | train | def to_unit(unit)
unit_details = self.class.resolve_unit(unit)
if unit_details.has_key?(:seconds)
seconds = self.normalize.get(:seconds)
self.class.div(seconds, unit_details.fetch(:seconds))
elsif unit_details.has_key?(:months)
months | ruby | {
"resource": ""
} |
q17595 | Timerizer.Duration.- | train | def -(other)
case other
when 0
self
when Duration
Duration.new(
seconds: @seconds - other.get(:seconds),
months: @months - other.get(:months)
)
else
| ruby | {
"resource": ""
} |
q17596 | Timerizer.Duration.* | train | def *(other)
case other
when Integer
Duration.new(
seconds: @seconds * other,
months: @months * other
)
else
| ruby | {
"resource": ""
} |
q17597 | Timerizer.Duration.to_s | train | def to_s(format = :long, options = nil)
format =
case format
when Symbol
FORMATS.fetch(format)
when Hash
FORMATS.fetch(:long).merge(format)
else
raise ArgumentError, "Expected #{format.inspect} to be a Symbol or Hash"
end
format = format... | ruby | {
"resource": ""
} |
q17598 | Timerizer.Duration.to_rounded_s | train | def to_rounded_s(format = :min_long, options = nil)
format =
case format
when Symbol
FORMATS.fetch(format)
when Hash
FORMATS.fetch(:long).merge(format)
else
raise ArgumentError, "Expected #{format.inspect} to be a Symbol or Hash"
end
format = format.mer... | ruby | {
"resource": ""
} |
q17599 | Elastomer::Client::RestApiSpec.ApiSpec.select_params | train | def select_params(api:, from:)
rest_api = get(api)
| 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.