butler-mainframe 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +5 -8
- data/lib/mainframe/customization/generic_functions.rb +12 -8
- data/lib/mainframe/host_base.rb +46 -32
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1b46290497b9756b0b72bbb6f48e92066ff14a7
|
4
|
+
data.tar.gz: 7e131b06d932887b33afd338d200dc69e4a4ba87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb11baa752d23d1a4cdad52b6fc7f39c434f0343778c656d01cd0782eb2ade4946a9ce0febde6b7a74e8ee8100e79ca63c6d5b9d6ecab0f1909fc6d5661c64db
|
7
|
+
data.tar.gz: a27c4a112f43c927ddb7d7169ca6858bea9a740419ee3e4109d033bd4a99fb83ac7a6a31bbac6b1607a01c88fd011f472ab204a61893d2465627c056b09e0695
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
0.7.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.6.0...v0.7.0) December 2th, 2015
|
2
|
+
------------------------------
|
3
|
+
* Now is possible to set erase_before_writing to execute an erase until end of field before writing a text
|
4
|
+
* Changed param name in write method: erase_before_writing instead of erase_field_first => deprecation warning
|
5
|
+
* Changed param name in write method: clean_chars_before_writing instead of clean_first_chars => deprecation warning
|
6
|
+
* Changed method name: screen_title becomes catch_title to align it to the methods name that provide a similar result => deprecation warning
|
7
|
+
|
1
8
|
0.6.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.5.0...v0.6.0) October 29th, 2015
|
2
9
|
------------------------------
|
3
10
|
* Improved rails integration
|
data/README.md
CHANGED
@@ -130,6 +130,10 @@ host.write 'ruby on rails', :y => 6, :x => 15
|
|
130
130
|
# With the hook you can use a regular expression to search a label on the y axis (2 rows up and down)
|
131
131
|
# It is usefull when the y position could change (atm it does not use x axis)
|
132
132
|
host.write 'ruby on rails', :y => 6, :x => 15, hook: 'SYSTEM='
|
133
|
+
|
134
|
+
# write a text erasing the field text currently on the screen. This executes a erase_eof command before writing.
|
135
|
+
host.write 'ruby on rails', :y => 6, :x => 15, hook: 'SYSTEM=', erase_before_writing: true
|
136
|
+
# If you have to do it permanently, you can set it when you instantiate the object: host = ButlerMainframe::Host.new(erase_before_writing: true)
|
133
137
|
```
|
134
138
|
|
135
139
|
### Navigate
|
@@ -204,7 +208,7 @@ Class Invoice
|
|
204
208
|
# We develop the function.
|
205
209
|
# In this simple case we put a number in a map CICS at row 10 and column 5
|
206
210
|
# as option we also choose to erase any previous value in the field
|
207
|
-
@host.write self.number, y: 10, x: 5,
|
211
|
+
@host.write self.number, y: 10, x: 5, erase_before_writing: true
|
208
212
|
|
209
213
|
# Press enter because the example mainframe program expects it as confirmation
|
210
214
|
@host.do_enter
|
@@ -419,13 +423,6 @@ stdin, stdout, thread = Open3.popen2e('"C:/Program Files (x86)/wc3270/ws3270.exe
|
|
419
423
|
|
420
424
|
Read the methods list documentation: [windows](http://x3270.bgp.nu/Windows/wc3270-script.html) or [unix](http://x3270.bgp.nu/Unix/x3270-script.html)
|
421
425
|
|
422
|
-
## ToDo
|
423
|
-
|
424
|
-
* <s>Improve unit test</s> **Done** although it is still a simple rake
|
425
|
-
* Improve write extending hooks to x axis and other ideas I have in mind
|
426
|
-
* Improve static navigation
|
427
|
-
* Add meta class to choose your host method name and multi language support as well
|
428
|
-
|
429
426
|
## Found a bug?
|
430
427
|
|
431
428
|
If you are having a problem please open an issue. You can also send an email to m.mastrodonato@gmail.com
|
@@ -122,7 +122,7 @@ module ButlerMainframe
|
|
122
122
|
wait_session
|
123
123
|
end
|
124
124
|
|
125
|
-
raise "It was waiting #{destination} map instead of: #{
|
125
|
+
raise "It was waiting #{destination} map instead of: #{catch_title(:rows => 2).strip}" unless destination_found
|
126
126
|
end
|
127
127
|
|
128
128
|
# Check if we are the first blank cics screen
|
@@ -132,7 +132,7 @@ module ButlerMainframe
|
|
132
132
|
|
133
133
|
# Check if we are on the login mainframe screen
|
134
134
|
def session_login?
|
135
|
-
/#{ButlerMainframe::Settings.session_login_tag}/i ===
|
135
|
+
/#{ButlerMainframe::Settings.session_login_tag}/i === catch_title
|
136
136
|
end
|
137
137
|
|
138
138
|
# Login to mainframe
|
@@ -147,7 +147,7 @@ module ButlerMainframe
|
|
147
147
|
|
148
148
|
wait_session
|
149
149
|
#inizializza_sessione
|
150
|
-
raise "It was waiting session login map instead of: #{
|
150
|
+
raise "It was waiting session login map instead of: #{catch_title}" unless session_login?
|
151
151
|
write user, :y => y_user, :x => x_user
|
152
152
|
write password, :y => y_password, :x => x_password, :sensible_data => true
|
153
153
|
do_enter
|
@@ -155,7 +155,7 @@ module ButlerMainframe
|
|
155
155
|
|
156
156
|
# Check the label to know when we are on the cics selection map
|
157
157
|
def cics_selection?
|
158
|
-
/#{ButlerMainframe::Settings.cics_selection_tag}/i ===
|
158
|
+
/#{ButlerMainframe::Settings.cics_selection_tag}/i === catch_title
|
159
159
|
end
|
160
160
|
|
161
161
|
# On this map, we have to select the cics environment
|
@@ -166,7 +166,7 @@ module ButlerMainframe
|
|
166
166
|
raise "Check cics configuration! #{cics} #{y_cics} #{x_cics}" unless cics && y_cics && x_cics
|
167
167
|
|
168
168
|
wait_session
|
169
|
-
raise "It was waiting cics selezion map instead of: #{
|
169
|
+
raise "It was waiting cics selezion map instead of: #{catch_title}, message: #{catch_message}" unless cics_selection?
|
170
170
|
write cics, :y => y_cics, :x => x_cics
|
171
171
|
do_enter
|
172
172
|
wait_session 1
|
@@ -174,7 +174,7 @@ module ButlerMainframe
|
|
174
174
|
|
175
175
|
# Check the label to know when we are on the cics selection map
|
176
176
|
def company_menu?
|
177
|
-
/#{ButlerMainframe::Settings.company_menu_tag}/i ===
|
177
|
+
/#{ButlerMainframe::Settings.company_menu_tag}/i === catch_title
|
178
178
|
end
|
179
179
|
|
180
180
|
# On this map, we have to select the cics environment
|
@@ -185,7 +185,7 @@ module ButlerMainframe
|
|
185
185
|
raise "Check company menu configuration! #{menu} #{y_menu} #{x_menu}" unless menu && y_menu && x_menu
|
186
186
|
|
187
187
|
wait_session
|
188
|
-
raise "It was waiting company menu map instead of: #{
|
188
|
+
raise "It was waiting company menu map instead of: #{catch_title}, message: #{catch_message}" unless company_menu?
|
189
189
|
write menu, :y => y_menu, :x => x_menu
|
190
190
|
do_enter
|
191
191
|
end
|
@@ -214,12 +214,16 @@ module ButlerMainframe
|
|
214
214
|
|
215
215
|
# Get the title usually the first row
|
216
216
|
# You can change default option :rows to get more lines starting from the first
|
217
|
-
def
|
217
|
+
def catch_title options={}
|
218
218
|
options = {
|
219
219
|
:rows => 1
|
220
220
|
}.merge(options)
|
221
221
|
scan(:y1 => 1, :x1 => 1, :y2 => options[:rows], :x2 => 80)
|
222
222
|
end
|
223
|
+
def screen_title options={}
|
224
|
+
show_deprecated_method 'catch_title'
|
225
|
+
catch_title options
|
226
|
+
end
|
223
227
|
|
224
228
|
def execute_cics name
|
225
229
|
write name, :y => 1, :x => 2
|
data/lib/mainframe/host_base.rb
CHANGED
@@ -15,28 +15,30 @@ module ButlerMainframe
|
|
15
15
|
|
16
16
|
def initialize options={}
|
17
17
|
options = {
|
18
|
-
:session_tag
|
19
|
-
:wait
|
20
|
-
:wait_debug
|
21
|
-
:debug
|
22
|
-
:browser_path
|
23
|
-
:session_url
|
24
|
-
:session_path
|
25
|
-
:timeout
|
26
|
-
:
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
:session_tag => ButlerMainframe.configuration.session_tag,
|
19
|
+
:wait => 0.01, # wait screen in seconds
|
20
|
+
:wait_debug => 2, # wait time for debug purpose
|
21
|
+
:debug => false,
|
22
|
+
:browser_path => ButlerMainframe.configuration.browser_path,
|
23
|
+
:session_url => ButlerMainframe.configuration.session_url,
|
24
|
+
:session_path => ButlerMainframe.configuration.session_path,
|
25
|
+
:timeout => ButlerMainframe.configuration.timeout,
|
26
|
+
:erase_before_writing => false, # execute an erase until end of field before write a text
|
27
|
+
:close_session => :evaluate
|
28
|
+
#:evaluate if the session is found will not be closed
|
29
|
+
#:never never close the session
|
30
|
+
#:always the session is always closed
|
30
31
|
}.merge(options)
|
31
32
|
|
32
|
-
@debug
|
33
|
-
@wait
|
34
|
-
@wait_debug
|
35
|
-
@session_tag
|
36
|
-
@close_session
|
37
|
-
@timeout
|
38
|
-
@
|
39
|
-
@
|
33
|
+
@debug = options[:debug]
|
34
|
+
@wait = options[:wait]
|
35
|
+
@wait_debug = options[:wait_debug]
|
36
|
+
@session_tag = options[:session_tag]
|
37
|
+
@close_session = options[:close_session]
|
38
|
+
@timeout = options[:timeout]
|
39
|
+
@erase_before_writing = options[:timeout]
|
40
|
+
@action = {}
|
41
|
+
@pid = nil
|
40
42
|
|
41
43
|
create_object options
|
42
44
|
end
|
@@ -80,8 +82,8 @@ module ButlerMainframe
|
|
80
82
|
# It reads one line or an area on the screen according to parameters supplied
|
81
83
|
def scan options={}
|
82
84
|
options = {
|
83
|
-
:y
|
84
|
-
:y1 => nil, :x1 => nil, :y2
|
85
|
+
:y => nil, :x => nil, :len => nil,
|
86
|
+
:y1 => nil, :x1 => nil, :y2 => nil, :x2 => nil,
|
85
87
|
}.merge(options)
|
86
88
|
if options[:len]
|
87
89
|
scan_row options[:y], options[:x], options[:len]
|
@@ -104,18 +106,20 @@ module ButlerMainframe
|
|
104
106
|
# :check => true,
|
105
107
|
# :raise_error_on_check => true,
|
106
108
|
# :sensible_data => nil,
|
107
|
-
# :
|
108
|
-
# :
|
109
|
+
# :clean_chars_before_writing => nil, # clean x chars before writing a value
|
110
|
+
# :erase_before_writing => nil # execute an erase until end of field before write a text
|
109
111
|
def write text, options={}
|
112
|
+
options = show_deprecated_param(:erase_field_first, :erase_before_writing, options) if options[:erase_field_first]
|
113
|
+
options = show_deprecated_param(:clean_first_chars, :clean_chars_before_writing, options) if options[:clean_first_chars]
|
110
114
|
options = {
|
111
115
|
:hook => nil,
|
112
|
-
:y => nil,
|
113
|
-
:x => nil,
|
116
|
+
:y => nil,
|
117
|
+
:x => nil,
|
114
118
|
:check => true,
|
115
119
|
:raise_error_on_check => true,
|
116
120
|
:sensible_data => nil,
|
117
|
-
:
|
118
|
-
:
|
121
|
+
:clean_chars_before_writing => nil,
|
122
|
+
:erase_before_writing => @erase_before_writing
|
119
123
|
}.merge(options)
|
120
124
|
|
121
125
|
y = options[:y]
|
@@ -124,8 +128,8 @@ module ButlerMainframe
|
|
124
128
|
x ||= get_cursor_axes[1]
|
125
129
|
|
126
130
|
hooked_rows = 2
|
127
|
-
raise "Missing coordinates! y(row)=#{y} x(column)=#{x} "
|
128
|
-
raise "Sorry, cannot write null values"
|
131
|
+
raise "Missing coordinates! y(row)=#{y} x(column)=#{x} " unless x && y
|
132
|
+
raise "Sorry, cannot write null values" unless text
|
129
133
|
|
130
134
|
bol_written = false
|
131
135
|
if options[:hook]
|
@@ -258,7 +262,7 @@ module ButlerMainframe
|
|
258
262
|
:raise_error_on_check => true,
|
259
263
|
:sensible_data => nil,
|
260
264
|
:clean_first_chars => nil,
|
261
|
-
:
|
265
|
+
:erase_before_writing => nil
|
262
266
|
}.merge(options)
|
263
267
|
raise "Impossible to write beyond row #{MAX_TERMINAL_ROWS}" if y > MAX_TERMINAL_ROWS
|
264
268
|
raise "Impossible to write beyond column #{MAX_TERMINAL_COLUMNS}" if x > MAX_TERMINAL_COLUMNS
|
@@ -273,7 +277,7 @@ module ButlerMainframe
|
|
273
277
|
end
|
274
278
|
end
|
275
279
|
|
276
|
-
if options[:
|
280
|
+
if options[:erase_before_writing]
|
277
281
|
set_cursor_axes y, x
|
278
282
|
do_erase
|
279
283
|
end
|
@@ -295,6 +299,16 @@ module ButlerMainframe
|
|
295
299
|
res
|
296
300
|
end
|
297
301
|
|
302
|
+
def show_deprecated_param old, new, params={}
|
303
|
+
#Ruby 2+ caller_locations(1,1)[0].label
|
304
|
+
puts "[DEPRECATION] please use param :#{new} instead of :#{old} for method #{caller[0][/`([^']*)'/, 1]}"
|
305
|
+
# Creating new param with the value of the old param
|
306
|
+
{new => params[old]}.merge(params)
|
307
|
+
end
|
308
|
+
def show_deprecated_method new
|
309
|
+
puts "[DEPRECATION] please use #{new} method instead of #{caller[0][/`([^']*)'/, 1]}"
|
310
|
+
end
|
311
|
+
|
298
312
|
# If is called a not existing method there is the chance that an optional module may not have been added
|
299
313
|
def method_missing method_name, *args
|
300
314
|
raise NoMethodError, "Method #{method_name} not found! Please check you have included any optional modules"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: butler-mainframe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Mastrodonato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem provides a virtual butler which can perform your custom tasks
|
14
14
|
on a 3270 emulator. Choose your emulator, configure your task and discover a new
|