Module: CapistranoMulticonfigParallel::StagesHelper

Included in:
ApplicationHelper
Defined in:
lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb

Overview

module used to fetch the stages (code taken from https://github.com/railsware/capistrano-multiconfig) TODO: find a way to do this without copying code. Can't currently use gem specification to require that gem because that is only compatible with capistrano version 3

Class Method Summary collapse

Class Method Details

.check_stage_path(paths, path) ⇒ Object



23
24
25
# File 'lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb', line 23

def check_stage_path(paths, path)
  paths.any? { |another| another != path && another.start_with?(path + ':') }
end

.checks_paths(paths) ⇒ Object



14
15
16
17
# File 'lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb', line 14

def checks_paths(paths)
  paths.reject! { |path| check_stage_path(paths, path) }
  sorted_paths(paths)
end

.fetch_stages ⇒ Object



8
9
10
11
12
# File 'lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb', line 8

def fetch_stages
  fetch_stages_paths do |paths|
    checks_paths(paths)
  end
end

.fetch_stages_paths ⇒ Object



34
35
36
# File 'lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb', line 34

def fetch_stages_paths
  stages_paths.tap { |paths| yield paths if block_given? }
end

.sorted_paths(paths) ⇒ Object



19
20
21
# File 'lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb', line 19

def sorted_paths(paths)
  paths.present? ? paths.uniq.sort : paths
end

.stages_paths ⇒ Object



27
28
29
30
31
32
# File 'lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb', line 27

def stages_paths
  stages_root = 'config/deploy'
  Dir["#{stages_root}/**/*.rb"].map do |file|
    file.slice(stages_root.size + 1..-4).tr('/', ':')
  end
end