livetext 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/bin/livetext +20 -0
  3. data/lib/bookish.rb +212 -0
  4. data/lib/calibre.rb +24 -0
  5. data/lib/liveblog.rb +195 -0
  6. data/lib/livemagick.rb +131 -0
  7. data/lib/livetext.rb +605 -0
  8. data/lib/markdown.rb +30 -0
  9. data/lib/pyggish.rb +194 -0
  10. data/lib/tutorial.rb +89 -0
  11. data/livetext-0.5.2.gem +0 -0
  12. data/livetext.gemspec +99 -4
  13. data/test/cleanup +1 -0
  14. data/test/newtest +10 -0
  15. data/test/rawtext.inc +4 -0
  16. data/test/simple_mixin.rb +3 -0
  17. data/test/simplefile.inc +2 -0
  18. data/test/test.rb +77 -0
  19. data/test/testfiles/basic_formatting/expected-error.txt +0 -0
  20. data/test/testfiles/basic_formatting/expected-output.txt +10 -0
  21. data/test/testfiles/basic_formatting/source.ltx +8 -0
  22. data/test/testfiles/block_comment/expected-error.txt +0 -0
  23. data/test/testfiles/block_comment/expected-output.txt +5 -0
  24. data/test/testfiles/block_comment/source.ltx +19 -0
  25. data/test/testfiles/comments_ignored_1/expected-error.txt +0 -0
  26. data/test/testfiles/comments_ignored_1/expected-output.txt +4 -0
  27. data/test/testfiles/comments_ignored_1/source.ltx +7 -0
  28. data/test/testfiles/copy_is_raw/expected-error.txt +0 -0
  29. data/test/testfiles/copy_is_raw/expected-output.txt +7 -0
  30. data/test/testfiles/copy_is_raw/source.ltx +4 -0
  31. data/test/testfiles/def_method/expected-error.txt +2 -0
  32. data/test/testfiles/def_method/expected-output.txt +5 -0
  33. data/test/testfiles/def_method/source.ltx +10 -0
  34. data/test/testfiles/example_alpha/expected-error.txt +0 -0
  35. data/test/testfiles/example_alpha/expected-output.txt +23 -0
  36. data/test/testfiles/example_alpha/source.ltx +17 -0
  37. data/test/testfiles/example_alpha2/expected-error.txt +0 -0
  38. data/test/testfiles/example_alpha2/expected-output.txt +12 -0
  39. data/test/testfiles/example_alpha2/source.ltx +24 -0
  40. data/test/testfiles/fixit +6 -0
  41. data/test/testfiles/functions/expected-error.txt +0 -0
  42. data/test/testfiles/functions/expected-output.txt +8 -0
  43. data/test/testfiles/functions/source.ltx +11 -0
  44. data/test/testfiles/hello_world/expected-error.txt +0 -0
  45. data/test/testfiles/hello_world/expected-output.txt +2 -0
  46. data/test/testfiles/hello_world/source.ltx +2 -0
  47. data/test/testfiles/more_complex_vars/expected-error.txt +0 -0
  48. data/test/testfiles/more_complex_vars/expected-output.txt +4 -0
  49. data/test/testfiles/more_complex_vars/source.ltx +5 -0
  50. data/test/testfiles/raw_text_block/expected-error.txt +0 -0
  51. data/test/testfiles/raw_text_block/expected-output.txt +14 -0
  52. data/test/testfiles/raw_text_block/source.ltx +16 -0
  53. data/test/testfiles/sigil_can_change/expected-error.txt +0 -0
  54. data/test/testfiles/sigil_can_change/expected-output.txt +6 -0
  55. data/test/testfiles/sigil_can_change/source.ltx +11 -0
  56. data/test/testfiles/simple_copy/expected-error.txt +0 -0
  57. data/test/testfiles/simple_copy/expected-output.txt +7 -0
  58. data/test/testfiles/simple_copy/source.ltx +6 -0
  59. data/test/testfiles/simple_include/expected-error.txt +0 -0
  60. data/test/testfiles/simple_include/expected-output.txt +7 -0
  61. data/test/testfiles/simple_include/source.ltx +6 -0
  62. data/test/testfiles/simple_mixin/expected-error.txt +0 -0
  63. data/test/testfiles/simple_mixin/expected-output.txt +5 -0
  64. data/test/testfiles/simple_mixin/source.ltx +6 -0
  65. data/test/testfiles/simple_vars/expected-error.txt +0 -0
  66. data/test/testfiles/simple_vars/expected-output.txt +6 -0
  67. data/test/testfiles/simple_vars/source.ltx +7 -0
  68. data/test/testfiles/single_raw_line/expected-error.txt +0 -0
  69. data/test/testfiles/single_raw_line/expected-output.txt +10 -0
  70. data/test/testfiles/single_raw_line/source.ltx +8 -0
  71. metadata +76 -9
  72. data/dlt +0 -1
@@ -0,0 +1,3 @@
1
+ def hello_world
2
+ puts "Hello, world."
3
+ end
@@ -0,0 +1,2 @@
1
+ a simple
2
+ include file.
data/test/test.rb ADDED
@@ -0,0 +1,77 @@
1
+ require 'minitest/autorun'
2
+
3
+ $LOAD_PATH << "./lib"
4
+ require 'livetext'
5
+
6
+ # How these tests work - see the block comment at the bottom.
7
+
8
+ class TestingLiveText < MiniTest::Test
9
+
10
+ def external_files
11
+ tag = caller[0]
12
+ n1, n2 = tag.index("`")+6, tag.index("'")-1
13
+ base = tag[n1..n2]
14
+ name = "test/testfiles/#{base}/xxx"
15
+
16
+ src, out, exp = name.sub(/xxx/, "source.ltx"), name.sub(/xxx/, "actual-output.txt"), name.sub(/xxx/, "expected-output.txt")
17
+ err, erx = name.sub(/xxx/, "actual-error.txt"), name.sub(/xxx/, "expected-error.txt")
18
+ cmd = "./bin/livetext #{src} >#{out} 2>#{err}"
19
+ # puts cmd
20
+ system(cmd)
21
+ output, expected, errors, errexp = File.read(out), File.read(exp), File.read(err), File.read(erx)
22
+
23
+ out_ok = output == expected
24
+ err_ok = errors == errexp
25
+ bad_out = "--- Expected: \n#{expected}\n--- Output: \n#{output}\n"
26
+ bad_err = "--- Error Expected: \n#{errexp}\n--- Error Output: \n#{errors}\n"
27
+
28
+ assert(out_ok, bad_out)
29
+ assert(err_ok, bad_err)
30
+ system("rm -f #{out} #{err}") # only on success
31
+ end
32
+
33
+ def xtest_hello_world; external_files end
34
+ def xtest_basic_formatting; external_files end
35
+
36
+ def xtest_comments_ignored_1; external_files end
37
+ def xtest_block_comment; external_files end
38
+
39
+ def xtest_simple_vars; external_files end
40
+ def xtest_more_complex_vars; external_files end
41
+
42
+ def xtest_sigil_can_change; external_files end
43
+
44
+ def xtest_def_method; external_files end
45
+
46
+ def xtest_single_raw_line; external_files end
47
+
48
+ def test_simple_include; external_files end
49
+ def test_simple_mixin; external_files end
50
+ def test_simple_copy; external_files end
51
+ def test_copy_is_raw; external_files end
52
+ def xtest_raw_text_block; external_files end
53
+
54
+ def xtest_example_alpha; external_files end
55
+ def xtest_example_alpha2; external_files end
56
+
57
+ def xtest_functions; external_files end
58
+
59
+ end
60
+
61
+
62
+ =begin
63
+
64
+ You can add any ordinary test method above. But so far, all these tests simply
65
+ call external_files.
66
+
67
+ The external_files method works this way:
68
+ - If the test (caller) method is test_my_silly_feature, then we will
69
+ look for a directory called testfiles/my_silly_feature
70
+ - In here, there must be a source.ltx, expected-output.txt, and expected-error.txt
71
+ - Technically, any of these can be empty
72
+ - We run livetext on the source and compare actual vs expected (stdout, stderr)
73
+ - The "real" output gets checked first
74
+ - Of course, both must compare correctly for the test to pass
75
+
76
+ =end
77
+
@@ -0,0 +1,10 @@
1
+ Here are examples of <b>boldface</b> and <i>italics</i> and <tt>code</tt>
2
+ as well as <b>more complex</b> examples of <i>italicized text</i>
3
+ and <tt>code font</tt>.
4
+ <p>
5
+
6
+ Here are some random punctuation marks:
7
+ # . @ <b> <i></b> <tt></i></tt> : ; % ^ & $
8
+ <p>
9
+
10
+ Oops, forgot to escape these: * _ `
@@ -0,0 +1,8 @@
1
+ Here are examples of *boldface and _italics and `code
2
+ as well as *(more complex) examples of _(italicized text)
3
+ and `(code font).
4
+
5
+ Here are some random punctuation marks:
6
+ # . @ * _ ` : ; % ^ & $
7
+
8
+ Oops, forgot to escape these: \* \_ \`
File without changes
@@ -0,0 +1,5 @@
1
+ abc 123
2
+ xyz
3
+ one
4
+ more
5
+ time
@@ -0,0 +1,19 @@
1
+ .comment
2
+ This is
3
+ a comment
4
+ .end
5
+ abc 123
6
+ xyz
7
+ .comment
8
+ And so is this.
9
+ .end
10
+
11
+ one
12
+ more
13
+ time
14
+ .comment
15
+ And so
16
+ is
17
+ this
18
+ .end
19
+
@@ -0,0 +1,4 @@
1
+ abc 123
2
+ this is a test
3
+ more stuff
4
+ still more stuff
@@ -0,0 +1,7 @@
1
+ . Comments are ignored
2
+ abc 123
3
+ this is a test
4
+ . whether at beginning, middle, or
5
+ more stuff
6
+ still more stuff
7
+ . end of the file
File without changes
@@ -0,0 +1,7 @@
1
+ A copy command
2
+ does not interpret its input:
3
+ This is not a comment:
4
+ .comment woohoo!
5
+ This is not a method:
6
+ .no_such_method
7
+ That's all.
@@ -0,0 +1,4 @@
1
+ A copy command
2
+ does not interpret its input:
3
+ .copy test/rawtext.inc
4
+ That's all.
@@ -0,0 +1,2 @@
1
+ This is the
2
+ foobar method
@@ -0,0 +1,5 @@
1
+ abc
2
+ 123
3
+ xyz
4
+ xyzzy
5
+ 123
@@ -0,0 +1,10 @@
1
+ abc
2
+ 123
3
+ .def foobar
4
+ ::STDERR.puts "This is the"
5
+ ::STDERR.puts "foobar method"
6
+ .end
7
+ xyz
8
+ .foobar
9
+ xyzzy
10
+ 123
File without changes
@@ -0,0 +1,23 @@
1
+ Here is an alphabetized list:
2
+ <p>
3
+
4
+ aardvark
5
+ anamorphic
6
+ anarchist
7
+ bellicose
8
+ cytology
9
+ ectomorph
10
+ fishmonger
11
+ fusillade
12
+ glyph
13
+ gryphon
14
+ halcyon
15
+ manicotti
16
+ mataeotechny
17
+ pareidolia
18
+ quark
19
+ zootrope
20
+ zymurgy
21
+ <p>
22
+
23
+ I hope that worked.
@@ -0,0 +1,17 @@
1
+ .def alpha
2
+ text = _body.join
3
+ text.gsub!(/\n/, " ")
4
+ words = text.split.sort
5
+ words.each {|w| _puts " #{w}" }
6
+ .end
7
+ Here is an alphabetized list:
8
+
9
+ .alpha
10
+ fishmonger anarchist aardvark glyph gryphon
11
+ halcyon zymurgy mataeotechny zootrope
12
+ pareidolia manicotti quark bellicose anamorphic
13
+ cytology fusillade ectomorph
14
+ .end
15
+
16
+
17
+ I hope that worked.
File without changes
@@ -0,0 +1,12 @@
1
+ Here is an alphabetized list:
2
+ <p>
3
+
4
+ aardvark anamorphic anarchist
5
+ bellicose cytology ectomorph
6
+ fishmonger fusillade glyph
7
+ gryphon halcyon manicotti
8
+ mataeotechny pareidolia quark
9
+ zootrope zymurgy
10
+ <p>
11
+
12
+ I hope that worked a second time.
@@ -0,0 +1,24 @@
1
+ .def alpha
2
+ cols = _args.first
3
+ cols = "1" if cols == ""
4
+ cols = cols.to_i
5
+ raise "Columns must be 1-5" unless cols.between?(1,5)
6
+ text = _body.join
7
+ text.gsub!(/\n/, " ")
8
+ words = text.split.sort
9
+ words.each_slice(cols) do |row|
10
+ row.each {|w| _print '%-15s' % w }
11
+ _puts
12
+ end
13
+ .end
14
+ Here is an alphabetized list:
15
+
16
+ .alpha 3
17
+ fishmonger anarchist aardvark glyph gryphon
18
+ halcyon zymurgy mataeotechny zootrope
19
+ pareidolia manicotti quark bellicose anamorphic
20
+ cytology fusillade ectomorph
21
+ .end
22
+
23
+
24
+ I hope that worked a second time.
@@ -0,0 +1,6 @@
1
+ cd $1
2
+ mv $1.err actual-error.txt
3
+ mv $1.erx expected-error.txt
4
+ mv $1.exp expected-output.txt
5
+ mv $1.ltx source.ltx
6
+ mv $1.out actual-output.txt
File without changes
@@ -0,0 +1,8 @@
1
+ Testing out
2
+ some functions
3
+ here...
4
+ <p>
5
+
6
+ I am calling Eureka! here...
7
+ Let's see
8
+ what happens.
@@ -0,0 +1,11 @@
1
+ Testing out
2
+ some functions
3
+ here...
4
+
5
+ .func myfunc
6
+ "Eureka!"
7
+ .end
8
+
9
+ I am calling $$myfunc here...
10
+ Let's see
11
+ what happens.
File without changes
@@ -0,0 +1,2 @@
1
+ Hello,
2
+ world!
@@ -0,0 +1,2 @@
1
+ Hello,
2
+ world!
@@ -0,0 +1,4 @@
1
+ Just some more text.
2
+ My birthday is May 31, so they tell me.
3
+ That's 5/31 if you're American.
4
+ That's all.
@@ -0,0 +1,5 @@
1
+ Just some more text.
2
+ .set bday="May 31", date="5/31"
3
+ My birthday is $bday, so they tell me.
4
+ That's $date if you're American.
5
+ That's all.
File without changes
@@ -0,0 +1,14 @@
1
+ This text block will be passed thru
2
+ with no interpretation or processing:
3
+ .comment
4
+ This isn't a
5
+ real comment.
6
+ .end This isn't picked up.
7
+
8
+ .not_a_method
9
+
10
+ And this stuff won't be munged: `alpha _beta *gamma
11
+ Or this: `(alpha male) _(beta max) *(gamma rays)
12
+ <p>
13
+
14
+ I hope that worked.
@@ -0,0 +1,16 @@
1
+ This text block will be passed thru
2
+ with no interpretation or processing:
3
+ .raw
4
+ .comment
5
+ This isn't a
6
+ real comment.
7
+ .end This isn't picked up.
8
+
9
+ .not_a_method
10
+
11
+ And this stuff won't be munged: `alpha _beta *gamma
12
+ Or this: `(alpha male) _(beta max) *(gamma rays)
13
+ __EOF__
14
+
15
+
16
+ I hope that worked.
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,11 @@
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
File without changes
@@ -0,0 +1,7 @@
1
+ The copy command
2
+ copies any file
3
+ without interpretation,
4
+ such as:
5
+ a simple
6
+ include file.
7
+ That is all.
@@ -0,0 +1,6 @@
1
+ The copy command
2
+ copies any file
3
+ without interpretation,
4
+ such as:
5
+ .copy test/simplefile.inc
6
+ That is all.
File without changes
@@ -0,0 +1,7 @@
1
+ Here I am
2
+ trying to
3
+ include
4
+ a simple
5
+ include file.
6
+ I hope that
7
+ worked.