greased-rails 0.0.7 → 0.0.8

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.
data/README.md CHANGED
@@ -38,6 +38,17 @@ If you don't create your own file, Greased will use the file in the "templates"
38
38
  * config/greased_settings.yml
39
39
  * config/greased/settings.yml
40
40
 
41
+ #### Partial Settings - greased_partial.yml
42
+
43
+ This is a YAML serialization of settings you want to override in greased_settings.yml. This is useful if you let Greased load the default template and only want to override a few settings without copying the whole template file over.
44
+
45
+ Save your file to one of the following locations:
46
+
47
+ * greased_partial.yml (in the root of your Rails application)
48
+ * greased/partial.yml
49
+ * config/greased_partial.yml
50
+ * config/greased/partial.yml
51
+
41
52
  ### Environment Variables - greased_variables.yml
42
53
 
43
54
  This is a YAML serialization of your environment variables. You can easily share environment variables across environments.
@@ -5,10 +5,18 @@ require 'active_support/core_ext/hash/deep_merge'
5
5
  module Greased
6
6
  class Applicator
7
7
 
8
+ # settings applied to application environment
8
9
  APP_SETTINGS_FILENAME_BASE = "settings.yml"
9
10
  APP_SETTINGS_FILENAME = "greased_#{APP_SETTINGS_FILENAME_BASE}"
11
+ # additional settings applied to application environment
12
+ # after default Greased (template) settings are applied
13
+ # or custom settings file is applied.
14
+ APP_PATCH_FILENAME_BASE = "partial.yml"
15
+ APP_PATCH_FILENAME = "greased_#{APP_PATCH_FILENAME_BASE}"
16
+ # environment variables to load into ENV
10
17
  ENV_VARS_FILENAME_BASE = "variables.yml"
11
18
  ENV_VARS_FILENAME = "greased_#{ENV_VARS_FILENAME_BASE}"
19
+ # default Greased template with application settings
12
20
  DEFAULT_SETTINGS_FILE = Pathname.new(File.join(File.dirname(__FILE__), '..', '..', 'templates', APP_SETTINGS_FILENAME)).realpath
13
21
  DEFAULT_ENV = "development"
14
22
 
@@ -36,6 +44,12 @@ module Greased
36
44
  File.join(::Rails.root, "config", "greased", APP_SETTINGS_FILENAME_BASE),
37
45
  DEFAULT_SETTINGS_FILE
38
46
  ],
47
+ :partial_filename => [
48
+ File.join(::Rails.root, APP_PATCH_FILENAME),
49
+ File.join(::Rails.root, "greased", APP_PATCH_FILENAME_BASE),
50
+ File.join(::Rails.root, "config", APP_PATCH_FILENAME),
51
+ File.join(::Rails.root, "config", "greased", APP_PATCH_FILENAME_BASE)
52
+ ],
39
53
  :env_filename => [
40
54
  File.join(::Rails.root, ENV_VARS_FILENAME),
41
55
  File.join(::Rails.root, "greased", ENV_VARS_FILENAME_BASE),
@@ -89,7 +103,7 @@ module Greased
89
103
  def variables(options = {})
90
104
  options = @options.merge(options)
91
105
  groups = Array.wrap(options[:groups])
92
- grouped_variables = load_settings(@options[:env_filename])
106
+ grouped_variables = load_settings(options[:env_filename])
93
107
 
94
108
  groups.inject({}) do |all, group|
95
109
  all.merge grouped_variables.fetch(options[:env], {}).fetch(group, {})
@@ -97,8 +111,12 @@ module Greased
97
111
  end
98
112
 
99
113
  def settings(options = {})
100
- options = @options.merge(options)
101
- config = load_settings(options[:app_filename], options).fetch(env, {})
114
+ options = @options.merge(:env => env).merge(options)
115
+ # get settings for application environment
116
+ config = load_settings(options[:app_filename], options).fetch(options[:env], {})
117
+ # add partial settings for environment
118
+ config.deep_merge! load_settings(options[:partial_filename], options).fetch(options[:env], {})
119
+
102
120
  Settings.new(app, env, config)
103
121
  end
104
122
 
@@ -122,6 +140,5 @@ module Greased
122
140
  all || {}
123
141
  end
124
142
 
125
-
126
143
  end
127
144
  end
@@ -26,7 +26,7 @@ module Greased
26
26
 
27
27
  options = Applicator.rails_options.merge(:app => application)
28
28
  applicator = Applicator.new(options)
29
- variables = applicator.variables(options).except("RACK_ENV", "RAILS_ENV")
29
+ variables = applicator.variables.except("RACK_ENV", "RAILS_ENV")
30
30
 
31
31
  variables.each do |key, value|
32
32
  ENV[key.to_s] = value.to_s
@@ -1,5 +1,5 @@
1
1
  module Greased
2
2
  module Rails
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
@@ -0,0 +1,30 @@
1
+ #
2
+ # Create a file like this in your application if you want to use the default
3
+ # greased_settings.yml template in your application and only specify a couple changes
4
+ # without creating a whole new greased_settings.yml file.
5
+ #
6
+ # The settings in this file will be applied after the greased_settings.yml file
7
+ # is applied to the application environment.
8
+ #
9
+ # *** NOTE ***
10
+ #
11
+ # For the "defaults" section to have any effect, you have to specify the environment
12
+ # that should inherit from the defaults when loading these settings. Otherwise
13
+ # the settings will be ignored rather than be applied to all environments.
14
+ #
15
+
16
+ defaults: &defaults
17
+ config:
18
+ # suppose you want to use all defaults in greased_settings.yml
19
+ # and only change the SSL settings for all environments
20
+ force_ssl: true
21
+
22
+ development:
23
+ <<: *defaults
24
+
25
+ staging:
26
+ <<: *defaults
27
+
28
+ production:
29
+ <<: *defaults
30
+
@@ -1,3 +1,9 @@
1
+ #
2
+ # Create a file like this in your application to specify your own default settings.
3
+ # By default, this template file will be loaded into your environment unless you
4
+ # create your own file. (You could create a blank file so no changes are loaded.)
5
+ #
6
+
1
7
  defaults: &defaults
2
8
  config:
3
9
  force_ssl: false
@@ -1,3 +1,9 @@
1
+ #
2
+ # This is an example of how you could organize your environment variables.
3
+ # Currently only the "application" group is loaded. The "deployment" group
4
+ # may be used in Rake tasks eventually.
5
+ #
6
+
1
7
  defaults: &defaults
2
8
  deployment:
3
9
  HEROKU_APP: my-app-name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greased-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -67,6 +67,7 @@ files:
67
67
  - lib/greased/settings.rb
68
68
  - release.sh
69
69
  - tasks/greased.rake
70
+ - templates/greased_partial.yml
70
71
  - templates/greased_settings.yml
71
72
  - templates/greased_variables.yml
72
73
  homepage: http://github.com/joelvh/greased-rails