Sha256: 205e7095fbb33d3aefc247956a1161d53871edad45195ce5fda0062903775ce0

Contents?: true

Size: 556 Bytes

Versions: 7

Compression:

Stored size: 556 Bytes

Contents

module Bonsai
  class Template
    @@path = "templates"
    
    class NotFound < StandardError; end
    
    class << self
      def path; @@path; end
      
      def path=(path)
        @@path = path
      end
      
      def find(name)
        disk_path = Dir["#{path}/#{name}.*"]
        
        if disk_path.any? 
          new disk_path.first
        else
          raise NotFound, "template '#{name}' not found at #{path}"
        end
      end
    end
    
    attr_reader :path
    
    def initialize(path)
      @path = path
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bonsai-1.1.4 lib/bonsai/template.rb
bonsai-1.1.3 lib/bonsai/template.rb
bonsai-1.1.2 lib/bonsai/template.rb
bonsai-1.1.1 lib/bonsai/template.rb
bonsai-1.1.0 lib/bonsai/template.rb
bonsai-1.0.1 lib/bonsai/template.rb
bonsai-1.0.0 lib/bonsai/template.rb