Regenerate gemspec for version 0.1.3

This commit is contained in:
magnolia-fan
2011-07-18 01:36:09 +04:00
parent 28b6001b0e
commit c0c41e9396
12 changed files with 249 additions and 14 deletions
+31
View File
@@ -0,0 +1,31 @@
require 'nokogiri'
require 'models/fb2_book'
require 'models/fb2_section'
class Fb2
def self.parse data
xml = Nokogiri::XML(data)
# building book
description = xml.css('description')
book = Fb2Book.new
book.title = description.css('title-info > book-title').text
book.author_first_name = description.css('title-info > author > first-name').text
book.author_last_name = description.css('title-info > author > last-name').text
book.annotation = description.css('title-info > annotation > p').text
book.genre = description.css('title-info > genre').text
book.lang = description.css('title-info > lang').text
book.keywords = description.css('title-info > keywords').text.split(', ')
book.sections = []
# building sections
xml.css('body > section').each do |s|
section = Fb2Section.new
section.title = s.css('title > p').text
section.contents = s.css('p').map{ |e| e.text }.drop(1)
book.sections << section
end
book
end
end
+3
View File
@@ -0,0 +1,3 @@
class Fb2Book
attr_accessor :title, :author_first_name, :author_last_name, :annotation, :genre, :lang, :keywords, :sections
end
+3
View File
@@ -0,0 +1,3 @@
class Fb2Section
attr_accessor :title, :contents
end