dmm-crawler 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +4 -0
- data/dmm-crawler.gemspec +1 -0
- data/lib/dmm-crawler.rb +1 -0
- data/lib/dmm-crawler/attributes.rb +8 -0
- data/lib/dmm-crawler/client.rb +4 -0
- data/lib/dmm-crawler/ranking.rb +2 -1
- data/lib/dmm-crawler/version.rb +1 -1
- data/spec/dmm-crawler/ranking_spec.rb +6 -9
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba00ec149d0da09749dc8ec8816ec3ddf8622f4e480c61eceadff8debebbcda8
|
4
|
+
data.tar.gz: 214724b5d29f1f1f6d8ba1de2352a237f9912bfd268a08c773b72fbdc103642b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd1d972aba0af499834e7749e5a5e55d3ee790761000a4a33f62045c6e30e8bf3c8046509acac7d77bcbb991f7e3f95a37534f5244c2aa8594bb6305cf4f2389
|
7
|
+
data.tar.gz: db9c7320934c9883568b129882d66fd355ddc2c348074dbc0949598f0f044bb325d84346a1650e2be0bfd0f5182990d11130a727fb87fd61c5af4a8c26acb767
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/dmm-crawler.gemspec
CHANGED
data/lib/dmm-crawler.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
module DMMCrawler
|
2
2
|
class Attributes
|
3
|
+
HTTP_STATUS_CODE_OF_SUCCESS = 200
|
4
|
+
|
3
5
|
def initialize(url, agent: Agent.instance.agent)
|
4
6
|
@page = agent.get(url)
|
7
|
+
@r_client = Rdmm::Client.new(affiliate_id: ENV['DMM_AFFILIATE_ID'], api_id: ENV['DMM_API_ID'])
|
5
8
|
end
|
6
9
|
|
7
10
|
def to_a
|
@@ -13,10 +16,15 @@ module DMMCrawler
|
|
13
16
|
author,
|
14
17
|
informations,
|
15
18
|
price,
|
19
|
+
affiliateable?,
|
16
20
|
tags
|
17
21
|
]
|
18
22
|
end
|
19
23
|
|
24
|
+
def affiliateable?
|
25
|
+
@r_client.list_items(site: 'DMM.R18', keyword: title).body['result']['status'] == HTTP_STATUS_CODE_OF_SUCCESS
|
26
|
+
end
|
27
|
+
|
20
28
|
private
|
21
29
|
|
22
30
|
def title
|
data/lib/dmm-crawler/client.rb
CHANGED
data/lib/dmm-crawler/ranking.rb
CHANGED
@@ -15,7 +15,7 @@ module DMMCrawler
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
arts.map.with_index(1) do |(title, title_link, image_url, submedia, author, informations, price, tags), rank|
|
18
|
+
arts.map.with_index(1) do |(title, title_link, image_url, submedia, author, informations, price, affiliateable, tags), rank|
|
19
19
|
{
|
20
20
|
title: title,
|
21
21
|
title_link: title_link,
|
@@ -25,6 +25,7 @@ module DMMCrawler
|
|
25
25
|
informations: informations,
|
26
26
|
rank: rank,
|
27
27
|
price: price,
|
28
|
+
affiliateable: affiliateable,
|
28
29
|
tags: tags
|
29
30
|
}
|
30
31
|
end
|
data/lib/dmm-crawler/version.rb
CHANGED
@@ -1,33 +1,30 @@
|
|
1
1
|
describe DMMCrawler::Ranking do
|
2
|
-
let(:attachments) { described_class.new(arguments).arts }
|
3
|
-
|
4
2
|
let(:agent) { DMMCrawler::Agent.instance.agent }
|
5
3
|
let(:submedia) { 'cg' }
|
6
4
|
let(:arguments) { { submedia: submedia, term: term, agent: agent } }
|
7
5
|
|
8
6
|
describe '#arts' do
|
7
|
+
subject { attachments }
|
8
|
+
|
9
9
|
after { sleep 2 }
|
10
10
|
|
11
11
|
context 'with length' do
|
12
|
-
|
13
|
-
|
12
|
+
let(:attachments) { described_class.new(arguments).arts.length }
|
14
13
|
let(:term) { '24' }
|
15
14
|
|
16
15
|
it { is_expected.to be 10 }
|
17
16
|
end
|
18
17
|
|
19
18
|
context 'with 24 argument' do
|
20
|
-
|
21
|
-
|
19
|
+
let(:attachments) { described_class.new(arguments).arts }
|
22
20
|
let(:term) { '24' }
|
23
21
|
|
24
|
-
it { is_expected.to all(include(:title, :title_link, :image_url, :submedia, :author, :informations, :rank, :price, :tags)) }
|
22
|
+
it { is_expected.to all(include(:title, :title_link, :image_url, :submedia, :author, :informations, :rank, :price, :affiliateable, :tags)) }
|
25
23
|
it { is_expected.to all(satisfy { |art| art.all? { |_k, v| v != '' } }) }
|
26
24
|
end
|
27
25
|
|
28
26
|
context 'with not registered argument' do
|
29
|
-
|
30
|
-
|
27
|
+
let(:attachments) { -> { described_class.new(arguments).arts } }
|
31
28
|
let(:term) { nil }
|
32
29
|
|
33
30
|
it { is_expected.to raise_error(TypeError) }
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmm-crawler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Ohmori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rdmm
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: mechanize
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|