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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccfeb1766d3d923889b807bd1356184e87854ba7f64f41529b071b6883fb7b5b
4
- data.tar.gz: d8b8f6e608c44bc912f92ee92f46637edd1b767afdb95464b62b0e6bfcf86ab6
3
+ metadata.gz: fd1dfb255c5b91f06fe66af135ef84ef65fcb96bd02ad5150090619460bd7d86
4
+ data.tar.gz: 5edbf7d85795d8aaff798d486c043464199c03542c924f297559835796b9d829
5
5
  SHA512:
6
- metadata.gz: d07d5063b430dc69ff2c9f9db568e858eb9a10c26a371ce26139bfa2cc3b367c8e6ee6fc54214e487b8169add837c8ff71a087c0f42707083912d1871816faad
7
- data.tar.gz: 84478f5fba144f60ef7e595a57830f9c61748189c28f4fddbbcf35f2c81f5b55dbd99df8796304341970cdd98e9c811618ff9b5e6269a1eae0c7385949928a38
6
+ metadata.gz: bc55b6280bce9d76a9d6553e239487f14712ba535fdf83c54006e6cd27c67e8babda30e58632fbf1d76f531bc8c822b96d34a1e0a5209cf4098f436567bd951d
7
+ data.tar.gz: 3e428d8b741ba820b43ef1dc891dd0cd2b3ae81d9b2ba0d578705c84296ade1c4b510eb69e706c8d5869e4153884f1af2a5cd1a22fed09e226a9d694134b6035
data/.circleci/config.yml CHANGED
@@ -6,7 +6,7 @@ jobs:
6
6
  environment:
7
7
  - CODECOV_TOKEN: 4d03ca51-5054-4858-87c7-b37c376ffb6a
8
8
  docker:
9
- - image: circleci/ruby:2.6.3
9
+ - image: circleci/ruby:2.6.5
10
10
 
11
11
  steps:
12
12
  - checkout
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ruby '2.6.3'
3
+ ruby '2.6.5'
4
4
 
5
5
  source "https://rubygems.org"
6
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- porky_lib (0.9.1)
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.207.0)
17
- aws-sdk-core (3.65.1)
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.24.0)
23
- aws-sdk-core (~> 3, >= 3.61.1)
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.48.0)
26
- aws-sdk-core (~> 3, >= 3.61.1)
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.17.0)
47
- parser (2.6.4.1)
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.8.0)
56
- rspec-core (~> 3.8.0)
57
- rspec-expectations (~> 3.8.0)
58
- rspec-mocks (~> 3.8.0)
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.8.0)
62
- rspec-support (~> 3.8.0)
63
- rspec-expectations (3.8.4)
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.8.0)
66
- rspec-mocks (3.8.2)
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.8.0)
69
- rspec-support (3.8.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.0)
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.3p62
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 path to a file on disk)
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 path to a file on disk)
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?(file)
7
- file.bytesize > max_size || (File.file?(file) && File.size(file) > max_size)
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(file)
11
- File.file?(file) ? File.read(file) : file
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PorkyLib
4
- VERSION = "0.9.1"
4
+ VERSION = "0.9.2"
5
5
  end
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.1
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-03 00:00:00.000000000 Z
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