namba 1.0.0.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- namba (0.0.1)
4
+ namba (1.0.0.1)
5
5
  multi_json
6
6
 
7
7
  GEM
@@ -4,19 +4,19 @@ require 'multi_json'
4
4
  module Namba
5
5
  module APIMethods
6
6
  def get_user_info name = self.username
7
- get_responce_from "http://api.namba.#{self.locale}/getUserInfo.php?username=" + name
7
+ get_response_from "http://api.namba.#{self.locale}/getUserInfo.php?username=" + name
8
8
  end
9
9
 
10
10
  def get_user_video name = self.username
11
- get_responce_from "http://api.namba.#{self.locale}/getVideo.php?username=" + name
11
+ get_response_from "http://api.namba.#{self.locale}/getVideo.php?username=" + name
12
12
  end
13
13
 
14
14
  def get_user_photo name = self.username
15
- get_responce_from "http://api.namba.#{self.locale}/getPhoto.php?username=" + name
15
+ get_response_from "http://api.namba.#{self.locale}/getPhoto.php?username=" + name
16
16
  end
17
17
 
18
18
  def get_friends_list name = self.username
19
- get_responce_from "http://api.namba.#{self.locale}/friends.php?username=" + name
19
+ get_response_from "http://api.namba.#{self.locale}/friends.php?username=" + name
20
20
  end
21
21
 
22
22
  def set_status text
@@ -37,13 +37,15 @@ module Namba
37
37
 
38
38
  private
39
39
 
40
- def get_responce_from url
40
+ def get_response_from url
41
41
  response = Net::HTTP.get_response(URI.parse(url))
42
+ raise InvalidResponseError, "Invalid response from service" unless response.code == "200"
42
43
  MultiJson.decode(response.body)
43
44
  end
44
45
 
45
46
  def post_data_to url, params = { :username => self.username, :password => self.password }
46
47
  response = Net::HTTP.post_form(URI.parse(url), params)
48
+ raise InvalidResponseError, "Invalid response from service" unless response.code == "200"
47
49
  MultiJson.decode(response.body)
48
50
  end
49
51
  end
data/lib/namba/error.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Namba
2
- class ConfigurationError < StandardError
3
- end
2
+ class ConfigurationError < StandardError; end
3
+ class InvalidResponseError < StandardError; end
4
4
  end
data/lib/namba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Namba
2
- VERSION = "1.0.0.1"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -42,4 +42,18 @@ describe Namba do
42
42
  end
43
43
  }.should raise_error(Namba::ConfigurationError, "Available locales are only 'kg' and 'kz'")
44
44
  end
45
+
46
+ it "should raise Invalid Response Error when status code is not 200" do
47
+ Namba.configure do |config|
48
+ config.username = "name"
49
+ config.password = "secret"
50
+ config.locale = :kz
51
+ end
52
+
53
+ n = Namba.new()
54
+
55
+ expect {
56
+ n.send(:get_response_from, "http://api.namba.#{n.locale}/404")
57
+ }.should raise_error(Namba::InvalidResponseError, "Invalid response from service")
58
+ end
45
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namba
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.1
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-15 00:00:00.000000000 Z
13
+ date: 2012-06-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
17
- requirement: &84280090 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *84280090
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: rspec
28
- requirement: &84238420 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ~>
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: 2.7.0
34
39
  type: :development
35
40
  prerelease: false
36
- version_requirements: *84238420
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 2.7.0
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: rake
39
- requirement: &84236540 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: '0'
45
55
  type: :development
46
56
  prerelease: false
47
- version_requirements: *84236540
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: webmock
50
- requirement: &84234790 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *84234790
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: rack-test
61
- requirement: &84230950 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -66,7 +86,12 @@ dependencies:
66
86
  version: '0'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *84230950
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
70
95
  description: Ruby wrapper for Namba API
71
96
  email:
72
97
  - sergey.kishenin@gmail.com
@@ -113,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
138
  version: '0'
114
139
  requirements: []
115
140
  rubyforge_project:
116
- rubygems_version: 1.8.10
141
+ rubygems_version: 1.8.24
117
142
  signing_key:
118
143
  specification_version: 3
119
144
  summary: Ruby wrapper for Namba API