orats 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/orats/commands/new/rails.rb +4 -6
- data/lib/orats/templates/auth.rb +2 -18
- data/lib/orats/templates/base.rb +20 -3
- data/lib/orats/templates/includes/new/rails/.env +1 -1
- data/lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb +2 -2
- data/lib/orats/version.rb +1 -1
- data/test/integration/cli_test.rb +11 -19
- data/test/test_helper.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b087e4b8c21cbfe5c1dcea8b3216f91d1b1631ff
|
4
|
+
data.tar.gz: efc9b450b01b1f0417fa8eb8a164c169e6d99bce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
-
|
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
|
data/lib/orats/templates/auth.rb
CHANGED
@@ -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.
|
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
|
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'
|
data/lib/orats/templates/base.rb
CHANGED
@@ -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
|
-
|
281
|
+
before: "Rails.application.configure" do
|
276
282
|
<<-'S'
|
277
|
-
|
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
|
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/
|
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 '
|
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>
|
data/lib/orats/version.rb
CHANGED
@@ -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
|
data/test/test_helper.rb
CHANGED
@@ -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
|
+
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-
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|