pdfh 0.1.9 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14832944087c61f4949fe3fd42cdb848ebfd8a8931826cbd3e4fc111f5813a31
4
- data.tar.gz: 16c139cc38b766307fe4fe9a21b740161af8fffcc05b5c8397cfdde843b1b943
3
+ metadata.gz: 375df17076824594d8622b7dd9474ab53400297c5ff4598463b5dac3fea352d2
4
+ data.tar.gz: 5174dd71598e65630e78b394f3aa46d2562e9de7d682dcb30cd5695af7a75012
5
5
  SHA512:
6
- metadata.gz: b0c320fcead6ae5e09a37ba17100837d392017b73fa0cd54b5d4126bebc52bd07f009457af741128df8197c67fb52d82eee2422a16b6240930f9e72ff795a950
7
- data.tar.gz: 335af04d4f5753d39e4464be53a24986f89dff1cc1e9fa2866e8340680317337cf3b24eb043cdbcdef5051fa47d45dcfe67ab685b289173dc42e789d5014e3c6
6
+ metadata.gz: 68bed2cab1ef5346e7774d03d66538fcdbdd0ccbc72168359d4e3422a7d39c306de4483dd074483aec6f63d197d7275b072cce080178547b94c6adf2853e81e9
7
+ data.tar.gz: 35087b577052e468a97183af2305e3cef5d03fa42d9942d4528701280894dbe290759bc01b124ce54ba5835e7af53a67cbff5438c568cc1d7e0ce4f50bcdaccd
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ *.yml
2
+
1
3
  .yardoc/
2
4
  _yardoc/
3
5
  coverage/
data/.rubocop.yml CHANGED
@@ -9,8 +9,10 @@ AllCops:
9
9
  NewCops: enable
10
10
  TargetRubyVersion: 2.5
11
11
  Exclude:
12
+ - doc/**/*
12
13
  - pkg/**/*
13
14
  - tmp/**/*
15
+ - vendor/**/*
14
16
 
15
17
  Layout/LineLength:
16
18
  Max: 120
data/.rubocop_todo.yml CHANGED
@@ -1,152 +1,47 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-03-02 12:13:30 UTC using RuboCop version 1.11.0.
3
+ # on 2021-05-15 01:26:47 UTC using RuboCop version 1.14.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: 1
9
+ # Offense count: 5
10
10
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
11
11
  Metrics/AbcSize:
12
- Max: 23
12
+ Max: 24
13
13
 
14
- # Offense count: 4
14
+ # Offense count: 6
15
15
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
16
16
  # IgnoredMethods: refine
17
17
  Metrics/BlockLength:
18
- Max: 144
18
+ Max: 87
19
19
 
20
20
  # Offense count: 1
21
21
  # Configuration parameters: CountComments, CountAsOne.
22
22
  Metrics/ClassLength:
23
- Max: 149
23
+ Max: 121
24
24
 
25
- # Offense count: 5
25
+ # Offense count: 6
26
26
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
27
27
  Metrics/MethodLength:
28
- Max: 13
28
+ Max: 17
29
29
 
30
30
  # Offense count: 2
31
31
  RSpec/AnyInstance:
32
32
  Exclude:
33
- - 'spec/pdfh_spec.rb'
34
-
35
- # Offense count: 13
36
- # Cop supports --auto-correct.
37
- RSpec/ContextMethod:
38
- Exclude:
39
- - 'spec/classes/document_spec.rb'
40
- - 'spec/classes/month_spec.rb'
41
- - 'spec/classes/pdf_handler_spec.rb'
42
- - 'spec/classes/settings_spec.rb'
43
- - 'spec/pdfh_spec.rb'
44
-
45
- # Offense count: 13
46
- # Configuration parameters: Prefixes.
47
- # Prefixes: when, with, without
48
- RSpec/ContextWording:
49
- Exclude:
50
- - 'spec/classes/document_spec.rb'
51
- - 'spec/classes/month_spec.rb'
52
- - 'spec/classes/pdf_handler_spec.rb'
53
- - 'spec/classes/settings_spec.rb'
54
- - 'spec/pdfh_spec.rb'
33
+ - 'spec/pdfh/document_processor_spec.rb'
55
34
 
56
35
  # Offense count: 1
57
- # Cop supports --auto-correct.
58
- # Configuration parameters: SkipBlocks, EnforcedStyle.
59
- # SupportedStyles: described_class, explicit
60
- RSpec/DescribedClass:
61
- Exclude:
62
- - 'spec/classes/settings_spec.rb'
63
-
64
- # Offense count: 16
65
- # Cop supports --auto-correct.
66
- # Configuration parameters: AllowConsecutiveOneLiners.
67
- RSpec/EmptyLineAfterExample:
68
- Exclude:
69
- - 'spec/classes/document_spec.rb'
70
- - 'spec/classes/dry_spec.rb'
71
- - 'spec/classes/month_spec.rb'
72
- - 'spec/classes/settings_spec.rb'
73
- - 'spec/classes/verbose_spec.rb'
74
-
75
- # Offense count: 2
76
- # Cop supports --auto-correct.
77
- RSpec/EmptyLineAfterFinalLet:
78
- Exclude:
79
- - 'spec/classes/pdf_handler_spec.rb'
80
- - 'spec/classes/settings_spec.rb'
81
-
82
- # Offense count: 1
83
- # Configuration parameters: Max.
36
+ # Configuration parameters: CountAsOne.
84
37
  RSpec/ExampleLength:
85
- Exclude:
86
- - 'spec/pdfh_spec.rb'
38
+ Max: 7
87
39
 
88
- # Offense count: 1
89
- RSpec/ExpectInHook:
90
- Exclude:
91
- - 'spec/pdfh_spec.rb'
92
-
93
- # Offense count: 6
94
- # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
95
- # Include: **/*_spec*rb*, **/spec/**/*
96
- RSpec/FilePath:
97
- Exclude:
98
- - 'spec/classes/document_spec.rb'
99
- - 'spec/classes/dry_spec.rb'
100
- - 'spec/classes/month_spec.rb'
101
- - 'spec/classes/pdf_handler_spec.rb'
102
- - 'spec/classes/settings_spec.rb'
103
- - 'spec/classes/verbose_spec.rb'
104
-
105
- # Offense count: 3
106
- # Cop supports --auto-correct.
107
- RSpec/LeadingSubject:
108
- Exclude:
109
- - 'spec/classes/document_spec.rb'
110
- - 'spec/classes/pdf_handler_spec.rb'
111
- - 'spec/classes/settings_spec.rb'
112
-
113
- # Offense count: 18
114
- # Configuration parameters: .
115
- # SupportedStyles: have_received, receive
116
- RSpec/MessageSpies:
117
- EnforcedStyle: receive
118
-
119
- # Offense count: 15
40
+ # Offense count: 2
120
41
  RSpec/MultipleExpectations:
121
- Max: 4
122
-
123
- # Offense count: 71
124
- # Configuration parameters: IgnoreSharedExamples.
125
- RSpec/NamedSubject:
126
- Exclude:
127
- - 'spec/classes/document_spec.rb'
128
- - 'spec/classes/month_spec.rb'
129
- - 'spec/classes/pdf_handler_spec.rb'
130
- - 'spec/classes/settings_spec.rb'
131
- - 'spec/pdfh_spec.rb'
132
-
133
- # Offense count: 16
134
- RSpec/StubbedMock:
135
- Exclude:
136
- - 'spec/classes/document_spec.rb'
137
- - 'spec/classes/pdf_handler_spec.rb'
138
- - 'spec/pdfh_spec.rb'
42
+ Max: 2
139
43
 
140
- # Offense count: 7
44
+ # Offense count: 1
141
45
  RSpec/SubjectStub:
142
46
  Exclude:
143
- - 'spec/classes/document_spec.rb'
144
- - 'spec/classes/pdf_handler_spec.rb'
145
- - 'spec/pdfh_spec.rb'
146
-
147
- # Offense count: 4
148
- # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
149
- RSpec/VerifiedDoubles:
150
- Exclude:
151
- - 'spec/classes/document_spec.rb'
152
- - 'spec/pdfh_spec.rb'
47
+ - 'spec/pdfh/document_processor_spec.rb'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.0.0
1
+ ruby-3.0.1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## v0.2.0
2
+ * Major gem refactoring
3
+ * Changed setting `base_path` to `destination_base_path`
4
+ * Add DocumentType listing option on executable file
5
+ * Add process individual documents providing type and files
6
+ ```bash
7
+ pdfh -t document_type_id path/to_files.pdf
8
+ ```
9
+ * Add settings.yml template in order to create a sample file
10
+
1
11
  ## v0.1.9
2
12
  * Add dependencies validation at run
3
13
 
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "bundler", "~> 2.0"
9
+ gem "code-scanning-rubocop", "~> 0.5"
9
10
  gem "pry", "~> 0.14"
10
11
  gem "rake", "~> 13.0"
11
12
  gem "rspec", "~> 3.9"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pdfh (0.1.9)
4
+ pdfh (0.2.0)
5
5
  colorize (~> 0.8.0)
6
6
 
7
7
  GEM
@@ -10,21 +10,23 @@ GEM
10
10
  ansi (1.5.0)
11
11
  ast (2.4.2)
12
12
  blockenspiel (0.5.0)
13
+ code-scanning-rubocop (0.5.0)
14
+ rubocop (~> 1.0)
13
15
  coderay (1.1.3)
14
16
  colorize (0.8.1)
15
17
  diff-lcs (1.4.4)
16
- docile (1.3.5)
18
+ docile (1.4.0)
17
19
  method_source (1.0.0)
18
20
  parallel (1.20.1)
19
- parser (3.0.0.0)
21
+ parser (3.0.1.1)
20
22
  ast (~> 2.4.1)
21
- pry (0.14.0)
23
+ pry (0.14.1)
22
24
  coderay (~> 1.1)
23
25
  method_source (~> 1.0)
24
26
  rainbow (3.0.0)
25
27
  rake (13.0.3)
26
28
  regexp_parser (2.1.1)
27
- rexml (3.2.4)
29
+ rexml (3.2.5)
28
30
  rspec (3.10.0)
29
31
  rspec-core (~> 3.10.0)
30
32
  rspec-expectations (~> 3.10.0)
@@ -40,23 +42,23 @@ GEM
40
42
  rspec-support (3.10.2)
41
43
  rspec_junit_formatter (0.4.1)
42
44
  rspec-core (>= 2, < 4, != 2.12.0)
43
- rubocop (1.11.0)
45
+ rubocop (1.14.0)
44
46
  parallel (~> 1.10)
45
47
  parser (>= 3.0.0.0)
46
48
  rainbow (>= 2.2.2, < 4.0)
47
49
  regexp_parser (>= 1.8, < 3.0)
48
50
  rexml
49
- rubocop-ast (>= 1.2.0, < 2.0)
51
+ rubocop-ast (>= 1.5.0, < 2.0)
50
52
  ruby-progressbar (~> 1.7)
51
53
  unicode-display_width (>= 1.4.0, < 3.0)
52
- rubocop-ast (1.4.1)
53
- parser (>= 2.7.1.5)
54
- rubocop-performance (1.10.1)
55
- rubocop (>= 0.90.0, < 2.0)
54
+ rubocop-ast (1.5.0)
55
+ parser (>= 3.0.1.1)
56
+ rubocop-performance (1.11.3)
57
+ rubocop (>= 1.7.0, < 2.0)
56
58
  rubocop-ast (>= 0.4.0)
57
59
  rubocop-rake (0.5.1)
58
60
  rubocop
59
- rubocop-rspec (2.2.0)
61
+ rubocop-rspec (2.3.0)
60
62
  rubocop (~> 1.0)
61
63
  rubocop-ast (>= 1.1.0)
62
64
  ruby-progressbar (1.11.0)
@@ -69,10 +71,10 @@ GEM
69
71
  simplecov
70
72
  terminal-table
71
73
  simplecov-html (0.12.3)
72
- simplecov_json_formatter (0.1.2)
73
- terminal-table (3.0.0)
74
- unicode-display_width (~> 1.1, >= 1.1.1)
75
- unicode-display_width (1.7.0)
74
+ simplecov_json_formatter (0.1.3)
75
+ terminal-table (3.0.1)
76
+ unicode-display_width (>= 1.1.1, < 3)
77
+ unicode-display_width (2.0.0)
76
78
  versionomy (0.5.0)
77
79
  blockenspiel (~> 0.5)
78
80
 
@@ -81,6 +83,7 @@ PLATFORMS
81
83
 
82
84
  DEPENDENCIES
83
85
  bundler (~> 2.0)
86
+ code-scanning-rubocop (~> 0.5)
84
87
  pdfh!
85
88
  pry (~> 0.14)
86
89
  rake (~> 13.0)
@@ -95,4 +98,4 @@ DEPENDENCIES
95
98
  versionomy (~> 0.5)
96
99
 
97
100
  BUNDLED WITH
98
- 2.2.12
101
+ 2.2.17
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
- # Pdfh
1
+ # PDF Handler (pdfh)
2
2
 
3
- Examine all PDF files in scrape directories, remove password (if has one), rename and copy to a new directory using regular expresions.
3
+ [![Rubocop](https://github.com/iax7/pdfh/actions/workflows/rubocop-analysis.yml/badge.svg)](https://github.com/iax7/pdfh/actions/workflows/rubocop-analysis.yml)
4
+ [![Ruby][ruby-badge]][ruby-url]
5
+
6
+ Examine all PDF files in Look up directories, remove password (if has one), rename and copy to a new directory using regular expresions.
4
7
 
5
8
  ## Installation
6
9
 
@@ -23,9 +26,9 @@ After installing this gem you need to create your configuration file on your hom
23
26
  `pdfh.yml`
24
27
  ```yaml
25
28
  ---
26
- scrape_dirs: # Directories where all pdf's are going to be analyzed
29
+ lookup_dirs: # Directories where all pdf's are going to be analyzed
27
30
  - ~/Downloads
28
- base_path: ~/PDFs # Directory where all matching documents will be copied
31
+ destination_base_path: ~/PDFs # Directory where all matching documents will be copied (MUST exist)
29
32
  document_types:
30
33
  - name: Document From Bank # Description
31
34
  re_file: '.*MyBankReg\.pdf' # Regular expression to match its filename
@@ -35,7 +38,7 @@ document_types:
35
38
  name_template: '{period} {subtype}' # Template for new filename when copied
36
39
  sub_types: # [OPTIONAL] In case your need an extra category
37
40
  - name: Account1 # Regular expresion to match this subtype
38
- month_offset: -1 # [OPTIONAL] Integer value to adjust month
41
+ month_offset: -1 # [OPTIONAL] Integer (signed) value to adjust month
39
42
  ```
40
43
 
41
44
  ## Development
@@ -63,3 +66,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
63
66
  ## Code of Conduct
64
67
 
65
68
  Everyone interacting in the Pdfh project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/iax7/pdfh/blob/master/CODE_OF_CONDUCT.md).
69
+
70
+ <!-- Links -->
71
+ [ruby-badge]: https://img.shields.io/badge/ruby-3.0.1-blue?style=flat&logo=ruby&logoColor=CC342D&labelColor=white
72
+ [ruby-url]: https://www.ruby-lang.org/en/
data/Rakefile CHANGED
@@ -12,6 +12,7 @@ task default: :spec
12
12
  desc "Bump gem version number (tiny|minor|major)"
13
13
  task :bump, :type do |_t, args|
14
14
  args.with_defaults(type: :tiny)
15
+
15
16
  version_file = File.join(__dir__, "lib", "pdfh", "version.rb")
16
17
  content = File.read(version_file)
17
18
 
@@ -22,4 +23,6 @@ task :bump, :type do |_t, args|
22
23
  File.write(version_file, content.gsub(version_pattern, "\\1#{next_version}\\3"))
23
24
 
24
25
  puts "Successfully bumped from #{current_version.to_s.red} to #{next_version.green}"
26
+ puts "\n> Building v#{next_version.green}..."
27
+ puts `rake build`
25
28
  end
data/bin/console CHANGED
@@ -9,6 +9,9 @@ require "pdfh"
9
9
 
10
10
  # (If you use this, don't forget to add pry to your Gemfile!)
11
11
  require "pry"
12
+
13
+ p Pdfh.parse_argv
14
+
12
15
  Pry.start
13
16
 
14
17
  # require "irb"
data/bin/run ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "pdfh"
6
+ require "pry"
7
+
8
+ Pdfh::DocumentProcessor.new.start
data/exe/pdfh CHANGED
@@ -1,43 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "optparse"
4
+ require "open3"
5
5
  require "pdfh"
6
- require "pdfh/version"
7
- require "pdfh/utils"
8
6
 
9
- options = {}
10
- opt = OptionParser.new do |opts|
11
- # Process ARGV
12
- opts.banner = "Usage: #{opts.program_name} [options]"
13
- opts.on("-v", "--verbose", "Show more output, useful for debug") { |o| options[:verbose] = o }
14
- opts.on("-d", "--dry", "Dry run, does not write new pdf") { |o| options[:dry] = o }
15
- opts.on_tail("-V", "--version", "Show version") do
16
- puts "#{opts.program_name} v#{Pdfh::VERSION}"
17
- exit
7
+ # @param apps [Array]
8
+ # @return [Boolean]
9
+ def validate_installed(*apps)
10
+ found_app = []
11
+ apps.each_with_object(found_app) do |app, result|
12
+ _stdout, _stderr, status = Open3.capture3("command -v #{app}")
13
+ puts "Missing #{app} command." unless status.success?
14
+ result << status.success?
18
15
  end
19
- opts.on_tail("-h", "--help", "Show this message") do
20
- puts opts
21
- exit
22
- end
23
- end
24
16
 
25
- begin
26
- opt.parse!
27
- rescue OptionParser::InvalidOption => e
28
- Pdfh.print_error e, exit_app: false
29
- puts opt
30
- exit 1
17
+ found_app.all?
31
18
  end
32
19
 
33
- def validate_installed(app)
34
- require "open3"
35
- _stdout, _stderr, status = Open3.capture3("command -v #{app}")
36
- puts "Missing #{app} command." unless status.success?
20
+ exit(1) unless validate_installed("qpdf", "pdftotext")
37
21
 
38
- status.success?
22
+ begin
23
+ Pdfh::DocumentProcessor.new.start
24
+ rescue StandardError => e
25
+ Pdfh.error_print e.message
39
26
  end
40
-
41
- exit(1) unless validate_installed("qpdf") && validate_installed("pdftotext")
42
-
43
- Pdfh.main(options)