da-suspenders 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
- module DaSuspenders
2
- VERSION = "1.0.0"
1
+ module DaSuspenders
2
+ VERSION = "1.0.1"
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
@@ -1,166 +1,173 @@
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 update_generators_config
67
- say "Updating config for generators", :yellow
68
- generators_config = <<-RUBY
69
- config.generators do |generate|
70
- generate.stylesheets false
71
- generate.test_framework :rspec
72
- end
73
- RUBY
74
- inject_into_class "config/application.rb", "Application", generators_config
75
- end
76
-
77
- def create_application_layout_and_views
78
- say "Creating application layout and shared views", :yellow
79
- trout "app/views/layouts/application.html.erb"
80
- trout "app/views/shared/_flashes.html.erb"
81
- end
82
-
83
- def install_misc_support_files
84
- say "Installing miscellaneous support files", :yellow
85
- trout "config/initializers/errors.rb"
86
- trout "app/helpers/body_class_helper.rb"
87
- end
88
-
89
- def install_app_config
90
- say "Installing app_config", :yellow
91
- generate "app_config:install staging"
92
- end
93
-
94
- def install_compass
95
- say "Installing compass", :yellow
96
- run "compass init rails . --sass-dir app/stylesheets --css-dir public/stylesheets -q"
97
- inside 'app/stylesheets' do
98
- remove_file 'ie.scss'
99
- remove_file 'print.scss'
100
- remove_file 'screen.scss'
101
- empty_directory 'content'
102
- empty_directory 'vendor'
103
- end
104
- trout "app/stylesheets/application.scss"
105
- trout "app/stylesheets/ie.scss"
106
- end
107
-
108
- def install_formtastic
109
- say "Installing formtastic", :yellow
110
- generate "formtastic:install"
111
- remove_file "public/stylesheets/formtastic.css"
112
- remove_file "public/stylesheets/formtastic-changes.css"
113
- trout "lib/templates/erb/scaffold/_form.html.erb"
114
- end
115
-
116
- def install_sprockets_and_jquery
117
- say "Installing sprockets, jQuery, and some other javascripts", :yellow
118
- plugin 'sprockets-rails', :git => 'git://github.com/gmoeck/sprockets-rails.git'
119
- plugin 'jrails', :git => 'git://github.com/die-antwort/jrails.git'
120
- route 'SprocketsApplication.routes(self)'
121
- remove_dir 'public/javascripts'
122
- remove_file "app/javascripts/application.js"
123
- trout "app/javascripts/application.js"
124
- trout "vendor/sprockets/modernizr/src/modernizr.js"
125
- trout "vendor/sprockets/jquery-ujs/src/rails.js"
126
- end
127
-
128
- def install_rspec_and_cucumber
129
- say "Installing rspec and cucumber", :yellow
130
- generate "rspec:install"
131
- generate "cucumber:install", "--rspec --capybara"
132
- inject_into_file "features/support/env.rb",
133
- %{Capybara.save_and_open_page_path = "tmp"\n} +
134
- %{Capybara.javascript_driver = :akephalos\n},
135
- :before => %{Capybara.default_selector = :css}
136
- # replace_in_file "features/support/env.rb",
137
- # %r{require .*capybara_javascript_emulation.*},
138
- # ''
139
- copy_file "factory_girl_steps.rb", "features/step_definitions/factory_girl_steps.rb"
140
- trout "features/step_definitions/js_steps.rb"
141
- end
142
-
143
- def cleanup
144
- say "Cleaning up", :yellow
145
- remove_file 'README'
146
- remove_file 'public/index.html'
147
- remove_file 'public/images/rails.png'
148
- end
149
-
150
- create_gemfile_and_install_gems
151
- add_staging_environment
152
- setup_database
153
- setup_german_locale
154
- setup_viennese_timezone
155
- update_generators_config
156
- create_application_layout_and_views
157
- install_misc_support_files
158
- install_app_config
159
- install_compass
160
- install_formtastic
161
- install_sprockets_and_jquery
162
- install_rspec_and_cucumber
163
- cleanup
164
-
165
- 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
+ "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
+ run "compass init rails . --sass-dir app/stylesheets --css-dir public/stylesheets -q"
102
+ inside 'app/stylesheets' do
103
+ remove_file 'ie.scss'
104
+ remove_file 'print.scss'
105
+ remove_file 'screen.scss'
106
+ empty_directory 'content'
107
+ empty_directory 'vendor'
108
+ end
109
+ trout "app/stylesheets/application.scss"
110
+ trout "app/stylesheets/ie.scss"
111
+ end
112
+
113
+ def install_formtastic
114
+ say "Installing formtastic", :yellow
115
+ generate "formtastic:install"
116
+ remove_file "public/stylesheets/formtastic.css"
117
+ remove_file "public/stylesheets/formtastic-changes.css"
118
+ trout "lib/templates/erb/scaffold/_form.html.erb"
119
+ end
120
+
121
+ def install_sprockets_and_jquery
122
+ say "Installing sprockets, jQuery, and some other javascripts", :yellow
123
+ plugin 'sprockets-rails', :git => 'git://github.com/gmoeck/sprockets-rails.git'
124
+ plugin 'jrails', :git => 'git://github.com/die-antwort/jrails.git'
125
+ route 'SprocketsApplication.routes(self)'
126
+ remove_dir 'public/javascripts'
127
+ remove_file "app/javascripts/application.js"
128
+ trout "app/javascripts/application.js"
129
+ trout "vendor/sprockets/modernizr/src/modernizr.js"
130
+ trout "vendor/sprockets/jquery-ujs/src/rails.js"
131
+ end
132
+
133
+ def install_rspec_and_cucumber
134
+ say "Installing rspec and cucumber", :yellow
135
+ generate "rspec:install"
136
+ generate "cucumber:install", "--rspec --capybara"
137
+ inject_into_file "features/support/env.rb",
138
+ %{Capybara.save_and_open_page_path = "tmp"\n} +
139
+ %{Capybara.javascript_driver = :akephalos\n},
140
+ :before => %{Capybara.default_selector = :css}
141
+ inject_into_file "features/support/paths.rb",
142
+ %{ when %r{"(/.*)?"}\n} +
143
+ %{ $1\n\n},
144
+ :before => " else"
145
+ copy_file "factory_girl_steps.rb", "features/step_definitions/factory_girl_steps.rb"
146
+ trout "features/step_definitions/js_steps.rb"
147
+ end
148
+
149
+ def cleanup
150
+ say "Cleaning up", :yellow
151
+ remove_file 'README'
152
+ remove_file 'public/index.html'
153
+ remove_file 'public/images/rails.png'
154
+ end
155
+
156
+ create_gemfile_and_install_gems
157
+ add_staging_environment
158
+ setup_database
159
+ setup_german_locale
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
166
173
  say "Remember to run 'rails generate hoptoad' with your API key.", :blue
@@ -1 +1 @@
1
- require 'factory_girl/step_definitions'
1
+ require 'factory_girl/step_definitions'
@@ -1,39 +1,39 @@
1
- development:
2
- adapter: mysql
3
- encoding: utf8
4
- reconnect: false
5
- database: <%= app_name %>_dev
6
- pool: 5
7
- username: root
8
- password: root
9
- host: localhost
10
-
11
- test:
12
- adapter: mysql
13
- encoding: utf8
14
- reconnect: false
15
- database: <%= app_name %>_test
16
- pool: 5
17
- username: root
18
- password: root
19
- host: localhost
20
-
21
- staging:
22
- adapter: mysql
23
- encoding: utf8
24
- reconnect: false
25
- database: <%= app_name %>_staging
26
- pool: 5
27
- username: <%= app_name %>_s
28
- password:
29
- host: localhost
30
-
31
- production:
32
- adapter: mysql
33
- encoding: utf8
34
- reconnect: false
35
- database: <%= app_name %>
36
- pool: 5
37
- username: <%= app_name %>
38
- password:
39
- host: localhost
1
+ development:
2
+ adapter: mysql
3
+ encoding: utf8
4
+ reconnect: false
5
+ database: <%= app_name %>_dev
6
+ pool: 5
7
+ username: root
8
+ password: root
9
+ host: localhost
10
+
11
+ test:
12
+ adapter: mysql
13
+ encoding: utf8
14
+ reconnect: false
15
+ database: <%= app_name %>_test
16
+ pool: 5
17
+ username: root
18
+ password: root
19
+ host: localhost
20
+
21
+ staging:
22
+ adapter: mysql
23
+ encoding: utf8
24
+ reconnect: false
25
+ database: <%= app_name %>_staging
26
+ pool: 5
27
+ username: <%= app_name %>_s
28
+ password:
29
+ host: localhost
30
+
31
+ production:
32
+ adapter: mysql
33
+ encoding: utf8
34
+ reconnect: false
35
+ database: <%= app_name %>
36
+ pool: 5
37
+ username: <%= app_name %>
38
+ password:
39
+ host: localhost