machinist_callbacks 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +52 -0
- data/VERSION +1 -1
- data/lib/machinist_callbacks.rb +13 -4
- data/machinist_callbacks.gemspec +18 -15
- data/spec/callbacks_spec.rb +30 -0
- metadata +16 -14
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
machinist_callbacks (0.1.3)
|
5
|
+
machinist (< 2.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (2.3.8)
|
11
|
+
actionpack (= 2.3.8)
|
12
|
+
actionpack (2.3.8)
|
13
|
+
activesupport (= 2.3.8)
|
14
|
+
rack (~> 1.1.0)
|
15
|
+
activerecord (2.3.8)
|
16
|
+
activesupport (= 2.3.8)
|
17
|
+
activeresource (2.3.8)
|
18
|
+
activesupport (= 2.3.8)
|
19
|
+
activesupport (2.3.8)
|
20
|
+
columnize (0.3.1)
|
21
|
+
faker (0.3.1)
|
22
|
+
linecache (0.43)
|
23
|
+
machinist (1.0.6)
|
24
|
+
rack (1.1.0)
|
25
|
+
rails (2.3.8)
|
26
|
+
actionmailer (= 2.3.8)
|
27
|
+
actionpack (= 2.3.8)
|
28
|
+
activerecord (= 2.3.8)
|
29
|
+
activeresource (= 2.3.8)
|
30
|
+
activesupport (= 2.3.8)
|
31
|
+
rake (>= 0.8.3)
|
32
|
+
rake (0.8.7)
|
33
|
+
rspec (1.2.9)
|
34
|
+
rspec-rails (1.2.9)
|
35
|
+
rack (>= 1.0.0)
|
36
|
+
rspec (>= 1.2.9)
|
37
|
+
ruby-debug (0.10.3)
|
38
|
+
columnize (>= 0.1)
|
39
|
+
ruby-debug-base (~> 0.10.3.0)
|
40
|
+
ruby-debug-base (0.10.3)
|
41
|
+
linecache (>= 0.3)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
faker
|
48
|
+
machinist_callbacks!
|
49
|
+
rails (= 2.3.8)
|
50
|
+
rspec (= 1.2.9)
|
51
|
+
rspec-rails (= 1.2.9)
|
52
|
+
ruby-debug
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/machinist_callbacks.rb
CHANGED
@@ -8,18 +8,18 @@ module Machinist
|
|
8
8
|
attr_reader :before_make_callback, :after_make_callback
|
9
9
|
|
10
10
|
def before_make(&callback)
|
11
|
-
|
11
|
+
append_callback(:before, callback)
|
12
12
|
end
|
13
13
|
|
14
14
|
def after_make(&callback)
|
15
|
-
|
15
|
+
append_callback(:after, callback)
|
16
16
|
end
|
17
17
|
|
18
18
|
class << self
|
19
19
|
|
20
20
|
def run_with_before_make(*args)
|
21
21
|
lathe = run_without_before_make(*args)
|
22
|
-
|
22
|
+
(lathe.object.instance_variable_get(:@before_make_callbacks) || []).each do |callback|
|
23
23
|
lathe.object.instance_eval(&callback)
|
24
24
|
end
|
25
25
|
lathe
|
@@ -29,6 +29,15 @@ module Machinist
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
+
private
|
33
|
+
|
34
|
+
def append_callback(type, callback)
|
35
|
+
variable = "@#{type}_make_callbacks"
|
36
|
+
chain = object.instance_variable_get(variable) || []
|
37
|
+
chain << callback
|
38
|
+
object.instance_variable_set(variable, chain)
|
39
|
+
end
|
40
|
+
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
@@ -40,7 +49,7 @@ makers << ActiveRecord::Base.send(ActiveRecord::Base.respond_to?(:singleton_clas
|
|
40
49
|
makers.each do |maker|
|
41
50
|
maker.send :define_method, :make_with_after_make do |*args|
|
42
51
|
object = make_without_after_make(*args)
|
43
|
-
|
52
|
+
(object.instance_variable_get(:@after_make_callbacks) || []).each do |callback|
|
44
53
|
object.instance_eval(&callback)
|
45
54
|
end
|
46
55
|
object
|
data/machinist_callbacks.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{machinist_callbacks}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Henning Koch"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-04}
|
13
13
|
s.description = %q{Callback hooks for machinist blueprints}
|
14
14
|
s.email = %q{github@makandra.de}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,6 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
".gitignore",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
20
22
|
"MIT-LICENSE",
|
21
23
|
"README.rdoc",
|
22
24
|
"Rakefile",
|
@@ -54,25 +56,25 @@ Gem::Specification.new do |s|
|
|
54
56
|
s.rubygems_version = %q{1.3.6}
|
55
57
|
s.summary = %q{Callback hooks for machinist blueprints}
|
56
58
|
s.test_files = [
|
57
|
-
"spec/
|
58
|
-
"spec/app_root/
|
59
|
-
"spec/app_root/
|
60
|
-
"spec/app_root/
|
59
|
+
"spec/app_root/app/controllers/application_controller.rb",
|
60
|
+
"spec/app_root/app/models/director.rb",
|
61
|
+
"spec/app_root/app/models/movie.rb",
|
62
|
+
"spec/app_root/app/models/producer.rb",
|
61
63
|
"spec/app_root/config/boot.rb",
|
62
64
|
"spec/app_root/config/environment.rb",
|
63
|
-
"spec/app_root/config/routes.rb",
|
64
65
|
"spec/app_root/config/environments/in_memory.rb",
|
65
66
|
"spec/app_root/config/environments/mysql.rb",
|
66
67
|
"spec/app_root/config/environments/postgresql.rb",
|
67
68
|
"spec/app_root/config/environments/sqlite.rb",
|
68
69
|
"spec/app_root/config/environments/sqlite3.rb",
|
70
|
+
"spec/app_root/config/routes.rb",
|
71
|
+
"spec/app_root/db/migrate/001_create_movies.rb",
|
72
|
+
"spec/app_root/db/migrate/002_create_directors.rb",
|
73
|
+
"spec/app_root/db/migrate/003_create_producers.rb",
|
69
74
|
"spec/app_root/lib/console_with_fixtures.rb",
|
70
|
-
"spec/
|
71
|
-
"spec/
|
72
|
-
"spec/
|
73
|
-
"spec/app_root/app/models/producer.rb",
|
74
|
-
"spec/callbacks_spec.rb",
|
75
|
-
"spec/spec_helper.rb"
|
75
|
+
"spec/spec_helper.rb",
|
76
|
+
"spec/support/blueprints.rb",
|
77
|
+
"spec/callbacks_spec.rb"
|
76
78
|
]
|
77
79
|
|
78
80
|
if s.respond_to? :specification_version then
|
@@ -88,3 +90,4 @@ Gem::Specification.new do |s|
|
|
88
90
|
s.add_dependency(%q<machinist>, ["< 2.0.0"])
|
89
91
|
end
|
90
92
|
end
|
93
|
+
|
data/spec/callbacks_spec.rb
CHANGED
@@ -109,5 +109,35 @@ describe 'machinist blueprints' do
|
|
109
109
|
|
110
110
|
end
|
111
111
|
|
112
|
+
%w[before_make after_make].each do |before_or_after_make|
|
113
|
+
|
114
|
+
describe "multiple #{before_or_after_make}s" do
|
115
|
+
|
116
|
+
before :each do
|
117
|
+
|
118
|
+
Movie.blueprint do
|
119
|
+
title "title"
|
120
|
+
year 1980
|
121
|
+
send(before_or_after_make) do
|
122
|
+
self.title = "The Good"
|
123
|
+
end
|
124
|
+
send(before_or_after_make) do
|
125
|
+
self.title << ", the Bad"
|
126
|
+
end
|
127
|
+
send(before_or_after_make) do
|
128
|
+
self.title << " and the Ugly"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should all be run' do
|
135
|
+
movie = Movie.make
|
136
|
+
movie.title.should == 'The Good, the Bad and the Ugly'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
112
142
|
end
|
113
143
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Henning Koch
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-04 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -41,6 +41,8 @@ extra_rdoc_files:
|
|
41
41
|
- README.rdoc
|
42
42
|
files:
|
43
43
|
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- Gemfile.lock
|
44
46
|
- MIT-LICENSE
|
45
47
|
- README.rdoc
|
46
48
|
- Rakefile
|
@@ -102,22 +104,22 @@ signing_key:
|
|
102
104
|
specification_version: 3
|
103
105
|
summary: Callback hooks for machinist blueprints
|
104
106
|
test_files:
|
105
|
-
- spec/
|
106
|
-
- spec/app_root/
|
107
|
-
- spec/app_root/
|
108
|
-
- spec/app_root/
|
107
|
+
- spec/app_root/app/controllers/application_controller.rb
|
108
|
+
- spec/app_root/app/models/director.rb
|
109
|
+
- spec/app_root/app/models/movie.rb
|
110
|
+
- spec/app_root/app/models/producer.rb
|
109
111
|
- spec/app_root/config/boot.rb
|
110
112
|
- spec/app_root/config/environment.rb
|
111
|
-
- spec/app_root/config/routes.rb
|
112
113
|
- spec/app_root/config/environments/in_memory.rb
|
113
114
|
- spec/app_root/config/environments/mysql.rb
|
114
115
|
- spec/app_root/config/environments/postgresql.rb
|
115
116
|
- spec/app_root/config/environments/sqlite.rb
|
116
117
|
- spec/app_root/config/environments/sqlite3.rb
|
118
|
+
- spec/app_root/config/routes.rb
|
119
|
+
- spec/app_root/db/migrate/001_create_movies.rb
|
120
|
+
- spec/app_root/db/migrate/002_create_directors.rb
|
121
|
+
- spec/app_root/db/migrate/003_create_producers.rb
|
117
122
|
- spec/app_root/lib/console_with_fixtures.rb
|
118
|
-
- spec/app_root/app/controllers/application_controller.rb
|
119
|
-
- spec/app_root/app/models/movie.rb
|
120
|
-
- spec/app_root/app/models/director.rb
|
121
|
-
- spec/app_root/app/models/producer.rb
|
122
|
-
- spec/callbacks_spec.rb
|
123
123
|
- spec/spec_helper.rb
|
124
|
+
- spec/support/blueprints.rb
|
125
|
+
- spec/callbacks_spec.rb
|