orats 0.9.4 → 0.9.5

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: 4f2c27bb2c2a590489d6a99623e2d7f558d379d9
4
- data.tar.gz: 4094e0ed724bda3bb83c461afd5027009ea41807
3
+ metadata.gz: b087e4b8c21cbfe5c1dcea8b3216f91d1b1631ff
4
+ data.tar.gz: efc9b450b01b1f0417fa8eb8a164c169e6d99bce
5
5
  SHA512:
6
- metadata.gz: 380dd962f0246cb071c3bef38867bb1f0ed289ba796d9f95ff329e7a213766b61fec6573ded56bf9740c5d766584e280a2abe60c38b37c1f76b64fee0ef03769
7
- data.tar.gz: 148b5771f26520873df6bb54f098a96d02f011fbd7d4d2b262fbe196b6550e4a1b7b72064fd955f09c671149f1fdafa57ee6f14cc58fe2e4a0cbb8f3fd515306
6
+ metadata.gz: 4715024b5981df05313fb886f2672f456ec8a7c524dbc109e1159ecc76930cd22dc3a61d3ac1adb5387eb9e239cbb7ebdd3273f67be655e2eb88c0f2dc7292b0
7
+ data.tar.gz: eb6d7aadc7522f5cc0378ce780debf1e77ce2f60c94c9c6f422f8322c58e286359fef650f70004c567cd950ec2230867a5bd84e91b32280e4c9eb236455f0c60
data/README.md CHANGED
@@ -121,9 +121,10 @@ All of the changes have git commits to go with them. After generating a project
121
121
  - Use the `dotenv` gem to manage environment variables
122
122
  - Use `foreman` to manage the app's processes
123
123
  - Use `bullet`, `rack mini profiler` and `meta_request` for profiling/analysis
124
+ - Log everything to 1 file and rotate it
124
125
  - Set `scss`/`coffee` as the default generator engines
125
126
  - **Production mode only**:
126
- - Setup log rotation
127
+ - Log everything to 1 file and write the rails output to syslog
127
128
  - Add popular file types to the assets precompile list
128
129
  - Compress `css`/`js` when running `rake assets:precompile`
129
130
  - Change validation errors to output inline on each element instead of a big list
@@ -28,13 +28,11 @@ module Orats
28
28
  def custom_rails_template
29
29
  task 'Add custom template'
30
30
 
31
- if @options[:custom].include('://')
32
- url_to_string(@options[:custom])
33
- else
34
- file_to_string(@options[:custom])
35
- end
36
-
37
31
  rails_template '', "--skip --template #{@options[:custom]}"
32
+ run_from @target_path,
33
+ 'rm -rf app/assets/stylesheets/application.css'
34
+
35
+ commit 'Add custom template'
38
36
  end
39
37
 
40
38
  def rails_template_actions
@@ -9,10 +9,6 @@ require 'securerandom'
9
9
  # -----------------------------------------------------------------------------
10
10
  # private functions
11
11
  # -----------------------------------------------------------------------------
12
- def generate_token
13
- SecureRandom.hex(64)
14
- end
15
-
16
12
  def method_to_sentence(method)
17
13
  method.tr!('_', ' ')
18
14
  method[0] = method[0].upcase
@@ -63,7 +59,7 @@ def update_gemfile
63
59
  inject_into_file 'Gemfile', before: "\ngem 'kaminari'" do
64
60
  <<-S
65
61
 
66
- gem 'devise', '~> 3.2.4'
62
+ gem 'devise', '~> 3.3.0'
67
63
  gem 'devise-async', '~> 0.9.0'
68
64
  gem 'pundit', '~> 0.2.3'
69
65
  S
@@ -74,19 +70,12 @@ end
74
70
  def update_dotenv
75
71
  task __method__
76
72
 
77
- inject_into_file '.env', before: "\nSMTP_ADDRESS" do
78
- <<-CODE
79
- TOKEN_DEVISE_SECRET: #{generate_token}
80
- TOKEN_DEVISE_PEPPER: #{generate_token}
81
- CODE
82
- end
83
-
84
73
  inject_into_file '.env', before: "\nDATABASE_NAME" do
85
74
  <<-CODE
86
75
  ACTION_MAILER_DEVISE_DEFAULT_FROM: info@#{app_name}.com
87
76
  CODE
88
77
  end
89
- commit 'Add devise tokens and default e-mail'
78
+ commit 'Add devise default e-mail'
90
79
  end
91
80
 
92
81
  def run_bundle_install
@@ -141,14 +130,9 @@ def update_devise_initializer
141
130
  gsub_file 'config/initializers/devise.rb',
142
131
  "'please-change-me-at-config-initializers-devise@example.com'",
143
132
  "ENV['ACTION_MAILER_DEVISE_DEFAULT_EMAIL']"
144
- gsub_file 'config/initializers/devise.rb', /(?<=key = )'\w{128}'/,
145
- "ENV['TOKEN_DEVISE_SECRET']"
146
- gsub_file 'config/initializers/devise.rb', /(?<=pepper = )'\w{128}'/,
147
- "ENV['TOKEN_DEVISE_PEPPER']"
148
133
  gsub_file 'config/initializers/devise.rb',
149
134
  '# config.timeout_in = 30.minutes',
150
135
  'config.timeout_in = 2.hours'
151
-
152
136
  gsub_file 'config/initializers/devise.rb',
153
137
  '# config.expire_auth_token_on_timeout = false',
154
138
  'config.expire_auth_token_on_timeout = true'
@@ -165,7 +165,13 @@ def update_app_config
165
165
  # http://www.loc.gov/standards/iso639-2/php/English_list.php
166
166
  config.i18n.default_locale = ENV['DEFAULT_LOCALE'] unless ENV['DEFAULT_LOCALE'] == 'en'
167
167
 
168
+ # Log everything to a single file.
168
169
  config.paths['log'] = ENV['LOG_FILE']
170
+
171
+ # Rotate logs daily. This gets overwritten in staging/production by writing
172
+ # to syslog instead of a log file. Rotating in development prevents your
173
+ # log file from getting out of control in size.
174
+ config.logger = Logger.new(config.paths['log'].first, 'daily')
169
175
  S
170
176
  end
171
177
 
@@ -272,12 +278,23 @@ def update_production_environment
272
278
  task __method__
273
279
 
274
280
  inject_into_file 'config/environments/production.rb',
275
- after: "config.log_level = :info\n" do
281
+ before: "Rails.application.configure" do
276
282
  <<-'S'
277
- config.logger = Logger.new(config.paths['log'].first, 'daily')
283
+ require 'syslog/logger'
284
+
285
+ S
286
+ end
287
+
288
+ inject_into_file 'config/environments/production.rb',
289
+ after: "config.log_level = :info\n" do
290
+ <<-S
291
+
292
+ # Log to syslog.
293
+ config.log_tags = [ :subdomain, :uuid ]
294
+ config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new('#{app_name}'))
278
295
  S
279
296
  end
280
- commit 'Update the logger to rotate daily'
297
+ commit 'Update the logger to be tagged and sent to syslog'
281
298
 
282
299
  inject_into_file 'config/environments/production.rb',
283
300
  after: "%w( search.js )\n" do
@@ -51,7 +51,7 @@ BACKGROUND_THREADS: 5
51
51
  SERVICE: 'app_name'
52
52
 
53
53
  # the log file that both the app and sidekiq write to
54
- # in production you might consider /var/log/user.log to leverage syslog
54
+ # in production you might consider /var/log/app_name/app_name.log
55
55
  LOG_FILE: 'log/app_name.log'
56
56
 
57
57
  # the path that will contain pids and sockets
@@ -8,7 +8,7 @@
8
8
 
9
9
  <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
10
10
  <li>
11
- <%= link_to 'Sign up', new_registration_path(resource_name) %>
11
+ <%= link_to 'Register', new_registration_path(resource_name) %>
12
12
  </li>
13
13
  <% end -%>
14
14
 
@@ -35,4 +35,4 @@
35
35
  <li><%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %></li>
36
36
  <% end -%>
37
37
  <% end -%>
38
- </ul>
38
+ </ul>
@@ -1,4 +1,4 @@
1
1
  # set the version of this gem
2
2
  module Orats
3
- VERSION = '0.9.4'
3
+ VERSION = '0.9.5'
4
4
  end
@@ -38,6 +38,17 @@ class TestCLI < Minitest::Test
38
38
  assert_orats 'templates', 'auth'
39
39
  end
40
40
 
41
+ def test_new_with_custom
42
+ custom_file = "#{TEST_PATH}/custom_file.rb"
43
+ `mkdir -p #{TEST_PATH}`
44
+ File.open(custom_file, 'w') do |file|
45
+ file.write "file 'custom_file.rb', 'class CustomFile\nend'"
46
+ end
47
+
48
+ assert_new "--custom #{custom_file}"
49
+ assert_path "#{TEST_PATH}/#{@target_path}/custom_file.rb"
50
+ end
51
+
41
52
  def test_version
42
53
  assert_orats 'version', 'Orats'
43
54
  end
@@ -77,25 +88,6 @@ class TestCLI < Minitest::Test
77
88
  system "rm -rf #{TEST_PATH}"
78
89
  end
79
90
 
80
- def assert_count(input, regex, expected)
81
- assert input.scan(regex).size == expected,
82
- "Found #{input.scan(regex).size} matches for '#{regex}' but " + \
83
- "expected #{expected}"
84
- end
85
-
86
- def assert_in_file(file_path, match_regex)
87
- file_contents = `cat #{file_path}`
88
- assert_match(/#{match_regex}/, file_contents)
89
- end
90
-
91
- def assert_path(file_or_dir)
92
- assert File.exist?(file_or_dir), "Expected path '#{file_or_dir}' to exist"
93
- end
94
-
95
- def refute_path(file_or_dir)
96
- refute File.exist?(file_or_dir), "Expected path '#{file_or_dir}' to exist"
97
- end
98
-
99
91
  def capture_orats(command)
100
92
  out, err = capture_subprocess_io do
101
93
  orats "#{command} #{@target_path}", flags: @extra_flags
@@ -42,6 +42,27 @@ module Orats
42
42
  system "#{prepend_command} #{BINARY_PATH} #{command} #{options[:flags]}"
43
43
  end
44
44
 
45
+ def assert_count(input, regex, expected)
46
+ assert input.scan(regex).size == expected,
47
+ "Found #{input.scan(regex).size} matches for '#{regex}' but " + \
48
+ "expected #{expected}"
49
+ end
50
+
51
+ def assert_in_file(file_path, match_regex)
52
+ file_contents = `cat #{file_path}`
53
+ assert_match(/#{match_regex}/, file_contents)
54
+ end
55
+
56
+ def assert_path(file_or_dir)
57
+ assert File.exist?(file_or_dir),
58
+ "Expected path '#{file_or_dir}' to exist"
59
+ end
60
+
61
+ def refute_path(file_or_dir)
62
+ refute File.exist?(file_or_dir),
63
+ "Expected path '#{file_or_dir}' to exist"
64
+ end
65
+
45
66
  private
46
67
 
47
68
  def answer(options)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Janetakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-15 00:00:00.000000000 Z
11
+ date: 2014-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor