Class: Librarian::Cli::ManifestPresenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli, manifests) ⇒ ManifestPresenter

Returns a new instance of ManifestPresenter.



8
9
10
11
12
13
14
# File 'lib/librarian/cli/manifest_presenter.rb', line 8

def initialize(cli, manifests)
  self.cli = cli or raise ArgumentError, "cli required"
  self.manifests = manifests or raise ArgumentError, "manifests required"
  self.manifests_index = Hash[manifests.map{|m| [m.name, m]}]

  self.scope_level = 0
end

Instance Attribute Details

#cliObject

Returns the value of attribute cli.



5
6
7
# File 'lib/librarian/cli/manifest_presenter.rb', line 5

def cli
  @cli
end

#manifestsObject

Returns the value of attribute manifests.



5
6
7
# File 'lib/librarian/cli/manifest_presenter.rb', line 5

def manifests
  @manifests
end

Instance Method Details

#present(names = [], options = { }) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/librarian/cli/manifest_presenter.rb', line 16

def present(names = [], options = { })
  full = options[:detailed]
  full = !names.empty? if full.nil?

  names = manifests.map(&:name).sort if names.empty?
  assert_no_manifests_missing!(names)

  present_each(names, :detailed => full)
end

#present_one(manifest, options = { }) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/librarian/cli/manifest_presenter.rb', line 26

def present_one(manifest, options = { })
  full = options[:detailed]

  say "#{manifest.name} (#{manifest.version})" do
    full or next

    present_one_source(manifest)
    present_one_dependencies(manifest)
  end
end