Class: Teapot::Loader
- Inherits:
-
Object
- Object
- Teapot::Loader
- Includes:
- Build::Helpers, Commands::Helpers
- Defined in:
- lib/teapot/loader.rb
Defined Under Namespace
Classes: Definitions
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#defined ⇒ Object
readonly
Returns the value of attribute defined.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #define_configuration(*args) {|configuration| ... } ⇒ Object
- #define_generator(*args) {|generator| ... } ⇒ Object
- #define_project(*args) {|project| ... } ⇒ Object
- #define_target(*args) {|target| ... } ⇒ Object
-
#host(*args, &block) ⇒ Object
Checks the host patterns and executes the block if they match.
-
#initialize(context, package) ⇒ Loader
constructor
A new instance of Loader.
-
#load(path) ⇒ Object
Load a teapot.rb file relative to the root of the @package.
- #teapot_version(version) ⇒ Object (also: #required_version)
Methods included from Commands::Helpers
Methods included from Build::Helpers
#build_directory, #build_external
Constructor Details
#initialize(context, package) ⇒ Loader
Returns a new instance of Loader.
62 63 64 65 66 67 68 |
# File 'lib/teapot/loader.rb', line 62 def initialize(context, package) @context = context @package = package @defined = Definitions.new @version = nil end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
70 71 72 |
# File 'lib/teapot/loader.rb', line 70 def context @context end |
#defined ⇒ Object (readonly)
Returns the value of attribute defined.
72 73 74 |
# File 'lib/teapot/loader.rb', line 72 def defined @defined end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
71 72 73 |
# File 'lib/teapot/loader.rb', line 71 def package @package end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
73 74 75 |
# File 'lib/teapot/loader.rb', line 73 def version @version end |
Instance Method Details
#define_configuration(*args) {|configuration| ... } ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/teapot/loader.rb', line 111 def define_configuration(*args) configuration = Configuration.new(@context, @package, *args) configuration.top! yield configuration @defined << configuration end |
#define_generator(*args) {|generator| ... } ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/teapot/loader.rb', line 103 def define_generator(*args) generator = Generator.new(@context, @package, *args) yield generator @defined << generator end |
#define_project(*args) {|project| ... } ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/teapot/loader.rb', line 87 def define_project(*args) project = Project.new(@context, @package, *args) yield project @defined << project end |
#define_target(*args) {|target| ... } ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/teapot/loader.rb', line 95 def define_target(*args) target = Target.new(@context, @package, *args) yield target @defined << target end |
#host(*args, &block) ⇒ Object
Checks the host patterns and executes the block if they match.
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/teapot/loader.rb', line 122 def host(*args, &block) name = @context.[:host_platform] || RUBY_PLATFORM if block_given? if args.find{|arg| arg === name} yield end else name end end |
#load(path) ⇒ Object
Load a teapot.rb file relative to the root of the @package.
135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/teapot/loader.rb', line 135 def load(path) absolute_path = @package.path + path raise NonexistantTeapotError.new(absolute_path) unless File.exist?(absolute_path) self.instance_eval(absolute_path.read, absolute_path.to_s) if @version == nil raise IncompatibleTeapotError.new(@package, "<unspecified>") end end |
#teapot_version(version) ⇒ Object Also known as: required_version
75 76 77 78 79 80 81 82 83 |
# File 'lib/teapot/loader.rb', line 75 def teapot_version(version) version = version[0..2] if version >= MINIMUM_LOADER_VERSION && version <= LOADER_VERSION @version = version else raise IncompatibleTeapotError.new(package, version) end end |