gem_config 0.2.3 → 0.2.4

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: 57e379d40fd9841d4cdfb62de3e01d7210f79a1d
4
- data.tar.gz: 98f0ce64593e693a50b82003c2853529a5165e49
3
+ metadata.gz: e38c07a983ddbdf73d79f7b1f7c613849d552c60
4
+ data.tar.gz: 394380642649dbd31e48c5c91350dd0a74aab495
5
5
  SHA512:
6
- metadata.gz: d94aaaca5660e5742b211cdd22015aa0661ee5d2d4dcd932014dda330271d7280f842d36c7437850ebd16611be8ba83fdec8a9c57d11fb09ba4fead4ad544767
7
- data.tar.gz: 3fa452a4ed955290cb266d614abc838d937bd458f97add5bf91104be49f7659c6c01b306ff1449d3230e2cd93ae85fff96aef28b49d7be6f9dc763ae3904c78f
6
+ metadata.gz: b1fef53ce71a8d421011cfef1c1cd075795488b17fe32e1076dbf5d756f3512ef5e68e3ce66fce120ae07a8c1a6cbc0a1c87a0f986bac773c51d2e37748e5ced
7
+ data.tar.gz: 206c1aecd2f2aa37393b05fb69b7ff210c4bef027810cc2f6dbb844e5f07b58061f0f20b981ab56ff8b0786ae031db2b433570438adf9227ac8adee4103df4b7
@@ -21,6 +21,4 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.add_development_dependency 'rake', '>= 0.9.0'
23
23
  gem.add_development_dependency 'rspec', '~> 2.13.0'
24
-
25
- gem.add_runtime_dependency 'activesupport', '>= 3.0.0'
26
24
  end
@@ -1,5 +1,3 @@
1
- require 'active_support/core_ext/hash/keys'
2
-
3
1
  module GemConfig
4
2
  class Rules < Hash
5
3
  InvalidKeyError = Class.new(StandardError)
@@ -24,7 +22,10 @@ module GemConfig
24
22
  private
25
23
 
26
24
  def check_attributes(attrs)
27
- attrs.assert_valid_keys :classes, :values, :default
25
+ allowed_keys = [:classes, :values, :default]
26
+ attrs.keys.each do |k|
27
+ raise ArgumentError, %("#{k}" is not a valid attribute. Valid attributes are: #{allowed_keys.join(', ')}) unless allowed_keys.include?(k)
28
+ end
28
29
 
29
30
  if attrs.has_key?(:classes)
30
31
  other_than_class = Array(attrs[:classes]).any? do |value|
@@ -1,3 +1,3 @@
1
1
  module GemConfig
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -33,78 +33,86 @@ describe GemConfig::Rules do
33
33
  end.to raise_error(ArgumentError)
34
34
  end
35
35
 
36
- describe 'parameter :classes' do
37
- it 'only allows a class or an array of classes as the value' do
36
+ describe 'parameters' do
37
+ it 'raises an exception when a not allowed parameter is passed' do
38
38
  expect do
39
- subject.has :foo, classes: String
40
- end.to_not raise_error(ArgumentError)
41
-
42
- expect do
43
- subject.has :foo, classes: [String, Numeric]
44
- end.to_not raise_error(ArgumentError)
45
-
46
- expect do
47
- subject.has :foo, classes: 'foo'
39
+ subject.has :foo, bar: 'baz'
48
40
  end.to raise_error(ArgumentError)
49
41
  end
50
- end
51
-
52
- describe 'parameter :values' do
53
- context 'when :classes are defined' do
54
- it 'only allows values of one of the specified classes' do
55
- expect do
56
- subject.has :foo, classes: String, values: 'foo'
57
- end.to_not raise_error(ArgumentError)
58
42
 
43
+ describe 'parameter :classes' do
44
+ it 'only allows a class or an array of classes as the value' do
59
45
  expect do
60
- subject.has :foo, classes: Numeric, values: 1
46
+ subject.has :foo, classes: String
61
47
  end.to_not raise_error(ArgumentError)
62
48
 
63
49
  expect do
64
- subject.has :foo, classes: [String, Numeric], values: ['foo', 1]
50
+ subject.has :foo, classes: [String, Numeric]
65
51
  end.to_not raise_error(ArgumentError)
66
52
 
67
53
  expect do
68
- subject.has :foo, classes: String, values: ['foo', 1]
54
+ subject.has :foo, classes: 'foo'
69
55
  end.to raise_error(ArgumentError)
70
56
  end
71
57
  end
72
- end
73
-
74
- describe 'parameter :default' do
75
- context 'when :classes are defined' do
76
- it 'only allows a value of one of the specified classes' do
77
- expect do
78
- subject.has :foo, classes: String, default: 'foo'
79
- end.to_not raise_error(ArgumentError)
80
-
81
- expect do
82
- subject.has :foo, classes: Numeric, default: 1
83
- end.to_not raise_error(ArgumentError)
84
-
85
- expect do
86
- subject.has :foo, classes: [String, Numeric], default: 'foo'
87
- end.to_not raise_error(ArgumentError)
88
58
 
89
- expect do
90
- subject.has :foo, classes: Numeric, default: 'foo'
91
- end.to raise_error(ArgumentError)
59
+ describe 'parameter :values' do
60
+ context 'when :classes are defined' do
61
+ it 'only allows values of one of the specified classes' do
62
+ expect do
63
+ subject.has :foo, classes: String, values: 'foo'
64
+ end.to_not raise_error(ArgumentError)
65
+
66
+ expect do
67
+ subject.has :foo, classes: Numeric, values: 1
68
+ end.to_not raise_error(ArgumentError)
69
+
70
+ expect do
71
+ subject.has :foo, classes: [String, Numeric], values: ['foo', 1]
72
+ end.to_not raise_error(ArgumentError)
73
+
74
+ expect do
75
+ subject.has :foo, classes: String, values: ['foo', 1]
76
+ end.to raise_error(ArgumentError)
77
+ end
92
78
  end
93
79
  end
94
80
 
95
- context 'when :values are defined' do
96
- it 'only allows one of the specified values' do
97
- expect do
98
- subject.has :foo, values: 'foo', default: 'foo'
99
- end.to_not raise_error(ArgumentError)
81
+ describe 'parameter :default' do
82
+ context 'when :classes are defined' do
83
+ it 'only allows a value of one of the specified classes' do
84
+ expect do
85
+ subject.has :foo, classes: String, default: 'foo'
86
+ end.to_not raise_error(ArgumentError)
87
+
88
+ expect do
89
+ subject.has :foo, classes: Numeric, default: 1
90
+ end.to_not raise_error(ArgumentError)
91
+
92
+ expect do
93
+ subject.has :foo, classes: [String, Numeric], default: 'foo'
94
+ end.to_not raise_error(ArgumentError)
95
+
96
+ expect do
97
+ subject.has :foo, classes: Numeric, default: 'foo'
98
+ end.to raise_error(ArgumentError)
99
+ end
100
+ end
100
101
 
101
- expect do
102
- subject.has :foo, values: ['foo', 1], default: 1
103
- end.to_not raise_error(ArgumentError)
102
+ context 'when :values are defined' do
103
+ it 'only allows one of the specified values' do
104
+ expect do
105
+ subject.has :foo, values: 'foo', default: 'foo'
106
+ end.to_not raise_error(ArgumentError)
104
107
 
105
- expect do
106
- subject.has :foo, values: ['foo', 1], default: 'bar'
107
- end.to raise_error(ArgumentError)
108
+ expect do
109
+ subject.has :foo, values: ['foo', 1], default: 1
110
+ end.to_not raise_error(ArgumentError)
111
+
112
+ expect do
113
+ subject.has :foo, values: ['foo', 1], default: 'bar'
114
+ end.to raise_error(ArgumentError)
115
+ end
108
116
  end
109
117
  end
110
118
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2013-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.13.0
41
- - !ruby/object:Gem::Dependency
42
- name: activesupport
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: 3.0.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: 3.0.0
55
41
  description: A nifty way to make your gem configurable.
56
42
  email: manuel.meurer@gmail.com
57
43
  executables: []