Class: Recluse::CLI::Whitelist
- Inherits:
-
Thor
- Object
- Thor
- Recluse::CLI::Whitelist
- Defined in:
- lib/recluse/cli/whitelist.rb
Overview
Whitelist related commands.
Instance Method Summary collapse
- #add(name, *patterns) ⇒ Object
- #clear(name) ⇒ Object
- #list(name) ⇒ Object
- #remove(name, *patterns) ⇒ Object
Instance Method Details
#add(name, *patterns) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/recluse/cli/whitelist.rb', line 10 def add(name, *patterns) uconf = UserConfig.new '.recluse' unless uconf.exist?("#{name}.yaml") puts "Profile #{name} doesn't exist" exit(-1) end profile = uconf["#{name}.yaml"] if profile.key?('whitelist') profile['whitelist'] += patterns else profile['whitelist'] = patterns end profile.save end |
#clear(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/recluse/cli/whitelist.rb', line 37 def clear(name) uconf = UserConfig.new '.recluse' unless uconf.exist?("#{name}.yaml") puts "Profile #{name} doesn't exist" exit(-1) end profile = uconf["#{name}.yaml"] profile['whitelist'] = [] profile.save end |
#list(name) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/recluse/cli/whitelist.rb', line 48 def list(name) uconf = UserConfig.new '.recluse' unless uconf.exist?("#{name}.yaml") puts "Profile #{name} doesn't exist" exit(-1) end profile = uconf["#{name}.yaml"] profile['whitelist'].each { |pattern| puts pattern } if profile.key?('whitelist') end |
#remove(name, *patterns) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/recluse/cli/whitelist.rb', line 25 def remove(name, *patterns) uconf = UserConfig.new '.recluse' unless uconf.exist?("#{name}.yaml") puts "Profile #{name} doesn't exist" exit(-1) end profile = uconf["#{name}.yaml"] return unless profile.key?('whitelist') profile['whitelist'] -= patterns profile.save end |