lknovel 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d57d2cbac7be77703b07028b81985f565f0479ee
4
+ data.tar.gz: a68226041b38efe2167909380b0c3754c899c350
5
+ SHA512:
6
+ metadata.gz: 12dcab45d1073b2c372144afc68bb93711697456b2bf90f22a1101e78fb9c3672d4d24486db4b15e2e204c7143c102f38cda34b2f84979a79b46b1e7222962cb
7
+ data.tar.gz: c6b8eb7a212b24979e0f5fabfd83982efbec6fced549985a0ecf6de787d15f5464297122c9e8aefc2ccc99c83dcffd1215f46d73f5a2eb1de8d9a4c8f9804040
data/CHANGELOG CHANGED
@@ -7,3 +7,4 @@
7
7
  0.0.5: Fix lots of errors detected by epubcheck
8
8
  0.0.6: Add --chapter-theads/--image-theads cli options, support download a
9
9
  whole series
10
+ 0.0.7: Use IE 10 user agent to open uri, fix parsing and downloading
data/Gemfile CHANGED
@@ -2,4 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in lknovel.gemspec
4
4
  gemspec
5
- gem 'coveralls', require: false
5
+ group :development, :test do
6
+ gem 'coveralls', require: false
7
+ end
data/README.md CHANGED
@@ -22,15 +22,17 @@ And then execute:
22
22
 
23
23
  ## Dependencies
24
24
 
25
- * Ruby 1.9
25
+ * [ruby >= 1.9](https://www.ruby-lang.org/en/installation/)
26
26
  * [nokogiri](http://nokogiri.org/)
27
27
  * [gepub](https://github.com/skoji/gepub)
28
28
  * [parallel](https://github.com/grosser/parallel)
29
29
 
30
- Rubygems will solve it for you.
30
+ Rubygems will solve them for you.
31
31
 
32
32
  If you encounter compiling/installing problem about nokogiri, install it
33
- manually using the package manager. For Debian/Ubuntu:
33
+ manually using the package manager.
34
+
35
+ For Debian/Ubuntu:
34
36
 
35
37
  # apt-get install ruby-nokogiri
36
38
 
@@ -60,7 +62,7 @@ manually using the package manager. For Debian/Ubuntu:
60
62
 
61
63
  ## Contributing
62
64
 
63
- 1. Fork it ( http://github.com/azuwis/lknovel/fork )
65
+ 1. Fork it ( https://github.com/azuwis/ruby-lknovel/fork )
64
66
  2. Create your feature branch (`git checkout -b my-new-feature`)
65
67
  3. Commit your changes (`git commit -am 'Add some feature'`)
66
68
  4. Push to the branch (`git push origin my-new-feature`)
@@ -5,7 +5,6 @@ require 'lknovel/image'
5
5
  require 'lknovel/meta'
6
6
  require 'lknovel/utils'
7
7
  require 'nokogiri'
8
- require 'open-uri'
9
8
 
10
9
  module Lknovel
11
10
  class Chapter
@@ -21,22 +20,22 @@ module Lknovel
21
20
 
22
21
  def parse
23
22
  page = retryable do
24
- Nokogiri::HTML(open(@url))
23
+ Nokogiri::HTML(openuri(@url))
25
24
  end
26
25
 
27
26
  @title = page.css('li.active')[0].text.sub('章', '章 ').strip
28
27
 
29
- @content = []
30
- page.css('div#J_view').css('div.lk-view-line, br + br').each do |x|
28
+ @content = page.css('div#J_view')
29
+ .css('div.lk-view-line, br + br')
30
+ .map do |x|
31
31
  img = x.css('img[data-cover]')
32
32
  if x.name == 'br'
33
- @content << ''
33
+ ''
34
34
  elsif img.length > 0
35
- lk_image = Image.new(URI.join(url, img[0]['data-cover']))
36
- @content << lk_image
35
+ Image.new(URI.join(url, img[0]['data-cover']))
37
36
  else
38
37
  # strip and remove leading wide space
39
- @content << x.text.strip.sub(/^ +/, '')
38
+ x.text.strip.sub(/^ +/, '')
40
39
  end
41
40
  end
42
41
  end
@@ -1,5 +1,4 @@
1
1
  require 'lknovel/utils'
2
- require 'open-uri'
3
2
  require 'uri'
4
3
 
5
4
  module Lknovel
@@ -17,7 +16,7 @@ module Lknovel
17
16
  if !File.exists?(file)
18
17
  File.open(file, 'wb') do |w|
19
18
  retryable do
20
- open(@uri, 'rb') do |r|
19
+ openuri(@uri, 'rb') do |r|
21
20
  w.write(r.read)
22
21
  end
23
22
  end
@@ -1,5 +1,5 @@
1
1
  module Lknovel
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  MODULE_PATH = File.expand_path('..', __FILE__)
4
4
  TEMPLATE_PATH = File.join(MODULE_PATH, 'templates')
5
5
  STYLESHEET_PATH = File.join(MODULE_PATH, 'assets', 'stylesheets')
@@ -2,7 +2,6 @@
2
2
  require 'lknovel/utils'
3
3
  require 'lknovel/volume'
4
4
  require 'nokogiri'
5
- require 'open-uri'
6
5
 
7
6
  module Lknovel
8
7
  class Series
@@ -14,7 +13,7 @@ module Lknovel
14
13
 
15
14
  def parse
16
15
  page = retryable do
17
- Nokogiri::HTML(open(@url))
16
+ Nokogiri::HTML(openuri(@url))
18
17
  end
19
18
 
20
19
  @volumes = page.css('dl dd h2.ft-24 strong a').map do |x|
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'parallel'
3
+ require 'open-uri'
3
4
 
4
5
  # http://blog.codefront.net/2008/01/14/retrying-code-blocks-in-ruby-on-exceptions-whatever/
5
6
  # Options:
@@ -26,6 +27,10 @@ def retryable(options = {}, &block)
26
27
  yield
27
28
  end
28
29
 
30
+ def openuri(name, *rest, &block)
31
+ open(name, *rest, {'User-Agent' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)'}, &block)
32
+ end
33
+
29
34
  def parallel_verbose(items, options = {}, &block)
30
35
  opts = {:title => 'Working', :verbose => true, :threads => 5}.merge(options)
31
36
  if opts[:verbose]
@@ -3,7 +3,6 @@ require 'lknovel/chapter'
3
3
  require 'lknovel/meta'
4
4
  require 'lknovel/utils'
5
5
  require 'nokogiri'
6
- require 'open-uri'
7
6
 
8
7
  module Lknovel
9
8
  class Volume
@@ -22,9 +21,8 @@ module Lknovel
22
21
 
23
22
  def parse
24
23
  page = retryable do
25
- Nokogiri::HTML(open(@url))
24
+ Nokogiri::HTML(openuri(@url))
26
25
  end
27
-
28
26
  page_title = page.title.split(' - ')
29
27
  @series = page_title[0]
30
28
  @number_s = page_title[1]
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lknovel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Zhong Jianxin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-21 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.5'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.5'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: minitest
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: gepub
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: nokogiri
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: parallel
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: pry-rescue
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description:
@@ -131,8 +116,8 @@ executables:
131
116
  extensions: []
132
117
  extra_rdoc_files: []
133
118
  files:
134
- - .gitignore
135
- - .travis.yml
119
+ - ".gitignore"
120
+ - ".travis.yml"
136
121
  - CHANGELOG
137
122
  - Gemfile
138
123
  - LICENSE.txt
@@ -160,27 +145,26 @@ files:
160
145
  homepage: https://github.com/azuwis/ruby-lknovel
161
146
  licenses:
162
147
  - MIT
148
+ metadata: {}
163
149
  post_install_message:
164
150
  rdoc_options: []
165
151
  require_paths:
166
152
  - lib
167
153
  required_ruby_version: !ruby/object:Gem::Requirement
168
- none: false
169
154
  requirements:
170
- - - ! '>='
155
+ - - ">="
171
156
  - !ruby/object:Gem::Version
172
157
  version: '0'
173
158
  required_rubygems_version: !ruby/object:Gem::Requirement
174
- none: false
175
159
  requirements:
176
- - - ! '>='
160
+ - - ">="
177
161
  - !ruby/object:Gem::Version
178
162
  version: '0'
179
163
  requirements: []
180
164
  rubyforge_project:
181
- rubygems_version: 1.8.23
165
+ rubygems_version: 2.2.2
182
166
  signing_key:
183
- specification_version: 3
167
+ specification_version: 4
184
168
  summary: Generate epub from http://lknovel.lightnovel.cn/
185
169
  test_files:
186
170
  - test/minitest_helper.rb