snappconfig 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -25
- data/lib/snappconfig/tasks.rake +5 -8
- data/snappconfig.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8fd70e2c0bb31207fb7217e072e1cec55bd6da6
|
4
|
+
data.tar.gz: 6a2fd01f719062ed424d6aca1b2c27921820c293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56cb2724a25c21ebd30858e7163bc59170a980148b9d148bdf299c31847f133cd9dc3f8793d035d7bb74bfbb07a4e4dce1a83daf36222c7aa1d6504e75808aa9
|
7
|
+
data.tar.gz: 43b6166613c9a9f654e530ac5b8145ade2797b9c29e7669940fd22293d03989cf6044d06642fd0ad4c66cbf3282464a5fcaac5730ec79b391e67044e38b72b51
|
data/README.md
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# Snappconfig
|
2
2
|
|
3
|
-
Smarter Rails configuration that works with Heroku
|
3
|
+
Smarter Rails configuration that works with Heroku:
|
4
4
|
|
5
|
-
-
|
6
|
-
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
5
|
+
- No setup code- just **add some YAML**.
|
6
|
+
- Supports **nested values and lists**. Use the data structures you want and access them with standard hash notation (e.g. `CONFIG[:this][:that]`)
|
7
|
+
- Promotes **secure best practices** that keep your secrets out of source control.
|
8
|
+
- Lets you write to a nestable `CONFIG` hash *or* to `ENV` variables.
|
9
|
+
- **Heroku-friendly**.
|
10
|
+
- Based on Ryan Bates’ excellent [Railscast](http://railscasts.com/episodes/85-yaml-configuration-revised) and inspired by [Figaro](https://github.com/laserlemon/figaro).
|
11
11
|
|
12
12
|
## Installation
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
|
15
|
+
|
16
16
|
**1)** Add it to your Gemfile and run `bundle` to install
|
17
17
|
|
18
18
|
gem 'snappconfig'
|
@@ -35,7 +35,7 @@ To access configuration values, simply read from `CONFIG` using standard hash no
|
|
35
35
|
|
36
36
|
token = CONFIG[:secret_token]
|
37
37
|
stripe_secret = CONFIG[:stripe][:secret_key]
|
38
|
-
|
38
|
+
|
39
39
|
Or if you wrote values to `ENV`, get them the way you normally would:
|
40
40
|
|
41
41
|
token = ENV['SECRET_TOKEN']
|
@@ -70,23 +70,23 @@ You can access `CONFIG` from anywhere in the app, including initializers and the
|
|
70
70
|
|
71
71
|
**Nested values:**
|
72
72
|
|
73
|
-
stripe:
|
73
|
+
stripe:
|
74
74
|
publishable_key: 5883eeb3cd43cee52585
|
75
|
-
secret_key: 0df20bf20903c4404968
|
76
|
-
|
75
|
+
secret_key: 0df20bf20903c4404968
|
76
|
+
|
77
77
|
development:
|
78
|
-
stripe:
|
78
|
+
stripe:
|
79
79
|
publishable_key: 5883eeb3cd43cee52585
|
80
80
|
secret_key: 0df20bf20903c4404968
|
81
81
|
production:
|
82
|
-
stripe:
|
82
|
+
stripe:
|
83
83
|
publishable_key: e753e42725fe43d3994a
|
84
84
|
secret_key: e8787290a07b1abecae9
|
85
85
|
|
86
86
|
|
87
87
|
**ENV values:**
|
88
88
|
|
89
|
-
ENV:
|
89
|
+
ENV:
|
90
90
|
BLOG_USERNAME: "admin"
|
91
91
|
BLOG_PASSWORD: "secret"
|
92
92
|
|
@@ -111,7 +111,7 @@ For example, the following files would be processed in order:
|
|
111
111
|
##Best practices
|
112
112
|
|
113
113
|
|
114
|
-
There's nothing to stop you from putting all your configuration into a single `application.yml` file. However, best practices dictate that protected values like **passwords and tokens should not be stored in source control.**
|
114
|
+
There's nothing to stop you from putting all your configuration into a single `application.yml` file. However, best practices dictate that protected values like **passwords and tokens should not be stored in source control.**
|
115
115
|
|
116
116
|
An obvious solution would be to git-ignore the config file, but that approach has its problems. Not all values need to be secret, and without any config file developers won't know what values are expected or what the defaults should be.
|
117
117
|
|
@@ -137,9 +137,9 @@ For instance, if we already have a mailer configuration that works for our app,
|
|
137
137
|
authentication: 'plain'
|
138
138
|
enable_starttls_auto: true
|
139
139
|
|
140
|
-
Using the `_REQUIRED` keyword, we indicate values we expect to be included in the configuration, even though they're not in this file.
|
140
|
+
Using the `_REQUIRED` keyword, we indicate values we expect to be included in the configuration, even though they're not in this file.
|
141
141
|
|
142
|
-
We can then fill in those values with a git-ignored file that only stores our secrets:
|
142
|
+
We can then fill in those values with a git-ignored file that only stores our secrets:
|
143
143
|
|
144
144
|
**application.secrets.yml:**
|
145
145
|
|
@@ -148,7 +148,7 @@ We can then fill in those values with a git-ignored file that only stores our se
|
|
148
148
|
smtp_settings:
|
149
149
|
password: 8675309
|
150
150
|
|
151
|
-
And there you have it- configuration without compromise
|
151
|
+
And there you have it- configuration without compromise
|
152
152
|
|
153
153
|
The `_REQUIRED` keyword is really handy. You can use it to stub out an entire config file template. If any of the required values are not present at runtime Snappconfig will raise an error, ensuring you never go live without a complete configuration.
|
154
154
|
|
@@ -156,7 +156,7 @@ The `_REQUIRED` keyword is really handy. You can use it to stub out an entire co
|
|
156
156
|
|
157
157
|
The Heroku file system is read-only, so if you're git-ignoring your config files you won't be able to add them in manually.
|
158
158
|
|
159
|
-
|
159
|
+
To fix that, Snappconfig provides a rake task to load your config files into Heroku. Just run:
|
160
160
|
|
161
161
|
$ rake heroku:config:load
|
162
162
|
|
@@ -164,9 +164,7 @@ or:
|
|
164
164
|
|
165
165
|
$ rake heroku:config:load[my_app]
|
166
166
|
|
167
|
-
to target a specific app.
|
168
|
-
|
169
|
-
Slick!
|
167
|
+
to target a specific app.
|
170
168
|
|
171
169
|
|
172
170
|
## Miscellaneous
|
data/lib/snappconfig/tasks.rake
CHANGED
@@ -5,19 +5,16 @@ namespace :heroku do
|
|
5
5
|
|
6
6
|
desc "Snappconfig task to load configuration into Heroku from YAML file(s)"
|
7
7
|
task :load, [:app] do |t, args|
|
8
|
+
|
8
9
|
puts "Loading configuration files into Heroku..."
|
9
10
|
merged_yaml = Snappconfig.merged_raw.to_yaml
|
10
11
|
shell_yaml = Shellwords.escape(merged_yaml)
|
11
|
-
|
12
|
+
|
12
13
|
app_switch = args[:app] ? " --app #{args[:app]}" : ""
|
13
|
-
|
14
|
+
# NOTE: Need to use 'Bundler.with_clean_env' instead of regular shell call
|
15
|
+
# in order to avoid Bundler::RubyVersionMismatch error (SEE: https://github.com/rbenv/rbenv/issues/400)
|
16
|
+
Bundler.with_clean_env { sh "heroku config:set CONFIG=#{shell_yaml}#{app_switch}" }
|
14
17
|
end
|
15
18
|
|
16
19
|
end
|
17
20
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
data/snappconfig.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "snappconfig"
|
7
|
-
spec.version = "0.1.
|
7
|
+
spec.version = "0.1.12"
|
8
8
|
spec.authors = ["Yarin Kessler"]
|
9
9
|
spec.email = "ykessler@appgrinders.com"
|
10
10
|
spec.summary = %q{Smarter Rails configuration with YAML}
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_development_dependency "bundler", "~> 1.
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
21
21
|
spec.add_development_dependency "rake"
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snappconfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yarin Kessler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.11'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.5.1
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Smarter Rails configuration with YAML
|