# File lib/librarian/puppet/dsl.rb, line 19
      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)
          debug { "Specfile not found, using defaults: #{specfile}" }
          specfile = Proc.new do
            forge FORGE_URL
            metadata
          end
        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 = Receiver.new(target)
          receiver.run(specfile)

          # 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)

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