Module: Capistrano::Configuration::Resources::FileResources
- Defined in:
- lib/capistrano/configuration/resources/file_resources.rb,
lib/capistrano/configuration/resources/file_resources/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
Instance Method Details
#file(name, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/capistrano/configuration/resources/file_resources.rb', line 10 def file(name, ={}) = .dup path = ( .delete(:path) || "." ) begin File.read(File.join(path, name), ) rescue SystemCallError => error abort("Could not render file resource - #{error}") end end |
#template(name, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/capistrano/configuration/resources/file_resources.rb', line 20 def template(name, ={}) path = .fetch(:path, "." ) if File.exist?(File.join(path, "#{name}.erb")) name = "#{name}.erb" else types = MIME::Types.type_for(name) if types.include?("text/html") name_without_ext = File.basename(name, File.extname(name)) if File.exist?(File.join(path, "#{name_without_ext}.rhtml")) name = "#{name_without_ext}.rhtml" end end end begin ERB.new(file(name, )).result(.fetch(:binding, binding)) rescue StandardError => error abort("Could not render template resource - #{error}") end end |