Module: TE3270

Extended by:
FunctionKeys
Defined in:
lib/te3270.rb,
lib/te3270/version.rb,
lib/te3270/accessors.rb,
lib/te3270/function_keys.rb,
lib/te3270/screen_factory.rb,
lib/te3270/emulators/extra.rb,
lib/te3270/emulator_factory.rb,
lib/te3270/emulators/quick3270.rb

Overview

This gem can be used to drive a 3270 terminal emulator. You have to have a supported emulator installed on the machines on which you use the gem. Currently the only supported emulators are EXTRA! X-treme by Attachmate and Quick3270 by DN-Computing. These are commercial products and you will need to purchase one of them in order to use this gem. We do plan to support other emulators as time permits.

This gem has been designed to work very similar to the page-object gem. You will use it to create screen objects for each screen in your application. Here is an example of one and how it can be used:

Another option is to mixin the TE3270::ScreenFactory module on use the factory methods to create the screen objects. If you are using Cucumber you can do this by calling the World method in your env.rb file. Then you can use the factory and navigation methods in your step definitions.

Examples:

Example mainframe page

class MainframeScreen
  include TE3270

  text_field(:userid, 10, 30, 20, true)
  text_field(:password, 12, 30, 20, true)
end

 ...

emulator = TN3270.emulator_for :extra do |emulator|
  emulator.session_file = 'path_to_session_file'
end
my_screen = MainframeScreen.new(emulator)
my_screen.userid = 'the_id'
my_screen.password = 'the_password'

Registering the ScreenFactory with Cucumber World

World(TE3270::ScreenFactory)

Before do
  @emulator = TE3270.emulator_for :quick3270 do |emulator|
    emulator.session_file = 'path_to_session_file'
  end
end

Using the factory method in a step definition

on(MainframeScreen).do_something

See Also:

Defined Under Namespace

Modules: Accessors, EmulatorFactory, Emulators, FunctionKeys, ScreenFactory

Constant Summary collapse

VERSION =
"0.1"

Constants included from FunctionKeys

FunctionKeys::KEYS

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disconnect(emulator) ⇒ Object

Disconnects and closes the emulator



80
81
82
# File 'lib/te3270.rb', line 80

def self.disconnect(emulator)
  emulator.disconnect
end

.emulator_for(platform, &block) ⇒ Object

Starts the terminal emulator and makes the connection. This method requires a block that has emulator specific information that is necessary to complete the connection. To know what information you should provide in the block please see the classes in the TE3270::Emulators package.

Parameters:

  • platform

    [:extra,:quick3270] use :extra for Extra emulator and :quick3270 for quick emulator



70
71
72
73
74
75
# File 'lib/te3270.rb', line 70

def self.emulator_for(platform, &block)
  platform_class = TE3270::EmulatorFactory.emulator_for(platform)
  @platform = platform_class.new
  @platform.connect &block
  @platform
end

.included(cls) ⇒ Object



58
59
60
# File 'lib/te3270.rb', line 58

def self.included(cls)
  cls.extend TE3270::Accessors
end

Instance Method Details

#connectObject

Open a new screen and connect to the host. Platform specific values are set by passing a block to this method. To see the valid platform specific values please read the documentation for your emulator class in the TE3270::Emulators module.



94
95
96
# File 'lib/te3270.rb', line 94

def connect
  platform.connect
end

#disconnectObject

Disconnect from platform (extra or quick)



101
102
103
# File 'lib/te3270.rb', line 101

def disconnect
  platform.disconnect
end

#initialize(platform) ⇒ Object



84
85
86
87
# File 'lib/te3270.rb', line 84

def initialize(platform)
  @platform = platform
  initialize_screen if respond_to? :initialize_screen
end

#screenshot(filename) ⇒ Object

Takes screenshot and saves to the filename specified. If you have visibility set to false then this method will first of all make the screen visible, take the screenshot, and then make set visibility to false again.

Parameters:

  • filename (String)

    of the file to be saved.



126
127
128
# File 'lib/te3270.rb', line 126

def screenshot(filename)
  platform.screenshot(filename)
end

#send_keys(keys) ⇒ Object

Send keys on the emulator



108
109
110
# File 'lib/te3270.rb', line 108

def send_keys(keys)
  platform.send_keys(keys)
end

#textObject

Retrieves the text from the current screen



115
116
117
# File 'lib/te3270.rb', line 115

def text
  platform.text
end

#wait_for_host(seconds = 5) ⇒ Object

Waits for the host for specified # of seconds. Default is 5 seconds

Parameters:

  • seconds (FixedNum) (defaults to: 5)

    to wait for



146
147
148
# File 'lib/te3270.rb', line 146

def wait_for_host(seconds=5)
  platform.wait_for_host(seconds)
end

#wait_for_string(str, row, column) ⇒ Object

Waits for the string to appear at the specified location

Parameters:

  • String (String)

    to wait for

  • row (FixedNum)

    number

  • column (FixedNum)

    number



137
138
139
# File 'lib/te3270.rb', line 137

def wait_for_string(str, row, column)
  platform.wait_for_string(str, row, column)
end

#wait_until_cursor_at(row, column) ⇒ Object

Waits for the cursor to appear at the specified location

Parameters:

  • row (FixedNum)

    number

  • column (FixedNum)

    number



156
157
158
# File 'lib/te3270.rb', line 156

def wait_until_cursor_at(row, column)
  platform.wait_until_cursor_at(row, column)
end