response_mate 0.1.10 → 0.1.11

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
- OWNiYmI2MzU2MGViYTYyNzkxNGM4NjY1YThjNjRjNGZjZWM3YTc0NA==
4
+ MjgxMWVjOGM0MmUxYWQ4NzBmZWE2ZTMyNmMzNGNkNjg3YzQxODM5NQ==
5
5
  data.tar.gz: !binary |-
6
- OTlhZDNlZDQ2OGFmMmYzZmM2YjhkYzA5OGIxZjg3ODQ4M2MxZDZkMw==
6
+ NGJiOGM5MmRmODVjY2U1ZTI1NzYwYTZhOTM2MWZlZDBhZDMzN2NmMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmQzNDgwNGVhZjQyMDM1MTFhMDc1OGFhNDY3ZGUwZDg2NmZhYWRmM2IxNTJj
10
- NDdkYmNiNTZhZDVmN2ZhZmZiMjM1MzAwMmU5MDI2OTJiZDg0YTdlZWY1ZmZj
11
- OGQ2ZWExMzEzNmQ5OWU3MzUxMmZjOWMzM2I0MzRiYzQ0YzVhMDg=
9
+ MGNjZDg1NGY2OTM3NTk2Njg4ZWY5MmI4YmM4OTBhYzcyMDU2YTM4MmNjYjYz
10
+ MTNlMDc4ZWRkMjAyOGVhZGFmZTI2OWRiYzBkYjcyNTU2MmZkMjA4ZDE0ODc0
11
+ ODU0ZmRjNzljOWU0Y2JiZWY1OTQwZDk4OGY1MmIyZjAwYWRlZmY=
12
12
  data.tar.gz: !binary |-
13
- NmM5NzlkNDIzNGJlN2E1MWVkZTNkYWYyZTQxNDBiMTRjYzBjYzc1YWJjODI0
14
- NDUzNWU0MDA5YWViM2FhNGE4ZDg5ZmJiZmM3N2Y1ZTU1MGZlMzMwY2FlZGVj
15
- YmMyYTA4MDU5MTVmZjY0NmYxZjk2MjhkNDA3MzVkMDlmNjk0MTg=
13
+ Nzc1ZjI0NTc5MTM5NGFmOGE2NDMzNWIyMmYwMDFlODQ1N2UwMzQ5MmFjMjI1
14
+ MjZiNjJmOGE5Y2YwMTM0OTQ3MTU0ZGY1NzRkYTM2ZWZlOGUxNDgzZjQzNzQ2
15
+ ZTBjYjJjMjU2ZTdlM2UwZDVlOGUxMTJjOTM4Zjk3ZDcyZjdjNjg=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- response_mate (0.1.10)
4
+ response_mate (0.1.11)
5
5
  activesupport
6
6
  addressable
7
7
  awesome_print
data/lib/response_mate.rb CHANGED
@@ -37,7 +37,7 @@ require 'response_mate/exporter'
37
37
 
38
38
  # Load all exporters
39
39
  require 'response_mate/exporters/postman'
40
- Dir.glob(File.join(File.expand_path('..', __FILE__),
41
- 'response_mate/exporters/*')).each(&method(:require))
40
+ require 'response_mate/exporters/postman/collection'
41
+ require 'response_mate/exporters/postman/environment'
42
42
 
43
43
  ResponseMate.setup
@@ -55,11 +55,12 @@ module ResponseMate
55
55
  map ['--version'] => :version
56
56
 
57
57
  desc 'export',
58
- 'Export to one of the available formats'
58
+ 'Export manifest or environment to one of the available formats'
59
59
  method_option :requests_manifest, aliases: '-r'
60
60
  method_option :format, required: true, aliases: '-f', default: 'postman'
61
61
  method_option :pretty, aliases: '-p', default: false
62
- method_option :upload, type: :boolean
62
+ method_option :resource, required: true, aliases: '-res', default: 'manifest'
63
+ method_option :upload, type: :boolean, aliases: '-u'
63
64
  def export
64
65
  ResponseMate::Commands::Export.new(args, options).run
65
66
  end
@@ -9,6 +9,7 @@ module ResponseMate
9
9
  @type = args.first || 'requests'
10
10
 
11
11
  @options[:manifest] = ResponseMate::Manifest.new(options[:requests_manifest])
12
+ @options[:environment] = ResponseMate::Environment.new(options[:environment])
12
13
  end
13
14
 
14
15
  def run
@@ -2,16 +2,18 @@
2
2
 
3
3
  module ResponseMate
4
4
  class Exporter
5
- attr_accessor :format, :handler, :manifest
5
+ attr_accessor :format, :handler, :manifest, :environment, :resource
6
6
 
7
7
  def initialize(args = {})
8
- @format = args[:format]
9
- @manifest = args[:manifest]
8
+ @format = args[:format]
9
+ @manifest = args[:manifest]
10
+ @environment = args[:environment]
11
+ @resource = args[:resource]
10
12
  end
11
13
 
12
14
  def export
13
15
  @handler = "ResponseMate::Exporters::#{format.capitalize}".safe_constantize.
14
- new manifest
16
+ new manifest, environment, resource
15
17
  handler.export
16
18
  end
17
19
  end
@@ -7,56 +7,23 @@ module ResponseMate::Exporters
7
7
  class Postman
8
8
  include ResponseMate::ManifestParser
9
9
 
10
- attr_accessor :manifest, :out
10
+ attr_accessor :manifest, :environment, :resource, :out
11
11
 
12
- def initialize(manifest)
13
- @manifest = manifest
12
+ def initialize(manifest, environment, resource)
13
+ @manifest = manifest
14
+ @environment = environment
15
+ @resource = resource
14
16
  @out = {}
15
17
  end
16
18
 
17
19
  def export
18
- build_structure
19
- build_requests
20
- out
21
- end
22
-
23
- private
24
-
25
- def build_structure
26
- out.merge!(
27
- id: SecureRandom.uuid,
28
- name: manifest.name,
29
- requests: [],
30
- order: [],
31
- timestamp: Time.now.to_i
32
- )
33
- end
34
-
35
- def build_requests
36
- manifest.requests.each do |request|
37
- req = ResponseMate::Manifest.parse_request(request.request)
38
- url = if req[:params].present?
39
- "#{req[:path]}?#{req[:params].to_query}"
40
- else
41
- req[:path]
42
- end
43
-
44
- out_req = {
45
- id: SecureRandom.uuid,
46
- collectionId: out[:id],
47
- data: [],
48
- description: '',
49
- method: req[:verb],
50
- name: request.key,
51
- url: url,
52
- version: 2,
53
- responses: [],
54
- dataMode: 'params',
55
- headers: request.headers || manifest.default_headers
56
- }
57
-
58
- out[:order] << out_req[:id]
59
- out[:requests] << out_req
20
+ case resource
21
+ when 'manifest'
22
+ ResponseMate::Exporters::Postman::Collection.new(manifest).export
23
+ when 'environment'
24
+ ResponseMate::Exporters::Postman::Environment.new(environment).export
25
+ else
26
+ fail 'Unsupported resource'
60
27
  end
61
28
  end
62
29
  end
@@ -0,0 +1,63 @@
1
+ # coding: utf-8
2
+
3
+ class ResponseMate::Exporters::Postman
4
+ # Handles exporting to postman format
5
+ # Example output
6
+ # https://www.getpostman.com/collections/dbc0521911e45471ff4a
7
+ class Collection
8
+ include ResponseMate::ManifestParser
9
+
10
+ attr_accessor :manifest, :out
11
+
12
+ def initialize(manifest)
13
+ @manifest = manifest
14
+ @out = {}
15
+ end
16
+
17
+ def export
18
+ build_structure
19
+ build_requests
20
+ out
21
+ end
22
+
23
+ private
24
+
25
+ def build_structure
26
+ out.merge!(
27
+ id: SecureRandom.uuid,
28
+ name: manifest.name,
29
+ requests: [],
30
+ order: [],
31
+ timestamp: Time.now.to_i
32
+ )
33
+ end
34
+
35
+ def build_requests
36
+ manifest.requests.each do |request|
37
+ req = ResponseMate::Manifest.parse_request(request.request)
38
+ url = if req[:params].present?
39
+ "#{req[:path]}?#{req[:params].to_query}"
40
+ else
41
+ req[:path]
42
+ end
43
+
44
+ out_req = {
45
+ id: SecureRandom.uuid,
46
+ collectionId: out[:id],
47
+ data: [],
48
+ description: '',
49
+ method: req[:verb],
50
+ name: request.key,
51
+ url: url,
52
+ version: 2,
53
+ responses: [],
54
+ dataMode: 'params',
55
+ headers: request.headers || manifest.default_headers
56
+ }
57
+
58
+ out[:order] << out_req[:id]
59
+ out[:requests] << out_req
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,44 @@
1
+ # coding: utf-8
2
+
3
+ class ResponseMate::Exporters::Postman
4
+ # Handles exporting to postman format
5
+ # Example output
6
+ # https://www.getpostman.com/collections/dbc0521911e45471ff4a
7
+ class Environment
8
+ attr_accessor :environment, :out
9
+
10
+ def initialize(environment)
11
+ @environment = environment
12
+ @out = {}
13
+ end
14
+
15
+ def export
16
+ build_structure
17
+ build_values
18
+ out
19
+ end
20
+
21
+ private
22
+
23
+ def build_structure
24
+ out.merge!(
25
+ id: SecureRandom.uuid,
26
+ name: 'exported_environment',
27
+ values: [],
28
+ timestamp: Time.now.to_i
29
+ )
30
+ end
31
+
32
+ def build_values
33
+ environment.env.each_pair do |k, v|
34
+ out_val = {
35
+ key: k,
36
+ value: v,
37
+ type: 'text'
38
+ }
39
+
40
+ out[:values] << out_val
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module ResponseMate
4
- VERSION = '0.1.10'
4
+ VERSION = '0.1.11'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: response_mate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitris Zorbas
@@ -281,6 +281,8 @@ files:
281
281
  - lib/response_mate/environment.rb
282
282
  - lib/response_mate/exporter.rb
283
283
  - lib/response_mate/exporters/postman.rb
284
+ - lib/response_mate/exporters/postman/collection.rb
285
+ - lib/response_mate/exporters/postman/environment.rb
284
286
  - lib/response_mate/helpers/application.rb
285
287
  - lib/response_mate/http.rb
286
288
  - lib/response_mate/inspector.rb