livetext 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f3a2e314692e74bb6300763aa877f977a8f472d
4
- data.tar.gz: b2d7d0aed5b79c3f9bfbb2b3d88063a590918a9a
3
+ metadata.gz: db1c4c67b59a4f9386d624c09e3ba3bd0a1f4ed7
4
+ data.tar.gz: 9d36cfe4d798dfb355d45dc024e2f38a41572d7c
5
5
  SHA512:
6
- metadata.gz: 6663cc36b63cb7b8cd0a0b6f74e3eca5ac03c670f993fa136ae5f7ebb25c3c9fca44ac2b731489b0a764f84efe015f7887d5d4f1ac064b57a0b265b8e4d3dbda
7
- data.tar.gz: 836148c5e892d5e06303b5cf376bc7009de7c040ef022f532bb1993fa2ec3de9e186698d6441da634ae73b3154495d3b97172d002b131ecb7c1f382879b6754c
6
+ metadata.gz: f46d91a2cb182faf39f1e5b129bf56c94773c5fa9448074899eb4a02707521224bb02923fba6198bd4dd4c49d00fabef39fe343bfe43df416beeded4ea280c17
7
+ data.tar.gz: 791b5256347e641ffdd378e566bf06affcdb3844ee7557555865606ecbcabfd1dbb640086233b64b054d1e4a662fb942795fe19926d81c05b9328b272daae7ca
data/lib/livetext.rb CHANGED
@@ -4,7 +4,7 @@ Plugins = File.expand_path(File.join(File.dirname(__FILE__), "../dsl"))
4
4
 
5
5
  TTY = ::File.open("/dev/tty", "w")
6
6
 
7
- require_relative "./pyggish"
7
+ require_relative "#{Plugins}/pyggish"
8
8
 
9
9
  class Enumerator
10
10
  def remaining
@@ -15,14 +15,10 @@ class Enumerator
15
15
  end
16
16
 
17
17
  class Livetext
18
- VERSION = "0.5.8"
18
+ VERSION = "0.5.9"
19
19
 
20
- MainSigil = "."
21
- Sigils = [MainSigil]
22
20
  Space = " "
23
21
 
24
- Objects = { MainSigil => nil }
25
-
26
22
  Disallowed = [:_data=, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>,
27
23
  :class, :singleton_class, :clone, :dup, :taint, :tainted?,
28
24
  :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?,
@@ -42,18 +38,17 @@ class Livetext
42
38
 
43
39
  def self.handle_line(line)
44
40
  nomarkup = true
45
- Livetext::Sigils.each do |sigil|
46
- scomment = rx(sigil, Livetext::Space) # apply these in order
47
- sname = rx(sigil)
48
- case
49
- when line =~ scomment
50
- handle_scomment(sigil, line)
51
- when line =~ sname
52
- handle_sname(sigil, line)
53
- else
54
- obj = Livetext::Objects[sigil]
55
- obj._passthru(line)
56
- end
41
+ sigil = "."
42
+ scomment = rx(sigil, Livetext::Space) # apply these in order
43
+ sname = rx(sigil)
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)
57
52
  end
58
53
  end
59
54
 
@@ -64,7 +59,7 @@ class Livetext
64
59
  file = File.new(fname)
65
60
  end
66
61
  source = file.each_line
67
- @main = Livetext::Objects[Livetext::MainSigil] = Livetext::System.new(source)
62
+ @main = Livetext::System.new(source)
68
63
  @main._pushfile(fname)
69
64
  @main.file = fname
70
65
  @main.lnum = 0
@@ -104,7 +99,7 @@ class Livetext
104
99
  end
105
100
 
106
101
  def self.handle_sname(sigil, line)
107
- obj = Livetext::Objects[sigil]
102
+ obj = @main # Livetext::Objects[sigil]
108
103
  name = _get_name(obj, sigil, line)
109
104
  unless obj.respond_to?(name)
110
105
  abort "#{obj.where}: '#{name}' is unknown"
@@ -165,7 +160,7 @@ module Livetext::Helpers
165
160
  @line = _next_line if _peek_next_line =~ /^ *$/
166
161
  end
167
162
 
168
- def _comment?(str, sigil=Livetext::MainSigil)
163
+ def _comment?(str, sigil=".")
169
164
  c1 = sigil + Livetext::Space
170
165
  c2 = sigil + sigil + Livetext::Space
171
166
  str.index(c1) == 0 || str.index(c2) == 0
@@ -176,14 +171,14 @@ module Livetext::Helpers
176
171
  return false
177
172
  end
178
173
 
179
- def _end?(str, sigil=Livetext::MainSigil)
174
+ def _end?(str, sigil=".")
180
175
  cmd = sigil + "end"
181
176
  return false if str.index(cmd) != 0
182
177
  return false unless _trailing?(str[5])
183
178
  return true
184
179
  end
185
180
 
186
- def _raw_body(tag = "__EOF__", sigil = Livetext::MainSigil)
181
+ def _raw_body(tag = "__EOF__", sigil = ".")
187
182
  lines = []
188
183
  loop do
189
184
  @line = _next_line
@@ -198,7 +193,7 @@ module Livetext::Helpers
198
193
  end
199
194
  end
200
195
 
201
- def _body(sigil=Livetext::MainSigil)
196
+ def _body(sigil=".")
202
197
  lines = []
203
198
  loop do
204
199
  @line = _next_line # no chomp needed
@@ -214,7 +209,7 @@ module Livetext::Helpers
214
209
  end
215
210
  end
216
211
 
217
- def _body!(sigil=Livetext::MainSigil)
212
+ def _body!(sigil=".")
218
213
  _body(sigil).join("\n")
219
214
  end
220
215
 
@@ -330,6 +325,7 @@ module Livetext::Helpers
330
325
  end
331
326
 
332
327
  module Livetext::Standard
328
+
333
329
  def comment
334
330
  junk = _body # do nothing with contents
335
331
  end
@@ -436,15 +432,6 @@ module Livetext::Standard
436
432
  _output(name)
437
433
  end
438
434
 
439
- def sigil
440
- char = _args.first
441
- raise "'#{char}' is not a single character" if char.length > 1
442
- obj = Livetext::Objects[Livetext::MainSigil]
443
- Livetext::Objects.replace(char => obj)
444
- Livetext::MainSigil.replace(char)
445
- _optional_blank_line
446
- end
447
-
448
435
  def _def
449
436
  name = _args[0]
450
437
  str = "def #{name}\n"
@@ -497,7 +484,6 @@ module Livetext::Standard
497
484
  def include!
498
485
  file = _args.first
499
486
  _pushfile
500
- # TTY.puts "include!: ****** file = #{file}"
501
487
  existing = File.exist?(file)
502
488
  return if not existing
503
489
  lines = ::File.readlines(file)
@@ -514,11 +500,17 @@ module Livetext::Standard
514
500
  name = _args.first
515
501
  file = "#{Plugins}/" + name + ".rb"
516
502
  return if @_mixins.include?(file)
503
+ file = "./#{name}.rb" unless File.exist?(file)
504
+ raise "No such file: #{name}.rb found" unless File.exist?(file)
505
+
517
506
  @_mixins << file
518
507
  _pushfile(file)
519
- # TTY.puts "mixin: ****** file = #{file} "
520
- text = ::File.read(file)
521
- self.class.class_eval(text)
508
+ main = Livetext.main
509
+ m0 = main.methods.reject {|x| x.to_s[0] == "_" }
510
+ self.class.class_eval(::File.read(file))
511
+ m1 = main.methods.reject {|x| x.to_s[0] == "_" }
512
+ $meths[file] = m1 - m0
513
+ TTY.puts "commands = #{$meths.inspect}"
522
514
  init = "init_#{name}"
523
515
  self.send(init) if self.respond_to? init
524
516
  _optional_blank_line
@@ -621,8 +613,7 @@ class Livetext::System < BasicObject
621
613
  end
622
614
  end
623
615
 
624
- ### FIXME - these are all top-level methods
625
-
616
+ $meths = {}
626
617
 
627
618
  if $0 == __FILE__
628
619
  Livetext.handle_file(ARGV[0] || STDIN)
data/livetext.gemspec CHANGED
@@ -1,7 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
+ system("rm -f *.gem")
2
3
  s.name = 'livetext'
3
- s.version = '0.5.8'
4
- s.date = '2017-03-08'
4
+ s.version = '0.5.9'
5
+ s.date = '2017-03-09'
5
6
  s.summary = "A smart processor for text"
6
7
  s.description = "A smart text processor extensible in Ruby"
7
8
  s.authors = ["Hal Fulton"]
@@ -77,10 +78,6 @@ Gem::Specification.new do |s|
77
78
  ./test/testfiles/raw_text_block/expected-error.txt
78
79
  ./test/testfiles/raw_text_block/expected-output.txt
79
80
  ./test/testfiles/raw_text_block/source.ltx
80
- ./test/testfiles/sigil_can_change
81
- ./test/testfiles/sigil_can_change/expected-error.txt
82
- ./test/testfiles/sigil_can_change/expected-output.txt
83
- ./test/testfiles/sigil_can_change/source.ltx
84
81
  ./test/testfiles/simple_copy
85
82
  ./test/testfiles/simple_copy/expected-error.txt
86
83
  ./test/testfiles/simple_copy/expected-output.txt
data/test/test.rb CHANGED
@@ -39,7 +39,7 @@ class TestingLiveText < MiniTest::Test
39
39
  def test_simple_vars; external_files end
40
40
  def test_more_complex_vars; external_files end
41
41
 
42
- def test_sigil_can_change; external_files end
42
+ # def test_sigil_can_change; external_files end
43
43
 
44
44
  def test_def_method; external_files end
45
45
 
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.5.8
4
+ version: 0.5.9
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-03-08 00:00:00.000000000 Z
11
+ date: 2017-03-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com
@@ -70,9 +70,6 @@ files:
70
70
  - "./test/testfiles/raw_text_block/expected-error.txt"
71
71
  - "./test/testfiles/raw_text_block/expected-output.txt"
72
72
  - "./test/testfiles/raw_text_block/source.ltx"
73
- - "./test/testfiles/sigil_can_change/expected-error.txt"
74
- - "./test/testfiles/sigil_can_change/expected-output.txt"
75
- - "./test/testfiles/sigil_can_change/source.ltx"
76
73
  - "./test/testfiles/simple_copy/expected-error.txt"
77
74
  - "./test/testfiles/simple_copy/expected-output.txt"
78
75
  - "./test/testfiles/simple_copy/source.ltx"
File without changes
@@ -1,6 +0,0 @@
1
- abc 123
2
- this is a test
3
- . this is not a comment
4
- more stuff
5
- .this means nothing
6
- still more stuff
@@ -1,11 +0,0 @@
1
- . This is a comment
2
- .sigil #
3
- # Comments are ignored
4
- abc 123
5
- this is a test
6
- . this is not a comment
7
- # whether at beginning, middle, or
8
- more stuff
9
- .this means nothing
10
- still more stuff
11
- # end of the file