Class: Librarian::Mock::Source::Mock::Registry::Dsl::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/librarian/mock/source/mock/registry.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Source

Returns a new instance of Source.



20
21
22
# File 'lib/librarian/mock/source/mock/registry.rb', line 20

def initialize(source)
  @source = source
end

Instance Method Details

#spec(name, version = nil, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/librarian/mock/source/mock/registry.rb', line 23

def spec(name, version = nil, &block)
  @source[name] ||= []
  unless version
    Spec.new(@source[name]).instance_eval(&block) if block
  else
    Spec.new(@source[name]).version(version, &block)
  end
  @source[name] = @source[name].sort_by{|a| Manifest::Version.new(a[:version])}.reverse
end