Class: Doubleshot::Dependencies::GemDependency

Inherits:
Dependency show all
Defined in:
lib/doubleshot/dependencies/gem_dependency.rb

Instance Attribute Summary

Attributes inherited from Dependency

#name, #version

Instance Method Summary collapse

Methods inherited from Dependency

#eql?, #hash, #lock, #locked?

Constructor Details

#initialize(name) ⇒ GemDependency

Returns a new instance of GemDependency.



7
8
9
10
# File 'lib/doubleshot/dependencies/gem_dependency.rb', line 7

def initialize(name)
  super
  @requirements = Set.new
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/doubleshot/dependencies/gem_dependency.rb', line 22

def ==(other)
  eql?(other) && requirements == other.requirements
end

#add_requirement(requirement) ⇒ Object



16
17
18
19
20
# File 'lib/doubleshot/dependencies/gem_dependency.rb', line 16

def add_requirement(requirement)
  requirement = Gem::Requirement.new(requirement)
  @requirements << requirement
  requirement
end

#requirementsObject



12
13
14
# File 'lib/doubleshot/dependencies/gem_dependency.rb', line 12

def requirements
  ReadonlyCollection.new(@requirements)
end

#to_s(long_form = false) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/doubleshot/dependencies/gem_dependency.rb', line 26

def to_s(long_form = false)
  if long_form && @version
    "#{name}:#{version}"
  else
    @name
  end
end