ultra_config 0.13.0 → 0.15.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e94fa14e6cc352acbdb58f0374be625261e5dedb
4
- data.tar.gz: 904585f13c8d3adabb5829bc9cfb96549d7437b7
2
+ SHA256:
3
+ metadata.gz: 881b7aa5c9f360176d51601e6c1ef032c2faacc139cb91bbcb707bfb2bd58bf1
4
+ data.tar.gz: 3f064ef444acf34a16e42df3dbb21236b530d943a8c9dc7c561ae5b5017d5b64
5
5
  SHA512:
6
- metadata.gz: b452a720488ea9a584f8ec2d9ab1a30f816922ebbd69e9839e8c4d73956eccdf5f245bbfa028237b2835cb4dcb155f9bdcd5bde1a75ac7372994fa121763cbd7
7
- data.tar.gz: 7d8f5fbda7d94f90899377d5b577ae24a86d368a2afd9ac80de7c18af7826876a0567a1be5e4659ff334a46d031a4d957b306a9a58d13ed59e1934d1d6dbf44a
6
+ metadata.gz: 40974f0690a05326b18012a72b7f55554d26c0f31eb9e0949441be55fc5faecccdb3b2eafe615736736a4dccf0550910ef8372f077ffb60731e5b7bcd809448b
7
+ data.tar.gz: 4fcb35a193e2b61bece67e593c6f28bf97cbce35eff0adc28aefc50d77b1265586a3aab916fe7116cf71a2aac25f9addf4fc6a40d0143f6bd034bc64be39cac1
@@ -0,0 +1,30 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+ name: Build + Publish
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 2.6
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.6.x
20
+
21
+ - name: Publish to RubyGems
22
+ run: |
23
+ mkdir -p $HOME/.gem
24
+ touch $HOME/.gem/credentials
25
+ chmod 0600 $HOME/.gem/credentials
26
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
27
+ gem build *.gemspec
28
+ gem push *.gem
29
+ env:
30
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -19,6 +19,10 @@ module UltraConfig
19
19
 
20
20
  def value=(value)
21
21
  @intermediate_value = value
22
+
23
+ # Be nice and convert Strings to Symbols
24
+ @intermediate_value = @intermediate_value.to_sym if @intermediate_value.is_a?(String) && @value.is_a?(Symbol)
25
+
22
26
  self.instance_eval(&@config_block) if @config_block
23
27
  type_safety(Settings.type_safety) unless @type_safety_checked
24
28
  @value = @intermediate_value
@@ -1,9 +1,12 @@
1
+ require 'logger'
2
+
1
3
  require_relative 'config'
2
4
 
3
5
  module UltraConfig
4
6
  class Namespace
5
7
  class ObjectNotFoundError < StandardError; end
6
8
 
9
+ attr_accessor :logger
7
10
  attr_reader :objects
8
11
 
9
12
  def initialize(parents = [], &block)
@@ -55,6 +58,21 @@ module UltraConfig
55
58
  hash
56
59
  end
57
60
 
61
+ def merge_hash!(hash, parents = [])
62
+ hash.each do |k, v|
63
+ options = send_chain(parents)
64
+ if options.objects[k.to_sym].is_a?(Config)
65
+ options.send("#{k}=", v) unless v.nil?
66
+ elsif options.objects[k.to_sym].is_a?(Namespace)
67
+ merge_hash!(v, parents + [k])
68
+ else
69
+ logger.warn { "received an unknown config #{k} with value #{v} and parents: #{parents}" }
70
+ end
71
+ end
72
+
73
+ self
74
+ end
75
+
58
76
  def to_sanitized_h
59
77
  hash = {}
60
78
  @objects.each do |name, object|
@@ -75,5 +93,18 @@ module UltraConfig
75
93
  def method_missing(m)
76
94
  raise ObjectNotFoundError
77
95
  end
96
+
97
+ private
98
+
99
+ # Send a chain of methods to an object
100
+ # @param arr [Array] list of methods to send to object
101
+ # @return [Object] result of method chain
102
+ def send_chain(arr)
103
+ arr.inject(self) {|obj, arr| obj.send(arr) }
104
+ end
105
+
106
+ def logger
107
+ @logger ||= (logger || Logger.new(IO::NULL))
108
+ end
78
109
  end
79
110
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'ultra_config'
7
- spec.version = '0.13.0'
7
+ spec.version = '0.15.3'
8
8
  spec.authors = ['Gregory Kuruc']
9
9
  spec.email = ['gjk910327@gmail.com']
10
10
 
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.15"
23
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bump", "~> 0.1"
23
+ spec.add_development_dependency "bundler", "~> 2.0"
24
+ spec.add_development_dependency "rake", ">= 12.3.3"
24
25
  spec.add_development_dependency "rspec", "~> 3.0"
25
26
  end
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultra_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Kuruc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2020-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: bump
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '0.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.15'
26
+ version: '0.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 12.3.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 12.3.3
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +73,8 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
76
+ - ".github/workflows/gem-push.yml"
77
+ - ".github/workflows/ruby.yml"
62
78
  - ".gitignore"
63
79
  - Gemfile
64
80
  - LICENSE.txt
@@ -90,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
106
  - !ruby/object:Gem::Version
91
107
  version: '0'
92
108
  requirements: []
93
- rubyforge_project:
94
- rubygems_version: 2.6.14
109
+ rubygems_version: 3.0.3
95
110
  signing_key:
96
111
  specification_version: 4
97
112
  summary: Provides a simple way to define a configuration with validation