apitools-middleware 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e96c4cfd9aeb2cae572d5df9879309971f594a12
4
- data.tar.gz: 9cd9ee6b6618e0d3e415fc8cf5c9e2c7ba02c94a
3
+ metadata.gz: 98fca66c7e5d7143c74e114003256d121e876bc4
4
+ data.tar.gz: 4b200fbe2463c067dcb67cc6895a64efb5985c2f
5
5
  SHA512:
6
- metadata.gz: 23d9f0fbe3b2e846b16d977dae035ea4e1e0f2c4862527d4589e9bd7f4f65a57087a678effd71500b34913bd7bfa77e9f8e681eb058728a134859b43587696fc
7
- data.tar.gz: c60111fdf6d7ca2a58fd30520b08357c4a0f993cce0da3e426830c3dcc86ca305885ba9af82504da9f28ee85511af39b8298b4f651de6fab6bf96a61cff3f53a
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, :manifest_path
11
+ attr_reader :repo
12
12
 
13
13
  extend Forwardable
14
- def_delegators :manifest, :name, :description, :author, :endpoints, :files
14
+ def_delegators :manifest, :name, :description, :author, :endpoints
15
15
 
16
16
  def initialize(repo, path)
17
17
  @repo = repo
18
- pathname = Pathname(path)
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 @manifest_path
80
+ content @manifest_file
69
81
  end
70
82
 
71
83
  def load_code
@@ -1,5 +1,5 @@
1
1
  module Apitools
2
2
  module Middleware
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
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(path.dirname.to_s)
8
+ expect(spec.path).to eq('some')
9
9
  end
10
10
 
11
11
  it 'remembers manifest from path' do
12
- expect(spec.manifest_path).to eq(path.basename)
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
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apitools-middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Cichra