draper 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGELOG.txt +12 -0
- data/Readme.markdown +7 -13
- data/lib/draper/active_model_support.rb +4 -7
- data/lib/draper/base.rb +30 -3
- data/lib/draper/decorated_enumerable_proxy.rb +1 -1
- data/lib/draper/railtie.rb +7 -1
- data/lib/draper/system.rb +1 -1
- data/lib/draper/test/minitest_integration.rb +10 -1
- data/lib/draper/test/rspec_integration.rb +0 -5
- data/lib/draper/test/view_context.rb +1 -1
- data/lib/draper/version.rb +1 -1
- data/lib/draper/view_context.rb +5 -9
- data/lib/generators/test_unit/templates/decorator_test.rb +1 -1
- data/spec/draper/base_spec.rb +38 -26
- data/spec/draper/model_support_spec.rb +1 -1
- data/spec/draper/view_context_spec.rb +5 -13
- data/spec/spec_helper.rb +10 -1
- data/spec/support/samples/application_controller.rb +10 -11
- data/spec/support/samples/application_helper.rb +3 -0
- data/spec/support/samples/decorator_with_application_helper.rb +4 -0
- data/spec/support/samples/sequel_product.rb +13 -0
- metadata +99 -104
data/.gitignore
CHANGED
data/CHANGELOG.txt
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
= Draper Changelog
|
2
2
|
|
3
|
+
= 0.16.0
|
4
|
+
|
5
|
+
* Automatically prime view_context, see 057ab4
|
6
|
+
|
7
|
+
* Fixed bug where rspec eq matchers didn't work, see 57617b
|
8
|
+
|
9
|
+
* Sequel ORM support, see 7d4942
|
10
|
+
|
11
|
+
* Fixed issues with newer minitest
|
12
|
+
|
13
|
+
* changed the way the view_context gets set. See 0b039c
|
14
|
+
|
3
15
|
= 0.15.0
|
4
16
|
|
5
17
|
* Proper minitest integration
|
data/Readme.markdown
CHANGED
@@ -233,7 +233,7 @@ ArticleDecorator.decorate(Article.all) # Returns an enumeration proxy of Artic
|
|
233
233
|
```ruby
|
234
234
|
ArticleDecorator.find(1)
|
235
235
|
```
|
236
|
-
|
236
|
+
|
237
237
|
### In Your Views
|
238
238
|
|
239
239
|
Use the new methods in your views like any other model method (ex: `@article.published_at`):
|
@@ -242,25 +242,15 @@ Use the new methods in your views like any other model method (ex: `@article.pub
|
|
242
242
|
<h1><%= @article.title %> <%= @article.published_at %></h1>
|
243
243
|
```
|
244
244
|
|
245
|
-
### Using in Mailers
|
246
|
-
|
247
|
-
To use decorators in mailers that use helpers, you have to call `set_current_view_context` in your
|
248
|
-
ActionMailer class.
|
249
|
-
|
250
|
-
```ruby
|
251
|
-
class ArticleMailer < ActionMailer::Base
|
252
|
-
default 'init-draper' => Proc.new { set_current_view_context }
|
253
|
-
end
|
254
|
-
```
|
255
245
|
### Integration with RSpec
|
256
246
|
|
257
247
|
Using the provided generator, Draper will place specs for your new decorator in `spec/decorators/`.
|
258
248
|
|
259
|
-
By default, specs in `spec/decorators` will be tagged as `type => :decorator`. Any spec tagged as `decorator` will
|
249
|
+
By default, specs in `spec/decorators` will be tagged as `type => :decorator`. Any spec tagged as `decorator` will make helpers available to the decorator.
|
260
250
|
|
261
251
|
If your decorator specs live somewhere else, which they shouldn't, make sure to tag them with `type => :decorator`. If you don't tag them, Draper's helpers won't be available to your decorator while testing.
|
262
252
|
|
263
|
-
Note: If you're using Spork, you need to `require 'draper/rspec_integration'` in your Spork.prefork block.
|
253
|
+
Note: If you're using Spork, you need to `require 'draper/test/rspec_integration'` in your Spork.prefork block.
|
264
254
|
|
265
255
|
## Possible Decoration Methods
|
266
256
|
|
@@ -378,6 +368,10 @@ Note how the `validates` line is executed when the `User` class is loaded, trigg
|
|
378
368
|
|
379
369
|
Using `I18n` directly in your model definition **is an antipattern**. The preferred solution would be to not override the `message` option in your `validates` macro, but provide the `activerecord.errors.models.attributes.user.email.presence` key in your translation files.
|
380
370
|
|
371
|
+
## Extension gems
|
372
|
+
|
373
|
+
For automatic decoration, check out [decorates_before_rendering](https://github.com/ohwillie/decorates_before_rendering).
|
374
|
+
|
381
375
|
## Contributing
|
382
376
|
|
383
377
|
1. Fork it.
|
@@ -2,14 +2,11 @@ module Draper::ActiveModelSupport
|
|
2
2
|
module Proxies
|
3
3
|
def self.extended(base)
|
4
4
|
# These methods (as keys) will be created only if the correspondent
|
5
|
-
# model
|
6
|
-
proxies =
|
7
|
-
proxies[:to_param] = ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
8
|
-
proxies[:errors] = ActiveModel::Validations if defined?(ActiveModel::Validations)
|
9
|
-
proxies[:id] = ActiveRecord::Base if defined?(ActiveRecord::Base)
|
5
|
+
# model responds to the method
|
6
|
+
proxies = [:to_param, :errors, :id]
|
10
7
|
|
11
|
-
proxies.each do |method_name
|
12
|
-
if base.model.
|
8
|
+
proxies.each do |method_name|
|
9
|
+
if base.model.respond_to?(method_name)
|
13
10
|
base.singleton_class.class_eval do
|
14
11
|
if !base.class.instance_methods.include?(method_name) || base.class.instance_method(method_name).owner === Draper::Base
|
15
12
|
define_method(method_name) do |*args, &block|
|
data/lib/draper/base.rb
CHANGED
@@ -88,7 +88,8 @@ module Draper
|
|
88
88
|
#
|
89
89
|
# @param [Symbols*] name of associations to decorate
|
90
90
|
def self.decorates_associations(*association_symbols)
|
91
|
-
association_symbols.
|
91
|
+
options = association_symbols.extract_options!
|
92
|
+
association_symbols.each{ |sym| decorates_association(sym, options) }
|
92
93
|
end
|
93
94
|
|
94
95
|
# Specifies a black list of methods which may *not* be proxied to
|
@@ -136,7 +137,7 @@ module Draper
|
|
136
137
|
if input.instance_of?(self)
|
137
138
|
input.options = options unless options.empty?
|
138
139
|
return input
|
139
|
-
elsif input.respond_to?(:each)
|
140
|
+
elsif input.respond_to?(:each) && (!defined?(Sequel) || !input.is_a?(Sequel::Model))
|
140
141
|
Draper::DecoratedEnumerableProxy.new(input, self, options)
|
141
142
|
elsif options[:infer]
|
142
143
|
input.decorator(options)
|
@@ -161,12 +162,30 @@ module Draper
|
|
161
162
|
decorate(model_class.last, options)
|
162
163
|
end
|
163
164
|
|
165
|
+
# Some helpers are private, for example html_escape... as a workaround
|
166
|
+
# we are wrapping the helpers in a delegator that passes the methods
|
167
|
+
# along through a send, which will ignore private/public distinctions
|
168
|
+
class HelpersWrapper
|
169
|
+
def initialize(helpers)
|
170
|
+
@helpers = helpers
|
171
|
+
end
|
172
|
+
|
173
|
+
def method_missing(method, *args, &block)
|
174
|
+
@helpers.send(method, *args, &block)
|
175
|
+
end
|
176
|
+
|
177
|
+
#needed for tests
|
178
|
+
def ==(other)
|
179
|
+
other.instance_variable_get(:@helpers) == @helpers
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
164
183
|
# Access the helpers proxy to call built-in and user-defined
|
165
184
|
# Rails helpers. Aliased to `.h` for convenience.
|
166
185
|
#
|
167
186
|
# @return [Object] proxy
|
168
187
|
def helpers
|
169
|
-
self.class.helpers
|
188
|
+
HelpersWrapper.new self.class.helpers
|
170
189
|
end
|
171
190
|
alias :h :helpers
|
172
191
|
|
@@ -212,6 +231,14 @@ module Draper
|
|
212
231
|
super || (allow?(method) && model.respond_to?(method, include_private))
|
213
232
|
end
|
214
233
|
|
234
|
+
# We always want to delegate present, in case we decorate a nil object.
|
235
|
+
#
|
236
|
+
# I don't like the idea of decorating a nil object, but we'll deal with
|
237
|
+
# that later.
|
238
|
+
def present?
|
239
|
+
model.present?
|
240
|
+
end
|
241
|
+
|
215
242
|
def method_missing(method, *args, &block)
|
216
243
|
super unless allow?(method)
|
217
244
|
|
data/lib/draper/railtie.rb
CHANGED
@@ -34,9 +34,15 @@ module Draper
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
initializer "draper.extend_active_record_base" do |app|
|
38
|
+
ActiveSupport.on_load(:active_record) do
|
39
|
+
self.send(:include, Draper::ModelSupport)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
37
43
|
console do
|
38
44
|
require 'action_controller/test_case'
|
39
|
-
ApplicationController.new.
|
45
|
+
ApplicationController.new.view_context
|
40
46
|
Draper::ViewContext.current.controller.request ||= ActionController::TestRequest.new
|
41
47
|
Draper::ViewContext.current.request ||= Draper::ViewContext.current.controller.request
|
42
48
|
Draper::ViewContext.current.params ||= {}
|
data/lib/draper/system.rb
CHANGED
@@ -9,7 +9,16 @@ module MiniTest
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class MiniTest::Unit::DecoratorTestCase < MiniTest::Unit::TestCase
|
12
|
-
|
12
|
+
if method_defined?(:before_setup)
|
13
|
+
# for minitext >= 2.11
|
14
|
+
def before_setup
|
15
|
+
super
|
16
|
+
Draper::ViewContext.infect!(self)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
# for older minitest, like what ships w/Ruby 1.9
|
20
|
+
add_setup_hook { Draper::ViewContext.infect!(self) }
|
21
|
+
end
|
13
22
|
end
|
14
23
|
|
15
24
|
MiniTest::Spec.register_spec_type(MiniTest::Spec::Decorator) do |desc|
|
@@ -17,10 +17,6 @@ RSpec.configure do |config|
|
|
17
17
|
config.before :type => :decorator do
|
18
18
|
Draper::ViewContext.infect!(self)
|
19
19
|
end
|
20
|
-
|
21
|
-
config.before :type => :view do
|
22
|
-
controller.set_current_view_context
|
23
|
-
end
|
24
20
|
end
|
25
21
|
|
26
22
|
if defined?(Capybara)
|
@@ -30,4 +26,3 @@ if defined?(Capybara)
|
|
30
26
|
config.include Capybara::RSpecMatchers, :type => :decorator
|
31
27
|
end
|
32
28
|
end
|
33
|
-
|
@@ -2,7 +2,7 @@ module Draper
|
|
2
2
|
module ViewContext
|
3
3
|
def self.infect!(context)
|
4
4
|
context.instance_eval do
|
5
|
-
ApplicationController.new.
|
5
|
+
ApplicationController.new.view_context
|
6
6
|
Draper::ViewContext.current.controller.request ||= ActionController::TestRequest.new
|
7
7
|
Draper::ViewContext.current.request ||= Draper::ViewContext.current.controller.request
|
8
8
|
Draper::ViewContext.current.params ||= {}
|
data/lib/draper/version.rb
CHANGED
data/lib/draper/view_context.rb
CHANGED
@@ -1,21 +1,17 @@
|
|
1
1
|
module Draper
|
2
2
|
module ViewContext
|
3
3
|
def self.current
|
4
|
-
Thread.current[:current_view_context]
|
4
|
+
Thread.current[:current_view_context] || view_context
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.current=(input)
|
8
8
|
Thread.current[:current_view_context] = input
|
9
9
|
end
|
10
|
-
end
|
11
|
-
|
12
|
-
module ViewContextFilter
|
13
|
-
def set_current_view_context
|
14
|
-
Draper::ViewContext.current = self.view_context
|
15
|
-
end
|
16
10
|
|
17
|
-
def
|
18
|
-
|
11
|
+
def view_context
|
12
|
+
super.tap do |context|
|
13
|
+
Draper::ViewContext.current = context
|
14
|
+
end
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|
data/spec/draper/base_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Draper::Base do
|
4
|
-
before(:each){ ApplicationController.new.
|
4
|
+
before(:each){ ApplicationController.new.view_context }
|
5
5
|
subject{ Decorator.new(source) }
|
6
6
|
let(:source){ Product.new }
|
7
7
|
let(:non_active_model_source){ NonActiveModelProduct.new }
|
@@ -57,7 +57,7 @@ describe Draper::Base do
|
|
57
57
|
decorates:business
|
58
58
|
end
|
59
59
|
BusinessDecorator.model_class.should == Business
|
60
|
-
end.
|
60
|
+
end.to_not raise_error
|
61
61
|
end
|
62
62
|
|
63
63
|
context("accepts ActiveRecord like :class_name option too") do
|
@@ -67,7 +67,7 @@ describe Draper::Base do
|
|
67
67
|
decorates :product, :class => Product
|
68
68
|
end
|
69
69
|
CustomDecorator.model_class.should == Product
|
70
|
-
end.
|
70
|
+
end.to_not raise_error
|
71
71
|
end
|
72
72
|
|
73
73
|
it "accepts constants for :class_name" do
|
@@ -76,7 +76,7 @@ describe Draper::Base do
|
|
76
76
|
decorates :product, :class_name => Product
|
77
77
|
end
|
78
78
|
CustomDecorator.model_class.should == Product
|
79
|
-
end.
|
79
|
+
end.to_not raise_error
|
80
80
|
end
|
81
81
|
|
82
82
|
it "accepts strings for :class" do
|
@@ -85,7 +85,7 @@ describe Draper::Base do
|
|
85
85
|
decorates :product, :class => 'Product'
|
86
86
|
end
|
87
87
|
CustomDecorator.model_class.should == Product
|
88
|
-
end.
|
88
|
+
end.to_not raise_error
|
89
89
|
end
|
90
90
|
|
91
91
|
it "accepts strings for :class_name" do
|
@@ -94,7 +94,7 @@ describe Draper::Base do
|
|
94
94
|
decorates :product, :class_name => 'Product'
|
95
95
|
end
|
96
96
|
CustomDecorator.model_class.should == Product
|
97
|
-
end.
|
97
|
+
end.to_not raise_error
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -183,11 +183,18 @@ describe Draper::Base do
|
|
183
183
|
context('.decorates_associations') do
|
184
184
|
subject { Decorator }
|
185
185
|
it "decorates each of the associations" do
|
186
|
-
subject.should_receive(:decorates_association).with(:similar_products)
|
187
|
-
subject.should_receive(:decorates_association).with(:previous_version)
|
186
|
+
subject.should_receive(:decorates_association).with(:similar_products, {})
|
187
|
+
subject.should_receive(:decorates_association).with(:previous_version, {})
|
188
188
|
|
189
189
|
subject.decorates_associations :similar_products, :previous_version
|
190
190
|
end
|
191
|
+
|
192
|
+
it "dispatches options" do
|
193
|
+
subject.should_receive(:decorates_association).with(:similar_products, :with => ProductDecorator)
|
194
|
+
subject.should_receive(:decorates_association).with(:previous_version, :with => ProductDecorator)
|
195
|
+
|
196
|
+
subject.decorates_associations :similar_products, :previous_version, :with => ProductDecorator
|
197
|
+
end
|
191
198
|
end
|
192
199
|
|
193
200
|
context(".wrapped_object") do
|
@@ -251,17 +258,6 @@ describe Draper::Base do
|
|
251
258
|
DecoratorWithSpecialMethods.new(source).errors.should be_an_instance_of Array
|
252
259
|
end
|
253
260
|
end
|
254
|
-
|
255
|
-
context "when not an ActiveModel descendant" do
|
256
|
-
it "does not proxy to_param" do
|
257
|
-
non_active_model_source.stub(:to_param).and_return(1)
|
258
|
-
Draper::Base.new(non_active_model_source).to_param.should_not == 1
|
259
|
-
end
|
260
|
-
|
261
|
-
it "does not proxy errors" do
|
262
|
-
Draper::Base.new(non_active_model_source).should_not respond_to :errors
|
263
|
-
end
|
264
|
-
end
|
265
261
|
end
|
266
262
|
|
267
263
|
context 'the decorated model' do
|
@@ -363,6 +359,15 @@ describe Draper::Base do
|
|
363
359
|
end
|
364
360
|
end
|
365
361
|
|
362
|
+
context "when given a collection of sequel models" do
|
363
|
+
# Sequel models implement #each
|
364
|
+
let(:source) { [SequelProduct.new, SequelProduct.new] }
|
365
|
+
|
366
|
+
it "returns a collection of wrapped objects" do
|
367
|
+
subject.each{ |decorated| decorated.should be_instance_of(Draper::Base) }
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
366
371
|
context "when given a single source object" do
|
367
372
|
let(:source) { Product.new }
|
368
373
|
|
@@ -468,10 +473,13 @@ describe Draper::Base do
|
|
468
473
|
end
|
469
474
|
|
470
475
|
context ".respond_to?" do
|
476
|
+
# respond_to? is called by some proxies (id, to_param, errors).
|
477
|
+
# This is, why I stub it this way.
|
471
478
|
it "delegate respond_to? to the decorated model" do
|
472
479
|
other = Draper::Base.new(source)
|
473
|
-
source.
|
474
|
-
|
480
|
+
source.stub(:respond_to?).and_return(false)
|
481
|
+
source.stub(:respond_to?).with(:whatever, true).once.and_return("mocked")
|
482
|
+
subject.respond_to?(:whatever, true).should == "mocked"
|
475
483
|
end
|
476
484
|
end
|
477
485
|
|
@@ -669,19 +677,19 @@ describe Draper::Base do
|
|
669
677
|
}
|
670
678
|
|
671
679
|
it "raise an exception for a blank allows" do
|
672
|
-
expect {blank_allows}.
|
680
|
+
expect {blank_allows}.to raise_error(ArgumentError)
|
673
681
|
end
|
674
682
|
|
675
683
|
it "raise an exception for a blank denies" do
|
676
|
-
expect {blank_denies}.
|
684
|
+
expect {blank_denies}.to raise_error(ArgumentError)
|
677
685
|
end
|
678
686
|
|
679
687
|
it "raise an exception for calling allows then denies" do
|
680
|
-
expect {using_allows_then_denies}.
|
688
|
+
expect {using_allows_then_denies}.to raise_error(ArgumentError)
|
681
689
|
end
|
682
690
|
|
683
691
|
it "raise an exception for calling denies then allows" do
|
684
|
-
expect {using_denies_then_allows}.
|
692
|
+
expect {using_denies_then_allows}.to raise_error(ArgumentError)
|
685
693
|
end
|
686
694
|
end
|
687
695
|
|
@@ -706,9 +714,13 @@ describe Draper::Base do
|
|
706
714
|
|
707
715
|
it "is able to use l rather than helpers.l" do
|
708
716
|
now = Time.now
|
709
|
-
decorator.helpers.should_receive(:localize).with(now)
|
717
|
+
decorator.helpers.instance_variable_get(:@helpers).should_receive(:localize).with(now)
|
710
718
|
decorator.l now
|
711
719
|
end
|
720
|
+
|
721
|
+
it "is able to access html_escape, a private method" do
|
722
|
+
decorator.sample_html_escaped_text.should == '<script>danger</script>'
|
723
|
+
end
|
712
724
|
end
|
713
725
|
|
714
726
|
context "#method_missing" do
|
@@ -5,20 +5,12 @@ describe Draper::ViewContext do
|
|
5
5
|
let(:app_controller) { ApplicationController }
|
6
6
|
let(:app_controller_instance) { app_controller.new }
|
7
7
|
|
8
|
-
it "implements #set_current_view_context" do
|
9
|
-
app_controller_instance.should respond_to(:set_current_view_context)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "calls #before_filter with #set_current_view_context" do
|
13
|
-
app_controller.before_filters.should include(:set_current_view_context)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "raises an exception if the view_context is fetched without being set" do
|
17
|
-
Draper::ViewContext.current = nil
|
18
|
-
expect {app_controller.current_view_context}.should raise_exception(Exception)
|
19
|
-
end
|
20
|
-
|
21
8
|
it "provides a method to create a view context while testing" do
|
22
9
|
Draper::ViewContext.should respond_to(:infect!)
|
23
10
|
end
|
11
|
+
|
12
|
+
it "copies the controller's view context to draper" do
|
13
|
+
ctx = app_controller_instance.view_context
|
14
|
+
Draper::ViewContext.current.should == ctx
|
15
|
+
end
|
24
16
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,11 +2,13 @@ require 'bundler/setup'
|
|
2
2
|
require 'ammeter/init'
|
3
3
|
require 'rails'
|
4
4
|
|
5
|
+
require 'action_view'
|
6
|
+
require './spec/support/samples/application_controller'
|
7
|
+
|
5
8
|
Bundler.require
|
6
9
|
|
7
10
|
require './spec/support/samples/active_model'
|
8
11
|
require './spec/support/samples/active_record'
|
9
|
-
require './spec/support/samples/application_controller'
|
10
12
|
require './spec/support/samples/application_helper'
|
11
13
|
require './spec/support/samples/decorator'
|
12
14
|
require './spec/support/samples/decorator_with_allows'
|
@@ -19,8 +21,15 @@ require './spec/support/samples/namespaced_product_decorator'
|
|
19
21
|
require './spec/support/samples/non_active_model_product'
|
20
22
|
require './spec/support/samples/product'
|
21
23
|
require './spec/support/samples/product_decorator'
|
24
|
+
require './spec/support/samples/sequel_product'
|
22
25
|
require './spec/support/samples/specific_product_decorator'
|
23
26
|
require './spec/support/samples/some_thing'
|
24
27
|
require './spec/support/samples/some_thing_decorator'
|
25
28
|
require './spec/support/samples/widget'
|
26
29
|
require './spec/support/samples/widget_decorator'
|
30
|
+
|
31
|
+
module ActionController
|
32
|
+
class Base
|
33
|
+
Draper::System.setup(self)
|
34
|
+
end
|
35
|
+
end
|
@@ -1,7 +1,16 @@
|
|
1
1
|
require './spec/support/samples/application_helper'
|
2
2
|
|
3
3
|
module ActionController
|
4
|
-
class
|
4
|
+
class AbstractController
|
5
|
+
def view_context
|
6
|
+
@view_context ||= ApplicationController
|
7
|
+
end
|
8
|
+
|
9
|
+
def view_context=(input)
|
10
|
+
@view_context = input
|
11
|
+
end
|
12
|
+
end
|
13
|
+
class Base < AbstractController
|
5
14
|
@@before_filters = []
|
6
15
|
def self.before_filters
|
7
16
|
@@before_filters
|
@@ -9,8 +18,6 @@ module ActionController
|
|
9
18
|
def self.before_filter(name)
|
10
19
|
@@before_filters << name
|
11
20
|
end
|
12
|
-
|
13
|
-
Draper::System.setup(self)
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
@@ -20,14 +27,6 @@ class ApplicationController < ActionController::Base
|
|
20
27
|
extend ActionView::Helpers::UrlHelper
|
21
28
|
extend ApplicationHelper
|
22
29
|
|
23
|
-
def view_context
|
24
|
-
@view_context ||= ApplicationController
|
25
|
-
end
|
26
|
-
|
27
|
-
def view_context=(input)
|
28
|
-
@view_context = input
|
29
|
-
end
|
30
|
-
|
31
30
|
def self.hello
|
32
31
|
"Hello!"
|
33
32
|
end
|
metadata
CHANGED
@@ -1,125 +1,121 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: draper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.16.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 15
|
9
|
-
- 0
|
10
|
-
version: 0.15.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jeff Casimir
|
14
9
|
- Steve Klabnik
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-08-11 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: activesupport
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
19
|
+
requirements:
|
27
20
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 2
|
33
|
-
version: "3.2"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.2'
|
34
23
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: actionpack
|
38
24
|
prerelease: false
|
39
|
-
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '3.2'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: actionpack
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
40
34
|
none: false
|
41
|
-
requirements:
|
35
|
+
requirements:
|
42
36
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 3
|
47
|
-
- 2
|
48
|
-
version: "3.2"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '3.2'
|
49
39
|
type: :runtime
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: ammeter
|
53
40
|
prerelease: false
|
54
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
42
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.2'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: ammeter
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
64
54
|
version: 0.2.2
|
65
55
|
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: rake
|
69
56
|
prerelease: false
|
70
|
-
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.2.2
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
71
66
|
none: false
|
72
|
-
requirements:
|
67
|
+
requirements:
|
73
68
|
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
hash: 63
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
- 9
|
79
|
-
- 2
|
69
|
+
- !ruby/object:Gem::Version
|
80
70
|
version: 0.9.2
|
81
71
|
type: :development
|
82
|
-
version_requirements: *id004
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
72
|
prerelease: false
|
86
|
-
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.9.2
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: rspec
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
87
82
|
none: false
|
88
|
-
requirements:
|
83
|
+
requirements:
|
89
84
|
- - ~>
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
segments:
|
93
|
-
- 2
|
94
|
-
- 10
|
95
|
-
version: "2.10"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '2.10'
|
96
87
|
type: :development
|
97
|
-
version_requirements: *id005
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: yard
|
100
88
|
prerelease: false
|
101
|
-
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '2.10'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: yard
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
102
98
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
segments:
|
108
|
-
- 0
|
109
|
-
version: "0"
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
110
103
|
type: :development
|
111
|
-
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
112
111
|
description: Draper implements a decorator or presenter pattern for Rails applications.
|
113
|
-
email:
|
112
|
+
email:
|
114
113
|
- jeff@casimircreative.com
|
115
114
|
- steve@steveklabnik.com
|
116
115
|
executables: []
|
117
|
-
|
118
116
|
extensions: []
|
119
|
-
|
120
117
|
extra_rdoc_files: []
|
121
|
-
|
122
|
-
files:
|
118
|
+
files:
|
123
119
|
- .gitignore
|
124
120
|
- .rspec
|
125
121
|
- .travis.yml
|
@@ -198,6 +194,7 @@ files:
|
|
198
194
|
- spec/support/samples/non_active_model_product.rb
|
199
195
|
- spec/support/samples/product.rb
|
200
196
|
- spec/support/samples/product_decorator.rb
|
197
|
+
- spec/support/samples/sequel_product.rb
|
201
198
|
- spec/support/samples/some_thing.rb
|
202
199
|
- spec/support/samples/some_thing_decorator.rb
|
203
200
|
- spec/support/samples/specific_product_decorator.rb
|
@@ -205,38 +202,35 @@ files:
|
|
205
202
|
- spec/support/samples/widget_decorator.rb
|
206
203
|
homepage: http://github.com/jcasimir/draper
|
207
204
|
licenses: []
|
208
|
-
|
209
205
|
post_install_message:
|
210
206
|
rdoc_options: []
|
211
|
-
|
212
|
-
require_paths:
|
207
|
+
require_paths:
|
213
208
|
- lib
|
214
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
210
|
none: false
|
216
|
-
requirements:
|
217
|
-
- -
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
|
220
|
-
segments:
|
211
|
+
requirements:
|
212
|
+
- - ! '>='
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
segments:
|
221
216
|
- 0
|
222
|
-
|
223
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
|
+
hash: -943728829209315877
|
218
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
219
|
none: false
|
225
|
-
requirements:
|
226
|
-
- -
|
227
|
-
- !ruby/object:Gem::Version
|
228
|
-
|
229
|
-
segments:
|
220
|
+
requirements:
|
221
|
+
- - ! '>='
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
segments:
|
230
225
|
- 0
|
231
|
-
|
226
|
+
hash: -943728829209315877
|
232
227
|
requirements: []
|
233
|
-
|
234
228
|
rubyforge_project: draper
|
235
|
-
rubygems_version: 1.8.
|
229
|
+
rubygems_version: 1.8.24
|
236
230
|
signing_key:
|
237
231
|
specification_version: 3
|
238
232
|
summary: Decorator pattern implementation for Rails.
|
239
|
-
test_files:
|
233
|
+
test_files:
|
240
234
|
- spec/draper/base_spec.rb
|
241
235
|
- spec/draper/helper_support_spec.rb
|
242
236
|
- spec/draper/model_support_spec.rb
|
@@ -258,6 +252,7 @@ test_files:
|
|
258
252
|
- spec/support/samples/non_active_model_product.rb
|
259
253
|
- spec/support/samples/product.rb
|
260
254
|
- spec/support/samples/product_decorator.rb
|
255
|
+
- spec/support/samples/sequel_product.rb
|
261
256
|
- spec/support/samples/some_thing.rb
|
262
257
|
- spec/support/samples/some_thing_decorator.rb
|
263
258
|
- spec/support/samples/specific_product_decorator.rb
|