htty 1.5.4 → 1.5.5
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 +4 -4
- data/.gitignore +12 -9
- data/.rspec +2 -1
- data/.travis.yml +11 -8
- data/.yardopts +1 -1
- data/Gemfile +22 -10
- data/Guardfile +31 -13
- data/History.markdown +6 -0
- data/README.markdown +29 -13
- data/Rakefile +2 -64
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/exe/htty +5 -0
- data/htty.gemspec +27 -29
- data/lib/htty.rb +29 -4
- data/lib/htty/cli.rb +9 -16
- data/lib/htty/cli/body_open_command.rb +2 -7
- data/lib/htty/cli/command.rb +10 -18
- data/lib/htty/cli/commands.rb +76 -11
- data/lib/htty/cli/commands/address.rb +1 -14
- data/lib/htty/cli/commands/body_clear.rb +1 -8
- data/lib/htty/cli/commands/body_edit.rb +1 -11
- data/lib/htty/cli/commands/body_request.rb +1 -12
- data/lib/htty/cli/commands/body_request_open.rb +1 -10
- data/lib/htty/cli/commands/body_response.rb +1 -12
- data/lib/htty/cli/commands/body_response_open.rb +1 -11
- data/lib/htty/cli/commands/body_set.rb +1 -10
- data/lib/htty/cli/commands/body_unset.rb +1 -9
- data/lib/htty/cli/commands/cd.rb +1 -8
- data/lib/htty/cli/commands/cookie_add.rb +1 -8
- data/lib/htty/cli/commands/cookie_remove.rb +1 -8
- data/lib/htty/cli/commands/cookies.rb +1 -15
- data/lib/htty/cli/commands/cookies_add.rb +1 -11
- data/lib/htty/cli/commands/cookies_clear.rb +1 -8
- data/lib/htty/cli/commands/cookies_remove.rb +1 -11
- data/lib/htty/cli/commands/cookies_remove_all.rb +1 -11
- data/lib/htty/cli/commands/cookies_use.rb +1 -14
- data/lib/htty/cli/commands/delete.rb +1 -8
- data/lib/htty/cli/commands/exit.rb +1 -8
- data/lib/htty/cli/commands/follow.rb +1 -10
- data/lib/htty/cli/commands/form.rb +1 -7
- data/lib/htty/cli/commands/form_add.rb +1 -7
- data/lib/htty/cli/commands/form_clear.rb +1 -8
- data/lib/htty/cli/commands/form_remove.rb +1 -7
- data/lib/htty/cli/commands/form_remove_all.rb +1 -7
- data/lib/htty/cli/commands/fragment_clear.rb +1 -8
- data/lib/htty/cli/commands/fragment_set.rb +1 -10
- data/lib/htty/cli/commands/fragment_unset.rb +1 -9
- data/lib/htty/cli/commands/get.rb +1 -8
- data/lib/htty/cli/commands/header_set.rb +1 -8
- data/lib/htty/cli/commands/header_unset.rb +1 -8
- data/lib/htty/cli/commands/headers_clear.rb +1 -8
- data/lib/htty/cli/commands/headers_request.rb +1 -15
- data/lib/htty/cli/commands/headers_response.rb +1 -15
- data/lib/htty/cli/commands/headers_set.rb +1 -10
- data/lib/htty/cli/commands/headers_unset.rb +1 -10
- data/lib/htty/cli/commands/headers_unset_all.rb +1 -10
- data/lib/htty/cli/commands/help.rb +4 -12
- data/lib/htty/cli/commands/history.rb +1 -10
- data/lib/htty/cli/commands/history_verbose.rb +1 -12
- data/lib/htty/cli/commands/host_set.rb +1 -8
- data/lib/htty/cli/commands/http_delete.rb +1 -12
- data/lib/htty/cli/commands/http_get.rb +1 -13
- data/lib/htty/cli/commands/http_head.rb +1 -9
- data/lib/htty/cli/commands/http_options.rb +1 -9
- data/lib/htty/cli/commands/http_patch.rb +1 -13
- data/lib/htty/cli/commands/http_post.rb +1 -13
- data/lib/htty/cli/commands/http_put.rb +1 -12
- data/lib/htty/cli/commands/http_trace.rb +1 -9
- data/lib/htty/cli/commands/patch.rb +1 -8
- data/lib/htty/cli/commands/path_set.rb +11 -11
- data/lib/htty/cli/commands/port_set.rb +1 -9
- data/lib/htty/cli/commands/post.rb +1 -8
- data/lib/htty/cli/commands/put.rb +1 -8
- data/lib/htty/cli/commands/query_add.rb +1 -13
- data/lib/htty/cli/commands/query_clear.rb +1 -8
- data/lib/htty/cli/commands/query_remove.rb +1 -13
- data/lib/htty/cli/commands/query_set.rb +1 -13
- data/lib/htty/cli/commands/query_unset.rb +1 -13
- data/lib/htty/cli/commands/query_unset_all.rb +1 -10
- data/lib/htty/cli/commands/quit.rb +1 -7
- data/lib/htty/cli/commands/reuse.rb +5 -12
- data/lib/htty/cli/commands/scheme_set.rb +1 -9
- data/lib/htty/cli/commands/ssl_verification.rb +1 -11
- data/lib/htty/cli/commands/ssl_verification_off.rb +1 -10
- data/lib/htty/cli/commands/ssl_verification_on.rb +1 -10
- data/lib/htty/cli/commands/status.rb +1 -11
- data/lib/htty/cli/commands/undo.rb +1 -7
- data/lib/htty/cli/commands/userinfo_clear.rb +1 -8
- data/lib/htty/cli/commands/userinfo_set.rb +1 -11
- data/lib/htty/cli/commands/userinfo_unset.rb +1 -9
- data/lib/htty/cli/display.rb +4 -6
- data/lib/htty/cli/http_method_command.rb +1 -10
- data/lib/htty/cli/input_device.rb +1 -0
- data/lib/htty/cli/url_escaping.rb +1 -6
- data/lib/htty/cookies_util.rb +3 -3
- data/lib/htty/headers.rb +3 -4
- data/lib/htty/http_patch.rb +20 -23
- data/lib/htty/no_header_error.rb +1 -1
- data/lib/htty/no_location_header_error.rb +1 -3
- data/lib/htty/no_response_error.rb +1 -1
- data/lib/htty/no_set_cookie_header_error.rb +1 -3
- data/lib/htty/payload.rb +1 -5
- data/lib/htty/platform.rb +1 -1
- data/lib/htty/preferences.rb +1 -1
- data/lib/htty/request.rb +3 -13
- data/lib/htty/requests_util.rb +1 -5
- data/lib/htty/response.rb +1 -4
- data/lib/htty/session.rb +1 -3
- data/lib/htty/tempfile_preserving_extname.rb +1 -2
- data/lib/htty/uri.rb +1 -2
- data/lib/htty/version.rb +1 -1
- data/lib/tasks.rb +3 -0
- data/lib/tasks/build_doc.rake +8 -0
- data/lib/tasks/lib_each.rake +25 -0
- data/lib/tasks/spec.rake +68 -0
- data/lib/tasks/spec_each.rake +19 -0
- metadata +48 -209
- data/bin/htty +0 -5
- data/spec/integration/htty/cli/commands/query_add_spec.rb +0 -57
- data/spec/integration/htty/cli/commands/query_remove_spec.rb +0 -55
- data/spec/integration/htty/cli/commands/query_set_spec.rb +0 -78
- data/spec/integration/htty/cli/commands/query_unset_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -76
- data/spec/unit/htty/cli/commands/address_spec.rb +0 -103
- data/spec/unit/htty/cli/commands/body_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/body_edit_spec.rb +0 -18
- data/spec/unit/htty/cli/commands/body_request_spec.rb +0 -67
- data/spec/unit/htty/cli/commands/body_response_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/body_set_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/body_unset_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/cd_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/cookie_add_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/cookies_add_spec.rb +0 -78
- data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/cookies_spec.rb +0 -76
- data/spec/unit/htty/cli/commands/cookies_use_spec.rb +0 -75
- data/spec/unit/htty/cli/commands/delete_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/exit_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/follow_spec.rb +0 -70
- data/spec/unit/htty/cli/commands/form_add_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/form_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +0 -66
- data/spec/unit/htty/cli/commands/form_remove_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/form_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/fragment_set_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/get_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/header_set_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/header_unset_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/headers_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/headers_request_spec.rb +0 -81
- data/spec/unit/htty/cli/commands/headers_response_spec.rb +0 -77
- data/spec/unit/htty/cli/commands/headers_set_spec.rb +0 -74
- data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/headers_unset_spec.rb +0 -63
- data/spec/unit/htty/cli/commands/help_spec.rb +0 -67
- data/spec/unit/htty/cli/commands/history_spec.rb +0 -65
- data/spec/unit/htty/cli/commands/history_verbose_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/host_set_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/http_delete_spec.rb +0 -75
- data/spec/unit/htty/cli/commands/http_get_spec.rb +0 -77
- data/spec/unit/htty/cli/commands/http_head_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/http_options_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/http_patch_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/http_post_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/http_put_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/http_trace_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/patch_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/path_set_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/port_set_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/post_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/put_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/query_add_spec.rb +0 -82
- data/spec/unit/htty/cli/commands/query_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/query_remove_spec.rb +0 -82
- data/spec/unit/htty/cli/commands/query_set_spec.rb +0 -82
- data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +0 -74
- data/spec/unit/htty/cli/commands/query_unset_spec.rb +0 -75
- data/spec/unit/htty/cli/commands/quit_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/reuse_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/scheme_set_spec.rb +0 -74
- data/spec/unit/htty/cli/commands/shared_examples_for_commands.rb +0 -55
- data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +0 -67
- data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +0 -60
- data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +0 -65
- data/spec/unit/htty/cli/commands/status_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/undo_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +0 -97
- data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +0 -72
- data/spec/unit/htty/cli/display_spec.rb +0 -84
- data/spec/unit/htty/cli_spec.rb +0 -28
- data/spec/unit/htty/command.rb +0 -47
- data/spec/unit/htty/headers_spec.rb +0 -40
- data/spec/unit/htty/payload_spec.rb +0 -60
- data/spec/unit/htty/preferences_spec.rb +0 -8
- data/spec/unit/htty/request_follow_spec.rb +0 -94
- data/spec/unit/htty/request_spec.rb +0 -1232
- data/spec/unit/htty/request_userinfo_spec.rb +0 -208
- data/spec/unit/htty/response_spec.rb +0 -0
- data/spec/unit/htty/session_spec.rb +0 -10
- data/spec/unit/htty/shared_examples_for_requests.rb +0 -32
- data/spec/unit/htty/url_escaping.rb +0 -70
- data/spec/unit/htty/version_spec.rb +0 -8
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/userinfo_unset")
|
|
3
|
-
|
|
4
|
-
module HTTY; end
|
|
5
|
-
|
|
6
|
-
class HTTY::CLI; end
|
|
7
|
-
|
|
8
|
-
module HTTY::CLI::Commands; end
|
|
1
|
+
require 'htty'
|
|
9
2
|
|
|
10
3
|
# Encapsulates the _userinfo-clear_ command.
|
|
11
4
|
class HTTY::CLI::Commands::UserinfoClear < HTTY::CLI::Command
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/../command")
|
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/../url_escaping")
|
|
4
|
-
require File.expand_path("#{File.dirname __FILE__}/address")
|
|
5
|
-
require File.expand_path("#{File.dirname __FILE__}/userinfo_unset")
|
|
6
|
-
|
|
7
|
-
module HTTY; end
|
|
8
|
-
|
|
9
|
-
class HTTY::CLI; end
|
|
10
|
-
|
|
11
|
-
module HTTY::CLI::Commands; end
|
|
1
|
+
require 'htty'
|
|
12
2
|
|
|
13
3
|
# Encapsulates the _userinfo-set_ command.
|
|
14
4
|
class HTTY::CLI::Commands::UserinfoSet < HTTY::CLI::Command
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/address")
|
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/userinfo_set")
|
|
4
|
-
|
|
5
|
-
module HTTY; end
|
|
6
|
-
|
|
7
|
-
class HTTY::CLI; end
|
|
8
|
-
|
|
9
|
-
module HTTY::CLI::Commands; end
|
|
1
|
+
require 'htty'
|
|
10
2
|
|
|
11
3
|
# Encapsulates the _userinfo-unset_ command.
|
|
12
4
|
class HTTY::CLI::Commands::UserinfoUnset < HTTY::CLI::Command
|
data/lib/htty/cli/display.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class HTTY::CLI; end
|
|
1
|
+
require 'htty'
|
|
4
2
|
|
|
5
3
|
# Encapsulates the display logic of _htty_'s command-line interface.
|
|
6
4
|
module HTTY::CLI::Display
|
|
@@ -174,13 +172,13 @@ module HTTY::CLI::Display
|
|
|
174
172
|
# http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M002281
|
|
175
173
|
def word_wrap_indented(text, columns=2..80)
|
|
176
174
|
indent_by, wrap_at = columns.min, columns.max - columns.min
|
|
177
|
-
text.split("\n").collect
|
|
175
|
+
text.split("\n").collect { |line|
|
|
178
176
|
(wrap_at < line.length) ?
|
|
179
177
|
line.gsub(/(.{1,#{wrap_at}})(\s+|$)/, "\\1\n").strip :
|
|
180
178
|
line
|
|
181
|
-
|
|
179
|
+
}.join("\n").split("\n").collect { |line|
|
|
182
180
|
indent line, indent_by
|
|
183
|
-
|
|
181
|
+
}.join "\n"
|
|
184
182
|
end
|
|
185
183
|
|
|
186
184
|
private
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
# TODO: See if we can avoid circular references without omitting these 'require' statements
|
|
3
|
-
# require File.expand_path("#{File.dirname __FILE__}/../request")
|
|
4
|
-
# require File.expand_path("#{File.dirname __FILE__}/commands/cookies_use")
|
|
5
|
-
# require File.expand_path("#{File.dirname __FILE__}/commands/follow")
|
|
6
|
-
# require File.expand_path("#{File.dirname __FILE__}/commands/ssl_verification_off")
|
|
7
|
-
|
|
8
|
-
module HTTY; end
|
|
9
|
-
|
|
10
|
-
class HTTY::CLI; end
|
|
1
|
+
require 'htty'
|
|
11
2
|
|
|
12
3
|
# Encapsulates behavior common to all HTTP-method-oriented HTTY::CLI::Command
|
|
13
4
|
# subclasses.
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/../uri")
|
|
3
|
-
|
|
4
|
-
module HTTY; end
|
|
5
|
-
|
|
6
|
-
class HTTY::CLI; end
|
|
1
|
+
require 'htty'
|
|
7
2
|
|
|
8
3
|
# Encapsulates the URL escaping logic of _htty_'s command-line interface.
|
|
9
4
|
module HTTY::CLI::UrlEscaping
|
data/lib/htty/cookies_util.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require 'htty'
|
|
2
2
|
|
|
3
3
|
# Provides support for marshaling HTTP cookies to and from strings.
|
|
4
4
|
module HTTY::CookiesUtil
|
|
@@ -21,9 +21,9 @@ module HTTY::CookiesUtil
|
|
|
21
21
|
cookies = Array(cookies)
|
|
22
22
|
return nil if cookies.empty?
|
|
23
23
|
|
|
24
|
-
cookies.collect
|
|
24
|
+
cookies.collect { |name, value|
|
|
25
25
|
[name, value].compact.join COOKIE_NAME_VALUE_DELIMITER
|
|
26
|
-
|
|
26
|
+
}.join COOKIES_DELIMITER
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
protected
|
data/lib/htty/headers.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
require 'uri'
|
|
2
1
|
require 'base64'
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
require 'htty'
|
|
3
|
+
require 'uri'
|
|
5
4
|
|
|
6
5
|
# Represents the Headers of a Request or a Response. Headers preserve the
|
|
7
6
|
# insertion order and are case insensitive. A custom Hash is used because Hash
|
|
@@ -74,7 +73,7 @@ class HTTY::Headers
|
|
|
74
73
|
def self.credentials_from(basic_authentication)
|
|
75
74
|
if match = /^Basic (.+)$/.match(basic_authentication)
|
|
76
75
|
credentials = Base64.decode64(match[1]).split(':')
|
|
77
|
-
return yield
|
|
76
|
+
return yield(*credentials) if block_given?
|
|
78
77
|
return credentials
|
|
79
78
|
end
|
|
80
79
|
end
|
data/lib/htty/http_patch.rb
CHANGED
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Net::HTTP.instance_methods.collect(&:to_sym).include?(:patch)
|
|
5
|
-
module Net
|
|
3
|
+
module Net
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
class HTTP < Protocol
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
# Represents a HTTP PATCH request. This class exists because Net::HTTP did
|
|
8
|
+
# not have this behavior in Ruby v1.9.2 and earlier.
|
|
9
|
+
class Patch < HTTPRequest
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
METHOD = 'PATCH'
|
|
12
|
+
REQUEST_HAS_BODY = true
|
|
13
|
+
RESPONSE_HAS_BODY = true
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
end
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
unless @newimpl
|
|
26
|
-
res.value
|
|
27
|
-
return res, res.body
|
|
28
|
-
end
|
|
29
|
-
res
|
|
17
|
+
def patch(path, data, initheader, &block)
|
|
18
|
+
res = nil
|
|
19
|
+
request(Patch.new(path, initheader), data) do |r|
|
|
20
|
+
r.read_body(nil, &block)
|
|
21
|
+
res = r
|
|
30
22
|
end
|
|
31
|
-
|
|
23
|
+
unless @newimpl
|
|
24
|
+
res.value
|
|
25
|
+
return res, res.body
|
|
26
|
+
end
|
|
27
|
+
res
|
|
32
28
|
end
|
|
33
29
|
|
|
34
30
|
end
|
|
31
|
+
|
|
35
32
|
end
|
data/lib/htty/no_header_error.rb
CHANGED
data/lib/htty/payload.rb
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/no_header_error")
|
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/cookies_util")
|
|
4
|
-
|
|
5
|
-
module HTTY; end
|
|
1
|
+
require 'htty'
|
|
6
2
|
|
|
7
3
|
# Encapsulates the headers and body of an HTTP(S) request or response.
|
|
8
4
|
class HTTY::Payload
|
data/lib/htty/platform.rb
CHANGED
data/lib/htty/preferences.rb
CHANGED
data/lib/htty/request.rb
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
require 'base64'
|
|
2
|
+
require 'htty'
|
|
2
3
|
require 'pathname'
|
|
3
4
|
require 'uri'
|
|
4
|
-
require File.expand_path("#{File.dirname __FILE__}/../htty/version")
|
|
5
|
-
require File.expand_path("#{File.dirname __FILE__}/cookies_util")
|
|
6
|
-
require File.expand_path("#{File.dirname __FILE__}/no_location_header_error")
|
|
7
|
-
require File.expand_path("#{File.dirname __FILE__}/no_response_error")
|
|
8
|
-
require File.expand_path("#{File.dirname __FILE__}/no_set_cookie_header_error")
|
|
9
|
-
require File.expand_path("#{File.dirname __FILE__}/uri")
|
|
10
|
-
require File.expand_path("#{File.dirname __FILE__}/payload")
|
|
11
|
-
require File.expand_path("#{File.dirname __FILE__}/requests_util")
|
|
12
|
-
require File.expand_path("#{File.dirname __FILE__}/response")
|
|
13
|
-
|
|
14
|
-
module HTTY; end
|
|
15
5
|
|
|
16
6
|
# Encapsulates an HTTP(S) request.
|
|
17
7
|
class HTTY::Request < HTTY::Payload
|
|
@@ -206,13 +196,13 @@ public
|
|
|
206
196
|
|
|
207
197
|
# Remove just one matching cookie from the end.
|
|
208
198
|
rejected = false
|
|
209
|
-
new_cookies = cookies.reverse.reject
|
|
199
|
+
new_cookies = cookies.reverse.reject { |cookie_name, cookie_value|
|
|
210
200
|
if !rejected && (cookie_name == name)
|
|
211
201
|
rejected = true
|
|
212
202
|
else
|
|
213
203
|
false
|
|
214
204
|
end
|
|
215
|
-
|
|
205
|
+
}.reverse
|
|
216
206
|
|
|
217
207
|
cookies_string = HTTY::CookiesUtil.cookies_to_string(new_cookies)
|
|
218
208
|
if cookies_string
|
data/lib/htty/requests_util.rb
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
require 'htty'
|
|
1
2
|
require 'net/http'
|
|
2
3
|
require 'net/https'
|
|
3
4
|
require 'uri'
|
|
4
|
-
require File.expand_path("#{File.dirname __FILE__}/http_patch")
|
|
5
|
-
require File.expand_path("#{File.dirname __FILE__}/preferences")
|
|
6
|
-
require File.expand_path("#{File.dirname __FILE__}/response")
|
|
7
|
-
|
|
8
|
-
module HTTY; end
|
|
9
5
|
|
|
10
6
|
# Provides support for making HTTP(S) requests.
|
|
11
7
|
module HTTY::RequestsUtil
|
data/lib/htty/response.rb
CHANGED
data/lib/htty/session.rb
CHANGED
data/lib/htty/uri.rb
CHANGED
data/lib/htty/version.rb
CHANGED
data/lib/tasks.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
namespace :lib do
|
|
2
|
+
desc "Check the source for missing 'require' statements. Set the 'VERBOSE' " +
|
|
3
|
+
'environment variable to "t[rue]" to display the name of each file as ' +
|
|
4
|
+
'it is loaded.'
|
|
5
|
+
task :each do
|
|
6
|
+
def verbose?
|
|
7
|
+
ENV['VERBOSE'].to_s =~ /^T/i
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Dir.chdir 'lib' do
|
|
11
|
+
Dir.glob( '**/*.rb' ) do |f|
|
|
12
|
+
next if f == 'tasks.rb'
|
|
13
|
+
|
|
14
|
+
if verbose?
|
|
15
|
+
puts "* #{f}"
|
|
16
|
+
else
|
|
17
|
+
print "\e[32m.\e[0m"
|
|
18
|
+
end
|
|
19
|
+
command = "/usr/bin/env ruby -e 'require File.expand_path(#{f.inspect})'"
|
|
20
|
+
break unless system(command)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
puts unless verbose?
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/tasks/spec.rake
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
else
|
|
5
|
+
def define_spec_task(name, options={})
|
|
6
|
+
desc options[:desc]
|
|
7
|
+
begin
|
|
8
|
+
require 'rspec/core/rake_task'
|
|
9
|
+
rescue LoadError
|
|
10
|
+
else
|
|
11
|
+
RSpec::Core::RakeTask.new name do |t|
|
|
12
|
+
t.rspec_opts ||= []
|
|
13
|
+
t.rspec_opts << "--backtrace" if options[:backtrace]
|
|
14
|
+
|
|
15
|
+
debugger_gem = %w(pry-byebug pry-debugger).detect do |gem|
|
|
16
|
+
`bundle show #{gem} 2>&1 >/dev/null`
|
|
17
|
+
$?.success?
|
|
18
|
+
end
|
|
19
|
+
if debugger_gem && options[:debug] != false
|
|
20
|
+
t.rspec_opts << "--require #{debugger_gem}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
t.rspec_opts << "--format #{options[:format]}" if options.key?(:format)
|
|
24
|
+
t.rspec_opts << '--no-profile' if options[:profile] == false
|
|
25
|
+
t.rspec_opts << '--warnings' if options[:warnings]
|
|
26
|
+
t.pattern = options[:pattern] || %w(spec/*_spec.rb spec/**/*_spec.rb)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
define_spec_task :spec, :desc => 'Run specs', :profile => true
|
|
32
|
+
|
|
33
|
+
namespace :spec do
|
|
34
|
+
uncommitted_files_in_spec = `git ls-files --modified --others spec/* spec/**/*`.split("\n")
|
|
35
|
+
uncommitted_spec_files = `git ls-files --modified --others spec/*_spec.rb spec/**/*_spec.rb`.split("\n")
|
|
36
|
+
nonspec_uncommitted_files_in_spec = uncommitted_files_in_spec -
|
|
37
|
+
uncommitted_spec_files
|
|
38
|
+
if nonspec_uncommitted_files_in_spec.empty?
|
|
39
|
+
if uncommitted_spec_files.empty?
|
|
40
|
+
desc 'Run uncommitted specs (none)'
|
|
41
|
+
task :uncommitted do
|
|
42
|
+
puts 'No uncommitted specs to run'
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
noun_phrase = "#{uncommitted_spec_files.length} uncommitted spec file#{(uncommitted_spec_files.length == 1) ? nil : 's'}"
|
|
46
|
+
desc = "Run #{noun_phrase}"
|
|
47
|
+
define_spec_task :uncommitted, :desc => desc,
|
|
48
|
+
:pattern => uncommitted_spec_files
|
|
49
|
+
end
|
|
50
|
+
else
|
|
51
|
+
noun_phrase = "#{uncommitted_files_in_spec.length} uncommitted file#{uncommitted_files_in_spec.length == 1 ? nil : 's'}"
|
|
52
|
+
desc = "Run all specs because of #{noun_phrase} in 'spec'"
|
|
53
|
+
define_spec_task :uncommitted, :desc => desc, :pattern => 'spec'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
define_spec_task :warnings,
|
|
57
|
+
:desc => 'Run specs with Ruby warnings enabled',
|
|
58
|
+
:format => :progress,
|
|
59
|
+
:profile => false,
|
|
60
|
+
:warnings => true
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Support the 'gem test' command.
|
|
64
|
+
define_spec_task :test, :desc => '', :backtrace => true,
|
|
65
|
+
:debug => false,
|
|
66
|
+
:format => :progress,
|
|
67
|
+
:profile => false
|
|
68
|
+
end
|