gb-firestarter 0.3.1 → 0.4.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.
@@ -1,34 +1,37 @@
1
- require 'rails/generators'
2
- require 'rails/generators/rails/app/app_generator'
1
+ require "rails/generators"
2
+ require "rails/generators/rails/app/app_generator"
3
3
 
4
4
  module Firestarter
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('/')})"
5
+ class AppGenerator < Rails::Generators::AppGenerator # rubocop:disable Metrics/ClassLength
6
+ class_option :database, type: :string, aliases: "-d", default: "postgresql",
7
+ desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
8
8
 
9
- class_option :github, :type => :string, :aliases => '-G', :default => nil,
10
- :desc => 'Create Github repository and add remote origin pointed to repo'
9
+ class_option :github, type: :string, aliases: "-G", default: nil,
10
+ desc: "Create Github repository and add remote origin pointed to repo"
11
11
 
12
- class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
13
- :desc => 'Skip Test::Unit files'
12
+ class_option :skip_test_unit, type: :boolean, aliases: "-T", default: true,
13
+ desc: "Skip Test::Unit files"
14
+
15
+ class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
16
+ desc: "Don't run bundle install"
14
17
 
15
18
  def finish_template
16
19
  invoke :firestarter_customization
17
20
  super
18
21
  end
19
22
 
20
- def firestarter_customization
23
+ def firestarter_customization # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
21
24
  invoke :customize_gemfile
25
+ invoke :bundle_install
22
26
  invoke :setup_development_environment
23
27
  invoke :setup_test_environment
24
28
  invoke :setup_production_environment
25
29
  invoke :setup_staging_environment
26
30
  invoke :setup_secret_token
27
31
  invoke :create_firestarter_views
28
- invoke :setup_coffeescript
32
+ invoke :setup_javascript
29
33
  invoke :configure_app
30
34
  invoke :setup_stylesheets
31
- invoke :copy_miscellaneous_files
32
35
  invoke :customize_error_pages
33
36
  invoke :remove_routes_comment_lines
34
37
  invoke :setup_git
@@ -40,13 +43,12 @@ module Firestarter
40
43
  def customize_gemfile
41
44
  build :replace_gemfile
42
45
  build :set_ruby_to_version_being_used
43
- bundle_command 'install'
44
46
  end
45
47
 
46
48
  def setup_database
47
- say 'Setting up database'
49
+ say "Setting up database"
48
50
 
49
- if 'postgresql' == options[:database]
51
+ if "postgresql" == options[:database]
50
52
  build :use_postgres_config_template
51
53
  end
52
54
 
@@ -58,7 +60,7 @@ module Firestarter
58
60
  end
59
61
 
60
62
  def setup_development_environment
61
- say 'Setting up the development environment'
63
+ say "Setting up the development environment"
62
64
  build :raise_on_delivery_errors
63
65
  build :raise_on_unpermitted_parameters
64
66
  build :provide_setup_script
@@ -67,7 +69,7 @@ module Firestarter
67
69
  end
68
70
 
69
71
  def setup_test_environment
70
- say 'Setting up the test environment'
72
+ say "Setting up the test environment"
71
73
  build :enable_factory_girl_syntax
72
74
  build :test_factories_first
73
75
  build :generate_rspec
@@ -78,36 +80,38 @@ module Firestarter
78
80
  end
79
81
 
80
82
  def setup_production_environment
81
- say 'Setting up the production environment'
83
+ say "Setting up the production environment"
82
84
  build :configure_smtp
83
85
  build :enable_rack_deflater
84
86
  end
85
87
 
86
88
  def setup_staging_environment
87
- say 'Setting up the staging environment'
89
+ say "Setting up the staging environment"
88
90
  build :setup_staging_environment
89
91
  end
90
92
 
91
93
  def setup_secret_token
92
- say 'Moving secret token out of version control'
94
+ say "Moving secret token out of version control"
93
95
  build :setup_secret_token
94
96
  end
95
97
 
96
98
  def create_firestarter_views
97
- say 'Creating firestarter views'
99
+ say "Creating firestarter views"
98
100
  build :create_partials_directory
99
101
  build :create_shared_flashes
100
102
  build :create_shared_javascripts
101
103
  build :create_application_layout
102
104
  end
103
105
 
104
- def setup_coffeescript
105
- say 'Setting up CoffeeScript defaults'
106
+ def setup_javascript
107
+ say "Setting up JS defaults"
106
108
  build :remove_turbolinks
109
+ build :remove_require_tree
110
+ build :add_retina_tag
107
111
  end
108
112
 
109
- def configure_app
110
- say 'Configuring app'
113
+ def configure_app # rubocop:disable Metrics/MethodLength
114
+ say "Configuring app"
111
115
  build :configure_action_mailer
112
116
  build :configure_time_zone
113
117
  build :configure_time_formats
@@ -117,16 +121,17 @@ module Firestarter
117
121
  build :setup_default_rake_task
118
122
  build :configure_puma
119
123
  build :setup_foreman
124
+ build :use_rubocop_config
120
125
  end
121
126
 
122
127
  def setup_stylesheets
123
- say 'Set up stylesheets'
128
+ say "Set up stylesheets"
124
129
  build :setup_stylesheets
125
130
  end
126
131
 
127
132
  def setup_git
128
- if !options[:skip_git]
129
- say 'Initializing git'
133
+ unless options[:skip_git]
134
+ say "Initializing git"
130
135
  invoke :setup_gitignore
131
136
  invoke :init_git
132
137
  end
@@ -140,13 +145,8 @@ module Firestarter
140
145
  build :init_git
141
146
  end
142
147
 
143
- def copy_miscellaneous_files
144
- say 'Copying miscellaneous support files'
145
- build :copy_miscellaneous_files
146
- end
147
-
148
148
  def customize_error_pages
149
- say 'Customizing the 500/404/422 pages'
149
+ say "Customizing the 500/404/422 pages"
150
150
  build :customize_error_pages
151
151
  end
152
152
 
@@ -154,12 +154,12 @@ module Firestarter
154
154
  build :remove_routes_comment_lines
155
155
  end
156
156
 
157
- def outro
158
- say 'Congratulations! You just started a fire.'
157
+ def bundle_install
158
+ bundle_command "install"
159
159
  end
160
160
 
161
- def run_bundle
162
- # Let's not: We'll bundle manually at the right spot
161
+ def outro
162
+ say "Congratulations! You just started a fire."
163
163
  end
164
164
 
165
165
  def ruby_version_with_patch_level
@@ -168,7 +168,7 @@ module Firestarter
168
168
 
169
169
  protected
170
170
 
171
- def get_builder_class
171
+ def get_builder_class # rubocop:disable Style/AccessorMethodName
172
172
  Firestarter::AppBuilder
173
173
  end
174
174
 
@@ -177,8 +177,8 @@ module Firestarter
177
177
  end
178
178
 
179
179
  def patch_level
180
- if RUBY_PATCHLEVEL == 0 && RUBY_VERSION >= '2.1.0'
181
- ''
180
+ if RUBY_PATCHLEVEL == 0 && RUBY_VERSION >= "2.1.0"
181
+ ""
182
182
  else
183
183
  "-p#{RUBY_PATCHLEVEL}"
184
184
  end
@@ -1,4 +1,4 @@
1
1
  module Firestarter
2
- RAILS_VERSION = ENV['RAILS_VERSION'] || '4.2.0'
3
- VERSION = '0.3.1'
2
+ RAILS_VERSION = ENV["RAILS_VERSION"] || "4.2.0"
3
+ VERSION = "0.4.0"
4
4
  end
@@ -1,38 +1,36 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- feature 'Suspend a new project with default configuration' do
4
- scenario 'specs pass' do
3
+ RSpec.describe "ignite a new project with default configuration" do
4
+ before(:all) do
5
+ drop_dummy_database
6
+ remove_project_directory
5
7
  run_firestarter
8
+ setup_app_dependencies
9
+ end
6
10
 
11
+ it "passes the specs" do
7
12
  Dir.chdir(project_path) do
8
13
  Bundler.with_clean_env do
9
- expect(`rake`).to include('0 failures')
14
+ expect(`rake`).to include("0 failures")
10
15
  end
11
16
  end
12
17
  end
13
18
 
14
- scenario 'staging config is inherited from production' do
15
- run_firestarter
16
-
19
+ it "inherits the staging config from production" do
17
20
  staging_file = IO.read("#{project_path}/config/environments/staging.rb")
18
21
  config_stub = "Dummy::Application.configure do"
19
- expect(staging_file).to match(/^require_relative 'production'/)
22
+ expect(staging_file).to match(/^require_relative "production"/)
20
23
  expect(staging_file).to match(/#{config_stub}/), staging_file
21
24
  end
22
25
 
23
- if RUBY_PATCHLEVEL == 0 && RUBY_VERSION >= '2.1.0'
24
- scenario '.ruby-version does not include patchlevel for Ruby 2.1.0+' do
25
- run_firestarter
26
+ it "creates .ruby-version from Suspenders .ruby-version" do
27
+ ruby_version_file = IO.read("#{project_path}/.ruby-version")
28
+ expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
29
+ end
26
30
 
27
- ruby_version_file = IO.read("#{project_path}/.ruby-version")
28
- expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
29
- end
30
- else
31
- scenario '.ruby-version includes patchlevel for all pre-Ruby 2.1.0 versions' do
32
- run_firestarter
31
+ it "downloads a .rubocop.yml" do
32
+ rubocop_file = IO.read("#{project_path}/.rubocop.yml")
33
33
 
34
- ruby_version_file = IO.read("#{project_path}/.ruby-version")
35
- expect(ruby_version_file).to eq "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}\n"
36
- end
34
+ expect(rubocop_file).to match %r{Style/StringLiterals}
37
35
  end
38
36
  end
@@ -1,11 +1,11 @@
1
- require 'capybara/rspec'
2
- require 'bundler/setup'
1
+ require "capybara/rspec"
2
+ require "bundler/setup"
3
3
 
4
4
  Bundler.require(:default, :test)
5
5
 
6
- require (Pathname.new(__FILE__).dirname + '../lib/firestarter').expand_path
6
+ require File.join(Pathname.new(__FILE__).dirname, "../lib/firestarter")
7
7
 
8
- Dir['./spec/support/**/*.rb'].each { |file| require file }
8
+ Dir["./spec/support/**/*.rb"].each { |file| require file }
9
9
 
10
10
  RSpec.configure do |config|
11
11
  config.include FirestarterTestHelpers
@@ -13,9 +13,4 @@ RSpec.configure do |config|
13
13
  config.before(:all) do
14
14
  create_tmp_directory
15
15
  end
16
-
17
- config.before(:each) do
18
- drop_dummy_database
19
- remove_project_directory
20
- end
21
16
  end
@@ -1,5 +1,5 @@
1
1
  module FirestarterTestHelpers
2
- APP_NAME = 'dummy'
2
+ APP_NAME = "dummy"
3
3
 
4
4
  def remove_project_directory
5
5
  FileUtils.rm_rf(project_path)
@@ -12,15 +12,15 @@ module FirestarterTestHelpers
12
12
  def run_firestarter(arguments = nil)
13
13
  Dir.chdir(tmp_path) do
14
14
  Bundler.with_clean_env do
15
- ENV['TESTING'] = '1'
15
+ ENV["TESTING"] = "1"
16
16
 
17
- %x(#{firestarter_bin} #{APP_NAME} #{arguments})
17
+ `bundle exec #{firestarter_bin} #{APP_NAME} #{arguments}`
18
18
  end
19
19
  end
20
20
  end
21
21
 
22
22
  def drop_dummy_database
23
- if File.exists?(project_path)
23
+ if File.exist?(project_path)
24
24
  Dir.chdir(project_path) do
25
25
  Bundler.with_clean_env do
26
26
  `rake db:drop`
@@ -29,6 +29,16 @@ module FirestarterTestHelpers
29
29
  end
30
30
  end
31
31
 
32
+ def setup_app_dependencies
33
+ if File.exist?(project_path)
34
+ Dir.chdir(project_path) do
35
+ Bundler.with_clean_env do
36
+ `bundle check || bundle install`
37
+ end
38
+ end
39
+ end
40
+ end
41
+
32
42
  def project_path
33
43
  @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
34
44
  end
@@ -40,10 +50,10 @@ module FirestarterTestHelpers
40
50
  end
41
51
 
42
52
  def firestarter_bin
43
- File.join(root_path, 'bin', 'firestarter')
53
+ File.join(root_path, "bin", "firestarter")
44
54
  end
45
55
 
46
56
  def root_path
47
- File.expand_path('../../../', __FILE__)
57
+ File.expand_path("../../../", __FILE__)
48
58
  end
49
59
  end
@@ -1,56 +1,49 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- ruby '<%= RUBY_VERSION %>'
3
+ ruby "<%= RUBY_VERSION %>"
4
4
 
5
- gem 'bourbon'
6
- gem 'coffee-rails'
7
- gem 'dotenv-rails'
8
- gem 'email_validator'
9
- gem 'foreman'
10
- gem 'jquery-rails'
11
- gem 'pg'
12
- gem 'pry-rails'
13
- gem 'puma'
14
- gem 'rack-timeout'
15
- gem 'rails', '~> <%= Firestarter::RAILS_VERSION %>'
16
- gem 'recipient_interceptor'
17
- gem 'sass-rails'
18
- gem 'slim-rails'
19
- gem 'title'
20
- gem 'uglifier'
5
+ gem "clearance"
6
+ gem "foreman"
7
+ gem "jquery-rails"
8
+ gem "pg"
9
+ gem "pry-rails"
10
+ gem "puma"
11
+ gem "rails", "~> <%= Firestarter::RAILS_VERSION %>"
12
+ gem "retina_tag", github: "naps62/retina_tag", ref: "9389bec"
13
+ gem "sass-rails"
14
+ gem "slim-rails"
21
15
 
22
16
  group :development do
23
- gem 'better_errors'
24
- gem 'binding_of_caller'
25
- gem 'letter_opener'
17
+ gem "better_errors"
18
+ gem "binding_of_caller"
19
+ gem "letter_opener"
20
+ gem "quiet_assets"
21
+ gem "spring", require: false
22
+ gem "spring-commands-rspec", require: false
26
23
  end
27
24
 
28
25
  group :development, :test do
29
- gem 'awesome_print'
30
- gem 'factory_girl_rails'
31
- gem 'rspec-rails', '~> 3.0'
32
- gem 'rubocop', require: false
33
- gem 'scss_lint', require: false
26
+ gem "factory_girl_rails"
27
+ gem "pry-remote", github: "Mon-Ouie/pry-remote"
28
+ gem "rspec-rails", "~> 3.0"
29
+ gem "rubocop", require: false
30
+ gem "scss_lint", require: false
34
31
  end
35
32
 
36
33
  group :test do
37
- gem 'capybara-webkit', '>= 1.0.0'
38
- gem 'database_cleaner'
39
- gem 'launchy'
40
- gem 'simplecov', require: false
41
- gem 'timecop'
42
- gem 'webmock'
43
- end
34
+ gem "capybara"
35
+ gem "database_cleaner"
36
+ gem "simplecov", require: false
37
+ gem "timecop"
38
+ gem "webmock"
44
39
 
45
- group :production, :staging do
46
- gem 'rails_12factor'
40
+ install_if -> { `cat /etc/os-release 2> /dev/null` !~ /Arch Linux/ } do
41
+ gem "capybara-webkit"
42
+ end
47
43
  end
48
44
 
49
- group :deploy do
50
- gem 'capistrano', '~> 3.2.1', require: false
51
- gem 'capistrano-rails', require: false
52
- gem 'capistrano-rvm', require: false
53
- gem 'capistrano-bundler', require: false
54
- gem 'capistrano3-env', require: false
55
- gem 'capistrano-foreman', github: 'groupbuddies/capistrano-foreman', branch: :master
45
+ group :production, :staging do
46
+ gem "rack-timeout"
47
+ gem "rails_12factor"
48
+ gem "uglifier"
56
49
  end
@@ -7,7 +7,7 @@ RSpec.configure do |config|
7
7
  DatabaseCleaner.strategy = :transaction
8
8
  end
9
9
 
10
- config.before(:each, :js => true) do
10
+ config.before(:each, js: true) do
11
11
  DatabaseCleaner.strategy = :deletion
12
12
  end
13
13
 
@@ -1,9 +1,9 @@
1
1
  if Rails.env.development?
2
- require 'factory_girl'
2
+ require "factory_girl"
3
3
 
4
4
  namespace :dev do
5
- desc 'Seed data for development environment'
6
- task setup: 'db:setup' do
5
+ desc "Seed data for development environment"
6
+ task setup: "db:setup" do
7
7
  FactoryGirl.find_definitions
8
8
  include FactoryGirl::Syntax::Methods
9
9