combustion 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +12 -1
- data/README.textile +23 -5
- data/combustion.gemspec +3 -2
- data/lib/combustion.rb +6 -6
- data/lib/combustion/application.rb +34 -25
- data/lib/combustion/database.rb +137 -135
- data/lib/combustion/generator.rb +22 -20
- metadata +19 -3
data/HISTORY
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.4.0 - March 16th 2013
|
2
|
+
* Don't delete the SQLite test database if it doesn't exist (Michael Gee, Alexander Rozumiy).
|
3
|
+
* Support for secret_key_base for Rails 4 apps (Philip Arndt).
|
4
|
+
* eager_load is set to true when using the production environment (Philip Arndt).
|
5
|
+
* whiny_nils is not set if using Rails 4 (Philip Arndt).
|
6
|
+
* Mysql2 can raise Mysql::Error with JRuby (Philip Arndt).
|
7
|
+
* Whitelist attributes typo is fixed (Geoff Hodgson).
|
8
|
+
* Mass assignment checks are now turned on, so errors are raised. This matches Rails' defaults for test environments (Josh Adams).
|
9
|
+
* Combustion no longer loads all of the Rails stack by default, just Railties and ActiveSupport. A combustion-rails gem will be created that uses all of Rails by default (Philip Arndt).
|
10
|
+
* Combustion classes now all define the outer module, so each can be required by themselves, should you desire (Philip Arndt).
|
11
|
+
|
1
12
|
0.3.3 - December 23rd 2012
|
2
13
|
* Removing version file - version number can just live in the gemspec.
|
3
14
|
* Load ActionController and ActionMailer via their Railties, not non-existent Engines (Chris Beer).
|
@@ -7,7 +18,7 @@
|
|
7
18
|
* Correctly drop the test database when using SQLite (Warren Seen).
|
8
19
|
* Don't attempt to load sprockets for Rails 3.0.x (Alex Rozumey).
|
9
20
|
|
10
|
-
0.3.2 - March 3rd
|
21
|
+
0.3.2 - March 3rd 2012
|
11
22
|
* Tentative Rails 3.0 and migrations support.
|
12
23
|
* Allow for different internal app directory.
|
13
24
|
|
data/README.textile
CHANGED
@@ -11,14 +11,14 @@ Get the gem into either your gemspec or your Gemfile, depending on how you manag
|
|
11
11
|
<pre><code># gemspec
|
12
12
|
gem.add_development_dependency 'combustion', '~> 0.3.1'
|
13
13
|
# Gemfile
|
14
|
-
gem 'combustion', '~> 0.3.1', :group => :
|
14
|
+
gem 'combustion', '~> 0.3.1', :group => :test</code></pre>
|
15
15
|
|
16
16
|
In your @spec_helper.rb@, get Combustion to set itself up - which has to happen before you introduce @rspec/rails@ and - if being used - @capybara/rails@. Here's an example within context:
|
17
17
|
|
18
18
|
<pre><code>require 'rubygems'
|
19
19
|
require 'bundler'
|
20
20
|
|
21
|
-
Bundler.require :default, :
|
21
|
+
Bundler.require :default, :test
|
22
22
|
|
23
23
|
require 'capybara/rspec'
|
24
24
|
|
@@ -50,10 +50,24 @@ Combustion.initialize!</code></pre>
|
|
50
50
|
|
51
51
|
h3. Configuring which Rails modules should be loaded.
|
52
52
|
|
53
|
-
By default, Combustion
|
53
|
+
By default, Combustion doesn't come with any of the Rails stack. You can customise this though - just pass in what you'd like loaded to the @Combustion.initialize!@ call:
|
54
54
|
|
55
|
-
<pre><code>
|
56
|
-
|
55
|
+
<pre><code>
|
56
|
+
Combustion.initialize! :active_record, :action_controller,
|
57
|
+
:action_view, :sprockets
|
58
|
+
</code></pre>
|
59
|
+
|
60
|
+
And then in your engine's Gemfile:
|
61
|
+
|
62
|
+
<pre><code>
|
63
|
+
group :test do
|
64
|
+
gem 'activerecord'
|
65
|
+
gem 'actionpack' # action_controller, action_view
|
66
|
+
gem 'sprockets'
|
67
|
+
end
|
68
|
+
</code></pre>
|
69
|
+
|
70
|
+
Make sure to specify the appropriate version that you want to use.
|
57
71
|
|
58
72
|
ActiveSupport is always loaded, as it's an integral part of Rails.
|
59
73
|
|
@@ -95,6 +109,10 @@ end</code></pre>
|
|
95
109
|
|
96
110
|
Just like in a standard Rails app, if you have a mounted engine, then its routes are accessible through whatever it has been loaded as.
|
97
111
|
|
112
|
+
h3. Using other Rails-focused libraries
|
113
|
+
|
114
|
+
Be aware that other gems may require parts of Rails when they're loaded, and this could cause some issues with Combustion's own setup. You may need to manage the loading yourself by setting @:require@ to false in your Gemfile for the gem in question, and then requiring it manually in your spec_helper. View "this issue":https://github.com/pat/combustion/issues/33 for an example with FactoryGirl.
|
115
|
+
|
98
116
|
h3. Environment and Logging
|
99
117
|
|
100
118
|
Your tests will execute within the test environment for the internal Rails app - and so logs are available at @spec/internal/log/test.log@. You should probably create that log directory so Rails doesn't complain.
|
data/combustion.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'combustion'
|
4
|
-
s.version = '0.
|
4
|
+
s.version = '0.4.0'
|
5
5
|
s.authors = ['Pat Allan']
|
6
6
|
s.email = ['pat@freelancing-gods.com']
|
7
7
|
s.homepage = ''
|
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
|
18
|
-
s.add_runtime_dependency '
|
18
|
+
s.add_runtime_dependency 'activesupport', '>= 3.0.0'
|
19
|
+
s.add_runtime_dependency 'railties', '>= 3.0.0'
|
19
20
|
s.add_runtime_dependency 'thor', '>= 0.14.6'
|
20
21
|
end
|
data/lib/combustion.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require 'active_support/dependencies'
|
3
3
|
|
4
|
-
module Combustion
|
4
|
+
module Combustion
|
5
5
|
mattr_accessor :path, :schema_format
|
6
|
-
|
6
|
+
|
7
7
|
self.path = '/spec/internal'
|
8
8
|
self.schema_format = :ruby
|
9
9
|
|
@@ -15,22 +15,22 @@ module Combustion
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.initialize!(*modules)
|
18
|
-
modules = Modules if modules
|
18
|
+
modules = Modules if modules == [:all]
|
19
19
|
modules.each { |mod| require "#{mod}/railtie" }
|
20
20
|
|
21
21
|
Combustion::Application.configure_for_combustion
|
22
22
|
Combustion::Application.initialize!
|
23
23
|
|
24
|
-
if modules.
|
24
|
+
if modules.map(&:to_s).include? 'active_record'
|
25
25
|
Combustion::Database.setup
|
26
26
|
end
|
27
27
|
|
28
28
|
RSpec.configure do |config|
|
29
29
|
include_capybara_into config
|
30
30
|
|
31
|
-
config.include
|
31
|
+
config.include Combustion::Application.routes.url_helpers
|
32
32
|
if Combustion::Application.routes.respond_to?(:mounted_helpers)
|
33
|
-
config.include
|
33
|
+
config.include Combustion::Application.routes.mounted_helpers
|
34
34
|
end
|
35
35
|
end if defined?(RSpec) && RSpec.respond_to?(:configure)
|
36
36
|
end
|
@@ -1,34 +1,43 @@
|
|
1
|
-
|
1
|
+
require 'securerandom'
|
2
|
+
Rails.env = ENV['RAILS_ENV'] || 'test'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module Combustion
|
5
|
+
class Application < Rails::Application
|
6
|
+
# Core Settings
|
7
|
+
config.cache_classes = true
|
8
|
+
config.whiny_nils = true if Rails.version < '4.0.0'
|
9
|
+
config.consider_all_requests_local = true
|
10
|
+
config.secret_token = Digest::SHA1.hexdigest Time.now.to_s
|
11
|
+
config.eager_load = Rails.env.production?
|
12
|
+
config.secret_key_base = SecureRandom.hex if Rails.version >= '4.0.0'
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
# ActiveSupport Settings
|
15
|
+
config.active_support.deprecation = :stderr
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def self.configure_for_combustion
|
17
|
-
config.root = File.expand_path File.join(Dir.pwd, Combustion.path)
|
17
|
+
# Turn on ActiveRecord attribute whitelisting
|
18
|
+
# This way the dummy app matches new rails apps re: this setting
|
19
|
+
config.active_record.whitelist_attributes = true if config.respond_to? :active_record
|
18
20
|
|
19
|
-
if
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
# Some settings we're not sure if we want, so let's not load them by default.
|
22
|
+
# Instead, wait for this method to be invoked (to get around load-order
|
23
|
+
# complications).
|
24
|
+
def self.configure_for_combustion
|
25
|
+
config.root = File.expand_path File.join(Dir.pwd, Combustion.path)
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
if defined? ActionController::Railtie
|
28
|
+
config.action_dispatch.show_exceptions = false
|
29
|
+
config.action_controller.perform_caching = false
|
30
|
+
config.action_controller.allow_forgery_protection = false
|
31
|
+
end
|
32
|
+
|
33
|
+
if defined? ActionMailer::Railtie
|
34
|
+
config.action_mailer.delivery_method = :test
|
35
|
+
config.action_mailer.default_url_options = {:host => 'www.example.com'}
|
36
|
+
end
|
29
37
|
|
30
|
-
|
31
|
-
|
38
|
+
if defined? Sprockets
|
39
|
+
config.assets.enabled = true
|
40
|
+
end
|
32
41
|
end
|
33
42
|
end
|
34
43
|
end
|
data/lib/combustion/database.rb
CHANGED
@@ -1,166 +1,168 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module Combustion
|
2
|
+
class Database
|
3
|
+
def self.setup
|
4
|
+
silence_stream(STDOUT) do
|
5
|
+
reset_database
|
6
|
+
load_schema
|
7
|
+
migrate
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
11
|
+
def self.reset_database
|
12
|
+
abcs = ActiveRecord::Base.configurations
|
13
|
+
case abcs['test']['adapter']
|
14
|
+
when /mysql/
|
15
|
+
ActiveRecord::Base.establish_connection(:test)
|
16
|
+
ActiveRecord::Base.connection.recreate_database(abcs['test']['database'],
|
17
|
+
mysql_creation_options(abcs['test']))
|
18
|
+
ActiveRecord::Base.establish_connection(:test)
|
19
|
+
when /postgresql/
|
20
|
+
ActiveRecord::Base.clear_active_connections!
|
21
|
+
drop_database(abcs['test'])
|
22
|
+
create_database(abcs['test'])
|
23
|
+
when /sqlite/
|
24
|
+
drop_database(abcs['test'])
|
25
|
+
create_database(abcs['test'])
|
26
|
+
when 'sqlserver'
|
27
|
+
test = abcs.deep_dup['test']
|
28
|
+
test_database = test['database']
|
29
|
+
test['database'] = 'master'
|
30
|
+
ActiveRecord::Base.establish_connection(test)
|
31
|
+
ActiveRecord::Base.connection.recreate_database!(test_database)
|
32
|
+
when "oci", "oracle"
|
33
|
+
ActiveRecord::Base.establish_connection(:test)
|
34
|
+
ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
|
35
|
+
ActiveRecord::Base.connection.execute(ddl)
|
36
|
+
end
|
37
|
+
when 'firebird'
|
38
|
+
ActiveRecord::Base.establish_connection(:test)
|
39
|
+
ActiveRecord::Base.connection.recreate_database!
|
40
|
+
else
|
41
|
+
raise "Cannot reset databases for '#{abcs['test']['adapter']}'"
|
35
42
|
end
|
36
|
-
when 'firebird'
|
37
|
-
ActiveRecord::Base.establish_connection(:test)
|
38
|
-
ActiveRecord::Base.connection.recreate_database!
|
39
|
-
else
|
40
|
-
raise "Cannot reset databases for '#{abcs['test']['adapter']}'"
|
41
43
|
end
|
42
|
-
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
def self.load_schema
|
46
|
+
case Combustion.schema_format
|
47
|
+
when :ruby
|
48
|
+
load Rails.root.join('db', 'schema.rb')
|
49
|
+
when :sql
|
50
|
+
ActiveRecord::Base.connection.execute(
|
51
|
+
File.read(Rails.root.join('db', 'structure.sql'))
|
52
|
+
)
|
53
|
+
else
|
54
|
+
raise "Unknown schema format: #{Combustion.schema_format}"
|
55
|
+
end
|
54
56
|
end
|
55
|
-
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
def self.migrate
|
59
|
+
migrator = ActiveRecord::Migrator
|
60
|
+
paths = Array('db/migrate/')
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
if migrator.respond_to?(:migrations_paths)
|
63
|
+
paths = migrator.migrations_paths
|
64
|
+
end
|
65
|
+
# Append the migrations inside the internal app's db/migrate directory
|
66
|
+
paths << File.join(Rails.root, 'db/migrate')
|
67
|
+
migrator.migrate paths, nil
|
63
68
|
end
|
64
|
-
# Append the migrations inside the internal app's db/migrate directory
|
65
|
-
paths << File.join(Rails.root, 'db/migrate')
|
66
|
-
migrator.migrate paths, nil
|
67
|
-
end
|
68
69
|
|
69
|
-
|
70
|
+
private
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
def self.create_database(config)
|
73
|
+
begin
|
74
|
+
if config['adapter'] =~ /sqlite/
|
75
|
+
if File.exist?(config['database'])
|
76
|
+
$stderr.puts "#{config['database']} already exists"
|
77
|
+
else
|
78
|
+
begin
|
79
|
+
# Create the SQLite database
|
80
|
+
ActiveRecord::Base.establish_connection(config)
|
81
|
+
ActiveRecord::Base.connection
|
82
|
+
rescue Exception => e
|
83
|
+
$stderr.puts e, *(e.backtrace)
|
84
|
+
$stderr.puts "Couldn't create database for #{config.inspect}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
return # Skip the else clause of begin/rescue
|
76
88
|
else
|
89
|
+
ActiveRecord::Base.establish_connection(config)
|
90
|
+
ActiveRecord::Base.connection
|
91
|
+
end
|
92
|
+
rescue
|
93
|
+
case config['adapter']
|
94
|
+
when /^(jdbc)?mysql/
|
95
|
+
if config['adapter'] =~ /jdbc/
|
96
|
+
#FIXME After Jdbcmysql gives this class
|
97
|
+
require 'active_record/railties/jdbcmysql_error'
|
98
|
+
error_class = ArJdbcMySQL::Error
|
99
|
+
else
|
100
|
+
error_class = config['adapter'] =~ /mysql2/ && defined?(Mysql2) ? Mysql2::Error : Mysql::Error
|
101
|
+
end
|
102
|
+
access_denied_error = 1045
|
103
|
+
begin
|
104
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
|
105
|
+
ActiveRecord::Base.connection.create_database(config['database'], mysql_creation_options(config))
|
106
|
+
ActiveRecord::Base.establish_connection(config)
|
107
|
+
rescue error_class => sqlerr
|
108
|
+
if sqlerr.errno == access_denied_error
|
109
|
+
print "#{sqlerr.error}. \nPlease provide the root password for your mysql installation\n>"
|
110
|
+
root_password = $stdin.gets.strip
|
111
|
+
grant_statement = "GRANT ALL PRIVILEGES ON #{config['database']}.* " \
|
112
|
+
"TO '#{config['username']}'@'localhost' " \
|
113
|
+
"IDENTIFIED BY '#{config['password']}' WITH GRANT OPTION;"
|
114
|
+
ActiveRecord::Base.establish_connection(config.merge(
|
115
|
+
'database' => nil, 'username' => 'root', 'password' => root_password))
|
116
|
+
ActiveRecord::Base.connection.create_database(config['database'], mysql_creation_options(config))
|
117
|
+
ActiveRecord::Base.connection.execute grant_statement
|
118
|
+
ActiveRecord::Base.establish_connection(config)
|
119
|
+
else
|
120
|
+
$stderr.puts sqlerr.error
|
121
|
+
$stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation}"
|
122
|
+
$stderr.puts "(if you set the charset manually, make sure you have a matching collation)" if config['charset']
|
123
|
+
end
|
124
|
+
end
|
125
|
+
when /^(jdbc)?postgresql$/
|
126
|
+
@encoding = config['encoding'] || ENV['CHARSET'] || 'utf8'
|
77
127
|
begin
|
78
|
-
|
128
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
129
|
+
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
|
79
130
|
ActiveRecord::Base.establish_connection(config)
|
80
|
-
ActiveRecord::Base.connection
|
81
131
|
rescue Exception => e
|
82
132
|
$stderr.puts e, *(e.backtrace)
|
83
133
|
$stderr.puts "Couldn't create database for #{config.inspect}"
|
84
134
|
end
|
85
135
|
end
|
86
|
-
return # Skip the else clause of begin/rescue
|
87
136
|
else
|
88
|
-
|
89
|
-
ActiveRecord::Base.connection
|
137
|
+
$stderr.puts "#{config['database']} already exists"
|
90
138
|
end
|
91
|
-
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.drop_database(config)
|
92
142
|
case config['adapter']
|
93
143
|
when /^(jdbc)?mysql/
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
begin
|
103
|
-
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
|
104
|
-
ActiveRecord::Base.connection.create_database(config['database'], mysql_creation_options(config))
|
105
|
-
ActiveRecord::Base.establish_connection(config)
|
106
|
-
rescue error_class => sqlerr
|
107
|
-
if sqlerr.errno == access_denied_error
|
108
|
-
print "#{sqlerr.error}. \nPlease provide the root password for your mysql installation\n>"
|
109
|
-
root_password = $stdin.gets.strip
|
110
|
-
grant_statement = "GRANT ALL PRIVILEGES ON #{config['database']}.* " \
|
111
|
-
"TO '#{config['username']}'@'localhost' " \
|
112
|
-
"IDENTIFIED BY '#{config['password']}' WITH GRANT OPTION;"
|
113
|
-
ActiveRecord::Base.establish_connection(config.merge(
|
114
|
-
'database' => nil, 'username' => 'root', 'password' => root_password))
|
115
|
-
ActiveRecord::Base.connection.create_database(config['database'], mysql_creation_options(config))
|
116
|
-
ActiveRecord::Base.connection.execute grant_statement
|
117
|
-
ActiveRecord::Base.establish_connection(config)
|
118
|
-
else
|
119
|
-
$stderr.puts sqlerr.error
|
120
|
-
$stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation}"
|
121
|
-
$stderr.puts "(if you set the charset manually, make sure you have a matching collation)" if config['charset']
|
122
|
-
end
|
123
|
-
end
|
144
|
+
ActiveRecord::Base.establish_connection(config)
|
145
|
+
ActiveRecord::Base.connection.drop_database config['database']
|
146
|
+
when /^(jdbc)?sqlite/
|
147
|
+
require 'pathname'
|
148
|
+
path = Pathname.new(config['database'])
|
149
|
+
file = path.absolute? ? path.to_s : File.join(Rails.root, path)
|
150
|
+
|
151
|
+
FileUtils.rm_f(file) if File.exist?(file)
|
124
152
|
when /^(jdbc)?postgresql$/
|
125
|
-
|
126
|
-
|
127
|
-
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
128
|
-
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
|
129
|
-
ActiveRecord::Base.establish_connection(config)
|
130
|
-
rescue Exception => e
|
131
|
-
$stderr.puts e, *(e.backtrace)
|
132
|
-
$stderr.puts "Couldn't create database for #{config.inspect}"
|
133
|
-
end
|
153
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
154
|
+
ActiveRecord::Base.connection.drop_database config['database']
|
134
155
|
end
|
135
|
-
else
|
136
|
-
$stderr.puts "#{config['database']} already exists"
|
137
156
|
end
|
138
|
-
end
|
139
157
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
ActiveRecord::Base.establish_connection(config)
|
144
|
-
ActiveRecord::Base.connection.drop_database config['database']
|
145
|
-
when /^(jdbc)?sqlite/
|
146
|
-
require 'pathname'
|
147
|
-
path = Pathname.new(config['database'])
|
148
|
-
file = path.absolute? ? path.to_s : File.join(Rails.root, path)
|
158
|
+
def self.mysql_creation_options(config)
|
159
|
+
@charset = ENV['CHARSET'] || 'utf8'
|
160
|
+
@collation = ENV['COLLATION'] || 'utf8_unicode_ci'
|
149
161
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
162
|
+
{
|
163
|
+
:charset => (config['charset'] || @charset),
|
164
|
+
:collation => (config['collation'] || @collation)
|
165
|
+
}
|
154
166
|
end
|
155
167
|
end
|
156
|
-
|
157
|
-
def self.mysql_creation_options(config)
|
158
|
-
@charset = ENV['CHARSET'] || 'utf8'
|
159
|
-
@collation = ENV['COLLATION'] || 'utf8_unicode_ci'
|
160
|
-
|
161
|
-
{
|
162
|
-
:charset => (config['charset'] || @charset),
|
163
|
-
:collation => (config['collation'] || @collation)
|
164
|
-
}
|
165
|
-
end
|
166
168
|
end
|
data/lib/combustion/generator.rb
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
require 'thor/group'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Combustion
|
4
|
+
class Generator < Thor::Group
|
5
|
+
include Thor::Actions
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def self.source_root
|
8
|
+
File.expand_path File.join(File.dirname(__FILE__), '..', '..')
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def create_directories
|
12
|
+
empty_directory 'spec/internal'
|
13
|
+
empty_directory 'spec/internal/config'
|
14
|
+
empty_directory 'spec/internal/db'
|
15
|
+
empty_directory 'spec/internal/log'
|
16
|
+
empty_directory 'spec/internal/public'
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
def create_files
|
20
|
+
template 'templates/routes.rb', 'spec/internal/config/routes.rb'
|
21
|
+
template 'templates/database.yml', 'spec/internal/config/database.yml'
|
22
|
+
template 'templates/schema.rb', 'spec/internal/db/schema.rb'
|
23
|
+
template 'templates/config.ru', 'config.ru'
|
24
|
+
create_file 'spec/internal/public/favicon.ico'
|
25
|
+
create_file 'spec/internal/log/.gitignore' do
|
26
|
+
'*.log'
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: combustion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,26 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: railties
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|