class Librarian::Dsl

Attributes

environment[RW]

Public Class Methods

new(environment) click to toggle source
# File lib/librarian/dsl.rb, line 66
def initialize(environment)
  self.environment = environment
end
run(environment, specfile = nil, precache_sources = [], &block) click to toggle source
# File lib/librarian/dsl.rb, line 16
def run(environment, specfile = nil, precache_sources = [], &block)
  new(environment).run(specfile, precache_sources, &block)
end

Private Class Methods

delegate_to_class(*names) click to toggle source
# File lib/librarian/dsl.rb, line 56
def delegate_to_class(*names)
  names.each do |name|
    define_method(name) { self.class.send(name) }
  end
end
dependency(name) click to toggle source
# File lib/librarian/dsl.rb, line 22
def dependency(name)
  dependency_name = name
  dependency_type = Dependency
  singleton_class = class << self; self end
  singleton_class.instance_eval do
    define_method(:dependency_name) { dependency_name }
    define_method(:dependency_type) { dependency_type }
  end
end
shortcut(name, options) click to toggle source
# File lib/librarian/dsl.rb, line 47
def shortcut(name, options)
  instances = source_shortcuts
  instances[name] = options
  singleton_class = class << self; self end
  singleton_class.instance_eval do
    define_method(:source_shortcuts) { instances }
  end
end
source(options) click to toggle source
# File lib/librarian/dsl.rb, line 34
def source(options)
  name = options.keys.first
  type = options[name]
  types = source_types
  types << [name, type]
  singleton_class = class << self; self end
  singleton_class.instance_eval do
    define_method(:source_types) { types }
  end
end

Public Instance Methods

debug_named_source_cache(name, target) click to toggle source
# File lib/librarian/dsl.rb, line 85
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
run(specfile = nil, sources = []) click to toggle source
# File lib/librarian/dsl.rb, line 70
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?
    receiver = Receiver.new(target)
    receiver.run(specfile)

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

Private Instance Methods

debug(*args, &block) click to toggle source
# File lib/librarian/dsl.rb, line 97
def debug(*args, &block)
  environment.logger.debug(*args, &block)
end