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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66c2233d4f9e67c3a8b91ae84b2bbedfd6c1cc76
4
- data.tar.gz: 68dd9ace5815bf61a318068e452484d364488d35
3
+ metadata.gz: 66d5f92af9598cbf23721af0be46eb699b3b83f4
4
+ data.tar.gz: 27f7f44009efb5c3a7fafbb59c0211c76ae07557
5
5
  SHA512:
6
- metadata.gz: 351d05d76364ade6179873959168318503eb9c4dc3fd7faa098d6cf435e157960510b8a8cfe785b7bfa4d612046dc031209e107740af37cfa9f67826259c3155
7
- data.tar.gz: 4ca021e7b701d953ce780ca27fc2acdba6778e9252d806fe33d634ebf786e66000376184f9f23d419dd48abefbb871e6af92f4e18602cfcc519102cc1371f842
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
  ```
@@ -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
@@ -10,11 +10,24 @@ Dmm::Api.configure do |options|
10
10
  options[:site] = "DMM.com"
11
11
  end
12
12
 
13
- res = Dmm::Api.get({:service => 'lod',:floor => 'nmb48',:keyword => "山本彩",:hits => "1"})
14
- pp res["result"]["result_count"]
15
- pp res["result"]["items"]["item"]["title"]
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
- res = Dmm::Api.get({:service => 'lod',:floor => 'nmb48',:keyword => "山本彩"})
18
- res["result"]["items"]["item"].each do |v|
19
- pp v["title"]
20
- end
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
@@ -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
@@ -1,9 +1,10 @@
1
1
  require "net/http"
2
2
  require "uri"
3
- require 'active_support/core_ext'
3
+ # require 'active_support/core_ext'
4
4
  require "dmm/api/version"
5
5
  require "dmm/api/response"
6
6
  require "dmm/api/request"
7
+ require "xmlsimple"
7
8
 
8
9
  module Dmm
9
10
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Dmm
2
2
  class Api
3
- VERSION = "0.1.3"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,21 +1,21 @@
1
1
  # coding: utf-8
2
2
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
 
4
- share_examples_for 'found items' do
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
- share_examples_for 'not found items' do
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.1.3
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-13 00:00:00.000000000 Z
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: activesupport
84
+ name: xml-simple
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
- version: 4.1.4
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: 4.1.4
96
+ version: '0'
97
97
  description: Ruby DMM Web Service API ver 2.0
98
98
  email:
99
99
  - admin@shoprev.net