Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make generators more explicit: add descriptions to options and notes …

…to templates.
  • Loading branch information...
commit e3a64cb3f2e0448c75e1211e39162f2e42361219 1 parent a6ee818
@michaelklishin michaelklishin authored
View
8 merb-gen/lib/merb-gen/controller.rb
@@ -7,12 +7,12 @@ def self.source_root
end
desc <<-DESC
- This is a controller generator
+ Generates a new controller.
DESC
- option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
+ option :testing_framework, :desc => 'Testing framework to use (one of: spec, test_unit)'
- first_argument :name, :required => true
+ first_argument :name, :required => true, :desc => "controller name"
invoke :helper
@@ -66,4 +66,4 @@ def chunks
add :controller, ControllerGenerator
-end
+end
View
4 merb-gen/lib/merb-gen/freezer.rb
@@ -7,7 +7,7 @@ def self.source_root
end
desc <<-DESC
- Generates a freezer
+ Generates Merb freezer scripts.
DESC
template :freezer, 'script/frozen_merb', 'script/frozen_merb'
@@ -16,4 +16,4 @@ def self.source_root
add :freezer, FreezerGenerator
-end
+end
View
8 merb-gen/lib/merb-gen/helper.rb
@@ -7,12 +7,12 @@ def self.source_root
end
desc <<-DESC
- This is a controller generator
+ Generates a new helper.
DESC
- option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
+ option :testing_framework, :desc => 'Testing framework to use (one of: spec, test_unit)'
- first_argument :name, :required => true
+ first_argument :name, :required => true, :desc => "helper name"
template :helper do
source('app/helpers/%file_name%_helper.rb')
@@ -50,4 +50,4 @@ def chunks
add :helper, HelperGenerator
-end
+end
View
10 merb-gen/lib/merb-gen/merb.rb
@@ -6,16 +6,16 @@ def self.source_root
File.join(super, 'merb')
end
- option :testing_framework, :default => :rspec, :desc => 'Specify which testing framework to use (spec, test_unit)'
- option :orm, :default => :none, :desc => 'Specify which Object-Relation Mapper to use (none, activerecord, datamapper, sequel)'
- option :flat, :as => :boolean
- option :very_flat, :as => :boolean
+ option :testing_framework, :default => :rspec, :desc => 'Testing framework to use (one of: spec, test_unit)'
+ option :orm, :default => :none, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
+ option :flat, :as => :boolean, :desc => "Generate a flat application: one file + configs + templates directory."
+ option :very_flat, :as => :boolean, :desc => "Generate a very flat, Sinatra-like one file application."
desc <<-DESC
This generates a full merb application
DESC
- first_argument :name, :required => true
+ first_argument :name, :required => true, :desc => "Application name"
invoke :app_full, :flat => nil, :very_flat => nil
invoke :app_flat, :flat => true
View
6 merb-gen/lib/merb-gen/merb_flat.rb
@@ -7,10 +7,12 @@ def self.source_root
end
desc <<-DESC
- This generates a flat merb application
+ This generates a flat merb application: all code but config files and
+ templates fits in one application. This is something in between Sinatra
+ and "regular" Merb application.
DESC
- first_argument :name, :required => true
+ first_argument :name, :required => true, :desc => "Application name"
glob!
View
11 merb-gen/lib/merb-gen/merb_full.rb
@@ -6,16 +6,19 @@ def self.source_root
File.join(super, 'merb')
end
- option :testing_framework, :default => :rspec, :desc => 'Specify which testing framework to use (spec, test_unit)'
- option :orm, :default => :none, :desc => 'Specify which Object-Relation Mapper to use (none, activerecord, datamapper, sequel)'
+ option :testing_framework, :default => :rspec,
+ :desc => 'Testing framework to use (one of: spec, test_unit).'
+ option :orm, :default => :none,
+ :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel).'
desc <<-DESC
- This generates a full merb application
+ This generates a Merb application with Ruby on Rails like structure.
+ Generator lets you configure your ORM and testing framework of choice.
DESC
glob!
- first_argument :name, :required => true
+ first_argument :name, :required => true, :desc => "Application name"
def app_name
self.name.snake_case
View
8 merb-gen/lib/merb-gen/merb_plugin.rb
@@ -6,16 +6,16 @@ def self.source_root
File.join(super, 'merb_plugin')
end
- option :testing_framework, :default => :rspec, :desc => 'Specify which testing framework to use (spec, test_unit)'
- option :orm, :default => :none, :desc => 'Specify which Object-Relation Mapper to use (none, activerecord, datamapper, sequel)'
+ option :testing_framework, :default => :rspec, :desc => 'Testing framework to use (one of: spec, test_unit)'
+ option :orm, :default => :none, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
desc <<-DESC
- This generates a plugin for merb
+ Merb plugin generator: lets you kick start your Merb plugin.
DESC
glob!
- first_argument :name, :required => true
+ first_argument :name, :required => true, :desc => "Plugin name"
def base_name
self.name.snake_case
View
5 merb-gen/lib/merb-gen/merb_very_flat.rb
@@ -7,10 +7,11 @@ def self.source_root
end
desc <<-DESC
- This generates a very flat merb application
+ This generates a very flat merb application: the whole application
+ fits in one file, very much like Sinatra or Camping.
DESC
- first_argument :name, :required => true
+ first_argument :name, :required => true, :desc => "Application name"
template :application do
source('application.rbt')
View
4 merb-gen/lib/merb-gen/migration.rb
@@ -10,8 +10,8 @@ def self.source_root
This is a migration generator
DESC
- option :orm, :desc => 'Specify which Object-Relation Mapper to use (none, activerecord, datamapper, sequel)'
- option :model, :as => :boolean, :desc => 'Set this option to generate a migration which creates a table for the provided model'
+ option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
+ option :model, :as => :boolean, :desc => 'Specify this option to generate a migration which creates a table for the provided model'
first_argument :name, :required => true
second_argument :attributes, :as => :hash, :default => {}
View
13 merb-gen/lib/merb-gen/model.rb
@@ -7,14 +7,15 @@ def self.source_root
end
desc <<-DESC
- This is a model generator
+ Generates a new model. You can specify an ORM different from what the rest
+ of the application uses.
DESC
- option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
- option :orm, :desc => 'Specify which Object-Relation Mapper to use (none, activerecord, datamapper, sequel)'
+ option :testing_framework, :desc => 'Testing framework to use (one of: spec, test_unit)'
+ option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
- first_argument :name, :required => true
- second_argument :attributes, :as => :hash, :default => {}
+ first_argument :name, :required => true, :desc => "model name"
+ second_argument :attributes, :as => :hash, :default => {}, :desc => "space separated model properties in form of name:type. Example: state:string"
invoke :migration do |generator|
generator.new(destination_root, options.merge(:model => true), name, attributes)
@@ -63,4 +64,4 @@ def attributes_for_accessor
add :model, ModelGenerator
-end
+end
View
8 merb-gen/lib/merb-gen/resource.rb
@@ -3,11 +3,11 @@ module Merb::Generators
class ResourceGenerator < ComponentGenerator
desc <<-DESC
- This is a resource generator
+ Generates a new resource.
DESC
- first_argument :name, :required => true
- second_argument :attributes, :as => :hash
+ first_argument :name, :required => true, :desc => "resource name"
+ second_argument :attributes, :as => :hash, :default => {}, :desc => "space separated resource model properties in form of name:type. Example: state:string"
invoke :model do |generator|
generator.new(destination_root, options, model_name, attributes)
@@ -29,4 +29,4 @@ def model_name
add :resource, ResourceGenerator
-end
+end
View
15 merb-gen/lib/merb-gen/resource_controller.rb
@@ -7,14 +7,17 @@ def self.source_root
end
desc <<-DESC
- This is a resource controller generator
+ Generates a new resource controller.
DESC
- option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
- option :orm, :desc => 'Specify which Object-Relation Mapper to use (none, activerecord, datamapper, sequel)'
+ option :testing_framework, :desc => 'Testing framework to use (one of: spec, test_unit)'
+ option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
- first_argument :name, :required => true
- second_argument :attributes, :as => :hash, :default => {}
+ first_argument :name, :required => true,
+ :desc => "model name"
+ second_argument :attributes, :as => :hash,
+ :default => {},
+ :desc => "space separated resource model properties in form of name:type. Example: state:string"
invoke :helper do |generator|
generator.new(destination_root, options, name)
@@ -85,4 +88,4 @@ def chunks
add :resource_controller, ResourceControllerGenerator
-end
+end
View
4 merb-gen/lib/merb-gen/session_migration.rb
@@ -7,10 +7,10 @@ def self.source_root
end
desc <<-DESC
- This is a migration generator
+ Generates a new session migration.
DESC
- option :orm, :desc => 'Specify which Object-Relation Mapper to use (none, activerecord, datamapper, sequel)'
+ option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
template :session_migration_activerecord, :orm => :activerecord do
source('activerecord/schema/migrations/%version%_sessions.rb')
View
14 merb-gen/templates/application/merb_very_flat/application.rbt
@@ -1,5 +1,11 @@
# run very flat apps with merb -I <app file>.
+Merb::Config.use { |c|
+ c[:framework] = { :public => [Merb.root / "public", nil] },
+ c[:session_store] = 'none',
+ c[:exception_details] = true
+}
+
Merb::Router.prepare do |r|
r.match('/').to(:controller => '<%= app_name %>', :action =>'index')
end
@@ -8,10 +14,4 @@ class <%= class_name %> < Merb::Controller
def index
"hi"
end
-end
-
-Merb::Config.use { |c|
- c[:framework] = { :public => [Merb.root / "public", nil] },
- c[:session_store] = 'none',
- c[:exception_details] = true
-}
+end
View
6 merb-gen/templates/component/controller/app/controllers/%file_name%.rb
@@ -1,9 +1,11 @@
<% with_modules(controller_modules) do -%>
class <%= controller_class_name %> < Application
-
+
+ # ...and remember, everything returned from an action
+ # goes to the client...
def index
render
end
end
-<% end -%>
+<% end -%>
View
2  merb-gen/templates/component/model/activerecord/app/models/%file_name%.rb
@@ -1,2 +1,2 @@
class <%= class_name %> < ActiveRecord::Base
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.