dmm-api 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/dmm-api.gemspec +2 -1
- data/example/com.rb +20 -7
- data/example/r18.rb +17 -4
- data/lib/dmm/api.rb +2 -1
- data/lib/dmm/api/response.rb +3 -2
- data/lib/dmm/api/version.rb +1 -1
- data/spec/dmm/api_spec.rb +5 -4
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66d5f92af9598cbf23721af0be46eb699b3b83f4
|
4
|
+
data.tar.gz: 27f7f44009efb5c3a7fafbb59c0211c76ae07557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa37e455cf5235cac9b3d6cd2e43e5919200725d7d5aee18116d2ab4e87f0cbbd021497172fd5d7c6fe1666042fb4a7ff7a0e97d49d734d7634b89f72cdf56c5
|
7
|
+
data.tar.gz: 79e79ecca6fa805956bc14ac5365c3daee227f673aad34b965b992ba13d4e26288d2913641d5647222c91f1cf3835fd77e65027a6800c30cf37eaf07cf8f6008
|
data/README.md
CHANGED
@@ -34,8 +34,8 @@ end
|
|
34
34
|
res = Dmm::Api.get({:service => 'lod',:floor => 'nmb48',:keyword => "山本彩"})
|
35
35
|
res.code # 200
|
36
36
|
res.message # "OK"
|
37
|
-
res["result"]["items"]["item"].each do |v|
|
38
|
-
title = v["title"]
|
37
|
+
res["result"][0]["items"][0]["item"].each do |v|
|
38
|
+
title = v["title"][0]
|
39
39
|
...
|
40
40
|
end
|
41
41
|
```
|
data/dmm-api.gemspec
CHANGED
@@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "vcr"
|
25
25
|
spec.add_development_dependency "webmock", "1.11.0"
|
26
26
|
# spec.add_runtime_dependency "nokogiri"
|
27
|
-
spec.add_runtime_dependency "activesupport", "4.1.4"
|
27
|
+
# spec.add_runtime_dependency "activesupport", "4.1.4"
|
28
|
+
spec.add_runtime_dependency "xml-simple"
|
28
29
|
end
|
data/example/com.rb
CHANGED
@@ -10,11 +10,24 @@ Dmm::Api.configure do |options|
|
|
10
10
|
options[:site] = "DMM.com"
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
pp res["result"]["
|
13
|
+
# version 0.1.3
|
14
|
+
# res = Dmm::Api.get({:service => 'lod',:floor => 'nmb48',:keyword => "山本彩",:hits => "1"})
|
15
|
+
# pp res["result"]["result_count"]
|
16
|
+
# pp res["result"]["items"]["item"]["title"]
|
16
17
|
|
17
|
-
|
18
|
-
res
|
19
|
-
|
20
|
-
|
18
|
+
# version 0.2.0 and later
|
19
|
+
res = Dmm::Api.get({:service => 'lod',:floor => 'nmb48',:keyword => "nmb48",:hits => "1"})
|
20
|
+
pp res["result"][0]["result_count"][0]
|
21
|
+
pp res["result"][0]["items"][0]["item"][0]["title"][0]
|
22
|
+
|
23
|
+
# version 0.1.3
|
24
|
+
# res = Dmm::Api.get({:service => 'lod',:floor => 'nmb48',:keyword => "山本彩"})
|
25
|
+
# res["result"]["items"]["item"].each do |v|
|
26
|
+
# pp v["title"]
|
27
|
+
# end
|
28
|
+
|
29
|
+
# version 0.2.0 and later
|
30
|
+
res = Dmm::Api.get({:service => 'lod',:floor => 'nmb48',:keyword => "nmb48"})
|
31
|
+
res["result"][0]["items"][0]["item"].each do |v|
|
32
|
+
pp v["title"][0]
|
33
|
+
end
|
data/example/r18.rb
CHANGED
@@ -10,11 +10,24 @@ Dmm::Api.configure do |options|
|
|
10
10
|
options[:site] = "DMM.co.jp"
|
11
11
|
end
|
12
12
|
|
13
|
+
# version 0.1.3
|
14
|
+
# res = Dmm::Api.get({:service => 'digital',:floor => 'videoa',:keyword => "菜月アンナ",:hits => "1"})
|
15
|
+
# pp res["result"]["result_count"]
|
16
|
+
# pp res["result"]["items"]["item"]["title"]
|
17
|
+
|
18
|
+
# version 0.2.0 and later
|
13
19
|
res = Dmm::Api.get({:service => 'digital',:floor => 'videoa',:keyword => "菜月アンナ",:hits => "1"})
|
14
|
-
pp res["result"]["result_count"]
|
15
|
-
pp res["result"]["items"]["item"]["title"]
|
20
|
+
pp res["result"][0]["result_count"][0]
|
21
|
+
pp res["result"][0]["items"][0]["item"][0]["title"][0]
|
22
|
+
|
23
|
+
# version 0.1.3
|
24
|
+
# res = Dmm::Api.get({:service => 'digital',:floor => 'videoa',:keyword => "菜月アンナ"})
|
25
|
+
# res["result"]["items"]["item"].each do |v|
|
26
|
+
# pp v["title"]
|
27
|
+
# end
|
16
28
|
|
29
|
+
# version 0.2.0 and later
|
17
30
|
res = Dmm::Api.get({:service => 'digital',:floor => 'videoa',:keyword => "菜月アンナ"})
|
18
|
-
res["result"]["items"]["item"].each do |v|
|
19
|
-
pp v["title"]
|
31
|
+
res["result"][0]["items"][0]["item"].each do |v|
|
32
|
+
pp v["title"][0]
|
20
33
|
end
|
data/lib/dmm/api.rb
CHANGED
data/lib/dmm/api/response.rb
CHANGED
@@ -3,8 +3,9 @@ module Dmm
|
|
3
3
|
class Response
|
4
4
|
def initialize(response)
|
5
5
|
@response =response
|
6
|
-
@body = Hash.from_xml(@response.body)
|
7
|
-
@body = @body["response"] if @body.key?("response")
|
6
|
+
# @body = Hash.from_xml(@response.body)
|
7
|
+
# @body = @body["response"] if @body.key?("response")
|
8
|
+
@body = XmlSimple.xml_in(@response.body)
|
8
9
|
end
|
9
10
|
|
10
11
|
def code
|
data/lib/dmm/api/version.rb
CHANGED
data/spec/dmm/api_spec.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
3
|
|
4
|
-
|
4
|
+
shared_examples_for 'found items' do
|
5
5
|
context 'code' do
|
6
6
|
it { expect(res.code).to eq 200 }
|
7
7
|
end
|
8
8
|
context 'size' do
|
9
|
-
it { expect(res["result"]["result_count"].to_i).to be > 0 }
|
9
|
+
it { expect(res["result"][0]["result_count"][0].to_i).to be > 0 }
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
shared_examples_for 'not found items' do
|
14
14
|
context 'code' do
|
15
15
|
it { expect(res.code).to eq 200 }
|
16
16
|
end
|
17
17
|
context 'size' do
|
18
|
-
it { expect(res["result"]["result_count"].to_i).to eq 0 }
|
18
|
+
it { expect(res["result"][0]["result_count"][0].to_i).to eq 0 }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -42,3 +42,4 @@ describe "Dmm::Api.get" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
45
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmm-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shoprev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,19 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.11.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: xml-simple
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - '
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - '
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '0'
|
97
97
|
description: Ruby DMM Web Service API ver 2.0
|
98
98
|
email:
|
99
99
|
- admin@shoprev.net
|