diskcatalog 1.2.3 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 924717b99bcbe0a071819b38a67893a99dcdbed0cb0c4fc6f3e48309838f3614
4
- data.tar.gz: e72b0379e4348cf604e285e91f5ee5728855ab15d693302889c6f2524d485798
3
+ metadata.gz: 4e0ad770b5bfab040d17787bfe39cb4f58b6a529c97ef1794bfa02cae9dc2534
4
+ data.tar.gz: cf0fab667155ab200608b10727f56efbf360cdb947ade106bd5b9065a3c9087a
5
5
  SHA512:
6
- metadata.gz: 86112b38aab32e6cfce76f94d1e9a737fdaf0915d40b2693c4198d05f5d813c98303bd9f44fa7b71229862ceb8ba9d8ad3f19370f9b434198842c61d8e4aa8b4
7
- data.tar.gz: 10b5729e36cfb3f3317b909d892e66dc39a2da63e6600778923218e8c211b374b2e9defb511fd92c50f78f7ff27e5bf629210e360d3c8b58cfea949013f23a5f
6
+ metadata.gz: 2474841f69413fc77f299293088b19ce423faa63dea352d47927b24f28eeaa6cdc54a38f044e458e08f6ed1eaf401966c59e45b9816c6b60992e8c9ef82b3570
7
+ data.tar.gz: 0e6f952649a11a2cfc851262a71c3654af582eaa9f334680c98015e6ede2968794c10ba3e7e8b2b2c1dcf3fd38da73fd7378c4e394dff12a482abb396a4d24a2
@@ -56,7 +56,7 @@
56
56
  </library>
57
57
  </orderEntry>
58
58
  <orderEntry type="module-library">
59
- <library name="minitest (v5.25.4) [path][gem]" type="rubylib">
59
+ <library name="minitest (v5.25.5) [path][gem]" type="rubylib">
60
60
  <properties>
61
61
  <option name="additionalInfo">
62
62
  <AdditionalInfo>
@@ -73,20 +73,20 @@
73
73
  <option value="lib" />
74
74
  </list>
75
75
  </option>
76
- <option name="url" value="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.4" />
77
- <option name="version" value="5.25.4" />
76
+ <option name="url" value="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.5" />
77
+ <option name="version" value="5.25.5" />
78
78
  </properties>
79
79
  <CLASSES>
80
- <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.4/lib" />
81
- <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.4/test" />
80
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.5/lib" />
81
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.5/test" />
82
82
  </CLASSES>
83
83
  <JAVADOC />
84
84
  <SOURCES>
85
- <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.4/lib" />
86
- <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.4/test" />
85
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.5/lib" />
86
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.5/test" />
87
87
  </SOURCES>
88
88
  <excluded>
89
- <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.4/test" />
89
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/minitest-5.25.5/test" />
90
90
  </excluded>
91
91
  </library>
92
92
  </orderEntry>
@@ -169,6 +169,41 @@
169
169
  </excluded>
170
170
  </library>
171
171
  </orderEntry>
172
+ <orderEntry type="module-library">
173
+ <library name="zlib (v3.2.1) [path][gem]" type="rubylib">
174
+ <properties>
175
+ <option name="additionalInfo">
176
+ <AdditionalInfo>
177
+ <option name="authors" value="該当なし" />
178
+ <option name="email" value="該当なし" />
179
+ <option name="homepage" value="該当なし" />
180
+ <option name="summary" value="該当なし" />
181
+ </AdditionalInfo>
182
+ </option>
183
+ <option name="fromPath" value="true" />
184
+ <option name="name" value="zlib" />
185
+ <option name="requirePaths">
186
+ <list>
187
+ <option value="lib" />
188
+ </list>
189
+ </option>
190
+ <option name="url" value="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/zlib-3.2.1" />
191
+ <option name="version" value="3.2.1" />
192
+ </properties>
193
+ <CLASSES>
194
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/zlib-3.2.1/ext" />
195
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/zlib-3.2.1/lib" />
196
+ </CLASSES>
197
+ <JAVADOC />
198
+ <SOURCES>
199
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/zlib-3.2.1/ext" />
200
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/zlib-3.2.1/lib" />
201
+ </SOURCES>
202
+ <excluded>
203
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.2.0/gems/zlib-3.2.1/ext" />
204
+ </excluded>
205
+ </library>
206
+ </orderEntry>
172
207
  <orderEntry type="library" scope="PROVIDED" name="bundler (v2.4.19, rbenv: 3.2.5) [gem]" level="application" />
173
208
  </component>
174
209
  </module>
data/Gemfile.lock CHANGED
@@ -1,20 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diskcatalog (1.2.3)
4
+ diskcatalog (1.3.1)
5
5
  sys-filesystem
6
+ zlib
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  ffi (1.17.1)
11
- minitest (5.25.4)
12
+ minitest (5.25.5)
12
13
  rake (13.2.1)
13
14
  sys-filesystem (1.5.3)
14
15
  ffi (~> 1.1)
16
+ zlib (3.2.1)
15
17
 
16
18
  PLATFORMS
17
19
  arm64-darwin-22
20
+ x64-mingw-ucrt
18
21
  x64-mingw32
19
22
  x86_64-darwin-22
20
23
  x86_64-darwin-24
data/diskcatalog.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
  spec.add_dependency "sys-filesystem"
33
+ spec.add_dependency "zlib"
33
34
  # Uncomment to register a new dependency of your gem
34
35
  # spec.add_dependency "example-gem", "~> 1.0"
35
36
 
data/exe/dcatz ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'zlib'
4
+
5
+
6
+ def zcat(filename)
7
+ return unless filename
8
+ return unless FileTest.file?(filename)
9
+ if filename =~ /\.gz$/
10
+ Zlib::GzipReader.open(filename) do |gz|
11
+ print gz.read
12
+ end
13
+ return
14
+ end
15
+ File.open(filename, 'rb') do |f|
16
+ while (line = f.gets)
17
+ print line
18
+ end
19
+ end
20
+ end
21
+
22
+ filename = ARGV[0]
23
+ zcat(filename)
24
+
25
+
@@ -18,6 +18,10 @@ module Diskcatalog
18
18
  '%.1f TB' % (size / tb)
19
19
  end.sub('.0', '')
20
20
  end
21
+
22
+ def self.windows?
23
+ RUBY_PLATFORM =~ /mswin|mingw|bccwin|cygwin/
24
+ end
21
25
  end
22
26
  end
23
27
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Diskcatalog
4
- VERSION = "1.2.3"
4
+ VERSION = "1.3.1"
5
5
  end
data/lib/diskcatalog.rb CHANGED
@@ -9,6 +9,7 @@ require 'optparse'
9
9
  require 'fileutils'
10
10
  require 'yaml'
11
11
  require 'sys/filesystem'
12
+ require 'zlib'
12
13
 
13
14
  module Diskcatalog
14
15
  DEF_CONFIG = File.expand_path("~/.catalogrc")
@@ -77,13 +78,23 @@ module Diskcatalog
77
78
  @dir = argv[0]
78
79
  end
79
80
 
81
+ @debug = @opts[:d]
82
+ @compress = @opts[:z]
80
83
  @output = @opts[:o]
81
84
  if @output
82
85
  @output_files = File.join(catalogdir, @output + '.files')
83
86
  @output_info = File.join(catalogdir, @output + '.info')
84
87
  end
85
88
  end
86
- attr_reader :dir, :search, :debug, :output, :output_files, :output_info
89
+ attr_reader :dir, :search, :debug, :output, :output_files, :output_info, :compress, :debug
90
+
91
+ def output_files
92
+ if compress
93
+ @output_files + '.gz'
94
+ else
95
+ @output_files
96
+ end
97
+ end
87
98
  end
88
99
 
89
100
  class SearchOption < Option
@@ -92,7 +103,7 @@ module Diskcatalog
92
103
  @search = nil
93
104
  if argv.size > 0
94
105
  @search = argv[0]
95
- end
106
+ end
96
107
  raise "SEARCH is not specified" unless @search
97
108
  end
98
109
  attr_reader :search
@@ -133,6 +144,8 @@ module Diskcatalog
133
144
  opt.on('-v', '--verbose', 'verbose message') {|v| opts[:v] = v}
134
145
  opt.on('-o FILENAME', '--output=FILENAME') {|v| opts[:o] = v}
135
146
  opt.on('--config=CONFIGFILE', 'Config file') {|v| opts[:c] = v }
147
+ opt.on('-d', '--debug', 'debug message') {|v| opts[:d] = v}
148
+ opt.on('-z', '--gzip', 'compress with gzip') {|v| opts[:z] = v}
136
149
  opt.on('-l', '--list') {|v| opts[:l] = v}
137
150
  opt.parse!(argv)
138
151
  # if opts[:o].nil?
@@ -175,7 +188,14 @@ module Diskcatalog
175
188
  unless FileTest.directory?(@option.dir)
176
189
  raise RuntimeError
177
190
  end
178
- out = File.open(@option.output_files, "w:utf-8")
191
+
192
+ if @option.compress
193
+ out = File.open(@option.output_files, "w:utf-8")
194
+ out = Zlib::GzipWriter.open(out)
195
+ else
196
+ out = File.open(@option.output_files, "w:utf-8")
197
+ end
198
+
179
199
  begin
180
200
  MyFind.find(@option.dir, ignore_error: true) do |f|
181
201
  if FileTest.file?(f)
@@ -190,8 +210,8 @@ module Diskcatalog
190
210
  puts e.message
191
211
  if option.debug
192
212
  p e.backtrace
213
+ p e.class
193
214
  end
194
- p e.class
195
215
  end
196
216
  out.close if out
197
217
  end
@@ -262,8 +282,24 @@ module Diskcatalog
262
282
  end
263
283
  end
264
284
 
265
- def search
266
- cmd = "#{SEARCH_CMD} #{@option.search} #{@option.catalogdir}"
285
+ # def write_zcat
286
+ # cmd = <<__EOM__
287
+ # ruby -rzlib -e 'print File.extname(ARGV[0])==".gz" ? Zlib::GzipReader.open(ARGV[0]).read : File.read(ARGV[0])' %1
288
+ # __EOM__
289
+ # zcat_path = File.join(@option.catalogdir, "zcat.bat")
290
+ # File.open(zcat_path, "w:utf-8") do |f|
291
+ # f.puts cmd
292
+ # end
293
+ # zcat_path
294
+ # end
295
+
296
+ def search
297
+ precmd = "-z"
298
+ if Diskcatalog::Utils.windows?
299
+ # zcat_path=write_zcat
300
+ precmd = "--pre=dcatz.bat" # .batを指定しないとエラーとなる。
301
+ end
302
+ cmd = "#{SEARCH_CMD} #{precmd} #{@option.search} #{@option.catalogdir}"
267
303
  puts cmd if @option.debug
268
304
  system(cmd)
269
305
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diskcatalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - src
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-11 00:00:00.000000000 Z
11
+ date: 2025-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sys-filesystem
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: zlib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Create disk catalog.
28
42
  email:
29
43
  - src@srcw.net
@@ -31,6 +45,7 @@ executables:
31
45
  - catalogsearch.cmd
32
46
  - dcatc
33
47
  - dcats
48
+ - dcatz
34
49
  extensions: []
35
50
  extra_rdoc_files: []
36
51
  files:
@@ -56,6 +71,7 @@ files:
56
71
  - exe/catalogsearch.cmd
57
72
  - exe/dcatc
58
73
  - exe/dcats
74
+ - exe/dcatz
59
75
  - lib/diskcatalog.rb
60
76
  - lib/diskcatalog/my_find.rb
61
77
  - lib/diskcatalog/utils.rb