lib/helpers.rb in livetext-0.9.22 vs lib/helpers.rb in livetext-0.9.23

- old
+ new

@@ -1,8 +1,10 @@ +# p __FILE__ -module Helpers +module Livetext::Helpers + Space = " " Sigil = "." # Can't change yet ESCAPING = { "'" => '&#39;', '&' => '&amp;', '"' => '&quot;', '<' => '&lt;', '>' => '&gt;' } @@ -21,12 +23,14 @@ return string end string.gsub(/['&\"<>]/, ESCAPING) end - def find_file(name, ext=".rb") - paths = [Livetext::Path.sub(/lib/, "imports/"), "./"] + def find_file(name, ext=".rb", which="imports") + failed = "#{__method__}: expected 'imports' or 'plugin'" + raise failed unless %w[imports plugin].include?(which) + paths = [Livetext::Path.sub(/lib/, "#{which}/"), "./"] base = "#{name}#{ext}" paths.each do |path| file = path + base return file if File.exist?(file) end @@ -59,10 +63,14 @@ line = @main.nextline break if line.nil? process_line(line) end val = @main.finalize rescue nil - @body + @body # FIXME? @body.join("\n") # array + rescue StandardError => err +# TTY.puts ">>> rescue in process_file!! (helpers)" +# TTY.puts @body + raise err end def process_line(line) nomarkup = true case line # must apply these in order