sinatra-rest-base 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/rest_base.rb +5 -0
- data/lib/{rest → rest_base}/application.rb +3 -3
- data/lib/{rest → rest_base}/application_helper.rb +1 -1
- data/lib/rest_base/authentication.rb +7 -0
- data/lib/{rest → rest_base}/authentication/authentication_base.rb +1 -1
- data/lib/{rest → rest_base}/authentication/basic_authentication.rb +1 -1
- data/lib/{rest → rest_base}/error_handeling.rb +3 -3
- data/lib/{rest → rest_base}/error_status_handeling.rb +1 -1
- data/lib/rest_base/exceptions.rb +6 -0
- data/lib/{rest → rest_base}/exceptions/invalid_request.rb +1 -1
- data/lib/rest_base/version.rb +3 -0
- data/sinatra-rest-base.gemspec +2 -2
- data/spec/fixtures/test_application.rb +3 -3
- data/spec/fixtures/test_end_points.rb +1 -1
- data/spec/fixtures/test_errors_end_points.rb +2 -2
- data/spec/lib/{rest → rest_base}/application_spec.rb +1 -1
- data/spec/lib/{rest → rest_base}/authentication/authentication_base_spec.rb +2 -2
- data/spec/lib/{rest → rest_base}/authentication/basic_authentication_spec.rb +5 -5
- data/spec/lib/{rest → rest_base}/error_handeling_spec.rb +1 -1
- data/spec/lib/{rest → rest_base}/error_status_handeling_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +24 -24
- data/lib/rest.rb +0 -5
- data/lib/rest/authentication.rb +0 -7
- data/lib/rest/exceptions.rb +0 -6
- data/lib/rest/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57d73eb788f53e9e785801ac3bc484fa3f64ddca
|
4
|
+
data.tar.gz: df2f1dc92f930e864c202809ac7015f9bf6dafca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebaf5fdcef53ed2b83f9d10e2709ddbefb43c9ad2d7a72890f3c5a353badcb8bac117eb77eaedc2495494d1549b1f929a18af8fab0be13e985c13cd27c315978
|
7
|
+
data.tar.gz: e25c7baf2ae4b255d08976a2b12d663b814821dfb5c8408601706c2d7898f86faa4ba8bf96003004eadf433e6017091c37ea010fc952bfc1bf6a0b0261e065c7
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Rest
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/sinatra-rest-base)
|
4
|
+
|
5
|
+
Core base for quick configuration of Sinatra for RESTful Services
|
4
6
|
|
5
7
|
#### What Does the Core Cover
|
6
8
|
|
data/lib/rest_base.rb
ADDED
@@ -2,9 +2,9 @@ require 'sinatra/base'
|
|
2
2
|
require 'json'
|
3
3
|
require 'active_support'
|
4
4
|
require 'active_support/core_ext/hash'
|
5
|
-
require '
|
5
|
+
require 'rest_base/authentication'
|
6
6
|
|
7
|
-
module
|
7
|
+
module RestBase
|
8
8
|
class Application < Sinatra::Base
|
9
9
|
attr_reader :request_body
|
10
10
|
attr_reader :request_version
|
@@ -14,7 +14,7 @@ module Rest
|
|
14
14
|
disable :raise_errors
|
15
15
|
disable :show_exceptions
|
16
16
|
set :api_version, 1
|
17
|
-
set :authentication,
|
17
|
+
set :authentication, RestBase::Authentication::BasicAuthentication.new([])
|
18
18
|
disable :header_versioning
|
19
19
|
end
|
20
20
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require '
|
2
|
+
require 'rest_base/exceptions'
|
3
3
|
|
4
|
-
module
|
4
|
+
module RestBase
|
5
5
|
class Application < Sinatra::Base
|
6
|
-
error
|
6
|
+
error RestBase::Exceptions::InvalidRequest do
|
7
7
|
cur_error = env["sinatra.error"]
|
8
8
|
errors = [cur_error.message]
|
9
9
|
|
data/sinatra-rest-base.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'rest_base/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "sinatra-rest-base"
|
8
|
-
spec.version =
|
8
|
+
spec.version = RestBase::VERSION
|
9
9
|
spec.authors = ["bmills"]
|
10
10
|
spec.email = ["brandon.mills@careerbuilder.com"]
|
11
11
|
spec.summary = %q{Base class for quickly setting up RESTful services through Sinatra.}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module RestBase
|
2
2
|
module Test
|
3
|
-
class TestApplication <
|
3
|
+
class TestApplication < RestBase::Application
|
4
4
|
configure do
|
5
5
|
enable :raise_errors
|
6
|
-
set :authentication,
|
6
|
+
set :authentication, RestBase::Authentication::BasicAuthentication.new(['key1', 'key2'])
|
7
7
|
enable :header_versioning
|
8
8
|
end
|
9
9
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module RestBase
|
2
2
|
module Test
|
3
3
|
class TestApplication
|
4
4
|
get '/invalid_request', :version => 1 do
|
@@ -7,7 +7,7 @@ module Rest
|
|
7
7
|
:param2 => "Must be an Integer"
|
8
8
|
}
|
9
9
|
|
10
|
-
raise
|
10
|
+
raise RestBase::Exceptions::InvalidRequest.new(param_errors)
|
11
11
|
end
|
12
12
|
|
13
13
|
get '/unauthorized', :version => 1 do
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RestBase::Authentication::AuthenticationBase do
|
4
4
|
describe :authorized? do
|
5
5
|
it "should always be true" do
|
6
|
-
target =
|
6
|
+
target = RestBase::Authentication::AuthenticationBase.new
|
7
7
|
|
8
8
|
expect(target.authorized?(nil, 'key')).to be_truthy
|
9
9
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RestBase::Authentication::BasicAuthentication do
|
4
4
|
describe :initialize do
|
5
5
|
it "should initialize with valid keys" do
|
6
6
|
expected_keys = ['key1', 'key2']
|
7
|
-
target =
|
7
|
+
target = RestBase::Authentication::BasicAuthentication.new(expected_keys)
|
8
8
|
|
9
9
|
expect(target.instance_variable_get(:@valid_keys)).to eq(expected_keys)
|
10
10
|
end
|
@@ -12,17 +12,17 @@ describe Rest::Authentication::BasicAuthentication do
|
|
12
12
|
|
13
13
|
describe :authorized? do
|
14
14
|
it "should authorized if empty valid array" do
|
15
|
-
target =
|
15
|
+
target = RestBase::Authentication::BasicAuthentication.new([])
|
16
16
|
expect(target.authorized?(nil, 'key')).to be_truthy
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should authorize the given key" do
|
20
|
-
target =
|
20
|
+
target = RestBase::Authentication::BasicAuthentication.new(['key1', 'key2'])
|
21
21
|
expect(target.authorized?(nil, 'key1')).to be_truthy
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should authorize the given key" do
|
25
|
-
target =
|
25
|
+
target = RestBase::Authentication::BasicAuthentication.new(['key1', 'key2'])
|
26
26
|
expect(target.authorized?(nil,'key')).to_not be_truthy
|
27
27
|
end
|
28
28
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,14 +6,14 @@ SimpleCov.start do
|
|
6
6
|
add_filter '/spec/'
|
7
7
|
end
|
8
8
|
|
9
|
-
require '
|
9
|
+
require 'rest_base'
|
10
10
|
Dir[File.dirname(__FILE__) + '/fixtures/**/*.rb'].each {|file| require file }
|
11
11
|
|
12
12
|
ENV['RACK_ENV'] = 'test'
|
13
13
|
|
14
14
|
module RSpecMixin
|
15
15
|
include Rack::Test::Methods
|
16
|
-
def app()
|
16
|
+
def app() RestBase::Test::TestApplication end
|
17
17
|
end
|
18
18
|
|
19
19
|
RSpec.configure do |conf|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-rest-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bmills
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -162,26 +162,26 @@ files:
|
|
162
162
|
- LICENSE.txt
|
163
163
|
- README.md
|
164
164
|
- Rakefile
|
165
|
-
- lib/
|
166
|
-
- lib/
|
167
|
-
- lib/
|
168
|
-
- lib/
|
169
|
-
- lib/
|
170
|
-
- lib/
|
171
|
-
- lib/
|
172
|
-
- lib/
|
173
|
-
- lib/
|
174
|
-
- lib/
|
175
|
-
- lib/
|
165
|
+
- lib/rest_base.rb
|
166
|
+
- lib/rest_base/application.rb
|
167
|
+
- lib/rest_base/application_helper.rb
|
168
|
+
- lib/rest_base/authentication.rb
|
169
|
+
- lib/rest_base/authentication/authentication_base.rb
|
170
|
+
- lib/rest_base/authentication/basic_authentication.rb
|
171
|
+
- lib/rest_base/error_handeling.rb
|
172
|
+
- lib/rest_base/error_status_handeling.rb
|
173
|
+
- lib/rest_base/exceptions.rb
|
174
|
+
- lib/rest_base/exceptions/invalid_request.rb
|
175
|
+
- lib/rest_base/version.rb
|
176
176
|
- sinatra-rest-base.gemspec
|
177
177
|
- spec/fixtures/test_application.rb
|
178
178
|
- spec/fixtures/test_end_points.rb
|
179
179
|
- spec/fixtures/test_errors_end_points.rb
|
180
|
-
- spec/lib/
|
181
|
-
- spec/lib/
|
182
|
-
- spec/lib/
|
183
|
-
- spec/lib/
|
184
|
-
- spec/lib/
|
180
|
+
- spec/lib/rest_base/application_spec.rb
|
181
|
+
- spec/lib/rest_base/authentication/authentication_base_spec.rb
|
182
|
+
- spec/lib/rest_base/authentication/basic_authentication_spec.rb
|
183
|
+
- spec/lib/rest_base/error_handeling_spec.rb
|
184
|
+
- spec/lib/rest_base/error_status_handeling_spec.rb
|
185
185
|
- spec/spec_helper.rb
|
186
186
|
homepage: ''
|
187
187
|
licenses:
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
205
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.
|
206
|
+
rubygems_version: 2.2.2
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: Base class for quickly setting up RESTful services through Sinatra.
|
@@ -211,10 +211,10 @@ test_files:
|
|
211
211
|
- spec/fixtures/test_application.rb
|
212
212
|
- spec/fixtures/test_end_points.rb
|
213
213
|
- spec/fixtures/test_errors_end_points.rb
|
214
|
-
- spec/lib/
|
215
|
-
- spec/lib/
|
216
|
-
- spec/lib/
|
217
|
-
- spec/lib/
|
218
|
-
- spec/lib/
|
214
|
+
- spec/lib/rest_base/application_spec.rb
|
215
|
+
- spec/lib/rest_base/authentication/authentication_base_spec.rb
|
216
|
+
- spec/lib/rest_base/authentication/basic_authentication_spec.rb
|
217
|
+
- spec/lib/rest_base/error_handeling_spec.rb
|
218
|
+
- spec/lib/rest_base/error_status_handeling_spec.rb
|
219
219
|
- spec/spec_helper.rb
|
220
220
|
has_rdoc:
|
data/lib/rest.rb
DELETED
data/lib/rest/authentication.rb
DELETED
data/lib/rest/exceptions.rb
DELETED
data/lib/rest/version.rb
DELETED