Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refs #7162, AWS gem monkey patches ActiveSupport methods

  • Loading branch information...
commit ef8af7e4e04d16d2f55531847dc0db32ba1d5fc8 1 parent a60b928
@konstantin-dzreev konstantin-dzreev authored
Showing with 191 additions and 196 deletions.
  1. +2 −1  History.txt
  2. +1 −1  Rakefile
  3. +9 −9 lib/acf/right_acf_interface.rb
  4. +1 −1  lib/acf/right_acf_origin_access_identities.rb
  5. +1 −1  lib/acf/right_acf_streaming_interface.rb
  6. +1 −1  lib/acw/right_acw_interface.rb
  7. +5 −5 lib/as/right_as_interface.rb
  8. +4 −4 lib/awsbase/right_awsbase.rb
  9. +12 −18 lib/awsbase/support.rb
  10. +5 −5 lib/ec2/right_ec2.rb
  11. +9 −9 lib/ec2/right_ec2_ebs.rb
  12. +2 −2 lib/ec2/right_ec2_images.rb
  13. +18 −18 lib/ec2/right_ec2_instances.rb
  14. +3 −3 lib/ec2/right_ec2_reserved_instances.rb
  15. +13 −13 lib/ec2/right_ec2_security_groups.rb
  16. +21 −21 lib/ec2/right_ec2_spot_instances.rb
  17. +3 −3 lib/ec2/right_ec2_vpc.rb
  18. +3 −3 lib/elb/right_elb_interface.rb
  19. +37 −37 lib/rds/right_rds_interface.rb
  20. +3 −3 lib/s3/right_s3.rb
  21. +8 −8 lib/s3/right_s3_interface.rb
  22. +17 −17 lib/sdb/active_sdb.rb
  23. +2 −2 lib/sdb/right_sdb_interface.rb
  24. +1 −1  lib/sqs/right_sqs.rb
  25. +3 −3 lib/sqs/right_sqs_gen2_interface.rb
  26. +4 −4 lib/sqs/right_sqs_interface.rb
  27. +1 −1  test/s3/test_right_s3.rb
  28. +1 −1  test/sdb/test_active_sdb.rb
  29. +1 −1  test/sqs/test_right_sqs_gen2.rb
View
3  History.txt
@@ -291,4 +291,5 @@ the source key.
- RDS: API '2010-01-01' (MultiAZ support)
- Fixed:
- RDS: DB Parameter group name on instance launch
-
+ - ActiveSupport dependency removal
+
View
2  Rakefile
@@ -30,7 +30,7 @@ Hoe.new('right_aws', RightAws::VERSION::STRING) do |p|
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
p.remote_rdoc_dir = "/right_aws_gem_doc"
- p.extra_deps = [['right_http_connection','>= 1.2.1']]
+ p.extra_deps = [['right_http_connection','>= 1.2.5']]
p.test_globs = testglobs
end
View
18 lib/acf/right_acf_interface.rb
@@ -121,8 +121,8 @@ def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
# Generates request hash for REST API.
def generate_request(method, path, params={}, body=nil, headers={}) # :nodoc:
# Params
- params.delete_if{ |key, val| val.blank? }
- unless params.blank?
+ params.delete_if{ |key, val| val.right_blank? }
+ unless params.right_blank?
path += "?" + params.to_a.collect{ |key,val| "#{AwsUtils::amz_escape(key)}=#{AwsUtils::amz_escape(val.to_s)}" }.join("&")
end
# Headers
@@ -133,7 +133,7 @@ def generate_request(method, path, params={}, body=nil, headers={}) # :nodoc:
headers['Authorization'] = "AWS #{@aws_access_key_id}:#{signature}"
# Request
path = "#{@params[:service]}#{@params[:api_version]}/#{path}"
- request = "Net::HTTP::#{method.capitalize}".constantize.new(path)
+ request = "Net::HTTP::#{method.capitalize}".right_constantize.new(path)
request.body = body if body
# Set request headers
headers.each { |key, value| request[key.to_s] = value }
@@ -180,18 +180,18 @@ def distribution_config_to_xml(config, xml_wrapper='DistributionConfig') # :nodo
origin_access_identity = ''
trusted_signers = ''
# CNAMES
- unless config[:cnames].blank?
+ unless config[:cnames].right_blank?
Array(config[:cnames]).each { |cname| cnames += " <CNAME>#{cname}</CNAME>\n" }
end
# Logging
- unless config[:logging].blank?
+ unless config[:logging].right_blank?
logging = " <Logging>\n" +
" <Bucket>#{config[:logging][:bucket]}</Bucket>\n" +
" <Prefix>#{config[:logging][:prefix]}</Prefix>\n" +
" </Logging>\n"
end
# Origin Access Identity
- unless config[:origin_access_identity].blank?
+ unless config[:origin_access_identity].right_blank?
origin_access_identity = config[:origin_access_identity]
unless origin_access_identity[%r{^origin-access-identity}]
origin_access_identity = "origin-access-identity/cloudfront/#{origin_access_identity}"
@@ -199,7 +199,7 @@ def distribution_config_to_xml(config, xml_wrapper='DistributionConfig') # :nodo
origin_access_identity = " <OriginAccessIdentity>#{origin_access_identity}</OriginAccessIdentity>\n"
end
# Trusted Signers
- unless config[:trusted_signers].blank?
+ unless config[:trusted_signers].right_blank?
trusted_signers = " <TrustedSigners>\n"
Array(config[:trusted_signers]).each do |trusted_signer|
trusted_signers += if trusted_signer.to_s[/self/i]
@@ -288,7 +288,7 @@ def incrementally_list_distributions(params={}, &block)
link = generate_request('GET', 'distribution', opts)
last_response = request_info(link, AcfDistributionListParser.new(:logger => @logger))
opts['Marker'] = last_response[:next_marker]
- break unless block && block.call(last_response) && !last_response[:next_marker].blank?
+ break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
end
last_response
end
@@ -317,7 +317,7 @@ def create_distribution(origin, comment='', enabled=true, cnames=[], caller_refe
:enabled => enabled,
:cnames => Array(cnames),
:caller_reference => caller_reference }
- config[:logging] = logging unless logging.blank?
+ config[:logging] = logging unless logging.right_blank?
create_distribution_by_config(config)
end
View
2  lib/acf/right_acf_origin_access_identities.rb
@@ -85,7 +85,7 @@ def incrementally_list_origin_access_identities(params={}, &block)
link = generate_request('GET', 'origin-access-identity/cloudfront', opts)
last_response = request_info(link, AcfOriginAccesIdentitiesListParser.new(:logger => @logger))
opts['Marker'] = last_response[:next_marker]
- break unless block && block.call(last_response) && !last_response[:next_marker].blank?
+ break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
end
last_response
end
View
2  lib/acf/right_acf_streaming_interface.rb
@@ -101,7 +101,7 @@ def incrementally_list_streaming_distributions(params={}, &block)
link = generate_request('GET', 'streaming-distribution', opts)
last_response = request_info(link, AcfDistributionListParser.new(:logger => @logger))
opts['Marker'] = last_response[:next_marker]
- break unless block && block.call(last_response) && !last_response[:next_marker].blank?
+ break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
end
last_response
end
View
2  lib/acw/right_acw_interface.rb
@@ -145,7 +145,7 @@ def get_metric_statistics(options={})
period = (options[:period] && options[:period].to_i) || 60
# Statistics ('Average' by default)
statistics = Array(options[:statistics]).flatten
- statistics = statistics.blank? ? ['Average'] : statistics.map{|statistic| statistic.to_s.capitalize }
+ statistics = statistics.right_blank? ? ['Average'] : statistics.map{|statistic| statistic.to_s.capitalize }
# Times (5.min.ago up to now by default)
start_time = options[:start_time] || (Time.now.utc - 5*60)
start_time = start_time.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00") if start_time.is_a?(Time)
View
10 lib/as/right_as_interface.rb
@@ -136,7 +136,7 @@ def describe_auto_scaling_groups(*auto_scaling_group_names)
auto_scaling_group_names = auto_scaling_group_names.flatten.compact
request_hash = amazonize_list('AutoScalingGroupNames.member', auto_scaling_group_names)
link = generate_request("DescribeAutoScalingGroups", request_hash)
- request_cache_or_info(:describe_auto_scaling_groups, link, DescribeAutoScalingGroupsParser, @@bench, auto_scaling_group_names.blank?)
+ request_cache_or_info(:describe_auto_scaling_groups, link, DescribeAutoScalingGroupsParser, @@bench, auto_scaling_group_names.right_blank?)
end
# Creates a new auto scaling group with the specified name.
@@ -302,7 +302,7 @@ def incrementally_describe_scaling_activities(auto_scaling_group_name, *activity
link = generate_request("DescribeScalingActivities", request_hash)
last_response = request_info( link, DescribeScalingActivitiesParser.new(:logger => @logger))
request_hash['NextToken'] = last_response[:next_token]
- break unless block && block.call(last_response) && !last_response[:next_token].blank?
+ break unless block && block.call(last_response) && !last_response[:next_token].right_blank?
end
last_response
end
@@ -355,10 +355,10 @@ def create_launch_configuration(launch_configuration_name, image_id, instance_ty
request_hash = { 'LaunchConfigurationName' => launch_configuration_name,
'ImageId' => image_id,
'InstanceType' => instance_type }
- request_hash.merge!(amazonize_list('SecurityGroups.member', options[:security_groups])) unless options[:security_groups].blank?
+ request_hash.merge!(amazonize_list('SecurityGroups.member', options[:security_groups])) unless options[:security_groups].right_blank?
request_hash.merge!(amazonize_block_device_mappings(options[:block_device_mappings], 'BlockDeviceMappings.member'))
request_hash['KeyName'] = options[:key_name] if options[:key_name]
- request_hash['UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].blank? if options[:user_data]
+ request_hash['UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].right_blank? if options[:user_data]
request_hash['KernelId'] = options[:kernel_id] if options[:kernel_id]
request_hash['RamdiskId'] = options[:ramdisk_id] if options[:ramdisk_id]
link = generate_request("CreateLaunchConfiguration", request_hash)
@@ -428,7 +428,7 @@ def incrementally_describe_launch_configurations(*launch_configuration_names, &b
link = generate_request("DescribeLaunchConfigurations", request_hash)
last_response = request_info( link, DescribeLaunchConfigurationsParser.new(:logger => @logger) )
request_hash['NextToken'] = last_response[:next_token]
- break unless block && block.call(last_response) && !last_response[:next_token].blank?
+ break unless block && block.call(last_response) && !last_response[:next_token].right_blank?
end
last_response
end
View
8 lib/awsbase/right_awsbase.rb
@@ -222,9 +222,9 @@ def init(service_info, aws_access_key_id, aws_secret_access_key, params={}) #:no
@params = params
# If one defines EC2_URL he may forget to use a single slash as an "empty service" path.
# Amazon does not like this therefore add this bad boy if he is missing...
- service_info[:default_service] = '/' if service_info[:default_service].blank?
+ service_info[:default_service] = '/' if service_info[:default_service].right_blank?
raise AwsError.new("AWS access keys are required to operate on #{service_info[:name]}") \
- if aws_access_key_id.blank? || aws_secret_access_key.blank?
+ if aws_access_key_id.right_blank? || aws_secret_access_key.right_blank?
@aws_access_key_id = aws_access_key_id
@aws_secret_access_key = aws_secret_access_key
# if the endpoint was explicitly defined - then use it
@@ -233,7 +233,7 @@ def init(service_info, aws_access_key_id, aws_secret_access_key, params={}) #:no
@params[:port] = URI.parse(@params[:endpoint_url]).port
@params[:service] = URI.parse(@params[:endpoint_url]).path
# make sure the 'service' path is not empty
- @params[:service] = service_info[:default_service] if @params[:service].blank?
+ @params[:service] = service_info[:default_service] if @params[:service].right_blank?
@params[:protocol] = URI.parse(@params[:endpoint_url]).scheme
@params[:region] = nil
else
@@ -537,7 +537,7 @@ def amazonize_list(masks, list) #:nodoc:
def amazonize_block_device_mappings(block_device_mappings, key = 'BlockDeviceMapping') # :nodoc:
result = {}
- unless block_device_mappings.blank?
+ unless block_device_mappings.right_blank?
block_device_mappings = [block_device_mappings] unless block_device_mappings.is_a?(Array)
block_device_mappings.each_with_index do |b, idx|
BLOCK_DEVICE_KEY_MAPPING.each do |local_name, remote_name|
View
30 lib/awsbase/support.rb
@@ -1,7 +1,3 @@
-# If ActiveSupport is loaded, then great - use it. But we don't
-# want a dependency on it, so if it's not present, define the few
-# extensions that we want to use...
-unless defined? ActiveSupport::CoreExtensions
# These are ActiveSupport-;like extensions to do a few handy things in the gems
# Derived from ActiveSupport, so the AS copyright notice applies:
#
@@ -39,15 +35,14 @@ class String #:nodoc:
# Examples
# "Module".constantize #=> Module
# "Class".constantize #=> Class
- def constantize()
+ def right_constantize()
unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ self
raise NameError, "#{self.inspect} is not a valid constant name!"
end
-
Object.module_eval("::#{$1}", __FILE__, __LINE__)
end
- def camelize()
+ def right_camelize()
self.dup.split(/_/).map{ |word| word.capitalize }.join('')
end
@@ -56,7 +51,7 @@ def camelize()
class Object #:nodoc:
# "", " ", nil, [], and {} are blank
- def blank?
+ def right_blank?
if respond_to?(:empty?) && respond_to?(:strip)
empty? or strip.empty?
elsif respond_to?(:empty?)
@@ -68,32 +63,32 @@ def blank?
end
class NilClass #:nodoc:
- def blank?
+ def right_blank?
true
end
end
class FalseClass #:nodoc:
- def blank?
+ def right_blank?
true
end
end
class TrueClass #:nodoc:
- def blank?
+ def right_blank?
false
end
end
class Array #:nodoc:
- alias_method :blank?, :empty?
+ alias_method :right_blank?, :empty?
end
class Hash #:nodoc:
- alias_method :blank?, :empty?
-
+ alias_method :right_blank?, :empty?
+
# Return a new hash with all keys converted to symbols.
- def symbolize_keys
+ def right_symbolize_keys
inject({}) do |options, (key, value)|
options[key.to_sym] = value
options
@@ -102,14 +97,13 @@ def symbolize_keys
end
class String #:nodoc:
- def blank?
+ def right_blank?
empty? || strip.empty?
end
end
class Numeric #:nodoc:
- def blank?
+ def right_blank?
false
end
end
-end
View
10 lib/ec2/right_ec2.rb
@@ -154,7 +154,7 @@ def request_info(request, parser) #:nodoc:
def describe_key_pairs(*key_pairs)
key_pairs = key_pairs.flatten
link = generate_request("DescribeKeyPairs", amazonize_list('KeyName', key_pairs))
- request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, @@bench, key_pairs.blank?
+ request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, @@bench, key_pairs.right_blank?
rescue Exception
on_exception
end
@@ -227,7 +227,7 @@ def associate_address(instance_id, public_ip)
def describe_addresses(*addresses)
addresses = addresses.flatten
link = generate_request("DescribeAddresses", amazonize_list('PublicIp', addresses))
- request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, addresses.blank?
+ request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, addresses.right_blank?
rescue Exception
on_exception
end
@@ -276,7 +276,7 @@ def release_address(public_ip)
def describe_availability_zones(*availability_zones)
availability_zones = availability_zones.flatten
link = generate_request("DescribeAvailabilityZones", amazonize_list('ZoneName', availability_zones))
- request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, availability_zones.blank?
+ request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, availability_zones.right_blank?
rescue Exception
on_exception
end
@@ -292,7 +292,7 @@ def describe_availability_zones(*availability_zones)
def describe_regions(*regions)
regions = regions.flatten
link = generate_request("DescribeRegions", amazonize_list('RegionName', regions))
- request_cache_or_info :describe_regions, link, QEc2DescribeRegionsParser, @@bench, regions.blank?
+ request_cache_or_info :describe_regions, link, QEc2DescribeRegionsParser, @@bench, regions.right_blank?
rescue Exception
on_exception
end
@@ -346,7 +346,7 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'instanceId' then @address[:instance_id] = @text.blank? ? nil : @text
+ when 'instanceId' then @address[:instance_id] = @text.right_blank? ? nil : @text
when 'publicIp' then @address[:public_ip] = @text
when 'item' then @result << @address
end
View
18 lib/ec2/right_ec2_ebs.rb
@@ -52,7 +52,7 @@ class Ec2
def describe_volumes(*volumes)
volumes = volumes.flatten
link = generate_request("DescribeVolumes", amazonize_list('VolumeId', volumes))
- request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, @@bench, volumes.blank?
+ request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, @@bench, volumes.right_blank?
rescue Exception
on_exception
end
@@ -72,7 +72,7 @@ def create_volume(snapshot_id, size, zone)
hash = { "Size" => size.to_s,
"AvailabilityZone" => zone.to_s }
# Get rig of empty snapshot: e8s guys do not like it
- hash["SnapshotId"] = snapshot_id.to_s unless snapshot_id.blank?
+ hash["SnapshotId"] = snapshot_id.to_s unless snapshot_id.right_blank?
link = generate_request("CreateVolume", hash )
request_info(link, QEc2CreateVolumeParser.new(:logger => @logger))
rescue Exception
@@ -123,8 +123,8 @@ def attach_volume(volume_id, instance_id, device)
#
def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
hash = { "VolumeId" => volume_id.to_s }
- hash["InstanceId"] = instance_id.to_s unless instance_id.blank?
- hash["Device"] = device.to_s unless device.blank?
+ hash["InstanceId"] = instance_id.to_s unless instance_id.right_blank?
+ hash["Device"] = device.to_s unless device.right_blank?
hash["Force"] = 'true' if force
#
link = generate_request("DetachVolume", hash)
@@ -161,7 +161,7 @@ def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
def describe_snapshots(*snapshots)
snapshots = snapshots.flatten
link = generate_request("DescribeSnapshots", amazonize_list('SnapshotId', snapshots))
- request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, @@bench, snapshots.blank?
+ request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, @@bench, snapshots.right_blank?
rescue Exception
on_exception
end
@@ -300,7 +300,7 @@ def modify_snapshot_attribute_create_volume_permission_remove_users(snapshot_id,
#
def modify_snapshot_attribute_create_volume_permission_add_groups(snapshot_id, *user_group)
user_group.flatten!
- user_group = ['all'] if user_group.blank?
+ user_group = ['all'] if user_group.right_blank?
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'add', :user_group => user_group )
end
@@ -310,7 +310,7 @@ def modify_snapshot_attribute_create_volume_permission_add_groups(snapshot_id, *
#
def modify_snapshot_attribute_create_volume_permission_remove_groups(snapshot_id, *user_group)
user_group.flatten!
- user_group = ['all'] if user_group.blank?
+ user_group = ['all'] if user_group.right_blank?
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'remove', :user_group => user_group )
end
@@ -337,7 +337,7 @@ def tagend(name)
when 'status' then @result[:aws_status] = @text
when 'createTime' then @result[:aws_created_at] = @text
when 'size' then @result[:aws_size] = @text.to_i ###
- when 'snapshotId' then @result[:snapshot_id] = @text.blank? ? nil : @text ###
+ when 'snapshotId' then @result[:snapshot_id] = @text.right_blank? ? nil : @text ###
when 'availabilityZone' then @result[:zone] = @text ###
end
end
@@ -386,7 +386,7 @@ def tagend(name)
when 'instanceId' then @volume[:aws_instance_id] = @text
when 'device' then @volume[:aws_device] = @text
when 'attachTime' then @volume[:aws_attached_at] = @text
- when 'snapshotId' then @volume[:snapshot_id] = @text.blank? ? nil : @text
+ when 'snapshotId' then @volume[:snapshot_id] = @text.right_blank? ? nil : @text
when 'availabilityZone' then @volume[:zone] = @text
when 'deleteOnTermination' then @volume[:delete_on_termination] = (@text == 'true')
when 'item'
View
4 lib/ec2/right_ec2_images.rb
@@ -269,8 +269,8 @@ def modify_image_product_code(image_id, product_code=[])
#
def create_image(instance_aws_id, options={})
params = { 'InstanceId' => instance_aws_id }
- params['Name'] = options[:name] unless options[:name].blank?
- params['Description'] = options[:description] unless options[:description].blank?
+ params['Name'] = options[:name] unless options[:name].right_blank?
+ params['Description'] = options[:description] unless options[:description].right_blank?
params['NoReboot'] = options[:no_reboot].to_s unless options[:no_reboot].nil?
link = generate_request("CreateImage", params)
request_info(link, QEc2RegisterImageParser.new(:logger => @logger))
View
36 lib/ec2/right_ec2_instances.rb
@@ -87,7 +87,7 @@ def get_desc_instances(instances) # :nodoc:
def describe_instances(*instances)
instances = instances.flatten
link = generate_request("DescribeInstances", amazonize_list('InstanceId', instances))
- request_cache_or_info(:describe_instances, link, QEc2DescribeInstancesParser, @@bench, instances.blank?) do |parser|
+ request_cache_or_info(:describe_instances, link, QEc2DescribeInstancesParser, @@bench, instances.right_blank?) do |parser|
get_desc_instances(parser.result)
end
rescue Exception
@@ -207,30 +207,30 @@ def launch_instances(image_id, options={})
def prepare_instance_launch_params(options={}) # :nodoc:
params = amazonize_list('SecurityGroup', Array(options[:group_ids]))
params['InstanceType'] = options[:instance_type] || DEFAULT_INSTANCE_TYPE
- params['ImageId'] = options[:image_id] unless options[:image_id].blank?
- params['AddressingType'] = options[:addressing_type] unless options[:addressing_type].blank?
- params['MinCount'] = options[:min_count] unless options[:min_count].blank?
- params['MaxCount'] = options[:max_count] unless options[:max_count].blank?
- params['KeyName'] = options[:key_name] unless options[:key_name].blank?
- params['KernelId'] = options[:kernel_id] unless options[:kernel_id].blank?
- params['RamdiskId'] = options[:ramdisk_id] unless options[:ramdisk_id].blank?
- params['Placement.AvailabilityZone'] = options[:availability_zone] unless options[:availability_zone].blank?
+ params['ImageId'] = options[:image_id] unless options[:image_id].right_blank?
+ params['AddressingType'] = options[:addressing_type] unless options[:addressing_type].right_blank?
+ params['MinCount'] = options[:min_count] unless options[:min_count].right_blank?
+ params['MaxCount'] = options[:max_count] unless options[:max_count].right_blank?
+ params['KeyName'] = options[:key_name] unless options[:key_name].right_blank?
+ params['KernelId'] = options[:kernel_id] unless options[:kernel_id].right_blank?
+ params['RamdiskId'] = options[:ramdisk_id] unless options[:ramdisk_id].right_blank?
+ params['Placement.AvailabilityZone'] = options[:availability_zone] unless options[:availability_zone].right_blank?
params['Monitoring.Enabled'] = options[:monitoring_enabled].to_s if options[:monitoring_enabled]
- params['SubnetId'] = options[:subnet_id] unless options[:subnet_id].blank?
- params['AdditionalInfo'] = options[:additional_info] unless options[:additional_info].blank?
+ params['SubnetId'] = options[:subnet_id] unless options[:subnet_id].right_blank?
+ params['AdditionalInfo'] = options[:additional_info] unless options[:additional_info].right_blank?
params['DisableApiTermination'] = options[:disable_api_termination].to_s unless options[:disable_api_termination].nil?
- params['InstanceInitiatedShutdownBehavior'] = options[:instance_initiated_shutdown_behavior] unless options[:instance_initiated_shutdown_behavior].blank?
-# params['VolumeId'] = options[:volume_id] unless options[:volume_id].blank?
-# params['RootDeviceName'] = options[:root_device_name] unless options[:root_device_name].blank?
-# params['RootDeviceType'] = options[:root_device_type] unless options[:root_device_type].blank?
+ params['InstanceInitiatedShutdownBehavior'] = options[:instance_initiated_shutdown_behavior] unless options[:instance_initiated_shutdown_behavior].right_blank?
+# params['VolumeId'] = options[:volume_id] unless options[:volume_id].right_blank?
+# params['RootDeviceName'] = options[:root_device_name] unless options[:root_device_name].right_blank?
+# params['RootDeviceType'] = options[:root_device_type] unless options[:root_device_type].right_blank?
params.merge!(amazonize_block_device_mappings(options[:block_device_mappings]))
- unless options[:user_data].blank?
+ unless options[:user_data].right_blank?
options[:user_data].strip!
# Do not use CGI::escape(encode64(...)) as it is done in Amazons EC2 library.
# Amazon 169.254.169.254 does not like escaped symbols!
# And it doesn't like "\n" inside of encoded string! Grrr....
# Otherwise, some of UserData symbols will be lost...
- params['UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].blank?
+ params['UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].right_blank?
end
params
end
@@ -429,7 +429,7 @@ def get_initial_password_v2(instance_id, private_key)
link = generate_request('GetPasswordData',
'InstanceId' => instance_id )
response = request_info(link, QEc2GetPasswordDataParser.new(:logger => @logger))
- if response[:password_data].blank?
+ if response[:password_data].right_blank?
raise AwsError.new("Initial password is not yet created for #{instance_id}")
else
OpenSSL::PKey::RSA.new(private_key).private_decrypt(Base64.decode64(response[:password_data]))
View
6 lib/ec2/right_ec2_reserved_instances.rb
@@ -47,7 +47,7 @@ class Ec2
def describe_reserved_instances(*reserved_instances)
reserved_instances = reserved_instances.flatten
link = generate_request("DescribeReservedInstances", amazonize_list('ReservedInstancesId', reserved_instances))
- request_cache_or_info(:describe_reserved_instances, link, QEc2DescribeReservedInstancesParser, @@bench, reserved_instances.blank?)
+ request_cache_or_info(:describe_reserved_instances, link, QEc2DescribeReservedInstancesParser, @@bench, reserved_instances.right_blank?)
rescue Exception
on_exception
end
@@ -82,12 +82,12 @@ def describe_reserved_instances_offerings(*list_and_params)
# backward compartibility with the old way
list ||= Array(params[:aws_ids])
rparams = {}
- rparams.update(amazonize_list('ReservedInstancesOfferingId', list)) unless list.blank?
+ rparams.update(amazonize_list('ReservedInstancesOfferingId', list)) unless list.right_blank?
rparams['InstanceType'] = params[:aws_instance_type] if params[:aws_instance_type]
rparams['AvailabilityZone'] = params[:aws_availability_zone] if params[:aws_availability_zone]
rparams['ProductDescription'] = params[:aws_product_description] if params[:aws_product_description]
link = generate_request("DescribeReservedInstancesOfferings", rparams)
- request_cache_or_info(:describe_reserved_instances_offerings, link, QEc2DescribeReservedInstancesOfferingsParser, @@bench, list.blank?)
+ request_cache_or_info(:describe_reserved_instances_offerings, link, QEc2DescribeReservedInstancesOfferingsParser, @@bench, list.right_blank?)
rescue Exception
on_exception
end
View
26 lib/ec2/right_ec2_security_groups.rb
@@ -82,7 +82,7 @@ class Ec2
def describe_security_groups(list=[])
link = generate_request("DescribeSecurityGroups", amazonize_list('GroupName', list))
- request_cache_or_info( :describe_security_groups, link, QEc2DescribeSecurityGroupsParser, @@bench, list.blank?) do |parser|
+ request_cache_or_info( :describe_security_groups, link, QEc2DescribeSecurityGroupsParser, @@bench, list.right_blank?) do |parser|
result = []
parser.result.each do |item|
result_item = { :aws_owner => item[:owner_id],
@@ -132,7 +132,7 @@ def describe_security_groups(list=[])
#
def create_security_group(name, description=nil)
# EC2 doesn't like an empty description...
- description = "-" if description.blank?
+ description = "-" if description.right_blank?
link = generate_request("CreateSecurityGroup",
'GroupName' => name.to_s,
'GroupDescription' => description.to_s)
@@ -186,16 +186,16 @@ def edit_security_group(action, group_name, params)
else raise "Unknown action #{action.inspect}!"
end
hash['GroupName'] = group_name
- hash['SourceSecurityGroupName'] = params[:source_group] unless params[:source_group].blank?
- hash['SourceSecurityGroupOwnerId'] = params[:source_group_owner].to_s.gsub(/-/,'') unless params[:source_group_owner].blank?
- hash['IpProtocol'] = params[:protocol] unless params[:protocol].blank?
- unless params[:port].blank?
+ hash['SourceSecurityGroupName'] = params[:source_group] unless params[:source_group].right_blank?
+ hash['SourceSecurityGroupOwnerId'] = params[:source_group_owner].to_s.gsub(/-/,'') unless params[:source_group_owner].right_blank?
+ hash['IpProtocol'] = params[:protocol] unless params[:protocol].right_blank?
+ unless params[:port].right_blank?
hash['FromPort'] = params[:port]
hash['ToPort'] = params[:port]
end
- hash['FromPort'] = params[:from_port] unless params[:from_port].blank?
- hash['ToPort'] = params[:to_port] unless params[:to_port].blank?
- hash['CidrIp'] = params[:cidr_ip] unless params[:cidr_ip].blank?
+ hash['FromPort'] = params[:from_port] unless params[:from_port].right_blank?
+ hash['ToPort'] = params[:to_port] unless params[:to_port].right_blank?
+ hash['CidrIp'] = params[:cidr_ip] unless params[:cidr_ip].right_blank?
#
link = generate_request(action, hash)
request_info(link, RightBoolResponseParser.new(:logger => @logger))
@@ -284,7 +284,7 @@ def modify_security_group_ingress(action, group_name, permissions)
# Protocol
hash["IpPermissions.#{pid}.IpProtocol"] = permission[:protocol]
# Port
- unless permission[:port].blank?
+ unless permission[:port].right_blank?
hash["IpPermissions.#{pid}.FromPort"] = permission[:port]
hash["IpPermissions.#{pid}.ToPort"] = permission[:port]
else
@@ -294,7 +294,7 @@ def modify_security_group_ingress(action, group_name, permissions)
# Source Group(s)
# Old way (if it is used):
# :source_group_owner => UserId, :source_group => GroupName
- if !permission[:source_group].blank? && !permission[:source_group_owner].blank?
+ if !permission[:source_group].right_blank? && !permission[:source_group_owner].right_blank?
permission[:source_groups] = { permission[:source_group_owner] => permission[:source_group]}
end
# # Fix UserId(s): '0000-0000-0000' => '000000000000'
@@ -310,8 +310,8 @@ def modify_security_group_ingress(action, group_name, permissions)
"IpPermissions.#{pid}.Groups.?.GroupName"],
permission[:source_groups] ))
# CidrIp(s)
- cidr_ips = permission[:cidr_ips] unless permission[:cidr_ips].blank?
- cidr_ips ||= permission[:cidr_ip] unless permission[:cidr_ip].blank?
+ cidr_ips = permission[:cidr_ips] unless permission[:cidr_ips].right_blank?
+ cidr_ips ||= permission[:cidr_ip] unless permission[:cidr_ip].right_blank?
hash.merge!(amazonize_list("IpPermissions.1.IpRanges.?.CidrIp", cidr_ips))
end
#
View
42 lib/ec2/right_ec2_spot_instances.rb
@@ -66,10 +66,10 @@ class Ec2
def describe_spot_price_history(options={})
options = options.dup
request_hash = {}
- request_hash['StartTime'] = AwsUtils::utc_iso8601(options[:start_time]) unless options[:start_time].blank?
- request_hash['EndTime'] = AwsUtils::utc_iso8601(options[:end_time]) unless options[:end_time].blank?
- request_hash['ProductDescription'] = options[:product_description] unless options[:product_description].blank?
- request_hash.merge!(amazonize_list('InstanceType', Array(options[:instance_types]))) unless options[:instance_types].blank?
+ request_hash['StartTime'] = AwsUtils::utc_iso8601(options[:start_time]) unless options[:start_time].right_blank?
+ request_hash['EndTime'] = AwsUtils::utc_iso8601(options[:end_time]) unless options[:end_time].right_blank?
+ request_hash['ProductDescription'] = options[:product_description] unless options[:product_description].right_blank?
+ request_hash.merge!(amazonize_list('InstanceType', Array(options[:instance_types]))) unless options[:instance_types].right_blank?
link = generate_request("DescribeSpotPriceHistory", request_hash)
request_info(link, QEc2DescribeSpotPriceHistoryParser.new)
rescue Exception
@@ -205,25 +205,25 @@ def request_spot_instances(options)
request_hash = { 'SpotPrice' => options[:spot_price],
'LaunchSpecification.ImageId' => options[:image_id],
'LaunchSpecification.InstanceType' => options[:instance_type]}
- request_hash['ValidFrom'] = AwsUtils::utc_iso8601(options[:valid_from]) unless options[:valid_from].blank?
- request_hash['ValidUntil'] = AwsUtils::utc_iso8601(options[:valid_until]) unless options[:valid_until].blank?
- request_hash['InstanceCount'] = options[:instance_count] unless options[:instance_count].blank?
- request_hash['Type'] = options[:type] unless options[:type].blank?
- request_hash['LaunchGroup'] = options[:launch_group] unless options[:launch_group].blank?
- request_hash['AvailabilityZoneGroup'] = options[:availability_zone_group] unless options[:availability_zone_group].blank?
- request_hash['LaunchSpecification.KeyName'] = options[:key_name] unless options[:key_name].blank?
- request_hash['LaunchSpecification.AddressingType'] = options[:addressing_type] unless options[:addressing_type].blank?
- request_hash['LaunchSpecification.KernelId'] = options[:kernel_id] unless options[:kernel_id].blank?
- request_hash['LaunchSpecification.RamdiskId'] = options[:ramdisk_id] unless options[:ramdisk_id].blank?
- request_hash['LaunchSpecification.SubnetId'] = options[:subnet_id] unless options[:subnet_id].blank?
- request_hash['LaunchSpecification.Placement.AvailabilityZone'] = options[:availability_zone] unless options[:availability_zone].blank?
- request_hash['LaunchSpecification.Monitoring.Enabled'] = options[:monitoring_enabled] unless options[:monitoring_enabled].blank?
- request_hash.merge!(amazonize_list('LaunchSpecification.SecurityGroup', options[:groups])) unless options[:groups].blank?
+ request_hash['ValidFrom'] = AwsUtils::utc_iso8601(options[:valid_from]) unless options[:valid_from].right_blank?
+ request_hash['ValidUntil'] = AwsUtils::utc_iso8601(options[:valid_until]) unless options[:valid_until].right_blank?
+ request_hash['InstanceCount'] = options[:instance_count] unless options[:instance_count].right_blank?
+ request_hash['Type'] = options[:type] unless options[:type].right_blank?
+ request_hash['LaunchGroup'] = options[:launch_group] unless options[:launch_group].right_blank?
+ request_hash['AvailabilityZoneGroup'] = options[:availability_zone_group] unless options[:availability_zone_group].right_blank?
+ request_hash['LaunchSpecification.KeyName'] = options[:key_name] unless options[:key_name].right_blank?
+ request_hash['LaunchSpecification.AddressingType'] = options[:addressing_type] unless options[:addressing_type].right_blank?
+ request_hash['LaunchSpecification.KernelId'] = options[:kernel_id] unless options[:kernel_id].right_blank?
+ request_hash['LaunchSpecification.RamdiskId'] = options[:ramdisk_id] unless options[:ramdisk_id].right_blank?
+ request_hash['LaunchSpecification.SubnetId'] = options[:subnet_id] unless options[:subnet_id].right_blank?
+ request_hash['LaunchSpecification.Placement.AvailabilityZone'] = options[:availability_zone] unless options[:availability_zone].right_blank?
+ request_hash['LaunchSpecification.Monitoring.Enabled'] = options[:monitoring_enabled] unless options[:monitoring_enabled].right_blank?
+ request_hash.merge!(amazonize_list('LaunchSpecification.SecurityGroup', options[:groups])) unless options[:groups].right_blank?
request_hash.merge!(amazonize_block_device_mappings(options[:block_device_mappings], 'LaunchSpecification.BlockDeviceMapping'))
- unless options[:user_data].blank?
+ unless options[:user_data].right_blank?
# See RightAws::Ec2#run_instances
options[:user_data].strip!
- request_hash['LaunchSpecification.UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].blank?
+ request_hash['LaunchSpecification.UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].right_blank?
end
link = generate_request("RequestSpotInstances", request_hash)
request_info(link, QEc2DescribeSpotInstanceParser.new(:logger => @logger))
@@ -253,7 +253,7 @@ def cancel_spot_instance_requests(*spot_instance_request_ids)
#
def create_spot_datafeed_subscription(bucket, prefix=nil)
request_hash = { 'Bucket' => bucket }
- request_hash['Prefix'] = prefix unless prefix.blank?
+ request_hash['Prefix'] = prefix unless prefix.right_blank?
link = generate_request("CreateSpotDatafeedSubscription", request_hash)
request_info(link, QEc2DescribeSpotDatafeedSubscriptionParser.new(:logger => @logger))
end
View
6 lib/ec2/right_ec2_vpc.rb
@@ -128,7 +128,7 @@ def describe_subnets(*list_and_filters)
def create_subnet(vpc_id, cidr_block, availability_zone = nil)
request_hash = { 'VpcId' => vpc_id,
'CidrBlock' => cidr_block }
- request_hash['AvailabilityZone'] = availability_zone unless availability_zone.blank?
+ request_hash['AvailabilityZone'] = availability_zone unless availability_zone.right_blank?
link = generate_request("CreateSubnet", request_hash)
request_info(link, QEc2DescribeSubnetsParser.new(:logger => @logger)).first
rescue Exception
@@ -301,7 +301,7 @@ def describe_vpn_gateways(*list_and_filters)
#
def create_vpn_gateway(type, availability_zone=nil)
request_hash = { 'Type' => type }
- request_hash['AvailabilityZone'] = availability_zone unless availability_zone.blank?
+ request_hash['AvailabilityZone'] = availability_zone unless availability_zone.right_blank?
link = generate_request("CreateVpnGateway", request_hash )
request_info(link, QEc2DescribeVpnGatewaysParser.new(:logger => @logger)).first
rescue Exception
@@ -520,7 +520,7 @@ def tagend(name)
@attachment[:state] = @text
when "#{@p1}/attachments/item",
"#{@p2}/attachments/item"
- @item[:attachments] << @attachment unless @attachment.blank?
+ @item[:attachments] << @attachment unless @attachment.right_blank?
when @p1, @p2
@result << @item
end
View
6 lib/elb/right_elb_interface.rb
@@ -166,7 +166,7 @@ def describe_load_balancers(*load_balancers)
load_balancers = load_balancers.flatten.compact
request_hash = amazonize_list("LoadBalancerNames.member", load_balancers)
link = generate_request("DescribeLoadBalancers", request_hash)
- request_cache_or_info(:describe_load_balancers, link, DescribeLoadBalancersParser, @@bench, load_balancers.blank?)
+ request_cache_or_info(:describe_load_balancers, link, DescribeLoadBalancersParser, @@bench, load_balancers.right_blank?)
end
# Create new load balancer.
@@ -183,7 +183,7 @@ def create_load_balancer(load_balancer_name, availability_zones=[], listeners=[]
# merge zones
request_hash.merge!( amazonize_list("AvailabilityZones.member", availability_zones) )
# merge listeners
- if listeners.blank?
+ if listeners.right_blank?
listeners = { :protocol => :http,
:load_balancer_port => 80,
:instance_port => 80 }
@@ -251,7 +251,7 @@ def disable_availability_zones_for_load_balancer(load_balancer_name, *availabili
#
def configure_health_check(load_balancer_name, health_check)
request_hash = { 'LoadBalancerName' => load_balancer_name }
- health_check.each{ |key, value| request_hash["HealthCheck.#{key.to_s.camelize}"] = value }
+ health_check.each{ |key, value| request_hash["HealthCheck.#{key.to_s.right_camelize}"] = value }
link = generate_request("ConfigureHealthCheck", request_hash)
request_info(link, HealthCheckParser.new(:logger => @logger))
end
View
74 lib/rds/right_rds_interface.rb
@@ -94,7 +94,7 @@ def incrementally_list_items(action, parser_class, params={}, &block) # :nodoc:
link = generate_request(action, params)
last_response = request_info( link, parser_class.new(:logger => @logger))
params['Marker'] = last_response[:marker]
- break unless block && block.call(last_response) && !last_response[:marker].blank?
+ break unless block && block.call(last_response) && !last_response[:marker].right_blank?
end
last_response
end
@@ -194,20 +194,20 @@ def create_db_instance(aws_id, master_username, master_user_password, params={})
request_hash['MasterUsername'] = master_username
request_hash['MasterUserPassword'] = master_user_password
# Mandatory with default values
- request_hash['DBInstanceClass'] = params[:instance_class].blank? ? DEFAULT_INSTANCE_CLASS : params[:instance_class].to_s
- request_hash['AllocatedStorage'] = params[:allocated_storage].blank? ? 25 : params[:allocated_storage]
- request_hash['Engine'] = params[:engine].blank? ? 'MySQL5.1' : params[:engine]
+ request_hash['DBInstanceClass'] = params[:instance_class].right_blank? ? DEFAULT_INSTANCE_CLASS : params[:instance_class].to_s
+ request_hash['AllocatedStorage'] = params[:allocated_storage].right_blank? ? 25 : params[:allocated_storage]
+ request_hash['Engine'] = params[:engine].right_blank? ? 'MySQL5.1' : params[:engine]
# Optional
- request_hash['EndpointPort'] = params[:endpoint_port] unless params[:endpoint_port].blank?
- request_hash['DBName'] = params[:db_name] unless params[:db_name].blank?
- request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].blank?
+ request_hash['EndpointPort'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
+ request_hash['DBName'] = params[:db_name] unless params[:db_name].right_blank?
+ request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
request_hash['MultiAZ'] = params[:multi_az].to_s unless params[:multi_az].nil?
- request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].blank?
- request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].blank?
- request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].blank?
+ request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].right_blank?
+ request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].right_blank?
+ request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].right_blank?
request_hash.merge!(amazonize_list('DBSecurityGroups.member', params[:db_security_groups]))
# request_hash.merge!(amazonize_list('DBParameterGroups.member', params[:db_parameter_groups]))
- request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].blank?
+ request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].right_blank?
link = generate_request('CreateDBInstance', request_hash)
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
end
@@ -224,17 +224,17 @@ def modify_db_instance(aws_id, params={})
# Mandatory
request_hash['DBInstanceIdentifier'] = aws_id
# Optional
- request_hash['MasterUserPassword'] = params[:master_user_password] unless params[:master_user_password].blank?
- request_hash['DBInstanceClass'] = params[:instance_class].to_s.capitalize unless params[:instance_class].blank?
- request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].blank?
- request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].blank?
- request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].blank?
- request_hash['AllocatedStorage'] = params[:allocated_storage] unless params[:allocated_storage].blank?
+ request_hash['MasterUserPassword'] = params[:master_user_password] unless params[:master_user_password].right_blank?
+ request_hash['DBInstanceClass'] = params[:instance_class].to_s.capitalize unless params[:instance_class].right_blank?
+ request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].right_blank?
+ request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].right_blank?
+ request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].right_blank?
+ request_hash['AllocatedStorage'] = params[:allocated_storage] unless params[:allocated_storage].right_blank?
request_hash['MultiAZ'] = params[:multi_az].to_s unless params[:multi_az].nil?
- request_hash['ApplyImmediately'] = params[:apply_immediately].to_s unless params[:apply_immediately].blank?
+ request_hash['ApplyImmediately'] = params[:apply_immediately].to_s unless params[:apply_immediately].right_blank?
request_hash.merge!(amazonize_list('DBSecurityGroups.member', params[:db_security_groups]))
# request_hash.merge!(amazonize_list('DBParameterGroups.member', params[:db_parameter_groups]))
- request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].blank?
+ request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].right_blank?
link = generate_request('ModifyDBInstance', request_hash)
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
end
@@ -273,11 +273,11 @@ def delete_db_instance(aws_id, params={})
request_hash = {}
request_hash['DBInstanceIdentifier'] = aws_id
request_hash['SkipFinalSnapshot'] = params.has_key?(:skip_final_snapshot) ? params[:skip_final_snapshot].to_s : 'false'
- if request_hash['SkipFinalSnapshot'] == 'false' && params[:snapshot_aws_id].blank?
+ if request_hash['SkipFinalSnapshot'] == 'false' && params[:snapshot_aws_id].right_blank?
params = params.dup
params[:snapshot_aws_id] = "#{aws_id}-final-snapshot-#{Time.now.utc.strftime('%Y%m%d%H%M%S')}"
end
- request_hash['FinalDBSnapshotIdentifier'] = params[:snapshot_aws_id] unless params[:snapshot_aws_id].blank?
+ request_hash['FinalDBSnapshotIdentifier'] = params[:snapshot_aws_id] unless params[:snapshot_aws_id].right_blank?
link = generate_request('DeleteDBInstance', request_hash)
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
end
@@ -319,7 +319,7 @@ def delete_db_instance(aws_id, params={})
#
def describe_db_security_groups(*db_security_group_name, &block)
items, params = AwsUtils::split_items_and_params(db_security_group_name)
- params['DBSecurityGroupName'] = items.first unless items.blank?
+ params['DBSecurityGroupName'] = items.first unless items.right_blank?
result = []
incrementally_list_items('DescribeDBSecurityGroups', DescribeDbSecurityGroupsParser, params) do |response|
result += response[:db_security_groups]
@@ -346,9 +346,9 @@ def create_db_security_group(db_security_group_name, db_security_group_descripti
def modify_db_security_group_ingress(action, db_security_group_name, params={}) # :nodoc:
request_hash = { 'DBSecurityGroupName' => db_security_group_name}
- request_hash['CIDRIP'] = params[:cidrip] unless params[:cidrip].blank?
- request_hash['EC2SecurityGroupName'] = params[:ec2_security_group_name] unless params[:ec2_security_group_name].blank?
- request_hash['EC2SecurityGroupOwnerId'] = params[:ec2_security_group_owner] unless params[:ec2_security_group_owner].blank?
+ request_hash['CIDRIP'] = params[:cidrip] unless params[:cidrip].right_blank?
+ request_hash['EC2SecurityGroupName'] = params[:ec2_security_group_name] unless params[:ec2_security_group_name].right_blank?
+ request_hash['EC2SecurityGroupOwnerId'] = params[:ec2_security_group_owner] unless params[:ec2_security_group_owner].right_blank?
link = generate_request(action, request_hash)
request_info(link, DescribeDbSecurityGroupsParser.new(:logger => @logger))[:db_security_groups].first
end
@@ -436,7 +436,7 @@ def delete_db_security_group(db_security_group_name)
#
def describe_db_parameter_groups(*db_parameter_group_name, &block)
items, params = AwsUtils::split_items_and_params(db_parameter_group_name)
- params['DBParameterGroupName'] = items.first unless items.blank?
+ params['DBParameterGroupName'] = items.first unless items.right_blank?
result = []
incrementally_list_items('DescribeDBParameterGroups', DescribeDbParameterGroupsParser, params) do |response|
result += response[:db_parameter_groups]
@@ -472,7 +472,7 @@ def modify_db_parameter_group(db_parameter_group_name, params={}) # :nodoc:
params.each do |key, value|
method = 'pending-reboot'
if value.is_a?(Hash)
- method = value[:method] unless value[:method].blank?
+ method = value[:method] unless value[:method].right_blank?
value = value[:value]
end
parameters << [key, value, method]
@@ -578,7 +578,7 @@ def describe_db_parameters(*db_parameter_group_name, &block)
# :data_type=>"integer"}, ... ]
#
def describe_engine_default_parameters(*engine, &block)
- engine = ['MySQL5.1'] if engine.blank?
+ engine = ['MySQL5.1'] if engine.right_blank?
item, params = AwsUtils::split_items_and_params(engine)
params['Engine'] = item if item
result = []
@@ -638,7 +638,7 @@ def describe_engine_default_parameters(*engine, &block)
def describe_db_snapshots(params={}, &block)
item, params = AwsUtils::split_items_and_params(params)
params['DBSnapshotIdentifier'] = item if item
- params['DBInstanceIdentifier'] = params.delete(:instance_aws_id) unless params[:instance_aws_id].blank?
+ params['DBInstanceIdentifier'] = params.delete(:instance_aws_id) unless params[:instance_aws_id].right_blank?
result = []
incrementally_list_items('DescribeDBSnapshots', DescribeDbSnapshotsParser, params) do |response|
result += response[:db_snapshots]
@@ -687,9 +687,9 @@ def create_db_snapshot(aws_id, instance_aws_id)
def restore_db_instance_from_db_snapshot(snapshot_aws_id, instance_aws_id, params={})
request_hash = { 'DBSnapshotIdentifier' => snapshot_aws_id,
'DBInstanceIdentifier' => instance_aws_id }
- request_hash['DBInstanceClass'] = params[:instance_class] unless params[:instance_class].blank?
- request_hash['EndpointPort'] = params[:endpoint_port] unless params[:endpoint_port].blank?
- request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].blank?
+ request_hash['DBInstanceClass'] = params[:instance_class] unless params[:instance_class].right_blank?
+ request_hash['EndpointPort'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
+ request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
link = generate_request('RestoreDBInstanceFromDBSnapshot', request_hash)
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
end
@@ -756,11 +756,11 @@ def delete_db_snapshot(aws_id)
#
def describe_events(params={}, &block)
params = params.dup
- params['SourceIdentifier'] = params.delete(:aws_id) unless params[:aws_id].blank?
- params['SourceType'] = params.delete(:source_type) unless params[:source_type].blank?
- params['Duration'] = params.delete(:duration) unless params[:duration].blank?
- params['StartDate'] = fix_date(params.delete(:start_date)) unless params[:start_date].blank?
- params['EndDate'] = fix_date(params.delete(:end_date)) unless params[:end_date].blank?
+ params['SourceIdentifier'] = params.delete(:aws_id) unless params[:aws_id].right_blank?
+ params['SourceType'] = params.delete(:source_type) unless params[:source_type].right_blank?
+ params['Duration'] = params.delete(:duration) unless params[:duration].right_blank?
+ params['StartDate'] = fix_date(params.delete(:start_date)) unless params[:start_date].right_blank?
+ params['EndDate'] = fix_date(params.delete(:end_date)) unless params[:end_date].right_blank?
result = []
incrementally_list_items('DescribeEvents', DescribeEventsParser, params) do |response|
result += response[:events]
View
6 lib/s3/right_s3.rb
@@ -249,7 +249,7 @@ def keys_and_service(options={}, head=false)
# key.head
#
def key(key_name, head=false)
- raise 'Key name can not be empty.' if key_name.blank?
+ raise 'Key name can not be empty.' if key_name.right_blank?
key_instance = nil
# if this key exists - find it ....
keys({'prefix'=>key_name}, head).each do |key|
@@ -650,7 +650,7 @@ def exists?
# key.delete #=> true
#
def delete
- raise 'Key name must be specified.' if @name.blank?
+ raise 'Key name must be specified.' if @name.right_blank?
@bucket.s3.interface.delete(@bucket, @name)
end
@@ -1086,7 +1086,7 @@ def initialize(bucket, name, meta_headers={})
@bucket = bucket
@name = name.to_s
@meta_headers = meta_headers
- raise 'Key name can not be empty.' if @name.blank?
+ raise 'Key name can not be empty.' if @name.right_blank?
end
# Generate link to PUT key data.
View
16 lib/s3/right_s3_interface.rb
@@ -214,7 +214,7 @@ def create_bucket(bucket, headers={})
else headers[:location].to_s
end
- unless location.blank?
+ unless location.right_blank?
data = "<CreateBucketConfiguration><LocationConstraint>#{location}</LocationConstraint></CreateBucketConfiguration>"
end
req_hash = generate_rest_request('PUT', headers.merge(:url=>bucket, :data => data))
@@ -300,7 +300,7 @@ def delete_bucket(bucket, headers={})
# 'max-keys' => "5"}, ..., {...}]
#
def list_bucket(bucket, options={}, headers={})
- bucket += '?'+options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.blank?
+ bucket += '?'+options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.right_blank?
req_hash = generate_rest_request('GET', headers.merge(:url=>bucket))
request_info(req_hash, S3ListBucketParser.new(:logger => @logger))
rescue
@@ -335,10 +335,10 @@ def list_bucket(bucket, options={}, headers={})
# ]
# }
def incrementally_list_bucket(bucket, options={}, headers={}, &block)
- internal_options = options.symbolize_keys
+ internal_options = options.right_symbolize_keys
begin
internal_bucket = bucket.dup
- internal_bucket += '?'+internal_options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless internal_options.blank?
+ internal_bucket += '?'+internal_options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless internal_options.right_blank?
req_hash = generate_rest_request('GET', headers.merge(:url=>internal_bucket))
response = request_info(req_hash, S3ImprovedListBucketParser.new(:logger => @logger))
there_are_more_keys = response[:is_truncated]
@@ -701,7 +701,7 @@ def rename(src_bucket, src_key, dest_key, headers={})
# <Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>" }
#
def get_acl(bucket, key='', headers={})
- key = key.blank? ? '' : "/#{CGI::escape key}"
+ key = key.right_blank? ? '' : "/#{CGI::escape key}"
req_hash = generate_rest_request('GET', headers.merge(:url=>"#{bucket}#{key}?acl"))
request_info(req_hash, S3HttpResponseBodyParser.new)
rescue
@@ -731,7 +731,7 @@ def get_acl(bucket, key='', headers={})
# :display_name=>"root"}}
#
def get_acl_parse(bucket, key='', headers={})
- key = key.blank? ? '' : "/#{CGI::escape key}"
+ key = key.right_blank? ? '' : "/#{CGI::escape key}"
req_hash = generate_rest_request('GET', headers.merge(:url=>"#{bucket}#{key}?acl"))
acl = request_info(req_hash, S3AclParser.new(:logger => @logger))
result = {}
@@ -755,7 +755,7 @@ def get_acl_parse(bucket, key='', headers={})
# Sets the ACL on a bucket or object.
def put_acl(bucket, key, acl_xml_doc, headers={})
- key = key.blank? ? '' : "/#{CGI::escape key}"
+ key = key.right_blank? ? '' : "/#{CGI::escape key}"
req_hash = generate_rest_request('PUT', headers.merge(:url=>"#{bucket}#{key}?acl", :data=>acl_xml_doc))
request_info(req_hash, S3HttpResponseBodyParser.new)
rescue
@@ -889,7 +889,7 @@ def delete_bucket_link(bucket, expires=nil, headers={})
# s3.list_bucket_link('my_awesome_bucket') #=> url string
#
def list_bucket_link(bucket, options=nil, expires=nil, headers={})
- bucket += '?' + options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.blank?
+ bucket += '?' + options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.right_blank?
generate_link('GET', headers.merge(:url=>bucket), expires)
rescue
on_exception
View
34 lib/sdb/active_sdb.rb
@@ -463,7 +463,7 @@ def select_from_ids(args, options) # :nodoc:
# user defined :conditions to string (if it was defined)
options[:conditions] = build_conditions(options[:conditions])
# join ids condition and user defined conditions
- options[:conditions] = options[:conditions].blank? ? ids_cond : "(#{options[:conditions]}) AND #{ids_cond}"
+ options[:conditions] = options[:conditions].right_blank? ? ids_cond : "(#{options[:conditions]}) AND #{ids_cond}"
result = sql_select(options)
# if one record was requested then return it
unless bunch_of_records_requested
@@ -552,7 +552,7 @@ def query(options) # :nodoc:
query_expression = query_expression.to_s
# quote from Amazon:
# The sort attribute must be present in at least one of the predicates of the query expression.
- if query_expression.blank?
+ if query_expression.right_blank?
query_expression = sort_query_expression
elsif !query_attributes(query_expression).include?(sort_by)
query_expression += " intersection #{sort_query_expression}"
@@ -605,7 +605,7 @@ def find_from_ids(args, options) # :nodoc:
# user defined :conditions to string (if it was defined)
options[:conditions] = build_conditions(options[:conditions])
# join ids condition and user defined conditions
- options[:conditions] = options[:conditions].blank? ? ids_cond : "#{options[:conditions]} intersection #{ids_cond}"
+ options[:conditions] = options[:conditions].right_blank? ? ids_cond : "#{options[:conditions]} intersection #{ids_cond}"
result = find_every(options)
# if one record was requested then return it
unless bunch_of_records_requested
@@ -656,9 +656,9 @@ def build_select(options) # :nodoc:
order = options[:order] ? " ORDER BY #{options[:order]}" : ''
limit = options[:limit] ? " LIMIT #{options[:limit]}" : ''
# mix sort by argument (it must present in response)
- unless order.blank?
+ unless order.right_blank?
sort_by, sort_order = sort_options(options[:order])
- conditions << (conditions.blank? ? " WHERE " : " AND ") << "(#{sort_by} IS NOT NULL)"
+ conditions << (conditions.right_blank? ? " WHERE " : " AND ") << "(#{sort_by} IS NOT NULL)"
end
"SELECT #{select} FROM #{from}#{conditions}#{order}#{limit}"
end
@@ -745,7 +745,7 @@ def attributes
def attributes=(attrs)
old_id = @attributes['id']
@attributes = uniq_values(attrs)
- @attributes['id'] = old_id if @attributes['id'].blank? && !old_id.blank?
+ @attributes['id'] = old_id if @attributes['id'].right_blank? && !old_id.right_blank?
self.attributes
end
@@ -799,7 +799,7 @@ def reload
old_id = id
attrs = connection.get_attributes(domain, id)[:attributes]
@attributes = {}
- unless attrs.blank?
+ unless attrs.right_blank?
attrs.each { |attribute, values| @attributes[attribute] = values }
@attributes['id'] = old_id
end
@@ -825,7 +825,7 @@ def reload_attributes(*attrs_list)
attrs_list.flatten.uniq.each do |attribute|
attribute = attribute.to_s
values = connection.get_attributes(domain, id, attribute)[:attributes][attribute]
- unless values.blank?
+ unless values.right_blank?
@attributes[attribute] = result[attribute] = values
else
@attributes.delete(attribute)
@@ -855,7 +855,7 @@ def put
prepare_for_update
attrs = @attributes.dup
attrs.delete('id')
- connection.put_attributes(domain, id, attrs) unless attrs.blank?
+ connection.put_attributes(domain, id, attrs) unless attrs.right_blank?
connection.put_attributes(domain, id, { 'id' => id }, :replace)
mark_as_old
@attributes
@@ -871,10 +871,10 @@ def put_attributes(attrs)
prepare_for_update
# if 'id' is present in attrs hash:
# replace internal 'id' attribute and remove it from the attributes to be sent
- @attributes['id'] = attrs['id'] unless attrs['id'].blank?
+ @attributes['id'] = attrs['id'] unless attrs['id'].right_blank?
attrs.delete('id')
# add new values to all attributes from list
- connection.put_attributes(domain, id, attrs) unless attrs.blank?
+ connection.put_attributes(domain, id, attrs) unless attrs.right_blank?
connection.put_attributes(domain, id, { 'id' => id }, :replace)
attrs.each do |attribute, values|
@attributes[attribute] ||= []
@@ -918,12 +918,12 @@ def save_attributes(attrs)
prepare_for_update
attrs = uniq_values(attrs)
# if 'id' is present in attrs hash then replace internal 'id' attribute
- unless attrs['id'].blank?
+ unless attrs['id'].right_blank?
@attributes['id'] = attrs['id']
else
attrs['id'] = id
end
- connection.put_attributes(domain, id, attrs, :replace) unless attrs.blank?
+ connection.put_attributes(domain, id, attrs, :replace) unless attrs.right_blank?
attrs.each { |attribute, values| attrs[attribute] = values }
mark_as_old
attrs
@@ -942,7 +942,7 @@ def delete_values(attrs)
raise_on_id_absence
attrs = uniq_values(attrs)
attrs.delete('id')
- unless attrs.blank?
+ unless attrs.right_blank?
connection.delete_attributes(domain, id, attrs)
attrs.each do |attribute, values|
# remove the values from the attribute
@@ -971,7 +971,7 @@ def delete_attributes(*attrs_list)
raise_on_id_absence
attrs_list = attrs_list.flatten.map{ |attribute| attribute.to_s }
attrs_list.delete('id')
- unless attrs_list.blank?
+ unless attrs_list.right_blank?
connection.delete_attributes(domain, id, attrs_list)
attrs_list.each { |attribute| @attributes.delete(attribute) }
end
@@ -1026,7 +1026,7 @@ def raise_on_id_absence
end
def prepare_for_update
- @attributes['id'] = self.class.generate_id if @attributes['id'].blank?
+ @attributes['id'] = self.class.generate_id if @attributes['id'].right_blank?
columns.all.each do |col_name|
self[col_name] ||= columns.default(col_name)
end
@@ -1044,7 +1044,7 @@ def uniq_values(attributes=nil) # :nodoc:
else
Array(values).uniq
end
- attrs.delete(attribute) if values.blank?
+ attrs.delete(attribute) if values.right_blank?
end
attrs
end
View
4 lib/sdb/right_sdb_interface.rb
@@ -170,7 +170,7 @@ def select_response_to_ruby(response) #:nodoc:
# (similar to ActiveRecord::Base#find using :conditions => ['query', param1, .., paramN])
#
def query_expression_from_array(params) #:nodoc:
- return '' if params.blank?
+ return '' if params.right_blank?
query = params.shift.to_s
query.gsub(/(\\)?(\?)/) do
if $1 # if escaped '\?' is found - replace it by '?' without backslash
@@ -182,7 +182,7 @@ def query_expression_from_array(params) #:nodoc:
end
def query_expression_from_hash(hash)
- return '' if hash.blank?
+ return '' if hash.right_blank?
expression = []
hash.each do |key, value|
expression << "#{key}=#{escape(value)}"
View
2  lib/sqs/right_sqs.rb
@@ -271,7 +271,7 @@ def grantees(grantee_email_address=nil, permission = nil)
grantees << Grantee.new(self, grantee_email_address, key, value[:name], value[:perms])
end
if grantee_email_address
- grantees.blank? ? nil : grantees.shift
+ grantees.right_blank? ? nil : grantees.shift
else
grantees
end
View
6 lib/sqs/right_sqs_gen2_interface.rb
@@ -201,7 +201,7 @@ def delete_queue(queue_url)
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/index.html?Query_QueryGetQueueAttributes.html
def get_queue_attributes(queue_url, *attributes)
attributes.flatten!
- attributes << 'All' if attributes.blank?
+ attributes << 'All' if attributes.right_blank?
params = amazonize_list('AttributeName', attributes)
params.merge!(:queue_url => queue_url)
req_hash = generate_request('GetQueueAttributes', params)
@@ -282,7 +282,7 @@ def remove_permissions(queue_url, label)
def receive_message(queue_url, max_number_of_messages=1, visibility_timeout=nil, attributes=nil)
return [] if max_number_of_messages == 0
params = {}
- params.merge!(amazonize_list('AttributeName', Array(attributes))) unless attributes.blank?
+ params.merge!(amazonize_list('AttributeName', Array(attributes))) unless attributes.right_blank?
params.merge!('MaxNumberOfMessages' => max_number_of_messages,
'VisibilityTimeout' => visibility_timeout,
:queue_url => queue_url )
@@ -429,7 +429,7 @@ def pop_messages(queue_url, number_of_messages=1, attributes=nil)
#
def pop_message(queue_url, attributes=nil)
messages = pop_messages(queue_url, 1, attributes)
- messages.blank? ? nil : messages[0]
+ messages.right_blank? ? nil : messages[0]
rescue
on_exception
end
View
8 lib/sqs/right_sqs_interface.rb
@@ -104,7 +104,7 @@ def generate_rest_request(method, param) # :nodoc:
param.each{ |key, value| param.delete(key) if (value.nil? || key.is_a?(Symbol)) }
# created request
param_to_str = param.to_a.collect{|key,val| key.to_s + "=" + CGI::escape(val.to_s) }.join("&")
- param_to_str = "?#{param_to_str}" unless param_to_str.blank?
+ param_to_str = "?#{param_to_str}" unless param_to_str.right_blank?
request = "Net::HTTP::#{method.capitalize}".constantize.new("#{queue_uri}#{param_to_str}")
request.body = message if message
# set main headers
@@ -311,7 +311,7 @@ def receive_messages(queue_url, number_of_messages=1, visibility_timeout=nil)
def peek_message(queue_url, message_id)
req_hash = generate_rest_request('GET', :queue_url => "#{queue_url}/#{CGI::escape message_id}" )
messages = request_info(req_hash, SqsReceiveMessagesParser.new(:logger => @logger))
- messages.blank? ? nil : messages[0]
+ messages.right_blank? ? nil : messages[0]
rescue
on_exception
end
@@ -452,7 +452,7 @@ def force_delete_queue(queue_url)
#
def receive_message(queue_url, visibility_timeout=nil)
result = receive_messages(queue_url, 1, visibility_timeout)
- result.blank? ? nil : result[0]
+ result.right_blank? ? nil : result[0]
rescue
on_exception
end
@@ -482,7 +482,7 @@ def pop_messages(queue_url, number_of_messages=1)
#
def pop_message(queue_url)
messages = pop_messages(queue_url)
- messages.blank? ? nil : messages[0]
+ messages.right_blank? ? nil : messages[0]
rescue
on_exception
end
View
2  test/s3/test_right_s3.rb
@@ -264,7 +264,7 @@ def test_26_save_meta
# create a key
key = bucket.key('test/copy/30')
key.put(RIGHT_OBJECT_TEXT)
- assert key.meta_headers.blank?
+ assert key.meta_headers.right_blank?
# store some meta keys
meta = {'family' => 'oops','race' => 'troll'}
assert_equal meta, key.save_meta(meta)
View
2  test/sdb/test_active_sdb.rb
@@ -77,7 +77,7 @@ def test_01_create_domain
def test_02_create_items
# check that DB is empty
clients = Client.find(:all)
- assert clients.blank?
+ assert clients.right_blank?
# put some clients there
@clients.each do |client|
Client.create client
View
2  test/sqs/test_right_sqs_gen2.rb
@@ -94,7 +94,7 @@ def test_05_add_permissions
def test_06_test_permissions
queue_url = @sqs.queue_url_by_name(@queue_name)
permissions = @sqs.get_queue_attributes(queue_url, 'Policy')
- assert !permissions.blank?
+ assert !permissions.right_blank?
end
def test_07_revoke_permissions
Please sign in to comment.
Something went wrong with that request. Please try again.