envault 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 316e360329e9b109ad2c92d4f95a9ca5b3983f3b
4
- data.tar.gz: 7f0d76ce9190ea1a60c4ff6d23b7c630d13e3c22
3
+ metadata.gz: a98c0fd6f91b487f7c882987c99253a009ba3a71
4
+ data.tar.gz: 6ed6282a051b144bee2b2c038182776d9cbacb82
5
5
  SHA512:
6
- metadata.gz: 43259b1f5f5d8471b65a297482cb5c4cb9306f85e9f54e8cdb422032bbea82d7f321d2dab205b82ff9195ce42684b2c47502a9f6c85b07277223dda53fd497ab
7
- data.tar.gz: bcd15899f969ac39f8b18b8314fd5c2ac645ba433a395d883ecc7f86406b2c32a88c72c0499b2e2f865256e6decd8a7be915d2108519f2945d2cc3cdb3383e24
6
+ metadata.gz: 98c7b035c76e2b71d0c70ba0db7ad5bcec096d2ec906c0e33524a48aad2b9fa8e7cc0fbc0b964040a28854bc60d0c0bce9d032af29d63d2874b3621d863e7041
7
+ data.tar.gz: 1c812a54c437ee881fd03c7fe4d602ec73c5b1d9c4f26351e432485639a0fbf04621ca8e19f8cef1491931597842e15855b75f069fdd6355867b3684bc362773
@@ -45,6 +45,7 @@ module Envault
45
45
  option :from_profile, type: :string, required: true, desc: 'from_profile'
46
46
  option :to_profile, type: :string, required: true, desc: 'to_profile'
47
47
  option :overwrite, type: :boolean, default: false, desc: 'overwrite'
48
+ option :quote, type: :boolean, default: true, desc: 'quote'
48
49
  def reencrypt_file
49
50
  yaml = YAML.load_file(options[:source])
50
51
  from = Core.new(
@@ -63,9 +64,9 @@ module Envault
63
64
  )
64
65
  output = to.encrypt_process(decrypted, cipher_keys)
65
66
  if options[:overwrite]
66
- Formatter.write_escape_yaml(options[:source], output)
67
+ Formatter.write_escape_yaml(options[:source], output, options[:quote])
67
68
  else
68
- puts Formatter.escape_yaml(output)
69
+ puts Formatter.escape_yaml(output, options[:quote])
69
70
  end
70
71
  end
71
72
 
@@ -74,6 +75,7 @@ module Envault
74
75
  option :keys, aliases: '-k', type: :array, required: false, desc: 'keys'
75
76
  option :plain_text, aliases: '-t', type: :array, default: [], required: false, desc: 'plain'
76
77
  option :output, aliases: '-o', type: :string, default: nil, desc: 'output'
78
+ option :quote, type: :boolean, default: true, desc: 'quote'
77
79
  def encrypt_file
78
80
  result = {}
79
81
  options[:plain_text].each do |plain_text_path|
@@ -83,9 +85,9 @@ module Envault
83
85
  result = result.merge(@core.encrypt_yaml(secret_yaml_path, options[:keys]))
84
86
  end
85
87
  if options[:output]
86
- Formatter.write_escape_yaml(options[:output], result)
88
+ Formatter.write_escape_yaml(options[:output], result, options[:quote])
87
89
  else
88
- puts Formatter.escape_yaml(result)
90
+ puts Formatter.escape_yaml(result, options[:quote])
89
91
  end
90
92
  end
91
93
 
@@ -93,6 +95,7 @@ module Envault
93
95
  option :source, aliases: '-s', type: :array, required: true, desc: 'source'
94
96
  option :plain_text, aliases: '-t', type: :array, default: [], required: false, desc: 'plain_text'
95
97
  option :output, aliases: '-o', type: :string, default: nil, desc: 'output'
98
+ option :quote, type: :boolean, default: true, desc: 'quote'
96
99
  def decrypt_file
97
100
  result = {}
98
101
  options[:plain_text].each do |plain_text_path|
@@ -102,9 +105,9 @@ module Envault
102
105
  result = result.merge(@core.decrypt_yaml(encrypt_yaml_path))
103
106
  end
104
107
  if options[:output]
105
- Formatter.write_escape_yaml(options[:output], result)
108
+ Formatter.write_escape_yaml(options[:output], result, options[:quote])
106
109
  else
107
- puts Formatter.escape_yaml(result)
110
+ puts Formatter.escape_yaml(result, options[:quote])
108
111
  end
109
112
  end
110
113
 
@@ -1,14 +1,14 @@
1
1
  module Envault
2
2
  class Formatter
3
- def self.escape_yaml(hash)
3
+ def self.escape_yaml(hash, quote = true)
4
4
  lines = []
5
5
  hash.map do |k, v|
6
- lines << %Q{#{k}: #{v.inspect}}
6
+ lines << %Q{#{k}: #{quote ? v.inspect : v}}
7
7
  end
8
8
  lines.join("\n")
9
9
  end
10
10
 
11
- def self.write_escape_yaml(path, hash)
11
+ def self.write_escape_yaml(path, hash, quote = true)
12
12
  File.write(path, escape_yaml(hash))
13
13
  end
14
14
  end
@@ -1,4 +1,4 @@
1
1
  module Envault
2
2
  # envault version
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
@@ -12,4 +12,15 @@ describe Envault do
12
12
  yaml = Formatter.escape_yaml(@envs)
13
13
  expect(yaml).to eq("USERNAME_A: \"hogehoge\"\nPASSWORD_A: \"hogehoge\"\nAPI_KEY_A: \"fugafuga\"")
14
14
  end
15
+
16
+ it "escape_yaml not quote" do
17
+ @envs = {
18
+ 'USERNAME_A' => 'hogehoge',
19
+ 'PASSWORD_A' => 'hogehoge',
20
+ 'API_KEY_A' => 'fugafuga'
21
+ }
22
+
23
+ yaml = Formatter.escape_yaml(@envs, false)
24
+ expect(yaml).to eq("USERNAME_A: hogehoge\nPASSWORD_A: hogehoge\nAPI_KEY_A: fugafuga")
25
+ end
15
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envault
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
  - toyama0919
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-07 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -157,12 +157,9 @@ executables:
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
- - ".document"
161
160
  - ".gitignore"
162
161
  - ".rspec"
163
162
  - ".travis.yml"
164
- - ".yardopts"
165
- - ChangeLog.md
166
163
  - Gemfile
167
164
  - README.md
168
165
  - Rakefile
@@ -203,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
200
  version: '0'
204
201
  requirements: []
205
202
  rubyforge_project:
206
- rubygems_version: 2.6.11
203
+ rubygems_version: 2.6.13
207
204
  signing_key:
208
205
  specification_version: 4
209
206
  summary: Encrypt secret information environment variables by yaml.
data/.document DELETED
@@ -1,3 +0,0 @@
1
- -
2
- ChangeLog.md
3
- LICENSE.txt
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --markup markdown --title "envault Documentation" --protected
@@ -1,4 +0,0 @@
1
- ### 0.1.0 / 2016-08-31
2
-
3
- * Initial release:
4
-