Top Level Namespace

Defined Under Namespace

Modules: Prigner Classes: Hash, NilClass, Pathname, Struct, Symbol

Instance Method Summary collapse

Instance Method Details

#templates_by_namespace(options = { :indent => nil, :details => false }) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/prigner/cli/list.rb', line 9

def templates_by_namespace(options = { :indent => nil, :details => false })
  puts "#{Prigner::Version}"
  puts "\nThe templates tagged with '*' are customized by user."
  message = []
  Prigner::Template.all.map do |namespace, list|
    message << "#{namespace}:"
    list.map do |template, custom|
      formatting = "#{options[:indent]}#{custom ? :* : :-} %s (%s)"
      attributes = [template.name, template.spec.version]
      if options[:details]
        formatting = "#{options[:indent]}#{custom ? :* : :-} %s (%s)\n" +
                     "#{options[:indent]}  %s\n" +
                     "#{options[:indent]}  Written by %s <%s>\n"
        attributes = [
          template.name,
          template.spec.version,
          template.spec.description,
          template.spec.author,
          template.spec.email
        ]
      end
      message << (formatting % attributes)
    end
  end
  puts "\n#{message.join("\n")}"
end