ebook_tools 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/ebook_tools.gemspec +1 -1
- data/lib/paras_in_mongo.rb +10 -9
- metadata +1 -1
data/CHANGELOG
CHANGED
data/ebook_tools.gemspec
CHANGED
data/lib/paras_in_mongo.rb
CHANGED
@@ -19,12 +19,12 @@ module ParasInMongo
|
|
19
19
|
section_title = ''
|
20
20
|
para_mongo_attrs = paras.map do |para|
|
21
21
|
unless para.parent == section
|
22
|
-
section_title = para.parent.search("info[1]/title").text
|
22
|
+
section_title = para.parent.search("info[1]/title").text rescue nil
|
23
23
|
section = para.parent
|
24
24
|
end
|
25
|
-
extract_para_attrs(para,source.merge(location: {section: section_title}))
|
25
|
+
extract_para_attrs(para,source.merge(location: {section: section_title})) rescue nil
|
26
26
|
end
|
27
|
-
para_mongo_attrs.each do |attrs|
|
27
|
+
para_mongo_attrs.compact.each do |attrs|
|
28
28
|
session[options['collection']].insert(attrs)
|
29
29
|
end
|
30
30
|
end
|
@@ -33,16 +33,17 @@ module ParasInMongo
|
|
33
33
|
def extract_book_info(doc)
|
34
34
|
book_id = doc.search("book")[0]['id']
|
35
35
|
book_info = doc.search("book/info[1]")
|
36
|
-
title = book_info.search("title[1]").text
|
37
|
-
author = book_info.search("authorgroup/author/personname[1]").text
|
38
|
-
pubdate = book_info.search("pubdate[1]").text
|
39
|
-
publisher = book_info.search("publisher/publishername[1]").text
|
36
|
+
title = book_info.search("title[1]").text rescue ''
|
37
|
+
author = book_info.search("authorgroup/author/personname[1]").text rescue ''
|
38
|
+
pubdate = book_info.search("pubdate[1]").text rescue ''
|
39
|
+
publisher = book_info.search("publisher/publishername[1]").text rescue ''
|
40
40
|
{title: title,book_id: book_id, author: author,pubdate: pubdate, publisher: publisher}
|
41
41
|
end
|
42
42
|
|
43
43
|
def extract_para_attrs(para,source)
|
44
44
|
para_attrs = {'_id' => para['id']}
|
45
|
-
|
45
|
+
|
46
|
+
content = para.search("content")[0].text
|
46
47
|
|
47
48
|
keywords = []
|
48
49
|
para.search("keyword").each do |keyword|
|
@@ -51,6 +52,6 @@ module ParasInMongo
|
|
51
52
|
|
52
53
|
para_attrs = para_attrs.merge(keywords: keywords, content: content)
|
53
54
|
#section = timer{para.parent.search("info[1]/title").text}
|
54
|
-
para_attrs.merge(source: source)
|
55
|
+
para_attrs.merge(source: source)
|
55
56
|
end
|
56
57
|
end
|