madCLIbs 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/lib/mad_clibs.rb +2 -0
- data/lib/mad_clibs/blanks/base.rb +4 -0
- data/lib/mad_clibs/prompter.rb +27 -7
- data/lib/mad_clibs/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a88d8d8ab13aa4123b03d4b45323be937e8ecc57
|
4
|
+
data.tar.gz: c6bdafb4a0f1e89b461395778358a886e7f65b7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b99b9dd7c248b257bd8ce285545fb61c72576c1e55c15b8300763f614ddcedfe519c604f3bd144a56545e42f6c80f9387c16164b11d68aa36c8962ff4fd9a57
|
7
|
+
data.tar.gz: 1c2a2ee54468a35c3f19608fc486ac2d9c34c1efcb3690b472b08b70ca9219088ebe5c23c75812588d2e4e5b394bc79141000bb26e7714474f16e0fc793f6cbc
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
## Change Log
|
2
|
+
|
3
|
+
### v0.0.5 (2015/02/17 19:51 +00:00)
|
4
|
+
- [b1a4fcb](https://github.com/donaldguy/madCLIbs/commit/b1a4fcb3fcaba985b536076c6f8b5ba9c9b68ee0) Handle zero blanks; Add to_s -> value for blanks (@donaldguy)
|
5
|
+
- [1aa811d](https://github.com/donaldguy/madCLIbs/commit/1aa811dc97fe749cb8e80166bc43e720dc5a0421) User-configurable token seperation logic (@donaldguy)
|
6
|
+
|
7
|
+
### v0.0.4 (2015/02/16 04:23 +00:00)
|
8
|
+
- [f16e304](https://github.com/donaldguy/madCLIbs/commit/f16e30444401af79db9b6f20e46eaddfc766e71e) Add Support for Custom Interrupt Handlers (@donaldguy)
|
9
|
+
|
10
|
+
### v0.0.3 (2015/02/15 18:54 +00:00)
|
11
|
+
- [2c3fea7](https://github.com/donaldguy/madCLIbs/commit/2c3fea7a0ffc4a261be30e114fc86608024ebae3) Add Shift-Tab support; Add demo GIF to README (@donaldguy)
|
12
|
+
- [9f2a8ef](https://github.com/donaldguy/madCLIbs/commit/9f2a8efce6ebfeb2007eb60a63f0d303f25f885b) Nestable outer-styles; Loosen single-char constraint (@donaldguy)
|
13
|
+
- [d044964](https://github.com/donaldguy/madCLIbs/commit/d04496425bbe772627b548f75d0625c9b9d8ce18) Badges (@donaldguy)
|
14
|
+
|
15
|
+
### v0.0.2 (2015/02/15 17:58 +00:00)
|
16
|
+
- [58803fc](https://github.com/donaldguy/madCLIbs/commit/58803fcb09d5ff29707d049c5381e135b34026e1) Remove dependency on activesupport (@donaldguy)
|
17
|
+
|
18
|
+
### v0.0.1 (2015/02/15 17:55 +00:00)
|
19
|
+
- [4ccbf56](https://github.com/donaldguy/madCLIbs/commit/4ccbf5621f0b54a6f4846fd7756b869e9c41baac) Tweak docs for initial release (@donaldguy)
|
20
|
+
- [37c6ab9](https://github.com/donaldguy/madCLIbs/commit/37c6ab938c840b64aa81d67e0fe75597ab90c418) Color support; Move a lot of Blank::Base to mixins (@donaldguy)
|
21
|
+
- [8d3dfc8](https://github.com/donaldguy/madCLIbs/commit/8d3dfc80059f85af98a074ca6f8106988718dbfa) Make cursor and arrow keys work (@donaldguy)
|
22
|
+
- [954c4b4](https://github.com/donaldguy/madCLIbs/commit/954c4b4151285e289da6f3426da7568d0f10962e) Proof of concept /w placeholders & tabbing between fields (@donaldguy)
|
23
|
+
- [b753175](https://github.com/donaldguy/madCLIbs/commit/b753175e9a9a03c83ca2345e8072ae889d4a8d29) Establish copyright provenance for iohelper.rb (@donaldguy)
|
24
|
+
- [0106789](https://github.com/donaldguy/madCLIbs/commit/0106789a6144c095912fb7fd34c9232c9ee0fc27) Initial commit establishing intention (@donaldguy)
|
data/lib/mad_clibs.rb
CHANGED
@@ -4,11 +4,13 @@ class MadClibs
|
|
4
4
|
autoload :Prompter, 'mad_clibs/prompter'
|
5
5
|
|
6
6
|
attr_accessor :interrupt_handler
|
7
|
+
attr_accessor :token_separator
|
7
8
|
|
8
9
|
def initialize(config = {})
|
9
10
|
@prompter = Prompter.new(self)
|
10
11
|
@interrupt_handler = config[:interrupt_handler]
|
11
12
|
@interrupt_handler ||= ->() { raise Interrupt }
|
13
|
+
@token_separator = config[:separator] || " "
|
12
14
|
end
|
13
15
|
|
14
16
|
def prompt(*args)
|
data/lib/mad_clibs/prompter.rb
CHANGED
@@ -16,10 +16,15 @@ class MadClibs
|
|
16
16
|
@blanks = line.instance_variable_get(:@blanks)
|
17
17
|
@current_blank_index = 0
|
18
18
|
|
19
|
-
|
19
|
+
if @blanks.empty?
|
20
20
|
render
|
21
|
-
|
22
|
-
|
21
|
+
@io.read_key(false) #pause to allow Ctrl-C; continue on any other key
|
22
|
+
else
|
23
|
+
until done?
|
24
|
+
render
|
25
|
+
place_cursor
|
26
|
+
getc
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
post_render
|
@@ -40,19 +45,29 @@ private
|
|
40
45
|
def render
|
41
46
|
buffer = StringIO.new
|
42
47
|
|
43
|
-
@tokens.
|
48
|
+
@tokens.length.times do |i|
|
49
|
+
token = @tokens[i]
|
44
50
|
if token.respond_to? :render
|
45
51
|
buffer.print token.render
|
46
52
|
elsif token.respond_to? :to_s
|
47
53
|
buffer.print token
|
48
54
|
end
|
49
55
|
|
50
|
-
|
56
|
+
|
57
|
+
buffer.print seperator_between(token, @tokens.fetch(i+1, nil))
|
51
58
|
end
|
52
59
|
|
53
60
|
@io.rerender buffer.string
|
54
61
|
end
|
55
62
|
|
63
|
+
def seperator_between(a,b)
|
64
|
+
if @controller.token_separator.respond_to? :call
|
65
|
+
@controller.token_separator.call(a, b)
|
66
|
+
else
|
67
|
+
@controller.token_separator
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
56
71
|
def getc
|
57
72
|
@last_char = @io.read_key(false)
|
58
73
|
case @last_char
|
@@ -75,12 +90,17 @@ private
|
|
75
90
|
def place_cursor
|
76
91
|
print @io.carriage_return
|
77
92
|
|
78
|
-
@tokens.
|
93
|
+
@tokens.length.times do |i|
|
94
|
+
t = @tokens[i]
|
79
95
|
if t == active_blank
|
80
96
|
print @io.char_right*t.position
|
81
97
|
break
|
82
98
|
end
|
83
|
-
|
99
|
+
|
100
|
+
token_width = Term::ANSIColor.uncolored(t).length
|
101
|
+
seperator_width = seperator_between(t, @tokens.fetch(i+1,nil)).size
|
102
|
+
|
103
|
+
print @io.char_right*(token_width + seperator_width)
|
84
104
|
end
|
85
105
|
end
|
86
106
|
|
data/lib/mad_clibs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madCLIbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Donald Guy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -52,6 +52,7 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- ".gitignore"
|
55
|
+
- CHANGELOG.md
|
55
56
|
- Gemfile
|
56
57
|
- LICENSE.txt
|
57
58
|
- README.md
|
@@ -100,3 +101,4 @@ signing_key:
|
|
100
101
|
specification_version: 4
|
101
102
|
summary: User-friendly fill-in-the-blank CLI forms (think HTML5 with placeholders)
|
102
103
|
test_files: []
|
104
|
+
has_rdoc:
|