rails-etcs 0.1.0.beta2 → 0.1.0.beta3
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.
- checksums.yaml +4 -4
- data/Appraisals +1 -1
- data/Gemfile +3 -0
- data/README.md +21 -6
- data/gemfiles/rails_4.2.gemfile +3 -0
- data/gemfiles/rails_5.0.gemfile +3 -0
- data/gemfiles/rails_5.1.gemfile +3 -0
- data/gemfiles/rails_5.2.gemfile +4 -1
- data/gemfiles/rails_head.gemfile +3 -0
- data/lib/rails/etcs/application/configuration.rb +10 -1
- data/lib/rails/etcs/application.rb +23 -13
- data/lib/rails/etcs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2b1136012e22d9ec9e8be3561c1fd2e6596df1c4a5db2189cf567fb420440fc
|
4
|
+
data.tar.gz: b82da6f787f7c42f9f374fcee9ff45651884dc7d96e8a6817a277bda59433622
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aedbf7efe88f3314d7d12721b451ebe4df6affbe000e425a88924d1b1f806b6a7c553dd8ba5e1fb0bbe0691de45dea48a1781b58a1b9d6e86487e264de196584
|
7
|
+
data.tar.gz: 524a96fd53f1f7269881313bd4ab4a0bb135b256bf3d63d86bace93035c4cc4373a90622428aef25ce1282dbff2fa43a22732e9490021a579d0605ab09cffb05
|
data/Appraisals
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,21 +2,18 @@
|
|
2
2
|
|
3
3
|
A collection of patches and alternatives for Rails core classes.
|
4
4
|
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
If you cannot install the gem alone you should better not use it.
|
8
|
-
|
9
5
|
## Usage
|
10
6
|
|
11
7
|
### Rails::Etcs::Application
|
12
8
|
|
13
|
-
`Rails::Etcs::Application` can be
|
9
|
+
`Rails::Etcs::Application` can be included when creating your application:
|
14
10
|
|
15
11
|
```ruby
|
16
12
|
# my-app/config/application.rb
|
17
13
|
|
18
14
|
module MyApp
|
19
|
-
class Application < ::Rails::
|
15
|
+
class Application < ::Rails::Application
|
16
|
+
include ::Rails::Etcs::Application
|
20
17
|
self.ident = 'my-app'
|
21
18
|
end
|
22
19
|
end
|
@@ -46,6 +43,24 @@ You can customize the application name via `self.ident = 'my-app'`. Configuratio
|
|
46
43
|
The same lookup is applied for `database.yml`, `secrets.yml`, and additional
|
47
44
|
initializers and environments files.
|
48
45
|
|
46
|
+
#### `#config_for`
|
47
|
+
|
48
|
+
`#config_for` has been patched with additional functionality.
|
49
|
+
|
50
|
+
It returns the full parsed config instead of the environment key when `env: false` is passed:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
config_for('database', env: false) # => {'development' => ..., 'test' => ..., ...}
|
54
|
+
```
|
55
|
+
|
56
|
+
The additional `quiet` keyword argument can be used to suppress a file not found exception. Together with the new `yield` support you can easily handle optional configuration:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
config_for('may-exist-or-not', quiet: true) do |conf|
|
60
|
+
# ...
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
49
64
|
## License
|
50
65
|
|
51
66
|
Rails::Etcs (c) 2018 Jan Graichen
|
data/gemfiles/rails_4.2.gemfile
CHANGED
data/gemfiles/rails_5.0.gemfile
CHANGED
data/gemfiles/rails_5.1.gemfile
CHANGED
data/gemfiles/rails_5.2.gemfile
CHANGED
data/gemfiles/rails_head.gemfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'xdg'
|
4
4
|
|
5
|
-
|
5
|
+
module Rails::Etcs::Application
|
6
6
|
class Configuration < ::Rails::Application::Configuration
|
7
7
|
attr_reader :ident
|
8
8
|
|
@@ -47,6 +47,15 @@ class Rails::Etcs::Application
|
|
47
47
|
with: paths['config'],
|
48
48
|
glob: 'secrets.yml{,.enc}'
|
49
49
|
|
50
|
+
if Gem::Requirement.new('< 5.1') =~ Gem::Version.new(Rails.version)
|
51
|
+
# Rails < 5.1 does not check for existing secrets file but just
|
52
|
+
# uses the first path even if it does not exist.
|
53
|
+
#
|
54
|
+
# This workaround fixes that by pre-expanding the path with only
|
55
|
+
# existing files.
|
56
|
+
paths.add 'config/secrets', with: paths['config/secrets'].existent
|
57
|
+
end
|
58
|
+
|
50
59
|
paths['config'].to_ary.reverse.each do |dir|
|
51
60
|
paths['config/initializers'] << File.join(dir, 'initializers')
|
52
61
|
paths['config/environments'] << File.join(dir, 'environments')
|
@@ -1,9 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Rails::Etcs
|
4
|
-
|
4
|
+
module Application
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
5
7
|
require 'rails/etcs/application/configuration'
|
6
8
|
|
9
|
+
included do
|
10
|
+
attr_writer :ident
|
11
|
+
|
12
|
+
def ident
|
13
|
+
@ident ||= begin
|
14
|
+
self.class.name.underscore
|
15
|
+
.gsub(/[^A-z]+/, '-')
|
16
|
+
.gsub(/-application$/, '')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
7
21
|
def config
|
8
22
|
@config ||= begin
|
9
23
|
root = self.class.find_root self.class.called_from
|
@@ -14,7 +28,8 @@ module Rails::Etcs
|
|
14
28
|
|
15
29
|
# rubocop:disable AbcSize
|
16
30
|
# rubocop:disable MethodLength
|
17
|
-
|
31
|
+
# rubocop:disable CyclomaticComplexity
|
32
|
+
def config_for(name, env: Rails.env, quiet: false)
|
18
33
|
files = paths['config']
|
19
34
|
.expanded
|
20
35
|
.map {|d| Pathname.new(d).join("#{name}.yml") }
|
@@ -22,13 +37,18 @@ module Rails::Etcs
|
|
22
37
|
yaml = files.find(&:exist?)
|
23
38
|
|
24
39
|
unless yaml
|
40
|
+
return if quiet
|
25
41
|
raise "Could not load configuration. No such file - #{files.join(', ')}"
|
26
42
|
end
|
27
43
|
|
28
44
|
require 'erb'
|
29
45
|
|
30
46
|
data = YAML.safe_load(ERB.new(yaml.read).result, [], [], true) || {}
|
31
|
-
data.fetch(env, {})
|
47
|
+
data = env ? data.fetch(env, {}) : data
|
48
|
+
|
49
|
+
yield data if block_given?
|
50
|
+
|
51
|
+
data
|
32
52
|
rescue Psych::SyntaxError => e
|
33
53
|
raise <<~ERR
|
34
54
|
YAML syntax error occurred while parsing #{yaml}.
|
@@ -38,15 +58,5 @@ module Rails::Etcs
|
|
38
58
|
ERR
|
39
59
|
end
|
40
60
|
# rubocop:enable all
|
41
|
-
|
42
|
-
class << self
|
43
|
-
attr_writer :ident
|
44
|
-
|
45
|
-
def ident
|
46
|
-
@ident ||= begin
|
47
|
-
name.underscore.gsub(/[^A-z]+/, '-').gsub(/-application$/, '')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
61
|
end
|
52
62
|
end
|
data/lib/rails/etcs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-etcs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xdg
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: 1.3.1
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.7.
|
110
|
+
rubygems_version: 2.7.7
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Collection of patches and alternatives for Rails core classes
|