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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89bfb242b0372b3c67a4ba96057127cee6c08274
4
- data.tar.gz: dbacc54a48e877ce1d878f7db807d898efe52322
3
+ metadata.gz: 57d73eb788f53e9e785801ac3bc484fa3f64ddca
4
+ data.tar.gz: df2f1dc92f930e864c202809ac7015f9bf6dafca
5
5
  SHA512:
6
- metadata.gz: 74be626356f30e39d18501da1a4393819ba53cb020863cc62d42603b59f6c156e50a8e7cf2372fc3fd35f03b2e2c0c86a4d845b7983400e52673cb6da099e36a
7
- data.tar.gz: 771e4dfa2b1ba37ddf90e1d57704a1d4dc5a3adedeb2fef4cf865b6616dc9971bdf06cab04d86b3ac51c0a531085e87f4aea47f5df4a4542c661b905dc98e88c
6
+ metadata.gz: ebaf5fdcef53ed2b83f9d10e2709ddbefb43c9ad2d7a72890f3c5a353badcb8bac117eb77eaedc2495494d1549b1f929a18af8fab0be13e985c13cd27c315978
7
+ data.tar.gz: e25c7baf2ae4b255d08976a2b12d663b814821dfb5c8408601706c2d7898f86faa4ba8bf96003004eadf433e6017091c37ea010fc952bfc1bf6a0b0261e065c7
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Rest
2
2
 
3
- Core base classes for quick configuration of Sinatra for RESTful Services
3
+ [![Gem Version](https://badge.fury.io/rb/sinatra-rest-base.svg)](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
@@ -0,0 +1,5 @@
1
+ module RestBase
2
+
3
+ end
4
+
5
+ Gem.find_files('rest_base/*.rb').each { |path| require path }
@@ -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 'rest/authentication'
5
+ require 'rest_base/authentication'
6
6
 
7
- module Rest
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, Rest::Authentication::BasicAuthentication.new([])
17
+ set :authentication, RestBase::Authentication::BasicAuthentication.new([])
18
18
  disable :header_versioning
19
19
  end
20
20
 
@@ -1,4 +1,4 @@
1
- module Rest
1
+ module RestBase
2
2
  class Application < Sinatra::Base
3
3
  def authenticated?
4
4
  authorized = true
@@ -0,0 +1,7 @@
1
+ module RestBase
2
+ module Authentication
3
+
4
+ end
5
+ end
6
+
7
+ Gem.find_files('rest_base/authentication/*.rb').each { |path| require path }
@@ -1,4 +1,4 @@
1
- module Rest
1
+ module RestBase
2
2
  module Authentication
3
3
  class AuthenticationBase
4
4
  def authorized?(request, key)
@@ -1,4 +1,4 @@
1
- module Rest
1
+ module RestBase
2
2
  module Authentication
3
3
  class BasicAuthentication < AuthenticationBase
4
4
  def initialize(keys)
@@ -1,9 +1,9 @@
1
1
  require 'sinatra/base'
2
- require 'rest/exceptions'
2
+ require 'rest_base/exceptions'
3
3
 
4
- module Rest
4
+ module RestBase
5
5
  class Application < Sinatra::Base
6
- error Rest::Exceptions::InvalidRequest do
6
+ error RestBase::Exceptions::InvalidRequest do
7
7
  cur_error = env["sinatra.error"]
8
8
  errors = [cur_error.message]
9
9
 
@@ -1,4 +1,4 @@
1
- module Rest
1
+ module RestBase
2
2
  class Application < Sinatra::Base
3
3
  not_found do
4
4
  response.body = 'Endpoint not found'
@@ -0,0 +1,6 @@
1
+ module RestBase
2
+ module Exceptions
3
+ end
4
+ end
5
+
6
+ Gem.find_files('rest_base/exceptions/*.rb').each { |path| require path }
@@ -1,4 +1,4 @@
1
- module Rest
1
+ module RestBase
2
2
  module Exceptions
3
3
  class InvalidRequest < StandardError
4
4
  attr_reader :invalid_params
@@ -0,0 +1,3 @@
1
+ module RestBase
2
+ VERSION = "1.0.0"
3
+ end
@@ -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 'rest/version'
4
+ require 'rest_base/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "sinatra-rest-base"
8
- spec.version = Rest::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 Rest
1
+ module RestBase
2
2
  module Test
3
- class TestApplication < Rest::Application
3
+ class TestApplication < RestBase::Application
4
4
  configure do
5
5
  enable :raise_errors
6
- set :authentication, Rest::Authentication::BasicAuthentication.new(['key1', 'key2'])
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 Rest
1
+ module RestBase
2
2
  module Test
3
3
  class TestApplication
4
4
  get '/', :version => 1 do
@@ -1,4 +1,4 @@
1
- module Rest
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 Rest::Exceptions::InvalidRequest.new(param_errors)
10
+ raise RestBase::Exceptions::InvalidRequest.new(param_errors)
11
11
  end
12
12
 
13
13
  get '/unauthorized', :version => 1 do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rest::Application do
3
+ describe RestBase::Application do
4
4
  before(:each) do
5
5
  @headers = { 'HTTP_AUTHORIZATION' => 'key1' }
6
6
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rest::Authentication::AuthenticationBase do
3
+ describe RestBase::Authentication::AuthenticationBase do
4
4
  describe :authorized? do
5
5
  it "should always be true" do
6
- target = Rest::Authentication::AuthenticationBase.new
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 Rest::Authentication::BasicAuthentication do
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 = Rest::Authentication::BasicAuthentication.new(expected_keys)
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 = Rest::Authentication::BasicAuthentication.new([])
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 = Rest::Authentication::BasicAuthentication.new(['key1', 'key2'])
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 = Rest::Authentication::BasicAuthentication.new(['key1', 'key2'])
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
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rest::Application do
3
+ describe RestBase::Application do
4
4
  before(:each) do
5
5
  @headers = { 'HTTP_AUTHORIZATION' => 'key1' }
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rest::Application do
3
+ describe RestBase::Application do
4
4
  before(:each) do
5
5
  @expected_body = {
6
6
  :errors => [],
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 'rest'
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() Rest::Test::TestApplication end
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.1.1
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: 2014-11-14 00:00:00.000000000 Z
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/rest.rb
166
- - lib/rest/application.rb
167
- - lib/rest/application_helper.rb
168
- - lib/rest/authentication.rb
169
- - lib/rest/authentication/authentication_base.rb
170
- - lib/rest/authentication/basic_authentication.rb
171
- - lib/rest/error_handeling.rb
172
- - lib/rest/error_status_handeling.rb
173
- - lib/rest/exceptions.rb
174
- - lib/rest/exceptions/invalid_request.rb
175
- - lib/rest/version.rb
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/rest/application_spec.rb
181
- - spec/lib/rest/authentication/authentication_base_spec.rb
182
- - spec/lib/rest/authentication/basic_authentication_spec.rb
183
- - spec/lib/rest/error_handeling_spec.rb
184
- - spec/lib/rest/error_status_handeling_spec.rb
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.4.4
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/rest/application_spec.rb
215
- - spec/lib/rest/authentication/authentication_base_spec.rb
216
- - spec/lib/rest/authentication/basic_authentication_spec.rb
217
- - spec/lib/rest/error_handeling_spec.rb
218
- - spec/lib/rest/error_status_handeling_spec.rb
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
@@ -1,5 +0,0 @@
1
- module Rest
2
-
3
- end
4
-
5
- Gem.find_files('rest/*.rb').each { |path| require path }
@@ -1,7 +0,0 @@
1
- module Rest
2
- module Authentication
3
-
4
- end
5
- end
6
-
7
- Gem.find_files('rest/authentication/*.rb').each { |path| require path }
@@ -1,6 +0,0 @@
1
- module Rest
2
- module Exceptions
3
- end
4
- end
5
-
6
- Gem.find_files('rest/exceptions/*.rb').each { |path| require path }
data/lib/rest/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module Rest
2
- VERSION = "0.1.1"
3
- end