dmm-sdk-ruby 0.1.5 → 0.1.6
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/lib/dmm/core.rb +61 -7
- data/lib/dmm/version.rb +1 -1
- metadata +1 -2
- data/lib/dmm/.core.rb.swp +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68d41909a86a1a92ac04e3e6417842b3e71d005b
|
4
|
+
data.tar.gz: 098d4f7da90e07093df92e0727e7c0109954b559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e2dc16d2466fbf3ce65c1ae4c38d27923dec24248b8bfbde384db4e8ba8f2bdf16348c3e577dbe161f91dadb01bcc993a06445a3d193f2700640ac6da08bd50
|
7
|
+
data.tar.gz: c46584f7fda19ad611996b3e81062710be801ad5b8b41a662f8787e72ef2c49ce548cea7d43b2a74b479535dd78e9b77dfe2e93b0abccc5139693c0a6782cf79
|
data/lib/dmm/core.rb
CHANGED
@@ -8,11 +8,10 @@ module Dmm
|
|
8
8
|
@url = 'http://affiliate-api.dmm.com/'
|
9
9
|
@api = api_id.nil? ? ENV['DMM_API_ID'] : api_id
|
10
10
|
@id = affiliate_id.nil? ? ENV['DMM_AFFILIATE_ID'] : affiliate_id
|
11
|
-
@site = 'DMM.co.jp'
|
12
11
|
@version = '2.00'
|
13
|
-
|
14
|
-
puts ENV['DMM_API_ID']
|
15
|
-
puts ENV['DMM_AFFILIATE_ID']
|
12
|
+
site
|
13
|
+
puts "API_ID= #{ENV['DMM_API_ID']}"
|
14
|
+
puts "AFFILIATE_ID= #{ENV['DMM_AFFILIATE_ID']}"
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -93,13 +92,64 @@ module Dmm
|
|
93
92
|
def get_sample_images(h = nil)
|
94
93
|
h ||= @hashdoc
|
95
94
|
arr = []
|
95
|
+
if h.nil?
|
96
|
+
return no_image(1)
|
97
|
+
end
|
98
|
+
if get_result_count(h) == "0"
|
99
|
+
return no_image(2)
|
100
|
+
end
|
96
101
|
items = get_items(h)
|
97
102
|
items.each do |m|
|
98
|
-
|
103
|
+
#Valid
|
104
|
+
if m[:sampleImageURL].nil?
|
105
|
+
next
|
106
|
+
end
|
107
|
+
if m[:sampleImageURL][:sample_s].nil?
|
108
|
+
next
|
109
|
+
end
|
110
|
+
if m[:sampleImageURL][:sample_s][:image].nil?
|
111
|
+
next
|
112
|
+
end
|
113
|
+
# あった
|
114
|
+
arr << {
|
115
|
+
:title => m[:title],
|
116
|
+
:affiliateURL => m[:affiliateURL],
|
117
|
+
:images => m[:sampleImageURL][:sample_s][:image]
|
118
|
+
}
|
119
|
+
end
|
120
|
+
if arr.empty?
|
121
|
+
arr << no_image(3)
|
99
122
|
end
|
100
123
|
arr
|
101
124
|
end
|
102
125
|
|
126
|
+
def get_result_count(h=nil)
|
127
|
+
h ||= @hashdoc
|
128
|
+
h[:response][:result][:result_count]
|
129
|
+
end
|
130
|
+
|
131
|
+
#util_valid
|
132
|
+
def no_image(i)
|
133
|
+
err_str = case i
|
134
|
+
when 1
|
135
|
+
"検索してないよ"
|
136
|
+
when 2
|
137
|
+
"検索結果は0件"
|
138
|
+
when 3
|
139
|
+
"すまない。sample_imageはないんだ(´・ω・`)"
|
140
|
+
else
|
141
|
+
"no_imageは直接呼び出さないでくれ"
|
142
|
+
end
|
143
|
+
|
144
|
+
hash = {
|
145
|
+
:title => 'I do not have an image',
|
146
|
+
:affiliateURL => 'http://www.dmm.com/top/#{@id}-001',
|
147
|
+
:images => 'http://pics.dmm.com/af/c_top/125_125.jpg',
|
148
|
+
:err => err_str
|
149
|
+
}
|
150
|
+
hash
|
151
|
+
end
|
152
|
+
|
103
153
|
#util
|
104
154
|
def create_uri(word, options = {})
|
105
155
|
arr = []
|
@@ -160,7 +210,9 @@ end
|
|
160
210
|
|
161
211
|
module Dmm
|
162
212
|
class R18
|
163
|
-
|
213
|
+
def site
|
214
|
+
@site = "DMM.co.jp"
|
215
|
+
end
|
164
216
|
include Dmm::Configuration
|
165
217
|
include Dmm::Util
|
166
218
|
end
|
@@ -168,7 +220,9 @@ end
|
|
168
220
|
|
169
221
|
module Dmm
|
170
222
|
class Com
|
171
|
-
|
223
|
+
def site
|
224
|
+
@site = "DMM.com"
|
225
|
+
end
|
172
226
|
include Dmm::Configuration
|
173
227
|
include Dmm::Util
|
174
228
|
end
|
data/lib/dmm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmm-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sutoh
|
@@ -53,7 +53,6 @@ files:
|
|
53
53
|
- dmm-sdk-ruby.gemspec
|
54
54
|
- lib/dmm-sdk.rb
|
55
55
|
- lib/dmm.rb
|
56
|
-
- lib/dmm/.core.rb.swp
|
57
56
|
- lib/dmm/core.rb
|
58
57
|
- lib/dmm/version.rb
|
59
58
|
homepage: ''
|
data/lib/dmm/.core.rb.swp
DELETED
Binary file
|