livetext 0.9.21 → 0.9.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.lt3 +8 -8
  3. data/bin/livetext +57 -40
  4. data/imports/bookish.rb +89 -90
  5. data/imports/calibre.rb +3 -3
  6. data/imports/livemagick.rb +17 -17
  7. data/imports/markdown.rb +10 -10
  8. data/imports/pyggish.rb +15 -47
  9. data/imports/tutorial.rb +18 -18
  10. data/lib/cmdargs.rb +10 -6
  11. data/lib/{errors.rb → livetext/errors.rb} +1 -1
  12. data/lib/{formatline.rb → livetext/formatline.rb} +69 -125
  13. data/lib/livetext/funcall.rb +84 -0
  14. data/lib/{functions.rb → livetext/functions.rb} +16 -3
  15. data/lib/livetext/global_helpers.rb +37 -0
  16. data/lib/livetext/handler/import.rb +44 -0
  17. data/lib/livetext/handler/mixin.rb +37 -0
  18. data/lib/livetext/handler.rb +3 -0
  19. data/lib/{helpers.rb → livetext/helpers.rb} +89 -67
  20. data/lib/{html.rb → livetext/html.rb} +3 -2
  21. data/lib/{parser → livetext/parser}/general.rb +0 -3
  22. data/lib/{parser → livetext/parser}/set.rb +1 -6
  23. data/lib/{parser → livetext/parser}/string.rb +2 -2
  24. data/lib/{parser.rb → livetext/parser.rb} +0 -1
  25. data/lib/livetext/parsing.rb +29 -0
  26. data/lib/livetext/paths.rb +13 -0
  27. data/lib/livetext/processor.rb +89 -0
  28. data/lib/livetext/reopen.rb +12 -0
  29. data/lib/livetext/skeleton.rb +17 -0
  30. data/lib/{standard.rb → livetext/standard.rb} +152 -122
  31. data/lib/livetext/userapi.rb +153 -0
  32. data/lib/livetext/version.rb +6 -0
  33. data/lib/livetext.rb +66 -27
  34. data/plugin/bookish.rb +85 -85
  35. data/plugin/calibre.rb +3 -3
  36. data/plugin/livemagick.rb +17 -17
  37. data/plugin/markdown.rb +10 -10
  38. data/plugin/pyggish.rb +131 -162
  39. data/plugin/tutorial.rb +15 -16
  40. data/test/all.rb +6 -0
  41. data/test/snapshots/def_method/expected-output.txt +2 -0
  42. data/test/snapshots/def_method/source.lt3 +4 -2
  43. data/test/snapshots/error_inc_line_num/OUT +17 -0
  44. data/test/snapshots/error_inc_line_num/README.txt +20 -0
  45. data/test/snapshots/error_inc_line_num/expected-output.txt +0 -6
  46. data/test/snapshots/error_inc_line_num/match-error.txt +1 -1
  47. data/test/snapshots/error_line_num/match-error.txt +1 -1
  48. data/test/snapshots/error_missing_end/expected-output.txt +0 -1
  49. data/test/snapshots/error_name_not_permitted/expected-output.txt +4 -0
  50. data/test/snapshots/error_name_not_permitted/match-error.txt +1 -1
  51. data/test/snapshots/error_no_such_copy/duh +26 -0
  52. data/test/snapshots/error_no_such_copy/expected-output.txt +1 -0
  53. data/test/snapshots/error_no_such_copy/match-error.txt +1 -1
  54. data/test/snapshots/error_no_such_copy/mystery.txt +36 -0
  55. data/test/snapshots/error_no_such_inc/match-error.txt +1 -1
  56. data/test/snapshots/error_no_such_mixin/expected-output.txt +1 -0
  57. data/test/snapshots/error_no_such_mixin/match-error.txt +1 -1
  58. data/test/snapshots/error_no_such_mixin/source.lt3 +1 -1
  59. data/test/snapshots/example_alpha/source.lt3 +2 -2
  60. data/test/snapshots/example_alpha2/expected-output.txt +0 -2
  61. data/test/snapshots/example_alpha2/source.lt3 +5 -4
  62. data/test/snapshots/{icanhaz → import}/expected-output.txt +2 -1
  63. data/test/snapshots/import/match-error.txt +1 -0
  64. data/test/snapshots/{icanhaz → import}/simple_import.rb +1 -1
  65. data/test/snapshots/{icanhaz → import}/source.lt3 +2 -2
  66. data/test/snapshots/{icanhaz2 → import2}/expected-error.txt +0 -0
  67. data/test/snapshots/{icanhaz2 → import2}/expected-output.txt +3 -1
  68. data/test/snapshots/{icanhaz2/simple_canhaz.rb → import2/simple_import.rb} +1 -1
  69. data/test/snapshots/import2/source.lt3 +8 -0
  70. data/test/snapshots/import_bookish/expected-error.txt +0 -0
  71. data/test/snapshots/import_bookish/expected-output.txt +10 -0
  72. data/test/snapshots/import_bookish/source.lt3 +7 -0
  73. data/test/snapshots/import_bookish/toc.tmp +0 -0
  74. data/test/snapshots/mixin_bookish/expected-error.txt +0 -0
  75. data/test/snapshots/mixin_bookish/expected-output.txt +10 -0
  76. data/test/snapshots/mixin_bookish/source.lt3 +7 -0
  77. data/test/snapshots/mixin_bookish/toc.tmp +0 -0
  78. data/test/snapshots/more_functions/expected-error.txt +0 -0
  79. data/test/snapshots/more_functions/expected-output.txt +37 -0
  80. data/test/snapshots/more_functions/source.lt3 +40 -0
  81. data/test/snapshots/raw_lines/expected-output.txt +0 -2
  82. data/test/snapshots/simple_import/expected-output.txt +2 -0
  83. data/test/snapshots/simple_import/simple_import.rb +1 -1
  84. data/test/snapshots/simple_import/source.lt3 +3 -1
  85. data/test/snapshots/simple_mixin/simple_mixin.rb +1 -1
  86. data/test/snapshots/single_raw_line/expected-output.txt +0 -2
  87. data/test/snapshots/subset.txt +14 -14
  88. data/test/snapshots.rb +30 -13
  89. data/test/unit/formatline.rb +253 -134
  90. data/test/unit/html.rb +2 -3
  91. data/test/unit/parser/general.rb +1 -2
  92. data/test/unit/parser/mixin.rb +1 -3
  93. data/test/unit/parser/set.rb +8 -12
  94. data/test/unit/parser/string.rb +6 -6
  95. data/test/unit/parser.rb +0 -1
  96. data/test/unit/standard.rb +0 -2
  97. metadata +47 -30
  98. data/imports/markdown_importable.rb +0 -45
  99. data/lib/handler/icanhaz.rb +0 -35
  100. data/lib/handler.rb +0 -1
  101. data/lib/livetext/importable.rb +0 -2
  102. data/lib/parser/file.rb +0 -8
  103. data/lib/parser/import.rb +0 -15
  104. data/lib/parser/mixin.rb +0 -38
  105. data/lib/processor.rb +0 -83
  106. data/lib/userapi.rb +0 -160
  107. data/test/snapshots/icanhaz/match-error.txt +0 -1
  108. data/test/snapshots/icanhaz2/source.lt3 +0 -6
  109. data/test/unit/parser/importable.rb +0 -19
data/plugin/pyggish.rb CHANGED
@@ -1,44 +1,44 @@
1
1
  require 'rouge'
2
2
 
3
- def self.pyg_change(code, klass, style)
4
- color = style[0..6]
5
- modifier = style[8]
6
- mod_open = modifier ? "<#{modifier}>" : ""
7
- mod_close = modifier ? "</#{modifier}>" : ""
8
- rx = /<span class="#{klass}">(?<cname>[^<]+?)<\/span>/
9
- loop do
10
- md = rx.match(code)
11
- break if md.nil?
12
- str = md[:cname]
13
- result = code.sub!(rx, "<font color=#{color}>#{mod_open}#{str}#{mod_close}</font>")
14
- break if result.nil?
15
- end
3
+ # FIXME This whole file has a weird vibe. It has dead code and
4
+ # also exposes methods that are not dot commands...
5
+
6
+ def self.pyg_change(code, klass, style)
7
+ color = style[0..6]
8
+ modifier = style[8]
9
+ mod_open = modifier ? "<#{modifier}>" : ""
10
+ mod_close = modifier ? "</#{modifier}>" : ""
11
+ rx = /<span class="#{klass}">(?<cname>[^<]+?)<\/span>/
12
+ loop do
13
+ md = rx.match(code)
14
+ break if md.nil?
15
+ str = md[:cname]
16
+ result = code.sub!(rx, "<font color=#{color}>#{mod_open}#{str}#{mod_close}</font>")
17
+ break if result.nil?
16
18
  end
19
+ end
17
20
 
18
- def self._codebar_color(lexer)
19
- color = case lexer
20
- when :elixir
21
- "#fc88fc"
22
- when :ruby
23
- "#fc8888"
24
- else
25
- raise "Unknown lexer"
26
- end
21
+ def self._codebar_color(lexer)
22
+ color = case lexer
23
+ when :elixir
24
+ "#fc88fc"
25
+ when :ruby
26
+ "#fc8888"
27
+ else
28
+ raise "Unknown lexer"
27
29
  end
30
+ end
28
31
 
29
- def self.pyg_finalize(code, lexer=:elixir)
30
- Styles.each_pair {|klass, style| pyg_change(code, klass, style) }
31
- File.open("debug-pf1", "w") {|f| f.puts code }
32
- code.sub!(/<pre>/, "<pre>\n")
33
- code.gsub!(/<span class="[np]">/, "")
34
- code.gsub!(/<\/span>/, "")
32
+ def self.pyg_finalize(code, lexer=:elixir)
33
+ Styles.each_pair {|klass, style| pyg_change(code, klass, style) }
34
+ code.sub!(/<pre>/, "<pre>\n")
35
+ code.gsub!(/<span class="[np]">/, "")
36
+ code.gsub!(/<\/span>/, "")
35
37
  color = _codebar_color(lexer)
36
38
  code.sub!(/<td class="linenos"/, "<td width=2%></td><td width=5% bgcolor=#{color}")
37
39
  code.gsub!(/<td/, "<td valign=top ")
38
40
  code.gsub!(/ class="[^"]*?"/, "") # Get rid of remaining Pygments CSS
39
- File.open("debug-pf2", "w") {|f| f.puts code }
40
41
  lines = code.split("\n")
41
- # lines.each {|line| line << "\n" }
42
42
  n1 = lines.index {|x| x =~ /<pre>/ }
43
43
  n2 = lines.index {|x| x =~ /<\/pre>/ }
44
44
  # FIXME ?
@@ -47,157 +47,126 @@ File.open("debug-pf2", "w") {|f| f.puts code }
47
47
  lines[n1].sub!(/ 1$/, " 1 ")
48
48
  (n1+1).upto(n2) {|n| lines[n].replace(" " + lines[n] + " ") }
49
49
  code = lines.join("\n")
50
- File.open("debug-pf3", "w") {|f| f.puts code }
51
50
  code
52
51
  end
53
52
 
54
-
55
- def _process_code(text)
56
- File.open("debug-pc1", "w") {|f| f.puts text }
57
- lines = text.split("\n")
58
- lines = lines.select {|x| x !~ /##~ omit/ }
59
- @refs = {}
60
- lines.each.with_index do |line, i|
61
- if line =~ /##~ ref/
62
- frag, name = line.split(/ *##~ ref/)
63
- @refs[name.strip] = i
64
- line.replace(frag)
53
+ def _process_code(text)
54
+ lines = text.split("\n")
55
+ lines = lines.select {|x| x !~ /##~ omit/ }
56
+ @refs = {}
57
+ lines.each.with_index do |line, i|
58
+ if line =~ /##~ ref/
59
+ frag, name = line.split(/ *##~ ref/)
60
+ @refs[name.strip] = i
61
+ line.replace(frag)
62
+ end
65
63
  end
64
+ lines.map! {|line| " " + line }
65
+ text2 = lines.join("\n")
66
+ text.replace(text2)
66
67
  end
67
- lines.map! {|line| " " + line }
68
- text2 = lines.join("\n")
69
- File.open("debug-pc2", "w") {|f| f.puts text2 }
70
- text.replace(text2)
71
- end
72
-
73
- def _colorize(code, lexer=:elixir)
74
- text = ::Pygments.highlight(code, lexer: lexer, options: {linenos: "table"})
75
- _debug "--- in _colorize: text = #{text.inspect}"
76
- text2 = PygmentFix.pyg_finalize(text, lexer)
77
- result = "<!-- colorized code -->\n" + text2
78
- result
79
- end
80
68
 
81
- def _colorize!(code, lexer=:elixir)
82
- text = ::Pygments.highlight(code, lexer: lexer, options: {})
83
- _debug "--- in _colorize!: text = #{text.inspect}"
84
- text2 = PygmentFix.pyg_finalize(text, lexer)
85
- result = "<!-- colorized code -->\n" + text2
86
- result
87
- end
88
-
89
- def OLD_ruby
90
- file = @_args.first
91
- if file.nil?
92
- code = "# Ruby code\n"
93
- _body {|line| code << line + "\n" }
94
- else
95
- code = "# Ruby code\n\n" + ::File.read(file)
69
+ def _colorize(code, lexer=:elixir)
70
+ text = ::Pygments.highlight(code, lexer: lexer, options: {linenos: "table"})
71
+ _debug "--- in _colorize: text = #{text.inspect}"
72
+ text2 = PygmentFix.pyg_finalize(text, lexer)
73
+ result = "<!-- colorized code -->\n" + text2
74
+ result
96
75
  end
97
76
 
98
- _process_code(code)
99
- html = _colorize(code, :ruby)
100
- _out "\n#{html}\n "
101
- end
102
-
103
- def OLD_elixir
104
- file = @_args.first
105
- if file.nil?
106
- code = ""
107
- _body {|line| code << line + "\n" }
108
- else
109
- code = ::File.read(file)
77
+ def _colorize!(code, lexer=:elixir)
78
+ text = ::Pygments.highlight(code, lexer: lexer, options: {})
79
+ _debug "--- in _colorize!: text = #{text.inspect}"
80
+ text2 = PygmentFix.pyg_finalize(text, lexer)
81
+ result = "<!-- colorized code -->\n" + text2
82
+ result
110
83
  end
111
84
 
112
- _process_code(code)
113
- html = _colorize(code, :elixir)
114
- _out "\n#{html}\n "
115
- end
116
-
117
- def fragment
118
- lang = @_args.empty? ? :elixir : @_args.first.to_sym # ruby or elixir
119
- @_args = []
120
- send(lang)
121
- _out "\n"
122
- end
123
-
124
- def code # FIXME ?
125
- text = ""
126
- _body {|line| _out " " + line }
127
- end
85
+ def fragment
86
+ lang = api.args.empty? ? :elixir : api.args.first.to_sym # ruby or elixir
87
+ api.args = []
88
+ # TTY.puts "\n#{self.inspect}"
89
+ send(lang)
90
+ api.out "\n"
91
+ end
128
92
 
129
- def mono
130
- _out "<pre>"
131
- _body {|line| _out " " + line }
132
- _out "</pre>"
133
- end
93
+ def code # FIXME ?
94
+ text = ""
95
+ api.body {|line| api.out " " + line }
96
+ end
134
97
 
135
- def create_code_styles
136
- dir = @_outdir || "."
137
- theme, back = "Github", "white"
138
- css = Rouge::Themes.const_get(theme).render(scope: '.rb_highlight')
139
- added = <<~CSS
140
- .rb_highlight {
141
- font-family: 'Monaco', 'Andale Mono', 'Lucida Grande', 'Courier', 'Lucida Console', 'Courier New', monospace;
142
- white-space: pre;
143
- background-color: #{back}
144
- }
145
- CSS
146
-
147
- css.gsub!(/{\n/, "{\n font-family: courier;")
148
- css = added + "\n" + css
149
- # STDERR.puts "Writing #{theme} theme to ruby.css"
150
- File.write("#{dir}/ruby.css", css)
151
-
152
- css = Rouge::Themes.const_get(theme).render(scope: '.ex_highlight')
153
- added = added.sub(/rb/, "ex")
154
- css.gsub!(/{\n/, "{\n font-family: courier;")
155
- css = added + "\n" + css
156
- # STDERR.puts "Writing #{theme} theme to elixir.css"
157
- File.write("#{dir}/elixir.css", css)
158
- end
98
+ def mono
99
+ api.out "<pre>"
100
+ api.body {|line| api.out " " + line }
101
+ api.out "</pre>"
102
+ end
159
103
 
104
+ def create_code_styles
105
+ dir = @_outdir || "."
106
+ theme, back = "Github", "white"
107
+ css = Rouge::Themes.const_get(theme).render(scope: '.rb_highlight')
108
+ added = <<~CSS
109
+ .rb_highlight {
110
+ font-family: 'Monaco', 'Andale Mono', 'Lucida Grande', 'Courier', 'Lucida Console', 'Courier New', monospace;
111
+ white-space: pre;
112
+ background-color: #{back}
113
+ }
114
+ CSS
115
+
116
+ css.gsub!(/{\n/, "{\n font-family: courier;")
117
+ css = added + "\n" + css
118
+ # STDERR.puts "Writing #{theme} theme to ruby.css"
119
+ File.write("#{dir}/ruby.css", css)
120
+
121
+ css = Rouge::Themes.const_get(theme).render(scope: '.ex_highlight')
122
+ added = added.sub(/rb/, "ex")
123
+ css.gsub!(/{\n/, "{\n font-family: courier;")
124
+ css = added + "\n" + css
125
+ # STDERR.puts "Writing #{theme} theme to elixir.css"
126
+ File.write("#{dir}/elixir.css", css)
127
+ end
160
128
 
161
- def format_ruby(source, theme = "Github", back = "black")
162
- # theme/back not used now
163
- formatter = Rouge::Formatters::HTML.new
164
- lexer = Rouge::Lexers::Ruby.new
165
- body = formatter.format(lexer.lex(source))
166
- text = "<div class=rb_highlight>#{body}</div>"
167
- text
168
- end
169
129
 
170
- def format_elixir(source, theme = "Github", back = "black")
171
- # theme/back not used now
172
- formatter = Rouge::Formatters::HTML.new
173
- lexer = Rouge::Lexers::Elixir.new
174
- body = formatter.format(lexer.lex(source))
175
- text = "<div class=ex_highlight>#{body}</div>"
176
- text
177
- end
130
+ def format_ruby(source, theme = "Github", back = "black")
131
+ # theme/back not used now
132
+ formatter = Rouge::Formatters::HTML.new
133
+ lexer = Rouge::Lexers::Ruby.new
134
+ body = formatter.format(lexer.lex(source))
135
+ text = "<div class=rb_highlight>#{body}</div>"
136
+ text
137
+ end
178
138
 
179
- def ruby
180
- file = @_args.first
181
- if file.nil?
182
- code = " # Ruby code\n\n"
183
- _body {|line| code << " " + line + "\n" }
184
- else
185
- code = "# Ruby code\n\n" + ::File.read(file)
139
+ def format_elixir(source, theme = "Github", back = "black")
140
+ # theme/back not used now
141
+ formatter = Rouge::Formatters::HTML.new
142
+ lexer = Rouge::Lexers::Elixir.new
143
+ body = formatter.format(lexer.lex(source))
144
+ text = "<div class=ex_highlight>#{body}</div>"
145
+ text
186
146
  end
187
147
 
188
- html = format_ruby(code)
189
- _out html
190
- end
148
+ def ruby
149
+ file = api.args.first
150
+ if file.nil?
151
+ code = " # Ruby code\n\n"
152
+ api.body {|line| code << " " + line + "\n" }
153
+ else
154
+ code = "# Ruby code\n\n" + ::File.read(file)
155
+ end
191
156
 
192
- def elixir
193
- file = @_args.first
194
- if file.nil?
195
- code = ""
196
- _body {|line| code << " " + line + "\n" }
197
- else
198
- code = ::File.read(file)
157
+ html = format_ruby(code)
158
+ api.out html
199
159
  end
200
160
 
201
- html = format_elixir(code)
202
- _out html
161
+ def elixir
162
+ file = api.args.first
163
+ if file.nil?
164
+ code = ""
165
+ api.body {|line| code << " " + line + "\n" }
166
+ else
167
+ code = ::File.read(file)
168
+ end
169
+
170
+ html = format_elixir(code)
171
+ api.out html
203
172
  end
data/plugin/tutorial.rb CHANGED
@@ -2,22 +2,22 @@ require 'cgi'
2
2
 
3
3
  def title(args = nil, body = nil)
4
4
  h1
5
- _optional_blank_line
5
+ api.optional_blank_line
6
6
  end
7
7
 
8
8
  def section(args = nil, body = nil)
9
9
  h3
10
- _optional_blank_line
10
+ api.optional_blank_line
11
11
  end
12
12
 
13
13
  def code(args = nil, body = nil)
14
14
  first = true # dumb hack! fixes blank space
15
- _body do |line|
15
+ api.body do |line|
16
16
  tag, first = "<pre>", false if first
17
- _out "#{tag} #{::CGI.escape_html(line)}" # indentation
17
+ api.out "#{tag} #{::CGI.escape_html(line)}" # indentation
18
18
  end
19
- _out "</pre>"
20
- _optional_blank_line
19
+ api.out "</pre>"
20
+ api.optional_blank_line
21
21
  end
22
22
 
23
23
  def rx(str)
@@ -25,14 +25,14 @@ def rx(str)
25
25
  end
26
26
 
27
27
  def inout(args = nil, body = nil)
28
- src, out = _args
28
+ src, out = api.args
29
29
  t1 = ::File.readlines(src) rescue (abort "t1 = #{src}")
30
30
  t2 = ::File.readlines(out) rescue (abort "t2 = #{out}")
31
31
  # To pacify markdown for README (FIXME later)
32
32
  t1 = t1.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
33
33
  t2 = t2.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
34
34
 
35
- _out <<-HTML
35
+ api.out <<-HTML
36
36
  <table width=80% cellpadding=4>
37
37
  <tr>
38
38
  <td width=50%><b>Input</b></td>
@@ -48,17 +48,16 @@ def inout(args = nil, body = nil)
48
48
  </tr>
49
49
  </table>
50
50
  HTML
51
- _optional_blank_line
51
+ api.optional_blank_line
52
52
  end
53
53
 
54
54
  def put_table(src, exp)
55
- STDERR.puts "put_table: #{[src, exp].inspect}"
56
55
  t1 = ::File.readlines(src) rescue (abort "Fail - src = #{src} t1 = #{src}")
57
56
  t2 = ::File.readlines(exp) rescue (abort "Fail - src = #{exp} t2 = #{out}")
58
57
  t1 = t1.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
59
58
  t2 = t2.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
60
59
 
61
- _out <<-HTML
60
+ api.out <<-HTML
62
61
  <font size=+1>
63
62
  <table width=80% cellpadding=4>
64
63
  <tr>
@@ -79,11 +78,11 @@ STDERR.puts "put_table: #{[src, exp].inspect}"
79
78
  end
80
79
 
81
80
  def testcase(args = nil, body = nil)
82
- name = _args.first
83
- _out "\n<font size=+1><b>Test: </font><font size=+2><tt>#{name}</tt></font></b></h3><br>"
81
+ name = api.args.first
82
+ api.out "\n<font size=+1><b>Test: </font><font size=+2><tt>#{name}</tt></font></b></h3><br>"
84
83
  src, exp = "test/snapshots/#{name}/source.lt3", "test/snapshots/#{name}/expected-output.txt"
85
- @_args = [src, exp] # Better way to do this??
84
+ api.args = [src, exp] # Better way to do this??
86
85
  put_table(src, exp)
87
- _out "<br>"
88
- _optional_blank_line
86
+ api.out "<br>"
87
+ api.optional_blank_line
89
88
  end
data/test/all.rb CHANGED
@@ -1,3 +1,9 @@
1
+ require 'simplecov' # These two lines must go first
2
+ SimpleCov.start do
3
+ puts "SimpleCov: Snapshots"
4
+ enable_coverage :branch
5
+ add_filter "/test/"
6
+ end
1
7
 
2
8
  require_relative 'unit/all'
3
9
  require_relative 'snapshots' # snapshots
@@ -1,5 +1,7 @@
1
1
  abc
2
2
  123
3
3
  xyz
4
+ <p>
5
+
4
6
  xyzzy
5
7
  123
@@ -2,10 +2,12 @@
2
2
  abc
3
3
  123
4
4
  .def foobar # yet another experimental comment
5
- ::STDERR.puts "This is the"
6
- ::STDERR.puts "foobar method"
5
+ ::STDERR.puts "This is the"
6
+ ::STDERR.puts "foobar method"
7
+ true
7
8
  .end
8
9
  xyz
9
10
  .foobar # and still another
11
+
10
12
  xyzzy
11
13
  123
@@ -0,0 +1,17 @@
1
+ This is my
2
+ source file
3
+ which includes file2 here:
4
+ This is file2
5
+ which has an error
6
+ about an unknown command
7
+ in line 5
8
+ This is my
9
+ source file
10
+ which includes file2 here:
11
+ This is file2
12
+ which has an error
13
+ about an unknown command
14
+ in line 5
15
+ <p>
16
+
17
+ And this is file2 line 7.
@@ -0,0 +1,20 @@
1
+ ---- File: source.lt3
2
+
3
+ This is my
4
+ source file
5
+ which includes file2 here:
6
+ .include file2.lt3
7
+
8
+ And here we are
9
+ back in the
10
+ original file.
11
+
12
+ --- File: file2.lt3
13
+
14
+ This is file2
15
+ which has an error
16
+ about an unknown command
17
+ in line 5
18
+ .foobar
19
+
20
+ And this is file2 line 7.
@@ -5,9 +5,3 @@ 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.
@@ -1 +1 @@
1
- 1 /Name 'foobar' is unknown/
1
+ 1 /Error: name 'foobar' is unknown/
@@ -1 +1 @@
1
- 1 /Name 'foobar' is unknown/
1
+ 1 /Error: name 'foobar' is unknown/
@@ -2,4 +2,3 @@ Blah
2
2
  blah
3
3
  <p>
4
4
 
5
-
@@ -0,0 +1,4 @@
1
+ Names such as 'class'
2
+ are not permitted here...
3
+ <p>
4
+
@@ -1 +1 @@
1
- 1 /Disallowed/
1
+ 1 /name 'class' is invalid/
@@ -0,0 +1,26 @@
1
+ ####
2
+ self =
3
+ #<Processor:0x00007fd5ec14d290
4
+ @parent=#<Livetext:0x00007fd5ec14d358
5
+ @source=nil,
6
+ @_mixins=[],
7
+ @_imports=[],
8
+ @_outdir=".",
9
+ @no_puts=false,
10
+ @body="Make sure a\nnonexistent file with .copy\ngives an error.\n<p>\n\n",
11
+ @main=#<Processor:0x00007fd5ec14d290 ...>,
12
+ @indentation=[0],
13
+ @_vars={"User"=>"Hal", :User=>"Hal", "Version"=>"0.9.24", :Version=>"0.9.24",
14
+ "File"=>"source.lt3", :File=>"source.lt3",
15
+ "FileDir"=>"/Users/Hal/Dropbox/topx/git/livetext/test/snapshots/error_no_such_copy",
16
+ :FileDir=>"/Users/Hal/Dropbox/topx/git/livetext/test/snapshots/error_no_such_copy"},
17
+ @backtrace=true>,
18
+ @_nopass=false,
19
+ @_nopara=false,
20
+ @output=#<IO:<STDOUT>>,
21
+ @sources=[[#<Enumerator: ["Make sure a", "nonexistent file with .copy", "gives an error.", "\n", ".copy nosuchfile.txt\n", "\n", "Nothing to\n", "see here.\n"]:each>, "source.lt3", 5]],
22
+ @indentation=nil,
23
+ @_mixins=[],
24
+ @_imports=[],
25
+ @_data="nosuchfile.txt",
26
+ @_args=["nosuchfile.txt"]>
@@ -2,3 +2,4 @@ Make sure a
2
2
  nonexistent file with .copy
3
3
  gives an error.
4
4
  <p>
5
+
@@ -1 +1 @@
1
- 1 /file nosuchfile.txt not found/
1
+ 1 /file 'nosuchfile.txt' not found/
@@ -0,0 +1,36 @@
1
+ livetext:78:in `parse_command_line'
2
+ livetext:78:in `loop'
3
+ livetext:92:in `block in parse_command_line'
4
+ helpers.rb:72:in `process_file'
5
+ helpers.rb:72:in `loop'
6
+ helpers.rb:75:in `block in process_file'
7
+ helpers.rb:95:in `process_line'
8
+ helpers.rb:124:in `handle_dotcmd'
9
+ standard.rb:273:in `copy': Error: file 'nosuchfile.txt' not found (FileNotFound)
10
+
11
+
12
+ parse_command_line
13
+ process_file
14
+ process_line
15
+ handle_dotcmd
16
+ copy
17
+
18
+
19
+
20
+
21
+ livetext "main" rescue unexpected
22
+ process_file ret Bool, print warning, rescue unex, no raise
23
+ process_line ret Bool, no rescue, no raise
24
+ handle_dotcmd ret Bool, no rescue, 2 custom exceptions
25
+ copy ret Bool, rescue only unexpected
26
+ check_file_exists returns Boolean, no rescue, no raise
27
+
28
+
29
+ METHOD RETURNS RESCUE RAISES OTHER
30
+ ------------------- ----------------- ----------------- ----------------- -----------------
31
+ parse_command_line nothing only unexpected
32
+ process_file
33
+ process_line
34
+ handle_dotcmd
35
+ copy
36
+
@@ -1 +1 @@
1
- 1 /file nosuchinc.lt3 not found/
1
+ 1 /file 'nosuchinc.lt3' not found/
@@ -3,3 +3,4 @@ we give an error
3
3
  when a mixin does not
4
4
  exist:
5
5
  <p>
6
+
@@ -1 +1 @@
1
- 1 /No such mixin 'nosuchthing'/
1
+ 1 /file 'nosuchthing' not found/
@@ -1,4 +1,4 @@
1
- Test that
1
+ Test that
2
2
  we give an error
3
3
  when a mixin does not
4
4
  exist:
@@ -1,7 +1,7 @@
1
1
  .def alpha
2
- text = _body.to_a.join(" ")
2
+ text = api.body.to_a.join(" ")
3
3
  words = text.split.sort
4
- words.each {|w| _out " #{w}" }
4
+ words.each {|w| api.out " #{w}" }
5
5
  .end
6
6
  Here is an alphabetized list:
7
7
 
@@ -7,6 +7,4 @@ fishmonger fusillade glyph
7
7
  gryphon halcyon manicotti
8
8
  mataeotechny pareidolia quark
9
9
  zootrope zymurgy
10
- <p>
11
-
12
10
  And that is all.
@@ -1,15 +1,16 @@
1
1
  .def alpha
2
- cols = _args.first
2
+ cols = api.args.first
3
3
  cols = "1" if cols == ""
4
4
  cols = cols.to_i
5
5
  raise "Columns must be 1-5" unless cols.between?(1,5)
6
- text = _body.join("\n")
6
+ text = api.body.join("\n")
7
7
  text.gsub!(/\n/, " ")
8
8
  words = text.split.sort
9
9
  words.each_slice(cols) do |row|
10
- row.each {|w| _out! '%-15s' % w }
11
- _out
10
+ row.each {|w| api.out! '%-15s' % w }
11
+ api.out
12
12
  end
13
+ api.optional_blank_line
13
14
  .end
14
15
  Here is an alphabetized list:
15
16