livetext 0.5.9 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/livetext.rb +42 -11
- data/livetext.gemspec +3 -4
- data/test/test.rb +19 -19
- data/test/testfiles/copy_is_raw/source.ltx +1 -1
- data/test/testfiles/simple_copy/source.ltx +1 -1
- data/test/testfiles/simple_include/source.ltx +1 -1
- data/test/testfiles/simple_mixin/source.ltx +1 -1
- metadata +2 -6
- data/test/rawtext.inc +0 -4
- data/test/simple_mixin.rb +0 -3
- data/test/simplefile.inc +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 342432e589fbafc4dea447d96303c9da09f88b3b
|
4
|
+
data.tar.gz: 364013916fd421dd922424ad1d9e709a1260723a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f60a26574a8bb62ebb2060c5566643321b2719a70998a7b594ecce614128717b95f8f02edfe1f4eb68dbd4547cd04e06ac70c472f6f6d00895dd6457a6eca49b
|
7
|
+
data.tar.gz: 46098f43661bc4d4eb0a3c22b499996a230f3f56a5636fd53528bf54632ed59af6f6357f19fffb08d8448aa790f5b88980087302fbe53cbe12b8c50980762e05
|
data/lib/livetext.rb
CHANGED
@@ -15,7 +15,7 @@ class Enumerator
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class Livetext
|
18
|
-
VERSION = "0.
|
18
|
+
VERSION = "0.6.0"
|
19
19
|
|
20
20
|
Space = " "
|
21
21
|
|
@@ -101,12 +101,12 @@ class Livetext
|
|
101
101
|
def self.handle_sname(sigil, line)
|
102
102
|
obj = @main # Livetext::Objects[sigil]
|
103
103
|
name = _get_name(obj, sigil, line)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
# unless obj.respond_to?(name)
|
105
|
+
# abort "#{obj.where}: '#{name}' is unknown"
|
106
|
+
# return
|
107
|
+
# end
|
108
108
|
|
109
|
-
if name == "notes"
|
109
|
+
if name == "notes" # FIXME wtf
|
110
110
|
obj.notes
|
111
111
|
else
|
112
112
|
obj.send(name)
|
@@ -134,6 +134,11 @@ class Livetext::Functions # Functions will go here... user-def AND pre-def??
|
|
134
134
|
end
|
135
135
|
|
136
136
|
module Livetext::Helpers
|
137
|
+
|
138
|
+
def _check_existence(file)
|
139
|
+
raise "No such file found" unless File.exist?(file)
|
140
|
+
end
|
141
|
+
|
137
142
|
def _source
|
138
143
|
@input
|
139
144
|
end
|
@@ -497,6 +502,25 @@ module Livetext::Standard
|
|
497
502
|
end
|
498
503
|
|
499
504
|
def mixin
|
505
|
+
name = _args.first # Expect a module name
|
506
|
+
file = "#{Plugins}/" + name.downcase + ".rb"
|
507
|
+
return if @_mixins.include?(file)
|
508
|
+
file = "./#{name}.rb" unless File.exist?(file)
|
509
|
+
_check_existence(file)
|
510
|
+
|
511
|
+
@_mixins << file
|
512
|
+
_pushfile(file)
|
513
|
+
newmod = Module.new
|
514
|
+
$mods << newmod
|
515
|
+
Object.const_set(name.capitalize, newmod)
|
516
|
+
newmod.instance_eval(File.read(file))
|
517
|
+
init = "init_#{name}"
|
518
|
+
self.send(init) if self.respond_to? init
|
519
|
+
_optional_blank_line
|
520
|
+
_popfile
|
521
|
+
end
|
522
|
+
|
523
|
+
def old_mixin
|
500
524
|
name = _args.first
|
501
525
|
file = "#{Plugins}/" + name + ".rb"
|
502
526
|
return if @_mixins.include?(file)
|
@@ -510,7 +534,6 @@ module Livetext::Standard
|
|
510
534
|
self.class.class_eval(::File.read(file))
|
511
535
|
m1 = main.methods.reject {|x| x.to_s[0] == "_" }
|
512
536
|
$meths[file] = m1 - m0
|
513
|
-
TTY.puts "commands = #{$meths.inspect}"
|
514
537
|
init = "init_#{name}"
|
515
538
|
self.send(init) if self.respond_to? init
|
516
539
|
_optional_blank_line
|
@@ -520,8 +543,8 @@ TTY.puts "commands = #{$meths.inspect}"
|
|
520
543
|
def copy
|
521
544
|
file = _args.first
|
522
545
|
_pushfile(file)
|
523
|
-
|
524
|
-
@output.puts
|
546
|
+
text = ::File.readlines(file)
|
547
|
+
@output.puts text
|
525
548
|
_optional_blank_line
|
526
549
|
_popfile
|
527
550
|
end
|
@@ -606,14 +629,22 @@ class Livetext::System < BasicObject
|
|
606
629
|
end
|
607
630
|
|
608
631
|
def method_missing(name, *args)
|
609
|
-
|
632
|
+
# TTY.puts $mods.inspect
|
633
|
+
$mods.reverse.each do |mod|
|
634
|
+
#TTY.puts "mod methods = #{mod.module_methods.inspect}"
|
635
|
+
if mod.respond_to?(name)
|
636
|
+
mod.send(name, *args)
|
637
|
+
return
|
638
|
+
end
|
639
|
+
end
|
640
|
+
TTY.puts "Got here"
|
610
641
|
_puts " Error: Method '#{name}' is not defined."
|
611
642
|
puts caller.map {|x| " " + x }
|
612
643
|
exit
|
613
644
|
end
|
614
645
|
end
|
615
646
|
|
616
|
-
$
|
647
|
+
$mods = []
|
617
648
|
|
618
649
|
if $0 == __FILE__
|
619
650
|
Livetext.handle_file(ARGV[0] || STDIN)
|
data/livetext.gemspec
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require_relative "./lib/livetext"
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
system("rm -f *.gem")
|
3
5
|
s.name = 'livetext'
|
4
|
-
s.version =
|
6
|
+
s.version = Livetext::VERSION
|
5
7
|
s.date = '2017-03-09'
|
6
8
|
s.summary = "A smart processor for text"
|
7
9
|
s.description = "A smart text processor extensible in Ruby"
|
@@ -28,9 +30,6 @@ Gem::Specification.new do |s|
|
|
28
30
|
./test
|
29
31
|
./test/cleanup
|
30
32
|
./test/newtest
|
31
|
-
./test/rawtext.inc
|
32
|
-
./test/simple_mixin.rb
|
33
|
-
./test/simplefile.inc
|
34
33
|
./test/test.rb
|
35
34
|
./test/testfiles
|
36
35
|
./test/testfiles/basic_formatting
|
data/test/test.rb
CHANGED
@@ -7,27 +7,29 @@ require 'livetext'
|
|
7
7
|
|
8
8
|
class TestingLiveText < MiniTest::Test
|
9
9
|
|
10
|
+
TTY = File.open("/dev/tty","w")
|
11
|
+
|
10
12
|
def external_files
|
11
13
|
tag = caller[0]
|
12
14
|
n1, n2 = tag.index("`")+6, tag.index("'")-1
|
13
15
|
base = tag[n1..n2]
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
16
|
+
origin = Dir.pwd
|
17
|
+
Dir.chdir("test/testfiles/#{base}") do
|
18
|
+
src, out, exp = "source.ltx", "actual-output.txt", "expected-output.txt"
|
19
|
+
err, erx = "actual-error.txt", "expected-error.txt"
|
20
|
+
cmd = "../../../bin/livetext #{src} >#{out} 2>#{err}"
|
21
|
+
system(cmd)
|
22
|
+
output, expected, errors, errexp = File.read(out), File.read(exp), File.read(err), File.read(erx)
|
23
|
+
|
24
|
+
out_ok = output == expected
|
25
|
+
err_ok = errors == errexp
|
26
|
+
bad_out = "--- Expected: \n#{expected}\n--- Output: \n#{output}\n"
|
27
|
+
bad_err = "--- Error Expected: \n#{errexp}\n--- Error Output: \n#{errors}\n"
|
28
|
+
|
29
|
+
assert(out_ok, bad_out)
|
30
|
+
assert(err_ok, bad_err)
|
31
|
+
system("rm -f #{out} #{err}") # only on success
|
32
|
+
end
|
31
33
|
end
|
32
34
|
|
33
35
|
def test_hello_world; external_files end
|
@@ -39,8 +41,6 @@ class TestingLiveText < MiniTest::Test
|
|
39
41
|
def test_simple_vars; external_files end
|
40
42
|
def test_more_complex_vars; external_files end
|
41
43
|
|
42
|
-
# def test_sigil_can_change; external_files end
|
43
|
-
|
44
44
|
def test_def_method; external_files end
|
45
45
|
|
46
46
|
def test_single_raw_line; external_files end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livetext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
@@ -32,9 +32,6 @@ files:
|
|
32
32
|
- "./notes.txt"
|
33
33
|
- "./test/cleanup"
|
34
34
|
- "./test/newtest"
|
35
|
-
- "./test/rawtext.inc"
|
36
|
-
- "./test/simple_mixin.rb"
|
37
|
-
- "./test/simplefile.inc"
|
38
35
|
- "./test/test.rb"
|
39
36
|
- "./test/testfiles/basic_formatting/expected-error.txt"
|
40
37
|
- "./test/testfiles/basic_formatting/expected-output.txt"
|
@@ -105,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
102
|
version: '0'
|
106
103
|
requirements: []
|
107
104
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.2.2
|
109
106
|
signing_key:
|
110
107
|
specification_version: 4
|
111
108
|
summary: A smart processor for text
|
112
109
|
test_files: []
|
113
|
-
has_rdoc:
|
data/test/rawtext.inc
DELETED
data/test/simple_mixin.rb
DELETED
data/test/simplefile.inc
DELETED