padrino-gen 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/padrino-gen +4 -4
- data/lib/padrino-gen/generators/cli.rb +5 -4
- data/lib/padrino-gen/generators/components/renderers/erb_gen.rb +1 -1
- data/lib/padrino-gen/generators/components/renderers/haml_gen.rb +2 -1
- data/lib/padrino-gen/generators/project/config.ru +0 -1
- data/lib/padrino-gen/generators/project/public/favicon.ico +0 -0
- data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +19 -23
- data/lib/padrino-gen.rb +0 -1
- data/padrino-gen.gemspec +6 -5
- data/test/helper.rb +1 -0
- data/test/test_project_generator.rb +2 -1
- metadata +6 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.5
|
data/bin/padrino-gen
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
|
-
|
3
|
+
padrino_gen_path = File.expand_path('../../lib', __FILE__)
|
4
|
+
$:.unshift(padrino_gen_path) if File.directory?(padrino_gen_path) && !$:.include?(padrino_gen_path)
|
4
5
|
|
5
6
|
# We try to load the vendored padrino-core if exist
|
6
|
-
|
7
|
-
|
8
|
-
end
|
7
|
+
padrino_core_path = File.expand_path('../../../padrino-core/lib', __FILE__)
|
8
|
+
$:.unshift(padrino_core_path) if File.directory?(padrino_core_path) && !$:.include?(padrino_core_path)
|
9
9
|
|
10
10
|
require 'padrino-gen'
|
11
11
|
require 'padrino-gen/generators/cli'
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'thor/group'
|
2
|
-
require 'padrino-core/support_lite'
|
3
2
|
|
4
3
|
module Padrino
|
5
4
|
module Generators
|
@@ -19,10 +18,12 @@ module Padrino
|
|
19
18
|
def load_boot
|
20
19
|
begin
|
21
20
|
ENV['PADRINO_LOG_LEVEL'] ||= "test"
|
22
|
-
|
23
|
-
|
21
|
+
boot = options[:root] ? File.join(options[:root], 'config/boot.rb') : 'config/boot.rb'
|
22
|
+
if File.exist?(boot)
|
23
|
+
require boot
|
24
24
|
else
|
25
|
-
|
25
|
+
# If we are outside app we need to load support_lite
|
26
|
+
require 'padrino-core/support_lite'
|
26
27
|
end
|
27
28
|
rescue Exception => e
|
28
29
|
puts "=> Problem loading config/boot.rb"
|
@@ -7,7 +7,7 @@ module Padrino
|
|
7
7
|
|
8
8
|
SASS_INIT = (<<-SASS).gsub(/^ {10}/, '')
|
9
9
|
# Enables support for SASS template reloading for rack.
|
10
|
-
# Store SASS files by default within '
|
10
|
+
# Store SASS files by default within 'app/stylesheets/sass'
|
11
11
|
# See http://nex-3.com/posts/88-sass-supports-rack for more details.
|
12
12
|
|
13
13
|
module SassInitializer
|
@@ -28,6 +28,7 @@ module Padrino
|
|
28
28
|
require_dependencies 'haml'
|
29
29
|
create_file destination_root('/lib/sass.rb'), SASS_INIT
|
30
30
|
inject_into_file destination_root('/app/app.rb'), SASS_REGISTER, :after => "configure do\n"
|
31
|
+
empty_directory destination_root('/app/stylesheets')
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
File without changes
|
@@ -66,7 +66,7 @@ if defined?(ActiveRecord)
|
|
66
66
|
"TO '#{config[:username]}'@'localhost' " \
|
67
67
|
"IDENTIFIED BY '#{config[:password]}' WITH GRANT OPTION;"
|
68
68
|
ActiveRecord::Base.establish_connection(config.merge(
|
69
|
-
:database => nil,
|
69
|
+
:database => nil, :username => 'root', :password => root_password))
|
70
70
|
ActiveRecord::Base.connection.create_database(config[:database], creation_options)
|
71
71
|
ActiveRecord::Base.connection.execute grant_statement
|
72
72
|
ActiveRecord::Base.establish_connection(config)
|
@@ -79,8 +79,8 @@ if defined?(ActiveRecord)
|
|
79
79
|
when 'postgresql'
|
80
80
|
@encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
|
81
81
|
begin
|
82
|
-
ActiveRecord::Base.establish_connection(config.merge(:database => 'postgres',
|
83
|
-
ActiveRecord::Base.connection.create_database(config[:database], config.merge(
|
82
|
+
ActiveRecord::Base.establish_connection(config.merge(:database => 'postgres', :schema_search_path => 'public'))
|
83
|
+
ActiveRecord::Base.connection.create_database(config[:database], config.merge(:encoding => @encoding))
|
84
84
|
ActiveRecord::Base.establish_connection(config)
|
85
85
|
rescue
|
86
86
|
$stderr.puts $!, *($!.backtrace)
|
@@ -110,7 +110,7 @@ if defined?(ActiveRecord)
|
|
110
110
|
|
111
111
|
desc 'Drops the database for the current Padrino.env'
|
112
112
|
task :drop => :environment do
|
113
|
-
config = ActiveRecord::Base.configurations[Padrino.env ||
|
113
|
+
config = ActiveRecord::Base.configurations[Padrino.env || :development]
|
114
114
|
begin
|
115
115
|
drop_database(config)
|
116
116
|
rescue Exception => e
|
@@ -184,7 +184,7 @@ if defined?(ActiveRecord)
|
|
184
184
|
|
185
185
|
desc "Retrieves the charset for the current environment's database"
|
186
186
|
task :charset => :environment do
|
187
|
-
config = ActiveRecord::Base.configurations[Padrino.env ||
|
187
|
+
config = ActiveRecord::Base.configurations[Padrino.env || :development]
|
188
188
|
case config[:adapter]
|
189
189
|
when 'mysql'
|
190
190
|
ActiveRecord::Base.establish_connection(config)
|
@@ -199,7 +199,7 @@ if defined?(ActiveRecord)
|
|
199
199
|
|
200
200
|
desc "Retrieves the collation for the current environment's database"
|
201
201
|
task :collation => :environment do
|
202
|
-
config = ActiveRecord::Base.configurations[Padrino.env ||
|
202
|
+
config = ActiveRecord::Base.configurations[Padrino.env || :development]
|
203
203
|
case config[:adapter]
|
204
204
|
when 'mysql'
|
205
205
|
ActiveRecord::Base.establish_connection(config)
|
@@ -267,32 +267,32 @@ if defined?(ActiveRecord)
|
|
267
267
|
desc "Dump the database structure to a SQL file"
|
268
268
|
task :dump => :environment do
|
269
269
|
abcs = ActiveRecord::Base.configurations
|
270
|
-
case abcs[Padrino.env][
|
270
|
+
case abcs[Padrino.env][:adapter]
|
271
271
|
when "mysql", "oci", "oracle"
|
272
272
|
ActiveRecord::Base.establish_connection(abcs[Padrino.env])
|
273
273
|
File.open("#{Padrino.root}/db/#{Padrino.env}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
274
274
|
when "postgresql"
|
275
|
-
ENV['PGHOST'] = abcs[Padrino.env][
|
276
|
-
ENV['PGPORT'] = abcs[Padrino.env][
|
277
|
-
ENV['PGPASSWORD'] = abcs[Padrino.env][
|
278
|
-
search_path = abcs[Padrino.env][
|
275
|
+
ENV['PGHOST'] = abcs[Padrino.env][:host] if abcs[Padrino.env][:host]
|
276
|
+
ENV['PGPORT'] = abcs[Padrino.env][:port].to_s if abcs[Padrino.env][:port]
|
277
|
+
ENV['PGPASSWORD'] = abcs[Padrino.env][:password].to_s if abcs[Padrino.env][:password]
|
278
|
+
search_path = abcs[Padrino.env][:schema_search_path]
|
279
279
|
unless search_path.blank?
|
280
280
|
search_path = search_path.split(",").map{|search_path| "--schema=#{search_path.strip}" }.join(" ")
|
281
281
|
end
|
282
|
-
`pg_dump -i -U "#{abcs[Padrino.env][
|
282
|
+
`pg_dump -i -U "#{abcs[Padrino.env][:username]}" -s -x -O -f db/#{Padrino.env}_structure.sql #{search_path} #{abcs[Padrino.env][:database]}`
|
283
283
|
raise "Error dumping database" if $?.exitstatus == 1
|
284
284
|
when "sqlite", "sqlite3"
|
285
|
-
dbfile = abcs[Padrino.env][
|
286
|
-
`#{abcs[Padrino.env][
|
285
|
+
dbfile = abcs[Padrino.env][:database] || abcs[Padrino.env][:dbfile]
|
286
|
+
`#{abcs[Padrino.env][:adapter]} #{dbfile} .schema > db/#{Padrino.env}_structure.sql`
|
287
287
|
when "sqlserver"
|
288
|
-
`scptxfr /s #{abcs[Padrino.env][
|
289
|
-
`scptxfr /s #{abcs[Padrino.env][
|
288
|
+
`scptxfr /s #{abcs[Padrino.env][:host]} /d #{abcs[Padrino.env][:database]} /I /f db\\#{Padrino.env}_structure.sql /q /A /r`
|
289
|
+
`scptxfr /s #{abcs[Padrino.env][:host]} /d #{abcs[Padrino.env][:database]} /I /F db\ /q /A /r`
|
290
290
|
when "firebird"
|
291
291
|
set_firebird_env(abcs[Padrino.env])
|
292
292
|
db_string = firebird_db_string(abcs[Padrino.env])
|
293
293
|
sh "isql -a #{db_string} > #{Padrino.root}/db/#{Padrino.env}_structure.sql"
|
294
294
|
else
|
295
|
-
raise "Task not supported by '#{abcs[
|
295
|
+
raise "Task not supported by '#{abcs[Padrino.env][:adapter]}'"
|
296
296
|
end
|
297
297
|
|
298
298
|
if ActiveRecord::Base.connection.supports_migrations?
|
@@ -361,15 +361,11 @@ if defined?(ActiveRecord)
|
|
361
361
|
|
362
362
|
FileUtils.rm(file)
|
363
363
|
when 'postgresql'
|
364
|
-
ActiveRecord::Base.establish_connection(config.merge(:database => 'postgres',
|
364
|
+
ActiveRecord::Base.establish_connection(config.merge(:database => 'postgres', :schema_search_path => 'public'))
|
365
365
|
ActiveRecord::Base.connection.drop_database config[:database]
|
366
366
|
end
|
367
367
|
end
|
368
368
|
|
369
|
-
def session_table_name
|
370
|
-
ActiveRecord::SessionStore::Session.table_name
|
371
|
-
end
|
372
|
-
|
373
369
|
def set_firebird_env(config)
|
374
370
|
ENV["ISC_USER"] = config[:username].to_s if config[:username]
|
375
371
|
ENV["ISC_PASSWORD"] = config[:password].to_s if config[:password]
|
@@ -526,7 +522,7 @@ if defined?(ActiveRecord)
|
|
526
522
|
fields = Array(args.shift).map(&:to_s)
|
527
523
|
options = args.shift
|
528
524
|
|
529
|
-
index_name = options[:name] if options
|
525
|
+
index_name = options[:name].to_s if options
|
530
526
|
index_name ||= ActiveRecord::Base.connection.index_name(table_name, :column => fields)
|
531
527
|
|
532
528
|
(self.indexes_in_schema ||= []) << index_name
|
data/lib/padrino-gen.rb
CHANGED
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.9.
|
8
|
+
s.version = "0.9.5"
|
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{2010-03-
|
12
|
+
s.date = %q{2010-03-11}
|
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{padrinorb@gmail.com}
|
@@ -69,6 +69,7 @@ Gem::Specification.new do |s|
|
|
69
69
|
"lib/padrino-gen/generators/project/config.ru",
|
70
70
|
"lib/padrino-gen/generators/project/config/apps.rb.tt",
|
71
71
|
"lib/padrino-gen/generators/project/config/boot.rb",
|
72
|
+
"lib/padrino-gen/generators/project/public/favicon.ico",
|
72
73
|
"lib/padrino-gen/generators/project/public/images/.empty_directory",
|
73
74
|
"lib/padrino-gen/generators/project/public/javascripts/.empty_directory",
|
74
75
|
"lib/padrino-gen/generators/project/public/stylesheets/.empty_directory",
|
@@ -109,7 +110,7 @@ Gem::Specification.new do |s|
|
|
109
110
|
s.specification_version = 3
|
110
111
|
|
111
112
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
112
|
-
s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.
|
113
|
+
s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.5"])
|
113
114
|
s.add_development_dependency(%q<haml>, [">= 2.2.1"])
|
114
115
|
s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
|
115
116
|
s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
|
@@ -117,7 +118,7 @@ Gem::Specification.new do |s|
|
|
117
118
|
s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
|
118
119
|
s.add_development_dependency(%q<fakeweb>, [">= 1.2.3"])
|
119
120
|
else
|
120
|
-
s.add_dependency(%q<padrino-core>, ["= 0.9.
|
121
|
+
s.add_dependency(%q<padrino-core>, ["= 0.9.5"])
|
121
122
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
122
123
|
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
123
124
|
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
@@ -126,7 +127,7 @@ Gem::Specification.new do |s|
|
|
126
127
|
s.add_dependency(%q<fakeweb>, [">= 1.2.3"])
|
127
128
|
end
|
128
129
|
else
|
129
|
-
s.add_dependency(%q<padrino-core>, ["= 0.9.
|
130
|
+
s.add_dependency(%q<padrino-core>, ["= 0.9.5"])
|
130
131
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
131
132
|
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
132
133
|
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
data/test/helper.rb
CHANGED
@@ -16,6 +16,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
16
16
|
assert_file_exists('/tmp/sample_project/app')
|
17
17
|
assert_file_exists('/tmp/sample_project/config/boot.rb')
|
18
18
|
assert_file_exists('/tmp/sample_project/spec/spec_helper.rb')
|
19
|
+
assert_file_exists('/tmp/sample_project/public/favicon.ico')
|
19
20
|
end
|
20
21
|
|
21
22
|
should "not create models folder if no orm is chosen" do
|
@@ -152,7 +153,6 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
152
153
|
should "properly generate default for erb" do
|
153
154
|
buffer = silence_logger { @project.start(['sample_project', '--root=/tmp', '--renderer=erb', '--script=none']) }
|
154
155
|
assert_match /Applying.*?erb.*?renderer/, buffer
|
155
|
-
assert_match_in_file(/gem 'erubis'/, '/tmp/sample_project/Gemfile')
|
156
156
|
end
|
157
157
|
|
158
158
|
should "properly generate for haml" do
|
@@ -161,6 +161,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
161
161
|
assert_match_in_file(/gem 'haml'/, '/tmp/sample_project/Gemfile')
|
162
162
|
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_project/lib/sass.rb')
|
163
163
|
assert_match_in_file(/register SassInitializer/m, '/tmp/sample_project/app/app.rb')
|
164
|
+
assert_dir_exists('/tmp/sample_project/app/stylesheets')
|
164
165
|
end
|
165
166
|
end
|
166
167
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 5
|
9
|
+
version: 0.9.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Padrino Team
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-03-
|
20
|
+
date: 2010-03-11 00:00:00 +01:00
|
21
21
|
default_executable: padrino-gen
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -30,8 +30,8 @@ dependencies:
|
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
- 9
|
33
|
-
-
|
34
|
-
version: 0.9.
|
33
|
+
- 5
|
34
|
+
version: 0.9.5
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- lib/padrino-gen/generators/project/config.ru
|
179
179
|
- lib/padrino-gen/generators/project/config/apps.rb.tt
|
180
180
|
- lib/padrino-gen/generators/project/config/boot.rb
|
181
|
+
- lib/padrino-gen/generators/project/public/favicon.ico
|
181
182
|
- lib/padrino-gen/generators/project/public/images/.empty_directory
|
182
183
|
- lib/padrino-gen/generators/project/public/javascripts/.empty_directory
|
183
184
|
- lib/padrino-gen/generators/project/public/stylesheets/.empty_directory
|