orats 0.9.7 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.rubocop.yml +24 -0
- data/.travis.yml +9 -0
- data/README.md +103 -194
- data/bin/orats +2 -5
- data/lib/orats/cli.rb +6 -67
- data/lib/orats/cli_help/destroy +11 -0
- data/lib/orats/cli_help/new +2 -26
- data/lib/orats/commands/new.rb +127 -0
- data/lib/orats/common.rb +0 -29
- data/lib/orats/templates/base/.dockerignore +5 -0
- data/lib/orats/templates/base/.gitignore +22 -0
- data/lib/orats/templates/base/.rubocop.yml +29 -0
- data/lib/orats/templates/base/Dockerfile +102 -0
- data/lib/orats/templates/base/Gemfile +69 -0
- data/lib/orats/templates/base/Gemfile.lock +205 -0
- data/lib/orats/templates/base/README.md +24 -0
- data/lib/orats/templates/base/Rakefile +7 -0
- data/lib/orats/templates/base/app/assets/config/manifest.js +3 -0
- data/lib/orats/templates/base/app/assets/images/.keep +0 -0
- data/lib/orats/templates/base/app/assets/javascripts/application.js +33 -0
- data/lib/orats/templates/base/app/assets/javascripts/cable.js +14 -0
- data/lib/orats/templates/base/app/assets/javascripts/channels/.keep +0 -0
- data/lib/orats/templates/base/app/assets/stylesheets/application.scss +89 -0
- data/lib/orats/templates/base/app/channels/application_cable/channel.rb +4 -0
- data/lib/orats/templates/base/app/channels/application_cable/connection.rb +4 -0
- data/lib/orats/templates/base/app/controllers/application_controller.rb +3 -0
- data/lib/orats/templates/base/app/controllers/concerns/.keep +0 -0
- data/lib/orats/templates/base/app/controllers/pages_controller.rb +4 -0
- data/lib/orats/templates/base/app/helpers/application_helper.rb +31 -0
- data/lib/orats/templates/base/app/helpers/pages_helper.rb +2 -0
- data/lib/orats/templates/base/app/jobs/application_job.rb +2 -0
- data/lib/orats/templates/base/app/mailers/application_mailer.rb +4 -0
- data/lib/orats/templates/base/app/models/application_record.rb +3 -0
- data/lib/orats/templates/base/app/models/concerns/.keep +0 -0
- data/lib/orats/templates/{includes/new/rails → base}/app/views/layouts/_flash.html.erb +1 -1
- data/lib/orats/templates/base/app/views/layouts/_footer.html.erb +3 -0
- data/lib/orats/templates/{includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb → base/app/views/layouts/_google_analytics.html.erb} +5 -9
- data/lib/orats/templates/{includes/new/rails → base}/app/views/layouts/_navigation.html.erb +5 -4
- data/lib/orats/templates/base/app/views/layouts/application.html.erb +48 -0
- data/lib/orats/templates/base/app/views/layouts/mailer.html.erb +13 -0
- data/lib/orats/templates/base/app/views/layouts/mailer.text.erb +1 -0
- data/lib/orats/templates/base/app/views/pages/home.html.erb +46 -0
- data/lib/orats/templates/base/bin/bundle +3 -0
- data/lib/orats/templates/base/bin/rails +4 -0
- data/lib/orats/templates/base/bin/rake +4 -0
- data/lib/orats/templates/base/bin/setup +34 -0
- data/lib/orats/templates/base/bin/update +29 -0
- data/lib/orats/templates/base/cable/config.ru +4 -0
- data/lib/orats/templates/base/config.ru +5 -0
- data/lib/orats/templates/base/config/application.rb +71 -0
- data/lib/orats/templates/base/config/boot.rb +3 -0
- data/lib/orats/templates/base/config/cable.yml +14 -0
- data/lib/orats/templates/base/config/database.yml +13 -0
- data/lib/orats/templates/base/config/environment.rb +5 -0
- data/lib/orats/templates/base/config/environments/development.rb +49 -0
- data/lib/orats/templates/base/config/environments/production.rb +56 -0
- data/lib/orats/templates/base/config/environments/staging.rb +6 -0
- data/lib/orats/templates/base/config/environments/test.rb +40 -0
- data/lib/orats/templates/base/config/initializers/application_controller_renderer.rb +6 -0
- data/lib/orats/templates/base/config/initializers/assets.rb +12 -0
- data/lib/orats/templates/base/config/initializers/backtrace_silencers.rb +9 -0
- data/lib/orats/templates/base/config/initializers/cookies_serializer.rb +5 -0
- data/lib/orats/templates/base/config/initializers/filter_parameter_logging.rb +4 -0
- data/lib/orats/templates/base/config/initializers/inflections.rb +16 -0
- data/lib/orats/templates/base/config/initializers/mime_types.rb +4 -0
- data/lib/orats/templates/base/config/initializers/new_framework_defaults.rb +27 -0
- data/lib/orats/templates/base/config/initializers/session_store.rb +4 -0
- data/lib/orats/templates/{includes/new/rails → base}/config/initializers/sidekiq.rb +1 -4
- data/lib/orats/templates/base/config/initializers/timeout.rb +1 -0
- data/lib/orats/templates/base/config/initializers/wrap_parameters.rb +15 -0
- data/lib/orats/templates/base/config/locales/en.yml +23 -0
- data/lib/orats/templates/base/config/puma.rb +60 -0
- data/lib/orats/templates/base/config/routes.rb +3 -0
- data/lib/orats/templates/{includes/new/rails → base}/config/secrets.yml +3 -2
- data/lib/orats/templates/base/config/sidekiq.yml.erb +5 -0
- data/lib/orats/templates/base/config/spring.rb +6 -0
- data/lib/orats/templates/base/db/seeds.rb +9 -0
- data/lib/orats/templates/base/docker-compose.yml +59 -0
- data/lib/orats/templates/base/lib/assets/.keep +0 -0
- data/lib/orats/templates/base/lib/tasks/.keep +0 -0
- data/lib/orats/templates/base/log/.keep +0 -0
- data/lib/orats/templates/base/public/404.html +67 -0
- data/lib/orats/templates/base/public/422.html +67 -0
- data/lib/orats/templates/base/public/500.html +66 -0
- data/lib/orats/templates/base/public/apple-touch-icon-precomposed.png +0 -0
- data/lib/orats/templates/base/public/apple-touch-icon.png +0 -0
- data/lib/orats/templates/base/public/favicon.ico +0 -0
- data/lib/orats/templates/base/public/robots.txt +5 -0
- data/lib/orats/templates/base/test/controllers/.keep +0 -0
- data/lib/orats/templates/base/test/controllers/pages_controller_test.rb +9 -0
- data/lib/orats/templates/base/test/fixtures/.keep +0 -0
- data/lib/orats/templates/base/test/fixtures/files/.keep +0 -0
- data/lib/orats/templates/base/test/helpers/.keep +0 -0
- data/lib/orats/templates/base/test/integration/.keep +0 -0
- data/lib/orats/templates/base/test/mailers/.keep +0 -0
- data/lib/orats/templates/base/test/models/.keep +0 -0
- data/lib/orats/templates/base/test/test_helper.rb +11 -0
- data/lib/orats/templates/base/tmp/.keep +0 -0
- data/lib/orats/templates/base/vendor/assets/javascripts/.keep +0 -0
- data/lib/orats/templates/base/vendor/assets/stylesheets/.keep +0 -0
- data/lib/orats/ui.rb +5 -5
- data/lib/orats/util.rb +14 -0
- data/lib/orats/version.rb +1 -1
- data/orats.gemspec +3 -2
- data/test/integration/cli_test.rb +43 -65
- data/test/test_helper.rb +9 -58
- metadata +114 -66
- data/lib/orats/argv_adjust.rb +0 -61
- data/lib/orats/cli_help/nuke +0 -19
- data/lib/orats/commands/new/exec.rb +0 -59
- data/lib/orats/commands/new/rails.rb +0 -215
- data/lib/orats/commands/new/server.rb +0 -67
- data/lib/orats/commands/nuke.rb +0 -108
- data/lib/orats/postgres.rb +0 -92
- data/lib/orats/process.rb +0 -35
- data/lib/orats/redis.rb +0 -25
- data/lib/orats/shell.rb +0 -12
- data/lib/orats/templates/auth.rb +0 -394
- data/lib/orats/templates/base.rb +0 -546
- data/lib/orats/templates/includes/common/.gitignore +0 -6
- data/lib/orats/templates/includes/common/LICENSE +0 -22
- data/lib/orats/templates/includes/new/rails/.env +0 -59
- data/lib/orats/templates/includes/new/rails/Gemfile +0 -48
- data/lib/orats/templates/includes/new/rails/Procfile +0 -3
- data/lib/orats/templates/includes/new/rails/README.md +0 -3
- data/lib/orats/templates/includes/new/rails/app/assets/favicon/favicon_base.png +0 -0
- data/lib/orats/templates/includes/new/rails/app/helpers/application_helper.rb +0 -53
- data/lib/orats/templates/includes/new/rails/app/models/account.rb +0 -40
- data/lib/orats/templates/includes/new/rails/app/views/devise/confirmations/new.html.erb +0 -26
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/reset_password_instructions.html.erb +0 -10
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/unlock_instructions.html.erb +0 -8
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/edit.html.erb +0 -28
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/new.html.erb +0 -26
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/edit.html.erb +0 -51
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/new.html.erb +0 -31
- data/lib/orats/templates/includes/new/rails/app/views/devise/sessions/new.html.erb +0 -39
- data/lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb +0 -38
- data/lib/orats/templates/includes/new/rails/app/views/devise/unlocks/new.html.erb +0 -26
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_comments_snippet.html.erb +0 -19
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_count_snippet.html.erb +0 -12
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_footer.html.erb +0 -2
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_auth.html.erb +0 -15
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_links.html.erb +0 -3
- data/lib/orats/templates/includes/new/rails/app/views/layouts/application.html.erb +0 -47
- data/lib/orats/templates/includes/new/rails/app/views/pages/home.html.erb +0 -58
- data/lib/orats/templates/includes/new/rails/config/database.yml +0 -6
- data/lib/orats/templates/includes/new/rails/config/environments/staging.rb +0 -5
- data/lib/orats/templates/includes/new/rails/config/initializers/devise_async.rb +0 -1
- data/lib/orats/templates/includes/new/rails/config/initializers/mini_profiler.rb +0 -4
- data/lib/orats/templates/includes/new/rails/config/puma.rb +0 -39
- data/lib/orats/templates/includes/new/rails/config/schedule.rb +0 -3
- data/lib/orats/templates/includes/new/rails/config/sidekiq.yml +0 -7
- data/lib/orats/templates/includes/new/rails/config/sitemap.rb +0 -20
- data/lib/orats/templates/includes/new/rails/config/unicorn.rb +0 -84
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/favicon.rake +0 -48
- data/lib/orats/templates/includes/new/rails/public/404.html +0 -13
- data/lib/orats/templates/includes/new/rails/public/422.html +0 -13
- data/lib/orats/templates/includes/new/rails/public/500.html +0 -13
- data/lib/orats/templates/includes/new/rails/public/502.html +0 -13
- data/lib/orats/templates/includes/new/rails/public/deploy.html +0 -14
- data/lib/orats/templates/includes/new/rails/test/fixtures/accounts.yml +0 -27
- data/lib/orats/templates/includes/new/rails/test/models/account_test.rb +0 -46
data/lib/orats/process.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module Orats
|
2
|
-
# manage detecting processes
|
3
|
-
module Process
|
4
|
-
def exit_if_process(detect_method, *processes)
|
5
|
-
result = process_detect(detect_method)
|
6
|
-
|
7
|
-
processes.each do |process|
|
8
|
-
task "Check if #{process} is available"
|
9
|
-
|
10
|
-
exit 1 if process_unusable?("#{result} #{process}", process)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def process_detect(method)
|
17
|
-
if method == :not_found
|
18
|
-
'which'
|
19
|
-
elsif method == :not_running
|
20
|
-
'ps cax | grep'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def process_unusable?(command, process)
|
25
|
-
out = run(command, capture: true)
|
26
|
-
|
27
|
-
if out.empty?
|
28
|
-
error "Cannot detect #{process}",
|
29
|
-
'trying to do `which` on it'
|
30
|
-
end
|
31
|
-
|
32
|
-
out.empty?
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/orats/redis.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Orats
|
2
|
-
# manage the redis process
|
3
|
-
module Redis
|
4
|
-
def redis_bin(bin_name = 'redis-cli')
|
5
|
-
exec = "#{bin_name} -h #{@options[:redis_location]}"
|
6
|
-
|
7
|
-
return exec if @options[:redis_password].empty?
|
8
|
-
exec << " -a #{@options[:redis_password]}"
|
9
|
-
end
|
10
|
-
|
11
|
-
def drop_namespace(namespace)
|
12
|
-
run "#{redis_bin} KEYS '#{namespace}:*'| " + \
|
13
|
-
"xargs --delim='\n' #{redis_bin} DEL"
|
14
|
-
end
|
15
|
-
|
16
|
-
def exit_if_redis_unreachable
|
17
|
-
task 'Check if you can ping redis'
|
18
|
-
|
19
|
-
return if run("#{redis_bin} ping")
|
20
|
-
|
21
|
-
error 'Cannot ping redis', 'attempt to PING'
|
22
|
-
exit 1
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/orats/shell.rb
DELETED
data/lib/orats/templates/auth.rb
DELETED
@@ -1,394 +0,0 @@
|
|
1
|
-
require 'securerandom'
|
2
|
-
|
3
|
-
# =============================================================================
|
4
|
-
# template for generating an orats auth project for rails 4.2.x
|
5
|
-
# =============================================================================
|
6
|
-
# view the task list at the bottom of the file
|
7
|
-
# -----------------------------------------------------------------------------
|
8
|
-
|
9
|
-
# -----------------------------------------------------------------------------
|
10
|
-
# private functions
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
def method_to_sentence(method)
|
13
|
-
method.tr!('_', ' ')
|
14
|
-
method[0] = method[0].upcase
|
15
|
-
method
|
16
|
-
end
|
17
|
-
|
18
|
-
def task(message, color = :blue)
|
19
|
-
puts
|
20
|
-
say_status 'task', set_color(message, :bold), color
|
21
|
-
end
|
22
|
-
|
23
|
-
def commit(message)
|
24
|
-
git add: '-A'
|
25
|
-
git commit: "-m '#{message}'"
|
26
|
-
end
|
27
|
-
|
28
|
-
def migrate(table_name, migration = '')
|
29
|
-
utc_now = Time.now.getutc.strftime('%Y%m%d%H%M%S')
|
30
|
-
class_name = table_name.to_s.classify.pluralize
|
31
|
-
|
32
|
-
file "db/migrate/#{utc_now}_create_#{table_name}.rb", %(
|
33
|
-
class Create#{class_name} < ActiveRecord::Migration
|
34
|
-
def change
|
35
|
-
#{migration}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def orats_to_local(source, dest = '')
|
42
|
-
dest = source if dest.empty?
|
43
|
-
|
44
|
-
base_path = "#{File.expand_path File.dirname(__FILE__)}/includes/new/rails"
|
45
|
-
|
46
|
-
run "mkdir -p #{File.dirname(dest)}" unless Dir.exist?(File.dirname(dest))
|
47
|
-
run "cp -f #{base_path}/#{source} #{dest}"
|
48
|
-
end
|
49
|
-
|
50
|
-
# ---
|
51
|
-
|
52
|
-
def delete_app_css
|
53
|
-
run 'rm -f app/assets/stylesheets/application.css'
|
54
|
-
end
|
55
|
-
|
56
|
-
def update_gemfile
|
57
|
-
task __method__
|
58
|
-
|
59
|
-
inject_into_file 'Gemfile', before: "\ngem 'kaminari'" do
|
60
|
-
<<-S
|
61
|
-
|
62
|
-
gem 'devise', '~> 3.4.1'
|
63
|
-
gem 'devise-async', '~> 0.9.0'
|
64
|
-
gem 'pundit', '~> 0.3.0'
|
65
|
-
S
|
66
|
-
end
|
67
|
-
commit 'Add authentication related gems'
|
68
|
-
end
|
69
|
-
|
70
|
-
def update_dotenv
|
71
|
-
task __method__
|
72
|
-
|
73
|
-
inject_into_file '.env', before: "\nDATABASE_NAME" do
|
74
|
-
<<-CODE
|
75
|
-
ACTION_MAILER_DEVISE_DEFAULT_FROM: info@#{app_name}.com
|
76
|
-
CODE
|
77
|
-
end
|
78
|
-
commit 'Add devise default e-mail'
|
79
|
-
end
|
80
|
-
|
81
|
-
def run_bundle_install
|
82
|
-
task __method__
|
83
|
-
|
84
|
-
run 'bundle install'
|
85
|
-
end
|
86
|
-
|
87
|
-
def add_pundit
|
88
|
-
task __method__
|
89
|
-
|
90
|
-
generate 'pundit:install'
|
91
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
92
|
-
after: "::Base\n" do
|
93
|
-
<<-S
|
94
|
-
include Pundit
|
95
|
-
|
96
|
-
S
|
97
|
-
end
|
98
|
-
|
99
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
100
|
-
after: ":exception\n" do
|
101
|
-
<<-S
|
102
|
-
|
103
|
-
rescue_from Pundit::NotAuthorizedError, with: :account_not_authorized
|
104
|
-
S
|
105
|
-
end
|
106
|
-
|
107
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
108
|
-
after: " #end\n" do
|
109
|
-
<<-S
|
110
|
-
|
111
|
-
def account_not_authorized
|
112
|
-
redirect_to request.headers['Referer'] || root_path, flash: { error: I18n.t('authorization.error') }
|
113
|
-
end
|
114
|
-
S
|
115
|
-
end
|
116
|
-
commit 'Add pundit policy and controller logic'
|
117
|
-
end
|
118
|
-
|
119
|
-
def add_devise_initializers
|
120
|
-
task __method__
|
121
|
-
|
122
|
-
orats_to_local 'config/initializers/devise_async.rb'
|
123
|
-
generate 'devise:install'
|
124
|
-
commit 'Add the devise and devise async initializers'
|
125
|
-
end
|
126
|
-
|
127
|
-
def update_devise_initializer
|
128
|
-
task 'Update the devise initializer'
|
129
|
-
|
130
|
-
gsub_file 'config/initializers/devise.rb',
|
131
|
-
"'please-change-me-at-config-initializers-devise@example.com'",
|
132
|
-
"ENV['ACTION_MAILER_DEVISE_DEFAULT_EMAIL']"
|
133
|
-
gsub_file 'config/initializers/devise.rb',
|
134
|
-
'# config.timeout_in = 30.minutes',
|
135
|
-
'config.timeout_in = 2.hours'
|
136
|
-
gsub_file 'config/initializers/devise.rb',
|
137
|
-
'# config.expire_auth_token_on_timeout = false',
|
138
|
-
'config.expire_auth_token_on_timeout = true'
|
139
|
-
gsub_file 'config/initializers/devise.rb',
|
140
|
-
'# config.lock_strategy = :failed_attempts',
|
141
|
-
'config.lock_strategy = :failed_attempts'
|
142
|
-
gsub_file 'config/initializers/devise.rb',
|
143
|
-
'# config.unlock_strategy = :both',
|
144
|
-
'config.unlock_strategy = :both'
|
145
|
-
gsub_file 'config/initializers/devise.rb', '# config.maximum_attempts = 20',
|
146
|
-
'config.maximum_attempts = 7'
|
147
|
-
gsub_file 'config/initializers/devise.rb', '# config.unlock_in = 1.hour',
|
148
|
-
'config.unlock_in = 2.hours'
|
149
|
-
gsub_file 'config/initializers/devise.rb',
|
150
|
-
'# config.last_attempt_warning = false',
|
151
|
-
'config.last_attempt_warning = true'
|
152
|
-
commit 'Update the devise defaults'
|
153
|
-
end
|
154
|
-
|
155
|
-
def update_sidekiq_config
|
156
|
-
task __method__
|
157
|
-
|
158
|
-
append_file 'config/sidekiq.yml' do
|
159
|
-
<<-S
|
160
|
-
- mailer
|
161
|
-
S
|
162
|
-
end
|
163
|
-
commit 'Add the devise mailer queue to sidekiq'
|
164
|
-
end
|
165
|
-
|
166
|
-
def update_routes
|
167
|
-
task __method__
|
168
|
-
|
169
|
-
gsub_file 'config/routes.rb', "mount Sidekiq::Web => '/sidekiq'\n", ''
|
170
|
-
inject_into_file 'config/routes.rb', after: "collection\n end\n" do
|
171
|
-
<<-S
|
172
|
-
|
173
|
-
# disable users from being able to register by uncommenting the lines below
|
174
|
-
# get 'accounts/sign_up(.:format)', to: redirect('/')
|
175
|
-
# post 'accounts(.:format)', to: redirect('/')
|
176
|
-
|
177
|
-
# disable users from deleting their own account by uncommenting the line below
|
178
|
-
# delete 'accounts(.:format)', to: redirect('/')
|
179
|
-
|
180
|
-
devise_for :accounts
|
181
|
-
|
182
|
-
authenticate :account, lambda { |account| account.is?(:admin) } do
|
183
|
-
mount Sidekiq::Web => '/sidekiq'
|
184
|
-
end
|
185
|
-
|
186
|
-
S
|
187
|
-
end
|
188
|
-
commit 'Add the devise route and protect sidekiq with authentication'
|
189
|
-
end
|
190
|
-
|
191
|
-
def add_en_locale_for_authorization
|
192
|
-
task __method__
|
193
|
-
|
194
|
-
gsub_file 'config/locales/en.yml', "hello: \"Hello world\"\n", ''
|
195
|
-
append_file 'config/locales/en.yml' do
|
196
|
-
<<-S
|
197
|
-
authorization:
|
198
|
-
error: 'You are not authorized to perform this action.'
|
199
|
-
S
|
200
|
-
end
|
201
|
-
commit 'Add en locale entry for authorization errors'
|
202
|
-
end
|
203
|
-
|
204
|
-
def add_devise_migration
|
205
|
-
task __method__
|
206
|
-
|
207
|
-
migrate :accounts, %{
|
208
|
-
create_table(:accounts) do |t|
|
209
|
-
## Database authenticatable
|
210
|
-
t.string :email, :null => false, :default => ''
|
211
|
-
t.string :encrypted_password, :null => false, :default => ''
|
212
|
-
|
213
|
-
## Recoverable
|
214
|
-
t.string :reset_password_token
|
215
|
-
t.datetime :reset_password_sent_at
|
216
|
-
|
217
|
-
## Rememberable
|
218
|
-
t.datetime :remember_created_at
|
219
|
-
|
220
|
-
## Trackable
|
221
|
-
t.integer :sign_in_count, :default => 0, :null => false
|
222
|
-
t.datetime :current_sign_in_at
|
223
|
-
t.datetime :last_sign_in_at
|
224
|
-
t.string :current_sign_in_ip
|
225
|
-
t.string :last_sign_in_ip
|
226
|
-
|
227
|
-
## Lockable
|
228
|
-
t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
229
|
-
t.string :unlock_token # Only if unlock strategy is :email or :both
|
230
|
-
t.datetime :locked_at
|
231
|
-
|
232
|
-
## Role
|
233
|
-
t.string :role, default: 'guest'
|
234
|
-
|
235
|
-
t.timestamps
|
236
|
-
end
|
237
|
-
|
238
|
-
add_index :accounts, :email, :unique => true
|
239
|
-
add_index :accounts, :reset_password_token, :unique => true
|
240
|
-
add_index :accounts, :unlock_token, :unique => true
|
241
|
-
}
|
242
|
-
commit 'Add devise model migration'
|
243
|
-
end
|
244
|
-
|
245
|
-
def add_account_model
|
246
|
-
task __method__
|
247
|
-
|
248
|
-
orats_to_local 'app/models/account.rb'
|
249
|
-
commit 'Add account model'
|
250
|
-
end
|
251
|
-
|
252
|
-
def add_seed_user
|
253
|
-
task __method__
|
254
|
-
|
255
|
-
append_file 'db/seeds.rb', "\nAccount.create({ email: " + \
|
256
|
-
" \"admin@#{app_name}.com\", password: \"password\",
|
257
|
-
role: \"admin\" })"
|
258
|
-
commit 'Add seed user'
|
259
|
-
end
|
260
|
-
|
261
|
-
def update_test_helper
|
262
|
-
task __method__
|
263
|
-
inject_into_file 'test/test_helper.rb', after: "end\n" do
|
264
|
-
<<-S
|
265
|
-
|
266
|
-
class ActionController::TestCase
|
267
|
-
include Devise::TestHelpers
|
268
|
-
end
|
269
|
-
S
|
270
|
-
end
|
271
|
-
commit 'Add devise test helper'
|
272
|
-
end
|
273
|
-
|
274
|
-
def add_account_fixtures
|
275
|
-
task __method__
|
276
|
-
orats_to_local 'test/fixtures/accounts.yml'
|
277
|
-
commit 'Add account fixtures'
|
278
|
-
end
|
279
|
-
|
280
|
-
def add_account_unit_tests
|
281
|
-
task __method__
|
282
|
-
|
283
|
-
orats_to_local 'test/models/account_test.rb'
|
284
|
-
commit 'Add account unit tests'
|
285
|
-
end
|
286
|
-
|
287
|
-
def add_current_user_alias
|
288
|
-
task __method__
|
289
|
-
|
290
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
291
|
-
after: "::Base\n" do
|
292
|
-
<<-S
|
293
|
-
alias_method :current_user, :current_account
|
294
|
-
|
295
|
-
S
|
296
|
-
end
|
297
|
-
commit 'Add current_user alias'
|
298
|
-
end
|
299
|
-
|
300
|
-
def add_devise_controller_override
|
301
|
-
task __method__
|
302
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
303
|
-
before: "end\n" do
|
304
|
-
<<-S
|
305
|
-
|
306
|
-
private
|
307
|
-
|
308
|
-
# override devise to customize the after sign in path
|
309
|
-
#def after_sign_in_path_for(resource)
|
310
|
-
# if resource.is? :admin
|
311
|
-
# admin_path
|
312
|
-
# else
|
313
|
-
# somewhere_path
|
314
|
-
# end
|
315
|
-
#end
|
316
|
-
S
|
317
|
-
end
|
318
|
-
commit 'Add devise after_sign_in_path_for override'
|
319
|
-
end
|
320
|
-
|
321
|
-
def add_devise_views
|
322
|
-
task __method__
|
323
|
-
|
324
|
-
orats_to_local 'app/views/devise/confirmations/new.html.erb'
|
325
|
-
orats_to_local 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
326
|
-
orats_to_local 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
327
|
-
orats_to_local 'app/views/devise/mailer/reset_password_instructions.html.erb'
|
328
|
-
orats_to_local 'app/views/devise/mailer/unlock_instructions.html.erb'
|
329
|
-
orats_to_local 'app/views/devise/passwords/edit.html.erb'
|
330
|
-
orats_to_local 'app/views/devise/passwords/new.html.erb'
|
331
|
-
orats_to_local 'app/views/devise/registrations/edit.html.erb'
|
332
|
-
orats_to_local 'app/views/devise/registrations/new.html.erb'
|
333
|
-
orats_to_local 'app/views/devise/sessions/new.html.erb'
|
334
|
-
orats_to_local 'app/views/devise/unlocks/new.html.erb'
|
335
|
-
orats_to_local 'app/views/devise/shared/_links.html.erb'
|
336
|
-
commit 'Add devise views'
|
337
|
-
end
|
338
|
-
|
339
|
-
def add_auth_links_to_the_navbar
|
340
|
-
task __method__
|
341
|
-
|
342
|
-
orats_to_local 'app/views/layouts/_navigation_auth.html.erb'
|
343
|
-
inject_into_file 'app/views/layouts/_navigation.html.erb',
|
344
|
-
after: "</ul>\n" do
|
345
|
-
<<-S
|
346
|
-
<ul class="nav navbar-nav nav-auth">
|
347
|
-
<%= render 'layouts/navigation_auth' %>
|
348
|
-
</ul>
|
349
|
-
S
|
350
|
-
end
|
351
|
-
|
352
|
-
append_file 'app/assets/stylesheets/application.scss' do
|
353
|
-
<<-S
|
354
|
-
|
355
|
-
@media (min-width: $screen-sm) {
|
356
|
-
.nav-auth {
|
357
|
-
float: right;
|
358
|
-
}
|
359
|
-
}
|
360
|
-
S
|
361
|
-
end
|
362
|
-
commit 'Add authentication links to the layout'
|
363
|
-
end
|
364
|
-
|
365
|
-
def remove_unused_files_from_git
|
366
|
-
task __method__
|
367
|
-
|
368
|
-
git add: '-u'
|
369
|
-
commit 'Remove unused files'
|
370
|
-
end
|
371
|
-
|
372
|
-
# ---
|
373
|
-
|
374
|
-
delete_app_css
|
375
|
-
update_gemfile
|
376
|
-
update_dotenv
|
377
|
-
run_bundle_install
|
378
|
-
add_pundit
|
379
|
-
add_devise_initializers
|
380
|
-
update_devise_initializer
|
381
|
-
update_sidekiq_config
|
382
|
-
update_routes
|
383
|
-
add_en_locale_for_authorization
|
384
|
-
add_devise_migration
|
385
|
-
add_account_model
|
386
|
-
add_seed_user
|
387
|
-
update_test_helper
|
388
|
-
add_account_fixtures
|
389
|
-
add_account_unit_tests
|
390
|
-
add_current_user_alias
|
391
|
-
add_devise_controller_override
|
392
|
-
add_devise_views
|
393
|
-
add_auth_links_to_the_navbar
|
394
|
-
remove_unused_files_from_git
|