Class: Librarian::Puppet::Dsl

Inherits:
Dsl
  • Object
show all
Defined in:
lib/librarian/puppet/dsl.rb

Defined Under Namespace

Classes: Receiver, Target

Constant Summary collapse

FORGE_URL =
"https://forgeapi.puppetlabs.com"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dependency_typeObject



26
27
28
# File 'lib/librarian/puppet/dsl.rb', line 26

def self.dependency_type
  Librarian::Puppet::Dependency
end

Instance Method Details

#default_specfileObject



19
20
21
22
23
24
# File 'lib/librarian/puppet/dsl.rb', line 19

def default_specfile
  Proc.new do
    forge FORGE_URL
    
  end
end

#post_process_target(target) ⇒ Object



30
31
32
33
34
# File 'lib/librarian/puppet/dsl.rb', line 30

def post_process_target(target)
  # save the default forge defined
  default_forge = target.sources.select {|s| s.is_a? Librarian::Puppet::Source::Forge}.first
  Librarian::Puppet::Source::Forge.default = default_forge || Librarian::Puppet::Source::Forge.from_lock_options(environment, :remote => FORGE_URL)
end

#receiver(target) ⇒ Object



36
37
38
# File 'lib/librarian/puppet/dsl.rb', line 36

def receiver(target)
  Receiver.new(target)
end

#run(specfile = nil, sources = []) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/librarian/puppet/dsl.rb', line 40

def run(specfile = nil, sources = [])
  specfile, sources = nil, specfile if specfile.kind_of?(Array) && sources.empty?

  Target.new(self).tap do |target|
    target.precache_sources(sources)
    debug_named_source_cache("Pre-Cached Sources", target)

    specfile ||= Proc.new if block_given?

    if specfile.kind_of?(Pathname) and !File.exists?(specfile)
      debug { "Specfile #{specfile} not found, using defaults" } unless specfile.nil?
      receiver(target).run(specfile, &default_specfile)
    else
      receiver(target).run(specfile)
    end

    post_process_target(target)

    debug_named_source_cache("Post-Cached Sources", target)
  end.to_spec
end