livetext 0.8.7 → 0.8.8

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: 5f41e0046b52fb9ac065abe45a4a7cc1b696420a
4
- data.tar.gz: 344de25c408e734970d273a467165d8d89a3eb51
3
+ metadata.gz: 3c91ce7a249cbd6ed27e1f538022a9e3fbc6d435
4
+ data.tar.gz: 99a2002ac810d323423651ebcd9a0a9964ccb12a
5
5
  SHA512:
6
- metadata.gz: a2155f28a062c3ccfa9e0e10b56eb451e2c78c450f2e4482f125d63fd31de2a5276725f78836108e08168ece87ddcb5de1deeb9e57f3c83bb845af57fcdffd3b
7
- data.tar.gz: 1bab0cfb96ee87c6e1dab271c6e74cabb3cdb3f94a14527ec1aa24ecdce1f73efe74c34af50319fb7fd9e9a29646ca456d4127ae8a9972f97478dd3f146107aa
6
+ metadata.gz: 6c7f6358e3f32cd1a5e2cf0e7fb915a6eca1add56f4cbbeee43c51f929a134d66fc8ff34aaeb80df22f4b900d8d9fe0501c9593bfcb36acf1983b4dd53ee62c3
7
+ data.tar.gz: 9e4074bc5af1c26d961852dd057bf63e10b6d3d0a334095644bac488e02d715d2c8cda4551593da9c394c5997c709b03b084d8422ae8a78286bda6b4328f146b
data/bin/livetext CHANGED
@@ -12,31 +12,37 @@ end
12
12
 
13
13
  x = Livetext.new
14
14
 
15
- case ARGV.first
16
- when "-v", "--version"
17
- puts "#{Livetext::VERSION}\n "
18
- when "-t", "--test" # FIXME doesn't work - path problem
19
- puts "bin: pwd = #{Dir.pwd}"
20
- puts "bin: path = #{Path}"
21
- file = "#{Path}/../test/test.rb"
22
- cmd = "ruby #{file} cmdline"
23
- puts cmd
24
- system(cmd)
25
- when "--path"
26
- puts Path
27
- when "-s", "--stdin"
28
- src = STDIN.read
29
- x.process(src)
30
- when nil
31
- puts <<-EOF
32
- Usage:
33
- livetext -v
34
- livetext --version
35
- livetext filename
36
- EOF
37
- puts
38
- when Object
39
- src = ARGV.first
40
- x.process_file(src)
41
- end
15
+ @backtrace = false
16
+
17
+ loop do
18
+ arg = ARGV.shift
19
+ break if arg.nil?
42
20
 
21
+ case arg
22
+ when "-v", "--version"
23
+ puts "#{Livetext::VERSION}\n "
24
+ when "-t", "--test" # FIXME doesn't work - path problem
25
+ file = "#{Path}/../test/test.rb"
26
+ flag = @backtrace ? "-back" : ""
27
+ cmd = "ruby #{file} cmdline#{flag}"
28
+ puts cmd
29
+ system(cmd)
30
+ when "--path"
31
+ puts Path
32
+ when "--backtrace"
33
+ @backtrace = true
34
+ when "-s", "--stdin"
35
+ src = STDIN.read
36
+ x.process(src)
37
+ when nil
38
+ puts <<-EOF
39
+ Usage:
40
+ livetext -v
41
+ livetext --version
42
+ livetext filename
43
+ EOF
44
+ puts
45
+ when Object
46
+ x.process_file(arg, @backtrace)
47
+ end
48
+ end
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.8.7"
2
+ VERSION = "0.8.8"
3
3
  end
4
4
 
5
5
  require 'fileutils'
@@ -110,9 +110,10 @@ class Livetext
110
110
  end
111
111
  end
112
112
 
113
- def process_file(fname)
113
+ def process_file(fname, backtrace=false)
114
114
  raise "No such file '#{fname}' to process" unless File.exist?(fname)
115
115
  enum = File.readlines(fname).each
116
+ @backtrace = backtrace
116
117
  @main.source(enum, fname, 0)
117
118
  loop do
118
119
  line = @main.nextline
data/lib/standard.rb CHANGED
@@ -43,7 +43,7 @@ module Livetext::Standard
43
43
  _error! "Illegal name '#{funcname}'" if _disallowed?(funcname)
44
44
  func_def = <<-EOS
45
45
  def #{funcname}
46
- #{_body!}
46
+ #{_body_text}
47
47
  end
48
48
  EOS
49
49
  Livetext::Functions.class_eval func_def
@@ -142,7 +142,7 @@ module Livetext::Standard
142
142
  name = @_args[0]
143
143
  str = "def #{name}\n"
144
144
  raise "Illegal name '#{name}'" if _disallowed?(name)
145
- str += _body!
145
+ str += _raw_body!
146
146
  str += "end\n"
147
147
  eval str
148
148
  rescue => err
data/lib/userapi.rb CHANGED
@@ -67,7 +67,7 @@ module Livetext::UserAPI
67
67
  @line = nextline
68
68
  break if _end?(@line, sigil)
69
69
  next if _comment?(@line, sigil) # FIXME?
70
- lines << @line
70
+ lines << _formatting(@line)
71
71
  end
72
72
  _optional_blank_line
73
73
  if block_given?
@@ -79,10 +79,14 @@ module Livetext::UserAPI
79
79
  _error!("Expecting .end, found end of file")
80
80
  end
81
81
 
82
- def _body!(sigil=".")
82
+ def _body_text(sigil=".")
83
83
  _body(sigil).join("\n")
84
84
  end
85
85
 
86
+ def _raw_body!(sigil=".")
87
+ _raw_body(sigil).join("\n")
88
+ end
89
+
86
90
  def _handle_escapes(str, set)
87
91
  str = str.dup
88
92
  set.each_char do |ch|
@@ -1,3 +1,4 @@
1
+ .backtrace
1
2
  abc
2
3
  123
3
4
  .def foobar
@@ -1,5 +1,5 @@
1
1
  .def alpha
2
- text = _body.join
2
+ text = _body_text
3
3
  text.gsub!(/\n/, " ")
4
4
  words = text.split.sort
5
5
  words.each {|w| _puts " #{w}" }
@@ -3,7 +3,7 @@
3
3
  cols = "1" if cols == ""
4
4
  cols = cols.to_i
5
5
  raise "Columns must be 1-5" unless cols.between?(1,5)
6
- text = _body.join
6
+ text = _body_text
7
7
  text.gsub!(/\n/, " ")
8
8
  words = text.split.sort
9
9
  words.each_slice(cols) do |row|
data/test/test.rb CHANGED
@@ -58,9 +58,6 @@ class TestingLivetext < MiniTest::Test
58
58
  src, out, exp = "source.lt3", "/tmp/#{base}--actual-output.txt", "expected-output.txt"
59
59
  err, erx = "/tmp/#{base}--actual-error.txt", "expected-error.txt"
60
60
  cmd = "livetext #{src} >#{out} 2>#{err}"
61
- puts
62
- puts Dir.pwd
63
- puts cmd
64
61
  system(cmd)
65
62
  output, expected, errors, errexp = File.read(out), File.read(exp), File.read(err), File.read(erx)
66
63
 
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.7
4
+ version: 0.8.8
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-04-10 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com