Module: ConfCtl::Cli::Swpins::Utils

Included in:
Base, Channel, Cluster, Core
Defined in:
lib/confctl/cli/swpins/utils.rb

Instance Method Summary collapse

Instance Method Details

#channel_list(pattern) ⇒ Object



22
23
24
# File 'lib/confctl/cli/swpins/utils.rb', line 22

def channel_list(pattern)
  ConfCtl::Swpins::ChannelList.pattern(pattern)
end

#cluster_name_list(pattern) ⇒ Object



3
4
5
# File 'lib/confctl/cli/swpins/utils.rb', line 3

def cluster_name_list(pattern)
  ConfCtl::Swpins::ClusterNameList.new(pattern:)
end

#each_channel(chan_pattern) ⇒ Object



26
27
28
29
30
31
# File 'lib/confctl/cli/swpins/utils.rb', line 26

def each_channel(chan_pattern)
  channel_list(chan_pattern).each do |chan|
    chan.parse
    yield(chan)
  end
end

#each_channel_spec(chan_pattern, sw_pattern) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/confctl/cli/swpins/utils.rb', line 33

def each_channel_spec(chan_pattern, sw_pattern)
  each_channel(chan_pattern) do |chan|
    chan.specs.each do |name, spec|
      yield(chan, spec) if ConfCtl::Pattern.match?(sw_pattern, name)
    end
  end
end

#each_cluster_name(cn_pattern) ⇒ Object



7
8
9
10
11
12
# File 'lib/confctl/cli/swpins/utils.rb', line 7

def each_cluster_name(cn_pattern)
  cluster_name_list(cn_pattern).each do |cn|
    cn.parse
    yield(cn)
  end
end

#each_cluster_name_spec(cn_pattern, sw_pattern) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/confctl/cli/swpins/utils.rb', line 14

def each_cluster_name_spec(cn_pattern, sw_pattern)
  each_cluster_name(cn_pattern) do |cn|
    cn.specs.each do |name, spec|
      yield(cn, spec) if ConfCtl::Pattern.match?(sw_pattern, name)
    end
  end
end

#spec_set_msg(parent, spec) ⇒ Object



41
42
43
44
45
46
# File 'lib/confctl/cli/swpins/utils.rb', line 41

def spec_set_msg(parent, spec)
  $stdout.write("Configuring #{spec.name} in #{parent.name}")
  $stdout.flush
  yield
  puts " -> #{spec.version}"
end

#spec_update_msg(parent, spec) ⇒ Object



48
49
50
51
52
53
# File 'lib/confctl/cli/swpins/utils.rb', line 48

def spec_update_msg(parent, spec)
  $stdout.write("Updating #{spec.name} in #{parent.name}")
  $stdout.flush
  yield
  puts " -> #{spec.version}"
end