Module: TE3270

Extended by:
FunctionKeys
Includes:
ScreenPopulator
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/emulators/x3270.rb,
lib/te3270/emulator_factory.rb,
lib/te3270/emulators/virtel.rb,
lib/te3270/screen_populator.rb,
lib/te3270/emulators/bluezone.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 supported emulators are EXTRA! X-treme by Attachmate, Quick3270 by DN-Computing, Virtel Web Access and X3270. These are commercial products, with the exception of X3270, 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, ScreenPopulator

Constant Summary collapse

VERSION =
"0.9.0"

Constants included from FunctionKeys

FunctionKeys::KEYS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ScreenPopulator

#populate_screen_with

Class Method Details

.disconnect(emulator) ⇒ Object

Disconnects and closes the emulator


82
83
84
# File 'lib/te3270.rb', line 82

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.

for Virtel Web access, and :x3270 for X3270

Parameters:

  • platform

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


72
73
74
75
76
77
# File 'lib/te3270.rb', line 72

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


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

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.


96
97
98
# File 'lib/te3270.rb', line 96

def connect
  platform.connect
end

#disconnectObject

Disconnect from platform (extra or quick)


103
104
105
# File 'lib/te3270.rb', line 103

def disconnect
  platform.disconnect
end

#initialize(platform) ⇒ Object


86
87
88
89
# File 'lib/te3270.rb', line 86

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.


128
129
130
# File 'lib/te3270.rb', line 128

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

#send_keys(keys) ⇒ Object

Send keys on the emulator


110
111
112
# File 'lib/te3270.rb', line 110

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

#textObject

Retrieves the text from the current screen


117
118
119
# File 'lib/te3270.rb', line 117

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


148
149
150
# File 'lib/te3270.rb', line 148

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


139
140
141
# File 'lib/te3270.rb', line 139

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


158
159
160
# File 'lib/te3270.rb', line 158

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