lib/ass_launcher/enterprise.rb in ass_launcher-0.1.1.alpha vs lib/ass_launcher/enterprise.rb in ass_launcher-0.2.0
- old
+ new
@@ -7,11 +7,11 @@
attr_accessor :search_path
end
# 1C:Entrprise platform abstraction layer
module Enterprise
require 'ass_launcher/enterprise/binary_wrapper'
- require 'ass_launcher/enterprise/web_clients'
+ require 'ass_launcher/enterprise/web_client'
require 'ass_launcher/enterprise/ole'
extend AssLauncher::Support::Platforms
WIN_BINARIES = { BinaryWrapper::ThinClient => '1cv8c.exe',
@@ -55,13 +55,24 @@
elsif linux?
LINUX_BINARIES[klass]
end
end
+ # Caching {BinaryWrapper} instances
+ # @api private
+ # @return [Hash]
+ def self.binary_wrappers_cache
+ @binary_wrappers_cache ||= {}
+ end
+
def self.find_clients(klass)
find_binaries(binaries(klass)).map do |binpath|
- klass.new(binpath)
+ if binary_wrappers_cache.key?(binpath)
+ binary_wrappers_cache[binpath]
+ else
+ binary_wrappers_cache[binpath] = klass.new(binpath)
+ end
end
end
private_class_method :find_clients
def self.requiremet?(client, requiremet)
@@ -89,23 +100,39 @@
find_clients(BinaryWrapper::ThickClient).map do |c|
c if requiremet?(c, requiremet)
end.compact
end
- # (see WebClients.client)
- def self.web_client(name)
- WebClients.client(name)
+ # @param uri (see WebClient#initialize)
+ # @param version (see WebClient#initialize)
+ # @return [AssLauncher::Enterprise::WebClient]
+ def self.web_client(uri = nil, version = nil)
+ WebClient.new(uri, version)
end
+ # Find binaries in Cygwin work slow.
+ # For rapid get binaries uses catch
+ # @return [Hash]
+ # @api private
+ def self.glob_cache
+ @glob_cache ||= {}
+ end
+
+ # Cliar {.glob_cache}
+ def self.clear_glob_cache
+ @glob_cache = nil
+ end
+
# Find and return all 1C:Entrprise binaries
# @return [Array<BinaryWrapper>]
def self.find_binaries(basename)
return [] if basename.to_s.empty?
+ return glob_cache[basename] if glob_cache.key?(basename)
r = []
search_paths.flatten.each do |sp|
r += platform.glob("#{sp}/**/#{basename}")
end
- r
+ glob_cache[basename] = r
end
private_class_method :find_binaries
end
end