pdfh 4.0.1 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 833d681fc080cc70f16c365322eb3d6c9acdccfcc817ccd8cac317fa89b03b31
4
- data.tar.gz: d818e4a7f2b65d06362525b5ecb94d534422d78ae8fa60357109603be6629467
3
+ metadata.gz: caac169994dac2298602338729f41f79b0b047d8e5c78a8ffff3e7afe861547a
4
+ data.tar.gz: c1c31260ea0460b96b5cf77c103215323feaee2e7c4dfa6199962ecf1f851e16
5
5
  SHA512:
6
- metadata.gz: 629936ffe78b2a1a9d8e405ac5ed1de5a7c4c2ae2022d8722888fa467e75b674961e51f381f7d5c62698a4b480a9405190f79ff57f6fe9ba38e0d781273590dc
7
- data.tar.gz: 3a3658de5d2775ba4a5503847f374e82d42fc73c64cffe5d5fb723ee73953c1d027f27325be9b4e7f31be7766f8f6b715515c1623fbb381b528bd2489c6e7c14
6
+ metadata.gz: 0c817645e707161a62c42ef478e0471668547cc78f03a6e9831e060ceceb8638bd85404c7a6a929a016fc6b953d7a97c2f244350551cbec8ca6e7063054f742e
7
+ data.tar.gz: 444b02a1ba3324ac7ea98983d8c9500a3dafea33307f22cad5042817929db28f8be885d6fd355574014b514d1f07ae8554990d944967e51de6c69daec29a959c
data/AGENTS.md CHANGED
@@ -59,7 +59,11 @@ Useful `mise` tasks (`mise.toml`):
59
59
  ## Processing Flow (High Level)
60
60
 
61
61
  ```text
62
- exe/pdfh → Main.start OptParserSettingsBuilder → SettingsValidator
62
+ exe/pdfh → DependencyValidator (qpdf, pdftotext)Main.start
63
+
64
+ OptParser (ARGV)
65
+
66
+ SettingsBuilder → SettingsValidator
63
67
 
64
68
  DirectoryScanner.scan (finds *.pdf)
65
69
 
@@ -76,9 +80,9 @@ Key service objects in `lib/pdfh/services/`:
76
80
  - `PdfTextExtractor` — shells out `pdftotext -enc UTF-8 -layout`
77
81
  - `DocumentMatcher` — iterates `DocumentType`s; matches `re_id` then `re_date`
78
82
  - `DocumentManager` — creates dest dir, copies/renames PDF, copies companion files
79
- - `SettingsBuilder` — locates and parses `pdfh.yml`
83
+ - `SettingsBuilder` — resolves config from env/known locations (`.yml`/`.yaml`), validates, and builds `Settings`
80
84
  - `SettingsValidator` — validates settings; raises `ArgumentError` on fatal errors, warns and skips on soft errors (e.g. missing lookup dirs)
81
- - `OptParser` — parses `ARGV` into `RunOptions`
85
+ - `OptParser` — parses `ARGV` into `RunOptions`; supports `--list-types` to print configured document type IDs
82
86
 
83
87
  ## Code Style and Conventions
84
88
 
@@ -127,6 +131,7 @@ Side effects and IO:
127
131
  - File system changes are centralized in `DocumentManager`.
128
132
  - Respect `dry_run` / `--dry` to avoid writing files.
129
133
  - When copying/moving files, preserve metadata if possible (`FileUtils` with `preserve: true`).
134
+ - After successful processing, source PDFs are moved to `*.bkp` in place (`DocumentManager#backup_original`).
130
135
 
131
136
  Testing:
132
137
 
@@ -136,7 +141,9 @@ Testing:
136
141
 
137
142
  ## Configuration and Templates
138
143
 
139
- - Configuration is loaded from `$PDFH_CONFIG_FILE`, then CWD, `~/.config/`, then `~/`.
144
+ - Configuration is loaded from `$PDFH_CONFIG_FILE`, then CWD, then `$XDG_CONFIG_HOME` (default `~/.config`), then `~/`.
145
+ - Supported config file extensions are `.yml` and `.yaml`.
146
+ - If no config file is found, `SettingsBuilder` creates a default template at `~/pdfh.yml`.
140
147
  - Document templates use `{placeholder}` tokens defined in `Document#rename_data`.
141
148
  - Date regex supports named captures `(?<m>...)` / `(?<y>...)` / `(?<d>...)` or positional captures.
142
149
 
@@ -149,7 +156,8 @@ Testing:
149
156
  - **v4 breaking change**: Config format changed in v4.0.0 — old configs are incompatible. `re_id` matches PDF *text content* (not filename). New placeholders: `{day}`, `{quarter}`, `{bimester}`, `{name}`.
150
157
  - **Multi-match behavior**: PDFs matching more than one `DocumentType` are silently skipped (see `Main.start`).
151
158
  - **`_unlocked` suffix**: `DocumentManager` strips `_unlocked` when locating companion files — legacy pattern from `qpdf` unlocking.
152
- - **Config search path**: `$PDFH_CONFIG_FILE` CWD `~/.config/` `~/`. Error message does not list paths checked.
159
+ - **First run side effect**: Missing config does not fail fast; it auto-creates `~/pdfh.yml` and continues from that template.
160
+ - **Dependency mismatch risk**: `qpdf` is still checked at startup (`exe/pdfh`) even though normal v4 processing does not call it directly.
153
161
  - **Colorize in tests**: Logging output is colored via `colorize`; specs mock `Console` with shared context `"with silent console"` to suppress output.
154
162
 
155
163
  ## Suggested Workflow for Agents
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pdfh (4.0.1)
4
+ pdfh (4.0.2)
5
5
  colorize (~> 1.1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (8.1.3)
10
+ activesupport (8.1.3.1)
11
11
  base64
12
12
  bigdecimal
13
13
  concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -22,56 +22,57 @@ GEM
22
22
  uri (>= 0.13.1)
23
23
  ast (2.4.3)
24
24
  base64 (0.3.0)
25
- bigdecimal (4.0.1)
25
+ bigdecimal (4.1.2)
26
26
  code-scanning-rubocop (0.6.1)
27
27
  rubocop (~> 1.0)
28
28
  colorize (1.1.0)
29
- concurrent-ruby (1.3.6)
29
+ concurrent-ruby (1.3.8)
30
30
  connection_pool (3.0.2)
31
- date (3.5.1)
32
31
  debug (1.11.1)
33
32
  irb (~> 1.10)
34
33
  reline (>= 0.3.8)
35
34
  diff-lcs (1.6.2)
36
35
  docile (1.4.1)
37
36
  drb (2.2.3)
38
- erb (6.0.2)
39
- factory_bot (6.5.6)
37
+ erb (6.0.6)
38
+ factory_bot (6.6.0)
40
39
  activesupport (>= 6.1.0)
41
- i18n (1.14.8)
40
+ i18n (1.15.2)
42
41
  concurrent-ruby (~> 1.0)
43
42
  io-console (0.8.2)
44
- irb (1.17.0)
43
+ irb (1.18.0)
45
44
  pp (>= 0.6.0)
46
45
  prism (>= 1.3.0)
47
46
  rdoc (>= 4.0.0)
48
47
  reline (>= 0.4.2)
49
- json (2.19.2)
50
- language_server-protocol (3.17.0.5)
48
+ json (2.21.2)
49
+ language_server-protocol (3.17.0.6)
51
50
  lint_roller (1.1.0)
52
51
  logger (1.7.0)
53
- minitest (6.0.2)
52
+ minitest (6.0.6)
54
53
  drb (~> 2.0)
55
54
  prism (~> 1.5)
56
- parallel (1.27.0)
57
- parser (3.3.10.2)
55
+ parallel (2.1.0)
56
+ parser (3.3.12.0)
58
57
  ast (~> 2.4.1)
59
58
  racc
60
- pp (0.6.3)
59
+ pp (0.6.4)
61
60
  prettyprint
62
61
  prettyprint (0.2.0)
63
62
  prism (1.9.0)
64
- psych (5.3.1)
65
- date
66
- stringio
67
63
  racc (1.8.1)
68
64
  rainbow (3.1.1)
69
- rake (13.3.1)
70
- rdoc (7.2.0)
65
+ rake (13.4.2)
66
+ rbs (4.1.2)
67
+ logger
68
+ prism (>= 1.6.0)
69
+ tsort
70
+ rdoc (8.0.0)
71
71
  erb
72
- psych (>= 4.0.0)
72
+ prism (>= 1.6.0)
73
+ rbs (>= 4.0.0)
73
74
  tsort
74
- regexp_parser (2.11.3)
75
+ regexp_parser (2.12.0)
75
76
  reline (0.6.3)
76
77
  io-console (~> 0.5)
77
78
  rspec (3.13.2)
@@ -87,18 +88,18 @@ GEM
87
88
  diff-lcs (>= 1.2.0, < 2.0)
88
89
  rspec-support (~> 3.13.0)
89
90
  rspec-support (3.13.7)
90
- rubocop (1.86.0)
91
+ rubocop (1.88.2)
91
92
  json (~> 2.3)
92
93
  language_server-protocol (~> 3.17.0.2)
93
94
  lint_roller (~> 1.1.0)
94
- parallel (~> 1.10)
95
+ parallel (>= 1.10)
95
96
  parser (>= 3.3.0.2)
96
97
  rainbow (>= 2.2.2, < 4.0)
97
98
  regexp_parser (>= 2.9.3, < 3.0)
98
99
  rubocop-ast (>= 1.49.0, < 2.0)
99
100
  ruby-progressbar (~> 1.7)
100
101
  unicode-display_width (>= 2.4.0, < 4.0)
101
- rubocop-ast (1.49.1)
102
+ rubocop-ast (1.50.0)
102
103
  parser (>= 3.3.7.2)
103
104
  prism (~> 1.7)
104
105
  rubocop-factory_bot (2.28.0)
@@ -111,9 +112,10 @@ GEM
111
112
  rubocop-rake (0.7.1)
112
113
  lint_roller (~> 1.1)
113
114
  rubocop (>= 1.72.1)
114
- rubocop-rspec (3.9.0)
115
+ rubocop-rspec (3.10.2)
115
116
  lint_roller (~> 1.1)
116
- rubocop (~> 1.81)
117
+ regexp_parser (>= 2.0)
118
+ rubocop (~> 1.86, >= 1.86.2)
117
119
  ruby-progressbar (1.13.0)
118
120
  securerandom (0.4.1)
119
121
  simplecov (0.22.0)
@@ -122,7 +124,6 @@ GEM
122
124
  simplecov_json_formatter (~> 0.1)
123
125
  simplecov-html (0.13.2)
124
126
  simplecov_json_formatter (0.1.4)
125
- stringio (3.2.0)
126
127
  tsort (0.2.0)
127
128
  tzinfo (2.0.6)
128
129
  concurrent-ruby (~> 1.0)
@@ -150,4 +151,4 @@ DEPENDENCIES
150
151
  simplecov (~> 0.22)
151
152
 
152
153
  BUNDLED WITH
153
- 4.0.9
154
+ 4.0.17
@@ -89,16 +89,18 @@ module Pdfh
89
89
  # Finds companion files by removing the _unlocked suffix from the PDF name if present.
90
90
  # This allows PDFs unlock by qpdf to locate their original companion files (e.g., .xml, .txt)
91
91
  # that were never renamed with the _unlocked suffix.
92
+ # Excludes PDF files and `.bkp` backup files (already-processed PDFs renamed by +backup_original+).
92
93
  #
93
- # @return [Array<String>] array of non-PDF files with the same base name
94
+ # @return [Array<String>] array of non-PDF, non-backup files with the same base name
94
95
  # @example
95
96
  # # If document is "cuenta_unlocked.pdf", searches for "cuenta.*"
96
- # # Returns ["cuenta.xml", "cuenta.txt"] (excluding "cuenta.pdf")
97
+ # # Returns ["cuenta.xml", "cuenta.txt"] (excluding "cuenta.pdf" and "cuenta.pdf.bkp")
97
98
  def companion_files
98
99
  @companion_files ||= begin
99
100
  base_name = document.file_info.stem.delete_suffix(PDF_UNLOCKED_MAGIC_SUFFIX)
100
101
  Dir.glob(File.join(document.file_info.dir, "#{base_name}.*")).reject do |file|
101
- File.extname(file) == ".pdf"
102
+ ext = File.extname(file)
103
+ ext == ".pdf" || file.end_with?(".bkp")
102
104
  end
103
105
  end
104
106
  end
data/lib/pdfh/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pdfh
4
- VERSION = "4.0.1"
4
+ VERSION = "4.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfh
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaias Piña
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 4.0.9
101
+ rubygems_version: 4.0.17
102
102
  specification_version: 4
103
103
  summary: Organize PDF files
104
104
  test_files: []