diskcatalog 0.1.0 → 0.2.0

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: f0eefbdc894982861188be371c1236b7040a8c48098177c2fe136e0f852deaec
4
- data.tar.gz: 4cbc90895d7948d74b790d2976f9bb8443f53f09995e09830340512438f18bbf
3
+ metadata.gz: b472547e057c9be023aff84991ecefb6a3d85d1010e7de9d27420b3aed32f2eb
4
+ data.tar.gz: dbd3f42b6f63b554827007a98373c52372d3caaddcdc0e4a1a24517e78085967
5
5
  SHA512:
6
- metadata.gz: 5ecba185745812d17e28423f960e734cd2266919b5854befa4ea24c38d4d78216d6bfffa6b9b3837557f9ea4f683f1fdf814c9e28dbff96e94782fd7e1bdd3b3
7
- data.tar.gz: 38842a37b131d732ceda1e49660619dfe4c91e23a6620e7cb00d3a4a29ffeb4db690964b21a13740222d89667247ff98a6099a0a2bce7b360989baedc6fa2379
6
+ metadata.gz: df21bf04899b92bd001afad66f84e71517012ef0e24f8bf67e605ac6d8c4f7e2416ead0fa6519f64422f60cc9b84ee8cf1b6302bce892a584f3650202bd6768c
7
+ data.tar.gz: 74ef4bc98b74c718040fd23642f03eb4a5e713267da7774a54f830fd72ba4f9434c374822894e8177f58015e8115d79f8717f3d73897045ced9ee8f425fc8d84
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diskcatalog (0.1.0)
4
+ diskcatalog (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.14.2)
10
- rake (13.0.3)
9
+ minitest (5.19.0)
10
+ rake (13.0.6)
11
11
 
12
12
  PLATFORMS
13
13
  x64-mingw32
@@ -19,4 +19,4 @@ DEPENDENCIES
19
19
  rake (~> 13.0)
20
20
 
21
21
  BUNDLED WITH
22
- 2.3.25
22
+ 2.4.9
data/build.sh ADDED
@@ -0,0 +1,18 @@
1
+ #!/bin/sh
2
+ # rmagick for sierra
3
+ export PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig
4
+ #export PATH=/usr/local/Cellar/imagemagick@6/6.9.7-5/bin:$PATH
5
+
6
+ bundle_dir=./vendor/bundle
7
+ if [ -d "$bundle_dir" ] ; then
8
+ /bin/rm -rf "$bundle_dir"
9
+ bundle update
10
+ else
11
+ /bin/rm -rf "$bundle_dir"
12
+ bundle install --path "$bundle_dir"
13
+ fi
14
+
15
+
16
+
17
+
18
+
data/catalogrc ADDED
@@ -0,0 +1,2 @@
1
+ general:
2
+ catalogdir: ./data
File without changes
data/exe/diskcatalog CHANGED
File without changes
data/exe/mkcat ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "diskcatalog"
4
+
5
+ Diskcatalog::Command.run(ARGV)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Diskcatalog
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/diskcatalog.rb CHANGED
@@ -5,18 +5,57 @@ require_relative "diskcatalog/version"
5
5
  require 'find'
6
6
  require 'optparse'
7
7
  require 'fileutils'
8
+ require 'yaml'
8
9
 
9
10
  module Diskcatalog
10
11
  class Error < StandardError; end
11
12
 
13
+ class Config
14
+ CATALOGDIR = File.expand_path("~/.catalog")
15
+
16
+ def self.create_from_yaml(yaml)
17
+ config = Config.new
18
+ catalogdir = config_value(yaml, "general", "catalogdir", true)
19
+ if catalogdir
20
+ catalogdir = File.expand_path(catalogdir)
21
+ end
22
+ config.catalogdir = catalogdir
23
+
24
+ ## puts config.catalogdir
25
+ config.init_default
26
+ if config.catalogdir.nil? || !FileTest.directory?(config.catalogdir)
27
+ raise RuntimeError, "catalogdir is not exist: #{config.catalogdir}"
28
+ end
29
+ config
30
+ end
31
+
32
+ def self.config_value(yaml, section, key, require)
33
+ return nil unless yaml
34
+ return nil unless yaml[section]
35
+ value = yaml[section][key]
36
+ if require && (value.nil? || value.empty?)
37
+ raise RuntimeError, "#{section}:#{key}: is empty"
38
+ end
39
+ value
40
+ end
41
+
42
+ def init_default
43
+ @catalogdir ||= CATALOGDIR
44
+ end
45
+
46
+ attr_accessor :catalogdir
47
+ end
48
+
49
+
12
50
  class Option
13
- def initialize(opts, dirs)
51
+ def initialize(opts, dirs, config)
14
52
  @opts = opts
15
53
  @dir = dirs[0] if dirs.size > 0
54
+ @config = config
16
55
  @debug = @opts[:d]
17
56
  @output = @opts[:o]
18
- @output_files = @output + '.files'
19
- @output_info = @output + '.info'
57
+ @output_files = File.join(config.catalogdir, @output + '.files')
58
+ @output_info = File.join(config.catalogdir, @output + '.info')
20
59
  @debug = true
21
60
  end
22
61
  attr_reader :dir, :debug, :output, :output_files, :output_info
@@ -36,12 +75,21 @@ module Diskcatalog
36
75
  end
37
76
  opt.on('-v', '--verbose', 'verbose message') {|v| opts[:v] = v}
38
77
  opt.on('-o FILENAME', '--output=FILENAME') {|v| opts[:o] = v}
78
+ opt.on('--config=CONFIGFILE', 'Config file') {|v| opts[:c] = v }
39
79
  opt.parse!(argv)
40
80
  if opts[:o].nil?
41
81
  puts opt.help
42
82
  exit
43
83
  end
44
- option = Option.new(opts, argv)
84
+ config_file = opts[:c] || "~/.catalogrc"
85
+ puts config_file
86
+ config_file = File.expand_path(config_file)
87
+ yaml = nil
88
+ if FileTest.file?(config_file)
89
+ yaml = YAML.load_file(config_file)
90
+ end
91
+ config = Config.create_from_yaml(yaml)
92
+ option = Option.new(opts, argv, config)
45
93
  begin
46
94
  command = Command.new(option)
47
95
  command.run
data/run_mkcat.sh ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ curdir=$(dirname $0)
4
+ bundle exec ruby $curdir/exe/mkcat "$@"
5
+
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: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - src
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-08-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Create disk catalog.
14
14
  email:
@@ -16,6 +16,7 @@ email:
16
16
  executables:
17
17
  - catalogsearch.cmd
18
18
  - diskcatalog
19
+ - mkcat
19
20
  extensions: []
20
21
  extra_rdoc_files: []
21
22
  files:
@@ -25,13 +26,16 @@ files:
25
26
  - LICENSE.txt
26
27
  - README.md
27
28
  - Rakefile
29
+ - build.sh
30
+ - catalogrc
28
31
  - diskcatalog.gemspec
29
32
  - exe/catalogsearch.cmd
30
33
  - exe/diskcatalog
34
+ - exe/mkcat
31
35
  - lib/diskcatalog.rb
32
36
  - lib/diskcatalog/version.rb
33
- - run_diskcatalog.cmd
34
- - run_diskcatalog.sh
37
+ - run_mkcat.cmd
38
+ - run_mkcat.sh
35
39
  - sig/diskcatalog.rbs
36
40
  homepage: https://github.com/src256
37
41
  licenses:
@@ -55,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
59
  - !ruby/object:Gem::Version
56
60
  version: '0'
57
61
  requirements: []
58
- rubygems_version: 3.2.22
62
+ rubygems_version: 3.2.33
59
63
  signing_key:
60
64
  specification_version: 4
61
65
  summary: Create disk catalog.
data/run_diskcatalog.sh DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
-
3
- curdir=$(dirname $0)
4
- bundle exec ruby $curdir/exe/diskcatalog "$@"
File without changes