Class: Librarian::Manifest

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

Defined Under Namespace

Classes: Version

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, name, extra = nil) ⇒ Manifest

Returns a new instance of Manifest.



46
47
48
49
50
51
52
# File 'lib/librarian/manifest.rb', line 46

def initialize(source, name, extra = nil)
  assert_name_valid! name

  self.source = source
  self.name = name
  self.extra = extra
end

Instance Attribute Details

#extraObject

Returns the value of attribute extra.



43
44
45
# File 'lib/librarian/manifest.rb', line 43

def extra
  @extra
end

#nameObject

Returns the value of attribute name.



43
44
45
# File 'lib/librarian/manifest.rb', line 43

def name
  @name
end

#sourceObject

Returns the value of attribute source.



43
44
45
# File 'lib/librarian/manifest.rb', line 43

def source
  @source
end

Instance Method Details

#dependenciesObject



80
81
82
# File 'lib/librarian/manifest.rb', line 80

def dependencies
  defined_dependencies || fetched_dependencies
end

#dependencies=(dependencies) ⇒ Object



84
85
86
# File 'lib/librarian/manifest.rb', line 84

def dependencies=(dependencies)
  self.defined_dependencies = _normalize_dependencies(dependencies)
end

#dependencies?Boolean

Returns:

  • (Boolean)


88
89
90
91
92
93
94
# File 'lib/librarian/manifest.rb', line 88

def dependencies?
  return unless defined_dependencies

  defined_dependencies.zip(fetched_dependencies).all? do |(a, b)|
    a.name == b.name && a.requirement == b.requirement
  end
end

#install!Object



100
101
102
# File 'lib/librarian/manifest.rb', line 100

def install!
  source.install!(self)
end

#latestObject



72
73
74
# File 'lib/librarian/manifest.rb', line 72

def latest
  @latest ||= source.manifests(name).first
end

#outdated?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/librarian/manifest.rb', line 76

def outdated?
  latest.version > version
end

#satisfies?(dependency) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/librarian/manifest.rb', line 96

def satisfies?(dependency)
  dependency.requirement.satisfied_by?(version)
end

#to_sObject



54
55
56
# File 'lib/librarian/manifest.rb', line 54

def to_s
  "#{name}/#{version} <#{source}>"
end

#versionObject



58
59
60
# File 'lib/librarian/manifest.rb', line 58

def version
  defined_version || fetched_version
end

#version=(version) ⇒ Object



62
63
64
# File 'lib/librarian/manifest.rb', line 62

def version=(version)
  self.defined_version = _normalize_version(version)
end

#version?Boolean

Returns:

  • (Boolean)


66
67
68
69
70
# File 'lib/librarian/manifest.rb', line 66

def version?
  return unless defined_version

  defined_version == fetched_version
end