gimbal 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6a4a087627c5a4359e58b9f758b27faeccf2709
4
- data.tar.gz: f6bdc796fcbf1ac58efd2e9ee97cb9893803a341
3
+ metadata.gz: 9c9bec73840acda47571b6eb7d1391c7d1c9b260
4
+ data.tar.gz: 8894555a3a221376fe8a9096903470d72ac836aa
5
5
  SHA512:
6
- metadata.gz: dfbf4f726e4f23e2003f5f24fb4b4ff35adc8426adf78c67f211841c9459effc48338dd987e62599e6dfe7e573ad1fb8cf9e528dc03e00145d457258a7131d65
7
- data.tar.gz: 4332a53e6bac1eb0ea799031044e54cd45778760a07d68d8e1bc503d9e485050546e93aaf9c31b4de33fc5a98a175f3332b2b27ee343ebcd8c3d79ea13b7170d
6
+ metadata.gz: 995d3ecfa9e1d058d3e42ad793129582c86742ce0dd9b3ea7a94230d70ebcf03aa3ca5f77f706aaf49288843afc47a518a2c189fdc54752a7c6f5e5979d2fbad
7
+ data.tar.gz: 624476dea16243d2084d0482474f4bfbb84ff1e372d948178240b68cf08be38dcc057e56f6f6b9d7ff08570af9a41acde75bf9ac056b181d7daa282f509c1610
@@ -64,6 +64,38 @@ module Gimbal
64
64
  inject_into_class "config/application.rb", "Application", config
65
65
  end
66
66
 
67
+ def configure_generators
68
+ config = <<-RUBY
69
+
70
+ config.generators do |generate|
71
+ generate.helper false
72
+ generate.javascript_engine false
73
+ generate.request_specs false
74
+ generate.routing_specs false
75
+ generate.stylesheets false
76
+ generate.test_framework :rspec
77
+ generate.view_specs false
78
+ end
79
+
80
+ RUBY
81
+
82
+ inject_into_class 'config/application.rb', 'Application', config
83
+ end
84
+
85
+ def configure_i18n_for_missing_translations
86
+ raise_on_missing_translations_in("development")
87
+ raise_on_missing_translations_in("test")
88
+ end
89
+
90
+ def configure_i18n_for_test_environment
91
+ copy_file "i18n.rb", "spec/support/i18n.rb"
92
+ end
93
+
94
+ def configure_i18n_tasks
95
+ run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/"
96
+ copy_file "config_i18n_tasks.yml", "config/i18n-tasks.yml"
97
+ end
98
+
67
99
  def use_mysql_config_template
68
100
  template 'mysql_database.yml.erb', 'config/database.yml', force: true
69
101
  end
@@ -91,6 +123,10 @@ module Gimbal
91
123
  generate 'rspec:install'
92
124
  end
93
125
 
126
+ def configure_puma
127
+ copy_file "puma.rb", "config/puma.rb"
128
+ end
129
+
94
130
  def enable_database_cleaner
95
131
  copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
96
132
  end
@@ -117,10 +153,34 @@ module Gimbal
117
153
  copy_file "spec_helper.rb", "spec/spec_helper.rb"
118
154
  end
119
155
 
156
+ def create_partials_directory
157
+ empty_directory 'app/views/application'
158
+ end
159
+
160
+ def create_shared_flashes
161
+ copy_file "_flashes.html.erb", "app/views/application/_flashes.html.erb"
162
+ copy_file "flashes_helper.rb", "app/helpers/flashes_helper.rb"
163
+ end
164
+
165
+ def create_shared_javascripts
166
+ copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
167
+ end
168
+
169
+ def create_application_layout
170
+ template 'gimbal_layout.html.erb.erb',
171
+ 'app/views/layouts/application.html.erb',
172
+ force: true
173
+ end
174
+
120
175
  def create_database
121
176
  bundle_command 'exec rake db:create db:migrate'
122
177
  end
123
178
 
179
+ def configure_time_formats
180
+ remove_file "config/locales/en.yml"
181
+ template "config_locales_en.yml.erb", "config/locales/en.yml"
182
+ end
183
+
124
184
  def create_github_repo(repo_name)
125
185
  run "hub create #{repo_name}"
126
186
  end
@@ -128,11 +188,10 @@ module Gimbal
128
188
  def setup_spring
129
189
  bundle_command "exec spring binstub --all"
130
190
  end
131
- end
132
191
 
133
- def setup_default_rake_task
134
- append_file 'Rakefile' do
135
- <<-EOS
192
+ def setup_default_rake_task
193
+ append_file 'Rakefile' do
194
+ <<-EOS
136
195
  task(:default).clear
137
196
  task default: [:spec]
138
197
  if defined? RSpec
@@ -141,7 +200,21 @@ if defined? RSpec
141
200
  t.verbose = false
142
201
  end
143
202
  end
144
- EOS
203
+ EOS
204
+ end
205
+ end
206
+
207
+ def setup_bundler_audit
208
+ copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
209
+ append_file "Rakefile", %{\ntask default: "bundler:audit"\n}
210
+ end
211
+
212
+ private
213
+
214
+ def raise_on_missing_translations_in(environment)
215
+ config = 'config.action_view.raise_on_missing_translations = true'
216
+
217
+ uncomment_lines("config/environments/#{environment}.rb", config)
145
218
  end
146
219
  end
147
220
  end
@@ -30,10 +30,12 @@ module Gimbal
30
30
  invoke :setup_development_environment
31
31
  invoke :setup_test_environment
32
32
  invoke :setup_production_environment
33
+ invoke :create_gimbal_views
33
34
  invoke :configure_app
34
35
  invoke :setup_git
35
36
  invoke :setup_database
36
37
  invoke :create_github_repo
38
+ invoke :setup_bundler_audit
37
39
  invoke :setup_spring
38
40
  end
39
41
 
@@ -61,6 +63,8 @@ module Gimbal
61
63
  build :set_dev_mail_delivery_method
62
64
  build :add_bullet_gem_configuration
63
65
  build :raise_on_unpermitted_parameters
66
+ build :configure_generators
67
+ build :configure_i18n_for_missing_translations
64
68
  end
65
69
 
66
70
  def setup_test_environment
@@ -72,6 +76,8 @@ module Gimbal
72
76
  build :enable_database_cleaner
73
77
  build :provide_shoulda_matchers_config
74
78
  build :configure_spec_support_features
79
+ build :configure_i18n_for_test_environment
80
+ build :configure_i18n_tasks
75
81
  build :configure_action_mailer_in_specs
76
82
  end
77
83
 
@@ -80,9 +86,19 @@ module Gimbal
80
86
 
81
87
  end
82
88
 
89
+ def create_gimbal_views
90
+ say 'Creating gimbal views'
91
+ build :create_partials_directory
92
+ build :create_shared_flashes
93
+ build :create_shared_javascripts
94
+ build :create_application_layout
95
+ end
96
+
83
97
  def configure_app
84
98
  say 'Configuring app'
99
+ build :configure_time_formats
85
100
  build :setup_default_rake_task
101
+ build :configure_puma
86
102
  end
87
103
 
88
104
  def setup_git
@@ -97,6 +113,11 @@ module Gimbal
97
113
  build :gitignore_files
98
114
  end
99
115
 
116
+ def setup_bundler_audit
117
+ say "Setting up bundler-audit"
118
+ build :setup_bundler_audit
119
+ end
120
+
100
121
  def setup_spring
101
122
  say "Springifying binstubs"
102
123
  build :setup_spring
@@ -1,5 +1,5 @@
1
1
  module Gimbal
2
2
  RAILS_VERSION = '~> 4.2.0'
3
3
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
@@ -39,6 +39,22 @@ RSpec.describe "Create a new project with default config" do
39
39
  )
40
40
  end
41
41
 
42
+ it "configs development to raise on missing translations" do
43
+ dev_config = IO.read("#{project_path}/config/environments/development.rb")
44
+
45
+ expect(dev_config).to match(
46
+ /^ +config.action_view.raise_on_missing_translations = true/,
47
+ )
48
+ end
49
+
50
+ it "configs test to raise on missing translations" do
51
+ dev_config = IO.read("#{project_path}/config/environments/test.rb")
52
+
53
+ expect(dev_config).to match(
54
+ /^ +config.action_view.raise_on_missing_translations = true/,
55
+ )
56
+ end
57
+
42
58
  it "configs bullet gem in development" do
43
59
  dev_config = IO.read("#{project_path}/config/environments/development.rb")
44
60
 
@@ -55,6 +71,31 @@ RSpec.describe "Create a new project with default config" do
55
71
  )
56
72
  end
57
73
 
74
+ it "configures generators" do
75
+ result = IO.read("#{project_path}/config/application.rb")
76
+
77
+ expect(result).to match(/^ +generate.helper false$/)
78
+ expect(result).to match(/^ +generate.javascript_engine false$/)
79
+ expect(result).to match(/^ +generate.request_specs false$/)
80
+ expect(result).to match(/^ +generate.routing_specs false$/)
81
+ expect(result).to match(/^ +generate.stylesheets false$/)
82
+ expect(result).to match(/^ +generate.test_framework :rspec/)
83
+ expect(result).to match(/^ +generate.view_specs false/)
84
+ end
85
+
86
+ it "configures language in html element" do
87
+ layout_path = "/app/views/layouts/application.html.erb"
88
+ layout_file = IO.read("#{project_path}#{layout_path}")
89
+ expect(layout_file).to match(/<html lang="en">/)
90
+ end
91
+
92
+ it "evaluates en.yml.erb" do
93
+ locales_en_file = IO.read("#{project_path}/config/locales/en.yml")
94
+ app_name = GimbalTestHelpers::APP_NAME
95
+
96
+ expect(locales_en_file).to match(/application: #{app_name.humanize}/)
97
+ end
98
+
58
99
  it "adds support file for action mailer" do
59
100
  expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
60
101
  end
@@ -71,6 +112,18 @@ RSpec.describe "Create a new project with default config" do
71
112
  expect(File).to exist("#{project_path}/spec/support/shoulda_matchers.rb")
72
113
  end
73
114
 
115
+ it "adds support file for i18n" do
116
+ expect(File).to exist("#{project_path}/spec/support/i18n.rb")
117
+ end
118
+
119
+ it "adds specs for missing or unused translations" do
120
+ expect(File).to exist("#{project_path}/spec/i18n_spec.rb")
121
+ end
122
+
123
+ it "configs i18n-tasks" do
124
+ expect(File).to exist("#{project_path}/config/i18n-tasks.yml")
125
+ end
126
+
74
127
  it "creates .ruby-version from Gimbal .ruby-version" do
75
128
  ruby_version_file = IO.read("#{project_path}/.ruby-version")
76
129
 
@@ -12,7 +12,7 @@ gem "jquery-rails"
12
12
  # gem "newrelic_rpm", ">= 3.9.8"
13
13
  gem "normalize-rails", "~> 3.0.0"
14
14
  gem "mysql2"
15
- # gem "puma"
15
+ gem "puma"
16
16
  # gem "rack-canonical-host"
17
17
  gem "rails", "<%= Gimbal::RAILS_VERSION %>"
18
18
  # gem "recipient_interceptor"
@@ -31,19 +31,19 @@ end
31
31
  group :development, :test do
32
32
  gem "awesome_print"
33
33
  gem "bullet"
34
- # gem "bundler-audit", require: false
34
+ gem "bundler-audit", require: false
35
35
  gem "byebug"
36
- # gem "dotenv-rails"
36
+ gem "dotenv-rails"
37
37
  gem "factory_girl_rails"
38
38
  gem "i18n-tasks"
39
- # gem "pry-rails"
39
+ gem "pry-rails"
40
40
  gem "rspec-rails", "~> 3.3.0"
41
41
  end
42
42
 
43
43
  group :test do
44
44
  # gem "capybara-webkit"
45
45
  gem "database_cleaner"
46
- # gem "formulaic"
46
+ gem "formulaic"
47
47
  gem "launchy"
48
48
  gem "shoulda-matchers"
49
49
  gem "simplecov", require: false
@@ -0,0 +1,7 @@
1
+ <% if flash.any? %>
2
+ <div class="flashes">
3
+ <% user_facing_flashes.each do |key, value| -%>
4
+ <div class="flash-<%= key %>"><%= value %></div>
5
+ <% end -%>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
4
+
5
+ <%= render "analytics" %>
6
+
7
+ <% if Rails.env.test? %>
8
+ <%= javascript_tag do %>
9
+ $.fx.off = true;
10
+ $.ajaxSetup({ async: false });
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "bundler/audit/cli"
3
+
4
+ namespace :bundler do
5
+ desc "Updates the ruby-advisory-db and runs audit"
6
+ task :audit do
7
+ %w(update check).each do |command|
8
+ Bundler::Audit::CLI.start [command]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ search:
2
+ paths:
3
+ - "app/controllers"
4
+ - "app/helpers"
5
+ - "app/presenters"
6
+ - "app/views"
7
+
8
+ ignore_unused:
9
+ - activerecord.*
10
+ - date.*
11
+ - simple_form.*
12
+ - time.*
13
+ - titles.*
@@ -0,0 +1,19 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default:
5
+ "%m/%d/%Y"
6
+ with_weekday:
7
+ "%a %m/%d/%y"
8
+
9
+ time:
10
+ formats:
11
+ default:
12
+ "%a, %b %-d, %Y at %r"
13
+ date:
14
+ "%b %-d, %Y"
15
+ short:
16
+ "%B %d"
17
+
18
+ titles:
19
+ application: <%= app_name.humanize %>
@@ -0,0 +1,5 @@
1
+ module FlashesHelper
2
+ def user_facing_flashes
3
+ flash.to_hash.slice("alert", "error", "notice", "success")
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="<%= I18n.locale %>">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="ROBOTS" content="NOODP" />
6
+ <meta name="viewport" content="initial-scale=1" />
7
+ <%%#
8
+ Configure default and controller-, and view-specific titles in
9
+ config/locales/en.yml. For more see:
10
+ https://github.com/calebthompson/title#usage
11
+ %>
12
+ <title><%%= title %></title>
13
+ <%%= stylesheet_link_tag :application, media: "all" %>
14
+ <%%= csrf_meta_tags %>
15
+ </head>
16
+ <body class="<%%= body_class %>">
17
+ <%%= render "flashes" -%>
18
+ <%%= yield %>
19
+ <%%= render "javascript" %>
20
+ </body>
21
+ </html>
data/templates/i18n.rb ADDED
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include AbstractController::Translation
3
+ end
data/templates/puma.rb ADDED
@@ -0,0 +1,28 @@
1
+ # https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server
2
+
3
+ # The environment variable WEB_CONCURRENCY may be set to a default value based
4
+ # on dyno size. To manually configure this value use heroku config:set
5
+ # WEB_CONCURRENCY.
6
+ #
7
+ # Increasing the number of workers will increase the amount of resting memory
8
+ # your dynos use. Increasing the number of threads will increase the amount of
9
+ # potential bloat added to your dynos when they are responding to heavy
10
+ # requests.
11
+ #
12
+ # Starting with a low number of workers and threads provides adequate
13
+ # performance for most applications, even under load, while maintaining a low
14
+ # risk of overusing memory.
15
+ workers Integer(ENV.fetch("WEB_CONCURRENCY", 2))
16
+ threads_count = Integer(ENV.fetch("MAX_THREADS", 2))
17
+ threads(threads_count, threads_count)
18
+
19
+ preload_app!
20
+
21
+ rackup DefaultRackup
22
+ environment ENV.fetch("RACK_ENV", "development")
23
+
24
+ on_worker_boot do
25
+ # Worker specific setup for Rails 4.1+
26
+ # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
27
+ ActiveRecord::Base.establish_connection
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimbal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Pascoe
@@ -96,11 +96,20 @@ files:
96
96
  - spec/support/fake_github.rb
97
97
  - spec/support/gimbal.rb
98
98
  - templates/Gemfile.erb
99
+ - templates/_flashes.html.erb
100
+ - templates/_javascript.html.erb
99
101
  - templates/action_mailer.rb
102
+ - templates/bundler_audit.rake
103
+ - templates/config_i18n_tasks.yml
104
+ - templates/config_locales_en.yml.erb
100
105
  - templates/database_cleaner_rspec.rb
101
106
  - templates/factory_girl_rspec.rb
107
+ - templates/flashes_helper.rb
102
108
  - templates/gimbal_gitignore
109
+ - templates/gimbal_layout.html.erb.erb
110
+ - templates/i18n.rb
103
111
  - templates/mysql_database.yml.erb
112
+ - templates/puma.rb
104
113
  - templates/rails_helper.rb
105
114
  - templates/shoulda_matchers_config_rspec.rb
106
115
  - templates/spec_helper.rb