class AssUpdater::UpdateHistory

Handle fo updtade history from v8upd11.xml @note (see AssUpdater::UpdateInfoService)

Public Instance Methods

[](version) click to toggle source

Return info about version <version> @param version [String,AssUpdater::AssVersion] @return [Hash] @raise [AssUpdater::Error] if info for version not found

# File lib/ass_updater/update_history.rb, line 35
def [](version)
  return [min_version] if version.to_s == '0.0.0.0'
  raw['update'].each do |h|
    next if h['version'] != version.to_s
    h['target'] = [] << h['target'] if h['target'].is_a? String
    return h
  end
  fail AssUpdater::Error, "Unkown version number `#{version}'"
end
all_versions() click to toggle source

Return all versions found in histry @return [Array<AssUpdater::AssVersion>]

# File lib/ass_updater/update_history.rb, line 23
def all_versions
  r = []
  raw['update'].each do |h|
    r << h['version']
  end
  AssUpdater::AssVersion.convert_array r
end
max_version() click to toggle source

Return max version from update histry @return [AssUpdater::AssVersion]

# File lib/ass_updater/update_history.rb, line 17
def max_version
  all_versions.max
end
min_version() click to toggle source

Returm min distrib version from update history @return [AssUpdater::AssVersion]

# File lib/ass_updater/update_history.rb, line 11
def min_version
  all_versions.min
end
target(version) click to toggle source

Return array of target versions for update to version <version> @param version [String,AssUpdater::AssVersion] @return [Array<AssUpdater::AssVersion>] @note (see ex

# File lib/ass_updater/update_history.rb, line 49
def target(version)
  exclude_unknown_version(
    AssUpdater::AssVersion.convert_array self[version]['target']
  )
end

Private Instance Methods

exclude_unknown_version(a) click to toggle source

@note Often ['target'] containe incorrect version number

not fonded in {#all_versions}.
# File lib/ass_updater/update_history.rb, line 60
def exclude_unknown_version(a)
  a.map do |i|
    i if all_versions.index(i)
  end.compact
end
get() click to toggle source
# File lib/ass_updater/update_history.rb, line 73
def get
  zip_f = Tempfile.new('upd11_zip')
  begin
    zip_f.write(ass_updater.http.get("#{updateinfo_path}/#{UPD11_ZIP}"))
    zip_f.rewind
    xml = unzip(zip_f)
  ensure
    zip_f.close
    zip_f.unlink
  end
  xml.force_encoding 'UTF-8'
end
parse() click to toggle source
# File lib/ass_updater/update_history.rb, line 66
def parse
  r = Nori.new(parser: :rexml,
               strip_namespaces: true).parse(get)['updateList']
  r['update'] = [] << r['update'] if r['update'].is_a? Hash
  r
end
unzip(zip_f) click to toggle source
# File lib/ass_updater/update_history.rb, line 86
def unzip(zip_f)
  xml = ''
  Zip::File.open(zip_f.path) do |zf|
    upd11_zip = zf.glob('v8cscdsc.xml').first
    unless upd11_zip
      fail AssUpdater::Error,
           "File `v8cscdsc.xml' not fount in zip `#{UPD11_ZIP}'"
    end
    xml = upd11_zip.get_input_stream.read
  end
  xml
end