apitools-middleware 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Rakefile +4 -0
- data/lib/apitools/middleware/local_repository.rb +3 -0
- data/lib/apitools/middleware/spec.rb +15 -6
- data/lib/apitools/middleware/version.rb +1 -1
- data/spec/fixtures/middleware/test/apitools.json +11 -0
- data/spec/fixtures/middleware/test/test_file.lua +0 -0
- data/spec/local_repository_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/spec_spec.rb +10 -0
- data/spec/support/fixtures_support.rb +10 -0
- metadata +19 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6243d5590eae94ad4e45bb82866da87397f4907e
|
4
|
+
data.tar.gz: e1bc333f6f01bae677269a29ae0ebc584225f6ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8faf2aaac44d25379ae36b751445afdfd430868040ea1cec8668c997208c9a0cb950ea036b44018af4c7ba864f0f67c196742eff7a297bd7542a11ce72ef33a5
|
7
|
+
data.tar.gz: 6638c6569f3b54bb908ba18be18210efdf112dd50e76f4eae26cf7439af34c36aeefbde8c81991e6546c1a3a9b41018ed0088f9f76612394edd9ccde63ad0235
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'semantic'
|
3
3
|
require 'forwardable'
|
4
|
+
require 'apitools/middleware/manifest'
|
4
5
|
|
5
6
|
module Apitools
|
6
7
|
module Middleware
|
@@ -35,6 +36,10 @@ module Apitools
|
|
35
36
|
Array(endpoints).first
|
36
37
|
end
|
37
38
|
|
39
|
+
def files
|
40
|
+
Array(manifest.files)
|
41
|
+
end
|
42
|
+
|
38
43
|
def version
|
39
44
|
Semantic::Version.new(manifest.version)
|
40
45
|
rescue ArgumentError
|
@@ -43,21 +48,25 @@ module Apitools
|
|
43
48
|
|
44
49
|
def valid?
|
45
50
|
required_attributes = [name, path, author, endpoint, version, description]
|
46
|
-
required_attributes.all?
|
51
|
+
return unless required_attributes.all?
|
52
|
+
|
53
|
+
lua_files = Array(files).map { |file| content(file) }
|
54
|
+
lua_files.none?{ |file| !file || file.nil? || file.empty? }
|
47
55
|
end
|
48
56
|
|
49
57
|
protected
|
50
58
|
|
59
|
+
def content(path)
|
60
|
+
@repo.content @path.join(path)
|
61
|
+
end
|
62
|
+
|
51
63
|
def load_manifest
|
52
|
-
|
64
|
+
content @manifest_path
|
53
65
|
end
|
54
66
|
|
55
67
|
def load_code
|
56
|
-
|
57
|
-
|
58
|
-
@repo.content(@path.join(file))
|
68
|
+
content files.first
|
59
69
|
end
|
60
|
-
|
61
70
|
end
|
62
71
|
end
|
63
72
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"name": "test",
|
3
|
+
"description": "test middleware",
|
4
|
+
"files": ["test-file.lua"],
|
5
|
+
"author" : "3scale",
|
6
|
+
"email" : "apitools@apitools.com",
|
7
|
+
"github-user" : "apitools",
|
8
|
+
"version" : "1.0.0",
|
9
|
+
"categories" : ["ploting", "analytics", "metrics"],
|
10
|
+
"endpoints": ["*"]
|
11
|
+
}
|
File without changes
|
@@ -33,4 +33,12 @@ describe Apitools::Middleware::LocalRepository do
|
|
33
33
|
expect(second.manifest).not_to be_valid
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
context 'third middleware' do
|
38
|
+
let(:third) { subject.middleware.last }
|
39
|
+
|
40
|
+
it 'is not valid' do
|
41
|
+
expect(third).not_to be_valid
|
42
|
+
end
|
43
|
+
end
|
36
44
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/spec_spec.rb
CHANGED
@@ -31,6 +31,7 @@ describe Apitools::Middleware::Spec do
|
|
31
31
|
|
32
32
|
before do
|
33
33
|
spec.manifest = manifest.to_json
|
34
|
+
expect(repo).to receive(:content).with(Pathname('some/middleware.lua')).and_return('code')
|
34
35
|
end
|
35
36
|
|
36
37
|
expect_it { to be_valid }
|
@@ -43,4 +44,13 @@ describe Apitools::Middleware::Spec do
|
|
43
44
|
|
44
45
|
expect_it { to_not be_valid }
|
45
46
|
end
|
47
|
+
|
48
|
+
context 'spec with invalid file' do
|
49
|
+
before do
|
50
|
+
spec.manifest = fixture('test')
|
51
|
+
expect(repo).to receive(:content)
|
52
|
+
end
|
53
|
+
|
54
|
+
expect_it { to_not be_valid }
|
55
|
+
end
|
46
56
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apitools-middleware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Cichra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.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
54
|
version: 3.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: semantic
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Apitools Middleware manifest, repository, specification and more.
|
@@ -73,9 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
@@ -91,11 +91,13 @@ files:
|
|
91
91
|
- spec/fixtures/middleware/cache/apitools.json
|
92
92
|
- spec/fixtures/middleware/privacy/apitools.json
|
93
93
|
- spec/fixtures/middleware/test/apitools.json
|
94
|
+
- spec/fixtures/middleware/test/test_file.lua
|
94
95
|
- spec/local_repository_spec.rb
|
95
96
|
- spec/manifest_spec.rb
|
96
97
|
- spec/repository_spec.rb
|
97
98
|
- spec/spec_helper.rb
|
98
99
|
- spec/spec_spec.rb
|
100
|
+
- spec/support/fixtures_support.rb
|
99
101
|
homepage: ''
|
100
102
|
licenses:
|
101
103
|
- MIT
|
@@ -106,12 +108,12 @@ require_paths:
|
|
106
108
|
- lib
|
107
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
110
|
requirements:
|
109
|
-
- -
|
111
|
+
- - '>='
|
110
112
|
- !ruby/object:Gem::Version
|
111
113
|
version: '0'
|
112
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
115
|
requirements:
|
114
|
-
- -
|
116
|
+
- - '>='
|
115
117
|
- !ruby/object:Gem::Version
|
116
118
|
version: '0'
|
117
119
|
requirements: []
|
@@ -124,9 +126,10 @@ test_files:
|
|
124
126
|
- spec/fixtures/middleware/cache/apitools.json
|
125
127
|
- spec/fixtures/middleware/privacy/apitools.json
|
126
128
|
- spec/fixtures/middleware/test/apitools.json
|
129
|
+
- spec/fixtures/middleware/test/test_file.lua
|
127
130
|
- spec/local_repository_spec.rb
|
128
131
|
- spec/manifest_spec.rb
|
129
132
|
- spec/repository_spec.rb
|
130
133
|
- spec/spec_helper.rb
|
131
134
|
- spec/spec_spec.rb
|
132
|
-
|
135
|
+
- spec/support/fixtures_support.rb
|