config 5.1.0 → 5.3.0

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: 0e7864a2d30e62a39dbeb3c3eff43e07568a844b391e8c5f51f49c0712a2786b
4
- data.tar.gz: b79745abcd726d5665aff0069ef3bef63250af5df0157f7515d0f67b65bfc9f6
3
+ metadata.gz: 777b7f8139564b25204ca8c3d375044d16d7ed58132d898493404f04133f7a22
4
+ data.tar.gz: 8ce204241f891f5cf9b2130d02c0d03c12999624dd6a12efc653462bc4e781f1
5
5
  SHA512:
6
- metadata.gz: 27b2ac548df27cb149bfb6f60753179d36d6bf2fa3caa0cb7a5f5e456450840357272c4c53bba986ad8f62d12f79960e87183faa2cd48f0afecdb695c802730a
7
- data.tar.gz: 71c11e19fe808da90a497616ff635e00e0a3a86c971b751cf5e9bdebe34d86272a9197ca1b8104f7a1b0d2d98677ecb56bb681168c7a08d9bbc4e7cf9b914913
6
+ metadata.gz: 143d0364fd88bfacfceb6032d82bdd7e8cf74179f4bef6b9439dc966e94692ebfd41c166a85b31dbfa052b57004cfbc91dccb6fb80646d23764ee5a9466f1902
7
+ data.tar.gz: a71272f604d882b05eab6958bddbb0aac72894dc62463668aaedcd3d98814d6eada6ab480cffd0679763bb0d8a125e792e7d02577b118a7771738dace0ad6af3
data/CHANGELOG.md CHANGED
@@ -1,8 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.3.0
4
+
5
+ * Remove `dry-validation` from dependencies ([#333](https://github.com/rubyconfig/config/pull/333))
6
+
7
+ ## 5.2.0
8
+
9
+ ### New features
10
+
11
+ * Allow to use custom filename && directory name to store configs ([#341](https://github.com/rubyconfig/config/pull/341))
12
+
13
+ ### Bug fixes
14
+
15
+ * Prevent name collision with private methods from ancestors ([#351](https://github.com/rubyconfig/config/pull/351))
16
+
3
17
  ## 5.1.0
4
18
 
5
- * Fix conflicts with Rails 7 active_support methods ([#347](https://github.com/rubyconfig/config/pull/339))
19
+ * Fix conflicts with Rails 7 active_support methods ([#347](https://github.com/rubyconfig/config/pull/347))
6
20
 
7
21
  ## 5.0.0
8
22
 
data/README.md CHANGED
@@ -270,6 +270,8 @@ After installing `Config` in Rails, you will find automatically generated file t
270
270
 
271
271
  * `const_name` - name of the object holing you settings. Default: `'Settings'`
272
272
  * `evaluate_erb_in_yaml` - evaluate ERB in YAML config files. Set to false if the config file contains ERB that should not be evaluated at load time. Default: `true`
273
+ * `file_name` - name of the file to store general keys accessible in all environments. Default: `'settings'` - located at `config/settings.yml`
274
+ * `dir_name` - name of the directory to store environment-specific files. Default: `'settings'` - located at `config/settings/`
273
275
 
274
276
  ### Merge customization
275
277
 
data/config.gemspec CHANGED
@@ -1,6 +1,5 @@
1
- $:.push File.expand_path('../lib', __FILE__)
2
-
3
- require 'config/version'
1
+ require_relative 'lib/config/version'
2
+ require_relative 'lib/config/dry_validation_requirements'
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.name = 'config'
@@ -20,6 +19,11 @@ Please consider donating to our open collective to help us maintain this project
20
19
  \n
21
20
  Donate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
22
21
 
22
+ s.metadata = {
23
+ 'changelog_uri' => "https://github.com/rubyconfig/config/blob/master/CHANGELOG.md",
24
+ 'source_code_uri' => 'https://github.com/rubyconfig/config',
25
+ 'bug_tracker_uri' => 'https://github.com/rubyconfig/config/issues'
26
+ }
23
27
  s.files = `git ls-files`.split($/)
24
28
  s.files.select! { |file| /(^lib\/|^\w+.md$|\.gemspec$)/ =~ file }
25
29
 
@@ -27,8 +31,8 @@ Donate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
27
31
  s.required_ruby_version = '>= 2.6.0'
28
32
 
29
33
  s.add_dependency 'deep_merge', '~> 1.2', '>= 1.2.1'
30
- s.add_dependency 'dry-validation', '~> 1.0', '>= 1.0.0'
31
34
 
35
+ s.add_development_dependency 'dry-validation', *Config::DryValidationRequirements::VERSIONS
32
36
  s.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
33
37
 
34
38
  # Testing
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Config
4
+ module DryValidationRequirements
5
+ VERSIONS = ['~> 1.0', '>= 1.0.0'].freeze
6
+
7
+ def self.load_dry_validation!
8
+ return if defined?(@load_dry_validation)
9
+
10
+ begin
11
+ require 'dry/validation/version'
12
+ version = Gem::Version.new(Dry::Validation::VERSION)
13
+ unless VERSIONS.all? { |req| Gem::Requirement.new(req).satisfied_by?(version) }
14
+ raise LoadError
15
+ end
16
+ rescue LoadError
17
+ raise ::Config::Error, 'Could not find a dry-validation version' \
18
+ ' matching requirements' \
19
+ " (#{VERSIONS.map(&:inspect) * ','})"
20
+ end
21
+
22
+ require 'dry/validation'
23
+ @load_dry_validation = true
24
+ nil
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ module Config
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -14,8 +14,8 @@ module Config
14
14
  def vars
15
15
  # Load only local options to Heroku
16
16
  Config.load_and_set_settings(
17
- Rails.root.join("config", "settings.local.yml").to_s,
18
- Rails.root.join("config", "settings", "#{environment}.local.yml").to_s,
17
+ Rails.root.join("config", "#{Config.file_name}.local.yml").to_s,
18
+ Rails.root.join("config", Config.dir_name, "#{environment}.local.yml").to_s,
19
19
  Rails.root.join("config", "environments", "#{environment}.local.yml").to_s
20
20
  )
21
21
 
@@ -122,7 +122,7 @@ module Config
122
122
  def [](param)
123
123
  return super if SETTINGS_RESERVED_NAMES.include?(param)
124
124
  return super if RAILS_RESERVED_NAMES.include?(param)
125
- send("#{param}")
125
+ public_send("#{param}")
126
126
  end
127
127
 
128
128
  def []=(param, value)
@@ -1,6 +1,8 @@
1
+ require_relative "../error"
2
+
1
3
  module Config
2
4
  module Validation
3
- class Error < StandardError
5
+ class Error < ::Config::Error
4
6
 
5
7
  def self.format(v_res)
6
8
  v_res.errors.group_by(&:path).map do |path, messages|
@@ -1,3 +1,6 @@
1
+ require_relative '../dry_validation_requirements'
2
+ require_relative '../error'
3
+
1
4
  module Config
2
5
  module Validation
3
6
  module Schema
@@ -9,7 +12,7 @@ module Config
9
12
  def schema(&block)
10
13
  if block_given?
11
14
  # Delay require until optional schema validation is requested
12
- require 'dry-validation'
15
+ Config::DryValidationRequirements.load_dry_validation!
13
16
  @schema = Dry::Schema.define(&block)
14
17
  else
15
18
  @schema
@@ -4,6 +4,10 @@ module Config
4
4
  module Validation
5
5
  module Validate
6
6
  def validate!
7
+ return unless Config.validation_contract || Config.schema
8
+
9
+ Config::DryValidationRequirements.load_dry_validation!
10
+
7
11
  validate_using!(Config.validation_contract)
8
12
  validate_using!(Config.schema)
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module Config
2
- VERSION = '5.1.0'.freeze
2
+ VERSION = '5.3.0'.freeze
3
3
  end
data/lib/config.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'config/compatibility'
2
1
  require 'config/options'
3
2
  require 'config/configuration'
3
+ require 'config/dry_validation_requirements'
4
4
  require 'config/version'
5
5
  require 'config/sources/yaml_source'
6
6
  require 'config/sources/hash_source'
@@ -19,6 +19,8 @@ module Config
19
19
  env_converter: :downcase,
20
20
  env_parse_values: true,
21
21
  fail_on_missing: false,
22
+ file_name: 'settings',
23
+ dir_name: 'settings',
22
24
  # deep_merge options
23
25
  knockout_prefix: nil,
24
26
  merge_nil_values: true,
@@ -58,8 +60,8 @@ module Config
58
60
 
59
61
  def self.setting_files(config_root, env)
60
62
  [
61
- File.join(config_root, 'settings.yml').to_s,
62
- File.join(config_root, 'settings', "#{env}.yml").to_s,
63
+ File.join(config_root, "#{Config.file_name}.yml").to_s,
64
+ File.join(config_root, Config.dir_name, "#{env}.yml").to_s,
63
65
  File.join(config_root, 'environments', "#{env}.yml").to_s,
64
66
  *local_setting_files(config_root, env)
65
67
  ].freeze
@@ -67,8 +69,8 @@ module Config
67
69
 
68
70
  def self.local_setting_files(config_root, env)
69
71
  [
70
- (File.join(config_root, 'settings.local.yml').to_s if env != 'test'),
71
- File.join(config_root, 'settings', "#{env}.local.yml").to_s,
72
+ (File.join(config_root, "#{Config.file_name}.local.yml").to_s if env != 'test'),
73
+ File.join(config_root, Config.dir_name, "#{env}.local.yml").to_s,
72
74
  File.join(config_root, 'environments', "#{env}.local.yml").to_s
73
75
  ].compact
74
76
  end
@@ -12,18 +12,18 @@ module Config
12
12
  end
13
13
 
14
14
  def copy_settings
15
- template "settings.yml", "config/settings.yml"
16
- template "settings.local.yml", "config/settings.local.yml"
17
- directory "settings", "config/settings"
15
+ template "settings.yml", "config/#{Config.file_name}.yml"
16
+ template "settings.local.yml", "config/#{Config.file_name}.local.yml"
17
+ directory "settings", "config/#{Config.dir_name}"
18
18
  end
19
19
 
20
20
  def modify_gitignore
21
21
  create_file '.gitignore' unless File.exist? '.gitignore'
22
22
 
23
23
  append_to_file '.gitignore' do
24
- "\n" +
25
- "config/settings.local.yml\n" +
26
- "config/settings/*.local.yml\n" +
24
+ "\n" +
25
+ "config/#{Config.file_name}.local.yml\n" +
26
+ "config/#{Config.dir_name}/*.local.yml\n" +
27
27
  "config/environments/*.local.yml\n"
28
28
  end
29
29
  end
@@ -55,4 +55,9 @@ Config.setup do |config|
55
55
  # Evaluate ERB in YAML config files at load time.
56
56
  #
57
57
  # config.evaluate_erb_in_yaml = true
58
+
59
+ # Name of directory and file to store config keys
60
+ #
61
+ # config.file_name = 'settings'
62
+ # config.dir_name = 'settings'
58
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Kuczynski
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-12-18 00:00:00.000000000 Z
13
+ date: 2024-03-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: deep_merge
@@ -42,7 +42,7 @@ dependencies:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: 1.0.0
45
- type: :runtime
45
+ type: :development
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
48
48
  requirements:
@@ -236,8 +236,9 @@ files:
236
236
  - README.md
237
237
  - config.gemspec
238
238
  - lib/config.rb
239
- - lib/config/compatibility.rb
240
239
  - lib/config/configuration.rb
240
+ - lib/config/dry_validation_requirements.rb
241
+ - lib/config/error.rb
241
242
  - lib/config/integrations/heroku.rb
242
243
  - lib/config/integrations/rails/railtie.rb
243
244
  - lib/config/integrations/sinatra.rb
@@ -261,7 +262,10 @@ files:
261
262
  homepage: https://github.com/rubyconfig/config
262
263
  licenses:
263
264
  - MIT
264
- metadata: {}
265
+ metadata:
266
+ changelog_uri: https://github.com/rubyconfig/config/blob/master/CHANGELOG.md
267
+ source_code_uri: https://github.com/rubyconfig/config
268
+ bug_tracker_uri: https://github.com/rubyconfig/config/issues
265
269
  post_install_message: "\n\e[33mThanks for installing Config\e[0m\nPlease consider
266
270
  donating to our open collective to help us maintain this project.\n\n\nDonate: \e[34mhttps://opencollective.com/rubyconfig/donate\e[0m\n"
267
271
  rdoc_options:
@@ -279,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
283
  - !ruby/object:Gem::Version
280
284
  version: '0'
281
285
  requirements: []
282
- rubygems_version: 3.4.10
286
+ rubygems_version: 3.4.22
283
287
  signing_key:
284
288
  specification_version: 4
285
289
  summary: Effortless multi-environment settings in Rails, Sinatra, Padrino and others
@@ -1,3 +0,0 @@
1
- if defined?(RbConfig) && defined?(Config)
2
- Object.send :remove_const, :Config
3
- end