Class: AssUpdater
- Inherits:
-
Object
- Object
- AssUpdater
- Defined in:
- lib/ass_updater.rb,
lib/ass_updater/http.rb,
lib/ass_updater/version.rb,
lib/ass_updater/ass_version.rb,
lib/ass_updater/update_info.rb,
lib/ass_updater/update_distrib.rb,
lib/ass_updater/update_history.rb,
lib/ass_updater/update_info_service.rb
Overview
– encoding utf-8
Defined Under Namespace
Classes: AssVersion, Error, HTTP, UpdateDistrib, UpdateHistory, UpdateInfo, UpdateInfoService
Constant Summary collapse
- PLATFORM_VERSIONS =
{ :"8.2" => '8.2', :"8.3" => '8.3' }
- KNOWN_CONF_CODENAME =
{ HRM: 'Зарплата и управление персоналом', Accounting: 'Бухгалтерия предприятия', AccountingKz: 'Бухгалтерия для Казахстана' }
- UPDATEREPO_BASE =
'http://downloads.v8.1c.ru/tmplts/'
- UPDATEINFO_BASE =
'http://downloads.1c.ru/ipp/ITSREPV/V8Update/Configs/'
- UPD11_ZIP =
'v8upd11.zip'
- VERSION =
'0.1.1'
Instance Attribute Summary collapse
-
#conf_code_name ⇒ String
readonly
See arguments of #initialize.
-
#conf_redaction ⇒ String
readonly
See arguments of #initialize.
-
#http ⇒ AssUpdater::HTTP
Object for access to 1C services.
-
#platform_version ⇒ String
readonly
See arguments of #initialize.
Instance Method Summary collapse
-
#get_update(user, password, version, tmplt_root) ⇒ AssUpdater::UpdateDistrib
Implement work with distributives of configuration update.
-
#get_updates(user, password, versions, tmplt_root) {|AssUpdater::UpdateDistrib| ... } ⇒ Array<AssUpdater::UpdateDistrib>
Get updates included in array <versions>.
-
#initialize(conf_code_name, conf_redaction, platform_version = PLATFORM_VERSIONS.keys.last) { ... } ⇒ AssUpdater
constructor
A new instance of AssUpdater.
-
#instaled_distribs(tmplt_root) ⇒ Array<AssUpdater::UpdateDistrib>
Return all instaled updates findet in 1C templates directory.
-
#instaled_versions(tmplt_root) ⇒ Array<AssUpdater::AssVersion>
Return versions all instaled updates finded in 1C templates directory <tmplt_root>.
-
#new_update_distrib(version, tmplt_root) ⇒ AssUpdater::UpdateDistrib
Wrapper return UpdateDistrib object.
-
#required_versions_for_update(from_ver = nil, to_ver = nil) ⇒ Array<AssUpdater::AssVersion>
Evaluate versions required for update configuration from version <from_ver> to version <to_ver>.
-
#update_history ⇒ Hash
Return updates history from v8upd11.xml.
-
#update_info ⇒ AssUpdater::UpdateInfo
Return info about last configuration release from file UpdInfo.txt.
Constructor Details
#initialize(conf_code_name, conf_redaction, platform_version = PLATFORM_VERSIONS.keys.last) { ... } ⇒ AssUpdater
Returns a new instance of AssUpdater.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ass_updater.rb', line 43 def initialize(conf_code_name, conf_redaction, platform_version = PLATFORM_VERSIONS.keys.last ) @conf_code_name = conf_code_name @http = AssUpdater::HTTP.new @conf_redaction = AssUpdater.valid_redaction(conf_redaction) @platform_version = AssUpdater.valid_platform_version(platform_version) yield self if block_given? end |
Instance Attribute Details
#conf_code_name ⇒ String (readonly)
See arguments of #initialize
29 30 31 |
# File 'lib/ass_updater.rb', line 29 def conf_code_name @conf_code_name end |
#conf_redaction ⇒ String (readonly)
See arguments of #initialize
29 30 31 |
# File 'lib/ass_updater.rb', line 29 def conf_redaction @conf_redaction end |
#http ⇒ AssUpdater::HTTP
Object for access to 1C services. It’s public for configure http connection.
32 33 34 |
# File 'lib/ass_updater.rb', line 32 def http @http end |
#platform_version ⇒ String (readonly)
See arguments of #initialize
29 30 31 |
# File 'lib/ass_updater.rb', line 29 def platform_version @platform_version end |
Instance Method Details
#get_update(user, password, version, tmplt_root) ⇒ AssUpdater::UpdateDistrib
Require authorization.
Service downloads.v8.1c.ru often unavailable and it fail on timeout. Don’t worry and try again.
Implement work with distributives of configuration update
103 104 105 106 |
# File 'lib/ass_updater.rb', line 103 def get_update(user, password, version, tmplt_root) distrib = new_update_distrib(version, tmplt_root) distrib.get(user, password) end |
#get_updates(user, password, versions, tmplt_root) {|AssUpdater::UpdateDistrib| ... } ⇒ Array<AssUpdater::UpdateDistrib>
Get updates included in array <versions>. See #get_update
115 116 117 118 119 120 121 122 |
# File 'lib/ass_updater.rb', line 115 def get_updates(user, password, versions, tmplt_root) r = [] versions.each do |version| r << get_update(user, password, version, tmplt_root) yield r.last if block_given? end r end |
#instaled_distribs(tmplt_root) ⇒ Array<AssUpdater::UpdateDistrib>
return distirbs present in #update_history only
Return all instaled updates findet in 1C templates directory
144 145 146 147 148 149 150 151 152 |
# File 'lib/ass_updater.rb', line 144 def instaled_distribs(tmplt_root) instaled_versions(tmplt_root).map do |v| begin new_update_distrib(v, tmplt_root) rescue AssUpdater::Error nil end end.compact end |
#instaled_versions(tmplt_root) ⇒ Array<AssUpdater::AssVersion>
Return versions all instaled updates finded in 1C templates directory <tmplt_root>
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ass_updater.rb', line 128 def instaled_versions(tmplt_root) (Dir.entries(conf_distribs_local_path(tmplt_root)).map do |e| next if e == '.' || e == '..' begin v = AssUpdater::AssVersion.new(e.split('_').join('.')) v if v.redaction == conf_redaction rescue ArgumentError nil end end).compact end |
#new_update_distrib(version, tmplt_root) ⇒ AssUpdater::UpdateDistrib
Wrapper return UpdateDistrib object
158 159 160 |
# File 'lib/ass_updater.rb', line 158 def new_update_distrib(version, tmplt_root) AssUpdater::UpdateDistrib.new(version, tmplt_root, self) end |
#required_versions_for_update(from_ver = nil, to_ver = nil) ⇒ Array<AssUpdater::AssVersion>
Evaluate versions required for update configuration from version <from_ver> to version <to_ver>. Return array iclude <to_ver> and exclude <from_ver> If called whithout arguments return versions required for update from version ‘0.0.0.0’ to last release.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ass_updater.rb', line 79 def required_versions_for_update(from_ver = nil, to_ver = nil) from_ver = AssUpdater::AssVersion.new(from_ver) to_ver = AssUpdater::AssVersion.new(to_ver || update_history.max_version) if from_ver >= to_ver fail ArgumentError, 'from_ver must be less than to_ver' end r = [] c_ver = to_ver loop do r << c_ver targets = update_history.target c_ver break if targets.size == 0 || targets.index(from_ver) c_ver = targets.min end r end |
#update_history ⇒ Hash
Service downloads.1c.ru often unavailable and initialize fail on timeout. Don’t worry and try again.
Return updates history from v8upd11.xml
64 65 66 |
# File 'lib/ass_updater.rb', line 64 def update_history @update_history ||= AssUpdater::UpdateHistory.new(self) end |
#update_info ⇒ AssUpdater::UpdateInfo
Return info about last configuration release from file UpdInfo.txt
57 58 59 |
# File 'lib/ass_updater.rb', line 57 def update_info @update_info ||= AssUpdater::UpdateInfo.new(self) end |