Sha256: 613f8c663f136e75f92a81586316b329db0b5242ad30684af02e8a913363ed0f
Contents?: true
Size: 968 Bytes
Versions: 2
Compression:
Stored size: 968 Bytes
Contents
class Mangos::BookUpdater attr_reader :package, :book def initialize(package, book, path) @package = package @book = book @path = path end def update page_paths = find_page_paths @book.key = Digest::SHA256.hexdigest(@path.to_s)[0..16] @book.page_paths = build_page_paths(page_paths) @book.pages = page_paths.length @book.path = @path.basename.to_s @book.published_on = @path.mtime.to_i @book.tags = Mangos::TagBreaker.new(@book.path).tags Mangos::Thumbnailer.new(page_paths.first, thumbnail_path).generate end def find_page_paths image_paths = @path.children.select { |p| p.image? && !p.hidden? } Naturalsorter::Sorter.sort(image_paths.map(&:to_s), true).map { |p| DecoratedPathname.new(p) } end def build_page_paths(page_paths) Mangos::PagesDeflater.new(page_paths.map { |p| p.basename.to_s }).deflate end def thumbnail_path @package.thumbnails_path + "#{@book.key}.jpg" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mangos-0.2 | lib/mangos/book_updater.rb |
mangos-0.1 | lib/mangos/book_updater.rb |