livetext 0.8.97 → 0.8.98

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42bc8ee5bb8b06789cb472fb038081a29fb00fce64583248ffe15f66cd88b9c8
4
- data.tar.gz: 7a4acc91072072ae4dffe193ce4e410ecd7251ebe323fb3c038f76e8da5ee6d9
3
+ metadata.gz: 00f683f16256558d0502dbc0a5a9011579bdfead42ad47f917a625ba3a7797bf
4
+ data.tar.gz: d4d83f4c157fa9f0db83adb1d98a03b87f810e4c5ee7b38fc554d926cce8cfac
5
5
  SHA512:
6
- metadata.gz: bd8c49581292b3fbf9a25849f0a3403f29dc73ac4e81bb115ef471a5fab413665e32d763b67571f6ecf095b273b36acdc61ff1790c5522d00c3b9de676395e38
7
- data.tar.gz: 4573738653920bd64d296e3f9d65f909a10bf438942dabb0b92aac07a2f0d207e33bf5ed00ea5d89db8adcdd9fa655846f936c3ef11e19b13e14b005a53f8896
6
+ metadata.gz: dbc69eef5f3b013c94c3a9bc424ca811f78bb656c2f63328b065f1ccbb9e6ad1f138dde746ab11c71ae0f459ebc52a0c5b64f4831ac8043357e01b6b30147b26
7
+ data.tar.gz: d84a5d9b0c177e70163574208593248d1e4c87e252101a6a4e011e8b26369b0ddee8ca44eef3fa4c8beed0feb3581cd67570bf675305cb7a321606d03b3d2c98
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.8.97"
2
+ VERSION = "0.8.98"
3
3
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
4
4
  end
5
5
 
@@ -52,6 +52,28 @@ class Livetext
52
52
  @indentation = [0]
53
53
  end
54
54
 
55
+ def _parse_colon_args(args, hash) # really belongs in livetext
56
+ h2 = hash.dup
57
+ e = args.each
58
+ loop do
59
+ arg = e.next.chop.to_sym
60
+ raise "_parse_args: #{arg} is unknown" unless hash.keys.include?(arg)
61
+ h2[arg] = e.next
62
+ end
63
+ h2 = h2.reject {|k,v| v.nil? }
64
+ h2.each_pair {|k, v| raise "#{k} has no value" if v.empty? }
65
+ h2
66
+ end
67
+
68
+ def _get_arg(name, args) # really belongs in livetext
69
+ raise "(#{name}) Expected an array" unless args.is_a? Array
70
+ raise "(#{name}) Expected an arg" if args.empty?
71
+ raise "(#{name}) Too many args: #{args.inspect}" if args.size > 1
72
+ val = args[0]
73
+ raise "Expected an argument '#{name}'" if val.nil?
74
+ val
75
+ end
76
+
55
77
  def mixin(mod)
56
78
  @main._mixin(mod)
57
79
  end
@@ -89,16 +111,19 @@ class Livetext
89
111
  end
90
112
  end
91
113
 
92
- def process(text)
114
+ def transform(text)
93
115
  _setfile!("(string)")
94
116
  enum = text.each_line
95
- front = text.match(/.*?\n/).to_a.first.chomp
117
+ front = text.match(/.*?\n/).to_a.first.chomp rescue ""
96
118
  @main.source(enum, "STDIN: '#{front}...'", 0)
97
119
  loop do
98
120
  line = @main.nextline
99
121
  break if line.nil?
100
122
  process_line(line)
101
123
  end
124
+ result = @body
125
+ @body = ""
126
+ result
102
127
  end
103
128
 
104
129
  # EXPERIMENTAL and incomplete
@@ -107,6 +132,7 @@ class Livetext
107
132
  when file && text.nil?
108
133
  xform_file(file)
109
134
  when file.nil? && text
135
+ transform(text)
110
136
  when file.nil? && text.nil?
111
137
  raise "Must specify file or text"
112
138
  when file && text
@@ -122,43 +148,43 @@ class Livetext
122
148
  self.body
123
149
  end
124
150
 
125
- def transform(text)
126
- _setfile!("(string)")
127
- @output = ::Livetext.output
128
- enum = text.each_line
129
- front = text.match(/.*?\n/).to_a.first.chomp rescue "..."
130
- @main.source(enum, "STDIN: '#{front}...'", 0)
131
- loop do
132
- line = @main.nextline
133
- break if line.nil?
134
- process_line(line) # transform_line ???
135
- end
136
- @body
137
- end
151
+ # def transform(text)
152
+ # _setfile!("(string)")
153
+ # @output = ::Livetext.output
154
+ # enum = text.each_line
155
+ # front = text.match(/.*?\n/).to_a.first.chomp rescue "..."
156
+ # @main.source(enum, "STDIN: '#{front}...'", 0)
157
+ # loop do
158
+ # line = @main.nextline
159
+ # break if line.nil?
160
+ # process_line(line) # transform_line ???
161
+ # end
162
+ # @body
163
+ # end
138
164
 
139
165
  ## FIXME don't need process *and* process_text
140
166
 
141
- def process_text(text)
142
- _setfile!("(string)")
143
- text = text.split("\n") if text.is_a? String
144
- enum = text.each
145
- @backtrace = false
146
- front = text[0].chomp
147
- @main.source(enum, "(text): '#{front}...'", 0)
148
- loop do
149
- line = @main.nextline
150
- break if line.nil?
151
- process_line(line)
152
- end
153
- val = @main.finalize if @main.respond_to? :finalize
154
- val
155
- rescue => err
156
- puts "process_text: err = #{err}"
157
- # puts err.backtrace.join("\n")
158
- puts @body
159
- @body = ""
160
- return @body
161
- end
167
+ # def process_text(text)
168
+ # _setfile!("(string)")
169
+ # text = text.split("\n") if text.is_a? String
170
+ # enum = text.each
171
+ # @backtrace = false
172
+ # front = text[0].chomp
173
+ # @main.source(enum, "(text): '#{front}...'", 0)
174
+ # loop do
175
+ # line = @main.nextline
176
+ # break if line.nil?
177
+ # process_line(line)
178
+ # end
179
+ # val = @main.finalize if @main.respond_to? :finalize
180
+ # val
181
+ # rescue => err
182
+ # puts "process_text: err = #{err}"
183
+ ## puts err.backtrace.join("\n")
184
+ # puts @body
185
+ # @body = ""
186
+ # return @body
187
+ # end
162
188
 
163
189
  ## FIXME process_file[!] should call process[_text]
164
190
 
@@ -181,20 +207,20 @@ class Livetext
181
207
  @body = ""
182
208
  end
183
209
 
184
- def process_file!(fname, backtrace=false)
185
- _setfile(fname)
186
- raise "No such file '#{fname}' to process" unless File.exist?(fname)
187
- @main.output = StringIO.new
188
- enum = File.readlines(fname).each
189
- @backtrace = backtrace
190
- @main.source(enum, fname, 0)
191
- loop do
192
- line = @main.nextline
193
- break if line.nil?
194
- process_line(line)
195
- end
196
- @main.finalize if @main.respond_to? :finalize
197
- end
210
+ # def process_file!(fname, backtrace=false)
211
+ # _setfile(fname)
212
+ # raise "No such file '#{fname}' to process" unless File.exist?(fname)
213
+ # @main.output = StringIO.new
214
+ # enum = File.readlines(fname).each
215
+ # @backtrace = backtrace
216
+ # @main.source(enum, fname, 0)
217
+ # loop do
218
+ # line = @main.nextline
219
+ # break if line.nil?
220
+ # process_line(line)
221
+ # end
222
+ # @main.finalize if @main.respond_to? :finalize
223
+ # end
198
224
 
199
225
  def handle_scomment(line)
200
226
  end
@@ -215,6 +241,7 @@ class Livetext
215
241
 
216
242
  def handle_dotcmd(line, indent = 0)
217
243
  indent = @indentation.last # top of stack
244
+ line = line.sub(/# .*$/, "")
218
245
  name = _get_name(line).to_sym
219
246
  result = nil
220
247
  if @main.respond_to?(name)
data/lib/standard.rb CHANGED
@@ -307,7 +307,7 @@ EOS
307
307
  if File.exist?(file)
308
308
  # Just keep going...
309
309
  else
310
- if File.expand_path(".").dirname != "/"
310
+ if File.dirname(File.expand_path(".")) != "/"
311
311
  Dir.chdir("..") { mixin }
312
312
  return
313
313
  else
@@ -4,9 +4,9 @@ a comment
4
4
  .end
5
5
  abc 123
6
6
  xyz
7
- .comment
7
+ .comment # and this is an extra-useless comment
8
8
  And so is this.
9
- .end
9
+ .end # comment of dubious nature
10
10
 
11
11
  one
12
12
  more
@@ -1,4 +1,4 @@
1
1
  A copy command
2
2
  does not interpret its input:
3
- .copy rawtext.inc
3
+ .copy rawtext.inc # another useless comment
4
4
  That's all.
@@ -1,11 +1,11 @@
1
1
  .backtrace
2
2
  abc
3
3
  123
4
- .def foobar
4
+ .def foobar # yet another experimental comment
5
5
  ::STDERR.puts "This is the"
6
6
  ::STDERR.puts "foobar method"
7
7
  .end
8
8
  xyz
9
- .foobar
9
+ .foobar # and still another
10
10
  xyzzy
11
11
  123
@@ -3,5 +3,5 @@ some text.
3
3
  .set name=GulliverFoyle, nation=Terra
4
4
  Hi, there.
5
5
  $name is my name, and $nation is my nation.
6
- I'm $name, from $nation.
6
+ I'm $name, from $nation\.
7
7
  That's all.
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.8.97
4
+ version: 0.8.98
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2019-12-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com