backdrop 0.2.0 → 0.2.1

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
- NWJjNzVkNDk1ZDYzMDNhYmQyMmRkZmNlZjIwMDUxMmVmZDkwY2VlMQ==
4
+ M2U1YjEzN2RjMzU1NjExYzFjYWJmYWUwMTlhNjczNmUwZjE2MjgzZQ==
5
5
  data.tar.gz: !binary |-
6
- NjVkZWVkZGMyM2JkYjZiOTI1YWU0YzRmY2U2YmQ2YTJmMWJkZDNhYw==
6
+ ZWE3NjU4OTllZDM1MmQ5Yzg4Y2YwODhhZjkwMDE2MGViNjAwYmIxOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzJjMmZhYzVmNTUyYWZlNGZmNDdkMGRkOTRmN2E3YTVlMDVjZWNiYTg0MDQ5
10
- YzEzZTVmOTlkNmUwZDZmNzIyNGI4Mjk0NTY1OGE3ZmM0YjM2MmY1MTBlNzMx
11
- MzI4MjdkYjExNGFiNjAzMjMzMDdjZmRhZTQ3NWZkMDcyMzlmOTU=
9
+ Mjk4NTViNmY3M2ZjOWNjNWQ5YTNiMmZhY2ViYzA1Y2M0NTUxNzA2ZGU4ZTJl
10
+ M2Q3OWRmZWIzODE1OGFmMTA0NGQ3YjQwYmE5M2U4NzUwNmVhYjM1ODUxYjA5
11
+ MTE1YWJjOGNlYzA2OThhNjAzNWIxMWMwN2VhOGVmNzQwMGJlOTc=
12
12
  data.tar.gz: !binary |-
13
- ZGY0ZWIyMDk1ZDJkMTU3ZjExMzU1ZWIxYzYwZTc5ZTJiYjY0MjRjNzNmOGRj
14
- MWVkNzg3NzJjNDM4ZTMxM2FjZDEwNmU4YThjYWE0NTNjZDY3ZjM4ZmFiNTcz
15
- NWJkMDc5MDlmMjc5MmFlMzBkNThmZTFhMzA5Zjg0MWRiMDM2YWE=
13
+ ZWY4YmRjNTY5MzY5MjE2OTBiNTU0ZDEwNDlkYzdmZDc1NGE5MTNhZDU0NmU5
14
+ MjdhZTY0NmNlZDhkM2EwMThiZTEwY2QxOGY2ZTUwM2YzNDA4NzA0ZjAyNGE2
15
+ YTVjMmZjODQ2Njc5MWRlM2ExYTk1NDYzOTcwZjg3NTkwY2Y4YjE=
@@ -1,7 +1,7 @@
1
1
  module Backdrop
2
2
  class Builder
3
3
  def build_response(output, project, data, response)
4
- file = data['route']
4
+ file = data['requests'].first['request_path']
5
5
  method = data['http_method'].downcase
6
6
  path = File.dirname file
7
7
  filename = File.basename file
@@ -1,3 +1,3 @@
1
1
  module Backdrop
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -14,8 +14,9 @@ describe Backdrop::Builder do
14
14
 
15
15
  let(:sample_data) do
16
16
  { 'http_method' => 'GET',
17
- 'route' => '/project/request',
17
+ 'route' => '/project/:property',
18
18
  'requests' => [{
19
+ 'request_path' => '/resource/get_request',
19
20
  'response_body' => '{"Hello":"World"}'
20
21
  }] }
21
22
  end
@@ -25,7 +26,7 @@ describe Backdrop::Builder do
25
26
  it 'creates the response file with given input' do
26
27
  subject.build_response(@output_dir, project, sample_data, response)
27
28
  output = File.read(
28
- "#{File.join(@output_dir, 'project', sample_data['route'])}.get"
29
+ "#{File.join(@output_dir, 'project', '/resource/get_request')}.get"
29
30
  )
30
31
  expect(output).to eq response
31
32
  end
@@ -31,8 +31,9 @@ describe Backdrop::Builders::Get do
31
31
 
32
32
  let(:data) do
33
33
  { 'http_method' => 'GET',
34
- 'route' => '/project/request',
34
+ 'route' => '/project/:property',
35
35
  'requests' => [{
36
+ 'request_path' => '/resource/request',
36
37
  'response_body' => '{"Hello":"World"}'
37
38
  }] }
38
39
  end
@@ -40,7 +41,7 @@ describe Backdrop::Builders::Get do
40
41
  it 'creates a file for each request' do
41
42
  subject.build @output_dir, 'project', data
42
43
  output = File.read(
43
- "#{File.join(@output_dir, 'project', data['route'])}.get"
44
+ "#{File.join(@output_dir, 'project', 'resource/request')}.get"
44
45
  )
45
46
  expect(output).to eq '{"Hello":"World"}'
46
47
  end
@@ -35,8 +35,9 @@ describe Backdrop::Builders::Put do
35
35
 
36
36
  let(:data) do
37
37
  { 'http_method' => 'PUT',
38
- 'route' => '/project/request',
38
+ 'route' => '/project/:property',
39
39
  'requests' => [{
40
+ 'request_path' => '/resource/request',
40
41
  'response_body' => '{"Hello":"World"}',
41
42
  'response_status' => 201
42
43
  }] }
@@ -45,7 +46,7 @@ describe Backdrop::Builders::Put do
45
46
  it 'creates a file with the status for each request' do
46
47
  subject.build @output_dir, 'project', data
47
48
  output = File.read(
48
- "#{File.join(@output_dir, 'project', data['route'])}.put"
49
+ "#{File.join(@output_dir, 'project', '/resource/request')}.put"
49
50
  )
50
51
  expect(output).to eq '201'
51
52
  end
@@ -3,7 +3,7 @@ require 'backdrop'
3
3
  require 'tmpdir'
4
4
  require 'rack/test'
5
5
 
6
- describe 'Backdrop POST' do
6
+ describe 'Backdrop' do
7
7
  include Rack::Test::Methods
8
8
 
9
9
  before(:all) do
@@ -27,17 +27,19 @@ describe 'Backdrop POST' do
27
27
  describe 'running with an out directory and API project' do
28
28
  let(:put_output) do
29
29
  { 'http_method' => 'PUT',
30
- 'route' => 'resource/put_request',
30
+ 'route' => 'resource/:property',
31
31
  'requests' => [{
32
32
  'response_body' => nil,
33
+ 'request_path' => '/resource/put_request',
33
34
  'response_status' => 201
34
35
  }] }
35
36
  end
36
37
 
37
38
  let(:get_output) do
38
39
  { 'http_method' => 'GET',
39
- 'route' => '/resource/get_request',
40
+ 'route' => '/resource/:property',
40
41
  'requests' => [{
42
+ 'request_path' => '/resource/get_request',
41
43
  'response_body' => '{"Hello":"World"}'
42
44
  }] }
43
45
  end
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Bowden
@@ -57,7 +57,6 @@ files:
57
57
  - backdrop.gemspec
58
58
  - config.ru
59
59
  - lib/backdrop.rb
60
- - lib/backdrop/api_builder.rb
61
60
  - lib/backdrop/app.rb
62
61
  - lib/backdrop/builders/builder.rb
63
62
  - lib/backdrop/builders/get.rb
@@ -1,28 +0,0 @@
1
- require 'json'
2
-
3
- module Backdrop
4
- class ApiBuilder
5
- def initialize(output_dir)
6
- @output_dir = output_dir
7
- end
8
-
9
- def build_response(project, data, response, method)
10
- file = data['route']
11
- path = File.dirname(file)
12
- filename = File.basename(file)
13
- filepath = File.join(@output_dir, project, path)
14
- FileUtils.mkdir_p filepath
15
- File.write("#{File.join(filepath, filename)}.#{method}", response)
16
- end
17
-
18
- def build_get(project, data)
19
- response = data['requests'].first['response_body']
20
- build_response(project, data, response, 'get')
21
- end
22
-
23
- def build_put(project, data)
24
- response = data['requests'].first['response_status']
25
- build_response(project, data, response, 'put')
26
- end
27
- end
28
- end