handshake 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/Manifest.txt +10 -0
- data/README +33 -0
- data/Rakefile +54 -0
- data/lib/handshake/handshake.rb +737 -0
- data/lib/handshake/inheritable_attributes.rb +132 -0
- data/lib/handshake/version.rb +8 -0
- data/lib/handshake.rb +1 -0
- data/test/tc_handshake.rb +494 -0
- metadata +54 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Brian Guthrie
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
data/README
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
== Handshake
|
2
|
+
|
3
|
+
Handshake is an informal design-by-contract system written in pure Ruby.
|
4
|
+
It's intended to allow Ruby developers to apply simple, clear constraints
|
5
|
+
to their methods and classes. Handshake is written by Brian Guthrie
|
6
|
+
(btguthrie@gmail.com) and lives at http://handshake.rubyforge.org.
|
7
|
+
|
8
|
+
Here's an example of Handshake in action:
|
9
|
+
|
10
|
+
class NonEmptyArray < Array
|
11
|
+
include Handshake
|
12
|
+
invariant { not empty? }
|
13
|
+
end
|
14
|
+
|
15
|
+
class NonEmptyStringArray < NonEmptyArray
|
16
|
+
contract :initialize, [[ String ]] => anything
|
17
|
+
contract :<<, String => self
|
18
|
+
contract :+, many?(String) => self
|
19
|
+
end
|
20
|
+
|
21
|
+
Handshake can also define pre- and post-conditions on your methods.
|
22
|
+
|
23
|
+
class Foo
|
24
|
+
before do
|
25
|
+
assert( not @widget.nil? )
|
26
|
+
end
|
27
|
+
def something_that_requires_widget
|
28
|
+
...
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
See Handshake::ClassMethods for more documentation on exact syntax and
|
33
|
+
capabilities.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
include FileUtils
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'handshake', 'version')
|
13
|
+
|
14
|
+
AUTHOR = "Brian Guthrie" # can also be an array of Authors
|
15
|
+
EMAIL = "btguthrie@gmail.com"
|
16
|
+
DESCRIPTION = "Handshake is a simple design-by-contract system for Ruby."
|
17
|
+
GEM_NAME = "handshake" # what ppl will type to install your gem
|
18
|
+
RUBYFORGE_PROJECT = "handshake" # The unix name for your project
|
19
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
|
+
|
21
|
+
|
22
|
+
NAME = "handshake"
|
23
|
+
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
24
|
+
VERS = ENV['VERSION'] || (Handshake::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
26
|
+
RDOC_OPTS = ['--quiet', '--title', "handshake documentation",
|
27
|
+
"--opname", "index.html",
|
28
|
+
"--line-numbers",
|
29
|
+
"--main", "README",
|
30
|
+
"--inline-source"]
|
31
|
+
|
32
|
+
class Hoe
|
33
|
+
def extra_deps
|
34
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate all the Rake tasks
|
39
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
40
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
41
|
+
p.author = AUTHOR
|
42
|
+
p.description = DESCRIPTION
|
43
|
+
p.email = EMAIL
|
44
|
+
p.summary = DESCRIPTION
|
45
|
+
p.url = HOMEPATH
|
46
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
47
|
+
p.test_globs = ["test/tc_*.rb"]
|
48
|
+
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
49
|
+
|
50
|
+
# == Optional
|
51
|
+
#p.changes - A description of the release's latest changes.
|
52
|
+
#p.extra_deps - An array of rubygem dependencies.
|
53
|
+
#p.spec_extras - A hash of extra values to set in the gemspec.
|
54
|
+
end
|