lib/livetext/userapi.rb in livetext-0.9.42 vs lib/livetext/userapi.rb in livetext-0.9.49
- old
+ new
@@ -2,44 +2,52 @@
require_relative 'html'
# Encapsulate the UserAPI as a class
class Livetext::UserAPI
+ include ::Livetext::Standard # FIXME - feels wonky?
- include ::Livetext::Standard
-
KBD = File.new("/dev/tty", "r")
TTY = File.new("/dev/tty", "w")
DotSpace = ". " # Livetext::Sigil + Livetext::Space
attr_accessor :data, :args
- def initialize(live)
+ def initialize(live) # Livetext::UserAPI
@live = live
+ @parent = live # FIXME experiment related to runeblog error
@vars = live.vars
- @html = HTML.new(self)
+ @html = Livetext::HTML.new(self)
@expander = Livetext::Expansion.new(live)
end
def api
@live.api
end
+ def dump(file = nil) # not a dot command!
+ file ||= ::STDOUT
+ # TTY.puts "--- Writing body (#{@live.body.size} bytes)"
+ file.puts @live.body
+ rescue => err
+ TTY.puts "#dump had an error: #{err.inspect}"
+ end
+
def html
@html
end
def dot
@live
end
def include_file(file)
+# checkpoint "DATA = #{file.inspect}"
api.data = file
api.args = [file]
-STDERR.puts "incfile: #{api.methods.sort.inspect}\n "
- api.dot_include
+ dot_include
end
def expand_variables(str)
@expander.expand_variables(str)
end
@@ -189,22 +197,23 @@
def err(*args)
STDERR.puts *args
end
def puts(*args)
- @live.output.puts *args
+ # @live.output.puts *args
+ @live.api.out *args
end
def print(*args)
- @live.output.print *args
+ # @live.output.print *args
+ @live.api.out! *args
end
def debug=(val)
@live.debug = val
end
def debug(*args)
TTY.puts *args if @live.debug
end
-
end