Class: Librarian::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/librarian/dependency.rb

Defined Under Namespace

Classes: Requirement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, requirement, source) ⇒ Dependency

Returns a new instance of Dependency.



102
103
104
105
106
107
108
109
110
# File 'lib/librarian/dependency.rb', line 102

def initialize(name, requirement, source)
  assert_name_valid! name

  self.name = name
  self.requirement = Requirement.new(requirement)
  self.source = source

  @manifests = nil
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



99
100
101
# File 'lib/librarian/dependency.rb', line 99

def name
  @name
end

#requirementObject

Returns the value of attribute requirement.



99
100
101
# File 'lib/librarian/dependency.rb', line 99

def requirement
  @requirement
end

#sourceObject

Returns the value of attribute source.



99
100
101
# File 'lib/librarian/dependency.rb', line 99

def source
  @source
end

Instance Method Details

#==(other) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/librarian/dependency.rb', line 128

def ==(other)
  !other.nil? &&
  self.class        == other.class        &&
  self.name         == other.name         &&
  self.requirement  == other.requirement  &&
  self.source       == other.source
end

#cache_manifests!Object



116
117
118
# File 'lib/librarian/dependency.rb', line 116

def cache_manifests!
  source.manifests(name)
end

#consistent_with?(other) ⇒ Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/librarian/dependency.rb', line 136

def consistent_with?(other)
  name != other.name || requirement.consistent_with?(other.requirement)
end

#inconsistent_with?(other) ⇒ Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/librarian/dependency.rb', line 140

def inconsistent_with?(other)
  !consistent_with?(other)
end

#manifestsObject



112
113
114
# File 'lib/librarian/dependency.rb', line 112

def manifests
  @manifests ||= cache_manifests!
end

#satisfied_by?(manifest) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/librarian/dependency.rb', line 120

def satisfied_by?(manifest)
  manifest.satisfies?(self)
end

#to_sObject



124
125
126
# File 'lib/librarian/dependency.rb', line 124

def to_s
  "#{name} (#{requirement}) <#{source}>"
end