chupa-text 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/doc/text/news.md +6 -0
- data/lib/chupa-text/formatters/hash.rb +5 -2
- data/lib/chupa-text/input-data.rb +4 -3
- data/lib/chupa-text/version.rb +1 -1
- data/test/formatters/test-mime.rb +18 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a508472a3d7b4b9a0cbcf39c8090ae013bf174859fb1c9d1d558c8847787d86c
|
4
|
+
data.tar.gz: 2eb41dedf87b02b40f67c12574c517dd10b0079bf4dfe652a1e8966e6eed31f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97240067f9c2fd099109513c775a365655e168b4c3e6cd39fb1b0387ba8a1d5493eba93856aa7364265c3b499ffb73bf634041c517487ae066a3f7ca33885088
|
7
|
+
data.tar.gz: 06ae2a89ad702422f72c2b9a1967ec7cfc22102890698b1dbdb48a442be3b10f96d68ece9b7729b02d6d36bbf8ae5b6596b47cab7e0b97c0768851b76ee0caa0
|
data/doc/text/news.md
CHANGED
@@ -52,8 +52,11 @@ module ChupaText
|
|
52
52
|
def format_headers(data, target)
|
53
53
|
format_header("mime-type", data.mime_type, target)
|
54
54
|
format_header("uri", data.uri, target)
|
55
|
-
|
56
|
-
|
55
|
+
case data.uri
|
56
|
+
when URI::HTTP, URI::FTP, nil
|
57
|
+
# No path
|
58
|
+
else
|
59
|
+
format_header("path", data.path, target)
|
57
60
|
end
|
58
61
|
format_header("size", data.size, target)
|
59
62
|
data.attributes.each do |name, value|
|
@@ -23,11 +23,12 @@ module ChupaText
|
|
23
23
|
def initialize(uri, options={})
|
24
24
|
super(options)
|
25
25
|
self.uri = uri
|
26
|
-
|
27
|
-
|
28
|
-
else
|
26
|
+
case @uri
|
27
|
+
when URI::HTTP, URI::FTP
|
29
28
|
@content = download
|
30
29
|
self.path = @content.path
|
30
|
+
else
|
31
|
+
@content = FileContent.new(path)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
data/lib/chupa-text/version.rb
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
17
|
class TestMIMEFormatter < Test::Unit::TestCase
|
18
|
+
include Helper
|
19
|
+
|
18
20
|
def setup
|
19
21
|
@output = StringIO.new
|
20
22
|
@formatter = ChupaText::Formatters::MIME.new(@output)
|
@@ -31,55 +33,50 @@ class TestMIMEFormatter < Test::Unit::TestCase
|
|
31
33
|
|
32
34
|
def test_text
|
33
35
|
data = ChupaText::TextData.new("Hello")
|
34
|
-
data.uri = URI.parse("
|
36
|
+
data.uri = URI.parse("http://example.com/hello.txt")
|
35
37
|
assert_equal(<<-MIME.gsub(/\n/, "\r\n"), format(data, [data]))
|
36
38
|
MIME-Version: 1.0
|
37
39
|
mime-type: text/plain
|
38
|
-
uri:
|
39
|
-
path: /tmp/hello.txt
|
40
|
+
uri: http://example.com/hello.txt
|
40
41
|
size: 5
|
41
|
-
Content-Type: multipart/mixed; boundary=
|
42
|
+
Content-Type: multipart/mixed; boundary=e37eebaf33e7c817702a3ceb4b86260a936b2503
|
42
43
|
|
43
|
-
--
|
44
|
+
--e37eebaf33e7c817702a3ceb4b86260a936b2503
|
44
45
|
mime-type: text/plain
|
45
|
-
uri:
|
46
|
-
path: /tmp/hello.txt
|
46
|
+
uri: http://example.com/hello.txt
|
47
47
|
size: 5
|
48
48
|
|
49
49
|
Hello
|
50
|
-
--
|
50
|
+
--e37eebaf33e7c817702a3ceb4b86260a936b2503--
|
51
51
|
MIME
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_texts
|
55
55
|
data = ChupaText::Data.new
|
56
|
-
data.uri = URI.parse("
|
56
|
+
data.uri = URI.parse("http://example.com/hello-world.zip")
|
57
57
|
data1 = ChupaText::TextData.new("Hello")
|
58
|
-
data1.uri = URI.parse("
|
58
|
+
data1.uri = URI.parse("http://example.com/hello-world.zip/hello.txt")
|
59
59
|
data2 = ChupaText::TextData.new("World")
|
60
|
-
data2.uri = URI.parse("
|
60
|
+
data2.uri = URI.parse("http://example.com/hello-world.zip/world.txt")
|
61
61
|
assert_equal(<<-MIME.gsub(/\n/, "\r\n"), format(data, [data1, data2]))
|
62
62
|
MIME-Version: 1.0
|
63
63
|
mime-type: application/zip
|
64
|
-
uri:
|
65
|
-
|
66
|
-
Content-Type: multipart/mixed; boundary=e53a82b45aee7c6a07ea51dcf930118dedf7da4d
|
64
|
+
uri: http://example.com/hello-world.zip
|
65
|
+
Content-Type: multipart/mixed; boundary=2982df00a82c74bdb9d9c6dd5bf007d435c352c9
|
67
66
|
|
68
|
-
--
|
67
|
+
--2982df00a82c74bdb9d9c6dd5bf007d435c352c9
|
69
68
|
mime-type: text/plain
|
70
|
-
uri:
|
71
|
-
path: /tmp/hello.txt
|
69
|
+
uri: http://example.com/hello-world.zip/hello.txt
|
72
70
|
size: 5
|
73
71
|
|
74
72
|
Hello
|
75
|
-
--
|
73
|
+
--2982df00a82c74bdb9d9c6dd5bf007d435c352c9
|
76
74
|
mime-type: text/plain
|
77
|
-
uri:
|
78
|
-
path: /tmp/world.txt
|
75
|
+
uri: http://example.com/hello-world.zip/world.txt
|
79
76
|
size: 5
|
80
77
|
|
81
78
|
World
|
82
|
-
--
|
79
|
+
--2982df00a82c74bdb9d9c6dd5bf007d435c352c9--
|
83
80
|
MIME
|
84
81
|
end
|
85
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chupa-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: archive-zip
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
version: '0'
|
210
210
|
requirements: []
|
211
211
|
rubyforge_project:
|
212
|
-
rubygems_version:
|
212
|
+
rubygems_version: 3.0.0.beta1
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: ChupaText is an extensible text extractor. You can plug your custom text
|