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.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -9
  3. data/.rspec +2 -1
  4. data/.travis.yml +11 -8
  5. data/.yardopts +1 -1
  6. data/Gemfile +22 -10
  7. data/Guardfile +31 -13
  8. data/History.markdown +6 -0
  9. data/README.markdown +29 -13
  10. data/Rakefile +2 -64
  11. data/bin/console +10 -0
  12. data/bin/setup +8 -0
  13. data/exe/htty +5 -0
  14. data/htty.gemspec +27 -29
  15. data/lib/htty.rb +29 -4
  16. data/lib/htty/cli.rb +9 -16
  17. data/lib/htty/cli/body_open_command.rb +2 -7
  18. data/lib/htty/cli/command.rb +10 -18
  19. data/lib/htty/cli/commands.rb +76 -11
  20. data/lib/htty/cli/commands/address.rb +1 -14
  21. data/lib/htty/cli/commands/body_clear.rb +1 -8
  22. data/lib/htty/cli/commands/body_edit.rb +1 -11
  23. data/lib/htty/cli/commands/body_request.rb +1 -12
  24. data/lib/htty/cli/commands/body_request_open.rb +1 -10
  25. data/lib/htty/cli/commands/body_response.rb +1 -12
  26. data/lib/htty/cli/commands/body_response_open.rb +1 -11
  27. data/lib/htty/cli/commands/body_set.rb +1 -10
  28. data/lib/htty/cli/commands/body_unset.rb +1 -9
  29. data/lib/htty/cli/commands/cd.rb +1 -8
  30. data/lib/htty/cli/commands/cookie_add.rb +1 -8
  31. data/lib/htty/cli/commands/cookie_remove.rb +1 -8
  32. data/lib/htty/cli/commands/cookies.rb +1 -15
  33. data/lib/htty/cli/commands/cookies_add.rb +1 -11
  34. data/lib/htty/cli/commands/cookies_clear.rb +1 -8
  35. data/lib/htty/cli/commands/cookies_remove.rb +1 -11
  36. data/lib/htty/cli/commands/cookies_remove_all.rb +1 -11
  37. data/lib/htty/cli/commands/cookies_use.rb +1 -14
  38. data/lib/htty/cli/commands/delete.rb +1 -8
  39. data/lib/htty/cli/commands/exit.rb +1 -8
  40. data/lib/htty/cli/commands/follow.rb +1 -10
  41. data/lib/htty/cli/commands/form.rb +1 -7
  42. data/lib/htty/cli/commands/form_add.rb +1 -7
  43. data/lib/htty/cli/commands/form_clear.rb +1 -8
  44. data/lib/htty/cli/commands/form_remove.rb +1 -7
  45. data/lib/htty/cli/commands/form_remove_all.rb +1 -7
  46. data/lib/htty/cli/commands/fragment_clear.rb +1 -8
  47. data/lib/htty/cli/commands/fragment_set.rb +1 -10
  48. data/lib/htty/cli/commands/fragment_unset.rb +1 -9
  49. data/lib/htty/cli/commands/get.rb +1 -8
  50. data/lib/htty/cli/commands/header_set.rb +1 -8
  51. data/lib/htty/cli/commands/header_unset.rb +1 -8
  52. data/lib/htty/cli/commands/headers_clear.rb +1 -8
  53. data/lib/htty/cli/commands/headers_request.rb +1 -15
  54. data/lib/htty/cli/commands/headers_response.rb +1 -15
  55. data/lib/htty/cli/commands/headers_set.rb +1 -10
  56. data/lib/htty/cli/commands/headers_unset.rb +1 -10
  57. data/lib/htty/cli/commands/headers_unset_all.rb +1 -10
  58. data/lib/htty/cli/commands/help.rb +4 -12
  59. data/lib/htty/cli/commands/history.rb +1 -10
  60. data/lib/htty/cli/commands/history_verbose.rb +1 -12
  61. data/lib/htty/cli/commands/host_set.rb +1 -8
  62. data/lib/htty/cli/commands/http_delete.rb +1 -12
  63. data/lib/htty/cli/commands/http_get.rb +1 -13
  64. data/lib/htty/cli/commands/http_head.rb +1 -9
  65. data/lib/htty/cli/commands/http_options.rb +1 -9
  66. data/lib/htty/cli/commands/http_patch.rb +1 -13
  67. data/lib/htty/cli/commands/http_post.rb +1 -13
  68. data/lib/htty/cli/commands/http_put.rb +1 -12
  69. data/lib/htty/cli/commands/http_trace.rb +1 -9
  70. data/lib/htty/cli/commands/patch.rb +1 -8
  71. data/lib/htty/cli/commands/path_set.rb +11 -11
  72. data/lib/htty/cli/commands/port_set.rb +1 -9
  73. data/lib/htty/cli/commands/post.rb +1 -8
  74. data/lib/htty/cli/commands/put.rb +1 -8
  75. data/lib/htty/cli/commands/query_add.rb +1 -13
  76. data/lib/htty/cli/commands/query_clear.rb +1 -8
  77. data/lib/htty/cli/commands/query_remove.rb +1 -13
  78. data/lib/htty/cli/commands/query_set.rb +1 -13
  79. data/lib/htty/cli/commands/query_unset.rb +1 -13
  80. data/lib/htty/cli/commands/query_unset_all.rb +1 -10
  81. data/lib/htty/cli/commands/quit.rb +1 -7
  82. data/lib/htty/cli/commands/reuse.rb +5 -12
  83. data/lib/htty/cli/commands/scheme_set.rb +1 -9
  84. data/lib/htty/cli/commands/ssl_verification.rb +1 -11
  85. data/lib/htty/cli/commands/ssl_verification_off.rb +1 -10
  86. data/lib/htty/cli/commands/ssl_verification_on.rb +1 -10
  87. data/lib/htty/cli/commands/status.rb +1 -11
  88. data/lib/htty/cli/commands/undo.rb +1 -7
  89. data/lib/htty/cli/commands/userinfo_clear.rb +1 -8
  90. data/lib/htty/cli/commands/userinfo_set.rb +1 -11
  91. data/lib/htty/cli/commands/userinfo_unset.rb +1 -9
  92. data/lib/htty/cli/display.rb +4 -6
  93. data/lib/htty/cli/http_method_command.rb +1 -10
  94. data/lib/htty/cli/input_device.rb +1 -0
  95. data/lib/htty/cli/url_escaping.rb +1 -6
  96. data/lib/htty/cookies_util.rb +3 -3
  97. data/lib/htty/headers.rb +3 -4
  98. data/lib/htty/http_patch.rb +20 -23
  99. data/lib/htty/no_header_error.rb +1 -1
  100. data/lib/htty/no_location_header_error.rb +1 -3
  101. data/lib/htty/no_response_error.rb +1 -1
  102. data/lib/htty/no_set_cookie_header_error.rb +1 -3
  103. data/lib/htty/payload.rb +1 -5
  104. data/lib/htty/platform.rb +1 -1
  105. data/lib/htty/preferences.rb +1 -1
  106. data/lib/htty/request.rb +3 -13
  107. data/lib/htty/requests_util.rb +1 -5
  108. data/lib/htty/response.rb +1 -4
  109. data/lib/htty/session.rb +1 -3
  110. data/lib/htty/tempfile_preserving_extname.rb +1 -2
  111. data/lib/htty/uri.rb +1 -2
  112. data/lib/htty/version.rb +1 -1
  113. data/lib/tasks.rb +3 -0
  114. data/lib/tasks/build_doc.rake +8 -0
  115. data/lib/tasks/lib_each.rake +25 -0
  116. data/lib/tasks/spec.rake +68 -0
  117. data/lib/tasks/spec_each.rake +19 -0
  118. metadata +48 -209
  119. data/bin/htty +0 -5
  120. data/spec/integration/htty/cli/commands/query_add_spec.rb +0 -57
  121. data/spec/integration/htty/cli/commands/query_remove_spec.rb +0 -55
  122. data/spec/integration/htty/cli/commands/query_set_spec.rb +0 -78
  123. data/spec/integration/htty/cli/commands/query_unset_spec.rb +0 -43
  124. data/spec/spec_helper.rb +0 -76
  125. data/spec/unit/htty/cli/commands/address_spec.rb +0 -103
  126. data/spec/unit/htty/cli/commands/body_clear_spec.rb +0 -64
  127. data/spec/unit/htty/cli/commands/body_edit_spec.rb +0 -18
  128. data/spec/unit/htty/cli/commands/body_request_spec.rb +0 -67
  129. data/spec/unit/htty/cli/commands/body_response_spec.rb +0 -72
  130. data/spec/unit/htty/cli/commands/body_set_spec.rb +0 -71
  131. data/spec/unit/htty/cli/commands/body_unset_spec.rb +0 -69
  132. data/spec/unit/htty/cli/commands/cd_spec.rb +0 -57
  133. data/spec/unit/htty/cli/commands/cookie_add_spec.rb +0 -64
  134. data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +0 -64
  135. data/spec/unit/htty/cli/commands/cookies_add_spec.rb +0 -78
  136. data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +0 -64
  137. data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +0 -73
  138. data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +0 -69
  139. data/spec/unit/htty/cli/commands/cookies_spec.rb +0 -76
  140. data/spec/unit/htty/cli/commands/cookies_use_spec.rb +0 -75
  141. data/spec/unit/htty/cli/commands/delete_spec.rb +0 -64
  142. data/spec/unit/htty/cli/commands/exit_spec.rb +0 -64
  143. data/spec/unit/htty/cli/commands/follow_spec.rb +0 -70
  144. data/spec/unit/htty/cli/commands/form_add_spec.rb +0 -64
  145. data/spec/unit/htty/cli/commands/form_clear_spec.rb +0 -64
  146. data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +0 -66
  147. data/spec/unit/htty/cli/commands/form_remove_spec.rb +0 -57
  148. data/spec/unit/htty/cli/commands/form_spec.rb +0 -57
  149. data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +0 -64
  150. data/spec/unit/htty/cli/commands/fragment_set_spec.rb +0 -73
  151. data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +0 -72
  152. data/spec/unit/htty/cli/commands/get_spec.rb +0 -64
  153. data/spec/unit/htty/cli/commands/header_set_spec.rb +0 -64
  154. data/spec/unit/htty/cli/commands/header_unset_spec.rb +0 -64
  155. data/spec/unit/htty/cli/commands/headers_clear_spec.rb +0 -64
  156. data/spec/unit/htty/cli/commands/headers_request_spec.rb +0 -81
  157. data/spec/unit/htty/cli/commands/headers_response_spec.rb +0 -77
  158. data/spec/unit/htty/cli/commands/headers_set_spec.rb +0 -74
  159. data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +0 -71
  160. data/spec/unit/htty/cli/commands/headers_unset_spec.rb +0 -63
  161. data/spec/unit/htty/cli/commands/help_spec.rb +0 -67
  162. data/spec/unit/htty/cli/commands/history_spec.rb +0 -65
  163. data/spec/unit/htty/cli/commands/history_verbose_spec.rb +0 -72
  164. data/spec/unit/htty/cli/commands/host_set_spec.rb +0 -71
  165. data/spec/unit/htty/cli/commands/http_delete_spec.rb +0 -75
  166. data/spec/unit/htty/cli/commands/http_get_spec.rb +0 -77
  167. data/spec/unit/htty/cli/commands/http_head_spec.rb +0 -69
  168. data/spec/unit/htty/cli/commands/http_options_spec.rb +0 -69
  169. data/spec/unit/htty/cli/commands/http_patch_spec.rb +0 -73
  170. data/spec/unit/htty/cli/commands/http_post_spec.rb +0 -73
  171. data/spec/unit/htty/cli/commands/http_put_spec.rb +0 -71
  172. data/spec/unit/htty/cli/commands/http_trace_spec.rb +0 -69
  173. data/spec/unit/htty/cli/commands/patch_spec.rb +0 -64
  174. data/spec/unit/htty/cli/commands/path_set_spec.rb +0 -72
  175. data/spec/unit/htty/cli/commands/port_set_spec.rb +0 -73
  176. data/spec/unit/htty/cli/commands/post_spec.rb +0 -64
  177. data/spec/unit/htty/cli/commands/put_spec.rb +0 -64
  178. data/spec/unit/htty/cli/commands/query_add_spec.rb +0 -82
  179. data/spec/unit/htty/cli/commands/query_clear_spec.rb +0 -64
  180. data/spec/unit/htty/cli/commands/query_remove_spec.rb +0 -82
  181. data/spec/unit/htty/cli/commands/query_set_spec.rb +0 -82
  182. data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +0 -74
  183. data/spec/unit/htty/cli/commands/query_unset_spec.rb +0 -75
  184. data/spec/unit/htty/cli/commands/quit_spec.rb +0 -64
  185. data/spec/unit/htty/cli/commands/reuse_spec.rb +0 -72
  186. data/spec/unit/htty/cli/commands/scheme_set_spec.rb +0 -74
  187. data/spec/unit/htty/cli/commands/shared_examples_for_commands.rb +0 -55
  188. data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +0 -67
  189. data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +0 -60
  190. data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +0 -65
  191. data/spec/unit/htty/cli/commands/status_spec.rb +0 -73
  192. data/spec/unit/htty/cli/commands/undo_spec.rb +0 -57
  193. data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +0 -64
  194. data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +0 -97
  195. data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +0 -72
  196. data/spec/unit/htty/cli/display_spec.rb +0 -84
  197. data/spec/unit/htty/cli_spec.rb +0 -28
  198. data/spec/unit/htty/command.rb +0 -47
  199. data/spec/unit/htty/headers_spec.rb +0 -40
  200. data/spec/unit/htty/payload_spec.rb +0 -60
  201. data/spec/unit/htty/preferences_spec.rb +0 -8
  202. data/spec/unit/htty/request_follow_spec.rb +0 -94
  203. data/spec/unit/htty/request_spec.rb +0 -1232
  204. data/spec/unit/htty/request_userinfo_spec.rb +0 -208
  205. data/spec/unit/htty/response_spec.rb +0 -0
  206. data/spec/unit/htty/session_spec.rb +0 -10
  207. data/spec/unit/htty/shared_examples_for_requests.rb +0 -32
  208. data/spec/unit/htty/url_escaping.rb +0 -70
  209. data/spec/unit/htty/version_spec.rb +0 -8
@@ -1,11 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/../command")
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 File.expand_path("#{File.dirname __FILE__}/../../request")
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 File.expand_path("#{File.dirname __FILE__}/../command")
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
@@ -1,6 +1,4 @@
1
- module HTTY; end
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 do |line|
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
- end.join("\n").split("\n").collect do |line|
179
+ }.join("\n").split("\n").collect { |line|
182
180
  indent line, indent_by
183
- end.join "\n"
181
+ }.join "\n"
184
182
  end
185
183
 
186
184
  private
@@ -1,13 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/display")
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,3 +1,4 @@
1
+ require 'htty'
1
2
  require 'readline'
2
3
 
3
4
  module HTTY::CLI::InputDevice
@@ -1,9 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/display")
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
@@ -1,4 +1,4 @@
1
- module HTTY; end
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 do |name, value|
24
+ cookies.collect { |name, value|
25
25
  [name, value].compact.join COOKIE_NAME_VALUE_DELIMITER
26
- end.join COOKIES_DELIMITER
26
+ }.join COOKIES_DELIMITER
27
27
  end
28
28
 
29
29
  protected
@@ -1,7 +1,6 @@
1
- require 'uri'
2
1
  require 'base64'
3
-
4
- module HTTY; end
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 *credentials if block_given?
76
+ return yield(*credentials) if block_given?
78
77
  return credentials
79
78
  end
80
79
  end
@@ -1,35 +1,32 @@
1
1
  require 'net/http'
2
2
 
3
- unless Net::HTTP.const_defined?(:Patch) &&
4
- Net::HTTP.instance_methods.collect(&:to_sym).include?(:patch)
5
- module Net
3
+ module Net
6
4
 
7
- class HTTP < Protocol
5
+ class HTTP < Protocol
8
6
 
9
- # Represents a HTTP PATCH request. This class exists because Net::HTTP did
10
- # not have this behavior in Ruby v1.9.2 and earlier.
11
- class Patch < HTTPRequest
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
- METHOD = 'PATCH'
14
- REQUEST_HAS_BODY = true
15
- RESPONSE_HAS_BODY = true
11
+ METHOD = 'PATCH'
12
+ REQUEST_HAS_BODY = true
13
+ RESPONSE_HAS_BODY = true
16
14
 
17
- end
15
+ end
18
16
 
19
- def patch(path, data, initheader, &block)
20
- res = nil
21
- request(Patch.new(path, initheader), data) do |r|
22
- r.read_body(nil, &block)
23
- res = r
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
@@ -1,4 +1,4 @@
1
- module HTTY; end
1
+ require 'htty'
2
2
 
3
3
  # Indicates that an header could not be found in a HTTY::Payload
4
4
  class HTTY::NoHeaderError < StandardError
@@ -1,6 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/response")
2
-
3
- module HTTY; end
1
+ require 'htty'
4
2
 
5
3
  # Indicates that the _Location_ header was missing from HTTY::Request#response.
6
4
  class HTTY::NoLocationHeaderError < StandardError
@@ -1,4 +1,4 @@
1
- module HTTY; end
1
+ require 'htty'
2
2
 
3
3
  # Indicates that HTTY::Request#response was missing.
4
4
  class HTTY::NoResponseError < StandardError
@@ -1,6 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/response")
2
-
3
- module HTTY; end
1
+ require 'htty'
4
2
 
5
3
  # Indicates that the _Set-Cookie_ header was missing from
6
4
  # HTTY::Request#response.
@@ -1,8 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/headers")
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
@@ -1,4 +1,4 @@
1
- module HTTY; end
1
+ require 'htty'
2
2
 
3
3
  # Provides methods for ascertaining system characteristics.
4
4
  module HTTY::Platform
@@ -1,4 +1,4 @@
1
- module HTTY; end
1
+ require 'htty'
2
2
 
3
3
  # Encapsulates _htty_ user preferences.
4
4
  class HTTY::Preferences
@@ -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 do |cookie_name, cookie_value|
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
- end.reverse
205
+ }.reverse
216
206
 
217
207
  cookies_string = HTTY::CookiesUtil.cookies_to_string(new_cookies)
218
208
  if cookies_string
@@ -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
@@ -1,7 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/cookies_util")
2
- require File.expand_path("#{File.dirname __FILE__}/payload")
3
-
4
- module HTTY; end
1
+ require 'htty'
5
2
 
6
3
  # Encapsulates an HTTP(S) response.
7
4
  class HTTY::Response < HTTY::Payload
@@ -1,6 +1,4 @@
1
- require File.expand_path("#{File.dirname __FILE__}/request")
2
-
3
- module HTTY; end
1
+ require 'htty'
4
2
 
5
3
  # Encapsulates an _htty_ session.
6
4
  class HTTY::Session
@@ -1,7 +1,6 @@
1
+ require 'htty'
1
2
  require 'tempfile'
2
3
 
3
- module HTTY; end
4
-
5
4
  # Adds file-extension-preservation behavior to Tempfile.
6
5
  class HTTY::TempfilePreservingExtname < Tempfile
7
6
 
@@ -1,7 +1,6 @@
1
+ require 'htty'
1
2
  require 'uri'
2
3
 
3
- module HTTY; end
4
-
5
4
  class HTTY::URI
6
5
  # There's a lot of confusion about this, the default implementation
7
6
  # of URI.escape is marked as "obsolete", CGI.escape does another work,
@@ -1,6 +1,6 @@
1
1
  module HTTY
2
2
 
3
3
  # The version of this release of _htty_.
4
- VERSION = '1.5.4' unless const_defined?(:VERSION)
4
+ VERSION = '1.5.5'
5
5
 
6
6
  end
@@ -0,0 +1,3 @@
1
+ Dir.glob "#{File.dirname __FILE__}/#{File.basename __FILE__, '.rb'}/*.rake" do |f|
2
+ load f
3
+ end
@@ -0,0 +1,8 @@
1
+ begin
2
+ require 'yard'
3
+ rescue LoadError
4
+ else
5
+ namespace :build do
6
+ YARD::Rake::YardocTask.new :doc
7
+ end
8
+ end
@@ -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
@@ -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