padrino-gen 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,14 +7,14 @@ To install the 'full-stack' padrino framework, simply grab the latest version fr
7
7
  $ sudo gem install padrino --source http://gemcutter.org
8
8
 
9
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.
10
+ Now you are ready to use this gem to enhance your existing Sinatra projects or build new Padrino applications.
11
11
 
12
12
  == Overview
13
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.
14
+ Padrino comes preloaded with flexible code generators powered in part by the excellent Thor gem
15
+ (incidentally also used in the Rails 3 generators). These generators are intended to allow for easy code generation
16
+ both in creating new applications and building on existing ones. The generators have been built to be as library agnostic
17
+ as possible, supporting a myriad of test frameworks, js libraries, mocking libraries, etc.
18
18
 
19
19
  See the wiki article for additional information: <...WIKI...>
20
20
 
@@ -52,6 +52,10 @@ There is also support for aliases for each component within the command:
52
52
 
53
53
  $ padrino-gen demo_app . -t=rspec -r=haml -m=rr -s=jquery -d=datamapper
54
54
 
55
+ You can also instruct the generator to skip a certain component to avoid using one at all (or to use your own):
56
+
57
+ $ padrino-gen demo_app . --test=none --renderer=none
58
+
55
59
  The available components and their default options are listed below:
56
60
 
57
61
  * test: <tt>bacon</tt> (default), <tt>shoulda</tt>, <tt>rspec</tt>, <tt>testspec</tt>, <tt>riot</tt>
@@ -70,8 +74,8 @@ If not executed manually, the bundling will be performed automatically the first
70
74
  Note that this command only has to be performed when the application is first generated or when the Gemfile is modified.
71
75
 
72
76
  The generator framework within padrino is extensible and additional components and tools can be added easily.
73
- This would be achieved through forking our project and reading through the code in <tt>/generators/sinatra_generator.rb</tt> and
74
- the setup instructions inside the relevant files within <tt>/generators/components/</tt>. We are happy to accept pull requests
77
+ This would be achieved through forking our project and reading through the code in <tt>lib/generators/skeleton.rb</tt> and
78
+ the setup instructions inside the relevant files within <tt>lib/generators/components/</tt>. We are happy to accept pull requests
75
79
  for additional component types not originally included (although helping us maintain them would also be appreciated).
76
80
 
77
81
  === Model Generator ===
data/Rakefile CHANGED
@@ -8,14 +8,15 @@ begin
8
8
  gem.summary = "Generators for easily creating and building padrino applications"
9
9
  gem.description = "Generators for easily creating and building padrino applications from the console"
10
10
  gem.email = "nesquena@gmail.com"
11
- gem.homepage = "http://github.com/padrino/padrino-gen"
11
+ gem.homepage = "http://github.com/padrino/padrino-framework/tree/master/padrino-gen"
12
12
  gem.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
13
+ gem.executables = ["padrino-gen"]
13
14
  gem.add_runtime_dependency "sinatra", ">= 0.9.2"
14
15
  gem.add_runtime_dependency "padrino-core", ">= 0.1.1"
15
16
  gem.add_runtime_dependency "thor", ">= 0.11.8"
16
- gem.add_runtime_dependency "bundler"
17
+ gem.add_runtime_dependency "bundler", ">= 0.5.0"
17
18
  gem.add_development_dependency "haml", ">= 2.2.1"
18
- gem.add_development_dependency "shoulda", ">= 0"
19
+ gem.add_development_dependency "shoulda", ">= 0"
19
20
  gem.add_development_dependency "mocha", ">= 0.9.7"
20
21
  gem.add_development_dependency "rack-test", ">= 0.5.0"
21
22
  gem.add_development_dependency "webrat", ">= 0.5.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/bin/padrino-gen CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- %w[rubygems activesupport thor].each { |gem| require gem }
2
+ %w[rubygems thor].each { |gem| require gem }
3
3
  require File.dirname(__FILE__) + "/../lib/padrino-gen"
4
4
 
5
- generator_mappings = ActiveSupport::OrderedHash.new
5
+ generator_mappings = SupportLite::OrderedHash.new
6
6
  generator_mappings[:app] = Padrino::Generators::Skeleton
7
7
  generator_mappings[:model] = Padrino::Generators::Model
8
8
  generator_mappings[:controller] = Padrino::Generators::Controller
@@ -97,7 +97,7 @@ module Padrino
97
97
  def component_option(name, caption, options = {})
98
98
  (@component_types ||= []) << name # TODO use ordered hash and combine with choices below
99
99
  (@available_choices ||= Hash.new({}))[name] = options[:choices]
100
- description = "The #{caption} component (#{options[:choices].join(', ')})"
100
+ description = "The #{caption} component (#{options[:choices].join(', ')}, none)"
101
101
  class_option name, :default => options[:choices].first, :aliases => options[:aliases], :desc => description
102
102
  end
103
103
 
@@ -2,6 +2,12 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Actions
5
+ BASE_TEST_HELPER = (<<-TEST).gsub(/^ {8}/, '')
6
+ RACK_ENV = 'test' unless defined?(RACK_ENV)
7
+ require File.dirname(__FILE__) + "/../config/boot"
8
+ Bundler.require_env(:testing)
9
+ TEST
10
+
5
11
  # Adds all the specified gems into the Gemfile for bundler
6
12
  # require_dependencies 'activerecord'
7
13
  # require_dependencies 'mocha', 'bacon', :env => :testing
@@ -25,8 +31,9 @@ module Padrino
25
31
  # insert_test_suite_setup('...CLASS_NAME...')
26
32
  # => inject_into_file("test/test_config.rb", TEST.gsub(/CLASS_NAME/, @class_name), :after => "set :environment, :test\n")
27
33
  def insert_test_suite_setup(suite_text, options={})
28
- options.reverse_merge!(:path => "test/test_config.rb", :after => /Test configuration\n/)
29
- inject_into_file(options[:path], suite_text.gsub(/CLASS_NAME/, @class_name), :after => options[:after])
34
+ test_helper_text = [BASE_TEST_HELPER, suite_text.gsub(/CLASS_NAME/, @class_name)].join("\n")
35
+ options.reverse_merge!(:path => "test/test_config.rb")
36
+ create_file(options[:path], test_helper_text)
30
37
  end
31
38
 
32
39
  # Injects the mock library include into the test class in test_config for setting up mock gen
@@ -34,6 +41,7 @@ module Padrino
34
41
  # => inject_into_file("test/test_config.rb", " include Mocha::API\n", :after => /class.*?\n/)
35
42
  def insert_mocking_include(library_name, options={})
36
43
  options.reverse_merge!(:indent => 2, :after => /class.*?\n/, :path => "test/test_config.rb")
44
+ return unless File.exist?(File.join(self.destination_root, options[:path]))
37
45
  include_text = indent_spaces(options[:indent]) + "include #{library_name}\n"
38
46
  inject_into_file(options[:path], include_text, :after => options[:after])
39
47
  end
@@ -52,6 +52,7 @@ module Padrino
52
52
  require_dependencies 'activerecord'
53
53
  create_file("config/database.rb", AR)
54
54
  create_file("Rakefile", RAKE)
55
+ empty_directory('app/models')
55
56
  end
56
57
 
57
58
  AR_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
@@ -19,6 +19,7 @@ module Padrino
19
19
  def setup_orm
20
20
  require_dependencies 'couchrest'
21
21
  create_file("config/database.rb", COUCHREST)
22
+ empty_directory('app/models')
22
23
  end
23
24
 
24
25
  CR_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
@@ -4,13 +4,14 @@ module Padrino
4
4
  module Orms
5
5
 
6
6
  module DatamapperGen
7
-
8
7
  DM = (<<-DM).gsub(/^ {10}/, '')
9
8
  module DatabaseSetup
10
9
  def self.registered(app)
11
10
  app.configure(:development) { DataMapper.setup(:default, 'your_dev_db_here') }
12
11
  app.configure(:production) { DataMapper.setup(:default, 'your_production_db_here') }
13
12
  app.configure(:test) { DataMapper.setup(:default, 'your_test_db_here') }
13
+ rescue ArgumentError => e
14
+ puts "Database options need to be configured within 'config/database.rb'!" if app.logging?
14
15
  end
15
16
  end
16
17
  DM
@@ -18,6 +19,7 @@ module Padrino
18
19
  def setup_orm
19
20
  require_dependencies 'dm-core', 'dm-validations'
20
21
  create_file("config/database.rb", DM)
22
+ empty_directory('app/models')
21
23
  end
22
24
 
23
25
  DM_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
@@ -28,23 +28,10 @@ module Padrino
28
28
  end
29
29
  MONGO
30
30
 
31
- CONCERNED = (<<-CONCERN).gsub(/^ {10}/, '')
32
- module MongoMapper
33
- module Document
34
- module ClassMethods
35
- # TODO find a cleaner way for it to know where to look for dependencies
36
- def concerned_with(*concerns)
37
- concerns.each { |concern| require_dependency "./app/models/\#{name.underscore}/\#{concern}" }
38
- end
39
- end
40
- end
41
- end
42
- CONCERN
43
-
44
31
  def setup_orm
45
32
  require_dependencies 'mongo_mapper'
46
33
  create_file("config/database.rb", MONGO)
47
- create_file("lib/ext/mongo_mapper.rb", CONCERNED)
34
+ empty_directory('app/models')
48
35
  end
49
36
 
50
37
  MM_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
@@ -19,6 +19,7 @@ module Padrino
19
19
  def setup_orm
20
20
  require_dependencies 'sequel'
21
21
  create_file("config/database.rb", SEQUEL)
22
+ empty_directory('app/models')
22
23
  end
23
24
 
24
25
  SQ_MODEL = (<<-MODEL).gsub(/^ {10}/, '')
@@ -40,7 +41,6 @@ module Padrino
40
41
  create_table :!TABLE! do
41
42
  primary_key :id
42
43
  # <type> <name>
43
- text :username, :unique => true, :null => false
44
44
  !FIELDS!
45
45
  end
46
46
  end
@@ -2,15 +2,29 @@ module Padrino
2
2
  module Generators
3
3
  module Components
4
4
  module Renderers
5
-
5
+
6
6
  module HamlGen
7
7
 
8
+ SASS_INIT = (<<-SASS).gsub(/^ {10}/, '')
9
+ # Enables support for SASS template reloading for rack.
10
+ # See http://nex-3.com/posts/88-sass-supports-rack for more details.
11
+
12
+ module SassInitializer
13
+ def self.registered(app)
14
+ require 'sass/plugin/rack'
15
+ app.use Sass::Plugin::Rack
16
+ end
17
+ end
18
+ SASS
19
+
8
20
  def setup_renderer
9
21
  require_dependencies 'haml'
22
+ create_file 'config/initializers/sass.rb', SASS_INIT
23
+ empty_directory 'public/stylesheets/sass'
10
24
  end
11
25
  end
12
-
26
+
13
27
  end
14
28
  end
15
29
  end
16
- end
30
+ end
@@ -6,6 +6,7 @@ module Padrino
6
6
  module JqueryGen
7
7
  def setup_script
8
8
  get("http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js", "public/javascripts/jquery.min.js")
9
+ create_file('public/javascripts/application.js')
9
10
  end
10
11
  end
11
12
 
@@ -7,6 +7,7 @@ module Padrino
7
7
  def setup_script
8
8
  get("http://prototypejs.org/assets/2009/8/31/prototype.js", "public/javascripts/prototype.js")
9
9
  get('http://github.com/nesquena/lowpro/raw/master/dist/lowpro.js', "public/javascripts/lowpro.js")
10
+ create_file('public/javascripts/application.js')
10
11
  end
11
12
  end
12
13
 
@@ -6,6 +6,7 @@ module Padrino
6
6
  module RightjsGen
7
7
  def setup_script
8
8
  get("http://rightjs.org/builds/current/right-min.js", "public/javascripts/right-min.js")
9
+ create_file('public/javascripts/application.js')
9
10
  end
10
11
  end
11
12
 
@@ -22,7 +22,6 @@ module Padrino
22
22
  # Copies over the base sinatra starting project
23
23
  def create_model
24
24
  if in_app_root?(options[:root])
25
- say "Name: #{name}, Fields: #{fields.inspect}"
26
25
  include_component_module_for(:orm, options[:root])
27
26
  include_component_module_for(:test, options[:root])
28
27
  migration_name = "create_#{name.pluralize.underscore}"
@@ -25,7 +25,7 @@ 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 project
28
+ # Copies over the Padrino base application skeleton
29
29
  def setup_skeleton
30
30
  self.destination_root = File.join(path, name)
31
31
  @class_name = name.classify
@@ -1,7 +1,6 @@
1
1
  .DS_Store
2
2
  log/**/*
3
3
  tmp/**/*
4
- vendor/gems/gems
5
- vendor/gems/specifications
6
- vendor/gems/doc
7
- vendor/gems/environment.rb
4
+ bin/*
5
+ vendor/gems/*
6
+ !vendor/gems/cache/
@@ -7,9 +7,14 @@ You can mount additional applications using any of these below:
7
7
  Padrino.mount("blog", :app_class => "BlogApp").to('/blog')
8
8
  Padrino.mount("blog", :app_file => "/path/to/blog/app.rb").to('/blog')
9
9
 
10
- Note that mounted apps by default should be placed into 'apps/app_name'
10
+ Note that mounted apps by default should be placed into 'apps/app_name'.
11
+
12
+ By default, this file simply mounts the core app which was generated with this project.
13
+ However, the mounted core can be modified as needed:
14
+
15
+ Padrino.mount_core(:app_file => "/path/to/file", :app_class => "Blog")
11
16
 
12
17
  =end
13
18
 
14
19
  # Mounts the core application for this project
15
- Padrino.mount_core(:app_class => "<%= @class_name %>")
20
+ Padrino.mount_core("<%= @class_name %>")
@@ -1,4 +1,4 @@
1
- # Define your named routes inside config/urls.rb
1
+ # Define your named routes inside config/urls.rb or define them inline
2
2
  # You can also use unnamed routes by defining them directly
3
3
 
4
4
  <%= @app_name %>.controllers do
@@ -6,6 +6,10 @@
6
6
  # session[:foo] = "bar"
7
7
  # haml_template 'index'
8
8
  # end
9
+
10
+ # get :sample, :map => "/sample/url" do
11
+ # "Hello world!"
12
+ # end
9
13
 
10
14
  # get "/example" do
11
15
  # "Hello world!"
data/lib/padrino-gen.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'padrino-core/support_lite'
1
2
  Dir[File.dirname(__FILE__) + "/generators/{components}/**/*.rb"].each { |lib| require lib }
2
3
  require File.dirname(__FILE__) + "/generators/actions.rb"
3
4
  Dir[File.dirname(__FILE__) + "/generators/{skeleton,mailer,controller,model}.rb"].each { |lib| require lib }
data/padrino-gen.gemspec CHANGED
@@ -5,26 +5,23 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-gen}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
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-20}
12
+ s.date = %q{2009-11-23}
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}
16
16
  s.executables = ["padrino-gen"]
17
17
  s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.rdoc"
18
+ "README.rdoc"
20
19
  ]
21
20
  s.files = [
22
21
  ".document",
23
22
  ".gitignore",
24
23
  "LICENSE",
25
24
  "README.rdoc",
26
- "README.rdoc",
27
- "Rakefile",
28
25
  "Rakefile",
29
26
  "VERSION",
30
27
  "bin/padrino-gen",
@@ -57,7 +54,6 @@ Gem::Specification.new do |s|
57
54
  "lib/generators/skeleton/app/app.rb.tt",
58
55
  "lib/generators/skeleton/app/controllers/.empty_directory",
59
56
  "lib/generators/skeleton/app/helpers/.empty_directory",
60
- "lib/generators/skeleton/app/models/.empty_directory",
61
57
  "lib/generators/skeleton/app/views/.empty_directory",
62
58
  "lib/generators/skeleton/config.ru",
63
59
  "lib/generators/skeleton/config/apps.rb.tt",
@@ -69,16 +65,13 @@ Gem::Specification.new do |s|
69
65
  "lib/generators/skeleton/public/images/.empty_directory",
70
66
  "lib/generators/skeleton/public/javascripts/.empty_directory",
71
67
  "lib/generators/skeleton/public/stylesheets/.empty_directory",
72
- "lib/generators/skeleton/test/test_config.rb.tt",
73
68
  "lib/generators/skeleton/tmp/.emptydirectory",
74
- "lib/generators/skeleton/vendor/gems/.empty_directory",
75
69
  "lib/generators/templates/controller.rb.tt",
76
70
  "lib/generators/templates/helper.rb.tt",
77
71
  "lib/generators/templates/mailer.rb.tt",
78
72
  "lib/generators/templates/mailer_initializer.rb.tt",
79
73
  "lib/padrino-gen.rb",
80
74
  "padrino-gen.gemspec",
81
- "test/active_support_helpers.rb",
82
75
  "test/helper.rb",
83
76
  "test/test_controller_generator.rb",
84
77
  "test/test_mailer_generator.rb",
@@ -86,7 +79,7 @@ Gem::Specification.new do |s|
86
79
  "test/test_model_generator.rb",
87
80
  "test/test_skeleton_generator.rb"
88
81
  ]
89
- s.homepage = %q{http://github.com/padrino/padrino-gen}
82
+ s.homepage = %q{http://github.com/padrino/padrino-framework/tree/master/padrino-gen}
90
83
  s.rdoc_options = ["--charset=UTF-8"]
91
84
  s.require_paths = ["lib"]
92
85
  s.rubygems_version = %q{1.3.5}
@@ -100,7 +93,7 @@ Gem::Specification.new do |s|
100
93
  s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
101
94
  s.add_runtime_dependency(%q<padrino-core>, [">= 0.1.1"])
102
95
  s.add_runtime_dependency(%q<thor>, [">= 0.11.8"])
103
- s.add_runtime_dependency(%q<bundler>, [">= 0"])
96
+ s.add_runtime_dependency(%q<bundler>, [">= 0.5.0"])
104
97
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
105
98
  s.add_development_dependency(%q<shoulda>, [">= 0"])
106
99
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
@@ -110,7 +103,7 @@ Gem::Specification.new do |s|
110
103
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
111
104
  s.add_dependency(%q<padrino-core>, [">= 0.1.1"])
112
105
  s.add_dependency(%q<thor>, [">= 0.11.8"])
113
- s.add_dependency(%q<bundler>, [">= 0"])
106
+ s.add_dependency(%q<bundler>, [">= 0.5.0"])
114
107
  s.add_dependency(%q<haml>, [">= 2.2.1"])
115
108
  s.add_dependency(%q<shoulda>, [">= 0"])
116
109
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -121,7 +114,7 @@ Gem::Specification.new do |s|
121
114
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
122
115
  s.add_dependency(%q<padrino-core>, [">= 0.1.1"])
123
116
  s.add_dependency(%q<thor>, [">= 0.11.8"])
124
- s.add_dependency(%q<bundler>, [">= 0"])
117
+ s.add_dependency(%q<bundler>, [">= 0.5.0"])
125
118
  s.add_dependency(%q<haml>, [">= 2.2.1"])
126
119
  s.add_dependency(%q<shoulda>, [">= 0"])
127
120
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
data/test/helper.rb CHANGED
@@ -7,14 +7,9 @@ require 'webrat'
7
7
 
8
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
9
  $LOAD_PATH.unshift(File.dirname(__FILE__))
10
- require 'active_support_helpers'
11
- require 'padrino-helpers'
12
10
  require 'padrino-gen'
13
11
 
14
12
  class Test::Unit::TestCase
15
- include Padrino::Helpers::OutputHelpers
16
- include Padrino::Helpers::TagHelpers
17
- include Padrino::Helpers::AssetTagHelpers
18
13
  include Rack::Test::Methods
19
14
  include Webrat::Methods
20
15
  include Webrat::Matchers
@@ -47,7 +42,26 @@ class Test::Unit::TestCase
47
42
  raise "Please specify a block!" if html.blank?
48
43
  assert matcher.matches?(html), matcher.failure_message
49
44
  end
45
+
46
+ # assert_file_exists('/tmp/app')
47
+ def assert_file_exists(file_path)
48
+ assert File.exist?(file_path), "File at path '#{file_path}' does not exist!"
49
+ end
50
+ alias assert_dir_exists assert_file_exists
51
+
52
+ # assert_no_file_exists('/tmp/app')
53
+ def assert_no_file_exists(file_path)
54
+ assert !File.exist?(file_path), "File should not exist at path '#{file_path}' but was found!"
55
+ end
56
+ alias assert_no_dir_exists assert_no_file_exists
50
57
 
58
+ # Asserts that a file matches the pattern
59
+ def assert_match_in_file(pattern, file)
60
+ File.exist?(file) ? assert_match(pattern, File.read(file)) : assert_file_exists(file)
61
+ end
62
+ end
63
+
64
+ class Object
51
65
  # Silences the output by redirecting to stringIO
52
66
  # silence_logger { ...commands... } => "...output..."
53
67
  def silence_logger(&block)
@@ -57,12 +71,6 @@ class Test::Unit::TestCase
57
71
  $stdout = orig_stdout
58
72
  log_buffer.rewind && log_buffer.read
59
73
  end
60
-
61
- # Asserts that a file matches the pattern
62
- def assert_match_in_file(pattern, file)
63
- assert File.exist?(file), "File '#{file}' does not exist!"
64
- assert_match pattern, File.read(file)
65
- end
66
74
  end
67
75
 
68
76
  module Webrat
@@ -12,7 +12,7 @@ class TestControllerGenerator < Test::Unit::TestCase
12
12
  should "fail outside app root" do
13
13
  output = silence_logger { @contgen.start(['demo', '-r=/tmp']) }
14
14
  assert_match(/not at the root/, output)
15
- assert !File.exist?('/tmp/app/controllers/demo.rb')
15
+ assert_no_file_exists('/tmp/app/controllers/demo.rb')
16
16
  end
17
17
 
18
18
  should "generate controller within existing application" do
@@ -20,7 +20,7 @@ class TestControllerGenerator < Test::Unit::TestCase
20
20
  silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
21
21
  assert_match_in_file(/SampleApp.controllers do/m, '/tmp/sample_app/app/controllers/demo_items.rb')
22
22
  assert_match_in_file(/SampleApp.helpers do/m, '/tmp/sample_app/app/helpers/demo_items_helper.rb')
23
- assert File.exist?('/tmp/sample_app/app/views/demo_items')
23
+ assert_file_exists('/tmp/sample_app/app/views/demo_items')
24
24
  end
25
25
 
26
26
  should "generate controller test for bacon" do
@@ -12,7 +12,7 @@ class TestMailerGenerator < Test::Unit::TestCase
12
12
  should "fail outside app root" do
13
13
  output = silence_logger { @mailgen.start(['demo', '-r=/tmp']) }
14
14
  assert_match(/not at the root/, output)
15
- assert !File.exist?('/tmp/app/mailers/demo_mailer.rb')
15
+ assert_no_file_exists('/tmp/app/mailers/demo_mailer.rb')
16
16
  end
17
17
 
18
18
  should "support generating a new mailer extended from base" do
@@ -20,7 +20,7 @@ class TestMailerGenerator < Test::Unit::TestCase
20
20
  silence_logger { @mailgen.start(['demo', '-r=/tmp/sample_app']) }
21
21
  assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_app/app/mailers/demo_mailer.rb')
22
22
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
23
- assert File.exist?('/tmp/sample_app/app/views/demo_mailer')
23
+ assert_file_exists('/tmp/sample_app/app/views/demo_mailer')
24
24
  end
25
25
 
26
26
  should "support generating a new mailer extended from base with long name" do
@@ -28,7 +28,7 @@ class TestMailerGenerator < Test::Unit::TestCase
28
28
  silence_logger { @mailgen.start(['user_notice', '-r=/tmp/sample_app']) }
29
29
  assert_match_in_file(/class UserNoticeMailer/m, '/tmp/sample_app/app/mailers/user_notice_mailer.rb')
30
30
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
31
- assert File.exist?('/tmp/sample_app/app/views/user_notice_mailer')
31
+ assert_file_exists('/tmp/sample_app/app/views/user_notice_mailer')
32
32
  end
33
33
 
34
34
  should "support generating a new mailer extended from base with capitalized name" do
@@ -36,7 +36,7 @@ class TestMailerGenerator < Test::Unit::TestCase
36
36
  silence_logger { @mailgen.start(['DEMO', '-r=/tmp/sample_app']) }
37
37
  assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_app/app/mailers/demo_mailer.rb')
38
38
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
39
- assert File.exist?('/tmp/sample_app/app/views/demo_mailer')
39
+ assert_file_exists('/tmp/sample_app/app/views/demo_mailer')
40
40
  end
41
41
  end
42
42
 
@@ -12,7 +12,7 @@ class TestModelGenerator < Test::Unit::TestCase
12
12
  should "fail outside app root" do
13
13
  output = silence_logger { @model_gen.start(['user', '-r=/tmp']) }
14
14
  assert_match(/not at the root/, output)
15
- assert !File.exist?('/tmp/app/models/user.rb')
15
+ assert_no_file_exists('/tmp/app/models/user.rb')
16
16
  end
17
17
 
18
18
  should "generate only generate model once" do
@@ -10,15 +10,24 @@ class TestSkeletonGenerator < Test::Unit::TestCase
10
10
  context 'the skeleton generator' do
11
11
  should "allow simple generator to run and create base_app with no options" do
12
12
  assert_nothing_raised { silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none']) } }
13
- assert File.exist?('/tmp/sample_app')
14
- assert File.exist?('/tmp/sample_app/app')
15
- assert File.exist?('/tmp/sample_app/config/boot.rb')
16
- assert File.exist?('/tmp/sample_app/test/test_config.rb')
13
+ assert_file_exists('/tmp/sample_app')
14
+ assert_file_exists('/tmp/sample_app/app')
15
+ assert_file_exists('/tmp/sample_app/config/boot.rb')
16
+ assert_dir_exists('/tmp/sample_app/app/models')
17
+ assert_file_exists('/tmp/sample_app/test/test_config.rb')
18
+ end
19
+ should "not create models folder if no orm is chosen" do
20
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '--orm=none']) }
21
+ assert_no_dir_exists('/tmp/sample_app/app/models')
22
+ end
23
+ should "not create tests folder if no test framework is chosen" do
24
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '--test=none']) }
25
+ assert_no_dir_exists('/tmp/sample_app/test')
17
26
  end
18
27
  should "place app specific names into correct files" do
19
28
  silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none']) }
20
29
  assert_match_in_file(/class SampleApp < Padrino::Application/m, '/tmp/sample_app/app/app.rb')
21
- assert_match_in_file(/Padrino.mount_core\(:app_class => "SampleApp"\)/m, '/tmp/sample_app/config/apps.rb')
30
+ assert_match_in_file(/Padrino.mount_core\("SampleApp"\)/m, '/tmp/sample_app/config/apps.rb')
22
31
  assert_match_in_file(/SampleApp.urls do/m, '/tmp/sample_app/config/urls.rb')
23
32
  end
24
33
  should "create components file containing options chosen with defaults" do
@@ -81,6 +90,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
81
90
  assert_match /Applying.*?sequel.*?orm/, buffer
82
91
  assert_match_in_file(/gem 'sequel'/, '/tmp/sample_app/Gemfile')
83
92
  assert_match_in_file(/Sequel.connect/, '/tmp/sample_app/config/database.rb')
93
+ assert_dir_exists('/tmp/sample_app/app/models')
84
94
  end
85
95
 
86
96
  should "properly generate for activerecord" do
@@ -89,6 +99,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
89
99
  assert_match_in_file(/gem 'activerecord'/, '/tmp/sample_app/Gemfile')
90
100
  assert_match_in_file(/Migrate the database/, '/tmp/sample_app/Rakefile')
91
101
  assert_match_in_file(/ActiveRecord::Base.establish_connection/, '/tmp/sample_app/config/database.rb')
102
+ assert_dir_exists('/tmp/sample_app/app/models')
92
103
  end
93
104
 
94
105
  should "properly generate default for datamapper" do
@@ -96,6 +107,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
96
107
  assert_match /Applying.*?datamapper.*?orm/, buffer
97
108
  assert_match_in_file(/gem 'dm-core'/, '/tmp/sample_app/Gemfile')
98
109
  assert_match_in_file(/DataMapper.setup/, '/tmp/sample_app/config/database.rb')
110
+ assert_dir_exists('/tmp/sample_app/app/models')
99
111
  end
100
112
 
101
113
  should "properly generate for mongomapper" do
@@ -103,6 +115,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
103
115
  assert_match /Applying.*?mongomapper.*?orm/, buffer
104
116
  assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/sample_app/Gemfile')
105
117
  assert_match_in_file(/MongoMapper.database/, '/tmp/sample_app/config/database.rb')
118
+ assert_dir_exists('/tmp/sample_app/app/models')
106
119
  end
107
120
 
108
121
  should "properly generate for couchrest" do
@@ -110,6 +123,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
110
123
  assert_match /Applying.*?couchrest.*?orm/, buffer
111
124
  assert_match_in_file(/gem 'couchrest'/, '/tmp/sample_app/Gemfile')
112
125
  assert_match_in_file(/CouchRest.database!/, '/tmp/sample_app/config/database.rb')
126
+ assert_dir_exists('/tmp/sample_app/app/models')
113
127
  end
114
128
  end
115
129
 
@@ -124,6 +138,8 @@ class TestSkeletonGenerator < Test::Unit::TestCase
124
138
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--renderer=haml','--script=none']) }
125
139
  assert_match /Applying.*?haml.*?renderer/, buffer
126
140
  assert_match_in_file(/gem 'haml'/, '/tmp/sample_app/Gemfile')
141
+ assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_app/config/initializers/sass.rb')
142
+ assert_file_exists('/tmp/sample_app/public/stylesheets/sass')
127
143
  end
128
144
  end
129
145
 
@@ -131,20 +147,23 @@ class TestSkeletonGenerator < Test::Unit::TestCase
131
147
  should "properly generate for jquery" do
132
148
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=jquery']) }
133
149
  assert_match /Applying.*?jquery.*?script/, buffer
134
- assert File.exist?('/tmp/sample_app/public/javascripts/jquery.min.js')
150
+ assert_file_exists('/tmp/sample_app/public/javascripts/jquery.min.js')
151
+ assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
135
152
  end
136
153
 
137
154
  should "properly generate for prototype" do
138
155
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=prototype']) }
139
156
  assert_match /Applying.*?prototype.*?script/, buffer
140
- assert File.exist?('/tmp/sample_app/public/javascripts/prototype.js')
141
- assert File.exist?('/tmp/sample_app/public/javascripts/lowpro.js')
157
+ assert_file_exists('/tmp/sample_app/public/javascripts/prototype.js')
158
+ assert_file_exists('/tmp/sample_app/public/javascripts/lowpro.js')
159
+ assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
142
160
  end
143
161
 
144
162
  should "properly generate for rightjs" do
145
163
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=rightjs']) }
146
164
  assert_match /Applying.*?rightjs.*?script/, buffer
147
- assert File.exist?('/tmp/sample_app/public/javascripts/right-min.js')
165
+ assert_file_exists('/tmp/sample_app/public/javascripts/right-min.js')
166
+ assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
148
167
  end
149
168
  end
150
169
 
@@ -153,6 +172,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
153
172
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=bacon', '--script=none']) }
154
173
  assert_match /Applying.*?bacon.*?test/, buffer
155
174
  assert_match_in_file(/gem 'bacon'/, '/tmp/sample_app/Gemfile')
175
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
156
176
  assert_match_in_file(/Bacon::Context/, '/tmp/sample_app/test/test_config.rb')
157
177
  end
158
178
 
@@ -160,6 +180,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
160
180
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=riot', '--script=none']) }
161
181
  assert_match /Applying.*?riot.*?test/, buffer
162
182
  assert_match_in_file(/gem 'riot'/, '/tmp/sample_app/Gemfile')
183
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
163
184
  assert_match_in_file(/Riot::Situation/, '/tmp/sample_app/test/test_config.rb')
164
185
  end
165
186
 
@@ -167,6 +188,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
167
188
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=rspec', '--script=none']) }
168
189
  assert_match /Applying.*?rspec.*?test/, buffer
169
190
  assert_match_in_file(/gem 'spec'/, '/tmp/sample_app/Gemfile')
191
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
170
192
  assert_match_in_file(/Spec::Runner/, '/tmp/sample_app/test/test_config.rb')
171
193
  end
172
194
 
@@ -174,6 +196,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
174
196
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=shoulda', '--script=none']) }
175
197
  assert_match /Applying.*?shoulda.*?test/, buffer
176
198
  assert_match_in_file(/gem 'shoulda'/, '/tmp/sample_app/Gemfile')
199
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
177
200
  assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
178
201
  end
179
202
 
@@ -181,6 +204,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
181
204
  buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=testspec', '--script=none']) }
182
205
  assert_match /Applying.*?testspec.*?test/, buffer
183
206
  assert_match_in_file(/gem 'test\/spec'/, '/tmp/sample_app/Gemfile')
207
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
184
208
  assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
185
209
  end
186
210
  end
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.3
4
+ version: 0.1.4
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-20 00:00:00 -08:00
15
+ date: 2009-11-23 00:00:00 -08:00
16
16
  default_executable: padrino-gen
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: "0"
56
+ version: 0.5.0
57
57
  version:
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: haml
@@ -112,7 +112,6 @@ executables:
112
112
  extensions: []
113
113
 
114
114
  extra_rdoc_files:
115
- - LICENSE
116
115
  - README.rdoc
117
116
  files:
118
117
  - .document
@@ -151,7 +150,6 @@ files:
151
150
  - lib/generators/skeleton/app/app.rb.tt
152
151
  - lib/generators/skeleton/app/controllers/.empty_directory
153
152
  - lib/generators/skeleton/app/helpers/.empty_directory
154
- - lib/generators/skeleton/app/models/.empty_directory
155
153
  - lib/generators/skeleton/app/views/.empty_directory
156
154
  - lib/generators/skeleton/config.ru
157
155
  - lib/generators/skeleton/config/apps.rb.tt
@@ -163,16 +161,13 @@ files:
163
161
  - lib/generators/skeleton/public/images/.empty_directory
164
162
  - lib/generators/skeleton/public/javascripts/.empty_directory
165
163
  - lib/generators/skeleton/public/stylesheets/.empty_directory
166
- - lib/generators/skeleton/test/test_config.rb.tt
167
164
  - lib/generators/skeleton/tmp/.emptydirectory
168
- - lib/generators/skeleton/vendor/gems/.empty_directory
169
165
  - lib/generators/templates/controller.rb.tt
170
166
  - lib/generators/templates/helper.rb.tt
171
167
  - lib/generators/templates/mailer.rb.tt
172
168
  - lib/generators/templates/mailer_initializer.rb.tt
173
169
  - lib/padrino-gen.rb
174
170
  - padrino-gen.gemspec
175
- - test/active_support_helpers.rb
176
171
  - test/helper.rb
177
172
  - test/test_controller_generator.rb
178
173
  - test/test_mailer_generator.rb
@@ -180,7 +175,7 @@ files:
180
175
  - test/test_model_generator.rb
181
176
  - test/test_skeleton_generator.rb
182
177
  has_rdoc: true
183
- homepage: http://github.com/padrino/padrino-gen
178
+ homepage: http://github.com/padrino/padrino-framework/tree/master/padrino-gen
184
179
  licenses: []
185
180
 
186
181
  post_install_message:
File without changes
@@ -1,5 +0,0 @@
1
- RACK_ENV = 'test' unless defined?(RACK_ENV)
2
- require File.dirname(__FILE__) + "/../config/boot"
3
- Bundler.require_env(:testing)
4
-
5
- # Test configuration
File without changes
@@ -1,7 +0,0 @@
1
- unless Fixnum.method_defined?(:days)
2
- require 'active_support/core_ext/object/misc'
3
- require 'active_support/core_ext/date'
4
- require 'active_support/core_ext/time'
5
- require 'active_support/core_ext/numeric'
6
- require 'active_support/duration'
7
- end