scriptty 1.0.0-java → 1.1.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/scriptty/expect.rb +23 -1
  3. data/test/expect_test.rb +9 -0
  4. metadata +145 -145
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -23,12 +23,13 @@ require 'scriptty/screen_pattern'
23
23
  require 'scriptty/util/transcript/writer'
24
24
  require 'set'
25
25
  require 'pp'
26
+ require 'pathname'
26
27
 
27
28
  module ScripTTY
28
29
  class Expect
29
30
 
30
31
  # Methods to export to Evaluator
31
- EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :send_password, :capture, :match, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout, :load_screens, :print, :puts, :p, :pp ]
32
+ EXPORTED_METHODS = Set.new [:basedir, :init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :send_password, :capture, :match, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_basedir, :set_timeout, :load_screens, :print, :puts, :p, :pp ]
32
33
 
33
34
  attr_reader :term # The terminal emulation object
34
35
 
@@ -38,6 +39,8 @@ module ScripTTY
38
39
  attr_accessor :transcript_writer # Set this to an instance of ScripTTY::Util::Transcript::Writer
39
40
  attr_accessor :transcript_writer_autoclose # Set this to false to disable closing transcript_writer on exit
40
41
 
42
+ attr_accessor :basedir # The base directory for eval_script_file and load_screens. Defaults to "."
43
+
41
44
  # Initialize the Expect object.
42
45
  def initialize(options={})
43
46
  @net = ScripTTY::Net::EventLoop.new
@@ -54,6 +57,7 @@ module ScripTTY
54
57
  @transcript_writer = options[:transcript_writer]
55
58
  @transcript_writer_autoclose = options[:transcript_writer_autoclose].nil? ? true : options[:transcript_writer_autoclose]
56
59
  @screen_patterns = {}
60
+ @basedir = "."
57
61
  end
58
62
 
59
63
  # Get instance variable from the Evaluator
@@ -78,9 +82,25 @@ module ScripTTY
78
82
  nil
79
83
  end
80
84
 
85
+ def set_basedir(path)
86
+ @basedir = path
87
+ nil
88
+ end
89
+
90
+ # Return the expanded path relative to basedir
91
+ def expand_path(path)
92
+ base = Pathname.new(@basedir)
93
+ p = Pathname.new(path)
94
+ unless p.absolute?
95
+ p = base.join(p)
96
+ end
97
+ p.expand_path.to_s
98
+ end
99
+
81
100
  # Load and evaluate a script from a file.
82
101
  def eval_script_file(path)
83
102
  fail_unexpected_block if block_given?
103
+ path = expand_path(path)
84
104
  eval_script_inline(File.read(path), path)
85
105
  end
86
106
 
@@ -178,7 +198,9 @@ module ScripTTY
178
198
  # Load screens from the specified filenames
179
199
  def load_screens(filenames_or_glob)
180
200
  fail_unexpected_block if block_given?
201
+ filenames_or_glob = filenames_or_glob.to_s if filenames_or_glob.is_a?(Pathname)
181
202
  if filenames_or_glob.is_a?(String)
203
+ filenames_or_glob = expand_path(filenames_or_glob)
182
204
  filenames = Dir.glob(filenames_or_glob)
183
205
  elsif filenames_or_glob.is_a?(Array)
184
206
  filenames = filenames_or_glob
data/test/expect_test.rb CHANGED
@@ -56,5 +56,14 @@ class ExpectTest < Test::Unit::TestCase
56
56
  end
57
57
  assert_equal "`screen' method given but does not take a block", exc.message
58
58
  end
59
+
60
+ def test_basedir
61
+ e = ScripTTY::Expect.new
62
+ assert_equal ".", e.basedir, "basedir should default to '.'"
63
+ e.set_basedir File.dirname(__FILE__) + "/expect"
64
+ assert_not_equal ".", e.basedir, "basedir should be changed by set_basedir"
65
+ e.load_screens "screens.txt"
66
+ assert_not_nil e.screen(:hello_world), "screen should load successfully"
67
+ end
59
68
  end
60
69
  end
metadata CHANGED
@@ -3,13 +3,13 @@ name: scriptty
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
- - 1
7
- - 0
8
- - 0
9
- version: 1.0.0
6
+ - 1
7
+ - 1
8
+ - 0
9
+ version: 1.1.0
10
10
  platform: java
11
11
  authors:
12
- - Dwayne Litzenberger
12
+ - Dwayne Litzenberger
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
@@ -17,30 +17,30 @@ cert_chain: []
17
17
  date: 2010-05-13 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: treetop
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
30
- type: :runtime
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: multibyte
34
- prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
42
- type: :runtime
43
- version_requirements: *id002
20
+ - !ruby/object:Gem::Dependency
21
+ name: treetop
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: multibyte
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
44
44
  description: |
45
45
  ScripTTY is a JRuby application and library that lets you control full-screen
46
46
  terminal applications using an expect-like scripting language and a full-screen
@@ -48,117 +48,117 @@ description: |
48
48
 
49
49
  email: dlitz@infonium.ca
50
50
  executables:
51
- - scriptty-capture
52
- - scriptty-dump-screens
53
- - scriptty-replay
54
- - scriptty-term-test
55
- - scriptty-transcript-parse
51
+ - scriptty-capture
52
+ - scriptty-dump-screens
53
+ - scriptty-replay
54
+ - scriptty-term-test
55
+ - scriptty-transcript-parse
56
56
  extensions: []
57
57
 
58
58
  extra_rdoc_files:
59
- - README.rdoc
59
+ - README.rdoc
60
60
  files:
61
- - .gitattributes
62
- - .gitignore
63
- - COPYING
64
- - COPYING.LESSER
65
- - README.rdoc
66
- - Rakefile
67
- - VERSION
68
- - bin/scriptty-capture
69
- - bin/scriptty-dump-screens
70
- - bin/scriptty-replay
71
- - bin/scriptty-term-test
72
- - bin/scriptty-transcript-parse
73
- - examples/captures/xterm-overlong-line-prompt.bin
74
- - examples/captures/xterm-vim-session.bin
75
- - examples/demo-capture.rb
76
- - examples/demo-telnet-session-screens.txt
77
- - examples/demo-telnet-session.rb
78
- - examples/rdispatch/demo-request-dispatcher.rb
79
- - examples/rdispatch/done_screen.txt
80
- - examples/rdispatch/login.rb
81
- - examples/rdispatch/start_screen.txt
82
- - examples/rdispatch/vim_screen.txt
83
- - examples/telnet-nego.rb
84
- - lib/scriptty/apps/capture_app.rb
85
- - lib/scriptty/apps/dump_screens_app.rb
86
- - lib/scriptty/apps/replay_app.rb
87
- - lib/scriptty/apps/term_test_app.rb
88
- - lib/scriptty/apps/transcript_parse_app.rb
89
- - lib/scriptty/cursor.rb
90
- - lib/scriptty/exception.rb
91
- - lib/scriptty/expect.rb
92
- - lib/scriptty/multiline_buffer.rb
93
- - lib/scriptty/net/console.rb
94
- - lib/scriptty/net/event_loop.rb
95
- - lib/scriptty/net/password_prompt.rb
96
- - lib/scriptty/request_dispatcher.rb
97
- - lib/scriptty/screen_pattern.rb
98
- - lib/scriptty/screen_pattern/generator.rb
99
- - lib/scriptty/screen_pattern/parser.rb
100
- - lib/scriptty/term.rb
101
- - lib/scriptty/term/dg410.rb
102
- - lib/scriptty/term/dg410/dg410-client-escapes.txt
103
- - lib/scriptty/term/dg410/dg410-escapes.txt
104
- - lib/scriptty/term/dg410/parser.rb
105
- - lib/scriptty/term/xterm.rb
106
- - lib/scriptty/term/xterm/xterm-escapes.txt
107
- - lib/scriptty/util/fsm.rb
108
- - lib/scriptty/util/fsm/definition_parser.rb
109
- - lib/scriptty/util/fsm/scriptty_fsm_definition.treetop
110
- - lib/scriptty/util/transcript/reader.rb
111
- - lib/scriptty/util/transcript/writer.rb
112
- - test.watchr
113
- - test/apps/capture_app_test.rb
114
- - test/apps/transcript_parse_app_test.rb
115
- - test/cursor_test.rb
116
- - test/expect/screens.txt
117
- - test/expect_test.rb
118
- - test/fsm_definition_parser_test.rb
119
- - test/fsm_test.rb
120
- - test/multiline_buffer_test.rb
121
- - test/net/event_loop_test.rb
122
- - test/screen_pattern/generator_test.rb
123
- - test/screen_pattern/parser_test.rb
124
- - test/screen_pattern/parser_test/explicit_cursor_pattern.txt
125
- - test/screen_pattern/parser_test/explicit_fields.txt
126
- - test/screen_pattern/parser_test/multiple_patterns.txt
127
- - test/screen_pattern/parser_test/simple_pattern.txt
128
- - test/screen_pattern/parser_test/truncated_heredoc.txt
129
- - test/screen_pattern/parser_test/utf16bebom_pattern.bin
130
- - test/screen_pattern/parser_test/utf16lebom_pattern.bin
131
- - test/screen_pattern/parser_test/utf8_pattern.bin
132
- - test/screen_pattern/parser_test/utf8_unix_pattern.bin
133
- - test/screen_pattern/parser_test/utf8bom_pattern.bin
134
- - test/term/dg410/parser_test.rb
135
- - test/term/xterm_test.rb
136
- - test/test_helper.rb
137
- - test/util/transcript/reader_test.rb
138
- - test/util/transcript/writer_test.rb
61
+ - .gitattributes
62
+ - .gitignore
63
+ - COPYING
64
+ - COPYING.LESSER
65
+ - README.rdoc
66
+ - Rakefile
67
+ - VERSION
68
+ - bin/scriptty-capture
69
+ - bin/scriptty-dump-screens
70
+ - bin/scriptty-replay
71
+ - bin/scriptty-term-test
72
+ - bin/scriptty-transcript-parse
73
+ - examples/captures/xterm-overlong-line-prompt.bin
74
+ - examples/captures/xterm-vim-session.bin
75
+ - examples/demo-capture.rb
76
+ - examples/demo-telnet-session-screens.txt
77
+ - examples/demo-telnet-session.rb
78
+ - examples/rdispatch/demo-request-dispatcher.rb
79
+ - examples/rdispatch/done_screen.txt
80
+ - examples/rdispatch/login.rb
81
+ - examples/rdispatch/start_screen.txt
82
+ - examples/rdispatch/vim_screen.txt
83
+ - examples/telnet-nego.rb
84
+ - lib/scriptty/apps/capture_app.rb
85
+ - lib/scriptty/apps/dump_screens_app.rb
86
+ - lib/scriptty/apps/replay_app.rb
87
+ - lib/scriptty/apps/term_test_app.rb
88
+ - lib/scriptty/apps/transcript_parse_app.rb
89
+ - lib/scriptty/cursor.rb
90
+ - lib/scriptty/exception.rb
91
+ - lib/scriptty/expect.rb
92
+ - lib/scriptty/multiline_buffer.rb
93
+ - lib/scriptty/net/console.rb
94
+ - lib/scriptty/net/event_loop.rb
95
+ - lib/scriptty/net/password_prompt.rb
96
+ - lib/scriptty/request_dispatcher.rb
97
+ - lib/scriptty/screen_pattern.rb
98
+ - lib/scriptty/screen_pattern/generator.rb
99
+ - lib/scriptty/screen_pattern/parser.rb
100
+ - lib/scriptty/term.rb
101
+ - lib/scriptty/term/dg410.rb
102
+ - lib/scriptty/term/dg410/dg410-client-escapes.txt
103
+ - lib/scriptty/term/dg410/dg410-escapes.txt
104
+ - lib/scriptty/term/dg410/parser.rb
105
+ - lib/scriptty/term/xterm.rb
106
+ - lib/scriptty/term/xterm/xterm-escapes.txt
107
+ - lib/scriptty/util/fsm.rb
108
+ - lib/scriptty/util/fsm/definition_parser.rb
109
+ - lib/scriptty/util/fsm/scriptty_fsm_definition.treetop
110
+ - lib/scriptty/util/transcript/reader.rb
111
+ - lib/scriptty/util/transcript/writer.rb
112
+ - test.watchr
113
+ - test/apps/capture_app_test.rb
114
+ - test/apps/transcript_parse_app_test.rb
115
+ - test/cursor_test.rb
116
+ - test/expect/screens.txt
117
+ - test/expect_test.rb
118
+ - test/fsm_definition_parser_test.rb
119
+ - test/fsm_test.rb
120
+ - test/multiline_buffer_test.rb
121
+ - test/net/event_loop_test.rb
122
+ - test/screen_pattern/generator_test.rb
123
+ - test/screen_pattern/parser_test.rb
124
+ - test/screen_pattern/parser_test/explicit_cursor_pattern.txt
125
+ - test/screen_pattern/parser_test/explicit_fields.txt
126
+ - test/screen_pattern/parser_test/multiple_patterns.txt
127
+ - test/screen_pattern/parser_test/simple_pattern.txt
128
+ - test/screen_pattern/parser_test/truncated_heredoc.txt
129
+ - test/screen_pattern/parser_test/utf16bebom_pattern.bin
130
+ - test/screen_pattern/parser_test/utf16lebom_pattern.bin
131
+ - test/screen_pattern/parser_test/utf8_pattern.bin
132
+ - test/screen_pattern/parser_test/utf8_unix_pattern.bin
133
+ - test/screen_pattern/parser_test/utf8bom_pattern.bin
134
+ - test/term/dg410/parser_test.rb
135
+ - test/term/xterm_test.rb
136
+ - test/test_helper.rb
137
+ - test/util/transcript/reader_test.rb
138
+ - test/util/transcript/writer_test.rb
139
139
  has_rdoc: true
140
140
  homepage: http://github.com/infonium/scriptty
141
141
  licenses: []
142
142
 
143
143
  post_install_message:
144
144
  rdoc_options:
145
- - --charset=UTF-8
145
+ - --charset=UTF-8
146
146
  require_paths:
147
- - lib
147
+ - lib
148
148
  required_ruby_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- segments:
153
- - 0
154
- version: "0"
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ segments:
153
+ - 0
154
+ version: "0"
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- segments:
160
- - 0
161
- version: "0"
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
161
+ version: "0"
162
162
  requirements: []
163
163
 
164
164
  rubyforge_project:
@@ -167,23 +167,23 @@ signing_key:
167
167
  specification_version: 3
168
168
  summary: write expect-like script to control full-screen terminal-based applications
169
169
  test_files:
170
- - test/apps/capture_app_test.rb
171
- - test/apps/transcript_parse_app_test.rb
172
- - test/cursor_test.rb
173
- - test/expect_test.rb
174
- - test/fsm_definition_parser_test.rb
175
- - test/fsm_test.rb
176
- - test/multiline_buffer_test.rb
177
- - test/net/event_loop_test.rb
178
- - test/screen_pattern/generator_test.rb
179
- - test/screen_pattern/parser_test.rb
180
- - test/term/dg410/parser_test.rb
181
- - test/term/xterm_test.rb
182
- - test/test_helper.rb
183
- - test/util/transcript/reader_test.rb
184
- - test/util/transcript/writer_test.rb
185
- - examples/demo-capture.rb
186
- - examples/demo-telnet-session.rb
187
- - examples/rdispatch/demo-request-dispatcher.rb
188
- - examples/rdispatch/login.rb
189
- - examples/telnet-nego.rb
170
+ - test/cursor_test.rb
171
+ - test/expect_test.rb
172
+ - test/fsm_definition_parser_test.rb
173
+ - test/fsm_test.rb
174
+ - test/multiline_buffer_test.rb
175
+ - test/test_helper.rb
176
+ - test/apps/capture_app_test.rb
177
+ - test/apps/transcript_parse_app_test.rb
178
+ - test/net/event_loop_test.rb
179
+ - test/screen_pattern/generator_test.rb
180
+ - test/screen_pattern/parser_test.rb
181
+ - test/term/xterm_test.rb
182
+ - test/term/dg410/parser_test.rb
183
+ - test/util/transcript/reader_test.rb
184
+ - test/util/transcript/writer_test.rb
185
+ - examples/demo-capture.rb
186
+ - examples/demo-telnet-session.rb
187
+ - examples/telnet-nego.rb
188
+ - examples/rdispatch/demo-request-dispatcher.rb
189
+ - examples/rdispatch/login.rb