Class: Librarian::Dsl::Receiver
- Inherits:
-
Object
- Object
- Librarian::Dsl::Receiver
- Defined in:
- lib/librarian/dsl/receiver.rb
Instance Method Summary collapse
-
#initialize(target) ⇒ Receiver
constructor
A new instance of Receiver.
- #run(specfile = nil) ⇒ Object
Constructor Details
#initialize(target) ⇒ Receiver
Returns a new instance of Receiver.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/librarian/dsl/receiver.rb', line 7 def initialize(target) singleton_class = class << self; self end singleton_class.class_eval do define_method(target.dependency_name) do |*args, &block| target.dependency(*args, &block) end define_method(:source) do |*args, &block| target.source(*args, &block) end target.source_types.each do |source_type| name = source_type[0] define_method(name) do |*args, &block| target.source(name, *args, &block) end end end end |
Instance Method Details
#run(specfile = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/librarian/dsl/receiver.rb', line 25 def run(specfile = nil) specfile = Proc.new if block_given? case specfile when Pathname instance_eval(File.read(specfile), specfile.to_s, 1) when String instance_eval(specfile) when Proc instance_eval(&specfile) else raise ArgumentError, "specfile must be a #{Pathname}, #{String}, or #{Proc} if no block is given (it was #{specfile.inspect})" end end |