crossing 0.0.8 → 0.1.0
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 +4 -4
- data/lib/crossing.rb +30 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea547ab9192c22203ae5940c83cc60142d219d26
|
4
|
+
data.tar.gz: 553d987c1b449c4f6bd92cf7ce6e3e616d400a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb6f637721a02d7885209a2db1ce229412664ff3e5337f4fee12fadad8f684730726e796b4b27b5be35453e755b5b5e127eb1c0cd3d5d5efa39eee34cdcf2da
|
7
|
+
data.tar.gz: ec738d813b1cd0c45c63aa77dc88f639df2e645b0cab40a72e09f2719addd975889e345d466e87bc6ec99a572d3992d8461ca0f7f60eb035151a2ead3180878f
|
data/lib/crossing.rb
CHANGED
@@ -2,10 +2,18 @@ require 'aws-sdk'
|
|
2
2
|
|
3
3
|
# Documentation incoming
|
4
4
|
class Crossing
|
5
|
-
def initialize(
|
6
|
-
raise CrossingMisconfigurationException if
|
7
|
-
raise CrossingMisconfigurationException unless
|
8
|
-
@
|
5
|
+
def initialize(s3_client_encrypted, s3_client_unencrypted = nil)
|
6
|
+
raise CrossingMisconfigurationException if s3_client_encrypted.nil?
|
7
|
+
raise CrossingMisconfigurationException unless s3_client_encrypted.is_a? Aws::S3::Encryption::Client
|
8
|
+
@s3_client_encrypted = s3_client_encrypted
|
9
|
+
|
10
|
+
if !s3_client_unencrypted.nil?
|
11
|
+
raise CrossingMisconfigurationException unless s3_client_unencrypted.is_a? Aws::S3::Client
|
12
|
+
@s3_client_unencrypted = s3_client_unencrypted
|
13
|
+
else
|
14
|
+
# create regular s3 client
|
15
|
+
@s3_client_unencrypted = Aws::S3::Client.new
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
19
|
def put(bucket, filename)
|
@@ -17,10 +25,10 @@ class Crossing
|
|
17
25
|
end
|
18
26
|
|
19
27
|
def put_content(bucket, filename, content)
|
20
|
-
@
|
21
|
-
|
22
|
-
|
23
|
-
|
28
|
+
@s3_client_encrypted.put_object(bucket: bucket,
|
29
|
+
key: File.basename(filename),
|
30
|
+
body: content,
|
31
|
+
tagging: 'x-crossing-uploaded=true')
|
24
32
|
end
|
25
33
|
|
26
34
|
def get(bucket, file)
|
@@ -34,8 +42,21 @@ class Crossing
|
|
34
42
|
File.open(file, 'wb') { |f| f.write(content) }
|
35
43
|
end
|
36
44
|
|
45
|
+
def get_multiple(bucket, filelist)
|
46
|
+
filelist.each { |file| get(bucket, file) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def put_multiple(bucket, filelist)
|
50
|
+
filelist.each { |file| put(bucket, file) }
|
51
|
+
end
|
52
|
+
|
37
53
|
def get_content(bucket, file)
|
38
|
-
@
|
54
|
+
@s3_client_encrypted.get_object(bucket: bucket, key: file).body.read
|
55
|
+
|
56
|
+
# If a decryption exception occurs, warn and get the object without decryption
|
57
|
+
rescue Aws::S3::Encryption::Errors::DecryptionError
|
58
|
+
STDERR.puts "WARNING: #{file} decryption failed. Retreiving the object without encryption."
|
59
|
+
@s3_client_unencrypted.get_object(bucket: bucket, key: file).body.read
|
39
60
|
end
|
40
61
|
end
|
41
62
|
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crossing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Ulick
|
8
8
|
- Jonny Sywulak
|
9
|
+
- Keith Monihen
|
9
10
|
- Stelligent
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: aws-sdk
|