moebius 0.1

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.
Files changed (2) hide show
  1. data/bin/moebius +53 -0
  2. metadata +74 -0
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Moebius: Simple comic book converter script.
4
+ #
5
+ # Things Prawn can do to make this script nicer:
6
+ # * Allow :margins => [0,0,0,0] or :margins => :none (or something like that)
7
+
8
+ if ARGV[0].nil?
9
+ puts "usage:"
10
+ puts "moebius directory-or-cb[zr]-file"
11
+ exit 1
12
+ end
13
+
14
+ require "rubygems"
15
+ require "prawn"
16
+ require 'find'
17
+ require 'fileutils'
18
+ require 'tempfile'
19
+
20
+
21
+ def process_file(file)
22
+ basename = File.basename(file, File.extname(file))
23
+ target = "/#{Dir::tmpdir}/#{basename}/".gsub(' ', '_')
24
+
25
+ # Extract comic images
26
+ FileUtils.mkdir_p target unless File.exists? target
27
+ `unzip -j "#{file}" -d #{target}` if File.extname(file) =~ /cbz/i
28
+ `unrar e "#{file}" #{target}` if File.extname(file) =~ /cbr/i
29
+ comicFiles = Dir["#{target}*.jpg"]
30
+
31
+ settings = { :skip_page_creation => true,
32
+ :bottom_margin => 0,
33
+ :top_margin => 0,
34
+ :right_margin => 0,
35
+ :left_margin => 0 }
36
+
37
+ # Generate PDF file
38
+ Prawn::Document.generate("#{basename}.pdf", settings) do
39
+ comicFiles.each do |file|
40
+ start_new_page
41
+ image file, :at => [0,802], :height => 842
42
+ end
43
+ end
44
+
45
+ # Remove tmp files
46
+ FileUtils.rm_r target
47
+ end
48
+
49
+ Find.find(ARGV[0]) do |path|
50
+ next if FileTest.directory? path
51
+ next unless File.extname(path) =~ /cb[zr]/i
52
+ process_file path
53
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moebius
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Will Leinweber
12
+ - Alexandre Girard
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-19 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: prawn
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: Convert cb[zr] files to pdfs
33
+ email: will@bitfission.com
34
+ executables:
35
+ - moebius
36
+ extensions: []
37
+
38
+ extra_rdoc_files: []
39
+
40
+ files: []
41
+
42
+ has_rdoc: true
43
+ homepage: http://github.com/will/moebius
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options: []
48
+
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ requirements:
66
+ - unrar
67
+ - unzip
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.6
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Convert cb[zr] files to pdfs
73
+ test_files: []
74
+