Sha256: 8ab9ea6f87d7ce41d4a0386f2a0872af032152765b8ac356f3e3834eaba6d64c
Contents?: true
Size: 1.16 KB
Versions: 6
Compression:
Stored size: 1.16 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(:full_app_name)}/#{name}.erb")) return file elsif File.exist?((file = "config/deploy/shared/#{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
6 entries across 6 versions & 1 rubygems