livetext 0.9.07 → 0.9.08
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/lib/livetext.rb +7 -2
- data/lib/processor.rb +2 -1
- data/lib/standard.rb +42 -6
- data/test/data/block_comment/source.lt3 +2 -2
- data/test/data/error_inc_line_num/expected-err-line1match.txt +1 -0
- data/test/data/error_invalid_name/expected-err-line1match.txt +1 -1
- data/test/data/error_mismatched_end/expected-err-line1match.txt +1 -0
- data/test/data/error_missing_end/expected-err-line1match.txt +1 -0
- data/test/data/error_name_not_permitted/expected-error.txt +1 -1
- data/test/data/error_no_such_copy/expected-err-line1match.txt +1 -0
- data/test/data/error_no_such_inc/expected-err-line1match.txt +1 -0
- data/test/data/error_no_such_mixin/expected-err-line1match.txt +1 -0
- data/test/data/error_no_such_mixin/expected-output.txt +0 -6
- data/test/data/functions/source.lt3 +1 -1
- data/test/test.rb +6 -8
- metadata +8 -10
- data/test/data/error_inc_line_num/expected-error.txt +0 -1
- data/test/data/error_invalid_name/expected-error.txt +0 -1
- data/test/data/error_line_num/expected-error.txt +0 -1
- data/test/data/error_mismatched_end/expected-error.txt +0 -1
- data/test/data/error_missing_end/expected-error.txt +0 -1
- data/test/data/error_no_such_copy/expected-error.txt +0 -1
- data/test/data/error_no_such_inc/expected-error.txt +0 -1
- data/test/data/error_no_such_mixin/expected-error.txt +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f983f97d1e649079c9ae7b8c059c099eb3fb4b70b3df8afa026aefad4009f83e
|
4
|
+
data.tar.gz: 5efeb66838ae1b36dff234d548e0835f6617af739c653d9e6af8888c68b09c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 957fccd4430db4bd5dfcaa889829e753b180ee9a48635ba88769dd6e2645768cbff293c887d6202dcfc58474deaa56bc03ce18973f612ec138b85db636909988
|
7
|
+
data.tar.gz: 18c66b6647b1bd78c75b5bf4c7d0b7b5649fc2f403b1013dedec8a7e0203fa0758ef17f5fd7f731705a9428ac993e8a449b6092b551a4708d84bf13848bdfd1b
|
data/lib/livetext.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Livetext
|
2
|
-
VERSION = "0.9.
|
2
|
+
VERSION = "0.9.08"
|
3
3
|
Path = File.expand_path(File.join(File.dirname(__FILE__)))
|
4
4
|
end
|
5
5
|
|
@@ -126,6 +126,7 @@ class Livetext
|
|
126
126
|
when Comment
|
127
127
|
handle_scomment(line)
|
128
128
|
when Dotcmd
|
129
|
+
STDERR.puts "line = #{line.inspect}"
|
129
130
|
handle_dotcmd(line)
|
130
131
|
when Ddotcmd
|
131
132
|
indent = line.index("$") + 1
|
@@ -184,6 +185,7 @@ class Livetext
|
|
184
185
|
enum = text.each
|
185
186
|
@backtrace = btrace
|
186
187
|
@main.source(enum, fname, 0)
|
188
|
+
line = nil
|
187
189
|
loop do
|
188
190
|
line = @main.nextline
|
189
191
|
break if line.nil?
|
@@ -192,6 +194,7 @@ class Livetext
|
|
192
194
|
val = @main.finalize if @main.respond_to? :finalize
|
193
195
|
@body
|
194
196
|
rescue => err
|
197
|
+
STDERR.puts "[process_file] fname = #{fname.inspect}\n line = #{line.inspect}"
|
195
198
|
STDERR.puts "ERROR #{err} in process_file"
|
196
199
|
err.backtrace.each {|x| STDERR.puts " " + x }
|
197
200
|
@body = ""
|
@@ -227,8 +230,10 @@ class Livetext
|
|
227
230
|
end
|
228
231
|
result
|
229
232
|
rescue => err
|
233
|
+
STDERR.puts "Error was: #{err.inspect} (calling @main._error!)"
|
234
|
+
STDERR.puts err.backtrace
|
230
235
|
@main._error!(err)
|
231
|
-
puts @body
|
236
|
+
# puts @body
|
232
237
|
@body = ""
|
233
238
|
return @body
|
234
239
|
end
|
data/lib/processor.rb
CHANGED
@@ -35,7 +35,8 @@ class Livetext
|
|
35
35
|
def _error!(err, abort=true, trace=false)
|
36
36
|
where = @sources.last || @save_location
|
37
37
|
puts @parent.body
|
38
|
-
STDERR.puts "Error: #{err}
|
38
|
+
STDERR.puts "[lib/processor] Error: #{err}" # (at #{where[1]} line #{where[2]})"
|
39
|
+
raise "lib/processor error!"
|
39
40
|
STDERR.puts err.backtrace if err.respond_to?(:backtrace) # && trace
|
40
41
|
exit if abort
|
41
42
|
end
|
data/lib/standard.rb
CHANGED
@@ -43,9 +43,11 @@ module Livetext::Standard
|
|
43
43
|
_error! "Illegal name '#{funcname}'" if _disallowed?(funcname)
|
44
44
|
func_def = <<-EOS
|
45
45
|
def #{funcname}(param)
|
46
|
-
#{
|
46
|
+
#{_body.to_a.join("\n")}
|
47
47
|
end
|
48
48
|
EOS
|
49
|
+
_optional_blank_line
|
50
|
+
|
49
51
|
Livetext::Functions.class_eval func_def
|
50
52
|
end
|
51
53
|
|
@@ -223,6 +225,26 @@ EOS
|
|
223
225
|
end
|
224
226
|
end
|
225
227
|
|
228
|
+
def variables! # cwd, not FileDir - weird, fix later
|
229
|
+
prefix = _args[0]
|
230
|
+
file = _args[1]
|
231
|
+
prefix = nil if prefix == "-" # FIXME dumb hack
|
232
|
+
if file
|
233
|
+
here = "" # different for ! version
|
234
|
+
lines = File.readlines(here + file)
|
235
|
+
else
|
236
|
+
lines = _body
|
237
|
+
end
|
238
|
+
lines.map! {|x| x.sub(/# .*/, "").strip } # strip comments
|
239
|
+
lines.each do |line|
|
240
|
+
next if line.strip.empty?
|
241
|
+
var, val = line.split(" ", 2)
|
242
|
+
val = FormatLine.var_func_parse(val)
|
243
|
+
var = prefix + "." + var if prefix
|
244
|
+
@parent._setvar(var, val)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
226
248
|
def variables
|
227
249
|
prefix = _args[0]
|
228
250
|
file = _args[1]
|
@@ -247,13 +269,21 @@ EOS
|
|
247
269
|
eval _data.chomp
|
248
270
|
end
|
249
271
|
|
272
|
+
def heredoc! # adds <br>...
|
273
|
+
_heredoc(true)
|
274
|
+
end
|
275
|
+
|
250
276
|
def heredoc
|
277
|
+
_heredoc
|
278
|
+
end
|
279
|
+
|
280
|
+
def _heredoc(bang=false)
|
251
281
|
var = @_args[0]
|
252
282
|
str = _body.join("\n")
|
253
283
|
s2 = ""
|
254
284
|
str.each_line do |s|
|
255
285
|
str = FormatLine.var_func_parse(s.chomp)
|
256
|
-
s2 << str
|
286
|
+
s2 << str + "<br>"
|
257
287
|
end
|
258
288
|
indent = @parent.indentation.last
|
259
289
|
indented = " " * indent
|
@@ -278,8 +308,10 @@ EOS
|
|
278
308
|
break if value
|
279
309
|
end
|
280
310
|
end
|
311
|
+
STDERR.puts "Cannot find #{file.inspect} from #{Dir.pwd}" unless value
|
281
312
|
return value
|
282
313
|
rescue
|
314
|
+
STDERR.puts "Can't find #{file.inspect} from #{Dir.pwd}"
|
283
315
|
return nil
|
284
316
|
end
|
285
317
|
|
@@ -287,21 +319,25 @@ EOS
|
|
287
319
|
# like include, but search upward as needed
|
288
320
|
file = @_args.first
|
289
321
|
file = _seek(file)
|
290
|
-
_error!(
|
322
|
+
_error!("No such include file #{file.inspect}") unless file
|
291
323
|
@parent.process_file(file)
|
292
324
|
_optional_blank_line
|
325
|
+
rescue => err
|
326
|
+
STDERR.puts ".seek error - #{err}"
|
327
|
+
STDERR.puts err.inspect
|
328
|
+
return nil
|
293
329
|
end
|
294
330
|
|
295
331
|
def in_out # FIXME dumb name!
|
296
332
|
file, dest = *@_args
|
297
|
-
_check_existence(file, "No such include file
|
333
|
+
_check_existence(file, "No such include file #{file.inspect}")
|
298
334
|
@parent.process_file(file, dest)
|
299
335
|
_optional_blank_line
|
300
336
|
end
|
301
337
|
|
302
338
|
def _include
|
303
339
|
file = @_args.first
|
304
|
-
_check_existence(file, "No such include file
|
340
|
+
_check_existence(file, "No such include file #{file.inspect}")
|
305
341
|
@parent.process_file(file)
|
306
342
|
_optional_blank_line
|
307
343
|
end
|
@@ -348,7 +384,7 @@ EOS
|
|
348
384
|
Dir.chdir("..") { mixin }
|
349
385
|
return
|
350
386
|
else
|
351
|
-
STDERR.puts "No such mixin '#{name}"
|
387
|
+
STDERR.puts "No such mixin '#{name}'"
|
352
388
|
puts @body
|
353
389
|
exit!
|
354
390
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: Name 'foobar' is unknown
|
@@ -1 +1 @@
|
|
1
|
-
Error: Illegal name 'to_s'
|
1
|
+
Error: Illegal name 'to_s'
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: Mismatched 'end'
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: #<RuntimeError: Expected .end, found end of file>
|
@@ -1 +1 @@
|
|
1
|
-
Error: Name 'class' is not permitted
|
1
|
+
Error: Name 'class' is not permitted
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: No such file 'nosuchfile.txt' to copy
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: No such include file 'nosuchinc.lt3'
|
@@ -0,0 +1 @@
|
|
1
|
+
No such mixin 'nosuchthing'
|
data/test/test.rb
CHANGED
@@ -18,7 +18,7 @@ class TestingLivetext < MiniTest::Test
|
|
18
18
|
|
19
19
|
TestLines = []
|
20
20
|
|
21
|
-
Dir.chdir `livetext --path`.chomp if ARGV.first == "cmdline"
|
21
|
+
Dir.chdir `livetext --path`.chomp.chomp if ARGV.first == "cmdline"
|
22
22
|
|
23
23
|
Dir.chdir(Data)
|
24
24
|
|
@@ -31,7 +31,7 @@ class TestingLivetext < MiniTest::Test
|
|
31
31
|
break if f.eof?
|
32
32
|
end
|
33
33
|
|
34
|
-
if File.size("subset.txt")
|
34
|
+
if File.size("subset.txt") == 0
|
35
35
|
puts "Defining via TestLines"
|
36
36
|
TestLines.each.with_index do |item, i|
|
37
37
|
msg, src, exp, blank = *item
|
@@ -51,8 +51,6 @@ class TestingLivetext < MiniTest::Test
|
|
51
51
|
selected = File.readlines("subset.txt").map(&:chomp)
|
52
52
|
Subset = selected.empty? ? TestDirs : selected
|
53
53
|
|
54
|
-
# puts "Subset = #{Subset.inspect}"
|
55
|
-
|
56
54
|
Subset.each do |tdir|
|
57
55
|
define_method("test_#{tdir}") do
|
58
56
|
external_files(tdir)
|
@@ -60,11 +58,11 @@ class TestingLivetext < MiniTest::Test
|
|
60
58
|
end
|
61
59
|
|
62
60
|
def green(str)
|
63
|
-
"[32m" + str + "[0m"
|
61
|
+
"[32m" + str.to_s + "[0m"
|
64
62
|
end
|
65
63
|
|
66
64
|
def red(str)
|
67
|
-
"[31m" + str + "[0m"
|
65
|
+
"[31m" + str.to_s + "[0m"
|
68
66
|
end
|
69
67
|
|
70
68
|
def external_files(base)
|
@@ -85,14 +83,14 @@ class TestingLivetext < MiniTest::Test
|
|
85
83
|
|
86
84
|
if File.exist?(expout_regex)
|
87
85
|
rx_out = /#{Regexp.escape(File.read(expout_regex).chomp)}/
|
88
|
-
expected = "(match test)"
|
86
|
+
expected = rx_out # "(match test)"
|
89
87
|
else
|
90
88
|
expected = File.read(exp)
|
91
89
|
end
|
92
90
|
|
93
91
|
if File.exist?(experr_regex)
|
94
92
|
rx_err = /#{Regexp.escape(File.read(experr_regex).chomp)}/
|
95
|
-
errexp = "(match test)"
|
93
|
+
errexp = rx_err # "(match test)"
|
96
94
|
else
|
97
95
|
errexp = File.read(erx)
|
98
96
|
end
|
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.08
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|
@@ -53,34 +53,32 @@ files:
|
|
53
53
|
- test/data/def_method/expected-error.txt
|
54
54
|
- test/data/def_method/expected-output.txt
|
55
55
|
- test/data/def_method/source.lt3
|
56
|
-
- test/data/error_inc_line_num/expected-
|
56
|
+
- test/data/error_inc_line_num/expected-err-line1match.txt
|
57
57
|
- test/data/error_inc_line_num/expected-output.txt
|
58
58
|
- test/data/error_inc_line_num/file2.lt3
|
59
59
|
- test/data/error_inc_line_num/source.lt3
|
60
60
|
- test/data/error_invalid_name/expected-err-line1match.txt
|
61
|
-
- test/data/error_invalid_name/expected-error.txt
|
62
61
|
- test/data/error_invalid_name/expected-output.txt
|
63
62
|
- test/data/error_invalid_name/source.lt3
|
64
63
|
- test/data/error_line_num/expected-err-line1match.txt
|
65
|
-
- test/data/error_line_num/expected-error.txt
|
66
64
|
- test/data/error_line_num/expected-output.txt
|
67
65
|
- test/data/error_line_num/source.lt3
|
68
|
-
- test/data/error_mismatched_end/expected-
|
66
|
+
- test/data/error_mismatched_end/expected-err-line1match.txt
|
69
67
|
- test/data/error_mismatched_end/expected-output.txt
|
70
68
|
- test/data/error_mismatched_end/source.lt3
|
71
|
-
- test/data/error_missing_end/expected-
|
69
|
+
- test/data/error_missing_end/expected-err-line1match.txt
|
72
70
|
- test/data/error_missing_end/expected-output.txt
|
73
71
|
- test/data/error_missing_end/source.lt3
|
74
72
|
- test/data/error_name_not_permitted/expected-error.txt
|
75
73
|
- test/data/error_name_not_permitted/expected-output.txt
|
76
74
|
- test/data/error_name_not_permitted/source.lt3
|
77
|
-
- test/data/error_no_such_copy/expected-
|
75
|
+
- test/data/error_no_such_copy/expected-err-line1match.txt
|
78
76
|
- test/data/error_no_such_copy/expected-output.txt
|
79
77
|
- test/data/error_no_such_copy/source.lt3
|
80
|
-
- test/data/error_no_such_inc/expected-
|
78
|
+
- test/data/error_no_such_inc/expected-err-line1match.txt
|
81
79
|
- test/data/error_no_such_inc/expected-output.txt
|
82
80
|
- test/data/error_no_such_inc/source.lt3
|
83
|
-
- test/data/error_no_such_mixin/expected-
|
81
|
+
- test/data/error_no_such_mixin/expected-err-line1match.txt
|
84
82
|
- test/data/error_no_such_mixin/expected-output.txt
|
85
83
|
- test/data/error_no_such_mixin/source.lt3
|
86
84
|
- test/data/example_alpha/expected-error.txt
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Name 'foobar' is unknown (at file2.lt3 line 5)
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Illegal name 'to_s' (at source.lt3 line 5)
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Name 'foobar' is unknown (at source.lt3 line 4)
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Mismatched 'end' (at source.lt3 line 6)
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Expecting .end, found end of file (at source.lt3 line 6)
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: No such file 'nosuchfile.txt' to copy (at source.lt3 line 5)
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: No such include file 'nosuchinc.lt3' (at source.lt3 line 5)
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: No such mixin 'nosuchthing' (at source.lt3 line 6)
|