rdmm 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fdf2276f123620c09e7985eaa349ae3aed3b946
4
- data.tar.gz: 5179c7024474006ca8c2cf34fca0355f4b8cd26c
3
+ metadata.gz: 6289605d1e798b6a8f366e25cf6f63875c3743ac
4
+ data.tar.gz: c59b124de32109ae37ac52ecd5697c0bea4ba7e8
5
5
  SHA512:
6
- metadata.gz: 6d667c0451e4a6fadb17ae3b994134f09d3f459e9f3018f7c3bcb3dfd7fcf6e47fb456b3808231143118ea3dbc7d49abf706984f66d9476abd85fa4b3bfae706
7
- data.tar.gz: 36bce25c65eb0dd6acf5965a01f58d19b7990d1cf3229bd4c32e157b1b9b5aa9b9f7114b14c3c069cc248260b2d16bba877fc6265ef4019c100843f6322972f3
6
+ metadata.gz: f9d5ea11c99520cfa18b3e3fe54fad37a138b27ed627bc4e1a341e86ebb65a73f20db2511edadc7e4b1d526b79893e6a0dbeaabc99d40050b8a380405f3944a8
7
+ data.tar.gz: b01ec990480a19e638c914c3be2f52fa8c0d306b7c815d17f2ebe9c96a56f58b76c9fb86a3a7fd15f49599802d2d149264fc747cf0720663fdea662ea92c96b9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.0.2
2
+
3
+ - Add `Rdmm::Responses::BaseResponse#total_count`
4
+ - Add `Rdmm::Client#list_series`
5
+ - Rename `#series_list` to `#series`
6
+
1
7
  ## 0.0.1
2
8
 
3
9
  - 1st Release :tada:
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Rdmm
2
2
 
3
+ [![CircleCI](https://img.shields.io/circleci/project/github/r7kamura/rdmm.svg)](https://circleci.com/gh/r7kamura/rdmm)
4
+ [![Gem Version](https://badge.fury.io/rb/rdmm.svg)](https://rubygems.org/gems/rdmm)
5
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/github/r7kamura/rdmm)
6
+
3
7
  An API Client library for DMM written in Ruby.
4
8
 
5
9
  ## Requirements
@@ -59,6 +63,72 @@ client.list_items(site: "DMM.com")
59
63
 
60
64
  `https://api.dmm.com/affiliate/v3/ItemList?affiliate_id=dummy&api_id=dummy&site=DMM.com`
61
65
 
66
+ ### Rdmm::Client#list_series
67
+
68
+ Available options:
69
+
70
+ - `:floor_id`
71
+ - `:hits`
72
+ - `:initial`
73
+ - `:offset`
74
+
75
+ ```ruby
76
+ client.list_series(floor_id: 27)
77
+ ```
78
+
79
+ `https://api.dmm.com/affiliate/v3/SeriesSearch?affiliate_id=dummy&api_id=dummy&site=DMM.com&floor_id=27`
80
+
81
+ ### Rdmm::Responses::BaseResponse#each
82
+
83
+ This class implements `Enumerable` module.
84
+
85
+ ```ruby
86
+ client.list_items(site: "DMM.com").map(&:title)
87
+ ```
88
+
89
+ <details>
90
+ <summary>output</summary>
91
+
92
+ ```ruby
93
+ ["キングダム",
94
+ "ハドソン川の奇跡",
95
+ "ミュージカル『刀剣乱舞』 〜真剣乱舞祭 2016〜",
96
+ "back number/アンコール",
97
+ "パンフレット 舞台『刀剣乱舞』虚伝 燃ゆる本能寺(再演)",
98
+ "終末のハーレム セミカラー版",
99
+ "VOICEROID+ 東北きりたん EX ダウンロード版",
100
+ "CHAOS;CHILD",
101
+ "【8〜14泊】Travel house 軽量 TSAロック付き 4輪 93L スーツケース レッド",
102
+ "ミュージカル『刀剣乱舞』真剣乱舞祭 2016 (ブルーレイディスク)",
103
+ "シン・ゴジラ",
104
+ "東京タラレバ娘",
105
+ "舞台『刀剣乱舞』虚伝 燃ゆる本能寺 〜再演〜",
106
+ "キングダム",
107
+ "宇多田ヒカル/Fantome(SHM-CD)",
108
+ "エルダー・スクロールズ・オンライン 日本語版 (インペリアルエディション)",
109
+ "自炊・電子書籍化キット プラス裁断機PK-513L&ScanSnap iX500 FI-IX500A",
110
+ "VOICEROID+ 結月ゆかり EX ダウンロード版",
111
+ "映画 闇金ウシジマくんthe Final",
112
+ "トレーディングブロマイド 25枚セット 舞台『刀剣乱舞』虚伝 燃ゆる本能寺(再演)"]
113
+ ```
114
+
115
+ </details>
116
+
117
+ ### Rdmm::Responses::BaseResponse#total_count
118
+
119
+ ```ruby
120
+ client.list_items(site: "DMM.com").total_count
121
+ ```
122
+
123
+ <details>
124
+ <summary>output</summary>
125
+
126
+ ```ruby
127
+ 50000
128
+ ```
129
+
130
+ </details>
131
+
62
132
  ### Rdmm::Resources::ItemResource
63
133
 
64
134
  Available attributes:
@@ -80,7 +150,7 @@ Available attributes:
80
150
  - `released_at`
81
151
  - `review_avarage`
82
152
  - `review_count`
83
- - `series_list`
153
+ - `series`
84
154
  - `service_code`
85
155
  - `service_name`
86
156
  - `title`
@@ -99,3 +169,25 @@ client.list_items(site: "DMM.com").first.title
99
169
  ```
100
170
 
101
171
  </details>
172
+
173
+ ### Rdmm::Resources::SeriesResource
174
+
175
+ Available attributes:
176
+
177
+ - `list_url`
178
+ - `name`
179
+ - `ruby`
180
+ - `series_id`
181
+
182
+ ```ruby
183
+ client.list_series(floor_id: 27).first.name
184
+ ```
185
+
186
+ <details>
187
+ <summary>output</summary>
188
+
189
+ ```ruby
190
+ "二四〇九階の彼女"
191
+ ```
192
+
193
+ </details>
data/lib/rdmm.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  require "rdmm/client"
2
2
  require "rdmm/queries/base_query"
3
3
  require "rdmm/queries/list_items_query"
4
+ require "rdmm/queries/list_series_query"
4
5
  require "rdmm/resources/base_resource"
5
6
  require "rdmm/resources/item_resource"
7
+ require "rdmm/resources/series_resource"
6
8
  require "rdmm/responses/base_response"
7
9
  require "rdmm/responses/list_items_response"
10
+ require "rdmm/responses/list_series_response"
8
11
  require "rdmm/version"
data/lib/rdmm/client.rb CHANGED
@@ -5,6 +5,7 @@ module Rdmm
5
5
  class Client
6
6
  BASE_URL = "https://api.dmm.com"
7
7
  PATH_TO_LIST_ITEMS = "/affiliate/v3/ItemList"
8
+ PATH_TO_LIST_SERIES = "/affiliate/v3/SeriesSearch"
8
9
 
9
10
  # @param affiliate_id [String]
10
11
  # @param api_id [String]
@@ -31,6 +32,15 @@ module Rdmm
31
32
  ::Rdmm::Responses::ListItemsResponse.new(faraday_response)
32
33
  end
33
34
 
35
+ # @param options [Hash]
36
+ # @return [Rdmm::Responses::ListSeriesResponse]
37
+ def list_series(options = {})
38
+ query_options = default_query_options.merge(options)
39
+ query = ::Rdmm::Queries::ListSeriesQuery.new(query_options)
40
+ faraday_response = get(PATH_TO_LIST_SERIES, query.to_hash)
41
+ ::Rdmm::Responses::ListSeriesResponse.new(faraday_response)
42
+ end
43
+
34
44
  private
35
45
 
36
46
  # @return [Hash]
@@ -22,6 +22,8 @@ module Rdmm
22
22
 
23
23
  property :affiliate_id
24
24
  property :api_id
25
+ property :hits
26
+ property :offset
25
27
 
26
28
  # @param options [Hash]
27
29
  def initialize(options = {})
@@ -38,6 +40,16 @@ module Rdmm
38
40
  options[:api_id]
39
41
  end
40
42
 
43
+ # @return [Integer, nil]
44
+ def hits
45
+ options[:hits]
46
+ end
47
+
48
+ # @return [Integer, nil]
49
+ def offset
50
+ options[:offset]
51
+ end
52
+
41
53
  # @return [Hash]
42
54
  def to_hash
43
55
  self.class.property_names.each_with_object({}) do |property_name, result|
@@ -6,11 +6,9 @@ module Rdmm
6
6
  property :cid
7
7
  property :floor
8
8
  property :gte_date
9
- property :hits
10
9
  property :keyword
11
10
  property :lte_date
12
11
  property :mono_stock
13
- property :offset
14
12
  property :service
15
13
  property :site
16
14
  property :sort
@@ -49,11 +47,6 @@ module Rdmm
49
47
  end
50
48
  end
51
49
 
52
- # @return [Integer, nil]
53
- def hits
54
- options[:hits]
55
- end
56
-
57
50
  # @return [String, nil]
58
51
  def keyword
59
52
  options[:keyword]
@@ -76,11 +69,6 @@ module Rdmm
76
69
  options[:mono_stock]
77
70
  end
78
71
 
79
- # @return [Integer, nil]
80
- def offset
81
- options[:offset]
82
- end
83
-
84
72
  # @note service code
85
73
  # @return [String, nil]
86
74
  def service
@@ -0,0 +1,18 @@
1
+ module Rdmm
2
+ module Queries
3
+ class ListSeriesQuery < BaseQuery
4
+ property :floor_id
5
+ property :initial
6
+
7
+ # @return [Integer, nil]
8
+ def floor_id
9
+ options[:floor_id]
10
+ end
11
+
12
+ # @return [String, nil]
13
+ def initial
14
+ options[:initial]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -91,7 +91,7 @@ module Rdmm
91
91
  end
92
92
 
93
93
  # @return [Array]
94
- def series_list
94
+ def series
95
95
  Array(source["iteminfo"]["series"])
96
96
  end
97
97
 
@@ -0,0 +1,25 @@
1
+ module Rdmm
2
+ module Resources
3
+ class SeriesResource < BaseResource
4
+ # @return [String]
5
+ def list_url
6
+ source["list_url"]
7
+ end
8
+
9
+ # @return [String]
10
+ def name
11
+ source["name"]
12
+ end
13
+
14
+ # @return [String]
15
+ def ruby
16
+ source["ruby"]
17
+ end
18
+
19
+ # @return [Integer]
20
+ def series_id
21
+ source["series_id"]
22
+ end
23
+ end
24
+ end
25
+ end
@@ -33,6 +33,11 @@ module Rdmm
33
33
  faraday_response.status
34
34
  end
35
35
 
36
+ # @return [Integer]
37
+ def total_count
38
+ body["result"]["total_count"]
39
+ end
40
+
36
41
  private
37
42
 
38
43
  # @return [Faraday::Response]
@@ -0,0 +1,12 @@
1
+ module Rdmm
2
+ module Responses
3
+ class ListSeriesResponse < BaseResponse
4
+ # @note Override
5
+ def resources
6
+ body["result"]["series"].map do |source|
7
+ ::Rdmm::Resources::SeriesResource.new(source)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
data/lib/rdmm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rdmm
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/rdmm.gemspec CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["r7kamura@gmail.com"]
10
10
  spec.summary = "An API Client library for DMM written in Ruby."
11
11
  spec.homepage = "https://github.com/r7kamura/rdmm"
12
+ spec.license = "MIT"
12
13
 
13
14
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
14
15
  f.match(%r{^(test|spec|features)/})
@@ -17,7 +18,7 @@ Gem::Specification.new do |spec|
17
18
 
18
19
  spec.add_dependency "faraday"
19
20
  spec.add_dependency "faraday_middleware"
20
- spec.add_development_dependency "bundler", "~> 1.14"
21
+ spec.add_development_dependency "bundler", "~> 1.13"
21
22
  spec.add_development_dependency "pry"
22
23
  spec.add_development_dependency "rake", "~> 10.0"
23
24
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdmm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.14'
47
+ version: '1.13'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.14'
54
+ version: '1.13'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +112,18 @@ files:
112
112
  - lib/rdmm/client.rb
113
113
  - lib/rdmm/queries/base_query.rb
114
114
  - lib/rdmm/queries/list_items_query.rb
115
+ - lib/rdmm/queries/list_series_query.rb
115
116
  - lib/rdmm/resources/base_resource.rb
116
117
  - lib/rdmm/resources/item_resource.rb
118
+ - lib/rdmm/resources/series_resource.rb
117
119
  - lib/rdmm/responses/base_response.rb
118
120
  - lib/rdmm/responses/list_items_response.rb
121
+ - lib/rdmm/responses/list_series_response.rb
119
122
  - lib/rdmm/version.rb
120
123
  - rdmm.gemspec
121
124
  homepage: https://github.com/r7kamura/rdmm
122
- licenses: []
125
+ licenses:
126
+ - MIT
123
127
  metadata: {}
124
128
  post_install_message:
125
129
  rdoc_options: []