Sha256: 722ac0fab2b82ffc830d9c7d4a5fe24ce356695d45cc9a9606774f84da7a9261

Contents?: true

Size: 839 Bytes

Versions: 5

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

require 'zlib'

module Xezat
  module Command
    class Doctor
      include Xezat

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

      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xezat-0.3.1 lib/xezat/command/doctor.rb
xezat-0.3.0 lib/xezat/command/doctor.rb
xezat-0.2.3 lib/xezat/command/doctor.rb
xezat-0.2.2 lib/xezat/command/doctor.rb
xezat-0.2.1 lib/xezat/command/doctor.rb