view_mapper 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.rdoc +3 -1
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/lib/view_mapper/belongs_to_parent_models.rb +130 -0
  5. data/lib/view_mapper/model_info.rb +2 -6
  6. data/lib/view_mapper/views/auto_complete/auto_complete_view.rb +2 -1
  7. data/lib/view_mapper/views/belongs_to/belongs_to_view.rb +1 -86
  8. data/lib/view_mapper/views/belongs_to/templates/{model.rb → model.erb} +2 -2
  9. data/lib/view_mapper/views/belongs_to/templates/view_form.html.erb +1 -1
  10. data/lib/view_mapper/views/belongs_to/templates/view_index.html.erb +1 -1
  11. data/lib/view_mapper/views/belongs_to/templates/view_show.html.erb +1 -1
  12. data/lib/view_mapper/views/belongs_to_auto_complete/belongs_to_auto_complete_view.rb +60 -0
  13. data/lib/view_mapper/views/belongs_to_auto_complete/templates/controller.rb +90 -0
  14. data/lib/view_mapper/views/belongs_to_auto_complete/templates/layout.html.erb +18 -0
  15. data/lib/view_mapper/views/belongs_to_auto_complete/templates/migration.rb +19 -0
  16. data/lib/view_mapper/views/belongs_to_auto_complete/templates/model.erb +16 -0
  17. data/lib/view_mapper/views/belongs_to_auto_complete/templates/view_edit.html.erb +11 -0
  18. data/lib/view_mapper/views/belongs_to_auto_complete/templates/view_form.html.erb +13 -0
  19. data/lib/view_mapper/views/belongs_to_auto_complete/templates/view_index.html.erb +30 -0
  20. data/lib/view_mapper/views/belongs_to_auto_complete/templates/view_new.html.erb +10 -0
  21. data/lib/view_mapper/views/belongs_to_auto_complete/templates/view_show.html.erb +16 -0
  22. data/lib/view_mapper/views/paperclip/paperclip_view.rb +2 -1
  23. data/lib/view_mapper.rb +2 -0
  24. data/test/test_helper.rb +29 -7
  25. data/test/views/auto_complete/auto_complete_test.rb +1 -1
  26. data/test/views/belongs_to/belongs_to_test.rb +13 -10
  27. data/test/views/belongs_to/expected_templates/_form.html.erb +1 -1
  28. data/test/views/belongs_to/expected_templates/index.html.erb +1 -1
  29. data/test/views/belongs_to/expected_templates/show.html.erb +1 -1
  30. data/test/views/belongs_to/expected_templates/some_other_model.rb +2 -2
  31. data/test/views/belongs_to_auto_complete/belongs_to_auto_complete_test.rb +489 -0
  32. data/test/views/belongs_to_auto_complete/expected_templates/_form.html.erb +13 -0
  33. data/test/views/belongs_to_auto_complete/expected_templates/create_some_other_models.rb +18 -0
  34. data/test/views/belongs_to_auto_complete/expected_templates/edit.html.erb +11 -0
  35. data/test/views/belongs_to_auto_complete/expected_templates/expected_routes.rb +47 -0
  36. data/test/views/belongs_to_auto_complete/expected_templates/index.html.erb +24 -0
  37. data/test/views/belongs_to_auto_complete/expected_templates/new.html.erb +10 -0
  38. data/test/views/belongs_to_auto_complete/expected_templates/show.html.erb +17 -0
  39. data/test/views/belongs_to_auto_complete/expected_templates/some_other_model.rb +16 -0
  40. data/test/views/belongs_to_auto_complete/expected_templates/some_other_models.html.erb +18 -0
  41. data/test/views/belongs_to_auto_complete/expected_templates/some_other_models_controller.rb +89 -0
  42. data/test/views/belongs_to_auto_complete/expected_templates/standard_routes.rb +43 -0
  43. data/view_mapper.gemspec +35 -6
  44. metadata +33 -4
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>SomeOtherModels: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ <%= javascript_include_tag :defaults %>
10
+ </head>
11
+ <body>
12
+
13
+ <p style="color: green"><%= flash[:notice] %></p>
14
+
15
+ <%= yield %>
16
+
17
+ </body>
18
+ </html>
@@ -0,0 +1,89 @@
1
+ class SomeOtherModelsController < ApplicationController
2
+
3
+ auto_complete_for :parent, :name
4
+ auto_complete_for :second_parent, :other_field
5
+
6
+ # GET /some_other_models
7
+ # GET /some_other_models.xml
8
+ def index
9
+ @some_other_models = SomeOtherModel.all
10
+
11
+ respond_to do |format|
12
+ format.html # index.html.erb
13
+ format.xml { render :xml => @some_other_models }
14
+ end
15
+ end
16
+
17
+ # GET /some_other_models/1
18
+ # GET /some_other_models/1.xml
19
+ def show
20
+ @some_other_model = SomeOtherModel.find(params[:id])
21
+
22
+ respond_to do |format|
23
+ format.html # show.html.erb
24
+ format.xml { render :xml => @some_other_model }
25
+ end
26
+ end
27
+
28
+ # GET /some_other_models/new
29
+ # GET /some_other_models/new.xml
30
+ def new
31
+ @some_other_model = SomeOtherModel.new
32
+
33
+ respond_to do |format|
34
+ format.html # new.html.erb
35
+ format.xml { render :xml => @some_other_model }
36
+ end
37
+ end
38
+
39
+ # GET /some_other_models/1/edit
40
+ def edit
41
+ @some_other_model = SomeOtherModel.find(params[:id])
42
+ end
43
+
44
+ # POST /some_other_models
45
+ # POST /some_other_models.xml
46
+ def create
47
+ @some_other_model = SomeOtherModel.new(params[:some_other_model])
48
+
49
+ respond_to do |format|
50
+ if @some_other_model.save
51
+ flash[:notice] = 'SomeOtherModel was successfully created.'
52
+ format.html { redirect_to(@some_other_model) }
53
+ format.xml { render :xml => @some_other_model, :status => :created, :location => @some_other_model }
54
+ else
55
+ format.html { render :action => "new" }
56
+ format.xml { render :xml => @some_other_model.errors, :status => :unprocessable_entity }
57
+ end
58
+ end
59
+ end
60
+
61
+ # PUT /some_other_models/1
62
+ # PUT /some_other_models/1.xml
63
+ def update
64
+ @some_other_model = SomeOtherModel.find(params[:id])
65
+
66
+ respond_to do |format|
67
+ if @some_other_model.update_attributes(params[:some_other_model])
68
+ flash[:notice] = 'SomeOtherModel was successfully updated.'
69
+ format.html { redirect_to(@some_other_model) }
70
+ format.xml { head :ok }
71
+ else
72
+ format.html { render :action => "edit" }
73
+ format.xml { render :xml => @some_other_model.errors, :status => :unprocessable_entity }
74
+ end
75
+ end
76
+ end
77
+
78
+ # DELETE /some_other_models/1
79
+ # DELETE /some_other_models/1.xml
80
+ def destroy
81
+ @some_other_model = SomeOtherModel.find(params[:id])
82
+ @some_other_model.destroy
83
+
84
+ respond_to do |format|
85
+ format.html { redirect_to(some_other_models_url) }
86
+ format.xml { head :ok }
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,43 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+
4
+ # Sample of regular route:
5
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6
+ # Keep in mind you can assign values other than :controller and :action
7
+
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
12
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
13
+ # map.resources :products
14
+
15
+ # Sample resource route with options:
16
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17
+
18
+ # Sample resource route with sub-resources:
19
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20
+
21
+ # Sample resource route with more complex sub-resources
22
+ # map.resources :products do |products|
23
+ # products.resources :comments
24
+ # products.resources :sales, :collection => { :recent => :get }
25
+ # end
26
+
27
+ # Sample resource route within a namespace:
28
+ # map.namespace :admin do |admin|
29
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30
+ # admin.resources :products
31
+ # end
32
+
33
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34
+ # map.root :controller => "welcome"
35
+
36
+ # See how all your routes lay out with "rake routes"
37
+
38
+ # Install the default routes as the lowest priority.
39
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
40
+ # consider removing the them or commenting them out if you're using named routes and resources.
41
+ map.connect ':controller/:action/:id'
42
+ map.connect ':controller/:action/:id.:format'
43
+ end
data/view_mapper.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{view_mapper}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pat Shaughnessy"]
12
- s.date = %q{2010-01-22}
12
+ s.date = %q{2010-02-11}
13
13
  s.description = %q{View_mapper will generate scaffolding for new or existing models, customized for the plugins you use in your app.}
14
14
  s.email = %q{pat@patshaughnessy.net}
15
15
  s.extra_rdoc_files = [
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "generators/view_for/USAGE",
29
29
  "generators/view_for/view_for_generator.rb",
30
30
  "lib/view_mapper.rb",
31
+ "lib/view_mapper/belongs_to_parent_models.rb",
31
32
  "lib/view_mapper/editable_manifest.rb",
32
33
  "lib/view_mapper/has_many_child_models.rb",
33
34
  "lib/view_mapper/model_info.rb",
@@ -40,12 +41,22 @@ Gem::Specification.new do |s|
40
41
  "lib/view_mapper/views/auto_complete/templates/view_new.html.erb",
41
42
  "lib/view_mapper/views/belongs_to/belongs_to_view.rb",
42
43
  "lib/view_mapper/views/belongs_to/templates/migration.rb",
43
- "lib/view_mapper/views/belongs_to/templates/model.rb",
44
+ "lib/view_mapper/views/belongs_to/templates/model.erb",
44
45
  "lib/view_mapper/views/belongs_to/templates/view_edit.html.erb",
45
46
  "lib/view_mapper/views/belongs_to/templates/view_form.html.erb",
46
47
  "lib/view_mapper/views/belongs_to/templates/view_index.html.erb",
47
48
  "lib/view_mapper/views/belongs_to/templates/view_new.html.erb",
48
49
  "lib/view_mapper/views/belongs_to/templates/view_show.html.erb",
50
+ "lib/view_mapper/views/belongs_to_auto_complete/belongs_to_auto_complete_view.rb",
51
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/controller.rb",
52
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/layout.html.erb",
53
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/migration.rb",
54
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/model.erb",
55
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/view_edit.html.erb",
56
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/view_form.html.erb",
57
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/view_index.html.erb",
58
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/view_new.html.erb",
59
+ "lib/view_mapper/views/belongs_to_auto_complete/templates/view_show.html.erb",
49
60
  "lib/view_mapper/views/has_many/has_many_view.rb",
50
61
  "lib/view_mapper/views/has_many/templates/helper.rb",
51
62
  "lib/view_mapper/views/has_many/templates/layout.html.erb",
@@ -91,6 +102,18 @@ Gem::Specification.new do |s|
91
102
  "test/views/belongs_to/expected_templates/new.html.erb",
92
103
  "test/views/belongs_to/expected_templates/show.html.erb",
93
104
  "test/views/belongs_to/expected_templates/some_other_model.rb",
105
+ "test/views/belongs_to_auto_complete/belongs_to_auto_complete_test.rb",
106
+ "test/views/belongs_to_auto_complete/expected_templates/_form.html.erb",
107
+ "test/views/belongs_to_auto_complete/expected_templates/create_some_other_models.rb",
108
+ "test/views/belongs_to_auto_complete/expected_templates/edit.html.erb",
109
+ "test/views/belongs_to_auto_complete/expected_templates/expected_routes.rb",
110
+ "test/views/belongs_to_auto_complete/expected_templates/index.html.erb",
111
+ "test/views/belongs_to_auto_complete/expected_templates/new.html.erb",
112
+ "test/views/belongs_to_auto_complete/expected_templates/show.html.erb",
113
+ "test/views/belongs_to_auto_complete/expected_templates/some_other_model.rb",
114
+ "test/views/belongs_to_auto_complete/expected_templates/some_other_models.html.erb",
115
+ "test/views/belongs_to_auto_complete/expected_templates/some_other_models_controller.rb",
116
+ "test/views/belongs_to_auto_complete/expected_templates/standard_routes.rb",
94
117
  "test/views/fake/fake_view.rb",
95
118
  "test/views/fake/templates/fake_template1.html.erb",
96
119
  "test/views/has_many/expected_templates/_form.html.erb",
@@ -132,6 +155,12 @@ Gem::Specification.new do |s|
132
155
  "test/views/belongs_to/belongs_to_test.rb",
133
156
  "test/views/belongs_to/expected_templates/create_some_other_models.rb",
134
157
  "test/views/belongs_to/expected_templates/some_other_model.rb",
158
+ "test/views/belongs_to_auto_complete/belongs_to_auto_complete_test.rb",
159
+ "test/views/belongs_to_auto_complete/expected_templates/create_some_other_models.rb",
160
+ "test/views/belongs_to_auto_complete/expected_templates/expected_routes.rb",
161
+ "test/views/belongs_to_auto_complete/expected_templates/some_other_model.rb",
162
+ "test/views/belongs_to_auto_complete/expected_templates/some_other_models_controller.rb",
163
+ "test/views/belongs_to_auto_complete/expected_templates/standard_routes.rb",
135
164
  "test/views/fake/fake_view.rb",
136
165
  "test/views/has_many/expected_templates/create_parents.rb",
137
166
  "test/views/has_many/expected_templates/parent.rb",
@@ -146,14 +175,14 @@ Gem::Specification.new do |s|
146
175
  s.specification_version = 3
147
176
 
148
177
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
149
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
178
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
150
179
  s.add_development_dependency(%q<mocha>, [">= 0"])
151
180
  else
152
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
181
+ s.add_dependency(%q<shoulda>, [">= 0"])
153
182
  s.add_dependency(%q<mocha>, [">= 0"])
154
183
  end
155
184
  else
156
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
185
+ s.add_dependency(%q<shoulda>, [">= 0"])
157
186
  s.add_dependency(%q<mocha>, [">= 0"])
158
187
  end
159
188
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Shaughnessy
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-22 00:00:00 -05:00
12
+ date: 2010-02-11 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: thoughtbot-shoulda
16
+ name: shoulda
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -53,6 +53,7 @@ files:
53
53
  - generators/view_for/USAGE
54
54
  - generators/view_for/view_for_generator.rb
55
55
  - lib/view_mapper.rb
56
+ - lib/view_mapper/belongs_to_parent_models.rb
56
57
  - lib/view_mapper/editable_manifest.rb
57
58
  - lib/view_mapper/has_many_child_models.rb
58
59
  - lib/view_mapper/model_info.rb
@@ -65,12 +66,22 @@ files:
65
66
  - lib/view_mapper/views/auto_complete/templates/view_new.html.erb
66
67
  - lib/view_mapper/views/belongs_to/belongs_to_view.rb
67
68
  - lib/view_mapper/views/belongs_to/templates/migration.rb
68
- - lib/view_mapper/views/belongs_to/templates/model.rb
69
+ - lib/view_mapper/views/belongs_to/templates/model.erb
69
70
  - lib/view_mapper/views/belongs_to/templates/view_edit.html.erb
70
71
  - lib/view_mapper/views/belongs_to/templates/view_form.html.erb
71
72
  - lib/view_mapper/views/belongs_to/templates/view_index.html.erb
72
73
  - lib/view_mapper/views/belongs_to/templates/view_new.html.erb
73
74
  - lib/view_mapper/views/belongs_to/templates/view_show.html.erb
75
+ - lib/view_mapper/views/belongs_to_auto_complete/belongs_to_auto_complete_view.rb
76
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/controller.rb
77
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/layout.html.erb
78
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/migration.rb
79
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/model.erb
80
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/view_edit.html.erb
81
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/view_form.html.erb
82
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/view_index.html.erb
83
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/view_new.html.erb
84
+ - lib/view_mapper/views/belongs_to_auto_complete/templates/view_show.html.erb
74
85
  - lib/view_mapper/views/has_many/has_many_view.rb
75
86
  - lib/view_mapper/views/has_many/templates/helper.rb
76
87
  - lib/view_mapper/views/has_many/templates/layout.html.erb
@@ -116,6 +127,18 @@ files:
116
127
  - test/views/belongs_to/expected_templates/new.html.erb
117
128
  - test/views/belongs_to/expected_templates/show.html.erb
118
129
  - test/views/belongs_to/expected_templates/some_other_model.rb
130
+ - test/views/belongs_to_auto_complete/belongs_to_auto_complete_test.rb
131
+ - test/views/belongs_to_auto_complete/expected_templates/_form.html.erb
132
+ - test/views/belongs_to_auto_complete/expected_templates/create_some_other_models.rb
133
+ - test/views/belongs_to_auto_complete/expected_templates/edit.html.erb
134
+ - test/views/belongs_to_auto_complete/expected_templates/expected_routes.rb
135
+ - test/views/belongs_to_auto_complete/expected_templates/index.html.erb
136
+ - test/views/belongs_to_auto_complete/expected_templates/new.html.erb
137
+ - test/views/belongs_to_auto_complete/expected_templates/show.html.erb
138
+ - test/views/belongs_to_auto_complete/expected_templates/some_other_model.rb
139
+ - test/views/belongs_to_auto_complete/expected_templates/some_other_models.html.erb
140
+ - test/views/belongs_to_auto_complete/expected_templates/some_other_models_controller.rb
141
+ - test/views/belongs_to_auto_complete/expected_templates/standard_routes.rb
119
142
  - test/views/fake/fake_view.rb
120
143
  - test/views/fake/templates/fake_template1.html.erb
121
144
  - test/views/has_many/expected_templates/_form.html.erb
@@ -179,6 +202,12 @@ test_files:
179
202
  - test/views/belongs_to/belongs_to_test.rb
180
203
  - test/views/belongs_to/expected_templates/create_some_other_models.rb
181
204
  - test/views/belongs_to/expected_templates/some_other_model.rb
205
+ - test/views/belongs_to_auto_complete/belongs_to_auto_complete_test.rb
206
+ - test/views/belongs_to_auto_complete/expected_templates/create_some_other_models.rb
207
+ - test/views/belongs_to_auto_complete/expected_templates/expected_routes.rb
208
+ - test/views/belongs_to_auto_complete/expected_templates/some_other_model.rb
209
+ - test/views/belongs_to_auto_complete/expected_templates/some_other_models_controller.rb
210
+ - test/views/belongs_to_auto_complete/expected_templates/standard_routes.rb
182
211
  - test/views/fake/fake_view.rb
183
212
  - test/views/has_many/expected_templates/create_parents.rb
184
213
  - test/views/has_many/expected_templates/parent.rb