safie 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +15 -2
- data/VERSION +1 -1
- data/lib/safie/access_token.rb +1 -1
- data/lib/safie/client.rb +2 -2
- data/lib/safie/exception.rb +39 -0
- data/lib/safie.rb +8 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76986f81ae83e04ed006e9df4d27c6d29c41bf368e11906338aa90d4a31854a9
|
4
|
+
data.tar.gz: 3a29d0eb9d29e06e624e6d7870f9e2f66f637ff43df9fcf9854cd1e819ac07a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cb5418f73a157d9da09905fdccd235c067ec97ee0d32be68df5ee4eb0975204f8ae1a5aaa7b6c687a2c3976f87fe5037a19f730aee57fe015a493f13b7c373b
|
7
|
+
data.tar.gz: e088cd677feb04ed1478d9cf31861b582ecb2b93bb4cd5e631d98336fb2c44b627b1091ef7d2f04a107c0e4d1b44e92568fd3e1f6b42eedfd8acd26fc7855b4d
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nov/safie.
|
36
36
|
|
37
37
|
## License
|
38
38
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
+
require 'rspec/core/rake_task'
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
7
|
+
namespace :coverage do
|
8
|
+
desc 'Open coverage report'
|
9
|
+
task :report do
|
10
|
+
require 'simplecov'
|
11
|
+
`open "#{File.join SimpleCov.coverage_path, 'index.html'}"`
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
task :spec do
|
16
|
+
Rake::Task[:'coverage:report'].invoke unless ENV['TRAVIS_RUBY_VERSION']
|
17
|
+
end
|
18
|
+
|
6
19
|
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/safie/access_token.rb
CHANGED
data/lib/safie/client.rb
CHANGED
@@ -4,8 +4,8 @@ module Safie
|
|
4
4
|
|
5
5
|
def initialize(attributes)
|
6
6
|
attributes_with_default = {
|
7
|
-
authorization_endpoint:
|
8
|
-
token_endpoint:
|
7
|
+
authorization_endpoint: ENDPOINTS[:authorization],
|
8
|
+
token_endpoint: ENDPOINTS[:token]
|
9
9
|
}.merge(attributes)
|
10
10
|
super attributes_with_default
|
11
11
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Safie
|
2
|
+
class Exception < StandardError; end
|
3
|
+
|
4
|
+
class ValidationFailed < Exception
|
5
|
+
attr_reader :object
|
6
|
+
|
7
|
+
def initialize(object)
|
8
|
+
super object.errors.full_messages.to_sentence
|
9
|
+
@object = object
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class HttpError < Exception
|
14
|
+
attr_accessor :status, :response
|
15
|
+
def initialize(status, message = nil, response = nil)
|
16
|
+
super message
|
17
|
+
@status = status
|
18
|
+
@response = response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class BadRequest < HttpError
|
23
|
+
def initialize(message = nil, response = nil)
|
24
|
+
super 400, message, response
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Unauthorized < HttpError
|
29
|
+
def initialize(message = nil, response = nil)
|
30
|
+
super 401, message, response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Forbidden < HttpError
|
35
|
+
def initialize(message = nil, response = nil)
|
36
|
+
super 403, message, response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/safie.rb
CHANGED
@@ -3,8 +3,13 @@ require 'rack/oauth2'
|
|
3
3
|
module Safie
|
4
4
|
ISSUER = 'https://app.safie.link'
|
5
5
|
DEFAULT_SCOPE = :use
|
6
|
-
|
7
|
-
|
6
|
+
ENDPOINTS = {
|
7
|
+
authorization: File.join(ISSUER, '/auth/authorize'),
|
8
|
+
token: File.join(ISSUER, '/auth/token'),
|
9
|
+
token_info: File.join(ISSUER, '/auth/tokeninfo')
|
10
|
+
}
|
11
|
+
VERSION = File.read(
|
12
|
+
File.join(File.dirname(__FILE__), '../VERSION')
|
8
13
|
).chomp
|
9
14
|
|
10
15
|
def self.logger
|
@@ -50,5 +55,6 @@ module Safie
|
|
50
55
|
self.debugging = false
|
51
56
|
end
|
52
57
|
|
58
|
+
require 'safie/exception'
|
53
59
|
require 'safie/client'
|
54
60
|
require 'safie/access_token'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/safie.rb
|
129
129
|
- lib/safie/access_token.rb
|
130
130
|
- lib/safie/client.rb
|
131
|
+
- lib/safie/exception.rb
|
131
132
|
- safie.gemspec
|
132
133
|
homepage: https://github.com/nov/safie
|
133
134
|
licenses:
|