Class: Capistrano::Template::Helpers::PathsLookup
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Capistrano::Template::Helpers::PathsLookup
- Defined in:
- lib/capistrano/template/helpers/paths_lookup.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
Returns the value of attribute paths.
Instance Method Summary collapse
- #existence_check(path) ⇒ Object
-
#initialize(paths, context) ⇒ PathsLookup
constructor
A new instance of PathsLookup.
- #paths_for_file(filename) ⇒ Object
- #template_exists?(filename) ⇒ Boolean
- #template_file(filename) ⇒ Object
Constructor Details
#initialize(paths, context) ⇒ PathsLookup
Returns a new instance of PathsLookup.
7 8 9 10 |
# File 'lib/capistrano/template/helpers/paths_lookup.rb', line 7 def initialize(paths, context) super context self.paths = paths end |
Instance Attribute Details
#paths ⇒ Object
Returns the value of attribute paths.
5 6 7 |
# File 'lib/capistrano/template/helpers/paths_lookup.rb', line 5 def paths @paths end |
Instance Method Details
#existence_check(path) ⇒ Object
20 21 22 |
# File 'lib/capistrano/template/helpers/paths_lookup.rb', line 20 def existence_check(path) File.exist?(path) end |
#paths_for_file(filename) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/capistrano/template/helpers/paths_lookup.rb', line 24 def paths_for_file(filename) paths.map do |path| path = format(path, host: host) ["#{path}/#{filename}.erb", "#{path}/#{filename}"] end.flatten end |
#template_exists?(filename) ⇒ Boolean
12 13 14 |
# File 'lib/capistrano/template/helpers/paths_lookup.rb', line 12 def template_exists?(filename) !template_file(filename).nil? end |
#template_file(filename) ⇒ Object
16 17 18 |
# File 'lib/capistrano/template/helpers/paths_lookup.rb', line 16 def template_file(filename) paths_for_file(filename).find { |path| existence_check(path) } end |