hashr 2.0.0 → 2.0.1

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
2
  SHA1:
3
- metadata.gz: 42431178382b878e92e706bfb03056aa44af07c0
4
- data.tar.gz: f783fc1ad3486ea303af6260865994ab354d3575
3
+ metadata.gz: 1d8704f86e52725690deaf8d11039316590fc32a
4
+ data.tar.gz: c0702f80dad1588deb39e4edc26738975d6d6bde
5
5
  SHA512:
6
- metadata.gz: eb8ed7db9182d12f32f19d216cf86c58b93013334a3d6510483b6427eaaf9c8648ef8300cab6060ba92c1170af4e9adda78568ae945c066d97f52d7355edc54d
7
- data.tar.gz: dc6f9cb0956eb536a71639ededadfa79502544fc86cab7593393ff5c09b1d0e59a0cc558deb362319e6dabb123ddfcd00acd98894b3f3f73833447a7087a9ed7
6
+ metadata.gz: d69e6ca9d3f9029f4c9f94cc26712a857de862daec959096bb0d872ee6cc80a52dba75a701db7f2e24fda905741ae3d8843b5ff15d25067cf60b97025491c9aa
7
+ data.tar.gz: b11b4afa18dcca79d517b2f4e67414b23e4177efaee84472966caa5dd10c7bc9ad1ffac6fa3ce5df93649ed4668fbf030507f10c3fa0dc85c47d0932dfcc9a2b
@@ -29,6 +29,8 @@ class Hashr
29
29
  value.respond_to?(:split) ? value.split(',') : Array(value)
30
30
  when true, false
31
31
  not FALSE.include?(value)
32
+ when Integer then Integer(value)
33
+ when Float then Float(value)
32
34
  else
33
35
  value
34
36
  end
@@ -1,3 +1,3 @@
1
1
  class Hashr < BasicObject
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -8,7 +8,9 @@ describe Hashr::Env do
8
8
  define string: 'string',
9
9
  hash: { key: 'value' },
10
10
  array: ['foo', 'bar'],
11
- bool: false
11
+ bool: false,
12
+ int: 4,
13
+ float: 11.1
12
14
  end
13
15
  end
14
16
 
@@ -55,6 +57,45 @@ describe Hashr::Env do
55
57
  expect(klass.new.array).to eq([])
56
58
  end
57
59
  end
60
+
61
+ describe 'to an int' do
62
+ it 'int given' do
63
+ ENV['HASHR_INT'] = '1'
64
+ expect(klass.new.int).to eq(1)
65
+ end
66
+
67
+ it 'errors for an empty string' do
68
+ ENV['HASHR_INT'] = ''
69
+ expect { klass.new.int }.to raise_error(ArgumentError)
70
+ end
71
+
72
+ it 'errors for a non-int' do
73
+ ENV['HASHR_INT'] = 'a'
74
+ expect { klass.new.int }.to raise_error(ArgumentError)
75
+ end
76
+ end
77
+
78
+ describe 'to a float' do
79
+ it 'float given' do
80
+ ENV['HASHR_FLOAT'] = '2.3'
81
+ expect(klass.new.float).to eq(2.3)
82
+ end
83
+
84
+ it 'int given' do
85
+ ENV['HASHR_FLOAT'] = '4'
86
+ expect(klass.new.float).to eq(4.0)
87
+ end
88
+
89
+ it 'errors for an empty string' do
90
+ ENV['HASHR_FLOAT'] = ''
91
+ expect { klass.new.float }.to raise_error(ArgumentError)
92
+ end
93
+
94
+ it 'errors for a non-float' do
95
+ ENV['HASHR_FLOAT'] = 'a'
96
+ expect { klass.new.float }.to raise_error(ArgumentError)
97
+ end
98
+ end
58
99
  end
59
100
 
60
101
  it 'data takes precedence over an env var' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-31 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simple Hash extension to make working with nested hashes (e.g. for configuration)
14
14
  easier and less error-prone.
@@ -50,10 +50,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  version: '0'
51
51
  requirements: []
52
52
  rubyforge_project: "[none]"
53
- rubygems_version: 2.4.5
53
+ rubygems_version: 2.6.8
54
54
  signing_key:
55
55
  specification_version: 4
56
56
  summary: Simple Hash extension to make working with nested hashes (e.g. for configuration)
57
57
  easier and less error-prone
58
58
  test_files: []
59
- has_rdoc: