presigner 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bc078b5581b47872e4a16ddd84d141d05b2534b
4
- data.tar.gz: 95f1bab9734e9585675892ae7e6eee45984bc0a0
3
+ metadata.gz: a3f4adbfcecd30e2ef055e30422d4c742a896a58
4
+ data.tar.gz: aa759f581b9af22456040a3e952b9f7bbb00455c
5
5
  SHA512:
6
- metadata.gz: 293766fec750b62011d0b516f41d1ff192eab8777a37b9f042489c8fc80e73ba681c94d9c62cd69a9e6e82a2656d861af64cd9c50adcef20d44f4e1c4943f6ee
7
- data.tar.gz: 3e039b1041d918816f2a4cd5ba34166ba7b62ccb048cb7414e97ab5920dc2841914061c88e85fdae64f6d0872bf6c6f3e1a5093abb586cc64f0824cce30c340e
6
+ metadata.gz: d9585fa043433eb7240c86ebc5da7f804bdffea17af4e9b54474a5e2af8120a56c525c2ba473d764908fac70c6a7aff0b2a840fdc7c38f586934b5090c8cb0f9
7
+ data.tar.gz: 1ac7da801128d21b2d1f6aee27a141521d5d7b138bcfe7e67af2e9b4761748088e54bbe44a7da5a2b0f65a6bb0137d9c9b694bcf8e0069d971e3ecee3fdb586c
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.3
4
+ - 2.2.0
5
+ - 2.0.0-p247
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Presigner
1
+ # Presigner [![Build Status](https://travis-ci.org/masaomoc/presigner.svg?branch=master)](https://travis-ci.org/masaomoc/presigner)
2
2
 
3
3
  Presigner is a CLI tool to generate Pre-Signed URL for Amazon S3.
4
4
 
data/lib/presigner.rb CHANGED
@@ -9,15 +9,16 @@ class Presigner
9
9
  def initialize(options)
10
10
  @bucket = options[:bucket]
11
11
  @key = options[:key]
12
- @duration = options[:duration].nil? ? DEFAULT_DURATION : options[:duration].to_i
12
+ @duration = options[:duration] || DEFAULT_DURATION
13
+ @region = options[:region] || "us-east-1"
13
14
  @base = Time.now.to_i
14
15
  end
15
16
 
16
- attr_reader :duration, :base, :bucket, :key
17
+ attr_reader :duration, :base, :bucket, :key, :region
17
18
 
18
19
  def generate
19
20
 
20
- s3 = AWS::S3.new
21
+ s3 = AWS::S3.new(region: region)
21
22
  # check if specified bucket and key exist.
22
23
  begin
23
24
  target_obj = s3.buckets[bucket].objects[key]
@@ -1,3 +1,3 @@
1
1
  class Presigner
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -27,7 +27,26 @@ class PresignerTest < Test::Unit::TestCase
27
27
 
28
28
  test "check if duration calculation is correct" do
29
29
  actual = @presigner.calc_duration
30
- assert_equal(actual, @presigner.base + Presigner::DEFAULT_DURATION)
30
+ assert_equal(actual, Presigner::DEFAULT_DURATION)
31
+ end
32
+
33
+ test "check Presigner.new without optional arguments" do
34
+ presigner = Presigner.new(bucket: 'foobucket',
35
+ key: 'barkey')
36
+ ## maybe < 2 sec.
37
+ assert_true(presigner.base < Time.now.to_i + 2 && presigner.base > Time.now.to_i - 1)
38
+ assert_equal(Presigner::DEFAULT_DURATION, presigner.duration)
39
+ assert_equal("us-east-1", presigner.region)
40
+ end
41
+
42
+ test "check Presigner.new with optional arguments" do
43
+ presigner = Presigner.new(bucket: 'foobucket',
44
+ key: 'barkey',
45
+ duration: 123,
46
+ region: 'ap-northeast-1',
47
+ )
48
+ assert_equal(123, presigner.duration)
49
+ assert_equal("ap-northeast-1", presigner.region)
31
50
  end
32
51
 
33
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: presigner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masao Mochizuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-01 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -149,10 +149,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.2.2
152
+ rubygems_version: 2.4.5.1
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: CLI Tool to generate Pre-Signed URL for Amazon S3
156
156
  test_files:
157
157
  - test/test_presigner.rb
158
- has_rdoc: