showcase 0.2.0.rc.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +19 -3
- data/lib/showcase/helpers/present.rb +10 -2
- data/lib/showcase/version.rb +1 -1
- data/spec/fixtures.rb +6 -0
- data/spec/helpers_spec.rb +7 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cc9956d43209ffcf07147c5ebd550aa6dd07407
|
4
|
+
data.tar.gz: 2f0302d869f55ac73959facae8ce2595d4c5f4b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28fdce56fdb476019ecf50d476f614bba7d8c7a01d569d78abe6c824ef213f930972d2b90ddf5010143f0d148527ba1f9f9c60e87908e1b674e75a95676ef1b7
|
7
|
+
data.tar.gz: d613dce8342d633d97368a003937a068e64bd2d8ec8dc8825cf857648e9c759281c31b15413a35592b9883c4880ec68670d7e56065535bd4c0539510a58740f4
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -100,7 +100,7 @@ from `BasePresenter` instead of `Showcase::Presenter`.
|
|
100
100
|
|
101
101
|
### Traits
|
102
102
|
|
103
|
-
Please [read the tests](https://github.com/stefanoverna/showcase/tree/master/lib/showcase/traits)
|
103
|
+
Please [read the tests](https://github.com/stefanoverna/showcase/tree/master/lib/showcase/traits)
|
104
104
|
for a detailed explanation of each method available.
|
105
105
|
|
106
106
|
#### `Showcase::Traits::Record`
|
@@ -145,7 +145,7 @@ Produces the following:
|
|
145
145
|
</div>
|
146
146
|
```
|
147
147
|
|
148
|
-
Additional HTML attributes can be optionally specified within a config block
|
148
|
+
Additional HTML attributes can be optionally specified within a config block
|
149
149
|
inside the presenter:
|
150
150
|
|
151
151
|
```ruby
|
@@ -258,6 +258,23 @@ In your views:
|
|
258
258
|
<% end %>
|
259
259
|
```
|
260
260
|
|
261
|
+
|
262
|
+
## Testing
|
263
|
+
|
264
|
+
Install gems:
|
265
|
+
|
266
|
+
```
|
267
|
+
$ bundle
|
268
|
+
$ rake appraisal:install
|
269
|
+
```
|
270
|
+
|
271
|
+
Launch tests:
|
272
|
+
|
273
|
+
```
|
274
|
+
rake appraisal
|
275
|
+
```
|
276
|
+
|
277
|
+
|
261
278
|
## Contributing
|
262
279
|
|
263
280
|
1. Fork it
|
@@ -265,4 +282,3 @@ In your views:
|
|
265
282
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
266
283
|
4. Push to the branch (`git push origin my-new-feature`)
|
267
284
|
5. Create new Pull Request
|
268
|
-
|
@@ -19,7 +19,7 @@ module Showcase
|
|
19
19
|
options.assert_valid_keys(:nil_presenter)
|
20
20
|
|
21
21
|
if obj || options.fetch(:nil_presenter, false)
|
22
|
-
klass ||=
|
22
|
+
klass ||= presenter_class(obj)
|
23
23
|
klass.new(obj, context)
|
24
24
|
else
|
25
25
|
nil
|
@@ -29,7 +29,15 @@ module Showcase
|
|
29
29
|
def present_collection(obj, klass = nil, context = presenter_context, options = {})
|
30
30
|
obj.map { |o| present(o, klass, context, options) }
|
31
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def presenter_class(obj)
|
36
|
+
obj.class.ancestors.each do |k|
|
37
|
+
klass = "#{k.name}Presenter".safe_constantize
|
38
|
+
return klass if klass
|
39
|
+
end
|
40
|
+
end
|
32
41
|
end
|
33
42
|
end
|
34
43
|
end
|
35
|
-
|
data/lib/showcase/version.rb
CHANGED
data/spec/fixtures.rb
CHANGED
data/spec/helpers_spec.rb
CHANGED
@@ -2,12 +2,17 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Showcase::Helpers do
|
4
4
|
let(:object) { Person.new('Steve Ballmer') }
|
5
|
+
let(:derived_object) { EnterpriseCustomer.new('Tito Traves') }
|
5
6
|
let(:context) { Context.new }
|
6
7
|
|
7
8
|
describe '.present' do
|
8
|
-
it '
|
9
|
+
it 'instantiates a new presenter, inferring the class' do
|
9
10
|
PersonPresenter.stub(:new).with(object, context).and_return 'Presenter'
|
10
|
-
context.present(object
|
11
|
+
context.present(object).should == 'Presenter'
|
12
|
+
end
|
13
|
+
it "instantiates a new presenter, searching presenter class in object ancestors chain" do
|
14
|
+
PersonPresenter.stub(:new).with(derived_object, context).and_return 'Presenter'
|
15
|
+
context.present(derived_object).should == 'Presenter'
|
11
16
|
end
|
12
17
|
it 'the presenter class to use can be specified as the second parameter' do
|
13
18
|
ProjectPresenter.stub(:new).with(object, context).and_return 'Presenter'
|
@@ -31,4 +36,3 @@ describe Showcase::Helpers do
|
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
34
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: showcase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -141,9 +141,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
141
|
version: '0'
|
142
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- - '
|
144
|
+
- - '>='
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
146
|
+
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
149
|
rubygems_version: 2.0.3
|