serket 0.0.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9849d15eee6960c7de33414df0d5748a5175d6a6
4
- data.tar.gz: 87fd71b37ebcb7ca3f21a67c58a1211b2140bd57
3
+ metadata.gz: 2f8bf96a313faec1a9264d3584c856f3409102ca
4
+ data.tar.gz: a743e66518dc65832c9fb905bc530a49d80fe74d
5
5
  SHA512:
6
- metadata.gz: 97aad6851b4293cb0f1f5a91a265843127c18d30e2f84aa78b302a2e562f527ffd224be67aa908cda35f1ccc891362886e7eb78f71b1769da2621d3b12053be9
7
- data.tar.gz: c92245e14eca0be9ea732fc2469558a7a9a257464337946db754d8ee0be22f395cefd68dd5a9d46132823b2ba2cd66873af05ce99749390dbe3bb5c88317d1b7
6
+ metadata.gz: 6d4dc192b1e5461d33d60636dc4876ce7cb4dadf78be9f434eb0b830e46e4996428ef0d27a8911a29a270a04f3778e362d141e277842b54d8c26fe28ef64daaf
7
+ data.tar.gz: a10af831390151ec3e85c29e718167af4a645aceddd6e030061d45f710c06c433d8ff57b568d560bd0cf664662633a286e61448013ec08d36fb25f05ee37813c
data/README.md CHANGED
@@ -32,7 +32,7 @@ Serket.configure do |config|
32
32
  end
33
33
  ```
34
34
 
35
- You can then use the FieldEncrypter class to encrypt some text:
35
+ You can then encrypt some text:
36
36
  ``
37
37
  Serket.encrypt("Hello out there!")
38
38
  ``
@@ -116,19 +116,13 @@ end
116
116
 
117
117
  This will automatically decrypt any values before saving assuming it matches your configurations.
118
118
 
119
- I recommend putting an initializer at config/initializers/serket.rb and putting your serket config block there. I would also recommend having dummy keys for test/development, and using different config blocks depending on current env (test/development vs production).
119
+ I recommend putting an initializer at config/initializers/serket.rb and putting your serket config block there.
120
+
120
121
  For example:
121
122
  ```
122
- if Rails.env.production?
123
- Serket.configure do |config|
124
- config.public_key_path = "config/keys/public_key.pem"
125
- config.private_key_path = "config/keys/private_key.pem"
126
- end
127
- else
128
- Serket.configure do |config|
129
- config.public_key_path = "config/keys/test_public_key.pem"
130
- config.private_key_path = "config/keys/test_private_key.pem"
131
- end
123
+ Serket.configure do |config|
124
+ config.public_key_path = ENV["SERKET_PUBLIC_KEY"]
125
+ config.private_key_path = ENV["SERKET_PRIVATE_KEY"]
132
126
  end
133
127
  ```
134
128
 
@@ -1,3 +1,3 @@
1
1
  module Serket
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/serket.rb CHANGED
@@ -19,10 +19,19 @@ module Serket
19
19
  end
20
20
 
21
21
  def self.encrypt(text)
22
- FieldEncrypter.new.encrypt(text)
22
+ field_encrypter.encrypt(text)
23
23
  end
24
24
 
25
25
  def self.decrypt(cipher)
26
- FieldDecrypter.new.decrypt(cipher)
26
+ field_decrypter.decrypt(cipher)
27
27
  end
28
+
29
+ private
30
+ def self.field_encrypter
31
+ @field_encrypter ||= FieldEncrypter.new
32
+ end
33
+
34
+ def self.field_decrypter
35
+ @field_decrypter ||= FieldDecrypter.new
36
+ end
28
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Nipper