Class: AssOle::AppExtension::Abstract::Extension Abstract
- Inherits:
-
Object
- Object
- AssOle::AppExtension::Abstract::Extension
- Includes:
- AbstractMethods, Snippets::Shared::AppCompatibility
- Defined in:
- lib/ass_ole/app_extension.rb
Overview
Docs for mixin AssOle::Snippets::Shared::AppCompatibility
Class parent for all extensions. Define your own class and override methods from AbstractMethods
Direct Known Subclasses
Defined Under Namespace
Modules: AbstractMethods
Instance Attribute Summary collapse
-
#ole_runtime ⇒ Object
readonly
see
ole_runtimeof #initialize. -
#safe_mode ⇒ Object
readonly
see
safe_modeof #initialize.
Instance Method Summary collapse
-
#all_extensions ⇒ Array<WIN32OLE>
Array of all application extensions.
-
#app_name ⇒ String
Application configuration name
metaData.Name. -
#app_version ⇒ Gem::Version
Application configuration version
metaData.Version. -
#apply_errors ⇒ Array<WIN32OLE>
Critical
ConfigurationExtensionApplicationIssueInformation. - #apply_errors_get(ext_data) ⇒ Object
-
#apply_warnings ⇒ Array<WIN32OLE>
Not critical
ConfigurationExtensionApplicationIssueInformation. -
#can_apply? ⇒ Boolean
Checks the possibility plugging extension.
-
#exist? ⇒ Boolean
Return
trueif extension stored in infobase. -
#initialize(ole_runtime, safe_mode = nil) ⇒ Extension
constructor
A new instance of Extension.
-
#ole ⇒ WIN32OLE
Extension ole object.
-
#ole_connector ⇒ Object
1C ole connector.
-
#plug ⇒ self
(also: #write)
Plug extension.
-
#plug! ⇒ self
(also: #write!)
Force plug without check #plugged?, #verify! and #can_apply?.
-
#plugged? ⇒ Boolean
Return
trueif extension #exist? and stored data can be applyed without errors. -
#save_stored_data(dir) ⇒ String
Save actual stored extension data to file.
-
#unplug! ⇒ self
(also: #delete!)
Unplug extension.
- #verify! ⇒ Object
- #verify_application! ⇒ Object private
- #verify_version_compatibility! ⇒ Object private
Methods included from AbstractMethods
#app_requirements, #data, #name, #platform_require, #version
Constructor Details
#initialize(ole_runtime, safe_mode = nil) ⇒ Extension
Returns a new instance of Extension.
151 152 153 154 |
# File 'lib/ass_ole/app_extension.rb', line 151 def initialize(ole_runtime, safe_mode = nil) @ole_runtime = ole_runtime @safe_mode = safe_mode end |
Instance Attribute Details
#ole_runtime ⇒ Object (readonly)
see ole_runtime of #initialize
142 143 144 |
# File 'lib/ass_ole/app_extension.rb', line 142 def ole_runtime @ole_runtime end |
#safe_mode ⇒ Object (readonly)
see safe_mode of #initialize
145 146 147 |
# File 'lib/ass_ole/app_extension.rb', line 145 def safe_mode @safe_mode end |
Instance Method Details
#all_extensions ⇒ Array<WIN32OLE>
Array of all application extensions.
272 273 274 275 276 277 278 |
# File 'lib/ass_ole/app_extension.rb', line 272 def all_extensions r = [] manager.Get.each do |ext| r << ext end r end |
#app_name ⇒ String
Returns application configuration name metaData.Name.
304 305 306 |
# File 'lib/ass_ole/app_extension.rb', line 304 def app_name .Name end |
#app_version ⇒ Gem::Version
Returns application configuration version metaData.Version.
310 311 312 |
# File 'lib/ass_ole/app_extension.rb', line 310 def app_version Gem::Version.new(.Version) end |
#apply_errors ⇒ Array<WIN32OLE>
Critical ConfigurationExtensionApplicationIssueInformation. If you have such problems, extension will not be connected.
208 209 210 |
# File 'lib/ass_ole/app_extension.rb', line 208 def apply_errors apply_errors_get(data) end |
#apply_errors_get(ext_data) ⇒ Object
230 231 232 233 234 |
# File 'lib/ass_ole/app_extension.rb', line 230 def apply_errors_get(ext_data) apply_problems_get(ext_data).select do |problem| sTring(problem.Severity) =~ %r{(Критичная|Critical)} end end |
#apply_warnings ⇒ Array<WIN32OLE>
Not critical ConfigurationExtensionApplicationIssueInformation. If you have such problems, extension will be connected.
215 216 217 218 219 |
# File 'lib/ass_ole/app_extension.rb', line 215 def apply_warnings apply_problems_get(data).select do |problem| (sTring(problem.Severity) =~ %r{(Критичная|Critical)}).nil? end end |
#can_apply? ⇒ Boolean
Checks the possibility plugging extension
239 240 241 242 243 244 245 |
# File 'lib/ass_ole/app_extension.rb', line 239 def can_apply? errors = apply_errors fail ApplyError, "Extension can't be applied:\n"\ " - #{errors.map(&:Description).join("\n - ")} " if\ errors.size > 0 true end |
#exist? ⇒ Boolean
Return true if extension stored in infobase
248 249 250 |
# File 'lib/ass_ole/app_extension.rb', line 248 def exist? !find_exists.nil? end |
#ole ⇒ WIN32OLE
Extension ole object.
288 289 290 |
# File 'lib/ass_ole/app_extension.rb', line 288 def ole @ole ||= ole_get end |
#ole_connector ⇒ Object
Returns 1C ole connector.
293 294 295 |
# File 'lib/ass_ole/app_extension.rb', line 293 def ole_connector ole_runtime.ole_connector end |
#plug ⇒ self Also known as: write
Plug extension. Do nothing if extension already plugged!
160 161 162 163 164 165 |
# File 'lib/ass_ole/app_extension.rb', line 160 def plug return self if plugged? verify! can_apply? && unsafe_mode_set.Write(data) self end |
#plug! ⇒ self Also known as: write!
Force plug without check #plugged?, #verify! and #can_apply?
170 171 172 173 |
# File 'lib/ass_ole/app_extension.rb', line 170 def plug! unsafe_mode_set.Write(data) self end |
#plugged? ⇒ Boolean
Return true if extension #exist? and stored data can be applyed without errors
254 255 256 |
# File 'lib/ass_ole/app_extension.rb', line 254 def plugged? exist? && apply_errors_get(ole.GetData).size == 0 end |
#save_stored_data(dir) ⇒ String
Save actual stored extension data to file
339 340 341 342 343 344 |
# File 'lib/ass_ole/app_extension.rb', line 339 def save_stored_data(dir) return unless exist? file = File.join(dir, "#{name}.#{Gem::Version.new(ole.Version)}.cfe") ole.GetData.Write(real_win_path(file)) file end |
#unplug! ⇒ self Also known as: delete!
Unplug extension. Do nothing unless extension plugged.
178 179 180 181 182 |
# File 'lib/ass_ole/app_extension.rb', line 178 def unplug! return self unless exist? ole.Delete self end |
#verify! ⇒ Object
298 299 300 301 |
# File 'lib/ass_ole/app_extension.rb', line 298 def verify! verify_version_compatibility! verify_application! end |
#verify_application! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/ass_ole/app_extension.rb', line 323 def verify_application! return unless app_requirements req = app_requirements[app_name.to_sym] fail IncompatibleError, "Unsupported application `#{app_name}`."\ " Supported:\n - #{app_requirements.keys.join("\n - ")}" unless req fail IncompatibleError, 'Unsupported application version'\ " `#{app_version}`. Require version #{req}" unless\ Gem::Requirement.new(req).satisfied_by? app_version end |
#verify_version_compatibility! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
315 316 317 318 319 320 |
# File 'lib/ass_ole/app_extension.rb', line 315 def verify_version_compatibility! fail IncompatibleError, "Require application compatibility "\ "`#{platform_require}`. Got application compatibility version"\ " `#{app_compatibility_version}`" unless\ platform_require.satisfied_by? app_compatibility_version end |