nicoquery 0.0.2.4 → 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.
- checksums.yaml +4 -4
- data/Gemfile.lock +33 -1
- data/Guardfile +57 -0
- data/lib/nicoquery/api/base.rb +6 -1
- data/lib/nicoquery/api/mylist_rss.rb +1 -1
- data/lib/nicoquery/object/mylist.rb +2 -0
- data/lib/nicoquery/object_mapper/getthumbinfo.rb +32 -2
- data/lib/nicoquery/object_mapper/mylist_rss.rb +8 -13
- data/lib/nicoquery/version.rb +1 -1
- data/nicoquery.gemspec +3 -0
- data/spec/api/mylist_rss_spec.rb +32 -9
- data/spec/fixture/getthumbinfo_sm20415650.rb +42 -0
- data/spec/fixture/mylist_rss_18266317.rb +1822 -0
- data/spec/fixture/mylist_rss_403.rb +27 -0
- data/spec/fixture/tag_search_403.rb +27 -0
- data/spec/object_mapper/getthumbinfo_spec.rb +75 -0
- data/spec/object_mapper/mylist_rss_spec.rb +84 -0
- metadata +57 -6
- data/spec/api/spec_helper.rb +0 -17
- data/spec/crawler/spec_helper.rb +0 -17
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fixture
|
2
|
+
def self.mylist_rss_403
|
3
|
+
<<-EOS
|
4
|
+
<?xml version="1.0" encoding="utf-8"?>
|
5
|
+
<rss version="2.0"
|
6
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
7
|
+
xmlns:atom="http://www.w3.org/2005/Atom">
|
8
|
+
|
9
|
+
<channel>
|
10
|
+
|
11
|
+
<title>マイリスト‐ニコニコ動画</title>
|
12
|
+
<link>http://www.nicovideo.jp/</link>
|
13
|
+
<atom:link rel="self" type="application/rss+xml" href="http://www.nicovideo.jp/mylist/38350049?rss=2.0"/>
|
14
|
+
<description>このマイリストは非公開に設定されています。</description>
|
15
|
+
<generator>ニコニコ動画</generator>
|
16
|
+
<language>ja-jp</language>
|
17
|
+
<copyright>(c) niwango, inc. All rights reserved.</copyright>
|
18
|
+
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
|
19
|
+
|
20
|
+
|
21
|
+
</channel>
|
22
|
+
|
23
|
+
</rss>
|
24
|
+
EOS
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fixture
|
2
|
+
def self.tag_search_rss_403
|
3
|
+
"""
|
4
|
+
<?xml version="1.0" encoding="utf-8"?>
|
5
|
+
<rss version="2.0"
|
6
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
7
|
+
xmlns:atom="http://www.w3.org/2005/Atom">
|
8
|
+
|
9
|
+
<channel>
|
10
|
+
|
11
|
+
<title>マイリスト‐ニコニコ動画</title>
|
12
|
+
<link>http://www.nicovideo.jp/</link>
|
13
|
+
<atom:link rel="self" type="application/rss+xml" href="http://www.nicovideo.jp/mylist/38350049?rss=2.0"/>
|
14
|
+
<description>このマイリストは非公開に設定されています。</description>
|
15
|
+
<generator>ニコニコ動画</generator>
|
16
|
+
<language>ja-jp</language>
|
17
|
+
<copyright>(c) niwango, inc. All rights reserved.</copyright>
|
18
|
+
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
|
19
|
+
|
20
|
+
|
21
|
+
</channel>
|
22
|
+
|
23
|
+
</rss>
|
24
|
+
"""
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "nicoquery/object_mapper/getthumbinfo"
|
2
|
+
require "fixture/getthumbinfo_sm20415650"
|
3
|
+
|
4
|
+
|
5
|
+
describe "NicoQuery::ObjectMapper::MylistRss" do
|
6
|
+
before do
|
7
|
+
xml = Fixture.getthumbinfo_sm20415650
|
8
|
+
@hash = NicoQuery::ObjectMapper::GetThumbInfo.new xml
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { @hash }
|
12
|
+
|
13
|
+
describe "#title" do
|
14
|
+
it "returns string of title" do
|
15
|
+
expect(subject.title).to eq "【Minecraft】まったりクラフター生活 ~最終日~【ゆっくり実況】"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#url" do
|
20
|
+
it "returns string of url" do
|
21
|
+
expect(subject.url).to eq "http://www.nicovideo.jp/watch/sm20415650"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#video_id" do
|
26
|
+
it "returns number of mylist_id" do
|
27
|
+
expect(subject.video_id).to eq "sm20415650"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#publish_date" do
|
32
|
+
it "returns number of thread_id" do
|
33
|
+
# expect(subject.video_id).to eq Time(2013, 8, 18, 2, 13, 47)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#thumbnail_url" do
|
38
|
+
it "returns number of thread_id" do
|
39
|
+
expect(subject.thumbnail_url).to eq "http://tn-skr3.smilevideo.jp/smile?i=20415650"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# describe "#view_counter" do
|
44
|
+
# it "returns number of view counter" do
|
45
|
+
# expect(subject.view_counter).to be_a_kind_of(Fixnum)
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
|
49
|
+
# describe "#comment_num" do
|
50
|
+
# it "returns number of comment num" do
|
51
|
+
# expect(subject.comment_num).to be_a_kind_of(Fixnum)
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
|
55
|
+
# describe "#mylist_counter" do
|
56
|
+
# it "returns number of mylist counter" do
|
57
|
+
# expect(subject.mylist_counter).to be_a_kind_of(Fixnum)
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
|
61
|
+
# describe "description" do
|
62
|
+
# subject { @movie }
|
63
|
+
# it "returns string of title" do
|
64
|
+
# # mylistのrssでは、descriptionの全文取得はできず、頭から256文字までしか取得できない。
|
65
|
+
# expect(subject.description).to eq "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam cursus. Morbi ut mi. Nullam enim leo, egestas id, condimentum at, laoreet mattis, massa. Sed eleifend nonummy diam. Praesent mauris ante, elementum et, bibendum at, posuere sit amet, nibh. Duis "
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
|
69
|
+
describe "#description.mylist_references" do
|
70
|
+
it "returns number of mylist references" do
|
71
|
+
expect(subject.description.mylist_references).to eq [29017292, 29022355]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "nicoquery/object_mapper/mylist_rss"
|
2
|
+
require "fixture/mylist_rss_18266317"
|
3
|
+
|
4
|
+
|
5
|
+
describe "NicoQuery::ObjectMapper::MylistRss" do
|
6
|
+
before do
|
7
|
+
# mylist:38369702 はテスト用に作ったマイリスト。以下の動画を含んでいる。
|
8
|
+
# sm9 新・豪血寺一族 -煩悩解放 - レッツゴー!陰陽師
|
9
|
+
# sm1097445 【初音ミク】みくみくにしてあげる♪【してやんよ】
|
10
|
+
xml = Fixture.mylist_rss_18266317
|
11
|
+
@mylist_rss = NicoQuery::ObjectMapper::MylistRSS.new xml
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { @mylist_rss.items[1] }
|
15
|
+
|
16
|
+
describe "#title" do
|
17
|
+
it "returns string of title" do
|
18
|
+
expect(subject.title).to eq "【Minecraft】GREEN'S CRAFT Part1【ゆっくり&VOICEROID+実況】"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#url" do
|
23
|
+
it "returns string of url" do
|
24
|
+
expect(subject.url).to eq "http://www.nicovideo.jp/watch/sm21615389"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#video_id" do
|
29
|
+
it "returns number of mylist_id" do
|
30
|
+
expect(subject.video_id).to eq "sm21615389"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#thread_id" do
|
35
|
+
it "returns number of thread_id" do
|
36
|
+
expect(subject.thread_id).to eq 1376736501
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#publish_date" do
|
41
|
+
it "returns number of thread_id" do
|
42
|
+
# expect(subject.video_id).to eq Time(2013, 8, 18, 2, 13, 47)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#thumbnail_url" do
|
47
|
+
it "returns number of thread_id" do
|
48
|
+
expect(subject.thumbnail_url).to eq "http://tn-skr2.smilevideo.jp/smile?i=21615389"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# describe "#view_counter" do
|
53
|
+
# it "returns number of view counter" do
|
54
|
+
# expect(subject.view_counter).to be_a_kind_of(Fixnum)
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
|
58
|
+
# describe "#comment_num" do
|
59
|
+
# it "returns number of comment num" do
|
60
|
+
# expect(subject.comment_num).to be_a_kind_of(Fixnum)
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
|
64
|
+
# describe "#mylist_counter" do
|
65
|
+
# it "returns number of mylist counter" do
|
66
|
+
# expect(subject.mylist_counter).to be_a_kind_of(Fixnum)
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
|
70
|
+
# describe "description" do
|
71
|
+
# subject { @movie }
|
72
|
+
# it "returns string of title" do
|
73
|
+
# # mylistのrssでは、descriptionの全文取得はできず、頭から256文字までしか取得できない。
|
74
|
+
# expect(subject.description).to eq "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam cursus. Morbi ut mi. Nullam enim leo, egestas id, condimentum at, laoreet mattis, massa. Sed eleifend nonummy diam. Praesent mauris ante, elementum et, bibendum at, posuere sit amet, nibh. Duis "
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
|
78
|
+
describe "#description.mylist_references" do
|
79
|
+
it "returns number of mylist references" do
|
80
|
+
expect(subject.description.mylist_references).to eq [38367203, 29017292, 29022355]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nicoquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masami Yonehara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -164,6 +164,48 @@ dependencies:
|
|
164
164
|
- - '>='
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: guard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: guard-rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: webmock
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
167
209
|
description: niconico manipulator
|
168
210
|
email:
|
169
211
|
- zeitdiebe@gmail.com
|
@@ -182,6 +224,7 @@ files:
|
|
182
224
|
- .travis.yml
|
183
225
|
- Gemfile
|
184
226
|
- Gemfile.lock
|
227
|
+
- Guardfile
|
185
228
|
- LICENSE
|
186
229
|
- README.md
|
187
230
|
- Rakefile
|
@@ -203,18 +246,22 @@ files:
|
|
203
246
|
- nicoquery.gemspec
|
204
247
|
- spec/api/getthumbinfo_spec.rb
|
205
248
|
- spec/api/mylist_rss_spec.rb
|
206
|
-
- spec/api/spec_helper.rb
|
207
249
|
- spec/api/tag_search_spec.rb
|
208
250
|
- spec/api/video_array_spec.rb
|
209
|
-
- spec/crawler/spec_helper.rb
|
210
251
|
- spec/crawler/tag_search_spec.rb
|
252
|
+
- spec/fixture/getthumbinfo_sm20415650.rb
|
253
|
+
- spec/fixture/mylist_rss_18266317.rb
|
254
|
+
- spec/fixture/mylist_rss_403.rb
|
211
255
|
- spec/fixture/tag_search.rb
|
256
|
+
- spec/fixture/tag_search_403.rb
|
212
257
|
- spec/fixture/tag_search_item.rb
|
213
258
|
- spec/fixture/tag_search_meta.rb
|
214
259
|
- spec/nicoquery_spec.rb
|
215
260
|
- spec/object/movie_spec.rb
|
216
261
|
- spec/object/mylist_spec.rb
|
217
262
|
- spec/object/tag_search_rss_spec.rb
|
263
|
+
- spec/object_mapper/getthumbinfo_spec.rb
|
264
|
+
- spec/object_mapper/mylist_rss_spec.rb
|
218
265
|
- spec/spec_helper.rb
|
219
266
|
homepage: ''
|
220
267
|
licenses:
|
@@ -243,16 +290,20 @@ summary: niconico manipulator
|
|
243
290
|
test_files:
|
244
291
|
- spec/api/getthumbinfo_spec.rb
|
245
292
|
- spec/api/mylist_rss_spec.rb
|
246
|
-
- spec/api/spec_helper.rb
|
247
293
|
- spec/api/tag_search_spec.rb
|
248
294
|
- spec/api/video_array_spec.rb
|
249
|
-
- spec/crawler/spec_helper.rb
|
250
295
|
- spec/crawler/tag_search_spec.rb
|
296
|
+
- spec/fixture/getthumbinfo_sm20415650.rb
|
297
|
+
- spec/fixture/mylist_rss_18266317.rb
|
298
|
+
- spec/fixture/mylist_rss_403.rb
|
251
299
|
- spec/fixture/tag_search.rb
|
300
|
+
- spec/fixture/tag_search_403.rb
|
252
301
|
- spec/fixture/tag_search_item.rb
|
253
302
|
- spec/fixture/tag_search_meta.rb
|
254
303
|
- spec/nicoquery_spec.rb
|
255
304
|
- spec/object/movie_spec.rb
|
256
305
|
- spec/object/mylist_spec.rb
|
257
306
|
- spec/object/tag_search_rss_spec.rb
|
307
|
+
- spec/object_mapper/getthumbinfo_spec.rb
|
308
|
+
- spec/object_mapper/mylist_rss_spec.rb
|
258
309
|
- spec/spec_helper.rb
|
data/spec/api/spec_helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
-
config.run_all_when_everything_filtered = true
|
10
|
-
config.filter_run :focus
|
11
|
-
|
12
|
-
# Run specs in random order to surface order dependencies. If you find an
|
13
|
-
# order dependency and want to debug it, you can fix the order by providing
|
14
|
-
# the seed, which is printed after each run.
|
15
|
-
# --seed 1234
|
16
|
-
config.order = 'random'
|
17
|
-
end
|
data/spec/crawler/spec_helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
-
config.run_all_when_everything_filtered = true
|
10
|
-
config.filter_run :focus
|
11
|
-
|
12
|
-
# Run specs in random order to surface order dependencies. If you find an
|
13
|
-
# order dependency and want to debug it, you can fix the order by providing
|
14
|
-
# the seed, which is printed after each run.
|
15
|
-
# --seed 1234
|
16
|
-
config.order = 'random'
|
17
|
-
end
|