Class: AssUpdater::UpdateDistrib

Inherits:
Object
  • Object
show all
Defined in:
lib/ass_updater/update_distrib.rb

Overview

Implement work with distributives of configuration update

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, tmplt_root, ass_updater) ⇒ UpdateDistrib

Returns a new instance of UpdateDistrib.

Parameters:



11
12
13
14
15
16
17
# File 'lib/ass_updater/update_distrib.rb', line 11

def initialize(version, tmplt_root, ass_updater)
  @ass_updater = ass_updater
  @version = AssUpdater::AssVersion.new(version)
  @version_info = @ass_updater.update_history[@version]
  @tmplt_root = tmplt_root.to_s.force_encoding('UTF-8')
  @target = AssUpdater::AssVersion.convert_array version_info['target']
end

Instance Attribute Details

#ass_updaterObject (readonly)

Returns the value of attribute ass_updater.



6
7
8
# File 'lib/ass_updater/update_distrib.rb', line 6

def ass_updater
  @ass_updater
end

#targetObject (readonly)

Returns the value of attribute target.



6
7
8
# File 'lib/ass_updater/update_distrib.rb', line 6

def target
  @target
end

#tmplt_rootObject (readonly)

Returns the value of attribute tmplt_root.



6
7
8
# File 'lib/ass_updater/update_distrib.rb', line 6

def tmplt_root
  @tmplt_root
end

#versionObject (readonly)

Returns the value of attribute version.



6
7
8
# File 'lib/ass_updater/update_distrib.rb', line 6

def version
  @version
end

#version_infoObject (readonly)

Returns the value of attribute version_info.



6
7
8
# File 'lib/ass_updater/update_distrib.rb', line 6

def version_info
  @version_info
end

Instance Method Details

#fileObject

Return path to distributive zip file on http server



41
42
43
# File 'lib/ass_updater/update_distrib.rb', line 41

def file
  File.join(AssUpdater::UPDATEREPO_BASE, fix_path(version_info_file))
end

#file_list(pattern = '*') ⇒ Object

Return files included in distributive. Files find in #local_path



52
53
54
55
56
# File 'lib/ass_updater/update_distrib.rb', line 52

def file_list(pattern = '*')
  Dir.glob(File.join(local_path, pattern)).map do |f|
    f.force_encoding 'UTF-8'
  end
end

#get(user, password) ⇒ AssUpdater::UpdateDistrib

Note:

Require authorization.

Note:

Service downloads.v8.1c.ru often unavailable and it fail on timeout. Don’t worry and try again.

Download <version> distributive of configuration update and uzip into tmplt_root. Exists in template_root distrib will be overwritten.

Parameters:

  • user (String)

    authorization user name

  • password (String)

    authorization password

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ass_updater/update_distrib.rb', line 27

def get(user, password)
  zip_f = Tempfile.new('1cv8_zip')
  begin
    download_distrib(zip_f, user, password)
    zip_f.rewind
    unzip_all(zip_f)
  ensure
    zip_f.close
    zip_f.unlink
  end
  self
end

#local_pathObject

Return local path where distributive installed



46
47
48
# File 'lib/ass_updater/update_distrib.rb', line 46

def local_path
  File.join(tmplt_root, File.dirname(version_info_file))
end