kms-tools 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: 36135cba337e0583f02134a249daf299dea7ec5f
4
- data.tar.gz: 06877816b0f9bab9a09034271c5fe2e0584c9ade
3
+ metadata.gz: f476cbf918a35dd81853ba790258f7ff4e9c0691
4
+ data.tar.gz: a04e1049a4f4a719afde2ef98c622a4b31522aaa
5
5
  SHA512:
6
- metadata.gz: 67c1df3ef40a95e59d1331e5628232b32ae51fe9261990f268114553eebc5b20f9c0ae47f5d2afb42b7daa2088311145633bbfb678cb2a913e7e170670db0a6a
7
- data.tar.gz: 00083083afa0d09b9b79e71672957a36a4f6fdeacb02ec9fefbe8104a9b1a2b8ec25d6605c044a907eea2e60ce519e015ea033a5be6ab8c751a41ccb5f0055e1
6
+ metadata.gz: 4075bd28de2bb5d7221a67202272df9d7a176b1672e2e2d4707afce91f9806d1d80cd4065736c0ea88075123e9b32db5be1893f580716d665f37ac5c319b902b
7
+ data.tar.gz: f971e0edf4617d074e69207953bc882bce4d7183af51c2d0890382c83812ae38ae7c8b49e39003f21a0ea61842083bb0aa91525de260a9845b5907f850ad3c87
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  doc
6
6
  .rspec
7
7
  spec/examples.txt
8
+ *.gem
@@ -1,3 +1,4 @@
1
+ #### v0.0.2
1
2
  #### v0.0.1
2
3
  #### v0.0.1
3
4
  #### 0.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sport Ngin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -22,10 +22,8 @@ flag [:k,:master_key], :desc => 'Encrypt using the specified key alias or key id
22
22
  commands_from '../lib/kms-tools/cli/commands'
23
23
 
24
24
  pre do |global,command,options,args|
25
- #KmsTools::VerifyAwsConfig.new
26
- $verbose = global[:verbose] || global[:debug]
27
- $debug = global[:debug]
28
- $color = global[:color]
25
+
26
+ KmsTools::Config.merge! global
29
27
  true
30
28
  end
31
29
 
@@ -16,8 +16,10 @@ spec = Gem::Specification.new do |s|
16
16
  s.executables << 'kms-tools'
17
17
 
18
18
  s.add_dependency 'aws-sdk'
19
- s.add_dependency "highline"
20
- s.add_dependency "hashdiff"
19
+ s.add_dependency 'highline'
20
+ s.add_dependency 'hashdiff'
21
+ s.add_dependency 'hashie'
22
+
21
23
 
22
24
  s.add_development_dependency 'rake'
23
25
  s.add_development_dependency 'yard'
@@ -1,5 +1,12 @@
1
1
  require 'aws-sdk'
2
- Dir[File.dirname(__FILE__) + '/kms-tools/*.rb'].each {|file| require file }
2
+
3
+ require 'kms-tools/version'
4
+
5
+ require 'kms-tools/config'
6
+ require 'kms-tools/base'
7
+ require 'kms-tools/decrypter'
8
+ require 'kms-tools/encrypter'
9
+ require 'kms-tools/encrypted_file'
3
10
 
4
11
  # Chunk size to use when processing streams
5
12
  STREAM_CHUNK_SIZE = 1048576
@@ -20,9 +20,9 @@ module KmsTools
20
20
  # @option options [String] :profile Use the specified profile from an AWS credentials file
21
21
  #
22
22
  def initialize(options = {})
23
- @master_key = options[:master_key]
24
- @region = options[:region]
25
- @profile = options[:profile]
23
+ @master_key = options[:master_key] || Config.master_key
24
+ @region = options[:region] || Config.region
25
+ @profile = options[:profile] || Config.profile
26
26
 
27
27
  @kms = Aws::KMS::Client.new({
28
28
  :region => region,
@@ -28,7 +28,7 @@ module KmsTools
28
28
  end
29
29
 
30
30
  def self.format(msg, log_style=:normal)
31
- if $color
31
+ if Config.color
32
32
  terminal.color(msg.to_s, log_style)
33
33
  else
34
34
  msg
@@ -36,11 +36,11 @@ module KmsTools
36
36
  end
37
37
 
38
38
  def self.say_verbose(msg)
39
- terminal.say format(msg.to_s, 'verbose') if $verbose
39
+ terminal.say format(msg.to_s, 'verbose') if Config.verbose
40
40
  end
41
41
 
42
42
  def self.say_debug(msg, log_style=:debug)
43
- terminal.say format(msg.to_s, log_style) if $debug
43
+ terminal.say format(msg.to_s, log_style) if Config.debug
44
44
  end
45
45
 
46
46
  def self.ask(*args, &block)
@@ -0,0 +1,35 @@
1
+ require 'yaml'
2
+ require 'hashie'
3
+
4
+ module KmsTools
5
+ class Config
6
+ class << self
7
+
8
+ def config
9
+ config_data.to_hash
10
+ end
11
+
12
+ def load(path)
13
+ load_config(path)
14
+ config
15
+ end
16
+
17
+ def config_data
18
+ @config_data ||= Hashie::Mash.new
19
+ end
20
+ private :config_data
21
+
22
+ def method_missing(method, args=false)
23
+ config_data.send(method, args)
24
+ end
25
+ private :method_missing
26
+
27
+ def load_config(file)
28
+ raise MissingConfig, "Missing configuration file: #{file} Run help command for config file switch" unless File.exist?(file)
29
+ config_data.merge! YAML.load_file(file)
30
+ end
31
+ private :load_config
32
+
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module KmsTools
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'kms-tools'
3
+
4
+ module KmsTools
5
+ describe Config do
6
+
7
+ context "config key methods" do
8
+ it "should return nil when not set" do
9
+ expect(Config.doesnt_exist).to eql(nil)
10
+ expect(Config.doesnt_exist?).to eql(false)
11
+ end
12
+ it "should return the config value when set" do
13
+ Config.new_value = "testing"
14
+ expect(Config.new_value).to eql("testing")
15
+ end
16
+ end
17
+
18
+ context "after loading a config file" do
19
+ before do
20
+ config_file = {"domain"=>"example_domain", "slack"=>{"slack_option"=>true, "username"=>"Rspec Tester", "icon_url"=>"http://fake.url", "channel"=>"#test-channel", "webhook"=>"https://slack.web.hook"}}
21
+ allow(YAML).to receive(:load_file).and_return(config_file)
22
+ allow(File).to receive(:exist?).and_return(true)
23
+ Config.load("dummy/path")
24
+ end
25
+
26
+ it "calling a method corresponding to a key in the file should return the value" do
27
+ expect(Config.domain).to eql("example_domain")
28
+ expect(Config.slack).to be_kind_of(Hash)
29
+ expect(Config.slack[:slack_option]).to eql(true)
30
+ end
31
+
32
+ it "overwriting values should work" do
33
+ expect(Config.slack).to be_kind_of(Hash)
34
+ Config.slack = "this is a string now"
35
+ expect(Config.slack).to eql("this is a string now")
36
+ end
37
+
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kms-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Krieger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +163,7 @@ files:
149
163
  - ".travis.yml"
150
164
  - CHANGELOG.markdown
151
165
  - Gemfile
166
+ - LICENSE.md
152
167
  - README.md
153
168
  - Rakefile
154
169
  - bin/kms-tools
@@ -163,14 +178,15 @@ files:
163
178
  - lib/kms-tools/cli/encrypt.rb
164
179
  - lib/kms-tools/cli/helpers.rb
165
180
  - lib/kms-tools/cli/output.rb
181
+ - lib/kms-tools/config.rb
166
182
  - lib/kms-tools/decrypter.rb
167
183
  - lib/kms-tools/encrypted_file.rb
168
184
  - lib/kms-tools/encrypter.rb
169
185
  - lib/kms-tools/version.rb
170
186
  - spec/kms-tools/aws_mocks.rb
171
187
  - spec/kms-tools/base_spec.rb
188
+ - spec/kms-tools/config_spec.rb
172
189
  - spec/kms-tools/decrypter_spec.rb
173
- - spec/kms-tools/encrypted_file_spec.rb
174
190
  - spec/kms-tools/encrypter_spec.rb
175
191
  - spec/kms-tools/test_data.rb
176
192
  - spec/spec_helper.rb
@@ -194,9 +210,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
210
  version: '0'
195
211
  requirements: []
196
212
  rubyforge_project:
197
- rubygems_version: 2.4.8
213
+ rubygems_version: 2.5.1
198
214
  signing_key:
199
215
  specification_version: 4
200
216
  summary: CLI for encrypting and decrypting data using Amazon KMS
201
217
  test_files: []
202
- has_rdoc: yard
@@ -1,14 +0,0 @@
1
- require "spec_helper"
2
- require "kms-tools"
3
-
4
- module KmsTools
5
- describe "With mocked AWS response" do
6
- include_context "aws mocks"
7
-
8
- before do
9
-
10
- end
11
-
12
- end
13
- end
14
-