apotomo 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +10 -1
- data/CHANGES.textile +4 -0
- data/README.rdoc +8 -8
- data/lib/apotomo/test_case.rb +38 -40
- data/lib/apotomo/version.rb +1 -1
- data/test/widget_test.rb +5 -1
- metadata +82 -121
data/.travis.yml
CHANGED
data/CHANGES.textile
CHANGED
data/README.rdoc
CHANGED
@@ -44,7 +44,7 @@ Let's wrap that comments block in a widget.
|
|
44
44
|
|
45
45
|
Go and generate a widget stub.
|
46
46
|
|
47
|
-
$ rails generate apotomo:widget
|
47
|
+
$ rails generate apotomo:widget Comments display write -e haml
|
48
48
|
create app/cells/
|
49
49
|
create app/cells/comments_widget
|
50
50
|
create app/cells/comments_widget.rb
|
@@ -62,10 +62,10 @@ You now tell your controller about the new widget.
|
|
62
62
|
include Apotomo::Rails::ControllerMethods
|
63
63
|
|
64
64
|
has_widgets do |root|
|
65
|
-
root << widget(
|
65
|
+
root << widget(:comments, :post => @post)
|
66
66
|
end
|
67
67
|
|
68
|
-
|
68
|
+
This creates a widget instance called <tt>comments_widget</tt> from the class CommentsWidget. We pass the current post into the widget - the block is executed in controller instance context, that's were <tt>@post</tt> comes from. Handy, isn't it?
|
69
69
|
|
70
70
|
== Render the widget
|
71
71
|
|
@@ -77,7 +77,7 @@ Rendering usually happens in your controller view, <tt>views/posts/show.html.ham
|
|
77
77
|
@post.body
|
78
78
|
|
79
79
|
%p
|
80
|
-
= render_widget
|
80
|
+
= render_widget :comments
|
81
81
|
|
82
82
|
== Write the widget
|
83
83
|
|
@@ -148,7 +148,7 @@ Also, updating the page is in your hands. Where Apotomo provides handy helpers a
|
|
148
148
|
|
149
149
|
Look, +replace+ basically generates
|
150
150
|
|
151
|
-
$("
|
151
|
+
$("comments").replaceWith(<the rendered view>);
|
152
152
|
|
153
153
|
If that's not what you want, do
|
154
154
|
|
@@ -166,11 +166,11 @@ Apotomo comes with its own test case and assertions to <b>build rock-solid web c
|
|
166
166
|
|
167
167
|
class CommentsWidgetTest < Apotomo::TestCase
|
168
168
|
has_widgets do |root|
|
169
|
-
root << widget(:
|
169
|
+
root << widget(:comments, :post => @pervert_post)
|
170
170
|
end
|
171
171
|
|
172
172
|
def test_render
|
173
|
-
render_widget
|
173
|
+
render_widget :comments
|
174
174
|
assert_select "li#me"
|
175
175
|
|
176
176
|
trigger :post, :comment => {:text => "Sex on the beach"}
|
@@ -202,4 +202,4 @@ If you wanna be cool, subscribe to our feed[http://feeds.feedburner.com/Apotomo]
|
|
202
202
|
|
203
203
|
|
204
204
|
== License
|
205
|
-
Copyright (c) 2007-
|
205
|
+
Copyright (c) 2007-2012 Nick Sutterer <apotonick@gmail.com> under the MIT License
|
data/lib/apotomo/test_case.rb
CHANGED
@@ -34,54 +34,52 @@ module Apotomo
|
|
34
34
|
module TestMethods
|
35
35
|
extend ActiveSupport::Concern
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
include Cell::TestCase::CommonTestMethods
|
38
|
+
|
39
|
+
attr_reader :view_assigns
|
40
|
+
|
41
|
+
def setup
|
42
|
+
super # defined in Cell::TestCase::CommonTestMethods.
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
super # defined in Cell::TestCase::CommonTestMethods.
|
44
|
-
|
45
|
-
@controller.instance_eval do
|
46
|
-
def controller_path
|
47
|
-
'barn'
|
48
|
-
end
|
44
|
+
@controller.instance_eval do
|
45
|
+
def controller_path
|
46
|
+
'barn'
|
49
47
|
end
|
50
|
-
@controller.extend Apotomo::Rails::ControllerMethods
|
51
48
|
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@last_invoke
|
49
|
+
@controller.extend Apotomo::Rails::ControllerMethods
|
50
|
+
end
|
51
|
+
|
52
|
+
# Renders the widget +name+.
|
53
|
+
def render_widget(*args)
|
54
|
+
@view_assigns = extract_state_ivars_for(root[args.first]) do
|
55
|
+
@last_invoke = root.render_widget(*args)
|
60
56
|
end
|
57
|
+
|
58
|
+
@last_invoke
|
59
|
+
end
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
61
|
+
# Triggers an event of +type+. You have to pass the +source+ as second options.
|
62
|
+
#
|
63
|
+
# Example:
|
64
|
+
#
|
65
|
+
# trigger :submit, :comments
|
66
|
+
def trigger(type, source, options={})
|
67
|
+
source = root.find_widget(source)
|
68
|
+
source.fire(type, options)
|
69
|
+
root.page_updates
|
70
|
+
end
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def parent_controller
|
82
|
-
@controller
|
72
|
+
# Returns the widget tree from TestCase.has_widgets.
|
73
|
+
def root
|
74
|
+
blk = self.class.has_widgets_blocks or raise "Please setup a widget tree using has_widgets()"
|
75
|
+
@root ||= Apotomo::Widget.new(parent_controller, "root").tap do |root|
|
76
|
+
self.instance_exec(root, &blk)
|
83
77
|
end
|
84
78
|
end
|
79
|
+
|
80
|
+
def parent_controller
|
81
|
+
@controller
|
82
|
+
end
|
85
83
|
|
86
84
|
module ClassMethods
|
87
85
|
def has_widgets_blocks
|
data/lib/apotomo/version.rb
CHANGED
data/test/widget_test.rb
CHANGED
@@ -110,7 +110,11 @@ class WidgetTest < ActiveSupport::TestCase
|
|
110
110
|
end
|
111
111
|
|
112
112
|
should "respond to .view_paths" do
|
113
|
-
|
113
|
+
if Cells.rails3_2_or_more?
|
114
|
+
assert_equal ActionView::PathSet.new(Apotomo::Widget::DEFAULT_VIEW_PATHS + ["test/widgets"]).paths, Apotomo::Widget.view_paths.paths
|
115
|
+
else
|
116
|
+
assert_equal ActionView::PathSet.new(Apotomo::Widget::DEFAULT_VIEW_PATHS + ["test/widgets"]), Apotomo::Widget.view_paths
|
117
|
+
end
|
114
118
|
end
|
115
119
|
|
116
120
|
should "respond to .controller_path" do
|
metadata
CHANGED
@@ -1,142 +1,112 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: apotomo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
version: 1.2.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.3
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Nick Sutterer
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: cells
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &74978860 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 3
|
30
|
-
- 6
|
31
|
-
- 7
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 3.6.7
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: onfire
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *74978860
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: onfire
|
27
|
+
requirement: &74978510 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
29
|
+
requirements:
|
41
30
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
- 2
|
46
|
-
- 0
|
31
|
+
- !ruby/object:Gem::Version
|
47
32
|
version: 0.2.0
|
48
33
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: hooks
|
52
34
|
prerelease: false
|
53
|
-
|
35
|
+
version_requirements: *74978510
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: hooks
|
38
|
+
requirement: &74978060 !ruby/object:Gem::Requirement
|
54
39
|
none: false
|
55
|
-
requirements:
|
40
|
+
requirements:
|
56
41
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
- 2
|
61
|
-
- 0
|
42
|
+
- !ruby/object:Gem::Version
|
62
43
|
version: 0.2.0
|
63
44
|
type: :runtime
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: shoulda
|
67
45
|
prerelease: false
|
68
|
-
|
46
|
+
version_requirements: *74978060
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: shoulda
|
49
|
+
requirement: &74977250 !ruby/object:Gem::Requirement
|
69
50
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
- 0
|
75
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
76
55
|
type: :development
|
77
|
-
version_requirements: *id004
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rake
|
80
56
|
prerelease: false
|
81
|
-
|
57
|
+
version_requirements: *74977250
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: &74976840 !ruby/object:Gem::Requirement
|
82
61
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
- 0
|
88
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
89
66
|
type: :development
|
90
|
-
version_requirements: *id005
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: slim
|
93
67
|
prerelease: false
|
94
|
-
|
68
|
+
version_requirements: *74976840
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: slim
|
71
|
+
requirement: &74966910 !ruby/object:Gem::Requirement
|
95
72
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
|
100
|
-
- 0
|
101
|
-
version: "0"
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
102
77
|
type: :development
|
103
|
-
version_requirements: *id006
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
name: haml
|
106
78
|
prerelease: false
|
107
|
-
|
79
|
+
version_requirements: *74966910
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: haml
|
82
|
+
requirement: &74966580 !ruby/object:Gem::Requirement
|
108
83
|
none: false
|
109
|
-
requirements:
|
110
|
-
- -
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
|
113
|
-
- 0
|
114
|
-
version: "0"
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
115
88
|
type: :development
|
116
|
-
version_requirements: *id007
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: tzinfo
|
119
89
|
prerelease: false
|
120
|
-
|
90
|
+
version_requirements: *74966580
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: tzinfo
|
93
|
+
requirement: &74966340 !ruby/object:Gem::Requirement
|
121
94
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
|
126
|
-
- 0
|
127
|
-
version: "0"
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
128
99
|
type: :development
|
129
|
-
|
130
|
-
|
131
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *74966340
|
102
|
+
description: Web component framework for Rails providing widgets that trigger events
|
103
|
+
and know when and how to update themselves with AJAX.
|
104
|
+
email:
|
132
105
|
- apotonick@gmail.com
|
133
106
|
executables: []
|
134
|
-
|
135
107
|
extensions: []
|
136
|
-
|
137
108
|
extra_rdoc_files: []
|
138
|
-
|
139
|
-
files:
|
109
|
+
files:
|
140
110
|
- .gitignore
|
141
111
|
- .travis.yml
|
142
112
|
- CHANGES.textile
|
@@ -226,37 +196,28 @@ files:
|
|
226
196
|
- test/widgets/mouse/feed.html.erb
|
227
197
|
- test/widgets/mouse/make_me_squeak.html.erb
|
228
198
|
- test/widgets/mouse/snuggle.html.erb
|
229
|
-
has_rdoc: true
|
230
199
|
homepage: http://github.com/apotonick/apotomo
|
231
200
|
licenses: []
|
232
|
-
|
233
201
|
post_install_message:
|
234
202
|
rdoc_options: []
|
235
|
-
|
236
|
-
require_paths:
|
203
|
+
require_paths:
|
237
204
|
- lib
|
238
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
239
206
|
none: false
|
240
|
-
requirements:
|
241
|
-
- -
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
|
244
|
-
|
245
|
-
version: "0"
|
246
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ! '>='
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
212
|
none: false
|
248
|
-
requirements:
|
249
|
-
- -
|
250
|
-
- !ruby/object:Gem::Version
|
251
|
-
|
252
|
-
- 0
|
253
|
-
version: "0"
|
213
|
+
requirements:
|
214
|
+
- - ! '>='
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
254
217
|
requirements: []
|
255
|
-
|
256
218
|
rubyforge_project:
|
257
|
-
rubygems_version: 1.
|
219
|
+
rubygems_version: 1.8.10
|
258
220
|
signing_key:
|
259
221
|
specification_version: 3
|
260
222
|
summary: Web components for Rails.
|
261
223
|
test_files: []
|
262
|
-
|