armin-joellenbeck-rdbc 0.0.6 → 0.0.7

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/Rakefile CHANGED
@@ -1,31 +1,32 @@
1
- require 'rake/gempackagetask'
2
- require 'rake/rdoctask'
3
-
4
-
5
- task :default => :rubydoctest
6
-
7
-
8
- task :all => [:doc, :package]
9
-
10
-
11
- Rake::RDocTask.new(:doc) do |t|
12
- t.rdoc_dir = 'doc'
13
- t.rdoc_files.include('README', 'lib/**/*.rb')
14
- t.options = [
15
- '--all',
16
- '--charset', 'utf8',
17
- '--inline-source',
18
- '--main', 'README',
19
- '--title', 'Design by Contract for Ruby'
20
- ]
21
- end
22
-
23
-
24
- Rake::GemPackageTask.new(eval(File.read('rdbc.gemspec'))) do |pkg|
25
- end
26
-
27
-
28
- task :rubydoctest do
29
- files = Dir['lib/**/*.rb','examples/**/*.rb'].join(' ')
30
- sh "RUBYLIB=examples:lib:$RUBYLIB rubydoctest #{files}"
31
- end
1
+ require 'rake/gempackagetask'
2
+ require 'rake/rdoctask'
3
+ require 'spec/rake/spectask'
4
+
5
+ task :default => 'spec'
6
+
7
+ task :all => [:clobber, :spec, :doc, :package]
8
+
9
+ Spec::Rake::SpecTask.new do |t|
10
+ t.libs << 'spec' << 'examples' << 'lib'
11
+ t.spec_opts << '--diff' << 'unified'
12
+ t.spec_opts << '--format' << 'progress'
13
+ end
14
+
15
+ Rake::RDocTask.new(:doc) do |t|
16
+ t.rdoc_dir = 'doc'
17
+ t.rdoc_files.include('README', 'lib/**/*.rb')
18
+ t.options = [
19
+ '--all',
20
+ '--charset', 'utf8',
21
+ '--inline-source',
22
+ '--main', 'README',
23
+ '--title', 'Design by Contract for Ruby'
24
+ ]
25
+ end
26
+
27
+ Rake::GemPackageTask.new(eval(File.read('rdbc.gemspec'))) do |pkg|
28
+ end
29
+
30
+ task :auto do
31
+ sh 'RUBYLIB=spec:examples:lib:$RUBYLIB autospec'
32
+ end
data/examples/stack.rb CHANGED
@@ -23,54 +23,18 @@ class Stack
23
23
  @objects.size
24
24
  end
25
25
 
26
- # doctest: A new Stack should be empty.
27
- # >> stack = Stack.new
28
- # >> stack.empty?
29
- # => true
30
26
  def empty?
31
27
  size == 0
32
28
  end
33
29
 
34
- # doctest: A new Stack should have no object on top.
35
- # >> stack = Stack.new
36
- # >> begin
37
- # ?> stack.top
38
- # ?> rescue Test::Unit::AssertionFailedError
39
- # ?> true
40
- # ?> else
41
- # ?> false
42
- # ?> end
43
- # => true
44
30
  def top
45
31
  @objects.last
46
32
  end
47
33
 
48
- # doctest: From a new Stack no object can be popped.
49
- # >> stack = Stack.new
50
- # >> begin
51
- # ?> stack.pop
52
- # ?> rescue Test::Unit::AssertionFailedError
53
- # ?> true
54
- # ?> else
55
- # ?> false
56
- # ?> end
57
- # => true
58
34
  def pop
59
35
  @objects.pop
60
36
  end
61
37
 
62
- # doctest: A pushed object should be on the top.
63
- # >> stack = Stack.new
64
- # >> object = Object.new
65
- # >> stack.push(object)
66
- # >> stack.empty?
67
- # => false
68
- # >> stack.top
69
- # => object
70
- # >> stack.pop
71
- # => object
72
- # >> stack.empty?
73
- # => true
74
38
  def push(object)
75
39
  @objects.push(object)
76
40
  nil
data/lib/contract.rb CHANGED
@@ -29,7 +29,7 @@ end
29
29
  class Class
30
30
 
31
31
  def contract(contract_class)
32
- decorator ContractDecorator(contract_class)
32
+ decorate ContractDecorator(contract_class)
33
33
  end
34
34
 
35
35
  end
@@ -1,4 +1,6 @@
1
+ require 'rubygems'
1
2
  require 'decorator'
3
+
2
4
  require 'translate'
3
5
 
4
6
 
@@ -10,7 +12,7 @@ class ContractDecorator < Decorator
10
12
 
11
13
  def initialize(object)
12
14
  super(object)
13
- @contract = self.class.contract_class.new
15
+ @contract = self.__class__.contract_class.new
14
16
  end
15
17
 
16
18
  def method_missing(method, *args)
data/lib/translate.rb CHANGED
@@ -1,47 +1,9 @@
1
1
  module Translate
2
2
 
3
- # doctest: Translate should give the pre method for a normal method
4
- # >> Translate.method_pre(:method)
5
- # => :method_pre
6
- #
7
- # doctest: Translate should give the pre method for a question method
8
- # >> Translate.method_pre(:method?)
9
- # => :method_pre?
10
- #
11
- # doctest: Translate should give the pre method for an exclamation method
12
- # >> Translate.method_pre(:method!)
13
- # => :method_pre!
14
- #
15
- # doctest: Translate should give the pre method for an assignment method
16
- # >> Translate.method_pre(:method=)
17
- # => :method_pre=
18
- #
19
- # doctest: Translate should give the pre method for an operator
20
- # >> Translate.method_pre(:+)
21
- # => :op_plus_pre
22
3
  def self.method_pre(method)
23
4
  method_with_suffix(method, :pre)
24
5
  end
25
6
 
26
- # doctest: Translate should give the post method for a normal method
27
- # >> Translate.method_post(:method)
28
- # => :method_post
29
- #
30
- # doctest: Translate should give the post method for a question method
31
- # >> Translate.method_post(:method?)
32
- # => :method_post?
33
- #
34
- # doctest: Translate should give the post method for an exclamation method
35
- # >> Translate.method_post(:method!)
36
- # => :method_post!
37
- #
38
- # doctest: Translate should give the post method for an assignment method
39
- # >> Translate.method_post(:method=)
40
- # => :method_post=
41
- #
42
- # doctest: Translate should give the post method for an operator
43
- # >> Translate.method_post(:+)
44
- # => :op_plus_post
45
7
  def self.method_post(method)
46
8
  method_with_suffix(method, :post)
47
9
  end
data/rdbc.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rdbc'
3
- s.version = '0.0.6'
3
+ s.version = '0.0.7'
4
4
  s.summary = 'Design by Contract for Ruby.'
5
5
  s.author = 'Armin Joellenbeck'
6
6
  s.email = 'armin@joellenbeck.net'
@@ -22,5 +22,5 @@ Gem::Specification.new do |s|
22
22
  '--main', 'README',
23
23
  '--title', 'Design by Contract for Ruby'
24
24
  ]
25
- s.add_dependency('tablatom-rubydoctest')
25
+ s.add_dependency('armin-joellenbeck-decorator')
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: armin-joellenbeck-rdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armin Joellenbeck
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-13 00:00:00 -07:00
12
+ date: 2008-10-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: tablatom-rubydoctest
16
+ name: armin-joellenbeck-decorator
17
17
  version_requirement:
18
18
  version_requirements: !ruby/object:Gem::Requirement
19
19
  requirements:
@@ -35,7 +35,6 @@ files:
35
35
  - rdbc.gemspec
36
36
  - examples/stack_contract.rb
37
37
  - examples/stack.rb
38
- - lib/decorator.rb
39
38
  - lib/contract.rb
40
39
  - lib/translate.rb
41
40
  - lib/contract_decorator.rb
data/lib/decorator.rb DELETED
@@ -1,31 +0,0 @@
1
- class Decorator
2
-
3
- attr_reader :object
4
-
5
- # doctest: A Decorator should be initialized with thr decorated object.
6
- # >> object = Object.new
7
- # >> decorator = Decorator.new(object)
8
- # >> decorator.object == object
9
- # => true
10
- def initialize(object)
11
- @object = object
12
- end
13
-
14
- def method_missing(method, *args)
15
- @object.send(method, *args)
16
- end
17
-
18
- end
19
-
20
-
21
- class Class
22
-
23
- def decorator(decorator_class)
24
- old_new = self.method(:new)
25
- (class << self; self; end).send(:define_method, :new) do |*args|
26
- object = old_new.call(*args)
27
- decorator_class.new(object)
28
- end
29
- end
30
-
31
- end