econfig-keychain 1.0.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 +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/econfig-keychain.gemspec +26 -0
- data/lib/econfig-keychain.rb +9 -0
- data/lib/econfig/keychain.rb +31 -0
- data/lib/econfig/keychain/version.rb +5 -0
- data/spec/econfig/keychain_spec.rb +49 -0
- data/spec/econfig/osx.keychain +0 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f3eaa6991696c10f88b4315f70df625725388f6d
|
4
|
+
data.tar.gz: 14f599969e12a65bcb9e735da30aed531294a068
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7d4776ab25bc1678b46e7afb5b02aaafc6284d98621fa0a6c56f4f3fee66fbe936870ad1075e978ad1edf2b26d705b58a55f6c921c163416c198efce18a4af05
|
7
|
+
data.tar.gz: e28c428795d06864daab308d8ef4e422fa1e1e8465def32acb5c1e3f36a85c2f5965954ff9e3898bc8ee2b34935b20c21c37a41a21749f25204b22bcf65c4a62
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
spec/econfig/.*
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kim Burgestrand
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Econfig::Keychain
|
2
|
+
|
3
|
+
An OSX keychain adapter for [Econfig](http://github.com/elabs/econfig), using [Mellon](https://github.com/elabs/mellon).
|
4
|
+
|
5
|
+
## Usage with Rails
|
6
|
+
|
7
|
+
For OSX, during development only.
|
8
|
+
|
9
|
+
First, add econfig-keychain to your Gemfile:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
gem "econfig", require: "econfig/rails"
|
13
|
+
gem "econfig-keychain"
|
14
|
+
```
|
15
|
+
|
16
|
+
Second, create a keychain you wish to store configuration in, name it something
|
17
|
+
clever like `thanks-a-latte`. Within `config/initializers/econfig.rb` write the
|
18
|
+
following:
|
19
|
+
|
20
|
+
``` ruby
|
21
|
+
MyApp.extend Econfig::Shortcut
|
22
|
+
|
23
|
+
if Rails.env.development?
|
24
|
+
Econfig.use_keychain "thanks-a-latte"
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
That's it! You can change your configuration from the Rails console:
|
29
|
+
|
30
|
+
``` ruby
|
31
|
+
MyApp.aws_access_key_id = "xyz"
|
32
|
+
```
|
33
|
+
|
34
|
+
You can also edit your configuration manually using the Mellon CLI:
|
35
|
+
|
36
|
+
```
|
37
|
+
bundle exec mellon edit myapp-development
|
38
|
+
```
|
39
|
+
|
40
|
+
# License
|
41
|
+
|
42
|
+
MIT. See LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'econfig/keychain/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "econfig-keychain"
|
8
|
+
spec.version = Econfig::Keychain::VERSION
|
9
|
+
spec.authors = ["Kim Burgestrand", "Elabs AB"]
|
10
|
+
spec.email = ["kim@burgestrand.se", "dev@elabs.se"]
|
11
|
+
spec.summary = %q{An OSX keychain adapter for Econfig.}
|
12
|
+
spec.homepage = "https://github.com/elabs/econfig-keychain"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "econfig"
|
21
|
+
spec.add_dependency "mellon", "~> 1.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "mellon"
|
2
|
+
require "econfig"
|
3
|
+
|
4
|
+
module Econfig
|
5
|
+
class Keychain
|
6
|
+
def initialize(keychain, name: nil)
|
7
|
+
name ||= [File.basename(Econfig.root), Econfig.env].join("-")
|
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
|
17
|
+
end
|
18
|
+
|
19
|
+
def init
|
20
|
+
keychain[project_name] ||= ""
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(key)
|
24
|
+
@store[key]
|
25
|
+
end
|
26
|
+
|
27
|
+
def set(key, value)
|
28
|
+
@store[key] = value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
$stderr.puts "If asked for a password, the password is empty. Just press OK."
|
2
|
+
|
3
|
+
require "econfig-keychain"
|
4
|
+
|
5
|
+
Econfig.root = __dir__
|
6
|
+
Econfig.env = "test"
|
7
|
+
|
8
|
+
describe Econfig::Keychain do
|
9
|
+
let(:keychain_path) { File.expand_path("./osx.temporary.keychain", __dir__) }
|
10
|
+
let(:keychain) { Mellon::Keychain.new(keychain_path) }
|
11
|
+
let(:backend) { Econfig::Keychain.new(keychain) }
|
12
|
+
|
13
|
+
around do |example|
|
14
|
+
original_keychain_path = File.expand_path("./osx.keychain", __dir__)
|
15
|
+
FileUtils.cp(original_keychain_path, keychain_path)
|
16
|
+
example.run
|
17
|
+
FileUtils.rm(keychain_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#init" do
|
21
|
+
it "creates the note in the keychain if it does not exist" do
|
22
|
+
Econfig.stub(env: "different")
|
23
|
+
expect { backend.init }.to change { keychain[backend.project_name] }
|
24
|
+
.from(nil).to("")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "does not overwrite existing data" do
|
28
|
+
backend.init
|
29
|
+
backend.get("i exist").should eq "this exist"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#get" do
|
34
|
+
it "fetches an option from the keychain" do
|
35
|
+
backend.get("i exist").should eq "this exist"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns nil if option does not exist" do
|
39
|
+
backend.get("does not exist").should be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#set" do
|
44
|
+
it "sets an option in the keychain" do
|
45
|
+
backend.set("new key", "pub")
|
46
|
+
backend.get("new key").should eq "pub"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: econfig-keychain
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kim Burgestrand
|
8
|
+
- Elabs AB
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: econfig
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: mellon
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.6'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.6'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- kim@burgestrand.se
|
87
|
+
- dev@elabs.se
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- econfig-keychain.gemspec
|
98
|
+
- lib/econfig-keychain.rb
|
99
|
+
- lib/econfig/keychain.rb
|
100
|
+
- lib/econfig/keychain/version.rb
|
101
|
+
- spec/econfig/keychain_spec.rb
|
102
|
+
- spec/econfig/osx.keychain
|
103
|
+
homepage: https://github.com/elabs/econfig-keychain
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: An OSX keychain adapter for Econfig.
|
127
|
+
test_files:
|
128
|
+
- spec/econfig/keychain_spec.rb
|
129
|
+
- spec/econfig/osx.keychain
|