cells 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/README.md +1 -1
- data/lib/cell/caching/notification.rb +2 -2
- data/lib/cell/partial.rb +1 -1
- data/lib/cell/rails.rb +3 -5
- data/lib/cell/version.rb +1 -1
- data/lib/cell/view_model.rb +3 -3
- data/test/builder_test.rb +1 -1
- data/test/caching_test.rb +7 -7
- data/test/concept_test.rb +1 -1
- data/test/public_test.rb +1 -1
- data/test/render_test.rb +1 -7
- data/test/test_helper.rb +4 -4
- data/test/twin_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10248a40af9eca0d333368d6df675d88f77be026
|
4
|
+
data.tar.gz: b4fb151ae10270795f57f5a418d3e552424a2631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc18a9d14431f421008e3b758d2ac9e567c09cde38330fb0be8264c33682f98e3d32b38f96d1efce0111ff0b3981e60e8262d02ade5d0c5ac83573b6fe675dbc
|
7
|
+
data.tar.gz: 3ba936fe9fa477efdf3504c6d2682f8251479b9cacf894bff4b5b95bac5025cc39c67bbc2fd005bf32febd6d519a833d366d299387336db9b281f996ae5cab8a
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -46,7 +46,7 @@ Usually, you'd pass in one or more objects you want the cell to present. That ca
|
|
46
46
|
A cell is a light-weight class with one or multiple methods that render views.
|
47
47
|
|
48
48
|
```ruby
|
49
|
-
class
|
49
|
+
class CommentCell < Cell::ViewModel
|
50
50
|
property :body
|
51
51
|
property :author
|
52
52
|
|
@@ -2,9 +2,9 @@ module Cell
|
|
2
2
|
module Caching
|
3
3
|
module Notifications
|
4
4
|
def fetch_from_cache_for(key, options)
|
5
|
-
ActiveSupport::Notifications.instrument('read_fragment.cells', :
|
5
|
+
ActiveSupport::Notifications.instrument('read_fragment.cells', key: key) do
|
6
6
|
cache_store.fetch(key, options) do
|
7
|
-
ActiveSupport::Notifications.instrument('write_fragment.cells', :
|
7
|
+
ActiveSupport::Notifications.instrument('write_fragment.cells', key: key) do
|
8
8
|
yield
|
9
9
|
end
|
10
10
|
end
|
data/lib/cell/partial.rb
CHANGED
@@ -12,6 +12,6 @@ module Cell::ViewModel::Partial
|
|
12
12
|
view += ".#{options[:formats].first}" if options[:formats]
|
13
13
|
prefixes = self.class.view_paths.collect { |path| parts.unshift(path).join("/") }
|
14
14
|
|
15
|
-
options.merge!(:
|
15
|
+
options.merge!(view: view, prefixes: prefixes)
|
16
16
|
end
|
17
17
|
end
|
data/lib/cell/rails.rb
CHANGED
@@ -15,7 +15,7 @@ module Cell
|
|
15
15
|
# Returns the cell instance for +name+. You may pass arbitrary options to your
|
16
16
|
# cell.
|
17
17
|
#
|
18
|
-
# = cell(:song, :
|
18
|
+
# = cell(:song, title: "Creeping Out Sara").render(:show)
|
19
19
|
def cell(name, *args, &block)
|
20
20
|
controller.cell(name, *args, &block)
|
21
21
|
end
|
@@ -39,10 +39,8 @@ module Cell
|
|
39
39
|
included do
|
40
40
|
extend Uber::Delegates
|
41
41
|
delegates :parent_controller, :session, :params, :request, :config, :env, :url_options
|
42
|
-
|
43
|
-
|
44
|
-
def protect_against_forgery? # TODO: implement forgery protection with ActionController.
|
45
|
-
false
|
42
|
+
# forgery protection.
|
43
|
+
delegates :parent_controller, :protect_against_forgery?, :form_authenticity_token, :request_forgery_protection_token
|
46
44
|
end
|
47
45
|
|
48
46
|
def call(*)
|
data/lib/cell/version.rb
CHANGED
data/lib/cell/view_model.rb
CHANGED
@@ -129,7 +129,7 @@ module Cell
|
|
129
129
|
def with_layout(options, content)
|
130
130
|
return content unless layout = options[:layout]
|
131
131
|
|
132
|
-
template = find_template(options.merge :
|
132
|
+
template = find_template(options.merge view: layout) # we could also allow a different layout engine, etc.
|
133
133
|
|
134
134
|
render_template(template, options) { content }
|
135
135
|
end
|
@@ -200,9 +200,9 @@ module Cell
|
|
200
200
|
def normalize_options(options, caller) # TODO: rename to #setup_options! to be inline with Trb.
|
201
201
|
options = if options.is_a?(Hash)
|
202
202
|
# TODO: speedup by not doing state_for_implicit_render.
|
203
|
-
{:
|
203
|
+
{view: state_for_implicit_render(caller)}.merge(options)
|
204
204
|
else
|
205
|
-
{:
|
205
|
+
{view: options.to_s}
|
206
206
|
end
|
207
207
|
|
208
208
|
options[:prefixes] ||= _prefixes
|
data/test/builder_test.rb
CHANGED
@@ -45,7 +45,7 @@ class BuilderTest < MiniTest::Spec
|
|
45
45
|
it do
|
46
46
|
cell = SongCell.(Song.new("San Francisco"), evergreen: true)
|
47
47
|
cell.must_be_instance_of EvergreenCell
|
48
|
-
cell.options.must_equal({:
|
48
|
+
cell.options.must_equal({evergreen:true})
|
49
49
|
end
|
50
50
|
|
51
51
|
# without arguments.
|
data/test/caching_test.rb
CHANGED
@@ -104,10 +104,10 @@ class CachingUnitTest < MiniTest::Spec
|
|
104
104
|
# end
|
105
105
|
|
106
106
|
# it "accept cache options" do
|
107
|
-
# key = @class.state_cache_key(:tock, :
|
107
|
+
# key = @class.state_cache_key(:tock, volume: 9)
|
108
108
|
# assert Cell::Rails.cache_store.write(key, 'ONE!')
|
109
109
|
|
110
|
-
# MusicianController.new.expire_cell_state(DirectorCell, :tock, :
|
110
|
+
# MusicianController.new.expire_cell_state(DirectorCell, :tock, volume: 9)
|
111
111
|
# assert_equal "1", @class.cache_store.read(@key)
|
112
112
|
# assert_not ::Cell::Rails.cache_store.read(key)
|
113
113
|
# end
|
@@ -183,7 +183,7 @@ class CachingTest < MiniTest::Spec
|
|
183
183
|
# compute key with cell properties from #initialize.
|
184
184
|
it do
|
185
185
|
director_cell.class.cache :show do
|
186
|
-
@counter < 3 ? {:
|
186
|
+
@counter < 3 ? {count: "<"} : {count: ">"}
|
187
187
|
end
|
188
188
|
|
189
189
|
director_cell(1).call.must_equal "1"
|
@@ -197,7 +197,7 @@ class CachingTest < MiniTest::Spec
|
|
197
197
|
director_cell.class.cache :show, :version
|
198
198
|
director_cell.class.class_eval do
|
199
199
|
def version
|
200
|
-
@counter < 3 ? {:
|
200
|
+
@counter < 3 ? {count: "<"} : {count: ">"}
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
@@ -261,7 +261,7 @@ class CachingTest < MiniTest::Spec
|
|
261
261
|
|
262
262
|
# options are passed through to cache store.
|
263
263
|
# :expires_in.
|
264
|
-
# :
|
264
|
+
# tags: lambda { |one, two, three| "#{one},#{two},#{three}" }
|
265
265
|
class CacheStore
|
266
266
|
attr_reader :fetch_args
|
267
267
|
|
@@ -288,7 +288,7 @@ end
|
|
288
288
|
|
289
289
|
class CachingInheritanceTest < CachingTest
|
290
290
|
class DirectorCell < ::DirectorCell
|
291
|
-
cache :show, :
|
291
|
+
cache :show, expires_in: 10.minutes do
|
292
292
|
"v1"
|
293
293
|
end
|
294
294
|
end
|
@@ -297,7 +297,7 @@ class CachingInheritanceTest < CachingTest
|
|
297
297
|
end
|
298
298
|
|
299
299
|
class DirectorsDaughterCell < ::DirectorCell
|
300
|
-
cache :show, :
|
300
|
+
cache :show, expires_in: 9.minutes do
|
301
301
|
"v2"
|
302
302
|
end
|
303
303
|
end
|
data/test/concept_test.rb
CHANGED
data/test/public_test.rb
CHANGED
@@ -20,7 +20,7 @@ class PublicTest < MiniTest::Spec
|
|
20
20
|
it { Cell::ViewModel.cell("public_test/song").must_be_instance_of SongCell }
|
21
21
|
|
22
22
|
# ViewModel.cell passes options to cell.
|
23
|
-
it { Cell::ViewModel.cell("public_test/song", Object, genre: "Metal").initialize_args.must_equal [Object, {:
|
23
|
+
it { Cell::ViewModel.cell("public_test/song", Object, genre: "Metal").initialize_args.must_equal [Object, {genre:"Metal"}] }
|
24
24
|
|
25
25
|
# ViewModel.cell(collection: []) renders cells.
|
26
26
|
it { Cell::ViewModel.cell('public_test/song', collection: [Object, Module]).must_equal '[Object, {}][Module, {}]' }
|
data/test/render_test.rb
CHANGED
@@ -95,10 +95,4 @@ class RenderTest < MiniTest::Spec
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# test inheritance
|
98
|
-
|
99
|
-
# test view: :bla and :bla
|
100
|
-
# with layout and locals.
|
101
|
-
# with layout and :text
|
102
|
-
|
103
|
-
# render with format (e.g. when using ERB for one view)
|
104
|
-
# should we allow changing the format "per run", so a cell can do .js and .haml? or should that be configurable on class level?
|
98
|
+
# with layout and locals.
|
data/test/test_helper.rb
CHANGED
@@ -22,19 +22,19 @@ end
|
|
22
22
|
|
23
23
|
class MusicianController < ActionController::Base
|
24
24
|
def view_with_concept_with_show
|
25
|
-
render :
|
25
|
+
render inline: %{<%= concept("view_extensions_test/cell", "Up For Breakfast", volume: 1).show %>} # TODO: concept doesn't need .call
|
26
26
|
end
|
27
27
|
|
28
28
|
def view_with_concept_without_call
|
29
|
-
render :
|
29
|
+
render inline: %{<%= concept("view_extensions_test/cell", "A Tale That Wasn't Right") %>} # this tests ViewModel#to_s.
|
30
30
|
end
|
31
31
|
|
32
32
|
def view_with_concept_with_call
|
33
|
-
render :
|
33
|
+
render inline: %{<%= concept("view_extensions_test/cell", "A Tale That Wasn't Right").call %>}
|
34
34
|
end
|
35
35
|
|
36
36
|
def view_with_cell_with_call
|
37
|
-
render :
|
37
|
+
render inline: %{<%= cell("view_extensions_test/song", "A Tale That Wasn't Right").call %>}
|
38
38
|
end
|
39
39
|
|
40
40
|
def action_with_concept_with_call
|
data/test/twin_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cells
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uber
|