apitools-middleware 0.0.3 → 0.0.4
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/lib/apitools/middleware/spec.rb +19 -7
- data/lib/apitools/middleware/version.rb +1 -1
- data/spec/spec_spec.rb +14 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98fca66c7e5d7143c74e114003256d121e876bc4
|
4
|
+
data.tar.gz: 4b200fbe2463c067dcb67cc6895a64efb5985c2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ec6095cdd19ac4a64f58b802b809c50bb55eee7a2de0ebf862c49b57b78779b078cd87d565e73e262ff962f758763766fc7ecf3d098a62dc3b03f746afbe5c8
|
7
|
+
data.tar.gz: 1858a0c45590a24ec7e9d2ee22ebe645a09202c5d998db493d8dfe6b75a32e8e611bb4655de79d23fbb558e91e570694b6a03882243d13bb226d75928ba8ca18
|
@@ -6,18 +6,16 @@ require 'apitools/middleware/manifest'
|
|
6
6
|
module Apitools
|
7
7
|
module Middleware
|
8
8
|
class Spec
|
9
|
-
MANIFEST_FILE = 'apitools.json' # should be apitools.json
|
9
|
+
MANIFEST_FILE = Pathname('apitools.json') # should be apitools.json
|
10
10
|
|
11
|
-
attr_reader :repo
|
11
|
+
attr_reader :repo
|
12
12
|
|
13
13
|
extend Forwardable
|
14
|
-
def_delegators :manifest, :name, :description, :author, :endpoints
|
14
|
+
def_delegators :manifest, :name, :description, :author, :endpoints
|
15
15
|
|
16
16
|
def initialize(repo, path)
|
17
17
|
@repo = repo
|
18
|
-
|
19
|
-
@path = pathname.dirname
|
20
|
-
@manifest_path = pathname.basename || MANIFEST_FILE
|
18
|
+
@path, @manifest_file = extract_path_and_manifest(path)
|
21
19
|
end
|
22
20
|
|
23
21
|
def manifest=(json)
|
@@ -36,6 +34,10 @@ module Apitools
|
|
36
34
|
@path.to_s
|
37
35
|
end
|
38
36
|
|
37
|
+
def manifest_file
|
38
|
+
@manifest_file.to_s
|
39
|
+
end
|
40
|
+
|
39
41
|
def endpoint
|
40
42
|
Array(endpoints).first
|
41
43
|
end
|
@@ -58,6 +60,16 @@ module Apitools
|
|
58
60
|
lua_files.none?{ |file| !file || file.nil? || file.empty? }
|
59
61
|
end
|
60
62
|
|
63
|
+
def extract_path_and_manifest(path)
|
64
|
+
pathname = Pathname(path)
|
65
|
+
|
66
|
+
if pathname.extname.empty? # no manifest at the end
|
67
|
+
[pathname, MANIFEST_FILE]
|
68
|
+
else
|
69
|
+
[pathname.dirname, pathname.basename]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
61
73
|
protected
|
62
74
|
|
63
75
|
def content(path)
|
@@ -65,7 +77,7 @@ module Apitools
|
|
65
77
|
end
|
66
78
|
|
67
79
|
def load_manifest
|
68
|
-
content @
|
80
|
+
content @manifest_file
|
69
81
|
end
|
70
82
|
|
71
83
|
def load_code
|
data/spec/spec_spec.rb
CHANGED
@@ -5,11 +5,11 @@ describe Apitools::Middleware::Spec do
|
|
5
5
|
subject(:spec) { described_class.new(repo, path.to_s) }
|
6
6
|
|
7
7
|
it 'trims path to just folder' do
|
8
|
-
expect(spec.path).to eq(
|
8
|
+
expect(spec.path).to eq('some')
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'remembers manifest from path' do
|
12
|
-
expect(spec.
|
12
|
+
expect(spec.manifest_file).to eq('path.json')
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'allows setting manifest as json' do
|
@@ -17,6 +17,18 @@ describe Apitools::Middleware::Spec do
|
|
17
17
|
expect(spec.manifest).to eq(name: 'manifest')
|
18
18
|
end
|
19
19
|
|
20
|
+
context 'path without manifest' do
|
21
|
+
let(:path) { Pathname('middleware/some-middleware') }
|
22
|
+
|
23
|
+
it 'uses default manifest name' do
|
24
|
+
expect(spec.manifest_file).to eq('apitools.json')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'uses path as a path' do
|
28
|
+
expect(spec.path).to eq('middleware/some-middleware')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
20
32
|
context 'with valid manifest' do
|
21
33
|
let(:manifest) do
|
22
34
|
{
|