bretels 1.0.0

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.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bretels (1.0.0)
5
+ bundler (>= 1.1)
6
+ hub (~> 1.10.2)
7
+ rails (= 3.2.12)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ actionmailer (3.2.12)
13
+ actionpack (= 3.2.12)
14
+ mail (~> 2.4.4)
15
+ actionpack (3.2.12)
16
+ activemodel (= 3.2.12)
17
+ activesupport (= 3.2.12)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.4)
21
+ rack (~> 1.4.5)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.2.1)
25
+ activemodel (3.2.12)
26
+ activesupport (= 3.2.12)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.12)
29
+ activemodel (= 3.2.12)
30
+ activesupport (= 3.2.12)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.12)
34
+ activemodel (= 3.2.12)
35
+ activesupport (= 3.2.12)
36
+ activesupport (3.2.12)
37
+ i18n (~> 0.6)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ builder (3.0.4)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ hub (1.10.4)
44
+ i18n (0.6.4)
45
+ journey (1.0.4)
46
+ json (1.7.6)
47
+ mail (2.4.4)
48
+ i18n (>= 0.4.0)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ mime-types (1.21)
52
+ multi_json (1.7.0)
53
+ polyglot (0.3.3)
54
+ rack (1.4.5)
55
+ rack-cache (1.2)
56
+ rack (>= 0.4)
57
+ rack-ssl (1.3.3)
58
+ rack
59
+ rack-test (0.6.2)
60
+ rack (>= 1.0)
61
+ rails (3.2.12)
62
+ actionmailer (= 3.2.12)
63
+ actionpack (= 3.2.12)
64
+ activerecord (= 3.2.12)
65
+ activeresource (= 3.2.12)
66
+ activesupport (= 3.2.12)
67
+ bundler (~> 1.0)
68
+ railties (= 3.2.12)
69
+ railties (3.2.12)
70
+ actionpack (= 3.2.12)
71
+ activesupport (= 3.2.12)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (>= 0.14.6, < 2.0)
76
+ rake (10.0.3)
77
+ rdoc (3.12.2)
78
+ json (~> 1.4)
79
+ sprockets (2.2.2)
80
+ hike (~> 1.2)
81
+ multi_json (~> 1.0)
82
+ rack (~> 1.0)
83
+ tilt (~> 1.1, != 1.3.0)
84
+ thor (0.17.0)
85
+ tilt (1.3.5)
86
+ treetop (1.4.12)
87
+ polyglot
88
+ polyglot (>= 0.3.1)
89
+ tzinfo (0.3.37)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ bretels!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010-2012 Mike Burns and thoughtbot, inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # Bretels
2
+
3
+ Bretels is the base Rails application used at [brightin](http://brightin.nl). Big thanks to [thoughtbot](http://thoughtbot.com) for providing such a great starting point.
4
+
5
+ ![Suspenders boy](http://media.tumblr.com/1TEAMALpseh5xzf0Jt6bcwSMo1_400.png)
6
+
7
+ Installation
8
+ ------------
9
+
10
+ First install the bretels gem:
11
+
12
+ gem install bretels
13
+
14
+ Then run:
15
+
16
+ bretels projectname
17
+
18
+ This will create a Rails 3.2 app in `projectname`. This script creates a
19
+ new git repository. It is not meant to be used against an existing repo.
20
+
21
+ Dependencies
22
+ ------------
23
+
24
+ Some gems included have native extensions. You should have GCC
25
+ installed on your machine before generating an app with Suspenders.
26
+
27
+ Use [OS X GCC Installer](https://github.com/kennethreitz/osx-gcc-installer/) for
28
+ Snow Leopard (OS X 10.6).
29
+
30
+ Use [Command Line Tools for XCode](https://developer.apple.com/downloads/index.action)
31
+ for Lion (OS X 10.7) or Mountain Lion (OS X 10.8).
32
+
33
+ We use [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
34
+ full-stack Javascript integration testing. It requires QT. Instructions for
35
+ installing QT are
36
+ [here](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit).
37
+
38
+ PostgreSQL needs to be installed and running for the `db:create` rake task.
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', 'lib', 'bretels', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'bretels', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'bretels', 'app_builder'), File.dirname(__FILE__))
6
+
7
+ if ['create', '--create'].include? ARGV[0]
8
+ ARGV.shift
9
+ puts "[WARNING] the bretels create argument is deprecated. Just use `bretels #{ARGV.join}` instead"
10
+ end
11
+
12
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
13
+ Bretels::AppGenerator.source_root templates_root
14
+ Bretels::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
15
+
16
+ Bretels::AppGenerator.start
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'bretels/version'
4
+ require 'date'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'bretels'
8
+ s.version = Bretels::VERSION
9
+ s.date = Date.today.strftime('%Y-%m-%d')
10
+ s.authors = ['brightin', 'thoughtbot']
11
+ s.email = 'developers@brightin.com'
12
+ s.homepage = 'http://github.com/brightin/bretels'
13
+
14
+ s.summary = "Generate a Rails app using brightins's best practices."
15
+ s.description = <<-HERE
16
+ Fork of thoughtbot's Suspenders for use at Brightin.
17
+ HERE
18
+
19
+ s.files = `git ls-files`.split("\n").
20
+ reject { |file| file =~ /^\./ }.
21
+ reject { |file| file =~ /^(rdoc|pkg)/ }
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+
26
+ s.rdoc_options = ["--charset=UTF-8"]
27
+ s.extra_rdoc_files = %w[README.md LICENSE]
28
+
29
+ s.add_dependency 'rails', '3.2.12'
30
+ s.add_dependency 'bundler', '>= 1.1'
31
+ s.add_dependency 'hub', '~> 1.10.2'
32
+ end
@@ -0,0 +1,35 @@
1
+ module Bretels
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
+ def replace_in_file(relative_path, find, replace)
9
+ path = File.join(destination_root, relative_path)
10
+ contents = IO.read(path)
11
+ unless contents.gsub!(find, replace)
12
+ raise "#{find.inspect} not found in #{relative_path}"
13
+ end
14
+ File.open(path, "w") { |file| file.write(contents) }
15
+ end
16
+
17
+ def action_mailer_host(rails_env, host)
18
+ inject_into_file(
19
+ "config/environments/#{rails_env}.rb",
20
+ "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
21
+ :before => "\nend"
22
+ )
23
+ end
24
+
25
+ def download_file(uri_string, destination)
26
+ uri = URI.parse(uri_string)
27
+ http = Net::HTTP.new(uri.host, uri.port)
28
+ http.use_ssl = true if uri_string =~ /^https/
29
+ request = Net::HTTP::Get.new(uri.path)
30
+ contents = http.request(request).body
31
+ path = File.join(destination_root, destination)
32
+ File.open(path, "w") { |file| file.write(contents) }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,272 @@
1
+ module Bretels
2
+ class AppBuilder < Rails::AppBuilder
3
+ include Bretels::Actions
4
+
5
+ def readme
6
+ template 'README.md.erb', 'README.md'
7
+ end
8
+
9
+ def remove_public_index
10
+ remove_file 'public/index.html'
11
+ end
12
+
13
+ def remove_rails_logo_image
14
+ remove_file 'app/assets/images/rails.png'
15
+ end
16
+
17
+ def raise_delivery_errors
18
+ replace_in_file 'config/environments/development.rb',
19
+ 'raise_delivery_errors = false', 'raise_delivery_errors = true'
20
+ end
21
+
22
+ def enable_factory_girl_syntax
23
+ copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
24
+ end
25
+
26
+ def test_factories_first
27
+ copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
28
+ end
29
+
30
+ def generate_factories_file
31
+ template 'factories.rb', 'spec/factories.rb'
32
+ end
33
+
34
+ def add_cdn_settings
35
+ config = <<-RUBY
36
+ \n\n # Cloudfront settings
37
+ # config.static_cache_control = "public, max-age=31536000"
38
+ # config.action_controller.asset_host = ENV['ASSET_HOST']
39
+ RUBY
40
+
41
+ inject_into_file 'config.ru', "use Rack::Deflater\n",
42
+ :before => "run #{app_const}"
43
+
44
+ inject_into_file 'config/environments/production.rb', config.rstrip,
45
+ :after => "config.assets.digest = true"
46
+ end
47
+
48
+ def configure_smtp
49
+ config = <<-RUBY
50
+ \n\n ActionMailer::Base.smtp_settings = {
51
+ :address => 'smtp.sendgrid.net',
52
+ :port => '587',
53
+ :authentication => :plain,
54
+ :user_name => ENV['SENDGRID_USERNAME'],
55
+ :password => ENV['SENDGRID_PASSWORD'],
56
+ :domain => 'herokuapp.com',
57
+ :enable_starttls_auto => true
58
+ }
59
+ config.action_mailer.delivery_method = :smtp
60
+ RUBY
61
+
62
+ inject_into_file 'config/environments/production.rb', config.rstrip,
63
+ :after => 'config.action_mailer.raise_delivery_errors = false'
64
+
65
+ inject_into_file(
66
+ "config/environments/development.rb",
67
+ "\n\n config.action_mailer.delivery_method = :letter_opener",
68
+ :before => "\nend"
69
+ )
70
+ end
71
+
72
+ def enable_force_ssl
73
+ replace_in_file 'config/environments/production.rb',
74
+ '# config.force_ssl = true', 'config.force_ssl = true'
75
+ end
76
+
77
+ def setup_staging_environment
78
+ template 'staging.rb.erb', 'config/environments/staging.rb'
79
+ end
80
+
81
+ def initialize_on_precompile
82
+ inject_into_file 'config/application.rb',
83
+ "\n config.assets.initialize_on_precompile = false",
84
+ :after => 'config.assets.enabled = true'
85
+ end
86
+
87
+ def lib_in_load_path
88
+ replace_in_file 'config/application.rb',
89
+ '# config.autoload_paths += %W(#{config.root}/extras)', 'config.autoload_paths += Dir["#{config.root}/lib/**/"]'
90
+ end
91
+
92
+ def create_partials_directory
93
+ empty_directory 'app/views/application'
94
+ end
95
+
96
+ def create_shared_flashes
97
+ copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
98
+ end
99
+
100
+ def create_shared_javascripts
101
+ copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
102
+ end
103
+
104
+ def create_application_layout
105
+ template 'suspenders_layout.html.erb.erb',
106
+ 'app/views/layouts/application.html.erb',
107
+ :force => true
108
+ end
109
+
110
+ def use_postgres_config_template
111
+ template 'postgresql_database.yml.erb', 'config/database.yml',
112
+ :force => true
113
+ end
114
+
115
+ def replace_gemfile
116
+ remove_file 'Gemfile'
117
+ copy_file 'Gemfile_clean', 'Gemfile'
118
+ end
119
+
120
+ def set_ruby_to_version_being_used
121
+ inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
122
+ after: /source 'https:\/\/rubygems.org'/
123
+ end
124
+
125
+ def enable_database_cleaner
126
+ copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
127
+ end
128
+
129
+ def configure_rspec
130
+ remove_file '.rspec'
131
+ copy_file 'rspec', '.rspec'
132
+
133
+ config = <<-RUBY
134
+
135
+ # Hand-pick the generators we use
136
+ config.generators do |generate|
137
+ generate.test_framework :rspec
138
+ generate.helper false
139
+ generate.stylesheets false
140
+ generate.javascript_engine false
141
+ generate.request_specs false
142
+ generate.routing_specs false
143
+ generate.view_specs false
144
+ end
145
+
146
+ RUBY
147
+
148
+ inject_into_class 'config/application.rb', 'Application', config
149
+ end
150
+
151
+ def blacklist_active_record_attributes
152
+ replace_in_file 'config/application.rb',
153
+ 'config.active_record.whitelist_attributes = true',
154
+ 'config.active_record.whitelist_attributes = false'
155
+ end
156
+
157
+ def configure_strong_parameters
158
+ copy_file 'strong_parameters.rb', 'config/initializers/strong_parameters.rb'
159
+ end
160
+
161
+ def configure_time_zone
162
+ replace_in_file 'config/application.rb',
163
+ "# config.time_zone = 'Central Time (US & Canada)'",
164
+ "config.time_zone = 'Amsterdam'"
165
+ end
166
+
167
+ def configure_dutch_language
168
+ replace_in_file 'config/application.rb',
169
+ '# config.i18n.default_locale = :de',
170
+ "config.i18n.default_locale = :nl\n config.i18n.available_locales = :nl"
171
+ end
172
+
173
+ def configure_time_formats
174
+ copy_file 'config_locales_nl.yml', 'config/locales/nl.yml'
175
+ end
176
+
177
+ def configure_rack_timeout
178
+ copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
179
+ end
180
+
181
+ def configure_action_mailer
182
+ action_mailer_host 'development', "#{app_name}.dev"
183
+ action_mailer_host 'test', 'www.example.com'
184
+ action_mailer_host 'production', "#{app_name}.nl"
185
+ end
186
+
187
+ def generate_rspec
188
+ copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
189
+ end
190
+
191
+ def setup_foreman
192
+ copy_file 'sample.env', '.sample.env'
193
+ copy_file 'unicorn.rb', 'config/unicorn.rb'
194
+ copy_file 'Procfile', 'Procfile'
195
+ end
196
+
197
+ def setup_stylesheets
198
+ copy_file 'app/assets/stylesheets/application.css',
199
+ 'app/assets/stylesheets/application.css.scss'
200
+ remove_file 'app/assets/stylesheets/application.css'
201
+ end
202
+
203
+ def gitignore_files
204
+ concat_file 'suspenders_gitignore', '.gitignore'
205
+ [
206
+ 'spec/support',
207
+ 'spec/lib',
208
+ 'spec/features',
209
+ 'spec/models',
210
+ ].each do |dir|
211
+ empty_directory_with_gitkeep dir
212
+ end
213
+ end
214
+
215
+ def init_git
216
+ run 'git init'
217
+ run 'git add .'
218
+ run 'git commit -m "Initial commit" > /dev/null'
219
+ end
220
+
221
+ def create_heroku_apps
222
+ run "#{path_addition} heroku create #{app_name}-production --remote=production"
223
+ run "#{path_addition} heroku create #{app_name}-staging --remote=staging"
224
+ run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging"
225
+ end
226
+
227
+ def create_github_repo(repo_name)
228
+ run "#{path_addition} hub create #{repo_name}"
229
+ end
230
+
231
+ def copy_miscellaneous_files
232
+ copy_file 'errors.rb', 'config/initializers/errors.rb'
233
+ end
234
+
235
+ def customize_error_pages
236
+ meta_tags =<<-EOS
237
+ <meta charset='utf-8' />
238
+ <meta name='robots' content='noodp' />
239
+ EOS
240
+ style_tags =<<-EOS
241
+ <link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
242
+ EOS
243
+
244
+ %w(500 404 422).each do |page|
245
+ inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
246
+ replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
247
+ replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
248
+ end
249
+ end
250
+
251
+ def remove_routes_comment_lines
252
+ replace_in_file 'config/routes.rb',
253
+ /Application\.routes\.draw do.*end/m,
254
+ "Application.routes.draw do\nend"
255
+ end
256
+
257
+ def add_email_validator
258
+ copy_file 'email_validator.rb', 'app/validators/email_validator.rb'
259
+ end
260
+
261
+ def disable_xml_params
262
+ copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
263
+ end
264
+
265
+ def setup_default_rake_task
266
+ append_file 'Rakefile' do
267
+ "task(:default).clear\ntask :default => [:spec]"
268
+ end
269
+ end
270
+
271
+ end
272
+ end
@@ -0,0 +1,178 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Bretels
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql',
7
+ :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
8
+
9
+ class_option :heroku, :type => :boolean, :aliases => '-H', :default => false,
10
+ :desc => 'Create staging and production Heroku apps'
11
+
12
+ class_option :github, :type => :string, :aliases => '-G', :default => nil,
13
+ :desc => 'Create Github repository and add remote origin pointed to repo'
14
+
15
+ class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
16
+ :desc => 'Skip Test::Unit files'
17
+
18
+ def finish_template
19
+ invoke :suspenders_customization
20
+ super
21
+ end
22
+
23
+ def suspenders_customization
24
+ invoke :remove_files_we_dont_need
25
+ invoke :customize_gemfile
26
+ invoke :setup_development_environment
27
+ invoke :setup_test_environment
28
+ invoke :setup_production_environment
29
+ invoke :setup_staging_environment
30
+ invoke :create_suspenders_views
31
+ invoke :setup_database
32
+ invoke :configure_app
33
+ invoke :setup_stylesheets
34
+ invoke :copy_miscellaneous_files
35
+ invoke :customize_error_pages
36
+ invoke :remove_routes_comment_lines
37
+ invoke :setup_git
38
+ invoke :create_heroku_apps
39
+ invoke :create_github_repo
40
+ invoke :outro
41
+ end
42
+
43
+ def remove_files_we_dont_need
44
+ build :remove_public_index
45
+ build :remove_rails_logo_image
46
+ end
47
+
48
+ def setup_development_environment
49
+ say 'Setting up the development environment'
50
+ build :raise_delivery_errors
51
+ build :initialize_on_precompile
52
+ build :lib_in_load_path
53
+ end
54
+
55
+ def setup_test_environment
56
+ say 'Setting up the test environment'
57
+ build :enable_factory_girl_syntax
58
+ build :test_factories_first
59
+ build :generate_rspec
60
+ build :configure_rspec
61
+ build :enable_database_cleaner
62
+ build :generate_factories_file
63
+ end
64
+
65
+ def setup_production_environment
66
+ say 'Setting up the production environment'
67
+ build :configure_smtp
68
+ build :enable_force_ssl
69
+ build :add_cdn_settings
70
+ end
71
+
72
+ def setup_staging_environment
73
+ say 'Setting up the staging environment'
74
+ build :setup_staging_environment
75
+ end
76
+
77
+ def create_suspenders_views
78
+ say 'Creating suspenders views'
79
+ build :create_partials_directory
80
+ build :create_shared_flashes
81
+ build :create_shared_javascripts
82
+ build :create_application_layout
83
+ end
84
+
85
+ def customize_gemfile
86
+ build :replace_gemfile
87
+ build :set_ruby_to_version_being_used
88
+ end
89
+
90
+ def setup_database
91
+ say 'Setting up database'
92
+
93
+ if 'postgresql' == options[:database]
94
+ build :use_postgres_config_template
95
+ end
96
+ end
97
+
98
+ def configure_app
99
+ say 'Configuring app'
100
+ build :configure_action_mailer
101
+ build :blacklist_active_record_attributes
102
+ build :configure_strong_parameters
103
+ build :configure_time_zone
104
+ build :configure_time_formats
105
+ build :configure_dutch_language
106
+ build :configure_rack_timeout
107
+ build :disable_xml_params
108
+ build :add_email_validator
109
+ build :setup_default_rake_task
110
+ build :setup_foreman
111
+ end
112
+
113
+ def setup_stylesheets
114
+ say 'Set up stylesheets'
115
+ build :setup_stylesheets
116
+ end
117
+
118
+ def setup_git
119
+ say 'Initializing git'
120
+ invoke :setup_gitignore
121
+ invoke :init_git
122
+ end
123
+
124
+ def create_heroku_apps
125
+ if options[:heroku]
126
+ say 'Creating Heroku apps'
127
+ build :create_heroku_apps
128
+ end
129
+ end
130
+
131
+ def create_github_repo
132
+ if options[:github]
133
+ say 'Creating Github repo'
134
+ build :create_github_repo, options[:github]
135
+ end
136
+ end
137
+
138
+ def setup_gitignore
139
+ build :gitignore_files
140
+ end
141
+
142
+ def init_git
143
+ build :init_git
144
+ end
145
+
146
+ def copy_miscellaneous_files
147
+ say 'Copying miscellaneous support files'
148
+ build :copy_miscellaneous_files
149
+ end
150
+
151
+ def customize_error_pages
152
+ say 'Customizing the 500/404/422 pages'
153
+ build :customize_error_pages
154
+ end
155
+
156
+ def remove_routes_comment_lines
157
+ build :remove_routes_comment_lines
158
+ end
159
+
160
+ def outro
161
+ say 'Done. Congratulations!'
162
+ say '1. Run bundle install'
163
+ say '2. Run rake db:create'
164
+ say "3. Run exceptional install <api-key>"
165
+ end
166
+
167
+ def run_bundle
168
+ # Let's not: We'll bundle manually at the right spot
169
+ end
170
+
171
+ protected
172
+
173
+ def get_builder_class
174
+ Bretels::AppBuilder
175
+ end
176
+
177
+ end
178
+ end
@@ -0,0 +1,3 @@
1
+ module Bretels
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,40 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '3.2.12'
4
+ gem 'flutie'
5
+ gem 'jquery-rails'
6
+ gem 'pg'
7
+ gem 'rack-timeout'
8
+ gem 'strong_parameters'
9
+ gem 'unicorn'
10
+ gem 'rails-i18n'
11
+
12
+ group :assets do
13
+ gem 'coffee-rails'
14
+ gem 'sass-rails'
15
+ gem 'uglifier'
16
+ end
17
+
18
+ group :development do
19
+ gem 'foreman'
20
+ gem 'better_errors'
21
+ gem 'binding_of_caller'
22
+ gem 'quiet_assets'
23
+ gem 'letter_opener'
24
+ end
25
+
26
+ group :development, :test do
27
+ gem 'rspec-rails'
28
+ gem 'factory_girl_rails'
29
+ end
30
+
31
+ group :test do
32
+ gem 'capybara-webkit', '>= 0.14.1'
33
+ gem 'database_cleaner'
34
+ gem 'launchy'
35
+ end
36
+
37
+ group :staging, :production do
38
+ gem 'exceptional'
39
+ gem 'newrelic_rpm'
40
+ end
@@ -0,0 +1 @@
1
+ web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@@ -0,0 +1,9 @@
1
+ You look great with Bretels
2
+ ===========================
3
+
4
+ Use the following guides for getting things done, programming well, and
5
+ programming in style.
6
+
7
+ * [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
8
+ * [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
9
+ * [Style](http://github.com/thoughtbot/guides/blob/master/style)
@@ -0,0 +1,5 @@
1
+ <div id="flash">
2
+ <% flash.each do |key, value| -%>
3
+ <div id="flash_<%= key %>"><%= value %></div>
4
+ <% end -%>
5
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
4
+
5
+ <% if Rails.env.test? %>
6
+ <%= javascript_tag do %>
7
+ $.ajaxSetup({ async: false });
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Set up Rails app. Run this script immediately after cloning the codebase.
4
+ # https://github.com/thoughtbot/guides/tree/master/protocol
5
+
6
+ bundle install --binstubs=bin/stubs
7
+ bundle exec rake db:setup
8
+
9
+ if [ ! -f .env ]; then
10
+ cp .sample.env .env
11
+ fi
@@ -0,0 +1,11 @@
1
+ nl:
2
+ date:
3
+ formats:
4
+ default: '%d-%m-%Y'
5
+ with_weekday: '%a %d-%m-%y'
6
+
7
+ time:
8
+ formats:
9
+ default: '%a, %b %-d, %Y at %r'
10
+ date: '%b %-d, %Y'
11
+ short: '%B %d'
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:deletion)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, :js => true) do
11
+ DatabaseCleaner.strategy = :deletion
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ # Protect against injection attacks
2
+ # http://www.kb.cert.org/vuls/id/380039
3
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -0,0 +1,7 @@
1
+ class EmailValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
4
+ record.errors[attribute] << (options[:message] || "is not an email")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ require 'net/http'
2
+ require 'net/smtp'
3
+
4
+ # Example:
5
+ # begin
6
+ # some http call
7
+ # rescue *HTTP_ERRORS => error
8
+ # notify_hoptoad error
9
+ # end
10
+
11
+ HTTP_ERRORS = [Timeout::Error,
12
+ Errno::EINVAL,
13
+ Errno::ECONNRESET,
14
+ EOFError,
15
+ Net::HTTPBadResponse,
16
+ Net::HTTPHeaderSyntaxError,
17
+ Net::ProtocolError]
18
+
19
+ SMTP_SERVER_ERRORS = [TimeoutError,
20
+ IOError,
21
+ Net::SMTPUnknownError,
22
+ Net::SMTPServerBusy,
23
+ Net::SMTPAuthenticationError]
24
+
25
+ SMTP_CLIENT_ERRORS = [Net::SMTPFatalError,
26
+ Net::SMTPSyntaxError]
27
+
28
+ SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ # factory :user do
3
+ # sequence :email do |n|
4
+ # "user#{n}@factory.com"
5
+ # end
6
+ # password "password123"
7
+ # password_confirmation "password123"
8
+ # end
9
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'validate FactoryGirl factories' do
4
+ FactoryGirl.factories.each do |factory|
5
+ context "with factory for :#{factory.name}" do
6
+ subject { FactoryGirl.build(factory.name) }
7
+
8
+ it 'is valid' do
9
+ is_valid = subject.valid?
10
+ expect(is_valid).to be_true, subject.errors.full_messages.join(',')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,11 @@
1
+ development: &default
2
+ adapter: postgresql
3
+ database: <%= app_name %>_development
4
+ encoding: utf8
5
+ min_messages: warning
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ test:
10
+ <<: *default
11
+ database: <%= app_name %>_test
@@ -0,0 +1 @@
1
+ Rack::Timeout.timeout = (ENV['TIMEOUT_IN_SECONDS'] || 5).to_i
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,2 @@
1
+ # http://ddollar.github.com/foreman/
2
+ RACK_ENV=development
@@ -0,0 +1,16 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path("../../config/environment", __FILE__)
3
+ require 'rspec/rails'
4
+ require 'rspec/autorun'
5
+ require 'capybara/rspec'
6
+
7
+ Capybara.javascript_driver = :webkit
8
+
9
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ config.include FactoryGirl::Syntax::Methods
13
+ config.use_transactional_fixtures = false
14
+ config.infer_base_class_for_anonymous_controllers = false
15
+ config.order = "random"
16
+ end
@@ -0,0 +1,4 @@
1
+ load "config/environments/production.rb"
2
+
3
+ <%=app_const%>.configure do
4
+ end
@@ -0,0 +1 @@
1
+ ActiveRecord::Base.send :include, ActiveModel::ForbiddenAttributesProtection
@@ -0,0 +1,15 @@
1
+ /.bundle
2
+ /db/*.sqlite3
3
+ /log/*.log
4
+ /tmp
5
+ .sass-cache
6
+ !.keep
7
+ *.DS_Store
8
+ *.swp
9
+ .env
10
+ bin/stubs
11
+ coverage/*
12
+ public/system
13
+ rerun.txt
14
+ tags
15
+ vendor/bundler_gems
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="robots" content="noopd" />
7
+ <title><%%= page_title %></title>
8
+ <%%= stylesheet_link_tag :application, :media => 'all' %>
9
+ <%%= csrf_meta_tags %>
10
+ </head>
11
+
12
+ <body class="<%%= body_class %>">
13
+ <%%= render 'flashes' %>
14
+ <%%= yield %>
15
+ <%%= render 'javascript' %>
16
+ </body>
17
+
18
+ </html>
@@ -0,0 +1,24 @@
1
+ worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
2
+ timeout Integer(ENV['WEB_TIMEOUT'] || 15)
3
+ preload_app true
4
+
5
+ before_fork do |server, worker|
6
+
7
+ Signal.trap 'TERM' do
8
+ puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
9
+ Process.kill 'QUIT', Process.pid
10
+ end
11
+
12
+ defined?(ActiveRecord::Base) and
13
+ ActiveRecord::Base.connection.disconnect!
14
+ end
15
+
16
+ after_fork do |server, worker|
17
+
18
+ Signal.trap 'TERM' do
19
+ puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
20
+ end
21
+
22
+ defined?(ActiveRecord::Base) and
23
+ ActiveRecord::Base.establish_connection
24
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bretels
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - brightin
9
+ - thoughtbot
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-04-12 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - '='
21
+ - !ruby/object:Gem::Version
22
+ version: 3.2.12
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - '='
29
+ - !ruby/object:Gem::Version
30
+ version: 3.2.12
31
+ - !ruby/object:Gem::Dependency
32
+ name: bundler
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '1.1'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '1.1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: hub
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.10.2
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 1.10.2
63
+ description: ! 'Fork of thoughtbot''s Suspenders for use at Brightin.
64
+
65
+ '
66
+ email: developers@brightin.com
67
+ executables:
68
+ - bretels
69
+ extensions: []
70
+ extra_rdoc_files:
71
+ - README.md
72
+ - LICENSE
73
+ files:
74
+ - Gemfile
75
+ - Gemfile.lock
76
+ - LICENSE
77
+ - README.md
78
+ - Rakefile
79
+ - bin/bretels
80
+ - bretels.gemspec
81
+ - lib/bretels/actions.rb
82
+ - lib/bretels/app_builder.rb
83
+ - lib/bretels/generators/app_generator.rb
84
+ - lib/bretels/version.rb
85
+ - templates/Gemfile_clean
86
+ - templates/Procfile
87
+ - templates/README.md.erb
88
+ - templates/_flashes.html.erb
89
+ - templates/_javascript.html.erb
90
+ - templates/bin_setup
91
+ - templates/config_locales_nl.yml
92
+ - templates/database_cleaner_rspec.rb
93
+ - templates/disable_xml_params.rb
94
+ - templates/email_validator.rb
95
+ - templates/errors.rb
96
+ - templates/factories.rb
97
+ - templates/factories_spec.rb
98
+ - templates/factory_girl_syntax_rspec.rb
99
+ - templates/postgresql_database.yml.erb
100
+ - templates/rack_timeout.rb
101
+ - templates/rspec
102
+ - templates/sample.env
103
+ - templates/spec_helper.rb
104
+ - templates/staging.rb.erb
105
+ - templates/strong_parameters.rb
106
+ - templates/suspenders_gitignore
107
+ - templates/suspenders_layout.html.erb.erb
108
+ - templates/unicorn.rb
109
+ homepage: http://github.com/brightin/bretels
110
+ licenses: []
111
+ post_install_message:
112
+ rdoc_options:
113
+ - --charset=UTF-8
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ segments:
123
+ - 0
124
+ hash: -35484308327208431
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ segments:
132
+ - 0
133
+ hash: -35484308327208431
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 1.8.24
137
+ signing_key:
138
+ specification_version: 3
139
+ summary: Generate a Rails app using brightins's best practices.
140
+ test_files: []