ultra_config 0.3.0 → 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
  SHA1:
3
- metadata.gz: 676f5e1dfc918319086131538dedc889aa4f866e
4
- data.tar.gz: 5d40a683ea9225df5dac8dd86091d26ef97e5afe
3
+ metadata.gz: 7fe814320bd63df05e458ca40594c0924825cd32
4
+ data.tar.gz: 6df1c641ed3ec366186d49ffeaedf36642f360b7
5
5
  SHA512:
6
- metadata.gz: ed611e8048ae483c96ec5a559b38f0daea2555e3350d168a753c212bddf906ffc52843e09403e7c72222df98f9ff44b5c8a3532e5f4214d9591edd90f06e496d
7
- data.tar.gz: 2d84201a46e57b356a107ee0d285be973414b65b2e4886c01d4f73fd02daaee7c1190535964449bd59749b5b804413e5de8df1c2e98de229c5ce8180e3bffc09
6
+ metadata.gz: 3ff2629253dbdc620322059e94fe436ddff426a01d07882ad8f148f0637557c38dbd0b3275796b9b37f0be786b6b4a342968004f799422fe413d7b69085b4d39
7
+ data.tar.gz: bb46e4c2058e26aa23288937b712b3999b8a33528baacf690c3015c37fbaa2af137ed4573008755ee795e87d43100fb5eba1ab841bb6f883bb447d616a2bd65b
data/README.md CHANGED
@@ -56,7 +56,7 @@ end
56
56
 
57
57
  # It can then be used like:
58
58
 
59
- ConfigTest.space1.space2.default
59
+ ConfigTest.space2.space3.default
60
60
 
61
61
  ```
62
62
 
@@ -68,7 +68,7 @@ After checking out the repo, run `bundle install` to install dependencies. Then,
68
68
 
69
69
  ## Contributing
70
70
 
71
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ultra_config.
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SpyMachine/ultra_config.
72
72
 
73
73
  ## License
74
74
 
@@ -8,19 +8,26 @@ module UltraConfig
8
8
  class TypeValidationError < ValidationError; end
9
9
 
10
10
  def self.validate(old, new, &validation)
11
+ @old_value = old
11
12
  @test_value = new
12
- type_safety(old) if Settings.type_safety == :strong
13
13
 
14
14
  self.instance_eval(&validation) if validation
15
+
16
+ type_safety(Settings.type_safety) unless @explicit_type_safety
15
17
  ensure
16
18
  @test_value = nil
19
+ @old_value = nil
20
+ @explicit_type_safety = false
17
21
  end
18
22
 
19
- def self.type_safety(old)
20
- return if old.nil?
21
- return if old.is_a?(Boolean) && @test_value.is_a?(Boolean)
23
+ def self.type_safety(type)
24
+ @explicit_type_safety = true
25
+ return unless type == :strong
26
+
27
+ return if @old_value.nil?
28
+ return if @old_value.is_a?(Boolean) && @test_value.is_a?(Boolean)
22
29
 
23
- raise TypeValidationError if old.class != @test_value.class
30
+ raise TypeValidationError if @old_value.class != @test_value.class
24
31
  end
25
32
 
26
33
  def self.one_of(list)
@@ -34,5 +41,9 @@ module UltraConfig
34
41
  def self.range(low, high)
35
42
  raise ValidationError unless (@test_value >= low && @test_value <= high)
36
43
  end
44
+
45
+ def self.custom(&block)
46
+ raise ValidationError unless block.call(@test_value)
47
+ end
37
48
  end
38
49
  end
data/ultra_config.gemspec CHANGED
@@ -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.3.0'
7
+ spec.version = '0.4.0'
8
8
  spec.authors = ['Gregory Kuruc']
9
9
  spec.email = ['gjk910327@gmail.com']
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultra_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
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-05-27 00:00:00.000000000 Z
11
+ date: 2018-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler