coolline 0.4.2 → 0.4.3
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.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/lib/coolline/coolline.rb +20 -2
- data/lib/coolline/version.rb +1 -1
- data/test/coolline_test.rb +13 -0
- data/test/helpers.rb +1 -0
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f1ff87139f5360e3f34721db4068b81576a7d45
|
4
|
+
data.tar.gz: dafbaa6784716d492c90cd41ccf7067bd3b1a97f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dac637b858d7925e93f5aa22b6ae302d618b29964938eb483160f3f38f57cdbca9e8b90b3219196ce5e6e652a5edb7ac0984cfdfa0c5558d6fff2b3a37c69e6b
|
7
|
+
data.tar.gz: f8143342410c48abdfdbdb49867cf2716c8bc0cbff743766871d437035a217eaa259f22cfd4603be58627ca9a56d578157fd2e92e55a1631a35b73953579ee64
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Coolline - Copyright (c) 2012-2013 - Mon ouïe
|
2
|
+
|
3
|
+
This software is provided 'as-is', without any express or
|
4
|
+
implied warranty. In no event will the authors be held
|
5
|
+
liable for any damages arising from the use of this software.
|
6
|
+
|
7
|
+
Permission is granted to anyone to use this software for any purpose,
|
8
|
+
including commercial applications, and to alter it and redistribute
|
9
|
+
it freely, subject to the following restrictions:
|
10
|
+
|
11
|
+
1. The origin of this software must not be misrepresented;
|
12
|
+
you must not claim that you wrote the original software.
|
13
|
+
If you use this software in a product, an acknowledgment
|
14
|
+
in the product documentation would be appreciated but
|
15
|
+
is not required.
|
16
|
+
|
17
|
+
2. Altered source versions must be plainly marked as such,
|
18
|
+
and must not be misrepresented as being the original software.
|
19
|
+
|
20
|
+
3. This notice may not be removed or altered from any
|
21
|
+
source distribution.
|
data/lib/coolline/coolline.rb
CHANGED
@@ -193,6 +193,23 @@ class Coolline
|
|
193
193
|
# Reads a line from the terminal
|
194
194
|
# @param [String] prompt Characters to print before each line
|
195
195
|
def readline(prompt = ">> ", default_line = "")
|
196
|
+
if @input.tty?
|
197
|
+
readline_full(prompt, default_line)
|
198
|
+
else
|
199
|
+
readline_dumb(prompt)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def readline_dumb(prompt)
|
204
|
+
print prompt
|
205
|
+
line = @input.gets
|
206
|
+
self.line = line ? line.chomp : ""
|
207
|
+
print transform(line), "\n"
|
208
|
+
|
209
|
+
line.chomp if line
|
210
|
+
end
|
211
|
+
|
212
|
+
def readline_full(prompt = ">> ", default_line = "")
|
196
213
|
@prompt = prompt
|
197
214
|
|
198
215
|
@history.delete_empty
|
@@ -221,7 +238,6 @@ class Coolline
|
|
221
238
|
|
222
239
|
render
|
223
240
|
end
|
224
|
-
|
225
241
|
end
|
226
242
|
|
227
243
|
@menu.erase
|
@@ -238,6 +254,8 @@ class Coolline
|
|
238
254
|
|
239
255
|
# Displays the current code on the terminal
|
240
256
|
def render
|
257
|
+
return unless @input.tty?
|
258
|
+
|
241
259
|
width = @input.winsize[1]
|
242
260
|
prompt_size = ansi_length(@prompt)
|
243
261
|
line = transform(@line)
|
@@ -388,7 +406,7 @@ class Coolline
|
|
388
406
|
def common_beginning(candidates)
|
389
407
|
candidates.inject do |common, el|
|
390
408
|
i = 0
|
391
|
-
i += 1 while common[i] == el[i]
|
409
|
+
i += 1 while common[i] == el[i] and i != el.size
|
392
410
|
|
393
411
|
el[0...i]
|
394
412
|
end
|
data/lib/coolline/version.rb
CHANGED
data/test/coolline_test.rb
CHANGED
@@ -15,3 +15,16 @@ context "a user uses colors for live code highlighting" do
|
|
15
15
|
asserts(:strip_ansi_codes, "\e[38;5;232mHate\e[0m").equals "Hate"
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
context "a user uses non-tty input" do
|
20
|
+
setup do
|
21
|
+
Coolline.new { |c|
|
22
|
+
c.input = StringIO.new("p 42\np 82\n")
|
23
|
+
c.output = StringIO.new
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
denies(:readline).raises_kind_of Exception
|
28
|
+
asserts(:readline).equals "p 82"
|
29
|
+
asserts(:readline).nil
|
30
|
+
end
|
data/test/helpers.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coolline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mon ouie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: riot
|
@@ -33,21 +33,22 @@ extensions: []
|
|
33
33
|
extra_rdoc_files:
|
34
34
|
- README.md
|
35
35
|
files:
|
36
|
-
- lib/coolline
|
37
|
-
- lib/coolline/ansi.rb
|
38
|
-
- lib/coolline/version.rb
|
36
|
+
- lib/coolline.rb
|
39
37
|
- lib/coolline/menu.rb
|
40
|
-
- lib/coolline/
|
41
|
-
- lib/coolline/history.rb
|
38
|
+
- lib/coolline/ansi.rb
|
42
39
|
- lib/coolline/coolline.rb
|
43
|
-
- lib/coolline.rb
|
40
|
+
- lib/coolline/history.rb
|
41
|
+
- lib/coolline/handler.rb
|
42
|
+
- lib/coolline/editor.rb
|
43
|
+
- lib/coolline/version.rb
|
44
44
|
- test/helpers.rb
|
45
45
|
- test/coolline_test.rb
|
46
46
|
- test/history_test.rb
|
47
|
-
- test/editor_test.rb
|
48
47
|
- test/run_all.rb
|
48
|
+
- test/editor_test.rb
|
49
49
|
- repl.rb
|
50
50
|
- .gemtest
|
51
|
+
- LICENSE
|
51
52
|
- README.md
|
52
53
|
homepage: http://github.com/Mon-Ouie/coolline
|
53
54
|
licenses: []
|
@@ -68,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
69
|
version: '0'
|
69
70
|
requirements: []
|
70
71
|
rubyforge_project:
|
71
|
-
rubygems_version: 2.0.
|
72
|
+
rubygems_version: 2.0.14
|
72
73
|
signing_key:
|
73
74
|
specification_version: 4
|
74
75
|
summary: Sounds like readline, smells like readline, but isn't readline
|