_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 30
4.3k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q1800
|
Rinda.TupleBag.delete
|
train
|
def delete(tuple)
key = bin_key(tuple)
bin = @hash[key]
return nil unless bin
bin.delete(tuple)
|
ruby
|
{
"resource": ""
}
|
q1801
|
Rinda.TupleBag.find_all
|
train
|
def find_all(template)
bin_for_find(template).find_all do |tuple|
|
ruby
|
{
"resource": ""
}
|
q1802
|
Rinda.TupleBag.find
|
train
|
def find(template)
bin_for_find(template).find do |tuple|
|
ruby
|
{
"resource": ""
}
|
q1803
|
Rinda.TupleBag.delete_unless_alive
|
train
|
def delete_unless_alive
deleted = []
@hash.each do |key, bin|
bin.delete_if do |tuple|
if tuple.alive?
false
else
|
ruby
|
{
"resource": ""
}
|
q1804
|
Rinda.TupleSpace.write
|
train
|
def write(tuple, sec=nil)
entry = create_entry(tuple, sec)
synchronize do
if entry.expired?
@read_waiter.find_all_template(entry).each do |template|
template.read(tuple)
end
notify_event('write', entry.value)
notify_event('delete', entry.value)
else
@bag.push(entry)
start_keeper if entry.expires
|
ruby
|
{
"resource": ""
}
|
q1805
|
Rinda.TupleSpace.move
|
train
|
def move(port, tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
synchronize do
entry = @bag.find(template)
if entry
port.push(entry.value) if port
@bag.delete(entry)
notify_event('take', entry.value)
return entry.value
end
raise RequestExpiredError if template.expired?
begin
@take_waiter.push(template)
start_keeper if template.expires
while true
raise RequestCanceledError if template.canceled?
|
ruby
|
{
"resource": ""
}
|
q1806
|
Rinda.TupleSpace.read
|
train
|
def read(tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
synchronize do
entry = @bag.find(template)
return entry.value if entry
raise RequestExpiredError if template.expired?
begin
@read_waiter.push(template)
start_keeper if template.expires
|
ruby
|
{
"resource": ""
}
|
q1807
|
Rinda.TupleSpace.read_all
|
train
|
def read_all(tuple)
template = WaitTemplateEntry.new(self, tuple, nil)
synchronize do
entry = @bag.find_all(template)
|
ruby
|
{
"resource": ""
}
|
q1808
|
Rinda.TupleSpace.notify
|
train
|
def notify(event, tuple, sec=nil)
template = NotifyTemplateEntry.new(self, event, tuple, sec)
synchronize do
|
ruby
|
{
"resource": ""
}
|
q1809
|
Rinda.TupleSpace.keep_clean
|
train
|
def keep_clean
synchronize do
@read_waiter.delete_unless_alive.each do |e|
e.signal
end
@take_waiter.delete_unless_alive.each do |e|
e.signal
end
@notify_waiter.delete_unless_alive.each do |e|
|
ruby
|
{
"resource": ""
}
|
q1810
|
Rinda.TupleSpace.notify_event
|
train
|
def notify_event(event, tuple)
ev = [event, tuple]
@notify_waiter.find_all_template(ev).each
|
ruby
|
{
"resource": ""
}
|
q1811
|
ArubaDoubles.History.to_pretty
|
train
|
def to_pretty
to_a.each_with_index.map
|
ruby
|
{
"resource": ""
}
|
q1812
|
FogTracker.CollectionTracker.update
|
train
|
def update
new_collection = Array.new
fog_collection = @account_tracker.connection.send(@type) || Array.new
@log.info "Fetching #{fog_collection.count} #{@type} on #{@account_name}."
# Here's where most of the network overhead is actually incurred
fog_collection.each do |resource|
@log.debug "Fetching resource: #{resource.class} #{resource.identity}"
resource._fog_collection_tracker = self
|
ruby
|
{
"resource": ""
}
|
q1813
|
FogTracker.AccountTracker.start
|
train
|
def start
if not running?
@log.debug "Starting tracking for account #{@name}..."
@timer = Thread.new do
begin
while true
update ; sleep @delay
end
|
ruby
|
{
"resource": ""
}
|
q1814
|
FogTracker.AccountTracker.update
|
train
|
def update
begin
@log.info "Polling account #{@name}..."
@collection_trackers.each {|tracker| tracker.update}
@preceeding_update_time = @most_recent_update
@most_recent_update = Time.now
@log.info "Polled account #{@name}"
@callback.call(all_resources) if @callback
rescue Exception => e
|
ruby
|
{
"resource": ""
}
|
q1815
|
Fulmar.Shell.execute_quiet
|
train
|
def execute_quiet(command, error_message)
# Ladies and gentleman: More debug, please!
puts command if @debug
return_value = -1
Open3.popen3(environment, command) do |_stdin, stdout, stderr, wait_thread|
Thread.new do
stdout.each do |line|
@last_output << line.strip
puts line unless @quiet
end
end
Thread.new do
stderr.each do |line|
@last_error << line
puts
|
ruby
|
{
"resource": ""
}
|
q1816
|
Mangdown.Client.cbz
|
train
|
def cbz(dir)
Mangdown::CBZ.all(dir)
rescue StandardError => error
raise
|
ruby
|
{
"resource": ""
}
|
q1817
|
Trollop.Parser.each_arg
|
train
|
def each_arg(args)
remains = []
i = 0
until i >= args.length
return remains += args[i..-1] if @stop_words.member? args[i]
case args[i]
when /^--$/ # arg terminator
return remains += args[(i + 1)..-1]
when /^--(\S+?)=(.*)$/ # long argument with equals
num_params_taken = yield "--#{$1}", [$2]
if num_params_taken.nil?
remains << args[i]
if @stop_on_unknown
return remains += args[i + 1..-1]
end
end
i += 1
when /^--(\S+)$/ # long argument
params = collect_argument_parameters(args, i + 1)
num_params_taken = yield args[i], params
if num_params_taken.nil?
remains << args[i]
if @stop_on_unknown
return remains += args[i + 1..-1]
end
else
i += num_params_taken
end
i += 1
when /^-(\S+)$/ # one or more short arguments
short_remaining = ""
shortargs = $1.split(//)
shortargs.each_with_index do |a, j|
if j == (shortargs.length - 1)
params = collect_argument_parameters(args, i + 1)
num_params_taken = yield "-#{a}", params
unless num_params_taken
short_remaining << a
if @stop_on_unknown
remains << "-#{short_remaining}"
|
ruby
|
{
"resource": ""
}
|
q1818
|
DoesFacebook.ControllerExtensions.parse_signed_request
|
train
|
def parse_signed_request
Rails.logger.info " Facebook application \"#{fb_app.namespace}\" configuration in use for this request."
if request_parameter = request.params["signed_request"]
encoded_signature, encoded_data = request_parameter.split(".")
decoded_signature = base64_url_decode(encoded_signature)
|
ruby
|
{
"resource": ""
}
|
q1819
|
Dis.Layer.store
|
train
|
def store(type, hash, file)
raise Dis::Errors::ReadOnlyError if readonly?
|
ruby
|
{
"resource": ""
}
|
q1820
|
Dis.Layer.exists?
|
train
|
def exists?(type, hash)
if directory(type, hash) &&
directory(type,
|
ruby
|
{
"resource": ""
}
|
q1821
|
Dis.Layer.get
|
train
|
def get(type, hash)
dir = directory(type, hash)
|
ruby
|
{
"resource": ""
}
|
q1822
|
Dis.Layer.delete
|
train
|
def delete(type, hash)
raise Dis::Errors::ReadOnlyError
|
ruby
|
{
"resource": ""
}
|
q1823
|
DaemonRunner.Session.renew!
|
train
|
def renew!
return if renew?
@renew = Thread.new do
## Wakeup every TTL/2 seconds and renew the session
loop do
sleep ttl / 2
begin
logger.debug(" - Renewing Consul session #{id}")
Diplomat::Session.renew(id)
rescue Faraday::ResourceNotFound
|
ruby
|
{
"resource": ""
}
|
q1824
|
DaemonRunner.Session.verify_session
|
train
|
def verify_session(wait_time = 2)
logger.info(" - Wait until Consul session #{id} exists")
wait_time.times do
exists = session_exist?
raise CreateSessionError, 'Error creating session' unless exists
|
ruby
|
{
"resource": ""
}
|
q1825
|
DaemonRunner.Session.session_exist?
|
train
|
def session_exist?
sessions = Diplomat::Session.list
|
ruby
|
{
"resource": ""
}
|
q1826
|
RxFile.ArrayNode.long_out
|
train
|
def long_out io , level
indent = " " * level
@children.each_with_index do |child , i|
io.write "\n#{indent}" unless i == 0
|
ruby
|
{
"resource": ""
}
|
q1827
|
Buckaruby.Gateway.issuers
|
train
|
def issuers(payment_method)
if payment_method != PaymentMethod::IDEAL && payment_method != PaymentMethod::IDEAL_PROCESSING
raise
|
ruby
|
{
"resource": ""
}
|
q1828
|
Buckaruby.Gateway.setup_transaction
|
train
|
def setup_transaction(options = {})
@logger.debug("[setup_transaction] options=#{options.inspect}")
validate_setup_transaction_params!(options)
normalize_account_iban!(options) if
|
ruby
|
{
"resource": ""
}
|
q1829
|
Buckaruby.Gateway.refundable?
|
train
|
def refundable?(options = {})
@logger.debug("[refundable?] options=#{options.inspect}")
validate_required_params!(options, :transaction_id)
|
ruby
|
{
"resource": ""
}
|
q1830
|
Buckaruby.Gateway.refund_transaction
|
train
|
def refund_transaction(options = {})
@logger.debug("[refund_transaction] options=#{options.inspect}")
validate_refund_transaction_params!(options)
response = execute_request(:refund_info, options)
unless response.refundable?
raise NonRefundableTransactionException, options[:transaction_id]
end
# Pick maximum refundable amount if amount is not supplied.
options[:amount] = response.maximum_amount unless options[:amount]
|
ruby
|
{
"resource": ""
}
|
q1831
|
Buckaruby.Gateway.cancellable?
|
train
|
def cancellable?(options = {})
@logger.debug("[cancellable?] options=#{options.inspect}")
|
ruby
|
{
"resource": ""
}
|
q1832
|
Buckaruby.Gateway.cancel_transaction
|
train
|
def cancel_transaction(options = {})
@logger.debug("[cancel_transaction] options=#{options.inspect}")
validate_required_params!(options, :transaction_id)
response = execute_request(:status, options)
unless
|
ruby
|
{
"resource": ""
}
|
q1833
|
Buckaruby.Gateway.validate_required_params!
|
train
|
def validate_required_params!(params, *required)
required.flatten.each do |param|
if !params.key?(param) || params[param].to_s.empty?
|
ruby
|
{
"resource": ""
}
|
q1834
|
Buckaruby.Gateway.validate_setup_transaction_params!
|
train
|
def validate_setup_transaction_params!(options)
required_params = [:amount, :payment_method, :invoicenumber]
required_params << :return_url if options[:payment_method] != PaymentMethod::SEPA_DIRECT_DEBIT
case options[:payment_method]
when PaymentMethod::IDEAL, PaymentMethod::IDEAL_PROCESSING
required_params << :payment_issuer
when PaymentMethod::SEPA_DIRECT_DEBIT
required_params << [:account_iban, :account_name]
end
validate_required_params!(options, required_params)
validate_amount!(options)
|
ruby
|
{
"resource": ""
}
|
q1835
|
Buckaruby.Gateway.validate_payment_issuer!
|
train
|
def validate_payment_issuer!(options)
if options[:payment_method] == PaymentMethod::IDEAL || options[:payment_method] == PaymentMethod::IDEAL_PROCESSING
unless Ideal::ISSUERS.include?(options[:payment_issuer])
|
ruby
|
{
"resource": ""
}
|
q1836
|
Buckaruby.Gateway.validate_recurrent_transaction_params!
|
train
|
def validate_recurrent_transaction_params!(options)
required_params = [:amount, :payment_method, :invoicenumber, :transaction_id]
validate_required_params!(options, required_params)
validate_amount!(options)
valid_payment_methods = [
|
ruby
|
{
"resource": ""
}
|
q1837
|
Buckaruby.Gateway.execute_request
|
train
|
def execute_request(request_type, options)
request = build_request(request_type)
response = request.execute(options)
case request_type
when :setup_transaction
SetupTransactionResponse.new(response, config)
when :recurrent_transaction
RecurrentTransactionResponse.new(response, config)
when :refund_transaction
RefundTransactionResponse.new(response, config)
when :refund_info
|
ruby
|
{
"resource": ""
}
|
q1838
|
Buckaruby.Gateway.build_request
|
train
|
def build_request(request_type)
case request_type
when :setup_transaction
SetupTransactionRequest.new(config)
when :recurrent_transaction
RecurrentTransactionRequest.new(config)
|
ruby
|
{
"resource": ""
}
|
q1839
|
RxFile.Node.as_string
|
train
|
def as_string(level)
io = StringIO.new
|
ruby
|
{
"resource": ""
}
|
q1840
|
RxFile.ObjectNode.add
|
train
|
def add k , v
raise "Key should be symbol not #{k}" unless k.is_a? Symbol
if( v.is_simple?)
@simple[k]
|
ruby
|
{
"resource": ""
}
|
q1841
|
Blur.ScriptCache.save
|
train
|
def save
directory = File.dirname @path
unless File.directory? directory
Dir.mkdir directory
end
|
ruby
|
{
"resource": ""
}
|
q1842
|
Authmac.HmacChecker.params_sorted_by_key
|
train
|
def params_sorted_by_key(params)
case params
when Hash
params.map { |k, v| [k.to_s, params_sorted_by_key(v)] }
.sort_by { |k, v| k }
.to_h
|
ruby
|
{
"resource": ""
}
|
q1843
|
Juici::Controllers.Trigger.rebuild!
|
train
|
def rebuild!
unless project = ::Juici::Project.where(name: params[:project]).first
not_found
end
unless build = ::Juici::Build.where(parent: project.name, _id: params[:id]).first
not_found
|
ruby
|
{
"resource": ""
}
|
q1844
|
ArubaDoubles.Double.run
|
train
|
def run(argv = ARGV)
history << [filename] + argv
output = @outputs[argv] || @default_output
|
ruby
|
{
"resource": ""
}
|
q1845
|
ArubaDoubles.Double.create
|
train
|
def create(&block)
register
self.instance_eval(&block) if block_given?
content = self.to_ruby
fullpath = File.join(self.class.bindir, filename)
#puts "creating double: #{fullpath} with content:\n#{content}" # debug
|
ruby
|
{
"resource": ""
}
|
q1846
|
ArubaDoubles.Double.to_ruby
|
train
|
def to_ruby
ruby = ['#!/usr/bin/env ruby']
ruby << "$: << '#{File.expand_path('..', File.dirname(__FILE__))}'"
ruby << 'require "aruba-doubles"'
ruby << 'ArubaDoubles::Double.run do'
@outputs.each_pair
|
ruby
|
{
"resource": ""
}
|
q1847
|
ArubaDoubles.Double.delete
|
train
|
def delete
deregister
fullpath = File.join(self.class.bindir,
|
ruby
|
{
"resource": ""
}
|
q1848
|
Rackstash.FilterChain.[]=
|
train
|
def []=(index, filter)
raise TypeError, 'must provide a filter' unless filter.respond_to?(:call)
synchronize do
id = index_at(index)
unless id && ([email protected]).cover?(id)
|
ruby
|
{
"resource": ""
}
|
q1849
|
Rackstash.FilterChain.call
|
train
|
def call(event)
each do |filter|
result = filter.call(event)
return
|
ruby
|
{
"resource": ""
}
|
q1850
|
Rackstash.FilterChain.insert_before
|
train
|
def insert_before(index, *filter_spec, &block)
filter = build_filter(filter_spec, &block)
synchronize do
id = index_at(index)
unless id && ([email protected]).cover?(id)
|
ruby
|
{
"resource": ""
}
|
q1851
|
Rackstash.FilterChain.build_filter
|
train
|
def build_filter(filter_spec, &block)
if filter_spec.empty?
return Rackstash::Filter.build(block) if block_given?
raise ArgumentError, 'Need to specify a filter'
|
ruby
|
{
"resource": ""
}
|
q1852
|
DaemonRunner.Client.start!
|
train
|
def start!
wait
logger.warn 'Tasks list is empty' if tasks.empty?
tasks.each do |task|
run_task(task)
sleep post_task_sleep_time
end
|
ruby
|
{
"resource": ""
}
|
q1853
|
Rackstash.ClassRegistry.fetch
|
train
|
def fetch(spec, default = UNDEFINED)
case spec
when Class
spec
when String, Symbol, ->(s) { s.respond_to?(:to_sym) }
@registry.fetch(spec.to_sym) do |key|
next yield(key) if block_given?
|
ruby
|
{
"resource": ""
}
|
q1854
|
Rackstash.ClassRegistry.[]=
|
train
|
def []=(name, registered_class)
unless registered_class.is_a?(Class)
raise TypeError, 'Can only register class objects'
end
case name
when String, Symbol
@registry[name.to_sym] = registered_class
else
|
ruby
|
{
"resource": ""
}
|
q1855
|
Blur.Callbacks.emit
|
train
|
def emit name, *args
# Trigger callbacks in scripts before triggering events in the client.
EM.defer { notify_scripts name, *args }
matching_callbacks = callbacks[name]
return
|
ruby
|
{
"resource": ""
}
|
q1856
|
VirtusModel.Base.export
|
train
|
def export(options = nil)
self.class.attributes.reduce({}) do |result, name|
value = attributes[name]
if self.class.association?(name, :many)
|
ruby
|
{
"resource": ""
}
|
q1857
|
VirtusModel.Base.extract_attributes
|
train
|
def extract_attributes(model)
self.class.attributes.reduce({}) do |result, name|
if model.respond_to?(name)
result[name] = model.public_send(name)
|
ruby
|
{
"resource": ""
}
|
q1858
|
VirtusModel.Base.validate_associations_many
|
train
|
def validate_associations_many
self.class.associations(:many).each do |name|
values = attributes[name] || []
values.each.with_index do |value, index|
|
ruby
|
{
"resource": ""
}
|
q1859
|
VirtusModel.Base.import_errors
|
train
|
def import_errors(name, model)
return unless model.respond_to?(:validate)
return if model.validate(validation_context)
model.errors.each do
|
ruby
|
{
"resource": ""
}
|
q1860
|
VirtusModel.Base.export_values
|
train
|
def export_values(values, options = nil)
return if values.nil?
values.map
|
ruby
|
{
"resource": ""
}
|
q1861
|
VirtusModel.Base.export_value
|
train
|
def export_value(value, options = nil)
return if value.nil?
|
ruby
|
{
"resource": ""
}
|
q1862
|
DaemonRunner.Semaphore.contender_key
|
train
|
def contender_key(value = 'none')
if value.nil? || value.empty?
raise ArgumentError, 'Value cannot be empty or nil'
end
key = "#{prefix}/#{session.id}"
|
ruby
|
{
"resource": ""
}
|
q1863
|
DaemonRunner.Semaphore.semaphore_state
|
train
|
def semaphore_state
options = { decode_values: true, recurse: true }
@state = Diplomat::Kv.get(prefix, options, :return)
|
ruby
|
{
"resource": ""
}
|
q1864
|
DaemonRunner.Semaphore.write_lock
|
train
|
def write_lock
index = lock_modify_index.nil? ? 0 : lock_modify_index
|
ruby
|
{
"resource": ""
}
|
q1865
|
DaemonRunner.Semaphore.renew?
|
train
|
def renew?
logger.debug("Watching Consul #{prefix} for changes")
options = { recurse: true }
changes = Diplomat::Kv.get(prefix, options, :wait, :wait)
|
ruby
|
{
"resource": ""
}
|
q1866
|
DaemonRunner.Semaphore.decode_semaphore_state
|
train
|
def decode_semaphore_state
lock_key = state.find { |k| k['Key'] == @lock }
member_keys = state.delete_if { |k| k['Key'] == @lock }
member_keys.map! { |k|
|
ruby
|
{
"resource": ""
}
|
q1867
|
DaemonRunner.Semaphore.prune_members
|
train
|
def prune_members
@holders = if lock_exists?
holders = lock_content['Holders']
return @holders = [] if holders.nil?
|
ruby
|
{
"resource": ""
}
|
q1868
|
DaemonRunner.Semaphore.add_self_to_holders
|
train
|
def add_self_to_holders
@holders.uniq!
@reset = true if @holders.length == 0
return true if @holders.include? session.id
if
|
ruby
|
{
"resource": ""
}
|
q1869
|
DaemonRunner.Semaphore.format_holders
|
train
|
def format_holders
@holders.uniq!
@holders.sort!
holders = {}
logger.debug "Holders are: #{@holders.join(',')}"
|
ruby
|
{
"resource": ""
}
|
q1870
|
DaemonRunner.Semaphore.generate_lockfile
|
train
|
def generate_lockfile
if lock_exists? && lock_content['Holders'] == @holders
logger.info 'Holders are unchanged, not updating'
return true
end
lockfile_format = {
|
ruby
|
{
"resource": ""
}
|
q1871
|
Juici.BuildQueue.bump!
|
train
|
def bump!
return unless @started
update_children
candidate_children.each do |child|
next if @child_pids.any? do |pid|
get_build_by_pid(pid).parent == child.parent
end
# We're good to launch this build
Juici.dbgp "Starting another child process"
return child.tap do |cld|
if pid = cld.build!
Juici.dbgp "Started child: #{pid}"
@child_pids << pid
@builds_by_pid[pid] = cld
|
ruby
|
{
"resource": ""
}
|
q1872
|
Blur.Network.got_message
|
train
|
def got_message message
@client.got_message self, message
rescue StandardError => exception
puts
|
ruby
|
{
"resource": ""
}
|
q1873
|
Blur.Network.disconnected!
|
train
|
def disconnected!
@channels.each { |_name, channel| channel.users.clear }
|
ruby
|
{
"resource": ""
}
|
q1874
|
Blur.Network.transmit
|
train
|
def transmit name, *arguments
message = IRCParser::Message.new command: name.to_s, parameters: arguments
if @client.verbose
formatted_command = message.command.to_s.ljust 8, ' '
formatted_params = message.parameters.map(&:inspect).join ' '
|
ruby
|
{
"resource": ""
}
|
q1875
|
SwitchBoard.RedisDataset.lock_id
|
train
|
def lock_id(locker_uid, id_to_lock, expire_in_sec = 5)
now = redis_time
@con.multi do
|
ruby
|
{
"resource": ""
}
|
q1876
|
Blur.Client.connect
|
train
|
def connect
networks = @networks.reject &:connected?
EventMachine.run do
load_scripts!
networks.each &:connect
EventMachine.error_handler do |exception|
|
ruby
|
{
"resource": ""
}
|
q1877
|
Blur.Client.quit
|
train
|
def quit signal = :SIGINT
@networks.each do |network|
network.transmit :QUIT, 'Got SIGINT?'
|
ruby
|
{
"resource": ""
}
|
q1878
|
Blur.Client.load_scripts!
|
train
|
def load_scripts!
scripts_dir = File.expand_path @config['blur']['scripts_dir']
script_file_paths = Dir.glob File.join scripts_dir, '*.rb'
# Sort the script file paths by file name so they load by alphabetical
# order.
#
# This will make it possible to create a script called '10_database.rb'
# which will be loaded before '20_settings.rb' and non-numeric prefixes
# will be loaded after that.
|
ruby
|
{
"resource": ""
}
|
q1879
|
Blur.Client.load_script_file
|
train
|
def load_script_file file_path
load file_path, true
rescue Exception => exception
warn "The script `#{file_path}' failed to load"
|
ruby
|
{
"resource": ""
}
|
q1880
|
Blur.Client.unload_scripts!
|
train
|
def unload_scripts!
@scripts.each do |name, script|
script.__send__
|
ruby
|
{
"resource": ""
}
|
q1881
|
Blur.Client.load_config!
|
train
|
def load_config!
config = YAML.load_file @config_path
if config.key? @environment
@config = config[@environment]
@config.deeper_merge! DEFAULT_CONFIG
emit :config_load
else
|
ruby
|
{
"resource": ""
}
|
q1882
|
Mangdown.Page.setup_path
|
train
|
def setup_path(dir = nil)
dir ||= chapter.path
dir = Tools.valid_path_name(dir)
name = self.name.tr('/', '')
file = Dir.entries(dir).find { |f| f[name] } if Dir.exist?(dir)
|
ruby
|
{
"resource": ""
}
|
q1883
|
PageRight.TextHelper.is_text_in_page?
|
train
|
def is_text_in_page?(content, flag=true)
if flag
assert page.has_content?("#{content}"), "Error: #{content} not found page !"
else
|
ruby
|
{
"resource": ""
}
|
q1884
|
PageRight.TextHelper.is_text_in_section?
|
train
|
def is_text_in_section?(section, content, flag=true)
within("#{section}") do
if flag
assert page.has_content?("#{content}"), "Error: #{content} not found in #{section} !"
else
|
ruby
|
{
"resource": ""
}
|
q1885
|
Juici.BuildEnvironment.load_json!
|
train
|
def load_json!(json)
return true if json == ""
loaded_json = JSON.load(json)
if loaded_json.is_a? Hash
env.merge!(loaded_json)
|
ruby
|
{
"resource": ""
}
|
q1886
|
Rackstash.Buffer.timestamp
|
train
|
def timestamp(time = nil)
@timestamp ||= begin
time ||= Time.now.utc.freeze
time
|
ruby
|
{
"resource": ""
}
|
q1887
|
Rackstash.Buffer.event
|
train
|
def event
event = fields.to_h
event[FIELD_TAGS] = tags.to_a
|
ruby
|
{
"resource": ""
}
|
q1888
|
RETS.HTTP.url_encode
|
train
|
def url_encode(str)
encoded_string = ""
str.each_char do |char|
case char
when "+"
encoded_string << "%2b"
when "="
encoded_string << "%3d"
|
ruby
|
{
"resource": ""
}
|
q1889
|
RETS.HTTP.save_digest
|
train
|
def save_digest(header)
@request_count = 0
@digest = {}
header.split(",").each do |line|
k, v = line.strip.split("=", 2)
@digest[k] = (k != "algorithm" and k != "stale")
|
ruby
|
{
"resource": ""
}
|
q1890
|
RETS.HTTP.create_digest
|
train
|
def create_digest(method, request_uri)
# http://en.wikipedia.org/wiki/Digest_access_authentication
first = Digest::MD5.hexdigest("#{@config[:username]}:#{@digest["realm"]}:#{@config[:password]}")
second = Digest::MD5.hexdigest("#{method}:#{request_uri}")
# Using the "newer" authentication QOP
if @digest_type.include?("auth")
cnonce = Digest::MD5.hexdigest("#{@headers["User-Agent"]}:#{@config[:password]}:#{@request_count}:#{@digest["nonce"]}")
hash = Digest::MD5.hexdigest("#{first}:#{@digest["nonce"]}:#{"%08X" % @request_count}:#{cnonce}:#{@digest["qop"]}:#{second}")
# Nothing specified, so default to the old one
elsif @digest_type.empty?
hash = Digest::MD5.hexdigest("#{first}:#{@digest["nonce"]}:#{second}")
else
raise RETS::HTTPError, "Cannot determine auth type for server (#{@digest_type.join(",")})"
end
http_digest =
|
ruby
|
{
"resource": ""
}
|
q1891
|
RETS.HTTP.get_rets_response
|
train
|
def get_rets_response(rets)
code, text = nil, nil
rets.attributes.each do |attr|
key = attr.first.downcase
if key == "replycode"
code = attr.last.value
elsif key == "replytext"
|
ruby
|
{
"resource": ""
}
|
q1892
|
TuneSpec.Instances.groups
|
train
|
def groups(name, opts = {}, *args, &block)
|
ruby
|
{
"resource": ""
}
|
q1893
|
TuneSpec.Instances.steps
|
train
|
def steps(name, opts = {}, *args, &block)
opts[:page] && opts[:page]
|
ruby
|
{
"resource": ""
}
|
q1894
|
TuneSpec.Instances.pages
|
train
|
def pages(name, opts = {}, *args, &block)
|
ruby
|
{
"resource": ""
}
|
q1895
|
Matchi.MatchersBase.to_s
|
train
|
def to_s
s = matcher_name
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.downcase
|
ruby
|
{
"resource": ""
}
|
q1896
|
FogTracker.Tracker.query
|
train
|
def query(query_string)
results = FogTracker::Query::QueryProcessor.new(
@trackers,
|
ruby
|
{
"resource": ""
}
|
q1897
|
FogTracker.Tracker.accounts=
|
train
|
def accounts=(new_accounts)
old_accounts = @accounts
@accounts = FogTracker.validate_accounts(new_accounts)
if (@accounts != old_accounts)
|
ruby
|
{
"resource": ""
}
|
q1898
|
FogTracker.Tracker.create_trackers
|
train
|
def create_trackers
@trackers = Hash.new
@accounts.each do |name, account|
@log.debug "Setting up tracker for account #{name}"
@trackers[name] = AccountTracker.new(name, account, {
:delay => @delay, :error_callback => @error_proc, :logger => @log,
|
ruby
|
{
"resource": ""
}
|
q1899
|
Rackstash.Logger.<<
|
train
|
def <<(msg)
buffer.add_message Message.new(
msg,
time: Time.now.utc.freeze,
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.