rack-pygments 0.3 → 0.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.
@@ -1,8 +1,8 @@
1
1
  require "nokogiri"
2
+ require "tempfile"
2
3
 
3
4
  module Rack
4
5
  class Pygments
5
-
6
6
  def initialize(app, opts={})
7
7
  @app = app
8
8
  @tag = opts[:html_tag].nil? ? 'highlight' : opts[:html_tag]
@@ -31,7 +31,15 @@ module Rack
31
31
  nodes = document.css(@tag)
32
32
  nodes.each do |node|
33
33
  lang = node.attribute(@attr).nil? ? 'bash' : node.attribute(@attr).value
34
- pygmentized = `echo '#{node.content}' | #{@bin} -l #{lang} -f html`
34
+
35
+ file = Tempfile.new('pygments')
36
+ file.write node.content
37
+ file.close
38
+
39
+ pygmentized = `#{@bin} -l #{lang} -f html #{file.path}`
40
+
41
+ file.delete
42
+
35
43
  node.replace(Nokogiri::HTML(pygmentized).css("div.highlight").first)
36
44
  end
37
45
  document.to_s
@@ -1,9 +1,9 @@
1
1
  module Rack
2
2
  class Pygments
3
3
  module Version
4
- STRING = "0.3"
4
+ STRING = "0.4"
5
5
  MAJOR = 0
6
- MINOR = 3
6
+ MINOR = 4
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- version: "0.3"
7
+ - 4
8
+ version: "0.4"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Bryan Goines
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-19 00:00:00 -05:00
17
+ date: 2010-07-24 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency