apotomo 1.2.6 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 869673532c8cc2f950193bfa92152e84f1a72b29
4
- data.tar.gz: 97d85b797409ec903b0ff2c62c50d3fd975384cc
3
+ metadata.gz: f65804220c4a86e32ec48fd0966e1fc89922c598
4
+ data.tar.gz: 780bf3c9e9f688c4c2bbd4879dfdfa6edd540d94
5
5
  SHA512:
6
- metadata.gz: d4771336d38c9b568ed1a945c073026df36becaaa44b6f312aead1c2ea2fcd304141142aaf21a7bf75587ade5b8eaf722c0f6757224147ef937e696297058fde
7
- data.tar.gz: 7046dc17fc8996102ced3bc8243421496bfa7a535d5a5d700f68bbb444549ac8cf5651a9665e7f62c5581bbce4aeb576b5a0f1d0383d85802d75176fadda0e0b
6
+ metadata.gz: 9dee577216e9fb9a740e464fd9fcebe549d77b9f654004cbb73141924dc00a580f4bc4d6a953085216dfe5087eafbe18e36f1744bd0f2383692b279c0a53af5d
7
+ data.tar.gz: e2d28c8832a7640e8a7bec5e50a723bcf1887074c7c7cb8e38364a9817d27ad3827a77e58da9bc22e092d9b70506b6d00c8b232e82a24c8a78cf8bd74b6b86e8
data/CHANGES.textile CHANGED
@@ -1,3 +1,7 @@
1
+ h2. 1.3.0
2
+
3
+ * Removed `Widget::DEFAULT_VIEW_PATHS`. This makes it compatible with Cells 3.11.
4
+
1
5
  h2. 1.2.6
2
6
 
3
7
  * Upgrade to newest hooks and uber, fixing `uninitialized constant Hooks::InheritableAttribute ` (fixes #144).
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem 'cells', "3.9.1"
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  **Web Components for Rails.**
4
4
 
5
- [![TravisCI Build Status](https://secure.travis-ci.org/apotonick/apotomo.png)](http://travis-ci.org/apotonick/apotomo)
6
5
 
7
6
  ## Overview
8
7
 
@@ -10,7 +9,7 @@ Do you need an _interactive user interface_ for your Rails application? A cool R
10
9
 
11
10
  Is your controller gettin' fat? And your partial-helper-AJAX pile is getting out of control?
12
11
 
13
- Do you want a framework to make the implementation easier? _You want Apotomo._
12
+ Do you want a framework to make the implementation easier? _You want Apotomo._
14
13
 
15
14
  **Apotomo** is based on [Cells](http://github.com/apotonick/cells), the popular View Components framework for Rails.
16
15
 
@@ -23,7 +22,7 @@ Easy as hell. You just need Ruby 1.9.3/2.0.0 and Rails 3/4.
23
22
  Add Apotomo to your `Gemfile`:
24
23
 
25
24
  ```ruby
26
- gem `apotomo`
25
+ gem 'apotomo'
27
26
  ```
28
27
 
29
28
  ## Example
@@ -60,7 +59,7 @@ You now tell your controller about the new widget.
60
59
 
61
60
  ```ruby
62
61
  class PostsController < ApplicationController
63
-
62
+
64
63
  has_widgets do |root|
65
64
  root << widget(:comments, :post => @post)
66
65
  end
@@ -77,7 +76,7 @@ Rendering usually happens in your controller view, `app/views/posts/show.html.ha
77
76
  %p
78
77
  = @post.body
79
78
  %p
80
- = render_widget :comments
79
+ = render_widget :comments, post: @post
81
80
  ```
82
81
 
83
82
  ## Write the widget
@@ -87,7 +86,7 @@ A widget is like a cell which is like a mini-controller.
87
86
  ```ruby
88
87
  class CommentsWidget < Apotomo::Widget
89
88
  responds_to_event :post
90
-
89
+
91
90
  def display(args)
92
91
  @comments = args[:post].comments # the parameter from outside.
93
92
 
@@ -97,13 +96,13 @@ class CommentsWidget < Apotomo::Widget
97
96
 
98
97
  Having `display` as the default state when rendering, this method collects comments to show and renders its view.
99
98
 
100
- And look at line 2 - if encountering a `:post` event we invoke `#post`, which is simply another state. How cool is that?
99
+ And look at line 2 - if encountering a `:post` event we invoke `#post`, which is simply another state. How cool is that?
101
100
 
102
101
  ```ruby
103
102
  def post(event)
104
103
  @comment = Comment.new :post_id => event[:post_id]
105
104
  @comment.update_attributes event[:comment] # a bit like params[].
106
-
105
+
107
106
  update :state => :display
108
107
  end
109
108
  end
@@ -128,7 +127,7 @@ Take a look at the widget's view `display.html.haml`.
128
127
  %ul
129
128
  - for comment in @comments
130
129
  %li= comment.text
131
-
130
+
132
131
  = form_for :comment, :url => url_for_event(:post), :remote => true do |f|
133
132
  = f.text_field :text
134
133
  = f.submit
@@ -179,11 +178,11 @@ class CommentsWidgetTest < Apotomo::TestCase
179
178
  has_widgets do |root|
180
179
  root << widget(:comments, :post => @pervert_post)
181
180
  end
182
-
181
+
183
182
  def test_render
184
183
  render_widget :comments
185
184
  assert_select "li#me"
186
-
185
+
187
186
  trigger :post, :comment => {:text => "Sex on the beach"}
188
187
  assert_response 'alert("Hey, you wanted to submit a pervert comment!");'
189
188
  end
@@ -5,20 +5,16 @@ module Apotomo
5
5
  rake_tasks do
6
6
  load "apotomo/apotomo.rake"
7
7
  end
8
-
9
- # As we are a Railtie only, the routes won't be loaded automatically. Beside that, we want our
8
+
9
+ # As we are a Railtie only, the routes won't be loaded automatically. Beside that, we want our
10
10
  # route to be the very first (otherwise #resources might supersede it).
11
11
  initializer 'apotomo.prepend_routes', :after => :add_routing_paths do |app|
12
12
  app.routes_reloader.paths.unshift(File.dirname(__FILE__) + "/../../config/routes.rb")
13
13
  end
14
-
14
+
15
15
  # Include a lazy loader via has_widgets.
16
16
  initializer 'apotomo.add_has_widgets' do |app|
17
17
  ActionController::Base.extend Apotomo::Rails::ControllerMethodsLoader
18
18
  end
19
-
20
- initializer 'apotomo.setup_view_paths', :after => 'cells.setup_view_paths' do |app|
21
- Apotomo::Widget.setup_view_paths!
22
- end
23
- end
19
+ end
24
20
  end
@@ -1,3 +1,3 @@
1
1
  module Apotomo
2
- VERSION = '1.2.6'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -30,16 +30,16 @@ module Apotomo
30
30
  # def display
31
31
  # @cheese = options[:favorites].first
32
32
  #
33
- # 2. Request data from forms etc. is available through <tt>event.data</tt> in the triggered states.
33
+ # 2. Request data from forms etc. is available through <tt>event.data</tt> in the triggered states.
34
34
  # Use the <tt>#[]</tt> shortcut to access values directly.
35
35
  #
36
36
  # def update(evt)
37
37
  # @cheese = Cheese.find evt[:cheese_id]
38
38
  class Widget < Cell::Rails
39
- DEFAULT_VIEW_PATHS = [File.join('app', 'widgets')]
40
-
39
+ self.view_paths = "app/widgets"
40
+
41
41
  include Hooks
42
-
42
+
43
43
  # Use this for setup code you're calling in every state. Almost like a +before_filter+ except that it's
44
44
  # invoked after the initialization in #has_widgets.
45
45
  #
@@ -51,60 +51,60 @@ module Apotomo
51
51
  # end
52
52
  define_hook :after_initialize
53
53
  define_hook :has_widgets
54
-
54
+
55
55
  attr_writer :visible
56
-
56
+
57
57
  include TreeNode
58
-
58
+
59
59
  include Onfire
60
-
60
+
61
61
  include EventMethods
62
62
  include WidgetShortcuts
63
63
  include JavascriptMethods
64
-
64
+
65
65
  helper Apotomo::Rails::ViewHelper
66
66
  helper Apotomo::Rails::ActionViewMethods
67
-
67
+
68
68
  abstract!
69
69
  undef :display # We don't want #display to be listed in #internal_methods.
70
-
70
+
71
71
  attr_reader :name
72
72
  alias_method :widget_id, :name
73
73
 
74
74
  attr_reader :options
75
-
75
+
76
76
  after_initialize do
77
77
  run_hook :has_widgets, self
78
78
  end
79
-
80
-
79
+
80
+
81
81
  def initialize(parent, id, options={})
82
82
  super(parent) # TODO: do that as long as cells do need a parent_controller.
83
83
  @options = options
84
84
  @name = id
85
85
  @visible = true
86
-
86
+
87
87
  setup_tree_node(parent)
88
-
88
+
89
89
  run_hook :after_initialize, self
90
90
  end
91
-
91
+
92
92
  def parent_controller
93
93
  # i hope we'll get rid of any parent_controller dependency, soon.
94
94
  root? ? @parent_controller : root.parent_controller
95
95
  end
96
-
96
+
97
97
  def visible?
98
98
  @visible
99
99
  end
100
-
100
+
101
101
  # Invokes +state+ and hopefully returns the rendered content.
102
102
  def invoke(state, *args)
103
- return render_state(state, *args) if method(state).arity != 0 # TODO: remove check and make trigger states receive the evt default.
103
+ return render_state(state, *args) if method(state).arity != 0 # TODO: remove check and make trigger states receive the evt default.
104
104
  render_state(state)
105
105
  end
106
-
107
- # Renders and returns a view for the current state. That's why it is usually called at the end of
106
+
107
+ # Renders and returns a view for the current state. That's why it is usually called at the end of
108
108
  # a state method.
109
109
  #
110
110
  # ==== Options
@@ -113,7 +113,7 @@ module Apotomo
113
113
  # Example:
114
114
  # class MouseWidget < Apotomo::Widget
115
115
  # def eat
116
- # render
116
+ # render
117
117
  # end
118
118
  #
119
119
  # render the view <tt>eat.haml</tt>.
@@ -124,27 +124,27 @@ module Apotomo
124
124
  def render(*args, &block)
125
125
  super
126
126
  end
127
-
127
+
128
128
  # Returns the widget named +widget_id+ if it's a descendent or self.
129
129
  def find_widget(widget_id)
130
130
  find {|node| node.name.to_s == widget_id.to_s}
131
131
  end
132
-
132
+
133
133
  def address_for_event(type, options={})
134
134
  options.reverse_merge! :source => name,
135
135
  :type => type,
136
- :controller => parent_controller.controller_path # DISCUSS: dependency to parent_controller.
136
+ :controller => parent_controller.controller_path # DISCUSS: dependency to parent_controller.
137
137
  end
138
-
138
+
139
139
  def url_for_event(type, options={})
140
- apotomo_event_path address_for_event(type, options)
140
+ apotomo_event_path address_for_event(type, options)
141
141
  end
142
-
143
-
142
+
143
+
144
144
  def self.controller_path
145
145
  @controller_path ||= name.sub(/Widget$/, '').underscore unless anonymous?
146
146
  end
147
-
147
+
148
148
  # Renders the +widget+ (instance or id).
149
149
  def render_widget(widget_id, state=:display, *args)
150
150
  if widget_id.kind_of?(Widget)
@@ -152,9 +152,9 @@ module Apotomo
152
152
  else
153
153
  widget = find_widget(widget_id) or raise "Couldn't render non-existent widget `#{widget_id}`"
154
154
  end
155
-
155
+
156
156
  widget.invoke(state, *args)
157
157
  end
158
158
  end
159
159
  end
160
-
160
+
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apotomo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cells
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.6.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.6.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: onfire
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hooks
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.4.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: slim
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: haml
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: tzinfo
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: minitest
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: 4.7.5
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: 4.7.5
125
125
  description: Web component framework for Rails providing widgets that trigger events
@@ -130,8 +130,8 @@ executables: []
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
- - ".gitignore"
134
- - ".travis.yml"
133
+ - .gitignore
134
+ - .travis.yml
135
135
  - CHANGES.textile
136
136
  - Gemfile
137
137
  - README.md
@@ -231,68 +231,18 @@ require_paths:
231
231
  - lib
232
232
  required_ruby_version: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">="
234
+ - - '>='
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
237
  required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  requirements:
239
- - - ">="
239
+ - - '>='
240
240
  - !ruby/object:Gem::Version
241
241
  version: '0'
242
242
  requirements: []
243
243
  rubyforge_project:
244
- rubygems_version: 2.2.1
244
+ rubygems_version: 2.2.2
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: Web components for Rails.
248
- test_files:
249
- - test/apotomo_test.rb
250
- - test/dummy/Rakefile
251
- - test/dummy/app/controllers/application_controller.rb
252
- - test/dummy/app/helpers/application_helper.rb
253
- - test/dummy/app/views/layouts/application.html.erb
254
- - test/dummy/config.ru
255
- - test/dummy/config/application.rb
256
- - test/dummy/config/boot.rb
257
- - test/dummy/config/database.yml
258
- - test/dummy/config/environment.rb
259
- - test/dummy/config/environments/development.rb
260
- - test/dummy/config/environments/production.rb
261
- - test/dummy/config/environments/test.rb
262
- - test/dummy/config/initializers/backtrace_silencers.rb
263
- - test/dummy/config/initializers/inflections.rb
264
- - test/dummy/config/initializers/mime_types.rb
265
- - test/dummy/config/initializers/secret_token.rb
266
- - test/dummy/config/initializers/session_store.rb
267
- - test/dummy/config/locales/en.yml
268
- - test/dummy/config/routes.rb
269
- - test/dummy/db/test.sqlite3
270
- - test/dummy/public/404.html
271
- - test/dummy/public/422.html
272
- - test/dummy/public/500.html
273
- - test/dummy/public/favicon.ico
274
- - test/dummy/public/stylesheets/.gitkeep
275
- - test/event_handler_test.rb
276
- - test/event_methods_test.rb
277
- - test/event_test.rb
278
- - test/invoke_event_handler_test.rb
279
- - test/javascript_generator_test.rb
280
- - test/rails/caching_test.rb
281
- - test/rails/controller_methods_test.rb
282
- - test/rails/rails_integration_test.rb
283
- - test/rails/view_helper_test.rb
284
- - test/rails/widget_generator_test.rb
285
- - test/render_test.rb
286
- - test/request_processor_test.rb
287
- - test/test_case_methods.rb
288
- - test/test_case_test.rb
289
- - test/test_helper.rb
290
- - test/tree_node_test.rb
291
- - test/widget_shortcuts_test.rb
292
- - test/widget_test.rb
293
- - test/widgets/mouse/eat.erb
294
- - test/widgets/mouse/eating.html.erb
295
- - test/widgets/mouse/educate.html.erb
296
- - test/widgets/mouse/feed.html.erb
297
- - test/widgets/mouse/make_me_squeak.html.erb
298
- - test/widgets/mouse/snuggle.html.erb
248
+ test_files: []