has_configuration 5.0.0 → 5.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e42443c258397453654818b1b489594899b993f9353a0f5773929692a5e25eb8
4
- data.tar.gz: 487e9fcd0fce895bde4e1647a8cc048c75ae231181b2d2ac9cd89f73f916717e
3
+ metadata.gz: 9ef13678ebcf0232c7c0b7535487a70b25d0e245686ca4acb7a8683cbee59d4a
4
+ data.tar.gz: '04568b62a1c1259c4e14dca63438e3ac60032f1ca78e103a0c09f0d8d816b14f'
5
5
  SHA512:
6
- metadata.gz: 9305a55f4a488492d459b583e44ccf956e124a94e1b5a9daa58765ee0bf4b7e6b239770a76594eef0e3b5ee1ce648b4857c766ff9cdc9102f1486e7057cfeddd
7
- data.tar.gz: 6045d9a8e991cc88829f7be6b816d3da307ea68928734bdf4cf43e7e41c8c048931233dba85cf24649e7d4618ed194dd0e9489cc3748e6a8473fbc3ba64a3e0a
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
- if @options[:file]
63
- @options[:file]
64
- elsif @class_name
65
- filename = "#{@class_name.downcase}.yml"
66
- defined?(Rails) ? Rails.root.join('config', filename).to_s : filename
67
- else
68
- raise ArgumentError,
69
- 'Unable to resolve filename, please add :file parameter to has_configuration'
70
- end
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 4.0 (/active_support/core_ext/hash/keys.rb)
97
+ # from Rails (/active_support/core_ext/hash/keys.rb)
95
98
  def deep_transform_keys(hash, &block)
96
- result = {}
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
@@ -4,7 +4,7 @@ module HasConfiguration #:nodoc:
4
4
  module VERSION #:nodoc:
5
5
  MAJOR = 5
6
6
  MINOR = 0
7
- BUILD = 0
7
+ BUILD = 1
8
8
 
9
9
  STRING = [MAJOR, MINOR, BUILD].join('.')
10
10
  end
@@ -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.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-04-12 00:00:00.000000000 Z
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.1.2
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: []