capistrano-ops 1.0.1 → 1.0.3

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
  SHA256:
3
- metadata.gz: 0ed2d908b8ec3ca6fc1c824ee868ac68ae9d22e123ee051fe45c27b6ad5ef8df
4
- data.tar.gz: ecd05a6efb4636281983d2a2a8ea61eff0ccd98181cbd49094a70212ee0b2d3d
3
+ metadata.gz: e7944bee1bc903f6dc873cac78ac255e7811341c1c8bf291de8cf0c2bc2a01a4
4
+ data.tar.gz: 49afc833c49c3b2d01009c2a7f13fa5a59e04b70691d9baac51ac292f6101240
5
5
  SHA512:
6
- metadata.gz: 229d0d86cdd193313cd869def5258f3dc8e694c6b75b3c260bdb63e0847fb3b5c102276be9c4795777bd3946ed93fb037d8d8cad97db6d5a4fbf43da5898a4de
7
- data.tar.gz: 9f2c4f1fed7e7388b538d9295310529aa60643516b4ac72dbe7ac052927d162b8230ebc55d5e976ea6f289b05415cfcc4a676a0d59d76f7a36374a0fa6768b61
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.1'
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')
@@ -2,48 +2,50 @@
2
2
 
3
3
  module Capistrano
4
4
  module Ops
5
- module Helper
6
- def binary_path
7
- gem_path = capture(:bundle, 'show', 'wkhtmltopdf-binary').strip
8
- "#{gem_path}/bin"
9
- end
5
+ module Wkhtmltopdf
6
+ module Helpers
7
+ def binary_path
8
+ gem_path = capture(:bundle, 'show', 'wkhtmltopdf-binary').strip
9
+ "#{gem_path}/bin"
10
+ end
10
11
 
11
- def gem_version
12
- capture(:cat, 'config/initializers/wicked_pdf.rb').scan(/wkhtmltopdf_ubuntu_(\d+\.\d+)_amd64/).flatten.first
13
- end
12
+ def gem_version
13
+ capture(:cat, 'config/initializers/wicked_pdf.rb').scan(/wkhtmltopdf_ubuntu_(\d+\.\d+)_amd64/).flatten.first
14
+ end
14
15
 
15
- def binary_path_and_version
16
- [binary_path, gem_version]
17
- end
16
+ def binary_path_and_version
17
+ [binary_path, gem_version]
18
+ end
18
19
 
19
- def file_existing?(file)
20
- test("[ -f #{file} ]")
21
- end
20
+ def file_existing?(file)
21
+ test("[ -f #{file} ]")
22
+ end
22
23
 
23
- def right_permissions?(file)
24
- test("[ $(stat -c '%a' #{file}) = '777' ]")
25
- end
24
+ def right_permissions?(file)
25
+ test("[ $(stat -c '%a' #{file}) = '777' ]")
26
+ end
26
27
 
27
- def check_file_and_permissions(binary_path, version)
28
- binary_file = "#{binary_path}/wkhtmltopdf_ubuntu_#{version}_amd64"
28
+ def check_file_and_permissions(binary_path, version)
29
+ binary_file = "#{binary_path}/wkhtmltopdf_ubuntu_#{version}_amd64"
29
30
 
30
- if file_existing?(binary_file)
31
- info('wkhtmltopdf binary already extracted')
31
+ if file_existing?(binary_file)
32
+ info('wkhtmltopdf binary already extracted')
32
33
 
33
- if right_permissions?(binary_file)
34
- info('wkhtmltopdf binary has already the right permissions')
34
+ if right_permissions?(binary_file)
35
+ info('wkhtmltopdf binary has already the right permissions')
36
+ else
37
+ info('adding right permissions to wkhtmltopdf binary')
38
+ execute("chmod 777 #{binary_file}")
39
+ end
35
40
  else
36
- info('adding right permissions to wkhtmltopdf binary')
41
+ info('extracting wkhtmltopdf binary')
42
+ # extract the binary but keep the gzip file
43
+ execute("cd #{binary_path} && gzip -dk wkhtmltopdf_ubuntu_#{version}_amd64.gz")
44
+ # add execute permission to the binary
37
45
  execute("chmod 777 #{binary_file}")
38
46
  end
39
- else
40
- info('extracting wkhtmltopdf binary')
41
- # extract the binary but keep the gzip file
42
- execute("cd #{binary_path} && gzip -dk wkhtmltopdf_ubuntu_#{version}_amd64.gz")
43
- # add execute permission to the binary
44
- execute("chmod 777 #{binary_file}")
47
+ info('wkhtmltopdf setup finished')
45
48
  end
46
- info('wkhtmltopdf setup finished')
47
49
  end
48
50
  end
49
51
  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/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.1
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