orats 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,12 +14,12 @@ module Orats
14
14
  super
15
15
 
16
16
  @remote_galaxyfile = galaxyfile url_to_string(@remote_paths[:galaxyfile])
17
- @remote_inventory = inventory url_to_string(@remote_paths[:inventory])
18
- @remote_playbook = playbook url_to_string(@remote_paths[:playbook])
17
+ @remote_inventory = inventory url_to_string(@remote_paths[:inventory])
18
+ @remote_playbook = playbook url_to_string(@remote_paths[:playbook])
19
19
 
20
20
  @local_galaxyfile = galaxyfile file_to_string(@local_paths[:galaxyfile])
21
- @local_inventory = inventory file_to_string(@local_paths[:inventory])
22
- @local_playbook = playbook file_to_string(@local_paths[:playbook])
21
+ @local_inventory = inventory file_to_string(@local_paths[:inventory])
22
+ @local_playbook = playbook file_to_string(@local_paths[:playbook])
23
23
  end
24
24
 
25
25
  def init
@@ -45,7 +45,7 @@ module Orats
45
45
  role_parts = line.split('role:')
46
46
 
47
47
  # start at the actual role name
48
- line = role_parts[1]
48
+ line = role_parts[1]
49
49
 
50
50
  if line.include?(',')
51
51
  line = line.split(',').first
@@ -5,8 +5,8 @@ module Orats
5
5
 
6
6
  def log_task(message)
7
7
  puts
8
- say_status 'task', "#{message}:", :yellow
9
- puts '-'*80, ''; sleep 0.25
8
+ say_status 'task', "#{message}:", :yellow
9
+ puts '-'*80, ''; sleep 0.25
10
10
  end
11
11
 
12
12
  def log_status_top(type, message, color)
@@ -26,7 +26,7 @@ module Orats
26
26
 
27
27
  def log_error(top_label, top_message, bottom_label, bottom_message, strip_newline = false)
28
28
  log_status_top top_label, "#{top_message}:", :red
29
- log_status_bottom bottom_label, bottom_message , :yellow, strip_newline
29
+ log_status_bottom bottom_label, bottom_message, :yellow, strip_newline
30
30
  yield if block_given?
31
31
  end
32
32
 
@@ -21,8 +21,8 @@ end
21
21
 
22
22
  def log_task(message)
23
23
  puts
24
- say_status 'task', "#{method_to_sentence(message.to_s)}:", :yellow
25
- puts '-'*80, ''; sleep 0.25
24
+ say_status 'task', "#{method_to_sentence(message.to_s)}:", :yellow
25
+ puts '-'*80, ''; sleep 0.25
26
26
  end
27
27
 
28
28
  def git_commit(message)
@@ -31,7 +31,7 @@ def git_commit(message)
31
31
  end
32
32
 
33
33
  def migrate(table_name, migration='')
34
- utc_now = Time.now.getutc.strftime("%Y%m%d%H%M%S")
34
+ utc_now = Time.now.getutc.strftime("%Y%m%d%H%M%S")
35
35
  class_name = table_name.to_s.classify.pluralize
36
36
 
37
37
  file "db/migrate/#{utc_now}_create_#{table_name}.rb", %{
@@ -52,12 +52,13 @@ end
52
52
  def update_gemfile
53
53
  log_task __method__
54
54
 
55
- inject_into_file 'Gemfile', before: "\ngem 'kaminari'" do <<-S
55
+ inject_into_file 'Gemfile', before: "\ngem 'kaminari'" do
56
+ <<-S
56
57
 
57
58
  gem 'devise', '~> 3.2.4'
58
59
  gem 'devise-async', '~> 0.9.0'
59
60
  gem 'pundit', '~> 0.2.3'
60
- S
61
+ S
61
62
  end
62
63
  git_commit 'Add authentication related gems'
63
64
  end
@@ -65,15 +66,17 @@ end
65
66
  def update_dotenv
66
67
  log_task __method__
67
68
 
68
- inject_into_file '.env', before: "\nSMTP_ADDRESS" do <<-CODE
69
+ inject_into_file '.env', before: "\nSMTP_ADDRESS" do
70
+ <<-CODE
69
71
  TOKEN_DEVISE_SECRET: #{generate_token}
70
72
  TOKEN_DEVISE_PEPPER: #{generate_token}
71
- CODE
73
+ CODE
72
74
  end
73
75
 
74
- inject_into_file '.env', before: "\nDATABASE_NAME" do <<-CODE
76
+ inject_into_file '.env', before: "\nDATABASE_NAME" do
77
+ <<-CODE
75
78
  ACTION_MAILER_DEVISE_DEFAULT_FROM: info@#{app_name}.com
76
- CODE
79
+ CODE
77
80
  end
78
81
  git_commit 'Add devise tokens and default e-mail'
79
82
  end
@@ -88,24 +91,27 @@ def add_pundit
88
91
  log_task __method__
89
92
 
90
93
  generate 'pundit:install'
91
- inject_into_file 'app/controllers/application_controller.rb', after: "::Base\n" do <<-S
94
+ inject_into_file 'app/controllers/application_controller.rb', after: "::Base\n" do
95
+ <<-S
92
96
  include Pundit
93
97
 
94
- S
98
+ S
95
99
  end
96
100
 
97
- inject_into_file 'app/controllers/application_controller.rb', after: ":exception\n" do <<-S
101
+ inject_into_file 'app/controllers/application_controller.rb', after: ":exception\n" do
102
+ <<-S
98
103
 
99
104
  rescue_from Pundit::NotAuthorizedError, with: :account_not_authorized
100
- S
105
+ S
101
106
  end
102
107
 
103
- inject_into_file 'app/controllers/application_controller.rb', after: " #end\n" do <<-S
108
+ inject_into_file 'app/controllers/application_controller.rb', after: " #end\n" do
109
+ <<-S
104
110
 
105
111
  def account_not_authorized
106
112
  redirect_to request.headers['Referer'] || root_path, flash: { error: I18n.t('authorization.error') }
107
113
  end
108
- S
114
+ S
109
115
  end
110
116
  git_commit 'Add pundit policy and controller logic'
111
117
  end
@@ -146,9 +152,10 @@ end
146
152
  def update_sidekiq_config
147
153
  log_task __method__
148
154
 
149
- append_file 'config/sidekiq.yml' do <<-S
155
+ append_file 'config/sidekiq.yml' do
156
+ <<-S
150
157
  - mailer
151
- S
158
+ S
152
159
  end
153
160
  git_commit 'Add the devise mailer queue to sidekiq'
154
161
  end
@@ -157,7 +164,8 @@ def update_routes
157
164
  log_task __method__
158
165
 
159
166
  gsub_file 'config/routes.rb', "mount Sidekiq::Web => '/sidekiq'\n", ''
160
- inject_into_file 'config/routes.rb', after: "collection\n end\n" do <<-S
167
+ inject_into_file 'config/routes.rb', after: "collection\n end\n" do
168
+ <<-S
161
169
 
162
170
  # disable users from being able to register by uncommenting the lines below
163
171
  # get 'accounts/sign_up(.:format)', to: redirect('/')
@@ -172,7 +180,7 @@ def update_routes
172
180
  mount Sidekiq::Web => '/sidekiq'
173
181
  end
174
182
 
175
- S
183
+ S
176
184
  end
177
185
  git_commit 'Add the devise route and protect sidekiq with authentication'
178
186
  end
@@ -181,10 +189,11 @@ def add_en_locale_for_authorization
181
189
  log_task __method__
182
190
 
183
191
  gsub_file 'config/locales/en.yml', "hello: \"Hello world\"\n", ''
184
- append_file 'config/locales/en.yml' do <<-S
192
+ append_file 'config/locales/en.yml' do
193
+ <<-S
185
194
  authorization:
186
195
  error: 'You are not authorized to perform this action.'
187
- S
196
+ S
188
197
  end
189
198
  git_commit 'Add en locale entry for authorization errors'
190
199
  end
@@ -233,7 +242,8 @@ end
233
242
  def add_account_model
234
243
  log_task __method__
235
244
 
236
- file 'app/models/account.rb' do <<-'S'
245
+ file 'app/models/account.rb' do
246
+ <<-'S'
237
247
  class Account < ActiveRecord::Base
238
248
  ROLES = %w[admin guest]
239
249
 
@@ -274,7 +284,7 @@ class Account < ActiveRecord::Base
274
284
  Rails.cache.delete("account:#{id}")
275
285
  end
276
286
  end
277
- S
287
+ S
278
288
  end
279
289
  git_commit 'Add account model'
280
290
  end
@@ -289,19 +299,21 @@ end
289
299
 
290
300
  def update_test_helper
291
301
  log_task __method__
292
- inject_into_file 'test/test_helper.rb', after: "end\n" do <<-S
302
+ inject_into_file 'test/test_helper.rb', after: "end\n" do
303
+ <<-S
293
304
 
294
305
  class ActionController::TestCase
295
306
  include Devise::TestHelpers
296
307
  end
297
- S
308
+ S
298
309
  end
299
310
  git_commit 'Add devise test helper'
300
311
  end
301
312
 
302
313
  def add_account_fixtures
303
314
  log_task __method__
304
- file 'test/fixtures/accounts.yml' do <<-S
315
+ file 'test/fixtures/accounts.yml' do
316
+ <<-S
305
317
  foo:
306
318
  id: 1
307
319
  email: foo@bar.com
@@ -328,7 +340,7 @@ beep:
328
340
  email: beep@beep.com
329
341
  encrypted_password: beepbeepbeep
330
342
  created_at: 2010-03-6 05:15:45
331
- S
343
+ S
332
344
  end
333
345
  git_commit 'Add account fixtures'
334
346
  end
@@ -336,7 +348,8 @@ end
336
348
  def add_account_unit_tests
337
349
  log_task __method__
338
350
 
339
- file 'test/models/account_test.rb' do <<-S
351
+ file 'test/models/account_test.rb' do
352
+ <<-S
340
353
  require 'test_helper'
341
354
 
342
355
  class AccountTest < ActiveSupport::TestCase
@@ -383,7 +396,7 @@ class AccountTest < ActiveSupport::TestCase
383
396
  assert_equal 20, Account.generate_password(20).length
384
397
  end
385
398
  end
386
- S
399
+ S
387
400
  end
388
401
  git_commit 'Add account unit tests'
389
402
  end
@@ -391,17 +404,19 @@ end
391
404
  def add_current_user_alias
392
405
  log_task __method__
393
406
 
394
- inject_into_file 'app/controllers/application_controller.rb', after: "::Base\n" do <<-S
407
+ inject_into_file 'app/controllers/application_controller.rb', after: "::Base\n" do
408
+ <<-S
395
409
  alias_method :current_user, :current_account
396
410
 
397
- S
411
+ S
398
412
  end
399
413
  git_commit 'Add current_user alias'
400
414
  end
401
415
 
402
416
  def add_devise_controller_override
403
417
  log_task __method__
404
- inject_into_file 'app/controllers/application_controller.rb', before: "end\n" do <<-S
418
+ inject_into_file 'app/controllers/application_controller.rb', before: "end\n" do
419
+ <<-S
405
420
 
406
421
  private
407
422
 
@@ -413,7 +428,7 @@ def add_devise_controller_override
413
428
  # somewhere_path
414
429
  # end
415
430
  #end
416
- S
431
+ S
417
432
  end
418
433
  git_commit 'Add devise after_sign_in_path_for override'
419
434
  end
@@ -421,7 +436,8 @@ end
421
436
  def add_devise_views
422
437
  log_task __method__
423
438
 
424
- file 'app/views/devise/confirmations/new.html.erb' do <<-S
439
+ file 'app/views/devise/confirmations/new.html.erb' do
440
+ <<-S
425
441
  <%
426
442
  title 'Confirm'
427
443
  meta_description '...'
@@ -448,19 +464,21 @@ def add_devise_views
448
464
  <%= render 'devise/shared/links' %>
449
465
  </div>
450
466
  </div>
451
- S
467
+ S
452
468
  end
453
469
 
454
- file 'app/views/devise/mailer/confirmation_instructions.html.erb' do <<-S
470
+ file 'app/views/devise/mailer/confirmation_instructions.html.erb' do
471
+ <<-S
455
472
  <p>Welcome <%= @email %>!</p>
456
473
 
457
474
  <p>You can confirm your account email through the link below:</p>
458
475
 
459
476
  <p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
460
- S
477
+ S
461
478
  end
462
479
 
463
- file 'app/views/devise/mailer/reset_password_instructions.html.erb' do <<-S
480
+ file 'app/views/devise/mailer/reset_password_instructions.html.erb' do
481
+ <<-S
464
482
  <p>Hello <%= @resource.email %>!</p>
465
483
 
466
484
  <p>Someone has requested a link to change your password. You can do this through the link below.</p>
@@ -469,10 +487,11 @@ def add_devise_views
469
487
 
470
488
  <p>If you didn't request this, please ignore this email.</p>
471
489
  <p>Your password won't change until you access the link above and create a new one.</p>
472
- S
490
+ S
473
491
  end
474
492
 
475
- file 'app/views/devise/mailer/unlock_instructions.html.erb' do <<-S
493
+ file 'app/views/devise/mailer/unlock_instructions.html.erb' do
494
+ <<-S
476
495
  <p>Hello <%= @resource.email %>!</p>
477
496
 
478
497
  <p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
@@ -480,10 +499,11 @@ def add_devise_views
480
499
  <p>Click the link below to unlock your account:</p>
481
500
 
482
501
  <p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
483
- S
502
+ S
484
503
  end
485
504
 
486
- file 'app/views/devise/passwords/edit.html.erb' do <<-S
505
+ file 'app/views/devise/passwords/edit.html.erb' do
506
+ <<-S
487
507
  <%
488
508
  title 'Change your password'
489
509
  meta_description '...'
@@ -512,10 +532,11 @@ def add_devise_views
512
532
  <%= render 'devise/shared/links' %>
513
533
  </div>
514
534
  </div>
515
- S
535
+ S
516
536
  end
517
537
 
518
- file 'app/views/devise/passwords/new.html.erb' do <<-S
538
+ file 'app/views/devise/passwords/new.html.erb' do
539
+ <<-S
519
540
  <%
520
541
  title 'Forgot your password?'
521
542
  meta_description '...'
@@ -542,10 +563,11 @@ def add_devise_views
542
563
  <%= render 'devise/shared/links' %>
543
564
  </div>
544
565
  </div>
545
- S
566
+ S
546
567
  end
547
568
 
548
- file 'app/views/devise/registrations/edit.html.erb' do <<-S
569
+ file 'app/views/devise/registrations/edit.html.erb' do
570
+ <<-S
549
571
  <%
550
572
  title 'Edit your account'
551
573
  meta_description '...'
@@ -596,10 +618,11 @@ def add_devise_views
596
618
  </p>
597
619
  </div>
598
620
  </div>
599
- S
621
+ S
600
622
  end
601
623
 
602
- file 'app/views/devise/registrations/new.html.erb' do <<-S
624
+ file 'app/views/devise/registrations/new.html.erb' do
625
+ <<-S
603
626
  <%
604
627
  title 'Register a new account'
605
628
  meta_description '...'
@@ -631,10 +654,11 @@ def add_devise_views
631
654
  <%= render 'devise/shared/links' %>
632
655
  </div>
633
656
  </div>
634
- S
657
+ S
635
658
  end
636
659
 
637
- file 'app/views/devise/sessions/new.html.erb' do <<-S
660
+ file 'app/views/devise/sessions/new.html.erb' do
661
+ <<-S
638
662
  <%
639
663
  title 'Sign in'
640
664
  meta_description '...'
@@ -674,10 +698,11 @@ def add_devise_views
674
698
  <%= render 'devise/shared/links' %>
675
699
  </div>
676
700
  </div>
677
- S
701
+ S
678
702
  end
679
703
 
680
- file 'app/views/devise/unlocks/new.html.erb' do <<-S
704
+ file 'app/views/devise/unlocks/new.html.erb' do
705
+ <<-S
681
706
  <%
682
707
  title 'Re-send unlock instructions'
683
708
  meta_description '...'
@@ -704,10 +729,11 @@ def add_devise_views
704
729
  <%= render 'devise/shared/links' %>
705
730
  </div>
706
731
  </div>
707
- S
732
+ S
708
733
  end
709
734
 
710
- file 'app/views/devise/shared/_links.html.erb' do <<-'S'
735
+ file 'app/views/devise/shared/_links.html.erb' do
736
+ <<-'S'
711
737
  <%= content_tag(:h4, 'Or do something else') if controller_name != 'sessions' %>
712
738
  <ul>
713
739
  <%- if controller_name != 'sessions' %>
@@ -746,7 +772,7 @@ def add_devise_views
746
772
  <% end -%>
747
773
  <% end -%>
748
774
  </ul>
749
- S
775
+ S
750
776
  end
751
777
  git_commit 'Add devise views'
752
778
  end
@@ -772,21 +798,23 @@ def add_auth_links_to_the_navbar
772
798
  <% end %>
773
799
  S
774
800
 
775
- inject_into_file 'app/views/layouts/_navigation.html.erb', after: "</ul>\n" do <<-S
801
+ inject_into_file 'app/views/layouts/_navigation.html.erb', after: "</ul>\n" do
802
+ <<-S
776
803
  <ul class="nav navbar-nav nav-auth">
777
804
  <%= render 'layouts/navigation_auth' %>
778
805
  </ul>
779
- S
806
+ S
780
807
  end
781
808
 
782
- append_file 'app/assets/stylesheets/application.css.scss' do <<-S
809
+ append_file 'app/assets/stylesheets/application.css.scss' do
810
+ <<-S
783
811
 
784
812
  @media (min-width: $screen-sm) {
785
813
  .nav-auth {
786
814
  float: right;
787
815
  }
788
816
  }
789
- S
817
+ S
790
818
  end
791
819
  git_commit 'Add authentication links to the layout'
792
820
  end