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.
- data/lib/padrino-gen/generators/app/app.rb.tt +8 -8
- data/lib/padrino-gen/generators/app.rb +0 -1
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/couchrest.rb +2 -5
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/sequel.rb +1 -1
- data/lib/padrino-gen/generators/components/stylesheets/scss.rb +2 -2
- data/lib/padrino-gen/generators/project/config/apps.rb.tt +10 -1
- data/lib/padrino-gen/generators/project.rb +1 -2
- data/lib/padrino-gen/generators/runner.rb +1 -1
- data/lib/padrino-gen/generators/templates/static/README.rdoc +16 -0
- data/lib/padrino-gen/generators/templates/static/js/dojo.js +1 -0
- data/lib/padrino-gen/generators/templates/static/js/ext.js +1 -0
- data/lib/padrino-gen/generators/templates/static/js/jquery.js +16 -0
- data/lib/padrino-gen/generators/templates/static/js/lowpro.js +1 -0
- data/lib/padrino-gen/generators/templates/static/js/mootools.js +468 -0
- data/lib/padrino-gen/generators/templates/static/js/protopak.js +1 -0
- data/lib/padrino-gen/generators/templates/static/js/right.js +1 -0
- data/lib/padrino-gen/generators/templates/static/ujs/dojo.js +24 -0
- data/lib/padrino-gen/generators/templates/static/ujs/ext.js +24 -0
- data/lib/padrino-gen/generators/templates/static/ujs/jquery.js +91 -0
- data/lib/padrino-gen/generators/templates/static/ujs/mootools.js +104 -0
- data/lib/padrino-gen/generators/templates/static/ujs/prototype.js +106 -0
- data/lib/padrino-gen/generators/templates/static/ujs/right.js +95 -0
- data/lib/padrino-gen/padrino-tasks/mongomapper.rb +39 -32
- data/padrino-gen.gemspec +1 -1
- data/test/fixtures/example_template.rb +3 -2
- data/test/helper.rb +1 -1
- data/test/test_app_generator.rb +4 -13
- data/test/test_model_generator.rb +2 -2
- data/test/test_plugin_generator.rb +3 -2
- data/test/test_project_generator.rb +7 -10
- metadata +21 -7
@@ -1,42 +1,49 @@
|
|
1
|
-
if
|
1
|
+
if defined?(MongoMapper)
|
2
2
|
namespace :mm do
|
3
|
-
desc
|
4
|
-
task :
|
5
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
13
|
+
models.each do |m|
|
14
|
+
# Get the model class
|
15
|
+
klass = m.camelize.constantize
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
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
|
-
|
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
|
data/test/test_app_generator.rb
CHANGED
@@ -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
|
32
|
-
assert_match_in_file
|
33
|
-
assert_match_in_file
|
34
|
-
|
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::
|
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::
|
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
|
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
|
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
|
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
|
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
|
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 '
|
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:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
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-
|
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:
|
31
|
+
hash: 13
|
32
32
|
segments:
|
33
33
|
- 0
|
34
34
|
- 9
|
35
|
-
-
|
36
|
-
version: 0.9.
|
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
|
|