sliver 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/Gemfile +10 -0
- data/README.md +1 -1
- data/lib/sliver.rb +1 -1
- data/lib/sliver/action.rb +1 -1
- data/lib/sliver/api.rb +2 -3
- data/lib/sliver/endpoints.rb +1 -1
- data/lib/sliver/hook.rb +4 -0
- data/lib/sliver/path.rb +10 -5
- data/lib/sliver/runner.rb +1 -5
- data/sliver.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe4e83efcb34646cfb507ccc74056fb402265f77
|
4
|
+
data.tar.gz: f52c128bb56392cd35d97940845c17e1f23fa1cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9b69f9c741d49387772a373cf6db8eab0dc39fcd9f49df34aa21b86cd54e344434c3d1e2b28f612cdc835fc2035643f73d9fd4fb5784924a551a5ed04a64832
|
7
|
+
data.tar.gz: bb79a247fddbe76eacc5cb0b07a6fe9ed681cd9ad96a318ccc6ab70fc2e2aa4f21e4c95f07de5a9e08ecc2118571b9685d9eff437c303e151fa31787a5ae0e26
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/sliver.rb
CHANGED
data/lib/sliver/action.rb
CHANGED
data/lib/sliver/api.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
class Sliver::API
|
2
|
-
|
3
|
-
NOT_FOUND = lambda { |environment| NOT_FOUND_RESPONSE }
|
2
|
+
NOT_FOUND = [404, {'X-Cascade' => 'pass'}, ['Not Found']].freeze
|
4
3
|
|
5
4
|
def initialize(&block)
|
6
5
|
@endpoints = Sliver::Endpoints.new
|
@@ -11,7 +10,7 @@ class Sliver::API
|
|
11
10
|
def call(environment)
|
12
11
|
endpoint = endpoints.find environment
|
13
12
|
|
14
|
-
endpoint.nil? ? NOT_FOUND
|
13
|
+
endpoint.nil? ? NOT_FOUND : invoke(endpoint, environment)
|
15
14
|
end
|
16
15
|
|
17
16
|
def invoke(endpoint, environment)
|
data/lib/sliver/endpoints.rb
CHANGED
data/lib/sliver/hook.rb
CHANGED
data/lib/sliver/path.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
class Sliver::Path
|
2
|
+
METHOD_KEY = "REQUEST_METHOD".freeze
|
3
|
+
PATH_KEY = "PATH_INFO".freeze
|
4
|
+
EMPTY_PATH = "".freeze
|
5
|
+
ROOT_PATH = "/".freeze
|
6
|
+
|
2
7
|
attr_reader :http_method, :string
|
3
8
|
|
4
9
|
def initialize(http_method, string)
|
@@ -11,12 +16,12 @@ class Sliver::Path
|
|
11
16
|
end
|
12
17
|
|
13
18
|
def hash
|
14
|
-
"#{http_method} #{string}".hash
|
19
|
+
@hash ||= "#{http_method} #{string}".hash
|
15
20
|
end
|
16
21
|
|
17
22
|
def matches?(environment)
|
18
|
-
method = environment[
|
19
|
-
path = normalised_path environment[
|
23
|
+
method = environment[METHOD_KEY]
|
24
|
+
path = normalised_path environment[PATH_KEY]
|
20
25
|
|
21
26
|
http_method == method && path[string_to_regexp]
|
22
27
|
end
|
@@ -24,7 +29,7 @@ class Sliver::Path
|
|
24
29
|
def to_params(environment)
|
25
30
|
return {} unless matches?(environment)
|
26
31
|
|
27
|
-
path = normalised_path environment[
|
32
|
+
path = normalised_path environment[PATH_KEY]
|
28
33
|
values = path.scan(string_to_regexp).flatten
|
29
34
|
|
30
35
|
string_keys.each_with_index.inject({}) do |hash, (key, index)|
|
@@ -36,7 +41,7 @@ class Sliver::Path
|
|
36
41
|
private
|
37
42
|
|
38
43
|
def normalised_path(string)
|
39
|
-
string ==
|
44
|
+
string == EMPTY_PATH ? ROOT_PATH : string
|
40
45
|
end
|
41
46
|
|
42
47
|
def string_keys
|
data/lib/sliver/runner.rb
CHANGED
@@ -45,11 +45,7 @@ class Sliver::Runner
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def post_process
|
48
|
-
processors.each { |processor| processor.call }
|
49
|
-
end
|
50
|
-
|
51
|
-
def processors
|
52
|
-
klass.processors.collect { |klass| klass.new action, response }
|
48
|
+
klass.processors.each { |processor| processor.call action, response }
|
53
49
|
end
|
54
50
|
|
55
51
|
def response
|
data/sliver.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = 'sliver'
|
4
|
-
spec.version = '0.2.
|
4
|
+
spec.version = '0.2.4'
|
5
5
|
spec.authors = ['Pat Allan']
|
6
6
|
spec.email = ['pat@freelancing-gods.com']
|
7
7
|
spec.summary = %q{Lightweight, simple Rack APIs}
|
@@ -17,5 +17,5 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.add_runtime_dependency 'rack', '>= 1.5.2'
|
18
18
|
|
19
19
|
spec.add_development_dependency 'rack-test', '>= 0.6.2'
|
20
|
-
spec.add_development_dependency 'rspec', '>= 3.
|
20
|
+
spec.add_development_dependency 'rspec', '>= 3.6.0'
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sliver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.6.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
|
-
version: 3.
|
54
|
+
version: 3.6.0
|
55
55
|
description: A super simple, object-focused extendable Rack API.
|
56
56
|
email:
|
57
57
|
- pat@freelancing-gods.com
|