cbr2pdf 0.0.2 → 0.1.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/bin/cbr2pdf +41 -9
- data/lib/cbr2pdf.rb +1 -5
- data/lib/cbr2pdf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 237be457d6d84b05e4a8add19becab5b9f57c17a
|
4
|
+
data.tar.gz: 636e97191a400e7e5a7d356a4797ee5499f31d3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04e388ed5ccdf8b0e4a4a8bc605a556a431324f92f583481f382ec2de55031a2e26dc67b9edccd1880b47168d84f2f79dcd89ebf88a46a7fce1ab1fd9084aadb
|
7
|
+
data.tar.gz: 5ba74e74205fa62f28beb4e02c37ae905357fcc2f3a264bdc6215518f70e5322451e4a7b36d7be08f62838de5cbcd587555eb9dcb4f65aa0fcec3705c6df7198
|
data/bin/cbr2pdf
CHANGED
@@ -8,7 +8,7 @@ require 'zip/zip'
|
|
8
8
|
me = File.basename(__FILE__)
|
9
9
|
|
10
10
|
options = {}
|
11
|
-
OptionParser.new do |opts|
|
11
|
+
optparse = OptionParser.new do |opts|
|
12
12
|
opts.banner = "Usage: #{me} -o OUTPUT_FILE INPUT_FILE [INPUT_FILE...]"
|
13
13
|
opts.on('-o', '--output FILE', String, 'Output file') do |o|
|
14
14
|
options[:output] = o
|
@@ -19,6 +19,11 @@ OptionParser.new do |opts|
|
|
19
19
|
end
|
20
20
|
end.parse!
|
21
21
|
|
22
|
+
if options[:output].nil?
|
23
|
+
puts 'Output file not specified'
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
|
22
27
|
inputs = ARGV
|
23
28
|
|
24
29
|
# ensure output file has .pdf on it
|
@@ -31,16 +36,43 @@ inputs.each do |input|
|
|
31
36
|
|
32
37
|
print "Reading #{File.basename(input)}"
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
case File.extname(input)
|
40
|
+
when '.cbr'
|
41
|
+
|
42
|
+
if `which unrar`.empty?
|
43
|
+
puts 'Unable to locate unrar utility'
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
Dir.mktmpdir do |dir|
|
48
|
+
puts `cd #{dir} && unrar e "#{input}"`
|
49
|
+
Dir["#{dir}/*"].each do |f|
|
50
|
+
next if File.directory?(f)
|
51
|
+
print '.'
|
52
|
+
begin
|
53
|
+
list << Magick::Image.read(f)[0]
|
54
|
+
rescue Magick::ImageMagickError => e
|
55
|
+
#p e
|
56
|
+
end
|
42
57
|
end
|
43
58
|
end
|
59
|
+
|
60
|
+
when '.cbz'
|
61
|
+
|
62
|
+
Zip::ZipFile.open(input) do |zf|
|
63
|
+
zf.each do |entry|
|
64
|
+
next if entry.ftype == :directory
|
65
|
+
print '.'
|
66
|
+
begin
|
67
|
+
list << Magick::Image.from_blob(zf.read(entry))[0]
|
68
|
+
rescue Magick::ImageMagickError => e
|
69
|
+
#p e
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
else
|
75
|
+
puts 'DUNNO!'
|
44
76
|
end
|
45
77
|
|
46
78
|
print "\n"
|
data/lib/cbr2pdf.rb
CHANGED
data/lib/cbr2pdf/version.rb
CHANGED