epub_book 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e4b4e7ecf61eeac4fa5d7aba678cd896c0bfbf5
4
- data.tar.gz: 93d917c915f27c762a8d614a3db76b8928d48243
3
+ metadata.gz: bd8a0433b5b28cbafc6bdd278240eebf5bff4a80
4
+ data.tar.gz: 64228d14dee44467a4e4f9bbbaeb00c9b708596d
5
5
  SHA512:
6
- metadata.gz: 490269203cc094c1debfe06324fe2d9b595a2becf7293e672704035e566c313e8db4148852fb802164644e1954d15fbdbf3738f4c845ee81352d47a53f038996
7
- data.tar.gz: ebd9829cd406bd795c2bbb9c0ebe721fe36c3e14cfef59f75928b8f9485ce011d45772bf31fa40eb11767b73fbdd52a3bf503ffc9cfe83853d0ac9cca7ec8896
6
+ metadata.gz: 92d7dc626ff49c8bb275de0559025d23c77374cc8c17887e4b08da219f5500b4d59e015965edb0ac86ee3779ef6f356550a42b323c78e771981d0e628e19fbfb
7
+ data.tar.gz: 6f2db1d7ba8edd0a12c73bb7ef8e02e7897cec35b1af5f2a858456f7c602d1bc97d8d9e85bb67fe5c68cc73f7c0480cfd91ee0c225f060c4226157da143dca07
@@ -110,11 +110,17 @@ module EpubBook
110
110
  #得到书目索引
111
111
  def fetch_index(url=nil)
112
112
  url ||= @index_url
113
- doc = Nokogiri::HTML(open(URI.encode(url),"User-Agent" => @user_agent ,'Referer'=> @referer).read)
113
+ _tmp_string = open(URI.encode(url),"User-Agent" => @user_agent ,'Referer'=> @referer).read
114
+ doc = Nokogiri::HTML(Encoding::UTF_8 === _tmp_string.encoding ? _tmp_string : _tmp_string.force_encoding('gbk').encode('utf-8'))
114
115
  #generate index.yml
115
116
 
116
117
  if !book[:title]
117
- doc1 = @des_url.nil? ? doc : Nokogiri::HTML(open(URI.encode(des_url),"User-Agent" => @user_agent ,'Referer'=> @referer).read)
118
+ doc1 = if @des_url.nil?
119
+ doc
120
+ else
121
+ _tmp_string = open(URI.encode(@des_url),"User-Agent" => @user_agent ,'Referer'=> @referer).read
122
+ Nokogiri::HTML(Encoding::UTF_8 === _tmp_string.encoding ? _tmp_string : _tmp_string.force_encoding('gbk').encode('utf-8'))
123
+ end
118
124
  get_des(doc1)
119
125
  end
120
126
 
@@ -152,7 +158,8 @@ module EpubBook
152
158
  next if test(?s,content_path)
153
159
 
154
160
  begin
155
- doc_file = Nokogiri::HTML(open(item[:url],"User-Agent" => @user_agent,'Referer'=> @referer).read)
161
+ _tmp_string = open(item[:url],"User-Agent" => @user_agent,'Referer'=> @referer).read
162
+ doc_file = Nokogiri::HTML(Encoding::UTF_8 === _tmp_string.encoding ? _tmp_string : _tmp_string.force_encoding('gbk').encode('utf-8'))
156
163
 
157
164
  File.open(content_path,'w') do |f|
158
165
  f.write("<h3>#{item[:label]}</h3>")
@@ -1,3 +1,3 @@
1
1
  module EpubBook
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub_book
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - qmliu