notroff 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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"
@@ -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
- lines = eval(ruby_expression, binding)
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(command, *filters)
103
- embed(*filters) {File.popen(command).readlines}
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notroff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: