sec_config 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/Rakefile +1 -0
- data/bin/sc +8 -0
- data/lib/sec_config.rb +2 -0
- data/lib/sec_config/cli.rb +15 -0
- data/lib/sec_config/generators/konf.rb +26 -0
- data/lib/sec_config/generators/templates/config.yml.erb +6 -0
- data/lib/sec_config/generators/templates/preinitializer.rb +6 -0
- data/lib/sec_config/generators/templates/sec_config.yml.sample.erb +6 -0
- data/lib/sec_config/version.rb +3 -0
- data/sec_config.gemspec +24 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjNlNWVhMWRlMWExYjBmYTQxMjNiOTI5OGQwNjNiMmQyYjM0NTViZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjExZTMwYjk2OWJhNjYzMTllYmExMzE1MDhkNTcxMGQyOTE3NmIyYg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzFmNDg4YjY2NDlkYjZlMjgxYzg0MzMzYTNmNTM4MWRmMjUzOWJhZTBiNGI5
|
10
|
+
NDIxZWM0M2YwNGQyMjEzZWZmZDljZDg0N2YxZjQwNTBiZmMxNmI5NTUwYjU1
|
11
|
+
Njc4ZDRkM2Q3MGExMGFkZGJhZGE2NzViYWNlNmE4MjJkMzYwNmM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmNiN2NmMGVjN2I3NDJiZTY2YzEyNzA2ZTBhZmEwOWU4ZTI1ZjFmMjMwMTZi
|
14
|
+
MDU1ZWVjNmUwY2E2MGM4NzM2Y2Q4MGE0YjA0ZjU2NWQ2Y2I1MmI0NGU5MmYw
|
15
|
+
ZDhlZjhiMDQ3OTFmZGU2ZjM4YzVlOTZlOTZmY2M0NmE0YWZhNDM=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Adam Nowak
|
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,86 @@
|
|
1
|
+
# `sec_config`
|
2
|
+
|
3
|
+
it's a tool which should help you to maintain various key-value based data for your rails project:
|
4
|
+
|
5
|
+
* often we use some kind of external APIs which require keys or tokens
|
6
|
+
* we don't want to save such data directly in the repo, however we would like to use it
|
7
|
+
* we would like to have different key values for different environments
|
8
|
+
|
9
|
+
this flow is used in [netguru](https://github.com/netguru) and we're happy to recommend it to everybody!
|
10
|
+
|
11
|
+
## installation
|
12
|
+
|
13
|
+
add this line to your application's gemfile:
|
14
|
+
|
15
|
+
gem 'sec_config'
|
16
|
+
|
17
|
+
and then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install sec_config
|
24
|
+
|
25
|
+
## usage
|
26
|
+
|
27
|
+
generate the structure and you're ready to go.
|
28
|
+
|
29
|
+
```shell
|
30
|
+
sc install
|
31
|
+
```
|
32
|
+
|
33
|
+
ok, what now? you have your `config.yml` file which is stored in repo.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
# config/config.yml
|
37
|
+
|
38
|
+
defaults: &defaults
|
39
|
+
not_important_key: "abcdef"
|
40
|
+
important_key: "123456"
|
41
|
+
|
42
|
+
development:
|
43
|
+
<<: *defaults
|
44
|
+
not_important_key: "fedcba"
|
45
|
+
|
46
|
+
production:
|
47
|
+
<<: *defaults
|
48
|
+
```
|
49
|
+
|
50
|
+
you have also a `sec_config.yml.sample` file which you should rename on the target environment to `sec_config.yml` and put the data you want overvrite the defaults with.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
# config/sec_config.yml
|
54
|
+
|
55
|
+
production:
|
56
|
+
important_key: "abc123"
|
57
|
+
```
|
58
|
+
|
59
|
+
### usage within your app ###
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# on development
|
63
|
+
AppConfig.not_important_key
|
64
|
+
# => fedcba
|
65
|
+
AppConfig.important_key
|
66
|
+
# => 123456
|
67
|
+
|
68
|
+
# on production
|
69
|
+
AppConfig.not_important_key
|
70
|
+
# => abcdef
|
71
|
+
AppConfig.important_key
|
72
|
+
# => abc123
|
73
|
+
```
|
74
|
+
|
75
|
+
### tips ###
|
76
|
+
|
77
|
+
* don't forget that `sec_config.yml` has to be edited directly on the environment which you want to be overwriting the data (`staging`, `production`, etc.)
|
78
|
+
* `*_secret`, `*_token`, `*_password` variables seem to be a good example of keys which **should not** be stored in the repo
|
79
|
+
|
80
|
+
## contributing
|
81
|
+
|
82
|
+
1. fork it
|
83
|
+
2. create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. commit your changes (`git commit -am 'add some feature'`)
|
85
|
+
4. push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. create new pull request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/sc
ADDED
data/lib/sec_config.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'sec_config/generators/konf'
|
3
|
+
|
4
|
+
class SecConfig::CLI < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
desc "install", "prepare structure and files for your app config"
|
8
|
+
method_option :path, default: File.join(Dir.pwd, "/config")
|
9
|
+
method_option :environments, default: [:development, :staging, :beta, :production], type: :array
|
10
|
+
|
11
|
+
def install
|
12
|
+
SecConfig::Generators::Konf.start([options[:path], options[:environments]])
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SecConfig::Generators
|
2
|
+
class Konf < Thor::Group
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
argument :path, type: :string
|
6
|
+
argument :environments, type: :array
|
7
|
+
class_option :include_preinitializer, type: :boolean
|
8
|
+
|
9
|
+
def create_konf_files
|
10
|
+
template("config.yml.erb", File.join(path, "config.yml"))
|
11
|
+
template("sec_config.yml.sample.erb", File.join(path, "sec_config.sample.yml"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_preinitializer
|
15
|
+
template("preinitializer.rb", File.join(path, "preinitializer.rb"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_to_gitignore
|
19
|
+
append_file ".gitignore", "config/sec_config.yml"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.source_root
|
23
|
+
File.expand_path("../templates", __FILE__)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
require 'konf'
|
3
|
+
|
4
|
+
pub_config = (YAML.load(ERB.new(File.read(File.expand_path('../config.yml', __FILE__))).result)[Rails.env] rescue {}) || {}
|
5
|
+
sec_config = (YAML.load(ERB.new(File.read(File.expand_path('../sec_config.yml', __FILE__))).result)[Rails.env] rescue {}) || {}
|
6
|
+
AppConfig = Konf.new(pub_config.deep_merge(sec_config))
|
data/sec_config.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sec_config/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sec_config"
|
8
|
+
spec.version = SecConfig::VERSION
|
9
|
+
spec.authors = ["Adam Nowak"]
|
10
|
+
spec.email = ["lubieniebieski@gmail.com"]
|
11
|
+
spec.description = %q{tool which should help you to maintain various key-value based data for your rails project}
|
12
|
+
spec.summary = %q{very useful in situations where we use some kind of external APIs which require keys or tokens and we don't want to save such data directly in the repo, however we would like to use it; we would like to have different key values for different environments}
|
13
|
+
spec.homepage = "https://github.com/lubieniebieski/sec_config"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "thor"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sec_config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Nowak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: tool which should help you to maintain various key-value based data for
|
56
|
+
your rails project
|
57
|
+
email:
|
58
|
+
- lubieniebieski@gmail.com
|
59
|
+
executables:
|
60
|
+
- sc
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/sc
|
70
|
+
- lib/sec_config.rb
|
71
|
+
- lib/sec_config/cli.rb
|
72
|
+
- lib/sec_config/generators/konf.rb
|
73
|
+
- lib/sec_config/generators/templates/config.yml.erb
|
74
|
+
- lib/sec_config/generators/templates/preinitializer.rb
|
75
|
+
- lib/sec_config/generators/templates/sec_config.yml.sample.erb
|
76
|
+
- lib/sec_config/version.rb
|
77
|
+
- sec_config.gemspec
|
78
|
+
homepage: https://github.com/lubieniebieski/sec_config
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.0.7
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: very useful in situations where we use some kind of external APIs which require
|
102
|
+
keys or tokens and we don't want to save such data directly in the repo, however
|
103
|
+
we would like to use it; we would like to have different key values for different
|
104
|
+
environments
|
105
|
+
test_files: []
|