Sha256: c71d64dcecdfd5bca8047ff4bb0174cba0253e67ee22a10f21013a97379a0e9a

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

module CapistranoMulticonfigParallel
  # module used to fetch the stages (code taken from https://github.com/railsware/capistrano-multiconfig)
  # TODO: find a way to remove this and still be compatible with capistrano 2.x
  module StagesHelper
  module_function

    def 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 = File.expand_path(File.join(detect_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

9 entries across 9 versions & 1 rubygems

Version Path
capistrano_multiconfig_parallel-1.0.7 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-1.0.6 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-1.0.5 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-1.0.4 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-1.0.3 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-1.0.2 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-1.0.1 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-1.0.0 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb
capistrano_multiconfig_parallel-0.32.0 lib/capistrano_multiconfig_parallel/helpers/stages_helper.rb