rails_simple_config 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +15 -15
- data/lib/rails_simple_config/railtie.rb +1 -1
- data/lib/rails_simple_config/version.rb +1 -1
- data/lib/rails_simple_config.rb +6 -6
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22fc744a5f6eaf1693c651df056cbb2576af72531b89e7158504f3a2bb738df7
|
4
|
+
data.tar.gz: 2662fb642e4638e8f6ce875af3d108efa258e70696e5ab2e5a07a28d4057c48c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84203788a331cb49209f23102ff4670cd4e4cc704e42aabb53305dcf784ccf88ed2566de0c03e5291f84e0209344876efd181717d26f6dadb89110f4f879a18b
|
7
|
+
data.tar.gz: 4a14cf4b341231acb917d7d122fe5b30b41a54db1d7f786efc200dbca1919999c7652c06ca873562bfe929b89dce7e561a528b740b216f65f009041ccad550df
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -15,17 +15,17 @@ Add RailsSimpleConfig to your Gemfile:
|
|
15
15
|
Run the generator to create the default configuration files:
|
16
16
|
|
17
17
|
rails generate rails_simple_config:install
|
18
|
-
|
18
|
+
|
19
19
|
The generator will create 3 files in your Rails `config` directory, namely:
|
20
20
|
|
21
21
|
* `secrets.yml`
|
22
22
|
* `secrets.example.yml`
|
23
23
|
* `config.yml`
|
24
24
|
|
25
|
-
The `secrets.yml` should _not_ be committed to source control. It should be used to keep settings which are
|
25
|
+
The `secrets.yml` should _not_ be committed to source control. It should be used to keep settings which are
|
26
26
|
considered a secret; such as your Amazon credentials. It is loaded first.
|
27
27
|
|
28
|
-
The `secrets.example.yml` file can be added to source control and should serve as an _example_ of the settings
|
28
|
+
The `secrets.example.yml` file can be added to source control and should serve as an _example_ of the settings
|
29
29
|
contained in the `secrets.yml` file.
|
30
30
|
|
31
31
|
The `config.yml` file should contain all other configuration settings.
|
@@ -34,42 +34,42 @@ The `config.yml` file should contain all other configuration settings.
|
|
34
34
|
|
35
35
|
### Define configuration settings
|
36
36
|
|
37
|
-
Define your settings in the generated `secrets.yml` and `config.yml` files, found in your Rails `config` directory.
|
37
|
+
Define your settings in the generated `secrets.yml` and `config.yml` files, found in your Rails `config` directory.
|
38
38
|
|
39
39
|
Both files contain a shared section and sections with overrides for the respective development, test and production Rails environments.
|
40
40
|
It can also contain ERB code so that more advanced configuration scenarios can be supported.
|
41
41
|
|
42
42
|
# example configuration
|
43
|
-
|
43
|
+
|
44
44
|
shared: &shared
|
45
45
|
|
46
46
|
title: My Website Title
|
47
47
|
description: Meta description of the site
|
48
48
|
keywords: Meta keywords for search engines
|
49
|
-
|
49
|
+
|
50
50
|
no_reply_email: noreply@example.com
|
51
51
|
|
52
52
|
dynamic_setting: <%= 30 * 60 %>
|
53
|
-
|
53
|
+
|
54
54
|
development:
|
55
55
|
|
56
56
|
# inherit shared settings
|
57
57
|
<<: *shared
|
58
|
-
|
58
|
+
|
59
59
|
# define additional settings and overrides
|
60
|
-
|
60
|
+
|
61
61
|
# e.g. mail settings for mailcatcher
|
62
62
|
smtp_server: localhost
|
63
63
|
smtp_port: 1025
|
64
64
|
mail_prefix: DEV -
|
65
|
-
|
65
|
+
|
66
66
|
production:
|
67
67
|
|
68
68
|
# inherit shared settings
|
69
69
|
<<: *shared
|
70
|
-
|
70
|
+
|
71
71
|
# define additional settings and overrides
|
72
|
-
|
72
|
+
|
73
73
|
# e.g. mail settings for send grid
|
74
74
|
smtp_server: www.sendgrid.com
|
75
75
|
smtp_port: 25
|
@@ -94,9 +94,9 @@ For example, in your application layout:
|
|
94
94
|
...
|
95
95
|
|
96
96
|
</body>
|
97
|
-
</html>
|
97
|
+
</html>
|
98
98
|
|
99
|
-
In addition, unlike other Rails configuration solutions, `SimpleConfig` is available to the Rails development, test and production environment configuration files,
|
99
|
+
In addition, unlike other Rails configuration solutions, `SimpleConfig` is available to the Rails development, test and production environment configuration files,
|
100
100
|
initializers and routes during startup. It can be used as a replacement for environment variables; thus making your setup and code much cleaner.
|
101
101
|
|
102
102
|
For example, the `SimpleConfig.no_reply_email` will be accessible to the [devise](https://github.com/plataformatec/devise) initializer when configuring `mailer_sender`:
|
@@ -116,7 +116,7 @@ For example, the `SimpleConfig.no_reply_email` will be accessible to the [devise
|
|
116
116
|
|
117
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`.
|
118
118
|
|
119
|
-
In development, the configuration is reloaded upon each request, however, any configuration used within the `application.rb` file and initializers
|
119
|
+
In development, the configuration is reloaded upon each request, however, any configuration used within the `application.rb` file and initializers
|
120
120
|
will _not_ be automatically reloaded, without having to restart your web server.
|
121
121
|
|
122
122
|
## Project Info
|
@@ -12,7 +12,7 @@ module RailsSimpleConfig
|
|
12
12
|
if Rails.env.development?
|
13
13
|
initializer :load_simple_config_development do
|
14
14
|
ActionController::Base.class_eval do
|
15
|
-
if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 1
|
15
|
+
if Rails::VERSION::MAJOR >= 6 || (Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 1)
|
16
16
|
prepend_before_action { ::SimpleConfig.reload! }
|
17
17
|
else
|
18
18
|
prepend_before_filter { ::SimpleConfig.reload! }
|
data/lib/rails_simple_config.rb
CHANGED
@@ -13,17 +13,17 @@ module SimpleConfig
|
|
13
13
|
load_file File.join(Rails.root, 'config', 'secrets.yml')
|
14
14
|
load_file File.join(Rails.root, 'config', 'config.yml')
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def reload!
|
18
18
|
clear
|
19
19
|
load!
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
private
|
23
|
-
|
23
|
+
|
24
24
|
def load_file(filename)
|
25
25
|
if File.exist?(filename)
|
26
|
-
configuration = YAML.load(ERB.new(File.read(filename)).result(binding))[Rails.env]
|
26
|
+
configuration = YAML.load(ERB.new(File.read(filename)).result(binding), aliases: true)[Rails.env]
|
27
27
|
configuration.each do |key, value|
|
28
28
|
self.__send__("#{key}=", value)
|
29
29
|
end if configuration
|
@@ -33,11 +33,11 @@ module SimpleConfig
|
|
33
33
|
end
|
34
34
|
|
35
35
|
@@config = Config.new
|
36
|
-
|
36
|
+
|
37
37
|
def self.load!
|
38
38
|
@@config.load!
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def self.reload!
|
42
42
|
@@config.reload!
|
43
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_simple_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Stefano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple YAML based configuration for Ruby on Rails, which supports shared
|
14
14
|
settings, ERB and more.
|
@@ -50,8 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
|
-
|
54
|
-
rubygems_version: 2.7.6
|
53
|
+
rubygems_version: 3.4.10
|
55
54
|
signing_key:
|
56
55
|
specification_version: 4
|
57
56
|
summary: Simple YAML based configuration gem for Rails
|