_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q4000 | Sinatra.Mapping.locations_get_from | train | def locations_get_from(*args)
args.flatten.reject do |path|
path == :root
end.collect do |path|
@locations[path] || path
end
end | ruby | {
"resource": ""
} |
q4001 | Plum.ServerConnection.reserve_stream | train | def reserve_stream(**args)
next_id = @max_stream_ids[0] + 2
stream = stream(next_id)
stream.set_state(:reserved_local)
stream.update_dependency(**args)
stream
end | ruby | {
"resource": ""
} |
q4002 | Sshez.Runner.process | train | def process(args)
parser = Parser.new(Exec.new(self))
parser.parse(args)
PRINTER.output
end | ruby | {
"resource": ""
} |
q4003 | BootstrapBuilder.Builder.element | train | def element(label = ' ', value = '', type = 'text_field', &block)
value += @template.capture(&block) if block_given?
%{
<div class='control-group'>
<label class='control-label'>#{label}</label>
<div class='controls'>
#{value}
</div>
</div>
... | ruby | {
"resource": ""
} |
q4004 | BootstrapBuilder.Builder.render_field | train | def render_field(field_name, method, options={}, html_options={}, &block)
case field_name
when 'check_box'
template = field_name
else
template = 'default_field'
end
@template.render(:partial => "#{BootstrapBuilder.config.template_folder}/#{template}", :locals => {
... | ruby | {
"resource": ""
} |
q4005 | KnifeTopo.CommandHelper.initialize_cmd_args | train | def initialize_cmd_args(args, name_args, new_name_args)
args = args.dup
args.shift(2 + name_args.length)
new_name_args + args
end | ruby | {
"resource": ""
} |
q4006 | KnifeTopo.CommandHelper.run_cmd | train | def run_cmd(command_class, args)
command = command_class.new(args)
command.config[:config_file] = config[:config_file]
command.configure_chef
command_class.load_deps
command.run
command
end | ruby | {
"resource": ""
} |
q4007 | KnifeTopo.CommandHelper.resource_exists? | train | def resource_exists?(relative_path)
rest.get_rest(relative_path)
true
rescue Net::HTTPServerException => e
raise unless e.response.code == '404'
false
end | ruby | {
"resource": ""
} |
q4008 | KnifeTopo.CommandHelper.check_chef_env | train | def check_chef_env(chef_env_name)
return unless chef_env_name
Chef::Environment.load(chef_env_name) if chef_env_name
rescue Net::HTTPServerException => e
raise unless e.to_s =~ /^404/
ui.info 'Creating chef environment ' + chef_env_name
chef_env = Chef::Environment.new
chef_env.n... | ruby | {
"resource": ""
} |
q4009 | Ralexa.AbstractService.result | train | def result(*params, &parser)
Result.new(
@client,
host,
path,
merged_params(*params),
&parser
).result
end | ruby | {
"resource": ""
} |
q4010 | Ralexa.AbstractService.collection | train | def collection(*params, &parser)
LazyCollection.new(
@client,
host,
path,
merged_params(*params),
&parser
)
end | ruby | {
"resource": ""
} |
q4011 | Ralexa.AbstractService.merged_params | train | def merged_params(*params)
params.reduce(default_params) do |merged, params|
merged.merge(params)
end
end | ruby | {
"resource": ""
} |
q4012 | Shop.Template.custom_template_path | train | def custom_template_path(name)
config = ShopConfig.new
custom_path = config.get('template', 'path')
if File.exists?("#{custom_path}/#{name}")
"#{custom_path}/#{name}"
else
false
end
end | ruby | {
"resource": ""
} |
q4013 | Shop.Template.template_path | train | def template_path(name=false)
custom_path = custom_template_path(name)
if custom_path
custom_path
else
path = File.expand_path File.dirname(__FILE__)
return "#{path}/../../templates/#{name}" if name
"#{path}/../../templates"
end
end | ruby | {
"resource": ""
} |
q4014 | Shop.Template.template | train | def template(name, datas)
file = template_path(name)
content = File.read(file)
datas.each do |k, v|
k = "<%= #{k} %>"
content = content.gsub(k, v)
end
return content
end | ruby | {
"resource": ""
} |
q4015 | RBarman.CliCommand.binary= | train | def binary=(path)
raise(ArgumentError, "binary doesn't exist") if !File.exists?(path)
raise(ArgumentError, "binary isn't called \'barman\'") if File.basename(path) != 'barman'
@binary = path
end | ruby | {
"resource": ""
} |
q4016 | RBarman.CliCommand.backup | train | def backup(server, backup_id, opts = {})
raise(ArgumentError, "backup id must not be nil!") if backup_id.nil?
opts[:backup_id] = backup_id
return backups(server, opts)[0]
end | ruby | {
"resource": ""
} |
q4017 | RBarman.CliCommand.server | train | def server(name, opts = {})
lines = run_barman_command("show-server #{name}")
server = parse_show_server_lines(name, lines)
lines = run_barman_command("check #{name}", { :abort_on_error => false })
parse_check_lines(server, lines)
server.backups = backups(server.name, opts) if opts[:with_b... | ruby | {
"resource": ""
} |
q4018 | RBarman.CliCommand.servers | train | def servers(opts = {})
result = Servers.new
lines = run_barman_command("list-server")
server_names = parse_list_server_lines(lines)
server_names.each do |name|
result << server(name, opts)
end
return result
end | ruby | {
"resource": ""
} |
q4019 | RBarman.CliCommand.wal_files | train | def wal_files(server, backup_id)
lines = run_barman_command("list-files --target wal #{server} #{backup_id}")
wal_files = parse_wal_files_list(lines)
xlog_db = read_xlog_db(server)
wal_files.each do |w|
wal = "#{w.timeline}#{w.xlog}#{w.segment}"
entry = xlog_db[wal]
w.siz... | ruby | {
"resource": ""
} |
q4020 | RBarman.CliCommand.parse_list_server_lines | train | def parse_list_server_lines(lines)
result = Array.new
lines.each do |l|
result << l.split("-")[0].strip
end
return result
end | ruby | {
"resource": ""
} |
q4021 | RBarman.CliCommand.create_recovery_cmd_args | train | def create_recovery_cmd_args(opts={})
args = Array.new
args << "--remote-ssh-command='#{opts[:remote_ssh_cmd]}'" if opts[:remote_ssh_cmd]
args << "--target-time '#{opts[:target_time].to_s}'" if opts[:target_time]
args << "--target-xid #{opts[:target_xid]}" if opts[:target_xid]
args << "--e... | ruby | {
"resource": ""
} |
q4022 | KnifeTopo.NodeUpdateHelper.update_node | train | def update_node(node_updates, merge = false)
config[:disable_editing] = true
begin
# load then update and save the node
node = Chef::Node.load(node_updates['name'])
env = node_updates['chef_environment']
check_chef_env(env) unless env == node['chef_environment']
do_... | ruby | {
"resource": ""
} |
q4023 | KnifeTopo.NodeUpdateHelper.update_node_with_values | train | def update_node_with_values(node, updates, merge = false)
updated = []
# merge the normal attributes (but not tags)
updated << 'normal' if update_attrs(node, updates['normal'], merge)
# update runlist
updated << 'run_list' if update_runlist(node, updates['run_list'])
# update chef... | ruby | {
"resource": ""
} |
q4024 | KnifeTopo.NodeUpdateHelper.update_attrs | train | def update_attrs(node, attrs, merge = false)
return false unless attrs
# keep the current tags
attrs['tags'] = node.normal.tags || []
original = Marshal.load(Marshal.dump(node.normal))
node.normal = if merge
Chef::Mixin::DeepMerge.merge(node.normal, attrs)
... | ruby | {
"resource": ""
} |
q4025 | TrueVault.User.create | train | def create(options = {})
query = {
query: {
username: options[:username],
password: options[:password],
attributes: hash_to_base64_json(options[:attributes])
}
}
new_options = default_options_to_merge_with.merge(query)
self.class.post("/#{@api_v... | ruby | {
"resource": ""
} |
q4026 | TrueVault.User.all | train | def all(read_attributes="01")
options = default_options_to_merge_with.merge({ query: { full: read_attributes} })
self.class.get("/#{@api_ver}/users", options)
end | ruby | {
"resource": ""
} |
q4027 | LeMeme.MemeLib.load_directory! | train | def load_directory!(dir)
paths = Dir.glob(dir).grep LeMeme::IMAGE_EXTENSIONS
@memes.merge!(paths.reduce({}) do |images, path|
path = File.expand_path(path)
name = path.split.last.sub(LeMeme::IMAGE_EXTENSIONS, '').to_s
images.merge(name => path)
end)
end | ruby | {
"resource": ""
} |
q4028 | LeMeme.MemeLib.meme | train | def meme(template: nil, top: nil, bottom: nil, watermark: nil)
path = template.nil? ? @memes.values.sample : @memes[template]
Meme.new(path, top: top, bottom: bottom, watermark: watermark)
end | ruby | {
"resource": ""
} |
q4029 | Permits.Ability.role_groups | train | def role_groups
groups = []
user_account_class.role_groups.map{|k,v| groups << k if user_account.has_any_role?(v)}
groups
end | ruby | {
"resource": ""
} |
q4030 | Plum.FlowControl.send | train | def send(frame)
if Frame::Data === frame
@send_buffer << frame
if @send_remaining_window < frame.length
if Stream === self
connection.callback(:send_deferred, self, frame)
else
callback(:send_deferred, self, frame)
end
else
co... | ruby | {
"resource": ""
} |
q4031 | Plum.FlowControl.window_update | train | def window_update(wsi)
@recv_remaining_window += wsi
sid = (Stream === self) ? self.id : 0
send_immediately Frame::WindowUpdate.new(sid, wsi)
end | ruby | {
"resource": ""
} |
q4032 | Bicho.Bug.add_attachment | train | def add_attachment(summary, file, **kwargs)
@client.add_attachment(summary, file, id, **kwargs).first
end | ruby | {
"resource": ""
} |
q4033 | PixelPi.Leds.show | train | def show
closed!
if @debug
ary = @leds.map { |value| Rainbow(@debug).color(*to_rgb(value)) }
$stdout.print "\r#{ary.join}"
end
self
end | ruby | {
"resource": ""
} |
q4034 | PixelPi.Leds.[]= | train | def []=( num, value )
closed!
if (num < 0 || num >= @leds.length)
raise IndexError, "index #{num} is outside of LED range: 0...#{@leds.length-1}"
end
@leds[num] = to_color(value)
end | ruby | {
"resource": ""
} |
q4035 | PixelPi.Leds.replace | train | def replace( ary )
closed!
@leds.length.times do |ii|
@leds[ii] = Integer(ary[ii])
end
self
end | ruby | {
"resource": ""
} |
q4036 | PixelPi.Leds.fill | train | def fill( *args )
closed!
if block_given?
@leds.fill do |ii|
value = yield(ii)
to_color(value)
end
else
value = to_color(args.shift)
@leds.fill(value, *args)
end
self
end | ruby | {
"resource": ""
} |
q4037 | Bicho.Query.each | train | def each
ret = Bicho.client.search_bugs(self)
return ret.each unless block_given?
ret.each { |bug| yield bug }
end | ruby | {
"resource": ""
} |
q4038 | Bicho.Query.method_missing | train | def method_missing(method_name, *args)
return super unless Bicho::SEARCH_FIELDS
.map(&:first)
.include?(method_name)
args.each do |arg|
append_query(method_name.to_s, arg)
end
self
end | ruby | {
"resource": ""
} |
q4039 | Bicho.Query.append_query | train | def append_query(param, value)
@query_map[param] = [] unless @query_map.key?(param)
@query_map[param] = [@query_map[param], value].flatten
end | ruby | {
"resource": ""
} |
q4040 | RTM.RTMMethodSpace.method_missing | train | def method_missing(symbol,*args)
if (@name == 'tasks' && symbol.to_s == 'notes')
return RTMMethodSpace.new("tasks.notes",@endpoint)
else
rtm_method = "rtm.#{@name}.#{symbol.to_s.rtmize}"
@endpoint.call_method(rtm_method,*args)
end
end | ruby | {
"resource": ""
} |
q4041 | Bitstamp.Model.attributes= | train | def attributes=(attributes = {})
attributes.each do |name, value|
begin
send("#{name}=", value)
rescue NoMethodError => e
puts "Unable to assign #{name}. No such method."
end
end
end | ruby | {
"resource": ""
} |
q4042 | Plum.Client.start | train | def start(&block)
raise IOError, "Session already started" if @started
_start
if block_given?
begin
ret = yield(self)
resume
return ret
ensure
close
end
end
self
end | ruby | {
"resource": ""
} |
q4043 | Plum.Client.request | train | def request(headers, body, options = {}, &block)
raise ArgumentError, ":method and :path headers are required" unless headers[":method"] && headers[":path"]
@session.request(headers, body, @config.merge(options), &block)
end | ruby | {
"resource": ""
} |
q4044 | PEROBS.FlatFile.open | train | def open
file_name = File.join(@db_dir, 'database.blobs')
new_db_created = false
begin
if File.exist?(file_name)
@f = File.open(file_name, 'rb+')
else
PEROBS.log.info "New FlatFile database '#{file_name}' created"
@f = File.open(file_name, 'wb+')
... | ruby | {
"resource": ""
} |
q4045 | PEROBS.FlatFile.close | train | def close
@space_list.close if @space_list.is_open?
@index.close if @index.is_open?
if @marks
@marks.erase
@marks = nil
end
if @f
@f.flush
@f.flock(File::LOCK_UN)
@f.fsync
@f.close
@f = nil
end
end | ruby | {
"resource": ""
} |
q4046 | PEROBS.FlatFile.sync | train | def sync
begin
@f.flush
@f.fsync
rescue IOError => e
PEROBS.log.fatal "Cannot sync flat file database: #{e.message}"
end
@index.sync
@space_list.sync
end | ruby | {
"resource": ""
} |
q4047 | PEROBS.FlatFile.delete_obj_by_id | train | def delete_obj_by_id(id)
if (pos = find_obj_addr_by_id(id))
delete_obj_by_address(pos, id)
return true
end
return false
end | ruby | {
"resource": ""
} |
q4048 | PEROBS.FlatFile.delete_obj_by_address | train | def delete_obj_by_address(addr, id)
@index.remove(id) if @index.is_open?
header = FlatFileBlobHeader.read(@f, addr, id)
header.clear_flags
@space_list.add_space(addr, header.length) if @space_list.is_open?
end | ruby | {
"resource": ""
} |
q4049 | PEROBS.FlatFile.delete_unmarked_objects | train | def delete_unmarked_objects
# We don't update the index and the space list during this operation as
# we defragmentize the blob file at the end. We'll end the operation
# with an empty space list.
clear_index_files
deleted_objects_count = 0
@progressmeter.start('Sweeping unmarked ob... | ruby | {
"resource": ""
} |
q4050 | PEROBS.FlatFile.write_obj_by_id | train | def write_obj_by_id(id, raw_obj)
# Check if we have already an object with the given ID. We'll mark it as
# outdated and save the header for later deletion. In case this
# operation is aborted or interrupted we ensure that we either have the
# old or the new version available.
if (old_addr... | ruby | {
"resource": ""
} |
q4051 | PEROBS.FlatFile.read_obj_by_address | train | def read_obj_by_address(addr, id)
header = FlatFileBlobHeader.read(@f, addr, id)
if header.id != id
PEROBS.log.fatal "Database index corrupted: Index for object " +
"#{id} points to object with ID #{header.id}"
end
buf = nil
begin
@f.seek(addr + FlatFileBlobHead... | ruby | {
"resource": ""
} |
q4052 | PEROBS.FlatFile.defragmentize | train | def defragmentize
distance = 0
new_file_size = 0
deleted_blobs = 0
corrupted_blobs = 0
valid_blobs = 0
# Iterate over all entries.
@progressmeter.start('Defragmentizing blobs file', @f.size) do |pm|
each_blob_header do |header|
# If we have stumbled over a co... | ruby | {
"resource": ""
} |
q4053 | PEROBS.FlatFile.refresh | train | def refresh
# This iteration might look scary as we iterate over the entries while
# while we are rearranging them. Re-inserted items may be inserted
# before or at the current entry and this is fine. They also may be
# inserted after the current entry and will be re-read again unless they
... | ruby | {
"resource": ""
} |
q4054 | PEROBS.FlatFile.regenerate_index_and_spaces | train | def regenerate_index_and_spaces
PEROBS.log.warn "Re-generating FlatFileDB index and space files"
@index.open unless @index.is_open?
@index.clear
@space_list.open unless @space_list.is_open?
@space_list.clear
@progressmeter.start('Re-generating database index', @f.size) do |pm|
... | ruby | {
"resource": ""
} |
q4055 | Chicago.RakeTasks.define | train | def define
namespace :db do
desc "Write Null dimension records"
task :create_null_records do
# TODO: replace this with proper logging.
warn "Loading NULL records."
@schema.dimensions.each do |dimension|
dimension.create_null_records(@staging_db)
... | ruby | {
"resource": ""
} |
q4056 | PEROBS.LockFile.lock | train | def lock
retries = @max_retries
while retries > 0
begin
@file = File.open(@file_name, File::RDWR | File::CREAT, 0644)
@file.sync = true
if @file.flock(File::LOCK_EX | File::LOCK_NB)
# We have taken the lock. Write the PID into the file and leave it
... | ruby | {
"resource": ""
} |
q4057 | PEROBS.LockFile.unlock | train | def unlock
unless @file
PEROBS.log.error "There is no current lock to release"
return false
end
begin
@file.flock(File::LOCK_UN)
@file.fsync
@file.close
forced_unlock
PEROBS.log.debug "Lock file #{@file_name} for PID #{$$} has been " +
... | ruby | {
"resource": ""
} |
q4058 | PEROBS.LockFile.forced_unlock | train | def forced_unlock
@file = nil
if File.exist?(@file_name)
begin
File.delete(@file_name)
PEROBS.log.debug "Lock file #{@file_name} has been deleted."
rescue IOError => e
PEROBS.log.error "Cannot delete lock file #{@file_name}: " +
e.message
end... | ruby | {
"resource": ""
} |
q4059 | Wmctile.Router.window | train | def window(index = 0)
if @arguments[:use_active_window]
Window.new(@arguments, Wmctile.current_window_id)
else
Window.new(@arguments, @window_strings[index])
end
rescue Errors::WindowNotFound
if @arguments[:exec]
# Exec the command
puts "Executing command: #{@... | ruby | {
"resource": ""
} |
q4060 | Wmctile.Router.switch_to_workspace | train | def switch_to_workspace(target_workspace)
if target_workspace == 'next'
target_workspace = Wmctile.current_workspace + 1
elsif target_workspace == 'previous'
target_workspace = Wmctile.current_workspace - 1
elsif target_workspace == 'history'
# must be -2 as -1 is the current w... | ruby | {
"resource": ""
} |
q4061 | StateManager.Base.transition_to | train | def transition_to(path, current_state=self.current_state)
path = path.to_s
state = current_state || self
exit_states = []
# Find the nearest parent state on the path of the current state which
# has a sub-state at the given path
new_states = state.find_states(path)
while(!new_... | ruby | {
"resource": ""
} |
q4062 | StateManager.Base.available_events | train | def available_events
state = current_state
ret = {}
while(state) do
ret = state.class.specification.events.merge(ret)
state = state.parent_state
end
ret
end | ruby | {
"resource": ""
} |
q4063 | Bugzilla.Product.enterable_products | train | def enterable_products
ids = get_enterable_products
Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
end | ruby | {
"resource": ""
} |
q4064 | Bugzilla.Product.accessible_products | train | def accessible_products
ids = get_accessible_products
Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
end | ruby | {
"resource": ""
} |
q4065 | PEROBS.FlatFileDB.put_hash | train | def put_hash(name, hash)
file_name = File.join(@db_dir, name + '.json')
begin
RobustFile.write(file_name, hash.to_json)
rescue IOError => e
PEROBS.log.fatal "Cannot write hash file '#{file_name}': #{e.message}"
end
end | ruby | {
"resource": ""
} |
q4066 | PolyBelongsTo.Core.pbt_parent | train | def pbt_parent
val = pbt
if val && !pbt_id.nil?
if poly?
"#{pbt_type}".constantize.where(id: pbt_id).first
else
"#{val}".camelize.constantize.where(id: pbt_id).first
end
end
end | ruby | {
"resource": ""
} |
q4067 | PolyBelongsTo.Core.pbt_top_parent | train | def pbt_top_parent
record = self
return nil unless record.pbt_parent
no_repeat = PolyBelongsTo::SingletonSet.new
while !no_repeat.include?(record.pbt_parent) && !record.pbt_parent.nil?
no_repeat.add?(record)
record = record.pbt_parent
end
record
end | ruby | {
"resource": ""
} |
q4068 | PolyBelongsTo.Core.pbt_parents | train | def pbt_parents
if poly?
Array[pbt_parent].compact
else
self.class.pbts.map do |i|
try{ "#{i}".camelize.constantize.where(id: send("#{i}_id")).first }
end.compact
end
end | ruby | {
"resource": ""
} |
q4069 | NdrSupport.Password.valid? | train | def valid?(string, word_list: [])
string = prepare_string(string.to_s.dup)
slug = slugify(strip_common_words(string, word_list))
meets_requirements?(slug)
end | ruby | {
"resource": ""
} |
q4070 | Synvert::Core.Rewriter.add_file | train | def add_file(filename, content)
return if @sandbox
filepath = File.join(Configuration.instance.get(:path), filename)
if File.exist?(filepath)
puts "File #{filepath} already exists."
return
end
FileUtils.mkdir_p File.dirname(filepath)
File.open filepath, 'w' do |file... | ruby | {
"resource": ""
} |
q4071 | Synvert::Core.Rewriter.remove_file | train | def remove_file(filename)
return if @sandbox
file_path = File.join(Configuration.instance.get(:path), filename)
File.delete(file_path) if File.exist?(file_path)
end | ruby | {
"resource": ""
} |
q4072 | EPPClient.Connection.open_connection | train | def open_connection
@tcpserver = TCPSocket.new(server, port)
@socket = OpenSSL::SSL::SSLSocket.new(@tcpserver, @context)
# Synchronously close the connection & socket
@socket.sync_close
# Connect
@socket.connect
# Get the initial greeting frame
greeting_process(one_fra... | ruby | {
"resource": ""
} |
q4073 | EPPClient.Connection.close_connection | train | def close_connection
if defined?(@socket) && @socket.is_a?(OpenSSL::SSL::SSLSocket)
@socket.close
@socket = nil
end
if defined?(@tcpserver) && @tcpserver.is_a?(TCPSocket)
@tcpserver.close
@tcpserver = nil
end
return true if @tcpserver.nil? && @socket.nil?
... | ruby | {
"resource": ""
} |
q4074 | EPPClient.Connection.one_frame | train | def one_frame
size = @socket.read(4)
raise SocketError, @socket.eof? ? 'Connection closed by remote server' : 'Error reading frame from remote server' if size.nil?
size = size.unpack('N')[0]
@recv_frame = @socket.read(size - 4)
recv_frame_to_xml
end | ruby | {
"resource": ""
} |
q4075 | Snogmetrics.KissmetricsApi.identify | train | def identify(identity)
unless @session[:km_identity] == identity
queue.delete_if { |e| e.first == 'identify' }
queue << ['identify', identity]
@session[:km_identity] = identity
end
end | ruby | {
"resource": ""
} |
q4076 | GoogleVoice.Api.sms | train | def sms(remote_number, text_message)
login unless logged_in?
remote_number = validate_number(remote_number)
text_message = @coder.encode(text_message)
@agent.post('https://www.google.com/voice/sms/send/', :id => '', :phoneNumber => remote_number, :text => text_message, "_rnr_se" => @rnr_se)
... | ruby | {
"resource": ""
} |
q4077 | GoogleVoice.Api.call | train | def call(remote_number, forwarding_number)
login unless logged_in?
remote_number = validate_number(remote_number)
forwarding_number = validate_number(forwarding_number)
@agent.post('https://www.google.com/voice/call/connect/', :outgoingNumber => remote_number, :forwardingNumber => forwarding_num... | ruby | {
"resource": ""
} |
q4078 | GoogleVoice.Api.init_xml_methods | train | def init_xml_methods()
(class << self; self; end).class_eval do
%w{ unread inbox starred all spam trash voicemail sms trash recorded placed received missed }.each do |method|
define_method "#{method}_xml".to_sym do
get_xml_document("https://www.google.com/voice/inbox/recent/#{method}... | ruby | {
"resource": ""
} |
q4079 | QuickBase.Client.setHTTPConnection | train | def setHTTPConnection( useSSL, org = "www", domain = "quickbase", proxy_options = nil )
@useSSL = useSSL
@org = org
@domain = domain
if USING_HTTPCLIENT
if proxy_options
@httpConnection = HTTPClient.new( "#{proxy_options["proxy_server"]}:#{proxy_options["proxy_port"] || ... | ruby | {
"resource": ""
} |
q4080 | QuickBase.Client.setHTTPConnectionAndqbhost | train | def setHTTPConnectionAndqbhost( useSSL, org = "www", domain = "quickbase", proxy_options = nil )
setHTTPConnection( useSSL, org, domain, proxy_options )
setqbhost( useSSL, org, domain )
end | ruby | {
"resource": ""
} |
q4081 | QuickBase.Client.sendRequest | train | def sendRequest( api_Request, xmlRequestData = nil )
fire( "onSendRequest" )
resetErrorInfo
# set up the request
getDBforRequestURL( api_Request )
getAuthenticationXMLforRequest( api_Request )
isHTMLRequest = isHTMLRequest?( api_Request )
api_Request = "API_" + api... | ruby | {
"resource": ""
} |
q4082 | QuickBase.Client.prependAPI? | train | def prependAPI?( request )
ret = true
ret = false if request.to_s.include?("API_") or request.to_s.include?("QBIS_")
ret
end | ruby | {
"resource": ""
} |
q4083 | QuickBase.Client.toggleTraceInfo | train | def toggleTraceInfo( showTrace )
if showTrace
# this will print a very large amount of stuff
set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname }
if block_given?
yield
set_tra... | ruby | {
"resource": ""
} |
q4084 | QuickBase.Client.getErrorInfoFromResponse | train | def getErrorInfoFromResponse
if @responseXMLdoc
errcode = getResponseValue( :errcode )
@errcode = errcode ? errcode : ""
errtext = getResponseValue( :errtext )
@errtext = errtext ? errtext : ""
errdetail = getResponseValue( :errdetail )
@errdetail = err... | ruby | {
"resource": ""
} |
q4085 | QuickBase.Client.parseResponseXML | train | def parseResponseXML( xml )
if xml
xml.gsub!( "\r", "" ) if @ignoreCR and @ignoreCR == true
xml.gsub!( "\n", "" ) if @ignoreLF and @ignoreLF == true
xml.gsub!( "\t", "" ) if @ignoreTAB and @ignoreTAB == true
xml.gsub!( "<BR/>", "<BR/>" ) if @escapeBR
@qdbap... | ruby | {
"resource": ""
} |
q4086 | QuickBase.Client.getResponseValue | train | def getResponseValue( field )
@fieldValue = nil
if field and @responseXMLdoc
@fieldValue = @responseXMLdoc.root.elements[ field.to_s ]
@fieldValue = fieldValue.text if fieldValue and fieldValue.has_text?
end
@fieldValue
end | ruby | {
"resource": ""
} |
q4087 | QuickBase.Client.getResponsePathValues | train | def getResponsePathValues( path )
@fieldValue = ""
e = getResponseElements( path )
e.each{ |e| @fieldValue << e.text if e and e.is_a?( REXML::Element ) and e.has_text? }
@fieldValue
end | ruby | {
"resource": ""
} |
q4088 | QuickBase.Client.getResponsePathValueByDBName | train | def getResponsePathValueByDBName ( path, dbName)
@fieldValue = ""
if path and @responseXMLdoc
e = @responseXMLdoc.root.elements[ path.to_s ]
end
e.each { |e|
if e and e.is_a?( REXML::Element ) and e.dbinfo.dbname == dbName
return e.dbinfo.dbid
end
... | ruby | {
"resource": ""
} |
q4089 | QuickBase.Client.getAttributeString | train | def getAttributeString( element )
attributes = ""
if element.is_a?( REXML::Element ) and element.has_attributes?
attributes = "("
element.attributes.each { |name,value|
attributes << "#{name}=#{value} "
}
attributes << ")"
end
attributes
... | ruby | {
"resource": ""
} |
q4090 | QuickBase.Client.lookupFieldName | train | def lookupFieldName( element )
name = ""
if element and element.is_a?( REXML::Element )
name = element.name
if element.name == "f" and @fields
fid = element.attributes[ "id" ]
field = lookupField( fid ) if fid
label = field.elements[ "label" ] if ... | ruby | {
"resource": ""
} |
q4091 | QuickBase.Client.lookupFieldType | train | def lookupFieldType( element )
type = ""
if element and element.is_a?( REXML::Element )
if element.name == "f" and @fields
fid = element.attributes[ "id" ]
field = lookupField( fid ) if fid
type = field.attributes[ "field_type" ] if field
end
... | ruby | {
"resource": ""
} |
q4092 | QuickBase.Client.lookupFieldPropertyByName | train | def lookupFieldPropertyByName( fieldName, property )
theproperty = nil
if isValidFieldProperty?(property)
fid = lookupFieldIDByName( fieldName )
field = lookupField( fid ) if fid
theproperty = field.elements[ property ] if field
theproperty = theproperty.text if the... | ruby | {
"resource": ""
} |
q4093 | QuickBase.Client.isRecordidField? | train | def isRecordidField?( fid )
fields = lookupFieldsByType( "recordid" )
(fields and fields.last and fields.last.attributes[ "id" ] == fid)
end | ruby | {
"resource": ""
} |
q4094 | QuickBase.Client.formatFieldValue | train | def formatFieldValue( value, type, options = nil )
if value and type
case type
when "date"
value = formatDate( value )
when "date / time","timestamp"
value = formatDate( value, "%m-%d-%Y %I:%M %p" )
when "timeofday"
... | ruby | {
"resource": ""
} |
q4095 | QuickBase.Client.findElementByAttributeValue | train | def findElementByAttributeValue( elements, attribute_name, attribute_value )
element = nil
if elements
if elements.is_a?( REXML::Element )
elements.each_element_with_attribute( attribute_name, attribute_value ) { |e| element = e }
elsif elements.is_a?( Array )
... | ruby | {
"resource": ""
} |
q4096 | QuickBase.Client.findElementsByAttributeName | train | def findElementsByAttributeName( elements, attribute_name )
elementArray = []
if elements
elements.each_element_with_attribute( attribute_name ) { |e| elementArray << e }
end
elementArray
end | ruby | {
"resource": ""
} |
q4097 | QuickBase.Client.lookupFieldData | train | def lookupFieldData( fid )
@field_data = nil
if @field_data_list
@field_data_list.each{ |field|
if field and field.is_a?( REXML::Element ) and field.has_elements?
fieldid = field.elements[ "fid" ]
if fieldid and fieldid.has_text? and fieldid.text == f... | ruby | {
"resource": ""
} |
q4098 | QuickBase.Client.getFieldDataValue | train | def getFieldDataValue(fid)
value = nil
if @field_data_list
field_data = lookupFieldData(fid)
if field_data
valueElement = field_data.elements[ "value" ]
value = valueElement.text if valueElement.has_text?
end
end
value
end | ruby | {
"resource": ""
} |
q4099 | QuickBase.Client.getFieldDataPrintableValue | train | def getFieldDataPrintableValue(fid)
printable = nil
if @field_data_list
field_data = lookupFieldData(fid)
if field_data
printableElement = field_data.elements[ "printable" ]
printable = printableElement.text if printableElement and printableElement.has_text?
... | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.