Class: Lono::Configset::List

Inherits:
Object
  • Object
show all
Defined in:
lib/lono/configset/list.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ List

Returns a new instance of List.



5
6
7
8
# File 'lib/lono/configset/list.rb', line 5

def initialize(options={})
  @options = options
  @stack, @blueprint, @template, @param = Lono::Conventions.new(options).values
end

Instance Method Details

#blueprint_configsetsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lono/configset/list.rb', line 22

def blueprint_configsets
  Lono::Configset::Preparer.new(@options).run # register and materialize gems

  @final ||= []

  project = Lono::Configset::Register::Project.new(@options)
  project.register
  finder = Lono::Finder::Configset.new
  finder.list("Configsets available to project and can used with configs:") if @options[:verbose]
  puts "Configsets project is using for the #{@blueprint} blueprint:" if @options[:verbose]
  show(project.configsets, finder.find_all, "project")

  blueprint = Lono::Configset::Register::Blueprint.new(@options)
  blueprint.register
  finder = Lono::Finder::Blueprint::Configset.new
  finder.list("Configsets available to #{@blueprint} blueprint:") if @options[:verbose]
  puts "Configsets built into the blueprint:" if @options[:verbose]
  show(blueprint.configsets, finder.find_all, "blueprint")

  table = Text::Table.new
  table.head = ["Name", "Path", "Type", "From"]
  @final.each do |spec|
    pretty_root = spec.root.sub("#{Lono.root}/",'').sub(ENV["HOME"], "~")
    table.rows << [spec.name, pretty_root, spec.source_type, spec.from]
  end

  if table.rows.empty?
    puts "No configsets being used."
  else
    puts "Configsets used by #{@blueprint.color(:green)} blueprint:"
    puts table
  end
end

#project_configsetsObject



18
19
20
# File 'lib/lono/configset/list.rb', line 18

def project_configsets
  Lono::Finder::Configset.list(filter_materialized: true, message: "Project configsets:")
end

#runObject



10
11
12
13
14
15
16
# File 'lib/lono/configset/list.rb', line 10

def run
  if @blueprint
    blueprint_configsets
  else
    project_configsets
  end
end

#show(configsets, all, from) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/lono/configset/list.rb', line 56

def show(configsets, all, from)
  configsets.each do |c|
    puts "    #{c.name}" if @options[:verbose]
    spec = all.find { |jadespec| jadespec.name == c.name }
    next unless spec
    spec.from = from
    @final << spec
  end
  puts "" if @options[:verbose]
end