Class: AssMaintainer::InfoBase
- Inherits:
-
Object
- Object
- AssMaintainer::InfoBase
- Extended by:
- AssLauncher::Api, Forwardable
- 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/helpers.rb
Overview
Class for manipulate with 1C:Enterprise application instance aka information base or infobase
Instances of this class have dinamicly generated interfaece
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 this class will be extended suitable module:
-
server infobase instance will be extend module ServerIb
-
file infobase instance will be exten module FileIb
Both instance type inherits methods from Interfaces::InfoBaseWrapper
All instances get methods wrappers for access to #options see InfoBase.build_options_wrapper
Defined Under Namespace
Modules: FileIb, Interfaces, ServerIb Classes: AbstractCfg, Cfg, Config, DbCfg, DefaultMaker, MethodDenied
Constant Summary collapse
- DEFAULT_SAGENT_PORT =
Deafult port for connect to 1C:Enterprise serever 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 =
-
:latform_requireRequired 1C:Enterprise version -
:agent_hostHost name of 1C:Enterprise server agent -
:agent_portTCP port of 1C:Enterprise server agent on default DEFAULT_SAGENT_PORT -
:agent_usrAdmin for 1C:Enterprise server agent -
:agent_pwdAdmin password for 1C:Enterprise server agent -
:laster_usrAdmin for 1C:Enterprise claster. See ServerIb#claster_usr -
:laster_pwdPasword Admin for 1C:Enterprise claster. See ServerIb#claster_pwd -
:nlock_codeCode for connect to locked infobase aka “/UC” parameter
-
{ platform_require: nil, sagent_host: nil, sagent_port: nil, sagent_usr: nil, sagent_pwd: nil, claster_usr: nil, claster_pwd: nil, unlock_code: nil }
- OPTIONS =
(ARGUMENTS.merge HOOKS).merge WORKERS
- ASS_PLATFORM_REQUIRE =
ENV['ASS_PLATFORM_REQUIRE'] || '> 0'
- VERSION =
'0.1.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 will be fail 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 ⇒ Dbase 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
User password.
-
#pwd=(password) ⇒ Object
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
User name.
-
#usr=(user_name) ⇒ Object
Set user name.
Constructor Details
#initialize(name, connection_string, read_only = true, **options) {|_self| ... } ⇒ InfoBase
Returns a new instance of InfoBase.
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ass_maintainer/info_base.rb', line 116 def initialize(name, connection_string, read_only = true, **) @name = name @connection_string = self.class.cs(connection_string.to_s) @read_only = read_only @options = OPTIONS.merge() 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
104 105 106 |
# File 'lib/ass_maintainer/info_base.rb', line 104 def connection_string @connection_string end |
#name ⇒ Object (readonly)
see #initialize name
102 103 104 |
# File 'lib/ass_maintainer/info_base.rb', line 102 def name @name end |
#options ⇒ Object (readonly)
see #initialize options
106 107 108 |
# File 'lib/ass_maintainer/info_base.rb', line 106 def @options end |
#read_only ⇒ Object (readonly) Also known as: read_only?
InfoBase is read only destructive methods will be fail with MethodDenied error
109 110 111 |
# File 'lib/ass_maintainer/info_base.rb', line 109 def read_only @read_only end |
Class Method Details
.build_options_wrapper ⇒ Object
Dinamicaly builds of options wrappers
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ass_maintainer/info_base.rb', line 85 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
132 133 134 135 136 137 |
# File 'lib/ass_maintainer/info_base.rb', line 132 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
330 331 332 |
# File 'lib/ass_maintainer/info_base.rb', line 330 def cfg @cfg ||= Cfg.new(self) if exists? end |
#common_args ⇒ Object
Common arguments for all commands
293 294 295 296 297 298 |
# File 'lib/ass_maintainer/info_base.rb', line 293 def common_args r = [] r += ['/L', locale] if locale r += ['/UC', unlock_code] if unlock_code r end |
#db_cfg ⇒ Dbase nil
Returns instance for manipuate with InfoBase database. If infobase not exists returns nil
322 323 324 |
# File 'lib/ass_maintainer/info_base.rb', line 322 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
266 267 268 |
# File 'lib/ass_maintainer/info_base.rb', line 266 def designer(&block) command(:thick, :designer, &block) end |
#dump(path) ⇒ Object
Dump infobase to .dt file
301 302 303 304 305 306 |
# File 'lib/ass_maintainer/info_base.rb', line 301 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
274 275 276 |
# File 'lib/ass_maintainer/info_base.rb', line 274 def enterprise(client, &block) command(client, :enterprise, &block) end |
#is ⇒ Symbol
Returns type of infobase
191 192 193 |
# File 'lib/ass_maintainer/info_base.rb', line 191 def is connection_string.is end |
#is?(type) ⇒ Boolean
Check type of infobase
197 198 199 |
# File 'lib/ass_maintainer/info_base.rb', line 197 def is?(type) connection_string.is?(type) end |
#locale ⇒ String
Get locale
220 221 222 |
# File 'lib/ass_maintainer/info_base.rb', line 220 def locale connection_string.locale end |
#locale=(l) ⇒ Object
Set locale
214 215 216 |
# File 'lib/ass_maintainer/info_base.rb', line 214 def locale=(l) connection_string.locale = l end |
#make ⇒ Object
Make new empty infobase wrpped in before_make and after_make hooks
153 154 155 156 |
# File 'lib/ass_maintainer/info_base.rb', line 153 def make make_infobase! unless exists? self end |
#ole(type) ⇒ Object
Get ole connector specified in type parameter
249 250 251 |
# File 'lib/ass_maintainer/info_base.rb', line 249 def ole(type) self.class.ole(type, ole_requirement) end |
#platform_require ⇒ String
Requrement 1C version
141 142 143 |
# File 'lib/ass_maintainer/info_base.rb', line 141 def platform_require [:platform_require] || self.class.config.platform_require end |
#pwd ⇒ String
User password
231 232 233 |
# File 'lib/ass_maintainer/info_base.rb', line 231 def pwd connection_string.pwd end |
#pwd=(password) ⇒ Object
Set user password
225 226 227 |
# File 'lib/ass_maintainer/info_base.rb', line 225 def pwd=(password) connection_string.pwd = password end |
#rebuild!(sure = :no) ⇒ Object
147 148 149 150 |
# File 'lib/ass_maintainer/info_base.rb', line 147 def rebuild!(sure = :no) rm! sure make end |
#restore!(path) ⇒ Object
Restore infobase from .dt file
310 311 312 313 314 315 316 |
# File 'lib/ass_maintainer/info_base.rb', line 310 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
171 172 173 174 175 176 |
# File 'lib/ass_maintainer/info_base.rb', line 171 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
236 237 238 239 |
# File 'lib/ass_maintainer/info_base.rb', line 236 def thick self.class.thicks(platform_require).last || fail("Platform 1C #{platform_require} not found") end |
#thin ⇒ AssLauncher::Enterprise::BinaryWrapper::ThinClient
242 243 244 245 |
# File 'lib/ass_maintainer/info_base.rb', line 242 def thin self.class.thins(platform_require).last || fail("Platform 1C #{platform_require} not found") end |
#usr ⇒ String
User name
208 209 210 |
# File 'lib/ass_maintainer/info_base.rb', line 208 def usr connection_string.usr end |
#usr=(user_name) ⇒ Object
Set user name
202 203 204 |
# File 'lib/ass_maintainer/info_base.rb', line 202 def usr=(user_name) connection_string.usr = user_name end |