mconnell-generators 1.0.6

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 (42) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG +43 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +46 -0
  5. data/Rakefile +17 -0
  6. data/TODO +11 -0
  7. data/bin/rubaidh_rails +11 -0
  8. data/generators.gemspec +59 -0
  9. data/generators/rubaidh_controller/USAGE +31 -0
  10. data/generators/rubaidh_controller/rubaidh_controller_generator.rb +40 -0
  11. data/generators/rubaidh_controller/templates/controller.rb +17 -0
  12. data/generators/rubaidh_controller/templates/controller_spec.rb +29 -0
  13. data/generators/rubaidh_controller/templates/view.html.erb +17 -0
  14. data/generators/rubaidh_helper/USAGE +23 -0
  15. data/generators/rubaidh_helper/rubaidh_helper_generator.rb +27 -0
  16. data/generators/rubaidh_helper/templates/helper.rb +12 -0
  17. data/generators/rubaidh_helper/templates/helper_spec.rb +14 -0
  18. data/generators/rubaidh_layout/rubaidh_layout_generator.rb +27 -0
  19. data/generators/rubaidh_layout/templates/base.css +334 -0
  20. data/generators/rubaidh_layout/templates/layout.html.erb +36 -0
  21. data/generators/rubaidh_layout/templates/style.css +321 -0
  22. data/generators/rubaidh_model/USAGE +25 -0
  23. data/generators/rubaidh_model/rubaidh_model_generator.rb +29 -0
  24. data/generators/rubaidh_model/templates/migration.rb +25 -0
  25. data/generators/rubaidh_model/templates/model.rb +15 -0
  26. data/generators/rubaidh_model/templates/model_exemplar.rb +13 -0
  27. data/generators/rubaidh_model/templates/model_spec.rb +31 -0
  28. data/generators/rubaidh_named_base.rb +31 -0
  29. data/generators/rubaidh_scaffold/USAGE +29 -0
  30. data/generators/rubaidh_scaffold/rubaidh_scaffold_generator.rb +90 -0
  31. data/generators/rubaidh_scaffold/templates/controller.rb +76 -0
  32. data/generators/rubaidh_scaffold/templates/controller_spec.rb +251 -0
  33. data/generators/rubaidh_scaffold/templates/partial_form.html.erb +13 -0
  34. data/generators/rubaidh_scaffold/templates/partial_layout.html.erb +13 -0
  35. data/generators/rubaidh_scaffold/templates/partial_model.html.erb +8 -0
  36. data/generators/rubaidh_scaffold/templates/routing_spec.rb +73 -0
  37. data/generators/rubaidh_scaffold/templates/view_edit.html.erb +10 -0
  38. data/generators/rubaidh_scaffold/templates/view_index.html.erb +10 -0
  39. data/generators/rubaidh_scaffold/templates/view_new.html.erb +9 -0
  40. data/generators/rubaidh_scaffold/templates/view_show.html.erb +17 -0
  41. data/templates/rubaidh.rb +115 -0
  42. metadata +113 -0
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /rdoc
2
+ /pkg
data/CHANGELOG ADDED
@@ -0,0 +1,43 @@
1
+ = Change Log
2
+
3
+ == Version 1.0.6
4
+
5
+ * Add Web App Theme to the application (script/generate rubaidh_layout)
6
+
7
+ * Fix error introduced in last version of a missing comma in a command to add a submodule
8
+
9
+ == Version 1.0.5
10
+
11
+ * Add .DS_Store to .gitignore
12
+
13
+ * Remove cucumber being installed as a submoduled plugin so we don't encounter issues with the gem path
14
+
15
+ * Added dependancy for grit gem
16
+
17
+ * Switched out Hoptoad for GetExceptional
18
+
19
+ * Switched out Remarkable for Shoulda
20
+
21
+ == Version 1.0.4
22
+
23
+ * Insert cucumber into the generated application, not a duplicate copy of
24
+ webrat.
25
+
26
+ == Version 1.0.3
27
+
28
+ * The rubaidh_rails application generator now pulls in edge Rails as a
29
+ submodule.
30
+
31
+ == Version 1.0.2
32
+
33
+ * Enhance (ie write) documentation.
34
+
35
+ == Version 1.0.1
36
+
37
+ * Modify the model generator to generate an object_daddy examplar too.
38
+
39
+ * Fix a regression that was causing generated routing spec failure.
40
+
41
+ == Version 1.0.0
42
+
43
+ * Initial release.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
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.rdoc ADDED
@@ -0,0 +1,46 @@
1
+ = Rubaidh Generators
2
+
3
+ Rails ships with its own generators for creating models, controllers and
4
+ complete scaffolds. RSpec ships with its own take on these generators. We ship
5
+ with yet another slightly different take on the generators, suited to
6
+ Rubaidh's tastes.
7
+
8
+ == Application Generator
9
+
10
+ The gem ships with a program called +rubaidh_rails+ which generates a Rails
11
+ application and applies the Rubaidh template to it. In short, this will:
12
+
13
+ * initialize a local Git repository, ignoring the appropriate things and
14
+ saving the log directory but not its contents;
15
+
16
+ * install RSpec, RSpec's Rails support, Shoulda and object_daddy
17
+ for testing support;
18
+
19
+ * install and enable GetExceptional for watching errors in production; and
20
+
21
+ * create and migrate all the appropriate databases.
22
+
23
+ So, for every new application, it'll save us a good hour of boring fiddling.
24
+ :-)
25
+
26
+ == Component Generators
27
+
28
+ We currently ship with 4 generators:
29
+
30
+ * rubaidh_model which generates a model, specification and exemplar.
31
+
32
+ * rubaidh_controller which generates a controller and specification.
33
+
34
+ * rubaidh_helper which generates a helper and its specification.
35
+
36
+ * rubaidh_scaffold which generates the full shebang for a CRUD-operated
37
+ RESTful resource.
38
+
39
+ * rubaidh_layout which generates a basic web-app theme
40
+
41
+ Where possible generators are built in terms of other generators (so the
42
+ scaffold calls on rubaidh_model to generate the model).
43
+
44
+ == License
45
+
46
+ Copyright (c) 2009 Rubaidh Ltd, released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'rake'
2
+ require 'rake/rdoctask'
3
+ require 'rake/gempackagetask'
4
+
5
+ Rake::RDocTask.new(:rdoc) do |rdoc|
6
+ rdoc.rdoc_dir = 'rdoc'
7
+ rdoc.title = 'Rubaidh Generators'
8
+ rdoc.options << '--line-numbers' << '--inline-source'
9
+ rdoc.rdoc_files.include('README.rdoc')
10
+ rdoc.rdoc_files.include('CHANGELOG')
11
+ rdoc.rdoc_files.include('MIT-LICENSE')
12
+ end
13
+
14
+ Rake::GemPackageTask.new(eval(File.read('generators.gemspec'))) do |p|
15
+ p.need_tar = false
16
+ p.need_zip = false
17
+ end
data/TODO ADDED
@@ -0,0 +1,11 @@
1
+ = To do
2
+
3
+ * Fix the scaffold to successfully create singleton resources too.
4
+
5
+ * Create a layout generator which creates a sensible default layout using YUI
6
+ grids.
7
+
8
+ * Figure out how to do automated testing of generators.
9
+
10
+ * Figure a way to keep track of changes to the Rails (and RSpec) generators
11
+ used as inspiration so we can merge in changes.
data/bin/rubaidh_rails ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ gem 'rails'
5
+
6
+ require 'rails/version'
7
+ require 'rails_generator'
8
+ require 'rails_generator/scripts/generate'
9
+
10
+ Rails::Generator::Base.use_application_sources!
11
+ Rails::Generator::Scripts::Generate.new.run(["-d", "mysql", "-m", File.join(File.dirname(__FILE__), '..', 'templates', 'rubaidh.rb')] + ARGV, :generator => 'app')
@@ -0,0 +1,59 @@
1
+ spec = Gem::Specification.new do |s|
2
+ s.name = 'generators'
3
+ s.version = '1.0.6'
4
+ s.date = '2009-03-17'
5
+ s.authors = ['Graeme Mathieson', 'Mark Connell' 'Rubaidh Ltd']
6
+ s.email = 'support@rubaidh.com'
7
+ s.rubyforge_project = 'rubaidh'
8
+ s.homepage = 'http://rubaidh.com/portfolio/open-source'
9
+ s.summary = '[Rails] Generators for building Ruby on Rails projects the Rubaidh Way'
10
+
11
+ s.description = 'Generators for building Ruby on Rails projects the Rubaidh Way'
12
+
13
+ s.files = %w(
14
+ .gitignore MIT-LICENSE Rakefile README.rdoc CHANGELOG TODO generators.gemspec
15
+ bin/rubaidh_rails
16
+ generators/rubaidh_controller/rubaidh_controller_generator.rb
17
+ generators/rubaidh_controller/templates/controller.rb
18
+ generators/rubaidh_controller/templates/controller_spec.rb
19
+ generators/rubaidh_controller/templates/view.html.erb
20
+ generators/rubaidh_controller/USAGE
21
+ generators/rubaidh_helper/rubaidh_helper_generator.rb
22
+ generators/rubaidh_helper/templates/helper.rb
23
+ generators/rubaidh_helper/templates/helper_spec.rb
24
+ generators/rubaidh_helper/USAGE
25
+ generators/rubaidh_model/rubaidh_model_generator.rb
26
+ generators/rubaidh_model/templates/migration.rb
27
+ generators/rubaidh_model/templates/model.rb
28
+ generators/rubaidh_model/templates/model_exemplar.rb
29
+ generators/rubaidh_model/templates/model_spec.rb
30
+ generators/rubaidh_model/USAGE
31
+ generators/rubaidh_named_base.rb
32
+ generators/rubaidh_scaffold/rubaidh_scaffold_generator.rb
33
+ generators/rubaidh_scaffold/templates/controller.rb
34
+ generators/rubaidh_scaffold/templates/controller_spec.rb
35
+ generators/rubaidh_scaffold/templates/partial_form.html.erb
36
+ generators/rubaidh_scaffold/templates/partial_layout.html.erb
37
+ generators/rubaidh_scaffold/templates/partial_model.html.erb
38
+ generators/rubaidh_scaffold/templates/routing_spec.rb
39
+ generators/rubaidh_scaffold/templates/view_edit.html.erb
40
+ generators/rubaidh_scaffold/templates/view_index.html.erb
41
+ generators/rubaidh_scaffold/templates/view_new.html.erb
42
+ generators/rubaidh_scaffold/templates/view_show.html.erb
43
+ generators/rubaidh_scaffold/USAGE
44
+ generators/rubaidh_layout/rubaidh_layout_generator.rb
45
+ generators/rubaidh_layout/templates/base.css
46
+ generators/rubaidh_layout/templates/style.css
47
+ generators/rubaidh_layout/templates/layout.html.erb
48
+ templates/rubaidh.rb
49
+ )
50
+
51
+ s.add_dependency 'rails', '>=2.3.0'
52
+ s.add_dependency 'grit', '>=1.0.1'
53
+
54
+ s.bindir = "bin"
55
+ s.executables = ["rubaidh_rails"]
56
+ s.default_executable = "rubaidh_rails"
57
+
58
+ s.has_rdoc = false
59
+ end
@@ -0,0 +1,31 @@
1
+ Description:
2
+ Stubs out a new controller, along with its helper, views and associated
3
+ specs. Pass the controller name, either CamelCased or under_scored, and a
4
+ list of views as arguments.
5
+
6
+ To create a controller within a module, specify the controller name as a
7
+ path like 'parent_module/controller_name'.
8
+
9
+ This generates a controller class in app/controllers, view templates in
10
+ app/views/controller_name, a helper class in app/helpers, a controller
11
+ spec in spec/controllers and a helper spec in spec/helpers.
12
+
13
+ Example:
14
+ `./script/generate controller CreditCard open debit credit close`
15
+
16
+ Credit card controller with URLs like /credit_card/debit.
17
+ Controller: app/controllers/credit_card_controller.rb
18
+ Controller Spec: spec/controllers/credit_card_controller_spec.rb
19
+ Views: app/views/credit_card/debit.html.erb [...]
20
+ Helper: app/helpers/credit_card_helper.rb
21
+ Helper Spec: spec/helpers/credit_card_helper_spec.rb
22
+
23
+ Modules Example:
24
+ `./script/generate controller 'admin/credit_card' suspend late_fee`
25
+
26
+ Credit card admin controller with URLs /admin/credit_card/suspend.
27
+ Controller: app/controllers/admin/credit_card_controller.rb
28
+ Controller Spec: spec/controllers/admin/credit_card_controller_spec.rb
29
+ Views: app/views/admin/credit_card/debit.html.erb [...]
30
+ Helper: app/helpers/admin/credit_card_helper.rb
31
+ Helper Spec: spec/helpers/admin/credit_card_helper_spec.rb
@@ -0,0 +1,40 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'rubaidh_named_base')
2
+
3
+ class RubaidhControllerGenerator < RubaidhNamedBase
4
+ def manifest
5
+ record do |m|
6
+ # Check for class naming collisions.
7
+ m.class_collisions "#{class_name}Controller"
8
+
9
+ # Controller, helper, views, and spec directories.
10
+ m.directory File.join('app/controllers', class_path)
11
+ m.directory File.join('app/views', class_path, file_name)
12
+ m.directory File.join('spec/controllers', class_path)
13
+
14
+ # Controller spec, class, and helper.
15
+ m.template 'controller.rb',
16
+ File.join('app/controllers',
17
+ class_path,
18
+ "#{file_name}_controller.rb")
19
+
20
+ m.template 'controller_spec.rb',
21
+ File.join('spec/controllers',
22
+ class_path,
23
+ "#{file_name}_controller_spec.rb")
24
+
25
+ # View template for each action.
26
+ actions.each do |action|
27
+ path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
28
+ m.template 'view.html.erb', path,
29
+ :assigns => { :action => action, :path => path }
30
+ end
31
+
32
+ m.dependency 'rubaidh_helper', [name] + @args
33
+ end
34
+ end
35
+
36
+ protected
37
+ def banner
38
+ "Usage: #{$0} #{spec.name} ControllerName [action]..."
39
+ end
40
+ end
@@ -0,0 +1,17 @@
1
+ # <%= class_name %> Controller
2
+ #
3
+ # Created on <%= Time.now.to_s :long %> by <%= user_full_name %> as part
4
+ # of the "<%= project_name %>" project.
5
+ #
6
+ #--
7
+ # Copyright (c) 2006-<%= Time.now.year %> Rubaidh Ltd. All rights reserved.
8
+ # See LICENSE in the top level source code folder for permissions.
9
+ #++
10
+
11
+ class <%= class_name %>Controller < ApplicationController
12
+ <% for action in actions -%>
13
+
14
+ def <%= action %>
15
+ end
16
+ <% end -%>
17
+ end
@@ -0,0 +1,29 @@
1
+ # <%= class_name %> Controller Spec
2
+ #
3
+ # Created on <%= Time.now.to_s :long %> by <%= user_full_name %> as part
4
+ # of the "<%= project_name %>" project.
5
+ #
6
+ #--
7
+ # Copyright (c) 2006-<%= Time.now.year %> Rubaidh Ltd. All rights reserved.
8
+ # See LICENSE in the top level source code folder for permissions.
9
+ #++
10
+
11
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
12
+
13
+ describe <%= class_name %>Controller do
14
+ <% unless actions.empty? -%>
15
+ <% for action in actions -%>
16
+
17
+ describe "responding to GET '<%= action %>'" do
18
+ def do_get
19
+ get :<%= action %>
20
+ end
21
+
22
+ it "should be successful" do
23
+ do_get
24
+ response.should be_success
25
+ end
26
+ end
27
+ <% end -%>
28
+ <% end -%>
29
+ end
@@ -0,0 +1,17 @@
1
+ <div class="block">
2
+ <div class="content">
3
+ <h2 class="title"><%= class_name %>#<%= action %></h2>
4
+ <div class="inner">
5
+ <p>Find me in <%= path %></p>
6
+ </div>
7
+ </div>
8
+ </div>
9
+
10
+ <%% content_for :sidebar do %>
11
+ <div class="block notice">
12
+ <h4>Sample</h4>
13
+ <p>
14
+ This is a sample notice for in the sidebar
15
+ </p>
16
+ </div>
17
+ <%% end %>
@@ -0,0 +1,23 @@
1
+ Description:
2
+ Stubs out a new helper. Pass the helper name, either
3
+ CamelCased or under_scored.
4
+
5
+ To create a helper within a module, specify the helper name as a
6
+ path like 'parent_module/helper_name'.
7
+
8
+ This generates a helper class in app/helpers and a helper spec
9
+ in spec/helpers.
10
+
11
+ Example:
12
+ `./script/generate helper CreditCard`
13
+
14
+ Credit card helper.
15
+ Helper: app/helpers/credit_card_helper.rb
16
+ Spec: spec/helpers/credit_card_helper_spec.rb
17
+
18
+ Modules Example:
19
+ `./script/generate helper 'admin/credit_card'`
20
+
21
+ Credit card admin helper.
22
+ Helper: app/helpers/admin/credit_card_helper.rb
23
+ Spec: spec/helpers/admin/credit_card_helper_spec.rb
@@ -0,0 +1,27 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'rubaidh_named_base')
2
+
3
+ class RubaidhHelperGenerator < RubaidhNamedBase
4
+ def manifest
5
+ record do |m|
6
+ # Check for class naming collisions.
7
+ m.class_collisions "#{class_name}Helper"
8
+
9
+ # Helper and helper test directories.
10
+ m.directory File.join('app/helpers', class_path)
11
+ m.directory File.join('spec/helpers', class_path)
12
+
13
+ # Helper and helper test class.
14
+
15
+ m.template 'helper.rb',
16
+ File.join('app/helpers',
17
+ class_path,
18
+ "#{file_name}_helper.rb")
19
+
20
+ m.template 'helper_spec.rb',
21
+ File.join('spec/helpers',
22
+ class_path,
23
+ "#{file_name}_helper_spec.rb")
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ # <%= class_name %> Helper
2
+ #
3
+ # Created on <%= Time.now.to_s :long %> by <%= user_full_name %> as part
4
+ # of the "<%= project_name %>" project.
5
+ #
6
+ #--
7
+ # Copyright (c) 2006-<%= Time.now.year %> Rubaidh Ltd. All rights reserved.
8
+ # See LICENSE in the top level source code folder for permissions.
9
+ #++
10
+
11
+ module <%= class_name %>Helper
12
+ end
@@ -0,0 +1,14 @@
1
+ # <%= class_name %> Helper Spec
2
+ #
3
+ # Created on <%= Time.now.to_s :long %> by <%= user_full_name %> as part
4
+ # of the "<%= project_name %>" project.
5
+ #
6
+ #--
7
+ # Copyright (c) 2006-<%= Time.now.year %> Rubaidh Ltd. All rights reserved.
8
+ # See LICENSE in the top level source code folder for permissions.
9
+ #++
10
+
11
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
12
+
13
+ describe <%= class_name %>Helper do
14
+ end