Sha256: 116c04c924a1a07fdfbfa0552ea65aa33132d0778434e09a35f50226f7f65431

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'itamae/resource/remote_file'

module Itamae
  module Resource
    class Template

      def find_source_file_with_daddy_convention
        begin
          ret = find_source_file_without_daddy_convention
        rescue SourceNotFoundError => e
          if attributes.source == :auto
            ret = find_source_file_in_templates
          else
            raise e
          end
        end

        ret
      end

      def find_source_file_in_templates
        itamae_dir = ::File.expand_path('../../../itamae', __FILE__)
        path = ::File.join(itamae_dir, source_file_dir, "#{attributes.path}.erb")
        if ::File.exist?(path)
          path
        else
          raise SourceNotFoundError, "source file is not found (searched in daddy path: #{path})"
        end
      end

      alias_method :find_source_file_without_daddy_convention, :find_source_file
      alias_method :find_source_file, :find_source_file_with_daddy_convention
    end
  end
end

Dir[File.join(File.dirname(__FILE__), 'itamae', '*.rb')].each do |f|
  require f
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
daddy-0.5.5 lib/daddy/itamae.rb
daddy-0.5.4 lib/daddy/itamae.rb
daddy-0.5.3 lib/daddy/itamae.rb
daddy-0.5.2 lib/daddy/itamae.rb
daddy-0.5.1 lib/daddy/itamae.rb