Method: ConfCtl::Swpins::Core#parse

Defined in:
lib/confctl/swpins/core.rb

#parseObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/confctl/swpins/core.rb', line 42

def parse
  @specs = {}

  # Add specs from channels
  channels.each do |chan|
    chan.specs.each do |name, chan_spec|
      s = chan_spec.clone
      s.channel = chan.name
      specs[name] = s
    end
  end

  # Add core-specific specs
  @json_specs = if File.exist?(path)
                  JSON.parse(File.read(path))
                else
                  {}
                end

  nix_specs.each do |name, nix_opts|
    specs[name] = Swpins::Spec.for(nix_opts['type'].to_sym).new(
      name,
      nix_opts[nix_opts['type']],
      json_specs[name]
    )
  end
end