livetext 0.9.51 → 0.9.55

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/imports/bookish.rb +3 -3
  3. data/lib/livetext/core.rb +108 -53
  4. data/lib/livetext/expansion.rb +25 -9
  5. data/lib/livetext/formatter.rb +149 -162
  6. data/lib/livetext/formatter_component.rb +189 -0
  7. data/lib/livetext/function_registry.rb +163 -0
  8. data/lib/livetext/handler/mixin.rb +25 -0
  9. data/lib/livetext/helpers.rb +25 -7
  10. data/lib/livetext/reopen.rb +2 -0
  11. data/lib/livetext/skeleton.rb +0 -3
  12. data/lib/livetext/standard.rb +118 -70
  13. data/lib/livetext/variable_manager.rb +65 -0
  14. data/lib/livetext/variables.rb +4 -0
  15. data/lib/livetext/version.rb +1 -1
  16. data/lib/livetext.rb +9 -3
  17. data/plugin/booktool.rb +8 -8
  18. data/test/extra/testgen.rb +1 -3
  19. data/test/snapshots/complex_body/expected-error.txt +0 -0
  20. data/test/snapshots/complex_body/expected-output.txt +8 -0
  21. data/test/snapshots/complex_body/source.lt3 +19 -0
  22. data/test/snapshots/debug_command/expected-error.txt +0 -0
  23. data/test/snapshots/debug_command/expected-output.txt +1 -0
  24. data/test/snapshots/debug_command/source.lt3 +3 -0
  25. data/test/snapshots/def_parameters/expected-error.txt +0 -0
  26. data/test/snapshots/def_parameters/expected-output.txt +21 -0
  27. data/test/snapshots/def_parameters/source.lt3 +44 -0
  28. data/test/snapshots/functions_reflection/expected-error.txt +0 -0
  29. data/test/snapshots/functions_reflection/expected-output.txt +27 -0
  30. data/test/snapshots/functions_reflection/source.lt3 +5 -0
  31. data/test/snapshots/mixin_functions/expected-error.txt +0 -0
  32. data/test/snapshots/mixin_functions/expected-output.txt +18 -0
  33. data/test/snapshots/mixin_functions/mixin_functions.rb +11 -0
  34. data/test/snapshots/mixin_functions/source.lt3 +15 -0
  35. data/test/snapshots/multiple_functions/expected-error.txt +0 -0
  36. data/test/snapshots/multiple_functions/expected-output.txt +5 -0
  37. data/test/snapshots/multiple_functions/source.lt3 +16 -0
  38. data/test/snapshots/nested_includes/expected-error.txt +0 -0
  39. data/test/snapshots/nested_includes/expected-output.txt +68 -0
  40. data/test/snapshots/nested_includes/level2.inc +34 -0
  41. data/test/snapshots/nested_includes/level3.inc +20 -0
  42. data/test/snapshots/nested_includes/source.lt3 +49 -0
  43. data/test/snapshots/parameter_handling/expected-error.txt +0 -0
  44. data/test/snapshots/parameter_handling/expected-output.txt +7 -0
  45. data/test/snapshots/parameter_handling/source.lt3 +10 -0
  46. data/test/snapshots/subset.txt +1 -0
  47. data/test/snapshots/system_info/expected-error.txt +0 -0
  48. data/test/snapshots/system_info/expected-output.txt +18 -0
  49. data/test/snapshots/system_info/source.lt3 +16 -0
  50. data/test/snapshots.rb +3 -4
  51. data/test/test_escape.lt3 +1 -0
  52. data/test/unit/all.rb +4 -0
  53. data/test/unit/bracketed.rb +2 -2
  54. data/test/unit/core_methods.rb +137 -0
  55. data/test/unit/double.rb +1 -3
  56. data/test/unit/formatter.rb +84 -0
  57. data/test/unit/formatter_component.rb +84 -0
  58. data/test/unit/function_registry.rb +132 -0
  59. data/test/unit/functions.rb +2 -2
  60. data/test/unit/html.rb +2 -2
  61. data/test/unit/parser/general.rb +2 -2
  62. data/test/unit/parser/mixin.rb +2 -2
  63. data/test/unit/parser/set.rb +2 -2
  64. data/test/unit/parser/string.rb +2 -2
  65. data/test/unit/single.rb +1 -3
  66. data/test/unit/standard.rb +1 -3
  67. data/test/unit/stringparser.rb +2 -2
  68. data/test/unit/variable_manager.rb +71 -0
  69. data/test/unit/variables.rb +2 -2
  70. metadata +41 -3
  71. data/lib/livetext/processor.rb +0 -88
@@ -1,88 +0,0 @@
1
-
2
- # Class Processor does the actual work of processing input.
3
-
4
- class Processor
5
-
6
- include Livetext::Standard
7
-
8
- Disallowed =
9
- %i[ __binding__ __id__ __send__ class
10
- clone display dup enum_for
11
- eql? equal? extend freeze
12
- frozen? hash inspect instance_eval
13
- instance_exec instance_of? is_a? kind_of?
14
- method methods nil? object_id
15
- pretty_inspect private_methods protected_methods public_method
16
- public_methods public_send respond_to? send
17
- singleton_class singleton_method singleton_methods taint
18
- tainted? tap to_enum to_s
19
- trust untaint untrust untrusted?
20
- define_singleton_method instance_variable_defined?
21
- instance_variable_get instance_variable_set
22
- remove_instance_variable instance_variables ]
23
-
24
- attr_reader :parent, :sources
25
-
26
- def initialize(parent, output = nil) # Processor
27
- @parent = parent || self
28
- # STDERR.puts "PARENT.api = #{parent.api.inspect}"
29
- @parent.api ||= Livetext::UserAPI.new(@parent)
30
- @nopass = false
31
- @nopara = false
32
- # Meh?
33
- @output = ::Livetext.output = (output || File.open("/dev/null", "w"))
34
- @sources = []
35
- @indentation = @parent.indentation
36
- @_mixins = []
37
- @_imports = []
38
- @html = Livetext::HTML.new(@parent.api)
39
- end
40
-
41
- def api
42
- @parent.api # FIXME Is this weird??
43
- end
44
-
45
- def html
46
- @html
47
- end
48
-
49
- def output=(io)
50
- @output = io
51
- end
52
-
53
- def error(*args)
54
- ::STDERR.puts *args
55
- end
56
-
57
- def disallowed?(name)
58
- flag = Disallowed.include?(name.to_sym)
59
- flag
60
- end
61
-
62
- def source(enum, file, line)
63
- @sources.push([enum, file, line])
64
- end
65
-
66
- def peek_nextline
67
- return nil if @sources.empty?
68
- source = @sources.last
69
- line = source[0].peek
70
- line
71
- rescue StopIteration
72
- @sources.pop
73
- nil
74
- rescue => err
75
- TTY.puts "#{__method__}: RESCUE err = #{err.inspect}"
76
- nil
77
- end
78
-
79
- def nextline
80
- return nil if @sources.empty?
81
- line = @sources.last[0].next
82
- @sources.last[2] += 1
83
- line
84
- rescue StopIteration
85
- @sources.pop
86
- nil
87
- end
88
- end