_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q27400
Koi.Entity.method_missing
test
def method_missing meth, *args, &blk if meth.to_s.end_with?('?') && Status.include?(s = meth.to_s.chop.to_sym)
ruby
{ "resource": "" }
q27401
AMEE.Connection.v3_get
test
def v3_get(path, options = {}) # Create request parameters get_params = { :method => "get" } get_params[:params] = options unless options.empty?
ruby
{ "resource": "" }
q27402
AMEE.Connection.v3_put
test
def v3_put(path, options = {}) # Expire cached objects from parent on down expire_matching "#{parent_path(path)}.*" # Create request parameters put_params = { :method => "put", :body => options[:body] ? options[:body] : form_encode(options) } if options[:content_type]
ruby
{ "resource": "" }
q27403
AMEE.Connection.v3_do_request
test
def v3_do_request(params, path, options = {}) req = Typhoeus::Request.new("https://#{v3_hostname}#{path}", v3_defaults.merge(params)) response =
ruby
{ "resource": "" }
q27404
FastTCPN.TimedPlace.add
test
def add(token, timestamp = nil) @net.call_callbacks(:place, :add, Event.new(@name, [token], @net)) unless @net.nil? if timestamp.nil?
ruby
{ "resource": "" }
q27405
DevTrainingBot.GoogleDriveService.authorize
test
def authorize client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH) token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH) authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store) user_id = 'default' credentials = authorizer.get_credentials(user_id) if credentials.nil? url = authorizer.get_authorization_url(base_url: OOB_URI) puts 'Open the following URL in
ruby
{ "resource": "" }
q27406
AMEE.Connection.get
test
def get(path, data = {}) # Allow format override format = data.delete(:format) || @format # Add parameters to URL query string get_params = { :method => "get", :verbose => DEBUG } get_params[:params] = data unless data.empty?
ruby
{ "resource": "" }
q27407
AMEE.Connection.post
test
def post(path, data = {}) # Allow format override format = data.delete(:format) || @format # Clear cache expire_matching "#{raw_path(path)}.*" # Extract return unit params query_params = {} query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit] query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit] # Create POST request post_params = {
ruby
{ "resource": "" }
q27408
AMEE.Connection.raw_post
test
def raw_post(path, body, options = {}) # Allow format override format = options.delete(:format) || @format # Clear cache expire_matching "#{raw_path(path)}.*" # Create POST request post = Typhoeus::Request.new("#{protocol}#{@server}#{path}", :verbose => DEBUG, :method => "post",
ruby
{ "resource": "" }
q27409
AMEE.Connection.put
test
def put(path, data = {}) # Allow format override format = data.delete(:format) || @format # Clear cache expire_matching "#{parent_path(path)}.*" # Extract return unit params query_params = {} query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit] query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit] # Create PUT request put_params = {
ruby
{ "resource": "" }
q27410
AMEE.Connection.raw_put
test
def raw_put(path, body, options = {}) # Allow format override format = options.delete(:format) || @format # Clear cache expire_matching "#{parent_path(path)}.*" # Create PUT request put = Typhoeus::Request.new("#{protocol}#{@server}#{path}", :verbose => DEBUG, :method => "put",
ruby
{ "resource": "" }
q27411
AMEE.Connection.authenticate
test
def authenticate # :x_amee_source = "X-AMEE-Source".to_sym request = Typhoeus::Request.new("#{protocol}#{@server}/auth/signIn", :method => "post", :verbose => DEBUG, :headers => { :Accept => content_type(:xml), }, :body => form_encode(:username=>@username, :password=>@password) ) hydra.queue(request) hydra.run response = request.response @auth_token = response.headers_hash['AuthToken'] d {request.url} d {response.code} d {@auth_token} connection_failed if response.code == 0 unless authenticated? raise AMEE::AuthFailed.new("Authentication failed. Please check your username and password. (tried #{@username},#{@password})") end
ruby
{ "resource": "" }
q27412
AMEE.Connection.response_ok?
test
def response_ok?(response, request) # first allow for debugging d {request.object_id} d {request} d {response.object_id} d {response.code} d {response.headers_hash} d {response.body} case response.code.to_i when 502, 503, 504 raise AMEE::ConnectionFailed.new("A connection error occurred while talking to AMEE: HTTP response code #{response.code}.\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}") when 408 raise AMEE::TimeOut.new("Request timed out.") when 404 raise AMEE::NotFound.new("The URL was not found on the server.\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}") when 403 raise AMEE::PermissionDenied.new("You do not have permission to perform the requested operation.\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}\n#{request.body}\Response: #{response.body}") when 401 authenticate return false when 400 if response.body.include? "would have resulted in a duplicate resource being created" raise AMEE::DuplicateResource.new("The
ruby
{ "resource": "" }
q27413
AMEE.Connection.do_request
test
def do_request(request, format = @format, options = {}) # Is this a v3 request? v3_request = request.url.include?("/#{v3_hostname}/") # make sure we have our auth token before we start # any v1 or v2 requests if !@auth_token && !v3_request d "Authenticating first before we hit #{request.url}" authenticate
ruby
{ "resource": "" }
q27414
AMEE.Connection.run_request
test
def run_request(request, format) # Is this a v3 request? v3_request = request.url.include?("/#{v3_hostname}/") # Execute with retries retries = [1] * @retries begin begin d "Queuing the request for #{request.url}" add_authentication_to(request) if @auth_token && !v3_request hydra.queue request hydra.run # Return response if OK end while !response_ok?(request.response, request) # Store updated authToken @auth_token
ruby
{ "resource": "" }
q27415
FastTCPN.TCPN.timed_place
test
def timed_place(name, keys = {}) place = create_or_find_place(name,
ruby
{ "resource": "" }
q27416
FastTCPN.TCPN.transition
test
def transition(name) t = find_transition name if t.nil?
ruby
{ "resource": "" }
q27417
FastTCPN.TCPN.sim
test
def sim @stopped = catch :stop_simulation do begin fired = fire_transitions advanced = move_clock_to find_next_time end while fired || advanced
ruby
{ "resource": "" }
q27418
FastTCPN.Transition.output
test
def output(place, &block) raise "This is not a Place object!" unless place.kind_of? Place raise "Tried to define output arc without
ruby
{ "resource": "" }
q27419
FastTCPN.Transition.fire
test
def fire(clock = 0) # Marking is shuffled each time before it is # used so here we can take first found binding mapping = Enumerator.new do |y| get_sentry.call(input_markings, clock, y) end.first return false if mapping.nil? tcpn_binding = TCPNBinding.new mapping, input_markings call_callbacks :before, Event.new(@name, tcpn_binding, clock, @net) tokens_for_outputs = @outputs.map do |o| o.block.call(tcpn_binding, clock) end mapping.each do |place_name, token| unless token.kind_of? Token t = if token.instance_of? Array token else [ token ] end t.each do |t| unless t.kind_of? Token raise InvalidToken.new("#{t.inspect} put by sentry for transition `#{name}` in binding for `#{place_name}`")
ruby
{ "resource": "" }
q27420
ArtTypograf.Client.send_request
test
def send_request(text) begin request = Net::HTTP::Post.new(@url.path, { 'Content-Type' => 'text/xml', 'SOAPAction' => '"http://typograf.artlebedev.ru/webservices/ProcessText"' }) request.body = form_xml(text, @options) response = Net::HTTP.new(@url.host, @url.port).start do |http| http.request(request) end rescue StandardError => exception raise NetworkError.new(exception.message, exception.backtrace)
ruby
{ "resource": "" }
q27421
Beaker.Librarian.install_librarian
test
def install_librarian(opts = {}) # Check for 'librarian_version' option librarian_version = opts[:librarian_version] ||= nil hosts.each do |host| install_package host, 'rubygems' install_package host, 'git' if librarian_version on host, "gem install
ruby
{ "resource": "" }
q27422
Beaker.Librarian.librarian_install_modules
test
def librarian_install_modules(directory, module_name) hosts.each do |host| sut_dir = File.join('/tmp', module_name) scp_to host, directory, sut_dir on host, "cd #{sut_dir} && librarian-puppet install --clean
ruby
{ "resource": "" }
q27423
Sigimera.Client.get_crisis
test
def get_crisis(identifier, params = nil) return nil if identifier.nil? or identifier.empty? endpoint = "/v1/crises/#{identifier}.json?auth_token=#{@auth_token}"
ruby
{ "resource": "" }
q27424
Sigimera.Client.get_crises_stat
test
def get_crises_stat response = self.get("/v1/stats/crises.json?auth_token=#{@auth_token}")
ruby
{ "resource": "" }
q27425
Sigimera.Client.get_user_stat
test
def get_user_stat response = self.get("/v1/stats/users.json?auth_token=#{@auth_token}")
ruby
{ "resource": "" }
q27426
Pose.ActiveRecordBaseAdditions.posify
test
def posify *source_methods, &block include ModelClassAdditions self.pose_content = proc do text_chunks =
ruby
{ "resource": "" }
q27427
FastTCPN.HashMarking.add
test
def add(objects) unless objects.kind_of? Array objects = [ objects ] end objects.each do |object|
ruby
{ "resource": "" }
q27428
FastTCPN.HashMarking.delete
test
def delete(tokens) unless tokens.instance_of? Array tokens = [ tokens ] end removed = tokens.map do |token|
ruby
{ "resource": "" }
q27429
Pose.Search.add_joins
test
def add_joins arel @query.joins.inject(arel) do |memo, join_data|
ruby
{ "resource": "" }
q27430
Pose.Search.add_wheres
test
def add_wheres arel @query.where.inject(arel) { |memo,
ruby
{ "resource": "" }
q27431
Pose.Search.load_classes
test
def load_classes result return if @query.ids_requested? result.each do |clazz, ids| if ids.size > 0
ruby
{ "resource": "" }
q27432
Pose.Search.search_word
test
def search_word word empty_result.tap do |result| data = Assignment.joins(:word) \ .select('pose_assignments.posable_id, pose_assignments.posable_type') \ .where('pose_words.text LIKE ?', "#{word}%") \
ruby
{ "resource": "" }
q27433
Pose.Search.search_words
test
def search_words {}.tap do |result| @query.query_words.each do |query_word| search_word(query_word).each do
ruby
{ "resource": "" }
q27434
GoogleSpreadsheets.Connection.client_login_authorization_header
test
def client_login_authorization_header(http_method, uri) if @user && @password && !@auth_token email = CGI.escape(@user) password = CGI.escape(@password) http = Net::HTTP.new('www.google.com', 443) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE resp, data = http.post('/accounts/ClientLogin', "accountType=HOSTED_OR_GOOGLE&Email=#{email}&Passwd=#{password}&service=wise",
ruby
{ "resource": "" }
q27435
Dev.Project.app_folder
test
def app_folder(app_name = self.current_app) if self.type == :multi if app_name.in? self.main_apps "#{self.folder}/main_apps/#{app_name}" elsif app_name.in? self.engines
ruby
{ "resource": "" }
q27436
Dev.Project.app_version_file
test
def app_version_file(app_name = self.current_app) Dir.glob("#{app_folder(app_name)}/lib/**/version.rb").min_by
ruby
{ "resource": "" }
q27437
Dev.Project.app_version
test
def app_version(app_name = self.current_app) if File.exists? app_version_file(app_name).to_s File.read(app_version_file(app_name)) .match(/VERSION = '([0-9\.]+)'\n/)
ruby
{ "resource": "" }
q27438
Dev.Project.bump_app_version_to
test
def bump_app_version_to(version) if File.exists? self.app_version_file version_file = self.app_version_file version_content = File.read("#{version_file}") File.open(version_file, 'w+') do |f|
ruby
{ "resource": "" }
q27439
Dev.Executable.load_project
test
def load_project config_file = Dir.glob("#{Dir.pwd}/**/dev.yml").first raise ExecutionError.new "No valid configuration files found. Searched for a file named 'dev.yml' "\ "in
ruby
{ "resource": "" }
q27440
Dev.Executable.help
test
def help puts print "Dev".green print " - available commands:\n" puts print "\tversion\t\t".limegreen print "Prints current version.\n" puts print "\tfeature\t\t".limegreen print "Opens or closes a feature for the current app.\n" print "\t\t\tWarning: the app is determined from the current working directory!\n" print "\t\t\tExample: " print "dev feature open my-new-feature".springgreen print " (opens a new feature for the current app)" print ".\n" print "\t\t\tExample: " print "dev feature close my-new-feature".springgreen print " (closes a developed new feature for the current app)" print ".\n" puts print "\thotfix\t\t".limegreen print "Opens or closes a hotfix for the current app.\n" print "\t\t\tWarning: the app is determined from the current working directory!\n" print "\t\t\tExample: " print "dev hotfix open 0.2.1".springgreen print " (opens a new hotfix for the current app)" print ".\n" print "\t\t\tExample: " print "dev hotfix close 0.2.1".springgreen print " (closes a developed new hotfix for the current app)" print ".\n"
ruby
{ "resource": "" }
q27441
FastTCPN.TimedHashMarking.add
test
def add(objects, timestamp = @time) unless objects.kind_of? Array objects = [ objects ] end objects.each do |object| if object.instance_of? Hash timestamp = object[:ts] || 0 object = object[:val] end token =
ruby
{ "resource": "" }
q27442
FastTCPN.TimedHashMarking.time=
test
def time=(time) if time < @time raise InvalidTime.new("You are trying to put back clock from #{@time} back to #{time}") end @time = time @waiting.keys.sort.each do |timestamp| if timestamp > @time @next_time = timestamp
ruby
{ "resource": "" }
q27443
EventMachine.WebSocketClient.send_message
test
def send_message data, binary=false if established? unless @closing @socket.send_data(@encoder.encode(data.to_s, binary ? BINARY_FRAME : TEXT_FRAME)) end
ruby
{ "resource": "" }
q27444
RubyMeetup.AuthenticatedClient.post
test
def post(options) uri = new_uri params = merge_params(options) response = Net::HTTP.post_form(uri, params) unless response.is_a?(Net::HTTPSuccess)
ruby
{ "resource": "" }
q27445
RubyMeetup.AuthenticatedClient.delete
test
def delete(options={}) uri = new_uri params = merge_params(options) uri.query = URI.encode_www_form(params) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Delete.new(uri) # uri or uri.request_uri? response = http.request(request)
ruby
{ "resource": "" }
q27446
Vagrantomatic.Vagrantomatic.instance_metadata
test
def instance_metadata(name) instance = instance(name) config = {} # annotate the raw config hash with data for puppet (and humans...) if instance.configured? config = instance.configfile_hash config["ensure"] = :present else
ruby
{ "resource": "" }
q27447
Vagrantomatic.Vagrantomatic.instances_metadata
test
def instances_metadata() instance_wildcard = File.join(@vagrant_vm_dir, "*", ::Vagrantomatic::Instance::VAGRANTFILE) instances = {} Dir.glob(instance_wildcard).each { |f| elements = f.split(File::SEPARATOR)
ruby
{ "resource": "" }
q27448
Scripto.CsvCommands.csv_read
test
def csv_read(path) lines = begin if path =~ /\.gz$/ Zlib::GzipReader.open(path) do |f| CSV.new(f).read end else CSV.read(path)
ruby
{ "resource": "" }
q27449
Scripto.CsvCommands.csv_write
test
def csv_write(path, rows, cols: nil) atomic_write(path) do |tmp|
ruby
{ "resource": "" }
q27450
Scripto.CsvCommands.csv_to_s
test
def csv_to_s(rows, cols: nil) string = "" f = CSV.new(StringIO.new(string))
ruby
{ "resource": "" }
q27451
RustyJson.RustStruct.add_value
test
def add_value(name, type, subtype = nil) if type.class == RustyJson::RustStruct || subtype.class == RustyJson::RustStruct if type.class == RustyJson::RustStruct t = type type = type.name
ruby
{ "resource": "" }
q27452
RodeoClown.ELB.rotate
test
def rotate(hsh) current_ec2, new_ec2 = hsh.first cur_instances = EC2.by_tags("Name" => current_ec2.to_s) new_instances = EC2.by_tags("Name" => new_ec2.to_s)
ruby
{ "resource": "" }
q27453
RodeoClown.ELB.wait_for_state
test
def wait_for_state(instances, exp_state) time = 0 all_good = false loop do all_good = instances.all? do |i| state = i.elb_health[:state] puts "#{i.id}: #{state}" exp_state == state end break if all_good || time > timeout sleep 1 time += 1 end
ruby
{ "resource": "" }
q27454
OWNet.RawConnection.read
test
def read(path) owconnect do |socket| owwrite(socket,:path => path, :function => READ)
ruby
{ "resource": "" }
q27455
OWNet.RawConnection.write
test
def write(path, value) owconnect do |socket| owwrite(socket, :path => path, :value => value.to_s, :function => WRITE)
ruby
{ "resource": "" }
q27456
OWNet.RawConnection.dir
test
def dir(path) owconnect do |socket| owwrite(socket,:path => path, :function => DIR) fields = [] while true response = owread(socket) if response.data
ruby
{ "resource": "" }
q27457
Praxis::Mapper.QueryStatistics.sum_totals_by_model
test
def sum_totals_by_model @sum_totals_by_model ||= begin totals = Hash.new { |hash, key| hash[key] = Hash.new(0) } @queries_by_model.each do |model, queries| totals[model][:query_count] = queries.length queries.each do |query| query.statistics.each do |stat, value|
ruby
{ "resource": "" }
q27458
Praxis::Mapper.QueryStatistics.sum_totals
test
def sum_totals @sum_totals ||= begin totals = Hash.new(0) sum_totals_by_model.each do |_, model_totals| model_totals.each do |stat, value|
ruby
{ "resource": "" }
q27459
Tai64.Time.to_label
test
def to_label s = '%016x%08x' sec = tai_second ts = if sec >= 0
ruby
{ "resource": "" }
q27460
Conject.ObjectContext.put
test
def put(name, object) raise "This ObjectContext already has an instance or configuration for '#{name.to_s}'" if directly_has?(name) Conject.install_object_context(object, self)
ruby
{ "resource": "" }
q27461
Conject.ObjectContext.configure_objects
test
def configure_objects(confs={}) confs.each do |key,opts| key = key.to_sym @object_configs[key]
ruby
{ "resource": "" }
q27462
HanselCore.Httperf.httperf
test
def httperf warm_up = false httperf_cmd = build_httperf_cmd if warm_up # Do a warm up run to setup any resources status "\n#{httperf_cmd} (warm up run)" IO.popen("#{httperf_cmd} 2>&1") else IO.popen("#{httperf_cmd} 2>&1") do |pipe| status "\n#{httperf_cmd}" @results << (httperf_result = HttperfResult.new({ :rate => @current_rate, :server => @current_job.server,
ruby
{ "resource": "" }
q27463
SFKB.REST.url
test
def url(path, params = {}) params = params.inject({}, &@@stringify) path = path.gsub(@@placeholder) { params.delete($1, &@@required) }
ruby
{ "resource": "" }
q27464
SFKB.REST.url?
test
def url?(string) return false unless string.to_s =~ url_pattern return false
ruby
{ "resource": "" }
q27465
Assit.Assertions.assit_equal
test
def assit_equal(expected, actual, message = "Object expected to be equal") if(expected !=
ruby
{ "resource": "" }
q27466
Assit.Assertions.assit_kind_of
test
def assit_kind_of(klass, object, message = "Object of wrong type") if(!object.kind_of?(klass))
ruby
{ "resource": "" }
q27467
Assit.Assertions.assit_real_string
test
def assit_real_string(object, message = "Not a non-empty string.") unless(object
ruby
{ "resource": "" }
q27468
Assit.Assertions.assit_block
test
def assit_block(&block) errors = [] assit((block.call(errors)
ruby
{ "resource": "" }
q27469
QbtClient.WebUI.poll
test
def poll interval: 10, &block raise '#poll requires a block' unless block_given? response_id = 0 loop do res = self.sync response_id if res response_id =
ruby
{ "resource": "" }
q27470
QbtClient.WebUI.sync
test
def sync response_id = 0 req = self.class.get '/sync/maindata', format: :json,
ruby
{ "resource": "" }
q27471
QbtClient.WebUI.add_trackers
test
def add_trackers torrent_hash, urls urls = Array(urls) # Ampersands in urls must be escaped. urls = urls.map { |url| url.gsub('&', '%26')
ruby
{ "resource": "" }
q27472
QbtClient.WebUI.download
test
def download urls urls = Array(urls) urls = urls.join('%0A') options = { body: "urls=#{urls}"
ruby
{ "resource": "" }
q27473
QbtClient.WebUI.delete_torrent_and_data
test
def delete_torrent_and_data torrent_hashes torrent_hashes = Array(torrent_hashes) torrent_hashes = torrent_hashes.join('|') options = {
ruby
{ "resource": "" }
q27474
QbtClient.WebUI.set_location
test
def set_location(torrent_hashes, path) torrent_hashes = Array(torrent_hashes) torrent_hashes = torrent_hashes.join('|') options = {
ruby
{ "resource": "" }
q27475
QbtClient.WebUI.increase_priority
test
def increase_priority torrent_hashes torrent_hashes = Array(torrent_hashes) torrent_hashes = torrent_hashes.join('|') options = {
ruby
{ "resource": "" }
q27476
QbtClient.WebUI.decrease_priority
test
def decrease_priority torrent_hashes torrent_hashes = Array(torrent_hashes) torrent_hashes = torrent_hashes.join('|') options = {
ruby
{ "resource": "" }
q27477
QbtClient.WebUI.maximize_priority
test
def maximize_priority torrent_hashes torrent_hashes = Array(torrent_hashes) torrent_hashes = torrent_hashes.join('|') options = {
ruby
{ "resource": "" }
q27478
QbtClient.WebUI.minimize_priority
test
def minimize_priority torrent_hashes torrent_hashes = Array(torrent_hashes) torrent_hashes = torrent_hashes.join('|') options = {
ruby
{ "resource": "" }
q27479
QbtClient.WebUI.set_file_priority
test
def set_file_priority torrent_hash, file_id, priority query = ["hash=#{torrent_hash}", "id=#{file_id}", "priority=#{priority}"] options = {
ruby
{ "resource": "" }
q27480
QbtClient.WebUI.set_download_limit
test
def set_download_limit torrent_hash, limit query = ["hashes=#{torrent_hash}", "limit=#{limit}"] options = {
ruby
{ "resource": "" }
q27481
QbtClient.WebUI.set_upload_limit
test
def set_upload_limit torrent_hash, limit query = ["hashes=#{torrent_hash}", "limit=#{limit}"] options = {
ruby
{ "resource": "" }
q27482
Scripto.MiscCommands.md5_file
test
def md5_file(path) File.open(path) do |f| digest, buf = Digest::MD5.new, "" while f.read(4096, buf)
ruby
{ "resource": "" }
q27483
Risky::ListKeys.ClassMethods.keys
test
def keys(*a) if block_given? bucket.keys(*a) do |keys| # This API is currently inconsistent from protobuffs to http if keys.kind_of? Array keys.each do |key|
ruby
{ "resource": "" }
q27484
Risky::ListKeys.ClassMethods.each
test
def each bucket.keys do |keys| keys.each do |key| if x = self[key]
ruby
{ "resource": "" }
q27485
Scripto.RunCommands.run
test
def run(command, args = nil) cmd = CommandLine.new(command,
ruby
{ "resource": "" }
q27486
RSqoot.Click.clicks
test
def clicks(options = {}) options = update_by_expire_time options if clicks_not_latest?(options) @rsqoot_clicks = get('clicks', options, SqootClick) @rsqoot_clicks =
ruby
{ "resource": "" }
q27487
RodeoClown.InstanceBuilder.build_instances
test
def build_instances(template = nil) build_args = if template == :template [build_options.first.merge(count: 1)] else build_options end
ruby
{ "resource": "" }
q27488
ScopedEnum.ScopeCreator.scope
test
def scope(scope_name, scope_enum_keys) target_enum = @record_class.defined_enums[@enum_name.to_s] sub_enum_values = target_enum.values_at(*scope_enum_keys) if @record_class.defined_enum_scopes.has_key?(scope_name) fail ArgumentError, "Conflicting scope names. A scope named #{scope_name} has already been defined" elsif sub_enum_values.include?(nil) unknown_key = scope_enum_keys[sub_enum_values.index(nil)] fail ArgumentError, "Unknown key - #{unknown_key} for enum #{@enum_name}" elsif @record_class.respond_to?(scope_name.to_s.pluralize) fail ArgumentError, "Scope name - #{scope_name} conflicts with a class method of the same name" elsif @record_class.instance_methods.include?("#{scope_name}?".to_sym) fail ArgumentError, "Scope name - #{scope_name} conflicts with
ruby
{ "resource": "" }
q27489
Revenc.Settings.configure
test
def configure # config file default options configuration = { :options => { :verbose => false, :coloring => 'AUTO' }, :mount => { :source => { :name => nil }, :mountpoint => { :name => nil }, :passphrasefile => { :name => 'passphrase' }, :keyfile => { :name => 'encfs6.xml' }, :cmd => nil, :executable => nil }, :unmount => { :mountpoint => { :name => nil }, :cmd => nil, :executable => nil }, :copy => { :source => { :name => nil }, :destination => { :name => nil }, :cmd => nil, :executable => nil } } # set default config if not given on command line config = @options[:config] unless config config = [ File.join(@working_dir, "revenc.conf"),
ruby
{ "resource": "" }
q27490
Feedtosis.Client.mark_new_entries
test
def mark_new_entries(response) digests = summary_digests # For each entry in the responses object, mark @_seen as false if the # digest of this entry doesn't exist in the cached object. response.entries.each do |e|
ruby
{ "resource": "" }
q27491
Feedtosis.Client.set_header_options
test
def set_header_options(curl) summary = summary_for_feed unless summary.nil? curl.headers['If-None-Match'] = summary[:etag] unless summary[:etag].nil? curl.headers['If-Modified-Since'] =
ruby
{ "resource": "" }
q27492
Feedtosis.Client.store_summary_to_backend
test
def store_summary_to_backend(feed, curl) headers = HttpHeaders.new(curl.header_str) # Store info about HTTP retrieval summary = { } summary.merge!(:etag => headers.etag) unless headers.etag.nil? summary.merge!(:last_modified => headers.last_modified) unless headers.last_modified.nil? # Store digest for each feed entry so we can detect new feeds on the next # retrieval new_digest_set = feed.entries.map do |e| digest_for(e) end
ruby
{ "resource": "" }
q27493
Ropenstack.Rest.error_manager
test
def error_manager(uri, response) case response when Net::HTTPSuccess then # This covers cases where the response may not validate as JSON. begin data = JSON.parse(response.body) rescue data = {} end ## Get the Headers out of the response object data['headers'] = response.to_hash() return data when Net::HTTPBadRequest
ruby
{ "resource": "" }
q27494
Ropenstack.Rest.do_request
test
def do_request(uri, request, manage_errors = true, timeout = 10) begin http = build_http(uri, timeout) if(manage_errors) return error_manager(uri, http.request(request)) else http.request(request) return { "Success" => true } end rescue Timeout::Error
ruby
{ "resource": "" }
q27495
Ropenstack.Rest.get_request
test
def get_request(uri, token = nil, manage_errors = true) request = Net::HTTP::Get.new(uri.request_uri,
ruby
{ "resource": "" }
q27496
Ropenstack.Rest.delete_request
test
def delete_request(uri, token = nil, manage_errors = true) request = Net::HTTP::Delete.new(uri.request_uri, initheader =
ruby
{ "resource": "" }
q27497
Ropenstack.Rest.put_request
test
def put_request(uri, body, token = nil, manage_errors = true) request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))
ruby
{ "resource": "" }
q27498
Ropenstack.Rest.post_request
test
def post_request(uri, body, token = nil, manage_errors = true) request = Net::HTTP::Post.new(uri.request_uri, initheader = build_headers(token))
ruby
{ "resource": "" }
q27499
SFKB.Knowledge.article
test
def article(id) url = index.knowledgeManagement.articles.article
ruby
{ "resource": "" }