shy_flag 0.1.6 → 0.1.7

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: d8b221f093fb46ac2a1910b298cc2bcdc73e633f
4
- data.tar.gz: 0089e54a7bb5fefa920b78ff51d15d4faa19ef7b
3
+ metadata.gz: 279f0879e90251e489b413b19114d18b801a37f9
4
+ data.tar.gz: 73c96641062ef443c6218c6449cc762e98cf2768
5
5
  SHA512:
6
- metadata.gz: bb127207b2a6fc6d8616a8150d82def2b795bc94b37618261bc7c15eeca7ad016c9fb53bea3fda6cb94e092ec08afe3ceaac4f9ac2f55d63774a386912238947
7
- data.tar.gz: 5fe5010737ca6d9b862657cd17e95600c2bd0bf9a5e85a6ad9219817dc280d74f7b8e9dd11bbb50457213ecfd214553607f3f46ed002f69f28ab9cf11614209e
6
+ metadata.gz: 90f971511dd04dbd500491aba8c2b5e8fa3e34c5fe775ad831232eb9e5cc4db90d7c2411ddfadb8a4c90fe5e6fa3534a1dae040da144e6c2ab8435c5512ed574
7
+ data.tar.gz: 84e8adb6553fedd0229db6c49789356d96afd07e64bd43936da5c5ac011d5003d0f88ebd35ec4c0d4842e70a6bd2d7c64bbb16565dcea3f50f7a9cd19fc615f2
data/README.md CHANGED
@@ -14,11 +14,11 @@ And then execute:
14
14
 
15
15
  ## Usage
16
16
 
17
- ShyFlag.get(aws_region,bucket_name,object_key,expir_time)
17
+ ShyFlag.get(aws_region,bucket_name,object_key,expir_time,credential)
18
18
 
19
- aws_region, bucket_name, object_key are required
19
+ aws_region, bucket_name, object_key, expir_time(eg: 3600 means 1 hour) are required
20
20
 
21
- expir_time is optional, default value is 3600(1h)
21
+ credential is optional (eg: {"access_key_id"=>"xxxxxxxxxxxxx","secret_access_key"=>"xxxxxxxxxxxxxxxxxxxxx"})
22
22
 
23
23
 
24
24
  #Recommendation
data/lib/s3/s3_loader.rb CHANGED
@@ -1,15 +1,18 @@
1
1
  require 'aws-sdk-s3'
2
2
 
3
3
  class S3Loader
4
- def initialize(region, bucket, key)
5
- @region=region
6
- @s3=s3_client
4
+ def initialize(region, bucket, key, credential)
5
+ @s3=s3_client(credential, region)
7
6
  @bucket=bucket
8
7
  @key=key
9
8
  end
10
9
 
11
- def s3_client
12
- Aws::S3::Client.new(region: @region)
10
+ def s3_client(credential, region)
11
+ if credential.nil?
12
+ Aws::S3::Client.new(region: region)
13
+ else
14
+ Aws::S3::Client.new(region: region,credentials: Aws::Credentials.new(credential['access_key_id'], credential['secret_access_key']))
15
+ end
13
16
  end
14
17
 
15
18
  def get_image_from_s3()
data/lib/shy_flag.rb CHANGED
@@ -2,10 +2,10 @@ require "version"
2
2
  require "s3/s3_loader"
3
3
 
4
4
  module ShyFlag
5
- def self.get(region, bucket, key, expire = 3600)
5
+ def self.get(region, bucket, key, expire = 3600, credential = nil)
6
6
  @expire = expire
7
7
  if(@expiration.nil? || @expiration < Time.now())
8
- @results = S3Loader.new(region, bucket, key).get_image_from_s3()
8
+ @results = S3Loader.new(region, bucket, key, credential).get_image_from_s3()
9
9
  @expiration = Time.now()+ @expire
10
10
  end
11
11
  @results
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ShyFlag
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shy_flag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - shyshenhaoyu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-09 00:00:00.000000000 Z
11
+ date: 2018-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler