twitch 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/twitch.rb +28 -17
  3. metadata +14 -22
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1aaa6641eba687a3e3b10c7bf9f7966c4795fa5f
4
+ data.tar.gz: 11d1d90915327fd4d367af1057b8f5593d2c74c4
5
+ SHA512:
6
+ metadata.gz: 46bc8ea7559f759f1f5f88adee2917ea9ce728c540d3e00dce7de4cb3eb195fe8a866cd809c2ff4e7e8a98180ea5ced175449d786e84b5a73bc50c12937f665d
7
+ data.tar.gz: 018060e0542c44653e2eaad7d86c08c8b9704512ac57959e91f7b3653e2f813675625ad1889863d3b8c4214a2e5dafb28d0a6717ff91182d9b2cc01a2a3dc0d7
data/lib/twitch.rb CHANGED
@@ -1,5 +1,4 @@
1
- require "curb"
2
- require "json"
1
+ require "httparty"
3
2
 
4
3
  class Twitch
5
4
  def initialize(options = {})
@@ -90,6 +89,13 @@ class Twitch
90
89
  put(url, data)
91
90
  end
92
91
 
92
+ def followChannel(username, channel)
93
+ return false if !@access_token
94
+ path = "/users/#{username}/follows/channels/#{channel}?oauth_token=#{@access_token}"
95
+ url = @base_url + path
96
+ put(url)
97
+ end
98
+
93
99
  def runCommercial(channel, length = 30)
94
100
  return false if !@access_token
95
101
  path = "/channels/#{channel}/commercial?oauth_token=#{@access_token}"
@@ -178,11 +184,16 @@ class Twitch
178
184
  path = "/videos/#{video_id}/"
179
185
  url = @base_url + path
180
186
  get(url)
181
- end
187
+ end
182
188
 
189
+ def isSubscribed(username, channel, options = {})
190
+ query = buildQueryString(options)
191
+ path = "/users/#{username}/subscriptions/#{channel}?oauth_token=#{@access_token}"
192
+ url = @base_url + path + query
193
+ get(url)
194
+ end
183
195
 
184
196
  private
185
-
186
197
  def buildQueryString(options)
187
198
  query = "?"
188
199
  options.each do |key, value|
@@ -192,24 +203,24 @@ class Twitch
192
203
  end
193
204
 
194
205
  def post(url, data)
195
- response_data = Curl.post(url, data)
206
+ response_data = HTTParty.post(url, :body => data)
196
207
  {
197
- :body => JSON.parse(response_data.body_str),
198
- :response => response_data.response_code
208
+ :body => response_data,
209
+ :response => response_data.code
199
210
  }
200
211
  end
201
212
 
202
213
  def get(url)
203
- c = Curl.get(url)
204
- {:body => JSON.parse(c.body_str), :response => c.response_code}
214
+ c = HTTParty.get(url)
215
+ {:body => c, :response => c.code}
205
216
  end
206
217
 
207
218
  def put(url, data)
208
- c = Curl.put(url,data.to_json) do |curl|
209
- curl.headers['Accept'] = 'application/json'
210
- curl.headers['Content-Type'] = 'application/json'
211
- curl.headers['Api-Version'] = '2.2'
212
- end
213
- {:body => JSON.parse(c.body_str), :response => c.response_code}
214
- end
215
- end
219
+ c = HTTParty.put(url, :body => data, :headers => {
220
+ 'Accept' => 'application/json',
221
+ 'Content-Type' => 'application/json',
222
+ 'Api-Version' => '2.2'
223
+ })
224
+ {:body => c, :response => c.code}
225
+ end
226
+ end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dustin Lakin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-05 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: curb
14
+ name: httparty
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: Simplify Twitch's API for Ruby
@@ -68,26 +61,25 @@ files:
68
61
  - lib/twitch.rb
69
62
  homepage: https://github.com/dustinlakin/twitch-rb
70
63
  licenses: []
64
+ metadata: {}
71
65
  post_install_message:
72
66
  rdoc_options: []
73
67
  require_paths:
74
68
  - lib
75
69
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
70
  requirements:
78
- - - ! '>='
71
+ - - '>='
79
72
  - !ruby/object:Gem::Version
80
73
  version: '0'
81
74
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
75
  requirements:
84
- - - ! '>='
76
+ - - '>='
85
77
  - !ruby/object:Gem::Version
86
78
  version: '0'
87
79
  requirements: []
88
80
  rubyforge_project:
89
- rubygems_version: 1.8.23
81
+ rubygems_version: 2.0.14
90
82
  signing_key:
91
- specification_version: 3
83
+ specification_version: 4
92
84
  summary: Twitch API
93
85
  test_files: []