class Teapot::Package

Attributes

name[R]
options[RW]
path[R]
uri[R]

Public Class Methods

new(path, name, options = {}) click to toggle source
# File lib/teapot/package.rb, line 30
def initialize(path, name, options = {})
        # The path where the package is (or will be) located:
        @path = Path[path]

        # Get the name of the package from the options, if provided:
        if options[:name]
                @name = options[:name]
        end

        if Symbol === name
                # If the name argument was symbolic, we convert it into a string, and use it for both the uri and the name itself:
                @uri = name.to_s
                @name ||= @uri
        else
                # Otherwise, we assume a path may have been given, and use that instead:
                @name ||= File.basename(name)
                @uri = name
        end
        
        # Copy the options provided:
        @options = options
end

Public Instance Methods

eql?(other) click to toggle source
# File lib/teapot/package.rb, line 105
def eql?(other)
        @path.eql?(other.path)
end
external?() click to toggle source
# File lib/teapot/package.rb, line 76
def external?
        @options.include?(:source)
end
external_url(root_path = nil) click to toggle source
# File lib/teapot/package.rb, line 85
def external_url(root_path = nil)
        Build::URI[root_path] + source_uri + Build::URI[@uri]
end
freeze() click to toggle source
Calls superclass method
# File lib/teapot/package.rb, line 53
def freeze
        @path.freeze
        @name.freeze
        @uri.freeze
        @options.freeze
        
        super
end
hash() click to toggle source

Package may be used as hash key / in a set:

# File lib/teapot/package.rb, line 101
def hash
        @path.hash
end
local() click to toggle source
# File lib/teapot/package.rb, line 68
def local
        @options[:local].to_s
end
local?() click to toggle source
# File lib/teapot/package.rb, line 72
def local?
        @options.include?(:local)
end
source_uri() click to toggle source

The source uri from which this package would be cloned. Might be relative, in which case it's relative to the root of the context.

# File lib/teapot/package.rb, line 81
def source_uri
        Build::URI[@options[:source]]
end
to_s() click to toggle source
# File lib/teapot/package.rb, line 89
def to_s
        if self.local?
                "links #{@name} from #{self.local}"
        elsif self.external?
                "clones #{@name} from #{self.external_url}"
        else
                "references #{@name} from #{@path}"
        end
end