Class: Teapot::Script
- Inherits:
-
Object
- Object
- Teapot::Script
- Defined in:
- lib/teapot/loader.rb
Overview
The DSL exposed to the ‘teapot.rb` file.
Constant Summary collapse
- Files =
Build::Files
- Rule =
Build::Rule
Instance Attribute Summary collapse
-
#configurations ⇒ Object
readonly
Returns the value of attribute configurations.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#default_configuration ⇒ Object
readonly
Returns the value of attribute default_configuration.
-
#default_project ⇒ Object
readonly
Returns the value of attribute default_project.
-
#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(*arguments, **options) {|configuration| ... } ⇒ Object
Define a new configuration.
-
#define_project(*arguments, **options) {|project| ... } ⇒ Object
Define a new project.
-
#define_target(*arguments, **options) {|target| ... } ⇒ Object
Define a new target.
-
#host(*arguments, **options, &block) ⇒ Object
Checks the host patterns and executes the block if they match.
-
#initialize(context, package, path = TEAPOT_FILE) ⇒ Script
constructor
Initialize a new script.
-
#teapot_version(version) ⇒ Object
(also: #required_version)
Specify the minimum required teapot gem version for compatibility checks.
Constructor Details
#initialize(context, package, path = TEAPOT_FILE) ⇒ Script
Initialize a new script.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/teapot/loader.rb', line 57 def initialize(context, package, path = TEAPOT_FILE) @context = context @package = package @defined = [] @version = nil @configurations = Build::Dependency::Set.new @default_project = nil @default_configuration = nil @mtime = nil end |
Instance Attribute Details
#configurations ⇒ Object (readonly)
Returns the value of attribute configurations.
77 78 79 |
# File 'lib/teapot/loader.rb', line 77 def configurations @configurations end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
72 73 74 |
# File 'lib/teapot/loader.rb', line 72 def context @context end |
#default_configuration ⇒ Object (readonly)
Returns the value of attribute default_configuration.
80 81 82 |
# File 'lib/teapot/loader.rb', line 80 def default_configuration @default_configuration end |
#default_project ⇒ Object (readonly)
Returns the value of attribute default_project.
79 80 81 |
# File 'lib/teapot/loader.rb', line 79 def default_project @default_project end |
#defined ⇒ Object (readonly)
Returns the value of attribute defined.
74 75 76 |
# File 'lib/teapot/loader.rb', line 74 def defined @defined end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
73 74 75 |
# File 'lib/teapot/loader.rb', line 73 def package @package end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
75 76 77 |
# File 'lib/teapot/loader.rb', line 75 def version @version end |
Instance Method Details
#define_configuration(*arguments, **options) {|configuration| ... } ⇒ Object
Define a new configuration.
121 122 123 124 125 126 127 128 129 |
# File 'lib/teapot/loader.rb', line 121 def define_configuration(*arguments, **) configuration = Configuration.new(@context, @package, *arguments, **) yield configuration @default_configuration ||= configuration @defined << configuration @configurations << configuration end |
#define_project(*arguments, **options) {|project| ... } ⇒ Object
Define a new project.
98 99 100 101 102 103 104 105 |
# File 'lib/teapot/loader.rb', line 98 def define_project(*arguments, **) project = Project.new(@context, @package, *arguments, **) yield project @default_project = project @defined << project end |
#define_target(*arguments, **options) {|target| ... } ⇒ Object
Define a new target.
109 110 111 112 113 114 115 116 117 |
# File 'lib/teapot/loader.rb', line 109 def define_target(*arguments, **) target = Target.new(@context, @package, *arguments, **) yield target target.update_environments! @defined << target end |
#host(*arguments, **options, &block) ⇒ Object
Checks the host patterns and executes the block if they match.
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/teapot/loader.rb', line 132 def host(*arguments, **, &block) name = @context.[:host_platform] || RUBY_PLATFORM if block_given? if arguments.find{|argument| argument === name} yield end else name end end |
#teapot_version(version) ⇒ Object Also known as: required_version
Specify the minimum required teapot gem version for compatibility checks.
84 85 86 87 88 89 90 91 92 |
# File 'lib/teapot/loader.rb', line 84 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 |