padrino-gen 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/README.rdoc +66 -1
  2. data/Rakefile +1 -0
  3. data/VERSION +1 -1
  4. data/bin/padrino-gen +13 -1
  5. data/lib/generators/actions.rb +28 -0
  6. data/lib/generators/components/orms/activerecord_gen.rb +2 -2
  7. data/lib/generators/components/orms/couchrest_gen.rb +2 -2
  8. data/lib/generators/components/orms/datamapper_gen.rb +2 -2
  9. data/lib/generators/components/orms/mongomapper_gen.rb +2 -2
  10. data/lib/generators/components/orms/sequel_gen.rb +2 -2
  11. data/lib/generators/components/tests/bacon_test_gen.rb +18 -0
  12. data/lib/generators/components/tests/riot_test_gen.rb +19 -2
  13. data/lib/generators/components/tests/rspec_test_gen.rb +20 -1
  14. data/lib/generators/components/tests/shoulda_test_gen.rb +25 -2
  15. data/lib/generators/components/tests/testspec_test_gen.rb +19 -1
  16. data/lib/generators/controller.rb +36 -0
  17. data/lib/generators/skeleton.rb +6 -6
  18. data/lib/generators/{project → skeleton}/.gitignore +0 -0
  19. data/lib/generators/{project → skeleton}/Gemfile +0 -0
  20. data/lib/generators/skeleton/app.rb.tt +10 -0
  21. data/lib/generators/{project/apps → skeleton/app}/.empty_directory +0 -0
  22. data/lib/generators/{project/lib → skeleton/app/controllers}/.empty_directory +0 -0
  23. data/lib/generators/{project/tmp/.emptydirectory → skeleton/app/helpers/.empty_directory} +0 -0
  24. data/lib/generators/skeleton/app/models/.empty_directory +0 -0
  25. data/lib/generators/skeleton/app/views/.empty_directory +0 -0
  26. data/lib/generators/{project → skeleton}/config.ru +0 -3
  27. data/lib/generators/skeleton/config/apps.rb.tt +15 -0
  28. data/lib/generators/skeleton/config/boot.rb +4 -0
  29. data/lib/generators/skeleton/config/initializers/.empty_directory +0 -0
  30. data/lib/generators/skeleton/config/initializers/example.rb +9 -0
  31. data/lib/generators/skeleton/config/urls.rb.tt +44 -0
  32. data/lib/generators/skeleton/lib/.empty_directory +0 -0
  33. data/lib/generators/skeleton/public/images/.empty_directory +0 -0
  34. data/lib/generators/skeleton/public/javascripts/.empty_directory +0 -0
  35. data/lib/generators/skeleton/public/stylesheets/.empty_directory +0 -0
  36. data/lib/generators/{project → skeleton}/test/test_config.rb.tt +0 -0
  37. data/lib/generators/skeleton/tmp/.emptydirectory +0 -0
  38. data/lib/generators/skeleton/vendor/gems/.empty_directory +0 -0
  39. data/lib/generators/templates/controller.rb.tt +13 -0
  40. data/lib/generators/templates/helper.rb.tt +7 -0
  41. data/lib/padrino-gen.rb +4 -1
  42. data/padrino-gen.gemspec +30 -10
  43. data/test/test_controller_generator.rb +56 -0
  44. data/test/test_skeleton_generator.rb +36 -30
  45. metadata +37 -10
  46. data/lib/generators/project/config/boot.rb +0 -6
data/README.rdoc CHANGED
@@ -1,6 +1,71 @@
1
1
  = padrino-gen
2
2
 
3
- Description goes here.
3
+ == Installation
4
+
5
+ To install the 'full-stack' padrino framework, simply grab the latest version from gemcutter:
6
+
7
+ $ sudo gem install padrino --source http://gemcutter.org
8
+
9
+ This will install the necessary padrino gems to get you started.
10
+ Now you are ready to use this gem to enhance your sinatra projects or to create new Padrino applications.
11
+
12
+ == Overview
13
+
14
+ Padrino comes preloaded with flexible code generators for Sinatra powered in part by the excellent
15
+ Thor gem (incidentally also used in the Rails 3 generators). These generators are intended to allow for easy code
16
+ generation both in creating new applications and building on existing ones. The generators have been built to be as
17
+ library-agnostic as possible, supporting a myriad of test frameworks, js libraries, mocking libraries, etc.
18
+
19
+ The usage for the generator is quite simple:
20
+
21
+ $ padrino-gen <the_app_name> </path/to/create/app> --<component-name> <value>
22
+
23
+ The simplest possible command to generate a base application would be:
24
+
25
+ $ padrino-gen demo_app .
26
+
27
+ This would construct a Sinatra application DemoApp (which extends from Sinatra::Application)
28
+ inside the folder 'demo_app' at our current path. Inside the application there would be configuration and
29
+ setup performed for the default components.
30
+
31
+ You can also define specific components to be used:
32
+
33
+ $ padrino-gen demo_app . --test=rspec --renderer=haml --mock=rr --script=jquery --orm datamapper
34
+
35
+ There is also support for aliases for each component within the command:
36
+
37
+ $ padrino-gen demo_app . -t=rspec -r=haml -m=rr -s=jquery -d=datamapper
38
+
39
+ The available components and their default options are listed below:
40
+
41
+ * test: <tt>bacon</tt> (default), <tt>shoulda</tt>, <tt>rspec</tt>, <tt>testspec</tt>, <tt>riot</tt>
42
+ * renderer: <tt>erb</tt> (default), <tt>haml</tt>
43
+ * mock: <tt>mocha</tt> (default), <tt>rr</tt>
44
+ * script: <tt>jquery</tt> (default), <tt>prototype</tt>, <tt>rightjs</tt>
45
+ * orm: <tt>datamapper</tt> (default), <tt>mongomapper</tt>, <tt>activerecord</tt>, <tt>sequel</tt>, <tt>couchrest</tt>
46
+
47
+ The generator uses the <tt>bundler</tt> gem to resolve any application dependencies when the application is newly created.
48
+ The necessary bundler command can be executed automatically through the generator with
49
+
50
+ $ padrino-gen demo_app . --run_bundler # alias -b
51
+
52
+ or this can be done manually through executing command <tt>gem bundle</tt> in the terminal at the root of the generated application.
53
+ If not executed manually, the bundling will be performed automatically the first time the application attempts to boot.
54
+ Note that this command only has to be performed when the application is first generated or when the Gemfile is modified.
55
+
56
+ The generator framework within padrino is extensible and additional components and tools can be added easily.
57
+ This would be achieved through forking our project and reading through the code in <tt>/generators/sinatra_generator.rb</tt> and
58
+ the setup instructions inside the relevant files within <tt>/generators/components/</tt>. We are happy to accept pull requests
59
+ for additional component types not originally included (although helping us maintain them would also be appreciated).
60
+
61
+ We are also planning to add generator actions such as:
62
+
63
+ * Model generation (working for any of the available orms listed)
64
+ * Routes generation
65
+ * Mailer generation
66
+ * Migrations generation
67
+
68
+ See the wiki article for additional information: <...WIKI...>
4
69
 
5
70
  == Copyright
6
71
 
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/padrino/padrino-gen"
12
12
  gem.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
13
13
  gem.add_runtime_dependency "sinatra", ">= 0.9.2"
14
+ gem.add_runtime_dependency "padrino-core", ">= 0.1.1"
14
15
  gem.add_runtime_dependency "thor", ">= 0.11.8"
15
16
  gem.add_runtime_dependency "bundler"
16
17
  gem.add_development_dependency "haml", ">= 2.2.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/padrino-gen CHANGED
@@ -1,5 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
  %w[rubygems activesupport thor].each { |gem| require gem }
3
3
  require File.dirname(__FILE__) + "/../lib/padrino-gen"
4
+
5
+ generator_mappings = ActiveSupport::OrderedHash.new
6
+ generator_mappings[:app] = Padrino::Generators::Skeleton
7
+ generator_mappings[:controller] = Padrino::Generators::Controller
8
+
9
+ generator_kind = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0].present?
10
+ generator_class = generator_mappings[generator_kind]
4
11
  arguments = ARGV.any? ? ARGV : ['-h']
5
- Padrino::Generators::Skeleton.start(arguments)
12
+
13
+ if generator_class
14
+ generator_class.start(arguments)
15
+ else
16
+ puts "Please specify generator to use (#{generator_mappings.keys.join(", ")})"
17
+ end
@@ -1,5 +1,6 @@
1
1
  module Padrino
2
2
  module Generators
3
+ class AppRootNotFound < RuntimeError; end
3
4
  module Actions
4
5
 
5
6
  def self.included(base)
@@ -14,6 +15,15 @@ module Padrino
14
15
  self.class.send(:include, generator_module_for(choice, component))
15
16
  send("setup_#{component}") if respond_to?("setup_#{component}")
16
17
  end
18
+
19
+ # Includes the component module for the given component and choice
20
+ # Determines the choice using .components file
21
+ # include_component_module_for(:mock)
22
+ # include_component_module_for(:mock, 'rr')
23
+ def include_component_module_for(component, root=nil, choice=nil)
24
+ choice = fetch_component_choice(component, root) unless choice
25
+ self.class.send(:include, generator_module_for(choice, component))
26
+ end
17
27
 
18
28
  # Prompts the user if necessary until a valid choice is returned for the component
19
29
  # resolve_valid_choice(:mock) => 'rr'
@@ -54,6 +64,24 @@ module Padrino
54
64
  def retrieve_component_config(target)
55
65
  YAML.load_file(target)
56
66
  end
67
+
68
+ # Returns the component choice stored within the .component file of an application
69
+ # fetch_component_choice(:mock)
70
+ def fetch_component_choice(component, root=nil)
71
+ comp_path = root ? File.join(root, '.components') : '.components'
72
+ retrieve_component_config(comp_path)[component]
73
+ end
74
+
75
+ # Returns true if inside a Padrino application
76
+ def in_app_root?(root=nil)
77
+ root ? File.exist?(File.join(root, 'config/boot.rb')) : File.exist?('config/boot.rb')
78
+ end
79
+
80
+ # Returns the app_name for the application at root
81
+ def fetch_app_name(root=nil)
82
+ app_path = root ? File.join(root, 'app.rb') : 'app.rb'
83
+ @app_name ||= File.read(app_path).scan(/class\s(.*?)\s</).flatten[0]
84
+ end
57
85
 
58
86
  module ClassMethods
59
87
  # Defines a class option to allow a component to be chosen and add to component type list
@@ -6,7 +6,7 @@ module Padrino
6
6
  module ActiverecordGen
7
7
 
8
8
  AR = (<<-AR).gsub(/^ {10}/, '')
9
- module ActiveRecordInitializer
9
+ module DatabaseSetup
10
10
  def self.registered(app)
11
11
  app.configure :development do
12
12
  ActiveRecord::Base.establish_connection(
@@ -50,7 +50,7 @@ module Padrino
50
50
 
51
51
  def setup_orm
52
52
  require_dependencies 'activerecord'
53
- create_file("config/initializers/active_record.rb", AR)
53
+ create_file("config/database.rb", AR)
54
54
  create_file("Rakefile", RAKE)
55
55
  end
56
56
  end
@@ -6,7 +6,7 @@ module Padrino
6
6
  module CouchrestGen
7
7
 
8
8
  COUCHREST = (<<-COUCHREST).gsub(/^ {10}/, '')
9
- module CouchRestInitializer
9
+ module DatabaseSetup
10
10
  def self.registered(app)
11
11
  app.configure(:development) { set :couchdb, CouchRest.database!('your_dev_db_here') }
12
12
  app.configure(:production) { set :couchdb, CouchRest.database!('your_production_db_here') }
@@ -18,7 +18,7 @@ module Padrino
18
18
 
19
19
  def setup_orm
20
20
  require_dependencies 'couchrest'
21
- create_file("config/initializers/couch_rest.rb", COUCHREST)
21
+ create_file("config/database.rb", COUCHREST)
22
22
  end
23
23
  end
24
24
 
@@ -6,7 +6,7 @@ module Padrino
6
6
  module DatamapperGen
7
7
 
8
8
  DM = (<<-DM).gsub(/^ {10}/, '')
9
- module DataMapperInitializer
9
+ module DatabaseSetup
10
10
  def self.registered(app)
11
11
  app.configure(:development) { DataMapper.setup(:default, 'your_dev_db_here') }
12
12
  app.configure(:production) { DataMapper.setup(:default, 'your_production_db_here') }
@@ -17,7 +17,7 @@ module Padrino
17
17
 
18
18
  def setup_orm
19
19
  require_dependencies 'dm-core', 'dm-validations'
20
- create_file("config/initializers/data_mapper.rb", DM)
20
+ create_file("config/database.rb", DM)
21
21
  end
22
22
  end
23
23
 
@@ -8,7 +8,7 @@ module Padrino
8
8
  MONGO = (<<-MONGO).gsub(/^ {10}/, '')
9
9
  class MongoDBConnectionFailure < RuntimeError; end
10
10
 
11
- module MongoDbInitializer
11
+ module DatabaseSetup
12
12
  def self.registered(app)
13
13
  app.configure :development do
14
14
  MongoMapper.connection = Mongo::Connection.new('localhost')
@@ -43,7 +43,7 @@ module Padrino
43
43
 
44
44
  def setup_orm
45
45
  require_dependencies 'mongo_mapper'
46
- create_file("config/initializers/mongo_db.rb", MONGO)
46
+ create_file("config/database.rb", MONGO)
47
47
  create_file("lib/ext/mongo_mapper.rb", CONCERNED)
48
48
  end
49
49
  end
@@ -6,7 +6,7 @@ module Padrino
6
6
  module SequelGen
7
7
 
8
8
  SEQUEL = (<<-SEQUEL).gsub(/^ {10}/, '')
9
- module SequelInitializer
9
+ module DatabaseSetup
10
10
  def self.registered(app)
11
11
  Sequel::Model.plugin(:schema)
12
12
  app.configure(:development) { Sequel.connect('your_dev_db_here') }
@@ -18,7 +18,7 @@ module Padrino
18
18
 
19
19
  def setup_orm
20
20
  require_dependencies 'sequel'
21
- create_file("config/initializers/sequel.rb", SEQUEL)
21
+ create_file("config/database.rb", SEQUEL)
22
22
  end
23
23
  end
24
24
 
@@ -14,10 +14,28 @@ module Padrino
14
14
  end
15
15
  TEST
16
16
 
17
+ # Setup the testing configuration helper and dependencies
17
18
  def setup_test
18
19
  require_dependencies 'bacon', :env => :testing
19
20
  insert_test_suite_setup BACON_SETUP
20
21
  end
22
+
23
+ BACON_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '')
24
+ require File.dirname(__FILE__) + '/../test_config.rb'
25
+
26
+ describe "!NAME!Controller" do
27
+ it 'returns text at root' do
28
+ get '/'
29
+ last_response.body.should == "some text"
30
+ end
31
+ end
32
+ TEST
33
+
34
+ # Generates a controller test given the controllers name
35
+ def generate_controller_test(name, root)
36
+ bacon_contents = BACON_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
37
+ create_file File.join(root, "test/controllers/#{name}_controller_test.rb"), bacon_contents
38
+ end
21
39
 
22
40
  end
23
41
 
@@ -2,7 +2,7 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Tests
5
-
5
+
6
6
  module RiotGen
7
7
  RIOT_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
8
  class Riot::Situation
@@ -19,8 +19,25 @@ module Padrino
19
19
  insert_test_suite_setup RIOT_SETUP
20
20
  end
21
21
 
22
+ RIOT_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '')
23
+ require File.dirname(__FILE__) + '/../test_config.rb'
24
+
25
+ context "!NAME!Controller" do
26
+ context "description here" do
27
+ setup { get '/' }
28
+ asserts("the response body") { last_response.body }.equals "Hello World"
29
+ end
30
+ end
31
+ TEST
32
+
33
+ # Generates a controller test given the controllers name
34
+ def generate_controller_test(name, root)
35
+ riot_contents = RIOT_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
36
+ create_file File.join(root, "test/controllers/#{name}_controller_test.rb"), riot_contents
37
+ end
38
+
22
39
  end
23
-
40
+
24
41
  end
25
42
  end
26
43
  end
@@ -2,7 +2,7 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Tests
5
-
5
+
6
6
  module RspecGen
7
7
  RSPEC_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
8
  Spec::Runner.configure do |conf|
@@ -14,11 +14,30 @@ module Padrino
14
14
  end
15
15
  TEST
16
16
 
17
+ # TODO move to spec directory to follow convention
17
18
  def setup_test
18
19
  require_dependencies 'spec', :env => :testing
19
20
  insert_test_suite_setup RSPEC_SETUP
20
21
  end
21
22
 
23
+ RSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '')
24
+ require File.dirname(__FILE__) + '/../test_config.rb'
25
+
26
+ describe "!NAME!Controller" do
27
+ setup { get('/') }
28
+ it "returns hello world" do
29
+ last_response.body.should == "Hello World"
30
+ end
31
+ end
32
+ TEST
33
+
34
+ # TODO move to spec directory to follow convention
35
+ # Generates a controller test given the controllers name
36
+ def generate_controller_test(name, root)
37
+ rspec_contents = RSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
38
+ create_file File.join(root, "test/controllers/#{name}_controller_spec.rb"), rspec_contents
39
+ end
40
+
22
41
  end
23
42
  end
24
43
  end
@@ -2,7 +2,7 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Tests
5
-
5
+
6
6
  module ShouldaGen
7
7
  SHOULDA_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
8
  class Test::Unit::TestCase
@@ -18,8 +18,31 @@ module Padrino
18
18
  require_dependencies 'test/unit', 'shoulda', :env => :testing
19
19
  insert_test_suite_setup SHOULDA_SETUP
20
20
  end
21
+
22
+ SHOULDA_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '')
23
+ require File.dirname(__FILE__) + '/../test_config.rb'
24
+
25
+ class !NAME!ControllerTest < Test::Unit::TestCase
26
+ context "!NAME!Controller" do
27
+ setup do
28
+ get '/'
29
+ end
30
+
31
+ should "return hello world text" do
32
+ assert_equal "Hello World", last_response.body
33
+ end
34
+ end
35
+ end
36
+ TEST
37
+
38
+ # Generates a controller test given the controllers name
39
+ def generate_controller_test(name, root)
40
+ shoulda_contents = SHOULDA_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
41
+ create_file File.join(root, "test/controllers/#{name}_controller_test.rb"), shoulda_contents
42
+ end
43
+
21
44
  end
22
-
45
+
23
46
  end
24
47
  end
25
48
  end
@@ -15,9 +15,27 @@ module Padrino
15
15
  TEST
16
16
 
17
17
  def setup_test
18
- require_dependencies 'test/spec', :path => "test/test_config.rb"
18
+ require_dependencies 'test/spec', :env => :testing
19
19
  insert_test_suite_setup TESTSPEC_SETUP
20
20
  end
21
+
22
+ TESTSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '')
23
+ require File.dirname(__FILE__) + '/../test_config.rb'
24
+
25
+ context "!NAME!Controller" do
26
+ setup { get('/') }
27
+ specify "returns hello world" do
28
+ last_response.body.should.equal "Hello World"
29
+ end
30
+ end
31
+ TEST
32
+
33
+ # Generates a controller test given the controllers name
34
+ def generate_controller_test(name, root)
35
+ testspec_contents = TESTSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
36
+ create_file File.join(root, "test/controllers/#{name}_controller_test.rb"), testspec_contents
37
+ end
38
+
21
39
  end
22
40
 
23
41
  end
@@ -0,0 +1,36 @@
1
+ require 'thor'
2
+
3
+ module Padrino
4
+ module Generators
5
+
6
+ class Controller < Thor::Group
7
+ # Define the source template root
8
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
9
+ def self.banner; "padrino-gen controller [name]"; end
10
+
11
+ # Include related modules
12
+ include Thor::Actions
13
+ include Padrino::Generators::Actions
14
+ include Padrino::Generators::Components::Actions
15
+
16
+ desc "Description:\n\n\tpadrino-gen controller generates a new Padrino controller"
17
+
18
+ argument :name, :desc => "The name of your padrino controller"
19
+ class_option :root, :aliases => '-r', :default => nil, :type => :string
20
+
21
+ # Copies over the base sinatra starting project
22
+ def create_controller
23
+ if in_app_root?(options[:root])
24
+ @app_name = fetch_app_name(options[:root])
25
+ template "templates/controller.rb.tt", File.join(options[:root] || '.', "app/controllers/#{name}.rb")
26
+ template "templates/helper.rb.tt", File.join(options[:root] || '.', "app/helpers/#{name}_helper.rb")
27
+ include_component_module_for(:test, options[:root])
28
+ generate_controller_test(name, options[:root] || '.')
29
+ else
30
+ say "You are not at the root of a Padrino application! (config/boot.rb not found)" and return unless in_app_root?
31
+ end
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -5,17 +5,17 @@ module Padrino
5
5
  class Skeleton < Thor::Group
6
6
  # Define the source template root
7
7
  def self.source_root; File.dirname(__FILE__); end
8
- def self.banner; "padrino-gen [app_name] [path] [options]"; end
8
+ def self.banner; "padrino-gen project [name] [path] [options]"; end
9
9
 
10
10
  # Include related modules
11
11
  include Thor::Actions
12
12
  include Padrino::Generators::Actions
13
13
  include Padrino::Generators::Components::Actions
14
14
 
15
- desc "Description:\n\n\tpadrino-gen generate a Padrino skeleton or application."
15
+ desc "Description:\n\n\tpadrino-gen project generates a new Padrino project"
16
16
 
17
- argument :name, :desc => "The name of your sinatra app"
18
- argument :path, :desc => "The path to create your app"
17
+ argument :name, :desc => "The name of your padrino project"
18
+ argument :path, :desc => "The path to create your padrino project"
19
19
  class_option :run_bundler, :aliases => '-b', :default => false, :type => :boolean
20
20
 
21
21
  # Definitions for the available customizable components
@@ -25,11 +25,11 @@ module Padrino
25
25
  component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs]
26
26
  component_option :renderer, "template engine", :aliases => '-r', :choices => [:erb, :haml]
27
27
 
28
- # Copies over the base sinatra starting application
28
+ # Copies over the base sinatra starting project
29
29
  def setup_skeleton
30
30
  self.destination_root = File.join(path, name)
31
31
  @class_name = name.classify
32
- directory("project/", self.destination_root)
32
+ directory("skeleton/", self.destination_root)
33
33
  store_component_config('.components')
34
34
  end
35
35
 
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ class <%= @class_name %> < Padrino::Application
2
+ configure do
3
+ # Application-specific configuration options
4
+ # set :sessions, false # Enabled by default
5
+ # set :log_to_file, true # Log to file instead of stdout (default is stdout in development)
6
+ # set :reload, false # Reload application files (default in development)
7
+ # disable :padrino_helpers # Disables padrino markup helpers (enabled by default)
8
+ # disable :flash # Disables rack-flash (enabled by default)
9
+ end
10
+ end
@@ -1,6 +1,3 @@
1
1
  RACK_ENV = ENV["RACK_ENV"] ||= "development" unless defined? RACK_ENV
2
2
  require File.dirname(__FILE__) + '/config/boot.rb'
3
-
4
- # Mount and run padrino applications
5
- Padrino.mount("core").to("/")
6
3
  run Padrino.application
@@ -0,0 +1,15 @@
1
+ =begin
2
+
3
+ This file mounts each application within the Padrino project to a specific path.
4
+ You can mount additional applications using any of these below:
5
+
6
+ Padrino.mount("blog").to('/blog')
7
+ Padrino.mount("blog", :app_class => "BlogApp").to('/blog')
8
+ Padrino.mount("blog", :app_file => "/path/to/blog/app.rb").to('/blog')
9
+
10
+ Note that mounted apps by default should be placed into 'apps/app_name'
11
+
12
+ =end
13
+
14
+ # Mounts the core application for this project
15
+ Padrino.mount_core(:app_class => "<%= @class_name %>")
@@ -0,0 +1,4 @@
1
+ # AUTOGENERATED FILE -- Don't change this file unless you know what you are doing!
2
+ PADRINO_ROOT = File.dirname(__FILE__) + '/..' unless defined? PADRINO_ROOT
3
+ require 'padrino'
4
+ Padrino.load!
@@ -0,0 +1,9 @@
1
+ # Initializers can be used to configure information about your padrino app
2
+ # The following format is used because initializers are applied as plugins into the application
3
+
4
+ module ExampleInitializer
5
+ def self.registered(app)
6
+ # Manipulate 'app' here to register components or adjust configuration
7
+ # app.set :example, "foo"
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ <%= @class_name %>::urls do
2
+ # map(:index).to("/")
3
+ # map(:test).to("/test")
4
+ end
5
+
6
+ =begin
7
+
8
+ This file contains named routes to be used in the Padrino application.
9
+ To create named routes simply add them to the urls block below.
10
+
11
+ You can specify simple routes as:
12
+
13
+ map(:index).to("/")
14
+ map(:test).to("/test")
15
+
16
+ Routes can also contain query parameters:
17
+
18
+ map(:account).to("/the/accounts/:name/and/:id")
19
+
20
+ Routes can also be grouped by a namespaced:
21
+
22
+ map :admin do |namespace|
23
+ namespace.map(:show).to("/admin/:id/show")
24
+ namespace.map(:destroy).to("/admin/:id/destroy")
25
+ end
26
+
27
+ Routes can then be accessed in controllers and views:
28
+
29
+ url_for(:account, :id => 1, :name => 'first')
30
+ url_for(:admin, :show, :id => 25)
31
+
32
+ To define the controller actions for a named route simply refer to the alias symbol:
33
+
34
+ # Configure the routes using the named alias
35
+ get(:account) { "name: params[:name] - id: params[:id]" }
36
+ get(:accounts) { "I am the body for the url /the/accounts/index" }
37
+ # and for namespaced routes
38
+ namespace :admin do
39
+ get :show do
40
+ "admin show for #{params[:id]}"
41
+ end
42
+ end
43
+
44
+ =end
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ # Define your named routes inside config/urls.rb
2
+ # You can also use unnamed routes by defining them directly
3
+
4
+ <%= @app_name %>::controllers do
5
+ # get :index do
6
+ # session[:foo] = "bar"
7
+ # haml_template 'index'
8
+ # end
9
+
10
+ # get "/example" do
11
+ # "Hello world!"
12
+ # end
13
+ end
@@ -0,0 +1,7 @@
1
+ # Helper methods defined here can be accessed in any controller or view in the application
2
+
3
+ <%= @app_name %>::helpers do
4
+ # def simple_helper_method
5
+ # ...
6
+ # end
7
+ end
data/lib/padrino-gen.rb CHANGED
@@ -1 +1,4 @@
1
- Dir[File.dirname(__FILE__) + "/generators/**/*.rb"].each { |lib| require lib }
1
+ Dir[File.dirname(__FILE__) + "/generators/{components}/**/*.rb"].each { |lib| require lib }
2
+ require File.dirname(__FILE__) + "/generators/actions.rb"
3
+ require File.dirname(__FILE__) + "/generators/skeleton.rb"
4
+ require File.dirname(__FILE__) + "/generators/controller.rb"
data/padrino-gen.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-gen}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2009-11-17}
12
+ s.date = %q{2009-11-18}
13
13
  s.default_executable = %q{padrino-gen}
14
14
  s.description = %q{Generators for easily creating and building padrino applications from the console}
15
15
  s.email = %q{nesquena@gmail.com}
@@ -47,19 +47,36 @@ Gem::Specification.new do |s|
47
47
  "lib/generators/components/tests/rspec_test_gen.rb",
48
48
  "lib/generators/components/tests/shoulda_test_gen.rb",
49
49
  "lib/generators/components/tests/testspec_test_gen.rb",
50
- "lib/generators/project/.gitignore",
51
- "lib/generators/project/Gemfile",
52
- "lib/generators/project/apps/.empty_directory",
53
- "lib/generators/project/config.ru",
54
- "lib/generators/project/config/boot.rb",
55
- "lib/generators/project/lib/.empty_directory",
56
- "lib/generators/project/test/test_config.rb.tt",
57
- "lib/generators/project/tmp/.emptydirectory",
50
+ "lib/generators/controller.rb",
58
51
  "lib/generators/skeleton.rb",
52
+ "lib/generators/skeleton/.gitignore",
53
+ "lib/generators/skeleton/Gemfile",
54
+ "lib/generators/skeleton/app.rb.tt",
55
+ "lib/generators/skeleton/app/.empty_directory",
56
+ "lib/generators/skeleton/app/controllers/.empty_directory",
57
+ "lib/generators/skeleton/app/helpers/.empty_directory",
58
+ "lib/generators/skeleton/app/models/.empty_directory",
59
+ "lib/generators/skeleton/app/views/.empty_directory",
60
+ "lib/generators/skeleton/config.ru",
61
+ "lib/generators/skeleton/config/apps.rb.tt",
62
+ "lib/generators/skeleton/config/boot.rb",
63
+ "lib/generators/skeleton/config/initializers/.empty_directory",
64
+ "lib/generators/skeleton/config/initializers/example.rb",
65
+ "lib/generators/skeleton/config/urls.rb.tt",
66
+ "lib/generators/skeleton/lib/.empty_directory",
67
+ "lib/generators/skeleton/public/images/.empty_directory",
68
+ "lib/generators/skeleton/public/javascripts/.empty_directory",
69
+ "lib/generators/skeleton/public/stylesheets/.empty_directory",
70
+ "lib/generators/skeleton/test/test_config.rb.tt",
71
+ "lib/generators/skeleton/tmp/.emptydirectory",
72
+ "lib/generators/skeleton/vendor/gems/.empty_directory",
73
+ "lib/generators/templates/controller.rb.tt",
74
+ "lib/generators/templates/helper.rb.tt",
59
75
  "lib/padrino-gen.rb",
60
76
  "padrino-gen.gemspec",
61
77
  "test/active_support_helpers.rb",
62
78
  "test/helper.rb",
79
+ "test/test_controller_generator.rb",
63
80
  "test/test_skeleton_generator.rb"
64
81
  ]
65
82
  s.homepage = %q{http://github.com/padrino/padrino-gen}
@@ -74,6 +91,7 @@ Gem::Specification.new do |s|
74
91
 
75
92
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
76
93
  s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
94
+ s.add_runtime_dependency(%q<padrino-core>, [">= 0.1.1"])
77
95
  s.add_runtime_dependency(%q<thor>, [">= 0.11.8"])
78
96
  s.add_runtime_dependency(%q<bundler>, [">= 0"])
79
97
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
@@ -83,6 +101,7 @@ Gem::Specification.new do |s|
83
101
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
84
102
  else
85
103
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
104
+ s.add_dependency(%q<padrino-core>, [">= 0.1.1"])
86
105
  s.add_dependency(%q<thor>, [">= 0.11.8"])
87
106
  s.add_dependency(%q<bundler>, [">= 0"])
88
107
  s.add_dependency(%q<haml>, [">= 2.2.1"])
@@ -93,6 +112,7 @@ Gem::Specification.new do |s|
93
112
  end
94
113
  else
95
114
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
115
+ s.add_dependency(%q<padrino-core>, [">= 0.1.1"])
96
116
  s.add_dependency(%q<thor>, [">= 0.11.8"])
97
117
  s.add_dependency(%q<bundler>, [">= 0"])
98
118
  s.add_dependency(%q<haml>, [">= 2.2.1"])
@@ -0,0 +1,56 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+ require 'thor'
3
+
4
+ class TestControllerGenerator < Test::Unit::TestCase
5
+ def setup
6
+ @skeleton = Padrino::Generators::Skeleton.dup
7
+ @contgen = Padrino::Generators::Controller.dup
8
+ `rm -rf /tmp/sample_app`
9
+ end
10
+
11
+ context 'the controller generator' do
12
+ should "fail outside app root" do
13
+ output = silence_logger { @contgen.start(['demo', '-r=/tmp']) }
14
+ assert_match(/not at the root/, output)
15
+ assert !File.exist?('/tmp/app/controllers/demo.rb')
16
+ end
17
+
18
+ should "generate controller within existing application" do
19
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '-t=bacon']) }
20
+ silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
21
+ assert_match_in_file(/SampleApp::controllers do/m, '/tmp/sample_app/app/controllers/demo_items.rb')
22
+ assert_match_in_file(/SampleApp::helpers do/m, '/tmp/sample_app/app/helpers/demo_items_helper.rb')
23
+ end
24
+
25
+ should "generate controller test for bacon" do
26
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '-t=bacon']) }
27
+ silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
28
+ assert_match_in_file(/describe "DemoItemsController" do/m, '/tmp/sample_app/test/controllers/demo_items_controller_test.rb')
29
+ end
30
+
31
+ should "generate controller test for riot" do
32
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '-t=riot']) }
33
+ silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
34
+ assert_match_in_file(/context "DemoItemsController" do/m, '/tmp/sample_app/test/controllers/demo_items_controller_test.rb')
35
+ end
36
+
37
+ should "generate controller test for testspec" do
38
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '-t=testspec']) }
39
+ silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
40
+ assert_match_in_file(/context "DemoItemsController" do/m, '/tmp/sample_app/test/controllers/demo_items_controller_test.rb')
41
+ end
42
+
43
+ should "generate controller test for rspec" do
44
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '-t=rspec']) }
45
+ silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
46
+ assert_match_in_file(/describe "DemoItemsController" do/m, '/tmp/sample_app/test/controllers/demo_items_controller_spec.rb')
47
+ end
48
+
49
+ should "generate controller test for shoulda" do
50
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '-t=shoulda']) }
51
+ silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
52
+ expected_pattern = /class DemoItemsControllerTest < Test::Unit::TestCase/m
53
+ assert_match_in_file(expected_pattern, '/tmp/sample_app/test/controllers/demo_items_controller_test.rb')
54
+ end
55
+ end
56
+ end
@@ -4,18 +4,25 @@ require 'thor'
4
4
  class TestSkeletonGenerator < Test::Unit::TestCase
5
5
  def setup
6
6
  `rm -rf /tmp/sample_app`
7
+ @skeleton = Padrino::Generators::Skeleton.dup
7
8
  end
8
9
 
9
10
  context 'the skeleton generator' do
10
11
  should "allow simple generator to run and create base_app with no options" do
11
- assert_nothing_raised { silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--script=none']) } }
12
+ assert_nothing_raised { silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none']) } }
12
13
  assert File.exist?('/tmp/sample_app')
13
- assert File.exist?('/tmp/sample_app/apps')
14
+ assert File.exist?('/tmp/sample_app/app')
14
15
  assert File.exist?('/tmp/sample_app/config/boot.rb')
15
16
  assert File.exist?('/tmp/sample_app/test/test_config.rb')
16
17
  end
18
+ should "place app specific names into correct files" do
19
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none']) }
20
+ assert_match_in_file(/class SampleApp < Padrino::Application/m, '/tmp/sample_app/app.rb')
21
+ assert_match_in_file(/Padrino.mount_core\(:app_class => "SampleApp"\)/m, '/tmp/sample_app/config/apps.rb')
22
+ assert_match_in_file(/SampleApp::urls do/m, '/tmp/sample_app/config/urls.rb')
23
+ end
17
24
  should "create components file containing options chosen with defaults" do
18
- silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp']) }
25
+ silence_logger { @skeleton.start(['sample_app', '/tmp']) }
19
26
  components_chosen = YAML.load_file('/tmp/sample_app/.components')
20
27
  assert_equal 'datamapper', components_chosen[:orm]
21
28
  assert_equal 'bacon', components_chosen[:test]
@@ -25,7 +32,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
25
32
  end
26
33
  should "create components file containing options chosen" do
27
34
  component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb']
28
- silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', *component_options]) }
35
+ silence_logger { @skeleton.start(['sample_app', '/tmp', *component_options]) }
29
36
  components_chosen = YAML.load_file('/tmp/sample_app/.components')
30
37
  assert_equal 'datamapper', components_chosen[:orm]
31
38
  assert_equal 'riot', components_chosen[:test]
@@ -35,7 +42,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
35
42
  end
36
43
  should "output to log components being applied" do
37
44
  component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb']
38
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', *component_options]) }
45
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', *component_options]) }
39
46
  assert_match /Applying.*?datamapper.*?orm/, buffer
40
47
  assert_match /Applying.*?riot.*?test/, buffer
41
48
  assert_match /Applying.*?mocha.*?mock/, buffer
@@ -43,7 +50,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
43
50
  assert_match /Applying.*?erb.*?renderer/, buffer
44
51
  end
45
52
  should "output gem files for base app" do
46
- silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--script=none']) }
53
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none']) }
47
54
  assert_match_in_file(/gem 'sinatra'/, '/tmp/sample_app/Gemfile')
48
55
  assert_match_in_file(/gem 'padrino'/, '/tmp/sample_app/Gemfile')
49
56
  assert_match_in_file(/gem 'rack-flash'/, '/tmp/sample_app/Gemfile')
@@ -53,14 +60,14 @@ class TestSkeletonGenerator < Test::Unit::TestCase
53
60
 
54
61
  context "a generator for mock component" do
55
62
  should "properly generate for rr" do
56
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--mock=rr', '--script=none']) }
63
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--mock=rr', '--script=none']) }
57
64
  assert_match /Applying.*?rr.*?mock/, buffer
58
65
  assert_match_in_file(/gem 'rr'/, '/tmp/sample_app/Gemfile')
59
66
  assert_match_in_file(/include RR::Adapters::RRMethods/m, '/tmp/sample_app/test/test_config.rb')
60
67
  end
61
68
 
62
69
  should "properly generate default for mocha" do
63
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--mock=mocha', '--script=none']) }
70
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--mock=mocha', '--script=none']) }
64
71
  assert_match /Applying.*?mocha.*?mock/, buffer
65
72
  assert_match_in_file(/gem 'mocha'/, '/tmp/sample_app/Gemfile')
66
73
  assert_match_in_file(/include Mocha::API/m, '/tmp/sample_app/test/test_config.rb')
@@ -69,53 +76,52 @@ class TestSkeletonGenerator < Test::Unit::TestCase
69
76
 
70
77
  context "the generator for orm components" do
71
78
  should "properly generate for sequel" do
72
- Padrino::Generators::Skeleton.instance_eval("undef setup_orm if respond_to?('setup_orm')")
73
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--orm=sequel', '--script=none']) }
79
+ @skeleton.instance_eval("undef setup_orm if respond_to?('setup_orm')")
80
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=sequel', '--script=none']) }
74
81
  assert_match /Applying.*?sequel.*?orm/, buffer
75
82
  assert_match_in_file(/gem 'sequel'/, '/tmp/sample_app/Gemfile')
76
- assert_match_in_file(/SequelInitializer/, '/tmp/sample_app/config/initializers/sequel.rb')
77
- # assert_match_in_file(/class User < Sequel::Model/, '/tmp/sample_app/app/models/user.rb')
83
+ assert_match_in_file(/Sequel.connect/, '/tmp/sample_app/config/database.rb')
78
84
  end
79
85
 
80
86
  should "properly generate for activerecord" do
81
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--orm=activerecord', '--script=none']) }
87
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=activerecord', '--script=none']) }
82
88
  assert_match /Applying.*?activerecord.*?orm/, buffer
83
89
  assert_match_in_file(/gem 'activerecord'/, '/tmp/sample_app/Gemfile')
84
- assert_match_in_file(/ActiveRecordInitializer/, '/tmp/sample_app/config/initializers/active_record.rb')
85
90
  assert_match_in_file(/Migrate the database/, '/tmp/sample_app/Rakefile')
91
+ assert_match_in_file(/ActiveRecord::Base.establish_connection/, '/tmp/sample_app/config/database.rb')
86
92
  end
87
93
 
88
94
  should "properly generate default for datamapper" do
89
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--orm=datamapper', '--script=none']) }
95
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=datamapper', '--script=none']) }
90
96
  assert_match /Applying.*?datamapper.*?orm/, buffer
91
97
  assert_match_in_file(/gem 'dm-core'/, '/tmp/sample_app/Gemfile')
92
- assert_match_in_file(/DataMapperInitializer/, '/tmp/sample_app/config/initializers/data_mapper.rb')
98
+ assert_match_in_file(/DataMapper.setup/, '/tmp/sample_app/config/database.rb')
93
99
  end
94
100
 
95
101
  should "properly generate for mongomapper" do
96
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--orm=mongomapper', '--script=none']) }
102
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=mongomapper', '--script=none']) }
97
103
  assert_match /Applying.*?mongomapper.*?orm/, buffer
98
104
  assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/sample_app/Gemfile')
99
- assert_match_in_file(/MongoDbInitializer/, '/tmp/sample_app/config/initializers/mongo_db.rb')
105
+ assert_match_in_file(/MongoMapper.database/, '/tmp/sample_app/config/database.rb')
100
106
  end
101
107
 
102
108
  should "properly generate for couchrest" do
103
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--orm=couchrest', '--script=none']) }
109
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=couchrest', '--script=none']) }
104
110
  assert_match /Applying.*?couchrest.*?orm/, buffer
105
111
  assert_match_in_file(/gem 'couchrest'/, '/tmp/sample_app/Gemfile')
106
- assert_match_in_file(/CouchRestInitializer/, '/tmp/sample_app/config/initializers/couch_rest.rb')
112
+ assert_match_in_file(/CouchRest.database!/, '/tmp/sample_app/config/database.rb')
107
113
  end
108
114
  end
109
115
 
110
116
  context "the generator for renderer component" do
111
117
  should "properly generate default for erb" do
112
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--renderer=erb', '--script=none']) }
118
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--renderer=erb', '--script=none']) }
113
119
  assert_match /Applying.*?erb.*?renderer/, buffer
114
120
  assert_match_in_file(/gem 'erubis'/, '/tmp/sample_app/Gemfile')
115
121
  end
116
122
 
117
123
  should "properly generate for haml" do
118
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--renderer=haml','--script=none']) }
124
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--renderer=haml','--script=none']) }
119
125
  assert_match /Applying.*?haml.*?renderer/, buffer
120
126
  assert_match_in_file(/gem 'haml'/, '/tmp/sample_app/Gemfile')
121
127
  end
@@ -123,20 +129,20 @@ class TestSkeletonGenerator < Test::Unit::TestCase
123
129
 
124
130
  context "the generator for script component" do
125
131
  should "properly generate for jquery" do
126
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--script=jquery']) }
132
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=jquery']) }
127
133
  assert_match /Applying.*?jquery.*?script/, buffer
128
134
  assert File.exist?('/tmp/sample_app/public/javascripts/jquery.min.js')
129
135
  end
130
136
 
131
137
  should "properly generate for prototype" do
132
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--script=prototype']) }
138
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=prototype']) }
133
139
  assert_match /Applying.*?prototype.*?script/, buffer
134
140
  assert File.exist?('/tmp/sample_app/public/javascripts/prototype.js')
135
141
  assert File.exist?('/tmp/sample_app/public/javascripts/lowpro.js')
136
142
  end
137
143
 
138
144
  should "properly generate for rightjs" do
139
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--script=rightjs']) }
145
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=rightjs']) }
140
146
  assert_match /Applying.*?rightjs.*?script/, buffer
141
147
  assert File.exist?('/tmp/sample_app/public/javascripts/right-min.js')
142
148
  end
@@ -144,35 +150,35 @@ class TestSkeletonGenerator < Test::Unit::TestCase
144
150
 
145
151
  context "the generator for test component" do
146
152
  should "properly default generate for bacon" do
147
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--test=bacon', '--script=none']) }
153
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=bacon', '--script=none']) }
148
154
  assert_match /Applying.*?bacon.*?test/, buffer
149
155
  assert_match_in_file(/gem 'bacon'/, '/tmp/sample_app/Gemfile')
150
156
  assert_match_in_file(/Bacon::Context/, '/tmp/sample_app/test/test_config.rb')
151
157
  end
152
158
 
153
159
  should "properly generate for riot" do
154
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--test=riot', '--script=none']) }
160
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=riot', '--script=none']) }
155
161
  assert_match /Applying.*?riot.*?test/, buffer
156
162
  assert_match_in_file(/gem 'riot'/, '/tmp/sample_app/Gemfile')
157
163
  assert_match_in_file(/Riot::Situation/, '/tmp/sample_app/test/test_config.rb')
158
164
  end
159
165
 
160
166
  should "properly generate for rspec" do
161
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--test=rspec', '--script=none']) }
167
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=rspec', '--script=none']) }
162
168
  assert_match /Applying.*?rspec.*?test/, buffer
163
169
  assert_match_in_file(/gem 'spec'/, '/tmp/sample_app/Gemfile')
164
170
  assert_match_in_file(/Spec::Runner/, '/tmp/sample_app/test/test_config.rb')
165
171
  end
166
172
 
167
173
  should "properly generate for shoulda" do
168
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--test=shoulda', '--script=none']) }
174
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=shoulda', '--script=none']) }
169
175
  assert_match /Applying.*?shoulda.*?test/, buffer
170
176
  assert_match_in_file(/gem 'shoulda'/, '/tmp/sample_app/Gemfile')
171
177
  assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
172
178
  end
173
179
 
174
180
  should "properly generate for testspec" do
175
- buffer = silence_logger { Padrino::Generators::Skeleton.start(['sample_app', '/tmp', '--test=testspec', '--script=none']) }
181
+ buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=testspec', '--script=none']) }
176
182
  assert_match /Applying.*?testspec.*?test/, buffer
177
183
  assert_match_in_file(/gem 'test\/spec'/, '/tmp/sample_app/Gemfile')
178
184
  assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-11-17 00:00:00 -08:00
15
+ date: 2009-11-18 00:00:00 -08:00
16
16
  default_executable: padrino-gen
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -25,6 +25,16 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.2
27
27
  version:
28
+ - !ruby/object:Gem::Dependency
29
+ name: padrino-core
30
+ type: :runtime
31
+ version_requirement:
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.1.1
37
+ version:
28
38
  - !ruby/object:Gem::Dependency
29
39
  name: thor
30
40
  type: :runtime
@@ -131,19 +141,36 @@ files:
131
141
  - lib/generators/components/tests/rspec_test_gen.rb
132
142
  - lib/generators/components/tests/shoulda_test_gen.rb
133
143
  - lib/generators/components/tests/testspec_test_gen.rb
134
- - lib/generators/project/.gitignore
135
- - lib/generators/project/Gemfile
136
- - lib/generators/project/apps/.empty_directory
137
- - lib/generators/project/config.ru
138
- - lib/generators/project/config/boot.rb
139
- - lib/generators/project/lib/.empty_directory
140
- - lib/generators/project/test/test_config.rb.tt
141
- - lib/generators/project/tmp/.emptydirectory
144
+ - lib/generators/controller.rb
142
145
  - lib/generators/skeleton.rb
146
+ - lib/generators/skeleton/.gitignore
147
+ - lib/generators/skeleton/Gemfile
148
+ - lib/generators/skeleton/app.rb.tt
149
+ - lib/generators/skeleton/app/.empty_directory
150
+ - lib/generators/skeleton/app/controllers/.empty_directory
151
+ - lib/generators/skeleton/app/helpers/.empty_directory
152
+ - lib/generators/skeleton/app/models/.empty_directory
153
+ - lib/generators/skeleton/app/views/.empty_directory
154
+ - lib/generators/skeleton/config.ru
155
+ - lib/generators/skeleton/config/apps.rb.tt
156
+ - lib/generators/skeleton/config/boot.rb
157
+ - lib/generators/skeleton/config/initializers/.empty_directory
158
+ - lib/generators/skeleton/config/initializers/example.rb
159
+ - lib/generators/skeleton/config/urls.rb.tt
160
+ - lib/generators/skeleton/lib/.empty_directory
161
+ - lib/generators/skeleton/public/images/.empty_directory
162
+ - lib/generators/skeleton/public/javascripts/.empty_directory
163
+ - lib/generators/skeleton/public/stylesheets/.empty_directory
164
+ - lib/generators/skeleton/test/test_config.rb.tt
165
+ - lib/generators/skeleton/tmp/.emptydirectory
166
+ - lib/generators/skeleton/vendor/gems/.empty_directory
167
+ - lib/generators/templates/controller.rb.tt
168
+ - lib/generators/templates/helper.rb.tt
143
169
  - lib/padrino-gen.rb
144
170
  - padrino-gen.gemspec
145
171
  - test/active_support_helpers.rb
146
172
  - test/helper.rb
173
+ - test/test_controller_generator.rb
147
174
  - test/test_skeleton_generator.rb
148
175
  has_rdoc: true
149
176
  homepage: http://github.com/padrino/padrino-gen
@@ -1,6 +0,0 @@
1
- # This file is merely for beginning the boot process
2
- PADRINO_ROOT = File.dirname(__FILE__) + '/..' unless defined? PADRINO_ROOT
3
-
4
- # Loads the required files into the application
5
- require 'padrino'
6
- Padrino.load!