Sha256: 6219f38803b9ba6c707637d68d899fee9c752072cf89d54d81dfce0ca274c3cb

Contents?: true

Size: 991 Bytes

Versions: 6

Compression:

Stored size: 991 Bytes

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) }.uniq.sort
    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

6 entries across 6 versions & 1 rubygems

Version Path
capistrano_multiconfig_parallel-0.19.1 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.19.0 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.18.2 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.18.1 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.18.0 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.17.0 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb