_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 30
4.3k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q25300
|
Rack.Unreloader.record_dependency
|
validation
|
def record_dependency(dependency, *files)
if @reloader
files = Unreloader.expand_paths(files)
|
ruby
|
{
"resource": ""
}
|
q25301
|
Rack.Unreloader.record_split_class
|
validation
|
def record_split_class(main_file, *files)
if @reloader
files = Unreloader.expand_paths(files)
files.each do |file|
|
ruby
|
{
"resource": ""
}
|
q25302
|
HireFire.Middleware.get_queue
|
validation
|
def get_queue(value)
ms = (Time.now.to_f
|
ruby
|
{
"resource": ""
}
|
q25303
|
TwoCaptcha.Client.decode
|
validation
|
def decode(options = {})
decode!(options)
rescue TwoCaptcha::Error => ex
|
ruby
|
{
"resource": ""
}
|
q25304
|
TwoCaptcha.Client.upload
|
validation
|
def upload(options = {})
args = {}
args[:body] = options[:raw64] if options[:raw64]
args[:method] = options[:method] || 'base64'
args.merge!(options)
response = request('in', :multipart, args)
unless response.match(/\AOK\|/)
|
ruby
|
{
"resource": ""
}
|
q25305
|
TwoCaptcha.Client.captcha
|
validation
|
def captcha(captcha_id)
response = request('res', :get, action: 'get', id: captcha_id)
decoded_captcha = TwoCaptcha::Captcha.new(id: captcha_id)
decoded_captcha.api_response = response
if
|
ruby
|
{
"resource": ""
}
|
q25306
|
TwoCaptcha.Client.load_captcha
|
validation
|
def load_captcha(options)
if options[:raw64]
options[:raw64]
elsif options[:raw]
Base64.encode64(options[:raw])
elsif options[:file]
Base64.encode64(options[:file].read)
|
ruby
|
{
"resource": ""
}
|
q25307
|
TwoCaptcha.Client.request
|
validation
|
def request(action, method = :get, payload = {})
res = TwoCaptcha::HTTP.request(
url: BASE_URL.gsub(':action', action),
timeout: timeout,
|
ruby
|
{
"resource": ""
}
|
q25308
|
TwoCaptcha.Client.validate_response
|
validation
|
def validate_response(response)
if (error = TwoCaptcha::RESPONSE_ERRORS[response])
fail(error)
|
ruby
|
{
"resource": ""
}
|
q25309
|
GitHub.Ldap.search
|
validation
|
def search(options, &block)
instrument "search.github_ldap", options.dup do |payload|
result =
if options[:base]
@connection.search(options, &block)
else
search_domains.each_with_object([]) do |base, result|
rs = @connection.search(options.merge(:base => base), &block)
|
ruby
|
{
"resource": ""
}
|
q25310
|
GitHub.Ldap.check_encryption
|
validation
|
def check_encryption(encryption, tls_options = {})
return unless encryption
tls_options ||= {}
case encryption.downcase.to_sym
when :ssl, :simple_tls
{
|
ruby
|
{
"resource": ""
}
|
q25311
|
GitHub.Ldap.configure_virtual_attributes
|
validation
|
def configure_virtual_attributes(attributes)
@virtual_attributes = if attributes == true
VirtualAttributes.new(true)
|
ruby
|
{
"resource": ""
}
|
q25312
|
LastPass.Vault.complete?
|
validation
|
def complete? chunks
!chunks.empty? && chunks.last.id == "ENDM"
|
ruby
|
{
"resource": ""
}
|
q25313
|
Gyoku.Prettifier.prettify
|
validation
|
def prettify(xml)
result = ''
formatter = REXML::Formatters::Pretty.new indent
|
ruby
|
{
"resource": ""
}
|
q25314
|
Raygun.SidekiqMiddleware.call
|
validation
|
def call(worker, message, queue)
begin
yield
rescue Exception => ex
raise ex if [Interrupt, SystemExit, SignalException].include?(ex.class)
|
ruby
|
{
"resource": ""
}
|
q25315
|
EM::Hiredis.Lock.acquire
|
validation
|
def acquire
df = EM::DefaultDeferrable.new
@redis.lock_acquire([@key], [@token, @timeout]).callback { |success|
if (success)
EM::Hiredis.logger.debug "#{to_s} acquired"
EM.cancel_timer(@expire_timer) if @expire_timer
@expire_timer = EM.add_timer(@timeout - 1) {
EM::Hiredis.logger.debug "#{to_s} Expires in 1s"
@onexpire.call if @onexpire
}
df.succeed
else
|
ruby
|
{
"resource": ""
}
|
q25316
|
EM::Hiredis.Lock.unlock
|
validation
|
def unlock
EM.cancel_timer(@expire_timer) if @expire_timer
df = EM::DefaultDeferrable.new
@redis.lock_release([@key], [@token]).callback { |keys_removed|
if keys_removed > 0
EM::Hiredis.logger.debug "#{to_s} released"
df.succeed
else
EM::Hiredis.logger.debug "#{to_s} could not
|
ruby
|
{
"resource": ""
}
|
q25317
|
RedisMock.Helper.redis_mock
|
validation
|
def redis_mock(replies = {})
begin
pid = fork do
trap("TERM") { exit }
RedisMock.start do |command, *args|
(replies[command.to_sym] || lambda { |*_| "+OK" }).call(*args)
end
end
sleep
|
ruby
|
{
"resource": ""
}
|
q25318
|
EventMachine::Hiredis.BaseClient.configure
|
validation
|
def configure(uri_string)
uri = URI(uri_string)
if uri.scheme == "unix"
@host = uri.path
@port = nil
else
@host = uri.host
@port = uri.port
|
ruby
|
{
"resource": ""
}
|
q25319
|
EventMachine::Hiredis.BaseClient.reconnect!
|
validation
|
def reconnect!(new_uri = nil)
@connection.close_connection
configure(new_uri) if new_uri
@auto_reconnect
|
ruby
|
{
"resource": ""
}
|
q25320
|
EventMachine::Hiredis.BaseClient.configure_inactivity_check
|
validation
|
def configure_inactivity_check(trigger_secs, response_timeout)
raise ArgumentError('trigger_secs must be > 0') unless trigger_secs.to_i > 0
raise ArgumentError('response_timeout must be > 0') unless response_timeout.to_i > 0
|
ruby
|
{
"resource": ""
}
|
q25321
|
EventMachine::Hiredis.PubsubClient.subscribe
|
validation
|
def subscribe(channel, proc = nil, &block)
if cb = proc || block
@sub_callbacks[channel] << cb
end
@subs << channel
|
ruby
|
{
"resource": ""
}
|
q25322
|
EventMachine::Hiredis.PubsubClient.unsubscribe
|
validation
|
def unsubscribe(channel)
@sub_callbacks.delete(channel)
@subs.delete(channel)
|
ruby
|
{
"resource": ""
}
|
q25323
|
EventMachine::Hiredis.PubsubClient.unsubscribe_proc
|
validation
|
def unsubscribe_proc(channel, proc)
df = EM::DefaultDeferrable.new
if @sub_callbacks[channel].delete(proc)
if @sub_callbacks[channel].any?
# Succeed deferrable immediately - no need to unsubscribe
df.succeed
else
|
ruby
|
{
"resource": ""
}
|
q25324
|
EventMachine::Hiredis.PubsubClient.psubscribe
|
validation
|
def psubscribe(pattern, proc = nil, &block)
if cb = proc || block
@psub_callbacks[pattern] << cb
end
@psubs << pattern
|
ruby
|
{
"resource": ""
}
|
q25325
|
EventMachine::Hiredis.PubsubClient.punsubscribe
|
validation
|
def punsubscribe(pattern)
@psub_callbacks.delete(pattern)
@psubs.delete(pattern)
|
ruby
|
{
"resource": ""
}
|
q25326
|
EventMachine::Hiredis.PubsubClient.punsubscribe_proc
|
validation
|
def punsubscribe_proc(pattern, proc)
df = EM::DefaultDeferrable.new
if @psub_callbacks[pattern].delete(proc)
if @psub_callbacks[pattern].any?
# Succeed deferrable immediately - no need to punsubscribe
df.succeed
else
|
ruby
|
{
"resource": ""
}
|
q25327
|
EventMachine::Hiredis.PubsubClient.raw_send_command
|
validation
|
def raw_send_command(sym, args)
if @connected
@connection.send_command(sym, args)
else
callback do
|
ruby
|
{
"resource": ""
}
|
q25328
|
GdsApi.Search.batch_search
|
validation
|
def batch_search(searches, additional_headers = {})
url_friendly_searches = searches.each_with_index.map do |search, index|
{ index => search }
end
searches_query = { search:
|
ruby
|
{
"resource": ""
}
|
q25329
|
GdsApi.Search.search_enum
|
validation
|
def search_enum(args, page_size: 100, additional_headers: {})
Enumerator.new do |yielder|
(0..Float::INFINITY).step(page_size).each do |index|
search_params = args.merge(start: index.to_i, count: page_size)
results = search(search_params, additional_headers).to_h.fetch('results', [])
|
ruby
|
{
"resource": ""
}
|
q25330
|
GdsApi.Search.advanced_search
|
validation
|
def advanced_search(args)
raise ArgumentError.new("Args cannot be blank") if args.nil? || args.empty?
request_path
|
ruby
|
{
"resource": ""
}
|
q25331
|
BitPay.RestConnector.process_request
|
validation
|
def process_request(request)
request['User-Agent'] = @user_agent
request['Content-Type'] = 'application/json'
request['X-BitPay-Plugin-Info'] = 'Rubylib' + VERSION
begin
response = @https.request request
rescue => error
raise BitPay::ConnectionError, "#{error.message}"
end
if response.kind_of? Net::HTTPSuccess
return JSON.parse(response.body)
|
ruby
|
{
"resource": ""
}
|
q25332
|
BitPay.RestConnector.refresh_tokens
|
validation
|
def refresh_tokens
response = get(path: 'tokens')["data"]
token_array = response || {}
tokens = {}
token_array.each do |t|
|
ruby
|
{
"resource": ""
}
|
q25333
|
FixtureBuilder.Builder.fixtures_class
|
validation
|
def fixtures_class
if defined?(ActiveRecord::FixtureSet)
ActiveRecord::FixtureSet
|
ruby
|
{
"resource": ""
}
|
q25334
|
Osbourne.Message.sns?
|
validation
|
def sns?
json_body.is_a?(Hash) && (%w[Message
|
ruby
|
{
"resource": ""
}
|
q25335
|
Qif.Transaction.to_s
|
validation
|
def to_s(format = 'dd/mm/yyyy')
SUPPORTED_FIELDS.collect do |k,v|
next unless current = instance_variable_get("@#{k}")
field = v.keys.first
case current.class.to_s
when "Time", "Date", "DateTime"
"#{field}#{DateFormat.new(format).format(current)}"
when "Float"
"#{field}#{'%.2f'%current}"
|
ruby
|
{
"resource": ""
}
|
q25336
|
Samlr.Signature.verify_digests!
|
validation
|
def verify_digests!
references.each do |reference|
node = referenced_node(reference.uri)
canoned = node.canonicalize(C14N, reference.namespaces)
|
ruby
|
{
"resource": ""
}
|
q25337
|
Samlr.Signature.referenced_node
|
validation
|
def referenced_node(id)
nodes = document.xpath("//*[@ID='#{id}']")
if nodes.size != 1
raise SignatureError.new("Reference validation error: Invalid element
|
ruby
|
{
"resource": ""
}
|
q25338
|
Samlr.Response.verify!
|
validation
|
def verify!
if signature.missing? && assertion.signature.missing?
raise Samlr::SignatureError.new("Neither response nor assertion signed with a certificate")
end
|
ruby
|
{
"resource": ""
}
|
q25339
|
SimpleScripting.Argv.decode_definition_and_options
|
validation
|
def decode_definition_and_options(definition_and_options)
# Only a hash (commands)
if definition_and_options.size == 1 && definition_and_options.first.is_a?(Hash)
options = definition_and_options.first.each_with_object({}) do |(key, value), current_options|
current_options[key] = definition_and_options.first.delete(key) if key.is_a?(Symbol)
end
# If there is an empty hash left, we remove it, so it's not considered commands.
|
ruby
|
{
"resource": ""
}
|
q25340
|
SimpleScripting.TabCompletion.complete
|
validation
|
def complete(execution_target, source_commandline=ENV.fetch('COMP_LINE'), cursor_position=ENV.fetch('COMP_POINT').to_i)
commandline_processor = CommandlineProcessor.process_commandline(source_commandline, cursor_position, @switches_definition)
if commandline_processor.completing_an_option?
|
ruby
|
{
"resource": ""
}
|
q25341
|
Danger.DangerJacoco.report
|
validation
|
def report(path, report_url = '', delimiter = %r{\/java\/|\/kotlin\/})
setup
classes = classes(delimiter)
parser = Jacoco::SAXParser.new(classes)
Nokogiri::XML::SAX::Parser.new(parser).parse(File.open(path))
total_covered = total_coverage(path)
report_markdown = "### JaCoCO Code Coverage #{total_covered[:covered]}% #{total_covered[:status]}\n"
report_markdown << "| Class | Covered | Meta | Status |\n"
|
ruby
|
{
"resource": ""
}
|
q25342
|
Danger.DangerJacoco.classes
|
validation
|
def classes(delimiter)
git = @dangerfile.git
affected_files = git.modified_files + git.added_files
affected_files.select
|
ruby
|
{
"resource": ""
}
|
q25343
|
Danger.DangerJacoco.report_class
|
validation
|
def report_class(jacoco_class)
counter = coverage_counter(jacoco_class)
coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
required_coverage = minimum_class_coverage_map[jacoco_class.name]
required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
status
|
ruby
|
{
"resource": ""
}
|
q25344
|
Danger.DangerJacoco.total_coverage
|
validation
|
def total_coverage(report_path)
jacoco_report = Nokogiri::XML(File.open(report_path))
report = jacoco_report.xpath('report/counter').select { |item| item['type'] == 'INSTRUCTION' }
missed_instructions = report.first['missed'].to_f
covered_instructions = report.first['covered'].to_f
total_instructions = missed_instructions + covered_instructions
|
ruby
|
{
"resource": ""
}
|
q25345
|
Mizuno.Server.rewindable
|
validation
|
def rewindable(request)
input = request.getInputStream
@options[:rewindable] ?
Rack::RewindableInput.new(input.to_io.binmode)
|
ruby
|
{
"resource": ""
}
|
q25346
|
Mizuno.RackHandler.servlet_to_rack
|
validation
|
def servlet_to_rack(request)
# The Rack request that we will pass on.
env = Hash.new
# Map Servlet bits to Rack bits.
env['REQUEST_METHOD'] = request.getMethod
env['QUERY_STRING'] = request.getQueryString.to_s
env['SERVER_NAME'] = request.getServerName
env['SERVER_PORT'] = request.getServerPort.to_s
env['rack.version'] = Rack::VERSION
env['rack.url_scheme'] = request.getScheme
env['HTTP_VERSION'] = request.getProtocol
env["SERVER_PROTOCOL"] = request.getProtocol
env['REMOTE_ADDR'] = request.getRemoteAddr
env['REMOTE_HOST'] = request.getRemoteHost
# request.getPathInfo seems to be blank, so we're using the URI.
env['REQUEST_PATH'] = request.getRequestURI
env['PATH_INFO'] = request.getRequestURI
env['SCRIPT_NAME'] = ""
# Rack says URI, but it hands off a URL.
env['REQUEST_URI'] = request.getRequestURL.to_s
# Java chops off the query string, but a Rack application will
# expect it, so we'll add it back if present
env['REQUEST_URI'] << "?#{env['QUERY_STRING']}" \
if env['QUERY_STRING']
# JRuby is like the matrix, only there's no spoon or fork().
env['rack.multiprocess'] = false
env['rack.multithread'] = true
env['rack.run_once'] = false
|
ruby
|
{
"resource": ""
}
|
q25347
|
Mizuno.RackHandler.handle_exceptions
|
validation
|
def handle_exceptions(response)
begin
yield
rescue => error
message = "Exception: #{error}"
message << "\n#{error.backtrace.join("\n")}" \
if (error.respond_to?(:backtrace))
|
ruby
|
{
"resource": ""
}
|
q25348
|
Mizuno.Reloader.find_files_for_reload
|
validation
|
def find_files_for_reload
paths = [ './', *$LOAD_PATH ].uniq
[ $0, *$LOADED_FEATURES ].uniq.map do |file|
|
ruby
|
{
"resource": ""
}
|
q25349
|
Mizuno.Reloader.find
|
validation
|
def find(file, paths)
if(Pathname.new(file).absolute?)
return unless (timestamp = mtime(file))
@logger.debug("Found #{file}")
[ file, timestamp ]
else
paths.each
|
ruby
|
{
"resource": ""
}
|
q25350
|
Mizuno.Reloader.mtime
|
validation
|
def mtime(file)
begin
return unless file
stat = File.stat(file)
|
ruby
|
{
"resource": ""
}
|
q25351
|
Namely.Collection.find
|
validation
|
def find(id)
build(resource_gateway.json_show(id))
rescue RestClient::ResourceNotFound
|
ruby
|
{
"resource": ""
}
|
q25352
|
Namely.Authenticator.authorization_code_url
|
validation
|
def authorization_code_url(options)
URL.new(options.merge(
path: "/api/v1/oauth2/authorize",
|
ruby
|
{
"resource": ""
}
|
q25353
|
Namely.Authenticator.current_user
|
validation
|
def current_user(options)
access_token = options.fetch(:access_token)
subdomain = options.fetch(:subdomain)
user_url = URL.new(options.merge(
params: {
access_token: access_token,
},
path: "/api/v1/profiles/me",
)).to_s
response =
|
ruby
|
{
"resource": ""
}
|
q25354
|
Namely.Model.save!
|
validation
|
def save!
if persisted?
update(to_h)
else
self.id = resource_gateway.create(to_h)
end
self
|
ruby
|
{
"resource": ""
}
|
q25355
|
Namely.Model.update
|
validation
|
def update(attributes)
attributes.each do |key, value|
self[key] = value
end
begin
|
ruby
|
{
"resource": ""
}
|
q25356
|
Mohawk.Accessors.text
|
validation
|
def text(name, locator)
define_method("#{name}") do
adapter.text(locator).value
end
define_method("#{name}=") do |text|
adapter.text(locator).set text
end
define_method("clear_#{name}") do
adapter.text(locator).clear
end
define_method("enter_#{name}") do |text|
|
ruby
|
{
"resource": ""
}
|
q25357
|
Mohawk.Accessors.button
|
validation
|
def button(name, locator)
define_method("#{name}") do |&block|
adapter.button(locator).click &block
end
define_method("#{name}_value") do
adapter.button(locator).value
|
ruby
|
{
"resource": ""
}
|
q25358
|
Mohawk.Accessors.combo_box
|
validation
|
def combo_box(name, locator)
define_method("#{name}") do
adapter.combo(locator).value
end
define_method("clear_#{name}") do |item|
adapter.combo(locator).clear item
end
define_method("#{name}_selections") do
adapter.combo(locator).values
end
define_method("#{name}=") do |item|
adapter.combo(locator).set item
|
ruby
|
{
"resource": ""
}
|
q25359
|
Mohawk.Accessors.radio
|
validation
|
def radio(name, locator)
define_method("#{name}") do
adapter.radio(locator).set
end
define_method("#{name}?") do
adapter.radio(locator).set?
end
|
ruby
|
{
"resource": ""
}
|
q25360
|
Mohawk.Accessors.label
|
validation
|
def label(name, locator)
define_method("#{name}") do
adapter.label(locator).value
end
|
ruby
|
{
"resource": ""
}
|
q25361
|
Mohawk.Accessors.link
|
validation
|
def link(name, locator)
define_method("#{name}_text") do
adapter.link(locator).value
end
define_method("click_#{name}") do
adapter.link(locator).click
end
|
ruby
|
{
"resource": ""
}
|
q25362
|
Mohawk.Accessors.menu_item
|
validation
|
def menu_item(name, locator)
define_method("#{name}") do
adapter.menu_item(locator).select
end
|
ruby
|
{
"resource": ""
}
|
q25363
|
Mohawk.Accessors.table
|
validation
|
def table(name, locator)
define_method("#{name}") do
adapter.table(locator)
end
define_method("#{name}=") do |which_item|
adapter.table(locator).select which_item
end
define_method("add_#{name}") do |hash_info|
adapter.table(locator).add hash_info
end
define_method("select_#{name}") do |hash_info|
adapter.table(locator).select hash_info
end
define_method("find_#{name}") do |hash_info|
|
ruby
|
{
"resource": ""
}
|
q25364
|
Mohawk.Accessors.tree_view
|
validation
|
def tree_view(name, locator)
define_method("#{name}") do
adapter.tree_view(locator).value
end
define_method("#{name}=") do |which_item|
adapter.tree_view(locator).select which_item
end
define_method("#{name}_items") do
adapter.tree_view(locator).items
end
define_method("expand_#{name}_item") do |which_item|
adapter.tree_view(locator).expand which_item
|
ruby
|
{
"resource": ""
}
|
q25365
|
Mohawk.Accessors.spinner
|
validation
|
def spinner(name, locator)
define_method(name) do
adapter.spinner(locator).value
end
define_method("#{name}=") do |value|
adapter.spinner(locator).value = value
end
define_method("increment_#{name}") do
adapter.spinner(locator).increment
end
define_method("decrement_#{name}") do
|
ruby
|
{
"resource": ""
}
|
q25366
|
Mohawk.Accessors.tabs
|
validation
|
def tabs(name, locator)
define_method(name) do
adapter.tab_control(locator).value
end
define_method("#{name}=") do |which|
adapter.tab_control(locator).selected_tab = which
end
define_method("#{name}_items") do
|
ruby
|
{
"resource": ""
}
|
q25367
|
FoundationRailsHelper.FlashHelper.display_flash_messages
|
validation
|
def display_flash_messages(closable: true, key_matching: {})
key_matching = DEFAULT_KEY_MATCHING.merge(key_matching)
key_matching.default = :primary
capture do
flash.each do |key, value|
next if ignored_key?(key.to_sym)
|
ruby
|
{
"resource": ""
}
|
q25368
|
PinPayment.Charge.refunds
|
validation
|
def refunds
response = Charge.get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{token}/refunds" })
|
ruby
|
{
"resource": ""
}
|
q25369
|
PinPayment.Recipient.update
|
validation
|
def update email, account_or_token = nil
attributes = self.class.attributes - [:token, :created_at]
options = self.class.parse_options_for_request(attributes, email: email,
|
ruby
|
{
"resource": ""
}
|
q25370
|
PinPayment.Customer.update
|
validation
|
def update email, card_or_token = nil
attributes = self.class.attributes - [:token, :created_at]
options = self.class.parse_options_for_request(attributes, email:
|
ruby
|
{
"resource": ""
}
|
q25371
|
SMB.ClientHelper.ls
|
validation
|
def ls(mask = '', raise = true)
ls_items = []
mask = '"' + mask + '"' if mask.include? ' '
output = exec 'ls ' + mask
output.lines.each do |line|
ls_item = LsItem.from_line(line)
|
ruby
|
{
"resource": ""
}
|
q25372
|
SMB.ClientHelper.put
|
validation
|
def put(from, to, overwrite = false, raise = true)
ls_items = ls to, false
if !overwrite && !ls_items.empty?
raise Client::RuntimeError, "File [#{to}] already exist"
end
from = '"' + from + '"' if from.include? ' '
to = '"' +
|
ruby
|
{
"resource": ""
}
|
q25373
|
SMB.ClientHelper.write
|
validation
|
def write(content, to, overwrite = false, raise = true)
# This is just a hack around +put+
tempfile = Tempfile.new
tempfile.write content
|
ruby
|
{
"resource": ""
}
|
q25374
|
SMB.ClientHelper.del
|
validation
|
def del(path, raise = true)
path = '"' + path + '"' if path.include? ' '
exec 'del ' + path
true
|
ruby
|
{
"resource": ""
}
|
q25375
|
SMB.ClientHelper.get
|
validation
|
def get(from, to = nil, overwrite = false, raise = true)
# Create a new tempfile but delete it
# The tempfile.path should be free to use now
tempfile = Tempfile.new
to ||= tempfile.path
tempfile.unlink
if !overwrite && File.exist?(to)
raise Client::RuntimeError, "File [#{to}] already exist locally"
|
ruby
|
{
"resource": ""
}
|
q25376
|
SMB.ClientHelper.read
|
validation
|
def read(from, overwrite = false, raise = true)
tempfile = Tempfile.new
to = tempfile.path
tempfile.unlink
|
ruby
|
{
"resource": ""
}
|
q25377
|
SMB.Client.exec
|
validation
|
def exec(cmd)
# Send command
@write1.puts cmd
# Wait for response
text = @read2.read
# Close previous pipe
@read2.close
# Create new pipe
@read2, @write2 = IO.pipe
# Raise at the
|
ruby
|
{
"resource": ""
}
|
q25378
|
SMB.Client.connect
|
validation
|
def connect
# Run +@executable+ in a separate thread to talk to hin asynchronously
Thread.start do
# Spawn the actual +@executable+ pty with +input+ and +output+ handle
begin
PTY.spawn(@executable + ' ' + params) do |output, input, pid|
@pid = pid
output.sync = true
input.sync = true
# Write inputs to pty from +exec+ method
Thread.start do
while (line = @read1.readline)
input.puts line
end
end
# Wait for responses ending with input prompt
loop do
output.expect(/smb: \\>$/) { |text| handle_response text }
end
end
|
ruby
|
{
"resource": ""
}
|
q25379
|
IsoBibItem.IsoBibliographicItem.to_all_parts
|
validation
|
def to_all_parts
me = DeepClone.clone(self)
me.disable_id_attribute
@relations << DocumentRelation.new(type: "partOf", identifier: nil, url: nil, bibitem: me)
@title.each(&:remove_part)
|
ruby
|
{
"resource": ""
}
|
q25380
|
Automata.DFA.valid?
|
validation
|
def valid?
# @todo Check that each state is connected.
# Iterate through each states to verify the graph
# is not disjoint.
|
ruby
|
{
"resource": ""
}
|
q25381
|
Automata.DFA.feed
|
validation
|
def feed(input)
head = @start.to_s
input.each_char { |symbol| head = @transitions[head][symbol] }
accept = is_accept_state? head
resp
|
ruby
|
{
"resource": ""
}
|
q25382
|
HBaseRb.Table.create_scanner
|
validation
|
def create_scanner(start_row=nil, end_row=nil, *columns, &block)
columns = (columns.length > 0) ? columns : column_families.keys
|
ruby
|
{
"resource": ""
}
|
q25383
|
Automata.Tape.transition
|
validation
|
def transition(read, write, move)
if read == @memory[@head]
@memory[@head] = write
case move
when 'R'
# Move right
@memory << '@' if @memory[@head + 1]
@head += 1
when 'L'
|
ruby
|
{
"resource": ""
}
|
q25384
|
Automata.PDA.feed
|
validation
|
def feed(input)
heads, @stack, accept = [@start], [], false
# Move any initial e-transitions
eTrans = transition(@start, '&') if has_transition?(@start, '&')
heads += eTrans
puts "initial heads: #{heads}"
puts "initial stack: #{@stack}"
# Iterate through each symbol of input string
input.each_char do |symbol|
newHeads = []
puts "Reading symbol: #{symbol}"
heads.each do |head|
puts "At head #{head}"
# Check
|
ruby
|
{
"resource": ""
}
|
q25385
|
Automata.PDA.has_transition?
|
validation
|
def has_transition?(state, symbol)
return false unless @transitions.has_key? state
if @transitions[state].has_key? symbol
actions = @transitions[state][symbol]
|
ruby
|
{
"resource": ""
}
|
q25386
|
AmazonFlexPay.Model.to_hash
|
validation
|
def to_hash
self.class.attribute_names.inject({}) do |hash, name|
val = format_value(send(name.underscore))
|
ruby
|
{
"resource": ""
}
|
q25387
|
AmazonFlexPay.Model.format_value
|
validation
|
def format_value(val)
case val
when AmazonFlexPay::Model
val.to_hash
when Time
val.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
when TrueClass, FalseClass
|
ruby
|
{
"resource": ""
}
|
q25388
|
AmazonFlexPay.Model.assign
|
validation
|
def assign(hash)
hash.each do |k, v|
send("#{k.to_s.underscore}=",
|
ruby
|
{
"resource": ""
}
|
q25389
|
AmazonFlexPay.Pipelines.edit_token_pipeline
|
validation
|
def edit_token_pipeline(caller_reference, return_url, options = {})
|
ruby
|
{
"resource": ""
}
|
q25390
|
AmazonFlexPay.Pipelines.multi_use_pipeline
|
validation
|
def multi_use_pipeline(caller_reference, return_url, options = {})
cbui MultiUse.new(options.merge(:caller_reference =>
|
ruby
|
{
"resource": ""
}
|
q25391
|
AmazonFlexPay.Pipelines.recipient_pipeline
|
validation
|
def recipient_pipeline(caller_reference, return_url, options = {})
cbui Recipient.new(options.merge(:caller_reference
|
ruby
|
{
"resource": ""
}
|
q25392
|
AmazonFlexPay.Pipelines.single_use_pipeline
|
validation
|
def single_use_pipeline(caller_reference, return_url, options = {})
|
ruby
|
{
"resource": ""
}
|
q25393
|
AmazonFlexPay::Pipelines.Base.to_param
|
validation
|
def to_param
params = to_hash.merge(
'callerKey' => AmazonFlexPay.access_key,
'signatureVersion' => 2,
'signatureMethod' => 'HmacSHA256'
)
|
ruby
|
{
"resource": ""
}
|
q25394
|
AmazonFlexPay.API.get_account_activity
|
validation
|
def get_account_activity(start_date, end_date, options = {})
submit
|
ruby
|
{
"resource": ""
}
|
q25395
|
AmazonFlexPay.API.refund
|
validation
|
def refund(transaction_id, caller_reference, options = {})
submit Refund.new(options.merge(:transaction_id =>
|
ruby
|
{
"resource": ""
}
|
q25396
|
AmazonFlexPay.API.verify_request
|
validation
|
def verify_request(request)
verify_signature(
# url without query string
request.protocol +
|
ruby
|
{
"resource": ""
}
|
q25397
|
AmazonFlexPay.API.submit
|
validation
|
def submit(request)
url = request.to_url
ActiveSupport::Notifications.instrument("amazon_flex_pay.api", :action => request.action_name, :request => url) do |payload|
begin
http = RestClient.get(url)
payload[:response] = http.body
payload[:code] = http.code
response = request.class::Response.from_xml(http.body)
response.request = request
response
rescue RestClient::BadRequest, RestClient::Unauthorized, RestClient::Forbidden => e
payload[:response] = e.http_body
payload[:code] = e.http_code
|
ruby
|
{
"resource": ""
}
|
q25398
|
JSONAPI::Consumer.Resource.save
|
validation
|
def save
return false unless valid?
self.last_result_set = if persisted?
self.class.requestor.update(self)
else
self.class.requestor.create(self)
end
if last_result_set.has_errors?
fill_errors
false
else
self.errors.clear if self.errors
mark_as_persisted!
if
|
ruby
|
{
"resource": ""
}
|
q25399
|
JSONAPI::Consumer.Resource.destroy
|
validation
|
def destroy
self.last_result_set = self.class.requestor.destroy(self)
if last_result_set.has_errors?
fill_errors
false
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.