rails_simple_config 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +26 -13
- data/lib/generators/rails_simple_config/install/install_generator.rb +3 -4
- data/lib/generators/rails_simple_config/install/templates/config.yml +11 -8
- data/lib/generators/rails_simple_config/install/templates/secrets.yml +3 -3
- data/lib/rails_simple_config/version.rb +1 -1
- data/rails_simple_config.gemspec +2 -2
- metadata +11 -13
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7062295f831684ba50ddcf292ee79cafc5857106
|
4
|
+
data.tar.gz: 81980f9ce7356c3bcd2bec9b0ac1f1bec3d31b03
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be92eb057ed4a1d32a26a7baf525d5b35ad6528869f61b0232b60408a3c1be89b5cef66389b4a833fc6169234101808b9a89e17d2aea1c4a31cee020a84a4144
|
7
|
+
data.tar.gz: f2cc3d168e8c8ca02a5a95a1bd1322b1361ad97b597b8443c1c1b0c218e7c91d1070373766205362e006829b78ffe86bccdb712ade07743ec875f2597f684b72
|
data/Gemfile.lock
CHANGED
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
|
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 `config` directory
|
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
|
20
|
-
considered a secret; such as your Amazon credentials.
|
21
|
-
|
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`
|
37
|
+
Define your settings in the generated `secrets.yml` and `config.yml` files, found in your Rails `config` directory.
|
30
38
|
|
31
|
-
|
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
|
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
|
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`
|
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`
|
107
|
-
|
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,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
6
|
template "config.yml", File.join("config", "config.yml")
|
7
|
-
template "secrets.yml", File.join("config", "secrets.yml")
|
8
|
-
template "secrets.yml", File.join("config", "secrets.example.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
|
-
|
17
|
-
|
15
|
+
description:
|
16
|
+
version: 0.0.1
|
17
|
+
|
18
|
+
# vendor information
|
19
|
+
vendor: "Your Company Name"
|
20
|
+
copyright: "© <%= 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
|
data/rails_simple_config.gemspec
CHANGED
@@ -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
|
8
|
-
s.description = %q{A simple YAML based configuration for Ruby on Rails
|
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.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Stefano
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description: A simple YAML based configuration for Ruby on Rails
|
15
|
-
|
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,25 @@ 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
53
|
rubyforge_project: rails_simple_config
|
56
|
-
rubygems_version:
|
54
|
+
rubygems_version: 2.2.2
|
57
55
|
signing_key:
|
58
|
-
specification_version:
|
59
|
-
summary: Simple YAML based configuration gem for Rails
|
56
|
+
specification_version: 4
|
57
|
+
summary: Simple YAML based configuration gem for Rails
|
60
58
|
test_files: []
|