twitch 0.0.5 → 0.1.0

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: 95f3eeb91c1f1d1fe9e7617efc34e39e559f7faf
4
- data.tar.gz: 24ef1ede7142906bdbc003e897a329a0bef8845f
3
+ metadata.gz: 23781ae0fb82fe7205a8b07bd14a47f5bbdcf6bd
4
+ data.tar.gz: fafa98561b1df4230c13ebe7ff385291f0d71764
5
5
  SHA512:
6
- metadata.gz: 008d286a0df1ad05cdf3405d184c174cbd9c3424eaee6dec9ab84bfde59190da36a260cf7c164b6ca18c7a8e74e26bcd0d0836035613888f2a2b1660f44069da
7
- data.tar.gz: 3e508a0606d788e2a35531b147f754022256a8206e30e6858a607380e6c45f9e4f695f5946258c9557fb19be0d6aec72abdbc04f8e969fbebdd7aba15dbd4451
6
+ metadata.gz: 36478d840ee2ead80c59612f88ab5392e418e273ccbaa014e2c2895629fbeb379fcc9068adff451c7f829e83e1a9b82e5f70fdae7d599ac7678bbfed69bace46
7
+ data.tar.gz: c57d5129e3163d0c78522fc3d08eb2e735558663d94c063f588a4fc413530ba3c102591aa32f7e2d73efd54b066e17a67cea2f6d0a7b3bcd0a0677691a8a4645
@@ -27,7 +27,7 @@ module Twitch
27
27
  get_adapter(adapter)
28
28
  end
29
29
 
30
- def getLink
30
+ def link
31
31
  scope = ""
32
32
  @scope.each { |s| scope += s + '+' }
33
33
  link = "https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id=#{@client_id}&redirect_uri=#{@redirect_uri}&scope=#{scope}"
@@ -47,59 +47,74 @@ module Twitch
47
47
 
48
48
  # User
49
49
 
50
- def getUser(user)
50
+ def user(user = nil)
51
+ return your_user unless user
52
+
51
53
  path = "/users/"
52
54
  url = @base_url + path + user;
55
+
53
56
  get(url)
54
57
  end
55
58
 
56
- def getYourUser
57
- return false if !@access_token
59
+ def your_user
60
+ return false unless @access_token
61
+
58
62
  path = "/user?oauth_token=#{@access_token}"
59
63
  url = @base_url + path
64
+
60
65
  get(url)
61
66
  end
62
67
 
63
68
  # Teams
64
69
 
65
- def getTeams
70
+ def teams
66
71
  path = "/teams/"
67
72
  url = @base_url + path;
73
+
68
74
  get(url)
69
75
  end
70
76
 
71
77
 
72
- def getTeam(team_id)
78
+ def team(team_id)
73
79
  path = "/teams/"
74
80
  url = @base_url + path + team_id;
81
+
75
82
  get(url)
76
83
  end
77
84
 
78
85
  # Channel
79
86
 
80
- def getChannel(channel)
87
+ def channel(channel = nil)
88
+ return your_channel unless channel
89
+
81
90
  path = "/channels/"
82
91
  url = @base_url + path + channel;
92
+
83
93
  get(url)
84
94
  end
85
95
 
86
- def getYourChannel
87
- return false if !@access_token
96
+ def your_channel
97
+ return false unless @access_token
98
+
88
99
  path = "/channel?oauth_token=#{@access_token}"
89
100
  url = @base_url + path;
101
+
90
102
  get(url)
91
103
  end
92
104
 
93
- def getEditors(channel)
94
- return false if !@access_token
105
+ def editors(channel)
106
+ return false unless @access_token
107
+
95
108
  path = "/channels/#{channel}/editors?oauth_token=#{@access_token}"
96
109
  url = @base_url + path;
110
+
97
111
  get(url)
98
112
  end
99
113
 
100
114
  # TODO: Add ability to set delay, which is only available for partered channels
101
- def editChannel(channel, status, game)
102
- return false if !@access_token
115
+ def edit_channel(channel, status, game)
116
+ return false unless @access_token
117
+
103
118
  path = "/channels/#{channel}/?oauth_token=#{@access_token}"
104
119
  url = @base_url + path
105
120
  data = {
@@ -111,29 +126,33 @@ module Twitch
111
126
  put(url, data)
112
127
  end
113
128
 
114
- def resetKey(channel)
115
- return false if !@access_token
129
+ def reset_key(channel)
130
+ return false unless @access_token
131
+
116
132
  path = "/channels/#{channel}/stream_key?oauth_token=#{@access_token}"
117
133
  url = @base_url + path
118
134
  delete(url)
119
135
  end
120
136
 
121
- def followChannel(username, channel)
122
- return false if !@access_token
137
+ def follow_channel(username, channel)
138
+ return false unless @access_token
139
+
123
140
  path = "/users/#{username}/follows/channels/#{channel}?oauth_token=#{@access_token}"
124
141
  url = @base_url + path
125
142
  put(url)
126
143
  end
127
144
 
128
- def followChannel(username, channel)
129
- return false if !@access_token
145
+ def follow_channel(username, channel)
146
+ return false unless @access_token
147
+
130
148
  path = "/users/#{username}/follows/channels/#{channel}?oauth_token=#{@access_token}"
131
149
  url = @base_url + path
132
150
  delete(url)
133
151
  end
134
152
 
135
- def runCommercial(channel, length = 30)
136
- return false if !@access_token
153
+ def run_commercial(channel, length = 30)
154
+ return false unless @access_token
155
+
137
156
  path = "/channels/#{channel}/commercial?oauth_token=#{@access_token}"
138
157
  url = @base_url + path
139
158
  post(url, {
@@ -141,143 +160,167 @@ module Twitch
141
160
  })
142
161
  end
143
162
 
144
- def getChannelTeams(channel)
145
- return false if !@access_token
163
+ def channel_teams(channel)
164
+ return false unless @access_token
165
+
146
166
  path = "/channels/#{channel}/teams?oauth_token=#{@access_token}"
147
167
  url = @base_url + path;
168
+
148
169
  get(url)
149
170
  end
150
171
 
151
172
  # Streams
152
173
 
153
- def getStream(stream_name)
174
+ def stream(stream_name)
154
175
  path = "/stream/#{stream_name}"
155
176
  url = @base_url + path;
177
+
156
178
  get(url)
157
179
  end
158
180
 
159
- def getStream(stream_name)
181
+ def stream(stream_name)
160
182
  path = "/streams/#{stream_name}"
161
183
  url = @base_url + path;
184
+
162
185
  get(url)
163
186
  end
164
187
 
165
- def getStreams(options = {})
166
- query = buildQueryString(options)
188
+ def streams(options = {})
189
+ query = build_query_string(options)
167
190
  path = "/streams"
168
191
  url = @base_url + path + query
192
+
169
193
  get(url)
170
194
  end
171
195
 
172
- def getFeaturedStreams(options = {})
173
- query = buildQueryString(options)
196
+ def featured_streams(options = {})
197
+ query = build_query_string(options)
174
198
  path = "/streams/featured"
175
199
  url = @base_url + path + query
200
+
176
201
  get(url)
177
202
  end
178
203
 
179
- def getSummeraizedStreams(options = {})
180
- query = buildQueryString(options)
204
+ def summarized_streams(options = {})
205
+ query = build_query_string(options)
181
206
  path = "/streams/summary"
182
207
  url = @base_url + path + query
208
+
183
209
  get(url)
184
210
  end
185
211
 
186
- def getYourFollowedStreams(options = {})
187
- return false if !@access_token
188
- query = buildQueryString(options)
212
+ def followed_streams(options = {})
213
+ return false unless @access_token
214
+
215
+ query = build_query_string(options)
189
216
  path = "/streams/followed?oauth_token=#{@access_token}"
190
217
  url = @base_url + path + query
218
+
191
219
  get(url)
192
220
  end
221
+ alias :your_followed_streams :followed_streams
193
222
 
194
223
  #Games
195
224
 
196
- def getTopGames(options = {})
197
- query = buildQueryString(options)
225
+ def top_games(options = {})
226
+ query = build_query_string(options)
198
227
  path = "/games/top"
199
228
  url = @base_url + path + query
229
+
200
230
  get(url)
201
231
  end
202
232
 
203
233
  #Search
204
234
 
205
- def searchChannels(options = {})
206
- query = buildQueryString(options)
235
+ def search_channels(options = {})
236
+ query = build_query_string(options)
207
237
  path = "/search/channels"
208
238
  url = @base_url + path + query
239
+
209
240
  get(url)
210
241
  end
211
242
 
212
- def searchStreams(options = {})
213
- query = buildQueryString(options)
243
+ def search_streams(options = {})
244
+ query = build_query_string(options)
214
245
  path = "/search/streams"
215
246
  url = @base_url + path + query
247
+
216
248
  get(url)
217
249
  end
218
250
 
219
- def searchGames(options = {})
220
- query = buildQueryString(options)
251
+ def search_games(options = {})
252
+ query = build_query_string(options)
221
253
  path = "/search/games"
222
254
  url = @base_url + path + query
255
+
223
256
  get(url)
224
257
  end
225
258
 
226
259
  # Videos
227
260
 
228
- def getChannelVideos(channel, options = {})
229
- query = buildQueryString(options)
261
+ def channel_videos(channel, options = {})
262
+ query = build_query_string(options)
230
263
  path = "/channels/#{channel}/videos"
231
264
  url = @base_url + path + query
265
+
232
266
  get(url)
233
267
  end
234
268
 
235
- def getVideo(video_id)
269
+ def video(video_id)
236
270
  path = "/videos/#{video_id}/"
237
271
  url = @base_url + path
272
+
238
273
  get(url)
239
274
  end
240
275
 
241
- def isSubscribed(username, channel, options = {})
242
- query = buildQueryString(options)
276
+ def subscribed?(username, channel, options = {})
277
+ query = build_query_string(options)
243
278
  path = "/users/#{username}/subscriptions/#{channel}?oauth_token=#{@access_token}"
244
279
  url = @base_url + path + query
280
+
245
281
  get(url)
246
282
  end
247
283
 
248
- def getYourFollowedVideos(options ={})
249
- return false if !@access_token
250
- query = buildQueryString(options)
284
+ def followed_videos(options ={})
285
+ return false unless @access_token
286
+
287
+ query = build_query_string(options)
251
288
  path = "/videos/followed?oauth_token=#{@access_token}"
252
289
  url = @base_url + path + query
290
+
253
291
  get(url)
254
292
  end
293
+ alias :your_followed_videos :followed_videos
255
294
 
256
- def getTopVideos(options = {})
257
- query = buildQueryString(options)
295
+ def top_videos(options = {})
296
+ query = build_query_string(options)
258
297
  path = "/videos/top"
259
298
  url = @base_url + path + query
299
+
260
300
  get(url)
261
301
  end
262
302
 
263
303
  # Blocks
264
304
 
265
- def getBlocks(username, options = {})
266
- query = buildQueryString(options)
305
+ def blocks(username, options = {})
306
+ query = build_query_string(options)
267
307
  path = "/users/#{username}/blocks?oauth_token=#{@access_token}"
268
308
  url = @base_url + path + query
309
+
269
310
  get(url)
270
311
  end
271
312
 
272
- def blockUser(username, target)
273
- return false if !@access_token
313
+ def block_user(username, target)
314
+ return false unless @access_token
315
+
274
316
  path = "/users/#{username}/blocks/#{target}?oauth_token=#{@access_token}"
275
317
  url = @base_url + path
276
318
  put(url)
277
319
  end
278
320
 
279
- def unblockUser(username, target)
280
- return false if !@access_token
321
+ def unblock_user(username, target)
322
+ return false unless @access_token
323
+
281
324
  path = "/users/#{username}/blocks/#{target}?oauth_token=#{@access_token}"
282
325
  url = @base_url + path
283
326
  delete(url)
@@ -285,73 +328,85 @@ module Twitch
285
328
 
286
329
  # Chat
287
330
 
288
- def getChatLinks(channel)
331
+ def chat_links(channel)
289
332
  path = "/chat/"
290
333
  url = @base_url + path + channel;
334
+
291
335
  get(url)
292
336
  end
293
337
 
294
- def getBadges(channel)
338
+ def badges(channel)
295
339
  path = "/chat/#{channel}/badges"
296
340
  url = @base_url + path;
341
+
297
342
  get(url)
298
343
  end
299
344
 
300
- def getEmoticons()
345
+ def emoticons()
301
346
  path = "/chat/emoticons"
302
347
  url = @base_url + path;
348
+
303
349
  get(url)
304
350
  end
305
351
 
306
352
  # Follows
307
353
 
308
- def getFollowing(channel)
354
+ def following(channel)
309
355
  path = "/channels/#{channel}/follows"
310
356
  url = @base_url + path;
357
+
311
358
  get(url)
312
359
  end
313
360
 
314
- def getFollowed(username)
361
+ def followed(username)
315
362
  path = "/users/#{username}/follows/channels"
316
363
  url = @base_url + path;
364
+
317
365
  get(url)
318
366
  end
319
367
 
320
- def getFollowStatus(username, channel)
368
+ def follow_status(username, channel)
321
369
  path = "/users/#{username}/follows/channels/#{channel}/?oauth_token=#{@access_token}"
322
370
  url = @base_url + path;
371
+
323
372
  get(url)
324
373
  end
325
374
 
326
375
  # Ingests
327
376
 
328
- def getIngests()
377
+ def ingests()
329
378
  path = "/ingests"
330
379
  url = @base_url + path
380
+
331
381
  get(url)
332
382
  end
333
383
 
334
384
  # Root
335
385
 
336
- def getRoot()
386
+ def root()
337
387
  path = "/?oauth_token=#{@access_token}"
338
388
  url = @base_url + path
389
+
339
390
  get(url)
340
391
  end
341
392
 
342
393
  # Subscriptions
343
394
 
344
- def getSubscribed(channel)
345
- return false if !@access_token
395
+ def subscribed(channel)
396
+ return false unless @access_token
397
+
346
398
  path = "/channels/#{channel}/subscriptions?oauth_token=#{@access_token}"
347
399
  url = @base_url + path
400
+
348
401
  get(url)
349
402
  end
350
403
 
351
- def isSubscribedToChannel(username, channel)
352
- return false if !@access_token
404
+ def subscribed_to_channel(username, channel)
405
+ return false unless @access_token
406
+
353
407
  path = "/channels/#{channel}/subscriptions/#{username}?oauth_token=#{@access_token}"
354
408
  url = @base_url + path
409
+
355
410
  get(url)
356
411
  end
357
412
  end
@@ -1,6 +1,6 @@
1
1
  module Twitch
2
2
  module Request
3
- def buildQueryString(options)
3
+ def build_query_string(options)
4
4
  query = "?"
5
5
  options.each do |key, value|
6
6
  query += "#{key}=#{value.to_s.gsub(" ", "+")}&"
@@ -2,8 +2,8 @@
2
2
  module Twitch
3
3
  module VERSION
4
4
  MAJOR = 0
5
- MINOR = 0
6
- TINY = 5
5
+ MINOR = 1
6
+ TINY = 0
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].compact.join(".")
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Lakin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty