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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97113be234e69a94d3710448d9468f4138fc7aa686275201c9f2441ed6fd217b
4
- data.tar.gz: be11f97456e1511bb91fed287485a456c9a8db7fafc4357d8cf0784dfb444a0e
3
+ metadata.gz: d81031d80654a357700972d1443aea5994ba4e3f4a1684e670a19b7041b12073
4
+ data.tar.gz: 17d66e6f6660066fd8c4fd83baf01eee8c2296a2a7a777ab7c0db3bbf9917d56
5
5
  SHA512:
6
- metadata.gz: 4f4ebd3d6fdb67b2f70e73841325586e80b2a5ff94178d4f25066072890af613571939d2bfb0f12ff1465a4c4cacbcccc6a0a50bda0a5514ca247709f0b45d09
7
- data.tar.gz: 3ae71d85db976f28f731df669fe2eddfc93d5cb94a176e01ef2298b5a4a5eaf5848fc33a1c10a70c286f00ca41773b00f3962bef0cf635399fa315b58bba4937
6
+ metadata.gz: e3ab55e7923da653b4c277491712e6564db633b664830ad2153b60b0ada7d09de69576074a0a3592406b03041f09990fa7a0daf0fd3f99d798543d22d5416a2c
7
+ data.tar.gz: ab8e04142b49119e51c9d7da40776efc674e75034148670c7f921a06320896426f7aba99a42ff467a97d07bd89c776bc4e04ddfa788ce826d51481baf8890470
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- # -*- mode: ruby; coding: utf-8 -*-
1
+ # -*- mode: ruby -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
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-2020 Sutou Kouhei <kou@clear-code.com>
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
@@ -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
@@ -18,8 +18,7 @@ module ChupaText
18
18
  class TextData < Data
19
19
  def initialize(text, options={})
20
20
  super(options)
21
- self.uri = uri.to_s.gsub(/\.[a-z\d]+\z/i, ".txt")
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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
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.3"
18
+ VERSION = "1.3.4"
19
19
  end
@@ -39,7 +39,7 @@ Ruby,ChupaText
39
39
  [
40
40
  :error,
41
41
  "[decomposer][csv] Failed to parse CSV: " +
42
- "CSV::MalformedCSVError: " +
42
+ "CSV::InvalidEncodingError: " +
43
43
  "Invalid byte sequence in UTF-8 in line 1.",
44
44
  ],
45
45
  ],
data/test/helper.rb CHANGED
@@ -49,4 +49,8 @@ module Helper
49
49
  def omit_on_windows(message)
50
50
  omit("Omit on Windows: #{message}") if Gem.win_platform?
51
51
  end
52
+
53
+ def omit_on_macos(message)
54
+ omit("Omit on macOS: #{message}") if RUBY_PLATFORM.include?("darwin")
55
+ end
52
56
  end
data/test/run-test.rb CHANGED
@@ -34,4 +34,5 @@ ChupaText::Decomposers.load
34
34
 
35
35
  require_relative "helper"
36
36
 
37
+ ENV["TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"] = "1_000_000"
37
38
  exit(Test::Unit::AutoRunner.run(true, test_dir.to_s))
@@ -52,8 +52,11 @@ class TestDefaultLogger < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  def test_string
55
- file = Tempfile.new("chupa-text-default-logger-output")
56
- assert_equal(file.path, output(file.path).path)
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
- file = Tempfile.new("chupa-text-default-logger-output")
67
- ENV["CHUPA_TEXT_LOG_OUTPUT"] = file.path
68
- ENV["CHUPA_TEXT_LOG_ROTATION_PERIOD"] = value
69
- logger = ChupaText::DefaultLogger.new
70
- device = logger.instance_variable_get(:@logdev)
71
- device.instance_variable_get(:@shift_age)
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
- file = Tempfile.new("chupa-text-default-logger-output")
98
- ENV["CHUPA_TEXT_LOG_OUTPUT"] = file.path
99
- ENV["CHUPA_TEXT_LOG_N_GENERATIONS"] = value
100
- logger = ChupaText::DefaultLogger.new
101
- device = logger.instance_variable_get(:@logdev)
102
- device.instance_variable_get(:@shift_age)
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
- file = Tempfile.new("chupa-text-default-logger-output")
121
- ENV["CHUPA_TEXT_LOG_OUTPUT"] = file.path
122
- ENV["CHUPA_TEXT_LOG_MAX_SIZE"] = value
123
- logger = ChupaText::DefaultLogger.new
124
- device = logger.instance_variable_get(:@logdev)
125
- device.instance_variable_get(:@shift_size)
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.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: 2022-02-01 00:00:00.000000000 Z
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: rexml
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: bundler
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: :development
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.4.0.dev
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.