notroff 0.2.3 → 0.2.4
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.
- data/lib/notroff/composite_processor.rb +1 -1
- data/lib/notroff/embedded.rb +11 -4
- metadata +1 -1
@@ -18,13 +18,13 @@ class CompositeProcessor
|
|
18
18
|
Logger.log
|
19
19
|
paras = processor.process( paras )
|
20
20
|
Logger.log "After processor #{processor.class}"
|
21
|
+
dump(paras)
|
21
22
|
Logger.log
|
22
23
|
end
|
23
24
|
paras
|
24
25
|
end
|
25
26
|
|
26
27
|
def dump(data)
|
27
|
-
return unless Verbose
|
28
28
|
Logger.log "======="
|
29
29
|
if data.nil?
|
30
30
|
Logger.log "data: nil"
|
data/lib/notroff/embedded.rb
CHANGED
@@ -71,6 +71,7 @@ class EmbeddedRubyProcessor
|
|
71
71
|
if p[:type] == :x
|
72
72
|
Logger.log p
|
73
73
|
results = process_command(p.string)
|
74
|
+
puts "**** results: #{results}"
|
74
75
|
new_paragraphs << results if results
|
75
76
|
else
|
76
77
|
new_paragraphs << p
|
@@ -81,12 +82,13 @@ class EmbeddedRubyProcessor
|
|
81
82
|
|
82
83
|
def process_command(ruby_expression)
|
83
84
|
Logger.log "Ruby expression: #{ruby_expression}"
|
84
|
-
|
85
|
+
paras = eval(ruby_expression, binding)
|
86
|
+
paras = [paras] unless paras.kind_of?(Array)
|
87
|
+
paras.map! {|p| Text.new(p, :type => :code)}
|
85
88
|
end
|
86
89
|
|
87
90
|
def embed(*filters, &block)
|
88
91
|
paras = block.call.map {|line| line.rstrip}
|
89
|
-
paras.map! {|p| Text.new(p, :type => :code)}
|
90
92
|
Logger.log "EMBED: #{paras}"
|
91
93
|
unless filters.empty?
|
92
94
|
filters.each {|f| paras = f.process(paras)}
|
@@ -99,8 +101,13 @@ class EmbeddedRubyProcessor
|
|
99
101
|
embed(*filters) {File.readlines(path)}
|
100
102
|
end
|
101
103
|
|
102
|
-
def run(
|
103
|
-
embed(*filters) {File.popen(
|
104
|
+
def run(shell_command, *filters)
|
105
|
+
embed(*filters) {File.popen(shell_command).readlines}
|
106
|
+
end
|
107
|
+
|
108
|
+
def ex(ruby_command, *filters)
|
109
|
+
puts "ruby_command: #{ruby_command}"
|
110
|
+
embed(*filters) {eval(ruby_command).to_s.split("\n")}
|
104
111
|
end
|
105
112
|
|
106
113
|
def matches(re1, re2=re1)
|