da-suspenders 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -4
- data/CHANGELOG.md +39 -30
- data/LICENSE +21 -21
- data/README.md +64 -66
- data/Rakefile +41 -40
- data/bin/da-suspenders +1 -1
- data/da-suspenders.gemspec +26 -26
- data/features/running_cucumber.feature +17 -17
- data/features/step_definitions/shell.rb +30 -30
- data/features/support/env.rb +0 -1
- data/lib/create.rb +57 -55
- data/lib/da-suspenders/version.rb +2 -2
- data/lib/errors.rb +12 -12
- data/template/da-suspenders.rb +159 -172
- data/template/files/factory_girl_steps.rb +1 -1
- data/template/files/mysql_database.yml.erb +39 -39
- data/template/trout/Gemfile +66 -43
- data/template/trout/app/assets/javascripts/application.js.coffee +10 -0
- data/template/trout/app/assets/stylesheets/application.css.scss +16 -0
- data/template/trout/app/assets/stylesheets/ie6.css.scss +4 -0
- data/template/trout/app/assets/stylesheets/ie7.css.scss +4 -0
- data/template/trout/app/helpers/body_class_helper.rb +6 -6
- data/template/trout/app/views/layouts/application.html.erb +16 -15
- data/template/trout/app/views/shared/_flashes.html.erb +5 -5
- data/template/trout/config/initializers/errors.rb +26 -26
- data/template/trout/config/initializers/will_paginate.rb +3 -3
- data/template/trout/config/locales/de.yml +54 -11
- data/template/trout/features/step_definitions/js_steps.rb +3 -3
- data/template/trout/vendor/assets/javascripts/jquery-ui-1.8.16.js +791 -0
- data/template/trout/vendor/{sprockets/modernizr/src → assets/javascripts}/modernizr.js +29 -29
- metadata +12 -14
- data/template/trout/app/javascripts/application.js +0 -10
- data/template/trout/app/stylesheets/application.scss +0 -14
- data/template/trout/app/stylesheets/ie.scss +0 -2
- data/template/trout/lib/templates/erb/scaffold/_form.html.erb +0 -13
- data/template/trout/vendor/sprockets/jquery-ujs/src/rails.js +0 -169
data/features/support/env.rb
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
require 'spec/expectations'
|
data/lib/create.rb
CHANGED
@@ -1,55 +1,57 @@
|
|
1
|
-
# Methods needed to create a project.
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require File.expand_path(File.dirname(__FILE__) + "/errors")
|
5
|
-
|
6
|
-
module DaSuspenders
|
7
|
-
class Create
|
8
|
-
attr_accessor :project_path
|
9
|
-
|
10
|
-
def self.run!(project_path)
|
11
|
-
creator = self.new(project_path)
|
12
|
-
creator.create_project!
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(project_path)
|
16
|
-
self.project_path = project_path
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
--
|
26
|
-
--
|
27
|
-
--skip-
|
28
|
-
COMMAND
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
1
|
+
# Methods needed to create a project.
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + "/errors")
|
5
|
+
|
6
|
+
module DaSuspenders
|
7
|
+
class Create
|
8
|
+
attr_accessor :project_path, :repo
|
9
|
+
|
10
|
+
def self.run!(project_path, repo)
|
11
|
+
creator = self.new(project_path, repo)
|
12
|
+
creator.create_project!
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(project_path, repo)
|
16
|
+
self.project_path = project_path
|
17
|
+
self.repo = repo
|
18
|
+
validate_project_path
|
19
|
+
validate_project_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_project!
|
23
|
+
command = <<-COMMAND
|
24
|
+
rails new #{project_path} \
|
25
|
+
--template="#{template}" \
|
26
|
+
--database=mysql \
|
27
|
+
--skip-test-unit
|
28
|
+
COMMAND
|
29
|
+
ENV["REPO"] = repo if repo
|
30
|
+
exec(command)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def validate_project_name
|
36
|
+
project_name = File.basename(project_path)
|
37
|
+
unless project_name =~ /^[a-z0-9_]+$/
|
38
|
+
raise InvalidInput.new("Project name must only contain [a-z0-9_]")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def validate_project_path
|
43
|
+
base_directory = Dir.pwd
|
44
|
+
full_path = File.join(base_directory, project_path)
|
45
|
+
|
46
|
+
# This is for the common case for the user's convenience; the race
|
47
|
+
# condition can still occur.
|
48
|
+
if File.exists?(full_path)
|
49
|
+
raise InvalidInput.new("Project directory (#{project_path}) already exists")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def template
|
54
|
+
File.expand_path(File.dirname(__FILE__) + "/../template/da-suspenders.rb")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module DaSuspenders
|
2
|
-
VERSION = "1.0
|
1
|
+
module DaSuspenders
|
2
|
+
VERSION = "1.1.0"
|
3
3
|
end
|
data/lib/errors.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# User errors
|
2
|
-
|
3
|
-
module DaSuspenders
|
4
|
-
class InvalidInput < Exception; end
|
5
|
-
|
6
|
-
module Errors
|
7
|
-
def error_with_message(msg)
|
8
|
-
STDERR.puts msg
|
9
|
-
exit 1
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# User errors
|
2
|
+
|
3
|
+
module DaSuspenders
|
4
|
+
class InvalidInput < Exception; end
|
5
|
+
|
6
|
+
module Errors
|
7
|
+
def error_with_message(msg)
|
8
|
+
STDERR.puts msg
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/template/da-suspenders.rb
CHANGED
@@ -1,173 +1,160 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
require "pathname"
|
3
|
-
require "trout"
|
4
|
-
|
5
|
-
template_root = File.expand_path(File.join(File.dirname(__FILE__)))
|
6
|
-
source_paths << File.join(template_root, "files")
|
7
|
-
|
8
|
-
# Helpers
|
9
|
-
|
10
|
-
def action_mailer_host(rails_env, host)
|
11
|
-
inject_into_file(
|
12
|
-
"config/environments/#{rails_env}.rb",
|
13
|
-
"\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
|
14
|
-
:before => "\nend"
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
def origin
|
19
|
-
"git://github.com/die-antwort/da-suspenders.git"
|
20
|
-
end
|
21
|
-
|
22
|
-
def trout(destination_path)
|
23
|
-
parent = Pathname.new(destination_path).parent
|
24
|
-
FileUtils.mkdir_p(parent) unless File.exists?(parent)
|
25
|
-
run "trout checkout --source-root=template/trout #{destination_path} #{origin}"
|
26
|
-
end
|
27
|
-
|
28
|
-
# Actions
|
29
|
-
|
30
|
-
def create_gemfile_and_install_gems
|
31
|
-
say "Creating Gemfile and installing gems (this may take a while)", :yellow
|
32
|
-
trout "Gemfile"
|
33
|
-
run "bundle install"
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_staging_environment
|
37
|
-
say "Adding staging environment", :yellow
|
38
|
-
run "cp config/environments/production.rb config/environments/staging.rb"
|
39
|
-
end
|
40
|
-
|
41
|
-
def setup_action_mailer
|
42
|
-
say "Setting up action mailer config", :yellow
|
43
|
-
action_mailer_host "development", "localhost:3000"
|
44
|
-
action_mailer_host "test", "example.com"
|
45
|
-
action_mailer_host "staging", "#{app_name}.dev.die-antwort.eu"
|
46
|
-
action_mailer_host "production", "FIXME"
|
47
|
-
end
|
48
|
-
|
49
|
-
def setup_database
|
50
|
-
say "Setting up database config", :yellow
|
51
|
-
template "mysql_database.yml.erb", "config/database.yml", :force => true
|
52
|
-
rake "db:create"
|
53
|
-
end
|
54
|
-
|
55
|
-
def setup_german_locale
|
56
|
-
say "Setting up german locale", :yellow
|
57
|
-
trout "config/locales/de.yml"
|
58
|
-
gsub_file 'config/application.rb', '# config.i18n.default_locale = :de', 'config.i18n.default_locale = :de'
|
59
|
-
end
|
60
|
-
|
61
|
-
def setup_viennese_timezone
|
62
|
-
say "Setting up viennese timezone", :yellow
|
63
|
-
gsub_file 'config/application.rb', "# config.time_zone = 'Central Time (US & Canada)'", "config.time_zone = 'Vienna'"
|
64
|
-
end
|
65
|
-
|
66
|
-
def disable_timestamped_migrations
|
67
|
-
say "Disabling timestamped migrations", :yellow
|
68
|
-
inject_into_class "config/application.rb", "Application", "\n config.active_record.timestamped_migrations = false\n\n"
|
69
|
-
end
|
70
|
-
|
71
|
-
def update_generators_config
|
72
|
-
say "Updating config for generators", :yellow
|
73
|
-
generators_config = <<-RUBY
|
74
|
-
config.generators do |generate|
|
75
|
-
generate.stylesheets false
|
76
|
-
generate.test_framework :rspec
|
77
|
-
end
|
78
|
-
RUBY
|
79
|
-
inject_into_class "config/application.rb", "Application", generators_config
|
80
|
-
end
|
81
|
-
|
82
|
-
def create_application_layout_and_views
|
83
|
-
say "Creating application layout and shared views", :yellow
|
84
|
-
trout "app/views/layouts/application.html.erb"
|
85
|
-
trout "app/views/shared/_flashes.html.erb"
|
86
|
-
end
|
87
|
-
|
88
|
-
def install_misc_support_files
|
89
|
-
say "Installing miscellaneous support files", :yellow
|
90
|
-
trout "config/initializers/errors.rb"
|
91
|
-
trout "app/helpers/body_class_helper.rb"
|
92
|
-
end
|
93
|
-
|
94
|
-
def install_app_config
|
95
|
-
say "Installing app_config", :yellow
|
96
|
-
generate "app_config:install staging"
|
97
|
-
end
|
98
|
-
|
99
|
-
def install_compass
|
100
|
-
say "Installing compass", :yellow
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
setup_viennese_timezone
|
161
|
-
disable_timestamped_migrations
|
162
|
-
update_generators_config
|
163
|
-
create_application_layout_and_views
|
164
|
-
install_misc_support_files
|
165
|
-
install_app_config
|
166
|
-
install_compass
|
167
|
-
install_formtastic
|
168
|
-
install_sprockets_and_jquery
|
169
|
-
install_rspec_and_cucumber
|
170
|
-
cleanup
|
171
|
-
|
172
|
-
say "Rails app #{app_name} has been created successully!", :blue
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
require "trout"
|
4
|
+
|
5
|
+
template_root = File.expand_path(File.join(File.dirname(__FILE__)))
|
6
|
+
source_paths << File.join(template_root, "files")
|
7
|
+
|
8
|
+
# Helpers
|
9
|
+
|
10
|
+
def action_mailer_host(rails_env, host)
|
11
|
+
inject_into_file(
|
12
|
+
"config/environments/#{rails_env}.rb",
|
13
|
+
"\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
|
14
|
+
:before => "\nend"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def origin
|
19
|
+
ENV["REPO"].presence || "git://github.com/die-antwort/da-suspenders.git"
|
20
|
+
end
|
21
|
+
|
22
|
+
def trout(destination_path)
|
23
|
+
parent = Pathname.new(destination_path).parent
|
24
|
+
FileUtils.mkdir_p(parent) unless File.exists?(parent)
|
25
|
+
run "trout checkout --source-root=template/trout #{destination_path} #{origin}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Actions
|
29
|
+
|
30
|
+
def create_gemfile_and_install_gems
|
31
|
+
say "Creating Gemfile and installing gems (this may take a while)", :yellow
|
32
|
+
trout "Gemfile"
|
33
|
+
run "bundle install"
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_staging_environment
|
37
|
+
say "Adding staging environment", :yellow
|
38
|
+
run "cp config/environments/production.rb config/environments/staging.rb"
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_action_mailer
|
42
|
+
say "Setting up action mailer config", :yellow
|
43
|
+
action_mailer_host "development", "localhost:3000"
|
44
|
+
action_mailer_host "test", "example.com"
|
45
|
+
action_mailer_host "staging", "#{app_name}.dev.die-antwort.eu"
|
46
|
+
action_mailer_host "production", "FIXME"
|
47
|
+
end
|
48
|
+
|
49
|
+
def setup_database
|
50
|
+
say "Setting up database config", :yellow
|
51
|
+
template "mysql_database.yml.erb", "config/database.yml", :force => true
|
52
|
+
rake "db:create"
|
53
|
+
end
|
54
|
+
|
55
|
+
def setup_german_locale
|
56
|
+
say "Setting up german locale", :yellow
|
57
|
+
trout "config/locales/de.yml"
|
58
|
+
gsub_file 'config/application.rb', '# config.i18n.default_locale = :de', 'config.i18n.default_locale = :de'
|
59
|
+
end
|
60
|
+
|
61
|
+
def setup_viennese_timezone
|
62
|
+
say "Setting up viennese timezone", :yellow
|
63
|
+
gsub_file 'config/application.rb', "# config.time_zone = 'Central Time (US & Canada)'", "config.time_zone = 'Vienna'"
|
64
|
+
end
|
65
|
+
|
66
|
+
def disable_timestamped_migrations
|
67
|
+
say "Disabling timestamped migrations", :yellow
|
68
|
+
inject_into_class "config/application.rb", "Application", "\n config.active_record.timestamped_migrations = false\n\n"
|
69
|
+
end
|
70
|
+
|
71
|
+
def update_generators_config
|
72
|
+
say "Updating config for generators", :yellow
|
73
|
+
generators_config = <<-RUBY
|
74
|
+
config.generators do |generate|
|
75
|
+
generate.stylesheets false
|
76
|
+
generate.test_framework :rspec
|
77
|
+
end
|
78
|
+
RUBY
|
79
|
+
inject_into_class "config/application.rb", "Application", generators_config
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_application_layout_and_views
|
83
|
+
say "Creating application layout and shared views", :yellow
|
84
|
+
trout "app/views/layouts/application.html.erb"
|
85
|
+
trout "app/views/shared/_flashes.html.erb"
|
86
|
+
end
|
87
|
+
|
88
|
+
def install_misc_support_files
|
89
|
+
say "Installing miscellaneous support files", :yellow
|
90
|
+
trout "config/initializers/errors.rb"
|
91
|
+
trout "app/helpers/body_class_helper.rb"
|
92
|
+
end
|
93
|
+
|
94
|
+
def install_app_config
|
95
|
+
say "Installing app_config", :yellow
|
96
|
+
generate "app_config:install staging"
|
97
|
+
end
|
98
|
+
|
99
|
+
def install_compass
|
100
|
+
say "Installing compass", :yellow
|
101
|
+
remove_file "app/assets/stylesheets/application.css"
|
102
|
+
trout "app/assets/stylesheets/application.css.scss"
|
103
|
+
trout "app/assets/stylesheets/ie6.css.scss"
|
104
|
+
trout "app/assets/stylesheets/ie7.css.scss"
|
105
|
+
end
|
106
|
+
|
107
|
+
def install_formtastic
|
108
|
+
say "Installing formtastic", :yellow
|
109
|
+
generate "formtastic:install"
|
110
|
+
end
|
111
|
+
|
112
|
+
def install_javascripts
|
113
|
+
say "Installing application.js.coffee, modernizr and jquery-ui", :yellow
|
114
|
+
remove_file "app/assets/javascripts/application.js"
|
115
|
+
trout "app/assets/javascripts/application.js.coffee"
|
116
|
+
trout "vendor/assets/javascripts/modernizr.js"
|
117
|
+
trout "vendor/assets/javascripts/jquery-ui-1.8.16.js"
|
118
|
+
end
|
119
|
+
|
120
|
+
def install_rspec_and_cucumber
|
121
|
+
say "Installing rspec and cucumber", :yellow
|
122
|
+
generate "rspec:install"
|
123
|
+
generate "cucumber:install", "--rspec --capybara"
|
124
|
+
inject_into_file "features/support/env.rb",
|
125
|
+
%{Capybara.save_and_open_page_path = "tmp"\n} +
|
126
|
+
%{Capybara.javascript_driver = :akephalos\n},
|
127
|
+
:before => %{Capybara.default_selector = :css}
|
128
|
+
inject_into_file "features/support/paths.rb",
|
129
|
+
%{ when %r{"(/.*)?"}\n} +
|
130
|
+
%{ $1\n\n},
|
131
|
+
:before => " else"
|
132
|
+
copy_file "factory_girl_steps.rb", "features/step_definitions/factory_girl_steps.rb"
|
133
|
+
trout "features/step_definitions/js_steps.rb"
|
134
|
+
end
|
135
|
+
|
136
|
+
def cleanup
|
137
|
+
say "Cleaning up", :yellow
|
138
|
+
remove_file 'README'
|
139
|
+
remove_file 'public/index.html'
|
140
|
+
remove_file 'public/images/rails.png'
|
141
|
+
end
|
142
|
+
|
143
|
+
create_gemfile_and_install_gems
|
144
|
+
add_staging_environment
|
145
|
+
setup_database
|
146
|
+
setup_german_locale
|
147
|
+
setup_viennese_timezone
|
148
|
+
disable_timestamped_migrations
|
149
|
+
update_generators_config
|
150
|
+
create_application_layout_and_views
|
151
|
+
install_misc_support_files
|
152
|
+
install_app_config
|
153
|
+
install_compass
|
154
|
+
install_formtastic
|
155
|
+
install_javascripts
|
156
|
+
install_rspec_and_cucumber
|
157
|
+
cleanup
|
158
|
+
|
159
|
+
say "Rails app #{app_name} has been created successully!", :blue
|
173
160
|
say "Remember to run 'rails generate hoptoad' with your API key.", :blue
|