configature 0.3.4 → 0.4.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: a224ef00f9af60ae0ba0763ccd95aa3fa1f96a0a2d1bc9065fd9901c9654334e
4
- data.tar.gz: fe233997b912aa51af9345f21aecb7401e957d8f3a9e3a1791ed143c7c8ca6f7
3
+ metadata.gz: ee6c275a728530ed00a099806fa3f85533c31529ff92cd9db94368c57c8708c2
4
+ data.tar.gz: cb23bbc46676159334bfc820f5faad62a9d824c31f126393dd1f7ec2854433ed
5
5
  SHA512:
6
- metadata.gz: 9ea6242794f99d7cafe567d80a1ed8b1baa5ec25329e7bdacd9e246f7e0775d8347acaad5d570e904a6707fef9ffef2d593468c1e4c9ffc3c69cb1c452211bd6
7
- data.tar.gz: 5b0af76af2347583a90091cc0717d2ecfe40a8c581032f438c7729a2ddbedadc0da867d5b3c87217df8b1185d4b82e717ae095c495b2cc5f56ea2f5c501787b7
6
+ metadata.gz: 758526740b609c06fd97ac288204c6c9b05b45bf5ad55c36f3cdc0d4fbede29eff9ff8a279ef33d9c2bca2c5166aa80a7c3172716df1082ff1e487da340fdae2
7
+ data.tar.gz: 6d5189acd62a10217b2faeb3b33a3ee463f8740057e2eecd58a01eab6a7a057538308f96e152608c823800e5d11988b6ace0539b7b2525ff36ecd40f2a3c9ae3
data/.travis.yml CHANGED
@@ -3,10 +3,8 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.3.8
7
- - 2.4.9
8
- - 2.5.7
9
- - 2.6.5
10
- - 2.7.0
11
- - jruby-9.2.9.0
12
- before_install: gem install bundler -v 2.1.4
6
+ - 2.6.7
7
+ - 2.7.3
8
+ - 3.0.1
9
+ before_install:
10
+ - gem install bundler
data/Gemfile CHANGED
@@ -3,8 +3,11 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in configature.gemspec
4
4
  gemspec
5
5
 
6
+ ruby '>= 2.6.0'
7
+
6
8
  group :development do
7
9
  gem 'rake'
8
10
  gem 'bundler'
9
11
  gem 'rspec'
12
+ gem 'rspec-core'
10
13
  end
data/Gemfile.lock CHANGED
@@ -1,28 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- configature (0.3.3)
4
+ configature (0.3.8)
5
+ ostruct
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
- diff-lcs (1.4.4)
10
- rake (13.0.1)
11
- rspec (3.9.0)
12
- rspec-core (~> 3.9.0)
13
- rspec-expectations (~> 3.9.0)
14
- rspec-mocks (~> 3.9.0)
15
- rspec-core (3.9.2)
16
- rspec-support (~> 3.9.3)
17
- rspec-expectations (3.9.2)
10
+ diff-lcs (1.6.2)
11
+ ostruct (0.6.1)
12
+ rake (13.3.0)
13
+ rspec (3.13.1)
14
+ rspec-core (~> 3.13.0)
15
+ rspec-expectations (~> 3.13.0)
16
+ rspec-mocks (~> 3.13.0)
17
+ rspec-core (3.13.5)
18
+ rspec-support (~> 3.13.0)
19
+ rspec-expectations (3.13.5)
18
20
  diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.9.0)
20
- rspec-mocks (3.9.1)
21
+ rspec-support (~> 3.13.0)
22
+ rspec-mocks (3.13.5)
21
23
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.9.0)
23
- rspec-support (3.9.3)
24
+ rspec-support (~> 3.13.0)
25
+ rspec-support (3.13.5)
24
26
 
25
27
  PLATFORMS
28
+ arm64-darwin-24
26
29
  ruby
27
30
 
28
31
  DEPENDENCIES
@@ -30,6 +33,10 @@ DEPENDENCIES
30
33
  configature!
31
34
  rake
32
35
  rspec
36
+ rspec-core
37
+
38
+ RUBY VERSION
39
+ ruby 3.3.4p94
33
40
 
34
41
  BUNDLED WITH
35
- 2.1.4
42
+ 2.5.23
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.4.0
data/configature.gemspec CHANGED
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
32
32
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
33
  end
34
34
 
35
+ spec.add_dependency 'ostruct'
36
+
35
37
  spec.bindir = 'exe'
36
38
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
39
  spec.require_paths = %w[ lib ]
@@ -7,9 +7,9 @@ require_relative './namespace'
7
7
 
8
8
  class Configature::Config < Configature::Data
9
9
  # == Constants ============================================================
10
-
10
+
11
11
  # == Properties ===========================================================
12
-
12
+
13
13
  # == Class Methods ========================================================
14
14
 
15
15
  def self.config_dir
@@ -21,7 +21,9 @@ class Configature::Config < Configature::Data
21
21
  end
22
22
 
23
23
  def self.namespace(name, file: nil, env_suffix: '', extends: nil, &block)
24
- namespace = self.namespaces[name] = Configature::Namespace.new(name, env_suffix: env_suffix, extends: extends && self.namespaces[extends]).tap do |n|
24
+ extends &&= self.namespaces[extends]
25
+
26
+ namespace = self.namespaces[name] = Configature::Namespace.new(name, env_suffix: env_suffix, extends: extends).tap do |n|
25
27
  case (block&.arity)
26
28
  when nil
27
29
  nil
@@ -32,7 +34,7 @@ class Configature::Config < Configature::Data
32
34
  end
33
35
  end
34
36
 
35
- file = file&.to_s || name.to_s
37
+ file = (file || extends&.config_name || name).to_s
36
38
 
37
39
  if (file and !file.include?('.'))
38
40
  file += '.yml'
@@ -42,11 +44,9 @@ class Configature::Config < Configature::Data
42
44
  iv = :"@#{name}"
43
45
 
44
46
  singleton_class.send(:define_method, name) do
45
- config_path = File.expand_path(file, self.config_dir)
46
-
47
- config = Configature::Support.yaml_if_exist(config_path)
48
-
49
- instance_variable_get(iv) or instance_variable_set(iv, namespace.__instantiate(source: config))
47
+ instance_variable_get(iv) or instance_variable_set(iv, namespace.__instantiate(
48
+ source: Configature::Support.yaml_if_exist(File.expand_path(file, self.config_dir))
49
+ ))
50
50
  end
51
51
  end
52
52
  end
@@ -54,15 +54,17 @@ class Configature::Config < Configature::Data
54
54
  def self.namespaces
55
55
  @namespaces ||= { }
56
56
  end
57
-
57
+
58
58
  # == Instance Methods =====================================================
59
59
 
60
- def initialize(config_dir: nil, env: ENV)
60
+ def initialize(config_dir: nil, path: nil, env: ENV, data: nil)
61
61
  super(
62
62
  self.class.namespaces.map do |name, namespace|
63
- config_path = File.expand_path('%s.yml' % name, config_dir || self.class.config_dir)
63
+ config = data || begin
64
+ path ||= File.expand_path('%s.yml' % namespace.config_name, config_dir || self.class.config_dir)
64
65
 
65
- config = Configature::Support.yaml_if_exist(config_path)
66
+ Configature::Support.yaml_if_exist(path)
67
+ end
66
68
 
67
69
  [
68
70
  name,
@@ -19,8 +19,8 @@ class Configature::Data < OpenStruct
19
19
  # == Instance Methods =====================================================
20
20
 
21
21
  def to_h
22
- super.transform_values do |v|
23
- self.class.hashify(v)
24
- end
22
+ super.map do |k, v|
23
+ [ k, self.class.hashify(v) ]
24
+ end.to_h
25
25
  end
26
26
  end
@@ -40,6 +40,7 @@ class Configature::Namespace
40
40
  # == Properties ===========================================================
41
41
 
42
42
  attr_reader :name
43
+ attr_reader :config_name
43
44
  attr_reader :env_name_prefix
44
45
  attr_reader :namespaces
45
46
  attr_reader :parameters
@@ -53,18 +54,25 @@ class Configature::Namespace
53
54
  @extends = extends
54
55
  @env = extends&.instance_variable_get(:@env)
55
56
  @env_default = extends&.instance_variable_get(:@env_default)
56
- @namespaces = extends ? extends.namespaces.dup : { }
57
- @parameters = extends ? extends.parameters.dup : { }
57
+ @namespaces = extends&.namespaces&.dup || { }
58
+ @parameters = extends&.parameters&.dup || { }
58
59
  @env_suffix = env_suffix
59
60
  @env_name_prefix = name ? Configature::Support.extend_env_prefix(env_name_prefix, name) : ''
60
61
 
62
+ @config_name = extends&.config_name || name
63
+
61
64
  yield(self) if (block_given?)
62
65
  end
63
66
 
64
67
  def namespace(name, env_suffix: '', extends: nil, &block)
65
68
  name = name.to_sym
66
69
 
67
- @namespaces[name] = self.class.new(name, env_suffix: env_suffix, extends: extends && self.namespaces[extends], env_name_prefix: @env_name_prefix).tap do |n|
70
+ @namespaces[name] = self.class.new(
71
+ name,
72
+ env_suffix: env_suffix,
73
+ extends: extends && self.namespaces[extends],
74
+ env_name_prefix: @env_name_prefix
75
+ ).tap do |n|
68
76
  case (block&.arity)
69
77
  when nil
70
78
  nil
@@ -4,9 +4,13 @@ class Configature::Stamper
4
4
  end
5
5
 
6
6
  def examples
7
- map = Dir.glob(File.expand_path('*.example', @dir)).map do |source|
7
+ map = (
8
+ Dir.glob(File.expand_path('*.example', @dir)).map do |source|
8
9
  [ source, source.delete_suffix('.example') ]
9
- end.to_h
10
+ end + Dir.glob(File.expand_path('*.example.*', @dir)).map do |source|
11
+ [ source, source.sub(/\.example\./, '.') ]
12
+ end
13
+ ).to_h
10
14
 
11
15
  if (block_given?)
12
16
  map.each do |k,v|
@@ -39,7 +43,7 @@ class Configature::Stamper
39
43
  ) if (block_given?)
40
44
  else
41
45
  FileUtils.copy(source, target)
42
-
46
+
43
47
  yield(
44
48
  source,
45
49
  target,
@@ -5,10 +5,9 @@ module Configature::Support
5
5
 
6
6
  def yaml_if_exist(path)
7
7
  return unless (File.exist?(path))
8
-
9
- # FIX: Use safe_load if safe_load supports aliases
8
+
10
9
  File.open(path) do |f|
11
- YAML.load(f)
10
+ YAML.safe_load(f, aliases: true) or { }
12
11
  end
13
12
  end
14
13
 
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Tadman
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
12
- dependencies: []
10
+ date: 2025-08-20 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: ostruct
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
13
26
  description: Assists in the creation of config files from example templates and can
14
27
  identify when some customization is necessary.
15
28
  email:
@@ -48,7 +61,6 @@ metadata:
48
61
  homepage_uri: https://postageapp.com/
49
62
  source_code_uri: https://github.com/postageapp/configuature
50
63
  changelog_uri: https://github.com/postageapp/configuature
51
- post_install_message:
52
64
  rdoc_options: []
53
65
  require_paths:
54
66
  - lib
@@ -63,8 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
75
  - !ruby/object:Gem::Version
64
76
  version: '0'
65
77
  requirements: []
66
- rubygems_version: 3.1.4
67
- signing_key:
78
+ rubygems_version: 3.6.2
68
79
  specification_version: 4
69
80
  summary: Configuration file auto-generator
70
81
  test_files: []