rails_config 0.4.2 → 0.5.0.beta1
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 +4 -4
- data/README.md +5 -4
- data/lib/generators/rails_config/install_generator.rb +3 -1
- data/lib/rails_config/integration/rails.rb +2 -8
- data/lib/rails_config/integration/sinatra.rb +2 -11
- data/lib/rails_config/options.rb +3 -5
- data/lib/rails_config/sources/yaml_source.rb +6 -4
- data/lib/rails_config/version.rb +1 -1
- data/lib/rails_config.rb +13 -1
- 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: e61cf6197d3a2803156500248660b7e93fb724ff
|
4
|
+
data.tar.gz: d6163325528368ca7ea2f31c7a5f1e4609faa2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39685ffecfdd708a5aa825a1a1ea323eeee36610b37bc95c471bc9033f722038d45039313003b77ec2934e941ba95e431d71dc9b2f9e62520eca5e2158bf5020
|
7
|
+
data.tar.gz: 539b6ef9a90acacba394d3c6d8fd6e3c62f7b330cdc2b52af5eb995597b9eeb37928b65344d3826eb3c3cf0e6f22390adb5d395bfa2ab6f6ed8e18d99362866d
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](http://travis-ci.org/railsconfig/rails_config)
|
1
2
|
[](http://badge.fury.io/rb/rails_config)
|
2
3
|
[](https://gemnasium.com/railsjedi/rails_config)
|
3
4
|
|
@@ -110,10 +111,10 @@ Config entries are compiled from:
|
|
110
111
|
config/settings.yml
|
111
112
|
config/settings/#{environment}.yml
|
112
113
|
config/environments/#{environment}.yml
|
113
|
-
|
114
|
+
|
114
115
|
config/settings.local.yml
|
115
116
|
config/settings/#{environment}.local.yml
|
116
|
-
config/environments/#{environment}.local.yml
|
117
|
+
config/environments/#{environment}.local.yml
|
117
118
|
|
118
119
|
Settings defined in files that are lower in the list override settings higher.
|
119
120
|
|
@@ -154,7 +155,7 @@ Example production environment config file:
|
|
154
155
|
|
155
156
|
### Developer specific config files
|
156
157
|
|
157
|
-
If you want to have local settings, specific to your machine or development environment,
|
158
|
+
If you want to have local settings, specific to your machine or development environment,
|
158
159
|
you can use the following files, which are automatically `.gitignored` :
|
159
160
|
|
160
161
|
Rails.root.join("config", "settings.local.yml").to_s,
|
@@ -180,7 +181,7 @@ Settings.add_source!("#{Rails.root}/config/settings/local.yml")
|
|
180
181
|
Settings.reload!
|
181
182
|
```
|
182
183
|
|
183
|
-
> Note: this is an example usage, it is easier to just use the default local files `settings.local.yml, settings/#{Rails.env}.local.yml and environments/#{Rails.env}.local.yml`
|
184
|
+
> Note: this is an example usage, it is easier to just use the default local files `settings.local.yml, settings/#{Rails.env}.local.yml and environments/#{Rails.env}.local.yml`
|
184
185
|
> for your developer specific settings.
|
185
186
|
|
186
187
|
## Embedded Ruby (ERB)
|
@@ -18,6 +18,8 @@ module RailsConfig
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def modify_gitignore
|
21
|
+
create_file '.gitignore' unless File.exists? '.gitignore'
|
22
|
+
|
21
23
|
append_to_file '.gitignore' do
|
22
24
|
"\n" +
|
23
25
|
"config/settings.local.yml\n" +
|
@@ -27,4 +29,4 @@ module RailsConfig
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
@@ -15,13 +15,7 @@ module RailsConfig
|
|
15
15
|
|
16
16
|
# Parse the settings before any of the initializers
|
17
17
|
RailsConfig.load_and_set_settings(
|
18
|
-
::Rails.root.join("config",
|
19
|
-
::Rails.root.join("config", "settings", "#{::Rails.env}.yml").to_s,
|
20
|
-
::Rails.root.join("config", "environments", "#{::Rails.env}.yml").to_s,
|
21
|
-
|
22
|
-
::Rails.root.join("config", "settings.local.yml").to_s,
|
23
|
-
::Rails.root.join("config", "settings", "#{::Rails.env}.local.yml").to_s,
|
24
|
-
::Rails.root.join("config", "environments", "#{::Rails.env}.local.yml").to_s
|
18
|
+
RailsConfig.setting_files(::Rails.root.join("config"), ::Rails.env)
|
25
19
|
)
|
26
20
|
end
|
27
21
|
|
@@ -37,4 +31,4 @@ module RailsConfig
|
|
37
31
|
end
|
38
32
|
end
|
39
33
|
end
|
40
|
-
end
|
34
|
+
end
|
@@ -18,18 +18,9 @@ module RailsConfig
|
|
18
18
|
root = Padrino.root
|
19
19
|
end
|
20
20
|
|
21
|
-
RailsConfig.load_and_set_settings(
|
22
|
-
File.join(root.to_s, "config", "settings.yml").to_s,
|
23
|
-
File.join(root.to_s, "config", "settings", "#{env}.yml").to_s,
|
24
|
-
File.join(root.to_s, "config", "environments", "#{env}.yml").to_s,
|
25
|
-
|
26
|
-
File.join(root.to_s, "config", "settings.local.yml").to_s,
|
27
|
-
File.join(root.to_s, "config", "settings", "#{env}.local.yml").to_s,
|
28
|
-
File.join(root.to_s, "config", "environments", "#{env}.local.yml").to_s
|
29
|
-
)
|
21
|
+
RailsConfig.load_and_set_settings(RailsConfig.setting_files(File.join(root, 'config'), env))
|
30
22
|
|
31
23
|
inner_app.use(::RailsConfig::Rack::Reloader) if inner_app.development?
|
32
24
|
end
|
33
25
|
end
|
34
|
-
|
35
|
-
end
|
26
|
+
end
|
data/lib/rails_config/options.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
module RailsConfig
|
3
3
|
class Options < OpenStruct
|
4
|
-
|
5
4
|
include Enumerable
|
6
5
|
|
7
|
-
def
|
8
|
-
|
9
|
-
end
|
6
|
+
def keys() marshal_dump.keys; end
|
7
|
+
def empty?() marshal_dump.empty?; end
|
10
8
|
|
11
9
|
def add_source!(source)
|
12
10
|
# handle yaml file paths
|
@@ -94,7 +92,7 @@ module RailsConfig
|
|
94
92
|
def []=(param, value)
|
95
93
|
send("#{param}=", value)
|
96
94
|
end
|
97
|
-
|
95
|
+
|
98
96
|
protected
|
99
97
|
|
100
98
|
# Recursively converts Hashes to Options (including Hashes inside Arrays)
|
@@ -4,7 +4,6 @@ require 'erb'
|
|
4
4
|
module RailsConfig
|
5
5
|
module Sources
|
6
6
|
class YAMLSource
|
7
|
-
|
8
7
|
attr_accessor :path
|
9
8
|
|
10
9
|
def initialize(path)
|
@@ -13,12 +12,15 @@ module RailsConfig
|
|
13
12
|
|
14
13
|
# returns a config hash from the YML file
|
15
14
|
def load
|
16
|
-
if @path and File.
|
15
|
+
if @path and File.exist?(@path.to_s)
|
17
16
|
result = YAML.load(ERB.new(IO.read(@path.to_s)).result)
|
18
17
|
end
|
19
18
|
result || {}
|
19
|
+
rescue Psych::SyntaxError => e
|
20
|
+
raise "YAML syntax error occurred while parsing #{@path}. " \
|
21
|
+
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
22
|
+
"Error: #{e.message}"
|
20
23
|
end
|
21
|
-
|
22
24
|
end
|
23
25
|
end
|
24
|
-
end
|
26
|
+
end
|
data/lib/rails_config/version.rb
CHANGED
data/lib/rails_config.rb
CHANGED
@@ -2,7 +2,7 @@ require 'active_support/core_ext/module/attribute_accessors'
|
|
2
2
|
|
3
3
|
require 'rails_config/options'
|
4
4
|
require 'rails_config/version'
|
5
|
-
require 'rails_config/engine'
|
5
|
+
require 'rails_config/engine' if defined?(::Rails)
|
6
6
|
require 'rails_config/sources/yaml_source'
|
7
7
|
require 'rails_config/vendor/deep_merge' unless defined?(DeepMerge)
|
8
8
|
|
@@ -40,6 +40,18 @@ module RailsConfig
|
|
40
40
|
Kernel.const_set(RailsConfig.const_name, RailsConfig.load_files(files))
|
41
41
|
end
|
42
42
|
|
43
|
+
def self.setting_files(config_root, env)
|
44
|
+
[
|
45
|
+
File.join(config_root, "settings.yml").to_s,
|
46
|
+
File.join(config_root, "settings", "#{env}.yml").to_s,
|
47
|
+
File.join(config_root, "environments", "#{env}.yml").to_s,
|
48
|
+
|
49
|
+
File.join(config_root, "settings.local.yml").to_s,
|
50
|
+
File.join(config_root, "settings", "#{env}.local.yml").to_s,
|
51
|
+
File.join(config_root, "environments", "#{env}.local.yml").to_s
|
52
|
+
].freeze
|
53
|
+
end
|
54
|
+
|
43
55
|
def self.reload!
|
44
56
|
Kernel.const_get(RailsConfig.const_name).reload!
|
45
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacques Crocker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -215,12 +215,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: '0'
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
217
|
requirements:
|
218
|
-
- - "
|
218
|
+
- - ">"
|
219
219
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
220
|
+
version: 1.3.1
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.4.1
|
224
224
|
signing_key:
|
225
225
|
specification_version: 4
|
226
226
|
summary: Provides a Settings helper for Rails that reads from config/settings.yml
|