backdrop 0.0.13 → 0.1.0
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 +8 -8
- data/.travis.yml +1 -0
- data/Gemfile +1 -0
- data/README.md +9 -1
- data/config.ru +3 -2
- data/lib/backdrop/app.rb +14 -9
- data/lib/backdrop/configuration.rb +11 -0
- data/lib/backdrop/extractor.rb +0 -1
- data/lib/backdrop/rake_task.rb +1 -1
- data/lib/backdrop/runner.rb +0 -2
- data/lib/backdrop/version.rb +1 -1
- data/lib/backdrop.rb +16 -0
- data/spec/backdrop/api_builder_spec.rb +1 -1
- data/spec/backdrop/configuration_spec.rb +27 -0
- data/spec/backdrop/extractor_spec.rb +1 -2
- data/spec/backdrop/runner_spec.rb +1 -2
- data/spec/backdrop_spec.rb +21 -0
- data/spec/integration/backdrop_spec.rb +17 -8
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDA3ZmYyZDU4NTg5ZjdkZGEwZWMzYjcyMjAyNjNjOTc2ZDhhYmViMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWYzMTA5ODUxYzhlMGI1MzFiMmIxMDVjYjkxMGQ4N2Q5MDU3MTRiNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTc5MWMwYmUzMDM3NzFiNDAzN2M1ZTIxYWJiYmIwYjcyY2RhYjUyM2U2MmVm
|
10
|
+
YTY2OWI5OGY4ODc4MWQxNGQ4ZmM0NTY0NmM3ZmY4YzI2NDYzOTgzYWM2ZDMz
|
11
|
+
YzkwNDNiYTIzZTQzOTg1NWE0NmEyM2NiMGVhYWVkMzRhNGJjMTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODFlZmI3M2RhNDk2MzdmODMxM2NkMmQ5YzMwNDBjZTJjYWU0NDM5ZDc4MzE4
|
14
|
+
ZDU5M2QwY2M4MzA0ZWEyYzM2YjZiZTE3ODc0NTc1NWNkMWNhNDExODQ0OTI1
|
15
|
+
M2M5MjY0MWM3NTg1MTNiZDhlYjQwNjgzYTFmZWJiOTlmNWFhZTg=
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Backdrop [](http://badge.fury.io/rb/backdrop) [](https://travis-ci.org/tpbowden/backdrop)
|
2
2
|
========
|
3
3
|
|
4
4
|
Detects all APIs required and generates stubs based on RAD documentation
|
@@ -20,6 +20,14 @@ Ensure your APIs are generating JSON docs
|
|
20
20
|
config.format = :json
|
21
21
|
end
|
22
22
|
|
23
|
+
Configuration
|
24
|
+
-------------
|
25
|
+
|
26
|
+
config/initializers/backdrop_init.rb
|
27
|
+
|
28
|
+
Backdrop.configure do |config|
|
29
|
+
config.output_dir = 'output_directory'
|
30
|
+
end
|
23
31
|
|
24
32
|
Generating Stubs
|
25
33
|
----------------
|
data/config.ru
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'backdrop'
|
2
|
+
|
3
|
+
Backdrop::App.run
|
data/lib/backdrop/app.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
-
require 'sinatra/base'
|
2
|
-
|
3
1
|
module Backdrop
|
4
2
|
class App < Sinatra::Base
|
5
|
-
|
3
|
+
def initialize(app = nil)
|
4
|
+
super app
|
5
|
+
self.class.build_routes
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.build_routes
|
9
|
+
files = Dir["#{Backdrop.configuration.output_dir}/**/*"]
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
files.each do |file|
|
12
|
+
route = file.gsub Backdrop.configuration.output_dir, ''
|
13
|
+
route = route.gsub '.json', ''
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
get route do
|
16
|
+
content_type :json
|
17
|
+
File.read File.expand_path(file)
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
data/lib/backdrop/extractor.rb
CHANGED
data/lib/backdrop/rake_task.rb
CHANGED
data/lib/backdrop/runner.rb
CHANGED
data/lib/backdrop/version.rb
CHANGED
data/lib/backdrop.rb
CHANGED
@@ -1 +1,17 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'backdrop/version'
|
3
|
+
require 'backdrop/configuration'
|
4
|
+
require 'backdrop/runner'
|
5
|
+
require 'backdrop/extractor'
|
6
|
+
require 'backdrop/api_builder'
|
1
7
|
require 'backdrop/app'
|
8
|
+
|
9
|
+
module Backdrop
|
10
|
+
def self.configuration
|
11
|
+
@configuration ||= Configuration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield(configuration) if block_given?
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'backdrop'
|
3
|
+
|
4
|
+
describe Backdrop::Configuration do
|
5
|
+
describe '#output_dir' do
|
6
|
+
it 'defaults to ./fixtures' do
|
7
|
+
expect(subject.output_dir).to eq './fixtures'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#output_dir=' do
|
12
|
+
it 'can be configured' do
|
13
|
+
subject.output_dir = 'somewhere'
|
14
|
+
expect(subject.output_dir).to eq 'somewhere'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#projects' do
|
19
|
+
it 'defaults to empty array' do
|
20
|
+
expect(subject.projects).to eq []
|
21
|
+
end
|
22
|
+
it 'can be configured' do
|
23
|
+
subject.projects = [1, 2]
|
24
|
+
expect(subject.projects).to eq [1, 2]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'backdrop'
|
3
|
+
|
4
|
+
describe Backdrop do
|
5
|
+
describe '.configure' do
|
6
|
+
it 'yields the configuration' do
|
7
|
+
Backdrop.configure do |config|
|
8
|
+
expect(config).to be_a(Backdrop::Configuration)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.configuration' do
|
14
|
+
it 'returns the current configuration' do
|
15
|
+
Backdrop.configure do |config|
|
16
|
+
@config = config
|
17
|
+
end
|
18
|
+
expect(Backdrop.configuration).to eq @config
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,14 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'backdrop
|
2
|
+
require 'backdrop'
|
3
3
|
require 'tmpdir'
|
4
|
+
require 'rack/test'
|
4
5
|
|
5
6
|
describe 'Backdrop' do
|
7
|
+
include Rack::Test::Methods
|
8
|
+
let!(:test_dir) { Dir.mktmpdir }
|
9
|
+
let(:subject) { Backdrop::Runner.new(output_path, [project_path]) }
|
10
|
+
let(:output_path) { File.join(test_dir, 'output') }
|
11
|
+
let(:project_path) { File.join(test_dir, 'project') }
|
12
|
+
|
13
|
+
def app
|
14
|
+
Backdrop.configure do |config|
|
15
|
+
config.output_dir = File.join(test_dir, 'output')
|
16
|
+
end
|
17
|
+
Backdrop::App
|
18
|
+
end
|
6
19
|
|
7
20
|
describe 'running backdrop with an out directory and API project' do
|
8
|
-
let!(:test_dir) { Dir.mktmpdir }
|
9
|
-
let(:subject) { Backdrop::Runner.new(output_path, [project_path]) }
|
10
|
-
let(:output_path) { File.join(test_dir, 'output') }
|
11
|
-
let(:project_path) { File.join(test_dir, 'project') }
|
12
21
|
let(:rad_output) do
|
13
22
|
{ 'http_method' => 'GET',
|
14
23
|
'route' => '/resource/request',
|
@@ -23,6 +32,7 @@ describe 'Backdrop' do
|
|
23
32
|
File.join(project_path, '/doc/api/request.json'),
|
24
33
|
JSON.generate(rad_output)
|
25
34
|
)
|
35
|
+
subject.run
|
26
36
|
end
|
27
37
|
|
28
38
|
after do
|
@@ -30,9 +40,8 @@ describe 'Backdrop' do
|
|
30
40
|
end
|
31
41
|
|
32
42
|
it 'creates the APIs in the target directory' do
|
33
|
-
|
34
|
-
|
35
|
-
expect(out).to eq '{"Hello":"World"}'
|
43
|
+
get '/project/resource/request'
|
44
|
+
expect(last_response.body).to eq '{"Hello":"World"}'
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backdrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Bowden
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/backdrop.rb
|
60
60
|
- lib/backdrop/api_builder.rb
|
61
61
|
- lib/backdrop/app.rb
|
62
|
+
- lib/backdrop/configuration.rb
|
62
63
|
- lib/backdrop/extractor.rb
|
63
64
|
- lib/backdrop/rake_task.rb
|
64
65
|
- lib/backdrop/runner.rb
|
@@ -66,8 +67,10 @@ files:
|
|
66
67
|
- lib/tasks/default.rake
|
67
68
|
- lib/tasks/rubocop.rake
|
68
69
|
- spec/backdrop/api_builder_spec.rb
|
70
|
+
- spec/backdrop/configuration_spec.rb
|
69
71
|
- spec/backdrop/extractor_spec.rb
|
70
72
|
- spec/backdrop/runner_spec.rb
|
73
|
+
- spec/backdrop_spec.rb
|
71
74
|
- spec/integration/backdrop_spec.rb
|
72
75
|
- spec/spec_helper.rb
|
73
76
|
homepage: http://github.com/tpbowden/backdrop
|