response_mate 0.1.1 → 0.1.2

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
- MzUyYjQzZWRjMjViY2FkOWNiNWNiZTBkZmNjYzVjOTEwYTQ5ODAyMA==
4
+ ZDJlNGRjM2NiYjk0NDhkZjM2MTI4OTkxNTAwNDUxZGE0ZDFjY2MwYQ==
5
5
  data.tar.gz: !binary |-
6
- NDU1NjQxZTE1YjMzYzdiM2E5ZDZjOGUwOTVjMDNlZjFmZmY4M2IwZg==
6
+ NTI2OWEyZmI1NmRhN2JlN2YyNmFhOTI3MTUxNWM4NmVjMWYyMDVlYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGY2ZmUyY2Q5YmZmMzI5YWEwYWFhMGJmYmQ3OGM0ZmI4OTVkYTBjNDM1MGI5
10
- NDY3NDdiYTIzYjdjZTVmZjBhNGU0NTU0NzQyYTFhYTlkZDk4YTQ0MGEyNTlm
11
- OWJmZGY3MTc3MzQ4OWFlZTZkMmNmMmMxNGYzNTI1OGEzOGVhMTg=
9
+ MTc0NWI4YzNjNTIzZjEyYWExZDgxNWRiNjI2NTk0NTFkNGRhODg0MGQyYjBh
10
+ NTU5YTNmOWQ4MjkzNjFmMGNiY2NlOGIxZDI5ZDEwNDVkYThlZTY0Y2UxMDBm
11
+ MjUyYjZhZTU3MWFhODQwNDEyOTVlOTc2M2RlMjFmZGY4N2I4ODQ=
12
12
  data.tar.gz: !binary |-
13
- YmFiZjUxNjZkYTExODQ3ZGQyZTNjZmNkZGNkNWJkMThhMTc3Y2NhYzU5ZTFj
14
- ODZjYmZhNDExNGVjZmQ0OTJiYzQ2OThhMjc5MjkzZTJmMjc0MjU2MGE4OGNm
15
- OTI5ZTFkY2JmMjZlYjM5MjRmOTQzMTZiZmMyZjdhYzNlODk4NGM=
13
+ MjM3MjRjYjllMTVmNDJjZGE3MmJjN2I1MDAzNWQ0YTNhZGE5OTkyNzYyNzdj
14
+ ODZhZmY3NWVmYTkxM2Y2NGJjMDRhOGMwMjk1ODcyNWJlYjQ5M2YyN2U0NjVj
15
+ YzU1Y2ZhNGZlYTk2ZjY2Njk0NTkzZDVjYjNhNjhlYzc1NThjNGE=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- response_mate (0.1.0)
4
+ response_mate (0.1.1)
5
5
  activesupport
6
6
  addressable
7
7
  awesome_print
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  ## ResponseMate
2
- [![Build Status](https://travis-ci.org/Zorbash/response_mate.png?branch=master)](https://travis-ci.org/Zorbash/response_mate)
2
+
3
+ [![Gem version](https://badge.fury.io/rb/response_mate.png)](http://badge.fury.io/rb/response_mate)
3
4
  [![Code Climate](https://codeclimate.com/github/Zorbash/response_mate.png)](https://codeclimate.com/github/Zorbash/response_mate)
4
5
  [![Dependencies tatus](https://gemnasium.com/Zorbash/response_mate.png)](https://gemnasium.com/Zorbash/response_mate)
5
- [[Coverage Status](https://coveralls.io/repos/Zorbash/response_mate/badge.png?branch=master)](https://coveralls.io/r/Zorbash/response_mate?branch=master)
6
+ [![Coverage Status](https://coveralls.io/repos/Zorbash/response_mate/badge.png?branch=master)](https://coveralls.io/r/Zorbash/response_mate?branch=master)
6
7
 
7
8
  ResponseMate is a command line tool that aims to make inspecting and
8
9
  recording HTTP requests/responses. It is designed with APIs in mind.
data/bin/response_mate CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # coding: utf-8
2
3
 
3
4
  require 'response_mate'
4
5
 
@@ -4,7 +4,7 @@ module ResponseMate
4
4
  class CLI < ::Thor
5
5
  package_name 'response_mate'
6
6
 
7
- desc 'Perform requests and records their output', 'Records'
7
+ desc 'record', 'Perform requests and record their output'
8
8
  method_option :base_url, aliases: '-b'
9
9
  method_option :requests_manifest, aliases: '-r'
10
10
  method_option :keys, aliases: '-k', type: :array
@@ -17,7 +17,7 @@ module ResponseMate
17
17
  invoke :setup, []
18
18
  end
19
19
 
20
- desc 'Perform requests and prints their output', 'Records'
20
+ desc 'inspect [key1,key2]', 'Perform requests and print their output'
21
21
  method_option :base_url, aliases: '-b'
22
22
  method_option :requests_manifest, aliases: '-r'
23
23
  method_option :interactive, type: :boolean, aliases: "-i"
@@ -26,17 +26,18 @@ module ResponseMate
26
26
  ResponseMate::Commands::Inspect.new(args, options).run
27
27
  end
28
28
 
29
- desc 'Initializes the required directory structure', 'Initializes'
29
+ desc 'setup', 'Initialize the required directory structure'
30
30
  def setup(output_dir = '')
31
31
  ResponseMate::Commands::Setup.new(args, options).run
32
32
  end
33
33
 
34
- desc 'Deletes existing response files', 'Cleans up recordings'
34
+ desc 'clear [output_dir]', 'Delete existing response files'
35
35
  def clear(output_dir = '')
36
36
  ResponseMate::Commands::Clear.new(args, options).run
37
37
  end
38
38
 
39
- desc 'Lists available recordings or keys to record', 'Recording listing'
39
+ desc 'list [request_type] (requests or recordings)',
40
+ 'List available recordings or keys to record'
40
41
  method_option :requests_manifest, aliases: '-r'
41
42
  def list(type = 'requests')
42
43
  ResponseMate::Commands::List.new(args, options).run
@@ -47,7 +48,14 @@ module ResponseMate
47
48
  invoke :setup, []
48
49
  end
49
50
 
50
- desc 'Exports to one of the available formats', 'Exports'
51
+ desc 'version', 'Print version information'
52
+ def version
53
+ puts "ResponseMate version #{ResponseMate::VERSION}"
54
+ end
55
+ map ['--version'] => :version
56
+
57
+ desc 'exportExports to one of the available formats',
58
+ 'Export to one of the available formats'
51
59
  method_option :requests_manifest, aliases: '-r'
52
60
  method_option :format, aliases: '-f'
53
61
  method_option :pretty, aliases: '-p', default: false
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
4
  module Commands
3
5
  class Base
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
4
  module Commands
3
5
  # Handles the invocation of the clear command
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
4
  module Commands
3
5
  class ResponseMate::Commands::Export < Base
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
4
  module Commands
3
5
  class ResponseMate::Commands::Inspect < Base
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
4
  module Commands
3
5
  class ResponseMate::Commands::List < Base
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
4
  module Commands
3
5
  # Handles the invocation of the record command
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
4
  module Commands
3
5
  # Handles the invocation of the setup command
@@ -1,4 +1,8 @@
1
+ # coding: utf-8
2
+
3
+ # This class provides a layer above the HTTP client
1
4
  class ResponseMate::Connection
5
+
2
6
  delegate :params, to: :client
3
7
  delegate(*(ResponseMate::ManifestParser::HTTP_VERBS), to: :client)
4
8
 
@@ -11,26 +15,37 @@ class ResponseMate::Connection
11
15
  c.adapter Faraday.default_adapter
12
16
  end
13
17
 
14
- client.headers.merge(ResponseMate::DEFAULT_HEADERS)
18
+ client.headers.merge!(ResponseMate::DEFAULT_HEADERS)
15
19
  client.url_prefix = base_url if base_url
16
20
  end
17
21
 
18
22
  def fetch(request)
19
23
  client.params = request[:params] if !request[:params].nil?
20
- unless base_url || request[:path] =~ /^http:\/\//
24
+
25
+ unless base_url || request[:path] =~ %r{http://}
21
26
  request[:path] = 'http://' + request[:path]
22
27
  end
23
- client.send request[:verb].downcase.to_sym, "#{base_url}#{request[:path]}"
28
+
29
+ verb, path = [request[:verb].downcase.to_sym, "#{base_url}#{request[:path]}"]
30
+
31
+ client.send verb, path do |req|
32
+ req.headers = headers_from_manifest(manifest)
33
+ if request[:data_mode] == 'raw'
34
+ req.headers['Content-Type'] = 'text/plain; charset=UTF-8'
35
+ req.body = request[:data]
36
+ elsif request[:data_mode] == 'urlencoded'
37
+ req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
38
+ req.headers['Content-Type'] = 'text/plain; charset=UTF-8'
39
+ end
40
+ end
24
41
  rescue Faraday::Error::ConnectionFailed
25
42
  puts "Is a server up and running at #{request[:path]}?".red
26
43
  exit 1
27
44
  end
28
45
 
29
- def set_headers_from_manifest(manifest)
30
- if manifest.try(:[], 'default_headers')
31
- manifest['default_headers'].each_pair do |k, v|
32
- client.headers[ResponseMate::Helpers.headerize(k)] = v
33
- end
46
+ def headers_from_manifest(manifest)
47
+ manifest.default_headers.inject({}) do |hash, (k, v)|
48
+ hash[ResponseMate::Helpers.headerize(k)] = v
34
49
  end
35
50
  end
36
51
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  class ResponseMate::Environment
2
4
  attr_accessor :filename, :env, :environment_text
3
5
 
@@ -12,11 +14,8 @@ class ResponseMate::Environment
12
14
  def parse
13
15
  begin
14
16
  @environment_text = File.read filename
17
+ @env = YAML.load(environment_text)
15
18
  rescue Errno::ENOENT
16
- puts filename.red << ' does not seem to exist'
17
- exit 1
18
19
  end
19
-
20
- @env = YAML.load(environment_text)
21
20
  end
22
21
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate::Exporters
2
4
  # Handles exporting to postman format
3
5
  # Example output
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate::Helpers
2
4
  def self.headerize(string); string.split('_').map(&:capitalize).join('-') end
3
5
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate::Http
2
4
  STATUS_CODES = {
3
5
  100 => 'Continue',
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  class ResponseMate::Inspector
2
4
  attr_accessor :conn, :base_url, :oauth, :manifest, :print_type
3
5
 
@@ -9,7 +11,6 @@ class ResponseMate::Inspector
9
11
 
10
12
  if !args[:interactive]
11
13
  @conn = ResponseMate::Connection.new(base_url)
12
- @conn.set_headers_from_manifest(manifest)
13
14
  else
14
15
  @conn = ResponseMate::Connection.new
15
16
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  class ResponseMate::Manifest
2
4
  include ResponseMate::ManifestParser
3
5
 
@@ -8,6 +10,7 @@ class ResponseMate::Manifest
8
10
  @filename = filename || ResponseMate.configuration.requests_manifest
9
11
  @oauth = ResponseMate::Oauth.new
10
12
  @environment = environment
13
+ @default_header
11
14
  parse
12
15
  end
13
16
 
@@ -28,17 +31,6 @@ class ResponseMate::Manifest
28
31
  @base_url = @request_hashes['base_url']
29
32
  @requests = @request_hashes['requests'].map { |rh| ResponseMate::Request.new(rh) }
30
33
  @default_headers = @request_hashes['default_headers']
31
- add_oauth_to_requests
32
- end
33
-
34
- def add_oauth_to_requests
35
- @requests.each do |req|
36
- if req[:params].present?
37
- req[:params].merge!('oauth_token' => oauth.token)
38
- else
39
- req[:params] = { 'oauth_token' => oauth.token }
40
- end
41
- end
42
34
  end
43
35
 
44
36
  class << self
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate::ManifestParser
2
4
  HTTP_VERBS = %w(GET POST PUT PATCH DELETE HEAD OPTIONS)
3
5
  REQUEST_MATCHER = /^(?<verb>(#{HTTP_VERBS.join('|')})) (?<path>(.)*)$/im
@@ -14,7 +14,6 @@ module ResponseMate
14
14
  @base_url = args[:base_url] || manifest.base_url
15
15
 
16
16
  @conn = ResponseMate::Connection.new(base_url)
17
- @conn.set_headers_from_manifest(manifest)
18
17
  end
19
18
 
20
19
  def record
@@ -1,2 +1,4 @@
1
+ # coding: utf-8
2
+
1
3
  class ResponseMate::Request < OpenStruct
2
4
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  class ResponseMate::Tape
2
4
  def write(key, request, response, meta = {})
3
5
  File.open("#{ResponseMate.configuration.output_dir}#{key}.yml", 'w') do |f|
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module ResponseMate
2
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
3
5
  end
@@ -4,38 +4,38 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'response_mate/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "response_mate"
7
+ spec.name = 'response_mate'
8
8
  spec.version = ResponseMate::VERSION
9
- spec.authors = ["Dimitris Zorbas"]
10
- spec.email = ["zorbash@skroutz.gr"]
9
+ spec.authors = ['Dimitris Zorbas']
10
+ spec.email = ['zorbash@skroutz.gr']
11
11
  spec.description = <<-DESC
12
12
  Cli tool to make inspecting and recording HTTP requests fun again
13
13
  DESC
14
- spec.summary = %q{}
15
- spec.homepage = ""
16
- spec.license = "MIT"
14
+ spec.summary = %q{A cli tool for browsing and recording api requests with ease}
15
+ spec.homepage = 'https://github.com/Zorbash/response_mate'
16
+ spec.license = 'MIT'
17
17
 
18
18
  spec.files = `git ls-files`.split($/)
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "pry"
26
- spec.add_development_dependency "pry-remote"
27
- spec.add_development_dependency "pry-nav"
28
- spec.add_development_dependency "rspec", "~> 2.14"
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'pry'
26
+ spec.add_development_dependency 'pry-remote'
27
+ spec.add_development_dependency 'pry-nav'
28
+ spec.add_development_dependency 'rspec', '~> 2.14'
29
29
  spec.add_development_dependency 'fakefs'
30
30
  spec.add_development_dependency 'rubocop'
31
31
 
32
- spec.add_dependency "thor", "~> 0.18.1"
33
- spec.add_dependency "awesome_print"
34
- spec.add_dependency "activesupport"
35
- spec.add_dependency "colored"
36
- spec.add_dependency "faraday"
37
- spec.add_dependency "faraday_middleware"
38
- spec.add_dependency "addressable"
39
- spec.add_dependency "highline"
40
- spec.add_dependency "mustache"
32
+ spec.add_dependency 'thor', '~> 0.18.1'
33
+ spec.add_dependency 'awesome_print'
34
+ spec.add_dependency 'activesupport'
35
+ spec.add_dependency 'colored'
36
+ spec.add_dependency 'faraday'
37
+ spec.add_dependency 'faraday_middleware'
38
+ spec.add_dependency 'addressable'
39
+ spec.add_dependency 'highline'
40
+ spec.add_dependency 'mustache'
41
41
  end
data/roadmap.md CHANGED
@@ -10,6 +10,7 @@
10
10
  - Export Tape as a separate class [Done]
11
11
 
12
12
  ## Milestone 0.2.0
13
+ - Support request types: [:raw, urlencoded]
13
14
  - Request helpers (random ids, uuids).
14
15
  - Paraller requests.
15
16
  - Expectations, a expectations.yml file will contain a list of keys and
@@ -19,6 +20,5 @@
19
20
  - Curl exporter.
20
21
  - Export environment.yml to postman format
21
22
  - Accept extra params/headers from cli
22
- - Support request types: [:raw, urlencoded]
23
23
  - read manifest file from url
24
24
  - Allow multiline input for inspect
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ResponseMate::CLI do
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ResponseMate::Configuration do
@@ -1,6 +1,7 @@
1
+ # coding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
- # TODO: This spec need some love
4
+ # TODO: This spec needs some love
4
5
  describe ResponseMate::Recorder, fakefs: true do
5
6
  pending '.initialize' do
6
7
  let(:subject) { ResponseMate::Recorder.new }
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ResponseMate do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
4
  require 'response_mate'
3
5
  require 'fakefs/safe'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: response_mate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitris Zorbas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-30 00:00:00.000000000 Z
11
+ date: 2014-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  type: :development
@@ -269,7 +269,6 @@ files:
269
269
  - environment.yml.sample
270
270
  - lib/response_mate.rb
271
271
  - lib/response_mate/cli.rb
272
- - lib/response_mate/commands.rb
273
272
  - lib/response_mate/commands/base.rb
274
273
  - lib/response_mate/commands/clear.rb
275
274
  - lib/response_mate/commands/export.rb
@@ -302,7 +301,7 @@ files:
302
301
  - spec/lib/response_mate/recorder_spec.rb
303
302
  - spec/lib/response_mate_spec.rb
304
303
  - spec/spec_helper.rb
305
- homepage: ''
304
+ homepage: https://github.com/Zorbash/response_mate
306
305
  licenses:
307
306
  - MIT
308
307
  metadata: {}
@@ -325,7 +324,7 @@ rubyforge_project:
325
324
  rubygems_version: 2.1.9
326
325
  signing_key:
327
326
  specification_version: 4
328
- summary: ''
327
+ summary: A cli tool for browsing and recording api requests with ease
329
328
  test_files:
330
329
  - spec/fixtures/two_keys.yml.erb
331
330
  - spec/lib/response_mate/cli_spec.rb
@@ -1 +0,0 @@
1
- module ResponseMate::Commands; end