butler-mainframe 0.8.0 → 0.9.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 +4 -0
- data/Gemfile +2 -1
- data/lib/mainframe/customization/generic_functions.rb +16 -20
- data/lib/mainframe/emulators/passport.rb +10 -10
- data/lib/mainframe/emulators/pcomm.rb +19 -15
- data/lib/mainframe/emulators/x3270.rb +12 -12
- data/lib/mainframe/host_base.rb +30 -31
- data/test/test.rake +1 -1
- 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: 7ef1f82ef019d80d63559e5c67ca6f5caf190916
|
4
|
+
data.tar.gz: 7560a4984f33ff6505a6cec3b08e4eb928a3bba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdbecce1c86b27f41c7d0a94d6a6a49437620e81b3c4ced0a047554547235be86f506a253bfaf6a8c810e914c09526127fce0c620f6b6c35a528934fc4b0ecd1
|
7
|
+
data.tar.gz: 2e2023ac2ddfbefff4dc76b3914d840b49202bd4a9cffe03bf078564b6df516c882f5bb502479838af6d0ec935510f9dd68dadf9d5980814ca11ae5f14350e78
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
0.9.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.8.0...v0.9.0) June 20th, 2016
|
2
|
+
------------------------------
|
3
|
+
* PComm emulator: it attempts to start the connection if the terminal is present
|
4
|
+
|
1
5
|
0.8.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.5...v0.8.0) May 3th, 2016
|
2
6
|
------------------------------
|
3
7
|
* PComm emulator: the write param 'clean_chars_before_writing' didn't work
|
data/Gemfile
CHANGED
@@ -17,7 +17,7 @@ module ButlerMainframe
|
|
17
17
|
# :user => ButlerMainframe::Settings.user,
|
18
18
|
# :password => ButlerMainframe::Settings.password,
|
19
19
|
# :raise_on_abend => false raise an exception if an abend is occured
|
20
|
-
def navigate
|
20
|
+
def navigate(destination, options={})
|
21
21
|
options = {
|
22
22
|
:session_user => ButlerMainframe::Settings.session_user,
|
23
23
|
:session_password => ButlerMainframe::Settings.session_password,
|
@@ -138,7 +138,7 @@ module ButlerMainframe
|
|
138
138
|
# Login to mainframe
|
139
139
|
# param1 user(array) [text, y, x]
|
140
140
|
# param2 password(array) [text, y, x]
|
141
|
-
def session_login
|
141
|
+
def session_login(ar_user, ar_password)
|
142
142
|
puts "Starting session login..." if @debug
|
143
143
|
user, y_user, x_user = ar_user
|
144
144
|
raise "Check session user configuration! #{user} #{y_user} #{x_user}" unless user && y_user && x_user
|
@@ -148,8 +148,8 @@ module ButlerMainframe
|
|
148
148
|
wait_session
|
149
149
|
#inizializza_sessione
|
150
150
|
raise "It was waiting session login map instead of: #{catch_title}" unless session_login?
|
151
|
-
write
|
152
|
-
write
|
151
|
+
write(user, :y => y_user, :x => x_user)
|
152
|
+
write(password, :y => y_password, :x => x_password, :sensible_data => true)
|
153
153
|
do_enter
|
154
154
|
end
|
155
155
|
|
@@ -167,7 +167,7 @@ module ButlerMainframe
|
|
167
167
|
|
168
168
|
wait_session
|
169
169
|
raise "It was waiting cics selezion map instead of: #{catch_title}, message: #{catch_message}" unless cics_selection?
|
170
|
-
write
|
170
|
+
write(cics, :y => y_cics, :x => x_cics)
|
171
171
|
do_enter
|
172
172
|
wait_session 1
|
173
173
|
end
|
@@ -186,7 +186,7 @@ module ButlerMainframe
|
|
186
186
|
|
187
187
|
wait_session
|
188
188
|
raise "It was waiting company menu map instead of: #{catch_title}, message: #{catch_message}" unless company_menu?
|
189
|
-
write
|
189
|
+
write(menu, :y => y_menu, :x => x_menu)
|
190
190
|
do_enter
|
191
191
|
end
|
192
192
|
|
@@ -214,31 +214,27 @@ 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 catch_title
|
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
|
223
|
+
def screen_title(options={})
|
224
224
|
show_deprecated_method 'catch_title'
|
225
|
-
catch_title
|
225
|
+
catch_title(options)
|
226
226
|
end
|
227
227
|
|
228
|
-
def execute_cics
|
229
|
-
write
|
228
|
+
def execute_cics(name)
|
229
|
+
write(name, :y => 1, :x => 2)
|
230
230
|
do_enter
|
231
231
|
end
|
232
232
|
|
233
|
-
def do_enter; exec_command
|
234
|
-
|
235
|
-
def
|
236
|
-
|
237
|
-
def
|
238
|
-
|
239
|
-
def do_quit; exec_command "CLEAR" end
|
240
|
-
|
241
|
-
def do_erase; exec_command "ERASE EOF" end
|
233
|
+
def do_enter; exec_command("ENTER") end
|
234
|
+
def go_back; exec_command("PA2") end
|
235
|
+
def do_confirm; exec_command("PF3") end
|
236
|
+
def do_quit; exec_command("CLEAR") end
|
237
|
+
def do_erase; exec_command("ERASE EOF") end
|
242
238
|
|
243
239
|
end
|
244
240
|
|
@@ -8,7 +8,7 @@ module ButlerMainframe
|
|
8
8
|
private
|
9
9
|
|
10
10
|
# Create objects from emulator library
|
11
|
-
def sub_create_object
|
11
|
+
def sub_create_object(options={})
|
12
12
|
str_obj = 'PASSPORT.System'
|
13
13
|
puts "#{Time.now.strftime "%H:%M:%S"} Creating object #{str_obj}..." if @debug == :full
|
14
14
|
@action[:object] = WIN32OLE.new(str_obj)
|
@@ -45,19 +45,19 @@ module ButlerMainframe
|
|
45
45
|
end
|
46
46
|
|
47
47
|
#Execute keyboard command like PF1 or PA2 or ENTER ...
|
48
|
-
def sub_exec_command
|
48
|
+
def sub_exec_command(cmd, options={})
|
49
49
|
# Cast cmd to_s cause it could be passed as label
|
50
50
|
@screen.SendKeys "<#{cmd.gsub /\s/, ''}>"
|
51
51
|
@screen.WaitHostQuiet
|
52
52
|
end
|
53
53
|
|
54
54
|
#It reads one line part of the screen
|
55
|
-
def sub_scan_row
|
55
|
+
def sub_scan_row(y, x, len)
|
56
56
|
@screen.GetString(y, x, len)
|
57
57
|
end
|
58
58
|
|
59
59
|
#It reads a rectangle on the screen
|
60
|
-
def sub_scan_area
|
60
|
+
def sub_scan_area(y1, x1, y2, x2)
|
61
61
|
@screen.Area(y1, x1, y2, x2).Value
|
62
62
|
end
|
63
63
|
|
@@ -67,31 +67,31 @@ module ButlerMainframe
|
|
67
67
|
end
|
68
68
|
|
69
69
|
# Move cursor to given coordinates
|
70
|
-
def sub_set_cursor_axes
|
70
|
+
def sub_set_cursor_axes(y, x, options={})
|
71
71
|
options = {
|
72
72
|
:wait => true
|
73
73
|
}.merge(options)
|
74
|
-
@screen.MoveTo
|
74
|
+
@screen.MoveTo(y, x)
|
75
75
|
@screen.WaitForCursor(y, x) if options[:wait]
|
76
76
|
end
|
77
77
|
|
78
78
|
# Write text on the screen at given coordinates
|
79
79
|
# :check_protect => true add sensitivity to protected areas
|
80
|
-
def sub_write_text
|
80
|
+
def sub_write_text(text, y, x, options={})
|
81
81
|
options = {
|
82
82
|
:check_protect => true
|
83
83
|
}.merge(options)
|
84
84
|
if options[:check_protect]
|
85
85
|
# This method is sensitive to protected areas
|
86
|
-
sub_set_cursor_axes
|
87
|
-
@screen.SendKeys
|
86
|
+
sub_set_cursor_axes(y, x)
|
87
|
+
@screen.SendKeys(text)
|
88
88
|
else
|
89
89
|
@screen.PutString(text, y, x)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
# Wait text at given coordinates and wait the session is available again
|
94
|
-
def sub_wait_for_string
|
94
|
+
def sub_wait_for_string(text, y, x)
|
95
95
|
@screen.WaitForString(text, y, x).Value == -1
|
96
96
|
end
|
97
97
|
|
@@ -10,13 +10,17 @@ module ButlerMainframe
|
|
10
10
|
private
|
11
11
|
|
12
12
|
# Create objects from emulator library
|
13
|
-
def sub_create_object
|
13
|
+
def sub_create_object(options={})
|
14
14
|
str_obj = 'PComm.autECLSession'
|
15
15
|
puts "#{Time.now.strftime "%H:%M:%S"} Creating object #{str_obj}..." if @debug == :full
|
16
16
|
@action[:object] = WIN32OLE.new(str_obj)
|
17
17
|
@action[:object].SetConnectionByName @session_tag
|
18
18
|
@space = @action[:object].autECLPS
|
19
19
|
@screen = @action[:object].autECLOIA
|
20
|
+
if @action[:object] && @action[:object].Started && !@action[:object].CommStarted
|
21
|
+
@action[:object].StartCommunication
|
22
|
+
wait_session(WAIT_AFTER_START_CONNECTION)
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
# Check is session is started
|
@@ -49,29 +53,29 @@ module ButlerMainframe
|
|
49
53
|
# See http://www-01.ibm.com/support/knowledgecenter/SSEQ5Y_6.0.0/com.ibm.pcomm.doc/books/html/admin_guide10.htm?lang=en
|
50
54
|
cmd_stop = "PCOMSTOP /S=#{@session_tag} /q"
|
51
55
|
if /^1.8/ === RUBY_VERSION
|
52
|
-
Thread.new {system cmd_stop}
|
56
|
+
Thread.new { system cmd_stop }
|
53
57
|
else
|
54
|
-
Process.spawn
|
58
|
+
Process.spawn(cmd_stop)
|
55
59
|
end
|
56
60
|
# Process.kill 9, @pid #Another way is to kill the process but the session start 2nd process pcscm.exe
|
57
61
|
end
|
58
62
|
end
|
59
63
|
|
60
64
|
#Execute keyboard command like PF1 or PA2 or ENTER ...
|
61
|
-
def sub_exec_command
|
65
|
+
def sub_exec_command(cmd, options={})
|
62
66
|
# Cast cmd to_s cause it could be passed as label
|
63
|
-
@space.SendKeys
|
64
|
-
@screen.WaitForAppAvailable
|
65
|
-
@screen.WaitForInputReady
|
67
|
+
@space.SendKeys("[#{cmd}]")
|
68
|
+
@screen.WaitForAppAvailable(@timeout)
|
69
|
+
@screen.WaitForInputReady(@timeout)
|
66
70
|
end
|
67
71
|
|
68
72
|
#It reads one line part of the screen
|
69
|
-
def sub_scan_row
|
73
|
+
def sub_scan_row(y, x, len)
|
70
74
|
@space.GetText(y, x, len)
|
71
75
|
end
|
72
76
|
|
73
77
|
#It reads a rectangle on the screen
|
74
|
-
def sub_scan_area
|
78
|
+
def sub_scan_area(y1, x1, y2, x2)
|
75
79
|
@space.GetTextRect(y1, x1, y2, x2)
|
76
80
|
end
|
77
81
|
|
@@ -81,17 +85,17 @@ module ButlerMainframe
|
|
81
85
|
end
|
82
86
|
|
83
87
|
# Move cursor to given coordinates
|
84
|
-
def sub_set_cursor_axes
|
88
|
+
def sub_set_cursor_axes(y, x, options={})
|
85
89
|
options = {
|
86
90
|
:wait => true
|
87
91
|
}.merge(options)
|
88
|
-
@space.SetCursorPos
|
92
|
+
@space.SetCursorPos(y, x)
|
89
93
|
@space.WaitForCursor(y, x, @timeout) if options[:wait]
|
90
94
|
end
|
91
95
|
|
92
96
|
# Write text on the screen at given coordinates
|
93
97
|
# :check_protect => true add sensitivity to protected areas
|
94
|
-
def sub_write_text
|
98
|
+
def sub_write_text(text, y, x, options={})
|
95
99
|
options = {
|
96
100
|
:check_protect => true
|
97
101
|
}.merge(options)
|
@@ -105,9 +109,9 @@ module ButlerMainframe
|
|
105
109
|
end
|
106
110
|
|
107
111
|
# Wait text at given coordinates and wait the session is available again
|
108
|
-
def sub_wait_for_string
|
109
|
-
@space.WaitForString
|
110
|
-
@screen.WaitForInputReady
|
112
|
+
def sub_wait_for_string(text, y, x)
|
113
|
+
@space.WaitForString(text, y, x, @timeout)
|
114
|
+
@screen.WaitForInputReady(@timeout)
|
111
115
|
end
|
112
116
|
|
113
117
|
end
|
@@ -8,14 +8,14 @@ module ButlerMainframe
|
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
def sub_create_object
|
11
|
+
def sub_create_object(options={})
|
12
12
|
str_obj = "#{options[:session_path]}"
|
13
13
|
puts "#{Time.now.strftime "%H:%M:%S"} Creating object #{str_obj}..." if @debug == :full
|
14
14
|
@action = {}
|
15
15
|
@action[:in], @action[:out], @action[:thr] = Open3.popen2e(str_obj)
|
16
16
|
@action[:object] = true
|
17
17
|
sleep WAIT_AFTER_START_SESSION
|
18
|
-
@pid
|
18
|
+
@pid = @action[:thr].pid
|
19
19
|
end
|
20
20
|
|
21
21
|
# Check is session is started
|
@@ -56,7 +56,7 @@ module ButlerMainframe
|
|
56
56
|
x_cmd cmd
|
57
57
|
|
58
58
|
command_skip_wait = %w(^erase ^delete)
|
59
|
-
x_cmd
|
59
|
+
x_cmd("Wait(#{@timeout}, Output)") unless /(#{command_skip_wait.join('|')})/i === cmd
|
60
60
|
end
|
61
61
|
|
62
62
|
#It reads one line part of the screen
|
@@ -71,29 +71,29 @@ module ButlerMainframe
|
|
71
71
|
|
72
72
|
# Get cursor coordinates
|
73
73
|
def sub_get_cursor_axes
|
74
|
-
res = x_cmd
|
75
|
-
res.split.map{|c| c.to_i + 1}
|
74
|
+
res = x_cmd("Query(Cursor)")
|
75
|
+
res.split.map { |c| c.to_i + 1 }
|
76
76
|
end
|
77
77
|
|
78
78
|
# Move cursor to given coordinates
|
79
|
-
def sub_set_cursor_axes
|
79
|
+
def sub_set_cursor_axes(y, x, options={})
|
80
80
|
options = {
|
81
81
|
:wait => true
|
82
82
|
}.merge(options)
|
83
|
-
x_cmd
|
83
|
+
x_cmd("MoveCursor(#{y-1},#{x-1})")
|
84
84
|
if options[:wait]
|
85
|
-
x_cmd
|
85
|
+
x_cmd("Wait(#{@timeout},InputField)")
|
86
86
|
raise "Positioning the cursor at the coordinates (#{y}, #{x}) failed!" unless sub_get_cursor_axes == [y, x]
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
# Write text on the screen at given coordinates
|
91
91
|
# :check_protect => true add sensitivity to protected areas
|
92
|
-
def sub_write_text
|
92
|
+
def sub_write_text(text, y, x, options={})
|
93
93
|
options = {
|
94
94
|
:check_protect => true
|
95
95
|
}.merge(options)
|
96
|
-
sub_set_cursor_axes
|
96
|
+
sub_set_cursor_axes(y, x)
|
97
97
|
x_cmd "String(\"#{text}\")", options
|
98
98
|
# TODO
|
99
99
|
# if options[:check_protect]
|
@@ -101,7 +101,7 @@ module ButlerMainframe
|
|
101
101
|
end
|
102
102
|
|
103
103
|
# Wait text at given coordinates
|
104
|
-
def sub_wait_for_string
|
104
|
+
def sub_wait_for_string(text, y, x)
|
105
105
|
x_cmd "Wait(#{@timeout},InputField)"
|
106
106
|
total_time = 0.0
|
107
107
|
sleep_time = 0.5
|
@@ -115,7 +115,7 @@ module ButlerMainframe
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# To communicate with executable
|
118
|
-
def x_cmd
|
118
|
+
def x_cmd(cmd, options={})
|
119
119
|
puts "x_cmd in: #{options[:sensible_data] ? ('*' * cmd.size) : cmd}" if @debug == :full
|
120
120
|
@action[:in].print "#{cmd}\n"
|
121
121
|
@action[:in].flush
|
data/lib/mainframe/host_base.rb
CHANGED
@@ -9,11 +9,12 @@ module ButlerMainframe
|
|
9
9
|
attr_reader :action, :wait
|
10
10
|
attr_accessor :debug, :close_session
|
11
11
|
|
12
|
-
MAX_TERMINAL_COLUMNS
|
13
|
-
MAX_TERMINAL_ROWS
|
14
|
-
|
12
|
+
MAX_TERMINAL_COLUMNS = 80
|
13
|
+
MAX_TERMINAL_ROWS = 24
|
14
|
+
WAIT_AFTER_START_CONNECTION = 1 #SECONDS
|
15
|
+
WAIT_AFTER_START_SESSION = 3 #SECONDS
|
15
16
|
|
16
|
-
def initialize
|
17
|
+
def initialize(options={})
|
17
18
|
options = {
|
18
19
|
:session_tag => ButlerMainframe.configuration.session_tag,
|
19
20
|
:wait => 0.01, # wait screen in seconds
|
@@ -74,33 +75,33 @@ module ButlerMainframe
|
|
74
75
|
|
75
76
|
|
76
77
|
# Sleep time between operations
|
77
|
-
def wait_session
|
78
|
+
def wait_session(wait=nil)
|
78
79
|
sleep(wait || (@debug ? @wait_debug : @wait))
|
79
80
|
end
|
80
81
|
|
81
82
|
# Execute keyboard command like PF1 or PA2 or ENTER ...
|
82
|
-
def exec_command
|
83
|
+
def exec_command(cmd)
|
83
84
|
puts "Command: #{cmd}" if @debug
|
84
85
|
sub_exec_command cmd
|
85
86
|
wait_session
|
86
87
|
end
|
87
88
|
|
88
89
|
# It reads one line or an area on the screen according to parameters supplied
|
89
|
-
def scan
|
90
|
+
def scan(options={})
|
90
91
|
options = {
|
91
92
|
:y => nil, :x => nil, :len => nil,
|
92
93
|
:y1 => nil, :x1 => nil, :y2 => nil, :x2 => nil,
|
93
94
|
}.merge(options)
|
94
95
|
if options[:len]
|
95
|
-
scan_row
|
96
|
+
scan_row(options[:y], options[:x], options[:len])
|
96
97
|
else
|
97
|
-
scan_area
|
98
|
+
scan_area(options[:y1], options[:x1], options[:y2], options[:x2])
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
101
102
|
# Scans and returns the text of the entire page
|
102
103
|
def scan_page
|
103
|
-
scan_area
|
104
|
+
scan_area(1, 1, MAX_TERMINAL_ROWS, MAX_TERMINAL_COLUMNS)
|
104
105
|
end
|
105
106
|
|
106
107
|
# Write text on screen at the coordinates
|
@@ -114,7 +115,7 @@ module ButlerMainframe
|
|
114
115
|
# :sensible_data => nil,
|
115
116
|
# :clean_chars_before_writing => nil, # clean x chars before writing a value, it switch off erase_before_writing
|
116
117
|
# :erase_before_writing => nil # execute an erase until end of field before write a text
|
117
|
-
def write
|
118
|
+
def write(text, options={})
|
118
119
|
options = show_deprecated_param(:erase_field_first, :erase_before_writing, options) if options[:erase_field_first]
|
119
120
|
options = show_deprecated_param(:clean_first_chars, :clean_chars_before_writing, options) if options[:clean_first_chars]
|
120
121
|
options = {
|
@@ -129,10 +130,8 @@ module ButlerMainframe
|
|
129
130
|
}.merge(options)
|
130
131
|
options[:erase_before_writing] = false if options[:clean_chars_before_writing]
|
131
132
|
|
132
|
-
y
|
133
|
-
x
|
134
|
-
y ||= get_cursor_axes[0]
|
135
|
-
x ||= get_cursor_axes[1]
|
133
|
+
y = options[:y] || get_cursor_axes[0]
|
134
|
+
x = options[:x] || get_cursor_axes[1]
|
136
135
|
|
137
136
|
hooked_rows = 2
|
138
137
|
raise "Missing coordinates! y(row)=#{y} x(column)=#{x} " unless x && y
|
@@ -143,7 +142,7 @@ module ButlerMainframe
|
|
143
142
|
(y-hooked_rows..y+hooked_rows).each do |row_number|
|
144
143
|
if /#{options[:hook]}/ === scan_row(row_number, 1, MAX_TERMINAL_COLUMNS)
|
145
144
|
puts "Change y from #{y} to #{row_number} cause hook to:#{options[:hook]}" if row_number != y && @debug
|
146
|
-
bol_written = write_text_on_map
|
145
|
+
bol_written = write_text_on_map(text, row_number, x, options)
|
147
146
|
break
|
148
147
|
end
|
149
148
|
end
|
@@ -160,8 +159,8 @@ module ButlerMainframe
|
|
160
159
|
end
|
161
160
|
|
162
161
|
# Move the cursor at given coordinates
|
163
|
-
def set_cursor_axes
|
164
|
-
sub_set_cursor_axes
|
162
|
+
def set_cursor_axes(y, x, options={})
|
163
|
+
sub_set_cursor_axes(y, x, options)
|
165
164
|
end
|
166
165
|
|
167
166
|
private
|
@@ -171,7 +170,7 @@ module ButlerMainframe
|
|
171
170
|
# These are the options with default values:
|
172
171
|
# :session_tag => Fixnum, String or null depending on emulator
|
173
172
|
# :debug => boolean
|
174
|
-
def create_object
|
173
|
+
def create_object(options={})
|
175
174
|
connection_attempts = 10
|
176
175
|
seconds_between_attempts = 1
|
177
176
|
|
@@ -224,7 +223,7 @@ module ButlerMainframe
|
|
224
223
|
# :browser_path => browser executable path, default value ButlerMainframe::Settings.browser_path (used by web emulator)
|
225
224
|
# :session_url => the session url used by browser
|
226
225
|
# :session_path => terminal session executable path, default value ButlerMainframe::Settings.session_path
|
227
|
-
def start_terminal_session
|
226
|
+
def start_terminal_session(options)
|
228
227
|
# Check configuration to know emulator starting type
|
229
228
|
executable, args = if options[:browser_path] && !options[:browser_path].empty?
|
230
229
|
[options[:browser_path], options[:session_url]]
|
@@ -248,22 +247,22 @@ module ButlerMainframe
|
|
248
247
|
end
|
249
248
|
|
250
249
|
#It reads one line on the screen
|
251
|
-
def scan_row
|
252
|
-
str = sub_scan_row
|
250
|
+
def scan_row(y, x, len)
|
251
|
+
str = sub_scan_row(y, x, len)
|
253
252
|
puts "Scan row y:#{y} x:#{x} lungo:#{len} = #{str}" if @debug
|
254
253
|
str
|
255
254
|
end
|
256
255
|
|
257
256
|
#It reads a rectangle on the screen
|
258
|
-
def scan_area
|
259
|
-
str = sub_scan_area
|
257
|
+
def scan_area(y1, x1, y2, x2)
|
258
|
+
str = sub_scan_area(y1, x1, y2, x2)
|
260
259
|
puts "Scan area y1:#{y1} x1:#{x1} y2:#{y2} x2:#{x2} = #{str}" if @debug
|
261
260
|
str
|
262
261
|
end
|
263
262
|
|
264
263
|
# Write a text on the screen
|
265
264
|
# It also contains the logic to control the successful writing
|
266
|
-
def write_text_on_map
|
265
|
+
def write_text_on_map(text, y, x, options={})
|
267
266
|
options = {
|
268
267
|
:check => true,
|
269
268
|
:raise_error_on_check => true,
|
@@ -281,17 +280,17 @@ module ButlerMainframe
|
|
281
280
|
end
|
282
281
|
|
283
282
|
if options[:erase_before_writing]
|
284
|
-
set_cursor_axes
|
283
|
+
set_cursor_axes(y, x)
|
285
284
|
do_erase
|
286
285
|
end
|
287
286
|
|
288
|
-
sub_write_text
|
287
|
+
sub_write_text(text, y, x, :check_protect => options[:check])
|
289
288
|
res = true
|
290
289
|
# If check is required it verify text is on the screen at given coordinates
|
291
290
|
# Sensible data option disable the check because it could be on hidden fields
|
292
291
|
if options[:check] && !options[:sensible_data]
|
293
292
|
# It expects the string is present on the session at the specified coordinates
|
294
|
-
unless sub_wait_for_string
|
293
|
+
unless sub_wait_for_string(text, y, x)
|
295
294
|
if options[:raise_error_on_check]
|
296
295
|
raise "write_text_on_map: Impossible to write #{options[:sensible_data] ? ('*' * text.size) : text} at row #{y} column #{x}"
|
297
296
|
else
|
@@ -302,18 +301,18 @@ module ButlerMainframe
|
|
302
301
|
res
|
303
302
|
end
|
304
303
|
|
305
|
-
def show_deprecated_param
|
304
|
+
def show_deprecated_param(old, new, params={})
|
306
305
|
#Ruby 2+ caller_locations(1,1)[0].label
|
307
306
|
puts "[DEPRECATION] please use param :#{new} instead of :#{old} for method #{caller[0][/`([^']*)'/, 1]}"
|
308
307
|
# Creating new param with the value of the old param
|
309
308
|
{new => params[old]}.merge(params)
|
310
309
|
end
|
311
|
-
def show_deprecated_method
|
310
|
+
def show_deprecated_method(new)
|
312
311
|
puts "[DEPRECATION] please use #{new} method instead of #{caller[0][/`([^']*)'/, 1]}"
|
313
312
|
end
|
314
313
|
|
315
314
|
# If is called a not existing method there is the chance that an optional module may not have been added
|
316
|
-
def method_missing
|
315
|
+
def method_missing(method_name, *args)
|
317
316
|
raise NoMethodError, "Method #{method_name} not found! Please check you have included any optional modules"
|
318
317
|
end
|
319
318
|
|
data/test/test.rake
CHANGED
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.9.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: 2016-
|
11
|
+
date: 2016-06-20 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
|