contracts 0.2.1 → 0.2.2
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 +12 -2
- metadata +20 -38
data/lib/contracts.rb
CHANGED
@@ -15,13 +15,23 @@ module Contracts
|
|
15
15
|
|
16
16
|
def self.common base
|
17
17
|
base.extend MethodDecorators
|
18
|
+
base.instance_eval do
|
19
|
+
def functype(funcname)
|
20
|
+
contracts = self.decorated_methods[:class_methods][funcname]
|
21
|
+
if contracts.nil?
|
22
|
+
"No contract for #{self}.#{funcname}"
|
23
|
+
else
|
24
|
+
"#{funcname} :: #{contracts}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
18
28
|
base.class_eval do
|
19
29
|
def Contract(*args)
|
20
30
|
self.class.Contract(*args)
|
21
31
|
end
|
22
32
|
|
23
33
|
def functype(funcname)
|
24
|
-
contracts = self.class.decorated_methods[funcname]
|
34
|
+
contracts = self.class.decorated_methods[:instance_methods][funcname]
|
25
35
|
if contracts.nil?
|
26
36
|
"No contract for #{self.class}.#{funcname}"
|
27
37
|
else
|
@@ -73,7 +83,7 @@ class Contract < Decorator
|
|
73
83
|
# This function is used by the default #failure_callback method
|
74
84
|
# and uses the hash passed into the failure_callback method.
|
75
85
|
def self.failure_msg(data)
|
76
|
-
expected = if data[:contract].to_s == ""
|
86
|
+
expected = if data[:contract].to_s == "" || data[:contract].is_a?(Hash)
|
77
87
|
data[:contract].inspect
|
78
88
|
else
|
79
89
|
data[:contract].to_s
|
metadata
CHANGED
@@ -1,68 +1,50 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: contracts
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 0.2.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Aditya Bhargava
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-06-07 00:00:00 Z
|
12
|
+
date: 2012-06-07 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
|
-
|
14
|
+
description: This library provides contracts for Ruby. Contracts let you clearly express
|
15
|
+
how your code behaves, and free you from writing tons of boilerplate, defensive
|
16
|
+
code.
|
22
17
|
email: bluemangroupie@gmail.com
|
23
18
|
executables: []
|
24
|
-
|
25
19
|
extensions: []
|
26
|
-
|
27
20
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
21
|
+
files:
|
30
22
|
- lib/builtin_contracts.rb
|
31
23
|
- lib/contracts.rb
|
32
24
|
- lib/decorators.rb
|
33
25
|
- lib/testable.rb
|
34
26
|
homepage: http://github.com/egonSchiele/contracts.ruby
|
35
27
|
licenses: []
|
36
|
-
|
37
28
|
post_install_message:
|
38
29
|
rdoc_options: []
|
39
|
-
|
40
|
-
require_paths:
|
30
|
+
require_paths:
|
41
31
|
- lib
|
42
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
33
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
|
48
|
-
|
49
|
-
- 0
|
50
|
-
version: "0"
|
51
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
39
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
60
44
|
requirements: []
|
61
|
-
|
62
45
|
rubyforge_project:
|
63
46
|
rubygems_version: 1.8.25
|
64
47
|
signing_key:
|
65
48
|
specification_version: 3
|
66
49
|
summary: Contracts for Ruby.
|
67
50
|
test_files: []
|
68
|
-
|