rack-xslview 0.0.2 → 0.1.0

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/README.md CHANGED
@@ -27,14 +27,13 @@ xslhash.default("/path/to/output.xhtml10.xsl")
27
27
 
28
28
  # Use the middleware
29
29
  use Rack::XSLView, :myxsl => default_xsl, :noxsl => noxsl, :xslhash => xslhash
30
-
31
-
32
30
  </pre>
33
31
 
34
32
 
35
33
  Resources
36
34
  ---------
37
35
 
36
+ * <http://www.docunext.com/wiki/Rack-XSLView>
38
37
  * <http://github.com/docunext/Rack-XSLView>
39
38
 
40
39
 
data/Rakefile CHANGED
@@ -56,7 +56,7 @@ Rake::RDocTask.new do |rdoc|
56
56
  end
57
57
 
58
58
  rdoc.rdoc_dir = 'rdoc'
59
- rdoc.title = "rack-rewrite #{version}"
59
+ rdoc.title = "rack-xslview #{version}"
60
60
  rdoc.rdoc_files.include('README*')
61
61
  rdoc.rdoc_files.include('lib/**/*.rb')
62
62
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.1.0
data/lib/rack-xslview.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # MIT License
1
2
  module Rack
2
3
  class XSLView
3
4
  def initialize(app, options)
@@ -6,7 +7,7 @@ module Rack
6
7
  @myhash = {}
7
8
  @options = {:myxsl => nil}.merge(options)
8
9
  if @options[:myxsl] == nil
9
- @xslt = ::XML::XSLT.new()
10
+ @xslt = XML::XSLT.new()
10
11
  @xslt.xsl = File.join(File.dirname(__FILE__), 'output.xhtml10.xsl')
11
12
  else
12
13
  @xslt = @options[:myxsl]
@@ -25,23 +26,25 @@ module Rack
25
26
  }
26
27
  @xslt.parameters = @myhash
27
28
  end
28
- status, headers, @response = @app.call(env)
29
- [status, headers, self]
30
- end
31
- end
32
- # Need to get entire response before transforming
33
- def each(&block)
34
- mycontent = ""
35
- @response.each { |part|
36
- mycontent += part
37
- }
38
- if ((mycontent.include? "<html") || !(mycontent.include? "<"))
39
- yield mycontent
40
- else
41
- @xslt.xml = mycontent
42
- yield @xslt.serve
29
+ status, headers, body = @app.call(env)
30
+
31
+ # Obtain entire request body
32
+ parts = ''
33
+ body.each { |part| parts << part.to_s }
34
+
35
+ # TODO Refactor
36
+ if ((parts.include? "<html") || !(parts.include? "<"))
37
+ [status, headers, body]
38
+ else
39
+ headers.delete('Content-Length')
40
+ @xslt.xml = parts
41
+ newbody = @xslt.serve
42
+ headers['Content-Length'] = newbody.length.to_s
43
+ [status, headers, newbody]
44
+ end
43
45
  end
44
46
  end
47
+
45
48
  private
46
49
  def choosesheet(env)
47
50
  @options[:xslhash].each_key { |path|
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'xml/xslt'
2
3
 
3
4
  class RackXslviewTest < Test::Unit::TestCase
4
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-xslview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Lash
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-27 00:00:00 -05:00
12
+ date: 2010-02-19 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency