sparkler 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/sparkler/app_builder.rb
CHANGED
@@ -30,7 +30,7 @@ module Sparkler
|
|
30
30
|
def add_custom_gems
|
31
31
|
additions_path = find_in_source_paths 'Gemfile_additions'
|
32
32
|
new_gems = File.open(additions_path).read
|
33
|
-
inject_into_file 'Gemfile', "\n#{new_gems}", after: /gem '
|
33
|
+
inject_into_file 'Gemfile', "\n#{new_gems}", after: /gem 'rails'.*$/
|
34
34
|
|
35
35
|
asset_gems = <<-END.gsub(/^ {6}/, '')
|
36
36
|
gem 'compass-rails', '~> 1.0.3'
|
@@ -40,8 +40,12 @@ module Sparkler
|
|
40
40
|
inject_into_file 'Gemfile', "\n#{asset_gems}", after: /gem 'uglifier'.*$/
|
41
41
|
end
|
42
42
|
|
43
|
+
def use_sqlite_config_template
|
44
|
+
template 'database.sqlite.yml.erb', 'config/database.yml', force: true
|
45
|
+
end
|
46
|
+
|
43
47
|
def use_postgres_config_template
|
44
|
-
template 'database.yml.erb', 'config/database.yml', force: true
|
48
|
+
template 'database.postgres.yml.erb', 'config/database.yml', force: true
|
45
49
|
end
|
46
50
|
|
47
51
|
def setup_local_postgres
|
@@ -52,12 +56,16 @@ module Sparkler
|
|
52
56
|
append_file '.git/info/exclude', '/pg/'
|
53
57
|
end
|
54
58
|
|
55
|
-
def
|
59
|
+
def create_postgres_database
|
56
60
|
pid = fork { exec 'postgres', '-D', 'pg' }
|
57
61
|
bundle_command 'exec rake db:create'
|
58
62
|
Process.kill "INT", pid
|
59
63
|
end
|
60
64
|
|
65
|
+
def create_sqlite_database
|
66
|
+
bundle_command 'exec rake db:create'
|
67
|
+
end
|
68
|
+
|
61
69
|
def setup_gitignore
|
62
70
|
gitignore_file = find_in_source_paths('gitignore_additions')
|
63
71
|
gitignore = File.open(gitignore_file).read
|
@@ -101,17 +109,19 @@ module Sparkler
|
|
101
109
|
copy_file 'cucumber_javascript.rb', 'features/support/javascript.rb'
|
102
110
|
end
|
103
111
|
|
104
|
-
def
|
105
|
-
generators_config = <<-RUBY.gsub(/^ {
|
112
|
+
def configure_generators
|
113
|
+
generators_config = <<-RUBY.gsub(/^ {2}/, '')
|
106
114
|
config.generators do |generate|
|
107
|
-
generate.
|
108
|
-
generate.
|
109
|
-
generate.
|
110
|
-
|
111
|
-
generate.view_specs false
|
112
|
-
end
|
115
|
+
generate.helper false
|
116
|
+
generate.assets false
|
117
|
+
generate.view_specs false
|
118
|
+
end\n
|
113
119
|
RUBY
|
114
120
|
inject_into_class 'config/application.rb', 'Application', generators_config
|
121
|
+
end
|
122
|
+
|
123
|
+
def configure_rspec
|
124
|
+
inject_into_file 'config/application.rb', " generate.test_framework :rspec\n", after: "config.generators do |generate|\n"
|
115
125
|
generate 'rspec:install'
|
116
126
|
end
|
117
127
|
end
|
@@ -4,7 +4,7 @@ require 'rails/generators/rails/app/app_generator'
|
|
4
4
|
module Sparkler
|
5
5
|
class AppGenerator < Rails::Generators::AppGenerator
|
6
6
|
class_option :skip_test_unit, type: :boolean, aliases: '-T', default: true, desc: 'Skip Test::Unit files'
|
7
|
-
class_option :database, type: :string, aliases: '-d', default: '
|
7
|
+
class_option :database, type: :string, aliases: '-d', default: 'sqlite3', desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
8
8
|
class_option :local_database, type: :boolean, aliases: '--local-database', default: false, desc: "Create a pg folder in the application"
|
9
9
|
|
10
10
|
def finish_template
|
@@ -13,6 +13,7 @@ module Sparkler
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def sparkler_customization
|
16
|
+
invoke :configure_generators
|
16
17
|
invoke :customize_gemfile
|
17
18
|
invoke :setup_database
|
18
19
|
invoke :remove_useless_files
|
@@ -33,10 +34,13 @@ module Sparkler
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def setup_database
|
36
|
-
if
|
37
|
+
if options[:database] == 'postgresql'
|
37
38
|
build :use_postgres_config_template
|
38
39
|
build :setup_local_postgres if options[:local_database]
|
39
|
-
build :
|
40
|
+
build :create_postgres_database
|
41
|
+
elsif options[:database] == 'sqlite3'
|
42
|
+
build :use_sqlite_config_template
|
43
|
+
build :create_sqlite_database
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
@@ -68,6 +72,11 @@ module Sparkler
|
|
68
72
|
bundle_command 'package'
|
69
73
|
end
|
70
74
|
|
75
|
+
def configure_generators
|
76
|
+
say 'Configuring generators'
|
77
|
+
build :configure_generators
|
78
|
+
end
|
79
|
+
|
71
80
|
def setup_git
|
72
81
|
say 'Initalizing git repo'
|
73
82
|
build :setup_gitignore
|
data/lib/sparkler/version.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sparkler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70209236171920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.2.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70209236171920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70209236171420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '1.1'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70209236171420
|
36
36
|
description: Spin up a Rails app using all the tools and frameworks we like at Gaslight.
|
37
37
|
Inspired heavily by thoughtbot's Suspenders.
|
38
38
|
email:
|
@@ -60,7 +60,8 @@ files:
|
|
60
60
|
- templates/application.css.sass
|
61
61
|
- templates/application_layout.html.haml
|
62
62
|
- templates/cucumber_javascript.rb
|
63
|
-
- templates/database.yml.erb
|
63
|
+
- templates/database.postgres.yml.erb
|
64
|
+
- templates/database.sqlite.yml.erb
|
64
65
|
- templates/env
|
65
66
|
- templates/gitignore_additions
|
66
67
|
- templates/home.html.haml
|