mini_readline 0.7.1 → 0.7.2

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: 68a9bb122c272cbd3d0bdf26532cca602a75e140
4
- data.tar.gz: 80fd1b109e5cdb190d4120f8762e1405cf533a9c
3
+ metadata.gz: c95e47d89d4da95acdbd7f8e0ae7008012bf1066
4
+ data.tar.gz: 4c3e1c916492b4c31aaab3edc1e4a15c6dfc4fbc
5
5
  SHA512:
6
- metadata.gz: e1a2dc21e88852da17e13cdf543232daaec3aac8def1b966e8984fd8084478183d18d28904d5c02295254501a369e7be86123c15149cee43eb95955f9ac4b8de
7
- data.tar.gz: a4b000eb3ee2d956521f0a538c54863ed77a2908c0e6b71dc64e589aca38a60e74cc251b3c327f970ecd8930657f475770d70ec084bcb889219370d46f5d8e4b
6
+ metadata.gz: a3d3c236b0853b86719e628d4627420bfe89fa7ebd02c38dda626a9df1d3b4fad37a779230819593e0b1291c60456fb8a95f0d5eb291778513d76c2e6c5a0ac7
7
+ data.tar.gz: f90214f1d610e02ce7dc28859654c6ca97b2e67cb0dfc6e62c76a18f1a121834b593d4f42ff1cc6a48898aa2dc69998fe5891acdbe4b1a65842f3bf59aa075bd
data/README.md CHANGED
@@ -73,7 +73,7 @@ There are a number of demo/test programs available for the mini_readline gem.
73
73
  These are:
74
74
 
75
75
  $ irbm
76
- Starting an IRB console with mini_readline.
76
+ Starting an IRB console with mini_readline (0.7.2).
77
77
  irb(main):001:0>
78
78
 
79
79
  This runs against the most recently installed gem. Also available in the gem
@@ -201,8 +201,7 @@ entries.
201
201
  <br>The available options are described below:
202
202
  ```ruby
203
203
  BASE_OPTIONS = {
204
- :window_width => 79, #The width of the edit area.
205
- :scroll_step => 12, #The amount scrolled.
204
+ :scroll_step => 12, #The amount horizontally scrolled.
206
205
 
207
206
  :prompt => ">", #The default prompt.
208
207
  :alt_prompt => "<< ", #The prompt when scrolled.
@@ -265,6 +264,10 @@ further actions on the part of the user. The terminal support class can be
265
264
  changed, to a user supplied class, to get data from another source, such as
266
265
  a serial attached terminal.
267
266
 
267
+ Finally the :window_width option is now ignored. Screen width now automatically
268
+ determined.
269
+
270
+
268
271
  #### Notes
269
272
  * Since the compatibility mode does not accept an options hash, the only way to
270
273
  affect options in this case is to modify the MiniReadline::BASE_OPTIONS hash.
@@ -352,6 +355,9 @@ options.
352
355
  statement to permit the use of clearer, easier to read access to regular
353
356
  expression results.
354
357
 
358
+ <br> An example of a custom auto-complete facility may be found in the mysh
359
+ gem located at: https://github.com/PeterCamilleri/mysh/blob/master/lib/mysh/user_input/smart_source.rb
360
+
355
361
  ### Important Security Note
356
362
 
357
363
  It must be remembered that any time strings are passed to the command line
@@ -417,13 +423,13 @@ Ruby | Win32 | Win64 | Cygwin | Linux | Mac
417
423
  ruby 1.9.3p484 | Yes | Yes | ? | ? | ?
418
424
  ruby 2.1.6p336 | Yes | ? | ? | ? | ?
419
425
  ruby 2.2.3p173 | ? | ? | Yes | ? | ?
420
- jruby 9.1.5.0 | ~Yes | ? | Planned | Planned | Planned
426
+ jruby 9.1.5.0 | Mostly | ? | Planned | Planned | Planned
421
427
  rubinius | N/A | N/A | N/A | Maybe | Maybe
422
428
 
423
429
  <br>Where:
424
430
 
425
431
  * 'Yes' means good to go! Coded and tested OK!
426
- * '~Yes' means mostly working but still some minor issues (See issue #7).
432
+ * 'Mostly' is mostly working but still some minor issues (See issue #7).
427
433
  * '?' _should_ work but are untested.
428
434
  * 'Planned' are not there yet and some work and much testing are needed.
429
435
  * 'N/A' entries reflect the fact that Rubinius does not run under Windows.
@@ -4,8 +4,7 @@
4
4
  module MiniReadline
5
5
 
6
6
  #The base options shared by all instances.
7
- BASE_OPTIONS = {:window_width => 79, #The width of the edit area.
8
- :scroll_step => 12, #The amount scrolled.
7
+ BASE_OPTIONS = {:scroll_step => 12, #The amount scrolled.
9
8
 
10
9
  :prompt => ">", #The default prompt.
11
10
  :alt_prompt => "<< ", #The prompt when scrolled.
@@ -29,13 +29,19 @@ module MiniReadline
29
29
  #Is Java present in the environment?
30
30
  TERM_JAVA = RUBY_PLATFORM =~ /java/
31
31
 
32
- #Select the type of platform in use.
33
- if TERM_PLATFORM == :windows
34
- require_relative 'raw_term/windows'
35
- else
36
- require_relative 'raw_term/ansi'
32
+ #Only install a terminal if one is not already provided.
33
+ unless BASE_OPTIONS[:term]
34
+
35
+ #Select the type of platform in use.
36
+ if TERM_PLATFORM == :windows
37
+ require_relative 'raw_term/windows'
38
+ else
39
+ require_relative 'raw_term/ansi'
40
+ end
41
+
42
+ #Get an instance of a raw terminal controller object.
43
+ BASE_OPTIONS[:term] = RawTerm.new
44
+
37
45
  end
38
46
 
39
- #Get an instance of a raw terminal controller object.
40
- BASE_OPTIONS[:term] = RawTerm.new
41
47
  end
@@ -5,8 +5,9 @@ require 'io/console'
5
5
  require_relative 'mapped_term'
6
6
  require_relative 'ansi/map'
7
7
  require_relative 'ansi/set_posn'
8
+ require_relative 'ansi/window_width'
8
9
 
9
- #* raw_term/other.rb - Support for raw terminal access in non-windows systems.
10
+ #* raw_term/ansi.rb - Support for raw terminal access in non-windows systems.
10
11
  module MiniReadline
11
12
 
12
13
  #The detected platform is not windows.
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+
3
+ #* ansi/window_width.rb - Determine the available screen width.
4
+ module MiniReadline
5
+
6
+ #* ansi/window_width.rb - Determine the available screen width.
7
+ class RawTerm
8
+
9
+ #Determine the available screen width.
10
+ #<br>Endemic Code Smells
11
+ #* :reek:UtilityFunction
12
+ def window_width
13
+ IO.console.winsize[1]
14
+ end
15
+
16
+ end
17
+ end
@@ -9,6 +9,7 @@ end
9
9
  require_relative 'mapped_term'
10
10
  require_relative 'windows/map'
11
11
  require_relative 'windows/set_posn'
12
+ require_relative 'windows/window_width'
12
13
 
13
14
  #* raw_term/windows.rb - Support for raw terminal access in windows systems.
14
15
  module MiniReadline
@@ -44,7 +45,7 @@ module MiniReadline
44
45
  define_singleton_method(:kbhit) { kbhit_proc.call }
45
46
 
46
47
  beep_proc = Win32API.new("user32", "MessageBeep", ['L'], '0')
47
- define_singleton_method(:beep) { beep_proc.call }
48
+ define_singleton_method(:beep) { beep_proc.call(0) }
48
49
 
49
50
  set_cursor_posn_proc = Win32API.new("kernel32",
50
51
  "SetConsoleCursorPosition",
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+
3
+ #* windows/window_width.rb - Determine the available screen width.
4
+ module MiniReadline
5
+
6
+ #* windows/window_width.rb - Determine the available screen width.
7
+ class RawTerm
8
+
9
+ #Determine the available screen width.
10
+ def window_width
11
+ raw_buffer = 0.chr * 24
12
+ get_screen_info(raw_buffer)
13
+ (raw_buffer[0,2].unpack('S'))[0]
14
+ end
15
+
16
+ end
17
+ end
@@ -58,9 +58,13 @@ module MiniReadline
58
58
 
59
59
  #Set up the options
60
60
  def set_options(options)
61
- @options = MiniReadline::BASE_OPTIONS.merge(instance_options)
62
- @options.merge!(options)
61
+ @options = MiniReadline::BASE_OPTIONS
62
+ .merge(instance_options)
63
+ .merge(options)
64
+
63
65
  (@term = @options[:term]).initialize_parms
66
+
67
+ @options[:window_width] = @term.window_width - 1
64
68
  set_prompt(@options[:prompt])
65
69
  verify_mask(@options[:secret_mask])
66
70
  end
@@ -7,7 +7,7 @@ module MiniReadline
7
7
  class Edit
8
8
 
9
9
  #An unmapped key was pressed. Beep!
10
- def unmapped(keyboard_args)
10
+ def unmapped(_keyboard_args)
11
11
  @term.beep
12
12
  end
13
13
  end
@@ -1,4 +1,4 @@
1
1
  module MiniReadline
2
2
  #The current version of the mini_readline gem.
3
- VERSION = "0.7.1"
3
+ VERSION = "0.7.2"
4
4
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  Intermediate Range Ballistic Missile.
18
18
  }.gsub(/\s+/, ' ').strip
19
19
 
20
- spec.homepage = "http://teuthida-technologies.com/"
20
+ spec.homepage = "https://github.com/PeterCamilleri/mini_readline"
21
21
  spec.license = "MIT"
22
22
 
23
23
  spec.files = `git ls-files`.split($/)
data/mini_readline.reek CHANGED
@@ -24,6 +24,9 @@ DuplicateMethodCall:
24
24
  FeatureEnvy:
25
25
  enabled: true
26
26
  exclude: []
27
+ InstanceVariableAssumption:
28
+ enabled: false
29
+ exclude: []
27
30
  IrresponsibleModule:
28
31
  enabled: true
29
32
  exclude: []
@@ -193,7 +193,7 @@ class MiniReadlineTester < Minitest::Test
193
193
  end
194
194
 
195
195
  def test_prompt_verification
196
- opts = {prompt: ">"*20, window_width: 39}
196
+ opts = {prompt: ">"*70}
197
197
  edit = MiniReadline::Readline.new()
198
198
  assert_raises(RuntimeError) {edit.readline(opts)}
199
199
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_readline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-15 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -91,12 +91,14 @@ files:
91
91
  - lib/mini_readline/raw_term/ansi.rb
92
92
  - lib/mini_readline/raw_term/ansi/map.rb
93
93
  - lib/mini_readline/raw_term/ansi/set_posn.rb
94
+ - lib/mini_readline/raw_term/ansi/window_width.rb
94
95
  - lib/mini_readline/raw_term/mapped_term.rb
95
96
  - lib/mini_readline/raw_term/mapped_term/mapper.rb
96
97
  - lib/mini_readline/raw_term/windows.rb
97
98
  - lib/mini_readline/raw_term/windows/map.rb
98
99
  - lib/mini_readline/raw_term/windows/set_posn.rb
99
100
  - lib/mini_readline/raw_term/windows/win_32_api.rb
101
+ - lib/mini_readline/raw_term/windows/window_width.rb
100
102
  - lib/mini_readline/read_line.rb
101
103
  - lib/mini_readline/read_line/edit.rb
102
104
  - lib/mini_readline/read_line/edit/auto_complete.rb
@@ -135,7 +137,7 @@ files:
135
137
  - reek.txt
136
138
  - sire.rb
137
139
  - tests/mini_readline_tests.rb
138
- homepage: http://teuthida-technologies.com/
140
+ homepage: https://github.com/PeterCamilleri/mini_readline
139
141
  licenses:
140
142
  - MIT
141
143
  metadata: {}