porky_lib 0.9.1 → 0.9.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 +4 -4
- data/.circleci/config.yml +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +23 -23
- data/README.md +2 -2
- data/lib/porky_lib/file_service_helper.rb +14 -4
- data/lib/porky_lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd1dfb255c5b91f06fe66af135ef84ef65fcb96bd02ad5150090619460bd7d86
|
|
4
|
+
data.tar.gz: 5edbf7d85795d8aaff798d486c043464199c03542c924f297559835796b9d829
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc55b6280bce9d76a9d6553e239487f14712ba535fdf83c54006e6cd27c67e8babda30e58632fbf1d76f531bc8c822b96d34a1e0a5209cf4098f436567bd951d
|
|
7
|
+
data.tar.gz: 3e428d8b741ba820b43ef1dc891dd0cd2b3ae81d9b2ba0d578705c84296ade1c4b510eb69e706c8d5869e4153884f1af2a5cd1a22fed09e226a9d694134b6035
|
data/.circleci/config.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
porky_lib (0.9.
|
|
4
|
+
porky_lib (0.9.2)
|
|
5
5
|
aws-sdk-kms
|
|
6
6
|
aws-sdk-s3
|
|
7
7
|
msgpack
|
|
@@ -13,17 +13,17 @@ GEM
|
|
|
13
13
|
specs:
|
|
14
14
|
ast (2.4.0)
|
|
15
15
|
aws-eventstream (1.0.3)
|
|
16
|
-
aws-partitions (1.
|
|
17
|
-
aws-sdk-core (3.
|
|
16
|
+
aws-partitions (1.228.0)
|
|
17
|
+
aws-sdk-core (3.72.0)
|
|
18
18
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
|
19
|
-
aws-partitions (~> 1.0)
|
|
19
|
+
aws-partitions (~> 1, >= 1.228.0)
|
|
20
20
|
aws-sigv4 (~> 1.1)
|
|
21
21
|
jmespath (~> 1.0)
|
|
22
|
-
aws-sdk-kms (1.
|
|
23
|
-
aws-sdk-core (~> 3, >= 3.
|
|
22
|
+
aws-sdk-kms (1.25.0)
|
|
23
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
|
24
24
|
aws-sigv4 (~> 1.1)
|
|
25
|
-
aws-sdk-s3 (1.
|
|
26
|
-
aws-sdk-core (~> 3, >= 3.
|
|
25
|
+
aws-sdk-s3 (1.51.0)
|
|
26
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
|
27
27
|
aws-sdk-kms (~> 1)
|
|
28
28
|
aws-sigv4 (~> 1.1)
|
|
29
29
|
aws-sigv4 (1.1.0)
|
|
@@ -43,8 +43,8 @@ GEM
|
|
|
43
43
|
jmespath (1.4.0)
|
|
44
44
|
json (2.2.0)
|
|
45
45
|
msgpack (1.3.1)
|
|
46
|
-
parallel (1.
|
|
47
|
-
parser (2.6.
|
|
46
|
+
parallel (1.18.0)
|
|
47
|
+
parser (2.6.5.0)
|
|
48
48
|
ast (~> 2.4.0)
|
|
49
49
|
rainbow (3.0.0)
|
|
50
50
|
rake (13.0.0)
|
|
@@ -52,24 +52,24 @@ GEM
|
|
|
52
52
|
ffi
|
|
53
53
|
rbnacl-libsodium (1.0.16)
|
|
54
54
|
rbnacl (>= 3.0.1)
|
|
55
|
-
rspec (3.
|
|
56
|
-
rspec-core (~> 3.
|
|
57
|
-
rspec-expectations (~> 3.
|
|
58
|
-
rspec-mocks (~> 3.
|
|
55
|
+
rspec (3.9.0)
|
|
56
|
+
rspec-core (~> 3.9.0)
|
|
57
|
+
rspec-expectations (~> 3.9.0)
|
|
58
|
+
rspec-mocks (~> 3.9.0)
|
|
59
59
|
rspec-collection_matchers (1.2.0)
|
|
60
60
|
rspec-expectations (>= 2.99.0.beta1)
|
|
61
|
-
rspec-core (3.
|
|
62
|
-
rspec-support (~> 3.
|
|
63
|
-
rspec-expectations (3.
|
|
61
|
+
rspec-core (3.9.0)
|
|
62
|
+
rspec-support (~> 3.9.0)
|
|
63
|
+
rspec-expectations (3.9.0)
|
|
64
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
65
|
-
rspec-support (~> 3.
|
|
66
|
-
rspec-mocks (3.
|
|
65
|
+
rspec-support (~> 3.9.0)
|
|
66
|
+
rspec-mocks (3.9.0)
|
|
67
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
68
|
-
rspec-support (~> 3.
|
|
69
|
-
rspec-support (3.
|
|
68
|
+
rspec-support (~> 3.9.0)
|
|
69
|
+
rspec-support (3.9.0)
|
|
70
70
|
rspec_junit_formatter (0.4.1)
|
|
71
71
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
72
|
-
rubocop (0.75.
|
|
72
|
+
rubocop (0.75.1)
|
|
73
73
|
jaro_winkler (~> 1.5.1)
|
|
74
74
|
parallel (~> 1.10)
|
|
75
75
|
parser (>= 2.6)
|
|
@@ -119,7 +119,7 @@ DEPENDENCIES
|
|
|
119
119
|
timecop
|
|
120
120
|
|
|
121
121
|
RUBY VERSION
|
|
122
|
-
ruby 2.6.
|
|
122
|
+
ruby 2.6.5p114
|
|
123
123
|
|
|
124
124
|
BUNDLED WITH
|
|
125
125
|
2.0.2
|
data/README.md
CHANGED
|
@@ -156,7 +156,7 @@ file_data = PorkyLib::Unencrypted::FileService.read(bucket_name, file_key)
|
|
|
156
156
|
|
|
157
157
|
### To Write To AWS S3
|
|
158
158
|
```ruby
|
|
159
|
-
# Where file is the data to encrypt and upload to S3 (can be raw data or
|
|
159
|
+
# Where file is the data to encrypt and upload to S3 (can be raw data or ruby file object)
|
|
160
160
|
# bucket_name is the name of the S3 bucket to write to
|
|
161
161
|
# key_id is the ID of the CMK to use to generate a data encryption key to encrypt the file data
|
|
162
162
|
# options is an optional parameter for specifying optional metadata about the file
|
|
@@ -165,7 +165,7 @@ file_key = PorkyLib::FileService.write(file, bucket_name, key_id, options)
|
|
|
165
165
|
|
|
166
166
|
### To Write Unencrypted Files To AWS S3
|
|
167
167
|
```ruby
|
|
168
|
-
# Where file is the data to upload to S3 (can be raw data or
|
|
168
|
+
# Where file is the data to upload to S3 (can be raw data or ruby file object)
|
|
169
169
|
# bucket_name is the name of the S3 bucket to write to
|
|
170
170
|
# options is an optional parameter for specifying optional metadata about the file
|
|
171
171
|
file_key = PorkyLib::Unencrypted::FileService.write(file, bucket_name, options)
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
require 'aws-sdk-s3'
|
|
4
4
|
|
|
5
5
|
module PorkyLib::FileServiceHelper
|
|
6
|
-
def file_size_invalid?(
|
|
7
|
-
|
|
6
|
+
def file_size_invalid?(file_or_content)
|
|
7
|
+
if a_file?(file_or_content)
|
|
8
|
+
File.size(file_or_content) > max_size
|
|
9
|
+
else
|
|
10
|
+
file_or_content.bytesize > max_size
|
|
11
|
+
end
|
|
8
12
|
end
|
|
9
13
|
|
|
10
|
-
def file_data(
|
|
11
|
-
|
|
14
|
+
def file_data(file_or_content)
|
|
15
|
+
a_file?(file_or_content) ? File.read(file_or_content) : file_or_content
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def write_tempfile(file_contents, file_key)
|
|
@@ -48,4 +52,10 @@ module PorkyLib::FileServiceHelper
|
|
|
48
52
|
def generate_file_key(options)
|
|
49
53
|
options.key?(:directory) ? "#{options[:directory]}/#{SecureRandom.uuid}" : SecureRandom.uuid
|
|
50
54
|
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def a_file?(file_or_content)
|
|
59
|
+
!file_or_content.is_a?(String)
|
|
60
|
+
end
|
|
51
61
|
end
|
data/lib/porky_lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: porky_lib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Fletcher
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-10-
|
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk-kms
|