block-chainable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ === 0.0.1 / 2008-03-07
2
+
3
+ * 1 minor enhancement
4
+ * Classes instantiated through blocks (using start) return the instance of the class for chaining
5
+
1
6
  === 0.0.1 / 2008-02-24
2
7
 
3
8
  * 2 major enhancements
data/README.txt CHANGED
@@ -23,16 +23,65 @@ you to assert values within the blocks as well as calling any other methods from
23
23
  * Stack trace should be simplified on errors within BlockChainable blocks
24
24
 
25
25
  == SYNOPSIS:
26
+ # a simple nonsense example showing the ability to call methods in outer block scopes
27
+
28
+ # create some simple classes that include BlockChainable
29
+ require 'block_chainable'
26
30
 
31
+ class Foo
32
+ include BlockChainable
33
+
34
+ def hi_from_foo
35
+ puts "hello from foo"
36
+ end
37
+ end
38
+
39
+ class Bar
40
+ include BlockChainable
41
+
42
+ def hi_from_bar
43
+ puts "hello from bar"
44
+ end
45
+ end
46
+
47
+ class Boo
48
+ include BlockChainable
49
+
50
+ def hi_from_boo
51
+ puts "hello from boo"
52
+ end
53
+ end
54
+
55
+
56
+ # we can now use the classes in a DSL manner. notice that calls can happen from with blocks to
57
+ # "outer-block" methods.
58
+ Foo do
59
+ hi_from_foo
60
+
61
+ Bar do
62
+ hi_from_bar
63
+ hi_from_foo
64
+
65
+ Boo do
66
+ hi_from_boo
67
+ hi_from_bar
68
+ hi_from_foo
69
+ end
70
+ end
71
+ end
72
+
73
+ # A slighty more complicated example.
27
74
  # a simple dsl for creating classroom rosters and printing them out. code can be found in the
28
75
  # example directory.
76
+
77
+ require 'block_chainable'
29
78
 
30
79
  # first, define our roster
31
80
  class Roster
32
81
  include BlockChainable
33
82
 
34
83
  def initialize(subject)
35
- @subject = subject
84
+ @subject = subject
36
85
  @students = []
37
86
  end
38
87
 
@@ -41,20 +90,20 @@ you to assert values within the blocks as well as calling any other methods from
41
90
  end
42
91
 
43
92
  def print_roster
44
- puts "Roster for #{@subject}:"
93
+ puts "Roster for #{@subject}:"
45
94
  @students.each{|s| puts " #{s}"}
46
95
  end
47
96
  end
48
97
 
49
98
  # next, define our student. the only tricky part here is add_to_roster, which calls
50
- # the method add_student_to_class, which is actually defined on the Classroom class.
51
- # BlockChainable will automatically send this method to the Classroom class with the
99
+ # the method add_student_to_roster, which is actually defined on the Roster class.
100
+ # BlockChainable will automatically send this method to the Roster class with the
52
101
  # Student instance as a parameter.
53
102
  class Student
54
103
  include BlockChainable
55
104
 
56
105
  def add_to_roster
57
- add_student_to_class self
106
+ add_student_to_roster self
58
107
  end
59
108
 
60
109
  def to_s
@@ -76,7 +125,6 @@ you to assert values within the blocks as well as calling any other methods from
76
125
 
77
126
  # we now have all the pieces we need for creating a simple dsl for building
78
127
  # and printing a class roster
79
- require 'block_chainable'
80
128
 
81
129
  Roster :Math do
82
130
  Student do
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'need'
6
6
  require 'spec/rake/spectask'
7
7
  need{'./lib/block_chainable.rb'}
8
8
 
9
- Hoe.new('block-chainable', '0.0.1') do |p|
9
+ Hoe.new('block-chainable', '0.0.2') do |p|
10
10
  p.rubyforge_name = 'block-chainable'
11
11
  p.author = 'Drew Olson'
12
12
  p.email = 'olsonas@gmail.com'
@@ -16,6 +16,7 @@ Hoe.new('block-chainable', '0.0.1') do |p|
16
16
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
17
17
  p.extra_deps << ['need', '>= 1.0.1']
18
18
  p.extra_deps << ['rspec', '>= 1.1.3']
19
+ p.remote_rdoc_dir = ''
19
20
  end
20
21
 
21
22
  Spec::Rake::SpecTask.new do |t|
@@ -18,6 +18,8 @@ module BlockChainable
18
18
  end
19
19
 
20
20
  klass_instance.instance_eval(&block)
21
+
22
+ klass_instance
21
23
  end
22
24
  end
23
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: block-chainable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Olson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-29 00:00:00 -06:00
12
+ date: 2008-03-07 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency