pdfh 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/pdfh/document.rb +22 -12
- data/lib/pdfh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8946e2ef210a5573d2654e9514f775c950e42a65b429365703450b117d3b073e
|
4
|
+
data.tar.gz: d9a5927dc608bb8e0ab74cbe28e7d2ff18597158b0daed41784e486dfe83eb92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4927717bb5ed460cd444db6a6088d852969e2804c3ebb6efde21b9f7f73a6a310b814b83f062f3ef453d06aaad90a1bff6b9d7cf44bdb6bca22f8dd60cd80d43
|
7
|
+
data.tar.gz: 1a7d43a0ebd0bd9d990337cda4470193b18f645fd3011828dc82c88c6e1d7e75670d3580ccdde721214e80848eb98086b9162ce7ed2b75a536ac8a04f3100f1f
|
data/CHANGELOG.md
CHANGED
data/lib/pdfh/document.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fileutils'
|
4
|
+
|
3
5
|
module Pdfh
|
4
6
|
##
|
5
7
|
# Handles the PDF detected by the rules
|
@@ -43,6 +45,7 @@ module Pdfh
|
|
43
45
|
Verbose.print " SubType: #{@sub_type}"
|
44
46
|
@month, @year, @extra = match_data
|
45
47
|
Verbose.print "==== Assigned: #{@month}, #{@year}, #{@extra} ==( Month, Year, Extra )================"
|
48
|
+
@companion = find_companion_files
|
46
49
|
end
|
47
50
|
|
48
51
|
def period
|
@@ -107,26 +110,26 @@ module Pdfh
|
|
107
110
|
|
108
111
|
def to_s
|
109
112
|
<<~STR
|
110
|
-
Name
|
111
|
-
Type
|
112
|
-
Sub Type
|
113
|
-
Period
|
113
|
+
Name: #{file_name_only}
|
114
|
+
Type: #{type_name}
|
115
|
+
Sub Type: #{sub_type}
|
116
|
+
Period: #{period}
|
114
117
|
File Path: #{file}
|
115
118
|
File Name: #{file_name}
|
116
|
-
New Name
|
119
|
+
New Name: #{new_name}
|
117
120
|
StorePath: #{store_path}
|
121
|
+
Companion: #{companion_files(join: true)}
|
118
122
|
STR
|
119
123
|
end
|
120
124
|
|
121
125
|
def companion_files(join: false)
|
122
|
-
|
123
|
-
|
124
|
-
files unless join
|
126
|
+
@companion unless join
|
125
127
|
|
126
|
-
|
128
|
+
@companion.empty? ? 'N/A' : @companion.join(', ')
|
127
129
|
end
|
128
130
|
|
129
131
|
def write_pdf(base_path)
|
132
|
+
Verbose.print '~~~~~~~~~~~~~~~~~~ Writing PDFs'
|
130
133
|
full_path = File.join(base_path, store_path, new_name)
|
131
134
|
dir_path = File.join(base_path, store_path)
|
132
135
|
|
@@ -219,15 +222,22 @@ module Pdfh
|
|
219
222
|
Dir.chdir(home_dir) do
|
220
223
|
all_files = Dir["#{file_name_only}.*"]
|
221
224
|
companion = all_files.reject { |f| f.include? 'pdf' }
|
225
|
+
Verbose.print " - #{companion.join(', ')}"
|
222
226
|
|
223
227
|
companion || []
|
224
228
|
end
|
225
229
|
end
|
226
230
|
|
227
231
|
def copy_companion_files(destination)
|
228
|
-
|
229
|
-
|
230
|
-
|
232
|
+
Verbose.print '~~~~~~~~~~~~~~~~~~ Writing Companion files'
|
233
|
+
@companion.each do |file|
|
234
|
+
Verbose.print " Working on #{file}..."
|
235
|
+
src_name = File.join(home_dir, file)
|
236
|
+
src_ext = File.extname(file)
|
237
|
+
dest_name = File.basename(new_name, '.pdf')
|
238
|
+
dest_full = File.join(destination, "#{dest_name}#{src_ext}")
|
239
|
+
Verbose.print " cp #{src_name} --> #{dest_full}"
|
240
|
+
FileUtils.cp(src_name, dest_full)
|
231
241
|
end
|
232
242
|
end
|
233
243
|
end
|
data/lib/pdfh/version.rb
CHANGED
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: 0.1.
|
4
|
+
version: 0.1.3
|
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: 2019-01-
|
11
|
+
date: 2019-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|