ass_maintainer-info_base 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.simplecov +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +94 -15
- data/Rakefile +0 -0
- data/ass_maintainer-info_base.gemspec +4 -1
- data/bin/runsrv +241 -0
- data/examples/describe_infobase.rb +0 -0
- data/lib/ass_maintainer/info_base.rb +79 -73
- data/lib/ass_maintainer/info_base/cfg.rb +14 -10
- data/lib/ass_maintainer/info_base/config.rb +0 -0
- data/lib/ass_maintainer/info_base/default_maker.rb +0 -0
- data/lib/ass_maintainer/info_base/file_ib.rb +24 -41
- data/lib/ass_maintainer/info_base/interfaces.rb +49 -20
- data/lib/ass_maintainer/info_base/server_ib.rb +257 -55
- data/lib/ass_maintainer/info_base/server_ib/enterprise_servers.rb +80 -0
- data/lib/ass_maintainer/info_base/server_ib/enterprise_servers/cluster.rb +114 -0
- data/lib/ass_maintainer/info_base/server_ib/enterprise_servers/server_agent.rb +91 -0
- data/lib/ass_maintainer/info_base/server_ib/enterprise_servers/support.rb +200 -0
- data/lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb +198 -0
- data/lib/ass_maintainer/info_base/version.rb +1 -1
- metadata +72 -26
- data/lib/ass_maintainer/info_base/server_ib/helpers.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50e50193d3052bdea87880539a64bc138c7e2081
|
4
|
+
data.tar.gz: '03469ca21025660f741ea514e2dec991f86d14fa'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2db4da3e0a521d58b5ffe3f90bf5e0e41932f0d3cad9fb2ba995d9356d7bc31aa52010c64118ed83b995ae72c63e4fa631f8191bf1811aef273e8df91acefe2d
|
7
|
+
data.tar.gz: bfa963a1384e6135faa8024fd4ca125adf7250b0f8cffb253a4b15b64f1fab8de1140a5fdb4179a257cb43f010f45f4413eff3ff0538734bdf28f8550fc57e0b
|
data/.gitignore
CHANGED
File without changes
|
data/.simplecov
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,18 +1,36 @@
|
|
1
1
|
# AssMaintainer::InfoBase
|
2
2
|
|
3
|
+
Gem for juggle with the [1C:Enterprise](http://1c.ru) application instances
|
4
|
+
(aka infobase or information base) as easy as possible.
|
5
|
+
Main thing of this gem is the class `AssMaintainer::InfoBase` which provides
|
6
|
+
features to do it.
|
3
7
|
|
4
|
-
|
5
|
-
as possible.
|
8
|
+
In this gem defined two types of 1C application instance:
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
1. application deployed on a 1C:Enterprise application server aka *server infobase*
|
11
|
+
2. application deployed as a file aka *file infobase*
|
9
12
|
|
10
|
-
|
13
|
+
Class `AssMaintainer::InfoBase` implements both types of applications but using
|
14
|
+
difference mixins for each of them in constructor. Type of application,
|
15
|
+
detects per type of [connection string](https://github.com/leoniv/ass_launcher/blob/master/lib/ass_launcher/support/connection_string.rb).
|
11
16
|
|
12
|
-
|
17
|
+
## Restriction
|
13
18
|
|
14
|
-
|
15
|
-
-
|
19
|
+
Fully work with server infobse possible in Windows(Cygwin)
|
20
|
+
x86 Ruby only. Cause of this is in-process OLE server `V83.COMConnector` which
|
21
|
+
used for connect to 1C:Enterprise application server when require check for
|
22
|
+
infobase exist or get infobase sessions or drop infobase or etc. actions.
|
23
|
+
|
24
|
+
Furthermore, for fully working with server infobse require logging on a
|
25
|
+
1C:Enterprise application server as a central-server administrator and
|
26
|
+
as a cluster administrator.
|
27
|
+
|
28
|
+
Structure 1C:Enterprise application server is complex and confusing.
|
29
|
+
For more info about 1C:Enterprise server look 1C documentation.
|
30
|
+
|
31
|
+
Some examples for restrictions look in
|
32
|
+
[example](./test/ass_maintainer/examples_test.rb) defined as `Restrictions for`
|
33
|
+
spec
|
16
34
|
|
17
35
|
## Installation
|
18
36
|
|
@@ -32,7 +50,7 @@ Or install it yourself as:
|
|
32
50
|
|
33
51
|
## Usage
|
34
52
|
|
35
|
-
Small example:
|
53
|
+
### Small example:
|
36
54
|
|
37
55
|
```ruby
|
38
56
|
reqiure 'ass_maintainer/info_base'
|
@@ -43,30 +61,91 @@ reqiure 'ass_maintainer/info_base'
|
|
43
61
|
connection_string = 'File="infobase_path";'
|
44
62
|
|
45
63
|
# Get InfoBase instance
|
46
|
-
ib = AssMaintainer::InfoBase.new('infobase_name', connection_string
|
64
|
+
ib = AssMaintainer::InfoBase.new('infobase_name', connection_string)
|
47
65
|
|
48
66
|
# Dump data
|
49
67
|
ib.dump(dump_path)
|
50
68
|
|
51
|
-
|
52
69
|
# As 1C application developer you should make dump of infobase configuration
|
53
70
|
|
54
71
|
# Dump configuration
|
55
72
|
ib.cfg.dump(cf_dump_path)
|
56
73
|
|
57
74
|
# ... etc
|
75
|
+
```
|
76
|
+
|
77
|
+
### Destructive actions protection
|
78
|
+
|
79
|
+
On default all instance of `AssMaintainer::InfoBase` marked as `read_only`. If
|
80
|
+
infobase is `read_only` all destructive actions denied,
|
81
|
+
`MethodDenied` exception will be raised. For control it behavior uses
|
82
|
+
`read_only` parameter of constructor.
|
58
83
|
|
84
|
+
```ruby
|
85
|
+
ib = AssMaintainer::InfoBase.new('ib_name', 'File="path"')
|
86
|
+
ib.rm! :yes #raised AssMaintainer::InfoBase::MethodDenied
|
87
|
+
|
88
|
+
ib = AssMaintainer::InfoBase.new('ib_name', 'File="path"', false)
|
89
|
+
ib.rm! :yes #=> nil
|
59
90
|
```
|
60
91
|
|
92
|
+
### Define 1C:Enterprise version requirement
|
93
|
+
|
94
|
+
On default using last installed 1C:Enterprise version. But
|
95
|
+
`AssMaintainer::InfoBase` provides feature for define 1C:Enterprise version
|
96
|
+
manually.
|
97
|
+
|
98
|
+
Example for define 1C:Enterprise platform requirement
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
# Define platform version for single instance
|
102
|
+
ib = AssMaintainer::InfoBase.new('ib_name', 'File="path"', platform_require: '~> 8.3.10.0')
|
103
|
+
ib.platform_require #=> "~> 8.3.10.0"
|
104
|
+
|
105
|
+
# Define platform verion for all instances
|
106
|
+
AssMaintainer::InfoBase.configure do |conf|
|
107
|
+
conf.platform_require = '~> 8.3.9.0'
|
108
|
+
end
|
109
|
+
|
110
|
+
ib = AssMaintainer::InfoBase.new('ib_name', 'File="path"')
|
111
|
+
ib.platform_require #=> "~> 8.3.9.0"
|
112
|
+
```
|
113
|
+
|
114
|
+
### More examples
|
115
|
+
|
61
116
|
For more examples see [examples](./test/ass_maintainer/examples_test.rb)
|
62
117
|
|
63
118
|
## Test
|
64
119
|
|
65
|
-
For
|
66
|
-
`PLATFORM_REQUIRE`
|
67
|
-
[
|
120
|
+
For execute all tests require 1C:Enterprise platform installed.
|
121
|
+
Version defined in constant `PLATFORM_REQUIRE` in
|
122
|
+
[platform_require.rb](./test/test_helper/platform_require.rb)
|
123
|
+
|
124
|
+
For execute server infobase tests defined in
|
125
|
+
[examples](./test/ass_maintainer/examples_test.rb) require:
|
126
|
+
- running 1C:Enterprise application server. Version defined in `PLATFORM_REQUIRE`
|
127
|
+
- running data base(DBMS) server suitable for 1C:Enterprise.
|
128
|
+
|
129
|
+
On default, server infobase tests skipped. For execute server infobase tests
|
130
|
+
require to pass server parameters in `ENV[ESRV_ENV]` like this:
|
131
|
+
|
132
|
+
```
|
133
|
+
$export ESRV_ENV="--ragent user:pass@host:port \
|
134
|
+
--rmngr user:pass@host:port \
|
135
|
+
--dbms MSSQLServer \
|
136
|
+
--dbsrv user:pass@localhost\\sqlexpress"
|
137
|
+
```
|
138
|
+
|
139
|
+
For running local 1C:Enterprise application server instance can use
|
140
|
+
[bin/runsrv](bin/runsrv):
|
141
|
+
|
142
|
+
$bin/runsrv -h
|
143
|
+
|
144
|
+
But `runsrv` running 1C server only! DBMS server must be already running manually
|
145
|
+
|
146
|
+
Running all tests:
|
68
147
|
|
69
|
-
$
|
148
|
+
$bundler exec rake test SIMPLECOV=YES
|
70
149
|
|
71
150
|
## Development
|
72
151
|
|
data/Rakefile
CHANGED
File without changes
|
@@ -19,7 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "ass_launcher", "~> 0.
|
22
|
+
spec.add_dependency "ass_launcher", "~> 0.3"
|
23
|
+
spec.add_dependency "ass_ole"
|
24
|
+
spec.add_dependency "net-ping", "~> 2.0.0"
|
23
25
|
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.10"
|
25
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -27,5 +29,6 @@ Gem::Specification.new do |spec|
|
|
27
29
|
spec.add_development_dependency "pry"
|
28
30
|
spec.add_development_dependency "simplecov"
|
29
31
|
spec.add_development_dependency "mocha"
|
32
|
+
spec.add_development_dependency "clamp"
|
30
33
|
|
31
34
|
end
|
data/bin/runsrv
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require_relative '../test/test_helper/platform_require'
|
5
|
+
require_relative '../test/test_helper/helper'
|
6
|
+
require 'net/ping/tcp'
|
7
|
+
|
8
|
+
module AssMaintainer::InfoBaseTest
|
9
|
+
module Tmp
|
10
|
+
SRVINFO = File.join Dir.tmpdir, "ass_maintainer_infobase_test.srvinfo"
|
11
|
+
end
|
12
|
+
|
13
|
+
module Server
|
14
|
+
PORT = '11540'
|
15
|
+
REGPORT = '11541'
|
16
|
+
RANGE = '11560:11591'
|
17
|
+
RAGENT_ADMIN = 'ragent'
|
18
|
+
RAGENT_PASS = '0000'
|
19
|
+
RMNGR_ADMIN = 'rmngr'
|
20
|
+
RMNGR_PASS = '1111'
|
21
|
+
|
22
|
+
class Ragent
|
23
|
+
BIN = 'ragent.exe'
|
24
|
+
attr_reader :platform_require, :port, :regport, :range
|
25
|
+
|
26
|
+
def initialize(platform_require, port = nil, regport = nil, range = nil)
|
27
|
+
@platform_require = platform_require
|
28
|
+
@port = port || PORT
|
29
|
+
@regport = regport || REGPORT
|
30
|
+
@range = range || RANGE
|
31
|
+
end
|
32
|
+
|
33
|
+
def thick
|
34
|
+
@thick ||= Helper.thicks(platform_require).last
|
35
|
+
end
|
36
|
+
|
37
|
+
def exists?
|
38
|
+
path && File.file?(path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def path
|
42
|
+
return unless thick
|
43
|
+
@path ||= thick.path.class.new("#{thick.path.dirname}/#{BIN}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def version
|
47
|
+
return unless exists?
|
48
|
+
thick.version
|
49
|
+
end
|
50
|
+
|
51
|
+
def srvinfo
|
52
|
+
return unless exists?
|
53
|
+
thick.path.class.new(@srvinfo).realpath.to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
def args
|
57
|
+
['-port', port,
|
58
|
+
'-regport', regport,
|
59
|
+
'-range', range,
|
60
|
+
'-agent',
|
61
|
+
'-d', srvinfo]
|
62
|
+
end
|
63
|
+
|
64
|
+
def cmd
|
65
|
+
path.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def running?
|
69
|
+
tcp_ping.ping?
|
70
|
+
end
|
71
|
+
|
72
|
+
def tcp_ping
|
73
|
+
@tcp_ping ||= Net::Ping::TCP.new(host, port)
|
74
|
+
end
|
75
|
+
|
76
|
+
def host
|
77
|
+
'localhost'
|
78
|
+
end
|
79
|
+
|
80
|
+
def run(srvinfo, make_admins_)
|
81
|
+
@srvinfo = srvinfo
|
82
|
+
fail "service on the tcp port `#{port}' is already running" if running?
|
83
|
+
fail "`#{BIN}' v#{version} isn't instaled!" unless exists?
|
84
|
+
Process.spawn "\"#{cmd}\" #{args.join(' ')}"
|
85
|
+
sleep(3)
|
86
|
+
make_admins if make_admins_
|
87
|
+
end
|
88
|
+
|
89
|
+
def runtime_new
|
90
|
+
Module.new do
|
91
|
+
is_ole_runtime :agent
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def run_ole_runtime
|
96
|
+
require 'ass_ole'
|
97
|
+
self.class.like_ole_runtime runtime_new
|
98
|
+
ole_runtime_get.run "localhost:#{port}", platform_require
|
99
|
+
end
|
100
|
+
|
101
|
+
def make_admins
|
102
|
+
run_ole_runtime
|
103
|
+
make_rmngr_admin
|
104
|
+
make_ragent_admin
|
105
|
+
end
|
106
|
+
|
107
|
+
def make_ragent_admin
|
108
|
+
authenticateAgent('', '')
|
109
|
+
regAgentAdmin ragent_admin_get
|
110
|
+
end
|
111
|
+
|
112
|
+
def ragent_admin_get
|
113
|
+
ai = createClusterAdminInfo
|
114
|
+
ai.Name = RAGENT_ADMIN
|
115
|
+
ai.Password = RAGENT_PASS
|
116
|
+
ai.PasswordAuthAllowed = true
|
117
|
+
ai
|
118
|
+
end
|
119
|
+
|
120
|
+
def make_rmngr_admin
|
121
|
+
cl = cluster_get
|
122
|
+
Authenticate(cl, '', '')
|
123
|
+
regClusterAdmin(cl, cluster_admin_get)
|
124
|
+
end
|
125
|
+
|
126
|
+
def cluster_get
|
127
|
+
getClusters[0]
|
128
|
+
end
|
129
|
+
|
130
|
+
def cluster_admin_get
|
131
|
+
ai = createClusterAdminInfo
|
132
|
+
ai.Name = RMNGR_ADMIN
|
133
|
+
ai.Password = RMNGR_PASS
|
134
|
+
ai.PasswordAuthAllowed = true
|
135
|
+
ai
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
require 'clamp'
|
140
|
+
class CMD < Clamp::Command
|
141
|
+
def prepare_srv_info
|
142
|
+
FileUtils.rm_r Tmp::SRVINFO if File.exist? Tmp::SRVINFO
|
143
|
+
FileUtils.mkdir_p Tmp::SRVINFO
|
144
|
+
Tmp::SRVINFO
|
145
|
+
end
|
146
|
+
|
147
|
+
def exists?
|
148
|
+
ragent.exists?
|
149
|
+
end
|
150
|
+
|
151
|
+
def running?
|
152
|
+
ragent.running?
|
153
|
+
end
|
154
|
+
|
155
|
+
def ragent
|
156
|
+
@ragent ||= Ragent
|
157
|
+
.new(PLATFORM_REQUIRE, port, regport, range)
|
158
|
+
end
|
159
|
+
alias_method :ra, :ragent
|
160
|
+
|
161
|
+
def srvinfo_get
|
162
|
+
return prepare_srv_info if srvinfo == Tmp::SRVINFO
|
163
|
+
srvinfo || prepare_srv_info
|
164
|
+
end
|
165
|
+
|
166
|
+
def errno_enotempty_mess
|
167
|
+
"rm -r #{srvinfo}: Device or resource busy\n"\
|
168
|
+
"Cause of this: \n"\
|
169
|
+
" 1) other ragent.exe is running and locking srvinfo directory\n"\
|
170
|
+
" 2) other rmngr.exe is running and locking srvinfo directory\n"\
|
171
|
+
"Kill suitable ragent.exe and rmngr.exe processes and try again:\n"\
|
172
|
+
" #{netstat.join("\n ")}"
|
173
|
+
end
|
174
|
+
|
175
|
+
def netstat
|
176
|
+
`netstat -abn -p tcp`.force_encoding('ASCII-8BIT')
|
177
|
+
.split("\r\n"*2)
|
178
|
+
.map {|i| i.gsub(/\s+/, ' ')}
|
179
|
+
.select {|i| i =~ %r{LISTENING.+r(agent|mngr)\.exe}}
|
180
|
+
.sort_by {|i| i.split(" ").last}
|
181
|
+
end
|
182
|
+
|
183
|
+
def rmngr_host
|
184
|
+
`hostname`.strip
|
185
|
+
end
|
186
|
+
|
187
|
+
def ragent_usr
|
188
|
+
"#{Server::RAGENT_ADMIN}:#{Server::RAGENT_PASS}@" if make_admins?
|
189
|
+
end
|
190
|
+
|
191
|
+
def rmngr_usr
|
192
|
+
"#{Server::RMNGR_ADMIN}:#{Server::RMNGR_PASS}@" if make_admins?
|
193
|
+
end
|
194
|
+
|
195
|
+
def success_mess
|
196
|
+
"for pass ESRV_ENV to test execute:\n"\
|
197
|
+
"export ESRV_ENV=\"--ragent #{ragent_usr}#{ra.host}:#{ra.port} \\\n"\
|
198
|
+
" --rmngr #{rmngr_usr}#{rmngr_host}:#{ra.regport} \\\n"\
|
199
|
+
" --dbms YOUR_DBMS \\\n"\
|
200
|
+
" --dbsrv user:pass@your_dbms_host:port\""
|
201
|
+
end
|
202
|
+
|
203
|
+
def execute
|
204
|
+
signal_usage_error 'Run in cygwin or windows only!' if Helper.linux?
|
205
|
+
ragent.run(srvinfo_get, make_admins?)
|
206
|
+
puts success_mess
|
207
|
+
rescue RuntimeError => e
|
208
|
+
raise Clamp::ExecutionError.new(e.message, '', 1)
|
209
|
+
rescue Errno::ENOTEMPTY => e
|
210
|
+
raise Clamp::ExecutionError.new(errno_enotempty_mess, '', 1)
|
211
|
+
end
|
212
|
+
|
213
|
+
option '--port', 'PORT', 'ragent.exe tcp port', default: PORT do |s|
|
214
|
+
Integer(s)
|
215
|
+
end
|
216
|
+
|
217
|
+
option '--regport', 'PORT', 'rmngr.exe tcp port', default: REGPORT do |s|
|
218
|
+
Integer(s)
|
219
|
+
end
|
220
|
+
|
221
|
+
option '--range', 'FROM:TO', 'rphost.exe tcp ports range', default: RANGE do |s|
|
222
|
+
from, to = s.split(':')
|
223
|
+
"#{Integer(from)}:#{Integer(to)}"
|
224
|
+
end
|
225
|
+
|
226
|
+
parameter '[SRVINFO]', 'path to ragent.exe srvinfo directory', default: Tmp::SRVINFO do |s|
|
227
|
+
signal_usage_error "Path `#{s}' not found or isn't directory!" unless File.directory? s
|
228
|
+
s
|
229
|
+
end
|
230
|
+
|
231
|
+
option '--plist', :flag, 'show netstat for rphost.exe and rmngr.exe and exit' do
|
232
|
+
$stderr.puts netstat.join("\n")
|
233
|
+
exit 0
|
234
|
+
end
|
235
|
+
|
236
|
+
option '--[no-]make-admins', :flag, 'default admins for ragent.exe and rmngr.exe will be maked'
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
AssMaintainer::InfoBaseTest::Server::CMD.run
|
File without changes
|
@@ -7,26 +7,26 @@ module AssMaintainer
|
|
7
7
|
# Class for manipulate with 1C:Enterprise application instance aka
|
8
8
|
# +information base+ or +infobase+
|
9
9
|
#
|
10
|
-
# Instances of this class
|
10
|
+
# Instances of this class has dynamically generated interface
|
11
11
|
#
|
12
12
|
# 1C:Enterprise application may be deployed as file (aka file infobase) or
|
13
13
|
# on a 1C:Enterprise server (aka server infobase). In the {#initialize}
|
14
|
-
# instance of
|
15
|
-
# - server infobase instance will be
|
16
|
-
# - file infobase instance will be
|
14
|
+
# instance of will be extended by suitable module:
|
15
|
+
# - server infobase instance will be extended by {ServerIb} module
|
16
|
+
# - file infobase instance will be extended by {FileIb} module
|
17
17
|
#
|
18
|
-
# Both
|
18
|
+
# Both instances types inherits methods from {Interfaces::InfoBase}
|
19
19
|
#
|
20
|
-
# All instances
|
20
|
+
# All instances gets methods for access to {#options} see
|
21
21
|
# {.build_options_wrapper}
|
22
22
|
class InfoBase
|
23
23
|
extend AssLauncher::Api
|
24
24
|
require 'ass_maintainer/info_base/config'
|
25
25
|
require 'ass_maintainer/info_base/interfaces'
|
26
|
+
require 'ass_maintainer/info_base/default_maker'
|
26
27
|
require 'ass_maintainer/info_base/file_ib'
|
27
28
|
require 'ass_maintainer/info_base/server_ib'
|
28
29
|
require 'ass_maintainer/info_base/cfg'
|
29
|
-
require 'ass_maintainer/info_base/default_maker'
|
30
30
|
|
31
31
|
# :nodoc:
|
32
32
|
class MethodDenied < StandardError
|
@@ -35,7 +35,7 @@ module AssMaintainer
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# Deafult port for connect to 1C:Enterprise
|
38
|
+
# Deafult port for connect to 1C:Enterprise server agent
|
39
39
|
DEFAULT_SAGENT_PORT = '1540'
|
40
40
|
|
41
41
|
# Hooks before and after make and remove infobase. Hooks may be passed as
|
@@ -57,25 +57,23 @@ module AssMaintainer
|
|
57
57
|
destroyer: nil
|
58
58
|
}
|
59
59
|
|
60
|
-
# - +:
|
61
|
-
# - +:
|
62
|
-
# - +:
|
60
|
+
# - +:platform_require+ Required 1C:Enterprise version
|
61
|
+
# - +:sagent_host+ Host name of 1C:Enterprise server agent
|
62
|
+
# - +:sagent_port+ TCP port of 1C:Enterprise server agent on
|
63
63
|
# default {DEFAULT_SAGENT_PORT}
|
64
|
-
# - +:
|
65
|
-
# - +:
|
66
|
-
# - +:
|
67
|
-
#
|
68
|
-
# - +:
|
69
|
-
# See {ServerIb#claster_pwd}
|
70
|
-
# - +:nlock_code+ Code for connect to locked infobase aka "/UC" parameter
|
64
|
+
# - +:sagent_usr+ Admin for 1C:Enterprise server agent
|
65
|
+
# - +:sagent_pwd+ Admin password for 1C:Enterprise server agent
|
66
|
+
# - +:cluster_usr+ Admin for 1C:Enterprise cluster.
|
67
|
+
# - +:cluster_pwd+ Pasword Admin for 1C:Enterprise cluster.
|
68
|
+
# - +:unlock_code+ Code for connect to locked infobase aka "/UC" parameter
|
71
69
|
ARGUMENTS = {
|
72
70
|
platform_require: nil,
|
73
71
|
sagent_host: nil,
|
74
72
|
sagent_port: nil,
|
75
73
|
sagent_usr: nil,
|
76
74
|
sagent_pwd: nil,
|
77
|
-
|
78
|
-
|
75
|
+
cluster_usr: nil,
|
76
|
+
cluster_pwd: nil,
|
79
77
|
unlock_code: nil
|
80
78
|
}
|
81
79
|
|
@@ -105,7 +103,7 @@ module AssMaintainer
|
|
105
103
|
# see {#initialize} +options+
|
106
104
|
attr_reader :options
|
107
105
|
# InfoBase is read only
|
108
|
-
# destructive methods
|
106
|
+
# destructive methods fails with {MethodDenied} error
|
109
107
|
attr_reader :read_only
|
110
108
|
alias_method :read_only?, :read_only
|
111
109
|
|
@@ -117,7 +115,7 @@ module AssMaintainer
|
|
117
115
|
@name = name
|
118
116
|
@connection_string = self.class.cs(connection_string.to_s)
|
119
117
|
@read_only = read_only
|
120
|
-
@options =
|
118
|
+
@options = validate_options(options)
|
121
119
|
case self.connection_string.is
|
122
120
|
when :file then extend FileIb
|
123
121
|
when :server then extend ServerIb
|
@@ -126,6 +124,13 @@ module AssMaintainer
|
|
126
124
|
yield self if block_given?
|
127
125
|
end
|
128
126
|
|
127
|
+
def validate_options(options)
|
128
|
+
_opts = options.keys - OPTIONS.keys
|
129
|
+
fail ArgumentError, "Unknown options: #{_opts}" unless _opts.empty?
|
130
|
+
OPTIONS.merge(options)
|
131
|
+
end
|
132
|
+
private :validate_options
|
133
|
+
|
129
134
|
# Add hook. In all hook whill be passed +self+
|
130
135
|
# @raise [ArgumentError] if invalid hook name or not block given
|
131
136
|
# @param hook [Symbol] hook name
|
@@ -186,52 +191,6 @@ module AssMaintainer
|
|
186
191
|
end
|
187
192
|
private :rm_infobase!
|
188
193
|
|
189
|
-
# Returns type of infobase
|
190
|
-
# @return [Symbol] +:file+ or +:server+
|
191
|
-
def is
|
192
|
-
connection_string.is
|
193
|
-
end
|
194
|
-
|
195
|
-
# Check type of infobase
|
196
|
-
# @param type [Symbol] +:file+ or +:server+
|
197
|
-
def is?(type)
|
198
|
-
connection_string.is?(type)
|
199
|
-
end
|
200
|
-
|
201
|
-
# Set user name
|
202
|
-
def usr=(user_name)
|
203
|
-
connection_string.usr = user_name
|
204
|
-
end
|
205
|
-
|
206
|
-
# User name
|
207
|
-
# @return [String]
|
208
|
-
def usr
|
209
|
-
connection_string.usr
|
210
|
-
end
|
211
|
-
|
212
|
-
# Set locale
|
213
|
-
# @param l [String] locale code +en+, +ru+ etc
|
214
|
-
def locale=(l)
|
215
|
-
connection_string.locale = l
|
216
|
-
end
|
217
|
-
|
218
|
-
# Get locale
|
219
|
-
# @return [String]
|
220
|
-
def locale
|
221
|
-
connection_string.locale
|
222
|
-
end
|
223
|
-
|
224
|
-
# Set user password
|
225
|
-
def pwd=(password)
|
226
|
-
connection_string.pwd = password
|
227
|
-
end
|
228
|
-
|
229
|
-
# User password
|
230
|
-
# @return [String]
|
231
|
-
def pwd
|
232
|
-
connection_string.pwd
|
233
|
-
end
|
234
|
-
|
235
194
|
# @return [AssLauncher::Enterprise::BinaryWrapper::ThickClient]
|
236
195
|
def thick
|
237
196
|
self.class.thicks(platform_require).last ||
|
@@ -318,7 +277,7 @@ module AssMaintainer
|
|
318
277
|
# Returns instance for manipuate with
|
319
278
|
# InfoBase database. If infobase not
|
320
279
|
# exists returns nil
|
321
|
-
# @return [
|
280
|
+
# @return [DbCfg nil]
|
322
281
|
def db_cfg
|
323
282
|
@db_cfg ||= DbCfg.new(self) if exists?
|
324
283
|
end
|
@@ -331,10 +290,57 @@ module AssMaintainer
|
|
331
290
|
@cfg ||= Cfg.new(self) if exists?
|
332
291
|
end
|
333
292
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
293
|
+
# Returns type of infobase
|
294
|
+
# @return [Symbol] +:file+ or +:server+
|
295
|
+
def is
|
296
|
+
connection_string.is
|
297
|
+
end
|
298
|
+
|
299
|
+
# Check type of infobase
|
300
|
+
# @param type [Symbol] +:file+ or +:server+
|
301
|
+
def is?(type)
|
302
|
+
connection_string.is?(type)
|
303
|
+
end
|
304
|
+
|
305
|
+
# Set user name
|
306
|
+
def usr=(user_name)
|
307
|
+
connection_string.usr = user_name
|
308
|
+
end
|
309
|
+
alias_method :user=, :usr=
|
310
|
+
|
311
|
+
# User name
|
312
|
+
# @return [String]
|
313
|
+
def usr
|
314
|
+
connection_string.usr
|
315
|
+
end
|
316
|
+
alias_method :user, :usr
|
317
|
+
|
318
|
+
# Set locale
|
319
|
+
# @param l [String] locale code +en+, +ru+ etc
|
320
|
+
def locale=(l)
|
321
|
+
connection_string.locale = l
|
322
|
+
end
|
323
|
+
|
324
|
+
# Get locale
|
325
|
+
# @return [String]
|
326
|
+
def locale
|
327
|
+
connection_string.locale
|
328
|
+
end
|
329
|
+
|
330
|
+
# Set user password
|
331
|
+
def pwd=(password)
|
332
|
+
connection_string.pwd = password
|
333
|
+
end
|
334
|
+
alias_method :password=, :pwd=
|
335
|
+
|
336
|
+
# User password
|
337
|
+
# @return [String]
|
338
|
+
def pwd
|
339
|
+
connection_string.pwd
|
340
|
+
end
|
341
|
+
alias_method :password, :pwd
|
342
|
+
|
343
|
+
include Interfaces::InfoBase
|
338
344
|
end
|
339
345
|
# rubocop:enable Metrics/ClassLength
|
340
346
|
end
|