padrino-gen 0.9.26 → 0.9.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/lib/padrino-gen/generators/app/app.rb.tt +8 -8
  2. data/lib/padrino-gen/generators/app.rb +0 -1
  3. data/lib/padrino-gen/generators/components/orms/activerecord.rb +1 -1
  4. data/lib/padrino-gen/generators/components/orms/couchrest.rb +2 -5
  5. data/lib/padrino-gen/generators/components/orms/datamapper.rb +1 -1
  6. data/lib/padrino-gen/generators/components/orms/sequel.rb +1 -1
  7. data/lib/padrino-gen/generators/components/stylesheets/scss.rb +2 -2
  8. data/lib/padrino-gen/generators/project/config/apps.rb.tt +10 -1
  9. data/lib/padrino-gen/generators/project.rb +1 -2
  10. data/lib/padrino-gen/generators/runner.rb +1 -1
  11. data/lib/padrino-gen/generators/templates/static/README.rdoc +16 -0
  12. data/lib/padrino-gen/generators/templates/static/js/dojo.js +1 -0
  13. data/lib/padrino-gen/generators/templates/static/js/ext.js +1 -0
  14. data/lib/padrino-gen/generators/templates/static/js/jquery.js +16 -0
  15. data/lib/padrino-gen/generators/templates/static/js/lowpro.js +1 -0
  16. data/lib/padrino-gen/generators/templates/static/js/mootools.js +468 -0
  17. data/lib/padrino-gen/generators/templates/static/js/protopak.js +1 -0
  18. data/lib/padrino-gen/generators/templates/static/js/right.js +1 -0
  19. data/lib/padrino-gen/generators/templates/static/ujs/dojo.js +24 -0
  20. data/lib/padrino-gen/generators/templates/static/ujs/ext.js +24 -0
  21. data/lib/padrino-gen/generators/templates/static/ujs/jquery.js +91 -0
  22. data/lib/padrino-gen/generators/templates/static/ujs/mootools.js +104 -0
  23. data/lib/padrino-gen/generators/templates/static/ujs/prototype.js +106 -0
  24. data/lib/padrino-gen/generators/templates/static/ujs/right.js +95 -0
  25. data/lib/padrino-gen/padrino-tasks/mongomapper.rb +39 -32
  26. data/padrino-gen.gemspec +1 -1
  27. data/test/fixtures/example_template.rb +3 -2
  28. data/test/helper.rb +1 -1
  29. data/test/test_app_generator.rb +4 -13
  30. data/test/test_model_generator.rb +2 -2
  31. data/test/test_plugin_generator.rb +3 -2
  32. data/test/test_project_generator.rb +7 -10
  33. metadata +21 -7
@@ -1,42 +1,49 @@
1
- if (defined?(MongoMapper) && defined?(I18n))
1
+ if defined?(MongoMapper)
2
2
  namespace :mm do
3
- desc "Generates .yml files for I18n translations"
4
- task :translate => :environment do
5
- models = Dir["#{Padrino.root}/app/models/**/*.rb"].map { |m| File.basename(m, ".rb") }
3
+ desc 'Drops all the collections for the database for the current Rails.env'
4
+ task :drop => :environment do
5
+ MongoMapper.database.collections.select {|c| c.name !~ /system/ }.each(&:drop)
6
+ end
7
+
8
+ if defined?(I18n)
9
+ desc "Generates .yml files for I18n translations"
10
+ task :translate => :environment do
11
+ models = Dir["#{Padrino.root}/app/models/**/*.rb"].map { |m| File.basename(m, ".rb") }
6
12
 
7
- models.each do |m|
8
- # Get the model class
9
- klass = m.camelize.constantize
13
+ models.each do |m|
14
+ # Get the model class
15
+ klass = m.camelize.constantize
10
16
 
11
- # Init the processing
12
- print "Processing #{m.humanize}: "
13
- FileUtils.mkdir_p("#{Padrino.root}/app/locale/models/#{m}")
14
- langs = Array(I18n.locale) # for now we use only one
17
+ # Init the processing
18
+ print "Processing #{m.humanize}: "
19
+ FileUtils.mkdir_p("#{Padrino.root}/app/locale/models/#{m}")
20
+ langs = Array(I18n.locale) # for now we use only one
15
21
 
16
- # Create models for it and en locales
17
- langs.each do |lang|
18
- filename = "#{Padrino.root}/app/locale/models/#{m}/#{lang}.yml"
19
- columns = klass.keys.values.map(&:name).reject { |name| name =~ /id/i }
20
- # If the lang file already exist we need to check it
21
- if File.exist?(filename)
22
- locale = File.open(filename).read
23
- columns.each do |c|
24
- locale += "\n #{c}: #{c.humanize}" unless locale.include?("#{c}:")
22
+ # Create models for it and en locales
23
+ langs.each do |lang|
24
+ filename = "#{Padrino.root}/app/locale/models/#{m}/#{lang}.yml"
25
+ columns = klass.keys.values.map(&:name).reject { |name| name =~ /id/i }
26
+ # If the lang file already exist we need to check it
27
+ if File.exist?(filename)
28
+ locale = File.open(filename).read
29
+ columns.each do |c|
30
+ locale += "\n #{c}: #{c.humanize}" unless locale.include?("#{c}:")
31
+ end
32
+ print "Lang #{lang.to_s.upcase} already exist ... "; $stdout.flush
33
+ # Do some ere
34
+ else
35
+ locale = "#{lang}:" + "\n" +
36
+ " models:" + "\n" +
37
+ " #{m}:" + "\n" +
38
+ " name: #{klass.human_name}" + "\n" +
39
+ " attributes:" + "\n" +
40
+ columns.map { |c| " #{c}: #{c.humanize}" }.join("\n")
41
+ print "created a new for #{lang.to_s.upcase} Lang ... "; $stdout.flush
25
42
  end
26
- print "Lang #{lang.to_s.upcase} already exist ... "; $stdout.flush
27
- # Do some ere
28
- else
29
- locale = "#{lang}:" + "\n" +
30
- " models:" + "\n" +
31
- " #{m}:" + "\n" +
32
- " name: #{klass.human_name}" + "\n" +
33
- " attributes:" + "\n" +
34
- columns.map { |c| " #{c}: #{c.humanize}" }.join("\n")
35
- print "created a new for #{lang.to_s.upcase} Lang ... "; $stdout.flush
43
+ File.open(filename, "w") { |f| f.puts locale }
36
44
  end
37
- File.open(filename, "w") { |f| f.puts locale }
45
+ puts
38
46
  end
39
- puts
40
47
  end
41
48
  end
42
49
  end
data/padrino-gen.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.date = Time.now.strftime("%Y-%m-%d")
15
15
 
16
16
  s.extra_rdoc_files = Dir["*.rdoc"]
17
- s.files = `git ls-files`.split("\n")
17
+ s.files = `git ls-files`.split("\n") | Dir.glob("{lib}/**/*")
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
@@ -1,9 +1,10 @@
1
- project :test => :shoulda, :orm => :activerecord, :dev => true
1
+ project :test => :shoulda, :orm => :activerecord, :template => 'mongochist', :dev => true
2
2
 
3
3
  generate :model, "post title:string body:text"
4
4
  generate :controller, "posts get:index get:new post:new"
5
5
  generate :migration, "AddEmailToUser email:string"
6
6
  generate :fake, "foo bar"
7
+ generate :plugin, "carrierwave"
7
8
 
8
9
  require_dependencies 'nokogiri'
9
10
 
@@ -11,4 +12,4 @@ initializer :test, "# Example"
11
12
 
12
13
  app :testapp do
13
14
  generate :controller, "users get:index"
14
- end
15
+ end
data/test/helper.rb CHANGED
@@ -84,7 +84,7 @@ class Test::Unit::TestCase
84
84
  project_root = options[:root]
85
85
  project_name = options[:name]
86
86
  settings = options.slice!(:name, :root)
87
- components = settings.map { |component, value| "--#{component}=#{value}" }
87
+ components = settings.sort_by { |k, v| k.to_s }.map { |component, value| "--#{component}=#{value}" }
88
88
  params = [project_name, *components].push("-r=#{project_root}")
89
89
  Padrino.expects(:bin_gen).with(*params.unshift('project')).returns(true)
90
90
  end
@@ -28,19 +28,10 @@ class TestAppGenerator < Test::Unit::TestCase
28
28
  assert_file_exists("#{@apptmp}/sample_project/demo/views")
29
29
  assert_file_exists("#{@apptmp}/sample_project/demo/views/layouts")
30
30
  assert_dir_exists("#{@apptmp}/sample_project/public/demo")
31
- assert_match_in_file 'Padrino.mount("Demo").to("/demo")', "#{@apptmp}/sample_project/config/apps.rb"
32
- assert_match_in_file 'class Demo < Padrino::Application', "#{@apptmp}/sample_project/demo/app.rb"
33
- assert_match_in_file 'set :session_secret, "', "#{@apptmp}/sample_project/demo/app.rb"
34
- end
35
-
36
- should "store and apply session_secret" do
37
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}") }
38
- silence_logger { generate(:app, 'demo', "--root=#{@apptmp}/sample_project") }
39
- assert_match_in_file(/session_secret:.+/, "#{@apptmp}/sample_project/.components")
40
- session_secret = YAML.load_file("#{@apptmp}/sample_project/.components")[:session_secret]
41
- assert_not_equal "", session_secret
42
- assert_match_in_file(/#{session_secret}/, "#{@apptmp}/sample_project/app/app.rb")
43
- assert_match_in_file(/#{session_secret}/, "#{@apptmp}/sample_project/demo/app.rb")
31
+ assert_match_in_file('Padrino.mount("Demo").to("/demo")', "#{@apptmp}/sample_project/config/apps.rb")
32
+ assert_match_in_file('class Demo < Padrino::Application', "#{@apptmp}/sample_project/demo/app.rb")
33
+ assert_match_in_file(/Padrino.configure_apps do/, "#{@apptmp}/sample_project/config/apps.rb")
34
+ assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb")
44
35
  end
45
36
 
46
37
  should "generate tiny app skeleton" do
@@ -122,7 +122,7 @@ class TestModelGenerator < Test::Unit::TestCase
122
122
  should "generate model file with no properties" do
123
123
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
124
124
  silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
125
- assert_match_in_file(/class User < CouchRest::ExtendedDocument/m, "#{@apptmp}/sample_project/app/models/user.rb")
125
+ assert_match_in_file(/class User < CouchRest::Model::Base/m, "#{@apptmp}/sample_project/app/models/user.rb")
126
126
  assert_match_in_file(/use_database COUCHDB/m, "#{@apptmp}/sample_project/app/models/user.rb")
127
127
  assert_match_in_file(/# property <name>[\s\n]+?end/m, "#{@apptmp}/sample_project/app/models/user.rb")
128
128
  end
@@ -130,7 +130,7 @@ class TestModelGenerator < Test::Unit::TestCase
130
130
  should "generate model file with given fields" do
131
131
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
132
132
  silence_logger { generate(:model, 'person', "name:string", "age", "email:string", "-r=#{@apptmp}/sample_project") }
133
- assert_match_in_file(/class Person < CouchRest::ExtendedDocument/m, "#{@apptmp}/sample_project/app/models/person.rb")
133
+ assert_match_in_file(/class Person < CouchRest::Model::Base/m, "#{@apptmp}/sample_project/app/models/person.rb")
134
134
  assert_match_in_file(/use_database COUCHDB/m, "#{@apptmp}/sample_project/app/models/person.rb")
135
135
  assert_match_in_file(/property :name/m, "#{@apptmp}/sample_project/app/models/person.rb")
136
136
  assert_match_in_file(/property :age/m, "#{@apptmp}/sample_project/app/models/person.rb")
@@ -29,11 +29,12 @@ class TestPluginGenerator < Test::Unit::TestCase
29
29
  end
30
30
 
31
31
  before_should "invoke Padrino.bin_gen" do
32
- expects_generated_project :name => 'sample_project', :test => :shoulda, :orm => :activerecord, :dev => true, :root => @apptmp
32
+ expects_generated_project :name => 'sample_project', :test => :shoulda, :orm => :activerecord, :dev => true, :template => 'mongochist', :root => @apptmp
33
33
  expects_generated :model, "post title:string body:text -r=#{@apptmp}/sample_project"
34
34
  expects_generated :controller, "posts get:index get:new post:new -r=#{@apptmp}/sample_project"
35
35
  expects_generated :migration, "AddEmailToUser email:string -r=#{@apptmp}/sample_project"
36
36
  expects_generated :fake, "foo bar -r=#{@apptmp}/sample_project"
37
+ expects_generated :plugin, "carrierwave -r=#{@apptmp}/sample_project"
37
38
  expects_dependencies 'nokogiri'
38
39
  expects_initializer :test, "# Example", :root => "#{@apptmp}/sample_project"
39
40
  expects_generated :app, "testapp -r=#{@apptmp}/sample_project"
@@ -125,4 +126,4 @@ class TestPluginGenerator < Test::Unit::TestCase
125
126
  expects_generated :admin_page, "post -r=#{@apptmp}/sample_admin"
126
127
  end
127
128
  end
128
- end
129
+ end
@@ -92,10 +92,7 @@ class TestProjectGenerator < Test::Unit::TestCase
92
92
 
93
93
  should "store and apply session_secret" do
94
94
  silence_logger { generate(:project,'sample_project', '--tiny',"--root=#{@apptmp}") }
95
- assert_match_in_file(/session_secret:.+/, "#{@apptmp}/sample_project/.components")
96
- session_secret = YAML.load_file("#{@apptmp}/sample_project/.components")[:session_secret]
97
- assert_not_equal "", session_secret
98
- assert_match_in_file(/#{session_secret}/, "#{@apptmp}/sample_project/app/app.rb")
95
+ assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb")
99
96
  end
100
97
 
101
98
  should "create components file containing options chosen with defaults" do
@@ -177,7 +174,7 @@ class TestProjectGenerator < Test::Unit::TestCase
177
174
  buffer = silence_logger { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=sequel', '--script=none') }
178
175
  assert_match(/Applying.*?sequel.*?orm/, buffer)
179
176
  assert_match_in_file(/gem 'sequel'/, "#{@apptmp}/project.com/Gemfile")
180
- assert_match_in_file(/gem 'sqlite3-ruby'/, "#{@apptmp}/project.com/Gemfile")
177
+ assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
181
178
  assert_match_in_file(/Sequel.connect/, "#{@apptmp}/project.com/config/database.rb")
182
179
  assert_match_in_file(%r{sqlite://}, "#{@apptmp}/project.com/config/database.rb")
183
180
  assert_match_in_file(%r{project_com}, "#{@apptmp}/project.com/config/database.rb")
@@ -193,7 +190,7 @@ class TestProjectGenerator < Test::Unit::TestCase
193
190
 
194
191
  should "properly generate sqlite3" do
195
192
  buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=sqlite') }
196
- assert_match_in_file(/gem 'sqlite3-ruby'/, "#{@apptmp}/sample_project/Gemfile")
193
+ assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
197
194
  assert_match_in_file(%r{sqlite://}, "#{@apptmp}/sample_project/config/database.rb")
198
195
  assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
199
196
  end
@@ -211,7 +208,7 @@ class TestProjectGenerator < Test::Unit::TestCase
211
208
  buffer = silence_logger { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=activerecord', '--script=none') }
212
209
  assert_match(/Applying.*?activerecord.*?orm/, buffer)
213
210
  assert_match_in_file(/gem 'activerecord', :require => "active_record"/, "#{@apptmp}/project.com/Gemfile")
214
- assert_match_in_file(/gem 'sqlite3-ruby', :require => "sqlite3"/, "#{@apptmp}/project.com/Gemfile")
211
+ assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
215
212
  assert_match_in_file(/ActiveRecord::Base.establish_connection/, "#{@apptmp}/project.com/config/database.rb")
216
213
  assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
217
214
  assert_dir_exists("#{@apptmp}/project.com/app/models")
@@ -233,7 +230,7 @@ class TestProjectGenerator < Test::Unit::TestCase
233
230
 
234
231
  should "properly generate sqlite3" do
235
232
  buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=sqlite3') }
236
- assert_match_in_file(/gem 'sqlite3-ruby', :require => "sqlite3"/, "#{@apptmp}/sample_project/Gemfile")
233
+ assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
237
234
  assert_match_in_file(/sample_project_development.db/, "#{@apptmp}/sample_project/config/database.rb")
238
235
  assert_match_in_file(%r{:adapter => 'sqlite3'}, "#{@apptmp}/sample_project/config/database.rb")
239
236
  end
@@ -302,7 +299,7 @@ class TestProjectGenerator < Test::Unit::TestCase
302
299
  should "properly generate for couchrest" do
303
300
  buffer = silence_logger { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=couchrest', '--script=none') }
304
301
  assert_match(/Applying.*?couchrest.*?orm/, buffer)
305
- assert_match_in_file(/gem 'couchrest'/, "#{@apptmp}/project.com/Gemfile")
302
+ assert_match_in_file(/gem 'couchrest_model'/, "#{@apptmp}/project.com/Gemfile")
306
303
  assert_match_in_file(/CouchRest.database!/, "#{@apptmp}/project.com/config/database.rb")
307
304
  assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
308
305
  assert_dir_exists("#{@apptmp}/project.com/app/models")
@@ -541,4 +538,4 @@ class TestProjectGenerator < Test::Unit::TestCase
541
538
  assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
542
539
  end
543
540
  end
544
- end
541
+ end
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 26
10
- version: 0.9.26
9
+ - 27
10
+ version: 0.9.27
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: 2011-04-28 00:00:00 Z
21
+ date: 2011-05-06 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: padrino-core
@@ -28,12 +28,12 @@ dependencies:
28
28
  requirements:
29
29
  - - "="
30
30
  - !ruby/object:Gem::Version
31
- hash: 15
31
+ hash: 13
32
32
  segments:
33
33
  - 0
34
34
  - 9
35
- - 26
36
- version: 0.9.26
35
+ - 27
36
+ version: 0.9.27
37
37
  type: :runtime
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency
@@ -159,6 +159,20 @@ files:
159
159
  - test/test_model_generator.rb
160
160
  - test/test_plugin_generator.rb
161
161
  - test/test_project_generator.rb
162
+ - lib/padrino-gen/generators/templates/static/js/dojo.js
163
+ - lib/padrino-gen/generators/templates/static/js/ext.js
164
+ - lib/padrino-gen/generators/templates/static/js/jquery.js
165
+ - lib/padrino-gen/generators/templates/static/js/lowpro.js
166
+ - lib/padrino-gen/generators/templates/static/js/mootools.js
167
+ - lib/padrino-gen/generators/templates/static/js/protopak.js
168
+ - lib/padrino-gen/generators/templates/static/js/right.js
169
+ - lib/padrino-gen/generators/templates/static/README.rdoc
170
+ - lib/padrino-gen/generators/templates/static/ujs/dojo.js
171
+ - lib/padrino-gen/generators/templates/static/ujs/ext.js
172
+ - lib/padrino-gen/generators/templates/static/ujs/jquery.js
173
+ - lib/padrino-gen/generators/templates/static/ujs/mootools.js
174
+ - lib/padrino-gen/generators/templates/static/ujs/prototype.js
175
+ - lib/padrino-gen/generators/templates/static/ujs/right.js
162
176
  homepage: http://www.padrinorb.com
163
177
  licenses: []
164
178