livetext 0.6.4 → 0.6.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/dsl/bookish.rb +0 -1
  3. data/lib/livetext.rb +52 -58
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d23c90a2364289b4f5e720e6ac84130cefec64d8
4
- data.tar.gz: cf627678cb3d385bc352af8e21e694ad2e05eaf6
3
+ metadata.gz: 7f706dc4d367cb931a999a1ba4918fbb46981a57
4
+ data.tar.gz: 5c0d148218f148c2f8e99877b8d331e3385bbfef
5
5
  SHA512:
6
- metadata.gz: 82dfce10e7c156429f18d819568287e0d4b5df8a24689b0d3cc6db9db9040fb24c7e4a5e660b2ea64be6f6986fbf6da9dc7c9faadfb5bfef9b1fc77d368bb2b7
7
- data.tar.gz: a17be3a281be93c67cf919467a002e5fe616bc33712f695552f5d34e38fbd6681d716f0f4828b759f11e6c7f11376a55ed9ab650646e2a7bc138cd7f544f4986
6
+ metadata.gz: c0e6c42f2b8a91c4d2fce8e03e0bba6f1ad60afd82edb0323566b45b48088b11b381655213c2ff969e8b6f2c73e2d16951d0429f410aee712e6bd09a016ce415
7
+ data.tar.gz: 6d9e96b0d091dfbc94bcdea217305aff01bc230c43c44f0b2e1cbd509b00b83a130dd97d7f36b30907af0be2b871a441260c1060a8b475e43f68e8e30126550c
data/dsl/bookish.rb CHANGED
@@ -1,4 +1,3 @@
1
- # noinspection RubyQuotedStringsInspection
2
1
  def hardbreaks
3
2
  @hard = false
4
3
  @hard = true unless @_args.first == "off"
data/lib/livetext.rb CHANGED
@@ -15,7 +15,7 @@ class Enumerator
15
15
  end
16
16
 
17
17
  class Livetext
18
- VERSION = "0.6.4"
18
+ VERSION = "0.6.5"
19
19
 
20
20
  Space = " "
21
21
 
@@ -42,13 +42,9 @@ class Livetext
42
42
  scomment = rx(sigil, Livetext::Space) # apply these in order
43
43
  sname = rx(sigil)
44
44
  case
45
- when line =~ scomment
46
- handle_scomment(sigil, line)
47
- when line =~ sname
48
- handle_sname(sigil, line)
49
- else
50
- obj = @main # Livetext::Objects[sigil]
51
- obj._passthru(line)
45
+ when line =~ scomment; handle_scomment(sigil, line)
46
+ when line =~ sname; handle_sname(sigil, line)
47
+ else @main._passthru(line)
52
48
  end
53
49
  end
54
50
 
@@ -60,7 +56,7 @@ class Livetext
60
56
  end
61
57
  source = file.each_line
62
58
  @main = Livetext::System.new(source)
63
- @main._pushfile(fname)
59
+ # @main._switch_file(fname)
64
60
  @main.file = fname
65
61
  @main.lnum = 0
66
62
 
@@ -87,34 +83,32 @@ class Livetext
87
83
  Livetext::Disallowed.include?(name.to_sym)
88
84
  end
89
85
 
90
- def self._get_name(obj, sigil, line)
86
+ def self._get_name(sigil, line)
91
87
  blank = line.index(" ") || line.index("\n")
92
88
  name = line[1..(blank-1)]
93
- abort "#{obj.where}: Name '#{name}' is not permitted" if _disallowed?(name)
94
- obj._data = line[(blank+1)..-1]
89
+ abort "#{@main.where}: Name '#{name}' is not permitted" if _disallowed?(name)
90
+ @main._data = line[(blank+1)..-1]
95
91
  name = "_def" if name == "def"
96
92
  name = "_include" if name == "include"
97
- abort "#{obj.where}: mismatched 'end'" if name == "end"
93
+ abort "#{@main.where}: mismatched 'end'" if name == "end"
98
94
  name
99
95
  end
100
96
 
101
97
  def self.handle_sname(sigil, line)
102
- obj = @main # Livetext::Objects[sigil]
103
- name = _get_name(obj, sigil, line)
104
- # unless obj.respond_to?(name)
105
- # abort "#{obj.where}: '#{name}' is unknown"
106
- # return
107
- # end
108
-
109
- if name == "notes" # FIXME wtf
110
- obj.notes
111
- else
112
- obj.send(name)
98
+ name = _get_name(sigil, line)
99
+ unless @main.respond_to?(name)
100
+ raise "'#{name}' is unknown"
101
+ return
113
102
  end
103
+
104
+ @main.send(name)
105
+
114
106
  rescue => err
115
- STDERR.puts "ERROR on #{obj.file} line #{obj.lnum} : #{err}"
116
- STDERR.puts " self = #{self.inspect} ivars = #{self.class.instance_variables}"
107
+ STDERR.puts "ERROR on #{@main.file} line #{@main.lnum} : #{err}"
108
+ # STDERR.puts " self = #{self.inspect} @main = #{@main.inspect}"
109
+ STDERR.puts " sources = #{@main.source_files.inspect}"
117
110
  STDERR.puts err.backtrace
111
+ STDERR.puts "--- Methods = #{(@main.methods - Object.methods).sort}\n "
118
112
  end
119
113
 
120
114
  end
@@ -463,10 +457,12 @@ module Livetext::Standard
463
457
  _optional_blank_line
464
458
  end
465
459
 
466
- def _pushfile(fname)
460
+ def _switch_file(fname)
461
+ ::STDERR.puts " switching to #{fname}, pushing #@file"
467
462
  @source_files ||= []
468
463
  @source_files.push(@file)
469
464
  @file = fname
465
+ ::STDERR.puts " sources = #{@source_files.inspect}"
470
466
  @file
471
467
  end
472
468
 
@@ -477,7 +473,7 @@ module Livetext::Standard
477
473
  def _include
478
474
  file = _args.first
479
475
  lines = ::File.readlines(file)
480
- _pushfile(file)
476
+ _switch_file(file)
481
477
  # STDERR.puts "_include: ****** Set @file = #@file"
482
478
  lines.each {|line| _debug " inc: #{line}" }
483
479
  rem = @input.remaining
@@ -489,7 +485,7 @@ module Livetext::Standard
489
485
 
490
486
  def include!
491
487
  file = _args.first
492
- _pushfile
488
+ _switch_file(file)
493
489
  existing = File.exist?(file)
494
490
  return if not existing
495
491
  lines = ::File.readlines(file)
@@ -510,14 +506,12 @@ module Livetext::Standard
510
506
  _check_existence(file)
511
507
 
512
508
  @_mixins << file
513
- _pushfile(file)
514
- newmod = Livetext.main
515
- newmod.extend(::Kernel)
516
- newmod.extend(::Livetext::Standard)
517
- newmod.extend(::Livetext::Helpers)
518
- $mods << newmod
519
- Object.const_set(name.capitalize, newmod)
520
- newmod.instance_eval(File.read(file))
509
+ _switch_file(file)
510
+ modname = name.capitalize
511
+ string = "module ::#{modname}\n" + File.read(file) + "\nend"
512
+ eval(string)
513
+ newmod = Object.const_get("::" + modname)
514
+ Livetext.main.extend(newmod) # CRAP
521
515
  init = "init_#{name}"
522
516
  self.send(init) if self.respond_to? init
523
517
  _optional_blank_line
@@ -532,7 +526,7 @@ module Livetext::Standard
532
526
  raise "No such file: #{name}.rb found" unless File.exist?(file)
533
527
 
534
528
  @_mixins << file
535
- _pushfile(file)
529
+ _switch_file(file)
536
530
  main = Livetext.main
537
531
  m0 = main.methods.reject {|x| x.to_s[0] == "_" }
538
532
  self.class.class_eval(::File.read(file))
@@ -546,7 +540,7 @@ module Livetext::Standard
546
540
 
547
541
  def copy
548
542
  file = _args.first
549
- _pushfile(file)
543
+ _switch_file(file)
550
544
  text = ::File.readlines(file)
551
545
  @output.puts text
552
546
  _optional_blank_line
@@ -590,9 +584,7 @@ module Livetext::Standard
590
584
  delim = "~~"
591
585
  _puts "<table>"
592
586
  _body do |line|
593
- # TTY.puts "Line = #{line}"
594
587
  line = _formatting(line)
595
- # TTY.puts "Line = #{line}\n "
596
588
  term, defn = line.split(delim)
597
589
  _puts "<tr>"
598
590
  _puts "<td width=3%><td width=10%>#{term}</td><td>#{defn}</td>"
@@ -608,18 +600,19 @@ class Livetext
608
600
  end
609
601
 
610
602
 
611
- class Livetext::System < BasicObject
603
+ class Livetext::System # < BasicObject
612
604
  include ::Kernel
613
605
  include ::Livetext::Helpers
614
606
  include ::Livetext::Standard
615
607
 
616
- attr_accessor :file, :lnum
608
+ attr_accessor :file, :lnum, :source_files
617
609
 
618
610
  def initialize(input = ::STDIN, output = ::STDOUT)
619
611
  @input = input
620
612
  @output = output
621
613
  @vars = {}
622
614
  @_mixins = []
615
+ @source_files = []
623
616
  @_outdir = "."
624
617
  @_file_num = 0
625
618
  @_nopass = false
@@ -632,22 +625,23 @@ class Livetext::System < BasicObject
632
625
  "Line #@lnum of #@file"
633
626
  end
634
627
 
635
- def method_missing(name, *args)
636
- name = "_def" if name == "def"
637
- name = "_include" if name == "include"
638
- $mods.reverse.each do |mod|
639
- if mod.respond_to?(name)
640
- mod.send(name, *args)
641
- return
642
- end
643
- end
644
- _puts " Error: Method '#{name}' is not defined."
645
- puts caller.map {|x| " " + x }
646
- exit
647
- end
648
- end
628
+ # def method_missing(name, *args)
629
+ # ::TTY.puts "MM: #{name}"
630
+ # name = "_def" if name.to_s == "def"
631
+ # name = "_include" if name.to_s == "include"
632
+ # @main.send(name, *args)
633
+ # # $mods.reverse.each do |mod|
634
+ # # if mod.respond_to?(name)
635
+ # # mod.send(name, *args)
636
+ # # return
637
+ # # end
638
+ # # end
639
+ # _puts " Error: Method '#{name}' is not defined (from method_missing)"
640
+ # puts caller.map {|x| " " + x }
641
+ # exit
642
+ # end
649
643
 
650
- $mods = []
644
+ end
651
645
 
652
646
  if $0 == __FILE__
653
647
  Livetext.handle_file(ARGV[0] || STDIN)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livetext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton