view_models 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +26 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +242 -0
- data/Rakefile +47 -0
- data/VERSION.yml +4 -0
- data/generators/view_models/USAGE +6 -0
- data/generators/view_models/templates/README +1 -0
- data/generators/view_models/templates/spec/view_model_spec.rb +7 -0
- data/generators/view_models/templates/view_models/view_model.rb +5 -0
- data/generators/view_models/templates/views/_empty.html.haml +0 -0
- data/generators/view_models/templates/views/view_models/collection/_collection.html.erb +1 -0
- data/generators/view_models/templates/views/view_models/collection/_collection.html.haml +8 -0
- data/generators/view_models/templates/views/view_models/collection/_collection.text.erb +6 -0
- data/generators/view_models/templates/views/view_models/collection/_list.html.erb +1 -0
- data/generators/view_models/templates/views/view_models/collection/_list.html.haml +7 -0
- data/generators/view_models/templates/views/view_models/collection/_list.text.erb +6 -0
- data/generators/view_models/templates/views/view_models/collection/_pagination.html.haml +12 -0
- data/generators/view_models/templates/views/view_models/collection/_pagination.text.erb +3 -0
- data/generators/view_models/templates/views/view_models/collection/_table.html.haml +5 -0
- data/generators/view_models/templates/views/view_models/collection/_table.text.erb +10 -0
- data/generators/view_models/view_models_generator.rb +47 -0
- data/lib/extensions/active_record.rb +19 -0
- data/lib/extensions/model_reader.rb +115 -0
- data/lib/extensions/view.rb +24 -0
- data/lib/helpers/collection.rb +124 -0
- data/lib/helpers/rails.rb +59 -0
- data/lib/helpers/view.rb +22 -0
- data/lib/view_models/base.rb +268 -0
- data/lib/view_models/controller_extractor.rb +24 -0
- data/lib/view_models/path_store.rb +61 -0
- data/lib/view_models/render_options.rb +109 -0
- data/lib/view_models/view.rb +26 -0
- data/lib/view_models.rb +3 -0
- data/rails/init.rb +18 -0
- data/spec/integration/integration_spec.rb +269 -0
- data/spec/integration/models/sub_subclass.rb +14 -0
- data/spec/integration/models/subclass.rb +3 -0
- data/spec/integration/view_models/project.rb +14 -0
- data/spec/integration/view_models/sub_subclass.rb +42 -0
- data/spec/integration/view_models/subclass.rb +1 -0
- data/spec/integration/views/view_models/collection/_collection.html.erb +1 -0
- data/spec/integration/views/view_models/collection/_collection.text.erb +6 -0
- data/spec/integration/views/view_models/collection/_list.html.erb +1 -0
- data/spec/integration/views/view_models/collection/_list.text.erb +6 -0
- data/spec/integration/views/view_models/sub_subclass/_capture_in_template.erb +2 -0
- data/spec/integration/views/view_models/sub_subclass/_capture_in_view_model.erb +3 -0
- data/spec/integration/views/view_models/sub_subclass/_collection_example.html.erb +3 -0
- data/spec/integration/views/view_models/sub_subclass/_collection_example.text.erb +3 -0
- data/spec/integration/views/view_models/sub_subclass/_collection_item.html.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_collection_item.text.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_exists.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_exists.html.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_exists.text.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_exists_in_both.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_inner.also_explicit.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_inner.nesting.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_list_example.html.erb +3 -0
- data/spec/integration/views/view_models/sub_subclass/_list_example.text.erb +3 -0
- data/spec/integration/views/view_models/sub_subclass/_list_item.html.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_list_item.text.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_outer.explicit.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_outer.nesting.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/_part_that_is_dependent_on_the_view_model.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/show.html.erb +1 -0
- data/spec/integration/views/view_models/sub_subclass/show.text.erb +1 -0
- data/spec/integration/views/view_models/subclass/_exists_in_both.erb +1 -0
- data/spec/integration/views/view_models/subclass/_no_sub_subclass.erb +1 -0
- data/spec/integration/views/view_models/subclass/_not_found_in_sub_subclass.erb +1 -0
- data/spec/lib/extensions/active_record_spec.rb +31 -0
- data/spec/lib/extensions/model_reader_spec.rb +93 -0
- data/spec/lib/helpers/collection_spec.rb +196 -0
- data/spec/lib/helpers/rails_spec.rb +88 -0
- data/spec/lib/helpers/view_spec.rb +20 -0
- data/spec/lib/view_models/base_spec.rb +102 -0
- data/spec/lib/view_models/view_spec.rb +9 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/spec_helper_extensions.rb +13 -0
- metadata +156 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../spec_helper')
|
2
|
+
|
3
|
+
describe ViewModels::Helpers::Rails::Collection do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@collection = stub :collection
|
7
|
+
@context = stub :context
|
8
|
+
@collection_view_model = ViewModels::Helpers::Rails::Collection.new @collection, @context
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "list" do
|
12
|
+
it "should call render_partial and return the rendered result" do
|
13
|
+
@collection_view_model.stub! :render_partial => :result
|
14
|
+
|
15
|
+
@collection_view_model.list.should == :result
|
16
|
+
end
|
17
|
+
it "should call render_partial with the right parameters" do
|
18
|
+
default_options = {
|
19
|
+
:collection => @collection,
|
20
|
+
:template_name => :list_item,
|
21
|
+
:separator => nil
|
22
|
+
}
|
23
|
+
|
24
|
+
@collection_view_model.should_receive(:render_partial).once.with :list, default_options
|
25
|
+
|
26
|
+
@collection_view_model.list
|
27
|
+
end
|
28
|
+
it "should override the default options if specific options are given" do
|
29
|
+
specific_options = {
|
30
|
+
:collection => :a,
|
31
|
+
:template_name => :c,
|
32
|
+
:separator => :d
|
33
|
+
}
|
34
|
+
|
35
|
+
@collection_view_model.should_receive(:render_partial).once.with :list, specific_options
|
36
|
+
|
37
|
+
@collection_view_model.list specific_options
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "collection" do
|
42
|
+
it "should call render_partial and return the rendered result" do
|
43
|
+
@collection_view_model.stub! :render_partial => :result
|
44
|
+
|
45
|
+
@collection_view_model.collection.should == :result
|
46
|
+
end
|
47
|
+
it "should call render_partial with the right parameters" do
|
48
|
+
default_options = {
|
49
|
+
:collection => @collection,
|
50
|
+
:template_name => :collection_item,
|
51
|
+
:separator => nil
|
52
|
+
}
|
53
|
+
@collection_view_model.should_receive(:render_partial).once.with :collection, default_options
|
54
|
+
|
55
|
+
@collection_view_model.collection
|
56
|
+
end
|
57
|
+
it "should override the default options if specific options are given" do
|
58
|
+
specific_options = {
|
59
|
+
:collection => :a,
|
60
|
+
:template_name => :c,
|
61
|
+
:separator => :d
|
62
|
+
}
|
63
|
+
|
64
|
+
@collection_view_model.should_receive(:render_partial).once.with :collection, specific_options
|
65
|
+
|
66
|
+
@collection_view_model.collection specific_options
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "table" do
|
71
|
+
it "should call render_partial and return the rendered result" do
|
72
|
+
@collection_view_model.stub! :render_partial => :result
|
73
|
+
|
74
|
+
@collection_view_model.table.should == :result
|
75
|
+
end
|
76
|
+
it "should call render_partial with the right parameters" do
|
77
|
+
default_options = {
|
78
|
+
:collection => @collection,
|
79
|
+
:template_name => :table_row,
|
80
|
+
:separator => nil
|
81
|
+
}
|
82
|
+
|
83
|
+
@collection_view_model.should_receive(:render_partial).once.with :table, default_options
|
84
|
+
|
85
|
+
@collection_view_model.table
|
86
|
+
end
|
87
|
+
it "should override the default options if specific options are given" do
|
88
|
+
specific_options = {
|
89
|
+
:collection => :a,
|
90
|
+
:template_name => :c,
|
91
|
+
:separator => :d
|
92
|
+
}
|
93
|
+
|
94
|
+
@collection_view_model.should_receive(:render_partial).once.with :table, specific_options
|
95
|
+
|
96
|
+
@collection_view_model.table(specific_options)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "pagination" do
|
101
|
+
it "should call render_partial and return the rendered result" do
|
102
|
+
@collection_view_model.stub! :render_partial => :result
|
103
|
+
|
104
|
+
@collection_view_model.pagination.should == :result
|
105
|
+
end
|
106
|
+
it "should call render_partial with the right parameters" do
|
107
|
+
default_options = {
|
108
|
+
:collection => @collection,
|
109
|
+
:separator => '|'
|
110
|
+
}
|
111
|
+
@collection_view_model.should_receive(:render_partial).once.with :pagination, default_options
|
112
|
+
|
113
|
+
@collection_view_model.pagination
|
114
|
+
end
|
115
|
+
it "should override the default options if specific options are given" do
|
116
|
+
specific_options = {
|
117
|
+
:collection => :a,
|
118
|
+
:separator => :c
|
119
|
+
}
|
120
|
+
@collection_view_model.should_receive(:render_partial).once.with :pagination, specific_options
|
121
|
+
|
122
|
+
@collection_view_model.pagination specific_options
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "render_partial" do
|
127
|
+
it "should call instance eval on the context" do
|
128
|
+
@context.should_receive(:instance_eval).once
|
129
|
+
|
130
|
+
@collection_view_model.send :render_partial, :some_name, :some_params
|
131
|
+
end
|
132
|
+
it "should render the partial in the 'context' context" do
|
133
|
+
@context.should_receive(:render).once
|
134
|
+
|
135
|
+
@collection_view_model.send :render_partial, :some_name, :some_params
|
136
|
+
end
|
137
|
+
it "should call render partial on context with the passed through parameters" do
|
138
|
+
@context.should_receive(:render).once.with(:partial => 'view_models/collection/some_name', :locals => { :a => :b })
|
139
|
+
|
140
|
+
@collection_view_model.send :render_partial, :some_name, { :a => :b }
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "delegation" do
|
145
|
+
describe "enumerable" do
|
146
|
+
Enumerable.instance_methods.map(&:to_sym).each do |method|
|
147
|
+
it "should delegate #{method} to the collection" do
|
148
|
+
@collection.should_receive(method).once
|
149
|
+
|
150
|
+
@collection_view_model.send method
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
describe "array" do
|
155
|
+
describe "length" do
|
156
|
+
it "should delegate to #length of the collection" do
|
157
|
+
@collection.should_receive(:length).once
|
158
|
+
|
159
|
+
@collection_view_model.length
|
160
|
+
end
|
161
|
+
it "should return the length of the collection" do
|
162
|
+
@collection.should_receive(:length).and_return :this_length
|
163
|
+
|
164
|
+
@collection_view_model.length.should == :this_length
|
165
|
+
end
|
166
|
+
it "should alias size" do
|
167
|
+
@collection.should_receive(:size).and_return :this_length
|
168
|
+
|
169
|
+
@collection_view_model.size.should == :this_length
|
170
|
+
end
|
171
|
+
end
|
172
|
+
describe "empty?" do
|
173
|
+
it "should delegate to #empty? of the collection" do
|
174
|
+
@collection.should_receive(:empty?).once
|
175
|
+
|
176
|
+
@collection_view_model.empty?
|
177
|
+
end
|
178
|
+
it "should return whatever #empty? of the collection returns" do
|
179
|
+
@collection.should_receive(:empty?).and_return :true_or_false
|
180
|
+
|
181
|
+
@collection_view_model.empty?.should == :true_or_false
|
182
|
+
end
|
183
|
+
end
|
184
|
+
describe "each" do
|
185
|
+
it "should delegate to #each of the collection" do
|
186
|
+
proc = stub :proc
|
187
|
+
|
188
|
+
@collection.should_receive(:each).with(proc).once
|
189
|
+
|
190
|
+
@collection_view_model.each proc
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../spec_helper')
|
2
|
+
|
3
|
+
describe ViewModels::Helpers::Rails do
|
4
|
+
include ViewModels::Helpers::Rails
|
5
|
+
|
6
|
+
describe "collection_view_model_for" do
|
7
|
+
it "should return kind of a ViewModels::Collection" do
|
8
|
+
collection_view_model_for([]).should be_kind_of ViewModels::Helpers::Rails::Collection
|
9
|
+
end
|
10
|
+
it "should pass any parameters directly through" do
|
11
|
+
collection = stub :collection
|
12
|
+
context = stub :context
|
13
|
+
ViewModels::Helpers::Rails::Collection.should_receive(:new).with(collection, context).once
|
14
|
+
collection_view_model_for collection, context
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "view_model_for" do
|
19
|
+
it "should just pass the params through to the view_model" do
|
20
|
+
class SomeModelClazz; end
|
21
|
+
class ViewModels::SomeModelClazz < ViewModels::Base; end
|
22
|
+
context = stub :context
|
23
|
+
self.stub! :default_view_model_class_for => ViewModels::SomeModelClazz
|
24
|
+
model = SomeModelClazz.new
|
25
|
+
|
26
|
+
ViewModels::SomeModelClazz.should_receive(:new).once.with model, context
|
27
|
+
|
28
|
+
view_model_for model, context
|
29
|
+
end
|
30
|
+
describe "specific_view_model_mapping" do
|
31
|
+
it "should return an empty hash by default" do
|
32
|
+
specific_view_model_mapping.should == {}
|
33
|
+
end
|
34
|
+
it "should raise an ArgumentError on an non-mapped model" do
|
35
|
+
# TODO really clear enough that one should provide a ViewModel with an initializer with 2 params?
|
36
|
+
#
|
37
|
+
class SomeViewModelClass; end
|
38
|
+
specific_view_model_mapping[String] = SomeViewModelClass
|
39
|
+
lambda {
|
40
|
+
view_model_for("Some String")
|
41
|
+
}.should raise_error(ArgumentError, "wrong number of arguments (2 for 0)")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
describe "no specific mapping" do
|
45
|
+
it "should raise on an non-mapped model" do
|
46
|
+
# TODO really clear enough that the view model class is missing?
|
47
|
+
#
|
48
|
+
lambda {
|
49
|
+
view_model_for(42)
|
50
|
+
}.should raise_error(NameError, "uninitialized constant ViewModels::Fixnum")
|
51
|
+
end
|
52
|
+
it "should return a default view_model instance" do
|
53
|
+
class SomeModelClazz; end
|
54
|
+
class ViewModels::SomeModelClazz < ViewModels::Base; end
|
55
|
+
view_model_for(SomeModelClazz.new).should be_instance_of ViewModels::SomeModelClazz
|
56
|
+
end
|
57
|
+
end
|
58
|
+
describe "with specific mapping" do
|
59
|
+
class SomeModelClazz; end
|
60
|
+
class ViewModels::SomeSpecificClazz < ViewModels::Base; end
|
61
|
+
before(:each) do
|
62
|
+
self.should_receive(:specific_view_model_mapping).any_number_of_times.and_return SomeModelClazz => ViewModels::SomeSpecificClazz
|
63
|
+
end
|
64
|
+
it "should return a specifically mapped view_model instance" do
|
65
|
+
view_model_for(SomeModelClazz.new).should be_instance_of ViewModels::SomeSpecificClazz
|
66
|
+
end
|
67
|
+
it "should not call #default_view_model_class_for" do
|
68
|
+
mock(self).should_receive(:default_view_model_class_for).never
|
69
|
+
view_model_for SomeModelClazz.new
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "default_view_model_class_for" do
|
75
|
+
it "should return a class with ViewModels:: prepended" do
|
76
|
+
class Gaga; end # The model.
|
77
|
+
class ViewModels::Gaga < ViewModels::Base; end
|
78
|
+
default_view_model_class_for(Gaga.new).should == ViewModels::Gaga
|
79
|
+
end
|
80
|
+
it "should raise a NameError if the Presenter class does not exist" do
|
81
|
+
class Brrzt; end # Just the model.
|
82
|
+
lambda {
|
83
|
+
default_view_model_class_for(Brrzt.new)
|
84
|
+
}.should raise_error(NameError, "uninitialized constant ViewModels::Brrzt")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../spec_helper')
|
2
|
+
|
3
|
+
require 'helpers/view'
|
4
|
+
|
5
|
+
describe ViewModels::Helpers::View do
|
6
|
+
|
7
|
+
class TestClass; end
|
8
|
+
|
9
|
+
describe "including it" do
|
10
|
+
it "should include all the view helpers" do
|
11
|
+
in_the TestClass do
|
12
|
+
include ViewModels::Helpers::View
|
13
|
+
end
|
14
|
+
|
15
|
+
TestClass.should include(ActionView::Helpers)
|
16
|
+
TestClass.should include(ERB::Util)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../spec_helper')
|
2
|
+
|
3
|
+
require 'view_models/base'
|
4
|
+
|
5
|
+
describe ViewModels::Base do
|
6
|
+
|
7
|
+
describe "readers" do
|
8
|
+
describe "model" do
|
9
|
+
before(:each) do
|
10
|
+
@model = stub :model
|
11
|
+
@view_model = ViewModels::Base.new @model, nil
|
12
|
+
end
|
13
|
+
it "should have a reader" do
|
14
|
+
@view_model.model.should == @model
|
15
|
+
end
|
16
|
+
end
|
17
|
+
describe "controller" do
|
18
|
+
before(:each) do
|
19
|
+
@context = stub :controller
|
20
|
+
@view_model = ViewModels::Base.new nil, @context
|
21
|
+
end
|
22
|
+
it "should have a reader" do
|
23
|
+
@view_model.controller.should == @context
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "context recognition" do
|
29
|
+
describe "context is a view" do
|
30
|
+
before(:each) do
|
31
|
+
@view = stub :view, :controller => 'controller'
|
32
|
+
@view_model = ViewModels::Base.new nil, @view
|
33
|
+
end
|
34
|
+
it "should get the controller from the view" do
|
35
|
+
@view_model.controller.should == 'controller'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
describe "context is a controller" do
|
39
|
+
before(:each) do
|
40
|
+
@controller = stub :controller
|
41
|
+
@view_model = ViewModels::Base.new nil, @controller
|
42
|
+
end
|
43
|
+
it "should just use it for the controller" do
|
44
|
+
@view_model.controller.should == @controller
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".master_helper_module" do
|
50
|
+
before(:each) do
|
51
|
+
class ViewModels::SpecificMasterHelperModule < ViewModels::Base; end
|
52
|
+
end
|
53
|
+
it "should be a class specific inheritable accessor" do
|
54
|
+
ViewModels::SpecificMasterHelperModule.master_helper_module = :some_value
|
55
|
+
ViewModels::SpecificMasterHelperModule.master_helper_module.should == :some_value
|
56
|
+
end
|
57
|
+
it "should be an instance of Module on Base" do
|
58
|
+
ViewModels::Base.master_helper_module.should be_instance_of(Module)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".controller_method" do
|
63
|
+
it "should set up delegate calls to the controller" do
|
64
|
+
ViewModels::Base.should_receive(:delegate).once.with(:method1, :method2, :to => :controller)
|
65
|
+
|
66
|
+
ViewModels::Base.controller_method :method1, :method2
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ".helper" do
|
71
|
+
it "should include the helper" do
|
72
|
+
helper_module = Module.new
|
73
|
+
|
74
|
+
ViewModels::Base.should_receive(:include).once.with helper_module
|
75
|
+
|
76
|
+
ViewModels::Base.helper helper_module
|
77
|
+
end
|
78
|
+
it "should include the helper in the master helper module" do
|
79
|
+
master_helper_module = Module.new
|
80
|
+
ViewModels::Base.should_receive(:master_helper_module).and_return master_helper_module
|
81
|
+
|
82
|
+
helper_module = Module.new
|
83
|
+
master_helper_module.should_receive(:include).once.with helper_module
|
84
|
+
|
85
|
+
ViewModels::Base.helper helper_module
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#logger" do
|
90
|
+
it "should delegate to the controller" do
|
91
|
+
controller = stub :controller
|
92
|
+
view_model = ViewModels::Base.new nil, controller
|
93
|
+
|
94
|
+
controller.should_receive(:logger).once
|
95
|
+
|
96
|
+
in_the view_model do
|
97
|
+
logger
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require 'spec'
|
4
|
+
|
5
|
+
require 'active_support'
|
6
|
+
require 'action_controller'
|
7
|
+
|
8
|
+
$:.unshift File.dirname(__FILE__)
|
9
|
+
$:.unshift File.join(File.dirname(__FILE__), '../lib')
|
10
|
+
|
11
|
+
require File.join(File.dirname(__FILE__), '../init')
|
12
|
+
|
13
|
+
require 'spec_helper_extensions'
|
14
|
+
include SpecHelperExtensions
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module SpecHelperExtensions
|
2
|
+
|
3
|
+
# Used to test private methods.
|
4
|
+
#
|
5
|
+
# The idea is to replace instance.send :private_method.
|
6
|
+
# Now it is rather like:
|
7
|
+
# We have the scenario we are in the given instance.
|
8
|
+
#
|
9
|
+
def in_the(instance, &block)
|
10
|
+
instance.instance_eval(&block)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: view_models
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 5
|
8
|
+
- 2
|
9
|
+
version: 1.5.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Florian Hanke
|
13
|
+
- Kaspar Schiess
|
14
|
+
- Niko Dittmann
|
15
|
+
- Andreas Schacke
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2010-03-01 00:00:00 +01:00
|
21
|
+
default_executable:
|
22
|
+
dependencies: []
|
23
|
+
|
24
|
+
description: "The view models gem adds the missing R (Representation) to Rails' MVC. It provides simple proxy functionality for your models and thus helps you keep the model and view representations of a model separate, as it should be. Also, you can define helper methods on the (view) model instead of globally to keep them focused, more quickly understood and more easily testable. View Models also introduce hierarchical rendering for your hierarchical models. If the account view is not defined for the subclass FemaleUser, it checks if it is defined for User, for example, to see when there is no specific view, if there is a general view. So, in other words: Polymorphism not just in the model, but also in the view."
|
25
|
+
email: florian.hanke@gmail.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.textile
|
32
|
+
files:
|
33
|
+
- CHANGELOG
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.textile
|
36
|
+
- Rakefile
|
37
|
+
- VERSION.yml
|
38
|
+
- generators/view_models/USAGE
|
39
|
+
- generators/view_models/templates/README
|
40
|
+
- generators/view_models/templates/spec/view_model_spec.rb
|
41
|
+
- generators/view_models/templates/view_models/view_model.rb
|
42
|
+
- generators/view_models/templates/views/_empty.html.haml
|
43
|
+
- generators/view_models/templates/views/view_models/collection/_collection.html.erb
|
44
|
+
- generators/view_models/templates/views/view_models/collection/_collection.html.haml
|
45
|
+
- generators/view_models/templates/views/view_models/collection/_collection.text.erb
|
46
|
+
- generators/view_models/templates/views/view_models/collection/_list.html.erb
|
47
|
+
- generators/view_models/templates/views/view_models/collection/_list.html.haml
|
48
|
+
- generators/view_models/templates/views/view_models/collection/_list.text.erb
|
49
|
+
- generators/view_models/templates/views/view_models/collection/_pagination.html.haml
|
50
|
+
- generators/view_models/templates/views/view_models/collection/_pagination.text.erb
|
51
|
+
- generators/view_models/templates/views/view_models/collection/_table.html.haml
|
52
|
+
- generators/view_models/templates/views/view_models/collection/_table.text.erb
|
53
|
+
- generators/view_models/view_models_generator.rb
|
54
|
+
- lib/extensions/active_record.rb
|
55
|
+
- lib/extensions/model_reader.rb
|
56
|
+
- lib/extensions/view.rb
|
57
|
+
- lib/helpers/collection.rb
|
58
|
+
- lib/helpers/rails.rb
|
59
|
+
- lib/helpers/view.rb
|
60
|
+
- lib/view_models.rb
|
61
|
+
- lib/view_models/base.rb
|
62
|
+
- lib/view_models/controller_extractor.rb
|
63
|
+
- lib/view_models/path_store.rb
|
64
|
+
- lib/view_models/render_options.rb
|
65
|
+
- lib/view_models/view.rb
|
66
|
+
- rails/init.rb
|
67
|
+
- spec/integration/integration_spec.rb
|
68
|
+
- spec/integration/models/sub_subclass.rb
|
69
|
+
- spec/integration/models/subclass.rb
|
70
|
+
- spec/integration/view_models/project.rb
|
71
|
+
- spec/integration/view_models/sub_subclass.rb
|
72
|
+
- spec/integration/view_models/subclass.rb
|
73
|
+
- spec/integration/views/view_models/collection/_collection.html.erb
|
74
|
+
- spec/integration/views/view_models/collection/_collection.text.erb
|
75
|
+
- spec/integration/views/view_models/collection/_list.html.erb
|
76
|
+
- spec/integration/views/view_models/collection/_list.text.erb
|
77
|
+
- spec/integration/views/view_models/sub_subclass/_capture_in_template.erb
|
78
|
+
- spec/integration/views/view_models/sub_subclass/_capture_in_view_model.erb
|
79
|
+
- spec/integration/views/view_models/sub_subclass/_collection_example.html.erb
|
80
|
+
- spec/integration/views/view_models/sub_subclass/_collection_example.text.erb
|
81
|
+
- spec/integration/views/view_models/sub_subclass/_collection_item.html.erb
|
82
|
+
- spec/integration/views/view_models/sub_subclass/_collection_item.text.erb
|
83
|
+
- spec/integration/views/view_models/sub_subclass/_exists.erb
|
84
|
+
- spec/integration/views/view_models/sub_subclass/_exists.html.erb
|
85
|
+
- spec/integration/views/view_models/sub_subclass/_exists.text.erb
|
86
|
+
- spec/integration/views/view_models/sub_subclass/_exists_in_both.erb
|
87
|
+
- spec/integration/views/view_models/sub_subclass/_inner.also_explicit.erb
|
88
|
+
- spec/integration/views/view_models/sub_subclass/_inner.nesting.erb
|
89
|
+
- spec/integration/views/view_models/sub_subclass/_list_example.html.erb
|
90
|
+
- spec/integration/views/view_models/sub_subclass/_list_example.text.erb
|
91
|
+
- spec/integration/views/view_models/sub_subclass/_list_item.html.erb
|
92
|
+
- spec/integration/views/view_models/sub_subclass/_list_item.text.erb
|
93
|
+
- spec/integration/views/view_models/sub_subclass/_outer.explicit.erb
|
94
|
+
- spec/integration/views/view_models/sub_subclass/_outer.nesting.erb
|
95
|
+
- spec/integration/views/view_models/sub_subclass/_part_that_is_dependent_on_the_view_model.erb
|
96
|
+
- spec/integration/views/view_models/sub_subclass/show.html.erb
|
97
|
+
- spec/integration/views/view_models/sub_subclass/show.text.erb
|
98
|
+
- spec/integration/views/view_models/subclass/_exists_in_both.erb
|
99
|
+
- spec/integration/views/view_models/subclass/_no_sub_subclass.erb
|
100
|
+
- spec/integration/views/view_models/subclass/_not_found_in_sub_subclass.erb
|
101
|
+
- spec/lib/extensions/active_record_spec.rb
|
102
|
+
- spec/lib/extensions/model_reader_spec.rb
|
103
|
+
- spec/lib/helpers/collection_spec.rb
|
104
|
+
- spec/lib/helpers/rails_spec.rb
|
105
|
+
- spec/lib/helpers/view_spec.rb
|
106
|
+
- spec/lib/view_models/base_spec.rb
|
107
|
+
- spec/lib/view_models/view_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
- spec/spec_helper_extensions.rb
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: http://floere.github.com/view_models
|
112
|
+
licenses: []
|
113
|
+
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options:
|
116
|
+
- --inline-source
|
117
|
+
- --charset=UTF-8
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
requirements: []
|
135
|
+
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 1.3.6
|
138
|
+
signing_key:
|
139
|
+
specification_version: 3
|
140
|
+
summary: A model proxy for Rails views. Helps you keep the representation of a model and the model itself separate.
|
141
|
+
test_files:
|
142
|
+
- spec/integration/integration_spec.rb
|
143
|
+
- spec/integration/models/sub_subclass.rb
|
144
|
+
- spec/integration/models/subclass.rb
|
145
|
+
- spec/integration/view_models/project.rb
|
146
|
+
- spec/integration/view_models/sub_subclass.rb
|
147
|
+
- spec/integration/view_models/subclass.rb
|
148
|
+
- spec/lib/extensions/active_record_spec.rb
|
149
|
+
- spec/lib/extensions/model_reader_spec.rb
|
150
|
+
- spec/lib/helpers/collection_spec.rb
|
151
|
+
- spec/lib/helpers/rails_spec.rb
|
152
|
+
- spec/lib/helpers/view_spec.rb
|
153
|
+
- spec/lib/view_models/base_spec.rb
|
154
|
+
- spec/lib/view_models/view_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- spec/spec_helper_extensions.rb
|