leml 0.2.0 → 0.2.1

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: 9203db353aaaa297b99e9a288feaf73317cf03ab
4
- data.tar.gz: 0fb30539a3e9d4498e589cf148774b4bde70ca9f
3
+ metadata.gz: 46bbf2d07767519d46ba6703eafd96d53f62d2b1
4
+ data.tar.gz: aae9577b0141efd89bae3941661651215cd36301
5
5
  SHA512:
6
- metadata.gz: 3a597c10bdf5e94c4f12db9f947fdff68b04996583bc642a55d154248ca2390db156a5291e9feb6f77c6e9f0b527887ced55cec44b040cb9e25cad8083dddcb9
7
- data.tar.gz: e0d7f671d3fc991371dc7c7133363dccf823458e3c7c8e82031ebdd38af50591d38221c0ab96370ddd9097eece996f8e3988f991afe6b581ecc93220e67d811d
6
+ metadata.gz: 051bedfc7a01849ba35887d8d072df544b5a3805911d4ecd520eb7d5d6ed28f44905cace01715ec0e24d92a32435986733d6f007d7adafe6068262211d998b61
7
+ data.tar.gz: 0b615426e6ba6d7283148a761df4b00fdfdc9038ad041026814afd4c7918fd09d3d0bdb464e60345f7a5d2b9391b1b7bb83464102bb8cf5590978467e6ba0d9e
@@ -1,4 +1,5 @@
1
1
  require 'rails'
2
+ require 'leml/errors'
2
3
 
3
4
  module Leml
4
5
  class Core
@@ -63,7 +64,7 @@ module Leml
63
64
 
64
65
  def initialize
65
66
  @key = File.exist?(KEY_FILE) ? File.read(KEY_FILE).chop : ENV['LEML_KEY']
66
- return if @key.blank?
67
+ raise NoLemlKeyError if @key.blank?
67
68
  @encryptor = ActiveSupport::MessageEncryptor.new(@key, cipher: 'aes-256-cbc')
68
69
  @secrets = YAML.load_file(SECRETS)
69
70
  end
@@ -74,7 +75,7 @@ module Leml
74
75
  end
75
76
 
76
77
  def edit
77
- no_editor if ENV['EDITOR'].blank?
78
+ raise NoEditorError if ENV['EDITOR'].blank?
78
79
  Dir.mktmpdir do |dir|
79
80
  tmp_file = create_decrypted_tmp_file(dir)
80
81
  system("#{ENV['EDITOR']} #{tmp_file.to_s}")
@@ -110,10 +111,14 @@ module Leml
110
111
 
111
112
  def encrypt_value(value)
112
113
  @encryptor.encrypt_and_sign(value)
114
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
115
+ raise InvalidLemlKey
113
116
  end
114
117
 
115
118
  def decrypt_value(value)
116
119
  @encryptor.decrypt_and_verify(value)
120
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
121
+ raise InvalidLemlKey
117
122
  end
118
123
 
119
124
  def no_editor
@@ -0,0 +1,19 @@
1
+ module Leml
2
+ class NoLemlKeyError < StandardError
3
+ def initialize
4
+ super("Leml key is not found. config. Please create `config/leml.key` and set the secret.\nFor further information, see: https://github.com/onunu/leml")
5
+ end
6
+ end
7
+
8
+ class NoEditorError < StandardError
9
+ def initialize
10
+ super("No editor, please set environment variable.\nex) EDITOR=vim bundle exec rake leml:edit")
11
+ end
12
+ end
13
+
14
+ class InvalidLemlKey < StandardError
15
+ def initialize
16
+ super("Key is invalid for decrypt, please check the value of `config/leml.key`")
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Leml
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - onunu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2017-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -51,6 +51,7 @@ files:
51
51
  - Rakefile
52
52
  - lib/leml.rb
53
53
  - lib/leml/core.rb
54
+ - lib/leml/errors.rb
54
55
  - lib/leml/railtie.rb
55
56
  - lib/leml/version.rb
56
57
  - lib/tasks/leml_tasks.rake