butler-mainframe 0.4.0 → 0.5.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: 1e16b62e1fe43ac913e3abf67d472103f7cfb1a6
4
- data.tar.gz: b9939a2aeea193b0fa8e1fa398d615796044a481
3
+ metadata.gz: c5b3e86c2581052e59a8f1e74ff1da11a09ebb3c
4
+ data.tar.gz: ddb71edc9e79c6b0a487e975f9bf9b2074b80beb
5
5
  SHA512:
6
- metadata.gz: 913d2e2e8ee7bf21878261a1a883afaef16bce3eabb4a65cf70f5d7624d2dbc081db01b88f071d525435cb2d7e49b9f2e96056955905b1e061a367f84ac294bf
7
- data.tar.gz: dd1c7ab32a76f4448d32fe859e22a31d7c520dd9ef4e60883a3906781f17ca3ef616682dcfcba1967559b6ac6520276ade306531142a8f7eb7d78dd6d7797785
6
+ metadata.gz: 542c1c9854d0163f5562cbc1bf2216ddf5294599362c8a8dc27d8fa2aeb82798c6d12c0dac9b8d2aaec842f3c71628306432e64a45ef3df1b234eacf471a381c
7
+ data.tar.gz: 2a176d220c4f589313277eb8674c255ce1fff43e0d61a004e8919f9b0406ea0885d0a9cc1e04c59dadfa77fa10c461de0805ad5ea11769c0d49355f2699cf17a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.5.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.4.0...v0.5.0) October 26th, 2015
2
+ ------------------------------
3
+ * Moved sensible parameters in a separate yml file (private.yml) do not share it
4
+ * Added coordinates to some setting variables
5
+ * Little improvements to navigation method
6
+
1
7
  0.4.0 [☰](https://github.com/marcomd/butler-mainframe/compare/v0.3.0...v0.4.0) October 22th, 2015
2
8
  ------------------------------
3
9
  * Improved x3270 sub class stability. Added a delay after session starting
data/README.md CHANGED
@@ -31,10 +31,11 @@ At the moment are managed the below emulators. First two are commercial which mu
31
31
 
32
32
  ## Configuration
33
33
 
34
- In the config folder there are two files:
34
+ In the config folder there are three files:
35
35
 
36
36
  * config.rb
37
37
  * settings.yml
38
+ * private.yml
38
39
 
39
40
  ### Emulator configuration
40
41
 
@@ -73,9 +74,9 @@ ButlerMainframe.configure do |config|
73
74
  end
74
75
  ```
75
76
 
76
- ### Use configuration
77
+ ### Configure the navigation
77
78
 
78
- settings.yml for the variables necessary to use the emulator like user, password, cics selection and everything else. It has one section for every environment in rails style.
79
+ settings.yml and private.yml for the variables necessary to use the emulator like user, password, cics selection and everything else. Put sensible data in the second one and remember to not share it. Both have one section for every environment in rails style.
79
80
 
80
81
  foo: add every variable you need and use it with => ButlerMainframe::Settings.foo
81
82
  bar: sub variable are accessible with hash => ButlerMainframe::Settings.foo[:bar]
@@ -126,7 +127,7 @@ host.scan x: 10, y: 10, len: 10
126
127
  host.write 'ruby on rails', :y => 6, :x => 15
127
128
 
128
129
  # write a text using a hook
129
- # With the hook you can use a regular expression to search a label on the y axis (3 rows up and down)
130
+ # With the hook you can use a regular expression to search a label on the y axis (2 rows up and down)
130
131
  # It is usefull when the y position could change (atm it does not use x axis)
131
132
  host.write 'ruby on rails', :y => 6, :x => 15, hook: 'SYSTEM='
132
133
  ```
@@ -252,7 +253,7 @@ I'll try to comment supported emulators based on my experience of about 11 years
252
253
 
253
254
  2. **IBM Personal communication**: it happened that the session got stuck even if it was extremely rare event and i could not never attribute the blame to it. I must also mention the fact that two different processes creates only troubles. High price but at the moment seems to be the best choice.
254
255
 
255
- 3. **x3270**: support is improving, it's free and open source. In future may become the best choice.
256
+ 3. **x3270**: support is improving, it's free and open source. In the future may become the best choice.
256
257
 
257
258
  ## More informations about supported emulators
258
259
 
@@ -384,20 +385,24 @@ Read the methods list documentation: [windows](http://x3270.bgp.nu/Windows/wc327
384
385
  ## ToDo
385
386
 
386
387
  * <s>Improve unit test</s> **Done** although it is still a simple rake
388
+ * Improve write extending hooks to x axis and other ideas I have in mind
387
389
  * Improve static navigation
388
390
  * Add meta class to choose your host method name and multi language support as well
389
391
 
390
- ## License
391
-
392
- The GNU Lesser General Public License, version 3.0 (LGPL-3.0)
393
- See LICENSE file
394
- Custom files are yours and not under license.
395
-
396
-
397
392
  ## Found a bug?
398
393
 
399
394
  If you are having a problem please open an issue. You can also send an email to m.mastrodonato@gmail.com
400
395
 
396
+ ## Contributing
401
397
 
398
+ 1. Fork it
399
+ 2. Create your feature branch (`git checkout -b my-feature`)
400
+ 3. Commit your changes (`git commit -am 'I made extensive use of all my creativity'`)
401
+ 4. Push to the branch (`git push origin my-feature`)
402
+ 5. Create new Pull Request
402
403
 
404
+ ## License
403
405
 
406
+ The GNU Lesser General Public License, version 3.0 (LGPL-3.0)
407
+ See LICENSE file
408
+ Custom files are yours and not under license.
@@ -30,7 +30,10 @@ debug = env == "development" ? true : false
30
30
  require "mainframe/emulators/#{ButlerMainframe.configuration.host_gateway.to_s.downcase}"
31
31
 
32
32
 
33
- ButlerMainframe::Settings.load!(File.join(ButlerMainframe.root,'lib','config','settings.yml'), :env => env)
33
+ %w(settings.yml private.yml).each do |file|
34
+ filepath = File.join(ButlerMainframe.root,'lib','config',file)
35
+ ButlerMainframe::Settings.load!(filepath, :env => env) if File.exist? filepath
36
+ end
34
37
 
35
38
  require 'mainframe/customization/active_record'
36
39
  # puts "Extending Host class with #{Host3270::ActiveRecord}" if debug
data/lib/config/config.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ButlerMainframe.configure do |config|
2
2
  config.host_gateway = :x3270
3
3
  config.session_path = '"C:/Program Files (x86)/wc3270/ws3270.exe" YOUR_HOST_IP -model 2 --'
4
- config.timeout = 5 # In seconds
4
+ config.timeout = 6 # In seconds
5
5
  end
6
6
 
@@ -1,7 +1,7 @@
1
1
  ButlerMainframe.configure do |config|
2
2
  config.host_gateway = :passport
3
3
  config.browser_path = 'c:/Program Files (x86)/Internet Explorer/iexplore.exe'
4
- config.session_url = 'https://localhost/zephyr/Ecomes.zwh?sessionprofile=3270dsp/Sessions/host3270'
4
+ config.session_url = 'https://YOUR_HOST_IP/zephyr/Ecomes.zwh?sessionprofile=3270dsp/Sessions/host3270'
5
5
  config.session_tag = 1
6
6
  config.timeout = 6000
7
7
  end
@@ -1,6 +1,10 @@
1
1
  ButlerMainframe.configure do |config|
2
2
  config.host_gateway = :pcomm
3
- config.session_path = '"C:/Program Files (x86)/IBM/Personal Communications/pcsws.exe" "C:/Users/XXXXXXXXXX/AppData/Roaming/IBM/Personal Communications/host3270.ws" /Q /H /S=A'
3
+ # These the used parameters:
4
+ # /Q to suppress starting logo
5
+ # /H for hidden session
6
+ # /S=A to select the session A (must be the same in session_tag)
7
+ config.session_path = '"C:/Program Files (x86)/IBM/Personal Communications/pcsws.exe" "C:/Users/YOUR_USER/AppData/Roaming/IBM/Personal Communications/host3270.ws" /Q /H /S=A'
4
8
  config.session_tag = 'A'
5
9
  config.timeout = 6000
6
10
  end
@@ -0,0 +1,16 @@
1
+ defaults: &defaults
2
+ session_user: ['YOUR_USER', 16, 36]
3
+ session_password: ['YOUR_PASSWORD', 17, 36]
4
+ #foo: add every variable you need and use it with => ButlerMainframe::Settings.foo
5
+ # bar: sub variable are accessible with hash => ButlerMainframe::Settings.foo[:bar]
6
+
7
+ development:
8
+ <<: *defaults
9
+
10
+ test:
11
+ <<: *defaults
12
+
13
+ production:
14
+ <<: *defaults
15
+ session_user: ['YOUR_USER', 16, 36]
16
+ session_password: ['YOUR_PASSWORD', 17, 36]
@@ -1,19 +1,18 @@
1
1
  defaults: &defaults
2
- # The number of iteration through static screen
3
- navigation_iterations: 10
4
- cics: '7'
5
- user: 'YOURUSER'
6
- password: 'YOURPASSWORD'
7
- #foo: add every variable you need and use it with => ButlerMainframe::Settings.foo
8
- # bar: sub variable are accessible with hash => ButlerMainframe::Settings.foo[:bar]
2
+ # The max number of iteration through static screen
3
+ max_attempts_number: 20
4
+ session_login_tag: 'EMSP00' # Use a regular expression
5
+ cics_selection_tag: 'EMSP01' # Use a regular expression
6
+ cics: ['7', 23, 14] # Text to write at coordinates y, x
7
+ company_menu: ['01', 24, 43]
9
8
  logoff_cics: 'cesf logoff'
10
- session_login_tag: 'EMSP00' #use a regular expression
11
- cics_selection_tag: 'EMSP01' #use a regular expression
12
- company_menu_tag: '\*\* \*\* \*\* \*\*' #use a regular expression
9
+ company_menu_tag: '\*\* \*\* \*\* \*\*' # Use a regular expression
13
10
  # Starts these transactions from blank cics in order to move forward
14
11
  transactions_cics:
15
12
  company_menu: 'vita'
16
13
  main_application: 'life'
14
+ #foo: add every variable you need and use it with => ButlerMainframe::Settings.foo
15
+ # bar: sub variable are accessible with hash => ButlerMainframe::Settings.foo[:bar]
17
16
 
18
17
  development:
19
18
  <<: *defaults
@@ -23,4 +22,4 @@ test:
23
22
 
24
23
  production:
25
24
  <<: *defaults
26
- cics: 4
25
+ cics: ['4', 23, 14]
@@ -1,19 +1,18 @@
1
1
  defaults: &defaults
2
- # The number of iteration through static screen
3
- navigation_iterations: 10
4
- cics: '7'
5
- user: 'YOURUSER'
6
- password: 'YOURPASSWORD'
7
- #foo: add every variable you need and use it with => ButlerMainframe::Settings.foo
8
- # bar: sub variable are accessible with hash => ButlerMainframe::Settings.foo[:bar]
2
+ # The max number of iteration through static screen
3
+ max_attempts_number: 20
4
+ session_login_tag: 'EMSP00' # Use a regular expression
5
+ cics_selection_tag: 'EMSP01' # Use a regular expression
6
+ cics: ['7', 23, 14] # Text to write at coordinates y, x
7
+ company_menu: ['01', 24, 43]
9
8
  logoff_cics: 'cesf logoff'
10
- session_login_tag: 'EMSP00' #use a regular expression
11
- cics_selection_tag: 'EMSP01' #use a regular expression
12
- company_menu_tag: '\*\* \*\* \*\* \*\*' #use a regular expression
9
+ company_menu_tag: '\*\* \*\* \*\* \*\*' # Use a regular expression
13
10
  # Starts these transactions from blank cics in order to move forward
14
11
  transactions_cics:
15
12
  company_menu: 'vita'
16
13
  main_application: 'life'
14
+ #foo: add every variable you need and use it with => ButlerMainframe::Settings.foo
15
+ # bar: sub variable are accessible with hash => ButlerMainframe::Settings.foo[:bar]
17
16
 
18
17
  development:
19
18
  <<: *defaults
@@ -23,4 +22,4 @@ test:
23
22
 
24
23
  production:
25
24
  <<: *defaults
26
- cics: 4
25
+ cics: ['4', 23, 14]
@@ -30,19 +30,23 @@ module Host3270
30
30
  # :raise_on_abend => false raise an exception if an abend is occured
31
31
  def navigate destination, options={}
32
32
  options = {
33
+ :session_user => ButlerMainframe::Settings.session_user,
34
+ :session_password => ButlerMainframe::Settings.session_password,
33
35
  :cics => ButlerMainframe::Settings.cics,
34
- :user => ButlerMainframe::Settings.user,
35
- :password => ButlerMainframe::Settings.password,
36
+ :company_menu => ButlerMainframe::Settings.company_menu,
36
37
  :raise_on_abend => false
37
38
  }.merge(options)
38
- attempts_number = ButlerMainframe::Settings.navigation_iterations
39
+ max_attempts_number = ButlerMainframe::Settings.max_attempts_number
39
40
  transactions_cics = ButlerMainframe::Settings.transactions_cics
40
41
 
41
42
  raise "Destination #{destination} not valid, please use: #{destination_list.join(', ')}" unless destination_list.include? destination
42
43
 
43
44
  puts "Navigating to #{destination}" if @debug
44
- bol_found = nil
45
- attempts_number.times do
45
+ destination_found = nil
46
+ attempt_number = 0
47
+ while !destination_found do
48
+ attempt_number += 1
49
+
46
50
  if abend?
47
51
  puts "Navigate: abend" if @debug
48
52
  options[:raise_on_abend] ? raise(catch_abend) : do_quit
@@ -54,14 +58,14 @@ module Host3270
54
58
  do_quit
55
59
  when :back then
56
60
  do_quit
57
- bol_found = true; break
61
+ destination_found = true
58
62
  when :next then
59
- company_menu
60
- bol_found = true; break
61
- when :company_menu then bol_found = true; break
63
+ company_menu options[:company_menu]
64
+ destination_found = true
65
+ when :company_menu then destination_found = true
62
66
  else
63
67
  # Every other destination is forward
64
- company_menu
68
+ company_menu options[:company_menu]
65
69
  end
66
70
  elsif cics?
67
71
  puts "Navigating to #{destination} from cics" if @debug
@@ -71,10 +75,10 @@ module Host3270
71
75
  execute_cics ButlerMainframe::Settings.logoff_cics
72
76
  when :back then
73
77
  execute_cics ButlerMainframe::Settings.logoff_cics
74
- bol_found = true; break
78
+ destination_found = true
75
79
  when :next then
76
80
  execute_cics transactions_cics[:main_application]
77
- bol_found = true; break
81
+ destination_found = true
78
82
  when :company_menu then
79
83
  execute_cics transactions_cics[:company_menu]
80
84
  else
@@ -84,14 +88,14 @@ module Host3270
84
88
  elsif cics_selection?
85
89
  puts "Navigating to #{destination} from cics selection" if @debug
86
90
  case destination
87
- when :cics_selection then bol_found = true; break
91
+ when :cics_selection then destination_found = true
88
92
  when :session_login then exec_command("PF3")
89
93
  when :next then
90
94
  cics_selection options[:cics] if options[:cics]
91
- bol_found = true; break
95
+ destination_found = true
92
96
  when :back then
93
97
  exec_command("PF3")
94
- bol_found = true; break
98
+ destination_found = true
95
99
  else
96
100
  cics_selection options[:cics] if options[:cics]
97
101
  end
@@ -99,25 +103,25 @@ module Host3270
99
103
  puts "Navigating to #{destination} from session login" if @debug
100
104
  case destination
101
105
  when :session_login,
102
- :back then bol_found = true; break
106
+ :back then destination_found = true
103
107
  when :next then
104
- session_login options[:user], options[:password] if options[:user] && options[:password]
105
- bol_found = true; break
108
+ session_login options[:session_user], options[:session_password]
109
+ destination_found = true
106
110
  else
107
- session_login options[:user], options[:password] if options[:user] && options[:password]
111
+ session_login options[:session_user], options[:session_password]
108
112
  end
109
113
  else
110
114
  puts "Navigating to #{destination} from unknown screen" if @debug
111
115
  # If we do not know where we are...
112
116
  case destination
113
- when :session_login then
117
+ when :session_login then
114
118
  # ...to come back to the first screen we surely have to go back
115
119
  go_back
116
120
  when :back then
117
121
  # ...we can try to go back (not all the screen may go back in the same way)
118
122
  go_back
119
- bol_found = true; break
120
- when :next then
123
+ destination_found = true
124
+ when :next then
121
125
  # ...but we dont know how to move forward
122
126
  raise "Define how to go forward in the navigation method on generic function module"
123
127
  else
@@ -125,10 +129,11 @@ module Host3270
125
129
  raise "Destination #{destination} not defined in the current screen"
126
130
  end
127
131
  end
132
+ break if attempt_number > max_attempts_number
128
133
  wait_session
129
134
  end
130
135
 
131
- raise "It was waiting #{destination} map instead of: #{screen_title(:rows => 2).strip}" unless bol_found
136
+ raise "It was waiting #{destination} map instead of: #{screen_title(:rows => 2).strip}" unless destination_found
132
137
  end
133
138
 
134
139
  # Check if we are the first blank cics screen
@@ -142,15 +147,20 @@ module Host3270
142
147
  end
143
148
 
144
149
  # Login to mainframe
145
- # param1 user
146
- # param2 password [sensible data]
147
- def session_login user, password
150
+ # param1 user(array) [text, y, x]
151
+ # param2 password(array) [text, y, x]
152
+ def session_login ar_user, ar_password
148
153
  puts "Starting session login..." if @debug
154
+ user, y_user, x_user = ar_user
155
+ raise "Check session user configuration! #{user} #{y_user} #{x_user}" unless user && y_user && x_user
156
+ password, y_password, x_password = ar_password
157
+ raise "Check session password configuration! #{password} #{y_password} #{x_password}" unless password && y_password && x_password
158
+
149
159
  wait_session
150
160
  #inizializza_sessione
151
161
  raise "It was waiting session login map instead of: #{screen_title}" unless session_login?
152
- write user, :y => 16, :x => 36
153
- write password, :y => 17, :x => 36, :sensible_data => true
162
+ write user, :y => y_user, :x => x_user
163
+ write password, :y => y_password, :x => x_password, :sensible_data => true
154
164
  do_enter
155
165
  end
156
166
 
@@ -160,12 +170,15 @@ module Host3270
160
170
  end
161
171
 
162
172
  # On this map, we have to select the cics environment
163
- # param1 cics usually is a number
164
- def cics_selection cics
173
+ # param1 cics(array) [text, y, x]
174
+ def cics_selection ar_cics
165
175
  puts "Starting selezione_cics..." if @debug
176
+ cics, y_cics, x_cics = ar_cics
177
+ raise "Check cics configuration! #{cics} #{y_cics} #{x_cics}" unless cics && y_cics && x_cics
178
+
166
179
  wait_session
167
180
  raise "It was waiting cics selezion map instead of: #{screen_title}, message: #{catch_message}" unless cics_selection?
168
- write cics, :y => 23, :x => 14
181
+ write cics, :y => y_cics, :x => x_cics
169
182
  do_enter
170
183
  wait_session 1
171
184
  end
@@ -177,11 +190,14 @@ module Host3270
177
190
 
178
191
  # On this map, we have to select the cics environment
179
192
  # param1 cics usually is a number
180
- def company_menu
193
+ def company_menu ar_menu
181
194
  puts "Starting company menu..." if @debug
195
+ menu, y_menu, x_menu = ar_menu
196
+ raise "Check company menu configuration! #{menu} #{y_menu} #{x_menu}" unless menu && y_menu && x_menu
197
+
182
198
  wait_session
183
199
  raise "It was waiting company menu map instead of: #{screen_title}, message: #{catch_message}" unless company_menu?
184
- write "01", :y => 24, :x => 43
200
+ write menu, :y => y_menu, :x => x_menu
185
201
  do_enter
186
202
  end
187
203
 
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.0
4
+ version: 0.5.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-10-22 00:00:00.000000000 Z
11
+ date: 2015-10-26 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
@@ -28,6 +28,7 @@ files:
28
28
  - lib/config/config_EXAMPLE_passport.rb
29
29
  - lib/config/config_EXAMPLE_pcomm.rb
30
30
  - lib/config/config_EXAMPLE_x3270.rb
31
+ - lib/config/private.yml
31
32
  - lib/config/settings.yml
32
33
  - lib/config/settings_EXAMPLE.yml
33
34
  - lib/core/configuration.rb