Sha256: 6d58f04ee22c50826e5ab7b854e8a18e283e18eb115576c24c87b1e9949c65ee
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# will first try and copy the file: # config/deploy/#{full_app_name}/#{from}.erb # to: # shared/config/to # if the original source path doesn exist then it will # search in: # config/deploy/shared/#{from}.erb # otherwise it will search in the gems template directory # this allows files which are common to all enviros to # come from a single source while allowing specific # ones to be over-ridden # if the target file name is the same as the source then # the second parameter can be left out def smart_template(from, to=nil) to ||= from full_to_path = "#{shared_path}/config/#{to}" if from_erb_path = template_file(from) from_erb = StringIO.new(ERB.new(File.read(from_erb_path)).result(binding)) upload! from_erb, full_to_path info "copying: #{from_erb} to: #{full_to_path}" else error "error #{from} not found" end end def template_file(name) if File.exist?((file = "config/deploy/#{fetch(:stage)}/#{name}.erb")) return file elsif File.exist?((file = "config/deploy/shared/#{name}.erb")) return file elsif File.exist?((file = "config/deploy/templates/#{name}.erb")) return file elsif File.exist?(file = File.expand_path("../templates/#{name}.erb",File.dirname(__FILE__))) return file end return nil end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-cookbook-5.0.0 | lib/capistrano/cookbook/helpers/template.rb |