pdfh 3.0.2 → 3.1.0
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 +3 -0
- data/.rubocop_todo.yml +5 -8
- data/Gemfile +1 -0
- data/Gemfile.lock +51 -35
- data/README.md +15 -15
- data/bin/run +1 -0
- data/lib/pdfh/models/document.rb +25 -16
- data/lib/pdfh/models/document_type.rb +26 -0
- data/lib/pdfh/models/settings.rb +2 -0
- data/lib/pdfh/utils/opt_parser.rb +2 -2
- data/lib/pdfh/utils/rename_validator.rb +50 -0
- data/lib/pdfh/version.rb +1 -1
- data/lib/pdfh.rb +1 -0
- data/pdfh.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecddee5472149aa038427798c482557111e62070ebed5558fdffcde55417b325
|
4
|
+
data.tar.gz: 75ff53bc3429bc5303411a81d3922e3f0b6f4249bf66bae396e867cd0b4615a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c51ac8db9d6f9b56c1608289c7d7694b21af6856eb69e06b4fd203ff2824ed3884a1ef1c64cefea37ff1358614e41e3c55264134d9616d9d14819d36ed7241a
|
7
|
+
data.tar.gz: b3d382767616e4008997ce8050691c1e578b8a181ee2a36a4fb4f6a8ed912e93f65511967db2990efbbcd33d73ffdc21535a5163ad9e248225e5e0054548b570
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2024-
|
3
|
+
# on 2024-03-13 18:36:20 UTC using RuboCop version 1.62.1.
|
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
|
@@ -21,12 +21,7 @@ RSpec/AnyInstance:
|
|
21
21
|
Exclude:
|
22
22
|
- 'spec/pdfh/main_spec.rb'
|
23
23
|
|
24
|
-
# Offense count:
|
25
|
-
# Configuration parameters: CountAsOne.
|
26
|
-
RSpec/ExampleLength:
|
27
|
-
Max: 6
|
28
|
-
|
29
|
-
# Offense count: 7
|
24
|
+
# Offense count: 8
|
30
25
|
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
31
26
|
# Include: **/*_spec*rb*, **/spec/**/*
|
32
27
|
RSpec/FilePath:
|
@@ -37,9 +32,10 @@ RSpec/FilePath:
|
|
37
32
|
- 'spec/pdfh/utils/month_spec.rb'
|
38
33
|
- 'spec/pdfh/utils/opt_parser_spec.rb'
|
39
34
|
- 'spec/pdfh/utils/pdf_file_handler_spec.rb'
|
35
|
+
- 'spec/pdfh/utils/rename_validator_spec.rb'
|
40
36
|
- 'spec/pdfh/utils/settings_builder_spec.rb'
|
41
37
|
|
42
|
-
# Offense count:
|
38
|
+
# Offense count: 8
|
43
39
|
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
44
40
|
# Include: **/*_spec.rb
|
45
41
|
RSpec/SpecFilePathFormat:
|
@@ -51,6 +47,7 @@ RSpec/SpecFilePathFormat:
|
|
51
47
|
- 'spec/pdfh/utils/month_spec.rb'
|
52
48
|
- 'spec/pdfh/utils/opt_parser_spec.rb'
|
53
49
|
- 'spec/pdfh/utils/pdf_file_handler_spec.rb'
|
50
|
+
- 'spec/pdfh/utils/rename_validator_spec.rb'
|
54
51
|
- 'spec/pdfh/utils/settings_builder_spec.rb'
|
55
52
|
|
56
53
|
# Offense count: 3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pdfh (3.0
|
4
|
+
pdfh (3.1.0)
|
5
5
|
colorize (~> 1.1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (7.1.2)
|
10
|
+
activesupport (7.1.3.2)
|
11
11
|
base64
|
12
12
|
bigdecimal
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -20,82 +20,96 @@ GEM
|
|
20
20
|
ansi (1.5.0)
|
21
21
|
ast (2.4.2)
|
22
22
|
base64 (0.2.0)
|
23
|
-
bigdecimal (3.1.
|
23
|
+
bigdecimal (3.1.7)
|
24
24
|
blockenspiel (0.5.0)
|
25
25
|
code-scanning-rubocop (0.6.1)
|
26
26
|
rubocop (~> 1.0)
|
27
27
|
coderay (1.1.3)
|
28
28
|
colorize (1.1.0)
|
29
|
-
concurrent-ruby (1.2.
|
29
|
+
concurrent-ruby (1.2.3)
|
30
30
|
connection_pool (2.4.1)
|
31
|
-
|
31
|
+
debug (1.9.2)
|
32
|
+
irb (~> 1.10)
|
33
|
+
reline (>= 0.3.8)
|
34
|
+
diff-lcs (1.5.1)
|
32
35
|
docile (1.4.0)
|
33
|
-
drb (2.2.
|
34
|
-
|
35
|
-
factory_bot (6.4.5)
|
36
|
+
drb (2.2.1)
|
37
|
+
factory_bot (6.4.6)
|
36
38
|
activesupport (>= 5.0.0)
|
37
|
-
i18n (1.14.
|
39
|
+
i18n (1.14.4)
|
38
40
|
concurrent-ruby (~> 1.0)
|
39
|
-
|
41
|
+
io-console (0.7.2)
|
42
|
+
irb (1.13.0)
|
43
|
+
rdoc (>= 4.0.0)
|
44
|
+
reline (>= 0.4.2)
|
45
|
+
json (2.7.2)
|
40
46
|
language_server-protocol (3.17.0.3)
|
41
|
-
method_source (1.
|
42
|
-
minitest (5.
|
47
|
+
method_source (1.1.0)
|
48
|
+
minitest (5.22.3)
|
43
49
|
mutex_m (0.2.0)
|
44
50
|
parallel (1.24.0)
|
45
|
-
parser (3.3.0
|
51
|
+
parser (3.3.1.0)
|
46
52
|
ast (~> 2.4.1)
|
47
53
|
racc
|
48
54
|
pry (0.14.2)
|
49
55
|
coderay (~> 1.1)
|
50
56
|
method_source (~> 1.0)
|
57
|
+
psych (5.1.2)
|
58
|
+
stringio
|
51
59
|
racc (1.7.3)
|
52
60
|
rainbow (3.1.1)
|
53
|
-
rake (13.1
|
61
|
+
rake (13.2.1)
|
62
|
+
rdoc (6.6.3.1)
|
63
|
+
psych (>= 4.0.0)
|
54
64
|
regexp_parser (2.9.0)
|
65
|
+
reline (0.5.5)
|
66
|
+
io-console (~> 0.5)
|
55
67
|
rexml (3.2.6)
|
56
|
-
rspec (3.
|
57
|
-
rspec-core (~> 3.
|
58
|
-
rspec-expectations (~> 3.
|
59
|
-
rspec-mocks (~> 3.
|
60
|
-
rspec-core (3.
|
61
|
-
rspec-support (~> 3.
|
62
|
-
rspec-expectations (3.
|
68
|
+
rspec (3.13.0)
|
69
|
+
rspec-core (~> 3.13.0)
|
70
|
+
rspec-expectations (~> 3.13.0)
|
71
|
+
rspec-mocks (~> 3.13.0)
|
72
|
+
rspec-core (3.13.0)
|
73
|
+
rspec-support (~> 3.13.0)
|
74
|
+
rspec-expectations (3.13.0)
|
63
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
-
rspec-support (~> 3.
|
65
|
-
rspec-mocks (3.
|
76
|
+
rspec-support (~> 3.13.0)
|
77
|
+
rspec-mocks (3.13.0)
|
66
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-support (3.
|
79
|
+
rspec-support (~> 3.13.0)
|
80
|
+
rspec-support (3.13.1)
|
69
81
|
rspec_junit_formatter (0.6.0)
|
70
82
|
rspec-core (>= 2, < 4, != 2.12.0)
|
71
|
-
rubocop (1.
|
83
|
+
rubocop (1.63.4)
|
72
84
|
json (~> 2.3)
|
73
85
|
language_server-protocol (>= 3.17.0)
|
74
86
|
parallel (~> 1.10)
|
75
|
-
parser (>= 3.
|
87
|
+
parser (>= 3.3.0.2)
|
76
88
|
rainbow (>= 2.2.2, < 4.0)
|
77
89
|
regexp_parser (>= 1.8, < 3.0)
|
78
90
|
rexml (>= 3.2.5, < 4.0)
|
79
|
-
rubocop-ast (>= 1.
|
91
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
80
92
|
ruby-progressbar (~> 1.7)
|
81
93
|
unicode-display_width (>= 2.4.0, < 3.0)
|
82
|
-
rubocop-ast (1.
|
83
|
-
parser (>= 3.
|
94
|
+
rubocop-ast (1.31.3)
|
95
|
+
parser (>= 3.3.1.0)
|
84
96
|
rubocop-capybara (2.20.0)
|
85
97
|
rubocop (~> 1.41)
|
86
98
|
rubocop-factory_bot (2.25.1)
|
87
99
|
rubocop (~> 1.41)
|
88
|
-
rubocop-performance (1.
|
100
|
+
rubocop-performance (1.21.0)
|
89
101
|
rubocop (>= 1.48.1, < 2.0)
|
90
|
-
rubocop-ast (>= 1.
|
102
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
91
103
|
rubocop-rake (0.6.0)
|
92
104
|
rubocop (~> 1.0)
|
93
|
-
rubocop-rspec (2.
|
105
|
+
rubocop-rspec (2.29.2)
|
94
106
|
rubocop (~> 1.40)
|
95
107
|
rubocop-capybara (~> 2.17)
|
96
108
|
rubocop-factory_bot (~> 2.22)
|
109
|
+
rubocop-rspec_rails (~> 2.28)
|
110
|
+
rubocop-rspec_rails (2.28.3)
|
111
|
+
rubocop (~> 1.40)
|
97
112
|
ruby-progressbar (1.13.0)
|
98
|
-
ruby2_keywords (0.0.5)
|
99
113
|
simplecov (0.22.0)
|
100
114
|
docile (~> 1.1)
|
101
115
|
simplecov-html (~> 0.11)
|
@@ -106,6 +120,7 @@ GEM
|
|
106
120
|
terminal-table
|
107
121
|
simplecov-html (0.12.3)
|
108
122
|
simplecov_json_formatter (0.1.4)
|
123
|
+
stringio (3.1.0)
|
109
124
|
terminal-table (3.0.2)
|
110
125
|
unicode-display_width (>= 1.1.1, < 3)
|
111
126
|
tzinfo (2.0.6)
|
@@ -120,6 +135,7 @@ PLATFORMS
|
|
120
135
|
DEPENDENCIES
|
121
136
|
bundler (~> 2.0)
|
122
137
|
code-scanning-rubocop (~> 0.5)
|
138
|
+
debug (~> 1.8)
|
123
139
|
factory_bot (~> 6.2)
|
124
140
|
pdfh!
|
125
141
|
pry (~> 0.14)
|
@@ -135,4 +151,4 @@ DEPENDENCIES
|
|
135
151
|
versionomy (~> 0.5)
|
136
152
|
|
137
153
|
BUNDLED WITH
|
138
|
-
2.5.
|
154
|
+
2.5.10
|
data/README.md
CHANGED
@@ -18,20 +18,22 @@ gem install pdfh
|
|
18
18
|
You need to install pdf handling dependencies in order to use this gem.
|
19
19
|
|
20
20
|
#### macOS
|
21
|
+
|
21
22
|
```bash
|
22
23
|
brew install qpdf # for qpdf
|
23
24
|
brew install xpdf # for pdftotext
|
24
25
|
```
|
25
26
|
|
26
27
|
#### Fedora
|
28
|
+
|
27
29
|
```bash
|
28
30
|
sudo dnf install -y qpdf poppler-utils
|
29
31
|
```
|
30
32
|
|
31
33
|
## Usage
|
32
34
|
|
33
|
-
After installing this gem you need to create your configuration file on your home folder.
|
34
|
-
|
35
|
+
After installing this gem you need to create your configuration file on your home folder. `pdfh.yml`
|
36
|
+
|
35
37
|
```yaml
|
36
38
|
---
|
37
39
|
lookup_dirs: # Directories where all pdf's are going to be analyzed
|
@@ -42,25 +44,22 @@ document_types:
|
|
42
44
|
re_file: '.*MyBankReg\.pdf' # Regular expression to match its filename
|
43
45
|
re_date: 'al \d{1,2} de (\w+) del? (\d+)' # Date regular expresion
|
44
46
|
pwd: base64string # [OPTIONAL] Password if the document is protected
|
45
|
-
store_path: "{
|
47
|
+
store_path: "{year}/bank_docs" # Relative path to copy this document
|
46
48
|
name_template: '{period} {subtype}' # Template for new filename when copied
|
47
49
|
sub_types: # [OPTIONAL] In case your need an extra category
|
48
50
|
- name: Account1 # Regular expresion to match this subtype
|
49
51
|
month_offset: -1 # [OPTIONAL] Integer (signed) value to adjust month
|
50
52
|
```
|
51
53
|
|
52
|
-
Store Path supported placeholders:
|
53
|
-
* `{YEAR}` 2022
|
54
|
+
**Store Path** and **Name Template** supported placeholders:
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
* `{subtype}` subtype.name if matched
|
63
|
-
* `{extra}` day if provided/matched
|
56
|
+
- `{original}` Original filename
|
57
|
+
- `{period}` 2022-01
|
58
|
+
- `{year}` 2022
|
59
|
+
- `{month}` 01
|
60
|
+
- `{type}` document_type.name
|
61
|
+
- `{subtype}` subtype.name if matched
|
62
|
+
- `{extra}` day if provided/matched
|
64
63
|
|
65
64
|
## Development
|
66
65
|
|
@@ -77,6 +76,7 @@ gem install pdfh-*
|
|
77
76
|
```
|
78
77
|
|
79
78
|
### Conventional Commits
|
79
|
+
|
80
80
|
```bash
|
81
81
|
npm install -g @commitlint/cli @commitlint/config-conventional
|
82
82
|
commitlint --from origin --to @
|
@@ -97,7 +97,7 @@ Everyone interacting in the Pdfh project’s codebases, issue trackers, chat roo
|
|
97
97
|
<!-- Links -->
|
98
98
|
[rubocop-img]: https://github.com/iax7/pdfh/actions/workflows/rubocop-analysis.yml/badge.svg
|
99
99
|
[rubocop-url]: https://github.com/iax7/pdfh/actions/workflows/rubocop-analysis.yml
|
100
|
-
[ruby-img]: https://img.shields.io/badge/ruby-3.
|
100
|
+
[ruby-img]: https://img.shields.io/badge/ruby-3.3-blue?style=flat&logo=ruby&logoColor=CC342D&labelColor=white
|
101
101
|
[ruby-url]: https://www.ruby-lang.org/en/
|
102
102
|
[cc-img]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=00&labelColor=fff
|
103
103
|
[cc-url]: https://conventionalcommits.org
|
data/bin/run
CHANGED
data/lib/pdfh/models/document.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module Pdfh
|
4
4
|
# Handles the PDF detected by the rules
|
5
5
|
class Document
|
6
|
-
IDENT = 12
|
7
|
-
|
8
6
|
attr_reader :text, :type, :file, :extra, :period
|
9
7
|
|
10
8
|
# @param file [String]
|
@@ -40,12 +38,17 @@ module Pdfh
|
|
40
38
|
|
41
39
|
# @return [void]
|
42
40
|
def print_info_line(property, info)
|
43
|
-
Pdfh.ident_print property, info.to_s, color: :light_blue, width:
|
41
|
+
Pdfh.ident_print property, info.to_s, color: :light_blue, width: 12
|
44
42
|
end
|
45
43
|
|
46
44
|
# @return [String]
|
47
45
|
def file_name_only
|
48
|
-
File.basename(@file,
|
46
|
+
File.basename(@file, file_extension)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [String]
|
50
|
+
def file_extension
|
51
|
+
File.extname(@file)
|
49
52
|
end
|
50
53
|
|
51
54
|
# @return [String]
|
@@ -60,7 +63,7 @@ module Pdfh
|
|
60
63
|
|
61
64
|
# @return [String]
|
62
65
|
def type_name
|
63
|
-
|
66
|
+
type&.name&.titleize || "N/A"
|
64
67
|
end
|
65
68
|
|
66
69
|
# @return [String]
|
@@ -68,23 +71,28 @@ module Pdfh
|
|
68
71
|
@sub_type&.name&.titleize || "N/A"
|
69
72
|
end
|
70
73
|
|
74
|
+
# @return [Hash{Symbol->String}]
|
75
|
+
def rename_data
|
76
|
+
{
|
77
|
+
original: file_name_only,
|
78
|
+
period: period.to_s,
|
79
|
+
year: period.year.to_s,
|
80
|
+
month: period.month.to_s,
|
81
|
+
type: type_name,
|
82
|
+
subtype: sub_type,
|
83
|
+
extra: extra || ""
|
84
|
+
}.freeze
|
85
|
+
end
|
86
|
+
|
71
87
|
# @return [String]
|
72
88
|
def new_name
|
73
|
-
|
74
|
-
new_name
|
75
|
-
.sub("{original}", file_name_only)
|
76
|
-
.sub("{period}", period.to_s)
|
77
|
-
.sub("{year}", period.year.to_s)
|
78
|
-
.sub("{month}", period.month.to_s)
|
79
|
-
.sub("{type}", type_name)
|
80
|
-
.sub("{subtype}", sub_type)
|
81
|
-
.sub("{extra}", extra || "")
|
82
|
-
"#{new_name}.pdf"
|
89
|
+
new_name = type.generate_new_name(rename_data)
|
90
|
+
"#{new_name}#{file_extension}"
|
83
91
|
end
|
84
92
|
|
85
93
|
# @return [String]
|
86
94
|
def store_path
|
87
|
-
|
95
|
+
type.generate_path(rename_data)
|
88
96
|
end
|
89
97
|
|
90
98
|
# @return [String]
|
@@ -95,6 +103,7 @@ module Pdfh
|
|
95
103
|
"#{type.print_cmd} #{relative_path}"
|
96
104
|
end
|
97
105
|
|
106
|
+
# @return [String (frozen)]
|
98
107
|
def companion_files(join: false)
|
99
108
|
return @companion unless join
|
100
109
|
|
@@ -11,6 +11,11 @@ module Pdfh
|
|
11
11
|
self.re_file = Regexp.new(re_file)
|
12
12
|
self.re_date = Regexp.new(re_date)
|
13
13
|
self.sub_types = extract_subtype(sub_types) if sub_types
|
14
|
+
@path_validator = RenameValidator.new(store_path)
|
15
|
+
@name_validator = RenameValidator.new(name_template)
|
16
|
+
return if @path_validator.valid? && @name_validator.valid?
|
17
|
+
|
18
|
+
raise_validators_error
|
14
19
|
end
|
15
20
|
|
16
21
|
# removes special characters from string and replaces spaces with dashes
|
@@ -35,6 +40,18 @@ module Pdfh
|
|
35
40
|
pwd
|
36
41
|
end
|
37
42
|
|
43
|
+
# @param values [Hash{Symbol->String}
|
44
|
+
# @return [String]
|
45
|
+
def generate_new_name(values)
|
46
|
+
@name_validator.gsub(values)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @param values [Hash{Symbol->String}
|
50
|
+
# @return [String]
|
51
|
+
def generate_path(values)
|
52
|
+
@path_validator.gsub(values)
|
53
|
+
end
|
54
|
+
|
38
55
|
private
|
39
56
|
|
40
57
|
# @return [boolean]
|
@@ -51,5 +68,14 @@ module Pdfh
|
|
51
68
|
DocumentSubType.new(name: name, month_offset: offset)
|
52
69
|
end
|
53
70
|
end
|
71
|
+
|
72
|
+
# @raise [ArgumentError] when called
|
73
|
+
# @return [void]
|
74
|
+
def raise_validators_error
|
75
|
+
template = "has invalid %<1>s. Unknown tokens: %<2>s"
|
76
|
+
path_errors = format(template, :store_path, @path_validator.unknown_list) unless @path_validator.valid?
|
77
|
+
name_errors = format(template, :name_template, @name_validator.unknown_list) unless @name_validator.valid?
|
78
|
+
raise ArgumentError, "Document type #{name.inspect} #{path_errors} #{name_errors}"
|
79
|
+
end
|
54
80
|
end
|
55
81
|
end
|
data/lib/pdfh/models/settings.rb
CHANGED
@@ -49,12 +49,12 @@ module Pdfh
|
|
49
49
|
# @return [nil]
|
50
50
|
def list_types
|
51
51
|
settings = SettingsBuilder.build
|
52
|
-
ident =
|
52
|
+
ident = 2
|
53
53
|
max_width = settings.document_types.map { |t| t.gid.size }.max
|
54
54
|
puts "#{" " * ident}#{"ID".ljust(max_width)} Type Name"
|
55
55
|
puts "#{" " * ident}#{"—" * max_width} #{"—" * 23}"
|
56
56
|
settings.document_types.each do |type|
|
57
|
-
puts "#{" " * ident}#{type.gid.ljust(max_width).yellow} #{type.name
|
57
|
+
puts "#{" " * ident}#{type.gid.ljust(max_width).yellow} #{type.name}"
|
58
58
|
end
|
59
59
|
nil
|
60
60
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pdfh
|
4
|
+
# Validates the rename template, and generate new name
|
5
|
+
class RenameValidator
|
6
|
+
RENAME_TYPES = {
|
7
|
+
"original" => "No name change",
|
8
|
+
"period" => "Year-Month",
|
9
|
+
"year" => "Year",
|
10
|
+
"month" => "Month",
|
11
|
+
"type" => "Document Type name",
|
12
|
+
"subtype" => "Document Subtype name",
|
13
|
+
"extra" => "Extra data extracted from date_re"
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
attr_reader :template, :all, :unknown, :valid
|
17
|
+
|
18
|
+
# @param template [String]
|
19
|
+
# @return [self]
|
20
|
+
def initialize(template)
|
21
|
+
@template = template
|
22
|
+
@all = template.scan(/{([^}]+)}/).flatten.map(&:downcase)
|
23
|
+
@unknown = all - types
|
24
|
+
@valid = all - unknown
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Array<String>]
|
28
|
+
def types
|
29
|
+
RENAME_TYPES.keys
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Boolean]
|
33
|
+
def valid?
|
34
|
+
unknown.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def unknown_list
|
39
|
+
unknown.join(", ")
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param values [Hash{Symbol->String}]
|
43
|
+
# @return [String (frozen)]
|
44
|
+
def gsub(values)
|
45
|
+
template
|
46
|
+
.gsub(/\{([^}]+)}/, &:downcase) # convert all text between {} to lowercase
|
47
|
+
.gsub("{", "%{") % values
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/pdfh/version.rb
CHANGED
data/lib/pdfh.rb
CHANGED
@@ -22,6 +22,7 @@ require_relative "pdfh/utils/month"
|
|
22
22
|
require_relative "pdfh/utils/opt_parser"
|
23
23
|
require_relative "pdfh/utils/options"
|
24
24
|
require_relative "pdfh/utils/pdf_file_handler"
|
25
|
+
require_relative "pdfh/utils/rename_validator"
|
25
26
|
require_relative "pdfh/utils/settings_builder"
|
26
27
|
|
27
28
|
require_relative "pdfh/main"
|
data/pdfh.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
22
22
|
spec.metadata["source_code_uri"] = spec.homepage
|
23
|
-
spec.metadata["changelog_uri"] = URI.join(spec.homepage, "CHANGELOG.md").to_s
|
23
|
+
spec.metadata["changelog_uri"] = URI.join(spec.homepage, "/blob/master/CHANGELOG.md").to_s
|
24
24
|
|
25
25
|
# Specify which files should be added to the gem when it is released.
|
26
26
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
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.1.0
|
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-
|
11
|
+
date: 2024-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/pdfh/utils/opt_parser.rb
|
65
65
|
- lib/pdfh/utils/options.rb
|
66
66
|
- lib/pdfh/utils/pdf_file_handler.rb
|
67
|
+
- lib/pdfh/utils/rename_validator.rb
|
67
68
|
- lib/pdfh/utils/settings_builder.rb
|
68
69
|
- lib/pdfh/version.rb
|
69
70
|
- pdfh.gemspec
|
@@ -74,7 +75,7 @@ metadata:
|
|
74
75
|
allowed_push_host: https://rubygems.org
|
75
76
|
homepage_uri: https://github.com/iax7/pdfh
|
76
77
|
source_code_uri: https://github.com/iax7/pdfh
|
77
|
-
changelog_uri: https://github.com/
|
78
|
+
changelog_uri: https://github.com/blob/master/CHANGELOG.md
|
78
79
|
rubygems_mfa_required: 'true'
|
79
80
|
post_install_message:
|
80
81
|
rdoc_options: []
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
|
-
rubygems_version: 3.5.
|
95
|
+
rubygems_version: 3.5.7
|
95
96
|
signing_key:
|
96
97
|
specification_version: 4
|
97
98
|
summary: Organize PDF files
|