pixiv 0.0.2 → 0.0.3
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/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/Rakefile +16 -1
- data/console_helper.rb +38 -0
- data/lib/pixiv/bookmark_list.rb +2 -2
- data/lib/pixiv/client.rb +8 -5
- data/lib/pixiv/illust.rb +25 -8
- data/lib/pixiv/member.rb +16 -2
- data/lib/pixiv/page.rb +22 -2
- data/lib/pixiv/version.rb +1 -1
- data/pixiv.gemspec +6 -2
- data/spec/fixtures/empty.html +10 -0
- data/spec/fixtures/illust_345.html +36 -0
- data/spec/fixtures/member_6.html +20 -0
- data/spec/pixiv/illust_spec.rb +64 -0
- data/spec/pixiv/member_spec.rb +38 -0
- data/spec/pixiv/page_spec.rb +17 -0
- data/spec/spec_helper.rb +22 -0
- metadata +75 -6
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Rakefile
CHANGED
@@ -1 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
task :c => :console
|
8
|
+
|
9
|
+
desc 'start console'
|
10
|
+
task :console do
|
11
|
+
Bundler.with_clean_env do
|
12
|
+
console_helper = File.expand_path('../console_helper.rb', __FILE__)
|
13
|
+
load_env = File.exist?('.env') ? 'source .env' : 'true'
|
14
|
+
exec "#{load_env} && pry -r #{console_helper} -e 'init;'"
|
15
|
+
end
|
16
|
+
end
|
data/console_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
def init
|
2
|
+
id = ENV['PIXIV_ID'] or warn 'PIXIV_ID is not set'
|
3
|
+
password = ENV['PIXIV_PASSWORD'] or warn 'PIXIV_PASSWORD is not set'
|
4
|
+
abort unless id && password
|
5
|
+
|
6
|
+
proxy =
|
7
|
+
begin
|
8
|
+
if ENV['HTTP_PROXY']
|
9
|
+
host, port = ENV['HTTP_PROXY'].split(/:/)
|
10
|
+
[host, (port || 80).to_i]
|
11
|
+
else
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'bundler/setup'
|
17
|
+
Bundler.require
|
18
|
+
|
19
|
+
$pixiv = Pixiv.new(id, password) do |agent|
|
20
|
+
agent.user_agent_alias = 'Mac Safari'
|
21
|
+
agent.set_proxy(*proxy) if proxy
|
22
|
+
end
|
23
|
+
|
24
|
+
Kernel.const_set(:P, $pixiv)
|
25
|
+
Kernel.const_set(:M, $pixiv.member)
|
26
|
+
end
|
27
|
+
|
28
|
+
def I(id)
|
29
|
+
$pixiv.illust(id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def M(id)
|
33
|
+
$pixiv.member(id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def BL(member_id, p = 1)
|
37
|
+
$pixiv.bookmark_list(member_id, p)
|
38
|
+
end
|
data/lib/pixiv/bookmark_list.rb
CHANGED
@@ -19,7 +19,7 @@ module Pixiv
|
|
19
19
|
# @return [Integer]
|
20
20
|
lazy_attr_reader(:member_id) { doc.body.match(/pixiv\.context\.userId = '(\d+)'/).to_a[1].to_i }
|
21
21
|
# @return [Array<Integer>]
|
22
|
-
lazy_attr_reader(:illust_ids) { search!('li[id^="li_"] a[href^="member_illust.php?mode=medium"]').map {|n| n
|
22
|
+
lazy_attr_reader(:illust_ids) { search!('li[id^="li_"] a[href^="member_illust.php?mode=medium"]').map {|n| n['href'].match(/illust_id=(\d+)$/).to_a[1].to_i } }
|
23
23
|
# @return [Array<Hash{Symbol=>Object}, nil>]
|
24
24
|
lazy_attr_reader(:illust_hashes) {
|
25
25
|
search!('li[id^="li_"]').map {|node| illust_hash_from_bookmark_item(node) }
|
@@ -55,7 +55,7 @@ module Pixiv
|
|
55
55
|
title: illust_node.inner_text,
|
56
56
|
member_id: member_node['href'].match(/\?id=(\d+)/).to_a[1].to_i,
|
57
57
|
member_name: member_node.inner_text,
|
58
|
-
small_image_url: illust_node.at('img')
|
58
|
+
small_image_url: illust_node.at('img')['src'],
|
59
59
|
}
|
60
60
|
end
|
61
61
|
end
|
data/lib/pixiv/client.rb
CHANGED
@@ -53,17 +53,19 @@ module Pixiv
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# @param [Integer] illust_id
|
56
|
-
# @return [Pixiv::Illust]
|
56
|
+
# @return [Pixiv::Illust] illust bound to +self+
|
57
57
|
def illust(illust_id)
|
58
58
|
attrs = {illust_id: illust_id}
|
59
|
-
Illust.lazy_new(attrs) { agent.get(Illust.url(illust_id)) }
|
59
|
+
illust = Illust.lazy_new(attrs) { agent.get(Illust.url(illust_id)) }
|
60
|
+
illust.bind(self)
|
60
61
|
end
|
61
62
|
|
62
63
|
# @param [Integer] member_id
|
63
|
-
# @return [Pixiv::Member]
|
64
|
+
# @return [Pixiv::Member] member bound to +self+
|
64
65
|
def member(member_id = member_id)
|
65
66
|
attrs = {member_id: member_id}
|
66
|
-
Member.lazy_new(attrs) { agent.get(Member.url(member_id)) }
|
67
|
+
member = Member.lazy_new(attrs) { agent.get(Member.url(member_id)) }
|
68
|
+
member.bind(self)
|
67
69
|
end
|
68
70
|
|
69
71
|
# @param [Pixiv::Member, Integer] member_or_member_id
|
@@ -136,7 +138,7 @@ module Pixiv
|
|
136
138
|
end
|
137
139
|
|
138
140
|
def member_id_from_mypage(doc)
|
139
|
-
doc.at('.profile_area a')
|
141
|
+
doc.at('.profile_area a')['href'].match(/(\d+)$/).to_a[1].to_i
|
140
142
|
end
|
141
143
|
|
142
144
|
# Generate filename from +pattern+ in context of +illust+ and +url+
|
@@ -170,6 +172,7 @@ module Pixiv
|
|
170
172
|
end
|
171
173
|
end
|
172
174
|
|
175
|
+
# @private
|
173
176
|
class DownloadActionRegistry
|
174
177
|
def initialize(&block)
|
175
178
|
instance_eval(&block) if block
|
data/lib/pixiv/illust.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
module Pixiv
|
2
4
|
class Illust < Page
|
3
5
|
# Returns the URL for given +illust_id+
|
@@ -8,7 +10,7 @@ module Pixiv
|
|
8
10
|
end
|
9
11
|
|
10
12
|
# @return [String]
|
11
|
-
lazy_attr_reader(:small_image_url) { at!('meta[property="og:image"]')
|
13
|
+
lazy_attr_reader(:small_image_url) { at!('meta[property="og:image"]')['content'] }
|
12
14
|
# @return [String]
|
13
15
|
lazy_attr_reader(:medium_image_url) { image_url_components.join('_m') }
|
14
16
|
# @return [String]
|
@@ -19,20 +21,35 @@ module Pixiv
|
|
19
21
|
: (0...num_pages).map {|n| image_url_components.join("_p#{n}") }
|
20
22
|
}
|
21
23
|
# @return [String]
|
22
|
-
lazy_attr_reader(:original_image_referer) { ROOT_URL + '/' + at!('//div[@class="works_display"]/a')
|
24
|
+
lazy_attr_reader(:original_image_referer) { ROOT_URL + '/' + at!('//div[@class="works_display"]/a')['href'] }
|
23
25
|
# @return [Integer]
|
24
|
-
lazy_attr_reader(:illust_id) { at!('#rpc_i_id')
|
26
|
+
lazy_attr_reader(:illust_id) { at!('#rpc_i_id')['title'].to_i }
|
25
27
|
# @return [Integer]
|
26
|
-
lazy_attr_reader(:member_id) { at!('#rpc_u_id')
|
28
|
+
lazy_attr_reader(:member_id) { at!('#rpc_u_id')['title'].to_i }
|
27
29
|
# @return [String]
|
28
|
-
lazy_attr_reader(:member_name) {
|
30
|
+
lazy_attr_reader(:member_name) {
|
31
|
+
at!('title').inner_text.match(%r!^「#{Regexp.escape(title)}」/「(.+)」の(?:イラスト|漫画) \[pixiv\]$!).to_a[1]
|
32
|
+
}
|
29
33
|
# @return [String]
|
30
|
-
lazy_attr_reader(:title) {
|
34
|
+
lazy_attr_reader(:title) { at!('.work-info h1.title').inner_text }
|
31
35
|
# @return [Integer]
|
32
36
|
lazy_attr_reader(:num_pages) {
|
33
|
-
n = at
|
34
|
-
n && n.to_i
|
37
|
+
n = doc.at('//ul[@class="meta"]/li[2]')
|
38
|
+
n && n.inner_text.match(/(\d+)P$/).to_a[1].to_i
|
35
39
|
}
|
40
|
+
# @return [Array<String>]
|
41
|
+
lazy_attr_reader(:tag_names) { search!('ul.tags a.text').map {|n| n.inner_text } }
|
42
|
+
# @return [String]
|
43
|
+
lazy_attr_reader(:caption) { at!('.work-info .caption').inner_text }
|
44
|
+
# @api experimental
|
45
|
+
# @return [Array<Nokogiri::XML::NodeSet, nil>]
|
46
|
+
lazy_attr_reader(:anchors_in_caption) { doc.search('.work-info .caption a') }
|
47
|
+
# @return [Integer]
|
48
|
+
lazy_attr_reader(:views_count) { at!('.view-count').inner_text.to_i }
|
49
|
+
# @return [Integer]
|
50
|
+
lazy_attr_reader(:rated_count) { at!('.rated-count').inner_text.to_i }
|
51
|
+
# @return [Integer]
|
52
|
+
lazy_attr_reader(:score) { at!('.score-count').inner_text.to_i }
|
36
53
|
|
37
54
|
alias id illust_id
|
38
55
|
alias original_image_referrer original_image_referer # referrer vs. referer
|
data/lib/pixiv/member.rb
CHANGED
@@ -10,13 +10,27 @@ module Pixiv
|
|
10
10
|
# @return [String]
|
11
11
|
lazy_attr_reader(:name) { at!('.profile_area h2').inner_text }
|
12
12
|
# @return [Integer]
|
13
|
-
lazy_attr_reader(:member_id) { at!('input[name="user_id"]')
|
13
|
+
lazy_attr_reader(:member_id) { at!('input[name="user_id"]')['value'].to_i }
|
14
14
|
# return [Integer]
|
15
|
-
lazy_attr_reader(:pixiv_id) { at!('.profile_area img')
|
15
|
+
lazy_attr_reader(:pixiv_id) { at!('.profile_area img')['src'].match(%r{/profile/([a-z_-]+)/}).to_a[1] }
|
16
16
|
|
17
17
|
alias id member_id
|
18
18
|
|
19
19
|
# @return [String]
|
20
20
|
def url; self.class.url(member_id) end
|
21
21
|
end
|
22
|
+
|
23
|
+
module Member::WithClient
|
24
|
+
include Page::WithClient
|
25
|
+
|
26
|
+
# (see Pixiv::Client#bookmark_list)
|
27
|
+
def bookmark_list(page_num = 1)
|
28
|
+
client.bookmark_list(self, page_num)
|
29
|
+
end
|
30
|
+
|
31
|
+
# (see Pixiv::Client#bookmarks)
|
32
|
+
def bookmarks(page_num = 1, &block)
|
33
|
+
client.bookmarks(self, page_num, &block)
|
34
|
+
end
|
35
|
+
end
|
22
36
|
end
|
data/lib/pixiv/page.rb
CHANGED
@@ -49,6 +49,21 @@ module Pixiv
|
|
49
49
|
self
|
50
50
|
end
|
51
51
|
|
52
|
+
# Bind +self+ to +client+
|
53
|
+
# @return self
|
54
|
+
def bind(client)
|
55
|
+
if self.class.const_defined?(:WithClient)
|
56
|
+
mod = self.class.const_get(:WithClient)
|
57
|
+
else
|
58
|
+
mod = Page::WithClient
|
59
|
+
end
|
60
|
+
unless singleton_class.include?(mod)
|
61
|
+
extend(mod)
|
62
|
+
end
|
63
|
+
self.client = client
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
52
67
|
protected
|
53
68
|
|
54
69
|
# Defines lazy attribute reader
|
@@ -85,14 +100,19 @@ module Pixiv
|
|
85
100
|
# @param [String] path XPath or CSS path
|
86
101
|
# @return [Nokogiri::HTML::Node]
|
87
102
|
def at!(path, node = doc)
|
88
|
-
node.at(path)
|
103
|
+
node.at(path) or raise Error::NodeNotFound, "node for `#{path}` not found"
|
89
104
|
end
|
90
105
|
|
91
106
|
# +node.search(path) or raise error
|
92
107
|
# @param [String] path XPath or CSS path
|
93
108
|
# @return [Array<Nokogiri::HTML::Node>]
|
94
109
|
def search!(path, node = doc)
|
95
|
-
node.search(path)
|
110
|
+
node.search(path) or raise Error::NodeNotFound, "node for `#{path}` not found"
|
96
111
|
end
|
97
112
|
end
|
113
|
+
|
114
|
+
module Page::WithClient
|
115
|
+
# @return [Pixiv::Client]
|
116
|
+
attr_accessor :client
|
117
|
+
end
|
98
118
|
end
|
data/lib/pixiv/version.rb
CHANGED
data/pixiv.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Pixiv::VERSION
|
9
9
|
gem.authors = ["Tomoki Aonuma"]
|
10
10
|
gem.email = ["uasi@uasi.jp"]
|
11
|
-
gem.description = %q{A client library for
|
12
|
-
gem.summary = %q{A client library for
|
11
|
+
gem.description = %q{A client library for pixiv}
|
12
|
+
gem.summary = %q{A client library for pixiv}
|
13
13
|
gem.homepage = "https://github.com/uasi/pixiv"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
@@ -18,4 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_dependency 'mechanize', '~> 2.0'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rake', '>= 0.8.7'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.12'
|
24
|
+
gem.add_development_dependency 'webmock', '~> 1.9'
|
21
25
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<!-- small_image_url = "http://i1.pixiv.net/img1/img/sayoko/345_s.jpg" -->
|
6
|
+
<meta property="og:image" content="http://i1.pixiv.net/img1/img/sayoko/345_s.jpg">
|
7
|
+
<!-- member_name = "Sayoko" -->
|
8
|
+
<title>「Illust #345」/「Sayoko」のイラスト [pixiv]</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<!-- The misleading h1.title element -->
|
12
|
+
<h1 class="title">pixiv logo here</h1>
|
13
|
+
<div class="work-info">
|
14
|
+
<!-- title = "Illust #345" -->
|
15
|
+
<h1 class="title">Illust #345</h1>
|
16
|
+
<!-- caption = "Caption" -->
|
17
|
+
<p class="caption">Caption</p>
|
18
|
+
</div>
|
19
|
+
<!-- illust_id = 345 -->
|
20
|
+
<div id="rpc_i_id" title="345"></div>
|
21
|
+
<!-- member_id = 6 -->
|
22
|
+
<div id="rpc_u_id" title="6"></div>
|
23
|
+
<!-- tag_names = ["tag_1", "tag_2", "tag_3"] -->
|
24
|
+
<ul class="tags">
|
25
|
+
<li><a class="text">tag_1</a></li>
|
26
|
+
<li><a class="text">tag_2</a></li>
|
27
|
+
<li><a class="text">tag_3</a></li>
|
28
|
+
</ul>
|
29
|
+
<!-- views_count = 1000 -->
|
30
|
+
<div class="view-count">1000</div>
|
31
|
+
<!-- rated_count = 10 -->
|
32
|
+
<div class="rated-count">10</div>
|
33
|
+
<!-- score = 100 -->
|
34
|
+
<div class="score-count">100</div>
|
35
|
+
</body>
|
36
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Member #6</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class="profile_area">
|
9
|
+
<!-- name = "Sayoko" -->
|
10
|
+
<h2>Sayoko</h2>
|
11
|
+
<!-- pixiv_id = "sayoko" -->
|
12
|
+
<img src="http://i1.pixiv.net/img1/profile/sayoko/123456.jpg">
|
13
|
+
</div>
|
14
|
+
<!-- member_id = 6 -->
|
15
|
+
<form action="/bookmark_add.php" method="post">
|
16
|
+
<input type="hidden" name="user_id" value="6">
|
17
|
+
</form>
|
18
|
+
</body>
|
19
|
+
</html>
|
20
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pixiv::Illust do
|
4
|
+
let(:illust_doc) { fixture_as_doc('illust_345.html') }
|
5
|
+
|
6
|
+
describe '.new' do
|
7
|
+
subject { Pixiv::Illust.new(illust_doc) }
|
8
|
+
its(:title) { should == 'Illust #345' }
|
9
|
+
its(:illust_id) { should == 345 }
|
10
|
+
its(:member_id) { should == 6 }
|
11
|
+
its(:member_name) { should == 'Sayoko' }
|
12
|
+
its(:tag_names) { should == %w[tag_1 tag_2 tag_3]}
|
13
|
+
its(:caption) { should == 'Caption' }
|
14
|
+
its(:views_count) { should == 1000 }
|
15
|
+
its(:rated_count) { should == 10 }
|
16
|
+
its(:score) { should == 100 }
|
17
|
+
its(:small_image_url) { should == 'http://i1.pixiv.net/img1/img/sayoko/345_s.jpg' }
|
18
|
+
its(:medium_image_url) { should == 'http://i1.pixiv.net/img1/img/sayoko/345_m.jpg' }
|
19
|
+
its(:original_image_url) { should == 'http://i1.pixiv.net/img1/img/sayoko/345.jpg' }
|
20
|
+
its(:num_pages) { should be_nil }
|
21
|
+
its(:illust?) { should be_true }
|
22
|
+
its(:manga?) { should be_false }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.new', 'given attrs covers attrs extracted from doc' do
|
26
|
+
before do
|
27
|
+
@attrs = {
|
28
|
+
title: 'Illust #105',
|
29
|
+
illust_id: 105,
|
30
|
+
member_id: 13,
|
31
|
+
member_name: 'Duke',
|
32
|
+
tag_names: %w[target_1 target_2 target_3],
|
33
|
+
caption: 'The Professional',
|
34
|
+
views_count: 1300,
|
35
|
+
rated_count: 13,
|
36
|
+
score: 130,
|
37
|
+
small_image_url: 'http://i1.pixiv.net/img1/img/duke/105_s.jpg',
|
38
|
+
}
|
39
|
+
end
|
40
|
+
subject { Pixiv::Illust.new(illust_doc, @attrs) }
|
41
|
+
its(:title) { should == 'Illust #105' }
|
42
|
+
its(:illust_id) { should == 105 }
|
43
|
+
its(:member_id) { should == 13 }
|
44
|
+
its(:member_name) { should == 'Duke' }
|
45
|
+
its(:tag_names) { should == %w[target_1 target_2 target_3] }
|
46
|
+
its(:caption) { should == 'The Professional' }
|
47
|
+
its(:views_count) { should == 1300 }
|
48
|
+
its(:rated_count) { should == 13 }
|
49
|
+
its(:score) { should == 130 }
|
50
|
+
its(:small_image_url) { should == 'http://i1.pixiv.net/img1/img/duke/105_s.jpg' }
|
51
|
+
its(:medium_image_url) { should == 'http://i1.pixiv.net/img1/img/duke/105_m.jpg' }
|
52
|
+
its(:original_image_url) { should == 'http://i1.pixiv.net/img1/img/duke/105.jpg' }
|
53
|
+
its(:num_pages) { should be_nil }
|
54
|
+
its(:illust?) { should be_true }
|
55
|
+
its(:manga?) { should be_false }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.url' do
|
59
|
+
it 'returns url for illust id' do
|
60
|
+
expect(Pixiv::Illust.url(345)).
|
61
|
+
to eq('http://www.pixiv.net/member_illust.php?mode=medium&illust_id=345')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pixiv::Member do
|
4
|
+
describe '.new' do
|
5
|
+
subject { Pixiv::Member.new(fixture_as_doc('member_6.html')) }
|
6
|
+
its(:member_id) { should == 6 }
|
7
|
+
its(:pixiv_id) { should == 'sayoko' }
|
8
|
+
its(:name) { should == 'Sayoko' }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new', 'given attrs cover attrs extracted from doc' do
|
12
|
+
before do
|
13
|
+
@doc = fixture_as_doc('member_6.html')
|
14
|
+
@attrs = {
|
15
|
+
member_id: 13,
|
16
|
+
pixiv_id: 'duke',
|
17
|
+
name: 'Duke',
|
18
|
+
}
|
19
|
+
end
|
20
|
+
subject { Pixiv::Member.new(@doc, @attrs) }
|
21
|
+
its(:member_id) { should == 13 }
|
22
|
+
its(:pixiv_id) { should == 'duke' }
|
23
|
+
its(:name) { should == 'Duke' }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.new', 'attr raises NodeNotFound if doc is wrong' do
|
27
|
+
subject { Pixiv::Member.new(fixture_as_doc('empty.html')) }
|
28
|
+
it { expect { subject.member_id }.to raise_error(Pixiv::Error::NodeNotFound) }
|
29
|
+
it { expect { subject.pixiv_id }.to raise_error(Pixiv::Error::NodeNotFound) }
|
30
|
+
it { expect { subject.name}.to raise_error(Pixiv::Error::NodeNotFound) }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.url' do
|
34
|
+
it 'returns url for given member id' do
|
35
|
+
expect(Pixiv::Member.url(6)).to eq('http://www.pixiv.net/member.php?id=6')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pixiv::Page do
|
4
|
+
let(:doc) { fixture_as_doc('empty.html') }
|
5
|
+
let(:doc_creator) { Proc.new { doc } }
|
6
|
+
let(:attrs) { {} }
|
7
|
+
|
8
|
+
describe '.lazy_new', 'with doc_creator' do
|
9
|
+
subject { Pixiv::Page.lazy_new(&doc_creator) }
|
10
|
+
its(:doc) { should == doc }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.lazy_new', 'with attrs and doc_creator' do
|
14
|
+
subject { Pixiv::Page.lazy_new(attrs, &doc_creator) }
|
15
|
+
its(:doc) { should == doc }
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pixiv'
|
2
|
+
require 'mechanize'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
|
5
|
+
# Disable "should" syntax.
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.expect_with :rspec do |c|
|
8
|
+
c.syntax = :expect
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def fixture_path
|
13
|
+
File.expand_path('../fixtures', __FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
def fixture(filename)
|
17
|
+
open(File.join(fixture_path, filename))
|
18
|
+
end
|
19
|
+
|
20
|
+
def fixture_as_doc(filename)
|
21
|
+
Nokogiri::HTML::Document.parse(fixture(filename))
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixiv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
@@ -27,7 +27,55 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '2.0'
|
30
|
-
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.8.7
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.8.7
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: webmock
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.9'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.9'
|
78
|
+
description: A client library for pixiv
|
31
79
|
email:
|
32
80
|
- uasi@uasi.jp
|
33
81
|
executables: []
|
@@ -35,10 +83,12 @@ extensions: []
|
|
35
83
|
extra_rdoc_files: []
|
36
84
|
files:
|
37
85
|
- .gitignore
|
86
|
+
- .travis.yml
|
38
87
|
- Gemfile
|
39
88
|
- LICENSE.txt
|
40
89
|
- README.md
|
41
90
|
- Rakefile
|
91
|
+
- console_helper.rb
|
42
92
|
- lib/pixiv.rb
|
43
93
|
- lib/pixiv/bookmark_list.rb
|
44
94
|
- lib/pixiv/client.rb
|
@@ -49,6 +99,13 @@ files:
|
|
49
99
|
- lib/pixiv/page_collection.rb
|
50
100
|
- lib/pixiv/version.rb
|
51
101
|
- pixiv.gemspec
|
102
|
+
- spec/fixtures/empty.html
|
103
|
+
- spec/fixtures/illust_345.html
|
104
|
+
- spec/fixtures/member_6.html
|
105
|
+
- spec/pixiv/illust_spec.rb
|
106
|
+
- spec/pixiv/member_spec.rb
|
107
|
+
- spec/pixiv/page_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
52
109
|
homepage: https://github.com/uasi/pixiv
|
53
110
|
licenses: []
|
54
111
|
post_install_message:
|
@@ -61,17 +118,29 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
118
|
- - ! '>='
|
62
119
|
- !ruby/object:Gem::Version
|
63
120
|
version: '0'
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
hash: -1798318064021145738
|
64
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
125
|
none: false
|
66
126
|
requirements:
|
67
127
|
- - ! '>='
|
68
128
|
- !ruby/object:Gem::Version
|
69
129
|
version: '0'
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
hash: -1798318064021145738
|
70
133
|
requirements: []
|
71
134
|
rubyforge_project:
|
72
135
|
rubygems_version: 1.8.24
|
73
136
|
signing_key:
|
74
137
|
specification_version: 3
|
75
|
-
summary: A client library for
|
76
|
-
test_files:
|
77
|
-
|
138
|
+
summary: A client library for pixiv
|
139
|
+
test_files:
|
140
|
+
- spec/fixtures/empty.html
|
141
|
+
- spec/fixtures/illust_345.html
|
142
|
+
- spec/fixtures/member_6.html
|
143
|
+
- spec/pixiv/illust_spec.rb
|
144
|
+
- spec/pixiv/member_spec.rb
|
145
|
+
- spec/pixiv/page_spec.rb
|
146
|
+
- spec/spec_helper.rb
|