livetext 0.9.10 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67d6ad974fae59754a4bf3d6c306e01a9028b8d5f0d86968fa2a3de5fbf97018
4
- data.tar.gz: d250929b203dbfe8bdec044b31abebfe6f7244e2dd19376b876c0daf2634b730
3
+ metadata.gz: 2f49173986fc8a17fc77f35032e823f4818d404007d5aacd2d3d5a4a74f19e02
4
+ data.tar.gz: 61c0eab54d60c23abe0c27a6b8adc16f621e35c347253b557f07ffc80b31f80e
5
5
  SHA512:
6
- metadata.gz: 20dfdad9784ef0bab8439b63d2dccac59f21a27ae57c178c8961bc5414a9dc87af4e78b0d7b5d2b61ca9809715e6fa6e1ee0cf6f8e9091053f724be3d1b7d505
7
- data.tar.gz: 7a8cc51ccf632a8ec43ee06669f54c39276e5d88fbeb990e4c2d23c33993eb308e83ae3aa5213a054d5e868cb5617eab2632cb480764ece197192d03f0a75618
6
+ metadata.gz: '07389bbd1154d200f6f56b0373c0459bf140baeefa370d789224f2dedd53fe5120f0f7116e2c9d1381ff07a48f945786bb8e5f3478ac9002aea0f9443f61f579'
7
+ data.tar.gz: 12829e57528407a55f842f8ad8de77b47396cb6fffb22d76feaf8d98d644ebf00fc50d447a24f453026980a7cb7631443e11f9f7d67121ce9529d583ef85e513
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.9.10"
2
+ VERSION = "0.9.11"
3
3
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
4
4
  end
5
5
 
@@ -74,6 +74,10 @@ class Livetext
74
74
  @main = Processor.new(self, output)
75
75
  @indentation = [0]
76
76
  @_vars = Livetext::Vars
77
+
78
+ # Other predefined variables (see also _setfile)
79
+ _setvar(:User, `whoami`.chomp)
80
+ _setvar(:Version, Livetext::VERSION)
77
81
  end
78
82
 
79
83
  def _parse_colon_args(args, hash) # really belongs in livetext
@@ -230,10 +234,10 @@ class Livetext
230
234
  end
231
235
  result
232
236
  rescue => err
233
- STDERR.puts "Error was: #{err.inspect} (calling @main._error!)"
237
+ STDERR.puts "Error: #{err.inspect}"
234
238
  STDERR.puts err.backtrace
235
- @main._error!(err)
236
- # puts @body
239
+ # @main._error!(err)
240
+ puts @body
237
241
  @body = ""
238
242
  return @body
239
243
  end
data/lib/processor.rb CHANGED
@@ -35,11 +35,11 @@ class Livetext
35
35
  def _error!(err, abort=true, trace=false)
36
36
  where = @sources.last || @save_location
37
37
  # puts @parent.body
38
- puts "[lib/processor] Error: #{err}"
39
- puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
38
+ # puts "[lib/processor] Error: #{err}"
39
+ # puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
40
40
  STDERR.puts "[lib/processor] Error: #{err}" # (at #{where[1]} line #{where[2]})"
41
- raise "lib/processor error!"
42
41
  STDERR.puts err.backtrace if err.respond_to?(:backtrace) # && trace
42
+ # raise "lib/processor error!" # FIXME
43
43
  exit if abort
44
44
  end
45
45
 
data/lib/userapi.rb CHANGED
@@ -93,10 +93,10 @@ module Livetext::UserAPI
93
93
  else
94
94
  lines
95
95
  end
96
- rescue => err
97
- str = err.inspect + "\n"
98
- str << err.backtrace.map {|x| " " + x }.join("\n")
99
- _error!(str)
96
+ # rescue => err
97
+ # str = err.inspect + "\n"
98
+ # str << err.backtrace.map {|x| " " + x }.join("\n")
99
+ # _error!(str)
100
100
  end
101
101
 
102
102
  def _body_text(raw=false)
@@ -0,0 +1,21 @@
1
+ [lib/processor] Error: Name 'foobar' is unknown
2
+ Error was: #<RuntimeError: lib/processor error!> (calling @main._error!)
3
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/processor.rb:41:in `_error!'
4
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:228:in `handle_dotcmd'
5
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:130:in `process_line'
6
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:192:in `block in process_file'
7
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `loop'
8
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `process_file'
9
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/standard.rb:341:in `_include'
10
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:226:in `handle_dotcmd'
11
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:130:in `process_line'
12
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:192:in `block in process_file'
13
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `loop'
14
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `process_file'
15
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:88:in `block in <top (required)>'
16
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:57:in `loop'
17
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:57:in `<top (required)>'
18
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/livetext:23:in `load'
19
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/livetext:23:in `<main>'
20
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
21
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'
@@ -5,3 +5,9 @@ which includes file2 here:
5
5
  which has an error
6
6
  about an unknown command
7
7
  in line 5
8
+ <p>
9
+
10
+ And this is file2 line 7.
11
+ And here we are
12
+ back in the
13
+ original file.
@@ -4,3 +4,5 @@ without something
4
4
  beginning a block:
5
5
  <p>
6
6
 
7
+ foo bar
8
+ baz
@@ -0,0 +1,32 @@
1
+ [lib/processor] Error: #<RuntimeError: Expected .end, found end of file>
2
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/userapi.rb:88:in `_body'
3
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/standard.rb:32:in `comment'
4
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:226:in `handle_dotcmd'
5
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:130:in `process_line'
6
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:192:in `block in process_file'
7
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `loop'
8
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `process_file'
9
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:88:in `block in <top (required)>'
10
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:57:in `loop'
11
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:57:in `<top (required)>'
12
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/livetext:23:in `load'
13
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/livetext:23:in `<main>'
14
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
15
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'
16
+ Error was: #<RuntimeError: lib/processor error!> (calling @main._error!)
17
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/processor.rb:41:in `_error!'
18
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/userapi.rb:99:in `rescue in _body'
19
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/userapi.rb:75:in `_body'
20
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/standard.rb:32:in `comment'
21
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:226:in `handle_dotcmd'
22
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:130:in `process_line'
23
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:192:in `block in process_file'
24
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `loop'
25
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/lib/livetext.rb:189:in `process_file'
26
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:88:in `block in <top (required)>'
27
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:57:in `loop'
28
+ /Users/Hal/.rvm/gems/ruby-2.7.0/gems/livetext-0.9.08/bin/livetext:57:in `<top (required)>'
29
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/livetext:23:in `load'
30
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/livetext:23:in `<main>'
31
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
32
+ /Users/Hal/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'
@@ -2,3 +2,4 @@ Blah
2
2
  blah
3
3
  <p>
4
4
 
5
+
@@ -3,3 +3,7 @@ nonexistent file with .copy
3
3
  gives an error.
4
4
  <p>
5
5
 
6
+ <p>
7
+
8
+ Nothing to
9
+ see here.
@@ -1,3 +1,4 @@
1
+ .debug
1
2
  Make sure a
2
3
  nonexistent file with .copy
3
4
  gives an error.
@@ -3,3 +3,7 @@ a nonexistent include
3
3
  will give an error.
4
4
  <p>
5
5
 
6
+ <p>
7
+
8
+ Nothing to
9
+ see here.
data/test/data/lines.txt CHANGED
@@ -118,3 +118,7 @@ Doubled underscore, midline
118
118
  This is __doubled, it seems
119
119
  This is <i>doubled</i>, it seems
120
120
 
121
+ Underscore inside parens
122
+ This is (_italicized and parenthesized)
123
+ This is (<i>italicized</i> and parenthesized)
124
+
File without changes
@@ -0,0 +1,6 @@
1
+ Here we go...
2
+ File = source.lt3
3
+ FileDir = /Users/Hal/Dropbox/topx/git/livetext/test/data/predef_vars
4
+ User = Hal
5
+ Version = 0.9.11
6
+ NoSuchVar = [NoSuchVar is undefined]
@@ -0,0 +1,6 @@
1
+ Here we go...
2
+ File = $File
3
+ FileDir = $FileDir
4
+ User = $User
5
+ Version = $Version
6
+ NoSuchVar = $NoSuchVar
data/test/testlines.rb CHANGED
@@ -8,20 +8,30 @@ require 'formatline'
8
8
  input = ARGV.first || "test/data/lines.txt"
9
9
  data = File.readlines(input)
10
10
 
11
- data.each_slice(4) do |lines|
11
+ pass = fail = 0
12
+ data.each_slice(4).with_index do |lines, i|
12
13
  title, input, expected, blank = *lines
14
+ lnum = i*4 + 1
13
15
  input.chomp!
14
16
  expected.chomp!
15
17
  expected = eval(expected) if expected[0] == "/"
16
18
 
17
- puts "-----------------------------"
18
- print "Test: #{title}"
19
19
 
20
20
  actual = FormatLine.parse!(input)
21
- next if expected === actual
21
+ if expected === actual
22
+ pass += 1
23
+ # puts "PASS: #{title}"
24
+ next
25
+ end
22
26
 
23
- puts "Input: #{input}"
27
+ fail += 1
28
+ puts "----------------------------- (line #{lnum})"
29
+ puts "Test: #{title}"
30
+ puts "Input: #{input}"
24
31
  puts " #{red('FAIL Expected: ')} #{expected.inspect}"
25
32
  puts " #{red(' Actual : ')} #{actual.inspect}"
26
33
  puts
27
34
  end
35
+
36
+ puts
37
+ puts "#{pass} passes #{fail} fails"
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.10
4
+ version: 0.9.11
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-12-07 00:00:00.000000000 Z
11
+ date: 2021-12-04 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,6 +53,7 @@ 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/FOO
56
57
  - test/data/error_inc_line_num/expected-err-line1match.txt
57
58
  - test/data/error_inc_line_num/expected-output.txt
58
59
  - test/data/error_inc_line_num/file2.lt3
@@ -66,6 +67,7 @@ files:
66
67
  - test/data/error_mismatched_end/expected-err-line1match.txt
67
68
  - test/data/error_mismatched_end/expected-output.txt
68
69
  - test/data/error_mismatched_end/source.lt3
70
+ - test/data/error_missing_end/ERR
69
71
  - test/data/error_missing_end/expected-err-line1match.txt
70
72
  - test/data/error_missing_end/expected-output.txt
71
73
  - test/data/error_missing_end/source.lt3
@@ -98,6 +100,9 @@ files:
98
100
  - test/data/more_complex_vars/expected-error.txt
99
101
  - test/data/more_complex_vars/expected-output.txt
100
102
  - test/data/more_complex_vars/source.lt3
103
+ - test/data/predef_vars/expected-error.txt
104
+ - test/data/predef_vars/expected-output.txt
105
+ - test/data/predef_vars/source.lt3
101
106
  - test/data/raw_lines/expected-error.txt
102
107
  - test/data/raw_lines/expected-output.txt
103
108
  - test/data/raw_lines/source.lt3
@@ -127,7 +132,6 @@ files:
127
132
  - test/data/table_with_heredocs/expected-error.txt
128
133
  - test/data/table_with_heredocs/expected-output.txt
129
134
  - test/data/table_with_heredocs/source.lt3
130
- - test/extratests.txt
131
135
  - test/formatting.rb
132
136
  - test/newtest
133
137
  - test/sdtest
@@ -152,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
156
  - !ruby/object:Gem::Version
153
157
  version: '0'
154
158
  requirements: []
155
- rubygems_version: 3.0.8
159
+ rubygems_version: 3.1.2
156
160
  signing_key:
157
161
  specification_version: 4
158
162
  summary: A smart processor for text
data/test/extratests.txt DELETED
@@ -1,20 +0,0 @@
1
- Line starts with underscore
2
- _This for example
3
- <i>This</i> for example
4
-
5
- Line starts with double underscore
6
- __This, for example
7
- <i>This,</i> for example
8
-
9
- Line has embedded underscores
10
- This has some_embedded_underscores
11
- This has some_embedded_underscores
12
-
13
- Doubled underscore, midline
14
- This is __doubled, it seems
15
- This is <i>doubled,</i> it seems
16
-
17
- Line has escaped underscores
18
- This has some\_escaped\_underscores
19
- This has some_escaped_underscores
20
-