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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95cec308eb73971828236c5ce0d322a5df4c3124d611aa34a81a1c7187ebd9f0
4
- data.tar.gz: d8ae0ae4019d53bb61415521f768d5f1a8eab01f2257bd3089fbff47ce3926a9
3
+ metadata.gz: 8946e2ef210a5573d2654e9514f775c950e42a65b429365703450b117d3b073e
4
+ data.tar.gz: d9a5927dc608bb8e0ab74cbe28e7d2ff18597158b0daed41784e486dfe83eb92
5
5
  SHA512:
6
- metadata.gz: 5237b1934642a3e52c8bd17b4598298c10c66bb90fb9961e9798b12466f9a0d5873f9443c896fe1fb243c6365981aa714c14a126ae2854a8a185fccc9bb77fa1
7
- data.tar.gz: 3a04a2ff6debcf3af1c7fd6ed794daac06d6f853f3b51b3ff3bab4a91a8831125c61f1873a7b4d02ef65e24b15419162260fd911c8c112c60ed3287242ea87ae
6
+ metadata.gz: 4927717bb5ed460cd444db6a6088d852969e2804c3ebb6efde21b9f7f73a6a310b814b83f062f3ef453d06aaad90a1bff6b9d7cf44bdb6bca22f8dd60cd80d43
7
+ data.tar.gz: 1a7d43a0ebd0bd9d990337cda4470193b18f645fd3011828dc82c88c6e1d7e75670d3580ccdde721214e80848eb98086b9162ce7ed2b75a536ac8a04f3100f1f
@@ -1,2 +1,5 @@
1
+ ## v0.1.3
2
+ * Fixed copy companion files, which was not copying the files.
3
+
1
4
  ## v0.1.2
2
5
  * Initial Release
@@ -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 : #{file_name_only}
111
- Type : #{type_name}
112
- Sub Type : #{sub_type}
113
- Period : #{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 : #{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
- files = find_companion_files
123
-
124
- files unless join
126
+ @companion unless join
125
127
 
126
- files.empty? ? 'N/A' : files.join(', ')
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
- find_companion_files.each do |file|
229
- Verbose.print " cp #{file} --> #{destination}"
230
- FileUtils.cp(file, destination)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pdfh
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
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.2
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-10 00:00:00.000000000 Z
11
+ date: 2019-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize