livetext 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/livetext +8 -6
- data/dsl/calibre.rb +1 -1
- data/dsl/liveblog.rb +2 -3
- data/lib/formatline.rb +7 -8
- data/lib/functions.rb +39 -0
- data/lib/livetext.rb +1 -1
- data/lib/standard.rb +3 -2
- data/test/testfiles/functions/source.ltx +1 -1
- data/test/testfiles/lines.txt +72 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93e53f99adb2db092428d0e3b5c66ecbfc173814
|
4
|
+
data.tar.gz: baffe8b343d7290ca8d8ffc3f419ea7745fc128c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 433d52e19811f6f6056759e5ec25df1944c34f382badf64d2e6f75e21f61e24381673a3f8e9119da776bc6257f0a37d8125160d157775453e003a50e131d23b9
|
7
|
+
data.tar.gz: a3254d97a375f0db7a74b9c8047a22b15a1157d0766a4ca1f8043bf70bfcbe42bf95483caa5accac2b924d52d1b014b26a14b439f460c23bd6e0f6baf0b1b56a
|
data/bin/livetext
CHANGED
@@ -12,14 +12,16 @@ end
|
|
12
12
|
|
13
13
|
case ARGV.first
|
14
14
|
when "-v", "--version"
|
15
|
-
puts "
|
15
|
+
puts "#{Livetext::VERSION}\n "
|
16
16
|
exit
|
17
17
|
when nil
|
18
|
-
puts
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
puts <<-EOF
|
19
|
+
Usage:
|
20
|
+
livetext -v
|
21
|
+
livetext --version
|
22
|
+
livetext filename
|
23
|
+
|
24
|
+
EOF
|
23
25
|
exit
|
24
26
|
else
|
25
27
|
src = ARGV.first
|
data/dsl/calibre.rb
CHANGED
data/dsl/liveblog.rb
CHANGED
data/lib/formatline.rb
CHANGED
@@ -44,17 +44,14 @@ class FormatLine
|
|
44
44
|
@buffer << str
|
45
45
|
end
|
46
46
|
|
47
|
-
def varsub(name)
|
48
|
-
Livetext::Vars[name]
|
49
|
-
end
|
50
|
-
|
51
47
|
def funcall(name, param)
|
52
48
|
fobj = ::Livetext::Functions.new
|
53
|
-
fobj.
|
49
|
+
fobj.param = param
|
50
|
+
fobj.send(name)
|
54
51
|
end
|
55
52
|
|
56
53
|
def vsub
|
57
|
-
@buffer <<
|
54
|
+
@buffer << Livetext::Vars[@vname]
|
58
55
|
@vname = ""
|
59
56
|
end
|
60
57
|
|
@@ -122,7 +119,7 @@ class FormatLine
|
|
122
119
|
emit("$")
|
123
120
|
break
|
124
121
|
when Alpha
|
125
|
-
loop { @vname << grab; break unless Alpha2 === peek }
|
122
|
+
loop { ch = peek; break if ch == EOL; @vname << grab; break unless Alpha2 === peek }
|
126
123
|
vsub
|
127
124
|
when "$"
|
128
125
|
case skip
|
@@ -130,13 +127,15 @@ class FormatLine
|
|
130
127
|
emit("$$")
|
131
128
|
break
|
132
129
|
when Alpha
|
133
|
-
loop { @fname << grab; break unless Alpha2 === peek }
|
130
|
+
loop { ch = peek; break if ch == EOL; @fname << grab; break unless Alpha2 === peek }
|
134
131
|
case peek
|
135
132
|
when " " # no param - just call
|
133
|
+
@param = nil
|
136
134
|
fcall # no param? Hmm
|
137
135
|
when "[" # long param - may have spaces - can hit eol
|
138
136
|
skip
|
139
137
|
loop { break if ["]", EOL].include?(peek); @param << grab }
|
138
|
+
skip
|
140
139
|
fcall
|
141
140
|
when ":" # param (single token or to-eol)
|
142
141
|
case skip
|
data/lib/functions.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
+
require 'standard' # FIXME
|
2
|
+
|
1
3
|
class Livetext::Functions # Functions will go here... user-def AND pre-def??
|
4
|
+
Formats = ::Livetext::Standard::SimpleFormats
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@param = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def param=(str)
|
11
|
+
@param = str
|
12
|
+
end
|
13
|
+
|
2
14
|
def date
|
3
15
|
Time.now.strftime("%F")
|
4
16
|
end
|
@@ -6,4 +18,31 @@ class Livetext::Functions # Functions will go here... user-def AND pre-def??
|
|
6
18
|
def time
|
7
19
|
Time.now.strftime("%T")
|
8
20
|
end
|
21
|
+
|
22
|
+
def simple_format(*args)
|
23
|
+
@param ||= "NO PARAMETER"
|
24
|
+
pairs = Formats.values_at(*args)
|
25
|
+
str = @param.dup
|
26
|
+
pairs.reverse.each do |pair|
|
27
|
+
str = "#{pair.first}#{str}#{pair.last}"
|
28
|
+
end
|
29
|
+
str
|
30
|
+
end
|
31
|
+
|
32
|
+
def b; simple_format(:b); end
|
33
|
+
def i; simple_format(:i); end
|
34
|
+
def t; simple_format(:t); end
|
35
|
+
def s; simple_format(:s); end
|
36
|
+
def bi; simple_format(:b, :i); end
|
37
|
+
def bt; simple_format(:b, :t); end
|
38
|
+
def bs; simple_format(:b, :s); end
|
39
|
+
def it; simple_format(:i, :t); end
|
40
|
+
def is; simple_format(:i, :s); end
|
41
|
+
def ts; simple_format(:t, :s); end
|
42
|
+
def bit; simple_format(:b, :i, :t); end
|
43
|
+
def bis; simple_format(:b, :i, :s); end
|
44
|
+
def bts; simple_format(:b, :t, :s); end
|
45
|
+
def its; simple_format(:i, :t, :s); end
|
46
|
+
def bits; simple_format(:b, :i, :t, :s); end
|
47
|
+
|
9
48
|
end
|
data/lib/livetext.rb
CHANGED
data/lib/standard.rb
CHANGED
@@ -57,13 +57,13 @@ module Livetext::Standard
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def say
|
60
|
-
str =
|
60
|
+
str = _formatting(@_data)
|
61
61
|
TTY.puts str
|
62
62
|
_optional_blank_line
|
63
63
|
end
|
64
64
|
|
65
65
|
def banner
|
66
|
-
str =
|
66
|
+
str = _formatting(@_data)
|
67
67
|
n = str.length - 1
|
68
68
|
_errout "-"*n
|
69
69
|
_errout str
|
@@ -153,6 +153,7 @@ module Livetext::Standard
|
|
153
153
|
|
154
154
|
def set
|
155
155
|
assigns = @_data.chomp.split(/, */)
|
156
|
+
# Do a better way?
|
156
157
|
assigns.each do |a|
|
157
158
|
var, val = a.split("=")
|
158
159
|
val = val[1..-2] if val[0] == ?" and val[-1] == ?"
|
data/test/testfiles/lines.txt
CHANGED
@@ -182,3 +182,75 @@ strike: Doubled, ignores EOL
|
|
182
182
|
Up to EOL, this is ~~redacted
|
183
183
|
Up to EOL, this is <strike>redacted</strike>
|
184
184
|
|
185
|
+
Trying $$b function, no param
|
186
|
+
This is $$b being called
|
187
|
+
This is <b>NO PARAMETER</b> being called
|
188
|
+
|
189
|
+
Trying $$b function, brackets
|
190
|
+
This is $$b[bold text] being called
|
191
|
+
This is <b>bold text</b> being called
|
192
|
+
|
193
|
+
Trying $$b function, unterminated brackets
|
194
|
+
This is $$b[bold text being called
|
195
|
+
This is <b>bold text being called</b>
|
196
|
+
|
197
|
+
Trying $$b function, colon param
|
198
|
+
This is $$b:token being called
|
199
|
+
This is <b>token</b> being called
|
200
|
+
|
201
|
+
Try $$i
|
202
|
+
There is $$i[some text] here
|
203
|
+
There is <i>some text</i> here
|
204
|
+
|
205
|
+
Try $$t
|
206
|
+
There is $$t[some text] here
|
207
|
+
There is <tt>some text</tt> here
|
208
|
+
|
209
|
+
Try $$s
|
210
|
+
There is $$s[some text] here
|
211
|
+
There is <strike>some text</strike> here
|
212
|
+
|
213
|
+
Try $$bi
|
214
|
+
There is $$bi[some text] here
|
215
|
+
There is <b><i>some text</i></b> here
|
216
|
+
|
217
|
+
Try $$bt
|
218
|
+
There is $$bt[some text] here
|
219
|
+
There is <b><tt>some text</tt></b> here
|
220
|
+
|
221
|
+
Try $$bs
|
222
|
+
There is $$bs[some text] here
|
223
|
+
There is <b><strike>some text</strike></b> here
|
224
|
+
|
225
|
+
Try $$it
|
226
|
+
There is $$it[some text] here
|
227
|
+
There is <i><tt>some text</tt></i> here
|
228
|
+
|
229
|
+
Try $$is
|
230
|
+
There is $$is[some text] here
|
231
|
+
There is <i><strike>some text</strike></i> here
|
232
|
+
|
233
|
+
Try $$ts
|
234
|
+
There is $$ts[some text] here
|
235
|
+
There is <tt><strike>some text</strike></tt> here
|
236
|
+
|
237
|
+
Try $$bit
|
238
|
+
There is $$bit[some text] here
|
239
|
+
There is <b><i><tt>some text</tt></i></b> here
|
240
|
+
|
241
|
+
Try $$bis
|
242
|
+
There is $$bis[some text] here
|
243
|
+
There is <b><i><strike>some text</strike></i></b> here
|
244
|
+
|
245
|
+
Try $$bts
|
246
|
+
There is $$bts[some text] here
|
247
|
+
There is <b><tt><strike>some text</strike></tt></b> here
|
248
|
+
|
249
|
+
Try $$its
|
250
|
+
There is $$its[some text] here
|
251
|
+
There is <i><tt><strike>some text</strike></tt></i> here
|
252
|
+
|
253
|
+
Try $$bits
|
254
|
+
There is $$bits[some text] here
|
255
|
+
There is <b><i><tt><strike>some text</strike></tt></i></b> here
|
256
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livetext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|
@@ -146,8 +146,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.4.2
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: A smart processor for text
|
153
153
|
test_files: []
|
154
|
+
has_rdoc:
|