cognac 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 919761511baee7130f501a32e61618926799b652
4
- data.tar.gz: 44fbca19631cea02f42324770ea4f60bbfdbce18
3
+ metadata.gz: d86971bb20a88cf6d836ee65efce4386553cf6c0
4
+ data.tar.gz: c41738a6e82b804746588401eb22afff221a8d86
5
5
  SHA512:
6
- metadata.gz: 1481ceb5cc53846f9db92cbc24a0bf5b3784b09a4c992e815b2d22a7f39bfeadc37119d8141c576e27ab7d67ef7c6b9d149bc063644e2c928ccc7a5cd01ddb3c
7
- data.tar.gz: e7b2d39d146e3955effedecd3bc04a24bf413ddbc995e60a0227f63e632336bf5398942aae716340c4138b1a08b566dc24c447babcf1430143c848e115d48760
6
+ metadata.gz: f4640a5c398bd1f4f76b6ce9944aa67cf181e9c1d96b5b21432e3ec14df452fe7b7a2a7112e3ee31a63294f8c662ebdf1c94f13cf33e8076ce71639ae14494cc
7
+ data.tar.gz: 6d39d5d12e8a0f2fd48274fd7551307d84e3b9814290cd5867bd7997a9a0adb907069015ee791a3ac6a248961fbaf46ece7933142ce9095924b6264eb782cdf0
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ cognac
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  $ gem install cognac
24
24
 
25
- ## Versions
25
+ ## Dependencies
26
26
 
27
27
  Ruby 2.2.2
28
28
  ActiveSupport 4.2.3
data/cognac.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["bparanj@gmail.com"]
11
11
 
12
12
  spec.summary = %q{A simple library to implement Amazon S3 upload using CORS.}
13
- spec.description = %q{This gem builds the AWS authentication signature as described in http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html. It requires the Amazon keys, as well as options about the request (request type, resource, etc).}
13
+ spec.description = %q{This gem builds the AWS authentication signature as described in http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html. It requires the Amazon keys, as well as options about the request (request type, resource, etc).}
14
14
  spec.homepage = "http://www.rubyplus.com"
15
15
  spec.license = "MIT"
16
16
 
@@ -1,3 +1,3 @@
1
1
  module Cognac
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/cognac.rb CHANGED
@@ -41,10 +41,10 @@ module Cognac
41
41
  Base64.encode64(OpenSSL::HMAC.digest("sha1", secret_access_key, s)).strip
42
42
  end
43
43
 
44
- def self.build_s3_upload_url(endpoint, aws_access_key, secret_access_key, signature_options = {})
45
- signature = ERB::Util.url_encode(build_s3_rest_signature(secret_access_key, signature_options))
46
- expires = signature_options[:date] || an_hour_from_now
47
- "#{endpoint}?AWSAccessKeyId=#{aws_access_key}&Expires=#{expires}&Signature=#{signature}"
44
+ def self.build_s3_upload_url(end_point, aws_access_key, secret_access_key, signature_options = {})
45
+ signature = encoded_signature(secret_access_key, signature_options)
46
+ expires = expiration(signature_options)
47
+ "#{end_point}?AWSAccessKeyId=#{aws_access_key}&Expires=#{expires}&Signature=#{signature}"
48
48
  end
49
49
 
50
50
  def self.generate_options_for_build_s3_upload_url(bucket, file_name, content_type)
@@ -65,5 +65,14 @@ module Cognac
65
65
  def self.an_hour_from_now
66
66
  1.hours.from_now.rfc822
67
67
  end
68
+
69
+ def self.encoded_signature(secret_access_key, signature_options)
70
+ ERB::Util.url_encode(build_s3_rest_signature(secret_access_key, signature_options))
71
+ end
72
+
73
+ def self.expiration(signature_options)
74
+ signature_options[:date] || an_hour_from_now
75
+ end
76
+
68
77
  end
69
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cognac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bala Paranj
@@ -76,6 +76,8 @@ extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
78
  - ".gitignore"
79
+ - ".ruby-gemset"
80
+ - ".ruby-version"
79
81
  - ".travis.yml"
80
82
  - Gemfile
81
83
  - LICENSE.txt