nicoapi-parser 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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/nicoapi/parser/tag_search.rb +20 -8
- data/lib/nicoapi/parser/version.rb +1 -1
- data/spec/parser/tag_search_spec.rb +28 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce8b6d903507a94d8dde344f0d70f6b7300ec0a5
|
4
|
+
data.tar.gz: c01d9da754d868c9f1dfb059868cc163458a54f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61fec288be621d0462ab7a43af42a501cc9e4761dd2519c5ab331827a14f583949d84895ce9ff2bfc772a45a6c87520c9a000e74c62d2b7d2120377fbb28098
|
7
|
+
data.tar.gz: 621be1bb79fe4fc1e41895d45f569731c65f3155380a84c6bee22269618d34b6419e9ce4f9f1d6608eac74867c38b814581ce5a038d8a5f759f15413337d4d23
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@ require "nicoapi/parser/version"
|
|
2
2
|
require "nori"
|
3
3
|
require "nokogiri"
|
4
4
|
|
5
|
-
require "pry"
|
6
5
|
|
7
6
|
module NicoAPI
|
8
7
|
module Parser
|
@@ -11,12 +10,8 @@ module NicoAPI
|
|
11
10
|
@parser = Nori.new
|
12
11
|
end
|
13
12
|
|
14
|
-
def
|
15
|
-
@
|
16
|
-
end
|
17
|
-
|
18
|
-
def parse
|
19
|
-
@object = (@parser.parse @xml)["rss"]["channel"]
|
13
|
+
def parse(xml)
|
14
|
+
@object = (@parser.parse xml)["rss"]["channel"]
|
20
15
|
|
21
16
|
@items = @object["item"].map do |item_object|
|
22
17
|
Item.new item_object
|
@@ -84,9 +79,26 @@ module NicoAPI
|
|
84
79
|
end
|
85
80
|
|
86
81
|
def text
|
87
|
-
@raw_text.scan
|
82
|
+
@raw_text.scan /(?<=class\=\"nico\-description\").{1,}(?=\<\/p\>)/
|
88
83
|
$&
|
89
84
|
end
|
85
|
+
|
86
|
+
def movie_references
|
87
|
+
# is this the high road?
|
88
|
+
text.scan(/((sm|nm)\d{1,8})/).map {|e| e[0]}
|
89
|
+
end
|
90
|
+
|
91
|
+
def mylist_references
|
92
|
+
text.scan /mylist\/\d{1,8}/
|
93
|
+
end
|
94
|
+
|
95
|
+
def community_references
|
96
|
+
text.scan /co\d{1,8}/
|
97
|
+
end
|
98
|
+
|
99
|
+
def seiga_references
|
100
|
+
text.scan /im\d{1,8}/
|
101
|
+
end
|
90
102
|
end
|
91
103
|
end
|
92
104
|
|
@@ -5,8 +5,7 @@ require "./spec/fixture"
|
|
5
5
|
describe "TagSearch" do
|
6
6
|
before do
|
7
7
|
@instance = NicoAPI::Parser::TagSearch.new
|
8
|
-
@instance.
|
9
|
-
@instance.parse
|
8
|
+
@instance.parse Fixture.tag_search_rss
|
10
9
|
end
|
11
10
|
|
12
11
|
shared_examples "url string" do
|
@@ -71,7 +70,6 @@ describe "TagSearch" do
|
|
71
70
|
end
|
72
71
|
|
73
72
|
describe "Description" do
|
74
|
-
|
75
73
|
describe "raw_text" do
|
76
74
|
subject { @instance.items[0].description.raw_text }
|
77
75
|
specify { expect(subject).to be_kind_of(String) }
|
@@ -82,6 +80,33 @@ describe "TagSearch" do
|
|
82
80
|
specify { expect(subject).to be_kind_of(String) }
|
83
81
|
end
|
84
82
|
|
83
|
+
# spec/fixture.rbを参照。
|
84
|
+
describe "movie_references" do
|
85
|
+
subject { @instance.items[5].description.movie_references }
|
86
|
+
specify { expect(subject).to be_kind_of(Array) }
|
87
|
+
specify { expect(subject.length).to eq 4 }
|
88
|
+
end
|
89
|
+
|
90
|
+
# Fixtureの最初の動画では、'mylist/(数字)'の記載が2つある。
|
91
|
+
describe "mylist_references" do
|
92
|
+
subject { @instance.items[0].description.mylist_references }
|
93
|
+
specify { expect(subject).to be_kind_of(Array) }
|
94
|
+
specify { expect(subject.length).to eq 2 }
|
95
|
+
end
|
96
|
+
|
97
|
+
# Fixtureの3番目の動画では、'co(数字)'の記載が2つある。
|
98
|
+
describe "community_references" do
|
99
|
+
subject { @instance.items[2].description.community_references }
|
100
|
+
specify { expect(subject).to be_kind_of(Array) }
|
101
|
+
specify { expect(subject.length).to eq 1 }
|
102
|
+
end
|
103
|
+
|
104
|
+
# Fixtureの3番目の動画では、'im(数字)'の記載が1つある。
|
105
|
+
describe "seiga_references" do
|
106
|
+
subject { @instance.items[3].description.seiga_references }
|
107
|
+
specify { expect(subject).to be_kind_of(Array) }
|
108
|
+
specify { expect(subject.length).to eq 1 }
|
109
|
+
end
|
85
110
|
end
|
86
111
|
end
|
87
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nicoapi-parser
|
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-07-
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|