hexx 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hexx/dependencies.rb +18 -2
- data/lib/hexx/version.rb +1 -1
- data/spec/hexx/dependencies_spec.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f682ab2559e5df4745c3b31da39343558726c2
|
4
|
+
data.tar.gz: 761e5de6edc7ac19029e67cbb0f7693baf4adea4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f6765140b1e83e75943def81b095b1f48fea48887d7ef6297e34f156051f2d3bf88d783fcef7f578eddd2092fa8f80d426e29b1060d727ab0cae5e6900f0293
|
7
|
+
data.tar.gz: 7e7039f4ba789a130a838ed32904420115e567d6d6d29cda539a971906c25c8c1efcba2343904b5513ae0fda73a7a4d6ef80382ae6fae3a43d72b9f9274e156c
|
data/lib/hexx/dependencies.rb
CHANGED
@@ -74,9 +74,21 @@ module Hexx
|
|
74
74
|
# # => "String"
|
75
75
|
# MyGem.some_class # => String
|
76
76
|
#
|
77
|
-
# @
|
77
|
+
# @example Dependencies can be set as a plain list of names
|
78
|
+
# module MyGem
|
79
|
+
# extend Hexx::Dependencies
|
80
|
+
# self.depends_on :some_class, "another_class"
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# @example Dependencies can be set as an array of names
|
84
|
+
# module MyGem
|
85
|
+
# extend Hexx::Dependencies
|
86
|
+
# self.depends_on %w(some_class another_class)
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# @param [Array<String, Symbol>] names The list of names for dependencies.
|
78
90
|
def depends_on(*names)
|
79
|
-
names.each do |name|
|
91
|
+
names.flatten.each do |name|
|
80
92
|
DependencyName.new(name).validate
|
81
93
|
add_dependency_setter name
|
82
94
|
add_dependency_getter name
|
@@ -91,6 +103,8 @@ module Hexx
|
|
91
103
|
|
92
104
|
# @api hide
|
93
105
|
# Runs validations and fails in case of any error.
|
106
|
+
# @raise [TypeError] if the name has a wrong type.
|
107
|
+
# @raise [ArgumentError] if the name is blank.
|
94
108
|
def validate
|
95
109
|
check_type
|
96
110
|
check_value
|
@@ -115,6 +129,8 @@ module Hexx
|
|
115
129
|
|
116
130
|
# @api hide
|
117
131
|
# Runs validations and fails in case of any error.
|
132
|
+
# @raise [TypeError] if the value has a wrong type.
|
133
|
+
# @raise [ArgumentError] if the value name is blank.
|
118
134
|
def validate
|
119
135
|
check_type
|
120
136
|
check_value
|
data/lib/hexx/version.rb
CHANGED
@@ -27,14 +27,19 @@ module Hexx
|
|
27
27
|
expect(described_module).to respond_to :depends_on
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
30
|
+
it "accepts symbolic attributes" do
|
31
31
|
expect { described_module.depends_on :item }.not_to raise_error
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "accepts string attributes" do
|
35
35
|
expect { described_module.depends_on "item" }.not_to raise_error
|
36
36
|
end
|
37
37
|
|
38
|
+
it "accepts arrays" do
|
39
|
+
expect { described_module.depends_on "item", [:item] }
|
40
|
+
.not_to raise_error
|
41
|
+
end
|
42
|
+
|
38
43
|
it "fails when wrong object given" do
|
39
44
|
expect { described_module.depends_on 1 }.to raise_error TypeError
|
40
45
|
end
|