contracts 0.0.3 → 0.0.4
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.
- data/lib/contracts.rb +2 -2
- data/lib/foo.rb +9 -4
- data/lib/test.rb +6 -5
- metadata +4 -4
data/lib/contracts.rb
CHANGED
@@ -132,8 +132,8 @@ Contracts: #{@contracts.map { |t| t.is_a?(Class) ? t.name : t.class.name }.join(
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def self.validate_hash(arg, contract)
|
135
|
-
|
136
|
-
result, info =
|
135
|
+
contract.keys.each do |k|
|
136
|
+
result, info = valid?(arg[k], contract[k])
|
137
137
|
return [result, info] unless result
|
138
138
|
end
|
139
139
|
end
|
data/lib/foo.rb
CHANGED
data/lib/test.rb
CHANGED
@@ -30,10 +30,11 @@ class Object
|
|
30
30
|
acc + v
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
Contract ({ :age => Num, :name => String }), nil
|
35
|
+
def person(data)
|
36
|
+
p data
|
37
|
+
end
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
+
person({:name => "Adit", :age => 25, :bar => 45})
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aditya Bhargava
|
@@ -19,7 +19,7 @@ date: 2012-06-07 00:00:00 -07:00
|
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description:
|
22
|
+
description: This library provides contracts for Ruby. Contracts let you clearly express how your code behaves, and free you from writing tons of boilerplate, defensive code.
|
23
23
|
email: bluemangroupie@gmail.com
|
24
24
|
executables: []
|
25
25
|
|