padrino-gen 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
data/bin/padrino-gen CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'rubygems' unless defined?(Gem)
2
3
 
3
4
  # We load padrino-gen
4
5
  padrino_gen_path = File.expand_path('../../lib', __FILE__)
@@ -128,10 +128,10 @@ module Padrino
128
128
  unless File.exist?(destination_root(app))
129
129
  say
130
130
  say "================================================================="
131
- say "We didn't found #{app.underscore.classify}! Available apps are:"
131
+ say "We didn't found #{app.underscore.camelize}! Available apps are:"
132
132
  say "================================================================="
133
133
  Padrino.mounted_apps.each do |app|
134
- say " - #{app.app_object}"
134
+ say " - #{app.app_class}"
135
135
  end
136
136
  say "================================================================="
137
137
  say
@@ -28,9 +28,10 @@ module Padrino
28
28
  # Copies over the Padrino base admin application
29
29
  def create_app
30
30
  self.destination_root = options[:root]
31
- @app_name = name.gsub(/\W/, "_").underscore.classify
31
+ @app_name = name.gsub(/\W/, "_").underscore.camelize
32
32
  if in_app_root?
33
33
  app_skeleton(name, options[:tiny])
34
+ empty_directory destination_root("public/#{name}")
34
35
  append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"#{@app_name}\").to(\"/#{name.underscore}\")"
35
36
 
36
37
  return if self.behavior == :revoke
@@ -9,7 +9,7 @@ end
9
9
  MONGO
10
10
 
11
11
  def setup_orm
12
- require_dependencies 'mongo_ext', :require => 'mongo'
12
+ require_dependencies 'bson_ext', :require => 'mongo'
13
13
  require_dependencies 'mongo_mapper'
14
14
  create_file("config/database.rb", MONGO.gsub(/!NAME!/, name.underscore))
15
15
  empty_directory('app/models')
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Padrino.mount("blog").to('/blog')
6
6
  # Padrino.mount("blog", :app_class => "BlogApp").to('/blog')
7
- # Padrino.mount("blog", :app_file => "/path/to/blog/app.rb").to('/blog')
7
+ # Padrino.mount("blog", :app_file => "path/to/blog/app.rb").to('/blog')
8
8
  #
9
9
  # You can also map apps to a specified host:
10
10
  #
@@ -18,7 +18,7 @@
18
18
  # By default, this file mounts the parimary app which was generated with this project.
19
19
  # However, the mounted app can be modified as needed:
20
20
  #
21
- # Padrino.mount(:app_file => "/path/to/file", :app_class => "Blog").to('/')
21
+ # Padrino.mount(:app_file => "path/to/file", :app_class => "Blog").to('/')
22
22
  #
23
23
 
24
24
  # Mounts the core application for this project
@@ -40,7 +40,7 @@ module Padrino
40
40
 
41
41
  # Copies over the Padrino base application App
42
42
  def setup_project
43
- @app_name = (options[:app] || name).gsub(/\W/, "_").underscore.classify
43
+ @app_name = (options[:app] || name).gsub(/\W/, "_").underscore.camelize
44
44
  self.destination_root = File.join(options[:root], name)
45
45
  directory("project/", destination_root)
46
46
  app_skeleton('app', options[:tiny])
@@ -22,6 +22,7 @@ class TestAppGenerator < Test::Unit::TestCase
22
22
  assert_file_exists('/tmp/sample_project/demo/helpers')
23
23
  assert_file_exists('/tmp/sample_project/demo/views')
24
24
  assert_file_exists('/tmp/sample_project/demo/views/layouts')
25
+ assert_dir_exists('/tmp/sample_project/public/demo')
25
26
  assert_match_in_file 'Padrino.mount("Demo").to("/demo")', '/tmp/sample_project/config/apps.rb'
26
27
  assert_match_in_file 'class Demo < Padrino::Application', '/tmp/sample_project/demo/app.rb'
27
28
  end
@@ -35,6 +36,7 @@ class TestAppGenerator < Test::Unit::TestCase
35
36
  assert_file_exists('/tmp/sample_project/demo/controllers.rb')
36
37
  assert_file_exists('/tmp/sample_project/demo/mailers.rb')
37
38
  assert_dir_exists('/tmp/sample_project/demo/views/mailers')
39
+ assert_dir_exists('/tmp/sample_project/public/demo')
38
40
  assert_match_in_file(/:notifier/,'/tmp/sample_project/demo/mailers.rb')
39
41
  assert_no_file_exists('/tmp/sample_project/demo/helpers')
40
42
  assert_no_file_exists('/tmp/sample_project/demo/controllers')
@@ -5,6 +5,7 @@ class TestControllerGenerator < Test::Unit::TestCase
5
5
  @controller_path = '/tmp/sample_project/app/controllers/demo_items.rb'
6
6
  @controller_test_path = '/tmp/sample_project/test/controllers/demo_items_controller_test.rb'
7
7
  `rm -rf /tmp/sample_project`
8
+ `rm -rf /tmp/warepedia`
8
9
  end
9
10
 
10
11
  context 'the controller generator' do
@@ -14,6 +15,22 @@ class TestControllerGenerator < Test::Unit::TestCase
14
15
  assert_no_file_exists('/tmp/app/controllers/demo.rb')
15
16
  end
16
17
 
18
+ should "generate controller within existing project" do
19
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
20
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
21
+ assert_match_in_file(/SampleProject.controllers :demo_items do/m, @controller_path)
22
+ assert_match_in_file(/SampleProject.helpers do/m, '/tmp/sample_project/app/helpers/demo_items_helper.rb')
23
+ assert_file_exists('/tmp/sample_project/app/views/demo_items')
24
+ end
25
+
26
+ should "generate controller within existing project with weird name" do
27
+ silence_logger { generate(:project, 'warepedia', '--root=/tmp', '--script=none', '-t=bacon') }
28
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/warepedia') }
29
+ assert_match_in_file(/Warepedia.controllers :demo_items do/m, "/tmp/warepedia/app/controllers/demo_items.rb")
30
+ assert_match_in_file(/Warepedia.helpers do/m, '/tmp/warepedia/app/helpers/demo_items_helper.rb')
31
+ assert_file_exists('/tmp/warepedia/app/views/demo_items')
32
+ end
33
+
17
34
  should "generate controller in specified app" do
18
35
  silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
19
36
  silence_logger { generate(:app, 'subby', '-r=/tmp/sample_project') }
@@ -33,14 +50,6 @@ class TestControllerGenerator < Test::Unit::TestCase
33
50
  assert_no_file_exists("/tmp/sample_project/test")
34
51
  end
35
52
 
36
- should "generate controller within existing application" do
37
- silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
38
- silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
39
- assert_match_in_file(/SampleProject.controllers :demo_items do/m, @controller_path)
40
- assert_match_in_file(/SampleProject.helpers do/m, '/tmp/sample_project/app/helpers/demo_items_helper.rb')
41
- assert_file_exists('/tmp/sample_project/app/views/demo_items')
42
- end
43
-
44
53
  should "generate controller test for bacon" do
45
54
  silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
46
55
  silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
@@ -6,7 +6,7 @@ class TestGenerator < Test::Unit::TestCase
6
6
  should "have default generators" do
7
7
  %w{controller mailer migration model app}.each do |gen|
8
8
  assert Padrino::Generators.mappings.has_key?(gen.to_sym)
9
- assert_equal "Padrino::Generators::#{gen.classify}", Padrino::Generators.mappings[gen.to_sym].name
9
+ assert_equal "Padrino::Generators::#{gen.camelize}", Padrino::Generators.mappings[gen.to_sym].name
10
10
  assert Padrino::Generators.mappings[gen.to_sym].respond_to?(:start)
11
11
  end
12
12
  end
@@ -3,6 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/helper')
3
3
  class TestProjectGenerator < Test::Unit::TestCase
4
4
  def setup
5
5
  `rm -rf /tmp/sample_project`
6
+ `rm -rf /tmp/warepedia`
6
7
  end
7
8
 
8
9
  context 'the project generator' do
@@ -48,9 +49,9 @@ class TestProjectGenerator < Test::Unit::TestCase
48
49
  end
49
50
 
50
51
  should "place app specific names into correct files" do
51
- silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none') }
52
- assert_match_in_file(/class SampleProject < Padrino::Application/m, '/tmp/sample_project/app/app.rb')
53
- assert_match_in_file(/Padrino.mount\("SampleProject"\).to\('\/'\)/m, '/tmp/sample_project/config/apps.rb')
52
+ silence_logger { generate(:project, 'warepedia', '--root=/tmp', '--script=none') }
53
+ assert_match_in_file(/class Warepedia < Padrino::Application/m, '/tmp/warepedia/app/app.rb')
54
+ assert_match_in_file(/Padrino.mount\("Warepedia"\).to\('\/'\)/m, '/tmp/warepedia/config/apps.rb')
54
55
  end
55
56
 
56
57
  should "create components file containing options chosen with defaults" do
@@ -229,6 +230,7 @@ class TestProjectGenerator < Test::Unit::TestCase
229
230
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=mongomapper', '--script=none') }
230
231
  assert_match /Applying.*?mongomapper.*?orm/, buffer
231
232
  assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/sample_project/Gemfile')
233
+ assert_match_in_file(/gem 'bson_ext'/, '/tmp/sample_project/Gemfile')
232
234
  assert_match_in_file(/MongoMapper.database/, '/tmp/sample_project/config/database.rb')
233
235
  assert_dir_exists('/tmp/sample_project/app/models')
234
236
  end
@@ -237,6 +239,7 @@ class TestProjectGenerator < Test::Unit::TestCase
237
239
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=mongoid', '--script=none') }
238
240
  assert_match /Applying.*?mongoid.*?orm/, buffer
239
241
  assert_match_in_file(/gem 'mongoid'/, '/tmp/sample_project/Gemfile')
242
+ assert_match_in_file(/gem 'bson_ext'/, '/tmp/sample_project/Gemfile')
240
243
  assert_match_in_file(/Mongoid.database/, '/tmp/sample_project/config/database.rb')
241
244
  assert_dir_exists('/tmp/sample_project/app/models')
242
245
  end
@@ -313,7 +316,9 @@ class TestProjectGenerator < Test::Unit::TestCase
313
316
  should "properly default generate for bacon" do
314
317
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=bacon', '--script=none') }
315
318
  assert_match /Applying.*?bacon.*?test/, buffer
316
- assert_match_in_file(/gem 'rack-test'.*?:require => "rack\/test".*?:group => "test"/, '/tmp/sample_project/Gemfile')
319
+ assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
320
+ assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
321
+ assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
317
322
  assert_match_in_file(/gem 'bacon'/, '/tmp/sample_project/Gemfile')
318
323
  assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
319
324
  assert_match_in_file(/Bacon::Context/, '/tmp/sample_project/test/test_config.rb')
@@ -323,7 +328,9 @@ class TestProjectGenerator < Test::Unit::TestCase
323
328
  should "properly generate for riot" do
324
329
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=riot', '--script=none') }
325
330
  assert_match /Applying.*?riot.*?test/, buffer
326
- assert_match_in_file(/gem 'rack-test'.*?:require => "rack\/test".*?:group => "test"/, '/tmp/sample_project/Gemfile')
331
+ assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
332
+ assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
333
+ assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
327
334
  assert_match_in_file(/gem 'riot'/, '/tmp/sample_project/Gemfile')
328
335
  assert_match_in_file(/include Rack::Test::Methods/, '/tmp/sample_project/test/test_config.rb')
329
336
  assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
@@ -335,7 +342,9 @@ class TestProjectGenerator < Test::Unit::TestCase
335
342
  should "properly generate for rspec" do
336
343
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=rspec', '--script=none') }
337
344
  assert_match /Applying.*?rspec.*?test/, buffer
338
- assert_match_in_file(/gem 'rack-test'.*?:require => "rack\/test".*?:group => "test"/, '/tmp/sample_project/Gemfile')
345
+ assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
346
+ assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
347
+ assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
339
348
  assert_match_in_file(/gem 'rspec'.*?:require => "spec"/, '/tmp/sample_project/Gemfile')
340
349
  assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/spec/spec_helper.rb')
341
350
  assert_match_in_file(/Spec::Runner/, '/tmp/sample_project/spec/spec_helper.rb')
@@ -345,7 +354,9 @@ class TestProjectGenerator < Test::Unit::TestCase
345
354
  should "properly generate for shoulda" do
346
355
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=shoulda', '--script=none') }
347
356
  assert_match /Applying.*?shoulda.*?test/, buffer
348
- assert_match_in_file(/gem 'rack-test'.*?:require => "rack\/test".*?:group => "test"/, '/tmp/sample_project/Gemfile')
357
+ assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
358
+ assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
359
+ assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
349
360
  assert_match_in_file(/gem 'shoulda'/, '/tmp/sample_project/Gemfile')
350
361
  assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
351
362
  assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_project/test/test_config.rb')
@@ -355,7 +366,9 @@ class TestProjectGenerator < Test::Unit::TestCase
355
366
  should "properly generate for testspec" do
356
367
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=testspec', '--script=none') }
357
368
  assert_match /Applying.*?testspec.*?test/, buffer
358
- assert_match_in_file(/gem 'rack-test'.*?:require => "rack\/test".*?:group => "test"/, '/tmp/sample_project/Gemfile')
369
+ assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
370
+ assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
371
+ assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
359
372
  assert_match_in_file(/gem 'test-spec'.*?:require => "test\/spec"/, '/tmp/sample_project/Gemfile')
360
373
  assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
361
374
  assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_project/test/test_config.rb')
@@ -365,7 +378,9 @@ class TestProjectGenerator < Test::Unit::TestCase
365
378
  should "properly generate for cucumber" do
366
379
  buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=cucumber', '--script=none') }
367
380
  assert_match /Applying.*?cucumber.*?test/, buffer
368
- assert_match_in_file(/gem 'rack-test'.*?:require => "rack\/test".*?:group => "test"/, '/tmp/sample_project/Gemfile')
381
+ assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
382
+ assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
383
+ assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
369
384
  assert_match_in_file(/gem 'rspec'.*?:require => "spec"/, '/tmp/sample_project/Gemfile')
370
385
  assert_match_in_file(/gem 'cucumber'/, '/tmp/sample_project/Gemfile')
371
386
  assert_match_in_file(/gem 'capybara'/, '/tmp/sample_project/Gemfile')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-gen
3
3
  version: !ruby/object:Gem::Version
4
- hash: 33
4
+ hash: 39
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 13
10
- version: 0.9.13
9
+ - 14
10
+ version: 0.9.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Padrino Team
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-06-19 00:00:00 +02:00
21
+ date: 2010-06-30 00:00:00 -07:00
22
22
  default_executable: padrino-gen
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - "="
29
29
  - !ruby/object:Gem::Version
30
- hash: 33
30
+ hash: 39
31
31
  segments:
32
32
  - 0
33
33
  - 9
34
- - 13
35
- version: 0.9.13
34
+ - 14
35
+ version: 0.9.14
36
36
  type: :runtime
37
37
  name: padrino-core
38
38
  prerelease: false