pdfh 3.0.1 → 3.0.2
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 +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +26 -21
- data/CHANGELOG.md +24 -15
- data/Gemfile.lock +3 -3
- data/README.md +6 -0
- data/commitlint.config.js +3 -0
- data/lib/pdfh/models/document_sub_type.rb +6 -0
- data/lib/pdfh/models/document_type.rb +1 -2
- data/lib/pdfh/utils/opt_parser.rb +27 -20
- data/lib/pdfh/utils/options.rb +1 -1
- data/lib/pdfh/version.rb +1 -1
- data/lib/pdfh.rb +1 -0
- data/pdfh.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800f047d683e60b4fafca9fc762c7df699194c916822221754de2383078e0da3
|
4
|
+
data.tar.gz: 6d10a59cdeb87d5127ff624ffad4c4fc644872ab91c8df50cd97db40f4fff0a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0caadec708ec57951c5e40192ccb84c735d652420d4bd1f0398fe3f4dc6758e3acf3ae1121459aa219275f7ef66084412cf8d7c8b07eb254f93c827513a4b9e
|
7
|
+
data.tar.gz: 125c1aebc9023315fa4355f880c25090c2f13aa34ebeadbcbcfc1481a49bb39d0112350fcd50b01844b278c45c9fa96842869ae969b8343fc600b6f4ee7740dd
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,22 +1,16 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2024-01-10 03:23:37 UTC using RuboCop version 1.59.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 8
|
10
10
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
11
11
|
Metrics/AbcSize:
|
12
12
|
Max: 25
|
13
13
|
|
14
|
-
# Offense count: 1
|
15
|
-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
|
16
|
-
# AllowedMethods: refine
|
17
|
-
Metrics/BlockLength:
|
18
|
-
Max: 26
|
19
|
-
|
20
14
|
# Offense count: 6
|
21
15
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
22
16
|
Metrics/MethodLength:
|
@@ -30,23 +24,34 @@ RSpec/AnyInstance:
|
|
30
24
|
# Offense count: 1
|
31
25
|
# Configuration parameters: CountAsOne.
|
32
26
|
RSpec/ExampleLength:
|
33
|
-
Max:
|
34
|
-
|
35
|
-
# Offense count: 2
|
36
|
-
RSpec/MultipleExpectations:
|
37
|
-
Max: 2
|
27
|
+
Max: 6
|
38
28
|
|
39
|
-
# Offense count:
|
40
|
-
# Configuration parameters:
|
41
|
-
#
|
42
|
-
RSpec/
|
29
|
+
# Offense count: 7
|
30
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
31
|
+
# Include: **/*_spec*rb*, **/spec/**/*
|
32
|
+
RSpec/FilePath:
|
43
33
|
Exclude:
|
44
|
-
- 'spec/pdfh/
|
34
|
+
- 'spec/pdfh/models/document_period_spec.rb'
|
35
|
+
- 'spec/pdfh/models/document_spec.rb'
|
36
|
+
- 'spec/pdfh/utils/console_spec.rb'
|
37
|
+
- 'spec/pdfh/utils/month_spec.rb'
|
38
|
+
- 'spec/pdfh/utils/opt_parser_spec.rb'
|
39
|
+
- 'spec/pdfh/utils/pdf_file_handler_spec.rb'
|
40
|
+
- 'spec/pdfh/utils/settings_builder_spec.rb'
|
45
41
|
|
46
|
-
# Offense count:
|
47
|
-
|
42
|
+
# Offense count: 7
|
43
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
44
|
+
# Include: **/*_spec.rb
|
45
|
+
RSpec/SpecFilePathFormat:
|
48
46
|
Exclude:
|
49
|
-
- 'spec/
|
47
|
+
- '**/spec/routing/**/*'
|
48
|
+
- 'spec/pdfh/models/document_period_spec.rb'
|
49
|
+
- 'spec/pdfh/models/document_spec.rb'
|
50
|
+
- 'spec/pdfh/utils/console_spec.rb'
|
51
|
+
- 'spec/pdfh/utils/month_spec.rb'
|
52
|
+
- 'spec/pdfh/utils/opt_parser_spec.rb'
|
53
|
+
- 'spec/pdfh/utils/pdf_file_handler_spec.rb'
|
54
|
+
- 'spec/pdfh/utils/settings_builder_spec.rb'
|
50
55
|
|
51
56
|
# Offense count: 3
|
52
57
|
# This cop supports safe autocorrection (--autocorrect).
|
data/CHANGELOG.md
CHANGED
@@ -1,31 +1,40 @@
|
|
1
|
+
## v3.0.2
|
2
|
+
- Fix `undefined method` when an invalid option is provided
|
3
|
+
- Fix and add tests to get above 90% coverage
|
4
|
+
|
5
|
+
## v3.0.1
|
6
|
+
- Refactor classes for better readability
|
7
|
+
- Upgrade to Ruby v3.3.0 and require at least Ruby 3.0.0
|
8
|
+
- Upgrade gem dependencies
|
9
|
+
|
1
10
|
## v3.0.0
|
2
|
-
|
3
|
-
|
4
|
-
|
11
|
+
- Migrate to `asdf` from `rvm`
|
12
|
+
- Upgrade old gems
|
13
|
+
- Bump to v3 (as this is project's third iteration)
|
5
14
|
|
6
15
|
## v0.2.0
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
16
|
+
- Major gem refactoring
|
17
|
+
- Change setting `base_path` to `destination_base_path`
|
18
|
+
- Add DocumentType listing option on executable file
|
19
|
+
- Add process individual documents providing type and files
|
11
20
|
```bash
|
12
21
|
pdfh -t document_type_id path/to_files.pdf
|
13
22
|
```
|
14
|
-
|
23
|
+
- Add `settings.yml` template in order to create a sample file
|
15
24
|
|
16
25
|
## v0.1.9
|
17
|
-
|
26
|
+
- Add dependencies validation at run
|
18
27
|
|
19
28
|
## v0.1.5
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
- Add `print_cmd` field in config file for information purposes
|
30
|
+
- Settings now validates an unexisting directory
|
31
|
+
- Refactor for easier maintenance
|
23
32
|
|
24
33
|
## v0.1.4
|
25
|
-
|
34
|
+
- Add titleize format when writing new file
|
26
35
|
|
27
36
|
## v0.1.3
|
28
|
-
|
37
|
+
- Fixed copy companion files, which was not copying the files.
|
29
38
|
|
30
39
|
## v0.1.2
|
31
|
-
|
40
|
+
- Initial Release
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pdfh (3.0.
|
5
|
-
colorize (~>
|
4
|
+
pdfh (3.0.2)
|
5
|
+
colorize (~> 1.1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
code-scanning-rubocop (0.6.1)
|
26
26
|
rubocop (~> 1.0)
|
27
27
|
coderay (1.1.3)
|
28
|
-
colorize (
|
28
|
+
colorize (1.1.0)
|
29
29
|
concurrent-ruby (1.2.2)
|
30
30
|
connection_pool (2.4.1)
|
31
31
|
diff-lcs (1.5.0)
|
data/README.md
CHANGED
@@ -76,6 +76,12 @@ build pdfh.gemspec
|
|
76
76
|
gem install pdfh-*
|
77
77
|
```
|
78
78
|
|
79
|
+
### Conventional Commits
|
80
|
+
```bash
|
81
|
+
npm install -g @commitlint/cli @commitlint/config-conventional
|
82
|
+
commitlint --from origin --to @
|
83
|
+
```
|
84
|
+
|
79
85
|
## Contributing
|
80
86
|
|
81
87
|
Bug reports and pull requests are welcome on GitHub at https://github.com/iax7/pdfh. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Pdfh
|
4
|
-
|
5
|
-
|
4
|
+
# Represents a type of document that can be processed by pdfh
|
6
5
|
DocumentType = Struct.new(:name, :re_file, :re_date, :pwd, :store_path, :name_template, :sub_types, :print_cmd,
|
7
6
|
keyword_init: true) do
|
8
7
|
# @return [self]
|
@@ -13,25 +13,9 @@ module Pdfh
|
|
13
13
|
opts.separator "Specific options:"
|
14
14
|
|
15
15
|
opts.on("-tID", "--type=ID", "Document type id (requires a trailing file list)")
|
16
|
-
opts.on_tail("-T", "--list-types", "List document types in configuration")
|
17
|
-
|
18
|
-
|
19
|
-
max_width = settings.document_types.map { |t| t.gid.size }.max
|
20
|
-
puts "#{" " * ident}#{"ID".ljust(max_width)} Type Name"
|
21
|
-
puts "#{" " * ident}#{"—" * max_width} #{"—" * 23}"
|
22
|
-
settings.document_types.each do |type|
|
23
|
-
puts "#{" " * ident}#{type.gid.ljust(max_width).yellow} #{type.name.inspect}"
|
24
|
-
end
|
25
|
-
exit
|
26
|
-
end
|
27
|
-
opts.on_tail("-V", "--version", "Show version") do
|
28
|
-
puts "#{opts.program_name} v#{Pdfh::VERSION}"
|
29
|
-
exit
|
30
|
-
end
|
31
|
-
opts.on_tail("-h", "--help", "help (this dialog)") do
|
32
|
-
puts opts
|
33
|
-
exit
|
34
|
-
end
|
16
|
+
opts.on_tail("-T", "--list-types", "List document types in configuration") { list_types || exit }
|
17
|
+
opts.on_tail("-V", "--version", "Show version") { version || exit }
|
18
|
+
opts.on_tail("-h", "--help", "help (this dialog)") { help || exit }
|
35
19
|
|
36
20
|
opts.on("-v", "--verbose", "Show more output. Useful for debug")
|
37
21
|
opts.on("-d", "--dry", "Dry run, does not write new pdf")
|
@@ -47,10 +31,33 @@ module Pdfh
|
|
47
31
|
options[:files] = ARGV if ARGV.any?
|
48
32
|
options.transform_keys { |key| key.to_s.tr("-", "_").to_sym }
|
49
33
|
rescue OptionParser::InvalidOption => e
|
50
|
-
error_print
|
34
|
+
Pdfh.error_print(e.message, exit_app: false)
|
51
35
|
puts OPT_PARSER.help
|
52
36
|
exit 1
|
53
37
|
end
|
38
|
+
|
39
|
+
# @return [nil]
|
40
|
+
def version
|
41
|
+
puts "#{OPT_PARSER.program_name} v#{Pdfh::VERSION}"
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [nil]
|
45
|
+
def help
|
46
|
+
puts OPT_PARSER
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [nil]
|
50
|
+
def list_types
|
51
|
+
settings = SettingsBuilder.build
|
52
|
+
ident = 4
|
53
|
+
max_width = settings.document_types.map { |t| t.gid.size }.max
|
54
|
+
puts "#{" " * ident}#{"ID".ljust(max_width)} Type Name"
|
55
|
+
puts "#{" " * ident}#{"—" * max_width} #{"—" * 23}"
|
56
|
+
settings.document_types.each do |type|
|
57
|
+
puts "#{" " * ident}#{type.gid.ljust(max_width).yellow} #{type.name.inspect}"
|
58
|
+
end
|
59
|
+
nil
|
60
|
+
end
|
54
61
|
end
|
55
62
|
end
|
56
63
|
end
|
data/lib/pdfh/utils/options.rb
CHANGED
data/lib/pdfh/version.rb
CHANGED
data/lib/pdfh.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative "ext/string"
|
|
12
12
|
# Models
|
13
13
|
require_relative "pdfh/models/document"
|
14
14
|
require_relative "pdfh/models/document_period"
|
15
|
+
require_relative "pdfh/models/document_sub_type"
|
15
16
|
require_relative "pdfh/models/document_type"
|
16
17
|
require_relative "pdfh/models/settings"
|
17
18
|
|
data/pdfh.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
# Uncomment to register a new dependency of your gem
|
35
|
-
spec.add_dependency "colorize", "~>
|
35
|
+
spec.add_dependency "colorize", "~> 1.1.0"
|
36
36
|
|
37
37
|
# For more information and examples about making a new gem, checkout our
|
38
38
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdfh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaias Piña
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.1.0
|
27
27
|
description: Examine all PDF files in Look up directories, remove password (if has
|
28
28
|
one), rename and copy to a new directory using regular expressions.
|
29
29
|
email:
|
@@ -48,12 +48,14 @@ files:
|
|
48
48
|
- bin/console
|
49
49
|
- bin/run
|
50
50
|
- bin/setup
|
51
|
+
- commitlint.config.js
|
51
52
|
- exe/pdfh
|
52
53
|
- lib/ext/string.rb
|
53
54
|
- lib/pdfh.rb
|
54
55
|
- lib/pdfh/main.rb
|
55
56
|
- lib/pdfh/models/document.rb
|
56
57
|
- lib/pdfh/models/document_period.rb
|
58
|
+
- lib/pdfh/models/document_sub_type.rb
|
57
59
|
- lib/pdfh/models/document_type.rb
|
58
60
|
- lib/pdfh/models/settings.rb
|
59
61
|
- lib/pdfh/settings_template.rb
|