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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmUxNDA4ODNiOGVjY2FhNzkyZDAyMjIyZjA2YzUwZmNmMTFkZDZiNg==
4
+ NDA3ZmYyZDU4NTg5ZjdkZGEwZWMzYjcyMjAyNjNjOTc2ZDhhYmViMQ==
5
5
  data.tar.gz: !binary |-
6
- NjIwNGE4NGQ4MzY0MjkxNGUwNDRkYzBmYWNlYmIyMWJlZDk3MzFmOA==
6
+ ZWYzMTA5ODUxYzhlMGI1MzFiMmIxMDVjYjkxMGQ4N2Q5MDU3MTRiNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDYzYzM1NmI2ZGI4ODc2ZmFlZjM1OGFkYTYwYjdlODRhZWU5YzhjZDQ3NDRk
10
- N2U4Y2VkYzQyYjdjMjZhYmI3OWExNDM5NTVmNTEyNDI0NzgxNzBmN2M4OGI5
11
- Y2UyZTFiOWM1NjU3NWRhYjUzYmFlYmY5ODZiYTcwNmQ5NThkODU=
9
+ MTc5MWMwYmUzMDM3NzFiNDAzN2M1ZTIxYWJiYmIwYjcyY2RhYjUyM2U2MmVm
10
+ YTY2OWI5OGY4ODc4MWQxNGQ4ZmM0NTY0NmM3ZmY4YzI2NDYzOTgzYWM2ZDMz
11
+ YzkwNDNiYTIzZTQzOTg1NWE0NmEyM2NiMGVhYWVkMzRhNGJjMTA=
12
12
  data.tar.gz: !binary |-
13
- NWU3YWE2OGEyNWNlMWQzNzNkNTMwMmE1MzRlMzhjMGI3NzJlMDgzZDBkNWIx
14
- ZWNkZTNmZjkwMWFlNTBmMzRiNDI2ZTVkNDVjY2M3ZjI0ZDkzNTVhODI0ZmFj
15
- Nzk0YzIyOWJiNDNiNDZhZWZjMzJjZWJmYjYxNmI1N2M1YzExOTE=
13
+ ODFlZmI3M2RhNDk2MzdmODMxM2NkMmQ5YzMwNDBjZTJjYWU0NDM5ZDc4MzE4
14
+ ZDU5M2QwY2M4MzA0ZWEyYzM2YjZiZTE3ODc0NTc1NWNkMWNhNDExODQ0OTI1
15
+ M2M5MjY0MWM3NTg1MTNiZDhlYjQwNjgzYTFmZWJiOTlmNWFhZTg=
data/.travis.yml CHANGED
@@ -12,3 +12,4 @@ deploy:
12
12
  tags: true
13
13
  all_branches: true
14
14
  repo: tpbowden/backdrop
15
+ rvm: 2.0.0
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :test do
6
+ gem 'rack-test'
6
7
  gem 'rake_rack'
7
8
  gem 'rspec'
8
9
  gem 'rubocop'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Backdrop [![Code Climate](https://codeclimate.com/github/tpbowden/Backdrop/badges/gpa.svg)](https://codeclimate.com/github/tpbowden/Backdrop) [![Gem Version](https://badge.fury.io/rb/backdrop.svg)](http://badge.fury.io/rb/backdrop) [![Build Status](https://travis-ci.org/tpbowden/Backdrop.svg?branch=master)](https://travis-ci.org/tpbowden/Backdrop) [![Dependency Status](https://gemnasium.com/tpbowden/Backdrop.svg)](https://gemnasium.com/tpbowden/Backdrop)
1
+ Backdrop [![Gem Version](https://badge.fury.io/rb/backdrop.svg)](http://badge.fury.io/rb/backdrop) [![Build Status](https://travis-ci.org/tpbowden/backdrop.svg?branch=master)](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 './sonar'
2
- run Sonar
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
- files = Dir['fixtures/**/*']
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
- files.each do |file|
8
- route = file.gsub 'fixtures', ''
9
- route = route.gsub '.json', ''
11
+ files.each do |file|
12
+ route = file.gsub Backdrop.configuration.output_dir, ''
13
+ route = route.gsub '.json', ''
10
14
 
11
- get "#{route}" do
12
- content_type :json
13
- File.read File.expand_path(file)
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
@@ -0,0 +1,11 @@
1
+ module Backdrop
2
+ class Configuration
3
+ attr_accessor :output_dir
4
+ attr_accessor :projects
5
+
6
+ def initialize
7
+ @output_dir = './fixtures'
8
+ @projects = []
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,4 @@
1
1
  require 'json'
2
- require 'backdrop/api_builder'
3
2
 
4
3
  module Backdrop
5
4
  class Extractor
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/tasklib'
3
- require 'backdrop/runner'
3
+ require 'backdrop'
4
4
 
5
5
  module Backdrop
6
6
  class RakeTask < Rake::TaskLib
@@ -1,5 +1,3 @@
1
- require 'backdrop/extractor'
2
-
3
1
  module Backdrop
4
2
  class Runner
5
3
  def initialize(output_dir, projects)
@@ -1,3 +1,3 @@
1
1
  module Backdrop
2
- VERSION = '0.0.13'
2
+ VERSION = '0.1.0'
3
3
  end
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
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'backdrop/api_builder'
2
+ require 'backdrop'
3
3
  require 'tmpdir'
4
4
 
5
5
  describe Backdrop::ApiBuilder do
@@ -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
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'backdrop/extractor'
3
- require 'backdrop/api_builder'
2
+ require 'backdrop'
4
3
  require 'tmpdir'
5
4
  require 'tempfile'
6
5
 
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'backdrop/extractor'
3
- require 'backdrop/runner'
2
+ require 'backdrop'
4
3
 
5
4
  describe Backdrop::Runner do
6
5
 
@@ -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/runner'
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
- subject.run
34
- out = (File.read(File.join(output_path, 'project/resource/request.json')))
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.13
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