Class: Xezat::Command::Doctor

Inherits:
Object
  • Object
show all
Includes:
Xezat
Defined in:
lib/xezat/command/doctor.rb

Constant Summary

Constants included from Xezat

Xezat::CONFIG_FILE, DATA_DIR, REPOSITORY_DIR, ROOT_DIR, TEMPLATE_DIR, VERSION

Instance Method Summary collapse

Methods included from Xezat

#config, #packages, #print_yaml, #variables

Instance Method Details

#executeObject



10
11
12
13
14
# File 'lib/xezat/command/doctor.rb', line 10

def execute
  get_contents_uniqueness.each do |path, pkg|
    puts "#{path} is not unique: #{pkg}" if pkg.length > 1
  end
end

#get_contents_uniqueness(path = '/etc/setup') ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/xezat/command/doctor.rb', line 16

def get_contents_uniqueness(path = '/etc/setup')
  content2pkg = {}
  Dir.glob(File.join(path, '*.lst.gz')) do |lst|
    pkg = File.basename(lst, '.lst.gz').intern
    Zlib::GzipReader.open(lst) do |gz|
      gz.each_line do |line|
        line.strip!
        next if line.end_with?('/')

        path = line.intern
        content2pkg[path] = [] unless content2pkg.key?(path)
        content2pkg[path] << pkg
      end
    end
  end
  content2pkg
end