livetext 0.9.03 → 0.9.04

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: 868972bd6d69160614982ec1673ffe4b1e6b52cc0c37b3f3665b4cd63a9465c4
4
- data.tar.gz: bb03f156bed4713bfa30804c6bb4fb5057a22db84523774a90649e62e22ac8f6
3
+ metadata.gz: 953abc29d2faf2ff8d8ae5e1c7e4033efbc1dbd57b69144634b3287b71424b77
4
+ data.tar.gz: 3086f96e6226ada9787338b26d08950667e44b65029e5bc5d80bc4c72b50b7bb
5
5
  SHA512:
6
- metadata.gz: f44235d6cd9649515ae9b6fed910b233f90c37f92c54bec3183f718b83e918ef95192aa8e8c08ec8b2eca16edbcbcc519a002214efeff4d042d7056f8a3a3a78
7
- data.tar.gz: 148fa1af92fa0320bbbe3db92fb89cd24d4ebc0620d65343c1c0120c1a61c5612df7fe27bf2d6b0cf805189e00a566487cda712a4e1e09be3ce1f4e9ea035999
6
+ metadata.gz: d8a49669fc15a3a5aad4151cf190f8d527edc1349fb30a7abfdf9141648f32bbb56d507a6f7ccfc983c9335d7f2df037a9dbf30325e27c02e1d68590ffb1c2bd
7
+ data.tar.gz: 9e4c56a912009b7332fd9702c1fd7a8a27fdbb9c639d0ae62ec4adabd31e8e70554a7ab4645ba6595a138712c0dfcb47430805d69530f26e5d9479dd90148b38
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.9.03"
2
+ VERSION = "0.9.04"
3
3
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
4
4
  end
5
5
 
@@ -31,6 +31,10 @@ class Livetext
31
31
  attr_accessor :output # both bad solutions?
32
32
  end
33
33
 
34
+ def vars
35
+ Livetext::Vars.dup
36
+ end
37
+
34
38
  def self.customize(mix: [], call: [], vars: {})
35
39
  obj = self.new
36
40
  mix = Array(mix)
@@ -50,10 +54,6 @@ class Livetext
50
54
  self
51
55
  end
52
56
 
53
- def vars
54
- Livetext::Vars.dup
55
- end
56
-
57
57
  Space = " "
58
58
  Sigil = "." # Can't change yet
59
59
 
@@ -73,29 +73,30 @@ class Livetext
73
73
  @body = ""
74
74
  @main = Processor.new(self, output)
75
75
  @indentation = [0]
76
+ @_vars = Livetext::Vars
76
77
  end
77
78
 
78
- def _parse_colon_args(args, hash) # really belongs in livetext
79
- h2 = hash.dup
80
- e = args.each
81
- loop do
82
- arg = e.next.chop.to_sym
83
- raise "_parse_args: #{arg} is unknown" unless hash.keys.include?(arg)
84
- h2[arg] = e.next
79
+ def _parse_colon_args(args, hash) # really belongs in livetext
80
+ h2 = hash.dup
81
+ e = args.each
82
+ loop do
83
+ arg = e.next.chop.to_sym
84
+ raise "_parse_args: #{arg} is unknown" unless hash.keys.include?(arg)
85
+ h2[arg] = e.next
86
+ end
87
+ h2 = h2.reject {|k,v| v.nil? }
88
+ h2.each_pair {|k, v| raise "#{k} has no value" if v.empty? }
89
+ h2
85
90
  end
86
- h2 = h2.reject {|k,v| v.nil? }
87
- h2.each_pair {|k, v| raise "#{k} has no value" if v.empty? }
88
- h2
89
- end
90
91
 
91
- def _get_arg(name, args) # really belongs in livetext
92
- raise "(#{name}) Expected an array" unless args.is_a? Array
93
- raise "(#{name}) Expected an arg" if args.empty?
94
- raise "(#{name}) Too many args: #{args.inspect}" if args.size > 1
95
- val = args[0]
96
- raise "Expected an argument '#{name}'" if val.nil?
97
- val
98
- end
92
+ def _get_arg(name, args) # really belongs in livetext
93
+ raise "(#{name}) Expected an array" unless args.is_a? Array
94
+ raise "(#{name}) Expected an arg" if args.empty?
95
+ raise "(#{name}) Too many args: #{args.inspect}" if args.size > 1
96
+ val = args[0]
97
+ raise "Expected an argument '#{name}'" if val.nil?
98
+ val
99
+ end
99
100
 
100
101
  def mixin(mod)
101
102
  @main._mixin(mod)
@@ -105,6 +106,8 @@ end
105
106
  str, sym = var.to_s, var.to_sym
106
107
  Livetext::Vars[str] = val
107
108
  Livetext::Vars[sym] = val
109
+ @_vars[str] = val
110
+ @_vars[sym] = val
108
111
  end
109
112
 
110
113
  def _setfile(file)
@@ -166,50 +169,13 @@ end
166
169
  self.body
167
170
  end
168
171
 
169
- def xform_file(file, vars: {})
172
+ def xform_file(file) # , vars: {})
170
173
  Livetext::Vars.replace(vars) unless vars.nil?
174
+ @_vars.replace(vars) unless vars.nil?
171
175
  self.process_file(file)
172
176
  self.body
173
177
  end
174
178
 
175
- # def transform(text)
176
- # _setfile!("(string)")
177
- # @output = ::Livetext.output
178
- # enum = text.each_line
179
- # front = text.match(/.*?\n/).to_a.first.chomp rescue "..."
180
- # @main.source(enum, "STDIN: '#{front}...'", 0)
181
- # loop do
182
- # line = @main.nextline
183
- # break if line.nil?
184
- # process_line(line) # transform_line ???
185
- # end
186
- # @body
187
- # end
188
-
189
- ## FIXME don't need process *and* process_text
190
-
191
- # def process_text(text)
192
- # _setfile!("(string)")
193
- # text = text.split("\n") if text.is_a? String
194
- # enum = text.each
195
- # @backtrace = false
196
- # front = text[0].chomp
197
- # @main.source(enum, "(text): '#{front}...'", 0)
198
- # loop do
199
- # line = @main.nextline
200
- # break if line.nil?
201
- # process_line(line)
202
- # end
203
- # val = @main.finalize if @main.respond_to? :finalize
204
- # val
205
- # rescue => err
206
- # puts "process_text: err = #{err}"
207
- ## puts err.backtrace.join("\n")
208
- # puts @body
209
- # @body = ""
210
- # return @body
211
- # end
212
-
213
179
  ## FIXME process_file[!] should call process[_text]
214
180
 
215
181
  def process_file(fname, btrace=false)
@@ -231,21 +197,6 @@ end
231
197
  @body = ""
232
198
  end
233
199
 
234
- # def process_file!(fname, backtrace=false)
235
- # _setfile(fname)
236
- # raise "No such file '#{fname}' to process" unless File.exist?(fname)
237
- # @main.output = StringIO.new
238
- # enum = File.readlines(fname).each
239
- # @backtrace = backtrace
240
- # @main.source(enum, fname, 0)
241
- # loop do
242
- # line = @main.nextline
243
- # break if line.nil?
244
- # process_line(line)
245
- # end
246
- # @main.finalize if @main.respond_to? :finalize
247
- # end
248
-
249
200
  def handle_scomment(line)
250
201
  end
251
202
 
@@ -265,7 +216,7 @@ end
265
216
 
266
217
  def handle_dotcmd(line, indent = 0)
267
218
  indent = @indentation.last # top of stack
268
- line = line.sub(/# .*$/, "")
219
+ line = line.sub(/# .*$/, "")
269
220
  name = _get_name(line).to_sym
270
221
  result = nil
271
222
  if @main.respond_to?(name)
@@ -472,6 +472,11 @@ EOS
472
472
  _out "</table></center>"
473
473
  end
474
474
 
475
+ def image
476
+ name = @_args[0]
477
+ _out "<img src='#{name}'></img>"
478
+ end
479
+
475
480
  def br
476
481
  n = _args.first || "1"
477
482
  out = ""
@@ -27,6 +27,10 @@ module Livetext::UserAPI
27
27
  end
28
28
  end
29
29
 
30
+ def _vars
31
+ @_vars.dup
32
+ end
33
+
30
34
  def _optional_blank_line
31
35
  peek = peek_nextline
32
36
  return if peek.nil?
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.03
4
+ version: 0.9.04
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-01-28 00:00:00.000000000 Z
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com