butler-mainframe 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ef1f82ef019d80d63559e5c67ca6f5caf190916
4
- data.tar.gz: 7560a4984f33ff6505a6cec3b08e4eb928a3bba2
3
+ metadata.gz: 783587371d145db981ac752afa8a77c05e47ff68
4
+ data.tar.gz: 42b7f67759930cc421585ff741bb99638a9d33ef
5
5
  SHA512:
6
- metadata.gz: fdbecce1c86b27f41c7d0a94d6a6a49437620e81b3c4ced0a047554547235be86f506a253bfaf6a8c810e914c09526127fce0c620f6b6c35a528934fc4b0ecd1
7
- data.tar.gz: 2e2023ac2ddfbefff4dc76b3914d840b49202bd4a9cffe03bf078564b6df516c882f5bb502479838af6d0ec935510f9dd68dadf9d5980814ca11ae5f14350e78
6
+ metadata.gz: 9413212f83962d7e92734f8ff09719ed1afdac51a16dc9df123841c52495ccbec8ecff37a41e380db634c7cf5463bedcd45ae1d1622368adba30e1b945f1759c
7
+ data.tar.gz: 1bf1250d01a27c1fc7aed90f7f045715a24a146b810279572108e617a435df2fbc7b36133af4ceab8ec671e7614772c500d37ff17986e0caad3452c379d0f396
@@ -1,95 +1,100 @@
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
-
5
- 0.8.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.5...v0.8.0) May 3th, 2016
6
- ------------------------------
7
- * PComm emulator: the write param 'clean_chars_before_writing' didn't work
8
- * Improved write with params clean_chars_before_writing:
9
- * now switch off erase_before_writing because there might be a conflict
10
- * now switch off check protect param which use SendKey and it could provide an unexpected result
11
-
12
- 0.7.5 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.4...v0.7.5) April 19th, 2016
13
- ------------------------------
14
- * Fixed a bug (Stack level too deep) on the write command when was passed the parameter :clean_chars_before_writing
15
-
16
- 0.7.4 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.3...v0.7.4) April 13th, 2016
17
- ------------------------------
18
- * You can now let the session open with the new quit parameter :never
19
- * Now you can change the close session parameter after the object was created
20
- * Improved documentation
21
- * PComm emulator: removed StopCommunication from quit due to session stuck if it will not be closed
22
-
23
- 0.7.3 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.2...v0.7.3) March 29th, 2016
24
- ------------------------------
25
- * PComm emulator: fixed a bug when closing the session with ruby 1.8
26
-
27
- 0.7.2 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.1...v0.7.2) March 22th, 2016
28
- ------------------------------
29
- * Fixed a bug during install in a rails project
30
-
31
- 0.7.1 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.0...v0.7.1) January 12th, 2016
32
- ------------------------------
33
- * Now the message contains the coordinates when you try to write a null value
34
-
35
- 0.7.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.6.0...v0.7.0) December 2th, 2015
36
- ------------------------------
37
- * Now is possible to set erase_before_writing permanently to execute an erase until end of field before writing a text
38
- * Changed param name in write method: erase_before_writing instead of erase_field_first => deprecation warning
39
- * Changed param name in write method: clean_chars_before_writing instead of clean_first_chars => deprecation warning
40
- * Changed method name: screen_title becomes catch_title to align it to the methods name that provide a similar result => deprecation warning
41
-
42
- 0.6.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.5.0...v0.6.0) October 29th, 2015
43
- ------------------------------
44
- * Improved rails integration
45
- * Added rails model test with the scaffold generator, see documentation
46
- * Added env parameter in the configuration file
47
- * Several little improvements
48
-
49
- 0.5.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.4.0...v0.5.0) October 26th, 2015
50
- ------------------------------
51
- * Moved sensible parameters in a separate yml file (private.yml) do not share it
52
- * Added coordinates to some setting variables
53
- * Little improvements to navigation method
54
-
55
- 0.4.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.3.0...v0.4.0) October 22th, 2015
56
- ------------------------------
57
- * Improved x3270 sub class stability. Added a delay after session starting
58
- * Several little improvements
59
-
60
- 0.3.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.2.0...v0.3.0) October 22th, 2015
61
- ------------------------------
62
- * Improved the host base class code to make it simpler
63
- * Improved automated tests with a more complex sequence and three iterations with decreasing latencies
64
- * Pcomm sub class now use safer method to close session
65
- * x3270 sub class is now more stable, It now passes all the tests although not always, rarely this does not happen with short delay time. There is still something to fix.
66
- * Improved navigation and added new setting parameters
67
- * Improved documentation
68
- * Several little improvements
69
-
70
- 0.2.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.1.0...v0.2.0) October 20th, 2015
71
- ------------------------------
72
- * Added support for the free and open source x3270 terminal emulator, use :x3270 as host gateway in butler configuration
73
- * Added x3270 sections to documentation
74
- * Passport sub class now remove spaces from command input
75
- * Added :erase_field_first param to write method in the host base class in addition to :clean_first_chars to clear a given number of chars
76
-
77
- 0.1.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.0.6...v0.1.0) October 14th, 2015
78
- ------------------------------
79
- * Added IBM personal communication support (tested on 6.0.16), use :pcomm as host gateway in butler configuration
80
- * Many documentation improvements with technical details and examples
81
- * Little improvements in host base to manage ready? sub methods, a new check as well as created?
82
- * Two new config parameters: timeout and session_tag to connect to the right session
83
- * Write text now have an option parameter :check_protect which raise an error when on protect area
84
- * Improved passport driver class: now it use a session screen @variable to optimize memory use
85
- * Change include module methods to monkey patch to add ruby 1.8.7 support
86
-
87
- 0.0.6 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.0.5...v0.0.6) October 12th, 2015
88
- ------------------------------
89
- * Added a simple rake test
90
- * Improved documentation
91
- * Some little improvements
92
-
93
- 0.0.5 October 7th, 2015
94
- ------------------------------
1
+ 0.10.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.9.0...v0.10.0) June 21th, 2016
2
+ ------------------------------
3
+ * New check keyboard locked for all emulators
4
+ * Now write a value in a protected field return specific error message and avoid to wait the text on the map
5
+
6
+ 0.9.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.8.0...v0.9.0) June 20th, 2016
7
+ ------------------------------
8
+ * PComm emulator: it attempts to start the connection if the terminal is present
9
+
10
+ 0.8.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.5...v0.8.0) May 3th, 2016
11
+ ------------------------------
12
+ * PComm emulator: the write param 'clean_chars_before_writing' didn't work
13
+ * Improved write with params clean_chars_before_writing:
14
+ * now switch off erase_before_writing because there might be a conflict
15
+ * now switch off check protect param which use SendKey and it could provide an unexpected result
16
+
17
+ 0.7.5 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.4...v0.7.5) April 19th, 2016
18
+ ------------------------------
19
+ * Fixed a bug (Stack level too deep) on the write command when was passed the parameter :clean_chars_before_writing
20
+
21
+ 0.7.4 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.3...v0.7.4) April 13th, 2016
22
+ ------------------------------
23
+ * You can now let the session open with the new quit parameter :never
24
+ * Now you can change the close session parameter after the object was created
25
+ * Improved documentation
26
+ * PComm emulator: removed StopCommunication from quit due to session stuck if it will not be closed
27
+
28
+ 0.7.3 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.2...v0.7.3) March 29th, 2016
29
+ ------------------------------
30
+ * PComm emulator: fixed a bug when closing the session with ruby 1.8
31
+
32
+ 0.7.2 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.1...v0.7.2) March 22th, 2016
33
+ ------------------------------
34
+ * Fixed a bug during install in a rails project
35
+
36
+ 0.7.1 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.7.0...v0.7.1) January 12th, 2016
37
+ ------------------------------
38
+ * Now the message contains the coordinates when you try to write a null value
39
+
40
+ 0.7.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.6.0...v0.7.0) December 2th, 2015
41
+ ------------------------------
42
+ * Now is possible to set erase_before_writing permanently to execute an erase until end of field before writing a text
43
+ * Changed param name in write method: erase_before_writing instead of erase_field_first => deprecation warning
44
+ * Changed param name in write method: clean_chars_before_writing instead of clean_first_chars => deprecation warning
45
+ * Changed method name: screen_title becomes catch_title to align it to the methods name that provide a similar result => deprecation warning
46
+
47
+ 0.6.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.5.0...v0.6.0) October 29th, 2015
48
+ ------------------------------
49
+ * Improved rails integration
50
+ * Added rails model test with the scaffold generator, see documentation
51
+ * Added env parameter in the configuration file
52
+ * Several little improvements
53
+
54
+ 0.5.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.4.0...v0.5.0) October 26th, 2015
55
+ ------------------------------
56
+ * Moved sensible parameters in a separate yml file (private.yml) do not share it
57
+ * Added coordinates to some setting variables
58
+ * Little improvements to navigation method
59
+
60
+ 0.4.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.3.0...v0.4.0) October 22th, 2015
61
+ ------------------------------
62
+ * Improved x3270 sub class stability. Added a delay after session starting
63
+ * Several little improvements
64
+
65
+ 0.3.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.2.0...v0.3.0) October 22th, 2015
66
+ ------------------------------
67
+ * Improved the host base class code to make it simpler
68
+ * Improved automated tests with a more complex sequence and three iterations with decreasing latencies
69
+ * Pcomm sub class now use safer method to close session
70
+ * x3270 sub class is now more stable, It now passes all the tests although not always, rarely this does not happen with short delay time. There is still something to fix.
71
+ * Improved navigation and added new setting parameters
72
+ * Improved documentation
73
+ * Several little improvements
74
+
75
+ 0.2.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.1.0...v0.2.0) October 20th, 2015
76
+ ------------------------------
77
+ * Added support for the free and open source x3270 terminal emulator, use :x3270 as host gateway in butler configuration
78
+ * Added x3270 sections to documentation
79
+ * Passport sub class now remove spaces from command input
80
+ * Added :erase_field_first param to write method in the host base class in addition to :clean_first_chars to clear a given number of chars
81
+
82
+ 0.1.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.0.6...v0.1.0) October 14th, 2015
83
+ ------------------------------
84
+ * Added IBM personal communication support (tested on 6.0.16), use :pcomm as host gateway in butler configuration
85
+ * Many documentation improvements with technical details and examples
86
+ * Little improvements in host base to manage ready? sub methods, a new check as well as created?
87
+ * Two new config parameters: timeout and session_tag to connect to the right session
88
+ * Write text now have an option parameter :check_protect which raise an error when on protect area
89
+ * Improved passport driver class: now it use a session screen @variable to optimize memory use
90
+ * Change include module methods to monkey patch to add ruby 1.8.7 support
91
+
92
+ 0.0.6 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.0.5...v0.0.6) October 12th, 2015
93
+ ------------------------------
94
+ * Added a simple rake test
95
+ * Improved documentation
96
+ * Some little improvements
97
+
98
+ 0.0.5 October 7th, 2015
99
+ ------------------------------
95
100
  * First working release
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rake'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
4
  gem 'butler-mainframe', path: '.'
@@ -1,241 +1,241 @@
1
- # These modules contain extensions for the Host class
2
- module ButlerMainframe
3
- module GenericFunctions
4
-
5
- # If you add your static screen you must add it in the navigation method to define how to manage it
6
- def destination_list
7
- [:company_menu,
8
- :cics_selection,
9
- :session_login,
10
- :next,
11
- :back]
12
- end
13
-
14
- # Use navigation method to move through the static screens
15
- # Options:
16
- # :cics => ButlerMainframe::Settings.cics,
17
- # :user => ButlerMainframe::Settings.user,
18
- # :password => ButlerMainframe::Settings.password,
19
- # :raise_on_abend => false raise an exception if an abend is occured
20
- def navigate(destination, options={})
21
- options = {
22
- :session_user => ButlerMainframe::Settings.session_user,
23
- :session_password => ButlerMainframe::Settings.session_password,
24
- :cics => ButlerMainframe::Settings.cics,
25
- :company_menu => ButlerMainframe::Settings.company_menu,
26
- :raise_on_abend => false
27
- }.merge(options)
28
- max_attempts_number = ButlerMainframe::Settings.max_attempts_number
29
- transactions_cics = ButlerMainframe::Settings.transactions_cics
30
-
31
- raise "Destination #{destination} not valid, please use: #{destination_list.join(', ')}" unless destination_list.include? destination
32
-
33
- puts "Navigating to #{destination}" if @debug
34
- destination_found = nil
35
- attempt_number = 0
36
- while !destination_found do
37
- attempt_number += 1
38
-
39
- if abend?
40
- puts "Navigate: abend" if @debug
41
- options[:raise_on_abend] ? raise(catch_abend) : do_quit
42
- elsif company_menu?
43
- puts "Navigating to #{destination} from company menu" if @debug
44
- case destination
45
- when :cics_selection,
46
- :session_login then
47
- do_quit
48
- when :back then
49
- do_quit
50
- destination_found = true
51
- when :next then
52
- company_menu options[:company_menu]
53
- destination_found = true
54
- when :company_menu then destination_found = true
55
- else
56
- # Every other destination is forward
57
- company_menu options[:company_menu]
58
- end
59
- elsif cics?
60
- puts "Navigating to #{destination} from cics" if @debug
61
- case destination
62
- when :cics_selection,
63
- :session_login then
64
- execute_cics ButlerMainframe::Settings.logoff_cics
65
- when :back then
66
- execute_cics ButlerMainframe::Settings.logoff_cics
67
- destination_found = true
68
- when :next then
69
- execute_cics transactions_cics[:main_application]
70
- destination_found = true
71
- when :company_menu then
72
- execute_cics transactions_cics[:company_menu]
73
- else
74
- #If we are in CICS with blank screen start the first transaction
75
- execute_cics transactions_cics[:main_application]
76
- end
77
- elsif cics_selection?
78
- puts "Navigating to #{destination} from cics selection" if @debug
79
- case destination
80
- when :cics_selection then destination_found = true
81
- when :session_login then exec_command("PF3")
82
- when :next then
83
- cics_selection options[:cics] if options[:cics]
84
- destination_found = true
85
- when :back then
86
- exec_command("PF3")
87
- destination_found = true
88
- else
89
- cics_selection options[:cics] if options[:cics]
90
- end
91
- elsif session_login?
92
- puts "Navigating to #{destination} from session login" if @debug
93
- case destination
94
- when :session_login,
95
- :back then destination_found = true
96
- when :next then
97
- session_login options[:session_user], options[:session_password]
98
- destination_found = true
99
- else
100
- session_login options[:session_user], options[:session_password]
101
- end
102
- else
103
- puts "Navigating to #{destination} from unknown screen" if @debug
104
- # If we do not know where we are...
105
- case destination
106
- when :session_login then
107
- # ...to come back to the first screen we surely have to go back
108
- go_back
109
- when :back then
110
- # ...we can try to go back (not all the screen may go back in the same way)
111
- go_back
112
- destination_found = true
113
- when :next then
114
- # ...but we dont know how to move forward
115
- raise "Define how to go forward in the navigation method on generic function module"
116
- else
117
- # We unlock the position with both commands to be sure that they are managed by all maps cics
118
- raise "Destination #{destination} not defined in the current screen"
119
- end
120
- end
121
- break if attempt_number > max_attempts_number
122
- wait_session
123
- end
124
-
125
- raise "It was waiting #{destination} map instead of: #{catch_title(:rows => 2).strip}" unless destination_found
126
- end
127
-
128
- # Check if we are the first blank cics screen
129
- def cics?
130
- scan(:y1 => 1, :x1 => 1, :y2 => 22, :x2 => 80).strip.empty?
131
- end
132
-
133
- # Check if we are on the login mainframe screen
134
- def session_login?
135
- /#{ButlerMainframe::Settings.session_login_tag}/i === catch_title
136
- end
137
-
138
- # Login to mainframe
139
- # param1 user(array) [text, y, x]
140
- # param2 password(array) [text, y, x]
141
- def session_login(ar_user, ar_password)
142
- puts "Starting session login..." if @debug
143
- user, y_user, x_user = ar_user
144
- raise "Check session user configuration! #{user} #{y_user} #{x_user}" unless user && y_user && x_user
145
- password, y_password, x_password = ar_password
146
- raise "Check session password configuration! #{password} #{y_password} #{x_password}" unless password && y_password && x_password
147
-
148
- wait_session
149
- #inizializza_sessione
150
- raise "It was waiting session login map instead of: #{catch_title}" unless session_login?
151
- write(user, :y => y_user, :x => x_user)
152
- write(password, :y => y_password, :x => x_password, :sensible_data => true)
153
- do_enter
154
- end
155
-
156
- # Check the label to know when we are on the cics selection map
157
- def cics_selection?
158
- /#{ButlerMainframe::Settings.cics_selection_tag}/i === catch_title
159
- end
160
-
161
- # On this map, we have to select the cics environment
162
- # param1 cics(array) [text, y, x]
163
- def cics_selection ar_cics
164
- puts "Starting selezione_cics..." if @debug
165
- cics, y_cics, x_cics = ar_cics
166
- raise "Check cics configuration! #{cics} #{y_cics} #{x_cics}" unless cics && y_cics && x_cics
167
-
168
- wait_session
169
- raise "It was waiting cics selezion map instead of: #{catch_title}, message: #{catch_message}" unless cics_selection?
170
- write(cics, :y => y_cics, :x => x_cics)
171
- do_enter
172
- wait_session 1
173
- end
174
-
175
- # Check the label to know when we are on the cics selection map
176
- def company_menu?
177
- /#{ButlerMainframe::Settings.company_menu_tag}/i === catch_title
178
- end
179
-
180
- # On this map, we have to select the cics environment
181
- # param1 cics usually is a number
182
- def company_menu ar_menu
183
- puts "Starting company menu..." if @debug
184
- menu, y_menu, x_menu = ar_menu
185
- raise "Check company menu configuration! #{menu} #{y_menu} #{x_menu}" unless menu && y_menu && x_menu
186
-
187
- wait_session
188
- raise "It was waiting company menu map instead of: #{catch_title}, message: #{catch_message}" unless company_menu?
189
- write(menu, :y => y_menu, :x => x_menu)
190
- do_enter
191
- end
192
-
193
- # Get the message line usually in the bottom of the screen
194
- # You can define which rows provide the message:
195
- # :first_row => 22,
196
- # :last_row => 23
197
- def catch_message options={}
198
- options = {
199
- :first_row => 22,
200
- :last_row => 23
201
- }.merge(options)
202
- scan(:y1 => options[:first_row], :x1 => 1, :y2 => options[:last_row], :x2 => 80).gsub(/\s+/, " ").strip
203
- end
204
-
205
- # Get the abend message
206
- def catch_abend
207
- scan(:y1 => 23, :x1 => 1, :y2 => 23, :x2 => 80)
208
- end
209
-
210
- # Check if there was a malfunction on the mainframe
211
- def abend?
212
- /DFHA/i === catch_abend
213
- end
214
-
215
- # Get the title usually the first row
216
- # You can change default option :rows to get more lines starting from the first
217
- def catch_title(options={})
218
- options = {
219
- :rows => 1
220
- }.merge(options)
221
- scan(:y1 => 1, :x1 => 1, :y2 => options[:rows], :x2 => 80)
222
- end
223
- def screen_title(options={})
224
- show_deprecated_method 'catch_title'
225
- catch_title(options)
226
- end
227
-
228
- def execute_cics(name)
229
- write(name, :y => 1, :x => 2)
230
- do_enter
231
- end
232
-
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
238
-
239
- end
240
-
1
+ # These modules contain extensions for the Host class
2
+ module ButlerMainframe
3
+ module GenericFunctions
4
+
5
+ # If you add your static screen you must add it in the navigation method to define how to manage it
6
+ def destination_list
7
+ [:company_menu,
8
+ :cics_selection,
9
+ :session_login,
10
+ :next,
11
+ :back]
12
+ end
13
+
14
+ # Use navigation method to move through the static screens
15
+ # Options:
16
+ # :cics => ButlerMainframe::Settings.cics,
17
+ # :user => ButlerMainframe::Settings.user,
18
+ # :password => ButlerMainframe::Settings.password,
19
+ # :raise_on_abend => false raise an exception if an abend is occured
20
+ def navigate(destination, options={})
21
+ options = {
22
+ :session_user => ButlerMainframe::Settings.session_user,
23
+ :session_password => ButlerMainframe::Settings.session_password,
24
+ :cics => ButlerMainframe::Settings.cics,
25
+ :company_menu => ButlerMainframe::Settings.company_menu,
26
+ :raise_on_abend => false
27
+ }.merge(options)
28
+ max_attempts_number = ButlerMainframe::Settings.max_attempts_number
29
+ transactions_cics = ButlerMainframe::Settings.transactions_cics
30
+
31
+ raise "Destination #{destination} not valid, please use: #{destination_list.join(', ')}" unless destination_list.include? destination
32
+
33
+ puts "Navigating to #{destination}" if @debug
34
+ destination_found = nil
35
+ attempt_number = 0
36
+ while !destination_found do
37
+ attempt_number += 1
38
+
39
+ if abend?
40
+ puts "Navigate: abend" if @debug
41
+ options[:raise_on_abend] ? raise(catch_abend) : do_quit
42
+ elsif company_menu?
43
+ puts "Navigating to #{destination} from company menu" if @debug
44
+ case destination
45
+ when :cics_selection,
46
+ :session_login then
47
+ do_quit
48
+ when :back then
49
+ do_quit
50
+ destination_found = true
51
+ when :next then
52
+ company_menu options[:company_menu]
53
+ destination_found = true
54
+ when :company_menu then destination_found = true
55
+ else
56
+ # Every other destination is forward
57
+ company_menu options[:company_menu]
58
+ end
59
+ elsif cics?
60
+ puts "Navigating to #{destination} from cics" if @debug
61
+ case destination
62
+ when :cics_selection,
63
+ :session_login then
64
+ execute_cics ButlerMainframe::Settings.logoff_cics
65
+ when :back then
66
+ execute_cics ButlerMainframe::Settings.logoff_cics
67
+ destination_found = true
68
+ when :next then
69
+ execute_cics transactions_cics[:main_application]
70
+ destination_found = true
71
+ when :company_menu then
72
+ execute_cics transactions_cics[:company_menu]
73
+ else
74
+ #If we are in CICS with blank screen start the first transaction
75
+ execute_cics transactions_cics[:main_application]
76
+ end
77
+ elsif cics_selection?
78
+ puts "Navigating to #{destination} from cics selection" if @debug
79
+ case destination
80
+ when :cics_selection then destination_found = true
81
+ when :session_login then exec_command("PF3")
82
+ when :next then
83
+ cics_selection options[:cics] if options[:cics]
84
+ destination_found = true
85
+ when :back then
86
+ exec_command("PF3")
87
+ destination_found = true
88
+ else
89
+ cics_selection options[:cics] if options[:cics]
90
+ end
91
+ elsif session_login?
92
+ puts "Navigating to #{destination} from session login" if @debug
93
+ case destination
94
+ when :session_login,
95
+ :back then destination_found = true
96
+ when :next then
97
+ session_login options[:session_user], options[:session_password]
98
+ destination_found = true
99
+ else
100
+ session_login options[:session_user], options[:session_password]
101
+ end
102
+ else
103
+ puts "Navigating to #{destination} from unknown screen" if @debug
104
+ # If we do not know where we are...
105
+ case destination
106
+ when :session_login then
107
+ # ...to come back to the first screen we surely have to go back
108
+ go_back
109
+ when :back then
110
+ # ...we can try to go back (not all the screen may go back in the same way)
111
+ go_back
112
+ destination_found = true
113
+ when :next then
114
+ # ...but we dont know how to move forward
115
+ raise "Define how to go forward in the navigation method on generic function module"
116
+ else
117
+ # We unlock the position with both commands to be sure that they are managed by all maps cics
118
+ raise "Destination #{destination} not defined in the current screen"
119
+ end
120
+ end
121
+ break if attempt_number > max_attempts_number
122
+ wait_session
123
+ end
124
+
125
+ raise "It was waiting #{destination} map instead of: #{catch_title(:rows => 2).strip}" unless destination_found
126
+ end
127
+
128
+ # Check if we are the first blank cics screen
129
+ def cics?
130
+ scan(:y1 => 1, :x1 => 1, :y2 => 22, :x2 => 80).strip.empty?
131
+ end
132
+
133
+ # Check if we are on the login mainframe screen
134
+ def session_login?
135
+ /#{ButlerMainframe::Settings.session_login_tag}/i === catch_title
136
+ end
137
+
138
+ # Login to mainframe
139
+ # param1 user(array) [text, y, x]
140
+ # param2 password(array) [text, y, x]
141
+ def session_login(ar_user, ar_password)
142
+ puts "Starting session login..." if @debug
143
+ user, y_user, x_user = ar_user
144
+ raise "Check session user configuration! #{user} #{y_user} #{x_user}" unless user && y_user && x_user
145
+ password, y_password, x_password = ar_password
146
+ raise "Check session password configuration! #{password} #{y_password} #{x_password}" unless password && y_password && x_password
147
+
148
+ wait_session
149
+ #inizializza_sessione
150
+ raise "It was waiting session login map instead of: #{catch_title}" unless session_login?
151
+ write(user, :y => y_user, :x => x_user)
152
+ write(password, :y => y_password, :x => x_password, :sensible_data => true)
153
+ do_enter
154
+ end
155
+
156
+ # Check the label to know when we are on the cics selection map
157
+ def cics_selection?
158
+ /#{ButlerMainframe::Settings.cics_selection_tag}/i === catch_title
159
+ end
160
+
161
+ # On this map, we have to select the cics environment
162
+ # param1 cics(array) [text, y, x]
163
+ def cics_selection ar_cics
164
+ puts "Starting selezione_cics..." if @debug
165
+ cics, y_cics, x_cics = ar_cics
166
+ raise "Check cics configuration! #{cics} #{y_cics} #{x_cics}" unless cics && y_cics && x_cics
167
+
168
+ wait_session
169
+ raise "It was waiting cics selezion map instead of: #{catch_title}, message: #{catch_message}" unless cics_selection?
170
+ write(cics, :y => y_cics, :x => x_cics)
171
+ do_enter
172
+ wait_session 1
173
+ end
174
+
175
+ # Check the label to know when we are on the cics selection map
176
+ def company_menu?
177
+ /#{ButlerMainframe::Settings.company_menu_tag}/i === catch_title
178
+ end
179
+
180
+ # On this map, we have to select the cics environment
181
+ # param1 cics usually is a number
182
+ def company_menu ar_menu
183
+ puts "Starting company menu..." if @debug
184
+ menu, y_menu, x_menu = ar_menu
185
+ raise "Check company menu configuration! #{menu} #{y_menu} #{x_menu}" unless menu && y_menu && x_menu
186
+
187
+ wait_session
188
+ raise "It was waiting company menu map instead of: #{catch_title}, message: #{catch_message}" unless company_menu?
189
+ write(menu, :y => y_menu, :x => x_menu)
190
+ do_enter
191
+ end
192
+
193
+ # Get the message line usually in the bottom of the screen
194
+ # You can define which rows provide the message:
195
+ # :first_row => 22,
196
+ # :last_row => 23
197
+ def catch_message options={}
198
+ options = {
199
+ :first_row => 22,
200
+ :last_row => 23
201
+ }.merge(options)
202
+ scan(:y1 => options[:first_row], :x1 => 1, :y2 => options[:last_row], :x2 => 80).gsub(/\s+/, " ").strip
203
+ end
204
+
205
+ # Get the abend message
206
+ def catch_abend
207
+ scan(:y1 => 23, :x1 => 1, :y2 => 23, :x2 => 80)
208
+ end
209
+
210
+ # Check if there was a malfunction on the mainframe
211
+ def abend?
212
+ /DFHA/i === catch_abend
213
+ end
214
+
215
+ # Get the title usually the first row
216
+ # You can change default option :rows to get more lines starting from the first
217
+ def catch_title(options={})
218
+ options = {
219
+ :rows => 1
220
+ }.merge(options)
221
+ scan(:y1 => 1, :x1 => 1, :y2 => options[:rows], :x2 => 80)
222
+ end
223
+ def screen_title(options={})
224
+ show_deprecated_method 'catch_title'
225
+ catch_title(options)
226
+ end
227
+
228
+ def execute_cics(name)
229
+ write(name, :y => 1, :x => 2)
230
+ do_enter
231
+ end
232
+
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
238
+
239
+ end
240
+
241
241
  end