livetext 0.9.23 → 0.9.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/README.lt3 +6 -6
  3. data/bin/livetext +57 -40
  4. data/imports/bookish.rb +81 -81
  5. data/imports/calibre.rb +3 -3
  6. data/imports/livemagick.rb +17 -17
  7. data/imports/markdown.rb +10 -10
  8. data/imports/pyggish.rb +13 -13
  9. data/imports/tutorial.rb +15 -15
  10. data/lib/cmdargs.rb +7 -4
  11. data/lib/{errors.rb → livetext/errors.rb} +4 -3
  12. data/lib/{formatline.rb → livetext/formatline.rb} +119 -18
  13. data/lib/livetext/funcall.rb +168 -0
  14. data/lib/{functions.rb → livetext/functions.rb} +0 -2
  15. data/lib/{global_helpers.rb → livetext/global_helpers.rb} +6 -3
  16. data/lib/{handler → livetext/handler}/import.rb +5 -9
  17. data/lib/livetext/handler/mixin.rb +33 -0
  18. data/lib/{handler.rb → livetext/handler.rb} +1 -1
  19. data/lib/{helpers.rb → livetext/helpers.rb} +78 -66
  20. data/lib/{html.rb → livetext/html.rb} +2 -3
  21. data/lib/livetext/lineparser.rb +441 -0
  22. data/lib/livetext/more.rb +158 -0
  23. data/lib/{parser → livetext/parser}/general.rb +0 -0
  24. data/lib/{parser → livetext/parser}/set.rb +0 -0
  25. data/lib/{parser → livetext/parser}/string.rb +0 -0
  26. data/lib/{parser.rb → livetext/parser.rb} +0 -3
  27. data/lib/{parsing.rb → livetext/parsing.rb} +0 -2
  28. data/lib/livetext/paths.rb +13 -0
  29. data/lib/{processor.rb → livetext/processor.rb} +18 -8
  30. data/lib/livetext/reopen.rb +12 -0
  31. data/lib/livetext/skeleton.rb +22 -0
  32. data/lib/{standard.rb → livetext/standard.rb} +150 -127
  33. data/lib/livetext/userapi.rb +170 -0
  34. data/lib/livetext/version.rb +6 -0
  35. data/lib/livetext.rb +14 -152
  36. data/plugin/bookish.rb +82 -81
  37. data/plugin/calibre.rb +3 -3
  38. data/plugin/livemagick.rb +17 -17
  39. data/plugin/markdown.rb +10 -10
  40. data/plugin/pyggish.rb +118 -118
  41. data/plugin/tutorial.rb +15 -15
  42. data/test/all.rb +6 -0
  43. data/test/snapshots/{error_inc_line_num → basic_formatting}/actual-error.txt +0 -0
  44. data/test/snapshots/basic_formatting/actual-output.txt +13 -0
  45. data/test/snapshots/basic_formatting/err-sdiff.txt +1 -0
  46. data/test/snapshots/basic_formatting/out-sdiff.txt +14 -0
  47. data/test/snapshots/def_method/expected-output.txt +2 -0
  48. data/test/snapshots/def_method/source.lt3 +4 -2
  49. data/test/snapshots/error_inc_line_num/{OUT → README.txt} +11 -8
  50. data/test/snapshots/error_inc_line_num/expected-output.txt +0 -6
  51. data/test/snapshots/error_inc_line_num/match-error.txt +1 -1
  52. data/test/snapshots/error_invalid_name/foo +5 -0
  53. data/test/snapshots/error_line_num/match-error.txt +1 -1
  54. data/test/snapshots/error_missing_end/expected-output.txt +0 -1
  55. data/test/snapshots/error_name_not_permitted/expected-output.txt +4 -0
  56. data/test/snapshots/error_name_not_permitted/match-error.txt +1 -1
  57. data/test/snapshots/error_no_such_copy/expected-output.txt +1 -0
  58. data/test/snapshots/error_no_such_mixin/expected-output.txt +1 -0
  59. data/test/snapshots/error_no_such_mixin/match-error.txt +1 -1
  60. data/test/snapshots/error_no_such_mixin/source.lt3 +1 -1
  61. data/test/snapshots/example_alpha/source.lt3 +2 -2
  62. data/test/snapshots/example_alpha2/expected-output.txt +0 -2
  63. data/test/snapshots/example_alpha2/source.lt3 +5 -4
  64. data/test/snapshots/import/expected-output.txt +2 -1
  65. data/test/snapshots/import/match-error.txt +1 -1
  66. data/test/snapshots/import/simple_import.rb +1 -1
  67. data/test/snapshots/import2/simple_import.rb +1 -1
  68. data/test/snapshots/import_bookish/expected-output.txt +4 -4
  69. data/test/snapshots/{error_invalid_name/actual-output.txt → more_functions/actual-error.txt} +0 -0
  70. data/test/snapshots/more_functions/actual-output.txt +37 -0
  71. data/test/snapshots/more_functions/err-sdiff.txt +1 -0
  72. data/test/snapshots/more_functions/expected-output.txt +1 -1
  73. data/test/snapshots/more_functions/out-sdiff.txt +38 -0
  74. data/test/snapshots/more_functions/source.lt3 +1 -1
  75. data/test/snapshots/raw_lines/expected-output.txt +0 -2
  76. data/test/snapshots/simple_import/simple_import.rb +1 -1
  77. data/test/snapshots/simple_mixin/simple_mixin.rb +1 -1
  78. data/test/snapshots/{error_missing_end/actual-output.txt → simple_vars/actual-error.txt} +0 -0
  79. data/test/snapshots/simple_vars/actual-output.txt +6 -0
  80. data/test/snapshots/simple_vars/err-sdiff.txt +1 -0
  81. data/test/snapshots/simple_vars/out-sdiff.txt +7 -0
  82. data/test/snapshots/single_raw_line/expected-output.txt +0 -2
  83. data/test/snapshots/subset.txt +9 -7
  84. data/test/snapshots/{error_no_such_copy/actual-output.txt → var_into_func/actual-error.txt} +0 -0
  85. data/test/snapshots/var_into_func/actual-output.txt +16 -0
  86. data/test/snapshots/var_into_func/err-sdiff.txt +1 -0
  87. data/test/snapshots/{error_no_such_inc/actual-output.txt → var_into_func/expected-error.txt} +0 -0
  88. data/test/snapshots/var_into_func/expected-output.txt +16 -0
  89. data/test/snapshots/var_into_func/out-sdiff.txt +17 -0
  90. data/test/snapshots/var_into_func/source.lt3 +16 -0
  91. data/test/snapshots.rb +16 -7
  92. data/test/unit/all.rb +3 -1
  93. data/test/unit/formatline.rb +145 -276
  94. data/test/unit/html.rb +1 -2
  95. data/test/unit/lineparser.rb +650 -0
  96. data/test/unit/parser/set.rb +13 -12
  97. data/test/unit/standard.rb +0 -1
  98. data/test/unit/tokenizer.rb +534 -0
  99. metadata +49 -39
  100. data/lib/funcall.rb +0 -93
  101. data/lib/parser/file.rb +0 -6
  102. data/lib/parser/mixin.rb +0 -34
  103. data/lib/userapi.rb +0 -164
  104. data/test/snapshots/error_inc_line_num/actual-output.txt +0 -17
  105. data/test/snapshots/error_invalid_name/actual-error.txt +0 -10
  106. data/test/snapshots/error_invalid_name/out-sdiff.txt +0 -6
  107. data/test/snapshots/error_missing_end/actual-error.txt +0 -10
  108. data/test/snapshots/error_missing_end/out-sdiff.txt +0 -6
  109. data/test/snapshots/error_no_such_copy/actual-error.txt +0 -10
  110. data/test/snapshots/error_no_such_copy/out-sdiff.txt +0 -5
  111. data/test/snapshots/error_no_such_inc/actual-error.txt +0 -10
  112. data/test/snapshots/error_no_such_inc/out-sdiff.txt +0 -6
  113. data/test/snapshots/error_no_such_mixin/actual-error.txt +0 -13
  114. data/test/snapshots/error_no_such_mixin/actual-output.txt +0 -0
  115. data/test/snapshots/error_no_such_mixin/out-sdiff.txt +0 -6
@@ -0,0 +1,38 @@
1
+ ACTUAL | EXPECTED
2
+ Testing some more functions here... Testing some more functions here...
3
+ <p> <p>
4
+
5
+ Here I am calling a function with Here I am calling a function with
6
+ a colon parameter... a colon parameter...
7
+ <p> <p>
8
+
9
+ <p> <p>
10
+
11
+ Next let's <b>do</b>*something with our parameter: | Next let's <b>do</b> something with our parameter:
12
+ <p> <p>
13
+
14
+ I'll call these variants... I'll call these variants...
15
+ <p> <p>
16
+
17
+ "Motel" spelled backwards is letom :) "Motel" spelled backwards is letom :)
18
+ <p> <p>
19
+
20
+ "lamina" reversed is animal "lamina" reversed is animal
21
+ <p> <p>
22
+
23
+ I can also use the erutaef tekcarb here. I can also use the erutaef tekcarb here.
24
+ <p> <p>
25
+
26
+ If I don't use a parameter for [Error evaluating $$reverse( If I don't use a parameter for [Error evaluating $$reverse(
27
+ me an error. (Bug or feature??) me an error. (Bug or feature??)
28
+ <p> <p>
29
+
30
+ What if a function doesn't use parameters at all, but What if a function doesn't use parameters at all, but
31
+ we pass them? Hmm... we pass them? Hmm...
32
+ <p> <p>
33
+
34
+ Now we succeed and succeed some more Now we succeed and succeed some more
35
+ and finally we succeed in life. and finally we succeed in life.
36
+ <p> <p>
37
+
38
+ But can we succeed, when our beds are burning? But can we succeed, when our beds are burning?
@@ -10,7 +10,7 @@ Here I am calling a function $$just_do_it:foobar with
10
10
  a colon parameter...
11
11
 
12
12
 
13
- Next let's *do* something with our parameter:
13
+ Next let's *do something with our parameter:
14
14
 
15
15
  .func reverse
16
16
  param.reverse # just reverse it
@@ -8,6 +8,4 @@ Ordinary line... plus two blank lines:
8
8
  No formatting: *foo `foo _foo ~foo
9
9
  No variables: $alpha $beta
10
10
  No functions: $$this $$that
11
- <p>
12
-
13
11
  That's all.
@@ -1,5 +1,5 @@
1
1
  module SimpleImport
2
2
  def hello_world
3
- _out "Hello, world."
3
+ api.out "Hello, world."
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  def hello_world
2
- _out "Hello, world."
2
+ api.out "Hello, world."
3
3
  end
@@ -0,0 +1,6 @@
1
+ Just
2
+ some text.
3
+ Hi, there.
4
+ GulliverFoyle is my name, and Terra is my nation.
5
+ I'm GulliverFoyle, from Terra
6
+ That's all.
@@ -0,0 +1 @@
1
+ ACTUAL | EXPECTED
@@ -0,0 +1,7 @@
1
+ ACTUAL | EXPECTED
2
+ Just Just
3
+ some text. some text.
4
+ Hi, there. Hi, there.
5
+ GulliverFoyle is my name, and Terra is my nation. GulliverFoyle is my name, and Terra is my nation.
6
+ I'm GulliverFoyle, from Terra | I'm GulliverFoyle, from Terra.
7
+ That's all. That's all.
@@ -5,6 +5,4 @@ without interpretation:
5
5
  .comment This is not a real comment.
6
6
  This is not _italics or *boldface
7
7
  This is not a $variable reference
8
- <p>
9
-
10
8
  That's all.
@@ -24,14 +24,14 @@ h This file specifies which snapshots will/won't be run.
24
24
 
25
25
  # import/include/mixin, others...
26
26
 
27
- x error_no_such_inc # Output BEFORE error doesn't get passed through ("leading" output)
28
- x error_no_such_copy # ^ Same behavior as error_no_such_inc
29
- x error_no_such_mixin # ^ Same behavior as error_missing_end
27
+ error_no_such_inc # Output BEFORE error doesn't get passed through ("leading" output)
28
+ error_no_such_copy # ^ Same behavior as error_no_such_inc
29
+ error_no_such_mixin # ^ Same behavior as error_missing_end
30
30
  simple_copy #
31
31
  simple_import #
32
32
  simple_include #
33
33
  simple_mixin #
34
- x import # "Leading" output doesn't get generated (same as error_no_such_inc)
34
+ import # "Leading" output doesn't get generated (same as error_no_such_inc)
35
35
  import2 #
36
36
  mixin_bookish #
37
37
  import_bookish #
@@ -62,15 +62,17 @@ x import # "Leading" output doesn't get generated (same as er
62
62
  # intraline formatting
63
63
 
64
64
  basic_formatting #
65
+ test_formatting_34 #
66
+ test_formatting_35 #
65
67
 
66
68
  # Errors
67
69
 
68
70
  error_line_num #
69
71
  error_mismatched_end #
70
72
  error_name_not_permitted #
71
- x error_invalid_name # ^ Same behavior as error_no_such_inc
72
- x error_missing_end # Output is duplicated somehow. Look for: puts @body or puts @main.body
73
- x error_inc_line_num # Forgot what's wrong here
73
+ error_invalid_name # ^ Same behavior as error_no_such_inc
74
+ error_missing_end # Output is duplicated somehow. Look for: puts @body or puts @main.body
75
+ error_inc_line_num # Forgot what's wrong here
74
76
 
75
77
  # functions
76
78
 
@@ -0,0 +1,16 @@
1
+ <p>
2
+
3
+ Testing STILL more functions here...
4
+ <p>
5
+
6
+ <p>
7
+
8
+ Now... let's try passing a variable to a function. Will this work??
9
+ <p>
10
+
11
+ Variable \regal is regal, which reversed is ahpla$
12
+ <p>
13
+
14
+ That's all.
15
+ <p>
16
+
@@ -0,0 +1 @@
1
+ ACTUAL | EXPECTED
@@ -0,0 +1,16 @@
1
+ <p>
2
+
3
+ Testing STILL more functions here...
4
+ <p>
5
+
6
+ <p>
7
+
8
+ Now... let's try passing a variable to a function. Will this work??
9
+ <p>
10
+
11
+ Variable $alpha is regal, which reversed is lager
12
+ <p>
13
+
14
+ That's all.
15
+ <p>
16
+
@@ -0,0 +1,17 @@
1
+ ACTUAL | EXPECTED
2
+ <p> <p>
3
+
4
+ Testing STILL more functions here... Testing STILL more functions here...
5
+ <p> <p>
6
+
7
+ <p> <p>
8
+
9
+ Now... let's try passing a variable to a function. Will thi Now... let's try passing a variable to a function. Will thi
10
+ <p> <p>
11
+
12
+ Variable \regal is regal, which reversed is ahpla$ | Variable $alpha is regal, which reversed is lager
13
+ <p> <p>
14
+
15
+ That's all. That's all.
16
+ <p> <p>
17
+
@@ -0,0 +1,16 @@
1
+
2
+ Testing STILL more functions here...
3
+
4
+
5
+ .func reverse
6
+ param.reverse # just reverse it
7
+ .end
8
+
9
+ Now... let's try passing a variable to a function. Will this work??
10
+
11
+ .set alpha = regal
12
+
13
+ Variable \$alpha is $alpha, which reversed is $$reverse:$alpha
14
+
15
+ That's all.
16
+
data/test/snapshots.rb CHANGED
@@ -1,3 +1,12 @@
1
+ require 'simplecov' # These two lines must go first
2
+ SimpleCov.use_merging(true)
3
+ SimpleCov.start do
4
+ puts "SimpleCov: Snapshots"
5
+ add_filter "/test/"
6
+ enable_coverage :branch
7
+ primary_coverage :branch
8
+ end
9
+
1
10
  require 'minitest/autorun'
2
11
 
3
12
  require_relative '../lib/livetext'
@@ -7,10 +16,10 @@ Snapshots...
7
16
 
8
17
  NOTE that the external_files method has been replaced by the Snapshot class.
9
18
 
10
- You can add any ordinary test method above. But so far, most of these tests simply
19
+ You can add any ordinary test method above. But so far, most of these tests simply
11
20
  call Snapshot.new
12
21
 
13
- It works this way:
22
+ It works this way:
14
23
  - If the test (caller) method is test_my_silly_feature, then we will
15
24
  look for a directory called snapshots/my_silly_feature
16
25
  - In here, there must be a source.lt3
@@ -20,12 +29,12 @@ It works this way:
20
29
  - The expected-* files are "literal" data
21
30
  * compared byte-for-byte
22
31
  * watch spaces and bad regexes, etc. #duh
23
- * each of these files corresponds to a single assertion
24
- - A match-* file has two entries per line:
32
+ * each of these files corresponds to a single assertion
33
+ - A match-* file has two entries per line:
25
34
  * a ONE-BASED line number (in actual-* file)
26
35
  * a String OR a Regexp (to match against that line)
27
36
  * If there is nonsense here, it currently isn't caught
28
- * each of these files MAY correspond to many assertions
37
+ * each of these files MAY correspond to many assertions
29
38
  - We run livetext on the source and compare actual vs expected (stdout, stderr)
30
39
  - The error output gets checked first (expected or match), THEN standard output
31
40
  - Of course, both must compare correctly for the test to pass
@@ -62,7 +71,7 @@ class TestingLivetext < MiniTest::Test
62
71
  TestDirs = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
63
72
 
64
73
  Specified = []
65
- Args.each do |name|
74
+ Args.each do |name|
66
75
  which = TestDirs.select {|tdir| Regexp.new(name) =~ tdir }
67
76
  which.each {|item| Specified << item }
68
77
  end
@@ -112,7 +121,7 @@ class TestingLivetext < MiniTest::Test
112
121
  end
113
122
  unless @excluded.empty?
114
123
  puts "\nExcluded:\n "
115
- @excluded.each.with_index do |name, num|
124
+ @excluded.each.with_index do |name, num|
116
125
  printf " %-20s %s\n", name, @reasons[num]
117
126
  end
118
127
  puts
data/test/unit/all.rb CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
2
  require_relative 'standard'
3
3
  require_relative 'parser' # nested
4
- require_relative 'formatline'
4
+ # require_relative 'formatline'
5
+ require_relative 'lineparser'
6
+ require_relative 'tokenizer'