capistrano-ops 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11e337322ee460de5e0abca9879513190ccb1eaf57ebf338b5575efcd4f7eb33
4
- data.tar.gz: 59f16b666897fdd8f93f21d0d7d91590e394fdfa4f9c942accb84be8720c94d7
3
+ metadata.gz: e7944bee1bc903f6dc873cac78ac255e7811341c1c8bf291de8cf0c2bc2a01a4
4
+ data.tar.gz: 49afc833c49c3b2d01009c2a7f13fa5a59e04b70691d9baac51ac292f6101240
5
5
  SHA512:
6
- metadata.gz: aafa5d8ed0745ac496462fb42840381dd3104478b77eac904b19b1959f94ea14d3d06fc7cccc62cbfa072aa0a7a36c945d49acd4eef6e23322a12a2e45b55247
7
- data.tar.gz: b1c212fcf862c2635b9a079cf3c2eb72095b2f6a4c26d918dd971db550e7a2f5f2a55a27495042b66622a64931dab6059038bba66011dfa50bc82f4f532ddf80
6
+ metadata.gz: b02060e7adb1a90050839b35cb86e3e19d1b5a32b09b723ce9f10933afb99a347b9a83ed0cea99e344c972262ba01db9f455f668385c493f2cf919e29bd9a5ab
7
+ data.tar.gz: d2e61ed960c9a4c37411b23e63f4e05faeb9047c613a1038ac38bf5eab5a5ae50d220dabec34c6f2bca539f9190180fc3d426e248273ecf27655dc5eb36bee4a
@@ -1,18 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'capistrano/ops/helper'
3
+ require 'capistrano/ops/task_loader'
4
4
  require 'capistrano/ops/backup/helper'
5
5
 
6
- module TaskLoader
7
- extend Capistrano::Ops::Helper
8
-
9
- def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
10
- if gem_in_gemfile?(gem_name)
11
- Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
12
- else
13
- puts warning_message
14
- end
15
- end
16
- end
17
-
18
6
  TaskLoader.load_tasks_if_gem_present('rails', 'backup/tasks', 'WARNING: Gemfile does not include rails gem which is required for backup tasks')
@@ -1,29 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'capistrano/ops/helper'
3
+ require 'capistrano/ops/task_loader'
4
4
  require 'capistrano/ops/figaro_yml/paths'
5
5
  require 'capistrano/ops/figaro_yml/helpers'
6
6
 
7
- module TaskLoader
8
- extend Capistrano::Ops::Helper
9
-
10
- def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
11
- if gem_in_gemfile?(gem_name)
12
- Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
13
- else
14
- puts warning_message
15
- end
16
- end
17
- end
18
-
19
7
  TaskLoader.load_tasks_if_gem_present('figaro', 'figaro_yml/tasks', 'WARNING: Gemfile does not include figaro gem which is required for figaro_yml tasks')
20
- # include Capistrano::Ops::Helper
21
-
22
- # Dir.glob("#{File.expand_path(__dir__)}/figaro_yml/tasks/*.rake").each { |f| load f }
23
-
24
- # # gem 'figaro' is required for figaro_yml tasks
25
-
26
- # figaro_gem = gem_in_gemfile?('figaro')
27
-
28
- # # check if Gemfile environment includes figaro gem and warn user if not found
29
- # puts 'WARNING: Gemfile does not include figaro gem which is required for figaro_yml tasks' unless figaro_gem
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Capistrano
2
4
  module Ops
3
5
  module Helper
4
6
  def gem_in_gemfile?(gem_name)
5
- if File.exist?('Gemfile')
6
- File.foreach('Gemfile') do |line|
7
- return true if line.include?('gem') && line.include?("'#{gem_name}'") && !line.include?('#')
8
- end
9
- end
10
- false
7
+ return false unless File.exist?('Gemfile')
8
+
9
+ regex = Regexp.new("^\s*gem\s+['\"]#{gem_name}['\"].*?(?=#|$)", Regexp::MULTILINE)
10
+ File.read('Gemfile').match?(regex)
11
11
  end
12
12
  end
13
13
  end
@@ -1,19 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'capistrano/ops/helper'
3
+ require 'capistrano/ops/task_loader'
4
4
  require 'capistrano/ops/logrotate/helpers'
5
5
  require 'capistrano/ops/logrotate/paths'
6
6
 
7
- module TaskLoader
8
- extend Capistrano::Ops::Helper
9
-
10
- def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
11
- if gem_in_gemfile?(gem_name)
12
- Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
13
- else
14
- puts warning_message
15
- end
16
- end
17
- end
18
-
19
7
  TaskLoader.load_tasks_if_gem_present('whenever', 'logrotate/tasks', 'WARNING: Gemfile does not include whenever gem which is required for logrotate tasks')
@@ -1,18 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'capistrano/ops/helper'
3
+ require 'capistrano/ops/task_loader'
4
4
  require 'capistrano/ops/logs/paths'
5
5
  require 'capistrano/ops/logs/helpers'
6
6
 
7
- module TaskLoader
8
- extend Capistrano::Ops::Helper
9
- def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
10
- if gem_in_gemfile?(gem_name)
11
- Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
12
- else
13
- puts warning_message
14
- end
15
- end
16
- end
17
-
18
7
  TaskLoader.load_tasks_if_gem_present('rails', 'logs/tasks', 'WARNING: Gemfile does not include rails gem which is required for logs tasks')
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'capistrano/ops/helper'
4
+
5
+ module TaskLoader
6
+ extend Capistrano::Ops::Helper
7
+
8
+ def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
9
+ unless gem_in_gemfile?(gem_name)
10
+ warn warning_message
11
+ return
12
+ end
13
+
14
+ base_path = File.expand_path(__dir__)
15
+ task_files = Dir.glob("#{base_path}/#{task_path}/**/*.rake")
16
+
17
+ task_files.each do |file|
18
+ load file
19
+ rescue StandardError => e
20
+ puts "Failed to load #{file}: #{e.message}"
21
+ end
22
+ end
23
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capistrano
4
4
  module Ops
5
- VERSION = '1.0.2'
5
+ VERSION = '1.0.3'
6
6
  end
7
7
  end
@@ -1,17 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'capistrano/ops/helper'
3
+ require 'capistrano/ops/task_loader'
4
4
 
5
- module TaskLoader
6
- extend Capistrano::Ops::Helper
7
-
8
- def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
9
- if gem_in_gemfile?(gem_name)
10
- Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
11
- else
12
- puts warning_message
13
- end
14
- end
15
- end
16
-
17
- TaskLoader.load_tasks_if_gem_present('whenever', 'whenever/tasks', 'WARNING: Gemfile does not include whenever gem which is required for logrotate tasks')
5
+ TaskLoader.load_tasks_if_gem_present('whenever', 'whenever/tasks', 'WARNING: Gemfile does not include whenever gem which is required for whenever tasks')
@@ -1,19 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'capistrano/ops/helper'
3
+ require 'capistrano/ops/task_loader'
4
4
  require 'capistrano/ops/wkhtmltopdf/helpers'
5
5
 
6
- module TaskLoader
7
- extend Capistrano::Ops::Helper
8
-
9
- def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
10
- if gem_in_gemfile?(gem_name)
11
- Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
12
- else
13
- puts warning_message
14
- end
15
- end
16
- end
17
-
18
6
  TaskLoader.load_tasks_if_gem_present('wicked_pdf', 'wkhtmltopdf/tasks',
19
7
  'WARNING: Gemfile does not include wkhtmltopdf-binary gem which is required for wkhtmltopdf tasks')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Crusius
@@ -200,6 +200,7 @@ files:
200
200
  - lib/capistrano/ops/rails/lib/tasks/pg/remove_old_dumps.rake
201
201
  - lib/capistrano/ops/rails/lib/tasks/storage/backup.rake
202
202
  - lib/capistrano/ops/rails/lib/tasks/storage/remove_old_backups.rake
203
+ - lib/capistrano/ops/task_loader.rb
203
204
  - lib/capistrano/ops/version.rb
204
205
  - lib/capistrano/ops/whenever.rb
205
206
  - lib/capistrano/ops/whenever/tasks/show_crontab.rake