has_configuration 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/has_configuration/configuration.rb +14 -13
- data/lib/version.rb +1 -1
- data/spec/lib/has_configuration_spec.rb +5 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef13678ebcf0232c7c0b7535487a70b25d0e245686ca4acb7a8683cbee59d4a
|
4
|
+
data.tar.gz: '04568b62a1c1259c4e14dca63438e3ac60032f1ca78e103a0c09f0d8d816b14f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad96fe37a596f768234729a99597a4429d1893b4765ba6196e3f904f038e021b4a5395927ae58a5f0d4a102568d0cbe663b4d85bd0d675563881e1bdb6b1cac6
|
7
|
+
data.tar.gz: 12f7267b2de11e3c0fe91b77e222281cf6dafc010f6d817358cd78ac936f5457612535a995b2bffde62efd65923bc105f4d7e33ad2a96d3347ee2e59d7a0710a
|
@@ -59,15 +59,18 @@ module HasConfiguration #:nodoc:
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def filename
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
62
|
+
@options[:file] || determine_filename_from_class ||
|
63
|
+
raise(
|
64
|
+
ArgumentError,
|
65
|
+
'Unable to resolve filename, please add :file parameter to has_configuration'
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def determine_filename_from_class
|
70
|
+
return unless @class_name
|
71
|
+
|
72
|
+
filename = "#{@class_name.downcase}.yml"
|
73
|
+
defined?(Rails) ? Rails.root.join('config', filename).to_s : filename
|
71
74
|
end
|
72
75
|
|
73
76
|
def environment
|
@@ -91,13 +94,11 @@ module HasConfiguration #:nodoc:
|
|
91
94
|
@deep_stringified_hash ||= deep_transform_keys(@hash, &:to_s)
|
92
95
|
end
|
93
96
|
|
94
|
-
# from Rails
|
97
|
+
# from Rails (/active_support/core_ext/hash/keys.rb)
|
95
98
|
def deep_transform_keys(hash, &block)
|
96
|
-
|
97
|
-
hash&.each do |key, value|
|
99
|
+
hash&.each_with_object({}) do |(key, value), result|
|
98
100
|
result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value
|
99
101
|
end
|
100
|
-
result
|
101
102
|
end
|
102
103
|
end
|
103
104
|
end
|
data/lib/version.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
class Dummy
|
4
|
+
require 'has_configuration'
|
5
|
+
has_configuration file: 'spec/fixtures/class.yml'
|
6
|
+
end
|
7
|
+
|
3
8
|
RSpec.describe HasConfiguration do
|
4
9
|
context 'when declared' do
|
5
|
-
Dummy = Class.new do
|
6
|
-
require 'has_configuration'
|
7
|
-
has_configuration file: 'spec/fixtures/class.yml'
|
8
|
-
end
|
9
|
-
|
10
10
|
context 'with a class' do
|
11
11
|
subject(:dummy) { Dummy }
|
12
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_configuration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Spickermann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -133,7 +133,7 @@ homepage: https://github.com/spickermann/has_configuration
|
|
133
133
|
licenses:
|
134
134
|
- MIT
|
135
135
|
metadata: {}
|
136
|
-
post_install_message:
|
136
|
+
post_install_message:
|
137
137
|
rdoc_options: []
|
138
138
|
require_paths:
|
139
139
|
- lib
|
@@ -148,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
152
|
-
signing_key:
|
151
|
+
rubygems_version: 3.2.3
|
152
|
+
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Simple configuration handling
|
155
155
|
test_files: []
|