Skip to content

Commit 2958927

Browse files
committed
Add new Settings gem.
1 parent eb19fb0 commit 2958927

File tree

8 files changed

+102
-1
lines changed

8 files changed

+102
-1
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ rails-starter.sublime-workspace
4040
/yarn-error.log
4141
yarn-debug.log*
4242
.yarn-integrity
43+
44+
config/settings.local.yml
45+
config/settings/*.local.yml
46+
config/environments/*.local.yml

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ gem "devise-i18n"
2727

2828
gem "meta-tags"
2929

30+
gem "config"
31+
3032
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
3133
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
3234

Gemfile.lock

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://git.thape.com.cn/rails/rails.git
3-
revision: ec9bed721be70c8deca5a57d3240c3a1d60f5622
3+
revision: a9e2f8440f1a532872b6039ff296df64465994c1
44
branch: eric_read
55
specs:
66
actioncable (7.1.0.alpha)
@@ -133,12 +133,16 @@ GEM
133133
regexp_parser (>= 1.5, < 3.0)
134134
xpath (~> 3.2)
135135
concurrent-ruby (1.2.0)
136+
config (4.1.0)
137+
deep_merge (~> 1.2, >= 1.2.1)
138+
dry-validation (~> 1.0, >= 1.0.0)
136139
connection_pool (2.3.0)
137140
crass (1.0.6)
138141
date (3.3.3)
139142
debug (1.7.1)
140143
irb (>= 1.5.0)
141144
reline (>= 0.3.1)
145+
deep_merge (1.2.2)
142146
devise (4.9.0)
143147
bcrypt (~> 3.0)
144148
orm_adapter (~> 0.1)
@@ -147,6 +151,38 @@ GEM
147151
warden (~> 1.2.3)
148152
devise-i18n (1.11.0)
149153
devise (>= 4.9.0)
154+
dry-configurable (1.0.1)
155+
dry-core (~> 1.0, < 2)
156+
zeitwerk (~> 2.6)
157+
dry-core (1.0.0)
158+
concurrent-ruby (~> 1.0)
159+
zeitwerk (~> 2.6)
160+
dry-inflector (1.0.0)
161+
dry-initializer (3.1.1)
162+
dry-logic (1.5.0)
163+
concurrent-ruby (~> 1.0)
164+
dry-core (~> 1.0, < 2)
165+
zeitwerk (~> 2.6)
166+
dry-schema (1.13.0)
167+
concurrent-ruby (~> 1.0)
168+
dry-configurable (~> 1.0, >= 1.0.1)
169+
dry-core (~> 1.0, < 2)
170+
dry-initializer (~> 3.0)
171+
dry-logic (>= 1.5, < 2)
172+
dry-types (>= 1.7, < 2)
173+
zeitwerk (~> 2.6)
174+
dry-types (1.7.1)
175+
concurrent-ruby (~> 1.0)
176+
dry-core (~> 1.0)
177+
dry-inflector (~> 1.0)
178+
dry-logic (~> 1.4)
179+
zeitwerk (~> 2.6)
180+
dry-validation (1.10.0)
181+
concurrent-ruby (~> 1.0)
182+
dry-core (~> 1.0, < 2)
183+
dry-initializer (~> 3.0)
184+
dry-schema (>= 1.12, < 2)
185+
zeitwerk (~> 2.6)
150186
ed25519 (1.3.0)
151187
erubi (1.12.0)
152188
globalid (1.1.0)
@@ -302,6 +338,7 @@ DEPENDENCIES
302338
capistrano-rbenv
303339
capistrano3-puma (>= 6.0.0.beta.1)
304340
capybara
341+
config
305342
debug
306343
devise
307344
devise-i18n

config/initializers/config.rb

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Config.setup do |config|
2+
# Name of the constant exposing loaded settings
3+
config.const_name = 'Settings'
4+
5+
# Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'.
6+
#
7+
# config.knockout_prefix = nil
8+
9+
# Overwrite an existing value when merging a `nil` value.
10+
# When set to `false`, the existing value is retained after merge.
11+
#
12+
# config.merge_nil_values = true
13+
14+
# Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged.
15+
#
16+
# config.overwrite_arrays = true
17+
18+
# Load environment variables from the `ENV` object and override any settings defined in files.
19+
#
20+
# config.use_env = false
21+
22+
# Define ENV variable prefix deciding which variables to load into config.
23+
#
24+
# Reading variables from ENV is case-sensitive. If you define lowercase value below, ensure your ENV variables are
25+
# prefixed in the same way.
26+
#
27+
# When not set it defaults to `config.const_name`.
28+
#
29+
config.env_prefix = 'SETTINGS'
30+
31+
# What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well
32+
# with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where
33+
# using dots in variable names might not be allowed (eg. Bash).
34+
#
35+
# config.env_separator = '.'
36+
37+
# Ability to process variables names:
38+
# * nil - no change
39+
# * :downcase - convert to lower case
40+
#
41+
# config.env_converter = :downcase
42+
43+
# Parse numeric values as integers instead of strings.
44+
#
45+
# config.env_parse_values = true
46+
47+
# Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details.
48+
#
49+
# config.schema do
50+
# required(:name).filled
51+
# required(:age).maybe(:int?)
52+
# required(:email).filled(format?: EMAIL_REGEX)
53+
# end
54+
55+
# Evaluate ERB in YAML config files at load time.
56+
#
57+
# config.evaluate_erb_in_yaml = true
58+
end

config/settings.yml

Whitespace-only changes.

config/settings/development.yml

Whitespace-only changes.

config/settings/production.yml

Whitespace-only changes.

config/settings/test.yml

Whitespace-only changes.

0 commit comments

Comments
 (0)