Class: Teapot::Config::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/teapot/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, name, options = {}) ⇒ Package

Returns a new instance of Package.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/teapot/config.rb', line 32

def initialize(config, name, options = {})
	@config = config
	
	if options[:name]
		@name = options[:name]
	end
	
	if Symbol === name
		@uri = name.to_s
		@name ||= @uri
	else
		@name ||= File.basename(name)
		@uri = name
	end
	
	@options = options
	@global = Environment.new
end

Instance Attribute Details

#globalObject (readonly)

Returns the value of attribute global.



54
55
56
# File 'lib/teapot/config.rb', line 54

def global
  @global
end

#nameObject (readonly)

Returns the value of attribute name.



51
52
53
# File 'lib/teapot/config.rb', line 51

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



53
54
55
# File 'lib/teapot/config.rb', line 53

def options
  @options
end

#uriObject (readonly)

Returns the value of attribute uri.



52
53
54
# File 'lib/teapot/config.rb', line 52

def uri
  @uri
end

Instance Method Details

#loader_pathObject



75
76
77
# File 'lib/teapot/config.rb', line 75

def loader_path
	"teapot.rb"
end

#local?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/teapot/config.rb', line 71

def local?
	@options.key? :local
end

#pathObject



79
80
81
# File 'lib/teapot/config.rb', line 79

def path
	@config.packages_path + @name
end

#relative_url(base_uri) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/teapot/config.rb', line 56

def relative_url(base_uri)
	source_uri = URI(@uri)

	unless source_uri.absolute?
		source_uri = base_uri + source_uri
	end
		
	# Git can't handle the default formatting that Ruby uses for file URIs.
	if source_uri.scheme == "file"
		source_uri = "file://" + source_uri.path
	end
	
	return source_uri
end

#to_sObject



83
84
85
# File 'lib/teapot/config.rb', line 83

def to_s
	"<#{@name}>"
end