Sha256: f824968a01886675076048c60b5f8f47469c03dbe73fbf087d2d3f34f506903c

Contents?: true

Size: 754 Bytes

Versions: 6

Compression:

Stored size: 754 Bytes

Contents

module Capistrano
  module Template
    module Helpers
      class PathsLookup < SimpleDelegator
        attr_accessor :paths

        def initialize(paths, context)
          super context
          self.paths = paths
        end

        def template_exists?(filename)
          !template_file(filename).nil?
        end

        def template_file(filename)
          paths_for_file(filename).find { |path| existence_check(path) }
        end

        def existence_check(path)
          File.exist?(path)
        end

        def paths_for_file(filename)
          paths.map do |path|
            path = path % { host: host }
            ["#{path}/#{filename}.erb", "#{path}/#{filename}"]
          end.flatten
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capistrano-template-0.0.7 lib/capistrano/template/helpers/paths_lookup.rb
capistrano-template-0.0.5 lib/capistrano/template/helpers/paths_lookup.rb
capistrano-template-0.0.4 lib/capistrano/template/helpers/paths_lookup.rb
capistrano-template-0.0.3 lib/capistrano/template/helpers/paths_lookup.rb
capistrano-template-0.0.2 lib/capistrano/template/helpers/paths_lookup.rb
capistrano-template-0.0.1 lib/capistrano/template/helpers/paths_lookup.rb