class AssUpdater

AssUpdater - make easy download and install updates for 1C configuration from service dounloads.v8.1c.ru. For read more about 1C configurations visit site v8.1c.ru

Constants

KNOWN_CONF_CODENAME
PLATFORM_VERSIONS
UPD11_ZIP
UPDATEINFO_BASE
UPDATEREPO_BASE
VERSION

Attributes

conf_code_name[R]

See arguments of {#initialize} @return [String]

conf_redaction[R]

See arguments of {#initialize} @return [String]

http[RW]

Object for access to 1C services. It's public for configure http connection. @return [AssUpdater::HTTP]

platform_version[R]

See arguments of {#initialize} @return [String]

Public Class Methods

new(conf_code_name, conf_redaction, platform_version = PLATFORM_VERSIONS.keys.last ) { |self| ... } click to toggle source

@param conf_code_name [String] code name of configuration @param conf_redaction [String] redaction is major version nuber of

configuration. See {AssUpdater::AssVersion#redaction}

@param platform_version [String] major version namber of target platform

1C:Enterprese.

@yield self. It's good place for configure http object. See

{AssUpdater::HTTP}

@raise [AssUpdater::Error] if given invalid <conf_redaction> or

<platform_version>
# 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

Private Class Methods

valid_platform_version(v) click to toggle source
# File lib/ass_updater.rb, line 168
def self.valid_platform_version(v)
  unless PLATFORM_VERSIONS.key?(v.to_sym)
    fail AssUpdater::Error,
         "Invalid platform_version `#{v}'."\
         "Support #{PLATFORM_VERSIONS.keys.join(' | ')} versions only."
  end
  PLATFORM_VERSIONS[v.to_sym]
end
valid_redaction(r) click to toggle source
# File lib/ass_updater.rb, line 177
def self.valid_redaction(r)
  fail AssUpdater::Error, "Invalid redaction #{r}" unless r =~ /\d\.\d/
  r
end

Public Instance Methods

get_update(user, password, version, tmplt_root) click to toggle source

(see AssUpdater::UpdateDistrib) @note (see AssUpdater::UpdateDistrib#get) @param user (see AssUpdater::UpdateDistrib#get) @param password (see AssUpdater::UpdateDistrib#get) @param version (see AssUpdater::UpdateDistrib#initialize) @param tmplt_root (see AssUpdater::UpdateDistrib#initialize) @return (see AssUpdater::UpdateDistrib#get)

# 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) { |last| ... } click to toggle source

Get updates included in array <versions>. See {#get_update} @param user (see get_update) @param password (see get_update) @param versions [Array<String,AssUpdater::AssVersion>] @param tmplt_root (see get_update) @return [Array<AssUpdater::UpdateDistrib>] returned {#get_update} @yield [AssUpdater::UpdateDistrib] for each getted distrib

# 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) click to toggle source

Return all instaled updates findet in 1C templates directory @note return distirbs present in {#update_history} only @param tmplt_root (see get_update) @return [Array<AssUpdater::UpdateDistrib>]

# 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) click to toggle source

Return versions all instaled updates finded in 1C templates directory <tmplt_root> @param tmplt_root (see get_update) @return [Array<AssUpdater::AssVersion>]

# 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) click to toggle source

Wrapper return UpdateDistrib object @param version (see get_update) @param tmplt_root (see get_update) @return [AssUpdater::UpdateDistrib]

# 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) click to toggle source

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. @param from_ver [String,AssUpdater::AssVersion] if nil from_ver set to

'0.0.0.0'

@param to_ver [String,AssUpdater::AssVersion] if nill to_ver set to last

release

@return [Array<AssUpdater::AssVersion>] @raise [ArgumentError] if <from_ver> more then <to_ver>

# 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() click to toggle source

Return updates history from v8upd11.xml @note (see AssUpdater::UpdateHistory) @return [Hash]

# File lib/ass_updater.rb, line 64
def update_history
  @update_history ||= AssUpdater::UpdateHistory.new(self)
end
update_info() click to toggle source

Return info about last configuration release from file UpdInfo.txt @note (see AssUpdater::UpdateInfo) @return [AssUpdater::UpdateInfo]

# File lib/ass_updater.rb, line 57
def update_info
  @update_info ||= AssUpdater::UpdateInfo.new(self)
end

Private Instance Methods

conf_distribs_local_path(tmplt_root) click to toggle source
# File lib/ass_updater.rb, line 164
def conf_distribs_local_path(tmplt_root)
  File.join(tmplt_root, '1c', conf_code_name)
end