Sha256: e071e40c831664f8ddb84d16f7e692fba377c0301d1f42ea0abf8e3416a7dcb5

Contents?: true

Size: 1.07 KB

Versions: 20

Compression:

Stored size: 1.07 KB

Contents

module CapistranoMulticonfigParallel
  # 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
  module StagesHelper
  module_function

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

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

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

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

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
capistrano_multiconfig_parallel-0.21.8 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.7 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.6 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.5 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.4 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.3 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.2 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.1 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.21.0 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.9 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.8 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.7 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.6 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.5 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.4 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.3 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.2 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.1 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.20.0 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.19.2 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb