chupa-text 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -2
- data/chupa-text.gemspec +2 -8
- data/doc/text/news.md +18 -0
- data/lib/chupa-text/data.rb +16 -8
- data/lib/chupa-text/text-data.rb +1 -2
- data/lib/chupa-text/version.rb +2 -2
- data/test/decomposers/test-csv.rb +1 -1
- data/test/helper.rb +4 -0
- data/test/run-test.rb +1 -0
- data/test/test-default-logger.rb +29 -20
- data/test/test-external-command.rb +1 -0
- metadata +6 -79
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d81031d80654a357700972d1443aea5994ba4e3f4a1684e670a19b7041b12073
|
4
|
+
data.tar.gz: 17d66e6f6660066fd8c4fd83baf01eee8c2296a2a7a777ab7c0db3bbf9917d56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3ab55e7923da653b4c277491712e6564db633b664830ad2153b60b0ada7d09de69576074a0a3592406b03041f09990fa7a0daf0fd3f99d798543d22d5416a2c
|
7
|
+
data.tar.gz: ab8e04142b49119e51c9d7da40776efc674e75034148670c7f921a06320896426f7aba99a42ff467a97d07bd89c776bc4e04ddfa788ce826d51481baf8890470
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# -*- mode: ruby
|
1
|
+
# -*- mode: ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013 Kouhei
|
3
|
+
# Copyright (C) 2013-2024 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -19,3 +19,11 @@
|
|
19
19
|
source "https://rubygems.org/"
|
20
20
|
|
21
21
|
gemspec
|
22
|
+
|
23
|
+
gem "bundler"
|
24
|
+
gem "kramdown"
|
25
|
+
gem "nokogiri"
|
26
|
+
gem "packnga"
|
27
|
+
gem "rake"
|
28
|
+
gem "test-unit"
|
29
|
+
gem "webrick"
|
data/chupa-text.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013-
|
3
|
+
# Copyright (C) 2013-2024 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -52,12 +52,6 @@ Gem::Specification.new do |spec|
|
|
52
52
|
|
53
53
|
spec.add_runtime_dependency("archive-zip", ">= 0.12.0")
|
54
54
|
spec.add_runtime_dependency("csv", ">= 3.0.4")
|
55
|
+
spec.add_runtime_dependency("logger")
|
55
56
|
spec.add_runtime_dependency("rexml")
|
56
|
-
|
57
|
-
spec.add_development_dependency("bundler")
|
58
|
-
spec.add_development_dependency("kramdown")
|
59
|
-
spec.add_development_dependency("nokogiri")
|
60
|
-
spec.add_development_dependency("packnga")
|
61
|
-
spec.add_development_dependency("rake")
|
62
|
-
spec.add_development_dependency("test-unit")
|
63
57
|
end
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 1.3.4: 2024-09-22
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Windows: Fixed file URI.
|
8
|
+
* GH-7
|
9
|
+
* Patch by Abe Tomoaki
|
10
|
+
|
11
|
+
* `ChupaText::TextData`: Fixed path generation.
|
12
|
+
* GH-13
|
13
|
+
* Patch by Abe Tomoaki
|
14
|
+
|
15
|
+
* Added `logger` dependency explicitly for Ruby 3.4.
|
16
|
+
|
17
|
+
### Thanks
|
18
|
+
|
19
|
+
* Abe Tomoaki
|
20
|
+
|
3
21
|
## 1.3.3: 2022-02-01
|
4
22
|
|
5
23
|
### Improvements
|
data/lib/chupa-text/data.rb
CHANGED
@@ -136,14 +136,7 @@ module ChupaText
|
|
136
136
|
def uri=(uri)
|
137
137
|
case uri
|
138
138
|
when Pathname
|
139
|
-
file_uri =
|
140
|
-
target = uri.expand_path
|
141
|
-
loop do
|
142
|
-
target, base = target.split
|
143
|
-
file_uri = "/#{CGI.escape(base.to_s)}#{file_uri}"
|
144
|
-
break if target.root?
|
145
|
-
end
|
146
|
-
file_uri = "file://#{file_uri}"
|
139
|
+
file_uri = convert_pathname_to_file_uri(uri)
|
147
140
|
@uri = URI.parse(file_uri)
|
148
141
|
self.path = uri
|
149
142
|
when NilClass
|
@@ -244,6 +237,21 @@ module ChupaText
|
|
244
237
|
end
|
245
238
|
|
246
239
|
private
|
240
|
+
def convert_pathname_to_file_uri(path)
|
241
|
+
components = []
|
242
|
+
escaped_path = nil
|
243
|
+
target = path.expand_path
|
244
|
+
loop do
|
245
|
+
target, base = target.split
|
246
|
+
components.unshift(CGI.escape(base.to_s))
|
247
|
+
if target.root?
|
248
|
+
escaped_path = target + components.join("/")
|
249
|
+
break
|
250
|
+
end
|
251
|
+
end
|
252
|
+
"file://#{escaped_path}"
|
253
|
+
end
|
254
|
+
|
247
255
|
def guess_mime_type
|
248
256
|
guess_mime_type_from_uri or
|
249
257
|
guess_mime_type_from_body
|
data/lib/chupa-text/text-data.rb
CHANGED
@@ -18,8 +18,7 @@ module ChupaText
|
|
18
18
|
class TextData < Data
|
19
19
|
def initialize(text, options={})
|
20
20
|
super(options)
|
21
|
-
self.uri =
|
22
|
-
self.path = path.to_s.gsub(/\.[a-z\d]+\z/i, ".txt")
|
21
|
+
self.uri = Pathname(path.to_s.gsub(/\.[a-z\d]+\z/i, ".txt"))
|
23
22
|
self.mime_type = "text/plain"
|
24
23
|
self.body = text
|
25
24
|
self.size = text.bytesize
|
data/lib/chupa-text/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013-
|
1
|
+
# Copyright (C) 2013-2022 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,5 +15,5 @@
|
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
17
|
module ChupaText
|
18
|
-
VERSION = "1.3.
|
18
|
+
VERSION = "1.3.4"
|
19
19
|
end
|
data/test/helper.rb
CHANGED
data/test/run-test.rb
CHANGED
data/test/test-default-logger.rb
CHANGED
@@ -52,8 +52,11 @@ class TestDefaultLogger < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_string
|
55
|
-
|
56
|
-
|
55
|
+
Tempfile.create("chupa-text-default-logger-output") do |file|
|
56
|
+
device = output(file.path)
|
57
|
+
device.close
|
58
|
+
assert_equal(file.path, device.path)
|
59
|
+
end
|
57
60
|
end
|
58
61
|
|
59
62
|
def test_default
|
@@ -63,12 +66,14 @@ class TestDefaultLogger < Test::Unit::TestCase
|
|
63
66
|
|
64
67
|
sub_test_case("rotation period") do
|
65
68
|
def rotation_period(value)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
Tempfile.create("chupa-text-default-logger-output") do |file|
|
70
|
+
ENV["CHUPA_TEXT_LOG_OUTPUT"] = file.path
|
71
|
+
ENV["CHUPA_TEXT_LOG_ROTATION_PERIOD"] = value
|
72
|
+
logger = ChupaText::DefaultLogger.new
|
73
|
+
logger.close
|
74
|
+
device = logger.instance_variable_get(:@logdev)
|
75
|
+
device.instance_variable_get(:@shift_age)
|
76
|
+
end
|
72
77
|
end
|
73
78
|
|
74
79
|
def test_daily
|
@@ -94,12 +99,14 @@ class TestDefaultLogger < Test::Unit::TestCase
|
|
94
99
|
|
95
100
|
sub_test_case("N generation") do
|
96
101
|
def n_generations(value)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
102
|
+
Tempfile.create("chupa-text-default-logger-output") do |file|
|
103
|
+
ENV["CHUPA_TEXT_LOG_OUTPUT"] = file.path
|
104
|
+
ENV["CHUPA_TEXT_LOG_N_GENERATIONS"] = value
|
105
|
+
logger = ChupaText::DefaultLogger.new
|
106
|
+
logger.close
|
107
|
+
device = logger.instance_variable_get(:@logdev)
|
108
|
+
device.instance_variable_get(:@shift_age)
|
109
|
+
end
|
103
110
|
end
|
104
111
|
|
105
112
|
def test_integer
|
@@ -117,12 +124,14 @@ class TestDefaultLogger < Test::Unit::TestCase
|
|
117
124
|
|
118
125
|
sub_test_case("max size") do
|
119
126
|
def max_size(value)
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
127
|
+
Tempfile.create("chupa-text-default-logger-output") do |file|
|
128
|
+
ENV["CHUPA_TEXT_LOG_OUTPUT"] = file.path
|
129
|
+
ENV["CHUPA_TEXT_LOG_MAX_SIZE"] = value
|
130
|
+
logger = ChupaText::DefaultLogger.new
|
131
|
+
logger.close
|
132
|
+
device = logger.instance_variable_get(:@logdev)
|
133
|
+
device.instance_variable_get(:@shift_size)
|
134
|
+
end
|
126
135
|
end
|
127
136
|
|
128
137
|
def test_unit
|
@@ -305,6 +305,7 @@ class TestExternalCommand < Test::Unit::TestCase
|
|
305
305
|
class TestLimitAS < self
|
306
306
|
def setup
|
307
307
|
omit_on_windows("RLIMIT_AS doesn't exist")
|
308
|
+
omit_on_macos("RLIMIT_AS doesn't exist")
|
308
309
|
@data = ChupaText::TextData.new("Hello")
|
309
310
|
limit_as = ChupaText::ExternalCommand.default_limit_as
|
310
311
|
begin
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chupa-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sutou Kouhei
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2024-09-22 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: archive-zip
|
@@ -39,7 +38,7 @@ dependencies:
|
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: 3.0.4
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
41
|
+
name: logger
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - ">="
|
@@ -53,83 +52,13 @@ dependencies:
|
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: '0'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: kramdown
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: nokogiri
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: packnga
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: test-unit
|
55
|
+
name: rexml
|
127
56
|
requirement: !ruby/object:Gem::Requirement
|
128
57
|
requirements:
|
129
58
|
- - ">="
|
130
59
|
- !ruby/object:Gem::Version
|
131
60
|
version: '0'
|
132
|
-
type: :
|
61
|
+
type: :runtime
|
133
62
|
prerelease: false
|
134
63
|
version_requirements: !ruby/object:Gem::Requirement
|
135
64
|
requirements:
|
@@ -289,7 +218,6 @@ homepage: http://ranguba.org/#about-chupa-text
|
|
289
218
|
licenses:
|
290
219
|
- LGPL-2.1+
|
291
220
|
metadata: {}
|
292
|
-
post_install_message:
|
293
221
|
rdoc_options: []
|
294
222
|
require_paths:
|
295
223
|
- lib
|
@@ -304,8 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
232
|
- !ruby/object:Gem::Version
|
305
233
|
version: '0'
|
306
234
|
requirements: []
|
307
|
-
rubygems_version: 3.
|
308
|
-
signing_key:
|
235
|
+
rubygems_version: 3.6.0.dev
|
309
236
|
specification_version: 4
|
310
237
|
summary: ChupaText is an extensible text extractor. You can plug your custom text
|
311
238
|
extractor in ChupaText. You can write your plugin by Ruby.
|