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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -67
  3. data/Rakefile +19 -0
  4. data/ass_launcher.gemspec +8 -2
  5. data/bin/dev-helper +7 -0
  6. data/bin/lib/dev_helper/cli_def_report.rb +191 -0
  7. data/bin/lib/dev_helper/cli_def_snippets.rb +426 -0
  8. data/bin/lib/dev_helper/designer.rb +172 -0
  9. data/bin/lib/dev_helper.rb +59 -0
  10. data/examples/arguments_builder_example.rb +150 -0
  11. data/examples/binary_wrappers_example.rb +211 -0
  12. data/examples/connection_string_example.rb +59 -0
  13. data/examples/create_infobase_example.rb +45 -0
  14. data/examples/enterprise_ole_example.rb +238 -0
  15. data/examples/enterprise_out_example.rb +87 -0
  16. data/examples/enterprise_running_example.rb +103 -0
  17. data/examples/example_helper.rb +122 -0
  18. data/examples/templates/example_template.cf +0 -0
  19. data/examples/templates/example_template.v8i +9 -0
  20. data/examples/templates/hello.epf +0 -0
  21. data/examples/troubles/with_creteinfobase_example.rb +408 -0
  22. data/examples/troubles/with_running_1c_example.rb +212 -0
  23. data/examples/v8i_file_example.rb +72 -0
  24. data/examples/webclient_example.rb +67 -0
  25. data/lib/ass_launcher/api.rb +113 -0
  26. data/lib/ass_launcher/enterprise/binary_wrapper.rb +159 -144
  27. data/lib/ass_launcher/enterprise/cli/arguments_builder.rb +177 -16
  28. data/lib/ass_launcher/enterprise/cli/binary_matcher.rb +69 -0
  29. data/lib/ass_launcher/enterprise/cli/parameters.rb +297 -44
  30. data/lib/ass_launcher/enterprise/cli/spec_dsl/dsl_helpers.rb +111 -5
  31. data/lib/ass_launcher/enterprise/cli/spec_dsl.rb +102 -51
  32. data/lib/ass_launcher/enterprise/cli.rb +50 -90
  33. data/lib/ass_launcher/enterprise/cli_def/8.2.17.rb +317 -0
  34. data/lib/ass_launcher/enterprise/cli_def/8.2.18.rb +3 -0
  35. data/lib/ass_launcher/enterprise/cli_def/8.3.3.rb +90 -0
  36. data/lib/ass_launcher/enterprise/cli_def/8.3.4.rb +58 -0
  37. data/lib/ass_launcher/enterprise/cli_def/8.3.5.rb +21 -0
  38. data/lib/ass_launcher/enterprise/cli_def/8.3.6.rb +91 -0
  39. data/lib/ass_launcher/enterprise/cli_def/8.3.7.rb +34 -0
  40. data/lib/ass_launcher/enterprise/cli_def/8.3.8.rb +127 -0
  41. data/lib/ass_launcher/enterprise/cli_def/8.3.9.rb +131 -0
  42. data/lib/ass_launcher/enterprise/cli_def.rb +46 -0
  43. data/lib/ass_launcher/enterprise/cli_defs_loader.rb +36 -0
  44. data/lib/ass_launcher/enterprise/ole/ole_binaries.rb +9 -2
  45. data/lib/ass_launcher/enterprise/ole/win32ole.rb +1 -1
  46. data/lib/ass_launcher/enterprise/ole.rb +17 -1
  47. data/lib/ass_launcher/enterprise/web_client.rb +164 -0
  48. data/lib/ass_launcher/enterprise.rb +33 -6
  49. data/lib/ass_launcher/support/connection_string.rb +33 -8
  50. data/lib/ass_launcher/support/linux.rb +88 -0
  51. data/lib/ass_launcher/support/platforms.rb +42 -10
  52. data/lib/ass_launcher/support/shell.rb +33 -6
  53. data/lib/ass_launcher/support/v8i_file.rb +3 -1
  54. data/lib/ass_launcher/support/v8i_section.rb +88 -40
  55. data/lib/ass_launcher/support.rb +1 -0
  56. data/lib/ass_launcher/version.rb +8 -1
  57. data/lib/ass_launcher.rb +1 -0
  58. metadata +79 -17
  59. data/lib/ass_launcher/enterprise/cli/cli.spec +0 -256
  60. data/lib/ass_launcher/enterprise/web_clients.rb +0 -59
@@ -0,0 +1,212 @@
1
+ require 'example_helper'
2
+
3
+ module Examples
4
+ module TroublesWithRunning1C
5
+ describe '1C:Enterprise show stupid GUI' do
6
+ # In this cases 1C:Enterprise open GUI dialog.
7
+ # Such stupid 1C:Enerprise behavior made difficult to run 1C:Enterprise
8
+ # without human watching
9
+
10
+ # For show dialogs set $SHOW_STUPID_GUI
11
+
12
+ it 'Thin client show dialog with error message' do
13
+ skip unless TROUBLES_EXECUTE_CONTROL::SHOW_STUPID_GUI
14
+ command = CLIENTS::THIN.command(['/F','bad infobase path', '/L', 'en'])
15
+ # It show error message window
16
+ command.run.wait
17
+ # But 1C:Enterprise process exit with status 0
18
+ command.process_holder.result.success?.must_equal true
19
+ end
20
+
21
+ it 'Thick client show dialog with offer for create new infobase' do
22
+ skip unless TROUBLES_EXECUTE_CONTROL::SHOW_STUPID_GUI
23
+ command = CLIENTS::THICK\
24
+ .command(:enterprise, ['/F','bad infobase path', '/L', 'en'])
25
+ # It show GUI dialg with offer create new infobase
26
+ command.run.wait
27
+ end
28
+
29
+ it 'Designer show dialg with error message for serevr infobase' do
30
+ skip unless TROUBLES_EXECUTE_CONTROL::SHOW_STUPID_GUI
31
+ designer = CLIENTS::THICK.command :designer do
32
+ _S 'example.org/fake_ib'
33
+ _L 'en'
34
+ end
35
+
36
+ # It show GUI
37
+ designer.run.wait
38
+ end
39
+
40
+ describe 'Solution. For file infobase only!!!' do
41
+ it 'Arguments builder check existing path for /F parameter' do
42
+ proc {
43
+ CLIENTS::THICK.command(:enterprise) do
44
+ _F 'bad infobase path'
45
+ end
46
+ }.must_raise ArgumentError
47
+ end
48
+
49
+ it 'Connection string fails in #to_args method if path not exists' do
50
+ extend AssLauncher::Api
51
+ conns = cs_file file: 'bad infobase path'
52
+
53
+ # Call #to_args directly
54
+ proc {
55
+ CLIENTS::THIN.command(conns.to_args)
56
+ }.must_raise Errno::ENOENT
57
+
58
+ # Passing connection string into arguments builder
59
+ # have the same effect
60
+ proc {
61
+ CLIENTS::THIN.command do
62
+ connection_string conns
63
+ end
64
+ }.must_raise Errno::ENOENT
65
+ end
66
+ end
67
+ end
68
+
69
+ describe '1C:Enterprise ignores mistakes in CLI parameters' do
70
+ # Usually command line apps are checking CLI parameters and
71
+ # exits with non zero status but usually 1C:Enterprise doesn't it
72
+
73
+ it 'Pass wrong parameter name /WrongParameter' do
74
+ command = CLIENTS::THICK\
75
+ .command(:designer, ['/F', TMP::EMPTY_IB, '/WrongParameter','']) do
76
+ checkModules do
77
+ thinClient
78
+ end
79
+ end
80
+ command.run.wait.result.exitstatus.must_equal 0
81
+ end
82
+
83
+ it 'Pass wrong parameter value' do
84
+ skip unless CLIENTS::THICK.version < Gem::Version.new('8.3.4')
85
+ command = CLIENTS::THICK\
86
+ .command(:designer, ['/F', TMP::EMPTY_IB,
87
+ '/SetPredefinedDataUpdate','Bad value'
88
+ ])
89
+ command.run.wait.result.exitstatus.must_equal 0
90
+ end
91
+
92
+ it 'One of the rare cases when 1C:Enterprise verifies of paramter value' do
93
+ command = CLIENTS::THICK\
94
+ .command(:designer, ['/F', TMP::EMPTY_IB]) do
95
+ checkModules do
96
+ thinClient
97
+ eXtension 'bad value'
98
+ end
99
+ end
100
+ command.run.wait.result.exitstatus.wont_equal 0
101
+
102
+ # But doesn't explains cause of error
103
+ command.process_holder.result.assout.must_equal ''
104
+ end
105
+
106
+ describe 'Solutions this troubles with arguments builder' do
107
+ it 'Arguments builder fails BuildError if unknown parameter given' do
108
+ proc {
109
+ CLIENTS::THICK\
110
+ .command (:enterprise) do
111
+ uncknownParameter
112
+ end
113
+ }.must_raise AssLauncher::Enterprise::Cli::ArgumentsBuilder::BuildError
114
+ end
115
+
116
+ it 'Cli::Parameter instance verifies given value' do
117
+ proc {
118
+ CLIENTS::THICK\
119
+ .command (:designer) do
120
+ setPredefinedDataUpdate 'Bad value'
121
+ end
122
+ }.must_raise ArgumentError
123
+
124
+ proc {
125
+ CLIENTS::THICK\
126
+ .command (:enterprise) do
127
+ debuggerURL 'tcp:/baduri'
128
+ end
129
+ }.must_raise ArgumentError
130
+ end
131
+ end
132
+ end
133
+
134
+ describe 'Trouble with /C CLI parameter' do
135
+ it 'Transform value if value contains double quote char' do
136
+ source_string = 'Hello "World"'
137
+
138
+ enterprise = CLIENTS::THICK\
139
+ .command :enterprise, ['/C', source_string] do
140
+ connection_string TMP::EMPTY_IB_CS
141
+ _Execute TEMPLATES::HELLO_EPF
142
+ end
143
+
144
+ enterprise.run.wait
145
+ ret_string = enterprise.process_holder.result.assout.strip
146
+
147
+ source_string.wont_equal ret_string
148
+ ret_string.must_equal 'Hello \\'
149
+ end
150
+
151
+ it 'Transform value if value contains escaped double quote char' do
152
+ source_string = 'Hello \"World\"'
153
+
154
+ enterprise = CLIENTS::THICK\
155
+ .command :enterprise, ['/C', source_string] do
156
+ connection_string TMP::EMPTY_IB_CS
157
+ _Execute TEMPLATES::HELLO_EPF
158
+ end
159
+
160
+ enterprise.run.wait
161
+ ret_string = enterprise.process_holder.result.assout.strip
162
+
163
+ source_string.wont_equal ret_string
164
+ ret_string.must_equal 'Hello \\\\\\'
165
+ end
166
+
167
+ describe 'Solutions' do
168
+ it 'Check value /C parameter with arguments builder' do
169
+ proc {
170
+ CLIENTS::THIN.command do
171
+ _C '"'
172
+ end
173
+ }.must_raise ArgumentError
174
+ end
175
+
176
+ it 'Passing value with single quote char' do
177
+ source_string = 'Hello \'World\''
178
+
179
+ enterprise = CLIENTS::THICK\
180
+ .command :enterprise do
181
+ _C source_string
182
+ connection_string TMP::EMPTY_IB_CS
183
+ _Debug
184
+ debuggerURL 'tcp://localhost'
185
+ _Execute TEMPLATES::HELLO_EPF
186
+ end
187
+
188
+ enterprise.run.wait
189
+ ret_string = enterprise.process_holder.result.assout.strip
190
+
191
+ source_string.must_equal ret_string
192
+ end
193
+ end
194
+ end
195
+
196
+ describe 'Designer talks "Infobase not found!" but exit with 0 for file infobase' do
197
+ designer = CLIENTS::THICK.command :designer, ['/F','./fake_ib'] do
198
+ _L 'en'
199
+ end
200
+
201
+ designer.run.wait
202
+
203
+ it 'Exitstatus == 0' do
204
+ designer.process_holder.result.exitstatus.must_equal 0
205
+ end
206
+
207
+ it 'Error message in out' do
208
+ designer.process_holder.result.assout.strip.must_equal 'Infobase not found!'
209
+ end
210
+ end
211
+ end
212
+ end
@@ -0,0 +1,72 @@
1
+ require 'example_helper'
2
+
3
+ module Examples
4
+ module V8iFile
5
+ require 'ass_launcher'
6
+
7
+ describe 'Build new v8i file' do
8
+
9
+ it 'V8i section must have :Connect field' do
10
+ proc do
11
+ AssLauncher::Support::V8iSection\
12
+ .new('Info base 1', {})
13
+ end.must_raise(ArgumentError)
14
+ end
15
+
16
+ # Build v8i section
17
+ v8i_section = AssLauncher::Support::V8iSection\
18
+ .new('Info base 1', 'Connect' => 'File="path"') do |s|
19
+ s[:ClientConnectionSpeed] = :Normal
20
+ s[:App] = :Auto
21
+ end
22
+
23
+ it 'V8i section is case insensitive' do
24
+ v8i_section[:app].must_equal :Auto
25
+ end
26
+
27
+ it 'For v8i section a Symbol key equal a String key' do
28
+ v8i_section[:app].must_equal :Auto
29
+ v8i_section[:app.to_s].must_equal :Auto
30
+ end
31
+
32
+ # Write section to file
33
+ v8i_file = File.join(Dir.tmpdir,'v8i_file_example.v8i')
34
+ # v8i file may contain many of sections
35
+ AssLauncher::Support::V8iFile.save(v8i_file, [v8i_section])
36
+
37
+
38
+ it 'File exists and valid' do
39
+ File.read(v8i_file).must_equal "[Info base 1]\r\n"\
40
+ "Connect=File=\"path\"\r\n"\
41
+ "ClientConnectionSpeed=Normal\r\n"\
42
+ "App=Auto\r\n"\
43
+ "\r\n"
44
+ FileUtils.rm_f v8i_file if File.exists? v8i_file
45
+ end
46
+ end
47
+
48
+ describe 'Use exists v8i file' do
49
+ extend AssLauncher::Api
50
+
51
+ # Read v8i file
52
+ v8i_sections = load_v8i(Examples::TEMPLATES::V8I)
53
+
54
+ # Get sections contained in v8i file
55
+ v8i_ib1 = v8i_sections.find {|s| s.caption == 'Info base 1'}
56
+ v8i_ib2 = v8i_sections.find {|s| s.caption == 'Info base 2'}
57
+
58
+ it 'v8i file contain sections describe two 1C:Enterprise applications' do
59
+ v8i_ib1.must_be_instance_of AssLauncher::Support::V8iSection
60
+ v8i_ib2.must_be_instance_of AssLauncher::Support::V8iSection
61
+ end
62
+
63
+ # Build connection string for 'Info base 1'
64
+ conns_ib1 = cs(v8i_ib1[:connect])
65
+
66
+ it 'Server connection string' do
67
+ conns_ib1.must_be_instance_of\
68
+ AssLauncher::Support::ConnectionString::Server
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,67 @@
1
+ require 'example_helper'
2
+
3
+ module Examples
4
+ module WebClient
5
+ require 'ass_launcher'
6
+
7
+ describe 'Get web client instanse for connect to infobase' do
8
+ describe 'Whith URL of infobase' do
9
+ extend AssLauncher::Api
10
+
11
+ wc = web_client('http://host/path/infobase', '8.3.8')
12
+ loc = wc.location do
13
+ # Buld arguments
14
+ _N 'user name'
15
+ _P 'pass'
16
+ _L 'en'
17
+ testClientID 'id'
18
+ debuggerURL 'http://debugger:5668'
19
+ end
20
+
21
+ it 'We get URI::HTTP instanse' do
22
+ loc.must_be_instance_of URI::HTTP
23
+ end
24
+
25
+ it 'We get perfect string for connect to infobase' do
26
+ loc.to_s.must_equal 'http://host/path/infobase?'\
27
+ 'DisableStartupMessages&'\
28
+ 'N=user%20name&'\
29
+ 'P=pass&'\
30
+ 'L=en&'\
31
+ 'TESTCLIENTID=id&'\
32
+ 'DebuggerURL=http%3A%2F%2Fdebugger%3A5668'
33
+ end
34
+ end
35
+
36
+ describe 'Whith connection string' do
37
+ extend AssLauncher::Api
38
+
39
+ cs = cs_http(ws: 'http://host/path/infobase', usr: 'user name',
40
+ pwd: 'pass')
41
+ wc = web_client(cs.uri, '8.3.8')
42
+
43
+ loc = wc.location do
44
+ # Buld arguments
45
+ _L 'en'
46
+ testClientID 'id'
47
+ debuggerURL 'http://debugger:5668'
48
+ end
49
+
50
+ it 'We get URI::HTTP instanse' do
51
+ loc.must_be_instance_of URI::HTTP
52
+ end
53
+
54
+ it 'We get perfect string for connect to infobase' do
55
+ loc.to_s.must_equal 'http://host/path/infobase?'\
56
+ 'N=user%20name&'\
57
+ 'P=pass&'\
58
+ 'DisableStartupMessages&'\
59
+ 'L=en&'\
60
+ 'TESTCLIENTID=id&'\
61
+ 'DebuggerURL=http%3A%2F%2Fdebugger%3A5668'
62
+ end
63
+
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,113 @@
1
+ # encoding: utf-8
2
+ module AssLauncher
3
+ # Helpers for easy to use ass_launcher
4
+ module Api
5
+ # Return sorted array of instaled 1C binary wrappers
6
+ # @example
7
+ # inclide AssLauncher::Api
8
+ # # I can get 1C thick client specific version
9
+ # cl = thicks('~> 8.3.8.0').last
10
+ # fail "Client '~> 8.3.8.0' not found" if cl.nil?
11
+ # @param requiremet [String, Gem::Version::Requirement] spec require version
12
+ # @return [Array<AssLauncher::Enterprise::BinaryWrapper::ThickClient>]
13
+ def thicks(requiremet = '>= 0')
14
+ AssLauncher::Enterprise.thick_clients(requiremet).sort
15
+ end
16
+
17
+ # Return sorted array of instaled 1C binary wrappers
18
+ # @example
19
+ # inclide AssLauncher::Api
20
+ # # I can get 1C thin client specific version
21
+ # cl = thins('~> 8.3.8.0').last
22
+ # fail "Client '~> 8.3.8.0' not found" if cl.nil?
23
+ # @param (see .thicks)
24
+ # @return [Array<AssLauncher::Enterprise::BinaryWrapper::ThinClient>]
25
+ def thins(requiremet = '>= 0')
26
+ AssLauncher::Enterprise.thin_clients(requiremet).sort
27
+ end
28
+
29
+ # (see AssLauncher::Support::ConnectionString.new)
30
+ # @example
31
+ # include AssLauncher::Api
32
+ # file_cs = cs 'file="path";'
33
+ # srv_cs = cs 'srvr="host";ref="ib_name";'
34
+ # http_cs = cs 'ws="http://host/ib";'
35
+ def cs(connstr)
36
+ AssLauncher::Support::ConnectionString.new(connstr)
37
+ end
38
+
39
+ # @example
40
+ # include AssLauncher::Api
41
+ # fcs = cs_file({:file => 'path'})
42
+ # @return [AssLauncher::Support::ConnectionString::File]
43
+ def cs_file(hash)
44
+ AssLauncher::Support::ConnectionString::File.new hash
45
+ end
46
+
47
+ # @example
48
+ # include AssLauncher::Api
49
+ # httpcs = cs_http({:ws => 'http://host/ib'})
50
+ # @return [AssLauncher::Support::ConnectionString::Http]
51
+ def cs_http(hash)
52
+ AssLauncher::Support::ConnectionString::Http.new hash
53
+ end
54
+
55
+ # @example
56
+ # include AssLauncher::Api
57
+ # srvcs = cs_srv({:srvr => 'host', :ref=> 'ib'})
58
+ # @return [AssLauncher::Support::ConnectionString::Server]
59
+ def cs_srv(hash)
60
+ AssLauncher::Support::ConnectionString::Server.new hash
61
+ end
62
+
63
+ # (see AssLauncher::Support::V8iFile.load)
64
+ # @example
65
+ # include AssLauncher::Api
66
+ #
67
+ # v8i = load_v8i('infobase.v8i')[0]
68
+ # conn_str = cs(v8i[:connect])
69
+ # conn_str.usr = 'admin'
70
+ # conn_str.pwd = 'password'
71
+ # designer = thicks.last.command(:designer, conn_str.to_args)
72
+ # designer.run.wait
73
+ def load_v8i(filename)
74
+ AssLauncher::Support::V8iFile.load(filename)
75
+ end
76
+
77
+ # Return 1C ole client suitable class instance
78
+ # @param type [Symbol] type of 1C ole client.
79
+ # See {Enterprise::Ole::OLE_CLIENT_TYPES}
80
+ # @param requiremet [String, Gem::Version::Requirement] require version spec
81
+ # @raise [ArgumentError] if invalid +type+ given
82
+ def ole(type, requiremet = '>= 0')
83
+ AssLauncher::Enterprise::Ole.ole_client(type).new(requiremet)
84
+ end
85
+
86
+ # (see Enterprise.web_client)
87
+ # @example
88
+ # include AssLauncher::Api
89
+ #
90
+ # # Get web client instanse for connect to
91
+ # # infobase 'http://host/port/path/infobase'
92
+ # wc = web_client('http://host/path/infobase')
93
+ #
94
+ # loc = wc.location do
95
+ # _N 'user_name'
96
+ # _P 'password'
97
+ # _L 'en'
98
+ # end # => URI
99
+ #
100
+ # # Or do it with uses connecton string
101
+ # connstr = cs 'ws="http://host/path/infobase";usr="user";pwd="password"'
102
+ # wc = web_client(connstr.uri)
103
+ # loc = wc.location do
104
+ # _L 'en'
105
+ # end # => URI
106
+ #
107
+ # # And use given location URI with selenium driver:
108
+ # # driver.navigate.to loc.to_s
109
+ def web_client(uri = nil, version = nil)
110
+ AssLauncher::Enterprise.web_client(uri, version)
111
+ end
112
+ end
113
+ end