livetext 0.9.42 → 0.9.44

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: 3cef25ba4a47577159b300d63d723939aef6e5bef6c083685d8f6539e988601e
4
- data.tar.gz: a20a3a5e09c47639180428833a62c855a0a13d26ec317b49a3e400b9f0b4a64c
3
+ metadata.gz: 77c132b3f86809adfbbed149564227c061911a51bc57124fdd17ed9fb67bae55
4
+ data.tar.gz: dc92358a343e8096f7e982005585fa9633d8860f6fe569e0db61bc40a764bd73
5
5
  SHA512:
6
- metadata.gz: b4ddc892156911f77e9bd4b3878e77ddfba0d739b03c5df0fbeefb1b22562c03f173ffdc36fceff940273557a27c12cec0a4aea3a35a5470efdfd5ec360f0261
7
- data.tar.gz: f222133e7b2e784e15b43241e711e29bad362c10f41857e1e72883aac95d523580127a50a146a5b539e266eea98067e094b6dc3b1490e6b8a2d1b88c1a813b08
6
+ metadata.gz: e8ec2c7c373c5587c1a492c0cd183bb6143c16a59ed49084fcc11294ed48e05c3e076ad48f03de56a5b60f2bad828629f54c086e51b8785e4eb6b39b6366bb7f
7
+ data.tar.gz: e129c8269d51269f635b4a4995abe568cdbd0b1aa61060986ffa34528157d79ae4a455a88d309010085928d8897204fadff094f79a94bb0d89aa9a83edd4903d
@@ -15,4 +15,4 @@ end
15
15
 
16
16
  make_exception(:EndWithoutOpening, "Error: found .end with no opening command")
17
17
  make_exception(:UnknownMethod, "Error: name '%1' is unknown")
18
-
18
+ make_exception(:NoSuchFile, "Error: can't find file '%1' (method '%2')")
@@ -179,27 +179,69 @@ module Livetext::Standard
179
179
  api.optional_blank_line
180
180
  end
181
181
 
182
+ =begin
183
+ Filename: foobar
184
+ get_globals - 1 - transforming /private/tmp/.blogs/views/foobar/data/global.lt3
185
+
186
+ >> variables: fdir = /private/tmp/.blogs/views/foobar/data/
187
+ fname = ../settings/view.txt
188
+ path = /private/tmp/.blogs/views/foobar/data/../settings/view.txt
189
+
190
+ rpath = /private/tmp/.blogs/views/foobar/settings/view.txt
191
+ path = /private/tmp/.blogs/views/foobar/settings/view.txt
192
+ dir = /private/tmp/.blogs/views/foobar/settings
193
+ base = view.txt
194
+
195
+ >> variables: fdir = /private/tmp/.blogs/views/foobar/data/
196
+ fname = ../settings/recent.txt
197
+ path = /private/tmp/.blogs/views/foobar/data/../settings/recent.txt
198
+ rpath = /private/tmp/.blogs/views/foobar/settings/recent.txt
199
+ path = /private/tmp/.blogs/views/foobar/settings/recent.txt
200
+ dir = /private/tmp/.blogs/views/foobar/settings
201
+ base = recent.txt
202
+
203
+ >> variables: fdir = /private/tmp/.blogs/views/foobar/data/
204
+ fname = ../settings/publish.txt
205
+ path = /private/tmp/.blogs/views/foobar/data/../settings/publish.txt
206
+ rpath = /private/tmp/.blogs/views/foobar/settings/publish.txt
207
+ path = /private/tmp/.blogs/views/foobar/settings/publish.txt
208
+ dir = /private/tmp/.blogs/views/foobar/settings
209
+ base = publish.txt
210
+
211
+ get_globals - 2
212
+
213
+ =end
214
+
182
215
  def variables(args = nil, body = nil)
183
216
  prefix = api.args[0]
184
- file = api.args[1]
185
- puts ">> variables: pre=#{prefix.inspect} file=#{file.inspect} pwd=#{Dir.pwd}"
217
+ fname = api.args[1]
186
218
  prefix = nil if prefix == "-" # FIXME dumb hack
187
- here = File.dirname(file)
188
- dok, fok = Dir.exist?(here), File.exist?(file)
189
- raise "No such dir #{here.inspect} (file #{file})" unless dok
190
- raise "No such file #{file.inspect} (file #{file})" unless fok
191
- if file
192
- here = ::Livetext::Vars[:FileDir] + "/"
193
- lines = File.readlines(here + file)
219
+ fdir = ::Livetext::Vars[:FileDir] + "/" # where is the file we are reading?
220
+ if fname
221
+ path0 = fdir + fname
222
+ # puts ">> variables: fdir = #{fdir} fname = #{fname} path = #{path0}"
223
+ pname = Pathname.new(path0)
224
+ rpath = pname.realpath(pname)
225
+ path, dir, base = rpath.to_s, rpath.dirname.to_s, rpath.basename.to_s
226
+ # puts " rpath = #{rpath} path = #{path} dir = #{dir} base = #{base}"
227
+ dok, fok = Dir.exist?(dir), File.exist?(path)
228
+ raise "No such dir #{dir.inspect} (file #{path})" unless dok
229
+ raise "No such file #{path.inspect} (file #{path})" unless fok
230
+ lines = File.readlines(path)
194
231
  else
195
232
  lines = api.body
196
233
  end
197
234
  pairs = Livetext::ParseGeneral.parse_vars(lines, prefix: nil)
198
235
  api.setvars(pairs)
199
236
  api.optional_blank_line
200
- rescue => e
201
- puts e
202
- puts $!
237
+ rescue => err
238
+ puts "Error in #{__method__} in #{__FILE__}
239
+ puts " #{err.inspect}"
240
+ if err.respond_to?(:backtrace)
241
+ context = err.backtrace.map {|x| " " + x}.join("\n")
242
+ puts context
243
+ end
244
+ abort "\nTerminated."
203
245
  end
204
246
 
205
247
  def heredoc(args = nil, body = nil)
@@ -416,6 +458,36 @@ puts ">> variables: pre=#{prefix.inspect} file=#{file.inspect} pwd=#{Dir.pwd}"
416
458
  api.optional_blank_line
417
459
  end
418
460
 
461
+ def table(args = nil, body = nil) # Same as xtable
462
+ title = api.data
463
+ delim = " :: "
464
+ api.out "<br>\n\n<center><table width=90% cellpadding=5>"
465
+ lines = api.body(true)
466
+ maxw = nil
467
+ processed = []
468
+ lines.each do |line|
469
+ line = api.format(line)
470
+ line.gsub!(/\n+/, "<br>\n")
471
+ processed << line
472
+ cells = line.split(delim)
473
+ wide = cells.map {|cell| cell.length }
474
+ maxw = [0] * cells.size
475
+ maxw = maxw.map.with_index {|x, i| [x, wide[i]].max }
476
+ end
477
+
478
+ sum = maxw.inject(0, :+)
479
+ maxw.map! {|x| (x/sum*100).floor }
480
+
481
+ processed.each do |line|
482
+ cells = line.split(delim)
483
+ html.wrap :tr do
484
+ cells.each {|cell| api.out " <td valign=top>#{cell}</td>" }
485
+ end
486
+ end
487
+ api.out "</table></center>"
488
+ api.optional_blank_line
489
+ end
490
+
419
491
  def image(args = nil, body = nil)
420
492
  name, wide, high = api.args
421
493
  geom = ""
@@ -2,5 +2,5 @@
2
2
  # Defining VERSION
3
3
 
4
4
  class Livetext
5
- VERSION = "0.9.42"
5
+ VERSION = "0.9.44"
6
6
  end
data/plugin/booktool.rb CHANGED
@@ -4,21 +4,22 @@ def mobi(args = nil, body = nil)
4
4
  out = api.format(api.args[0])
5
5
  src = api.args[1]
6
6
  @cover = api.args[2]
7
+ @name = api.args[3]
7
8
  if ::File.directory?(src)
8
9
  files = ::Dir["#{src}/*"].grep /\.html$/
9
10
  files = files.sort # why is this necessary now?
10
- cmd = "cat #{files.join(' ')} >TEMP.html"
11
+ cmd = "cat #{files.join(' ')} >#@name.html"
11
12
  system(cmd)
12
13
  else
13
14
  raise "Not supported yet"
14
15
  end
15
16
 
16
17
  cmd = "ebook-convert "
17
- cmd << "TEMP.html #{out}.mobi "
18
+ cmd << "#@name.html #{out}.mobi "
18
19
  cmd << "--cover #@cover " if @cover
19
20
  system(cmd)
20
21
 
21
- system("links -dump TEMP.html >/tmp/links.out")
22
+ system("links -dump #@name.html >/tmp/links.out")
22
23
  str = `wc -w /tmp/links.out`
23
24
  nw = str.split[0]
24
25
  end
@@ -27,21 +28,22 @@ def epub(args = nil, body = nil)
27
28
  out = api.format(api.args[0])
28
29
  src = api.args[1]
29
30
  @cover = api.args[2]
31
+ @name = api.args[3]
30
32
  if ::File.directory?(src)
31
33
  files = ::Dir["#{src}/*"].grep /\.html$/
32
34
  files = files.sort # why is this necessary now?
33
- cmd = "cat #{files.join(' ')} >TEMP.html"
35
+ cmd = "cat #{files.join(' ')} >#@name.html"
34
36
  system(cmd)
35
37
  else
36
38
  raise "Not supported yet"
37
39
  end
38
40
 
39
41
  cmd = "ebook-convert "
40
- cmd << "TEMP.html #{out}.epub "
42
+ cmd << "#@name.html #{out}.epub "
41
43
  cmd << "--cover #@cover " if @cover
42
44
  system(cmd)
43
45
 
44
- system("links -dump TEMP.html >/tmp/links.out")
46
+ system("links -dump #@name.html >/tmp/links.out")
45
47
  str = `wc -w /tmp/links.out`
46
48
  nw = str.split[0]
47
49
  puts "Approx words: #{nw}"
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require 'livetext'
4
6
 
5
7
  # Just another testing class. Chill.
data/test/extra/double.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require 'livetext'
4
6
 
5
7
  # Just another testing class. Chill.
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require 'livetext'
4
6
 
5
7
  # Just another testing class. Chill.
data/test/extra/single.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require 'livetext'
4
6
 
5
7
  # Just another testing class. Chill.
@@ -41,6 +41,8 @@ end
41
41
  output.puts <<~RUBY
42
42
  require 'minitest/autorun'
43
43
 
44
+ MiniTest = Minitest unless defined?(MiniTest)
45
+
44
46
  require 'livetext'
45
47
 
46
48
  # Just another testing class. Chill.
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require 'livetext'
4
6
 
5
7
  # Just another testing class. Chill.
data/test/snapshots.rb CHANGED
@@ -9,6 +9,8 @@ end
9
9
 
10
10
  require 'minitest/autorun'
11
11
 
12
+ MiniTest = Minitest unless defined?(MiniTest)
13
+
12
14
  require_relative '../lib/livetext'
13
15
 
14
16
  =begin
data/test/unit/html.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require 'livetext'
4
6
 
5
7
  class TestingLivetext < MiniTest::Test
@@ -1,6 +1,8 @@
1
1
 
2
2
  require 'minitest/autorun'
3
3
 
4
+ MiniTest = Minitest unless defined?(MiniTest)
5
+
4
6
  require_relative '../parser' # nested
5
7
 
6
8
  ParseGeneral = ::Livetext::ParseGeneral
@@ -1,6 +1,8 @@
1
1
 
2
2
  require 'minitest/autorun'
3
3
 
4
+ MiniTest = Minitest unless defined?(MiniTest)
5
+
4
6
  require_relative '../parser' # nested
5
7
 
6
8
  class TestParseSet < MiniTest::Test
@@ -1,6 +1,8 @@
1
1
 
2
2
  require 'minitest/autorun'
3
3
 
4
+ MiniTest = Minitest unless defined?(MiniTest)
5
+
4
6
  require_relative '../parser' # nested
5
7
 
6
8
  ParseSet = ::Livetext::ParseSet
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require_relative '../parser' # nested
4
6
 
5
7
  class TestStringParser < MiniTest::Test
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest
4
+
3
5
  require_relative '../../lib/livetext'
4
6
 
5
7
  class TestingLivetext < MiniTest::Test
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
 
3
+ MiniTest = Minitest unless defined?(MiniTest)
4
+
3
5
  require_relative '../../lib/stringparser'
4
6
 
5
7
  class TestStringParser < MiniTest::Test
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.42
4
+ version: 0.9.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-10 00:00:00.000000000 Z
11
+ date: 2024-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com