livetext 0.8.25 → 0.8.26

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
  SHA1:
3
- metadata.gz: b361038930421fd67a403b32b0f2f5e511f6f35c
4
- data.tar.gz: c6769d374d3b981ef89193c31dd75f7869810ecb
3
+ metadata.gz: 32e86e25ebebcbf8fe7b16ae41d200f09acd4575
4
+ data.tar.gz: 9232fb4dc849f320b79d92a9b367842f3bd2564f
5
5
  SHA512:
6
- metadata.gz: 7a260fec5f64e897f2d7a09b162e8bf55ee76b6bb59982fa17f4724162746b2930224577c3a415ab6ee91e57586d360bf4c90bac3445c66c255a3f286c8adb62
7
- data.tar.gz: 7503dd3e8c18a9e22b758c0d691e9d91a6861f6414bc6e67dba2d03f8de0e8188c132208ec6405cb282b19a3900258e3b74aa5fa837f069df2a54d28b8f52387
6
+ metadata.gz: 67f94af5e205a02512ecb802f33a33be2fb8e6e2186febbbf2c23937357b4900c5a40098a52e7995326f5a3732792f9b64a5bc3aaf914c0c970673426b037915
7
+ data.tar.gz: 2635e5b110ea1b24e38dc0e8e83ea7fc20ae18baa258258ab67a3477aa9e9545a96056281ff97ebc9d5beaa3f7713e596db173e189655d1aa6c985bf445df0c3
data/dsl/liveblog.rb CHANGED
@@ -1,23 +1,37 @@
1
1
  require 'ostruct'
2
2
  require 'yaml'
3
+ require 'pp'
3
4
 
4
5
  require 'runeblog' # Now depends explicitly
5
6
 
6
7
  class ::Livetext::Functions # do this differently??
7
8
 
8
9
  def asset # FIXME this is baloney...
9
- param = Livetext::Functions.param
10
- puts "REACHED func_asset"
11
- text, name = param.split("|")
10
+ param = ::Livetext::Functions.param
11
+ context = ::Livetext::Functions.context
12
+ main = context.eval("@main") rescue "NO MAIN?"
13
+ @meta = main.instance_eval("@main.instance_eval { @meta }")
14
+ @config = main.instance_eval("@main.instance_eval { @config }")
15
+ @root = @config.root
16
+
17
+ text, name = param.split("|")
12
18
 
13
- # FIXME how should this work?
14
- # url = find_asset(name)
15
- url = name
16
- "<a href='#{url}'>#{text}</a>"
19
+ # FIXME how should this work?
20
+ view = ThisConfig.view
21
+ url = find_asset(name)
22
+ "<a href='#{url}'>#{text}</a>"
17
23
  end
18
24
 
19
25
  end
20
26
 
27
+
28
+ begin
29
+ ThisBlog
30
+ rescue
31
+ ThisBlog = RuneBlog.new
32
+ ThisConfig = ThisBlog.read_config
33
+ end
34
+
21
35
  ### find_asset
22
36
 
23
37
  def find_asset(asset)
@@ -46,23 +60,31 @@ end
46
60
  #############
47
61
 
48
62
  def init_liveblog
49
- @blog = RuneBlog.new
50
- @config = @blog.read_config
63
+ @blog = ThisBlog
64
+ @config = ThisConfig
51
65
  @root = @config.root
52
66
  @teaser = ""
53
67
  @body = ""
54
68
  @body = ""
55
69
  @meta = ::OpenStruct.new
70
+
71
+ @deploy ||= {}
72
+ @config.views.each do |view|
73
+ deployment = @config.viewdir(view) + "deploy"
74
+ raise "File '#{deployment}' not found" unless File.exist?(deployment)
75
+ lines = File.readlines(deployment).map {|x| x.chomp }
76
+ @deploy[view] = lines
77
+ end
56
78
  end
57
79
 
58
80
  def _errout(*args)
59
81
  ::STDERR.puts *args
60
82
  end
61
83
 
62
- def _passthru(line)
84
+ def _passthru(line, context = nil)
63
85
  return if line.nil?
64
86
  @body << "<p>" if line == "\n" and ! @_nopara
65
- line = _formatting(line)
87
+ line = _formatting(line, context)
66
88
  @body << line + "\n"
67
89
  end
68
90
 
@@ -87,7 +109,7 @@ end
87
109
 
88
110
  def views
89
111
  _debug "data = #{_args}"
90
- @meta.views = _args # + ["main"]
112
+ @meta.views = _args.dup # + ["main"]
91
113
  end
92
114
 
93
115
  def liveblog_version
@@ -118,13 +140,13 @@ def asset
118
140
  @meta.assets ||= {}
119
141
  list = _args
120
142
  list.each {|asset| @meta.assets[asset] = find_asset(asset) }
121
- STDERR.puts red("\n [DEBUG] ") + "Asset(s): #{@meta.assets}"
143
+ # STDERR.puts red("\n [DEBUG] ") + "Asset(s): #{@meta.assets}"
122
144
  end
123
145
 
124
146
  def assets
125
147
  @meta.assets ||= []
126
148
  @meta.assets += _body
127
- STDERR.puts red("\n [DEBUG] ") + "Assets: #{_body.inspect}"
149
+ # STDERR.puts red("\n [DEBUG] ") + "Assets: #{_body.inspect}"
128
150
  end
129
151
 
130
152
  def finalize
data/lib/formatline.rb CHANGED
@@ -49,7 +49,8 @@ class FormatLine
49
49
  self.send("func_" + name.to_s, param)
50
50
  else
51
51
  fobj = ::Livetext::Functions.new
52
- ::Livetext::Functions.param = param
52
+ ::Livetext::Functions.param = param # is this screwed up???
53
+ ::Livetext::Functions.context = @context # is this screwed up???
53
54
  fobj.send(name)
54
55
  end
55
56
  end
@@ -88,7 +89,9 @@ class FormatLine
88
89
  @substr = ""
89
90
  end
90
91
 
91
- def parse(line)
92
+ def parse(line, context = nil)
93
+ context ||= binding
94
+ @context = context
92
95
  @enum = line.chomp.each_char
93
96
  @buffer = ""
94
97
  @substr = ""
data/lib/functions.rb CHANGED
@@ -4,13 +4,10 @@ class Livetext::Functions # Functions will go here... user-def AND pre-def??
4
4
  Formats = ::Livetext::Standard::SimpleFormats
5
5
 
6
6
  @param = nil
7
+ @context = nil
7
8
 
8
- def self.param
9
- @param
10
- end
11
-
12
- def self.param=(str)
13
- @param = str
9
+ class << self
10
+ attr_accessor :param, :context
14
11
  end
15
12
 
16
13
  def date
data/lib/livetext.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  class Livetext
2
- VERSION = "0.8.25"
2
+ VERSION = "0.8.26"
3
3
  end
4
4
 
5
+ $Livetext = Livetext
6
+
5
7
  require 'fileutils'
6
8
 
7
9
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
@@ -20,7 +22,7 @@ TTY = ::File.open("/dev/tty", "w")
20
22
  class Livetext
21
23
  Vars = {}
22
24
 
23
- attr_reader :main
25
+ attr_reader :main, :context
24
26
 
25
27
  class Processor
26
28
  include Livetext::Standard
@@ -54,6 +56,7 @@ class Livetext
54
56
  def _error!(err, abort=true, trace=false)
55
57
  where = @sources.last || @save_location
56
58
  STDERR.puts "Error: #{err} (at #{where[1]} line #{where[2]})"
59
+ STDERR.puts err.backtrace
57
60
  STDERR.puts err.backtrace if @backtrace && err.respond_to?(:backtrace)
58
61
  exit if abort
59
62
  end
@@ -100,7 +103,10 @@ class Livetext
100
103
  @main = Processor.new(self, output)
101
104
  end
102
105
 
103
- def process_line(line, sigil=".")
106
+ def process_line(line, context=nil)
107
+ context ||= binding
108
+ @context = context
109
+ sigil = "." # Can't change yet
104
110
  nomarkup = true
105
111
  # FIXME inefficient
106
112
  scomment = rx(sigil, Livetext::Space) # apply these in order
@@ -110,19 +116,21 @@ class Livetext
110
116
  elsif line =~ sname
111
117
  handle_sname(line)
112
118
  else
113
- @main._passthru(line)
119
+ @main._passthru(line, context)
114
120
  end
115
121
  end
116
122
 
117
- def process_file(fname, backtrace=false)
123
+ def process_file(fname, context=nil)
124
+ context ||= binding
125
+ @context = context
118
126
  raise "No such file '#{fname}' to process" unless File.exist?(fname)
119
127
  enum = File.readlines(fname).each
120
- @backtrace = backtrace
128
+ @backtrace = false
121
129
  @main.source(enum, fname, 0)
122
130
  loop do
123
131
  line = @main.nextline
124
132
  break if line.nil?
125
- process_line(line)
133
+ process_line(line, context)
126
134
  end
127
135
  val = @main.finalize if @main.respond_to? :finalize
128
136
  val
data/lib/userapi.rb CHANGED
@@ -4,8 +4,6 @@ require 'formatline'
4
4
 
5
5
  module Livetext::UserAPI
6
6
 
7
- Parser = ::FormatLine.new
8
-
9
7
  def _check_existence(file, msg)
10
8
  _error! msg unless File.exist?(file)
11
9
  end
@@ -99,15 +97,18 @@ module Livetext::UserAPI
99
97
  str
100
98
  end
101
99
 
102
- def _formatting(line)
103
- l2 = Parser.parse(line)
100
+ def _formatting(line, context = nil)
101
+ @parser ||= ::FormatLine.new
102
+ l2 = @parser.parse(line, context)
104
103
  line.replace(l2)
105
104
  end
106
105
 
107
- def _passthru(line)
106
+ def _passthru(line, context = nil)
108
107
  return if @_nopass
108
+ # p [@_nopara, line]
109
109
  _puts "<p>" if line == "\n" and ! @_nopara
110
- _formatting(line)
110
+ # _puts "<p>" if line == "" and ! @_nopara
111
+ _formatting(line, context)
111
112
  _puts line
112
113
  end
113
114
 
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.25
4
+ version: 0.8.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-20 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com
@@ -148,8 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.2.2
151
+ rubygems_version: 2.4.2
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: A smart processor for text
155
155
  test_files: []
156
+ has_rdoc: