mhtml 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/lib/mhtml/document.rb +28 -1
- data/lib/mhtml/root_document.rb +4 -1
- data/lib/mhtml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60fd056e7a5ded9db6a7e18e49c982100672e084
|
4
|
+
data.tar.gz: 1236377e35f0c3176bcaa25aaa6db13757d64d63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb37bbcc90d6e0c7658cde28c89bc69e2d79315709f6d86c8ac941c3284471e7ef0d7d7c25d04f0a8cb8a33ffe79b56216d2b09a5b4bc8a75eb16b7e4caace7
|
7
|
+
data.tar.gz: '095474af649049223490a686331be4368b6956c6f0281985436c4815f91fb9ddcbd92905c1c0c86af731801bfefd5de988efccbfa60427775a1bb2a9524a02f7'
|
data/lib/mhtml/document.rb
CHANGED
@@ -3,7 +3,13 @@ require 'http-parser'
|
|
3
3
|
module Mhtml
|
4
4
|
class Document
|
5
5
|
attr_reader :chunked, :parser
|
6
|
-
|
6
|
+
|
7
|
+
attr_accessor :headers,
|
8
|
+
:body,
|
9
|
+
:is_quoted_printable,
|
10
|
+
:encoding,
|
11
|
+
:file_path,
|
12
|
+
:root_doc
|
7
13
|
|
8
14
|
def initialize(str = nil)
|
9
15
|
@chunked = !str.is_a?(String)
|
@@ -61,6 +67,23 @@ module Mhtml
|
|
61
67
|
header
|
62
68
|
end
|
63
69
|
|
70
|
+
def relative_file_path
|
71
|
+
return nil if @file_path.nil?
|
72
|
+
return @file_path if @root_doc.nil? || @root_doc.file_path.nil?
|
73
|
+
return '.' if @file_path == @root_doc.file_path
|
74
|
+
|
75
|
+
str = nil
|
76
|
+
if @file_path.start_with?(@root_doc.file_path)
|
77
|
+
start = @root_doc.file_path.length
|
78
|
+
str = @file_path[start..@file_path.length - 1]
|
79
|
+
else
|
80
|
+
str = @file_path
|
81
|
+
end
|
82
|
+
|
83
|
+
str = str[1..(str.length - 1)] if str[0] == '/'
|
84
|
+
str
|
85
|
+
end
|
86
|
+
|
64
87
|
# for testing only = no spec implemented
|
65
88
|
def to_s
|
66
89
|
@headers.join(LINE_BREAK) + Mhtml::DOUBLE_LINE_BREAK + @body
|
@@ -117,6 +140,10 @@ module Mhtml
|
|
117
140
|
if !value.nil? && value.value == 'quoted-printable'
|
118
141
|
@is_quoted_printable = true
|
119
142
|
end
|
143
|
+
|
144
|
+
elsif header.key == 'Content-Location'
|
145
|
+
value = header.values.first
|
146
|
+
@file_path = value.value unless value.nil?
|
120
147
|
end
|
121
148
|
|
122
149
|
@headers_proc.call(header) unless @headers_proc.nil?
|
data/lib/mhtml/root_document.rb
CHANGED
@@ -71,7 +71,9 @@ module Mhtml
|
|
71
71
|
is_last_part = i + 1 == parts.length
|
72
72
|
handle_chunked_body(part, is_last_part, is_last_subdoc)
|
73
73
|
else
|
74
|
-
|
74
|
+
sub_doc = Document.new(part)
|
75
|
+
sub_doc.root_doc = self
|
76
|
+
@sub_docs << sub_doc
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
@@ -110,6 +112,7 @@ module Mhtml
|
|
110
112
|
|
111
113
|
def create_chunked_subdoc
|
112
114
|
@chunked_sub_doc = Document.new
|
115
|
+
@chunked_sub_doc.root_doc = self
|
113
116
|
|
114
117
|
@chunked_sub_doc.on_header do |header|
|
115
118
|
@subdoc_header_proc.call(header) unless @subdoc_header_proc.nil?
|
data/lib/mhtml/version.rb
CHANGED