pdfh 3.1.0 → 3.2.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/Gemfile.lock +75 -58
- data/README.md +13 -3
- data/exe/pdfh +1 -1
- data/lib/pdfh/main.rb +1 -0
- data/lib/pdfh/models/document.rb +12 -16
- data/lib/pdfh/models/document_sub_type.rb +1 -1
- data/lib/pdfh/models/document_type.rb +31 -17
- data/lib/pdfh/models/settings.rb +1 -0
- data/lib/pdfh/utils/console.rb +8 -0
- data/lib/pdfh/utils/pdf_file_handler.rb +1 -0
- data/lib/pdfh/utils/settings_builder.rb +8 -3
- data/lib/pdfh/version.rb +1 -1
- data/lib/pdfh.rb +1 -1
- data/mise.toml +2 -0
- metadata +4 -7
- data/.tool-versions +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cc0c0f6ba735b3d69c9f5bf32e6acc94b185b3606574834504634acad34f1e8
|
4
|
+
data.tar.gz: fd4bf05918b2631d2cb6335341704be2540d50cdcf5a395e7e85dd2206c865ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c58687eba046fb229b713a70650554a93473b22c9fe39c6d5427adde475187ec64a91031fb9b6ef6f22de9e516a5b5f75e7bdd6276657541127247395d53cec4
|
7
|
+
data.tar.gz: 0bc6756a6c83335f4afaad5708da797bd5d4e052542b12fa0ee030e23e66a779fe6303aa21eb6f63b6bba849291bf3a2f08a0a32ea1ea4b4f05ab14f2c3b976d
|
data/Gemfile.lock
CHANGED
@@ -1,131 +1,148 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pdfh (3.
|
4
|
+
pdfh (3.2.0)
|
5
5
|
colorize (~> 1.1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (
|
10
|
+
activesupport (8.0.1)
|
11
11
|
base64
|
12
|
+
benchmark (>= 0.3)
|
12
13
|
bigdecimal
|
13
|
-
concurrent-ruby (~> 1.0, >= 1.
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
14
15
|
connection_pool (>= 2.2.5)
|
15
16
|
drb
|
16
17
|
i18n (>= 1.6, < 2)
|
18
|
+
logger (>= 1.4.2)
|
17
19
|
minitest (>= 5.1)
|
18
|
-
|
19
|
-
tzinfo (~> 2.0)
|
20
|
+
securerandom (>= 0.3)
|
21
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
22
|
+
uri (>= 0.13.1)
|
20
23
|
ansi (1.5.0)
|
21
24
|
ast (2.4.2)
|
22
25
|
base64 (0.2.0)
|
23
|
-
|
26
|
+
benchmark (0.4.0)
|
27
|
+
bigdecimal (3.1.9)
|
24
28
|
blockenspiel (0.5.0)
|
25
29
|
code-scanning-rubocop (0.6.1)
|
26
30
|
rubocop (~> 1.0)
|
27
31
|
coderay (1.1.3)
|
28
32
|
colorize (1.1.0)
|
29
|
-
concurrent-ruby (1.
|
30
|
-
connection_pool (2.
|
31
|
-
|
33
|
+
concurrent-ruby (1.3.5)
|
34
|
+
connection_pool (2.5.0)
|
35
|
+
date (3.4.1)
|
36
|
+
debug (1.10.0)
|
32
37
|
irb (~> 1.10)
|
33
38
|
reline (>= 0.3.8)
|
34
|
-
diff-lcs (1.
|
35
|
-
docile (1.4.
|
39
|
+
diff-lcs (1.6.0)
|
40
|
+
docile (1.4.1)
|
36
41
|
drb (2.2.1)
|
37
|
-
factory_bot (6.
|
38
|
-
activesupport (>=
|
39
|
-
i18n (1.14.
|
42
|
+
factory_bot (6.5.1)
|
43
|
+
activesupport (>= 6.1.0)
|
44
|
+
i18n (1.14.7)
|
40
45
|
concurrent-ruby (~> 1.0)
|
41
|
-
io-console (0.
|
42
|
-
irb (1.
|
46
|
+
io-console (0.8.0)
|
47
|
+
irb (1.15.1)
|
48
|
+
pp (>= 0.6.0)
|
43
49
|
rdoc (>= 4.0.0)
|
44
50
|
reline (>= 0.4.2)
|
45
|
-
json (2.
|
46
|
-
language_server-protocol (3.17.0.
|
51
|
+
json (2.10.1)
|
52
|
+
language_server-protocol (3.17.0.4)
|
53
|
+
lint_roller (1.1.0)
|
54
|
+
logger (1.6.6)
|
47
55
|
method_source (1.1.0)
|
48
|
-
minitest (5.
|
49
|
-
|
50
|
-
|
51
|
-
parser (3.3.1.0)
|
56
|
+
minitest (5.25.4)
|
57
|
+
parallel (1.26.3)
|
58
|
+
parser (3.3.7.1)
|
52
59
|
ast (~> 2.4.1)
|
53
60
|
racc
|
54
|
-
|
61
|
+
pp (0.6.2)
|
62
|
+
prettyprint
|
63
|
+
prettyprint (0.2.0)
|
64
|
+
pry (0.15.2)
|
55
65
|
coderay (~> 1.1)
|
56
66
|
method_source (~> 1.0)
|
57
|
-
psych (5.
|
67
|
+
psych (5.2.3)
|
68
|
+
date
|
58
69
|
stringio
|
59
|
-
racc (1.
|
70
|
+
racc (1.8.1)
|
60
71
|
rainbow (3.1.1)
|
61
72
|
rake (13.2.1)
|
62
|
-
rdoc (6.
|
73
|
+
rdoc (6.12.0)
|
63
74
|
psych (>= 4.0.0)
|
64
|
-
regexp_parser (2.
|
65
|
-
reline (0.
|
75
|
+
regexp_parser (2.10.0)
|
76
|
+
reline (0.6.0)
|
66
77
|
io-console (~> 0.5)
|
67
|
-
rexml (3.2.6)
|
68
78
|
rspec (3.13.0)
|
69
79
|
rspec-core (~> 3.13.0)
|
70
80
|
rspec-expectations (~> 3.13.0)
|
71
81
|
rspec-mocks (~> 3.13.0)
|
72
|
-
rspec-core (3.13.
|
82
|
+
rspec-core (3.13.3)
|
73
83
|
rspec-support (~> 3.13.0)
|
74
|
-
rspec-expectations (3.13.
|
84
|
+
rspec-expectations (3.13.3)
|
75
85
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
86
|
rspec-support (~> 3.13.0)
|
77
|
-
rspec-mocks (3.13.
|
87
|
+
rspec-mocks (3.13.2)
|
78
88
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
89
|
rspec-support (~> 3.13.0)
|
80
|
-
rspec-support (3.13.
|
90
|
+
rspec-support (3.13.2)
|
81
91
|
rspec_junit_formatter (0.6.0)
|
82
92
|
rspec-core (>= 2, < 4, != 2.12.0)
|
83
|
-
rubocop (1.
|
93
|
+
rubocop (1.73.2)
|
84
94
|
json (~> 2.3)
|
85
|
-
language_server-protocol (
|
95
|
+
language_server-protocol (~> 3.17.0.2)
|
96
|
+
lint_roller (~> 1.1.0)
|
86
97
|
parallel (~> 1.10)
|
87
98
|
parser (>= 3.3.0.2)
|
88
99
|
rainbow (>= 2.2.2, < 4.0)
|
89
|
-
regexp_parser (>=
|
90
|
-
|
91
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
100
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
101
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
92
102
|
ruby-progressbar (~> 1.7)
|
93
|
-
unicode-display_width (>= 2.4.0, <
|
94
|
-
rubocop-ast (1.
|
103
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
104
|
+
rubocop-ast (1.38.1)
|
95
105
|
parser (>= 3.3.1.0)
|
96
|
-
rubocop-capybara (2.
|
106
|
+
rubocop-capybara (2.21.0)
|
97
107
|
rubocop (~> 1.41)
|
98
|
-
rubocop-factory_bot (2.
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
rubocop (
|
105
|
-
rubocop-
|
108
|
+
rubocop-factory_bot (2.27.0)
|
109
|
+
lint_roller (~> 1.1)
|
110
|
+
rubocop (~> 1.72, >= 1.72.1)
|
111
|
+
rubocop-performance (1.24.0)
|
112
|
+
lint_roller (~> 1.1)
|
113
|
+
rubocop (>= 1.72.1, < 2.0)
|
114
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
115
|
+
rubocop-rake (0.7.1)
|
116
|
+
lint_roller (~> 1.1)
|
117
|
+
rubocop (>= 1.72.1)
|
118
|
+
rubocop-rspec (2.31.0)
|
106
119
|
rubocop (~> 1.40)
|
107
120
|
rubocop-capybara (~> 2.17)
|
108
121
|
rubocop-factory_bot (~> 2.22)
|
109
122
|
rubocop-rspec_rails (~> 2.28)
|
110
|
-
rubocop-rspec_rails (2.
|
111
|
-
rubocop (~> 1.
|
123
|
+
rubocop-rspec_rails (2.29.1)
|
124
|
+
rubocop (~> 1.61)
|
112
125
|
ruby-progressbar (1.13.0)
|
126
|
+
securerandom (0.4.1)
|
113
127
|
simplecov (0.22.0)
|
114
128
|
docile (~> 1.1)
|
115
129
|
simplecov-html (~> 0.11)
|
116
130
|
simplecov_json_formatter (~> 0.1)
|
117
|
-
simplecov-console (0.9.
|
131
|
+
simplecov-console (0.9.3)
|
118
132
|
ansi
|
119
133
|
simplecov
|
120
134
|
terminal-table
|
121
|
-
simplecov-html (0.
|
135
|
+
simplecov-html (0.13.1)
|
122
136
|
simplecov_json_formatter (0.1.4)
|
123
|
-
stringio (3.1.
|
124
|
-
terminal-table (
|
125
|
-
unicode-display_width (>= 1.1.1, <
|
137
|
+
stringio (3.1.5)
|
138
|
+
terminal-table (4.0.0)
|
139
|
+
unicode-display_width (>= 1.1.1, < 4)
|
126
140
|
tzinfo (2.0.6)
|
127
141
|
concurrent-ruby (~> 1.0)
|
128
|
-
unicode-display_width (
|
142
|
+
unicode-display_width (3.1.4)
|
143
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
144
|
+
unicode-emoji (4.0.4)
|
145
|
+
uri (1.0.3)
|
129
146
|
versionomy (0.5.0)
|
130
147
|
blockenspiel (~> 0.5)
|
131
148
|
|
@@ -151,4 +168,4 @@ DEPENDENCIES
|
|
151
168
|
versionomy (~> 0.5)
|
152
169
|
|
153
170
|
BUNDLED WITH
|
154
|
-
2.5
|
171
|
+
2.6.5
|
data/README.md
CHANGED
@@ -30,9 +30,19 @@ brew install xpdf # for pdftotext
|
|
30
30
|
sudo dnf install -y qpdf poppler-utils
|
31
31
|
```
|
32
32
|
|
33
|
+
#### Arch
|
34
|
+
|
35
|
+
```bash
|
36
|
+
sudo pacman -S qpdf poppler
|
37
|
+
```
|
38
|
+
|
33
39
|
## Usage
|
34
40
|
|
35
|
-
After installing this gem you need to create your configuration file on
|
41
|
+
After installing this gem you need to create your configuration file on any of the following directories:
|
42
|
+
|
43
|
+
- `~/.config/pdfh.yml`
|
44
|
+
- `~/pdfh.yml`
|
45
|
+
- or configure `PDFH_CONFIG_FILE` environment variable
|
36
46
|
|
37
47
|
```yaml
|
38
48
|
---
|
@@ -84,7 +94,7 @@ commitlint --from origin --to @
|
|
84
94
|
|
85
95
|
## Contributing
|
86
96
|
|
87
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/iax7/pdfh
|
97
|
+
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.
|
88
98
|
|
89
99
|
## License
|
90
100
|
|
@@ -97,7 +107,7 @@ Everyone interacting in the Pdfh project’s codebases, issue trackers, chat roo
|
|
97
107
|
<!-- Links -->
|
98
108
|
[rubocop-img]: https://github.com/iax7/pdfh/actions/workflows/rubocop-analysis.yml/badge.svg
|
99
109
|
[rubocop-url]: https://github.com/iax7/pdfh/actions/workflows/rubocop-analysis.yml
|
100
|
-
[ruby-img]: https://img.shields.io/badge/ruby-3.
|
110
|
+
[ruby-img]: https://img.shields.io/badge/ruby-3.4-blue?style=flat&logo=ruby&logoColor=CC342D&labelColor=white
|
101
111
|
[ruby-url]: https://www.ruby-lang.org/en/
|
102
112
|
[cc-img]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=00&labelColor=fff
|
103
113
|
[cc-url]: https://conventionalcommits.org
|
data/exe/pdfh
CHANGED
@@ -9,7 +9,7 @@ require "pdfh"
|
|
9
9
|
def validate_installed(*apps)
|
10
10
|
found_app = []
|
11
11
|
apps.each_with_object(found_app) do |app, result|
|
12
|
-
_stdout, _stderr, status = Open3.capture3("
|
12
|
+
_stdout, _stderr, status = Open3.capture3("which #{app}")
|
13
13
|
puts "Missing #{app} command." unless status.success?
|
14
14
|
result << status.success?
|
15
15
|
end
|
data/lib/pdfh/main.rb
CHANGED
data/lib/pdfh/models/document.rb
CHANGED
@@ -12,14 +12,18 @@ module Pdfh
|
|
12
12
|
def initialize(file, type, text)
|
13
13
|
@file = file
|
14
14
|
@type = type
|
15
|
-
Pdfh.debug "=== Document Type: #{type.name} =============================="
|
16
15
|
@text = text
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [void]
|
19
|
+
def process
|
20
|
+
Pdfh.debug "=== Document Type: #{type.name} =============================="
|
17
21
|
Pdfh.debug "~~~~~~~~~~~~~~~~~~ Finding a subtype"
|
18
22
|
@sub_type = type.sub_type(@text)
|
19
23
|
Pdfh.debug " SubType: #{@sub_type}"
|
20
24
|
@companion = search_companion_files
|
21
25
|
|
22
|
-
month, year, @extra =
|
26
|
+
month, year, @extra = match_date(@sub_type&.re_date || @type.re_date)
|
23
27
|
@period = DocumentPeriod.new(day: extra, month: month, month_offset: @sub_type&.month_offset, year: year)
|
24
28
|
Pdfh.debug " Period: #{@period.inspect}"
|
25
29
|
end
|
@@ -32,7 +36,6 @@ module Pdfh
|
|
32
36
|
print_info_line "New Name", new_name
|
33
37
|
print_info_line "Store Path", store_path
|
34
38
|
print_info_line "Extra files", companion_files(join: true)
|
35
|
-
print_info_line "Print CMD", print_cmd
|
36
39
|
print_info_line "Processed?", "No (in Dry mode)" if Pdfh.dry?
|
37
40
|
end
|
38
41
|
|
@@ -95,14 +98,6 @@ module Pdfh
|
|
95
98
|
type.generate_path(rename_data)
|
96
99
|
end
|
97
100
|
|
98
|
-
# @return [String]
|
99
|
-
def print_cmd
|
100
|
-
return "N/A" if type.print_cmd.nil? || type.print_cmd.empty?
|
101
|
-
|
102
|
-
relative_path = File.join(store_path, new_name)
|
103
|
-
"#{type.print_cmd} #{relative_path}"
|
104
|
-
end
|
105
|
-
|
106
101
|
# @return [String (frozen)]
|
107
102
|
def companion_files(join: false)
|
108
103
|
return @companion unless join
|
@@ -125,16 +120,17 @@ module Pdfh
|
|
125
120
|
# named matches can appear in any order with names 'd', 'm' and 'y'
|
126
121
|
# unnamed matches needs to be in order month, year
|
127
122
|
# @return [Array] - format [month, year, day]
|
128
|
-
|
123
|
+
# @param regex [RegularExpression]
|
124
|
+
def match_date(regex)
|
129
125
|
Pdfh.debug "~~~~~~~~~~~~~~~~~~ Match Data RegEx"
|
130
|
-
Pdfh.debug " Using regex: #{
|
131
|
-
Pdfh.debug " named: #{
|
132
|
-
matched =
|
126
|
+
Pdfh.debug " Using regex: #{regex}"
|
127
|
+
Pdfh.debug " named: #{regex.named_captures}"
|
128
|
+
matched = regex.match(@text)
|
133
129
|
raise ReDateError unless matched
|
134
130
|
|
135
131
|
Pdfh.debug " captured: #{matched.captures}"
|
136
132
|
|
137
|
-
return matched.captures.map(&:downcase) if
|
133
|
+
return matched.captures.map(&:downcase) if regex.named_captures.empty?
|
138
134
|
|
139
135
|
extra = matched.captures.size > 2 ? matched[:d] : nil
|
140
136
|
[matched[:m].downcase, matched[:y], extra]
|
@@ -2,5 +2,5 @@
|
|
2
2
|
|
3
3
|
module Pdfh
|
4
4
|
# Provides a way to divide document type by subtypes, for different name, and month adjustments
|
5
|
-
DocumentSubType = Struct.new(:name, :month_offset, keyword_init: true)
|
5
|
+
DocumentSubType = Struct.new(:name, :month_offset, :re_date, keyword_init: true)
|
6
6
|
end
|
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
module Pdfh
|
4
4
|
# Represents a type of document that can be processed by pdfh
|
5
|
-
DocumentType
|
6
|
-
|
5
|
+
class DocumentType
|
6
|
+
attr_reader :name, :re_file, :re_date, :pwd, :store_path, :name_template, :sub_types
|
7
|
+
|
8
|
+
# @param args [Hash]
|
7
9
|
# @return [self]
|
8
10
|
def initialize(args)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
args.each { |k, v| instance_variable_set(:"@#{k}", v) }
|
12
|
+
@name_template ||= "{original}"
|
13
|
+
@re_file = Regexp.new(re_file)
|
14
|
+
@re_date = Regexp.new(re_date)
|
15
|
+
@sub_types = extract_subtypes(sub_types) if sub_types&.any?
|
14
16
|
@path_validator = RenameValidator.new(store_path)
|
15
17
|
@name_validator = RenameValidator.new(name_template)
|
16
18
|
return if @path_validator.valid? && @name_validator.valid?
|
@@ -18,6 +20,11 @@ module Pdfh
|
|
18
20
|
raise_validators_error
|
19
21
|
end
|
20
22
|
|
23
|
+
# @return [Hash{Symbol->any}]
|
24
|
+
def to_h
|
25
|
+
instance_variables.to_h { |var| [var.to_s.delete_prefix("@"), instance_variable_get(var)] }
|
26
|
+
end
|
27
|
+
|
21
28
|
# removes special characters from string and replaces spaces with dashes
|
22
29
|
# @example usage
|
23
30
|
# "Test This?%&".gid
|
@@ -27,6 +34,7 @@ module Pdfh
|
|
27
34
|
name.downcase.gsub(/[^0-9A-Za-z\s]/, "").tr(" ", "-")
|
28
35
|
end
|
29
36
|
|
37
|
+
# search the subtype name in the pdf document
|
30
38
|
# @return [DocumentSubType]
|
31
39
|
def sub_type(text)
|
32
40
|
# Regexp.new(st.name).match?(name)
|
@@ -54,28 +62,34 @@ module Pdfh
|
|
54
62
|
|
55
63
|
private
|
56
64
|
|
65
|
+
attr_accessor :path_validator, :name_validator
|
66
|
+
|
57
67
|
# @return [boolean]
|
58
68
|
def base64?
|
59
69
|
pwd.is_a?(String) && Base64.strict_encode64(Base64.decode64(pwd)) == pwd
|
60
70
|
end
|
61
71
|
|
62
|
-
# @param sub_types [Array]
|
63
|
-
# @return [DocumentSubType]
|
64
|
-
def
|
72
|
+
# @param sub_types [Array<Hash{Symbol->String}>]
|
73
|
+
# @return [Array<DocumentSubType>]
|
74
|
+
def extract_subtypes(sub_types)
|
65
75
|
sub_types.map do |st|
|
66
|
-
|
67
|
-
|
68
|
-
|
76
|
+
data = {
|
77
|
+
name: st[:name],
|
78
|
+
month_offset: st[:month_offset].to_i,
|
79
|
+
re_date: st[:re_date] && Regexp.new(st[:re_date])
|
80
|
+
}.compact
|
81
|
+
DocumentSubType.new(data)
|
69
82
|
end
|
70
83
|
end
|
71
84
|
|
72
85
|
# @raise [ArgumentError] when called
|
73
86
|
# @return [void]
|
74
87
|
def raise_validators_error
|
75
|
-
template = "has invalid %<
|
76
|
-
|
77
|
-
|
78
|
-
|
88
|
+
template = "has invalid %<field>s[Unknown tokens=%<error>s]"
|
89
|
+
errors = []
|
90
|
+
errors << format(template, field: :store_path, error: path_validator.unknown_list) unless path_validator.valid?
|
91
|
+
errors << format(template, field: :name_template, error: name_validator.unknown_list) unless name_validator.valid?
|
92
|
+
raise ArgumentError, "Document type #{name.inspect} #{errors.join(", ")}"
|
79
93
|
end
|
80
94
|
end
|
81
95
|
end
|
data/lib/pdfh/models/settings.rb
CHANGED
data/lib/pdfh/utils/console.rb
CHANGED
@@ -41,6 +41,14 @@ module Pdfh
|
|
41
41
|
exit 1 if exit_app
|
42
42
|
end
|
43
43
|
|
44
|
+
# @param e [StandardError]
|
45
|
+
# @return [void]
|
46
|
+
def backtrace_print(e)
|
47
|
+
e.backtrace&.each do |line|
|
48
|
+
output " ↳ #{line.sub("#{Dir.pwd}/", "")}".colorize(:light_black)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
44
52
|
# @param message [String]
|
45
53
|
# @return [void]
|
46
54
|
def warn_print(message)
|
@@ -3,13 +3,17 @@
|
|
3
3
|
module Pdfh
|
4
4
|
# Loads or creates a default settings yaml file
|
5
5
|
class SettingsBuilder
|
6
|
-
CONFIG_FILE_LOCATIONS = [Dir.pwd,
|
6
|
+
CONFIG_FILE_LOCATIONS = [Dir.pwd, ENV.fetch("XDG_CONFIG_HOME", "~/.config"), "~"].freeze
|
7
7
|
SUPPORTED_EXTENSIONS = %w[yml yaml].freeze
|
8
|
+
ENV_VAR = "PDFH_CONFIG_FILE"
|
8
9
|
|
9
10
|
class << self
|
10
11
|
# @return [Pdfh::Settings]
|
11
12
|
def build
|
12
|
-
|
13
|
+
env_config_file = ENV.fetch(ENV_VAR, nil)
|
14
|
+
raise "File path in #{ENV_VAR} not found" if env_config_file && !File.exist?(env_config_file)
|
15
|
+
|
16
|
+
config_file = env_config_file || search_config_file
|
13
17
|
file_hash = YAML.load_file(config_file, symbolize_names: true)
|
14
18
|
Pdfh.debug "Loaded configuration file: #{config_file}"
|
15
19
|
|
@@ -42,7 +46,8 @@ module Pdfh
|
|
42
46
|
# Gets the first settings file found, or creates a new one
|
43
47
|
# @return [String]
|
44
48
|
def search_config_file
|
45
|
-
CONFIG_FILE_LOCATIONS.each do |
|
49
|
+
CONFIG_FILE_LOCATIONS.each do |dir_string|
|
50
|
+
dir = File.expand_path(dir_string)
|
46
51
|
SUPPORTED_EXTENSIONS.each do |ext|
|
47
52
|
path = File.join(dir, "#{config_file_name}.#{ext}")
|
48
53
|
return path if File.exist?(path)
|
data/lib/pdfh/version.rb
CHANGED
data/lib/pdfh.rb
CHANGED
@@ -45,6 +45,6 @@ module Pdfh
|
|
45
45
|
class << self
|
46
46
|
extend Forwardable
|
47
47
|
def_delegators :@options, :verbose?, :dry?, :file_mode?
|
48
|
-
def_delegators :@console, :ident_print, :warn_print, :error_print, :headline, :debug, :info, :print_options
|
48
|
+
def_delegators :@console, :ident_print, :warn_print, :error_print, :backtrace_print, :headline, :debug, :info, :print_options
|
49
49
|
end
|
50
50
|
end
|
data/mise.toml
ADDED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdfh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaias Piña
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: colorize
|
@@ -37,7 +36,6 @@ files:
|
|
37
36
|
- ".rspec"
|
38
37
|
- ".rubocop.yml"
|
39
38
|
- ".rubocop_todo.yml"
|
40
|
-
- ".tool-versions"
|
41
39
|
- CHANGELOG.md
|
42
40
|
- CODE_OF_CONDUCT.md
|
43
41
|
- Gemfile
|
@@ -67,6 +65,7 @@ files:
|
|
67
65
|
- lib/pdfh/utils/rename_validator.rb
|
68
66
|
- lib/pdfh/utils/settings_builder.rb
|
69
67
|
- lib/pdfh/version.rb
|
68
|
+
- mise.toml
|
70
69
|
- pdfh.gemspec
|
71
70
|
homepage: https://github.com/iax7/pdfh
|
72
71
|
licenses:
|
@@ -77,7 +76,6 @@ metadata:
|
|
77
76
|
source_code_uri: https://github.com/iax7/pdfh
|
78
77
|
changelog_uri: https://github.com/blob/master/CHANGELOG.md
|
79
78
|
rubygems_mfa_required: 'true'
|
80
|
-
post_install_message:
|
81
79
|
rdoc_options: []
|
82
80
|
require_paths:
|
83
81
|
- lib
|
@@ -92,8 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
90
|
- !ruby/object:Gem::Version
|
93
91
|
version: '0'
|
94
92
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
96
|
-
signing_key:
|
93
|
+
rubygems_version: 3.6.6
|
97
94
|
specification_version: 4
|
98
95
|
summary: Organize PDF files
|
99
96
|
test_files: []
|
data/.tool-versions
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby 3.3.0
|