vibe 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42957330c65a385053f38e6115fbffd5582de233
4
- data.tar.gz: 10720a0efce24e336875a5a85b4f95af9781a414
3
+ metadata.gz: 0ec56f54779cd6dd4e418c333ba973e367c26fa2
4
+ data.tar.gz: e03299e56442ad85771b612b59c7c9c91ddbda27
5
5
  SHA512:
6
- metadata.gz: 500385ff02ff764ac6de551c03a1b8e4c32da0a2062ffda57e4c92dfe697f49ddc5331853cf752cc5183318a1092d031986c46da90bee6d364544aacbd67da15
7
- data.tar.gz: 22740c4ed6955d176283b698805565267ea85f67126b90a61e338b26701d387b9edd0919b379be6d13a4133a33dd0037a5e5b3ad1d49e3c4a0eb60159bb47efc
6
+ metadata.gz: 9984fca7a1dd501ddb5e468f98c2f3d063caca89458584ffa3da23ad3ea36f83de9671ce718bbace7faef5447c15fab62f89445869d8adc3a13f187b73d640ad
7
+ data.tar.gz: 2861afe80b7f825e08dd2d82278a7efacde8a490d457523de057735a9d937eb818de79a20c54bba7d8eaaeb14055c84abbba8ffab503de231bd3647b38f8e9b1
data/.gitignore CHANGED
@@ -32,3 +32,8 @@ Gemfile.lock
32
32
 
33
33
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
34
  .rvmrc
35
+
36
+ # Text editor temp files
37
+ *~
38
+ *.swp
39
+ *.swo
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/README.md CHANGED
@@ -3,16 +3,18 @@ Vibe API
3
3
  [![Gem Version](https://badge.fury.io/rb/vibe.png)][gem]
4
4
  [![Dependency Status](https://gemnasium.com/amalfra/vibe.png)][gemnasium]
5
5
  [![Code Climate](https://codeclimate.com/github/amalfra/vibe.png)][codeclimate]
6
+ [![Travis CI](https://travis-ci.org/amalfra/vibe.svg?branch=master)][travis]
6
7
 
7
8
  [gem]: http://badge.fury.io/rb/vibe
8
9
  [gemnasium]: https://gemnasium.com/amalfra/vibe
9
10
  [codeclimate]: https://codeclimate.com/github/amalfra/vibe
11
+ [travis]: https://travis-ci.org/amalfra/vibe/
10
12
 
11
13
  [RDocs](http://rubydoc.info/github/amalfra/vibe/master/frames)
12
14
 
13
15
  A Ruby wrapper for the Vibe REST API.
14
16
 
15
- > Get API key here : https://vibeapp.co/dev/
17
+ > Get API key here : https://z1.vibeapp.co/dev/
16
18
 
17
19
  ## Installation
18
20
 
@@ -32,7 +32,7 @@ module Vibe
32
32
  raise error
33
33
  end
34
34
 
35
- get_request '/initial_data', :email => email
35
+ get_request '/profile_lookup/', :person_email => email
36
36
  end
37
37
 
38
38
  # Get Stats for API Key
@@ -45,7 +45,7 @@ module Vibe
45
45
  end
46
46
 
47
47
  # Disable cache for API key status calls
48
- get_request('/api_stats', {:api_key => api_key}, true)
48
+ get_request('/stats/', {:key => api_key}, true)
49
49
  end
50
50
 
51
51
  end # Client
@@ -4,7 +4,7 @@ module Vibe
4
4
  VALID_OPTIONS_KEYS = [:api_key, :cache, :cache_driver].freeze
5
5
  VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
6
6
 
7
- DEFAULT_ENDPOINT = 'https://vibeapp.co/api/v1/'.freeze
7
+ DEFAULT_ENDPOINT = 'https://z1.vibeapp.co/api/v1/'.freeze
8
8
  DEFAULT_METHOD = :get.freeze
9
9
  DEFAULT_USER_AGENT = "Vibe API Ruby Gem #{Vibe::VERSION}".freeze
10
10
 
@@ -1,5 +1,5 @@
1
1
  module Vibe
2
- # Raised when Vibe returns the HTTP status code 404
2
+ # Raised for Errors related to Client
3
3
  module Error
4
4
  class ClientError < VibeError
5
5
  attr_reader :problem, :summary, :resolution
@@ -49,9 +49,9 @@ module Vibe
49
49
  if params[:api_key]
50
50
  new_api_key = params[:api_key]
51
51
  params = params.tap { |hs| hs.delete(:api_key) }
52
- params.merge!({:api_key => new_api_key, :user_agent => user_agent})
52
+ params.merge!({:key => new_api_key, :user_agent => user_agent})
53
53
  else
54
- params.merge!({:api_key => api_key, :user_agent => user_agent})
54
+ params.merge!({:key => api_key, :user_agent => user_agent})
55
55
  end
56
56
 
57
57
  begin
@@ -1,3 +1,3 @@
1
1
  module Vibe
2
- VERSION = "0.0.4"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -37,7 +37,7 @@ describe 'client' do
37
37
  api = Vibe::Client.new
38
38
 
39
39
  @config.each do |key, value|
40
- api.send("#{key}=", value)
40
+ api.send("#{key}=", value).must_equal value
41
41
  end
42
42
  end
43
43
 
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
3
  describe 'configuration' do
4
-
4
+
5
5
  describe '.api_key' do
6
6
  it 'should return default key' do
7
7
  Vibe.api_key.must_equal Vibe::Configuration::DEFAULT_API_KEY
@@ -13,13 +13,43 @@ describe 'configuration' do
13
13
  Vibe.user_agent.must_equal Vibe::Configuration::DEFAULT_USER_AGENT
14
14
  end
15
15
  end
16
-
16
+
17
17
  describe '.method' do
18
18
  it 'should return default http method' do
19
19
  Vibe.method.must_equal Vibe::Configuration::DEFAULT_METHOD
20
20
  end
21
21
  end
22
-
22
+
23
+ describe '.endpoint' do
24
+ it 'should return default endpoint' do
25
+ Vibe.endpoint.must_equal Vibe::Configuration::DEFAULT_ENDPOINT
26
+ end
27
+ end
28
+
29
+ describe '.api_key' do
30
+ it 'should return default api_key' do
31
+ Vibe.api_key.must_equal Vibe::Configuration::DEFAULT_API_KEY
32
+ end
33
+ end
34
+
35
+ describe '.format' do
36
+ it 'should return default format' do
37
+ Vibe.format.must_equal Vibe::Configuration::DEFAULT_FORMAT
38
+ end
39
+ end
40
+
41
+ describe '.cache' do
42
+ it 'should return default cache' do
43
+ Vibe.cache.must_equal Vibe::Configuration::DEFAULT_CACHE
44
+ end
45
+ end
46
+
47
+ describe '.cache_driver' do
48
+ it 'should return default cache_driver' do
49
+ Vibe.cache_driver.must_equal Vibe::Configuration::DEFAULT_CACHE_DRIVER
50
+ end
51
+ end
52
+
23
53
  after do
24
54
  Vibe.reset
25
55
  end
@@ -0,0 +1,211 @@
1
+ require 'helper'
2
+
3
+ describe 'error' do
4
+
5
+ before do
6
+ %w[
7
+ service_error
8
+ not_found
9
+ forbidden
10
+ bad_request
11
+ unauthorized
12
+ service_unavailable
13
+ internal_server_error
14
+ unprocessable_entity
15
+ client_error
16
+ invalid_options
17
+ required_params
18
+ unknown_value
19
+ ].each do |error|
20
+ require "vibe/error/#{error}"
21
+ end
22
+ end
23
+
24
+ describe 'VibeError class' do
25
+ before do
26
+ @message = 'abcd'
27
+ end
28
+
29
+ it 'should set error message' do
30
+ error = Vibe::Error::VibeError.new @message
31
+ error.to_s.must_equal @message
32
+ end
33
+ end
34
+
35
+ describe 'BadRequest class' do
36
+ before do
37
+ @env = {
38
+ :status_code => 400,
39
+ :body => 'abcd'
40
+ }
41
+ end
42
+
43
+ it 'should set error message' do
44
+ error = Vibe::Error::BadRequest.new @env
45
+ error.to_s.must_equal @env[:body]
46
+ end
47
+ end
48
+
49
+
50
+ describe 'Forbidden class' do
51
+ before do
52
+ @env = {
53
+ :status_code => 403,
54
+ :body => 'abcd'
55
+ }
56
+ end
57
+
58
+ it 'should set error message' do
59
+ error = Vibe::Error::BadRequest.new @env
60
+ error.to_s.must_equal @env[:body]
61
+ end
62
+ end
63
+
64
+
65
+ describe 'InternalServerError class' do
66
+ before do
67
+ @env = {
68
+ :status_code => 500,
69
+ :body => 'abcd'
70
+ }
71
+ end
72
+
73
+ it 'should set error message' do
74
+ error = Vibe::Error::InternalServerError.new @env
75
+ error.to_s.must_equal @env[:body]
76
+ end
77
+ end
78
+
79
+ describe 'NotFound class' do
80
+ before do
81
+ @env = {
82
+ :status_code => 500,
83
+ :body => 'abcd'
84
+ }
85
+ end
86
+
87
+ it 'should set error message' do
88
+ error = Vibe::Error::NotFound.new @env
89
+ error.to_s.must_equal @env[:body]
90
+ end
91
+ end
92
+
93
+ describe 'ServiceUnavailable class' do
94
+ before do
95
+ @env = {
96
+ :status_code => 503,
97
+ :body => 'abcd'
98
+ }
99
+ end
100
+
101
+ it 'should set error message' do
102
+ error = Vibe::Error::ServiceUnavailable.new @env
103
+ error.to_s.must_equal @env[:body]
104
+ end
105
+ end
106
+
107
+ describe 'Unauthorized class' do
108
+ before do
109
+ @env = {
110
+ :status_code => 401,
111
+ :body => 'abcd'
112
+ }
113
+ end
114
+
115
+ it 'should set error message' do
116
+ error = Vibe::Error::Unauthorized.new @env
117
+ error.to_s.must_equal @env[:body]
118
+ end
119
+ end
120
+
121
+ describe 'UnprocessableEntity class' do
122
+ before do
123
+ @env = {
124
+ :status_code => 422,
125
+ :body => 'abcd'
126
+ }
127
+ end
128
+
129
+ it 'should set error message' do
130
+ error = Vibe::Error::UnprocessableEntity.new @env
131
+ error.to_s.must_equal @env[:body]
132
+ end
133
+ end
134
+
135
+ describe 'ClientError class' do
136
+ before do
137
+ @message = 'test'
138
+ @attributes = {
139
+ :problem => 'a',
140
+ :summary => 'b',
141
+ :resolution => 'c'
142
+ }
143
+ end
144
+
145
+ it 'should set error message' do
146
+ error = Vibe::Error::ClientError.new @message
147
+ error.to_s.must_equal @message
148
+ end
149
+
150
+ it 'should generate error message' do
151
+ error = Vibe::Error::ClientError.new @message
152
+ ret = error.generate_message @attributes
153
+ ret.to_s.must_equal "\nProblem:\n #{@attributes[:problem]}"+ "\nSummary:\n #{@attributes[:summary]}"+ "\nResolution:\n #{@attributes[:resolution]}"
154
+ end
155
+ end
156
+
157
+ describe 'InvalidOptions class' do
158
+ before do
159
+ @valid = ['abcd']
160
+ @invalid = ['efgh']
161
+ end
162
+
163
+ it 'should set error message' do
164
+ error = Vibe::Error::InvalidOptions.new @invalid, @valid
165
+ eq = Vibe::Error::ClientError.new 'asfsd'
166
+ eq = eq.generate_message :problem => "Invalid option #{@invalid.join(', ')} provided for this request.",
167
+ :summary => "Vibe gem checks the request parameters passed to ensure that Vibe api is not hit unnecessairly and to fail fast.",
168
+ :resolution => "Valid options are: #{@valid.join(', ')}, make sure these are the ones you are using"
169
+
170
+ error.to_s.must_equal eq
171
+ end
172
+ end
173
+
174
+ describe 'RequiredParams class' do
175
+ before do
176
+ @provided = {
177
+ 'abcd' => 'asfsdg'
178
+ }
179
+ @required = ['efgh']
180
+ end
181
+
182
+ it 'should set error message' do
183
+ error = Vibe::Error::RequiredParams.new @provided, @required
184
+ eq = Vibe::Error::ClientError.new 'asfsd'
185
+ eq = eq.generate_message :problem => "Missing required parameters: #{@provided.keys.join(', ')} provided for this request.",
186
+ :summary => "Vibe gem checks the request parameters passed to ensure that Vibe api is not hit unnecessairly and to fail fast.",
187
+ :resolution => "Required parameters are: #{@required.join(', ')}, make sure these are the ones you are using"
188
+
189
+ error.to_s.must_equal eq
190
+ end
191
+ end
192
+
193
+ describe 'UnknownValue class' do
194
+ before do
195
+ @key = 'abcd'
196
+ @value = 'efgh'
197
+ @permitted = 'asfsdfsfdsfhb'
198
+ end
199
+
200
+ it 'should set error message' do
201
+ error = Vibe::Error::UnknownValue.new @key, @value, @permitted
202
+ eq = Vibe::Error::ClientError.new 'asfsd'
203
+ eq = eq.generate_message :problem => "Wrong value of '#{@value}' for the parameter: #{@key} provided for this request.",
204
+ :summary => "Vibe gem checks the request parameters passed to ensure that Vibe api is not hit unnecessairly and fails fast.",
205
+ :resolution => "Permitted values are: #{@permitted}, make sure these are the ones you are using"
206
+
207
+ error.to_s.must_equal eq
208
+ end
209
+ end
210
+
211
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vibe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amal Francis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: A Ruby wrapper for the Vibe REST API
@@ -73,8 +73,9 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - CODE_OF_CONDUCT.md
78
79
  - Gemfile
79
80
  - LICENSE
80
81
  - README.md
@@ -103,6 +104,7 @@ files:
103
104
  - test/helper.rb
104
105
  - test/vibe/client_test.rb
105
106
  - test/vibe/configuration_test.rb
107
+ - test/vibe/error_test.rb
106
108
  - test/vibe/vibe_test.rb
107
109
  - vibe.gemspec
108
110
  homepage: https://github.com/amalfra/vibe
@@ -115,17 +117,17 @@ require_paths:
115
117
  - lib
116
118
  required_ruby_version: !ruby/object:Gem::Requirement
117
119
  requirements:
118
- - - '>='
120
+ - - ">="
119
121
  - !ruby/object:Gem::Version
120
122
  version: 1.9.3
121
123
  required_rubygems_version: !ruby/object:Gem::Requirement
122
124
  requirements:
123
- - - '>='
125
+ - - ">="
124
126
  - !ruby/object:Gem::Version
125
127
  version: '0'
126
128
  requirements: []
127
129
  rubyforge_project:
128
- rubygems_version: 2.3.0
130
+ rubygems_version: 2.4.6
129
131
  signing_key:
130
132
  specification_version: 4
131
133
  summary: A Ruby wrapper for the Vibe REST API
@@ -133,4 +135,5 @@ test_files:
133
135
  - test/helper.rb
134
136
  - test/vibe/client_test.rb
135
137
  - test/vibe/configuration_test.rb
138
+ - test/vibe/error_test.rb
136
139
  - test/vibe/vibe_test.rb