Class: Librarian::Dsl
- Inherits:
-
Object
show all
- Defined in:
- lib/librarian/dsl.rb,
lib/librarian/dsl/target.rb,
lib/librarian/dsl/receiver.rb
Defined Under Namespace
Classes: Error, Receiver, Target
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(environment) ⇒ Dsl
66
67
68
|
# File 'lib/librarian/dsl.rb', line 66
def initialize(environment)
self.environment = environment
end
|
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
11
12
13
|
# File 'lib/librarian/dsl.rb', line 11
def environment
@environment
end
|
Class Method Details
.run(environment, specfile = nil, precache_sources = [], &block) ⇒ Object
16
17
18
|
# File 'lib/librarian/dsl.rb', line 16
def run(environment, specfile = nil, precache_sources = [], &block)
new(environment).run(specfile, precache_sources, &block)
end
|
Instance Method Details
#debug_named_source_cache(name, target) ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/librarian/dsl.rb', line 103
def debug_named_source_cache(name, target)
source_cache = target.source_cache
debug { "#{name}:" }
source_cache.each do |key, value|
type = key[0]
attributes = key[1...key.size]
debug { " #{key.inspect}" }
end
end
|
#default_specfile ⇒ Object
70
71
72
|
# File 'lib/librarian/dsl.rb', line 70
def default_specfile
nil
end
|
#post_process_target(target) ⇒ Object
74
75
76
|
# File 'lib/librarian/dsl.rb', line 74
def post_process_target(target)
nil
end
|
#receiver(target) ⇒ Object
78
79
80
|
# File 'lib/librarian/dsl.rb', line 78
def receiver(target)
Receiver.new(target)
end
|
#run(specfile = nil, sources = []) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/librarian/dsl.rb', line 82
def run(specfile = nil, sources = [])
specfile, sources = nil, specfile if specfile.kind_of?(Array) && sources.empty?
if specfile.kind_of?(Pathname) and !File.exists?(specfile)
specfile = default_specfile
debug { "Specfile not found, using defaults: #{specfile}" } unless specfile.nil?
end
Target.new(self).tap do |target|
target.precache_sources(sources)
debug_named_source_cache("Pre-Cached Sources", target)
specfile ||= Proc.new if block_given?
receiver(target).run(specfile)
post_process_target(target)
debug_named_source_cache("Post-Cached Sources", target)
end.to_spec
end
|