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 CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.7 2013.6.7
2
+ fix bug: 不能获取段落内容
3
+
1
4
  0.1.6 2013.6.7
2
5
  重构para_import_mongo,提升速度
3
6
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ebook_tools}
5
- s.version = '0.1.6'
5
+ s.version = '0.1.7'
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Aaron"]
@@ -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
- content = para.search("content[1]").text
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebook_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: