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 +4 -4
- data/README.md +3 -3
- data/lib/s3/s3_loader.rb +8 -5
- data/lib/shy_flag.rb +2 -2
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 279f0879e90251e489b413b19114d18b801a37f9
|
4
|
+
data.tar.gz: 73c96641062ef443c6218c6449cc762e98cf2768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|