Class: Kindai::Publisher
- Inherits:
-
Object
- Object
- Kindai::Publisher
- Defined in:
- lib/kindai/publisher.rb
Instance Attribute Summary collapse
-
#book ⇒ Object
Returns the value of attribute book.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
Class Method Summary collapse
Instance Method Summary collapse
- #divide ⇒ Object
- #empty(glob) ⇒ Object
- #ensure_book ⇒ Object
- #name(n) ⇒ Object
- #publish ⇒ Object
- #publish_auto ⇒ Object
- #publish_default ⇒ Object
- #publish_for_ipad ⇒ Object
- #publish_for_iphone ⇒ Object
- #publish_for_kindle ⇒ Object
- #resize(width, height) ⇒ Object
- #trim(geometry = true) ⇒ Object
- #zip ⇒ Object
Instance Attribute Details
#book ⇒ Object
Returns the value of attribute book.
5 6 7 |
# File 'lib/kindai/publisher.rb', line 5 def book @book end |
#root_path ⇒ Object
Returns the value of attribute root_path.
4 5 6 |
# File 'lib/kindai/publisher.rb', line 4 def root_path @root_path end |
Class Method Details
.new_from_path(root_path) ⇒ Object
7 8 9 10 11 |
# File 'lib/kindai/publisher.rb', line 7 def self.new_from_path(root_path) me = self.new me.root_path = root_path me end |
Instance Method Details
#divide ⇒ Object
33 34 35 36 |
# File 'lib/kindai/publisher.rb', line 33 def divide config(:divide, true) self end |
#empty(glob) ⇒ Object
38 39 40 |
# File 'lib/kindai/publisher.rb', line 38 def empty(glob) FileUtils.rm_r(Dir.glob(File.join(self.root_path, glob))) end |
#ensure_book ⇒ Object
86 87 88 89 |
# File 'lib/kindai/publisher.rb', line 86 def ensure_book @book ||= Kindai::Book.new_from_local_directory(root_path) true end |
#name(n) ⇒ Object
13 14 15 16 |
# File 'lib/kindai/publisher.rb', line 13 def name(n) config(:name, n) self end |
#publish ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kindai/publisher.rb', line 42 def publish Kindai::Util.logger.info("publish #{root_path}, #{config(:name)}") raise "no name" unless config(:name) self.ensure_book if seems_finished? Kindai::Util.logger.info("already published") return end create_directory path = original_path path = trim!(path) if trim? path = divide!(path) if divide? path = resize!(path) if resize? path = zip!(path) if zip? end |
#publish_auto ⇒ Object
60 61 62 63 64 |
# File 'lib/kindai/publisher.rb', line 60 def publish_auto self.ensure_book self.clone.trim.resize(1280, 960).trim.zip.name('iphone').publish self.clone.trim.resize(600, 800).divide.zip.name('kindle').publish end |
#publish_default ⇒ Object
66 67 68 69 |
# File 'lib/kindai/publisher.rb', line 66 def publish_default self.ensure_book self.clone.trim.name('default').publish end |
#publish_for_ipad ⇒ Object
76 77 78 79 |
# File 'lib/kindai/publisher.rb', line 76 def publish_for_ipad self.ensure_book self.clone.trim.resize(768*2, 1024).trim.zip.name('ipad').publish end |
#publish_for_iphone ⇒ Object
71 72 73 74 |
# File 'lib/kindai/publisher.rb', line 71 def publish_for_iphone self.ensure_book self.clone.trim.resize(1280, 960).trim.zip.name('iphone').publish end |
#publish_for_kindle ⇒ Object
81 82 83 84 |
# File 'lib/kindai/publisher.rb', line 81 def publish_for_kindle self.ensure_book self.clone.trim.resize(600, 800).divide.zip.name('kindle').publish end |
#resize(width, height) ⇒ Object
18 19 20 21 |
# File 'lib/kindai/publisher.rb', line 18 def resize(width, height) config(:resize, {:width => width, :height => height}) self end |
#trim(geometry = true) ⇒ Object
23 24 25 26 |
# File 'lib/kindai/publisher.rb', line 23 def trim(geometry = true) config(:trim, geometry) unless config(:trim) self end |
#zip ⇒ Object
28 29 30 31 |
# File 'lib/kindai/publisher.rb', line 28 def zip config(:zip, true) self end |