rails_simple_config 0.0.3 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4c89164a55cdd5a6bf2f9f713ae2243212cd4638e1fbd2e4810540e500ea1dd2
4
+ data.tar.gz: 6b417ae172e9a2d0a1ad71924bc5fbdc736ae33e5d155bc6c4b8837c340d85ea
5
+ SHA512:
6
+ metadata.gz: 5907458a1a536e9cef7fbca1f379773c0165e5eda32c0f01fc45cf8161b81ba735a344511bf646f0884568bfe55e50f63e6fe8173a1407c859fd67e2ca4f37d4
7
+ data.tar.gz: 7b56bd45d8f31088a1280dd7311e10d4048e41daf3de5c14530207e0a5926409bcd5ccf3536be5c0ea8b02b02e3a95f519742fc406ad5b671db2f3bccb5816a7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_simple_config (0.0.1)
4
+ rails_simple_config (0.0.7)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -12,3 +12,6 @@ PLATFORMS
12
12
 
13
13
  DEPENDENCIES
14
14
  rails_simple_config!
15
+
16
+ BUNDLED WITH
17
+ 2.2.31
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Rails Simple Config
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rails_simple_config.png)](http://badge.fury.io/rb/rails_simple_config)
4
+
3
5
  A simple YAML based configuration for Ruby on Rails 3+, which supports shared settings, ERB and more.
4
6
 
5
7
  Inspired in part by the database configuration in Rails, [app_config](https://github.com/die-antwort/app_config) and [rails_config](https://github.com/railsjedi/rails_config).
@@ -10,15 +12,21 @@ Add RailsSimpleConfig to your Gemfile:
10
12
 
11
13
  gem 'rails_simple_config'
12
14
 
13
- Run the generator to create the default configuration file:
15
+ Run the generator to create the default configuration files:
14
16
 
15
17
  rails generate rails_simple_config:install
16
18
 
17
- The generator will create 3 files in your Rails root directory; namely `secrets.yml`, `secrets.example.yml` and `config.yml`.
19
+ The generator will create 3 files in your Rails `config` directory, namely:
20
+
21
+ * `secrets.yml`
22
+ * `secrets.example.yml`
23
+ * `config.yml`
18
24
 
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.
25
+ The `secrets.yml` should _not_ be committed to source control. It should be used to keep settings which are
26
+ considered a secret; such as your Amazon credentials. It is loaded first.
27
+
28
+ The `secrets.example.yml` file can be added to source control and should serve as an _example_ of the settings
29
+ contained in the `secrets.yml` file.
22
30
 
23
31
  The `config.yml` file should contain all other configuration settings.
24
32
 
@@ -26,21 +34,25 @@ The `config.yml` file should contain all other configuration settings.
26
34
 
27
35
  ### Define configuration settings
28
36
 
29
- Define your settings in the generated `secrets.yml` and `config.yml` file, found in your Rails root directory.
37
+ Define your settings in the generated `secrets.yml` and `config.yml` files, found in your Rails `config` directory.
30
38
 
31
- The file contains sections for the development, test and production Rails environments, and a shared section.
39
+ Both files contain a shared section and sections with overrides for the respective development, test and production Rails environments.
32
40
  It can also contain ERB code so that more advanced configuration scenarios can be supported.
33
41
 
34
42
  # example configuration
35
43
 
36
44
  shared: &shared
45
+
37
46
  title: My Website Title
38
47
  description: Meta description of the site
39
48
  keywords: Meta keywords for search engines
40
49
 
41
50
  no_reply_email: noreply@example.com
51
+
52
+ dynamic_setting: <%= 30 * 60 %>
42
53
 
43
54
  development:
55
+
44
56
  # inherit shared settings
45
57
  <<: *shared
46
58
 
@@ -52,6 +64,7 @@ It can also contain ERB code so that more advanced configuration scenarios can b
52
64
  mail_prefix: DEV -
53
65
 
54
66
  production:
67
+
55
68
  # inherit shared settings
56
69
  <<: *shared
57
70
 
@@ -63,7 +76,7 @@ It can also contain ERB code so that more advanced configuration scenarios can b
63
76
 
64
77
  ### Access configuration settings
65
78
 
66
- To access configuration settings in your Rails application, use the `SimpleConfig` global module.
79
+ To access configuration settings in your Rails application, use the `SimpleConfig` global or the `AppConfig` alias for it.
67
80
 
68
81
  For example, in your application layout:
69
82
 
@@ -83,8 +96,8 @@ For example, in your application layout:
83
96
  </body>
84
97
  </html>
85
98
 
86
- In addition, unlike other Rails configuration solutions, `SimpleConfig` is available to the development, test and production configurations, initializers and routes during startup.
87
- It can be used as a replacement for environment variables; thus making your setup much cleaner.
99
+ In addition, unlike other Rails configuration solutions, `SimpleConfig` is available to the Rails development, test and production environment configuration files,
100
+ initializers and routes during startup. It can be used as a replacement for environment variables; thus making your setup and code much cleaner.
88
101
 
89
102
  For example, the `SimpleConfig.no_reply_email` will be accessible to the [devise](https://github.com/plataformatec/devise) initializer when configuring `mailer_sender`:
90
103
 
@@ -101,10 +114,10 @@ For example, the `SimpleConfig.no_reply_email` will be accessible to the [devise
101
114
 
102
115
  ### Notes
103
116
 
104
- `SimpleConfig` inherits from [ActiveSupport::OrderedOptions](http://api.rubyonrails.org/classes/ActiveSupport/OrderedOptions.html), so accessing undefined settings will always return `nil`.
117
+ `SimpleConfig` makes use of the [ActiveSupport::OrderedOptions](http://api.rubyonrails.org/classes/ActiveSupport/OrderedOptions.html) class, so accessing undefined settings will always return `nil`.
105
118
 
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.
119
+ In development, the configuration is reloaded upon each request, however, any configuration used within the `application.rb` file and initializers
120
+ will _not_ be automatically reloaded, without having to restart your web server.
108
121
 
109
122
  ## Project Info
110
123
 
@@ -1,5 +1,5 @@
1
1
  Description:
2
- Creates the default configuration file (config.yml) in the project root directory.
2
+ Creates the default configuration file (config.yml) in the project config directory.
3
3
 
4
4
  Example:
5
5
  `rails generate rails_simple_config:install`
@@ -1,12 +1,11 @@
1
1
  module RailsSimpleConfig
2
2
  class InstallGenerator < Rails::Generators::Base
3
3
  source_root File.expand_path('../templates', __FILE__)
4
-
4
+
5
5
  def copy_files
6
- template "config.yml", "./config.yml"
7
- template "secrets.yml", "./secrets.yml"
8
- template "secrets.yml", "./secrets.example.yml"
6
+ template "config.yml", File.join("config", "config.yml")
7
+ template "secrets.yml", File.join("config", "secrets.yml") unless File.exist?(File.join("config", "secrets.yml"))
9
8
  end
10
-
9
+
11
10
  end
12
11
  end
@@ -12,9 +12,12 @@ shared: &shared
12
12
 
13
13
  # application settings
14
14
  title: Example
15
- description:
16
- keywords:
17
- version:
15
+ description:
16
+ version: 0.0.1
17
+
18
+ # vendor information
19
+ vendor: "Your Company Name"
20
+ copyright: "&copy; <%= Date.today.year %> Your Company Name"
18
21
 
19
22
  # url settings
20
23
  scheme: http
@@ -22,7 +25,7 @@ shared: &shared
22
25
 
23
26
  # mail settings
24
27
  smtp_domain: www.example.com
25
- smtp_server:
28
+ smtp_server:
26
29
  smtp_user_name:
27
30
  smtp_password:
28
31
 
@@ -30,19 +33,19 @@ shared: &shared
30
33
  info_email: info@example.com
31
34
  no_reply_email: noreply@example.com
32
35
  support_email: support@example.com
33
-
36
+
34
37
  ##
35
- # Define settings per Rails environment,
38
+ # Define settings per Rails environment,
36
39
  # provide overrides to the shared settings as needed
37
40
  #
38
41
  development:
39
42
  # inherit shared settings
40
43
  <<: *shared
41
-
44
+
42
45
  # url settings
43
46
  subdomain: dev
44
47
  domain: localhost:3000
45
-
48
+
46
49
  # mail setting (for mailcatcher)
47
50
  smtp_server: localhost
48
51
  smtp_port: 1025
@@ -14,18 +14,18 @@
14
14
  shared: &shared
15
15
 
16
16
  ## E.g. Amazon key and secret
17
- # s3_key: XXXXXXXXXXXXXXXXXXXX
17
+ # s3_key: XXXXXXXXXXXXXXXXXXXX
18
18
  # s3_secret: 12345678901234567890ABCDEFGHIJKLMNOPQRST
19
19
  example: sekret!
20
20
 
21
21
  ##
22
- # Define settings per Rails environment,
22
+ # Define settings per Rails environment,
23
23
  # provide overrides to the shared settings as needed
24
24
  #
25
25
  development:
26
26
  # inherit shared settings
27
27
  <<: *shared
28
-
28
+
29
29
  test:
30
30
  # inherit shared settings
31
31
  <<: *shared
@@ -12,7 +12,11 @@ module RailsSimpleConfig
12
12
  if Rails.env.development?
13
13
  initializer :load_simple_config_development do
14
14
  ActionController::Base.class_eval do
15
- prepend_before_filter { ::SimpleConfig.reload! }
15
+ if Rails::VERSION::MAJOR >= 6 || (Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 1)
16
+ prepend_before_action { ::SimpleConfig.reload! }
17
+ else
18
+ prepend_before_filter { ::SimpleConfig.reload! }
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -1,3 +1,3 @@
1
1
  module RailsSimpleConfig
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -10,8 +10,8 @@ module SimpleConfig
10
10
 
11
11
  def load!
12
12
  puts "Loading configuration for '#{Rails.env}'."
13
- load_file(Rails.root + 'secrets.yml')
14
- load_file(Rails.root + 'config.yml')
13
+ load_file File.join(Rails.root, 'config', 'secrets.yml')
14
+ load_file File.join(Rails.root, 'config', 'config.yml')
15
15
  end
16
16
 
17
17
  def reload!
@@ -23,7 +23,7 @@ module SimpleConfig
23
23
 
24
24
  def load_file(filename)
25
25
  if File.exist?(filename)
26
- configuration = YAML.load(ERB.new(File.read(filename)).result)[Rails.env]
26
+ configuration = YAML.load(ERB.new(File.read(filename)).result(binding))[Rails.env]
27
27
  configuration.each do |key, value|
28
28
  self.__send__("#{key}=", value)
29
29
  end if configuration
@@ -48,3 +48,5 @@ module SimpleConfig
48
48
 
49
49
  end
50
50
 
51
+ # alias to support using AppConfig global
52
+ AppConfig = SimpleConfig
@@ -4,8 +4,8 @@ require "rails_simple_config/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "rails_simple_config"
7
- s.summary = %q{Simple YAML based configuration gem for Rails 3+}
8
- s.description = %q{A simple YAML based configuration for Ruby on Rails 3+, which supports shared settings, ERB and more.}
7
+ s.summary = %q{Simple YAML based configuration gem for Rails}
8
+ s.description = %q{A simple YAML based configuration for Ruby on Rails, which supports shared settings, ERB and more.}
9
9
 
10
10
  s.authors = ["Chris Stefano"]
11
11
  s.email = ["virtualstaticvoid@gmail.com"]
metadata CHANGED
@@ -1,25 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_simple_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Stefano
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-09-09 00:00:00.000000000Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: A simple YAML based configuration for Ruby on Rails 3+, which supports
15
- shared settings, ERB and more.
13
+ description: A simple YAML based configuration for Ruby on Rails, which supports shared
14
+ settings, ERB and more.
16
15
  email:
17
16
  - virtualstaticvoid@gmail.com
18
17
  executables: []
19
18
  extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
22
- - .gitignore
21
+ - ".gitignore"
23
22
  - Gemfile
24
23
  - Gemfile.lock
25
24
  - MIT-LICENSE
@@ -35,26 +34,24 @@ files:
35
34
  - rails_simple_config.gemspec
36
35
  homepage: https://github.com/virtualstaticvoid/rails_simple_config
37
36
  licenses: []
37
+ metadata: {}
38
38
  post_install_message:
39
39
  rdoc_options: []
40
40
  require_paths:
41
41
  - lib
42
42
  required_ruby_version: !ruby/object:Gem::Requirement
43
- none: false
44
43
  requirements:
45
- - - ! '>='
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
47
  required_rubygems_version: !ruby/object:Gem::Requirement
49
- none: false
50
48
  requirements:
51
- - - ! '>='
49
+ - - ">="
52
50
  - !ruby/object:Gem::Version
53
51
  version: '0'
54
52
  requirements: []
55
- rubyforge_project: rails_simple_config
56
- rubygems_version: 1.8.6
53
+ rubygems_version: 3.2.3
57
54
  signing_key:
58
- specification_version: 3
59
- summary: Simple YAML based configuration gem for Rails 3+
55
+ specification_version: 4
56
+ summary: Simple YAML based configuration gem for Rails
60
57
  test_files: []