vibe 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +23 -0
- data/LICENSE +22 -0
- data/README.md +13 -0
- data/Rakefile +14 -0
- data/lib/vibe.rb +14 -0
- data/lib/vibe/client.rb +31 -0
- data/lib/vibe/configuration.rb +49 -0
- data/lib/vibe/error.rb +29 -0
- data/lib/vibe/error/bad_request.rb +10 -0
- data/lib/vibe/error/client_error.rb +18 -0
- data/lib/vibe/error/forbidden.rb +10 -0
- data/lib/vibe/error/internal_server_error.rb +10 -0
- data/lib/vibe/error/invalid_options.rb +16 -0
- data/lib/vibe/error/not_found.rb +10 -0
- data/lib/vibe/error/required_params.rb +16 -0
- data/lib/vibe/error/service_error.rb +21 -0
- data/lib/vibe/error/service_unavailable.rb +10 -0
- data/lib/vibe/error/unauthorized.rb +10 -0
- data/lib/vibe/error/unknown_value.rb +16 -0
- data/lib/vibe/error/unprocessable_entity.rb +10 -0
- data/lib/vibe/error/validations.rb +16 -0
- data/lib/vibe/request.rb +56 -0
- data/lib/vibe/version.rb +3 -0
- data/test/helper.rb +3 -0
- data/test/vibe/client_test.rb +48 -0
- data/test/vibe/configuration_test.rb +45 -0
- data/test/vibe/vibe_test.rb +7 -0
- data/vibe.gemspec +25 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3a618d2547d2ba134182f8af9d83961e3bec85f
|
4
|
+
data.tar.gz: e183c7107daa1c0254b547029b59fcb6180a6465
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 292c62a9feff52f505a9703721c26d0e5d8ec988e98d150e2e3d576cb90ddc0ff3b5f680adf3052c75d142675c375b7c1d3d20f021b9946469e4d74ed5336985
|
7
|
+
data.tar.gz: 7cfa1dbd417c5dcd9510433ccf835703b5225635df969627055d9b58fbba67c79ac6db602897fd0e0901baa467b92d603d2ef8c214e6a16af1b920b578307018
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vibe (0.0.1)
|
5
|
+
rest-client (~> 1.7.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
mime-types (2.4.2)
|
11
|
+
netrc (0.8.0)
|
12
|
+
rake (10.1.0)
|
13
|
+
rest-client (1.7.2)
|
14
|
+
mime-types (>= 1.16, < 3.0)
|
15
|
+
netrc (~> 0.7)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
bundler (~> 1.7)
|
22
|
+
rake (~> 10.0)
|
23
|
+
vibe!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Amal Francis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Vibe API
|
2
|
+
========
|
3
|
+
|
4
|
+
A Ruby wrapper for the Vibe REST API.
|
5
|
+
|
6
|
+
UNDER MIT LICENSE
|
7
|
+
=================
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
desc "Open an irb session preloaded with this library"
|
4
|
+
task :console do
|
5
|
+
sh "irb -rubygems -I lib -r vibe.rb"
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rake/testtask'
|
9
|
+
Rake::TestTask.new do |test|
|
10
|
+
test.libs << 'lib' << 'test'
|
11
|
+
test.ruby_opts << "-rubygems"
|
12
|
+
test.pattern = 'test/**/*_test.rb'
|
13
|
+
test.verbose = true
|
14
|
+
end
|
data/lib/vibe.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
%w{version error configuration client}.each do |local|
|
2
|
+
require "vibe/#{local}"
|
3
|
+
end
|
4
|
+
|
5
|
+
module Vibe
|
6
|
+
extend Configuration
|
7
|
+
|
8
|
+
# Alias for Vibe::Client.new
|
9
|
+
#
|
10
|
+
# @return [Vibe::Client]
|
11
|
+
def self.new(options = { }, &block)
|
12
|
+
@api_client = Vibe::Client.new(options, &block)
|
13
|
+
end
|
14
|
+
end
|
data/lib/vibe/client.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'vibe/request'
|
2
|
+
|
3
|
+
module Vibe
|
4
|
+
class Client
|
5
|
+
|
6
|
+
include Request
|
7
|
+
|
8
|
+
attr_accessor *Configuration::VALID_CONFIG_KEYS
|
9
|
+
|
10
|
+
def initialize(options={}, &block)
|
11
|
+
# Merge the config values from the module and those passed
|
12
|
+
# to the client.
|
13
|
+
merged_options = Vibe.options.merge(options)
|
14
|
+
|
15
|
+
# Copy the merged values and ignore those
|
16
|
+
# not part of our configuration
|
17
|
+
Configuration::VALID_CONFIG_KEYS.each do |key|
|
18
|
+
send("#{key}=", merged_options[key]) if Configuration::VALID_OPTIONS_KEYS.include? key
|
19
|
+
send("#{key}=", Vibe.options[key]) if Configuration::VALID_CONNECTION_KEYS.include? key
|
20
|
+
end
|
21
|
+
|
22
|
+
self.instance_eval(&block) if block_given?
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get Data from an Email
|
26
|
+
def get_data(email)
|
27
|
+
get_request '/initial_data', :email => email
|
28
|
+
end
|
29
|
+
|
30
|
+
end # Client
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Vibe
|
2
|
+
module Configuration
|
3
|
+
VALID_CONNECTION_KEYS = [:endpoint, :user_agent, :method, :format].freeze
|
4
|
+
VALID_OPTIONS_KEYS = [:api_key].freeze
|
5
|
+
VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
|
6
|
+
|
7
|
+
DEFAULT_ENDPOINT = 'https://vibeapp.co/api/v1/'.freeze
|
8
|
+
DEFAULT_METHOD = :get.freeze
|
9
|
+
DEFAULT_USER_AGENT = "Vibe API Ruby Gem #{Vibe::VERSION}".freeze
|
10
|
+
|
11
|
+
DEFAULT_API_KEY = nil
|
12
|
+
DEFAULT_FORMAT = :json.freeze
|
13
|
+
|
14
|
+
# Build accessor methods for every config options so we can do this
|
15
|
+
attr_accessor *Configuration::VALID_CONFIG_KEYS
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
self.endpoint = DEFAULT_ENDPOINT
|
19
|
+
self.method = DEFAULT_METHOD
|
20
|
+
self.user_agent = DEFAULT_USER_AGENT
|
21
|
+
self.format = DEFAULT_FORMAT
|
22
|
+
end
|
23
|
+
|
24
|
+
# Make sure we have the default values set when we get 'extended'
|
25
|
+
def self.extended(base)
|
26
|
+
base.reset
|
27
|
+
end
|
28
|
+
|
29
|
+
# Setup Configuration
|
30
|
+
def configure
|
31
|
+
yield self
|
32
|
+
end
|
33
|
+
|
34
|
+
def reset
|
35
|
+
self.endpoint = DEFAULT_ENDPOINT
|
36
|
+
self.method = DEFAULT_METHOD
|
37
|
+
self.user_agent = DEFAULT_USER_AGENT
|
38
|
+
self.format = DEFAULT_FORMAT
|
39
|
+
|
40
|
+
self.api_key = DEFAULT_API_KEY
|
41
|
+
end
|
42
|
+
|
43
|
+
# Return the configuration values set in this module
|
44
|
+
def options
|
45
|
+
Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Configuration
|
49
|
+
end
|
data/lib/vibe/error.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Vibe
|
2
|
+
module Error
|
3
|
+
class VibeError < StandardError
|
4
|
+
attr_reader :response_message, :response_headers
|
5
|
+
|
6
|
+
def initialize(message)
|
7
|
+
super(message)
|
8
|
+
@response_message = message
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end # Error
|
12
|
+
end
|
13
|
+
|
14
|
+
%w[
|
15
|
+
service_error
|
16
|
+
not_found
|
17
|
+
forbidden
|
18
|
+
bad_request
|
19
|
+
unauthorized
|
20
|
+
service_unavailable
|
21
|
+
internal_server_error
|
22
|
+
unprocessable_entity
|
23
|
+
client_error
|
24
|
+
invalid_options
|
25
|
+
required_params
|
26
|
+
unknown_value
|
27
|
+
].each do |error|
|
28
|
+
require "vibe/error/#{error}"
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Vibe
|
2
|
+
# Raised when Vibe returns the HTTP status code 404
|
3
|
+
module Error
|
4
|
+
class ClientError < VibeError
|
5
|
+
attr_reader :problem, :summary, :resolution
|
6
|
+
|
7
|
+
def initialize(message)
|
8
|
+
super(message)
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_message(attributes)
|
12
|
+
"\nProblem:\n #{attributes[:problem]}"+
|
13
|
+
"\nSummary:\n #{attributes[:summary]}"+
|
14
|
+
"\nResolution:\n #{attributes[:resolution]}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vibe
|
2
|
+
# Raised when invalid options are passed to a request body
|
3
|
+
module Error
|
4
|
+
class InvalidOptions < ClientError
|
5
|
+
def initialize(invalid, valid)
|
6
|
+
super(
|
7
|
+
generate_message(
|
8
|
+
:problem => "Invalid option #{invalid.keys.join(', ')} provided for this request.",
|
9
|
+
:summary => "Vibe gem checks the request parameters passed to ensure that Vibe api is not hit unnecessairly and to fail fast.",
|
10
|
+
:resolution => "Valid options are: #{valid.join(', ')}, make sure these are the ones you are using"
|
11
|
+
)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end # Error
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vibe
|
2
|
+
# Raised when invalid options are passed to a request body
|
3
|
+
module Error
|
4
|
+
class RequiredParams < ClientError
|
5
|
+
def initialize(provided, required)
|
6
|
+
super(
|
7
|
+
generate_message(
|
8
|
+
:problem => "Missing required parameters: #{provided.keys.join(', ')} provided for this request.",
|
9
|
+
:summary => "Vibe gem checks the request parameters passed to ensure that Vibe api is not hit unnecessairly and to fail fast.",
|
10
|
+
:resolution => "Required parameters are: #{required.join(', ')}, make sure these are the ones you are using"
|
11
|
+
)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end # Error
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Vibe
|
2
|
+
# Raised when Vibe returns any of the HTTP status codes
|
3
|
+
module Error
|
4
|
+
class ServiceError < VibeError
|
5
|
+
attr_accessor :http_headers
|
6
|
+
|
7
|
+
def initialize(env)
|
8
|
+
super(generate_message(env))
|
9
|
+
@http_headers = env[:response_headers]
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate_message(env)
|
13
|
+
if ENV['DEBUG']
|
14
|
+
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]} #{env[:body]}"
|
15
|
+
else
|
16
|
+
env[:body]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end # Error
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vibe
|
2
|
+
# Raised when invalid options are passed to a request body
|
3
|
+
module Error
|
4
|
+
class UnknownValue < ClientError
|
5
|
+
def initialize(key, value, permitted)
|
6
|
+
super(
|
7
|
+
generate_message(
|
8
|
+
:problem => "Wrong value of '#{value}' for the parameter: #{key} provided for this request.",
|
9
|
+
:summary => "Vibe gem checks the request parameters passed to ensure that Vibe api is not hit unnecessairly and fails fast.",
|
10
|
+
:resolution => "Permitted values are: #{permitted}, make sure these are the ones you are using"
|
11
|
+
)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end # Error
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vibe
|
2
|
+
# Raised when passed parameters are missing or contain wrong values.
|
3
|
+
module Error
|
4
|
+
class Validations < ClientError
|
5
|
+
def initialize(errors)
|
6
|
+
super(
|
7
|
+
generate_message(
|
8
|
+
:problem => '',
|
9
|
+
:summary => '',
|
10
|
+
:resolution => ''
|
11
|
+
)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end # Error
|
16
|
+
end
|
data/lib/vibe/request.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
|
3
|
+
module Vibe
|
4
|
+
module Request
|
5
|
+
|
6
|
+
extend Configuration
|
7
|
+
include Error
|
8
|
+
|
9
|
+
METHODS = [:get, :post, :put, :delete, :patch]
|
10
|
+
|
11
|
+
def get_request(path, params={})
|
12
|
+
request(:get, path, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def request(method, path, params)
|
16
|
+
if !METHODS.include?(method)
|
17
|
+
raise ArgumentError, "unkown http method: #{method}"
|
18
|
+
end
|
19
|
+
|
20
|
+
if !api_key
|
21
|
+
raise ClientError, 'API key need to be set'
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "EXECUTED: #{method} - #{path} with #{params}" if ENV['DEBUG']
|
25
|
+
|
26
|
+
params.merge!({:api_key => api_key, :user_agent => user_agent})
|
27
|
+
|
28
|
+
begin
|
29
|
+
puts params if ENV['DEBUG']
|
30
|
+
response = RestClient.send("#{method}", endpoint + path.gsub!(/^\//, ""), :params => params){ |response, request, result, &block|
|
31
|
+
if [301, 302, 307].include? response.code
|
32
|
+
response.follow_redirection(request, result, &block)
|
33
|
+
elsif !response.code.between?(200, 400)
|
34
|
+
if response.code == 401
|
35
|
+
resp = JSON.parse(response.body)
|
36
|
+
raise Unauthorized, {:status => response.code, :method => method, :response_headers => response.headers, :url => endpoint + path, :body => resp['status']}
|
37
|
+
elsif response.code == 403
|
38
|
+
resp = JSON.parse(response.body)
|
39
|
+
raise Forbidden, {:status => response.code, :method => method, :response_headers => response.headers, :url => endpoint + path, :body => resp['status']}
|
40
|
+
elsif response.code == 422
|
41
|
+
resp = JSON.parse(response.body)
|
42
|
+
raise UnprocessableEntity, {:status => response.code, :method => method, :response_headers => response.headers, :url => endpoint + path, :body => resp['status']}
|
43
|
+
else
|
44
|
+
raise ServiceError, {:status => response.code, :method => method, :response_headers => response.headers, :url => endpoint + path, :body => "API Returned status code #{response.code}"}
|
45
|
+
end
|
46
|
+
else
|
47
|
+
JSON.parse(response)
|
48
|
+
end
|
49
|
+
}
|
50
|
+
rescue SocketError => e
|
51
|
+
raise VibeError, 'xgcv'
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end # Request
|
56
|
+
end
|
data/lib/vibe/version.rb
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe 'client' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@keys = Vibe::Configuration::VALID_CONFIG_KEYS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'with module configuration' do
|
10
|
+
before do
|
11
|
+
Vibe.configure do |config|
|
12
|
+
@keys.each do |key|
|
13
|
+
config.send("#{key}=", key)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
Vibe.reset
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should inherit module configuration" do
|
23
|
+
api = Vibe::Client.new
|
24
|
+
@keys.each do |key|
|
25
|
+
api.send(key).must_equal key
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'with class configuration' do
|
30
|
+
before do
|
31
|
+
@config = {
|
32
|
+
:api_key => 'ak'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should override module configuration after' do
|
37
|
+
api = Vibe::Client.new
|
38
|
+
|
39
|
+
@config.each do |key, value|
|
40
|
+
api.send("#{key}=", value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe 'configuration' do
|
4
|
+
|
5
|
+
describe '.api_key' do
|
6
|
+
it 'should return default key' do
|
7
|
+
Vibe.api_key.must_equal Vibe::Configuration::DEFAULT_API_KEY
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.user_agent' do
|
12
|
+
it 'should return default user agent' do
|
13
|
+
Vibe.user_agent.must_equal Vibe::Configuration::DEFAULT_USER_AGENT
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.method' do
|
18
|
+
it 'should return default http method' do
|
19
|
+
Vibe.method.must_equal Vibe::Configuration::DEFAULT_METHOD
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
Vibe.reset
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.configure' do
|
28
|
+
Vibe::Configuration::VALID_CONFIG_KEYS.each do |key|
|
29
|
+
it "should set the #{key}" do
|
30
|
+
Vibe.configure do |config|
|
31
|
+
config.send("#{key}=", key)
|
32
|
+
Vibe.send(key).must_equal key
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Vibe::Configuration::VALID_CONFIG_KEYS.each do |key|
|
39
|
+
describe ".#{key}" do
|
40
|
+
it 'should return the default value' do
|
41
|
+
Vibe.send(key).must_equal Vibe::Configuration.const_get("DEFAULT_#{key.upcase}")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/vibe.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vibe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vibe"
|
8
|
+
spec.version = Vibe::VERSION
|
9
|
+
spec.authors = ["Amal Francis"]
|
10
|
+
spec.email = ["amalfra@gmail.com"]
|
11
|
+
spec.summary = %q{A Ruby wrapper for the Vibe REST API}
|
12
|
+
spec.description = %q{A Ruby wrapper for the Vibe REST API}
|
13
|
+
spec.homepage = "https://github.com/amalfra/vibe"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rest-client", "~> 1.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vibe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amal Francis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: A Ruby wrapper for the Vibe REST API
|
56
|
+
email:
|
57
|
+
- amalfra@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/vibe.rb
|
69
|
+
- lib/vibe/client.rb
|
70
|
+
- lib/vibe/configuration.rb
|
71
|
+
- lib/vibe/error.rb
|
72
|
+
- lib/vibe/error/bad_request.rb
|
73
|
+
- lib/vibe/error/client_error.rb
|
74
|
+
- lib/vibe/error/forbidden.rb
|
75
|
+
- lib/vibe/error/internal_server_error.rb
|
76
|
+
- lib/vibe/error/invalid_options.rb
|
77
|
+
- lib/vibe/error/not_found.rb
|
78
|
+
- lib/vibe/error/required_params.rb
|
79
|
+
- lib/vibe/error/service_error.rb
|
80
|
+
- lib/vibe/error/service_unavailable.rb
|
81
|
+
- lib/vibe/error/unauthorized.rb
|
82
|
+
- lib/vibe/error/unknown_value.rb
|
83
|
+
- lib/vibe/error/unprocessable_entity.rb
|
84
|
+
- lib/vibe/error/validations.rb
|
85
|
+
- lib/vibe/request.rb
|
86
|
+
- lib/vibe/version.rb
|
87
|
+
- test/helper.rb
|
88
|
+
- test/vibe/client_test.rb
|
89
|
+
- test/vibe/configuration_test.rb
|
90
|
+
- test/vibe/vibe_test.rb
|
91
|
+
- vibe.gemspec
|
92
|
+
homepage: https://github.com/amalfra/vibe
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.2.2
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: A Ruby wrapper for the Vibe REST API
|
116
|
+
test_files:
|
117
|
+
- test/helper.rb
|
118
|
+
- test/vibe/client_test.rb
|
119
|
+
- test/vibe/configuration_test.rb
|
120
|
+
- test/vibe/vibe_test.rb
|