lib/keep_up/dependency.rb in keep_up-0.6.1 vs lib/keep_up/dependency.rb in keep_up-0.6.2

- old
+ new

@@ -1,36 +1,41 @@ module KeepUp # Single dependency with its current locked version. class Dependency - def initialize(dependency:, locked_spec:) - @dependency = dependency - @locked_spec = locked_spec + def initialize(name:, requirement_list:, locked_version:) + @name = name + @requirement_list = requirement_list + @locked_version = Gem::Version.new locked_version end - def name - @dependency.name - end + attr_reader :name, :locked_version - def locked_version - @locked_spec.version + def requirement + @requirement ||= Gem::Requirement.new @requirement_list end def matches_spec?(spec) - @dependency.matches_spec? spec + dependency.matches_spec? spec end def generalize_specification(specification) return specification if requirement.exact? segments = specification.version.segments return specification if segments.count <= segment_count version = segments.take(segment_count).join('.') Gem::Specification.new(specification.name, version) end + def ==(other) + other.name == name && + other.locked_version == locked_version && + other.requirement == requirement + end + private - def requirement - @dependency.requirement + def dependency + @dependency ||= Gem::Dependency.new name, requirement end def segment_count @segment_count ||= begin _, ver = requirement.requirements.first