Sha256: b08ac012da5ae3f2a1049b7f2b543b372e2f7e5eb9d458b8c72b68c1d8a3fd30
Contents?: true
Size: 998 Bytes
Versions: 3
Compression:
Stored size: 998 Bytes
Contents
module Elasticity class AwsUtils # Escape a string according to Amazon's rules. # See: http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/index.html?REST_RESTAuth.html def self.aws_escape(param) param.to_s.gsub(/([^a-zA-Z0-9._~-]+)/n) do '%' + $1.unpack('H2' * $1.size).join('%').upcase end end # With the advent of v4 signing, we can skip the complex translation from v2 # and ship the JSON over with nearly the same structure. def self.convert_ruby_to_aws_v4(value) case value when Array return value.map{|v| convert_ruby_to_aws_v4(v)} when Hash result = {} value.each do |k,v| result[camelize(k.to_s)] = convert_ruby_to_aws_v4(v) end return result else return value end end def self.camelize(word) word.to_s.gsub(/\/(.?)/) { '::' + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
elasticity-6.0.14 | lib/elasticity/aws_utils.rb |
elasticity-6.0.13 | lib/elasticity/aws_utils.rb |
elasticity-6.0.12 | lib/elasticity/aws_utils.rb |