dyck icon indicating copy to clipboard operation
dyck copied to clipboard

Mobi parser/generator library in Ruby

= {project-name} Marat Radchenko [email protected] :project-name: Dyck :project-handle: dyck :slug: slonopotamus/{project-handle} :uri-project: https://github.com/{slug} :uri-ci: {uri-project}/actions?query=branch%3Amaster :uri-gem: https://rubygems.org/gems/{project-handle}

image:https://img.shields.io/gem/v/{project-handle}.svg[Latest Release,link={uri-gem}] image:{uri-project}/workflows/CI/badge.svg?branch=master[Build Status,link={uri-ci}]

{project-name} is a Mobi parser/generator library written in Ruby.

== Installation

Add this line to your application's Gemfile:

[source,ruby]

gem 'dyck'

And then execute:

[source,shell script]

$ bundle install

Or install it yourself as:

[source,shell script]

$ gem install dyck

== Usage

Reading existing Mobi file:

[source,ruby]

require 'dyck'

f = File.open('book.mobi') mobi = Dyck::Mobi::read(f)

Access Mobi data

mobi.title mobi.publishing_date mobi.author mobi.mobi6.parts # Document text in MOBI6 format mobi.kf8.parts # Document text in KF8 format mobi.resources # Images, fonts, audio, video


Writing new Mobi file:

[source,ruby]

require 'dyck'

mobi = Dyck::Mobi.new

Fill file metadata

mobi.title = 'Moby Dick' mobi.publishing_date = Time.parse('October 18, 1851') mobi.author = 'Herman Melville' mobi.subjects = %w[whale sea] mobi.description = "The book is the sailor Ishmael's narrative of the obsessive quest of Ahab,"
" captain of the whaling ship Pequod, for revenge on Moby Dick, the giant white sperm whale "
"that on the ship's previous voyage bit off Ahab's leg at the knee."

Add MOBI6 data

mobi.mobi6 = Dyck::MobiData.new mobi.mobi6.parts << '

Book text in MOBI6 format'

And/or, add KF8 data

mobi.kf8 = Dyck::MobiData.new mobi.kf8.parts << '

Book text in KF8 format'

Write to file

File.open('moby-dick.mobi', 'wb') do |f| mobi.write(f) end

== Development

After checking out the repo, run bundle install to install dependencies. Then, run bundle exec rake spec to run the tests.