snappconfig 0.0.7 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14eb983b17f43b7bb6f16c65df5a8595ca02de9f
4
- data.tar.gz: 2bd84af7c8bb5d396dd709fe79c7334140a5912d
3
+ metadata.gz: 6d4915af10d39c30322808dc8eca8686f71d1aa6
4
+ data.tar.gz: 82476c17726d99fcb073f35d25d88723c180b21e
5
5
  SHA512:
6
- metadata.gz: 1135507a51adfd8544ec0cbba1b053626253f9e2a1fffd4c2b5663287246190ff6c4af99d22be5935aca389700fe3323a55d2cc43be2c53cb121a966004b5693
7
- data.tar.gz: 500ed4fd39889e499f93f310564913babdddb30b957a028afaa328e73f8715f60bb51f526f5e17500efc5840898548e0450d2b9a0378e09102089119520f0c06
6
+ metadata.gz: 31dfaed8409d853d2cdd82e7288572032a1349ff9bc2e7a747bd5755dc704bc15b4ebab9c6d17969732a3f2c59a55a346fcd179c6d2c01619faa2ed8fe357638
7
+ data.tar.gz: 5430a096600d31a6febd48d1957b8352009ef2d0429ca079f8d09805e22f37882e00524e5ad652130f5e0512d12d1f576e7e39ebebc1cfc18a376da5a7c7f518
data/README.md CHANGED
@@ -19,7 +19,7 @@ Smarter Rails configuration that works with Heroku. Here's why it rocks:
19
19
 
20
20
  **2)** Use the generator to create config files (optional):
21
21
 
22
- $ rails generate snappconfig:install
22
+ $ rails generate snappconfig
23
23
 
24
24
  This will create:
25
25
 
@@ -31,22 +31,34 @@ This will create:
31
31
 
32
32
  ## Usage
33
33
 
34
- To access config values, just use standard hash notation:
34
+ To access configuration values, simply read from `CONFIG` using standard hash notation:
35
35
 
36
36
  token = CONFIG[:secret_token]
37
37
  stripe_secret = CONFIG[:stripe][:secret_key]
38
38
 
39
- Or if you wrote values to **ENV**, get them the way you normally would:
39
+ Or if you wrote values to `ENV`, get them the way you normally would:
40
40
 
41
41
  token = ENV['SECRET_TOKEN']
42
42
 
43
+ You can access `CONFIG` from anywhere in the app, including initializers and the application.rb file:
44
+
45
+ **application.rb example:**
46
+
47
+ module MyApp
48
+ class Application < Rails::Application
49
+ config.action_mailer.smtp_settings = {
50
+ :user_name => CONFIG[:mailer][:smtp_settings][:user_name],
51
+ :password => CONFIG[:mailer][:smtp_settings][:password]
52
+ ...
53
+
43
54
 
44
55
 
45
56
  ## YAML file examples
46
57
 
47
58
 
48
59
 
49
- ####Environment specfic (with defaults)
60
+ **Environment specfic (with defaults):**
61
+
50
62
  mailer_host: "localhost:3000"
51
63
  development:
52
64
  mailer_host: "localhost:3000"
@@ -56,7 +68,8 @@ Or if you wrote values to **ENV**, get them the way you normally would:
56
68
  mailer_host: "blog.example.com"
57
69
  ( **NOTE:** Default values can also be put under a 'defaults' group key. )
58
70
 
59
- ####Nested values:
71
+ **Nested values:**
72
+
60
73
  stripe:
61
74
  publishable_key: 5883eeb3cd43cee52585
62
75
  secret_key: 0df20bf20903c4404968
@@ -70,7 +83,8 @@ Or if you wrote values to **ENV**, get them the way you normally would:
70
83
  publishable_key: e753e42725fe43d3994a
71
84
  secret_key: e8787290a07b1abecae9
72
85
 
73
- ####ENV values:
86
+
87
+ **ENV values:**
74
88
 
75
89
  ENV:
76
90
  BLOG_USERNAME: "admin"
@@ -89,8 +103,8 @@ Snappconfig will load all files in the `config/` directory that start with **"ap
89
103
  For example, the following files would be processed in order:
90
104
 
91
105
  - **application**.yml
92
- - **application.2**.yml
93
106
  - **application.test**.yml
107
+ - **application.test.2**.yml
94
108
 
95
109
 
96
110
  <a name='best_practices'/>
@@ -134,7 +148,7 @@ We can then fill in those values with a git-ignored file that only stores our se
134
148
  smtp_settings:
135
149
  password: 8675309
136
150
 
137
- And there it is- configuration without compromise!
151
+ And there you have it- configuration without compromise!
138
152
 
139
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.
140
154
 
@@ -142,13 +156,22 @@ The `_REQUIRED` keyword is really handy. You can use it to stub out an entire co
142
156
 
143
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.
144
158
 
145
- But don't worry, Snappconfig's got you covered- just run the custom rake task:
159
+ But don't worry, Snappconfig provides a rake task to load your config files into Heroku. Just run:
160
+
161
+ $ rake heroku:config:load
162
+
163
+ or:
164
+
165
+ $ rake heroku:config:load[my_app]
166
+
167
+ to target a specific app.
146
168
 
147
- $ rake snappconfig:heroku
169
+ Slick!
148
170
 
149
- and your app configuration will automatically be passed into Heroku for you. Slick!
150
171
 
172
+ ## Miscellaneous
151
173
 
174
+ - Configuration is only loaded when an application starts up. Remember to **restart your app** whenever you make changes to your YAML files.
152
175
 
153
176
  ## Contributing
154
177
 
@@ -0,0 +1,23 @@
1
+ class SnappconfigGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../templates", __FILE__)
3
+
4
+ # all public methods in here will be run in order
5
+
6
+ def create_configuration
7
+ template "application.yml", "config/application.yml"
8
+ template "application.secrets.yml", "config/application.secrets.yml"
9
+ end
10
+
11
+ def ignore_configuration
12
+ if File.exists?(".gitignore")
13
+ append_to_file(".gitignore") do
14
+ <<-EOF.strip_heredoc
15
+
16
+ # Ignore application secrets.
17
+ /config/application.secrets.yml
18
+ EOF
19
+ end
20
+ end
21
+ end
22
+
23
+ end
@@ -1,15 +1,22 @@
1
1
  require "shellwords"
2
2
 
3
- namespace :snappconfig do
4
-
5
- task :heroku do
6
- puts "Passing application configuration to Heroku..."
7
- merged_yaml = Snappconfig.merged_raw.to_yaml
8
- shell_yaml = Shellwords.escape(merged_yaml)
9
- puts `heroku config:set CONFIG=#{shell_yaml}`
3
+ namespace :heroku do
4
+ namespace :config do
5
+
6
+ task :load, [:app] do |t, args|
7
+ puts "Loading configuration files into Heroku..."
8
+ merged_yaml = Snappconfig.merged_raw.to_yaml
9
+ shell_yaml = Shellwords.escape(merged_yaml)
10
+
11
+ app_switch = args[:app] ? " --app #{args[:app]}" : ""
12
+ puts `heroku config:set CONFIG=#{shell_yaml}#{app_switch}`
13
+ end
14
+
10
15
  end
11
-
12
16
  end
13
17
 
14
18
 
15
19
 
20
+
21
+
22
+
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.0.7"
7
+ spec.version = "0.1.1"
8
8
  spec.authors = ["Yarin Kessler"]
9
9
  spec.email = "ykessler@appgrinders.com"
10
10
  spec.summary = %q{Smarter Rails configuration with YAML}
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.0.7
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yarin Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-20 00:00:00.000000000 Z
11
+ date: 2013-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -49,9 +49,9 @@ files:
49
49
  - LICENSE.txt
50
50
  - README.md
51
51
  - Rakefile
52
- - lib/generators/snappconfig/install/install_generator.rb
53
- - lib/generators/snappconfig/install/templates/application.secrets.yml
54
- - lib/generators/snappconfig/install/templates/application.yml
52
+ - lib/generators/snappconfig/snappconfig_generator.rb
53
+ - lib/generators/snappconfig/templates/application.secrets.yml
54
+ - lib/generators/snappconfig/templates/application.yml
55
55
  - lib/snappconfig.rb
56
56
  - lib/snappconfig/railtie.rb
57
57
  - lib/snappconfig/tasks.rake
@@ -1,27 +0,0 @@
1
- module Snappconfig
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path("../templates", __FILE__)
5
-
6
- # all public methods in here will be run in order
7
-
8
- def create_configuration
9
- template "application.yml", "config/application.yml"
10
- template "application.secrets.yml", "config/application.secrets.yml"
11
- end
12
-
13
- def ignore_configuration
14
- if File.exists?(".gitignore")
15
- append_to_file(".gitignore") do
16
- <<-EOF.strip_heredoc
17
-
18
- # Ignore application secrets.
19
- /config/application.secrets.yml
20
- EOF
21
- end
22
- end
23
- end
24
-
25
- end
26
- end
27
- end