Class: Steep::Project::DSL
- Inherits:
-
Object
- Object
- Steep::Project::DSL
- Defined in:
- lib/steep/project/dsl.rb
Defined Under Namespace
Classes: TargetDSL
Constant Summary collapse
- @@templates =
{ gemfile: TargetDSL.new(:gemfile).tap do |target| target.check "Gemfile" target.library "gemfile" end }
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Class Method Summary collapse
- .parse(project, code, filename: "Steepfile") ⇒ Object
- .register_template(name, target) ⇒ Object
- .templates ⇒ Object
Instance Method Summary collapse
-
#initialize(project:) ⇒ DSL
constructor
A new instance of DSL.
- #target(name, template: nil, &block) ⇒ Object
Constructor Details
#initialize(project:) ⇒ DSL
Returns a new instance of DSL.
86 87 88 89 |
# File 'lib/steep/project/dsl.rb', line 86 def initialize(project:) @project = project @global_signatures = [] end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
73 74 75 |
# File 'lib/steep/project/dsl.rb', line 73 def project @project end |
Class Method Details
.parse(project, code, filename: "Steepfile") ⇒ Object
95 96 97 |
# File 'lib/steep/project/dsl.rb', line 95 def self.parse(project, code, filename: "Steepfile") self.new(project: project).instance_eval(code, filename) end |
.register_template(name, target) ⇒ Object
91 92 93 |
# File 'lib/steep/project/dsl.rb', line 91 def self.register_template(name, target) templates[name] = target end |
.templates ⇒ Object
82 83 84 |
# File 'lib/steep/project/dsl.rb', line 82 def self.templates @@templates end |
Instance Method Details
#target(name, template: nil, &block) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/steep/project/dsl.rb', line 99 def target(name, template: nil, &block) target = if template self.class.templates[template]&.dup&.update(name: name) or raise "Unknown template: #{template}, available templates: #{@@templates.keys.join(", ")}" else TargetDSL.new(name) end target.instance_eval(&block) if block_given? Project::Target.new( name: target.name, source_patterns: target.sources, ignore_patterns: target.ignored_sources, signature_patterns: target.signatures, options: Options.new.tap do || .libraries.push(*target.libraries) case target.vendor_dir when Array .vendored_stdlib_path = target.vendor_dir[0] .vendored_gems_path = target.vendor_dir[1] when Pathname .vendored_stdlib_path = target.vendor_dir + "stdlib" .vendored_gems_path = target.vendor_dir + "gems" end end ).tap do |target| project.targets << target end end |