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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a448dab79ade7a009e9a651c20b3cd91092adc7e
4
- data.tar.gz: b669baa0693438142740bf6120a87005ef9ec411
3
+ metadata.gz: 6243d5590eae94ad4e45bb82866da87397f4907e
4
+ data.tar.gz: e1bc333f6f01bae677269a29ae0ebc584225f6ca
5
5
  SHA512:
6
- metadata.gz: 5d7d3d4db1c0c63da26f5d6025caa065501bcf62255d3fd88546b30de4d5872167742e6e17f5e2af2b18c3046d580c0541f292c5b6033e2f0c264e064190590b
7
- data.tar.gz: 8becb7e16e33500c920cec7b4ebcee83bc9bd02b98a4f91821a20404f18070da51e9f09bc6a373577eca8acbbe3487f6031b7a3fa44bfc7a7fe29c66cefec3ed
6
+ metadata.gz: 8faf2aaac44d25379ae36b751445afdfd430868040ea1cec8668c997208c9a0cb950ea036b44018af4c7ba864f0f67c196742eff7a297bd7542a11ce72ef33a5
7
+ data.tar.gz: 6638c6569f3b54bb908ba18be18210efdf112dd50e76f4eae26cf7439af34c36aeefbde8c81991e6546c1a3a9b41018ed0088f9f76612394edd9ccde63ad0235
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.2
4
+ - 2.1.1
4
5
  - 2.0.0
5
- - 1.9.3
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ task :test do
4
+ exec 'rspec'
5
+ end
6
+ task default: :test
@@ -1,4 +1,5 @@
1
1
  require 'pathname'
2
+ require 'apitools/middleware/repository'
2
3
 
3
4
  module Apitools
4
5
  module Middleware
@@ -12,6 +13,8 @@ module Apitools
12
13
 
13
14
  def content(file)
14
15
  Pathname(file).read
16
+ rescue Errno::ENOENT
17
+ false
15
18
  end
16
19
 
17
20
  def middleware
@@ -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
- @repo.content(@path.join(@manifest_path))
64
+ content @manifest_path
53
65
  end
54
66
 
55
67
  def load_code
56
- file = files.first
57
-
58
- @repo.content(@path.join(file))
68
+ content files.first
59
69
  end
60
-
61
70
  end
62
71
  end
63
72
  end
@@ -1,5 +1,5 @@
1
1
  module Apitools
2
2
  module Middleware
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  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
+ }
@@ -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
@@ -1,4 +1,5 @@
1
1
  require 'apitools/middleware'
2
+ require 'support/fixtures_support'
2
3
 
3
4
  # This file was generated by the `rspec --init` command. Conventionally, all
4
5
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -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
@@ -0,0 +1,10 @@
1
+ module FixturesSupport
2
+ def fixture(name)
3
+ path = File.join('spec', 'fixtures', 'middleware', name, 'apitools.json')
4
+ File.read(path)
5
+ end
6
+ end
7
+
8
+ RSpec.configure do |config|
9
+ config.include FixturesSupport
10
+ 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.1
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-28 00:00:00.000000000 Z
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
- - ".gitignore"
77
- - ".rspec"
78
- - ".travis.yml"
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
- has_rdoc:
135
+ - spec/support/fixtures_support.rb