Class: Yakka::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/yakka/rules.rb

Class Method Summary collapse

Class Method Details

.clearObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/yakka/rules.rb', line 22

def clear
  begin
    Host.empty!

    puts "[Emptying] ".color(:green) + "Done."
  rescue
    puts "[Emptying] ".color(:red) + "Can not be done."
    exit 0
  end
end

.enable(rule) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yakka/rules.rb', line 7

def enable(rule)
  begin
    clear
    
    Yakka.configuration.rules[rule].each do |host|
      Host.add(host, '127.0.0.1', true)
      
      puts "[Adding] ".color(:green) + host.underline
    end
  rescue
    puts "[Adding] ".color(:red) + "Can not be done."
    exit 0
  end
end

.listObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/yakka/rules.rb', line 33

def list
  begin
    rules = Yakka.configuration.rules
    
    puts "[Listing] ".color(:green) + "#{rules.length} rule(s):"
    rules.each_key do |key|
      puts "  #{key}"
    end
  rescue
    puts "[Listing] ".color(:red) + "Can not be done."
    exit 0
  end
end