econfig-keychain 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +21 -8
- data/Rakefile +4 -0
- data/econfig-keychain.gemspec +2 -0
- data/lib/econfig/keychain/version.rb +1 -1
- data/lib/econfig/keychain.rb +12 -13
- data/lib/econfig-keychain.rb +2 -2
- data/spec/econfig/keychain_spec.rb +25 -10
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8510be80ac12c816ca31d78e99966ed7e7239f48
|
4
|
+
data.tar.gz: 17623f293d5e9d461cf910c7d30f63dd955c3d52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c99c777e3f184bb88509dc28d366e9fbaea0af8271625f7a281325d2da474d32c017f28e9204c3524f2d26545a7372adc8dfc39d03ad5d261f18492bf8639e7a
|
7
|
+
data.tar.gz: f2a97f4e6e69865ba0320c62c7794d88d87ce95d5d5d8e4885b900664df553366edb04b1e5a9c921e67f9b8bf93c03508b164e056c3c5bccf83f66bfb7595bb7
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
[HEAD][]
|
2
2
|
--------
|
3
3
|
|
4
|
+
[v1.0.2][]
|
5
|
+
----------
|
6
|
+
|
7
|
+
- Allow specifying project name in Econfig.use_keychain [974df0db]
|
8
|
+
- Enforce Econfig.init, works better with Rails as well [1680b780]
|
9
|
+
|
4
10
|
[v1.0.1][]
|
5
11
|
----------
|
6
12
|
|
@@ -17,6 +23,7 @@
|
|
17
23
|
|
18
24
|
Initial release!
|
19
25
|
|
20
|
-
[HEAD]: https://github.com/elabs/econfig-keychain/compare/v1.0.
|
26
|
+
[HEAD]: https://github.com/elabs/econfig-keychain/compare/v1.0.2...HEAD
|
27
|
+
[v1.0.2]: https://github.com/elabs/econfig-keychain/compare/v1.0.1...v1.0.2
|
21
28
|
[v1.0.1]: https://github.com/elabs/econfig-keychain/compare/v1.0.0...v1.0.1
|
22
29
|
[v1.0.0]: https://github.com/elabs/econfig-keychain/compare/f877fd49...v1.0.0
|
data/README.md
CHANGED
@@ -14,29 +14,42 @@ gem "econfig-keychain"
|
|
14
14
|
```
|
15
15
|
|
16
16
|
Second, create a keychain you wish to store configuration in, name it something
|
17
|
-
clever like `thanks-a-latte`. Within `config/
|
18
|
-
following:
|
17
|
+
clever like `thanks-a-latte`. Within `config/application.rb` write the following:
|
19
18
|
|
20
19
|
``` ruby
|
21
|
-
|
20
|
+
# … some rails setup previously
|
21
|
+
module MyApp
|
22
|
+
extend Econfig::Shortcut
|
23
|
+
Econfig.use_keychain "thanks-a-latte" if Rails.env.development?
|
24
|
+
|
25
|
+
class Application < Rails::Application
|
26
|
+
# … rest of the configuration
|
27
|
+
```
|
28
|
+
|
29
|
+
That's it!
|
30
|
+
|
31
|
+
Econfig::Keychain will automatically create an empty secure note using the name of the directory your project is located at, in the `thanks-a-latte` keychain. If you wish to specify the name yourself, you can do so:
|
22
32
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
33
|
+
``` ruby
|
34
|
+
Econfig.use_keychain "thanks-a-latte", name: "project name"
|
26
35
|
```
|
27
36
|
|
28
|
-
|
37
|
+
## Changing configuration
|
38
|
+
|
39
|
+
Econfig::Keychain supports changing configuration by setting values, e.g. from the Rails console:
|
29
40
|
|
30
41
|
``` ruby
|
31
42
|
MyApp.aws_access_key_id = "xyz"
|
32
43
|
```
|
33
44
|
|
34
|
-
You can also edit your configuration manually using the Mellon CLI:
|
45
|
+
You can also edit your configuration with your `$EDITOR` manually using the Mellon CLI:
|
35
46
|
|
36
47
|
```
|
37
48
|
bundle exec mellon edit myapp
|
38
49
|
```
|
39
50
|
|
51
|
+
Finally, you can also edit the keychain entry manually using Keychain Access.
|
52
|
+
|
40
53
|
# License
|
41
54
|
|
42
55
|
MIT. See LICENSE.
|
data/Rakefile
CHANGED
data/econfig-keychain.gemspec
CHANGED
data/lib/econfig/keychain.rb
CHANGED
@@ -4,28 +4,27 @@ require "econfig"
|
|
4
4
|
module Econfig
|
5
5
|
class Keychain
|
6
6
|
def initialize(keychain, name: nil)
|
7
|
-
name
|
8
|
-
@store = ::Mellon::Store.new(name, keychain: keychain)
|
9
|
-
end
|
10
|
-
|
11
|
-
def project_name
|
12
|
-
@store.project_name
|
13
|
-
end
|
14
|
-
|
15
|
-
def keychain
|
16
|
-
@store.keychain
|
7
|
+
@init = { keychain: keychain, name: name }
|
17
8
|
end
|
18
9
|
|
19
10
|
def init
|
20
|
-
|
11
|
+
project_name = @init[:name] || File.basename(Econfig.root)
|
12
|
+
@store = ::Mellon::Store.new(project_name, keychain: @init[:keychain])
|
13
|
+
@store.keychain[@store.project_name] ||= ""
|
21
14
|
end
|
22
15
|
|
23
16
|
def get(key)
|
24
|
-
|
17
|
+
store[key]
|
25
18
|
end
|
26
19
|
|
27
20
|
def set(key, value)
|
28
|
-
|
21
|
+
store[key] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def store
|
27
|
+
@store or raise Econfig::UninitializedError
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
data/lib/econfig-keychain.rb
CHANGED
@@ -2,8 +2,8 @@ require "econfig/keychain"
|
|
2
2
|
|
3
3
|
module Econfig
|
4
4
|
class << self
|
5
|
-
def use_keychain(keychain)
|
6
|
-
Econfig.instance.backends << Econfig::Keychain.new(keychain)
|
5
|
+
def use_keychain(keychain, **kwargs)
|
6
|
+
Econfig.instance.backends << Econfig::Keychain.new(keychain, **kwargs)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -8,6 +8,7 @@ Econfig.env = "test"
|
|
8
8
|
describe Econfig::Keychain do
|
9
9
|
let(:keychain_path) { File.expand_path("./osx.temporary.keychain", __dir__) }
|
10
10
|
let(:keychain) { Mellon::Keychain.new(keychain_path) }
|
11
|
+
let(:project_name) { File.basename(Econfig.root) }
|
11
12
|
let(:backend) { Econfig::Keychain.new(keychain) }
|
12
13
|
|
13
14
|
around do |example|
|
@@ -20,7 +21,7 @@ describe Econfig::Keychain do
|
|
20
21
|
describe "#init" do
|
21
22
|
it "creates the note in the keychain if it does not exist" do
|
22
23
|
Econfig.stub(root: "different")
|
23
|
-
expect { backend.init }.to change { keychain[
|
24
|
+
expect { backend.init }.to change { keychain[project_name] }
|
24
25
|
.from(nil).to("")
|
25
26
|
end
|
26
27
|
|
@@ -30,20 +31,34 @@ describe Econfig::Keychain do
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
backend.get("
|
34
|
+
context "before init" do
|
35
|
+
specify "#get raises an error" do
|
36
|
+
expect { backend.get("key") }.to raise_error(Econfig::UninitializedError)
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
-
backend.
|
39
|
+
specify "#set raises an error" do
|
40
|
+
expect { backend.set("key", "value") }.to raise_error(Econfig::UninitializedError)
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
context "after init" do
|
45
|
+
before { backend.init }
|
46
|
+
|
47
|
+
describe "#get" do
|
48
|
+
it "fetches an option from the keychain" do
|
49
|
+
backend.get("i exist").should eq "this exist"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns nil if option does not exist" do
|
53
|
+
backend.get("does not exist").should be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#set" do
|
58
|
+
it "sets an option in the keychain" do
|
59
|
+
backend.set("new key", "pub")
|
60
|
+
backend.get("new key").should eq "pub"
|
61
|
+
end
|
47
62
|
end
|
48
63
|
end
|
49
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: econfig-keychain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kim Burgestrand
|
@@ -9,76 +9,76 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: econfig
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: mellon
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.6'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.6'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
description:
|
@@ -89,7 +89,7 @@ executables: []
|
|
89
89
|
extensions: []
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
|
-
- .gitignore
|
92
|
+
- ".gitignore"
|
93
93
|
- CHANGELOG.md
|
94
94
|
- Gemfile
|
95
95
|
- LICENSE
|
@@ -111,12 +111,12 @@ require_paths:
|
|
111
111
|
- lib
|
112
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
116
|
+
version: '2.0'
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
|
-
- -
|
119
|
+
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|