mini_readline 0.6.4 → 0.6.5

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: 4cfcf3f362557c6f4ab5ec93418b4ca44ae54a07
4
- data.tar.gz: cf0b61fd89ff2bb18d1b8b9a3d06d343e8e2d896
3
+ metadata.gz: de25a37c0b75ebcb2e6e8edbcc0e7bfb08aaa863
4
+ data.tar.gz: b842f03c9f0804b79ee9254bf7d623a06536e111
5
5
  SHA512:
6
- metadata.gz: 709d6bac30409e21669602e21cc55d0caa9ff198b9599ddfdcc73cbe45f6b6acb4ccc4655e894314af175fc01679b57fa2ca299b4cdf149a3eb11080654952b8
7
- data.tar.gz: 6cb9c33a15db38317a2a7d933cc61acf4f01d83d996d739316821ac21de9eb6eaf3b9865d0701be63971756c69629f9860e1179757cec830001b8966b93e955f
6
+ metadata.gz: 8c9a5d664a358812295f1358f21c6857abd02204f94d9b0c317636da9d11a506c868e1822887774cf6bb88e8524986898d01d5af9258ddc51530872aacb71692
7
+ data.tar.gz: 294db641b431ea5a069441332405185cc89ae771ca74115d4dad71e88213f31d6508c41c9a65bebdf261d8d503742e73184ac622601c7845c45ccccb26e235cc
data/README.md CHANGED
@@ -102,35 +102,46 @@ also be accomplished with the command:
102
102
 
103
103
  ### Compatible Mode
104
104
 
105
- In this mode, mini_readline is somewhat compatible with the classic readline.
106
- Simply use:
105
+ In compatible mode, mini_readline tries to be somewhat compatible with the
106
+ classic system readline facility. Here is this compatible mode in action with
107
+ entry history enabled:
107
108
 
108
109
  ```ruby
109
- Readline.readline('>', true)
110
+ MiniReadline.readline('>', true)
110
111
  ```
111
- or to avoid tracking command history, use:
112
-
112
+ and with entry history disabled:
113
113
  ```ruby
114
- Readline.readline('>', false)
114
+ MiniReadline.readline('>', false)
115
115
  ```
116
116
  Where the string argument is the prompt seen by the user and the flag controls
117
- the history buffer. This assumes that the $no_alias_read_line_module setting
118
- mentioned above was *not* used. If it was, then these somewhat less compatible
119
- forms are required:
117
+ the history buffer. Use true to enable history and false to disable it.
118
+
119
+ ##### Extensions
120
+
121
+ In addition to the standard readline arguments, additional arguments may be
122
+ passed in to access additional features. This is done with an optional trailing
123
+ hash argument. For example, the following bit of compatibility mode code gets
124
+ a string with password hiding:
120
125
  ```ruby
121
- MiniReadline.readline('>', true)
126
+ MiniReadline.readline(">", false, secret_mask: "*")
122
127
  ```
123
- and
124
- ```ruby
125
- MiniReadline.readline('>', false)
126
- ```
127
- While it does require some small changes, the latter form is the preferred one.
128
+ See the section Options below for more information on the sorts of things that
129
+ can be accomplished with these options settings.
128
130
 
129
131
  ##### Module Aliasing [Deprecated]
130
132
 
131
133
  For enhanced compatibility, the mini_readline gem has the ability to alias
132
- itself as the readline gem. This ability is subject to the following list
133
- of conditions.
134
+ itself as the readline gem. When this feature is used, compatible code is even
135
+ more compatible looking:
136
+ ```ruby
137
+ Readline.readline('>', true)
138
+ ```
139
+ or to avoid tracking command history, use:
140
+
141
+ ```ruby
142
+ Readline.readline('>', false)
143
+ ```
144
+ The aliasing of modules is subject to the following list of conditions:
134
145
 
135
146
  1) If the global variable $no_alias_read_line_module is set to true before the
136
147
  mini_readline gem is required, *no* aliasing will take place.
@@ -259,6 +270,9 @@ BASE_OPTIONS = {
259
270
  #string "*" to use stars or " "
260
271
  #for invisible secrets.
261
272
 
273
+ :initial => "", #The initial text for the entry.
274
+ #An empty string for none.
275
+
262
276
  :term => nil, #Filled in by raw_term.rb
263
277
  #MiniReadline::RawTerm
264
278
 
@@ -288,7 +302,11 @@ eoi inputs are treated as unmapped. If enabled, they raise a MiniReadlineEOI
288
302
  exception.
289
303
  * :secret_mask is a masking character to be used for sensitive input like a
290
304
  password or missile launch code. This should be exactly one character long.
291
- Typical values are "*" or " ".
305
+ Typical values are "\*" or " ". Also, any secret entries should be done with
306
+ the history option **TURNED OFF**. Otherwise later entries will be able to
307
+ retrieve the secret codes by just scrolling through previous entries.
308
+ * :initial is the initial text used to prefill the readline edit area with the
309
+ specified text. Leave as an empty string to default to the empty edit area.
292
310
  * :term is the interactive source of data, the console by default. The raw
293
311
  terminal console driver automatically adapts to the system environment
294
312
  (Windows or Other) so that correct operation is normally achieved with no
@@ -26,8 +26,8 @@ module MiniReadline
26
26
  end
27
27
 
28
28
  #The (limited) compatibility module function.
29
- def self.readline(prompt = "", history = nil)
30
- get_reader.readline(prompt: prompt, history: history)
29
+ def self.readline(prompt = "", history = nil, options = {})
30
+ get_reader.readline(options.merge({prompt: prompt, history: history}))
31
31
  end
32
32
 
33
33
  end
@@ -26,6 +26,9 @@ module MiniReadline
26
26
  #string "*" to use stars or " "
27
27
  #for invisible secrets.
28
28
 
29
+ :initial => "", #The initial text for the entry.
30
+ #An empty string for none.
31
+
29
32
  :term => nil, #Filled in by raw_term.rb
30
33
  #MiniReadline::RawTerm
31
34
 
@@ -11,7 +11,7 @@ module MiniReadline
11
11
  PLATFORM = :windows
12
12
 
13
13
  #The class used to manipulate console i/o on a low level.
14
- #<br>Endemin Code Smells
14
+ #<br>Endemic Code Smells
15
15
  # :reek:TooManyInstanceVariables
16
16
  class RawTerm
17
17
 
@@ -39,8 +39,8 @@ module MiniReadline
39
39
  @options = options
40
40
  @history = history
41
41
  @term = @options[:term]
42
- @edit_posn = 0
43
- @edit_buffer = ""
42
+ @edit_buffer = @options[:initial]
43
+ @edit_posn = @edit_buffer.length
44
44
  @working = true
45
45
 
46
46
  @edit_window = EditWindow.new(@options)
@@ -1,4 +1,4 @@
1
1
  module MiniReadline
2
2
  #The current version of the mini_readline gem.
3
- VERSION = "0.6.4"
3
+ VERSION = "0.6.5"
4
4
  end
@@ -73,16 +73,29 @@ class MiniReadlineTester < Minitest::Test
73
73
  assert_equal("quit", result)
74
74
  end
75
75
 
76
+ def test_reading_with_a_default
77
+ puts
78
+ puts "To finish this test, enter the word: quit"
79
+
80
+ result = ''
81
+
82
+ loop do
83
+ result = MiniReadline.readline(">", false, initial: "qui").chomp
84
+ puts result.inspect
85
+ break unless result != "quit"
86
+ end
87
+
88
+ assert_equal("quit", result)
89
+ end
90
+
76
91
  def test_reading_a_password
77
92
  puts
78
93
  puts "To finish this test, enter the word: password"
79
94
 
80
- edit = MiniReadline::Readline.new
81
-
82
95
  result = ''
83
96
 
84
97
  loop do
85
- result = edit.readline(prompt: ">", secret_mask: "*").chomp
98
+ result = MiniReadline.readline(">", false, secret_mask: "*").chomp
86
99
  puts result.inspect
87
100
  break unless result != "password"
88
101
  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.6.4
4
+ version: 0.6.5
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-09-13 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest