livetext 0.9.41 → 0.9.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/livetext +23 -0
- data/lib/livetext/more.rb +0 -2
- data/lib/livetext/standard.rb +79 -4
- data/lib/livetext/version.rb +1 -1
- data/test/snapshots/table_with_heredocs/expected-output.txt +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eecc4b7aec5571c91f72cdba9b7d2e3ab43c7caf3f079ba336ccc112d4a4939
|
4
|
+
data.tar.gz: d3556ab21ab322f054c0aae264a8e2c833f61f1baa69bb5a965d4b418bf08c58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665b6c06e3f9469a7f98c1e4b6b9a7a4fad55d7a554811d4c92a63757a7ec2d44f33f4468ea2d709896d4bcc4cadb8a1a7f95fdacb2533982a552c133116bbd3
|
7
|
+
data.tar.gz: 7f391f554863d8411fd3523a09029419914dd8d8df66df1ac5bc2e0186060b543977c46c9e4bbe59343cb8dfa78263c81ff876f8732811b1ed2caa33fb41f05a
|
data/bin/livetext
CHANGED
@@ -5,6 +5,25 @@ require 'rubygems'
|
|
5
5
|
require_relative '../lib/livetext'
|
6
6
|
|
7
7
|
def usage
|
8
|
+
STDERR.puts <<~EOF
|
9
|
+
Usage:
|
10
|
+
livetext [options] [filename]
|
11
|
+
|
12
|
+
Options:
|
13
|
+
-v, --version Print version information
|
14
|
+
-t, --test Run all tests
|
15
|
+
-p, --path Print the path of the installed gem
|
16
|
+
-b, --backtrace Enable backtrace information
|
17
|
+
-m name, --mixin name Load the specified mixin before processing
|
18
|
+
-s, --stdin Read from standard input
|
19
|
+
-h, --help Print this help information
|
20
|
+
-i name, --install name Install the specified plugin
|
21
|
+
|
22
|
+
EOF
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
def old_usage
|
8
27
|
STDERR.puts <<~EOF
|
9
28
|
Usage:
|
10
29
|
livetext filename
|
@@ -22,6 +41,10 @@ def usage
|
|
22
41
|
livetext -p
|
23
42
|
livetext --path
|
24
43
|
|
44
|
+
Load a mixin:
|
45
|
+
livetext -m name
|
46
|
+
livetext --mixin name
|
47
|
+
|
25
48
|
Run tests:
|
26
49
|
livetext -t
|
27
50
|
livetext --test
|
data/lib/livetext/more.rb
CHANGED
@@ -101,12 +101,10 @@ class Livetext
|
|
101
101
|
obj = self.new
|
102
102
|
mix = Array(mix)
|
103
103
|
call = Array(call)
|
104
|
-
# STDERR.puts "#{__method__}: obj meth = #{obj.methods.sort.inspect}"
|
105
104
|
mix.each do |lib|
|
106
105
|
obj.invoke_dotcmd(:mixin, lib.dup)
|
107
106
|
end
|
108
107
|
call.each {|cmd| obj.main.send(cmd[1..-1]) } # ignores leading dot, no param
|
109
|
-
# vars.each_pair {|var, val| obj.setvar(var, val.to_s) }
|
110
108
|
obj.api.setvars(vars)
|
111
109
|
obj
|
112
110
|
end
|
data/lib/livetext/standard.rb
CHANGED
@@ -179,19 +179,64 @@ module Livetext::Standard
|
|
179
179
|
api.optional_blank_line
|
180
180
|
end
|
181
181
|
|
182
|
+
=begin
|
183
|
+
Filename: foobar
|
184
|
+
get_globals - 1 - transforming /private/tmp/.blogs/views/foobar/data/global.lt3
|
185
|
+
|
186
|
+
>> variables: fdir = /private/tmp/.blogs/views/foobar/data/
|
187
|
+
fname = ../settings/view.txt
|
188
|
+
path = /private/tmp/.blogs/views/foobar/data/../settings/view.txt
|
189
|
+
|
190
|
+
rpath = /private/tmp/.blogs/views/foobar/settings/view.txt
|
191
|
+
path = /private/tmp/.blogs/views/foobar/settings/view.txt
|
192
|
+
dir = /private/tmp/.blogs/views/foobar/settings
|
193
|
+
base = view.txt
|
194
|
+
|
195
|
+
>> variables: fdir = /private/tmp/.blogs/views/foobar/data/
|
196
|
+
fname = ../settings/recent.txt
|
197
|
+
path = /private/tmp/.blogs/views/foobar/data/../settings/recent.txt
|
198
|
+
rpath = /private/tmp/.blogs/views/foobar/settings/recent.txt
|
199
|
+
path = /private/tmp/.blogs/views/foobar/settings/recent.txt
|
200
|
+
dir = /private/tmp/.blogs/views/foobar/settings
|
201
|
+
base = recent.txt
|
202
|
+
|
203
|
+
>> variables: fdir = /private/tmp/.blogs/views/foobar/data/
|
204
|
+
fname = ../settings/publish.txt
|
205
|
+
path = /private/tmp/.blogs/views/foobar/data/../settings/publish.txt
|
206
|
+
rpath = /private/tmp/.blogs/views/foobar/settings/publish.txt
|
207
|
+
path = /private/tmp/.blogs/views/foobar/settings/publish.txt
|
208
|
+
dir = /private/tmp/.blogs/views/foobar/settings
|
209
|
+
base = publish.txt
|
210
|
+
|
211
|
+
get_globals - 2
|
212
|
+
|
213
|
+
=end
|
214
|
+
|
182
215
|
def variables(args = nil, body = nil)
|
183
216
|
prefix = api.args[0]
|
184
|
-
|
217
|
+
fname = api.args[1]
|
185
218
|
prefix = nil if prefix == "-" # FIXME dumb hack
|
186
|
-
|
187
|
-
|
188
|
-
|
219
|
+
fdir = ::Livetext::Vars[:FileDir] + "/" # where is the file we are reading?
|
220
|
+
if fname
|
221
|
+
path0 = fdir + fname
|
222
|
+
# puts ">> variables: fdir = #{fdir} fname = #{fname} path = #{path0}"
|
223
|
+
pname = Pathname.new(path0)
|
224
|
+
rpath = pname.realpath(pname)
|
225
|
+
path, dir, base = rpath.to_s, rpath.dirname.to_s, rpath.basename.to_s
|
226
|
+
# puts " rpath = #{rpath} path = #{path} dir = #{dir} base = #{base}"
|
227
|
+
dok, fok = Dir.exist?(dir), File.exist?(path)
|
228
|
+
raise "No such dir #{dir.inspect} (file #{path})" unless dok
|
229
|
+
raise "No such file #{path.inspect} (file #{path})" unless fok
|
230
|
+
lines = File.readlines(path)
|
189
231
|
else
|
190
232
|
lines = api.body
|
191
233
|
end
|
192
234
|
pairs = Livetext::ParseGeneral.parse_vars(lines, prefix: nil)
|
193
235
|
api.setvars(pairs)
|
194
236
|
api.optional_blank_line
|
237
|
+
rescue => e
|
238
|
+
puts e
|
239
|
+
puts $!
|
195
240
|
end
|
196
241
|
|
197
242
|
def heredoc(args = nil, body = nil)
|
@@ -408,6 +453,36 @@ module Livetext::Standard
|
|
408
453
|
api.optional_blank_line
|
409
454
|
end
|
410
455
|
|
456
|
+
def table(args = nil, body = nil) # Same as xtable
|
457
|
+
title = api.data
|
458
|
+
delim = " :: "
|
459
|
+
api.out "<br>\n\n<center><table width=90% cellpadding=5>"
|
460
|
+
lines = api.body(true)
|
461
|
+
maxw = nil
|
462
|
+
processed = []
|
463
|
+
lines.each do |line|
|
464
|
+
line = api.format(line)
|
465
|
+
line.gsub!(/\n+/, "<br>\n")
|
466
|
+
processed << line
|
467
|
+
cells = line.split(delim)
|
468
|
+
wide = cells.map {|cell| cell.length }
|
469
|
+
maxw = [0] * cells.size
|
470
|
+
maxw = maxw.map.with_index {|x, i| [x, wide[i]].max }
|
471
|
+
end
|
472
|
+
|
473
|
+
sum = maxw.inject(0, :+)
|
474
|
+
maxw.map! {|x| (x/sum*100).floor }
|
475
|
+
|
476
|
+
processed.each do |line|
|
477
|
+
cells = line.split(delim)
|
478
|
+
html.wrap :tr do
|
479
|
+
cells.each {|cell| api.out " <td valign=top>#{cell}</td>" }
|
480
|
+
end
|
481
|
+
end
|
482
|
+
api.out "</table></center>"
|
483
|
+
api.optional_blank_line
|
484
|
+
end
|
485
|
+
|
411
486
|
def image(args = nil, body = nil)
|
412
487
|
name, wide, high = api.args
|
413
488
|
geom = ""
|
data/lib/livetext/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
Testing heredocs (used in a table)
|
2
2
|
<p>
|
3
3
|
|
4
|
-
<br
|
4
|
+
<br>
|
5
|
+
|
6
|
+
<center><table width=90% cellpadding=5>
|
5
7
|
<tr>
|
6
8
|
<td valign=top>This is <br>only <br>a test.<br></td>
|
7
9
|
<td valign=top>This is <br>just <br>some <br>random text.<br></td>
|
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.9.
|
4
|
+
version: 0.9.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|