Class: AssMaintainer::InfoBase

Inherits:
Object
  • Object
show all
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_require Required 1C:Enterprise version
  • :sagent_host Host name of 1C:Enterprise server agent
  • :sagent_port TCP port of 1C:Enterprise server agent on default DEFAULT_SAGENT_PORT
  • :sagent_usr Admin for 1C:Enterprise server agent
  • :sagent_pwd Admin password for 1C:Enterprise server agent
  • :cluster_usr Admin for 1C:Enterprise cluster.
  • :cluster_pwd Pasword Admin for 1C:Enterprise cluster.
  • :unlock_code Code 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

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • name (String)

    name of infobase

  • connection_string (String AssLauncher::Support::ConnectionString)
  • read_only (true false) (defaults to: true)

    infobse is read only or not

  • options (Hash)

Yields:

  • (_self)

Yield Parameters:



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, **options)
  @name = name
  @connection_string = self.class.cs(connection_string.to_s)
  @read_only = read_only
  @options = validate_options(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_stringObject (readonly)

see #initialize connection_string



102
103
104
# File 'lib/ass_maintainer/info_base.rb', line 102

def connection_string
  @connection_string
end

#nameObject (readonly)

see #initialize name



100
101
102
# File 'lib/ass_maintainer/info_base.rb', line 100

def name
  @name
end

#optionsObject (readonly)

see #initialize options



104
105
106
# File 'lib/ass_maintainer/info_base.rb', line 104

def options
  @options
end

#read_onlyObject (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_wrapperObject

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.build_options_wrapper
  OPTIONS.each_key do |key|
    next if WORKERS.keys.include? key
    define_method key do
      options[key]
    end

    next if HOOKS.keys.include? key
    define_method "#{key}=".to_sym do |arg|
      options[key] = arg
    end
  end
end

.configConfig

Get settings

Returns:



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

Yields:



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

Parameters:

  • hook (Symbol)

    hook name

Raises:

  • (ArgumentError)

    if invalid hook name or not block given



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?
  options[hook] = block
end

#cfgCfg nil

Returns instance for manipuate with databse configuration. If infobase not exists returns nil

Returns:



289
290
291
# File 'lib/ass_maintainer/info_base.rb', line 289

def cfg
  @cfg ||= Cfg.new(self) if exists?
end

#common_argsObject

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_cfgDbCfg nil

Returns instance for manipuate with InfoBase database. If infobase not exists returns nil

Returns:



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

Returns:

  • (AssLauncher::Support::Shell::Command)


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

Parameters:

  • client (Symbol)

    :thin or thick client

Returns:

  • (AssLauncher::Support::Shell::Command)


233
234
235
# File 'lib/ass_maintainer/info_base.rb', line 233

def enterprise(client, &block)
  command(client, :enterprise, &block)
end

#isSymbol

Returns type of infobase

Returns:

  • (Symbol)

    :file or :server



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

Parameters:

  • type (Symbol)

    :file or :server

Returns:

  • (Boolean)


301
302
303
# File 'lib/ass_maintainer/info_base.rb', line 301

def is?(type)
  connection_string.is?(type)
end

#localeString

Get locale

Returns:

  • (String)


326
327
328
# File 'lib/ass_maintainer/info_base.rb', line 326

def locale
  connection_string.locale
end

#locale=(l) ⇒ Object

Set locale

Parameters:

  • l (String)

    locale code en, ru etc



320
321
322
# File 'lib/ass_maintainer/info_base.rb', line 320

def locale=(l)
  connection_string.locale = l
end

#makeObject

Make new empty infobase wrpped in before_make and after_make hooks

Raises:



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

Parameters:

  • type (Symbol)

    see AssLauncher::Api#ole



208
209
210
# File 'lib/ass_maintainer/info_base.rb', line 208

def ole(type)
  self.class.ole(type, ole_requirement)
end

#platform_requireString

Requrement 1C version

Returns:

  • (String)


146
147
148
# File 'lib/ass_maintainer/info_base.rb', line 146

def platform_require
  options[:platform_require] || self.class.config.platform_require
end

#pwdString Also known as: password

User password

Returns:

  • (String)


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

Rebuild infobse first call #rm! second call #make

Raises:



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

Raises:



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

Raises:



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

#thickAssLauncher::Enterprise::BinaryWrapper::ThickClient

Returns:

  • (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

#thinAssLauncher::Enterprise::BinaryWrapper::ThinClient

Returns:

  • (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

#usrString Also known as: user

User name

Returns:

  • (String)


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