emmanuel-inherited_resources 0.9.1

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.
data/CHANGELOG ADDED
@@ -0,0 +1,95 @@
1
+ # Version 0.8
2
+
3
+ * Fixed a small bug on optional belongs to with namespaced controllers.
4
+ * Allow a parameter to be given to collection_url in polymorphic cases to replace
5
+ the parent.
6
+ * Allow InheritedResources to be called without inheritance.
7
+ * Ensure that controllers that inherit from a controller with InheritedResources
8
+ works properly.
9
+
10
+ # Version 0.7
11
+
12
+ * Allow procs as default value in has scope to be able to use values from session, for example.
13
+ * Allow blocks with arity 0 or -1 to be given as the redirect url:
14
+
15
+ def destroy
16
+ destroy!{ project_url(@project) }
17
+ end
18
+
19
+ * Allow interpolation_options to be set in the application controller.
20
+ * Added has_scope to controller (an interface for named_scopes).
21
+ * Added polymorphic_belongs_to, optional_belongs_to and singleton_belongs_to
22
+ as quick methods.
23
+ * Only load belongs_to, singleton and polymorphic helpers if they are actually
24
+ required. base_helpers, class_methods, dumb_responder and url_helpers are loaded
25
+ when you inherited from base for the first time.
26
+
27
+ # Version 0.6
28
+
29
+ * Ensure that the default template is not rendered if the default_template_format
30
+ is not accepted. This is somehow related with the security breach report:
31
+
32
+ http://www.rorsecurity.info/journal/2009/4/24/hidden-actions-render-templates.html
33
+
34
+ IR forbids based on mime types. For example: respond_to :html, :except => :index
35
+ ensures that the index.html.erb view is not rendered, making your IR controllers
36
+ safer.
37
+
38
+ * Fixed a bug that happens only when format.xml is given to blocks and then it
39
+ acts as default, instead of format.html.
40
+ * Fixed a strange bug where when you have create.html.erb or update.html.erb,
41
+ it makes IE6 and IE7 return unprocessable entity (because they send Mime::ALL).
42
+ * Stop rescueing any error when constantizing the resource class and allow
43
+ route_prefix to be nil.
44
+ * Cleaned up tests and responder structure. Whenever you pass a block to aliases
45
+ and this block responds to the request, the other blocks are not parsed improving performance.
46
+ * [BACKWARDS INCOMPATIBLE] By default, Inherited Resources respond only :html requests.
47
+ * Added a quick way to overwrite the redirect to url in :create, :update and :destroy.
48
+
49
+ # Version 0.5
50
+
51
+ * Decoupled routes name from :instance_name and :collection_name. This way we
52
+ have more flexibility. Use route_instance_name and route_collection_name to
53
+ to change routes.
54
+ * Avoid calling human_name on nil when a resource class is not defined.
55
+ * Only call I18n if it's defined.
56
+
57
+ # Version 0.4
58
+
59
+ * Dealing with namespaced controllers out of the box.
60
+ * Added support to namespaced routes through :route_prefix.
61
+ * Added fix when resource_url is not defined.
62
+ * Added better handling for namespaced controllers.
63
+ * Added flash messages scoped by namespaced controllers.
64
+ * Deprecated {{resource}} in I18n, use {{resource_name}} instead.
65
+ * rspec bug fix is not automatically required anymore. User has to do it
66
+ explicitly.
67
+ * Added a file which fix a rspec bug when render is called inside a method
68
+ which receives a block.
69
+ * parent? does not take begin_of_association_chain into account anymore
70
+ * Added options to url helpers.
71
+ * Added :optional to belongs_to associations. It allows you to deal with
72
+ categories/1/products/2 and /products/2 with just one controller.
73
+ * Cleaned up tests.
74
+
75
+ # Version 0.3
76
+
77
+ * Minor bump after three bug fixes.
78
+ * Bug fix when showing warning of constant redefinition.
79
+ * Bug fix with ApplicationController not being unloaded properly on development.
80
+ * Bug fix when having root singleton resources. Calling collection_url would
81
+ raise "NoMethodError _url", not it will call root_url.
82
+ * More comments on UrlHelpers.
83
+
84
+ # Version 0.2
85
+
86
+ * Bug fix when ApplicationController is already loaded when we load respond_to.
87
+ * Added support success/failure blocks.
88
+ * Eager loading of files to work properly in multithreaded environments.
89
+
90
+ # Version 0.1
91
+
92
+ * Added more helper_methods.
93
+ * Added Rails 2.3.0 and changed tests to work with ActionController::TestCase.
94
+ * First release. Support to I18n, singleton controllers, polymorphic
95
+ controllers, belongs_to, nested_belongs_to and url helpers.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 José Valim
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,528 @@
1
+ Inherited Resources
2
+ License: MIT
3
+ Version: 0.9.1
4
+
5
+ You can also read this README in pretty html at the GitHub project Wiki page:
6
+
7
+ http://wiki.github.com/josevalim/inherited_resources
8
+
9
+ Description
10
+ -----------
11
+
12
+ Inherited Resources speeds up development by making your controllers inherit
13
+ all restful actions so you just have to focus on what is important. It makes
14
+ your controllers more powerful and cleaner at the same time.
15
+
16
+ Plus, making your controllers follow a pattern, it helps you to write better
17
+ code by following fat models and skinny controllers convention.
18
+
19
+ Inherited Resources is tested and compatible with Rails 2.2.x and Rails 2.3.x.
20
+
21
+ keywords: resources, controller, singleton, belongs_to, polymorphic, named_scope and I18n
22
+
23
+ Installation
24
+ ------------
25
+
26
+ Install Inherited Resources is very easy. It is stored in GitHub, so just run
27
+ the following:
28
+
29
+ gem sources -a http://gems.github.com
30
+ sudo gem install josevalim-inherited_resources
31
+
32
+ If you want it as plugin, just do:
33
+
34
+ script/plugin install git://github.com/josevalim/inherited_resources.git
35
+
36
+ Basic Usage
37
+ -----------
38
+
39
+ To use Inherited Resources you just have to inherit (duh) it:
40
+
41
+ class ProjectsController < InheritedResources::Base
42
+ end
43
+
44
+ And all actions are defined and working, check it! Your projects collection
45
+ (in the index action) is still available in the instance variable @projects
46
+ and your project resource (all other actions) is available as @ project.
47
+
48
+ The next step is to define which mime types this controller provides:
49
+
50
+ class ProjectsController < InheritedResources::Base
51
+ respond_to :html, :xml, :json
52
+ end
53
+
54
+ You can also specify them based per action:
55
+
56
+ class ProjectsController < InheritedResources::Base
57
+ respond_to :html, :xml, :json
58
+ respond_to :js, :only => :create
59
+ respond_to :iphone, :except => [ :edit, :update ]
60
+ end
61
+
62
+ For each request, it first checkes if the "controller/action.format" file is
63
+ available (for example "projects/create.xml") and if it's not, it checks if
64
+ the resource respond to :to_format (in this case, :to_xml). Otherwise returns 404.
65
+
66
+ Another option is to specify which actions the controller will inherit from
67
+ the InheritedResources::Base:
68
+
69
+ class ProjectsController < InheritedResources::Base
70
+ actions :index, :show, :new, :create
71
+ end
72
+
73
+ Or:
74
+
75
+ class ProjectsController < InheritedResources::Base
76
+ actions :all, :except => [ :edit, :update, :destroy ]
77
+ end
78
+
79
+ In your views, you will get the following helpers:
80
+
81
+ resource #=> @project
82
+ collection #=> @projects
83
+ resource_class #=> Project
84
+
85
+ As you might expect, collection (@projects instance variable) is only available
86
+ on index actions.
87
+
88
+ If for some reason you cannot inherit from InheritedResources::Base, you can
89
+ call inherit_resources in your controller class scope:
90
+
91
+ class AccountsController < ApplicationController
92
+ inherit_resources
93
+ end
94
+
95
+ Overwriting defaults
96
+ --------------------
97
+
98
+ Whenever you inherit from InheritedResources, several defaults are assumed.
99
+ For example you can have an AccountsController to account management while the
100
+ resource is an User:
101
+
102
+ class AccountsController < InheritedResources::Base
103
+ defaults :resource_class => User, :collection_name => 'users', :instance_name => 'user'
104
+ end
105
+
106
+ In the case above, in your views you will have @users and @user variables, but
107
+ the routes used will still be accounts_url and account_url. If you plan also to
108
+ change the routes, you can use :route_collection_name and :route_instance_name.
109
+
110
+ Namespaced controllers work out of the box, but if you need to specify a
111
+ different route prefix, you can do the following:
112
+
113
+ class Administrators::PeopleController < InheritedResources::Base
114
+ defaults :route_prefix => 'admin'
115
+ end
116
+
117
+ Then your named routes will be: 'admin_people_url', 'admin_person_url' instead
118
+ of 'administrators_people_url' and 'administrators_person_url'.
119
+
120
+ If you want to customize how resources are retrieved you can overwrite
121
+ collection and resource methods. The first is called on index action and the
122
+ second on all other actions. Let's suppose you want to add pagination to your
123
+ projects collection:
124
+
125
+ class ProjectsController < InheritedResources::Base
126
+ protected
127
+ def collection
128
+ @projects ||= end_of_association_chain.paginate(params[:page]).all
129
+ end
130
+ end
131
+
132
+ The end_of_association_chain returns your resource after nesting all associations
133
+ and scopes (more about this below).
134
+
135
+ InheritedResources also introduces another method called begin_of_association_chain.
136
+ It's mostly used when you want to create resources based on the @current_user and
137
+ you have urls like "account/projects". In such cases, you have to do
138
+ @current_user.projects.find or @current_user.projects.build in your actions.
139
+
140
+ You can deal with it just doing:
141
+
142
+ class ProjectsController < InheritedResources::Base
143
+ protected
144
+ def begin_of_association_chain
145
+ @current_user
146
+ end
147
+ end
148
+
149
+ Overwriting actions
150
+ -------------------
151
+
152
+ Let's suppose that after destroying a project you want to redirect to your
153
+ root url instead of redirecting to projects url. You just have to do:
154
+
155
+ class ProjectsController < InheritedResources::Base
156
+ def destroy
157
+ super do |format|
158
+ format.html { redirect_to root_url }
159
+ end
160
+ end
161
+ end
162
+
163
+ You are opening your action and giving the parent action a new behavior. On
164
+ the other hand, I have to agree that calling super is not very readable. That's
165
+ why all methods have aliases. So this is equivalent:
166
+
167
+ class ProjectsController < InheritedResources::Base
168
+ def destroy
169
+ destroy! do |format|
170
+ format.html { redirect_to root_url }
171
+ end
172
+ end
173
+ end
174
+
175
+ Even more, since most of the times when you change a create, update or destroy
176
+ action is because you want to to change to where it redirects, a shortcut is
177
+ provided. So you can do:
178
+
179
+ class ProjectsController < InheritedResources::Base
180
+ def destroy
181
+ destroy!{ root_url }
182
+ end
183
+ end
184
+
185
+ Now let's suppose that before create a project you have to do something special
186
+ but you don't want to create a before filter for it:
187
+
188
+ class ProjectsController < InheritedResources::Base
189
+ def create
190
+ @project = Project.new(params[:project])
191
+ @project.something_special!
192
+ create!
193
+ end
194
+ end
195
+
196
+ Yes, that simple! The nice part is since you already set the instance variable
197
+ @project, it will not build a project again.
198
+
199
+ Before we finish this topic, we should talk about one more thing: "success/failure
200
+ blocks". Let's suppose that when we update our project, in case of failure, we
201
+ want to redirect to the project url instead of re-rendering the edit template.
202
+
203
+ Our first attempt to do this would be:
204
+
205
+ class ProjectsController < InheritedResources::Base
206
+ def update
207
+ update! do |format|
208
+ unless @project.errors.empty? # failure
209
+ format.html { redirect_to project_url(@project) }
210
+ end
211
+ end
212
+ end
213
+ end
214
+
215
+ Looks to verbose, right? We can actually do:
216
+
217
+ class ProjectsController < InheritedResources::Base
218
+ def update
219
+ update! do |success, failure|
220
+ failure.html { redirect_to project_url(@project) }
221
+ end
222
+ end
223
+ end
224
+
225
+ Much better! So explaining everything: when you give a block which expects one
226
+ argument it will be executed in both scenarios: success and failure. But If you
227
+ give a block that expects two arguments, the first will be executed only in
228
+ success scenarios and the second in failure scenarios. You keep everything
229
+ clean and organized inside the same action.
230
+
231
+ Some DSL
232
+ --------
233
+
234
+ For those DSL lovers, InheritedResources won't leave you alone. You can overwrite
235
+ your success/failure blocks straight from your class binding. For it, you just
236
+ need to add a DSL block to your application controller:
237
+
238
+ class ApplicationController < ActionController::Base
239
+ include InheritedResources::DSL
240
+ end
241
+
242
+ And then you can rewrite the last example as:
243
+
244
+ class ProjectsController < InheritedResources::Base
245
+ update! do |success, failure|
246
+ failure.html { redirect_to project_url(@project) }
247
+ end
248
+ end
249
+
250
+ Flash messages and I18n
251
+ -----------------------
252
+
253
+ Flash messages are powered by I18n api. It checks for messages in the following
254
+ order:
255
+
256
+ flash.controller_name.action_name.status
257
+ flash.actions.action_name.status
258
+
259
+ If none is available, a default message in english set. In a create action
260
+ on projects controller, it will search for:
261
+
262
+ flash.projects.create.status
263
+ flash.actions.create.status
264
+
265
+ The status can be :notice (when the object can be created, updated
266
+ or destroyed with success) or :error (when the objecy cannot be created
267
+ or updated).
268
+
269
+ Those messages are interpolated by using the resource class human name, which
270
+ is also localized and it means you can set:
271
+
272
+ flash:
273
+ actions:
274
+ create:
275
+ notice: "Hooray! {{resource_name}} was successfully created!"
276
+
277
+ It will replace {{resource_name}} by the human name of the resource class,
278
+ which is "Project" in this case.
279
+
280
+ But sometimes, flash messages are not that simple. Sometimes you want to say
281
+ the title of the project while updating a project. Well, that's easy also:
282
+
283
+ flash:
284
+ projects:
285
+ update:
286
+ notice: "Hooray! The project "{{project_title}}" was updated!"
287
+
288
+ Since :project_title is not available for interpolation by default, you have
289
+ to overwrite interpolation_options.
290
+
291
+ def interpolation_options
292
+ { :project_title => @project.title }
293
+ end
294
+
295
+ Then you will finally have:
296
+
297
+ "Hooray! The project "Plataforma" was updated!"
298
+
299
+ By default, resource name is capitalized. If you want to make it lower case, you
300
+ can add to your application controller:
301
+
302
+ def interpolation_options
303
+ { :resource_name => resource_class.human_name.downcase }
304
+ end
305
+
306
+ Finally, if your controller is namespaced, for example Admin::ProjectsController,
307
+ the messages will be checked in the following order:
308
+
309
+ flash.admin.projects.create.notice
310
+ flash.admin.actions.create.notice
311
+ flash.projects.create.notice
312
+ flash.actions.create.notice
313
+
314
+ Has Scope
315
+ ---------
316
+
317
+ InheritedResources tries to integrate nicely with your model. In order to do so,
318
+ it also is named_scope fluent. Let's suppose our Project model with the scopes:
319
+
320
+ class Project < ActiveRecord::Base
321
+ named_scope :featured, :conditions => { :featured => true }
322
+ named_scope :by_methodology, proc {|methodology| { :conditions => { :methodology => methodology } } }
323
+ named_scope :limit, proc{|limit| :limit => limit.to_i }
324
+ end
325
+
326
+ Your controller:
327
+
328
+ class ProjectsController < InheritedResources::Base
329
+ has_scope :featured, :boolean => true, :only => :index
330
+ has_scope :by_methodology
331
+ has_scope :limit, :default => 10
332
+ end
333
+
334
+ Then for each request:
335
+
336
+ /projects
337
+ #=> acts like a normal request, but returning 10 projects
338
+
339
+ /projects?featured=true
340
+ #=> calls the featured named scope and bring 10 featured projects
341
+
342
+ /projects?featured=true&by_methodology=agile&limit=20
343
+ #=> brings 20 featured projects with methodology agile
344
+
345
+ You can retrieve the current scopes in use with :current_scopes method.
346
+ In the last case, it would return:
347
+
348
+ { :featured => "true", :by_methodology => "agile", :limit => "20" }
349
+
350
+ Finally, let's suppose you store on the session how many projects the user sees
351
+ per page. In such cases, you can give a proc as default value:
352
+
353
+ has_scope :limit, :default => proc{|c| c.session[:limit] || 10 }
354
+
355
+ Belongs to
356
+ ----------
357
+
358
+ Finally, our Projects are going to get some Tasks. Then you create a
359
+ TasksController and do:
360
+
361
+ class TasksController < InheritedResources::Base
362
+ belongs_to :project
363
+ end
364
+
365
+ belongs_to accepts several options to be able to configure the association.
366
+ For example, if you want urls like /projects/:project_title/tasks, you can
367
+ customize how InheritedResources find your projects:
368
+
369
+ class TasksController < InheritedResources::Base
370
+ belongs_to :project, :finder => :find_by_title!, :param => :project_title
371
+ end
372
+
373
+ It also accepts :route_name, :parent_class and :instance_name as options.
374
+ Check the lib/inherited_resources/class_methods.rb for more.
375
+
376
+ Nested belongs to
377
+ -----------------
378
+
379
+ Now, our Tasks get some Comments and you need to nest even deeper. Good
380
+ practices says that you should never nest more than two resources, but sometimes
381
+ you have to for security reasons. So this is an example of how you can do it:
382
+
383
+ class CommentsController < InheritedResources::Base
384
+ nested_belongs_to :project, :task
385
+ end
386
+
387
+ If you need to configure any of these belongs to, you can nest them using blocks:
388
+
389
+ class CommentsController < InheritedResources::Base
390
+ belongs_to :project, :finder => :find_by_title!, :param => :project_title do
391
+ belongs_to :task
392
+ end
393
+ end
394
+
395
+ Warning: calling several belongs_to is the same as nesting them:
396
+
397
+ class CommentsConroller < InheritedResources::Base
398
+ belongs_to :project
399
+ belongs_to :task
400
+ end
401
+
402
+ In other words, the code above is the same as calling nested_belongs_to.
403
+
404
+ Polymorphic belongs to
405
+ ----------------------
406
+
407
+ We can go even further. Let's suppose our Projects can now have Files, Messages
408
+ and Tasks, and they are all commentable. In this case, the best solution is to
409
+ use polymorphism:
410
+
411
+ class CommentsController < InheritedResources::Base
412
+ belongs_to :task, :file, :message, :polymorphic => true
413
+ # polymorphic_belongs_to :task, :file, :message
414
+ end
415
+
416
+ You can even use it with nested resources:
417
+
418
+ class CommentsController < InheritedResources::Base
419
+ belongs_to :project do
420
+ belongs_to :task, :file, :message, :polymorphic => true
421
+ end
422
+ end
423
+
424
+ The url in such cases can be:
425
+
426
+ /project/1/task/13/comments
427
+ /project/1/file/11/comments
428
+ /project/1/message/9/comments
429
+
430
+ When using polymorphic associations, you get some free helpers:
431
+
432
+ parent? #=> true
433
+ parent_type #=> :task
434
+ parent_class #=> Task
435
+ parent #=> @task
436
+
437
+ Optional belongs to
438
+ -------------------
439
+
440
+ Later you decide to create a view to show all comments, independent if they belong
441
+ to a task, file or message. You can reuse your polymorphic controller just doing:
442
+
443
+ class ProjectsController < InheritedResources::Base
444
+ belongs_to :task, :file, :message, :optional => true
445
+ # optional_belongs_to :task, :file, :message
446
+ end
447
+
448
+ This will handle all those urls properly:
449
+
450
+ /comment/1
451
+ /tasks/2/comment/5
452
+ /files/10/comment/3
453
+ /messages/13/comment/11
454
+
455
+ This is treated as a special type of polymorphic associations, thus all helpers
456
+ are available. As you expect, when no parent is found, the helpers return:
457
+
458
+ parent? #=> false
459
+ parent_type #=> nil
460
+ parent_class #=> nil
461
+ parent #=> nil
462
+
463
+ Singletons
464
+ ----------
465
+
466
+ Now we are going to add manager to projects. We say that Manager is a singleton
467
+ resource because a Project has just one manager. You should declare it as
468
+ has_one (or resource) in your routes.
469
+
470
+ To declare an association as singleton, you just have to give the :singleton
471
+ option.
472
+
473
+ class ManagersController < InheritedResources::Base
474
+ belongs_to :project, :singleton => true
475
+ # singleton_belongs_to :project
476
+ end
477
+
478
+ It will deal with everything again and hide the action :index from you.
479
+
480
+ URL Helpers
481
+ -----------
482
+
483
+ When you use InheritedResources it creates some URL helpers.
484
+ And they handle everything for you. :)
485
+
486
+ # /posts/1/comments
487
+ resource_url # => /posts/1/comments/#{@comment.to_param}
488
+ resource_url(comment) # => /posts/1/comments/#{comment.to_param}
489
+ new_resource_url # => /posts/1/comments/new
490
+ edit_resource_url # => /posts/1/comments/#{@comment.to_param}/edit
491
+ edit_resource_url(comment) #=> /posts/1/comments/#{comment.to_param}/edit
492
+ collection_url # => /posts/1/comments
493
+
494
+ # /projects/1/tasks
495
+ resource_url # => /projects/1/tasks/#{@task.to_param}
496
+ resource_url(task) # => /projects/1/tasks/#{task.to_param}
497
+ new_resource_url # => /projects/1/tasks/new
498
+ edit_resource_url # => /projects/1/tasks/#{@task.to_param}/edit
499
+ edit_resource_url(task) # => /projects/1/tasks/#{task.to_param}/edit
500
+ collection_url # => /projects/1/tasks
501
+
502
+ # /users
503
+ resource_url # => /users/#{@user.to_param}
504
+ resource_url(user) # => /users/#{user.to_param}
505
+ new_resource_url # => /users/new
506
+ edit_resource_url # => /users/#{@user.to_param}/edit
507
+ edit_resource_url(user) # => /users/#{user.to_param}/edit
508
+ collection_url # => /users
509
+
510
+ Those urls helpers also accepts a hash as options, just as in named routes.
511
+
512
+ # /projects/1/tasks
513
+ collection_url(:page => 1, :limit => 10) #=> /projects/1/tasks?page=1&limit=10
514
+
515
+ In polymorphic cases, you can also give the parent as parameter to collection_url.
516
+
517
+ Another nice thing is that those urls are not guessed during runtime. They are
518
+ all created when your application is loaded (except for polymorphic
519
+ associations, that relies on Rails polymorphic_url).
520
+
521
+ Bugs and Feedback
522
+ -----------------
523
+
524
+ If you discover any bugs, please send an e-mail to jose.valim@plataformatec.com.br
525
+ If you just want to give some positive feedback or drop a line, that's fine too!
526
+
527
+ Copyright (c) 2009 José Valim
528
+ http://blog.plataformatec.com.br/
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |s|
10
+ s.name = "inherited_resources"
11
+ s.rubyforge_project = "inherited_resources"
12
+ s.summary = "Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important."
13
+ s.email = "jose.valim@gmail.com"
14
+ s.homepage = "http://github.com/josevalim/inherited_resources"
15
+ s.description = "Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important."
16
+ s.authors = ['José Valim']
17
+ s.files = FileList["[A-Z]*", "{lib}/**/*"]
18
+ end
19
+ rescue LoadError
20
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
21
+ end
22
+
23
+ desc 'Run tests for InheritedResources.'
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = true
27
+ end
28
+
29
+ desc 'Generate documentation for InheritedResources.'
30
+ Rake::RDocTask.new(:rdoc) do |rdoc|
31
+ rdoc.rdoc_dir = 'rdoc'
32
+ rdoc.title = 'InheritedResources'
33
+ rdoc.options << '--line-numbers' << '--inline-source'
34
+ rdoc.rdoc_files.include('README')
35
+ rdoc.rdoc_files.include('MIT-LICENSE')
36
+ rdoc.rdoc_files.include('lib/**/*.rb')
37
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.0