raygun 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -3
- data/.rbenv-version +1 -1
- data/README.md +2 -9
- data/Rakefile +1 -1
- data/TODO.md +0 -5
- data/app_prototype/.gitignore +15 -0
- data/app_prototype/.rspec +1 -0
- data/app_prototype/.rvmrc +1 -0
- data/{templates/Gemfile_customized → app_prototype/Gemfile} +1 -0
- data/{templates/Guardfile_customized → app_prototype/Guardfile} +6 -0
- data/{templates → app_prototype}/Procfile +0 -0
- data/{templates/README.md.erb → app_prototype/README.md} +0 -0
- data/app_prototype/Rakefile +10 -0
- data/app_prototype/app/assets/javascripts/application.js +16 -0
- data/app_prototype/app/assets/javascripts/users.js.coffee +3 -0
- data/{templates/_app → app_prototype/app}/assets/stylesheets/_footer.less +0 -0
- data/{templates/_app → app_prototype/app}/assets/stylesheets/application.css.less +0 -0
- data/{templates/_app → app_prototype/app}/controllers/application_controller.rb +1 -0
- data/{templates/_app → app_prototype/app}/controllers/password_resets_controller.rb +0 -0
- data/{templates/_app → app_prototype/app}/controllers/registrations_controller.rb +2 -0
- data/{templates/_app → app_prototype/app}/controllers/user_sessions_controller.rb +1 -1
- data/app_prototype/app/controllers/users_controller.rb +41 -0
- data/{templates/_app → app_prototype/app}/helpers/application_helper.rb +0 -0
- data/app_prototype/app/helpers/users_helper.rb +2 -0
- data/app_prototype/app/mailers/.gitkeep +0 -0
- data/{templates/_app → app_prototype/app}/mailers/user_mailer.rb +0 -0
- data/app_prototype/app/models/.gitkeep +0 -0
- data/{templates/_app → app_prototype/app}/models/ability.rb +0 -0
- data/{templates/_app → app_prototype/app}/models/user.rb +0 -0
- data/{templates/_app → app_prototype/app}/models/user_session.rb +0 -0
- data/{templates/_app/views/layouts/application.html.slim.erb → app_prototype/app/views/layouts/application.html.slim} +2 -2
- data/{templates/_app → app_prototype/app}/views/password_resets/edit.html.slim +0 -0
- data/{templates/_app → app_prototype/app}/views/password_resets/new.html.slim +0 -0
- data/{templates/_app → app_prototype/app}/views/registrations/new.html.slim +0 -0
- data/{templates/_app → app_prototype/app}/views/user_mailer/activation_needed_email.html.erb +0 -0
- data/{templates/_app → app_prototype/app}/views/user_mailer/activation_needed_email.text.erb +0 -0
- data/{templates/_app → app_prototype/app}/views/user_mailer/activation_success_email.html.erb +0 -0
- data/{templates/_app → app_prototype/app}/views/user_mailer/activation_success_email.text.erb +0 -0
- data/{templates/_app → app_prototype/app}/views/user_mailer/reset_password_email.html.erb +0 -0
- data/{templates/_app → app_prototype/app}/views/user_mailer/reset_password_email.text.erb +0 -0
- data/{templates/_app → app_prototype/app}/views/user_sessions/new.html.slim +0 -0
- data/app_prototype/app/views/users/_form.html.slim +12 -0
- data/app_prototype/app/views/users/edit.html.slim +5 -0
- data/app_prototype/app/views/users/index.html.slim +26 -0
- data/app_prototype/app/views/users/new.html.slim +4 -0
- data/app_prototype/app/views/users/show.html.slim +17 -0
- data/app_prototype/config.ru +8 -0
- data/app_prototype/config/application.rb +77 -0
- data/app_prototype/config/boot.rb +6 -0
- data/{templates/_config/database.yml.erb → app_prototype/config/database.yml} +2 -2
- data/app_prototype/config/environment.rb +5 -0
- data/app_prototype/config/environments/acceptance.rb +69 -0
- data/app_prototype/config/environments/development.rb +39 -0
- data/app_prototype/config/environments/production.rb +69 -0
- data/app_prototype/config/environments/test.rb +40 -0
- data/app_prototype/config/initializers/backtrace_silencers.rb +7 -0
- data/app_prototype/config/initializers/inflections.rb +15 -0
- data/app_prototype/config/initializers/mime_types.rb +5 -0
- data/app_prototype/config/initializers/secret_token.rb +7 -0
- data/app_prototype/config/initializers/session_store.rb +8 -0
- data/app_prototype/config/initializers/simple_form.rb +142 -0
- data/app_prototype/config/initializers/simple_form_bootstrap.rb +45 -0
- data/app_prototype/config/initializers/sorcery.rb +398 -0
- data/app_prototype/config/initializers/wrap_parameters.rb +14 -0
- data/app_prototype/config/locales/en.yml +5 -0
- data/app_prototype/config/locales/simple_form.en.yml +26 -0
- data/app_prototype/config/routes.rb +21 -0
- data/app_prototype/db/migrate/20121128215324_sorcery_core.rb +17 -0
- data/app_prototype/db/migrate/20121128215325_sorcery_brute_force_protection.rb +13 -0
- data/app_prototype/db/migrate/20121128215326_sorcery_activity_logging.rb +17 -0
- data/app_prototype/db/migrate/20121128215327_sorcery_user_activation.rb +17 -0
- data/app_prototype/db/migrate/20121128215328_sorcery_remember_me.rb +15 -0
- data/app_prototype/db/migrate/20121128215329_sorcery_reset_password.rb +17 -0
- data/app_prototype/db/migrate/20121128215330_sorcery_external.rb +14 -0
- data/app_prototype/db/migrate/20121128215337_add_admin_to_users.rb +5 -0
- data/{templates/_db → app_prototype/db}/sample_data.rb +0 -0
- data/app_prototype/db/schema.rb +53 -0
- data/app_prototype/db/seeds.rb +7 -0
- data/app_prototype/lib/assets/.gitkeep +0 -0
- data/app_prototype/lib/tasks/.gitkeep +0 -0
- data/{templates/_lib → app_prototype/lib}/tasks/coverage.rake +0 -0
- data/{templates/_lib → app_prototype/lib}/tasks/db.rake +0 -0
- data/{templates/_lib → app_prototype/lib}/tasks/spec.rake +0 -0
- data/{templates/_lib → app_prototype/lib}/templates/rails/scaffold_controller/controller.rb +0 -0
- data/{templates/_lib → app_prototype/lib}/templates/rspec/scaffold/controller_spec.rb +1 -1
- data/{templates/_lib → app_prototype/lib}/templates/slim/scaffold/_form.html.slim +0 -0
- data/{templates/_lib → app_prototype/lib}/templates/slim/scaffold/edit.html.slim +0 -0
- data/{templates/_lib → app_prototype/lib}/templates/slim/scaffold/index.html.slim +0 -0
- data/{templates/_lib → app_prototype/lib}/templates/slim/scaffold/new.html.slim +0 -0
- data/{templates/_lib → app_prototype/lib}/templates/slim/scaffold/show.html.slim +0 -0
- data/app_prototype/log/.gitkeep +0 -0
- data/app_prototype/public/404.html +26 -0
- data/app_prototype/public/422.html +26 -0
- data/app_prototype/public/500.html +25 -0
- data/app_prototype/public/favicon.ico +0 -0
- data/{templates/_public/index.html.erb → app_prototype/public/index.html} +2 -2
- data/app_prototype/public/robots.txt +5 -0
- data/app_prototype/script/rails +6 -0
- data/app_prototype/spec/controllers/user_sessions_controller_spec.rb +42 -0
- data/app_prototype/spec/controllers/users_controller_spec.rb +150 -0
- data/{templates/_spec → app_prototype/spec}/factories/users.rb +0 -0
- data/{templates/_spec → app_prototype/spec}/features/user_sessions_spec.rb +5 -1
- data/app_prototype/spec/helpers/users_helper_spec.rb +15 -0
- data/{templates/_spec → app_prototype/spec}/javascripts/example_spec.js.coffee +0 -0
- data/{templates/_spec → app_prototype/spec}/javascripts/spec.css +0 -0
- data/{templates/_spec → app_prototype/spec}/javascripts/spec.js.coffee +0 -0
- data/{templates/_spec → app_prototype/spec}/mailers/user_mailer_spec.rb +0 -0
- data/{templates/_spec → app_prototype/spec}/models/ability_spec.rb +0 -0
- data/{templates/_spec → app_prototype/spec}/models/user_spec.rb +0 -0
- data/app_prototype/spec/spec_helper.rb +84 -0
- data/{templates/_spec → app_prototype/spec}/support/accept_values.rb +0 -0
- data/{templates/_spec → app_prototype/spec}/support/factory_girl.rb +0 -0
- data/{templates/_spec → app_prototype/spec}/support/sorcery.rb +0 -0
- data/{templates/_spec → app_prototype/spec}/support/user_sessions_feature_helper.rb +0 -0
- data/app_prototype/spec/views/users/edit.html.slim_spec.rb +20 -0
- data/app_prototype/spec/views/users/index.html.slim_spec.rb +23 -0
- data/app_prototype/spec/views/users/new.html.slim_spec.rb +20 -0
- data/app_prototype/spec/views/users/show.html.slim_spec.rb +17 -0
- data/app_prototype/vendor/assets/javascripts/.gitkeep +0 -0
- data/app_prototype/vendor/assets/stylesheets/.gitkeep +0 -0
- data/app_prototype/vendor/plugins/.gitkeep +0 -0
- data/bin/raygun +48 -6
- data/lib/raygun/version.rb +1 -1
- data/raygun.gemspec +0 -3
- metadata +118 -108
- data/lib/raygun/actions.rb +0 -26
- data/lib/raygun/app_builder.rb +0 -362
- data/lib/raygun/generators/app_generator.rb +0 -188
- data/lib/raygun/helpers/ruby_version_helpers.rb +0 -52
- data/lib/raygun/raygun.rb +0 -11
- data/templates/rbenv-version.erb +0 -1
- data/templates/rvmrc.erb +0 -1
data/lib/raygun/actions.rb
DELETED
@@ -1,26 +0,0 @@
|
|
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
|
data/lib/raygun/app_builder.rb
DELETED
@@ -1,362 +0,0 @@
|
|
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_rbenv
|
58
|
-
template 'rbenv-version.erb', '.rbenv-version', rbenv_ruby: rbenv_ruby
|
59
|
-
end
|
60
|
-
|
61
|
-
def configure_gemfile
|
62
|
-
run 'gem install bundler'
|
63
|
-
copy_file 'Gemfile_customized', 'Gemfile', force: true
|
64
|
-
end
|
65
|
-
|
66
|
-
def setup_generators
|
67
|
-
directory '_lib/templates/rails', 'lib/templates/rails'
|
68
|
-
|
69
|
-
%w(_form index show new edit).each do |view|
|
70
|
-
template = "lib/templates/slim/scaffold/#{view}.html.slim"
|
71
|
-
remove_file template
|
72
|
-
copy_file "_lib/templates/slim/scaffold/#{view}.html.slim", template
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def configure_rspec
|
77
|
-
generators_config = <<-RUBY
|
78
|
-
|
79
|
-
config.generators do |generate|
|
80
|
-
generate.stylesheets false
|
81
|
-
#generate.helpers false
|
82
|
-
generate.routing_specs false
|
83
|
-
#generate.view_specs false
|
84
|
-
end
|
85
|
-
|
86
|
-
RUBY
|
87
|
-
inject_into_class 'config/application.rb', 'Application', generators_config
|
88
|
-
|
89
|
-
copy_file '_lib/templates/rspec/scaffold/controller_spec.rb',
|
90
|
-
'lib/templates/rspec/scaffold/controller_spec.rb'
|
91
|
-
end
|
92
|
-
|
93
|
-
def generate_rspec
|
94
|
-
generate 'rspec:install'
|
95
|
-
end
|
96
|
-
|
97
|
-
def add_rspec_support
|
98
|
-
shared_transaction = <<-RUBY
|
99
|
-
|
100
|
-
# Forces all threads to share the same connection. This works on
|
101
|
-
# Capybara because it starts the web server in a thread.
|
102
|
-
#
|
103
|
-
# http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
|
104
|
-
|
105
|
-
class ActiveRecord::Base
|
106
|
-
mattr_accessor :shared_connection
|
107
|
-
@@shared_connection = nil
|
108
|
-
|
109
|
-
def self.connection
|
110
|
-
@@shared_connection || retrieve_connection
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
115
|
-
|
116
|
-
# Turn down the logging while testing.
|
117
|
-
Rails.logger.level = 4
|
118
|
-
RUBY
|
119
|
-
|
120
|
-
append_to_file 'spec/spec_helper.rb', shared_transaction
|
121
|
-
|
122
|
-
copy_file '_spec/support/accept_values.rb', 'spec/support/accept_values.rb'
|
123
|
-
end
|
124
|
-
|
125
|
-
def add_js_testing
|
126
|
-
directory '_spec/javascripts', 'spec/javascripts'
|
127
|
-
copy_file '_lib/tasks/spec.rake', 'lib/tasks/spec.rake'
|
128
|
-
end
|
129
|
-
|
130
|
-
def configure_time_zone
|
131
|
-
'config/application.rb'.tap do |fn|
|
132
|
-
#inject_into_file fn, ' config.active_record.default_timezone = :utc\n', after: "'Central Time (US & Canada)'\n"
|
133
|
-
#uncomment_lines fn, 'config.time_zone'
|
134
|
-
gsub_file fn, 'Central Time (US & Canada)', 'Pacific Time (US & Canada)'
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def configure_action_mailer
|
139
|
-
action_mailer_host 'development', "#{app_name}.local"
|
140
|
-
action_mailer_host 'test', "example.com"
|
141
|
-
action_mailer_host 'acceptance', "acceptance.#{app_name}.com"
|
142
|
-
action_mailer_host 'production', "#{app_name}.com"
|
143
|
-
end
|
144
|
-
|
145
|
-
def add_lib_to_load_path
|
146
|
-
'config/application.rb'.tap do |fn|
|
147
|
-
gsub_file fn, '#{config.root}/extras', '#{config.root}/lib'
|
148
|
-
uncomment_lines fn, 'config.autoload_paths'
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def setup_simple_form
|
153
|
-
generate 'simple_form:install --bootstrap -s'
|
154
|
-
|
155
|
-
replace_in_file 'config/initializers/simple_form.rb',
|
156
|
-
%(# config.label_text = lambda { |label, required| "\#{required} \#{label}" }),
|
157
|
-
%(config.label_text = lambda { |label, required| "\#{label}" })
|
158
|
-
end
|
159
|
-
|
160
|
-
def setup_authentication
|
161
|
-
# User model
|
162
|
-
generate 'scaffold user email:string name:string'
|
163
|
-
|
164
|
-
remove_file 'app/models/user.rb'
|
165
|
-
remove_file 'spec/factories/users.rb'
|
166
|
-
remove_file 'spec/requests/users_spec.rb'
|
167
|
-
create_users_migration = 'db/migrate/' + Dir.new('./db/migrate').entries.select { |e| e =~ /create_users/ }.first
|
168
|
-
remove_file create_users_migration
|
169
|
-
|
170
|
-
generate 'sorcery:install brute_force_protection activity_logging user_activation remember_me reset_password external'
|
171
|
-
|
172
|
-
copy_file '_app/models/user.rb', 'app/models/user.rb', force: true
|
173
|
-
copy_file '_spec/support/sorcery.rb', 'spec/support/sorcery.rb'
|
174
|
-
copy_file '_spec/factories/users.rb', 'spec/factories/users.rb', force: true
|
175
|
-
copy_file '_spec/models/user_spec.rb', 'spec/models/user_spec.rb', force: true
|
176
|
-
|
177
|
-
gsub_file 'spec/controllers/users_controller_spec.rb', 'login_user build :user', 'login_user build :admin'
|
178
|
-
|
179
|
-
inject_into_file 'app/controllers/users_controller.rb',
|
180
|
-
"\n before_filter :require_login\n",
|
181
|
-
after: "UsersController < ApplicationController\n"
|
182
|
-
|
183
|
-
# User mailer (has to happen before sorcery config changes)
|
184
|
-
generate 'mailer UserMailer activation_needed_email activation_success_email reset_password_email'
|
185
|
-
copy_file '_app/mailers/user_mailer.rb', 'app/mailers/user_mailer.rb', force: true
|
186
|
-
copy_file '_spec/mailers/user_mailer_spec.rb', 'spec/mailers/user_mailer_spec.rb', force: true
|
187
|
-
|
188
|
-
%w(activation_needed_email activation_success_email reset_password_email).each do |fn|
|
189
|
-
remove_file "app/views/user_mailer/#{fn}.text.slim"
|
190
|
-
|
191
|
-
%w(html.erb text.erb).each do |ext|
|
192
|
-
copy_file "_app/views/user_mailer/#{fn}.#{ext}", "app/views/user_mailer/#{fn}.#{ext}", force: true
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
remove_dir 'spec/fixtures/user_mailer'
|
197
|
-
|
198
|
-
# Patch sorcery configuration and migrations
|
199
|
-
sorcery_core_migration = 'db/migrate/' + Dir.new('./db/migrate').entries.select { |e| e =~ /sorcery_core/ }.first
|
200
|
-
inject_into_file sorcery_core_migration, " t.string :name\n", after: "create_table :users do |t|\n"
|
201
|
-
comment_lines sorcery_core_migration, /^.* t.string :username.*$\n/
|
202
|
-
|
203
|
-
'config/initializers/sorcery.rb'.tap do |fn|
|
204
|
-
replace_in_file fn, 'config.user_class = "User"', 'config.user_class = User'
|
205
|
-
replace_in_file fn, '# user.username_attribute_names =', 'user.username_attribute_names = :email'
|
206
|
-
replace_in_file fn, '# user.user_activation_mailer =', 'user.user_activation_mailer = UserMailer'
|
207
|
-
replace_in_file fn, '# user.reset_password_mailer =', 'user.reset_password_mailer = UserMailer'
|
208
|
-
#replace_in_file sorcery_rb, /# user.unlock_token_mailer =.*$/, 'user.unlock_token_mailer = UserMailer'
|
209
|
-
end
|
210
|
-
|
211
|
-
# Routes, controllers, helpers and views
|
212
|
-
route "resources :password_resets, only: [:new, :create, :edit, :update]"
|
213
|
-
route "match 'sign_up/:token/activate' => 'registrations#activate', via: :get"
|
214
|
-
route "match 'sign_up' => 'registrations#create', via: :post"
|
215
|
-
route "match 'sign_up' => 'registrations#new', via: :get"
|
216
|
-
route "resources :registrations, only: [:new, :create, :activate]"
|
217
|
-
route "resources :user_sessions, only: [:new, :create, :destroy]"
|
218
|
-
route "match 'sign_out' => 'user_sessions#destroy', as: :sign_out"
|
219
|
-
route "match 'sign_in' => 'user_sessions#new', as: :sign_in"
|
220
|
-
|
221
|
-
copy_file '_app/controllers/application_controller.rb',
|
222
|
-
'app/controllers/application_controller.rb',
|
223
|
-
force: true
|
224
|
-
|
225
|
-
copy_file '_app/helpers/application_helper.rb',
|
226
|
-
'app/helpers/application_helper.rb',
|
227
|
-
force: true
|
228
|
-
|
229
|
-
copy_file '_app/models/user_session.rb',
|
230
|
-
'app/models/user_session.rb'
|
231
|
-
|
232
|
-
copy_file '_app/controllers/user_sessions_controller.rb',
|
233
|
-
'app/controllers/user_sessions_controller.rb'
|
234
|
-
|
235
|
-
copy_file '_app/views/user_sessions/new.html.slim',
|
236
|
-
'app/views/user_sessions/new.html.slim'
|
237
|
-
|
238
|
-
copy_file '_spec/support/user_sessions_feature_helper.rb',
|
239
|
-
'spec/support/user_sessions_feature_helper.rb'
|
240
|
-
|
241
|
-
copy_file '_spec/features/user_sessions_spec.rb',
|
242
|
-
'spec/features/user_sessions_spec.rb'
|
243
|
-
|
244
|
-
copy_file '_app/controllers/registrations_controller.rb',
|
245
|
-
'app/controllers/registrations_controller.rb'
|
246
|
-
|
247
|
-
directory '_app/views/registrations', 'app/views/registrations'
|
248
|
-
|
249
|
-
copy_file '_app/controllers/password_resets_controller.rb',
|
250
|
-
'app/controllers/password_resets_controller.rb'
|
251
|
-
|
252
|
-
directory '_app/views/password_resets', 'app/views/password_resets'
|
253
|
-
|
254
|
-
copy_file '_app/views/password_resets/edit.html.slim',
|
255
|
-
'app/views/password_resets/edit.html.slim'
|
256
|
-
end
|
257
|
-
|
258
|
-
def setup_authorization
|
259
|
-
generate 'migration add_admin_to_users admin:boolean'
|
260
|
-
|
261
|
-
copy_file '_app/models/ability.rb', 'app/models/ability.rb'
|
262
|
-
copy_file '_spec/models/ability_spec.rb', 'spec/models/ability_spec.rb'
|
263
|
-
|
264
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
265
|
-
" check_authorization\n",
|
266
|
-
after: "protect_from_forgery\n"
|
267
|
-
|
268
|
-
append_to_file 'config/environments/test.rb', 'Sorcery::CryptoProviders::BCrypt.cost = 1'
|
269
|
-
end
|
270
|
-
|
271
|
-
def setup_simplecov
|
272
|
-
copy_file '_lib/tasks/coverage.rake', 'lib/tasks/coverage.rake'
|
273
|
-
|
274
|
-
coverage = <<-RUBY
|
275
|
-
# Coverage must be enabled before the application is loaded.
|
276
|
-
if ENV['COVERAGE']
|
277
|
-
require 'simplecov'
|
278
|
-
|
279
|
-
# Writes the coverage stat to a file to be used by Cane.
|
280
|
-
class SimpleCov::Formatter::QualityFormatter
|
281
|
-
def format(result)
|
282
|
-
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
283
|
-
File.open('coverage/covered_percent', 'w') do |f|
|
284
|
-
f.puts result.source_files.covered_percent.to_f
|
285
|
-
end
|
286
|
-
end
|
287
|
-
end
|
288
|
-
SimpleCov.formatter = SimpleCov::Formatter::QualityFormatter
|
289
|
-
|
290
|
-
SimpleCov.start do
|
291
|
-
add_filter '/spec/'
|
292
|
-
add_filter '/config/'
|
293
|
-
add_filter '/vendor/'
|
294
|
-
add_group 'Models', 'app/models'
|
295
|
-
add_group 'Controllers', 'app/controllers'
|
296
|
-
add_group 'Helpers', 'app/helpers'
|
297
|
-
add_group 'Views', 'app/views'
|
298
|
-
add_group 'Mailers', 'app/mailers'
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
RUBY
|
303
|
-
|
304
|
-
prepend_to_file 'spec/spec_helper.rb', coverage
|
305
|
-
end
|
306
|
-
|
307
|
-
def setup_default_rake_task
|
308
|
-
append_file 'Rakefile' do
|
309
|
-
"\ntask(:default).clear\ntask default: 'spec'"
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
def setup_guard
|
314
|
-
copy_file 'Guardfile_customized', 'Guardfile'
|
315
|
-
bundle_command 'exec guard init jasmine'
|
316
|
-
end
|
317
|
-
|
318
|
-
def setup_logging
|
319
|
-
inject_into_file 'config.ru',
|
320
|
-
"\n# Disable buffering for real time logging (foreman and heroku).\n$stdout.sync = true\n\n",
|
321
|
-
before: /run \w+::Application/
|
322
|
-
end
|
323
|
-
|
324
|
-
def setup_stylesheets
|
325
|
-
remove_file 'app/assets/stylesheets/application.css'
|
326
|
-
directory '_app/assets/stylesheets', 'app/assets/stylesheets'
|
327
|
-
end
|
328
|
-
|
329
|
-
def setup_javascripts
|
330
|
-
inject_into_file 'app/assets/javascripts/application.js',
|
331
|
-
"//= require twitter/bootstrap\n",
|
332
|
-
after: "require jquery_ujs\n"
|
333
|
-
end
|
334
|
-
|
335
|
-
def copy_rake_tasks
|
336
|
-
copy_file '_lib/tasks/db.rake', 'lib/tasks/db.rake'
|
337
|
-
copy_file '_db/sample_data.rb', 'db/sample_data.rb'
|
338
|
-
end
|
339
|
-
|
340
|
-
def copy_procfile
|
341
|
-
copy_file 'Procfile'
|
342
|
-
end
|
343
|
-
|
344
|
-
def remove_routes_comment_lines
|
345
|
-
replace_in_file 'config/routes.rb', /Application\.routes\.draw do.*end/m, "Application.routes.draw do\nend"
|
346
|
-
end
|
347
|
-
|
348
|
-
def convert_to_19_hash_syntax
|
349
|
-
original_destination_root = destination_root
|
350
|
-
inside(Raygun::AppGenerator.launch_path) do
|
351
|
-
run "find #{original_destination_root} -name '*.rb' | xargs hash_syntax -n"
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
def consistent_quoting
|
356
|
-
gsub_file 'config/application.rb', '"utf-8"', "'utf-8'"
|
357
|
-
%w(acceptance production).each do |fn|
|
358
|
-
gsub_file "config/environments/#{fn}.rb", '"X-Sendfile"', "'X-Sendfile'"
|
359
|
-
end
|
360
|
-
end
|
361
|
-
end
|
362
|
-
end
|
@@ -1,188 +0,0 @@
|
|
1
|
-
module Raygun
|
2
|
-
class AppGenerator < Rails::Generators::AppGenerator
|
3
|
-
include Raygun::RubyVersionHelpers
|
4
|
-
|
5
|
-
# set and get raygun launch path
|
6
|
-
def self.launch_path(path=nil)
|
7
|
-
@_launch_path = path if path
|
8
|
-
@_launch_path
|
9
|
-
end
|
10
|
-
|
11
|
-
class_option :database, type: :string, aliases: '-d', default: 'postgresql',
|
12
|
-
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
13
|
-
|
14
|
-
class_option :skip_test_unit, type: :boolean, aliases: '-T', default: true,
|
15
|
-
desc: "Skip Test::Unit files"
|
16
|
-
|
17
|
-
def finish_template
|
18
|
-
invoke :raygun_customization
|
19
|
-
super
|
20
|
-
end
|
21
|
-
|
22
|
-
def raygun_customization
|
23
|
-
|
24
|
-
with_ruby_version do
|
25
|
-
invoke :remove_files_we_dont_need
|
26
|
-
invoke :remove_routes_comment_lines
|
27
|
-
invoke :setup_development_environment
|
28
|
-
invoke :setup_production_environment
|
29
|
-
invoke :setup_acceptance_environment
|
30
|
-
#invoke :setup_staging_environment
|
31
|
-
invoke :configure_ruby_version
|
32
|
-
invoke :customize_gemfile
|
33
|
-
invoke :setup_database
|
34
|
-
invoke :setup_generators
|
35
|
-
invoke :create_raygun_views
|
36
|
-
invoke :configure_app
|
37
|
-
invoke :setup_javascripts
|
38
|
-
invoke :setup_stylesheets
|
39
|
-
invoke :copy_miscellaneous_files
|
40
|
-
end
|
41
|
-
|
42
|
-
invoke :knits_and_picks
|
43
|
-
invoke :outro
|
44
|
-
end
|
45
|
-
|
46
|
-
def remove_files_we_dont_need
|
47
|
-
say "Removing unwanted files."
|
48
|
-
build :remove_rails_logo_image
|
49
|
-
build :remove_application_layout
|
50
|
-
end
|
51
|
-
|
52
|
-
def remove_routes_comment_lines
|
53
|
-
build :remove_routes_comment_lines
|
54
|
-
end
|
55
|
-
|
56
|
-
def setup_development_environment
|
57
|
-
say "Setting up the development environment."
|
58
|
-
build :raise_delivery_errors
|
59
|
-
build :enable_factory_girl_syntax
|
60
|
-
end
|
61
|
-
|
62
|
-
def setup_production_environment
|
63
|
-
say "Setting up the production environment."
|
64
|
-
build :enable_threadsafe_mode
|
65
|
-
end
|
66
|
-
|
67
|
-
def setup_acceptance_environment
|
68
|
-
say "Setting up the acceptance environment."
|
69
|
-
build :setup_acceptance_environment
|
70
|
-
build :initialize_on_precompile
|
71
|
-
end
|
72
|
-
|
73
|
-
def configure_ruby_version
|
74
|
-
if rvm_installed?
|
75
|
-
say "Configuring RVM"
|
76
|
-
build :configure_rvm
|
77
|
-
else
|
78
|
-
say "Configuring rbenv"
|
79
|
-
build :configure_rbenv
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def customize_gemfile
|
84
|
-
say "Customizing the Gemfile."
|
85
|
-
build :configure_gemfile
|
86
|
-
bundle_command 'install'
|
87
|
-
end
|
88
|
-
|
89
|
-
def setup_database
|
90
|
-
say "Setting up database"
|
91
|
-
build :use_postgres_config_template
|
92
|
-
build :create_database
|
93
|
-
end
|
94
|
-
|
95
|
-
def setup_generators
|
96
|
-
say "Installing custom view generator templates"
|
97
|
-
build :setup_generators
|
98
|
-
end
|
99
|
-
|
100
|
-
def create_raygun_views
|
101
|
-
say "Creating views and layouts"
|
102
|
-
build :replace_public_index
|
103
|
-
build :create_partials_directory
|
104
|
-
#build :create_shared_flashes
|
105
|
-
#build :create_shared_javascripts
|
106
|
-
build :create_application_layout
|
107
|
-
end
|
108
|
-
|
109
|
-
def configure_app
|
110
|
-
say "Configuring app"
|
111
|
-
|
112
|
-
build :configure_rspec
|
113
|
-
build :generate_rspec
|
114
|
-
build :add_rspec_support
|
115
|
-
|
116
|
-
build :add_js_testing
|
117
|
-
|
118
|
-
build :setup_logging
|
119
|
-
build :configure_time_zone
|
120
|
-
build :configure_action_mailer
|
121
|
-
build :add_lib_to_load_path
|
122
|
-
build :setup_simple_form
|
123
|
-
build :setup_authentication
|
124
|
-
build :setup_authorization
|
125
|
-
build :setup_simplecov
|
126
|
-
build :setup_default_rake_task
|
127
|
-
build :setup_guard
|
128
|
-
end
|
129
|
-
|
130
|
-
def setup_stylesheets
|
131
|
-
say "Configuring stylesheets"
|
132
|
-
build :setup_stylesheets
|
133
|
-
end
|
134
|
-
|
135
|
-
def setup_javascripts
|
136
|
-
say "Configuring javascripts"
|
137
|
-
build :setup_javascripts
|
138
|
-
end
|
139
|
-
|
140
|
-
def copy_miscellaneous_files
|
141
|
-
say "Copying miscellaneous support files"
|
142
|
-
build :copy_rake_tasks
|
143
|
-
build :copy_procfile
|
144
|
-
end
|
145
|
-
|
146
|
-
def knits_and_picks
|
147
|
-
say "Converting old hash syntax and fixing knit picks"
|
148
|
-
build :convert_to_19_hash_syntax
|
149
|
-
build :consistent_quoting
|
150
|
-
end
|
151
|
-
|
152
|
-
def outro
|
153
|
-
say ""
|
154
|
-
say "You're done! Next steps..."
|
155
|
-
say ""
|
156
|
-
say "# Prepare the database: schema and reference / sample data"
|
157
|
-
say "$ cd #{ARGV[0]}"
|
158
|
-
say "$ rake db:migrate db:seed db:sample_data"
|
159
|
-
say ""
|
160
|
-
say "# Run the specs (they should all pass)"
|
161
|
-
say "$ rake"
|
162
|
-
say ""
|
163
|
-
say "# Load reference and sample data, then run the app and check things out"
|
164
|
-
say "$ foreman start"
|
165
|
-
say "$ open http://0.0.0.0:3000"
|
166
|
-
say ""
|
167
|
-
say "Enjoy your Carbon Five flavored Rails application!"
|
168
|
-
end
|
169
|
-
|
170
|
-
def run_bundle
|
171
|
-
# Let's not: We'll bundle manually at the right spot
|
172
|
-
end
|
173
|
-
|
174
|
-
protected
|
175
|
-
|
176
|
-
def get_builder_class
|
177
|
-
Raygun::AppBuilder
|
178
|
-
end
|
179
|
-
|
180
|
-
# We want output from our bundle commands, overriding thor's implementation.
|
181
|
-
def bundle_command(command)
|
182
|
-
say_status :run, "bundle #{command}"
|
183
|
-
cmd = "#{Gem.ruby} -rubygems #{Gem.bin_path('bundler', 'bundle')} #{command}"
|
184
|
-
IO.popen(cmd) { |p| p.each { |f| puts f } }
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
end
|