ass_launcher 0.1.1.alpha → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,88 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module AssLauncher
|
4
|
+
module Support
|
5
|
+
# Utils for Linux platform
|
6
|
+
module Linux
|
7
|
+
extend Platforms
|
8
|
+
# Rpm package manager utils
|
9
|
+
module Rpm
|
10
|
+
# Return instaled package version for +file+
|
11
|
+
# @param file [String] path to file
|
12
|
+
# @return [Gem::Version] package version
|
13
|
+
def self.version(file)
|
14
|
+
out = `rpm -q --queryformat '%{RPMTAG_VERSION}.%{RPMTAG_RELEASE}' #{pkg(file)}`
|
15
|
+
Gem::Version.new(out.strip)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return package name for +file+
|
19
|
+
# @param file (see .version)
|
20
|
+
def self.pkg(file)
|
21
|
+
`rpm -qf #{file}`.strip
|
22
|
+
end
|
23
|
+
|
24
|
+
# True if it's pakage manager
|
25
|
+
def self.manager?
|
26
|
+
`rpm --version`
|
27
|
+
return true
|
28
|
+
rescue Errno::ENOENT
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Deb package manager utils
|
34
|
+
module Deb
|
35
|
+
# (see Rpm.version)
|
36
|
+
def self.version(file)
|
37
|
+
pkg = pkg(file)
|
38
|
+
out = `apt-cache policy #{pkg} | grep -i installed:`
|
39
|
+
v = out.strip.split(':')[1].strip.gsub('-', '.')
|
40
|
+
Gem::Version.new(v)
|
41
|
+
end
|
42
|
+
|
43
|
+
# (see Rpm.version)
|
44
|
+
def self.pkg(file)
|
45
|
+
`dpkg -S #{file}`.strip.split(':')[0]
|
46
|
+
end
|
47
|
+
|
48
|
+
# (see Rpm.manager?)
|
49
|
+
def self.manager?
|
50
|
+
`dpkg --version`
|
51
|
+
return true
|
52
|
+
rescue Errno::ENOENT
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# (see Rpm.version)
|
58
|
+
# @raise [NotImplementedError]
|
59
|
+
def get_pkg_version(file)
|
60
|
+
return pkg_manager.version(file) if pkg_manager
|
61
|
+
fail NotImplementedError
|
62
|
+
end
|
63
|
+
|
64
|
+
# Return suitable manager or +nil+
|
65
|
+
# @return (see #current_pkg_manager)
|
66
|
+
def pkg_manager
|
67
|
+
@pkg_manager ||= current_pkg_manager
|
68
|
+
end
|
69
|
+
|
70
|
+
# Clculate current package manager
|
71
|
+
# @return [Deb Rpm nil]
|
72
|
+
def current_pkg_manager
|
73
|
+
return Deb if Deb.manager?
|
74
|
+
return Rpm if Rpm.manager?
|
75
|
+
end
|
76
|
+
|
77
|
+
def rpm?
|
78
|
+
pkg_manager == Rpm
|
79
|
+
end
|
80
|
+
|
81
|
+
def deb?
|
82
|
+
pkg_manager == Deb
|
83
|
+
end
|
84
|
+
|
85
|
+
extend self
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,11 +1,41 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
3
|
+
module AssLauncher
|
4
|
+
# Code partly copied from sources [FFI::Platform] module
|
5
|
+
# Module provides some functional like [FFI::Platform]
|
6
|
+
# Gem +ffi+ builds binary extension and decided don't use it
|
7
7
|
module Platform
|
8
|
-
|
8
|
+
# :nocov:
|
9
|
+
OS = case RbConfig::CONFIG['host_os'].downcase
|
10
|
+
when /linux/
|
11
|
+
'linux'
|
12
|
+
when /darwin/
|
13
|
+
'darwin'
|
14
|
+
when /freebsd/
|
15
|
+
'freebsd'
|
16
|
+
when /netbsd/
|
17
|
+
'netbsd'
|
18
|
+
when /openbsd/
|
19
|
+
'openbsd'
|
20
|
+
when /sunos|solaris/
|
21
|
+
'solaris'
|
22
|
+
when /mingw|mswin/
|
23
|
+
'windows'
|
24
|
+
else
|
25
|
+
RbConfig::CONFIG['host_os'].downcase
|
26
|
+
end
|
27
|
+
# :nocov:
|
28
|
+
|
29
|
+
# @param [String) os
|
30
|
+
# @return [Boolean]
|
31
|
+
# Test if current OS is +os+.
|
32
|
+
def self.os?(os)
|
33
|
+
OS == os
|
34
|
+
end
|
35
|
+
|
36
|
+
IS_CYGWIN = os?('cygwin')
|
37
|
+
IS_WINDOWS = os?('windows')
|
38
|
+
IS_LINUX = os?('linux')
|
9
39
|
|
10
40
|
def self.cygwin?
|
11
41
|
IS_CYGWIN
|
@@ -14,10 +44,12 @@ module FFI
|
|
14
44
|
def self.linux?
|
15
45
|
IS_LINUX
|
16
46
|
end
|
47
|
+
|
48
|
+
def self.windows?
|
49
|
+
IS_WINDOWS
|
50
|
+
end
|
17
51
|
end
|
18
|
-
end
|
19
52
|
|
20
|
-
module AssLauncher
|
21
53
|
module Support
|
22
54
|
# OS-specific things
|
23
55
|
# Mixin module help work with things as paths and env in other plases
|
@@ -50,19 +82,19 @@ module AssLauncher
|
|
50
82
|
module Platforms
|
51
83
|
# True if run in Cygwin
|
52
84
|
def cygwin?
|
53
|
-
|
85
|
+
Platform.cygwin?
|
54
86
|
end
|
55
87
|
module_function :cygwin?
|
56
88
|
|
57
89
|
# True if run in MinGW
|
58
90
|
def windows?
|
59
|
-
|
91
|
+
Platform.windows?
|
60
92
|
end
|
61
93
|
module_function :windows?
|
62
94
|
|
63
95
|
# True if run in Linux
|
64
96
|
def linux?
|
65
|
-
|
97
|
+
Platform.linux?
|
66
98
|
end
|
67
99
|
module_function :linux?
|
68
100
|
|
@@ -31,7 +31,7 @@ module AssLauncher
|
|
31
31
|
|
32
32
|
# Configuration for {AssLauncher}
|
33
33
|
class Configuration
|
34
|
-
|
34
|
+
attr_reader :logger
|
35
35
|
|
36
36
|
def initialize
|
37
37
|
@logger = Loggining.default_logger
|
@@ -113,17 +113,42 @@ module AssLauncher
|
|
113
113
|
# @option options [Boolean]:silent_mode run 1C with
|
114
114
|
# /DisableStartupDialogs and /DisableStartupMessages parameters.
|
115
115
|
# Default true
|
116
|
+
# @raise [ArgumentError] when +capture_assout: true+ and +args+
|
117
|
+
# include +/OUT+ parameter
|
116
118
|
def initialize(cmd, args = [], options = {})
|
117
119
|
@options = DEFAULT_OPTIONS.merge(options).freeze
|
118
120
|
@cmd = cmd
|
119
121
|
@args = args
|
122
|
+
validate_args
|
120
123
|
@args += _silent_mode
|
121
124
|
@ass_out_file = _ass_out_file
|
122
125
|
end
|
123
126
|
|
127
|
+
def validate_args
|
128
|
+
fail ArgumentError,
|
129
|
+
'Duplicate of /OUT parameter.'\
|
130
|
+
' Delete /OUT from args or set option capture_assout: false' if\
|
131
|
+
duplicate_param_out?
|
132
|
+
end
|
133
|
+
private :validate_args
|
134
|
+
|
135
|
+
def duplicate_param_out?
|
136
|
+
capture_assout? && args_include?(%r{\A\/OUT\z}i)
|
137
|
+
end
|
138
|
+
private :duplicate_param_out?
|
139
|
+
|
140
|
+
def args_include?(regex)
|
141
|
+
args.grep(regex).size > 0
|
142
|
+
end
|
143
|
+
private :args_include?
|
144
|
+
|
145
|
+
def capture_assout?
|
146
|
+
options[:capture_assout]
|
147
|
+
end
|
148
|
+
|
124
149
|
# @return [true] if command was already running
|
125
150
|
def running?
|
126
|
-
!
|
151
|
+
!process_holder.nil?
|
127
152
|
end
|
128
153
|
|
129
154
|
# Run command
|
@@ -151,7 +176,7 @@ module AssLauncher
|
|
151
176
|
private :_out_ass_argument
|
152
177
|
|
153
178
|
def _ass_out_file
|
154
|
-
if
|
179
|
+
if capture_assout?
|
155
180
|
out_file = AssOutFile.new(options[:assout_encoding])
|
156
181
|
_out_ass_argument out_file
|
157
182
|
else
|
@@ -280,7 +305,7 @@ module AssLauncher
|
|
280
305
|
class UnexpectedAssOut < StandardError; end
|
281
306
|
class RunAssError < StandardError; end
|
282
307
|
attr_reader :out, :assout, :exitstatus, :err
|
283
|
-
|
308
|
+
attr_reader :expected_assout
|
284
309
|
def initialize(exitstatus, out, err, assout)
|
285
310
|
@err = err
|
286
311
|
@out = out
|
@@ -299,9 +324,11 @@ module AssLauncher
|
|
299
324
|
self
|
300
325
|
end
|
301
326
|
|
327
|
+
CUT_ASSOUT_LENGTH = 640
|
328
|
+
|
302
329
|
def cut_assout
|
303
|
-
return assout if assout.size <=
|
304
|
-
"#{assout[0,
|
330
|
+
return assout if assout.size <= CUT_ASSOUT_LENGTH
|
331
|
+
"#{assout[0, CUT_ASSOUT_LENGTH].strip}..."
|
305
332
|
end
|
306
333
|
private :cut_assout
|
307
334
|
|
@@ -2,67 +2,115 @@ module AssLauncher
|
|
2
2
|
module Support
|
3
3
|
# Implemet section of v8i file
|
4
4
|
class V8iSection
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@fields = fields
|
12
|
-
end
|
5
|
+
# Class provaides case insensitive access to {#_hash} fields of
|
6
|
+
# {V8iSection}
|
7
|
+
# @api private
|
8
|
+
class Fields
|
9
|
+
# Define required fields of v8i
|
10
|
+
REQUIRED = [:connect]
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
# @return [Hash] containe {V8iSection} fields
|
13
|
+
attr_reader :_hash
|
14
|
+
|
15
|
+
# @param hash [Hash]
|
16
|
+
# @raise [ArgumentError] if not all {REQUIRED} given
|
17
|
+
def initialize(hash)
|
18
|
+
@_hash = hash
|
19
|
+
fail ArgumentError if\
|
20
|
+
(REQUIRED - dict.keys).size > 0
|
21
|
+
end
|
22
|
+
|
23
|
+
# Dictionary for case insensitive access to {#_hash} values
|
24
|
+
# @return [Hash]
|
25
|
+
def dict
|
26
|
+
@dict ||= build_dict
|
27
|
+
end
|
28
|
+
|
29
|
+
# :nodoc:
|
30
|
+
def build_dict
|
31
|
+
r = {}
|
32
|
+
_hash.each_key do |key|
|
33
|
+
r[key.downcase.to_sym] = key
|
34
|
+
end
|
35
|
+
r
|
36
|
+
end
|
37
|
+
private :build_dict
|
38
|
+
|
39
|
+
# Translate any +key+ in to real {#_hash} key
|
40
|
+
def trans(key)
|
41
|
+
dict[key.downcase.to_sym] || dict_add(key)
|
42
|
+
end
|
43
|
+
private :trans
|
20
44
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
45
|
+
def dict_add(key)
|
46
|
+
dict[key.downcase.to_sym] = key
|
47
|
+
key
|
48
|
+
end
|
49
|
+
private :dict_add
|
50
|
+
|
51
|
+
# :nodoc:
|
52
|
+
def [](key)
|
53
|
+
_hash[trans(key)]
|
54
|
+
end
|
55
|
+
|
56
|
+
# :nodoc:
|
57
|
+
def []=(key, value)
|
58
|
+
_hash[trans(key)] = value
|
59
|
+
end
|
60
|
+
|
61
|
+
# :nodoc:
|
62
|
+
def key?(key)
|
63
|
+
dict.key? key.to_s.downcase.to_sym
|
64
|
+
end
|
65
|
+
|
66
|
+
# :nodoc:
|
67
|
+
def to_s
|
68
|
+
res = ''
|
69
|
+
_hash.each do |key, value|
|
70
|
+
res << "#{key}=#{value}\r\n"
|
71
|
+
end
|
72
|
+
res
|
73
|
+
end
|
40
74
|
end
|
41
75
|
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
76
|
+
# @return [String]
|
77
|
+
attr_accessor :caption
|
78
|
+
# @return [Fields]
|
79
|
+
attr_reader :fields
|
80
|
+
# @param caption [String] caption of section
|
81
|
+
# @param fields [Hash]
|
82
|
+
def initialize(caption, fields)
|
83
|
+
@caption = caption
|
84
|
+
@fields = Fields.new(fields)
|
85
|
+
yield self if block_given?
|
46
86
|
end
|
47
87
|
|
88
|
+
# Return value of field +key+
|
89
|
+
# @note It case insensitive
|
90
|
+
# @param key [String, Symbol]
|
48
91
|
def [](key)
|
49
92
|
fields[key]
|
50
93
|
end
|
51
94
|
|
95
|
+
# Set value of field +key+
|
96
|
+
# @note (see #[])
|
97
|
+
# @param key (see #[])
|
98
|
+
# @param value [String]
|
52
99
|
def []=(key, value)
|
53
100
|
fields[key] = value
|
54
101
|
end
|
55
102
|
|
103
|
+
# @note (see #[])
|
104
|
+
# @param key (see #[])
|
56
105
|
def key?(key)
|
57
106
|
fields.key?(key)
|
58
107
|
end
|
59
108
|
|
109
|
+
# :nodoc:
|
60
110
|
def to_s
|
61
111
|
res = ''
|
62
112
|
res << "[#{caption}]\r\n"
|
63
|
-
fields.
|
64
|
-
res << "#{key}=#{value}\r\n"
|
65
|
-
end
|
113
|
+
res << fields.to_s
|
66
114
|
res
|
67
115
|
end
|
68
116
|
end
|
data/lib/ass_launcher/support.rb
CHANGED
data/lib/ass_launcher/version.rb
CHANGED