ass_launcher 0.1.1.alpha → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +69 -67
- data/Rakefile +19 -0
- data/ass_launcher.gemspec +8 -2
- data/bin/dev-helper +7 -0
- data/bin/lib/dev_helper/cli_def_report.rb +191 -0
- data/bin/lib/dev_helper/cli_def_snippets.rb +426 -0
- data/bin/lib/dev_helper/designer.rb +172 -0
- data/bin/lib/dev_helper.rb +59 -0
- data/examples/arguments_builder_example.rb +150 -0
- data/examples/binary_wrappers_example.rb +211 -0
- data/examples/connection_string_example.rb +59 -0
- data/examples/create_infobase_example.rb +45 -0
- data/examples/enterprise_ole_example.rb +238 -0
- data/examples/enterprise_out_example.rb +87 -0
- data/examples/enterprise_running_example.rb +103 -0
- data/examples/example_helper.rb +122 -0
- data/examples/templates/example_template.cf +0 -0
- data/examples/templates/example_template.v8i +9 -0
- data/examples/templates/hello.epf +0 -0
- data/examples/troubles/with_creteinfobase_example.rb +408 -0
- data/examples/troubles/with_running_1c_example.rb +212 -0
- data/examples/v8i_file_example.rb +72 -0
- data/examples/webclient_example.rb +67 -0
- data/lib/ass_launcher/api.rb +113 -0
- data/lib/ass_launcher/enterprise/binary_wrapper.rb +159 -144
- data/lib/ass_launcher/enterprise/cli/arguments_builder.rb +177 -16
- data/lib/ass_launcher/enterprise/cli/binary_matcher.rb +69 -0
- data/lib/ass_launcher/enterprise/cli/parameters.rb +297 -44
- data/lib/ass_launcher/enterprise/cli/spec_dsl/dsl_helpers.rb +111 -5
- data/lib/ass_launcher/enterprise/cli/spec_dsl.rb +102 -51
- data/lib/ass_launcher/enterprise/cli.rb +50 -90
- data/lib/ass_launcher/enterprise/cli_def/8.2.17.rb +317 -0
- data/lib/ass_launcher/enterprise/cli_def/8.2.18.rb +3 -0
- data/lib/ass_launcher/enterprise/cli_def/8.3.3.rb +90 -0
- data/lib/ass_launcher/enterprise/cli_def/8.3.4.rb +58 -0
- data/lib/ass_launcher/enterprise/cli_def/8.3.5.rb +21 -0
- data/lib/ass_launcher/enterprise/cli_def/8.3.6.rb +91 -0
- data/lib/ass_launcher/enterprise/cli_def/8.3.7.rb +34 -0
- data/lib/ass_launcher/enterprise/cli_def/8.3.8.rb +127 -0
- data/lib/ass_launcher/enterprise/cli_def/8.3.9.rb +131 -0
- data/lib/ass_launcher/enterprise/cli_def.rb +46 -0
- data/lib/ass_launcher/enterprise/cli_defs_loader.rb +36 -0
- data/lib/ass_launcher/enterprise/ole/ole_binaries.rb +9 -2
- data/lib/ass_launcher/enterprise/ole/win32ole.rb +1 -1
- data/lib/ass_launcher/enterprise/ole.rb +17 -1
- data/lib/ass_launcher/enterprise/web_client.rb +164 -0
- data/lib/ass_launcher/enterprise.rb +33 -6
- data/lib/ass_launcher/support/connection_string.rb +33 -8
- data/lib/ass_launcher/support/linux.rb +88 -0
- data/lib/ass_launcher/support/platforms.rb +42 -10
- data/lib/ass_launcher/support/shell.rb +33 -6
- data/lib/ass_launcher/support/v8i_file.rb +3 -1
- data/lib/ass_launcher/support/v8i_section.rb +88 -40
- data/lib/ass_launcher/support.rb +1 -0
- data/lib/ass_launcher/version.rb +8 -1
- data/lib/ass_launcher.rb +1 -0
- metadata +79 -17
- data/lib/ass_launcher/enterprise/cli/cli.spec +0 -256
- data/lib/ass_launcher/enterprise/web_clients.rb +0 -59
@@ -0,0 +1,36 @@
|
|
1
|
+
module AssLauncher
|
2
|
+
module Enterprise
|
3
|
+
# @api private
|
4
|
+
# Mixin for {CliDef}
|
5
|
+
# Load all CLI definitions from files +cli_def/v.v.v.rb+
|
6
|
+
module CliDefsLoader
|
7
|
+
DEFS_PATH = File.expand_path('../cli_def', __FILE__)
|
8
|
+
def version_from_file_name(file)
|
9
|
+
Gem::Version.new File.basename(file, '.rb')
|
10
|
+
end
|
11
|
+
private :version_from_file_name
|
12
|
+
|
13
|
+
def defs_versions
|
14
|
+
Dir.glob(File.join(DEFS_PATH, '*.rb')).map do |l|
|
15
|
+
version_from_file_name l
|
16
|
+
end.sort
|
17
|
+
end
|
18
|
+
private :defs_versions
|
19
|
+
|
20
|
+
def load_def(v)
|
21
|
+
require File.join(DEFS_PATH, "#{v}")
|
22
|
+
@loaded_defs ||= []
|
23
|
+
@loaded_defs << v
|
24
|
+
end
|
25
|
+
private :load_def
|
26
|
+
|
27
|
+
def load_defs
|
28
|
+
defs_versions.sort.each do |v|
|
29
|
+
enterprise_version v
|
30
|
+
load_def v
|
31
|
+
end
|
32
|
+
end
|
33
|
+
private :load_defs
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -128,7 +128,7 @@ module AssLauncher
|
|
128
128
|
# @note It work not correct. If old version ole object is loded in
|
129
129
|
# memory new registred version will be ignored.
|
130
130
|
class COMConnector < AbstractAssOleBinary
|
131
|
-
require '
|
131
|
+
require 'English'
|
132
132
|
BINARY = 'comcntr.dll'
|
133
133
|
def binary
|
134
134
|
BINARY
|
@@ -203,10 +203,17 @@ module AssLauncher
|
|
203
203
|
private :_binary_wrapper
|
204
204
|
|
205
205
|
def reg_server
|
206
|
-
run_as_enterprise
|
206
|
+
run_as_enterprise reg_server_args
|
207
207
|
end
|
208
208
|
private :reg_server
|
209
209
|
|
210
|
+
def reg_server_args
|
211
|
+
r = ['/regserver']
|
212
|
+
r << '-currentuser' if version >= Gem::Version.new('8.3.9')
|
213
|
+
r
|
214
|
+
end
|
215
|
+
private :reg_server_args
|
216
|
+
|
210
217
|
def unreg_server
|
211
218
|
run_as_enterprise ['/unregserver']
|
212
219
|
end
|
@@ -6,6 +6,13 @@ module AssLauncher
|
|
6
6
|
module Enterprise
|
7
7
|
# 1C:Enterprise ole objects layer
|
8
8
|
module Ole
|
9
|
+
# Wrapper for {OLE_CLIENT_TYPES}
|
10
|
+
def self.ole_client(type)
|
11
|
+
fail ArgumentError, "Invalid ole type `#{type}'. Use types:"\
|
12
|
+
" #{OLE_CLIENT_TYPES.keys}" unless OLE_CLIENT_TYPES.key? type
|
13
|
+
OLE_CLIENT_TYPES[type]
|
14
|
+
end
|
15
|
+
|
9
16
|
# 1C Infobase External Connection
|
10
17
|
class IbConnection
|
11
18
|
attr_reader :__ole__
|
@@ -54,7 +61,7 @@ module AssLauncher
|
|
54
61
|
end
|
55
62
|
|
56
63
|
# Set 1C Ole server properties
|
57
|
-
def __configure_com_connector__(
|
64
|
+
def __configure_com_connector__(opts)
|
58
65
|
opts.each do |k, v|
|
59
66
|
__ole_binary__.ole.setproperty(k, v)
|
60
67
|
end
|
@@ -183,6 +190,15 @@ module AssLauncher
|
|
183
190
|
end
|
184
191
|
protected :__ole_binary__
|
185
192
|
end
|
193
|
+
|
194
|
+
# Define type of 1C OLE clients
|
195
|
+
OLE_CLIENT_TYPES = {
|
196
|
+
external: AssLauncher::Enterprise::Ole::IbConnection,
|
197
|
+
wprocess: AssLauncher::Enterprise::Ole::WpConnection,
|
198
|
+
sagent: AssLauncher::Enterprise::Ole::AgentConnection,
|
199
|
+
thin: AssLauncher::Enterprise::Ole::ThinApplication,
|
200
|
+
thick: AssLauncher::Enterprise::Ole::ThickApplication
|
201
|
+
}
|
186
202
|
end
|
187
203
|
end
|
188
204
|
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module AssLauncher
|
4
|
+
module Enterprise
|
5
|
+
# Abstract 1C:Enterprise client. Provides {#location} method as URI
|
6
|
+
# generator for connection to
|
7
|
+
# 1C information base via web browser.
|
8
|
+
# @example (see #initialize)
|
9
|
+
# @example (see #location)
|
10
|
+
class WebClient
|
11
|
+
require 'uri'
|
12
|
+
require 'ass_launcher/enterprise/cli'
|
13
|
+
DEFAULT_OPTIONS = { disable_startup_messages: true }
|
14
|
+
DEFAULT_VERSION = '999'
|
15
|
+
|
16
|
+
# @return [URI] base uri location
|
17
|
+
attr_reader :uri
|
18
|
+
# Version for 1C:Enterprise platform
|
19
|
+
attr_reader :version
|
20
|
+
# @return [WebClient]
|
21
|
+
# @example
|
22
|
+
#
|
23
|
+
# # Get webclient usin connection string:
|
24
|
+
# connection_string =\
|
25
|
+
# AssLauncher::Support::ConnectionString.new(
|
26
|
+
# 'ws="http://host:port/infobase"')
|
27
|
+
# wc = AssLauncher::Enterprise::WebClient.new(cs.uri)
|
28
|
+
#
|
29
|
+
# #or without connection_string
|
30
|
+
# wc = AssLauncher::Enterprise::WebClient.new('http://host/path')
|
31
|
+
#
|
32
|
+
# @param uri [String URI] base infobase location
|
33
|
+
# @param version [String] version 1C:Enterprise platform.
|
34
|
+
# The {Enterprise::WebClient#cli_spec}
|
35
|
+
# depends on the {Enterprise::WebClient#version}.
|
36
|
+
# Default supposed max possable version.
|
37
|
+
# {Enterprise::WebClient::DEFAULT_VERSION}
|
38
|
+
#
|
39
|
+
def initialize(uri = '', version = DEFAULT_VERSION)
|
40
|
+
@version = Gem::Version.new(version || DEFAULT_VERSION)
|
41
|
+
@uri ||= URI(uri || '')
|
42
|
+
end
|
43
|
+
|
44
|
+
def uri=(uri)
|
45
|
+
@uri = URI(uri)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Cli::CliSpec]
|
49
|
+
def cli_spec
|
50
|
+
@cli_spec ||= AssLauncher::Enterprise::Cli::CliSpec.for(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Defined run modes fo client
|
54
|
+
# @return (see Cli.defined_modes_for)
|
55
|
+
def self.run_modes
|
56
|
+
Cli.defined_modes_for(self)
|
57
|
+
end
|
58
|
+
|
59
|
+
# (see .run_modes)
|
60
|
+
def run_modes
|
61
|
+
self.class.run_modes
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_args(&block)
|
65
|
+
args_builder.build_args(&block)
|
66
|
+
end
|
67
|
+
private :build_args
|
68
|
+
|
69
|
+
def args_builder
|
70
|
+
Cli::ArgumentsBuilder.new(cli_spec, run_modes[0])
|
71
|
+
end
|
72
|
+
private :args_builder
|
73
|
+
|
74
|
+
# Build URI location for connect to web infobase.
|
75
|
+
#
|
76
|
+
# We can use {Cli::ArgumentsBuilder} for
|
77
|
+
# build connection string with validation parameters on defined in
|
78
|
+
# {#cli_spec} specifications.
|
79
|
+
#
|
80
|
+
# Or we can pass parameters as +args+ array directly.
|
81
|
+
# @example
|
82
|
+
# wc = AssLauncher::Enterprise::WebClient.new('http://host/path')
|
83
|
+
#
|
84
|
+
# # Without ArgumentsBulder
|
85
|
+
# wc.location(['O', 'low', 'C', 'passed string',
|
86
|
+
# 'N', '1cuser',
|
87
|
+
# 'P', '1cpassw',
|
88
|
+
# 'Authoff', '']) #=> URI
|
89
|
+
#
|
90
|
+
# # With ArgumentsBulder
|
91
|
+
# wc.location do
|
92
|
+
# _O :Low
|
93
|
+
# _C 'passed string'
|
94
|
+
# _N '1cuser'
|
95
|
+
# _P '1cuser_password'
|
96
|
+
# wA :-
|
97
|
+
# oIDA :-
|
98
|
+
# authOff
|
99
|
+
# _L 'en'
|
100
|
+
# vL 'en'
|
101
|
+
# debuggerURL 'localhost'
|
102
|
+
# _UsePrivilegedMode
|
103
|
+
# end #=> URI
|
104
|
+
#
|
105
|
+
# @param args [Arry]
|
106
|
+
# @option options [bool] :disable_startup_messages adds or not
|
107
|
+
# '/DisableStartupMessages' flag parameter into +args+
|
108
|
+
#
|
109
|
+
def location(args = [], **options, &block)
|
110
|
+
options = DEFAULT_OPTIONS.merge options
|
111
|
+
args += ['DisableStartupMessages', '']\
|
112
|
+
if options[:disable_startup_messages]
|
113
|
+
args += build_args(&block) if block_given?
|
114
|
+
add_to_query uri.dup, args_to_query(args)
|
115
|
+
end
|
116
|
+
|
117
|
+
def add_to_query(uri, q)
|
118
|
+
if uri.query
|
119
|
+
uri.query += escape "&#{q}" if q
|
120
|
+
else
|
121
|
+
uri.query = escape "#{q}" if q
|
122
|
+
end
|
123
|
+
uri
|
124
|
+
end
|
125
|
+
private :add_to_query
|
126
|
+
|
127
|
+
def escape(s)
|
128
|
+
self.class.escape(s)
|
129
|
+
end
|
130
|
+
private :escape
|
131
|
+
|
132
|
+
# Fuckin 1C is bad understand of CGI.escape.
|
133
|
+
# From escaping exclude: =&
|
134
|
+
# and ' ' replaced on '%20'
|
135
|
+
def self.escape(string)
|
136
|
+
string.gsub(/([^ a-zA-Z0-9_.\-=&]+)/) do
|
137
|
+
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
138
|
+
end.gsub(' ', '%20')
|
139
|
+
end
|
140
|
+
|
141
|
+
CLI_TO_WEB_PARAM_NAME = %r{^/}
|
142
|
+
|
143
|
+
def args_to_query(args)
|
144
|
+
r = to_query(args)
|
145
|
+
r.gsub!(/&$/, '')
|
146
|
+
return nil if r.empty?
|
147
|
+
r
|
148
|
+
end
|
149
|
+
private :args_to_query
|
150
|
+
|
151
|
+
def to_query(args)
|
152
|
+
r = ''
|
153
|
+
args.each_with_index do |v, i|
|
154
|
+
next if (i + 1).even?
|
155
|
+
r << "#{v.gsub(CLI_TO_WEB_PARAM_NAME, '')}"
|
156
|
+
r << "=#{args[i + 1]}" unless args[i + 1].to_s.empty?
|
157
|
+
r << '&'
|
158
|
+
end
|
159
|
+
r
|
160
|
+
end
|
161
|
+
private :to_query
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
@@ -9,7 +9,7 @@ module AssLauncher
|
|
9
9
|
# 1C:Entrprise platform abstraction layer
|
10
10
|
module Enterprise
|
11
11
|
require 'ass_launcher/enterprise/binary_wrapper'
|
12
|
-
require 'ass_launcher/enterprise/
|
12
|
+
require 'ass_launcher/enterprise/web_client'
|
13
13
|
require 'ass_launcher/enterprise/ole'
|
14
14
|
|
15
15
|
extend AssLauncher::Support::Platforms
|
@@ -57,9 +57,20 @@ module AssLauncher
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
# Caching {BinaryWrapper} instances
|
61
|
+
# @api private
|
62
|
+
# @return [Hash]
|
63
|
+
def self.binary_wrappers_cache
|
64
|
+
@binary_wrappers_cache ||= {}
|
65
|
+
end
|
66
|
+
|
60
67
|
def self.find_clients(klass)
|
61
68
|
find_binaries(binaries(klass)).map do |binpath|
|
62
|
-
|
69
|
+
if binary_wrappers_cache.key?(binpath)
|
70
|
+
binary_wrappers_cache[binpath]
|
71
|
+
else
|
72
|
+
binary_wrappers_cache[binpath] = klass.new(binpath)
|
73
|
+
end
|
63
74
|
end
|
64
75
|
end
|
65
76
|
private_class_method :find_clients
|
@@ -91,20 +102,36 @@ module AssLauncher
|
|
91
102
|
end.compact
|
92
103
|
end
|
93
104
|
|
94
|
-
# (see
|
95
|
-
|
96
|
-
|
105
|
+
# @param uri (see WebClient#initialize)
|
106
|
+
# @param version (see WebClient#initialize)
|
107
|
+
# @return [AssLauncher::Enterprise::WebClient]
|
108
|
+
def self.web_client(uri = nil, version = nil)
|
109
|
+
WebClient.new(uri, version)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Find binaries in Cygwin work slow.
|
113
|
+
# For rapid get binaries uses catch
|
114
|
+
# @return [Hash]
|
115
|
+
# @api private
|
116
|
+
def self.glob_cache
|
117
|
+
@glob_cache ||= {}
|
118
|
+
end
|
119
|
+
|
120
|
+
# Cliar {.glob_cache}
|
121
|
+
def self.clear_glob_cache
|
122
|
+
@glob_cache = nil
|
97
123
|
end
|
98
124
|
|
99
125
|
# Find and return all 1C:Entrprise binaries
|
100
126
|
# @return [Array<BinaryWrapper>]
|
101
127
|
def self.find_binaries(basename)
|
102
128
|
return [] if basename.to_s.empty?
|
129
|
+
return glob_cache[basename] if glob_cache.key?(basename)
|
103
130
|
r = []
|
104
131
|
search_paths.flatten.each do |sp|
|
105
132
|
r += platform.glob("#{sp}/**/#{basename}")
|
106
133
|
end
|
107
|
-
r
|
134
|
+
glob_cache[basename] = r
|
108
135
|
end
|
109
136
|
private_class_method :find_binaries
|
110
137
|
end
|
@@ -18,7 +18,7 @@ module AssLauncher
|
|
18
18
|
class Error < StandardError; end
|
19
19
|
class ParseError < StandardError; end
|
20
20
|
# Commonn connection string fields
|
21
|
-
COMMON_FIELDS = %w(Usr Pwd LicDstr prmod Locale)
|
21
|
+
COMMON_FIELDS = %w(Usr Pwd LicDstr prmod Locale Zn)
|
22
22
|
# Fields for server-infobase
|
23
23
|
SERVER_FIELDS = %w(Srvr Ref)
|
24
24
|
# Fields for file-infobase
|
@@ -121,6 +121,7 @@ module AssLauncher
|
|
121
121
|
r += ['/P', pwd] if pwd
|
122
122
|
r += ['/UsePrivilegedMode', ''] if prmod.to_s == '1'
|
123
123
|
r += ['/L', locale] if locale
|
124
|
+
r += ['/Z', zn] if zn
|
124
125
|
r
|
125
126
|
end
|
126
127
|
private :to_args_common
|
@@ -152,7 +153,10 @@ module AssLauncher
|
|
152
153
|
|
153
154
|
def self.included(base)
|
154
155
|
base.fields.each do |f|
|
155
|
-
base.send(:
|
156
|
+
base.send(:attr_reader, f.downcase.to_sym) unless\
|
157
|
+
base.instance_methods.include? f.downcase.to_sym
|
158
|
+
base.send(:attr_writer, f.downcase.to_sym) unless\
|
159
|
+
base.instance_methods.include? "#{f.downcase}=".to_sym
|
156
160
|
end
|
157
161
|
end
|
158
162
|
|
@@ -231,8 +235,6 @@ module AssLauncher
|
|
231
235
|
SERVER_FIELDS
|
232
236
|
end
|
233
237
|
|
234
|
-
include ConnectionString
|
235
|
-
|
236
238
|
def initialize(hash)
|
237
239
|
fail ConnectionString::Error unless required_fields_received?(hash)
|
238
240
|
_set_properties(hash)
|
@@ -309,6 +311,8 @@ module AssLauncher
|
|
309
311
|
['/S', "#{srvr}/#{ref}"]
|
310
312
|
end
|
311
313
|
private :to_args_private
|
314
|
+
|
315
|
+
include ConnectionString
|
312
316
|
end
|
313
317
|
|
314
318
|
# Connection string for file-infobases
|
@@ -322,8 +326,6 @@ module AssLauncher
|
|
322
326
|
required_fields | COMMON_FIELDS
|
323
327
|
end
|
324
328
|
|
325
|
-
include ConnectionString
|
326
|
-
|
327
329
|
def initialize(hash)
|
328
330
|
fail ConnectionString::Error unless required_fields_received?(hash)
|
329
331
|
_set_properties(hash)
|
@@ -364,6 +366,8 @@ module AssLauncher
|
|
364
366
|
['/F', path.realpath.to_s]
|
365
367
|
end
|
366
368
|
private :to_args_private
|
369
|
+
|
370
|
+
include ConnectionString
|
367
371
|
end
|
368
372
|
|
369
373
|
# Connection string for infobases published on http server
|
@@ -377,8 +381,6 @@ module AssLauncher
|
|
377
381
|
required_fields | COMMON_FIELDS | HTTP_WEB_AUTH_FIELDS | PROXY_FIELDS
|
378
382
|
end
|
379
383
|
|
380
|
-
include ConnectionString
|
381
|
-
|
382
384
|
def initialize(hash)
|
383
385
|
fail ConnectionString::Error unless required_fields_received?(hash)
|
384
386
|
_set_properties(hash)
|
@@ -394,9 +396,29 @@ module AssLauncher
|
|
394
396
|
uri = URI(ws)
|
395
397
|
uri.user = wsn
|
396
398
|
uri.password = wsp
|
399
|
+
q = uri_query
|
400
|
+
uri.query = escape q if q
|
397
401
|
uri
|
398
402
|
end
|
399
403
|
|
404
|
+
def escape(s)
|
405
|
+
AssLauncher::Enterprise::WebClient.escape s
|
406
|
+
end
|
407
|
+
private :escape
|
408
|
+
|
409
|
+
def uri_query
|
410
|
+
r = ''
|
411
|
+
r << "N=#{usr}&" if usr
|
412
|
+
r << "P=#{pwd}&" if pwd
|
413
|
+
r << "L=#{locale}&" if locale
|
414
|
+
r << "Z=#{zn}&" if zn
|
415
|
+
r << "UsePrivilegedMode&" if prmod
|
416
|
+
r.gsub!(/&$/i, '')
|
417
|
+
return nil if r.empty?
|
418
|
+
r
|
419
|
+
end
|
420
|
+
private :uri_query
|
421
|
+
|
400
422
|
# Convert connection string to array of 1C:Enterprise parameters.
|
401
423
|
# @return [Array] of 1C:Enterprise CLI parameters.
|
402
424
|
def to_args_private
|
@@ -416,6 +438,9 @@ module AssLauncher
|
|
416
438
|
r += ['-PPwd', wsppwd] if wsppwd
|
417
439
|
r
|
418
440
|
end
|
441
|
+
private :to_args_private_proxy
|
442
|
+
|
443
|
+
include ConnectionString
|
419
444
|
end
|
420
445
|
end
|
421
446
|
end
|