padrino-gen 0.12.9 → 0.13.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/bin/padrino-gen +2 -2
- data/lib/padrino-gen/generators/actions.rb +5 -17
- data/lib/padrino-gen/generators/app/app.rb.tt +2 -3
- data/lib/padrino-gen/generators/components/mocks/mocha.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +0 -16
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +38 -19
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +0 -1
- data/lib/padrino-gen/generators/components/stylesheets/compass.rb +16 -5
- data/lib/padrino-gen/generators/components/tests/bacon.rb +0 -2
- data/lib/padrino-gen/generators/components/tests/minitest.rb +0 -2
- data/lib/padrino-gen/generators/components/tests/riot.rb +0 -2
- data/lib/padrino-gen/generators/components/tests/rspec.rb +1 -5
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +0 -3
- data/lib/padrino-gen/generators/components/tests/steak.rb +0 -2
- data/lib/padrino-gen/generators/controller.rb +0 -1
- data/lib/padrino-gen/generators/helper.rb +0 -1
- data/lib/padrino-gen/generators/mailer.rb +0 -1
- data/lib/padrino-gen/generators/migration.rb +0 -1
- data/lib/padrino-gen/generators/plugin.rb +1 -1
- data/lib/padrino-gen/generators/project/config/boot.rb +0 -11
- data/lib/padrino-gen/generators/project.rb +2 -3
- data/lib/padrino-gen/generators/runner.rb +0 -1
- data/lib/padrino-gen/generators/task.rb +0 -1
- data/lib/padrino-gen/generators/templates/Gemfile.tt +0 -10
- data/lib/padrino-gen/generators/templates/Rakefile.tt +0 -2
- data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +10 -16
- data/lib/padrino-gen/padrino-tasks/datamapper.rb +2 -4
- data/lib/padrino-gen/padrino-tasks/sequel.rb +3 -4
- data/test/helper.rb +17 -14
- data/test/test_component_generator.rb +3 -5
- data/test/test_controller_generator.rb +0 -13
- data/test/test_helper_generator.rb +0 -13
- data/test/test_mailer_generator.rb +0 -5
- data/test/test_migration_generator.rb +0 -5
- data/test/test_model_generator.rb +24 -30
- data/test/test_plugin_generator.rb +0 -4
- data/test/test_project_generator.rb +8 -23
- data/test/test_task_generator.rb +0 -5
- metadata +46 -28
- data/lib/padrino-gen/generators/components/tests/testunit.rb +0 -112
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ODQ1NWVjOGU4MTE0MWI3MmI2NGQ3MTA1YzU3NDRiOTIzMzc0MmJkNQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3417ec67988324174088f6cfd71fa88935bbcf24
|
4
|
+
data.tar.gz: 06002f5bc93956942455fbefac8140fb872eda77
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Mjg0YWE5OWMyMzE2MDExZjc4YTExMWU1OGQwMGE4YTQ5NDBhNzUyNDgyN2Q2
|
11
|
-
ZTBhYjQxYzUwZWNhOThiN2RjNTI1ZjMzMjA3ODgyY2MyZGE4NWQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTNiMzQyNDQwZmI0NGE4ZjZmOTgwMWM1M2I5NmY4MGZiMTVlNDE3ZTYyYzYw
|
14
|
-
ZDkxMDAxODhlZjZlZmI3MmEwYmQyYmM5YjQ0Y2M0MDhjNWY2N2Y0NDlkOTY0
|
15
|
-
OGE1MjM1ODc4OTNjOWNhZTE1NGE4OTAyNDc4ZjRmZDA2MjE2Mjc=
|
6
|
+
metadata.gz: 49b82476e19803ba0e284519518058ae101d48b26c5d8f66fdf720734d912a958d40feed06952e488af063eb6c6bdca937b8a34e33b1c53c3acde215c26658bd
|
7
|
+
data.tar.gz: 7cf1ff30dda912f122dc8b08c4f0de46a54e44aef97b3c244ef5205176fde6e7b1fa415b1591496835958a174b729f91df7989ae70e587ecdf4429f379740781
|
data/bin/padrino-gen
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require '
|
3
|
-
|
2
|
+
require 'rubygems' unless defined?(Gem) # Useful only on --dev mode
|
3
|
+
require 'bundler/setup' if %w(Gemfile .components).all? { |f| File.exist?(f) }
|
4
4
|
|
5
5
|
padrino_gen_path = File.expand_path('../../lib', __FILE__)
|
6
6
|
$:.unshift(padrino_gen_path) if File.directory?(padrino_gen_path) && !$:.include?(padrino_gen_path)
|
@@ -377,9 +377,9 @@ WARNING
|
|
377
377
|
#
|
378
378
|
def initializer(name, data=nil)
|
379
379
|
@_init_name, @_init_data = name, data
|
380
|
-
register = data ? " register #{name.to_s.underscore.camelize}Initializer\n" : " register #{name}\n"
|
380
|
+
register = data.present? ? " register #{name.to_s.underscore.camelize}Initializer\n" : " register #{name}\n"
|
381
381
|
inject_into_file destination_root("/app/app.rb"), register, :after => "Padrino::Application\n"
|
382
|
-
template "templates/initializer.rb.tt", destination_root("/
|
382
|
+
template "templates/initializer.rb.tt", destination_root("/lib/#{name}_initializer.rb") if data.present?
|
383
383
|
end
|
384
384
|
|
385
385
|
##
|
@@ -520,24 +520,12 @@ WARNING
|
|
520
520
|
#
|
521
521
|
def valid_constant?(name)
|
522
522
|
if name =~ /^\d/
|
523
|
-
|
523
|
+
raise ::NameError, "Project name #{name} cannot start with numbers"
|
524
524
|
elsif name =~ /^\W/
|
525
|
-
|
525
|
+
raise ::NameError, "Project name #{name} cannot start with non-word character"
|
526
526
|
end
|
527
527
|
end
|
528
528
|
|
529
|
-
##
|
530
|
-
# Validates namespace name (controller name, etc.) or fails with an error.
|
531
|
-
#
|
532
|
-
# @example
|
533
|
-
# validate_namespace 'Project_One1' #=> pass
|
534
|
-
# validate_namespace 'Erroneous/name' #=> fail
|
535
|
-
#
|
536
|
-
def validate_namespace(name)
|
537
|
-
valid_constant? name
|
538
|
-
name.match(/^[[:alnum:]_]+$/) || fail(::NameError, "Namespace '#{name}' must consist only of alphanumeric characters or '_'")
|
539
|
-
end
|
540
|
-
|
541
529
|
##
|
542
530
|
# Recognizes the path of application.
|
543
531
|
#
|
@@ -592,7 +580,7 @@ WARNING
|
|
592
580
|
[ :test, 'testing framework', { :aliases => '-t', :default => :none }],
|
593
581
|
[ :mock, 'mocking library', { :aliases => '-m', :default => :none }],
|
594
582
|
[ :script, 'javascript library', { :aliases => '-s', :default => :none }],
|
595
|
-
[ :renderer, 'template engine', { :aliases => '-e', :default => :
|
583
|
+
[ :renderer, 'template engine', { :aliases => '-e', :default => :none }],
|
596
584
|
[ :stylesheet, 'stylesheet engine', { :aliases => '-c', :default => :none }]
|
597
585
|
].each do |name, caption, opts|
|
598
586
|
opts[:default] = '' if options[:default] == false
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module <%= @project_name %>
|
2
2
|
class <%= @app_name %> < Padrino::Application
|
3
|
-
<% unless options.api? -%>
|
4
3
|
register Padrino::Mailer
|
5
4
|
register Padrino::Helpers
|
6
|
-
|
5
|
+
|
7
6
|
enable :sessions
|
8
7
|
|
9
8
|
##
|
@@ -16,7 +15,7 @@ module <%= @project_name %>
|
|
16
15
|
#
|
17
16
|
# set :cache, Padrino::Cache.new(:LRUHash) # Keeps cached values in memory
|
18
17
|
# set :cache, Padrino::Cache.new(:Memcached) # Uses default server at localhost
|
19
|
-
# set :cache, Padrino::Cache.new(:Memcached,
|
18
|
+
# set :cache, Padrino::Cache.new(:Memcached, '127.0.0.1:11211', :exception_retry_limit => 1)
|
20
19
|
# set :cache, Padrino::Cache.new(:Memcached, :backend => memcached_or_dalli_instance)
|
21
20
|
# set :cache, Padrino::Cache.new(:Redis) # Uses default server at localhost
|
22
21
|
# set :cache, Padrino::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0)
|
@@ -4,7 +4,7 @@ def setup_mock
|
|
4
4
|
when 'rspec'
|
5
5
|
inject_into_file 'spec/spec_helper.rb', " conf.mock_with :mocha\n", :after => "RSpec.configure do |conf|\n"
|
6
6
|
else
|
7
|
-
inject_into_file 'test/test_config.rb', "require 'mocha/api'
|
7
|
+
inject_into_file 'test/test_config.rb', "require 'mocha/api'", :after => "require File.expand_path(File.dirname(__FILE__) + \"/../config/boot\")\n"
|
8
8
|
insert_mocking_include "Mocha::API"
|
9
9
|
end
|
10
10
|
end
|
@@ -41,21 +41,6 @@ case Padrino.env
|
|
41
41
|
end
|
42
42
|
DM
|
43
43
|
|
44
|
-
IDENTITY_MAP_MIDDLEWARE = <<-MIDDLEWARE
|
45
|
-
class IdentityMap
|
46
|
-
def initialize(app, name = :default)
|
47
|
-
@app = app
|
48
|
-
@name = name.to_sym
|
49
|
-
end
|
50
|
-
|
51
|
-
def call(env)
|
52
|
-
::DataMapper.repository(@name) do
|
53
|
-
@app.call(env)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
MIDDLEWARE
|
58
|
-
|
59
44
|
def setup_orm
|
60
45
|
dm = DM
|
61
46
|
db = @project_name.underscore
|
@@ -88,7 +73,6 @@ def setup_orm
|
|
88
73
|
|
89
74
|
create_file("config/database.rb", dm)
|
90
75
|
insert_hook("DataMapper.finalize", :after_load)
|
91
|
-
middleware :identity_map, IDENTITY_MAP_MIDDLEWARE
|
92
76
|
end
|
93
77
|
|
94
78
|
DM_MODEL = (<<-MODEL) unless defined?(DM_MODEL)
|
@@ -1,4 +1,31 @@
|
|
1
1
|
MONGOID = (<<-MONGO) unless defined?(MONGOID)
|
2
|
+
# Connection.new takes host and port
|
3
|
+
host = 'localhost'
|
4
|
+
port = Mongo::Connection::DEFAULT_PORT
|
5
|
+
|
6
|
+
database_name = case Padrino.env
|
7
|
+
when :development then '!NAME!_development'
|
8
|
+
when :production then '!NAME!_production'
|
9
|
+
when :test then '!NAME!_test'
|
10
|
+
end
|
11
|
+
|
12
|
+
Mongoid.database = Mongo::Connection.new(host, port).db(database_name)
|
13
|
+
|
14
|
+
# You can also configure Mongoid this way:
|
15
|
+
# Mongoid.configure do |config|
|
16
|
+
# name = @settings["database"]
|
17
|
+
# host = @settings["host"]
|
18
|
+
# config.master = Mongo::Connection.new.db(name)
|
19
|
+
# config.slaves = [
|
20
|
+
# Mongo::Connection.new(host, @settings["slave_one"]["port"], :slave_ok => true).db(name),
|
21
|
+
# Mongo::Connection.new(host, @settings["slave_two"]["port"], :slave_ok => true).db(name)
|
22
|
+
# ]
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# More installation and setup notes are on http://mongoid.org/.
|
26
|
+
MONGO
|
27
|
+
|
28
|
+
MONGOID3 = (<<-MONGO) unless defined?(MONGOID3)
|
2
29
|
# Connection.new takes host and port.
|
3
30
|
|
4
31
|
host = 'localhost'
|
@@ -11,18 +38,12 @@ database_name = case Padrino.env
|
|
11
38
|
end
|
12
39
|
|
13
40
|
# Use MONGO_URI if it's set as an environmental variable.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
case Mongoid::VERSION
|
21
|
-
when /^(3|4)/
|
22
|
-
Mongoid::Config.sessions = database_settings
|
23
|
-
else
|
24
|
-
Mongoid::Config.load_configuration :clients => database_settings
|
25
|
-
end
|
41
|
+
Mongoid::Config.sessions =
|
42
|
+
if ENV['MONGO_URI']
|
43
|
+
{default: {uri: ENV['MONGO_URI'] }}
|
44
|
+
else
|
45
|
+
{default: {hosts: ["#\{host\}:#\{port\}"], database: database_name}}
|
46
|
+
end
|
26
47
|
|
27
48
|
# If you want to use a YML file for config, use this instead:
|
28
49
|
#
|
@@ -30,33 +51,31 @@ end
|
|
30
51
|
#
|
31
52
|
# And add a config/database.yml file like this:
|
32
53
|
# development:
|
33
|
-
#
|
54
|
+
# sessions:
|
34
55
|
# default:
|
35
56
|
# database: !NAME!_development
|
36
57
|
# hosts:
|
37
58
|
# - localhost:27017
|
38
|
-
#
|
39
59
|
# production:
|
40
|
-
#
|
60
|
+
# sessions:
|
41
61
|
# default:
|
42
62
|
# database: !NAME!_production
|
43
63
|
# hosts:
|
44
64
|
# - localhost:27017
|
45
|
-
#
|
46
65
|
# test:
|
47
|
-
#
|
66
|
+
# sessions:
|
48
67
|
# default:
|
49
68
|
# database: !NAME!_test
|
50
69
|
# hosts:
|
51
70
|
# - localhost:27017
|
52
71
|
#
|
53
72
|
#
|
54
|
-
# More installation and setup notes are on
|
73
|
+
# More installation and setup notes are on http://mongoid.org/en/mongoid/docs/installation.html#configuration
|
55
74
|
MONGO
|
56
75
|
|
57
76
|
def setup_orm
|
58
77
|
require_dependencies 'mongoid', :version => '>= 3.0.0'
|
59
|
-
create_file('config/database.rb',
|
78
|
+
create_file('config/database.rb', MONGOID3.gsub(/!NAME!/, @project_name.underscore))
|
60
79
|
end
|
61
80
|
|
62
81
|
MONGOID_MODEL = (<<-MODEL) unless defined?(MONGOID_MODEL)
|
@@ -11,7 +11,6 @@ MONGO
|
|
11
11
|
def setup_orm
|
12
12
|
require_dependencies 'mongo_mapper'
|
13
13
|
require_dependencies 'bson_ext', :require => 'mongo'
|
14
|
-
require_dependencies 'activemodel', :version => '< 5'
|
15
14
|
create_file("config/database.rb", MONGO.gsub(/!NAME!/, @project_name.underscore))
|
16
15
|
end
|
17
16
|
|
@@ -1,7 +1,10 @@
|
|
1
1
|
COMPASS_INIT = <<-COMPASS unless defined?(COMPASS_INIT)
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
# Enables support for Compass, a stylesheet authoring framework based on SASS.
|
3
|
+
# See http://compass-style.org/ for more details.
|
4
|
+
# Store Compass/SASS files (by default) within 'app/stylesheets'.
|
5
|
+
|
6
|
+
module CompassInitializer
|
7
|
+
def self.registered(app)
|
5
8
|
require 'sass/plugin/rack'
|
6
9
|
|
7
10
|
Compass.configuration do |config|
|
@@ -19,10 +22,18 @@ COMPASS_INIT = <<-COMPASS unless defined?(COMPASS_INIT)
|
|
19
22
|
Compass.handle_configuration_change!
|
20
23
|
|
21
24
|
app.use Sass::Plugin::Rack
|
25
|
+
end
|
26
|
+
end
|
22
27
|
COMPASS
|
23
28
|
|
29
|
+
COMPASS_REGISTER = <<-COMPASSR unless defined?(COMPASS_REGISTER)
|
30
|
+
register CompassInitializer\n
|
31
|
+
COMPASSR
|
32
|
+
|
24
33
|
def setup_stylesheet
|
25
|
-
require_dependencies 'compass
|
26
|
-
|
34
|
+
require_dependencies 'compass'
|
35
|
+
create_file destination_root('/lib/compass_plugin.rb'), COMPASS_INIT
|
36
|
+
inject_into_file destination_root('/app/app.rb'), COMPASS_REGISTER, :after => "register Padrino::Helpers\n"
|
37
|
+
|
27
38
|
directory "components/stylesheets/compass/", destination_root('/app/stylesheets')
|
28
39
|
end
|
@@ -57,12 +57,8 @@ begin
|
|
57
57
|
desc "Run complete application spec suite"
|
58
58
|
task 'spec' => spec_tasks.map { |f| "spec:\#{f}" }
|
59
59
|
rescue LoadError
|
60
|
-
|
61
|
-
puts "RSpec is not part of this bundle, skip specs."
|
62
|
-
end
|
60
|
+
puts "RSpec is not part of this bundle, skip specs."
|
63
61
|
end
|
64
|
-
|
65
|
-
task :default => :spec
|
66
62
|
TEST
|
67
63
|
|
68
64
|
RSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_MODEL_TEST)
|
@@ -54,8 +54,6 @@ end
|
|
54
54
|
|
55
55
|
desc "Run application test suite"
|
56
56
|
task 'test' => test_tasks.map { |f| "test:\#{f}" }
|
57
|
-
|
58
|
-
task :default => :test
|
59
57
|
TEST
|
60
58
|
|
61
59
|
SHOULDA_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_MODEL_TEST)
|
@@ -91,7 +89,6 @@ TEST
|
|
91
89
|
def setup_test
|
92
90
|
require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
|
93
91
|
require_dependencies 'shoulda', :group => 'test'
|
94
|
-
require_dependencies 'test-unit', :group => 'test'
|
95
92
|
insert_test_suite_setup SHOULDA_SETUP
|
96
93
|
create_file destination_root("test/test.rake"), SHOULDA_RAKE
|
97
94
|
end
|
@@ -55,7 +55,7 @@ module Padrino
|
|
55
55
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
56
56
|
http.start do
|
57
57
|
http.request_get(uri.path) do |res|
|
58
|
-
plugins = res.body.scan(%r{/plugins/(\w
|
58
|
+
plugins = res.body.scan(%r{/plugins/(\w+)_plugin.rb}).uniq
|
59
59
|
end
|
60
60
|
end
|
61
61
|
say "Available plugins:", :green
|
@@ -12,10 +12,6 @@ Bundler.require(:default, RACK_ENV)
|
|
12
12
|
# Padrino::Logger::Config[:development][:log_level] = :devel
|
13
13
|
# Padrino::Logger::Config[:development][:log_static] = true
|
14
14
|
#
|
15
|
-
# ## Configure Ruby to allow requiring features from your lib folder
|
16
|
-
#
|
17
|
-
# $LOAD_PATH.unshift Padrino.root('lib')
|
18
|
-
#
|
19
15
|
# ## Enable logging of source location
|
20
16
|
#
|
21
17
|
# Padrino::Logger::Config[:development][:source_location] = true
|
@@ -38,15 +34,8 @@ Bundler.require(:default, RACK_ENV)
|
|
38
34
|
# include Padrino::Helpers::TranslationHelpers
|
39
35
|
# end
|
40
36
|
|
41
|
-
##
|
42
|
-
# Require initializers before all other dependencies.
|
43
|
-
# Dependencies from 'config' folder are NOT re-required on reload.
|
44
|
-
#
|
45
|
-
Padrino.dependency_paths.unshift Padrino.root('config/initializers/*.rb')
|
46
|
-
|
47
37
|
##
|
48
38
|
# Add your before (RE)load hooks here
|
49
|
-
# These hooks are run before any dependencies are required.
|
50
39
|
#
|
51
40
|
Padrino.before_load do
|
52
41
|
end
|
@@ -27,11 +27,10 @@ module Padrino
|
|
27
27
|
class_option :dev, :desc => 'Use padrino from a git checkout', :default => false, :type => :boolean
|
28
28
|
class_option :tiny, :desc => 'Generate tiny app skeleton', :aliases => '-i', :default => false, :type => :boolean
|
29
29
|
class_option :lean, :desc => 'Generate lean project without apps', :aliases => '-l', :default => false, :type => :boolean
|
30
|
-
class_option :
|
30
|
+
class_option :adapter, :desc => 'SQL adapter for ORM (sqlite, mysql, mysql2, mysql-gem, postgres)', :aliases => '-a', :default => 'sqlite', :type => :string
|
31
31
|
class_option :template, :desc => 'Generate project from template', :aliases => '-p', :default => nil, :type => :string
|
32
32
|
class_option :gem, :desc => 'Generate project as a gem', :aliases => '-g', :default => false, :type => :boolean
|
33
33
|
class_option :migration_format, :desc => 'Filename format for migrations (number, timestamp)', :default => 'number', :type => :string
|
34
|
-
class_option :adapter, :desc => 'SQL adapter for ORM (sqlite, mysql, mysql2, mysql-gem, postgres)', :aliases => '-a', :default => 'sqlite', :type => :string
|
35
34
|
|
36
35
|
# Definitions for the available customizable components.
|
37
36
|
defines_component_options
|
@@ -136,7 +135,7 @@ module Padrino
|
|
136
135
|
say "#{name} is ready for development!", :green
|
137
136
|
say '=' * 65, :green
|
138
137
|
say "$ cd #{options[:root]}/#{name}"
|
139
|
-
say "$ bundle
|
138
|
+
say "$ bundle" unless options[:bundle]
|
140
139
|
say "=" * 65, :green
|
141
140
|
say
|
142
141
|
end
|
@@ -20,15 +20,6 @@ gem 'rake'
|
|
20
20
|
|
21
21
|
# Test requirements
|
22
22
|
|
23
|
-
<% if options.api? -%>
|
24
|
-
<% if options.dev? -%>
|
25
|
-
gem 'padrino-core', :path => '<%= Padrino::Generators::DEV_PATH %>/padrino-core'
|
26
|
-
gem 'padrino-gen', :path => '<%= Padrino::Generators::DEV_PATH %>/padrino-gen'
|
27
|
-
<% else -%>
|
28
|
-
gem 'padrino-core', '<%= Padrino.version %>'
|
29
|
-
gem 'padrino-gen', '<%= Padrino.version %>'
|
30
|
-
<% end -%>
|
31
|
-
<% else -%>
|
32
23
|
# Padrino Stable Gem
|
33
24
|
<% if options.dev? %># <% end %>gem 'padrino', '<%= Padrino.version %>'
|
34
25
|
|
@@ -39,4 +30,3 @@ gem 'padrino-gen', '<%= Padrino.version %>'
|
|
39
30
|
<% unless options.dev? %># <% end %>%w(core support gen helpers cache mailer admin).each do |g|
|
40
31
|
<% unless options.dev? %># <% end %> gem 'padrino-' + g, <% if options.dev? %>:path => '<%= Padrino::Generators::DEV_PATH %>/padrino-' + g<% else %>'<%= Padrino.version %>'<% end %>
|
41
32
|
<% unless options.dev? %># <% end %>end
|
42
|
-
<% end -%>
|
@@ -44,7 +44,7 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
|
|
44
44
|
else
|
45
45
|
begin
|
46
46
|
# Create the SQLite database
|
47
|
-
|
47
|
+
Dir.mkdir File.dirname(config[:database]) unless File.exist?(File.dirname(config[:database]))
|
48
48
|
ActiveRecord::Base.establish_connection(config)
|
49
49
|
ActiveRecord::Base.connection
|
50
50
|
rescue StandardError => e
|
@@ -121,17 +121,17 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking ar:schema:dump. Target specific version with
|
124
|
+
desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking ar:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
125
125
|
task :migrate => :skeleton do
|
126
126
|
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
127
|
-
ActiveRecord::Migrator.migrate("db/migrate/",
|
127
|
+
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
128
128
|
Rake::Task["ar:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
129
129
|
end
|
130
130
|
|
131
131
|
namespace :migrate do
|
132
|
-
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with
|
132
|
+
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
|
133
133
|
task :redo => :skeleton do
|
134
|
-
if
|
134
|
+
if ENV["VERSION"]
|
135
135
|
Rake::Task["ar:migrate:down"].invoke
|
136
136
|
Rake::Task["ar:migrate:up"].invoke
|
137
137
|
else
|
@@ -143,10 +143,10 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
|
|
143
143
|
desc 'Resets your database using your migrations for the current environment'
|
144
144
|
task :reset => ["ar:drop", "ar:create", "ar:migrate"]
|
145
145
|
|
146
|
-
desc 'Runs the "up" for a given
|
146
|
+
desc 'Runs the "up" for a given migration VERSION.'
|
147
147
|
task(:up => :skeleton){ migrate_as(:up) }
|
148
148
|
|
149
|
-
desc 'Runs the "down" for a given
|
149
|
+
desc 'Runs the "down" for a given migration VERSION.'
|
150
150
|
task(:down => :skeleton){ migrate_as(:down) }
|
151
151
|
end
|
152
152
|
|
@@ -246,7 +246,7 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
|
|
246
246
|
unless search_path.blank?
|
247
247
|
search_path = search_path.split(",").map{|search_path| "--schema=#{search_path.strip}" }.join(" ")
|
248
248
|
end
|
249
|
-
`pg_dump -U "#{config[:username]}" -s -x -O -f db/#{Padrino.env}_structure.sql #{search_path} #{config[:database]}`
|
249
|
+
`pg_dump -i -U "#{config[:username]}" -s -x -O -f db/#{Padrino.env}_structure.sql #{search_path} #{config[:database]}`
|
250
250
|
raise "Error dumping database" if $?.exitstatus == 1
|
251
251
|
when "sqlite", "sqlite3"
|
252
252
|
dbfile = config[:database] || config[:dbfile]
|
@@ -309,12 +309,6 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
|
|
309
309
|
puts
|
310
310
|
end
|
311
311
|
end
|
312
|
-
|
313
|
-
task :seed => :environment do
|
314
|
-
missing_model_features = Padrino.send(:default_dependency_paths) - Padrino.send(:dependency_paths)
|
315
|
-
Padrino.require_dependencies(missing_model_features)
|
316
|
-
Rake::Task['db:seed'].invoke
|
317
|
-
end
|
318
312
|
end
|
319
313
|
|
320
314
|
def drop_database(config)
|
@@ -355,8 +349,8 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
|
|
355
349
|
end
|
356
350
|
|
357
351
|
def migrate_as(type)
|
358
|
-
version =
|
359
|
-
|
352
|
+
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
353
|
+
raise "VERSION is required" unless version
|
360
354
|
ActiveRecord::Migrator.run(type, "db/migrate/", version)
|
361
355
|
dump_schema
|
362
356
|
end
|
@@ -24,14 +24,14 @@ if PadrinoTasks.load?(:datamapper, defined?(DataMapper))
|
|
24
24
|
|
25
25
|
desc "Migrate up using migrations"
|
26
26
|
task :up, [:version] => :load do |t, args|
|
27
|
-
version = args[:version] ||
|
27
|
+
version = args[:version] || ENV['VERSION']
|
28
28
|
migrate_up!(version)
|
29
29
|
puts "<= dm:migrate:up #{version} executed"
|
30
30
|
end
|
31
31
|
|
32
32
|
desc "Migrate down using migrations"
|
33
33
|
task :down, [:version] => :load do |t, args|
|
34
|
-
version = args[:version] ||
|
34
|
+
version = args[:version] || ENV['VERSION']
|
35
35
|
migrate_down!(version)
|
36
36
|
puts "<= dm:migrate:down #{version} executed"
|
37
37
|
end
|
@@ -86,8 +86,6 @@ if PadrinoTasks.load?(:datamapper, defined?(DataMapper))
|
|
86
86
|
task :setup => [:create, :migrate, :seed]
|
87
87
|
end
|
88
88
|
|
89
|
-
task 'db:migrate:down' => 'dm:migrate:down'
|
90
|
-
task 'db:migrate:up' => 'dm:migrate:up'
|
91
89
|
task 'db:migrate' => 'dm:migrate'
|
92
90
|
task 'db:create' => 'dm:create'
|
93
91
|
task 'db:drop' => 'dm:drop'
|
@@ -9,11 +9,11 @@ if PadrinoTasks.load?(:sequel, defined?(Sequel))
|
|
9
9
|
puts "<= sq:migrate:auto executed"
|
10
10
|
end
|
11
11
|
|
12
|
-
desc "Perform migration up/down to
|
12
|
+
desc "Perform migration up/down to VERSION"
|
13
13
|
task :to, [:version] => :skeleton do |t, args|
|
14
|
-
version = (args[:version] ||
|
14
|
+
version = (args[:version] || ENV['VERSION']).to_s.strip
|
15
15
|
::Sequel.extension :migration
|
16
|
-
|
16
|
+
raise "No VERSION was provided" if version.empty?
|
17
17
|
::Sequel::Migrator.apply(Sequel::Model.db, "db/migrate", version.to_i)
|
18
18
|
puts "<= sq:migrate:to[#{version}] executed"
|
19
19
|
end
|
@@ -80,7 +80,6 @@ if PadrinoTasks.load?(:sequel, defined?(Sequel))
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
task 'db:create' => 'sq:create'
|
84
83
|
task 'db:migrate' => 'sq:migrate'
|
85
84
|
task 'db:reset' => 'sq:reset'
|
86
85
|
end
|