te3270 0.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43a4597d3e0372918c7aa435c1e5382acb1da399
4
+ data.tar.gz: b33dd3a8d4a7c0a3beb388c829783ef87ea7c635
5
+ SHA512:
6
+ metadata.gz: b191bae8db8652acb276e4c72ae2f568b52d410d3f6aee02a2f4c4d2d29d23e82c3e0b33dea0b1f84cdbe1ca2de721c0743b3e2a168bdefe82119b3a7e4b1723
7
+ data.tar.gz: 225c1a950743da301bdefa346e62fe2b7e9f2f7aa4e526521210f1b0a64dd1e52d7ed52f5c87793faebc4778c36c101d8f2d5cb6609fec9f99414eac8c6845f2
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/ChangeLog ADDED
@@ -0,0 +1,2 @@
1
+ === Version 0.1 / 2014-2-7
2
+ * Initial release with basic functionality for EXTRA X-treme! and Quick3270
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ require 'rbconfig'
4
+
5
+ gem 'rake'
6
+ gem 'fuubar'
7
+ gem 'guard-rspec'
8
+ gem 'wdm', '>= 0.1.0'
9
+ gem 'rb-inotify'
10
+
11
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+
2
+ guard :rspec, :all_on_start => true, :cmd => 'rspec --color --format Fuubar' do
3
+ watch(%r{^spec/*/.+_spec\.rb$})
4
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
5
+ watch('spec/spec_helper.rb') { "spec" }
6
+ end
7
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jeffrey S. Morgan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # TE3270
2
+
3
+ This gem can be used to drive a 3270 terminal emulator. You have to have a supported emulator installed on the
4
+ machines on which you use the gem. Currently the only supported emulators are
5
+ [EXTRA! X-treme](http://www.attachmate.com/Products/Terminal+Emulation/Extra/xtreme/extra-x-treme.htm) by
6
+ Attachmate and [Quick3270](http://www.dn-computing.com/Quick3270.htm) by DN-Computing. These are commercial
7
+ products and you will need to purchase one of them in order to use this gem. We do plan to support other
8
+ emulators as time permits.
9
+
10
+ ## Documentation
11
+
12
+ You can view the RDocs for this project [here](http://rdoc.info/github/cheezy/te3270/master/frames).
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'te3270'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install te3270
27
+
28
+ ## Usage
29
+
30
+ You can create classes that are similar to page-object classes. In these classes you can define
31
+ the various fields that you wish to interact with on the screen.
32
+
33
+ class MainframeScreen
34
+ include TE3270
35
+
36
+ text_field(:userid, 10, 30, 20)
37
+ text_field(:password, 12, 30, 20)
38
+
39
+ def login(username, password)
40
+ self.userid = username
41
+ self.password = password
42
+ end
43
+ end
44
+
45
+ emulator = TE3270.emulator_for :extra do |platform|
46
+ platform.session_file = 'sessionfile.edp'
47
+ end
48
+ my_screen = MainframeScreen.new(emulator)
49
+ my_screen.userid = 'the_id'
50
+ my_screen.password = 'the_password'
51
+
52
+ If you are using this gem with cucumber then you can register the ScreenFactory module with the
53
+ cucumber World like this:
54
+
55
+ World(TE3270::ScreenFactory)
56
+
57
+ You also need to setup some hooks to start and stop the emulator:
58
+
59
+ Begin do
60
+ @emulator = TE3270.emulator_for :extra do |platform|
61
+ platform.session_file = 'sessionfile.edp'
62
+ end
63
+ end
64
+
65
+ After do
66
+ TE3270.disconnect(@emulator)
67
+ end
68
+
69
+ This allows you to use the `on` method in your step definitions like this:
70
+
71
+ on(MainframeScreen).login('the_user', 'the_password')
72
+
73
+ or you can use the version of `on` that takes a block like this:
74
+
75
+ on(MainframeScreen) do |screen|
76
+ screen.userid = 'the_id'
77
+ screen.password = 'the_password'
78
+ end
79
+
80
+ ## Contributing
81
+
82
+ 1. Fork it
83
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
84
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
85
+ 4. Push to the branch (`git push origin my-new-feature`)
86
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,30 @@
1
+
2
+ module TE3270
3
+ module Accessors
4
+
5
+ #
6
+ # adds two methods to the screen object - one to set text in a text field,
7
+ # another to retrieve text from a text field.
8
+ #
9
+ # @example
10
+ # text_field(:first_name, 23,45,20)
11
+ # # will generate 'first_name', 'first_name=' method
12
+ #
13
+ # @param [String] the name used for the generated methods
14
+ # @param [FixedNum] row number of the location
15
+ # @param [FixedNum] column number of the location
16
+ # @param [FixedNum] length of the text field
17
+ # @param [true|false] editable is by default true
18
+ #
19
+ def text_field(name, row, column, length, editable=true)
20
+ define_method(name) do
21
+ platform.get_string(row, column, length)
22
+ end
23
+
24
+ define_method("#{name}=") do |value|
25
+ platform.put_string(value, row, column)
26
+ end if editable
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ require 'te3270/emulators/extra'
2
+ require 'te3270/emulators/quick3270'
3
+
4
+ module TE3270
5
+ #
6
+ # Provides a mapping between a key used in the +emulator_for+ method
7
+ # and the class that implements the access to the emulator.
8
+ #
9
+ module EmulatorFactory
10
+
11
+ EMULATORS = {
12
+ extra: TE3270::Emulators::Extra,
13
+ quick3270: TE3270::Emulators::Quick3270
14
+ }
15
+
16
+ def self.emulator_for(platform)
17
+ EMULATORS[platform]
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,197 @@
1
+ require 'win32ole'
2
+ require 'win32/screenshot'
3
+
4
+ module TE3270
5
+ module Emulators
6
+ #
7
+ # This class has the code necessary to communicate with the terminal emulator called EXTRA! X-treme.
8
+ # You can use this emulator by providing the +:extra+ parameter to the constructor of your screen
9
+ # object or by passing the same value to the +emulator_for+ method on the +TE3270+ module.
10
+ #
11
+ class Extra
12
+
13
+ attr_writer :session_file, :visible, :window_state, :max_wait_time
14
+
15
+
16
+ #
17
+ # Creates a method to connect to Extra System. This method expects a block in which certain
18
+ # platform specific values can be set. Extra can take the following parameters.
19
+ #
20
+ # * session_file - this value is required and should be the filename of the session.
21
+ # * visible - determines if the emulator is visible or not. If not set it will default to +true+.
22
+ # * window_state - determines the state of the session window. Valid values are +:minimized+,
23
+ # +:normal+, and +:maximized+. If not set it will default to +:normal+.
24
+ #
25
+ # @example Example calling screen object constructor with a block
26
+ # screen_object = MyScreenObject.new(:extra)
27
+ # screen_object.connect do |emulator|
28
+ # emulator.session_file = 'path_to_session_file'
29
+ # emulator.visible = true
30
+ # emulator.window_state = :maximized
31
+ # end
32
+ #
33
+ def connect
34
+ start_extra_system
35
+
36
+ yield self if block_given?
37
+ raise 'The session file must be set in a block when calling connect with the Extra emulator.' if @session_file.nil?
38
+ open_session
39
+ @screen = session.Screen
40
+ @area = screen.SelectAll
41
+ end
42
+
43
+ #
44
+ # Disconnects the Extra System connection
45
+ #
46
+ def disconnect
47
+ system.Quit
48
+ end
49
+
50
+ #
51
+ # Extracts text of specified length from a start point.
52
+ #
53
+ # @param [Fixnum] row the x coordinate of location on the screen.
54
+ # @param [Fixnum] column the y coordinate of location on the screen.
55
+ # @param [Fixnum] length the length of string to extract
56
+ # @return [String]
57
+ #
58
+ def get_string(row, column, length)
59
+ screen.GetString(row, column, length)
60
+ end
61
+
62
+ #
63
+ # Puts string at the coordinates specified.
64
+ #
65
+ # @param [String] str the string to set
66
+ # @param [Fixnum] row the x coordinate of the location on the screen.
67
+ # @param [Fixnum] column the y coordinate of the location on the screen.
68
+ #
69
+ def put_string(str, row, column)
70
+ screen.PutString(str, row, column)
71
+ quiet_period
72
+ end
73
+
74
+ #
75
+ # Sends keystrokes to the host, including function keys.
76
+ #
77
+ # @param [String] keys keystokes up to 255 in length
78
+ #
79
+ def send_keys(keys)
80
+ screen.SendKeys(keys)
81
+ quiet_period
82
+ end
83
+
84
+ #
85
+ # Wait for the string to appear at the specified location
86
+ #
87
+ # @param [String] str the string to wait for
88
+ # @param [Fixnum] row the x coordinate of location
89
+ # @param [Fixnum] column the y coordinate of location
90
+ #
91
+ def wait_for_string(str, row, column)
92
+ wait_for do
93
+ screen.WaitForString(str, row, column)
94
+ end
95
+ end
96
+
97
+ #
98
+ # Waits for the host to not send data for a specified number of seconds
99
+ #
100
+ # @param [Fixnum] seconds the maximum number of seconds to wait
101
+ #
102
+ def wait_for_host(seconds)
103
+ wait_for(seconds) do
104
+ screen.WaitHostQuiet
105
+ end
106
+ end
107
+
108
+ #
109
+ # Waits until the cursor is at the specified location.
110
+ #
111
+ # @param [Fixnum] row the x coordinate of the location
112
+ # @param [Fixnum] column the y coordinate of the location
113
+ #
114
+ def wait_until_cursor_at(row, column)
115
+ wait_for do
116
+ screen.WaitForCursor(row, column)
117
+ end
118
+ end
119
+
120
+ #
121
+ # Creates a method to take screenshot of the active screen. If you have set the +:visible+
122
+ # property to false it will be made visible prior to taking the screenshot and then changed
123
+ # to invisible after.
124
+ #
125
+ # @param [String] filename the path and name of the screenshot file to be saved
126
+ #
127
+ def screenshot(filename)
128
+ File.delete(filename) if File.exists?(filename)
129
+ session.Visible = true unless visible
130
+ hwnd = session.WindowHandle
131
+ Win32::Screenshot::Take.of(:window, hwnd: hwnd).write(filename)
132
+ session.Visible = false unless visible
133
+ end
134
+
135
+ #
136
+ # Returns the text of the active screen
137
+ #
138
+ # @return [String]
139
+ #
140
+ def text
141
+ area.Value
142
+ end
143
+
144
+ private
145
+
146
+ attr_reader :system, :sessions, :session, :screen, :area
147
+
148
+ WINDOW_STATES = {
149
+ minimized: 0,
150
+ normal: 1,
151
+ maximized: 2
152
+ }
153
+
154
+ def wait_for(seconds = system.TimeoutValue / 1000)
155
+ wait_collection = yield
156
+ wait_collection.Wait(seconds * 1000)
157
+ end
158
+
159
+ def quiet_period
160
+ wait_for_host(max_wait_time)
161
+ end
162
+
163
+ def max_wait_time
164
+ @max_wait_time ||= 1
165
+ end
166
+
167
+ def window_state
168
+ @window_state.nil? ? 1 : WINDOW_STATES[@window_state]
169
+ end
170
+
171
+ def visible
172
+ @visible.nil? ? true : @visible
173
+ end
174
+
175
+ def hide_splash_screen
176
+ version = system.Version
177
+ sessions.VisibleOnStartup = true if version.to_i >= 9
178
+ end
179
+
180
+ def open_session
181
+ @sessions = system.Sessions
182
+ hide_splash_screen
183
+ @session = sessions.Open @session_file
184
+ @session.WindowState = window_state
185
+ @session.Visible = visible
186
+ end
187
+
188
+ def start_extra_system
189
+ begin
190
+ @system = WIN32OLE.new('EXTRA.System')
191
+ rescue Exception => e
192
+ $stderr.puts e
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,178 @@
1
+ require 'win32ole'
2
+ require 'win32/screenshot'
3
+
4
+ module TE3270
5
+ module Emulators
6
+
7
+ #
8
+ # This class has the code necessary to communicate with the terminal emulator called Quick3270.
9
+ # You can use this emulator by providing the +:quick+ parameter to the constructor of your screen
10
+ # object or by passing the same value to the +emulator_for+ method on the +TE3270+ module.
11
+ #
12
+
13
+ class Quick3270
14
+
15
+ attr_writer :session_file, :visible, :max_wait_time
16
+
17
+ #
18
+ # Creates a method to connect to Quick System. This method expects a block in which certain
19
+ # platform specific values can be set. Quick can take the following parameters.
20
+ #
21
+ # * session_file - this value is required and should be the filename of the session.
22
+ # * visible - determines if the emulator is visible or not. If not set it will default to +true+.
23
+ #
24
+ # @example Example calling screen object constructor with a block
25
+ # screen_object = MyScreenObject.new(:quick3270)
26
+ # screen_object.connect do |emulator|
27
+ # emulator.session_file = 'path_to_session_file'
28
+ # emulator.visible = true
29
+ # end
30
+ #
31
+ def connect
32
+ start_quick_system
33
+ yield self if block_given?
34
+ raise "The session file must be set in a block when calling connect with the Quick3270 emulator." if @session_file.nil?
35
+ establish_session
36
+ end
37
+
38
+ #
39
+ # Disconnects the Quick System connection
40
+ #
41
+ def disconnect
42
+ session.Disconnect
43
+ system.Application.Quit
44
+ end
45
+
46
+ #
47
+ # Extracts text of specified length from a start point.
48
+ #
49
+ # @param [Fixnum] row the x coordinate of location on the screen.
50
+ # @param [Fixnum] column the y coordinate of location on the screen.
51
+ # @param [Fixnum] length the length of string to extract
52
+ # @return [String]
53
+ #
54
+ def get_string(row, column, length)
55
+ screen.GetString(row, column, length)
56
+ end
57
+
58
+ #
59
+ # Puts string at the coordinates specified.
60
+ #
61
+ # @param [String] str the string to set
62
+ # @param [Fixnum] row the x coordinate of the location on the screen.
63
+ # @param [Fixnum] column the y coordinate of the location on the screen.
64
+ #
65
+ def put_string(str, row, column)
66
+ screen.MoveTo(row, column)
67
+ screen.PutString(str)
68
+ quiet_period
69
+ end
70
+
71
+ #
72
+ # Sends keystrokes to the host, including function keys.
73
+ #
74
+ # @param [String] keys keystokes up to 255 in length
75
+ #
76
+ def send_keys(keys)
77
+ screen.SendKeys(keys)
78
+ quiet_period
79
+ end
80
+
81
+ #
82
+ # Wait for the string to appear at the specified location
83
+ #
84
+ # @param [String] str the string to wait for
85
+ # @param [Fixnum] row the x coordinate of location
86
+ # @param [Fixnum] column the y coordinate of location
87
+ #
88
+ def wait_for_string(str, row, column)
89
+ screen.WaitForString(str, row, column)
90
+ end
91
+
92
+ #
93
+ # Waits for the host to not send data for a specified number of seconds
94
+ #
95
+ # @param [Fixnum] seconds the maximum number of seconds to wait
96
+ #
97
+ def wait_for_host(seconds)
98
+ screen.WaitHostQuiet(seconds * 1000)
99
+ end
100
+
101
+ #
102
+ # Waits until the cursor is at the specified location.
103
+ #
104
+ # @param [Fixnum] row the x coordinate of the location
105
+ # @param [Fixnum] column the y coordinate of the location
106
+ #
107
+ def wait_until_cursor_at(row, column)
108
+ screen.WaitForCursor(row, column)
109
+ end
110
+
111
+ #
112
+ # Creates a method to take screenshot of the active screen. If you have set the +:visible+
113
+ # property to false it will be made visible prior to taking the screenshot and then changed
114
+ # to invisible after.
115
+ #
116
+ # @param [String] filename the path and name of the screenshot file to be saved
117
+ #
118
+ def screenshot(filename)
119
+ File.delete(filename) if File.exists?(filename)
120
+ system.Visible = true unless visible
121
+ title = system.WindowTitle
122
+ Win32::Screenshot::Take.of(:window, title: title).write(filename)
123
+ system.Visible = false unless visible
124
+ end
125
+
126
+ #
127
+ # Returns the text of the active screen
128
+ #
129
+ # @return [String]
130
+ #
131
+ def text
132
+ rows = screen.Rows
133
+ columns = screen.Cols
134
+ result = ''
135
+ rows.times { |row| result += "#{screen.GetString(row+1, 1, columns)}\\n" }
136
+ result
137
+ end
138
+
139
+ private
140
+
141
+ attr_reader :system, :session, :screen
142
+
143
+ def quiet_period
144
+ screen.WaitHostQuiet(max_wait_time)
145
+ end
146
+
147
+ def max_wait_time
148
+ @max_wait_time ||= 3000
149
+ end
150
+
151
+ def visible
152
+ @visible.nil? ? true : @visible
153
+ end
154
+
155
+ def start_quick_system
156
+ begin
157
+ @system = WIN32OLE.new('Quick3270.Application')
158
+ rescue Exception => e
159
+ $stderr.puts e
160
+ end
161
+ end
162
+
163
+ def establish_session
164
+ system.Visible = visible
165
+ @session = system.ActiveSession
166
+ session.Open @session_file
167
+ @screen = session.Screen
168
+ session.Connect
169
+ connected = session.Connected
170
+ while not connected
171
+ screen.WaitHostQuiet(1000)
172
+ connected = session.Connected
173
+ end
174
+ end
175
+
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,78 @@
1
+
2
+ module TE3270
3
+ #
4
+ # Creates methods that are mixed in with the +TE3270+ module that represent all of the
5
+ # function keys that can be send to the system. These keys would typically be sent to
6
+ # the +send_keys_ method.
7
+ #
8
+ # @example Using a function key
9
+ # on(MyScreen).send_keys TE3270.Enter
10
+ #
11
+ module FunctionKeys
12
+
13
+ KEYS = [
14
+ 'Attn',
15
+ 'BackSpace',
16
+ 'BackTab',
17
+ 'CapsLock',
18
+ 'Clear',
19
+ 'Down',
20
+ 'Left',
21
+ 'Left2',
22
+ 'Right',
23
+ 'Right2',
24
+ 'CursorSelect',
25
+ 'Up',
26
+ 'Delete',
27
+ 'Dup',
28
+ 'Enter',
29
+ 'EraseEOF',
30
+ 'EraseInput',
31
+ 'FieldMark',
32
+ 'Home',
33
+ 'Insert',
34
+ 'BackTab',
35
+ 'NewLIne',
36
+ 'PenSel',
37
+ 'Print',
38
+ 'Reset',
39
+ 'ShiftOn',
40
+ 'SysReq',
41
+ 'Tab',
42
+ 'Pa1',
43
+ 'Pa2',
44
+ 'Pa3',
45
+ 'Pf1',
46
+ 'Pf2',
47
+ 'Pf3',
48
+ 'Pf4',
49
+ 'Pf5',
50
+ 'Pf6',
51
+ 'Pf7',
52
+ 'Pf8',
53
+ 'Pf9',
54
+ 'Pf10',
55
+ 'Pf11',
56
+ 'Pf12',
57
+ 'Pf13',
58
+ 'Pf14',
59
+ 'Pf15',
60
+ 'Pf16',
61
+ 'Pf17',
62
+ 'Pf18',
63
+ 'Pf19',
64
+ 'Pf20',
65
+ 'Pf21',
66
+ 'Pf22',
67
+ 'Pf23',
68
+ 'Pf24',
69
+ ]
70
+
71
+ KEYS.each do |key|
72
+ define_method(key) do
73
+ "<#{key}>"
74
+ end
75
+ end
76
+
77
+ end
78
+ end