pct 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pct/version.rb +1 -1
  3. data/lib/pct.rb +23 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee452e3c06feccbfb13bde1e96c48ae01cee39bd3f5ff59fda297c27f4392cfb
4
- data.tar.gz: 0f03dd5fa069655cd278ad5143157a01b0a658aab2e4d2c49132cc6ac1098499
3
+ metadata.gz: b1f3eda427a8c6faa05bde5f37b542a2025c3adaf1b4e00b5ede5499a5805fc0
4
+ data.tar.gz: c8c11080fc227c4ab87e81553c805656c0c0ed247c32fce534233493f619e4a1
5
5
  SHA512:
6
- metadata.gz: c10e48e2a83e9cf6fed37868dced4ce3051e3df1da38643401fad9b6b316b94eab33f15213898566826bad3a9e875573feaefe38df98af83b89b4f1c61b50178
7
- data.tar.gz: f31c5372ad61952280198a852853bf0a80809af6c15354adac8bb3b2968b6288e74bf1ca1bcc5b2b6449957f79db48d8c89923d9d7fd14df3c2caec7d7f60c25
6
+ metadata.gz: 6b8ab87ae536ac1fe4c19eb5726d5141f2616103f27d06fd2803144575c31d382840780f74476ce03ca0b98bc6ba4a31ba68155abd25ac2a77faaebf9c28d1b5
7
+ data.tar.gz: 03d92501baf2b58e796bd0f8e3722951ec6c6d33a313f5bb7e983f08e902a15dcc59834ccfd7384fdfcdae2a561ae22a408afc555604a08fe9469d55eef84df1
data/lib/pct/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pct
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/pct.rb CHANGED
@@ -7,6 +7,19 @@ require 'aws-sdk-kms'
7
7
  module Pct
8
8
  class Error < StandardError; end
9
9
 
10
+ class Decryptable
11
+ def initialize(client, crypted)
12
+ @client = client
13
+ @crypted = crypted
14
+ end
15
+
16
+ def decrypted
17
+ @decrypted ||= client.decrypt({
18
+ ciphertext_blob: Base64.decode64(@crypted)
19
+ }).plaintext
20
+ end
21
+ end
22
+
10
23
  DEFAULT = <<~EOS
11
24
  configuration:
12
25
  example_key: "some value that should be encrypted"
@@ -28,6 +41,16 @@ module Pct
28
41
  to_decrypted(config['configuration'])
29
42
  end
30
43
 
44
+ def to_usable(configuration)
45
+ Hash[configuration.map do |k, v|
46
+ if v.is_a?(Hash)
47
+ [k, to_usable(v)]
48
+ else
49
+ [k, Decryptable.new(client, v)]
50
+ end
51
+ end]
52
+ end
53
+
31
54
  def self.encrypt(value, key)
32
55
  raise ArgumentError, "all values for encryption must be a string" if !value.is_a?(String)
33
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emily Dobervich