contracts 0.10 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +17 -0
- data/Gemfile +2 -1
- data/README.md +12 -0
- data/Rakefile +11 -0
- data/lib/contracts.rb +4 -2
- data/lib/contracts/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7928ae4cc32437fe0b85893e7f381a47864309e8
|
4
|
+
data.tar.gz: cfdd1ee61dd1e002bec1337815f75ce56c942b0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a68ba2b3654e8882954789e2370a88108c822dc97d390062c9507ab06b56f4fb8fb6739b4051a6a71ad3648742969bf936f096892f78ab5bc831108d667c563d
|
7
|
+
data.tar.gz: 2da1f049afd136edfdea28b9b9e1b4142ec721151b44bfde574075786338cea065cffc00273815edcd7b7b84f49926826fc69ffda462d3b94a87a8ce1b4ad831
|
data/CHANGELOG.markdown
CHANGED
@@ -1,4 +1,20 @@
|
|
1
|
+
## v0.10.1
|
2
|
+
|
3
|
+
- Enhancement: make `@pattern_match` instance variable not render ruby warning. Required to use new aruba versions in rspec tests - [Dennis Günnewig](https://github.com/dg-ratiodata) [#179](https://github.com/egonSchiele/contracts.ruby/pull/179)
|
4
|
+
|
5
|
+
## v0.10
|
6
|
+
|
7
|
+
- Bugfix: make `Maybe[Proc]` work correctly - [Simon George](https://github.com/sfcgeorge) [#142](https://github.com/egonSchiele/contracts.ruby/pull/142)
|
8
|
+
- Bugfix: make `Func` contract verified when used as return contract - [Rob Rosenbaum](https://github.com/robnormal) [#145](https://github.com/egonSchiele/contracts.ruby/pull/145)
|
9
|
+
- Bugfix: make `Pos`, `Neg` and `Nat` contracts handle non-numeric values correctly - [Matt Griffin](https://github.com/betamatt) and [Gavin Sinclair](https://github.com/gsinclair) [#147](https://github.com/egonSchiele/contracts.ruby/pull/147) [#173](https://github.com/egonSchiele/contracts.ruby/pull/173)
|
10
|
+
- Enhancement: reduce user class pollution through introduction of contracts engine - [Oleksii Fedorov](https://github.com/waterlink) [#141](https://github.com/egonSchiele/contracts.ruby/pull/141)
|
11
|
+
- Feature: add builtin `KeywordArgs` and `Optional` contracts for keyword arguments handling - [Oleksii Fedorov](https://github.com/waterlink) [#151](https://github.com/egonSchiele/contracts.ruby/pull/151)
|
12
|
+
- Feature: recognize module as a class contract - [Oleksii Fedorov](https://github.com/waterlink) [#153](https://github.com/egonSchiele/contracts.ruby/pull/153)
|
13
|
+
- Feature: custom validators with `Contract.override_validator` - [Oleksii Fedorov](https://github.com/waterlink) [#159](https://github.com/egonSchiele/contracts.ruby/pull/159)
|
14
|
+
- Feature: add builtin `RangeOf[...]` contract - [Gavin Sinclair](https://github.com/gsinclair) [#171](https://github.com/egonSchiele/contracts.ruby/pull/171)
|
15
|
+
|
1
16
|
## v0.9
|
17
|
+
|
2
18
|
- MAJOR fix in pattern-matching: If the return contract for a pattern-matched function fails, it should NOT try the next pattern-match function. Pattern-matching is only for params, not return values.
|
3
19
|
- raise an error if multiple defns have the same contract for pattern matching.
|
4
20
|
|
@@ -19,6 +35,7 @@
|
|
19
35
|
- various small fixes
|
20
36
|
|
21
37
|
## v0.8
|
38
|
+
|
22
39
|
- code refactored (very slight loss of performance, big increase in readability)
|
23
40
|
- fail when defining a contract on a module without `include Contracts::Modules`
|
24
41
|
- fixed several bugs in argument parsing, functions with complex params get contracts applied correctly now.
|
data/Gemfile
CHANGED
@@ -4,10 +4,11 @@ gemspec
|
|
4
4
|
|
5
5
|
group :test do
|
6
6
|
gem "rspec"
|
7
|
-
gem "rubocop", "~> 0.29.1", :platform => [:ruby_20, :ruby_21]
|
7
|
+
gem "rubocop", "~> 0.29.1", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
8
8
|
end
|
9
9
|
|
10
10
|
group :development do
|
11
11
|
gem "method_profiler"
|
12
12
|
gem "ruby-prof"
|
13
|
+
gem "rake"
|
13
14
|
end
|
data/README.md
CHANGED
@@ -53,6 +53,18 @@ Check out [this awesome tutorial](http://egonschiele.github.com/contracts.ruby).
|
|
53
53
|
|
54
54
|
Check out [this screencast](https://vimeo.com/85883356).
|
55
55
|
|
56
|
+
## Development
|
57
|
+
|
58
|
+
To get started do the following:
|
59
|
+
|
60
|
+
1. Install required gems for development
|
61
|
+
|
62
|
+
`bundle install`
|
63
|
+
|
64
|
+
2. Run our test suite
|
65
|
+
|
66
|
+
`bundle exec rake`
|
67
|
+
|
56
68
|
## Performance
|
57
69
|
|
58
70
|
Using contracts.ruby results in very little slowdown. Check out [this blog post](http://adit.io/posts/2013-03-04-How-I-Made-My-Ruby-Project-10x-Faster.html#seconds-6) for more info.
|
data/Rakefile
ADDED
data/lib/contracts.rb
CHANGED
@@ -110,6 +110,8 @@ class Contract < Contracts::Decorator
|
|
110
110
|
|
111
111
|
@ret_validator = Contract.make_validator(ret_contract)
|
112
112
|
|
113
|
+
@pattern_match = false
|
114
|
+
|
113
115
|
# == @has_proc_contract
|
114
116
|
last_contract = args_contracts.last
|
115
117
|
is_a_proc = last_contract.is_a?(Class) && (last_contract <= Proc || last_contract <= Method)
|
@@ -251,7 +253,7 @@ class Contract < Contracts::Decorator
|
|
251
253
|
|
252
254
|
# Used to determine type of failure exception this contract should raise in case of failure
|
253
255
|
def failure_exception
|
254
|
-
if
|
256
|
+
if pattern_match?
|
255
257
|
PatternMatchingError
|
256
258
|
else
|
257
259
|
ParamContractError
|
@@ -266,6 +268,6 @@ class Contract < Contracts::Decorator
|
|
266
268
|
|
267
269
|
# Used to determine if contract is a pattern matching contract
|
268
270
|
def pattern_match?
|
269
|
-
@pattern_match
|
271
|
+
@pattern_match == true
|
270
272
|
end
|
271
273
|
end
|
data/lib/contracts/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditya Bhargava
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This library provides contracts for Ruby. Contracts let you clearly express
|
14
14
|
how your code behaves, and free you from writing tons of boilerplate, defensive
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- CHANGELOG.markdown
|
26
26
|
- Gemfile
|
27
27
|
- README.md
|
28
|
+
- Rakefile
|
28
29
|
- TODO.markdown
|
29
30
|
- TUTORIAL.md
|
30
31
|
- benchmarks/bench.rb
|
@@ -81,8 +82,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
84
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.2.2
|
85
86
|
signing_key:
|
86
87
|
specification_version: 4
|
87
88
|
summary: Contracts for Ruby.
|
88
89
|
test_files: []
|
90
|
+
has_rdoc:
|