Class: Teapot::Script

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(context, package, path = TEAPOT_FILE) ⇒ Script

Returns a new instance of Script.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/teapot/loader.rb', line 63

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

#configurationsObject (readonly)

Returns the value of attribute configurations.



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

def configurations
  @configurations
end

#contextObject (readonly)

Returns the value of attribute context.



78
79
80
# File 'lib/teapot/loader.rb', line 78

def context
  @context
end

#default_configurationObject (readonly)

Returns the value of attribute default_configuration.



86
87
88
# File 'lib/teapot/loader.rb', line 86

def default_configuration
  @default_configuration
end

#default_projectObject (readonly)

Returns the value of attribute default_project.



85
86
87
# File 'lib/teapot/loader.rb', line 85

def default_project
  @default_project
end

#definedObject (readonly)

Returns the value of attribute defined.



80
81
82
# File 'lib/teapot/loader.rb', line 80

def defined
  @defined
end

#packageObject (readonly)

Returns the value of attribute package.



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

def package
  @package
end

#versionObject (readonly)

Returns the value of attribute version.



81
82
83
# File 'lib/teapot/loader.rb', line 81

def version
  @version
end

Instance Method Details

#define_configuration(*arguments, **options) {|configuration| ... } ⇒ Object

Yields:

  • (configuration)


119
120
121
122
123
124
125
126
127
# File 'lib/teapot/loader.rb', line 119

def define_configuration(*arguments, **options)
  configuration = Configuration.new(@context, @package, *arguments, **options)

  yield configuration

  @default_configuration ||= configuration
  @defined << configuration
  @configurations << configuration
end

#define_project(*arguments, **options) {|project| ... } ⇒ Object

Yields:

  • (project)


100
101
102
103
104
105
106
107
# File 'lib/teapot/loader.rb', line 100

def define_project(*arguments, **options)
  project = Project.new(@context, @package, *arguments, **options)
  
  yield project
  
  @default_project = project
  @defined << project
end

#define_target(*arguments, **options) {|target| ... } ⇒ Object

Yields:

  • (target)


109
110
111
112
113
114
115
116
117
# File 'lib/teapot/loader.rb', line 109

def define_target(*arguments, **options)
  target = Target.new(@context, @package, *arguments, **options)
  
  yield target
  
  target.update_environments!
  
  @defined << target
end

#host(*arguments, **options, &block) ⇒ Object

Checks the host patterns and executes the block if they match.



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/teapot/loader.rb', line 130

def host(*arguments, **options, &block)
  name = @context.options[: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



88
89
90
91
92
93
94
95
96
# File 'lib/teapot/loader.rb', line 88

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