Project

fb2rb

0.0
The project is in a healthy, maintained state
Fiction Book 2 parser/generator library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 13.0.0
~> 0.5.0
~> 3.12.0
~> 1.12.1

Runtime

~> 2.3.0
>= 1.10, < 1.14
 Project Readme

FB2rb

Latest Release Build Status

fb2rb is a Fiction Book 2 parser/generator library written in Ruby.

Installation

Add this line to your application’s Gemfile:

gem 'fb2rb'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install fb2rb

Usage

You can create FB2 book in memory and write it to file:

require 'fb2rb'

book = FB2rb::Book.new
book.description.title_info.book_title = 'Book title'

body = FB2rb::Body.new(nil, '<p>Book text</p>')
book.bodies << body

book.write_compressed('/path/to/book.fb2.zip')
# or
book.write_uncompressed('/path/to/book.fb2')

Also, you can read existing FB2 file:

require 'fb2rb'

book = FB2rb::Book.read_compressed('/path/to/book.fb2.zip')
# or
book = FB2rb::Book.read_uncompressed('/path/to/book.fb2')

puts book.description.title_info.book_title
puts book.bodies[0].content

Development

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