Class: Steep::Project::DSL

Inherits:
Object show all
Includes:
LibraryOptions
Defined in:
lib/steep/project/dsl.rb

Defined Under Namespace

Modules: LibraryOptions, WithPattern Classes: GroupDSL, TargetDSL

Instance Attribute Summary collapse

Attributes included from LibraryOptions

#collection_config_path, #core_root, #stdlib_root

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LibraryOptions

#collection_config, #disable_collection, #libraries, #library, #library_configured?, #repo_path, #repo_paths, #stdlib_path, #to_library_options

Constructor Details

#initialize(project:) ⇒ DSL

Returns a new instance of DSL.



240
241
242
# File 'lib/steep/project/dsl.rb', line 240

def initialize(project:)
  @project = project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



238
239
240
# File 'lib/steep/project/dsl.rb', line 238

def project
  @project
end

Class Method Details

.eval(project, &block) ⇒ Object



252
253
254
255
256
257
258
# File 'lib/steep/project/dsl.rb', line 252

def self.eval(project, &block)
  Steep.logger.tagged "DSL.eval" do
    dsl = self.new(project: project)
    dsl.instance_exec(&block)
    project.global_options = dsl.to_library_options
  end
end

.parse(project, code, filename: "Steepfile") ⇒ Object



244
245
246
247
248
249
250
# File 'lib/steep/project/dsl.rb', line 244

def self.parse(project, code, filename: "Steepfile")
  Steep.logger.tagged filename do
    dsl = self.new(project: project)
    dsl.instance_eval(code, filename)
    project.global_options = dsl.to_library_options
  end
end

Instance Method Details

#target(name, &block) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/steep/project/dsl.rb', line 260

def target(name, &block)
  name = name.to_str.to_sym unless Symbol === name
  dsl = TargetDSL.new(name, project: project)

  Steep.logger.tagged "target=#{name}" do
    dsl.instance_eval(&block) if block
  end

  target = Project::Target.new(
    name: dsl.name,
    source_pattern: dsl.source_pattern,
    inline_source_pattern: dsl.inline_source_pattern,
    signature_pattern: dsl.signature_pattern,
    options: dsl.library_configured? ? dsl.to_library_options : nil,
    code_diagnostics_config: dsl.code_diagnostics_config,
    project: project,
    unreferenced: dsl.unreferenced,
    implicitly_returns_nil: dsl.implicitly_returns_nil
  )

  dsl.groups.each do
    group = Group.new(target, _1.name, _1.source_pattern, _1.inline_source_pattern, _1.signature_pattern, _1.code_diagnostics_config || target.code_diagnostics_config)
    target.groups << group
  end

  project.targets << target
end