view_models 1.5.7 → 2.0.0.ruby19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. data/lib/init.rb +1 -0
  2. data/lib/padrino/README.textile +3 -0
  3. data/lib/padrino/init.rb +10 -0
  4. data/lib/padrino/lib/helpers/collection.rb +27 -0
  5. data/lib/padrino/lib/padrino/view_models.rb +19 -0
  6. data/lib/padrino/lib/view_models/base.rb +65 -0
  7. data/lib/rails2/README.textile +3 -0
  8. data/{TODO.textile → lib/rails2/TODO.textile} +0 -0
  9. data/{generators → lib/rails2/generators}/view_models/USAGE +0 -0
  10. data/{generators → lib/rails2/generators}/view_models/templates/README +0 -0
  11. data/{generators → lib/rails2/generators}/view_models/templates/spec/view_model_spec.rb +0 -0
  12. data/{generators → lib/rails2/generators}/view_models/templates/view_models/view_model.rb +0 -0
  13. data/{generators → lib/rails2/generators}/view_models/templates/views/_empty.html.haml +0 -0
  14. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_collection.html.erb +0 -0
  15. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_collection.html.haml +0 -0
  16. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_collection.text.erb +0 -0
  17. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_list.html.erb +0 -0
  18. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_list.text.erb +0 -0
  19. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_pagination.html.haml +0 -0
  20. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_pagination.text.erb +0 -0
  21. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_table.html.haml +0 -0
  22. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_table.text.erb +0 -0
  23. data/{generators → lib/rails2/generators}/view_models/view_models_generator.rb +0 -0
  24. data/lib/rails2/init.rb +18 -0
  25. data/lib/{experimental → rails2/lib/experimental}/modules_in_render_hierarchy.rb +0 -0
  26. data/lib/{extensions → rails2/lib/extensions}/view.rb +0 -0
  27. data/lib/rails2/lib/helpers/collection.rb +27 -0
  28. data/lib/{helpers → rails2/lib/helpers}/view.rb +0 -0
  29. data/lib/rails2/lib/view_models.rb +1 -0
  30. data/lib/rails2/lib/view_models/base.rb +99 -0
  31. data/lib/{view_models → rails2/lib/view_models}/view.rb +5 -1
  32. data/lib/shared/README.textile +3 -0
  33. data/lib/shared/init.rb +11 -0
  34. data/lib/shared/lib/view_models.rb +4 -0
  35. data/lib/{view_models → shared/lib/view_models}/base.rb +46 -91
  36. data/lib/{view_models/controller_extractor.rb → shared/lib/view_models/context_extractor.rb} +4 -2
  37. data/lib/{extensions → shared/lib/view_models/extensions}/active_record.rb +2 -0
  38. data/lib/{extensions → shared/lib/view_models/extensions}/model_reader.rb +1 -1
  39. data/lib/{helpers → shared/lib/view_models/helpers}/collection.rb +1 -13
  40. data/lib/{helpers/rails.rb → shared/lib/view_models/helpers/mapping.rb} +5 -1
  41. data/lib/{view_models → shared/lib/view_models}/path_store.rb +0 -0
  42. data/lib/{view_models → shared/lib/view_models}/render_options.rb +4 -0
  43. data/lib/view_models.rb +5 -3
  44. metadata +60 -109
  45. data/CHANGELOG +0 -26
  46. data/MIT-LICENSE +0 -20
  47. data/README.textile +0 -40
  48. data/Rakefile +0 -49
  49. data/VERSION.yml +0 -4
  50. data/generators/view_models/templates/views/view_models/collection/_list.html.haml +0 -7
  51. data/lib/experimental/README.textile +0 -32
  52. data/rails/init.rb +0 -18
  53. data/spec/integration/integration_spec.rb +0 -281
  54. data/spec/integration/models/sub_subclass.rb +0 -14
  55. data/spec/integration/models/subclass.rb +0 -3
  56. data/spec/integration/view_models/module_for_rendering.rb +0 -7
  57. data/spec/integration/view_models/project.rb +0 -14
  58. data/spec/integration/view_models/sub_subclass.rb +0 -42
  59. data/spec/integration/view_models/subclass.rb +0 -1
  60. data/spec/integration/views/view_models/collection/_collection.html.erb +0 -1
  61. data/spec/integration/views/view_models/collection/_collection.text.erb +0 -6
  62. data/spec/integration/views/view_models/collection/_list.html.erb +0 -1
  63. data/spec/integration/views/view_models/collection/_list.text.erb +0 -6
  64. data/spec/integration/views/view_models/module_for_rendering/_not_found_in_sub_subclass_but_in_module.erb +0 -1
  65. data/spec/integration/views/view_models/sub_subclass/_capture_in_template.erb +0 -2
  66. data/spec/integration/views/view_models/sub_subclass/_capture_in_view_model.erb +0 -3
  67. data/spec/integration/views/view_models/sub_subclass/_collection_example.html.erb +0 -3
  68. data/spec/integration/views/view_models/sub_subclass/_collection_example.text.erb +0 -3
  69. data/spec/integration/views/view_models/sub_subclass/_collection_item.html.erb +0 -1
  70. data/spec/integration/views/view_models/sub_subclass/_collection_item.text.erb +0 -1
  71. data/spec/integration/views/view_models/sub_subclass/_exists.erb +0 -1
  72. data/spec/integration/views/view_models/sub_subclass/_exists.html.erb +0 -1
  73. data/spec/integration/views/view_models/sub_subclass/_exists.text.erb +0 -1
  74. data/spec/integration/views/view_models/sub_subclass/_exists_in_both.erb +0 -1
  75. data/spec/integration/views/view_models/sub_subclass/_inner.also_explicit.erb +0 -1
  76. data/spec/integration/views/view_models/sub_subclass/_inner.nesting.erb +0 -1
  77. data/spec/integration/views/view_models/sub_subclass/_list_example.html.erb +0 -3
  78. data/spec/integration/views/view_models/sub_subclass/_list_example.text.erb +0 -3
  79. data/spec/integration/views/view_models/sub_subclass/_list_item.html.erb +0 -1
  80. data/spec/integration/views/view_models/sub_subclass/_list_item.text.erb +0 -1
  81. data/spec/integration/views/view_models/sub_subclass/_outer.explicit.erb +0 -1
  82. data/spec/integration/views/view_models/sub_subclass/_outer.nesting.erb +0 -1
  83. data/spec/integration/views/view_models/sub_subclass/_part_that_is_dependent_on_the_view_model.erb +0 -1
  84. data/spec/integration/views/view_models/sub_subclass/show.html.erb +0 -1
  85. data/spec/integration/views/view_models/sub_subclass/show.text.erb +0 -1
  86. data/spec/integration/views/view_models/subclass/_exists_in_both.erb +0 -1
  87. data/spec/integration/views/view_models/subclass/_no_sub_subclass.erb +0 -1
  88. data/spec/integration/views/view_models/subclass/_not_found_in_sub_subclass.erb +0 -1
  89. data/spec/lib/extensions/active_record_spec.rb +0 -31
  90. data/spec/lib/extensions/model_reader_spec.rb +0 -93
  91. data/spec/lib/helpers/collection_spec.rb +0 -196
  92. data/spec/lib/helpers/rails_spec.rb +0 -84
  93. data/spec/lib/helpers/view_spec.rb +0 -20
  94. data/spec/lib/view_models/base_spec.rb +0 -102
  95. data/spec/lib/view_models/view_spec.rb +0 -9
  96. data/spec/spec_helper.rb +0 -14
  97. data/spec/spec_helper_extensions.rb +0 -13
@@ -1,20 +0,0 @@
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
@@ -1,102 +0,0 @@
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
@@ -1,9 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
-
3
- require 'view_models/view'
4
-
5
- describe ViewModels::View do
6
-
7
-
8
-
9
- end
data/spec/spec_helper.rb DELETED
@@ -1,14 +0,0 @@
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
@@ -1,13 +0,0 @@
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