Class: AssMaintainer::InfoBase
- Inherits:
-
Object
- Object
- AssMaintainer::InfoBase
- Extended by:
- AssLauncher::Api
- Includes:
- Interfaces::InfoBase
- Defined in:
- lib/ass_maintainer/info_base.rb,
lib/ass_maintainer/info_base/cfg.rb,
lib/ass_maintainer/info_base/config.rb,
lib/ass_maintainer/info_base/file_ib.rb,
lib/ass_maintainer/info_base/version.rb,
lib/ass_maintainer/info_base/server_ib.rb,
lib/ass_maintainer/info_base/interfaces.rb,
lib/ass_maintainer/info_base/default_maker.rb,
lib/ass_maintainer/info_base/server_ib/enterprise_servers.rb,
lib/ass_maintainer/info_base/server_ib/enterprise_servers/cluster.rb,
lib/ass_maintainer/info_base/server_ib/enterprise_servers/support.rb,
lib/ass_maintainer/info_base/server_ib/enterprise_servers/server_agent.rb,
lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb
Overview
Class for manipulate with 1C:Enterprise application instance aka
information base or infobase
Instances of this class has dynamically generated interface
1C:Enterprise application may be deployed as file (aka file infobase) or on a 1C:Enterprise server (aka server infobase). In the #initialize instance of will be extended by suitable module:
- server infobase instance will be extended by ServerIb module
- file infobase instance will be extended by FileIb module
Both instances types inherits methods from Interfaces::InfoBase
All instances gets methods for access to #options see InfoBase.build_options_wrapper
Defined Under Namespace
Modules: Abstract, FileIb, Interfaces, ServerIb Classes: Cfg, Config, DbCfg, DefaultMaker, LockError, MethodDenied, Session, UnlockError
Constant Summary collapse
- DEFAULT_SAGENT_PORT =
Deafult port for connect to 1C:Enterprise server agent
'1540'- HOOKS =
Hooks before and after make and remove infobase. Hooks may be passed as options or seted later see #add_hook
{ before_make: ->(ib) {}, after_make: ->(ib) {}, before_rm: ->(ib) {}, after_rm: ->(ib) {} }
- WORKERS =
On default for make and remove infobase uses DefaultMaker and FileIb::FileBaseDestroyer or ServerIb::ServerBaseDestroyer but we can pass custom maker and destroyer as #options. Maker and destroyer must implements Interfaces::IbMaker and Interfaces::IbDestroyer
{ maker: nil, destroyer: nil }
- ARGUMENTS =
:platform_requireRequired 1C:Enterprise version:sagent_hostHost name of 1C:Enterprise server agent:sagent_portTCP port of 1C:Enterprise server agent on default DEFAULT_SAGENT_PORT:sagent_usrAdmin for 1C:Enterprise server agent:sagent_pwdAdmin password for 1C:Enterprise server agent:cluster_usrAdmin for 1C:Enterprise cluster.:cluster_pwdPasword Admin for 1C:Enterprise cluster.:unlock_codeCode for connect to locked infobase aka "/UC" parameter
{ platform_require: nil, sagent_host: nil, sagent_port: nil, sagent_usr: nil, sagent_pwd: nil, cluster_usr: nil, cluster_pwd: nil, unlock_code: nil }
- OPTIONS =
(ARGUMENTS.merge HOOKS).merge WORKERS
- ASS_PLATFORM_REQUIRE =
ENV['ASS_PLATFORM_REQUIRE'] || '> 0'
- VERSION =
'1.0.0'
Instance Attribute Summary collapse
-
#connection_string ⇒ Object
readonly
see #initialize
connection_string. -
#name ⇒ Object
readonly
see #initialize
name. -
#options ⇒ Object
readonly
see #initialize
options. -
#read_only ⇒ Object
(also: #read_only?)
readonly
InfoBase is read only destructive methods fails with MethodDenied error.
Class Method Summary collapse
-
.build_options_wrapper ⇒ Object
Dinamicaly builds of options wrappers.
-
.config ⇒ Config
Get settings.
-
.configure {|config| ... } ⇒ Object
Make settings.
Instance Method Summary collapse
-
#add_hook(hook, &block) ⇒ Object
Add hook.
-
#cfg ⇒ Cfg nil
Returns instance for manipuate with databse configuration.
-
#common_args ⇒ Object
Common arguments for all commands.
-
#db_cfg ⇒ DbCfg nil
Returns instance for manipuate with InfoBase database.
-
#designer(&block) ⇒ AssLauncher::Support::Shell::Command
Build command for run designer block will be passed to arguments builder.
-
#dump(path) ⇒ Object
Dump infobase to
.dtfile. -
#enterprise(client, &block) ⇒ AssLauncher::Support::Shell::Command
Build command for run enterprise block will be passed to arguments builder.
-
#initialize(name, connection_string, read_only = true, **options) {|_self| ... } ⇒ InfoBase
constructor
A new instance of InfoBase.
-
#is ⇒ Symbol
Returns type of infobase.
-
#is?(type) ⇒ Boolean
Check type of infobase.
-
#locale ⇒ String
Get locale.
-
#locale=(l) ⇒ Object
Set locale.
-
#make ⇒ Object
Make new empty infobase wrpped in
before_makeandafter_makehooks. -
#ole(type) ⇒ Object
Get ole connector specified in
typeparameter. -
#platform_require ⇒ String
Requrement 1C version.
-
#pwd ⇒ String
(also: #password)
User password.
-
#pwd=(password) ⇒ Object
(also: #password=)
Set user password.
- #rebuild!(sure = :no) ⇒ Object
-
#restore!(path) ⇒ Object
Restore infobase from
.dtfile. -
#rm!(sure = :no) ⇒ Object
Remove infobase wrpped in
before_rmandafter_rmhooks. - #thick ⇒ AssLauncher::Enterprise::BinaryWrapper::ThickClient
- #thin ⇒ AssLauncher::Enterprise::BinaryWrapper::ThinClient
-
#usr ⇒ String
(also: #user)
User name.
-
#usr=(user_name) ⇒ Object
(also: #user=)
Set user name.
Methods included from Interfaces::InfoBase
#exists?, #lock, #lock_schjobs, #locked?, #sessions, #unlock, #unlock!, #unlock_schjobs
Constructor Details
#initialize(name, connection_string, read_only = true, **options) {|_self| ... } ⇒ InfoBase
Returns a new instance of InfoBase.
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ass_maintainer/info_base.rb', line 114 def initialize(name, connection_string, read_only = true, **) @name = name @connection_string = self.class.cs(connection_string.to_s) @read_only = read_only @options = () case self.connection_string.is when :file then extend FileIb when :server then extend ServerIb else fail ArgumentError end yield self if block_given? end |
Instance Attribute Details
#connection_string ⇒ Object (readonly)
see #initialize connection_string
102 103 104 |
# File 'lib/ass_maintainer/info_base.rb', line 102 def connection_string @connection_string end |
#name ⇒ Object (readonly)
see #initialize name
100 101 102 |
# File 'lib/ass_maintainer/info_base.rb', line 100 def name @name end |
#options ⇒ Object (readonly)
see #initialize options
104 105 106 |
# File 'lib/ass_maintainer/info_base.rb', line 104 def @options end |
#read_only ⇒ Object (readonly) Also known as: read_only?
InfoBase is read only destructive methods fails with MethodDenied error
107 108 109 |
# File 'lib/ass_maintainer/info_base.rb', line 107 def read_only @read_only end |
Class Method Details
.build_options_wrapper ⇒ Object
Dinamicaly builds of options wrappers
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ass_maintainer/info_base.rb', line 83 def self. OPTIONS.each_key do |key| next if WORKERS.keys.include? key define_method key do [key] end next if HOOKS.keys.include? key define_method "#{key}=".to_sym do |arg| [key] = arg end end end |
.config ⇒ Config
Get settings
24 25 26 |
# File 'lib/ass_maintainer/info_base/config.rb', line 24 def self.config @config ||= Config.new end |
.configure {|config| ... } ⇒ Object
Make settings
18 19 20 |
# File 'lib/ass_maintainer/info_base/config.rb', line 18 def self.configure yield config end |
Instance Method Details
#add_hook(hook, &block) ⇒ Object
Add hook. In all hook whill be passed self
137 138 139 140 141 142 |
# File 'lib/ass_maintainer/info_base.rb', line 137 def add_hook(hook, &block) fail ArgumentError, "Invalid hook `#{hook}'" unless\ HOOKS.keys.include? hook fail ArgumentError, 'Block require' unless block_given? [hook] = block end |
#cfg ⇒ Cfg nil
Returns instance for manipuate with databse configuration. If infobase not exists returns nil
289 290 291 |
# File 'lib/ass_maintainer/info_base.rb', line 289 def cfg @cfg ||= Cfg.new(self) if exists? end |
#common_args ⇒ Object
Common arguments for all commands
252 253 254 255 256 257 |
# File 'lib/ass_maintainer/info_base.rb', line 252 def common_args r = [] r += ['/L', locale] if locale r += ['/UC', unlock_code] if unlock_code r end |
#db_cfg ⇒ DbCfg nil
Returns instance for manipuate with InfoBase database. If infobase not exists returns nil
281 282 283 |
# File 'lib/ass_maintainer/info_base.rb', line 281 def db_cfg @db_cfg ||= DbCfg.new(self) if exists? end |
#designer(&block) ⇒ AssLauncher::Support::Shell::Command
Build command for run designer block will be passed to arguments builder
225 226 227 |
# File 'lib/ass_maintainer/info_base.rb', line 225 def designer(&block) command(:thick, :designer, &block) end |
#dump(path) ⇒ Object
Dump infobase to .dt file
260 261 262 263 264 265 |
# File 'lib/ass_maintainer/info_base.rb', line 260 def dump(path) designer do dumpIB path end.run.wait.result.verify! path end |
#enterprise(client, &block) ⇒ AssLauncher::Support::Shell::Command
Build command for run enterprise block will be passed to arguments builder
233 234 235 |
# File 'lib/ass_maintainer/info_base.rb', line 233 def enterprise(client, &block) command(client, :enterprise, &block) end |
#is ⇒ Symbol
Returns type of infobase
295 296 297 |
# File 'lib/ass_maintainer/info_base.rb', line 295 def is connection_string.is end |
#is?(type) ⇒ Boolean
Check type of infobase
301 302 303 |
# File 'lib/ass_maintainer/info_base.rb', line 301 def is?(type) connection_string.is?(type) end |
#locale ⇒ String
Get locale
326 327 328 |
# File 'lib/ass_maintainer/info_base.rb', line 326 def locale connection_string.locale end |
#locale=(l) ⇒ Object
Set locale
320 321 322 |
# File 'lib/ass_maintainer/info_base.rb', line 320 def locale=(l) connection_string.locale = l end |
#make ⇒ Object
Make new empty infobase
wrpped in before_make and after_make hooks
158 159 160 161 |
# File 'lib/ass_maintainer/info_base.rb', line 158 def make make_infobase! unless exists? self end |
#ole(type) ⇒ Object
Get ole connector specified in type parameter
208 209 210 |
# File 'lib/ass_maintainer/info_base.rb', line 208 def ole(type) self.class.ole(type, ole_requirement) end |
#platform_require ⇒ String
Requrement 1C version
146 147 148 |
# File 'lib/ass_maintainer/info_base.rb', line 146 def platform_require [:platform_require] || self.class.config.platform_require end |
#pwd ⇒ String Also known as: password
User password
338 339 340 |
# File 'lib/ass_maintainer/info_base.rb', line 338 def pwd connection_string.pwd end |
#pwd=(password) ⇒ Object Also known as: password=
Set user password
331 332 333 |
# File 'lib/ass_maintainer/info_base.rb', line 331 def pwd=(password) connection_string.pwd = password end |
#rebuild!(sure = :no) ⇒ Object
152 153 154 155 |
# File 'lib/ass_maintainer/info_base.rb', line 152 def rebuild!(sure = :no) rm! sure make end |
#restore!(path) ⇒ Object
Restore infobase from .dt file
269 270 271 272 273 274 275 |
# File 'lib/ass_maintainer/info_base.rb', line 269 def restore!(path) fail MethodDenied, :restore! if read_only? designer do restoreIB path end.run.wait.result.verify! path end |
#rm!(sure = :no) ⇒ Object
Remove infobase
wrpped in before_rm and after_rm hooks
176 177 178 179 180 181 |
# File 'lib/ass_maintainer/info_base.rb', line 176 def rm!(sure = :no) fail 'If you are sure pass :yes value' unless sure == :yes return unless exists? rm_infobase! nil end |
#thick ⇒ AssLauncher::Enterprise::BinaryWrapper::ThickClient
195 196 197 198 |
# File 'lib/ass_maintainer/info_base.rb', line 195 def thick self.class.thicks(platform_require).last || fail("Platform 1C #{platform_require} not found") end |
#thin ⇒ AssLauncher::Enterprise::BinaryWrapper::ThinClient
201 202 203 204 |
# File 'lib/ass_maintainer/info_base.rb', line 201 def thin self.class.thins(platform_require).last || fail("Platform 1C #{platform_require} not found") end |
#usr ⇒ String Also known as: user
User name
313 314 315 |
# File 'lib/ass_maintainer/info_base.rb', line 313 def usr connection_string.usr end |
#usr=(user_name) ⇒ Object Also known as: user=
Set user name
306 307 308 |
# File 'lib/ass_maintainer/info_base.rb', line 306 def usr=(user_name) connection_string.usr = user_name end |