-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Simplify HTTPIO top level class * Reduce complexity of building class * Rename / organisation of Buffer methods2 * Reduce ABC Score of HTTP IO spec massively * Split out triple class into 3 single classes * Partially port spec code for io_http_buffer * DRY up rspec shared contexts correctly * Move webrick alias handler to isolated support file for rspec * Fix require path issues and after hook problem * Split up of final pieces of spec and partition correctly - remove excess crud * Clean up some fake objects * Place server archetype in subject and remove https scheme alteration * Moved received headers into the mock class * Remove redundant assign of a localhost entity * Move body IO into mock server class * Move starting of server into before hook of shared context * Re-generate TODO file now a lot of the porting is complete * Fix up a couple of RSpec named offenses that could slip through * Move shellwords requirement to correct location and refactor excess complexity of initial build methods * Add changelog
- Loading branch information
Showing
14 changed files
with
572 additions
and
476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'shellwords' | ||
|
||
module Cucumber | ||
module Formatter | ||
class CurlOptionParser | ||
def self.parse(options) | ||
args = Shellwords.split(options) | ||
|
||
url = nil | ||
http_method = 'PUT' | ||
headers = {} | ||
|
||
until args.empty? | ||
arg = args.shift | ||
case arg | ||
when '-X', '--request' | ||
http_method = remove_arg_for(args, arg) | ||
when '-H' | ||
header_arg = remove_arg_for(args, arg) | ||
headers = headers.merge(parse_header(header_arg)) | ||
else | ||
raise StandardError, "#{options} was not a valid curl command. Can't set url to #{arg} it is already set to #{url}" if url | ||
|
||
url = arg | ||
end | ||
end | ||
raise StandardError, "#{options} was not a valid curl command" unless url | ||
|
||
[url, http_method, headers] | ||
end | ||
|
||
# TODO: [LH] -> Switch below methods to private | ||
def self.remove_arg_for(args, arg) | ||
return args.shift unless args.empty? | ||
|
||
raise StandardError, "Missing argument for #{arg}" | ||
end | ||
|
||
def self.parse_header(header_arg) | ||
parts = header_arg.split(':', 2) | ||
raise StandardError, "#{header_arg} was not a valid header" unless parts.length == 2 | ||
|
||
{ parts[0].strip => parts[1].strip } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.