raygun 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/.gitignore +17 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +63 -0
  6. data/Rakefile +1 -0
  7. data/TODO.md +24 -0
  8. data/bin/raygun +11 -0
  9. data/lib/raygun/actions.rb +26 -0
  10. data/lib/raygun/app_builder.rb +283 -0
  11. data/lib/raygun/generators/app_generator.rb +182 -0
  12. data/lib/raygun/version.rb +3 -0
  13. data/marvin.jpg +0 -0
  14. data/raygun.gemspec +25 -0
  15. data/templates/Gemfile_customized +32 -0
  16. data/templates/README.md.erb +31 -0
  17. data/templates/_app/assets/stylesheets/_footer.less +30 -0
  18. data/templates/_app/assets/stylesheets/application.css.less +8 -0
  19. data/templates/_app/controllers/application_controller.rb +14 -0
  20. data/templates/_app/controllers/password_resets_controller.rb +38 -0
  21. data/templates/_app/controllers/registrations_controller.rb +27 -0
  22. data/templates/_app/controllers/user_sessions_controller.rb +25 -0
  23. data/templates/_app/helpers/application_helper.rb +11 -0
  24. data/templates/_app/mailers/user_mailer.rb +22 -0
  25. data/templates/_app/models/user.rb +17 -0
  26. data/templates/_app/models/user_session.rb +6 -0
  27. data/templates/_app/views/layouts/application.html.slim.erb +36 -0
  28. data/templates/_app/views/password_resets/edit.html.slim +16 -0
  29. data/templates/_app/views/password_resets/new.html.slim +11 -0
  30. data/templates/_app/views/registrations/new.html.slim +14 -0
  31. data/templates/_app/views/user_mailer/activation_needed_email.html.erb +17 -0
  32. data/templates/_app/views/user_mailer/activation_needed_email.text.erb +9 -0
  33. data/templates/_app/views/user_mailer/activation_success_email.html.erb +17 -0
  34. data/templates/_app/views/user_mailer/activation_success_email.text.erb +9 -0
  35. data/templates/_app/views/user_mailer/reset_password_email.html.erb +16 -0
  36. data/templates/_app/views/user_mailer/reset_password_email.text.erb +8 -0
  37. data/templates/_app/views/user_sessions/new.html.slim +13 -0
  38. data/templates/_config/database.yml.erb +13 -0
  39. data/templates/_db/sample_data.rb +17 -0
  40. data/templates/_lib/email_validator.rb +9 -0
  41. data/templates/_lib/tasks/db.rake +7 -0
  42. data/templates/_lib/templates/rspec/scaffold/controller_spec.rb +152 -0
  43. data/templates/_lib/templates/slim/scaffold/_form.html.slim +13 -0
  44. data/templates/_lib/templates/slim/scaffold/edit.html.slim +5 -0
  45. data/templates/_lib/templates/slim/scaffold/index.html.slim +27 -0
  46. data/templates/_lib/templates/slim/scaffold/new.html.slim +4 -0
  47. data/templates/_lib/templates/slim/scaffold/show.html.slim +15 -0
  48. data/templates/_public/index.html.erb +41 -0
  49. data/templates/_spec/factories/users.rb +7 -0
  50. data/templates/_spec/mailers/user_mailer_spec.rb +48 -0
  51. data/templates/_spec/models/user_spec.rb +29 -0
  52. data/templates/_spec/requests/user_sessions_spec.rb +29 -0
  53. data/templates/_spec/support/accept_values.rb +55 -0
  54. data/templates/_spec/support/factory_girl.rb +3 -0
  55. data/templates/_spec/support/sorcery.rb +3 -0
  56. data/templates/_spec/support/user_sessions_request_helper.rb +21 -0
  57. data/templates/rvmrc.erb +1 -0
  58. metadata +168 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3-p194@raygun --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in raygun.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Carbon Five
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ <img src="https://raw.github.com/carbonfive/raygun/master/marvin.jpg" align="right"/>
2
+
3
+ # Raygun
4
+
5
+ __NOTE: Currently a work in progress and not yet representative of best practices. Soon the veil will be lifted.__
6
+
7
+ Command line Rails application generator that builds a new project skeleton configured with all of the Carbon Five
8
+ best practices baked right in.
9
+
10
+ Inspired by and code shamelessly lifted from ThoughtBot's Suspenders. Thanks!
11
+
12
+ Major tools/libraries:
13
+
14
+ * Rails
15
+ * PostgreSQL
16
+ * Slim
17
+ * Less
18
+ * Bootstrap
19
+ * Sorcery
20
+ * Cancan
21
+ * RSpec
22
+ * Factory Girl
23
+ * Guard
24
+
25
+ And many tweaks, patterns and common recipes.
26
+
27
+ ## Projects Goals
28
+
29
+ Raygun...
30
+ * should generate a new rails application that's ready for feature development immediately.
31
+ * should generate an application that has best practices that apply to most projects baked in.
32
+ * is a forum for discussing what should or should not be included as part of a standard stack.
33
+
34
+ ## Installation
35
+
36
+ $ gem install raygun
37
+
38
+ ## Usage
39
+
40
+ $ raygun your-project
41
+
42
+ Once your project is baked out, you can easily kick the wheels:
43
+
44
+ $ cd your-project
45
+
46
+ # Prep the database
47
+ $ rake db:create db:migrate db:test:prepare
48
+
49
+ # Run the specs
50
+ $ rake spec
51
+
52
+ # Load some sample data, fire up the app and open it in a browser
53
+ $ rake db:seed db:sample_data
54
+ $ rails s
55
+ $ open http://0.0.0.0:3000
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/TODO.md ADDED
@@ -0,0 +1,24 @@
1
+ # TODOs
2
+
3
+ Looking for inspiration? Here are some ideas for things that still could be done.
4
+
5
+ * Cleanup/refactor raygun code (a few simple helpers would help out a whole lot)
6
+ * Automated testing of raygun (e.g. generate an app and run its specs?)
7
+ * Raygun on CI
8
+ * Add the concept of an admin / super user
9
+ * Invite user flow
10
+ * Use cancan to restrict access to /users to an admin
11
+ * Use cancan to allow users to edit only themselves and admins to edit any user
12
+ * Continue to improve bootstrap view templates
13
+ * CSS/less best practices for file organization
14
+ * JS/coffeescript best practices
15
+ * Add pagination to the default index scaffold (kaminari)
16
+ * JS testing
17
+ * Use foreigner for database constraints
18
+ * Fast tests best practices
19
+ * Use guard (rspec, livereload, js testing, etc)
20
+ * Paperclip + S3 configuration
21
+ * Application monitoring
22
+ * Analytics
23
+ * One step configuration for Heroku (production and acceptance)
24
+ * One step configuration on CI
data/bin/raygun ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', 'lib', 'raygun', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'raygun', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'raygun', 'app_builder'), File.dirname(__FILE__))
6
+
7
+ templates_root = File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__))
8
+ Raygun::AppGenerator.source_root templates_root
9
+ Raygun::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
10
+
11
+ Raygun::AppGenerator.start
@@ -0,0 +1,26 @@
1
+ module Raygun
2
+ module Actions
3
+ #def concat_file(source, destination)
4
+ # contents = IO.read(find_in_source_paths(source))
5
+ # append_file destination, contents
6
+ #end
7
+ #
8
+
9
+ def replace_in_file(relative_path, find, replace)
10
+ path = File.join(destination_root, relative_path)
11
+ contents = IO.read(path)
12
+ unless contents.gsub!(find, replace)
13
+ raise "#{find.inspect} not found in #{relative_path}"
14
+ end
15
+ File.open(path, "w") { |file| file.write(contents) }
16
+ end
17
+
18
+ def action_mailer_host(rails_env, host)
19
+ inject_into_file(
20
+ "config/environments/#{rails_env}.rb",
21
+ "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
22
+ :before => "\nend"
23
+ )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,283 @@
1
+ module Raygun
2
+ class AppBuilder < Rails::AppBuilder
3
+ include Raygun::Actions
4
+
5
+ def readme
6
+ template 'README.md.erb', 'README.md'
7
+ end
8
+
9
+ def replace_public_index
10
+ template '_public/index.html.erb', 'public/index.html', force: true
11
+ end
12
+
13
+ def remove_rails_logo_image
14
+ remove_file 'app/assets/images/rails.png'
15
+ end
16
+
17
+ def remove_application_layout
18
+ remove_file 'app/views/layouts/application.html.erb'
19
+ end
20
+
21
+ def enable_factory_girl_syntax
22
+ copy_file '_spec/support/factory_girl.rb', 'spec/support/factory_girl.rb'
23
+ end
24
+
25
+ def enable_threadsafe_mode
26
+ uncomment_lines 'config/environments/production.rb', 'config.threadsafe!'
27
+ end
28
+
29
+ def initialize_on_precompile
30
+ inject_into_file 'config/application.rb',
31
+ "\n config.assets.initialize_on_precompile = false",
32
+ after: 'config.assets.enabled = true'
33
+ end
34
+
35
+ def setup_acceptance_environment
36
+ run 'cp config/environments/production.rb config/environments/acceptance.rb'
37
+ end
38
+
39
+ def create_application_layout
40
+ template '_app/views/layouts/application.html.slim.erb',
41
+ 'app/views/layouts/application.html.slim',
42
+ force: true
43
+ end
44
+
45
+ def use_postgres_config_template
46
+ template '_config/database.yml.erb', 'config/database.yml', force: true
47
+ end
48
+
49
+ def create_database
50
+ bundle_command 'exec rake db:create'
51
+ end
52
+
53
+ def configure_rvm
54
+ template 'rvmrc.erb', '.rvmrc', rvm_ruby: rvm_ruby
55
+ end
56
+
57
+ def configure_gemfile
58
+ run 'gem install bundler'
59
+ copy_file 'Gemfile_customized', 'Gemfile', force: true
60
+ end
61
+
62
+ def setup_generators
63
+ %w(_form index show new edit).each do |view|
64
+ template = "lib/templates/slim/scaffold/#{view}.html.slim"
65
+ remove_file template
66
+ copy_file "_lib/templates/slim/scaffold/#{view}.html.slim", template
67
+ end
68
+ end
69
+
70
+ def configure_rspec
71
+ generators_config = <<-RUBY
72
+
73
+ config.generators do |generate|
74
+ generate.stylesheets false
75
+ #generate.helpers false
76
+ generate.route_specs false
77
+ #generate.view_specs false
78
+ end
79
+
80
+ RUBY
81
+ inject_into_class 'config/application.rb', 'Application', generators_config
82
+
83
+ copy_file '_lib/templates/rspec/scaffold/controller_spec.rb',
84
+ 'lib/templates/rspec/scaffold/controller_spec.rb'
85
+ end
86
+
87
+ def generate_rspec
88
+ generate 'rspec:install'
89
+ end
90
+
91
+ def add_rspec_support
92
+ shared_transaction = <<-RUBY
93
+
94
+ # Forces all threads to share the same connection. This works on
95
+ # Capybara because it starts the web server in a thread.
96
+ #
97
+ # http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
98
+
99
+ class ActiveRecord::Base
100
+ mattr_accessor :shared_connection
101
+ @@shared_connection = nil
102
+
103
+ def self.connection
104
+ @@shared_connection || retrieve_connection
105
+ end
106
+ end
107
+
108
+ ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
109
+
110
+ # Turn down the logging while testing.
111
+ Rails.logger.level = 4
112
+ RUBY
113
+
114
+ append_to_file 'spec/spec_helper.rb', shared_transaction
115
+
116
+ copy_file '_spec/support/accept_values.rb', 'spec/support/accept_values.rb'
117
+ end
118
+
119
+ def configure_time_zone
120
+ 'config/application.rb'.tap do |fn|
121
+ #inject_into_file fn, ' config.active_record.default_timezone = :utc\n', after: "'Central Time (US & Canada)'\n"
122
+ #uncomment_lines fn, 'config.time_zone'
123
+ gsub_file fn, 'Central Time (US & Canada)', 'Pacific Time (US & Canada)'
124
+ end
125
+ end
126
+
127
+ def configure_action_mailer
128
+ action_mailer_host 'development', "#{app_name}.local"
129
+ action_mailer_host 'test', "example.com"
130
+ action_mailer_host 'acceptance', "acceptance.#{app_name}.com"
131
+ action_mailer_host 'production', "#{app_name}.com"
132
+ end
133
+
134
+ def add_lib_to_load_path
135
+ 'config/application.rb'.tap do |fn|
136
+ gsub_file fn, '#{config.root}/extras', '#{config.root}/lib'
137
+ uncomment_lines fn, 'config.autoload_paths'
138
+ end
139
+ end
140
+
141
+ def add_email_validator
142
+ # CN: I'm not thrilled with this use of the lib directory, but it's not that unusual. Would love to hear what
143
+ # other folks think about where such things should live.
144
+ copy_file '_lib/email_validator.rb', 'lib/email_validator.rb'
145
+ end
146
+
147
+ def setup_simple_form
148
+ generate 'simple_form:install --bootstrap -s'
149
+
150
+ replace_in_file 'config/initializers/simple_form.rb',
151
+ %(# config.label_text = lambda { |label, required| "\#{required} \#{label}" }),
152
+ %(config.label_text = lambda { |label, required| "\#{label}" })
153
+ end
154
+
155
+ def setup_authentication
156
+ # User model
157
+ generate 'scaffold user email:string name:string'
158
+
159
+ remove_file 'app/models/user.rb'
160
+ remove_file 'spec/factories/users.rb'
161
+ remove_file 'spec/requests/users_spec.rb'
162
+ create_users_migration = 'db/migrate/' + Dir.new('./db/migrate').entries.select { |e| e =~ /create_users/ }.first
163
+ remove_file create_users_migration
164
+
165
+ generate 'sorcery:install brute_force_protection activity_logging user_activation remember_me reset_password external'
166
+
167
+ copy_file '_app/models/user.rb', 'app/models/user.rb', force: true
168
+ copy_file '_spec/support/sorcery.rb', 'spec/support/sorcery.rb'
169
+ copy_file '_spec/factories/users.rb', 'spec/factories/users.rb', force: true
170
+ copy_file '_spec/models/user_spec.rb', 'spec/models/user_spec.rb', force: true
171
+
172
+ inject_into_file 'app/controllers/users_controller.rb',
173
+ "\n before_filter :require_login\n\n",
174
+ after: "UsersController < ApplicationController\n"
175
+
176
+ # User mailer (has to happen before sorcery config changes)
177
+ generate 'mailer UserMailer activation_needed_email activation_success_email reset_password_email'
178
+ copy_file '_app/mailers/user_mailer.rb', 'app/mailers/user_mailer.rb', force: true
179
+ copy_file '_spec/mailers/user_mailer_spec.rb', 'spec/mailers/user_mailer_spec.rb', force: true
180
+
181
+ %w(activation_needed_email activation_success_email reset_password_email).each do |fn|
182
+ remove_file "app/views/user_mailer/#{fn}.text.slim"
183
+
184
+ %w(html.erb text.erb).each do |ext|
185
+ copy_file "_app/views/user_mailer/#{fn}.#{ext}", "app/views/user_mailer/#{fn}.#{ext}", force: true
186
+ end
187
+ end
188
+
189
+ remove_dir 'spec/fixtures/user_mailer'
190
+
191
+ # Patch sorcery configuration and migrations
192
+ sorcery_core_migration = 'db/migrate/' + Dir.new('./db/migrate').entries.select { |e| e =~ /sorcery_core/ }.first
193
+ inject_into_file sorcery_core_migration, " t.string :name\n", after: "create_table :users do |t|\n"
194
+ comment_lines sorcery_core_migration, /^.* t.string :username.*$\n/
195
+
196
+ 'config/initializers/sorcery.rb'.tap do |fn|
197
+ replace_in_file fn, 'config.user_class = "User"', 'config.user_class = User'
198
+ replace_in_file fn, '# user.username_attribute_names =', 'user.username_attribute_names = :email'
199
+ replace_in_file fn, '# user.user_activation_mailer =', 'user.user_activation_mailer = UserMailer'
200
+ replace_in_file fn, '# user.reset_password_mailer =', 'user.reset_password_mailer = UserMailer'
201
+ #replace_in_file sorcery_rb, /# user.unlock_token_mailer =.*$/, 'user.unlock_token_mailer = UserMailer'
202
+ end
203
+
204
+ # Routes, controllers, helpers and views
205
+ route "resources :password_resets, only: [:new, :create, :edit, :update]"
206
+ route "match 'sign_up/:token/activate' => 'registrations#activate', via: :get"
207
+ route "match 'sign_up' => 'registrations#create', via: :post"
208
+ route "match 'sign_up' => 'registrations#new', via: :get"
209
+ route "resources :registrations, only: [:new, :create, :activate]"
210
+ route "resources :user_sessions, only: [:new, :create, :destroy]"
211
+ route "match 'sign_out' => 'user_sessions#destroy', as: :sign_out"
212
+ route "match 'sign_in' => 'user_sessions#new', as: :sign_in"
213
+
214
+ copy_file '_app/controllers/application_controller.rb',
215
+ 'app/controllers/application_controller.rb',
216
+ force: true
217
+
218
+ copy_file '_app/helpers/application_helper.rb',
219
+ 'app/helpers/application_helper.rb',
220
+ force: true
221
+
222
+ copy_file '_app/models/user_session.rb',
223
+ 'app/models/user_session.rb'
224
+
225
+ copy_file '_app/controllers/user_sessions_controller.rb',
226
+ 'app/controllers/user_sessions_controller.rb'
227
+
228
+ copy_file '_app/views/user_sessions/new.html.slim',
229
+ 'app/views/user_sessions/new.html.slim'
230
+
231
+ copy_file '_spec/support/user_sessions_request_helper.rb',
232
+ 'spec/support/user_sessions_request_helper.rb'
233
+
234
+ copy_file '_spec/requests/user_sessions_spec.rb',
235
+ 'spec/requests/user_sessions_spec.rb'
236
+
237
+ copy_file '_app/controllers/registrations_controller.rb',
238
+ 'app/controllers/registrations_controller.rb'
239
+
240
+ directory '_app/views/registrations', 'app/views/registrations'
241
+
242
+ copy_file '_app/controllers/password_resets_controller.rb',
243
+ 'app/controllers/password_resets_controller.rb'
244
+
245
+ directory '_app/views/password_resets', 'app/views/password_resets'
246
+
247
+ copy_file '_app/views/password_resets/edit.html.slim',
248
+ 'app/views/password_resets/edit.html.slim'
249
+
250
+ end
251
+
252
+ def setup_stylesheets
253
+ remove_file 'app/assets/stylesheets/application.css'
254
+ directory '_app/assets/stylesheets', 'app/assets/stylesheets'
255
+ end
256
+
257
+ def setup_javascripts
258
+ inject_into_file 'app/assets/javascripts/application.js',
259
+ "//= require twitter/bootstrap\n",
260
+ after: "require jquery_ujs\n"
261
+ end
262
+
263
+ def copy_rake_tasks
264
+ copy_file '_lib/tasks/db.rake', 'lib/tasks/db.rake'
265
+ copy_file '_db/sample_data.rb', 'db/sample_data.rb'
266
+ end
267
+
268
+ def remove_routes_comment_lines
269
+ replace_in_file 'config/routes.rb', /Application\.routes\.draw do.*end/m, "Application.routes.draw do\nend"
270
+ end
271
+
272
+ def convert_to_19_hash_syntax
273
+ run 'hash_syntax -n'
274
+ end
275
+
276
+ def consistent_quoting
277
+ gsub_file 'config/application.rb', '"utf-8"', "'utf-8'"
278
+ %w(acceptance production).each do |fn|
279
+ gsub_file "config/environments/#{fn}.rb", '"X-Sendfile"', "'X-Sendfile'"
280
+ end
281
+ end
282
+ end
283
+ end
@@ -0,0 +1,182 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+ require 'rvm'
4
+
5
+ module Raygun
6
+ class AppGenerator < Rails::Generators::AppGenerator
7
+
8
+ class_option :database, type: :string, aliases: '-d', default: 'postgresql',
9
+ desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
10
+
11
+ class_option :skip_test_unit, type: :boolean, aliases: '-T', default: true,
12
+ desc: "Skip Test::Unit files"
13
+
14
+ def finish_template
15
+ invoke :raygun_customization
16
+ super
17
+ end
18
+
19
+ def raygun_customization
20
+ rvm_original_env = RVM.current.expanded_name
21
+
22
+ invoke :remove_files_we_dont_need
23
+ invoke :remove_routes_comment_lines
24
+ invoke :setup_development_environment
25
+ invoke :setup_production_environment
26
+ invoke :setup_acceptance_environment
27
+ #invoke :setup_staging_environment
28
+ # FUTURE autodetect rvm or rbenv
29
+ invoke :configure_rvm
30
+ # FUTURE invoke :configure_rbenv
31
+ invoke :customize_gemfile
32
+ invoke :setup_database
33
+ invoke :setup_generators
34
+ invoke :create_raygun_views
35
+ invoke :configure_app
36
+ invoke :setup_javascripts
37
+ invoke :setup_stylesheets
38
+ invoke :copy_miscellaneous_files
39
+
40
+ # Go back to the original rvm environment.
41
+ @@env.use!(rvm_original_env)
42
+
43
+ invoke :knits_and_picks
44
+ invoke :outro
45
+ end
46
+
47
+ def remove_files_we_dont_need
48
+ say "Removing unwanted files."
49
+ build :remove_rails_logo_image
50
+ build :remove_application_layout
51
+ end
52
+
53
+ def remove_routes_comment_lines
54
+ build :remove_routes_comment_lines
55
+ end
56
+
57
+ def setup_development_environment
58
+ say "Setting up the development environment."
59
+ build :raise_delivery_errors
60
+ build :enable_factory_girl_syntax
61
+ end
62
+
63
+ def setup_production_environment
64
+ say "Setting up the production environment."
65
+ build :enable_threadsafe_mode
66
+ end
67
+
68
+ def setup_acceptance_environment
69
+ say "Setting up the acceptance environment."
70
+ build :setup_acceptance_environment
71
+ build :initialize_on_precompile
72
+ end
73
+
74
+ def configure_rvm
75
+ say "Configuring RVM"
76
+
77
+ @@env = RVM::Environment.new
78
+
79
+ @@env.gemset_create(app_name)
80
+ @@env.gemset_use!(app_name)
81
+
82
+ build :configure_rvm
83
+ end
84
+
85
+ def customize_gemfile
86
+ say "Customizing the Gemfile."
87
+ build :configure_gemfile
88
+ bundle_command 'install'
89
+ end
90
+
91
+ def setup_database
92
+ say 'Setting up database'
93
+ build :use_postgres_config_template
94
+ build :create_database
95
+ end
96
+
97
+ def setup_generators
98
+ say 'Installing custom view generator templates'
99
+ build :setup_generators
100
+ end
101
+
102
+ def create_raygun_views
103
+ say 'Creating views and layouts'
104
+ build :replace_public_index
105
+ build :create_partials_directory
106
+ #build :create_shared_flashes
107
+ #build :create_shared_javascripts
108
+ build :create_application_layout
109
+ end
110
+
111
+ def configure_app
112
+ say 'Configuring app'
113
+
114
+ build :configure_rspec
115
+ build :generate_rspec
116
+ build :add_rspec_support
117
+
118
+ build :configure_time_zone
119
+ build :configure_action_mailer
120
+ build :add_lib_to_load_path
121
+ build :add_email_validator
122
+ build :setup_simple_form
123
+ build :setup_authentication
124
+ build :setup_default_rake_task
125
+ #build :setup_guard
126
+ end
127
+
128
+ def setup_stylesheets
129
+ say "Configuring stylesheets"
130
+ build :setup_stylesheets
131
+ end
132
+
133
+ def setup_javascripts
134
+ say "Configuring javascripts"
135
+ build :setup_javascripts
136
+ end
137
+
138
+ def copy_miscellaneous_files
139
+ say 'Copying miscellaneous support files'
140
+ build :copy_rake_tasks
141
+ end
142
+
143
+ def knits_and_picks
144
+ say 'Converting old hash syntax and fixing knit picks'
145
+ build :convert_to_19_hash_syntax
146
+ build :consistent_quoting
147
+ end
148
+
149
+ def outro
150
+ say ""
151
+ say "You're done! Next steps..."
152
+ say ""
153
+ say "# Prepare the database"
154
+ say " $ cd #{ARGV[0]}"
155
+ say " $ rake db:create db:migrate db:test:prepare"
156
+ say ""
157
+ say "# Run the specs (they should all pass)"
158
+ say " $ rake spec"
159
+ say ""
160
+ say "# Load reference and sample data, then run the app and check things out"
161
+ say " $ rake db:seed db:sample_data"
162
+ say " $ rails s"
163
+ say " $ open http://0.0.0.0:3000"
164
+ say ""
165
+ say "Enjoy your Carbon Five flavored Rails application!"
166
+ end
167
+
168
+ def run_bundle
169
+ # Let's not: We'll bundle manually at the right spot
170
+ end
171
+
172
+ def rvm_ruby
173
+ @@env.expanded_name.match(/(.*)@/)[1]
174
+ end
175
+
176
+ protected
177
+
178
+ def get_builder_class
179
+ Raygun::AppBuilder
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,3 @@
1
+ module Raygun
2
+ VERSION = "0.0.2"
3
+ end
data/marvin.jpg ADDED
Binary file
data/raygun.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'raygun/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = "raygun"
9
+ gem.version = Raygun::VERSION
10
+ gem.authors = ["Christian Nelson"]
11
+ gem.email = ["christian@carbonfive.com"]
12
+ gem.description = %q{Carbon Five Rails application generator}
13
+ gem.summary = %q{Generates and customizes Rails applications with Carbon Five best practices baked in.}
14
+ gem.homepage = "https://github.com/carbonfive/raygun"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency 'rails', '3.2.8'
22
+ gem.add_dependency 'bundler', '>= 1.2'
23
+ gem.add_dependency 'rvm', '>= 1.11.3.5'
24
+ gem.add_dependency 'hash_syntax', '>= 1.0'
25
+ end