_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q24900
Cloudster.Cloud.get_ec2_details
train
def get_ec2_details(options = {}) stack_resources = resources(options) ec2_resource_ids = get_resource_ids(stack_resources, "AWS::EC2::Instance") ec2 = Fog::Compute::AWS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key,
ruby
{ "resource": "" }
q24901
Cloudster.Cloud.get_elb_details
train
def get_elb_details(options = {}) stack_resources = resources(options) elb_resource_ids = get_resource_ids(stack_resources, "AWS::ElasticLoadBalancing::LoadBalancer") elb = Fog::AWS::ELB.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key,
ruby
{ "resource": "" }
q24902
Cloudster.Cloud.outputs
train
def outputs(options = {}) require_options(options, [:stack_name]) stack_description = describe(:stack_name => options[:stack_name]) outputs = stack_description["Outputs"] rescue [] outputs_hash = {}
ruby
{ "resource": "" }
q24903
Cloudster.Cloud.is_s3_bucket_name_available?
train
def is_s3_bucket_name_available?(bucket_name) s3 = Fog::Storage::AWS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
ruby
{ "resource": "" }
q24904
Gattica.Convertible.to_h
train
def to_h output = {} instance_variables.each do |var| output.merge!({
ruby
{ "resource": "" }
q24905
AndroidAdb.Adb.get_devices
train
def get_devices devices = [] run_adb("devices") do |pout| pout.each do |line| line = line.strip if (!line.empty? && line
ruby
{ "resource": "" }
q24906
AndroidAdb.Adb.get_packages
train
def get_packages(adb_opts = {}) packages = [] run_adb_shell("pm list packages -f", adb_opts) do |pout| pout.each do |line| @log.debug("{stdout} #{line}") unless @log.nil? parts = line.split(":") if (parts.length > 1)
ruby
{ "resource": "" }
q24907
CelluloidPubsub.Helper.setup_celluloid_logger
train
def setup_celluloid_logger return if !debug_enabled? || (respond_to?(:log_file_path) && log_file_path.blank?)
ruby
{ "resource": "" }
q24908
CelluloidPubsub.Helper.setup_celluloid_exception_handler
train
def setup_celluloid_exception_handler Celluloid.task_class = defined?(Celluloid::TaskThread) ? Celluloid::TaskThread
ruby
{ "resource": "" }
q24909
CelluloidPubsub.Helper.setup_log_file
train
def setup_log_file return if !debug_enabled? || (respond_to?(:log_file_path) && log_file_path.blank?)
ruby
{ "resource": "" }
q24910
CelluloidPubsub.Helper.parse_options
train
def parse_options(options) options = options.is_a?(Array) ? options.first : options options
ruby
{ "resource": "" }
q24911
Dumbo.DependencyResolver.resolve
train
def resolve list = dependency_list.sort { |a, b| a.last.size <=>
ruby
{ "resource": "" }
q24912
Microdata.Itemprop.make_absolute_url
train
def make_absolute_url(url) return url unless URI.parse(url).relative?
ruby
{ "resource": "" }
q24913
Aequitas.OrderedHash.[]=
train
def []=(k, i=nil, v=nil) if v insert(i,k,v) else
ruby
{ "resource": "" }
q24914
FREDAPI.Request.request
train
def request method, path, opts={} conn_options = connection_options opts opts['api_key'] = api_key unless opts.has_key? 'api_key' opts['file_type'] = file_type unless opts.has_key? 'file_type' response = connection(conn_options).send(method) do |request| case method when :get request.url path, opts when :delete request.url path, opts when :patch, :post, :put
ruby
{ "resource": "" }
q24915
StateMachine.State.enter!
train
def enter! @state_machine.current_state = self @entry_actions.each do |entry_action| entry_action.call(@state_machine) end @transition_map.each do |type, events_to_transition_arrays|
ruby
{ "resource": "" }
q24916
StateMachine.State.exit!
train
def exit! map = @transition_map map.each do |type, events_to_transition_arrays| events_to_transition_arrays.each do |event, transitions| transitions.each(&:unarm) end end @exit_actions.each
ruby
{ "resource": "" }
q24917
StateMachine.State.cleanup
train
def cleanup @transition_map.each do |type, events_to_transition_arrays| events_to_transition_arrays.each do |event, transitions| transitions.clear end end @transition_map
ruby
{ "resource": "" }
q24918
StateMachine.State.guarded_execute
train
def guarded_execute(event_type, event_trigger_value) @state_machine.raise_outside_initial_queue return if terminating? if @transition_map[event_type].nil? || @transition_map[event_type][event_trigger_value].nil? raise ArgumentError, "No registered transition found "\ "for event #{event_type}:#{event_trigger_value}." end possible_transitions = @transition_map[event_type][event_trigger_value] return if possible_transitions.empty? allowed_transitions = possible_transitions.select(&:allowed?) if allowed_transitions.empty? @state_machine.log "All transitions are disallowed for "\ "#{event_type}:#{event_trigger_value}." elsif allowed_transitions.count > 1 list = allowed_transitions.collect do |t|
ruby
{ "resource": "" }
q24919
Gattica.User.validate
train
def validate raise GatticaError::InvalidEmail, "The email address '#{@email}' is not valid" if not @email.match(/^(?:[_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-zA-Z0-9\-\.]+)*(\.[a-z]{2,4})$/i)
ruby
{ "resource": "" }
q24920
FREDAPI.Configuration.options
train
def options OPTION_KEYS.inject({}){|o,k|o.
ruby
{ "resource": "" }
q24921
Wiki.Wiki.recent_updates
train
def recent_updates(options) default_options = { path: nil, limit: 10 } options = default_options.merge(options) limit = [options[:limit], 1].max paging_window = limit * 2 updates_hash = {} offset = 0 until updates_hash.count >= limit changes = recent_changes(options[:path], paging_window, offset) break if
ruby
{ "resource": "" }
q24922
CelluloidPubsub.Client.supervise_actors
train
def supervise_actors current_actor = Actor.current @actor.link current_actor if
ruby
{ "resource": "" }
q24923
CelluloidPubsub.Client.on_message
train
def on_message(data) message = JSON.parse(data) log_debug("#{@actor.class} received JSON #{message}")
ruby
{ "resource": "" }
q24924
CelluloidPubsub.Client.on_close
train
def on_close(code, reason) connection.terminate terminate log_debug("#{@actor.class} dispatching on close #{code} #{reason}") if @actor.respond_to?(:async)
ruby
{ "resource": "" }
q24925
CelluloidPubsub.Client.send_action
train
def send_action(action, channel = nil, data = {}) data = data.is_a?(Hash) ? data : {} publishing_data = { 'client_action' => action, 'channel' => channel, 'data'
ruby
{ "resource": "" }
q24926
CelluloidPubsub.Client.chat
train
def chat(message) final_message = message.is_a?(Hash) ? message.to_json : JSON.dump(action: 'message', message: message)
ruby
{ "resource": "" }
q24927
Travis.CLI.preparse
validation
def preparse(unparsed, args = [], opts = {}) case unparsed when Hash then opts.merge! unparsed when Array then unparsed.each { |e| preparse(e, args, opts) }
ruby
{ "resource": "" }
q24928
Scientist::Experiment.MismatchError.to_s
validation
def to_s super + ":\n" + format_observation(result.control) + "\n" + result.candidates.map {
ruby
{ "resource": "" }
q24929
RestClient.Request.process_url_params
validation
def process_url_params(url, headers) url_params = nil # find and extract/remove "params" key if the value is a Hash/ParamsArray headers.delete_if do |key, value| if key.to_s.downcase == 'params' && (value.is_a?(Hash) || value.is_a?(RestClient::ParamsArray)) if url_params raise ArgumentError.new("Multiple 'params' options passed") end url_params = value true else false end
ruby
{ "resource": "" }
q24930
RestClient.Request.stringify_headers
validation
def stringify_headers headers headers.inject({}) do |result, (key, value)| if key.is_a? Symbol key = key.to_s.split(/_/).map(&:capitalize).join('-') end if 'CONTENT-TYPE' == key.upcase result[key] = maybe_convert_extension(value.to_s) elsif 'ACCEPT' == key.upcase # Accept can be composed of several comma-separated values if value.is_a? Array target_values = value else target_values
ruby
{ "resource": "" }
q24931
RestClient.Request.maybe_convert_extension
validation
def maybe_convert_extension(ext) unless ext =~ /\A[a-zA-Z0-9_@-]+\z/ # Don't look up strings unless they look like they could be a file # extension known to mime-types. # # There currently isn't any API public way to look up extensions # directly out of MIME::Types, but the type_for() method only strips
ruby
{ "resource": "" }
q24932
RestClient.Resource.[]
validation
def [](suburl, &new_block) case when block_given? then self.class.new(concat_urls(url, suburl), options, &new_block) when block then self.class.new(concat_urls(url, suburl),
ruby
{ "resource": "" }
q24933
RestClient.AbstractResponse.cookies
validation
def cookies hash = {} cookie_jar.cookies(@request.uri).each do |cookie|
ruby
{ "resource": "" }
q24934
RestClient.AbstractResponse.cookie_jar
validation
def cookie_jar return @cookie_jar if defined?(@cookie_jar) && @cookie_jar jar = @request.cookie_jar.dup
ruby
{ "resource": "" }
q24935
RestClient.AbstractResponse.follow_get_redirection
validation
def follow_get_redirection(&block) new_args = request.args.dup new_args[:method] = :get
ruby
{ "resource": "" }
q24936
RestClient.AbstractResponse._follow_redirection
validation
def _follow_redirection(new_args, &block) # parse location header and merge into existing URL url = headers[:location] # cannot follow redirection if there is no location header unless url raise exception_with_response end # handle relative redirects unless url.start_with?('http') url = URI.parse(request.url).merge(url).to_s
ruby
{ "resource": "" }
q24937
OmniAuth.Strategy.call!
validation
def call!(env) # rubocop:disable CyclomaticComplexity, PerceivedComplexity unless env['rack.session'] error = OmniAuth::NoSessionError.new('You must provide a session to use OmniAuth.') raise(error) end @env = env @env['omniauth.strategy'] = self if on_auth_path? return mock_call!(env) if OmniAuth.config.test_mode return options_call if on_auth_path? && options_request? return request_call if
ruby
{ "resource": "" }
q24938
OmniAuth.Strategy.options_call
validation
def options_call OmniAuth.config.before_options_phase.call(env) if OmniAuth.config.before_options_phase
ruby
{ "resource": "" }
q24939
OmniAuth.Strategy.callback_call
validation
def callback_call setup_phase log :info, 'Callback phase initiated.' @env['omniauth.origin'] = session.delete('omniauth.origin') @env['omniauth.origin'] = nil if env['omniauth.origin'] == '' @env['omniauth.params'] = session.delete('omniauth.params') || {}
ruby
{ "resource": "" }
q24940
OmniAuth.Strategy.mock_call!
validation
def mock_call!(*) return mock_request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
ruby
{ "resource": "" }
q24941
GoogleAdsSavon.Model.instance_action_module
validation
def instance_action_module @instance_action_module ||= Module.new do # Returns the <tt>GoogleAdsSavon::Client</tt> from the class instance. def client(&block)
ruby
{ "resource": "" }
q24942
AdwordsApi.Api.soap_header_handler
validation
def soap_header_handler(auth_handler, version, header_ns, default_ns) auth_method = @config.read('authentication.method', :OAUTH2) handler_class = case auth_method when :OAUTH2, :OAUTH2_SERVICE_ACCOUNT AdsCommon::SavonHeaders::OAuthHeaderHandler else raise AdsCommon::Errors::AuthError,
ruby
{ "resource": "" }
q24943
AdwordsApi.Api.report_utils
validation
def report_utils(version = nil) version = api_config.default_version if version.nil? # Check if version exists.
ruby
{ "resource": "" }
q24944
AdwordsApi.Api.batch_job_utils
validation
def batch_job_utils(version = nil) version = api_config.default_version if version.nil? # Check if version exists.
ruby
{ "resource": "" }
q24945
AdwordsApi.Api.run_with_temporary_flag
validation
def run_with_temporary_flag(flag_name, flag_value, block) previous = @credential_handler.instance_variable_get(flag_name) @credential_handler.instance_variable_set(flag_name, flag_value) begin return block.call
ruby
{ "resource": "" }
q24946
AdsCommon.ParametersValidator.validate_arguments
validation
def validate_arguments(args_hash, fields_list, type_ns = nil) check_extra_fields(args_hash, array_from_named_list(fields_list)) add_order_key(args_hash, fields_list) fields_list.each do |field| key = field[:name] item = args_hash[key] check_required_argument_present(item, field) unless item.nil? original_name = field[:original_name] if original_name key = handle_name_override(args_hash, key, original_name) end item_type = get_full_type_signature(field[:type]) item_ns = field[:ns] || type_ns key = handle_namespace_override(args_hash, key, item_ns) if
ruby
{ "resource": "" }
q24947
AdsCommon.ParametersValidator.validate_choice_argument
validation
def validate_choice_argument(item, parent, key, item_type) result = false if item_type.kind_of?(Hash) && item_type.include?(:choices) # If we have an array of choices, we need to go over them individually. # We drop original array and replace it with the generated one that's # nested one level more. if item.kind_of?(Array) parent[key] = [] item.each do |sub_item| unless validate_choice_argument(sub_item, parent, key, item_type) validate_arg(sub_item, parent, key, item_type) end end return true end # New root needed for extra nesting we have (choice field). new_root = {} choice_items = arrayize(item) choice_items.each do |choice_item| choice_type = choice_item.delete(:xsi_type) choice_item_type = find_choice_by_xsi_type(choice_type, item_type[:choices]) if choice_type.nil? || choice_item_type.nil? raise AdsCommon::Errors::TypeMismatchError.new( 'choice subtype', choice_type, choice_item.to_s()) end choice_item[:xsi_type] = choice_type # Note we use original name that produces a string like
ruby
{ "resource": "" }
q24948
AdsCommon.ParametersValidator.check_extra_fields
validation
def check_extra_fields(args_hash, known_fields) extra_fields = args_hash.keys - known_fields - IGNORED_HASH_KEYS unless extra_fields.empty?
ruby
{ "resource": "" }
q24949
AdsCommon.ParametersValidator.check_required_argument_present
validation
def check_required_argument_present(arg, field) # At least one item required, none passed. if field[:min_occurs] > 0 and arg.nil? raise AdsCommon::Errors::MissingPropertyError.new( field[:name], field[:type]) end # An object passed when an array is expected.
ruby
{ "resource": "" }
q24950
AdsCommon.ParametersValidator.handle_name_override
validation
def handle_name_override(args, key, original_name) rename_hash_key(args,
ruby
{ "resource": "" }
q24951
AdsCommon.ParametersValidator.handle_namespace_override
validation
def handle_namespace_override(args, key, ns) add_extra_namespace(ns) new_key = prefix_key_with_namespace(key.to_s.lower_camelcase, ns) rename_hash_key(args, key,
ruby
{ "resource": "" }
q24952
AdsCommon.ParametersValidator.validate_arg
validation
def validate_arg(arg, parent, key, arg_type) result = case arg when Array validate_array_arg(arg, parent, key, arg_type) when Hash validate_hash_arg(arg, parent, key, arg_type) when Time arg = validate_time_arg(arg,
ruby
{ "resource": "" }
q24953
AdsCommon.ParametersValidator.validate_array_arg
validation
def validate_array_arg(arg, parent, key, arg_type) result = arg.map do |item|
ruby
{ "resource": "" }
q24954
AdsCommon.ParametersValidator.validate_hash_arg
validation
def validate_hash_arg(arg, parent, key, arg_type) arg_type = handle_xsi_type(arg, parent, key, arg_type)
ruby
{ "resource": "" }
q24955
AdsCommon.ParametersValidator.validate_time_arg
validation
def validate_time_arg(arg, parent, key) xml_value =
ruby
{ "resource": "" }
q24956
AdsCommon.ParametersValidator.add_attribute
validation
def add_attribute(node, key, name, value) node[:attributes!] ||= {} node[:attributes!][key] ||= {} if node[:attributes!][key].include?(name) node[:attributes!][key][name] = arrayize(node[:attributes!][key][name])
ruby
{ "resource": "" }
q24957
AdsCommon.ParametersValidator.prefix_key_with_namespace
validation
def prefix_key_with_namespace(key, ns_index = nil) namespace = (ns_index.nil?) ? DEFAULT_NAMESPACE : ("ns%d"
ruby
{ "resource": "" }
q24958
AdsCommon.ParametersValidator.get_full_type_signature
validation
def get_full_type_signature(type_name) result = (type_name.nil?) ? nil : @registry.get_type_signature(type_name)
ruby
{ "resource": "" }
q24959
AdsCommon.ParametersValidator.implode_parent
validation
def implode_parent(data_type) result = [] if data_type[:base] parent_type = @registry.get_type_signature(data_type[:base]) result += implode_parent(parent_type) end data_type[:fields].each do |field|
ruby
{ "resource": "" }
q24960
AdsCommon.ParametersValidator.time_to_xml_hash
validation
def time_to_xml_hash(time) return { :hour => time.hour, :minute => time.min, :second
ruby
{ "resource": "" }
q24961
AdsCommon.Config.load
validation
def load(filename) begin new_config = YAML::load_file(filename) if new_config.kind_of?(Hash) @config = new_config else raise AdsCommon::Errors::Error, "Incorrect configuration file: '%s'" % filename end rescue
ruby
{ "resource": "" }
q24962
AdsCommon.Config.process_hash_keys
validation
def process_hash_keys(hash) return hash.inject({}) do |result, pair| key, value = pair result[key.to_sym] = value.is_a?(Hash) ?
ruby
{ "resource": "" }
q24963
AdsCommon.Config.find_value
validation
def find_value(data, path) return (path.nil? or data.nil?) ? nil : path.split('.').inject(data) do |node, section| break if node.nil? key = section.to_sym
ruby
{ "resource": "" }
q24964
AdwordsApi.BatchJobUtils.initialize_url
validation
def initialize_url(batch_job_url) headers = DEFAULT_HEADERS headers['Content-Length'] = 0 headers['x-goog-resumable'] = 'start' response = AdsCommon::Http.post_response(
ruby
{ "resource": "" }
q24965
AdwordsApi.BatchJobUtils.put_incremental_operations
validation
def put_incremental_operations( operations, batch_job_url, total_content_length = 0, is_last_request = false) @api.utils_reporter.batch_job_utils_used() headers = DEFAULT_HEADERS soap_operations = generate_soap_operations(operations) request_body = soap_operations.join is_first_request = (total_content_length == 0) if is_first_request request_body = (UPLOAD_XML_PREFIX % [@version]) + request_body end if is_last_request request_body += UPLOAD_XML_SUFFIX end request_body = add_padding(request_body) content_length = request_body.bytesize headers['Content-Length'] = content_length lower_bound = total_content_length upper_bound = total_content_length + content_length - 1 total_bytes = is_last_request ? upper_bound + 1 : '*' content_range =
ruby
{ "resource": "" }
q24966
AdwordsApi.BatchJobUtils.get_job_results
validation
def get_job_results(batch_job_url) @api.utils_reporter.batch_job_utils_used() xml_response = AdsCommon::Http.get_response(batch_job_url, @api.config) begin return sanitize_result(
ruby
{ "resource": "" }
q24967
AdwordsApi.BatchJobUtils.extract_soap_operations
validation
def extract_soap_operations(full_soap_xml) doc = Nokogiri::XML(full_soap_xml) operations = doc.css('wsdl|operations') operations.attr('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')
ruby
{ "resource": "" }
q24968
AdwordsApi.BatchJobUtils.sanitize_result
validation
def sanitize_result(results) if results.is_a?(Array) ret = [] results.each do |result| ret << sanitize_result(result) end return ret end if results.is_a?(Hash) ret = {}
ruby
{ "resource": "" }
q24969
AdwordsApi.ServiceQuery.has_next_landscape_page
validation
def has_next_landscape_page(page) raise ArgumentError, 'Cannot page through query with no LIMIT clause.' if @start_index.nil? return false unless page[:entries] total_landscape_points_in_page = 0 page[:entries].each do
ruby
{ "resource": "" }
q24970
AdsCommon.ApiConfig.version_has_service
validation
def version_has_service(version, service) return service_config.include?(version) &&
ruby
{ "resource": "" }
q24971
AdsCommon.ApiConfig.endpoint
validation
def endpoint(version, service) base = get_wsdl_base(version) if !subdir_config().nil? base = base.to_s + subdir_config()[[version, service]].to_s
ruby
{ "resource": "" }
q24972
AdsCommon.ApiConfig.do_require
validation
def do_require(version, service) filename = [api_path, version.to_s, service.to_s.snakecase].join('/')
ruby
{ "resource": "" }
q24973
AdsCommon.ApiConfig.module_name
validation
def module_name(version, service) return
ruby
{ "resource": "" }
q24974
AdsCommon.ApiConfig.get_wsdls
validation
def get_wsdls(version) res = {} wsdl_base = get_wsdl_base(version) postfix = wsdl_base.start_with?('http') ? '?wsdl' : '.wsdl' services(version).each do |service| path = wsdl_base if (!subdir_config().nil?) subdir_name = subdir(version, service); path =
ruby
{ "resource": "" }
q24975
GoogleAdsSavon.Client.process
validation
def process(offset = 0, instance = self, &block) block.arity > 0 ? yield_objects(offset,
ruby
{ "resource": "" }
q24976
GoogleAdsSavon.Client.yield_objects
validation
def yield_objects(offset, instance, &block) to_yield = [:soap, :wsdl, :http, :wsse] yield
ruby
{ "resource": "" }
q24977
GoogleAdsSavon.Client.evaluate
validation
def evaluate(instance, &block) original_self = eval "self", block.binding # A proxy that attemps to make method calls on +instance+. If a NoMethodError is # raised, the call will be made on +original_self+. proxy = Object.new proxy.instance_eval do
ruby
{ "resource": "" }
q24978
GoogleAdsSavon.Client.remove_blank_values
validation
def remove_blank_values(hash) hash.delete_if
ruby
{ "resource": "" }
q24979
AdManagerApi.PQLValues.values
validation
def values() # values_array is an Ad-Manager-compliant list of values of the following # form: [:key => ..., :value => {:xsi_type => ..., :value => ...}] values_array = @values.map do |key, value| raise 'Missing value in StatementBuilder.' if value.nil? raise 'Misconfigured value in StatementBuilder.' unless value.is_a? Hash raise 'Value cannot be nil on StatementBuilder.' if value[:value].nil? raise 'Missing value type for %s.' % key if value[:xsi_type].nil? unless VALUE_TYPES.values.include?(value[:xsi_type]) raise 'Unknown value type for %s.' % key end if value[:xsi_type] == 'SetValue' if value[:value].map {|v| v.class}.to_set.size >
ruby
{ "resource": "" }
q24980
AdManagerApi.PQLValues.generate_value_object
validation
def generate_value_object(value) typeKeyValue = VALUE_TYPES.find {|key, val| value.is_a? key} dateTypes = [AdManagerApi::AdManagerDate, AdManagerApi::AdManagerDateTime] if dateTypes.include?(value.class) value
ruby
{ "resource": "" }
q24981
AdManagerApi.StatementBuilder.validate
validation
def validate() if [email protected]_s.strip.empty? and @from.to_s.strip.empty? raise 'FROM clause is required with SELECT' end if [email protected]_s.strip.empty? and @select.to_s.strip.empty? raise 'SELECT clause is required with FROM' end if [email protected]? and @limit.nil? raise 'LIMIT clause is required with OFFSET'
ruby
{ "resource": "" }
q24982
AdManagerApi.StatementBuilder.to_statement
validation
def to_statement() @api.utils_reporter.statement_builder_used() validate() ordering = @ascending ? 'ASC' : 'DESC' pql_query = PQLQuery.new pql_query << SELECT % @select unless @select.to_s.empty? pql_query << FROM % @from unless @from.to_s.empty? pql_query << WHERE % @where unless @where.to_s.empty? pql_query << ORDER % [@order_by, ordering] unless @order_by.to_s.empty?
ruby
{ "resource": "" }
q24983
AdManagerApi.AdManagerDate.method_missing
validation
def method_missing(name, *args, &block) result = @date.send(name, *args, &block) return
ruby
{ "resource": "" }
q24984
AdManagerApi.AdManagerDateTime.to_h
validation
def to_h { :date => AdManagerApi::AdManagerDate.new( @api, @time.year, @time.month, @time.day ).to_h, :hour => @time.hour, :minute => @time.min,
ruby
{ "resource": "" }
q24985
AdManagerApi.AdManagerDateTime.method_missing
validation
def method_missing(name, *args, &block) # Restrict time zone related functions from being passed to internal ruby # Time attribute, since AdManagerDateTime handles timezones its own way. restricted_functions = [:dst?, :getgm, :getlocal, :getutc, :gmt, :gmtime, :gmtoff, :isdst, :localtime, :utc] if restricted_functions.include? name raise NoMethodError, 'undefined
ruby
{ "resource": "" }
q24986
AdsCommon.SavonService.create_savon_client
validation
def create_savon_client(endpoint, namespace) client = GoogleAdsSavon::Client.new do |wsdl, httpi| wsdl.endpoint = endpoint wsdl.namespace = namespace AdsCommon::Http.configure_httpi(@config, httpi)
ruby
{ "resource": "" }
q24987
AdsCommon.SavonService.get_soap_xml
validation
def get_soap_xml(action_name, args) registry = get_service_registry() validator = ParametersValidator.new(registry)
ruby
{ "resource": "" }
q24988
AdsCommon.SavonService.execute_action
validation
def execute_action(action_name, args, &block) registry = get_service_registry() validator = ParametersValidator.new(registry) args = validator.validate_args(action_name, args) request_info, response = handle_soap_request(
ruby
{ "resource": "" }
q24989
AdsCommon.SavonService.handle_soap_request
validation
def handle_soap_request(action, xml_only, args, extra_namespaces) original_action_name = get_service_registry.get_method_signature(action)[:original_name] original_action_name = action if original_action_name.nil? request_info = nil response = @client.request(original_action_name) do |soap, wsdl, http| soap.body = args @header_handler.prepare_request(http, soap)
ruby
{ "resource": "" }
q24990
AdsCommon.SavonService.handle_errors
validation
def handle_errors(response) if response.soap_fault? exception = exception_for_soap_fault(response) raise exception end if response.http_error?
ruby
{ "resource": "" }
q24991
AdsCommon.SavonService.exception_for_soap_fault
validation
def exception_for_soap_fault(response) begin fault = response[:fault] if fault[:detail] and fault[:detail][:api_exception_fault] exception_fault = fault[:detail][:api_exception_fault] exception_name = ( exception_fault[:application_exception_type] || FALLBACK_API_ERROR_EXCEPTION) exception_class = get_module().const_get(exception_name)
ruby
{ "resource": "" }
q24992
AdsCommon.SavonService.run_user_block
validation
def run_user_block(extractor, response, body, &block) header = extractor.extract_header_data(response) case block.arity when 1 then yield(header)
ruby
{ "resource": "" }
q24993
AdsCommon.SavonService.do_logging
validation
def do_logging(action, request, response) logger = get_logger() return unless should_log_summary(logger.level, response.soap_fault?) response_hash = response.hash soap_headers = {} begin soap_headers = response_hash[:envelope][:header][:response_header] rescue NoMethodError # If there are no headers, just ignore. We'll log what we know. end summary_message = ('ID: %s, URL: %s, Service: %s, Action: %s, Response ' + 'time: %sms, Request ID: %s') % [@header_handler.identifier, request.url, self.class.to_s.split("::").last, action, soap_headers[:response_time], soap_headers[:request_id]] if soap_headers[:operations] summary_message += ', Operations: %s' % soap_headers[:operations] end summary_message += ', Is fault: %s' % response.soap_fault? request_message = nil response_message = nil if should_log_payloads(logger.level, response.soap_fault?)
ruby
{ "resource": "" }
q24994
AdsCommon.SavonService.format_headers
validation
def format_headers(headers) return headers.map do |k, v|
ruby
{ "resource": "" }
q24995
AdsCommon.SavonService.format_fault
validation
def format_fault(message) if message.length > MAX_FAULT_LOG_LENGTH message
ruby
{ "resource": "" }
q24996
AdsCommon.SavonService.should_log_summary
validation
def should_log_summary(level, is_fault) # Fault summaries log at WARN. return level <= Logger::WARN if is_fault
ruby
{ "resource": "" }
q24997
AdsCommon.SavonService.should_log_payloads
validation
def should_log_payloads(level, is_fault) # Fault payloads log at INFO. return level <= Logger::INFO if is_fault
ruby
{ "resource": "" }
q24998
AdwordsApi.ReportUtils.download_report_as_file
validation
def download_report_as_file(report_definition, path, cid = nil) report_body = download_report(report_definition, cid)
ruby
{ "resource": "" }
q24999
AdwordsApi.ReportUtils.download_report_as_file_with_awql
validation
def download_report_as_file_with_awql(report_query, format, path, cid = nil) report_body
ruby
{ "resource": "" }