rails_simple_config 0.0.1 → 0.0.2

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
@@ -13,12 +13,20 @@ Add RailsSimpleConfig to your Gemfile:
13
13
  Run the generator to create the default configuration file:
14
14
 
15
15
  rails generate rails_simple_config:install
16
+
17
+ The generator will create 3 files in your Rails root directory; namely `secrets.yml`, `secrets.example.yml` and `config.yml`.
18
+
19
+ The `secrets.yml` should _not_ be committed to source control, and it should be used to keep settings which are
20
+ considered a secret; such as your Amazon credentials. These settings will be loaded first. The `secrets.example.yml` filename
21
+ can be added to source control and kept as an _example_ of the settings contained in the `secrets.yml` file.
22
+
23
+ The `config.yml` file should contain all other configuration settings.
16
24
 
17
25
  ## Usage
18
26
 
19
27
  ### Define configuration settings
20
28
 
21
- Define your settings in the generated `config.yml` file, found in your Rails root directory.
29
+ Define your settings in the generated `secrets.yml` and `config.yml` file, found in your Rails root directory.
22
30
 
23
31
  The file contains sections for the development, test and production Rails environments, and a shared section.
24
32
  It can also contain ERB code so that more advanced configuration scenarios can be supported.
@@ -95,6 +103,9 @@ For example, the `SimpleConfig.no_reply_email` will be accessible to the [devise
95
103
 
96
104
  `SimpleConfig` inherits from [ActiveSupport::OrderedOptions](http://api.rubyonrails.org/classes/ActiveSupport/OrderedOptions.html), so accessing undefined settings will always return `nil`.
97
105
 
106
+ In development, the configuration is reloaded upon each request, however, any configuration used within the `application.rb` filename
107
+ or any initializers will _not_ be automatically reloaded, without having to restart your web server.
108
+
98
109
  ## Project Info
99
110
 
100
111
  RailsSimpleConfig is hosted on [Github](http://github.com/virtualstaticvoid/rails_simple_config), where your contributions, forkings, comments and feedback are greatly welcomed.
@@ -4,6 +4,8 @@ module RailsSimpleConfig
4
4
 
5
5
  def copy_files
6
6
  template "config.yml", "./config.yml"
7
+ template "secrets.yml", "./secrets.yml"
8
+ template "secrets.yml", "./secrets.example.yml"
7
9
  end
8
10
 
9
11
  end
@@ -10,7 +10,18 @@ module SimpleConfig
10
10
 
11
11
  def load!
12
12
  puts "Loading configuration for '#{Rails.env}'."
13
- filename = Rails.root + 'config.yml'
13
+ load(Rails.root + 'secrets.yml')
14
+ load(Rails.root + 'config.yml')
15
+ end
16
+
17
+ def reload!
18
+ clear
19
+ load!
20
+ end
21
+
22
+ private
23
+
24
+ def load(filename)
14
25
  if File.exist?(filename)
15
26
  configuration = YAML.load(ERB.new(File.read(filename)).result)[Rails.env]
16
27
  configuration.each do |key, value|
@@ -18,11 +29,6 @@ module SimpleConfig
18
29
  end if configuration
19
30
  end
20
31
  end
21
-
22
- def reload!
23
- clear
24
- load!
25
- end
26
32
 
27
33
  end
28
34
 
@@ -32,6 +38,10 @@ module SimpleConfig
32
38
  @@config.load!
33
39
  end
34
40
 
41
+ def self.reload!
42
+ @@config.reload!
43
+ end
44
+
35
45
  def self.method_missing(method, *args)
36
46
  @@config.__send__(method, *args)
37
47
  end
@@ -1,3 +1,3 @@
1
1
  module RailsSimpleConfig
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_simple_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2011-08-23 00:00:00.000000000Z
12
+ date: 2011-09-09 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: A simple YAML based configuration for Ruby on Rails 3+, which supports
15
15
  shared settings, ERB and more.