rack-tidy-ffi 0.2 → 0.2.1
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/rack-tidy-ffi.rb +16 -12
- data/lib/rack-tidy-ffi/version.rb +1 -1
- metadata +4 -4
data/lib/rack-tidy-ffi.rb
CHANGED
@@ -3,23 +3,27 @@ require "#{path}/tidy-machine"
|
|
3
3
|
|
4
4
|
class RackTidyFFI
|
5
5
|
attr_accessor :headers
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(app)
|
8
|
-
@app = app
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
12
|
@status, @headers, @response = @app.call(env)
|
13
|
-
# TODO: include all response attributes... needed?
|
14
|
-
# response_body = ""
|
15
|
-
# response_body = @response.each { |part| response_body += part }
|
16
13
|
if @headers["Content-Type"].include? "text/html"
|
17
|
-
|
14
|
+
body = if @response.is_a? Array
|
15
|
+
@response.first
|
16
|
+
elsif @response.is_a? Rack::BodyProxy
|
17
|
+
@response.body.first
|
18
|
+
else
|
19
|
+
@response.body
|
20
|
+
end
|
21
|
+
response = TidyMachine.new(body).tidy
|
18
22
|
response = "<!DOCTYPE HTML>\n#{response}"
|
19
23
|
@headers["Content-Length"] = response.length.to_s
|
20
24
|
@response = [response]
|
21
25
|
end
|
22
26
|
[@status, @headers, @response]
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-tidy-ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tidy_ffi
|
16
|
-
requirement: &
|
16
|
+
requirement: &2165459740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.1.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2165459740
|
25
25
|
description: Rack middleware to tidy application output using tidy_ffi gem - default
|
26
26
|
output is indented and w/ html5 doctype - works with ruby1.9
|
27
27
|
email: makevoid@gmail.com
|