Class: AviraUpdateMirrors::ParseInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/avira_update_mirrors/parse_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ParseInfo

Returns a new instance of ParseInfo.



6
7
8
9
10
11
12
# File 'lib/avira_update_mirrors/parse_info.rb', line 6

def initialize(options)
  @wwwroot_dir = options[:wwwroot_dir]
  @downloads_dir = options[:downloads_dir]
  @files = {}
  @need_download_files = {}
  
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



4
5
6
# File 'lib/avira_update_mirrors/parse_info.rb', line 4

def files
  @files
end

#need_download_filesObject (readonly)

Returns the value of attribute need_download_files.



4
5
6
# File 'lib/avira_update_mirrors/parse_info.rb', line 4

def need_download_files
  @need_download_files
end

Instance Method Details

#check_files_md5 {|" checking #{@files.size} files md5"| ... } ⇒ Object

Yields:



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/avira_update_mirrors/parse_info.rb', line 21

def check_files_md5(&block)
  yield "  checking #{@files.size} files md5"
  @files.each do |fname, fzipmd5|
    fpath = File.join(@wwwroot_dir, fname)
    unless File.exist?(fpath)
      @need_download_files[fname] = fzipmd5
    else
      unless Digest::MD5.file(fpath) == fzipmd5.downcase
        @need_download_files[fname] = fzipmd5
      end
    end
  end
end

#generate_files_list(&block) ⇒ Object



14
15
16
17
18
19
# File 'lib/avira_update_mirrors/parse_info.rb', line 14

def generate_files_list(&block)
  Dir[File.join(@downloads_dir, "**", "*.info.gz")].each do |info_gz|
    yield "  reading and parsing #{info_gz}"
    parse_xml(read_gz(info_gz))
  end
end