streamio 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.0.4 2012-12-03
2
+
3
+ * Add proper handling of authorization by raising Streamio::Errors::Unauthorized when using wrong username/password.
4
+
1
5
  # 1.0.3 2012-12-03
2
6
 
3
7
  * Fix ruby 1.8 compatability by avoiding use of define_singleton_method.
@@ -5,6 +5,7 @@ require "multi_json"
5
5
  require "time"
6
6
 
7
7
  require "streamio/version"
8
+ require "streamio/errors"
8
9
  require "streamio/resource"
9
10
  require "streamio/model"
10
11
  require "streamio/video"
@@ -0,0 +1,6 @@
1
+ module Streamio
2
+ module Errors
3
+ class Unauthorized < StandardError
4
+ end
5
+ end
6
+ end
@@ -12,7 +12,7 @@ module Streamio
12
12
  end
13
13
 
14
14
  def get(path, parameters = {})
15
- @net.request(net_request(Net::HTTP::Get, path, parameters))
15
+ validate_and_return @net.request(net_request(Net::HTTP::Get, path, parameters))
16
16
  end
17
17
 
18
18
  def post(path, parameters = {})
@@ -20,15 +20,15 @@ module Streamio
20
20
  value.is_a?(File)
21
21
  end ? Net::HTTP::Post::Multipart : Net::HTTP::Post
22
22
 
23
- @net.request(net_request(request_class, path, parameters))
23
+ validate_and_return @net.request(net_request(request_class, path, parameters))
24
24
  end
25
25
 
26
26
  def put(path, parameters = {})
27
- @net.request(net_request(Net::HTTP::Put, path, parameters))
27
+ validate_and_return @net.request(net_request(Net::HTTP::Put, path, parameters))
28
28
  end
29
29
 
30
30
  def delete(path)
31
- @net.request(net_request(Net::HTTP::Delete, path))
31
+ validate_and_return @net.request(net_request(Net::HTTP::Delete, path))
32
32
  end
33
33
 
34
34
  private
@@ -54,5 +54,10 @@ module Streamio
54
54
  req["Accept"] = "application/json"
55
55
  req
56
56
  end
57
+
58
+ def validate_and_return(response)
59
+ raise Errors::Unauthorized if response.code.to_i == 401
60
+ response
61
+ end
57
62
  end
58
63
  end
@@ -1,3 +1,3 @@
1
1
  module Streamio
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -116,6 +116,7 @@ extra_rdoc_files: []
116
116
  files:
117
117
  - lib/streamio/audio.rb
118
118
  - lib/streamio/encoding_profile.rb
119
+ - lib/streamio/errors.rb
119
120
  - lib/streamio/image.rb
120
121
  - lib/streamio/model.rb
121
122
  - lib/streamio/player.rb
@@ -143,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
144
  version: '0'
144
145
  segments:
145
146
  - 0
146
- hash: -2432446855761254527
147
+ hash: 3096267224614195611
147
148
  required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  none: false
149
150
  requirements:
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  version: '0'
153
154
  segments:
154
155
  - 0
155
- hash: -2432446855761254527
156
+ hash: 3096267224614195611
156
157
  requirements: []
157
158
  rubyforge_project:
158
159
  rubygems_version: 1.8.24