Class: Teapot::Config::Package
- Inherits:
-
Object
- Object
- Teapot::Config::Package
- Defined in:
- lib/teapot/config.rb
Instance Attribute Summary collapse
-
#global ⇒ Object
readonly
Returns the value of attribute global.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(config, name, options = {}) ⇒ Package
constructor
A new instance of Package.
- #loader_path ⇒ Object
- #local? ⇒ Boolean
- #path ⇒ Object
- #relative_url(base_uri) ⇒ Object
- #to_s ⇒ Object
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, = {}) @config = config if [:name] @name = [:name] end if Symbol === name @uri = name.to_s @name ||= @uri else @name ||= File.basename(name) @uri = name end @options = @global = Environment.new end |
Instance Attribute Details
#global ⇒ Object (readonly)
Returns the value of attribute global.
54 55 56 |
# File 'lib/teapot/config.rb', line 54 def global @global end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
51 52 53 |
# File 'lib/teapot/config.rb', line 51 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
53 54 55 |
# File 'lib/teapot/config.rb', line 53 def @options end |
#uri ⇒ Object (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_path ⇒ Object
75 76 77 |
# File 'lib/teapot/config.rb', line 75 def loader_path "teapot.rb" end |
#local? ⇒ Boolean
71 72 73 |
# File 'lib/teapot/config.rb', line 71 def local? @options.key? :local end |
#path ⇒ Object
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_s ⇒ Object
83 84 85 |
# File 'lib/teapot/config.rb', line 83 def to_s "<#{@name}>" end |