htty 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -1
  3. data/.rspec +2 -0
  4. data/.travis.yml +21 -3
  5. data/.yardopts +1 -1
  6. data/Gemfile +2 -2
  7. data/Guardfile +12 -10
  8. data/History.markdown +14 -0
  9. data/{MIT-LICENSE.markdown → License.markdown} +1 -1
  10. data/README.markdown +50 -65
  11. data/Rakefile +2 -2
  12. data/htty.gemspec +2 -2
  13. data/lib/htty/cli.rb +59 -74
  14. data/lib/htty/cli/command.rb +21 -20
  15. data/lib/htty/cli/commands/body_edit.rb +89 -0
  16. data/lib/htty/cli/commands/query_add.rb +3 -0
  17. data/lib/htty/cli/commands/query_set.rb +3 -0
  18. data/lib/htty/cli/commands/userinfo_set.rb +8 -14
  19. data/lib/htty/cli/display.rb +14 -12
  20. data/lib/htty/cli/input_device.rb +75 -0
  21. data/lib/htty/cli/url_escaping.rb +2 -2
  22. data/lib/htty/headers.rb +81 -0
  23. data/lib/htty/no_header_error.rb +10 -0
  24. data/lib/htty/payload.rb +22 -9
  25. data/lib/htty/request.rb +67 -43
  26. data/lib/htty/requests_util.rb +22 -8
  27. data/lib/htty/response.rb +20 -1
  28. data/lib/htty/uri.rb +16 -0
  29. data/lib/htty/version.rb +1 -1
  30. data/spec/integration/htty/cli/commands/query_add_spec.rb +7 -1
  31. data/spec/integration/htty/cli/commands/query_remove_spec.rb +19 -1
  32. data/spec/integration/htty/cli/commands/query_set_spec.rb +9 -3
  33. data/spec/integration/htty/cli/commands/query_unset_spec.rb +8 -2
  34. data/spec/spec_helper.rb +69 -0
  35. data/spec/unit/htty/cli/commands/address_spec.rb +1 -1
  36. data/spec/unit/htty/cli/commands/body_clear_spec.rb +1 -1
  37. data/spec/unit/htty/cli/commands/body_edit_spec.rb +18 -0
  38. data/spec/unit/htty/cli/commands/body_request_spec.rb +1 -1
  39. data/spec/unit/htty/cli/commands/body_response_spec.rb +1 -1
  40. data/spec/unit/htty/cli/commands/body_set_spec.rb +1 -1
  41. data/spec/unit/htty/cli/commands/body_unset_spec.rb +1 -1
  42. data/spec/unit/htty/cli/commands/cd_spec.rb +1 -1
  43. data/spec/unit/htty/cli/commands/cookie_add_spec.rb +1 -1
  44. data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +1 -1
  45. data/spec/unit/htty/cli/commands/cookies_add_spec.rb +1 -1
  46. data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +1 -1
  47. data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +1 -1
  48. data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +1 -1
  49. data/spec/unit/htty/cli/commands/cookies_spec.rb +1 -1
  50. data/spec/unit/htty/cli/commands/cookies_use_spec.rb +1 -1
  51. data/spec/unit/htty/cli/commands/delete_spec.rb +1 -1
  52. data/spec/unit/htty/cli/commands/exit_spec.rb +1 -1
  53. data/spec/unit/htty/cli/commands/follow_spec.rb +1 -1
  54. data/spec/unit/htty/cli/commands/form_add_spec.rb +1 -1
  55. data/spec/unit/htty/cli/commands/form_clear_spec.rb +1 -1
  56. data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +1 -1
  57. data/spec/unit/htty/cli/commands/form_remove_spec.rb +1 -1
  58. data/spec/unit/htty/cli/commands/form_spec.rb +1 -1
  59. data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +1 -1
  60. data/spec/unit/htty/cli/commands/fragment_set_spec.rb +1 -1
  61. data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +1 -1
  62. data/spec/unit/htty/cli/commands/get_spec.rb +1 -1
  63. data/spec/unit/htty/cli/commands/header_set_spec.rb +1 -1
  64. data/spec/unit/htty/cli/commands/header_unset_spec.rb +1 -1
  65. data/spec/unit/htty/cli/commands/headers_clear_spec.rb +1 -1
  66. data/spec/unit/htty/cli/commands/headers_request_spec.rb +1 -1
  67. data/spec/unit/htty/cli/commands/headers_response_spec.rb +1 -1
  68. data/spec/unit/htty/cli/commands/headers_set_spec.rb +1 -1
  69. data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +1 -1
  70. data/spec/unit/htty/cli/commands/headers_unset_spec.rb +1 -1
  71. data/spec/unit/htty/cli/commands/help_spec.rb +1 -1
  72. data/spec/unit/htty/cli/commands/history_spec.rb +1 -1
  73. data/spec/unit/htty/cli/commands/history_verbose_spec.rb +1 -1
  74. data/spec/unit/htty/cli/commands/host_set_spec.rb +1 -1
  75. data/spec/unit/htty/cli/commands/http_delete_spec.rb +1 -1
  76. data/spec/unit/htty/cli/commands/http_get_spec.rb +1 -1
  77. data/spec/unit/htty/cli/commands/http_head_spec.rb +1 -1
  78. data/spec/unit/htty/cli/commands/http_options_spec.rb +1 -1
  79. data/spec/unit/htty/cli/commands/http_patch_spec.rb +1 -1
  80. data/spec/unit/htty/cli/commands/http_post_spec.rb +1 -1
  81. data/spec/unit/htty/cli/commands/http_put_spec.rb +1 -1
  82. data/spec/unit/htty/cli/commands/http_trace_spec.rb +1 -1
  83. data/spec/unit/htty/cli/commands/patch_spec.rb +1 -1
  84. data/spec/unit/htty/cli/commands/path_set_spec.rb +1 -1
  85. data/spec/unit/htty/cli/commands/port_set_spec.rb +1 -1
  86. data/spec/unit/htty/cli/commands/post_spec.rb +1 -1
  87. data/spec/unit/htty/cli/commands/put_spec.rb +1 -1
  88. data/spec/unit/htty/cli/commands/query_add_spec.rb +1 -1
  89. data/spec/unit/htty/cli/commands/query_clear_spec.rb +1 -1
  90. data/spec/unit/htty/cli/commands/query_remove_spec.rb +1 -1
  91. data/spec/unit/htty/cli/commands/query_set_spec.rb +1 -1
  92. data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +1 -1
  93. data/spec/unit/htty/cli/commands/query_unset_spec.rb +1 -1
  94. data/spec/unit/htty/cli/commands/quit_spec.rb +1 -1
  95. data/spec/unit/htty/cli/commands/reuse_spec.rb +1 -1
  96. data/spec/unit/htty/cli/commands/scheme_set_spec.rb +1 -1
  97. data/spec/unit/htty/cli/commands/shared_examples_for_commands.rb +55 -0
  98. data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +1 -1
  99. data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +1 -1
  100. data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +1 -1
  101. data/spec/unit/htty/cli/commands/status_spec.rb +1 -1
  102. data/spec/unit/htty/cli/commands/undo_spec.rb +1 -1
  103. data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +1 -1
  104. data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +23 -1
  105. data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +1 -1
  106. data/spec/unit/htty/cli/display_spec.rb +84 -0
  107. data/spec/unit/htty/cli_spec.rb +1 -1
  108. data/spec/unit/htty/command.rb +47 -0
  109. data/spec/unit/htty/{ordered_hash_spec.rb → headers_spec.rb} +4 -4
  110. data/spec/unit/htty/payload_spec.rb +60 -0
  111. data/spec/unit/htty/preferences_spec.rb +1 -1
  112. data/spec/unit/htty/request_follow_spec.rb +94 -0
  113. data/spec/unit/htty/request_spec.rb +5 -187
  114. data/spec/unit/htty/request_userinfo_spec.rb +208 -0
  115. data/spec/unit/htty/session_spec.rb +1 -1
  116. data/spec/unit/htty/shared_examples_for_requests.rb +32 -0
  117. data/spec/unit/htty/url_escaping.rb +70 -0
  118. data/spec/unit/htty/version_spec.rb +1 -1
  119. metadata +43 -30
  120. data/lib/htty/ordered_hash.rb +0 -68
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3b290d26fc218bc076d46a221d175b42e90eb80
4
+ data.tar.gz: 3f69157993072a96e5d052a89b847bd874ac9570
5
+ SHA512:
6
+ metadata.gz: 6970d457cec829c0f55020e681d5bf898a6a74d48c7004ed0397b75ff5ddb7823a90a1c924504eebc7177ea9a9863fd75ac131d3f743ca971f135ec21cb475ff
7
+ data.tar.gz: 18e1e0ef5c813c95ce3be0afb08a8f8c3f7241d744964c2a0ae7dae99f919dacb02181ee5305bf945dd7e14d3e0b426f36b4e8af91fd4292b9eef434bfef1a66
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  .bundle/
2
2
  .rbx
3
- .rvmrc
3
+ .ruby-gemset
4
+ .ruby-version
4
5
  .yardoc/
5
6
  *.gem
6
7
  Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml CHANGED
@@ -1,10 +1,28 @@
1
+ language: ruby
1
2
  bundler_args: --without debug doc tooling
2
3
  rvm:
3
4
  - 1.8.7
4
5
  - 1.9.2
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.0
9
+ - ruby-head
5
10
  - ree
6
- - jruby
7
- - rbx
11
+ - jruby-18mode
12
+ - jruby-19mode
13
+ - jruby-head
14
+ - rbx-18mode
15
+ - rbx-19mode
16
+ - rbx-head
8
17
  notifications:
9
18
  irc: "irc.freenode.org#htty"
10
- script: "bundle exec rake"
19
+ script: "bundle exec rake test"
20
+ matrix:
21
+ allow_failures:
22
+ - rvm: ruby-head
23
+ - rvm: jruby-18mode
24
+ - rvm: jruby-19mode
25
+ - rvm: jruby-head
26
+ - rvm: rbx-18mode
27
+ - rvm: rbx-19mode
28
+ - rvm: rbx-head
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --file MIT-LICENSE.markdown --file History.markdown --no-private --protected --title "htty, the HTTP TTY"
1
+ --file History.markdown --file License.markdown --no-private --protected --title "htty, the HTTP TTY"
data/Gemfile CHANGED
@@ -11,11 +11,11 @@ end
11
11
 
12
12
  group :doc do
13
13
  gem 'yard', '~> 0', :platforms => [:ruby, :mswin, :mingw]
14
- gem 'rdiscount', '~> 1', :platforms => [:ruby, :mswin, :mingw]
14
+ gem 'rdiscount', :platforms => [:ruby, :mswin, :mingw]
15
15
  end
16
16
 
17
17
  group :tooling do
18
- gem 'guard-rspec', '~> 1'
18
+ gem 'guard-rspec', '~> 3'
19
19
  if RUBY_PLATFORM =~ /darwin/i
20
20
  gem 'rb-fsevent', '~> 0', :require => false
21
21
  end
data/Guardfile CHANGED
@@ -1,17 +1,19 @@
1
- guard 'rspec', :cli => '--color', :version => 2 do
2
- # Run the corresponding spec (or all specs) when code changes.
3
- watch( %r{^lib/(.+)\.rb$} ) do |match|
4
- corresponding_specs = %W(spec/integration/#{match[1]}_spec.rb
5
- spec/unit/#{match[1]}_spec.rb)
6
- existing = corresponding_specs.select do |s|
7
- File.file? File.expand_path( "../#{s}", __FILE__ )
8
- end
9
- existing.empty? ? 'spec' : existing
1
+ interactor :off
2
+
3
+ guard :rspec, :cli => '--debug' do
4
+ # Run the corresponding spec(s) (or all specs) when code changes.
5
+ watch(%r{^lib/(.+)\.rb$}) do |match|
6
+ corresponding_specs = Dir["spec/{integration,unit}/#{match[1]}_spec.rb"]
7
+ corresponding_specs.empty? ? 'spec' : corresponding_specs
10
8
  end
11
9
 
12
10
  # Run a spec when it changes.
13
11
  watch %r{^spec/.+_spec\.rb$}
14
12
 
13
+ # Run all specs when the RSpec configuration changes.
14
+ watch('.rspec' ) { 'spec' }
15
+ watch('spec/spec_helper.rb') { 'spec' }
16
+
15
17
  # Run all specs when the bundle changes.
16
- watch( 'Gemfile.lock' ) { 'spec' }
18
+ watch('Gemfile.lock') { 'spec' }
17
19
  end
data/History.markdown CHANGED
@@ -1,6 +1,20 @@
1
1
  Version history for the _htty_ project
2
2
  ======================================
3
3
 
4
+ <a name="v1.5.0"></a>v1.5.0, Tue 4/01/2014
5
+ -------------------------------------------
6
+
7
+ * Added support for Ruby v1.9.3, v2.0, and v2.1 \[with help from [gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")\]
8
+ * Added the `body-edit` command for using `$EDITOR` to manipulate the request body [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
9
+ * Added support for following relative URIs in _Location_ response headers [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
10
+ * Added support for automatically URL-encoding reserved characters such as _?_ [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
11
+ * Added support for automatically synchronizing userinfo and the _Authorization_ request header [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
12
+ * Improved support for scripting via _stdin_ [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
13
+ * Added support for case-insensitive editing of request headers [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
14
+ * Fixed a bug that mangled the prompt upon backspace [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
15
+ * Fixed bugs in the `query-*` commands [[gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub")]
16
+ * Updated and refined dependencies
17
+
4
18
  <a name="v1.4.1"></a>v1.4.1, Wed 9/26/2012
5
19
  -------------------------------------------
6
20
 
@@ -1,7 +1,7 @@
1
1
  The MIT License
2
2
  ===============
3
3
 
4
- Source code for _htty_ is Copyright © 2010–2012 [Nils Jonsson](mailto:htty@nilsjonsson.com) and [contributors](http://github.com/htty/htty/contributors "htty contributors at GitHub").
4
+ Source code for _htty_ is Copyright © 2010–2014 [Nils Jonsson](mailto:htty@nilsjonsson.com) and [contributors](http://github.com/htty/htty/contributors "htty contributors at GitHub").
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
7
 
data/README.markdown CHANGED
@@ -27,21 +27,26 @@
27
27
  |____| |____| / ______|
28
28
  \/
29
29
 
30
- [<img align="right" src="https://gemnasium.com/htty/htty.png" title="Gemnasium build status" />](http://gemnasium.com/htty/htty) [<img align="right" src="https://secure.travis-ci.org/htty/htty.png?branch=master" title="Travis CI build status" />](http://travis-ci.org/htty/htty) [htty](http://htty.github.com) is a console application for interacting with web servers. It’s a fun way to explore web APIs and to learn the ins and outs of HTTP.
30
+ [htty](http://htty.github.io) is a console application for interacting with web servers. It’s a fun way to explore web APIs and to learn the ins and outs of HTTP.
31
31
 
32
- See what’s changed lately by reading the [project history](http://htty.github.com/file.History.html).
32
+ [![Travis CI build status]](http://travis-ci.org/htty/htty "Travis CI build status")
33
+ [![Gemnasium build status]](http://gemnasium.com/htty/htty "Gemnasium build status")
34
+ [![Code Climate report] ](http://codeclimate.com/github/htty/htty "Code Climate report")
35
+ [![RubyGems release] ](http://rubygems.org/gems/htty "RubyGems release")
33
36
 
34
- <a name="installation"></a>Installation
35
- =======================================
37
+ See what’s changed lately by reading the [project history](http://github.com/htty/htty/blob/master/History.markdown).
38
+
39
+ Installation
40
+ ============
36
41
 
37
42
  It couldn’t be much easier.
38
43
 
39
44
  $ gem install htty
40
45
 
41
- You’ll need Ruby and RubyGems. It’s known to work well under OS X against Ruby v1.8.7 and v1.9.2.
46
+ You’ll need Ruby and RubyGems. It’s known to work well under OS X against Ruby v1.8.7, v1.9.2, v1.9.3, v2.0, and v2.1.
42
47
 
43
- <a name="features"></a>Features
44
- ===============================
48
+ Features
49
+ ========
45
50
 
46
51
  * Intuitive, Tab-completed commands and command aliases
47
52
  * Support for familiar HTTP methods _GET_, _POST_, _PUT_, and _DELETE_, as well as _PATCH_, _HEAD_, _OPTIONS_ and _TRACE_
@@ -60,17 +65,17 @@ The things you can do with _htty_ are:
60
65
  * **Review history** — a normal and a verbose transcript of your session are available at all times (destroyed when you quit _htty_)
61
66
  * **Reuse previous requests** — you can refer to prior requests and copy them
62
67
 
63
- <a name="examples"></a>Examples
64
- ===============================
68
+ Examples
69
+ ========
65
70
 
66
71
  Here are a few annotated _htty_ session transcripts to get you started.
67
72
 
68
- <a name="basic-example"></a>Querying a web service
69
- --------------------------------------------------
73
+ Querying a web service
74
+ ----------------------
70
75
 
71
76
  This simple example shows how to explore a read-only web service with _htty_.
72
77
 
73
- ![ESV Bible Web Service example #1](http://htty.github.com/images/esvapi1.png)
78
+ ![ESV Bible Web Service example #1](http://htty.github.io/images/esvapi1.png)
74
79
 
75
80
  You can point _htty_ at a complete or partial web URL. If you don’t supply a URL, http://0.0.0.0/ (port 80) will be used. You can vary the protocol scheme, userinfo, host, port, path, query string, and fragment as you wish.
76
81
 
@@ -80,17 +85,17 @@ The `get` command is one of seven HTTP request methods supported. A concise summ
80
85
 
81
86
  You can follow redirects using the `follow` command. No request is made until you type a request command such as `get` or `post`.
82
87
 
83
- ![ESV Bible Web Service example #2](http://htty.github.com/images/esvapi2.png)
88
+ ![ESV Bible Web Service example #2](http://htty.github.io/images/esvapi2.png)
84
89
 
85
90
  You can tweak segments of the address at will. Here we are navigating the site’s path hierarchy, which you can do with relative as well as absolute pathspecs.
86
91
 
87
- ![ESV Bible Web Service example #3](http://htty.github.com/images/esvapi3.png)
92
+ ![ESV Bible Web Service example #3](http://htty.github.io/images/esvapi3.png)
88
93
 
89
94
  Here we add query-string parameters. Notice that characters that require URL encoding are automatically URL-encoded (unless they are part of a URL-encoded expression).
90
95
 
91
96
  The `headers-response` and `body-response` commands reveal the details of a response.
92
97
 
93
- ![ESV Bible Web Service example #4](http://htty.github.com/images/esvapi4.png)
98
+ ![ESV Bible Web Service example #4](http://htty.github.io/images/esvapi4.png)
94
99
 
95
100
  There was some cruft in the web service’s response (a horizontal line, a passage reference, verse numbers, a copyright stamp, and line breaks). We eliminate it by using API options provided by the web service we’re talking to.
96
101
 
@@ -98,22 +103,22 @@ We do a Julia Child maneuver and use the `address` command to change the entire
98
103
 
99
104
  Exit your session at any time by typing `quit` or hitting Ctrl-D.
100
105
 
101
- <a name="cookies-example"></a>Working with cookies
102
- --------------------------------------------------
106
+ Working with cookies
107
+ --------------------
103
108
 
104
109
  The next example demonstrates <i>htty</i>’s HTTP Secure support and cookies features, as well as how to review and revisit past requests.
105
110
 
106
- ![Google example #1](http://htty.github.com/images/google1.png)
111
+ ![Google example #1](http://htty.github.io/images/google1.png)
107
112
 
108
113
  The _https://_ scheme and port 443 imply each other, just as the _http://_ scheme and port 80 imply each other. If you omit the scheme or the port, it will default to the appropriate value.
109
114
 
110
115
  Notice that when cookies are offered in a response, a bold asterisk (it looks like a cookie) appears in the response summary. The same cookie symbol appears next to the _Set-Cookie_ header when you display response headers.
111
116
 
112
- ![Google example #2](http://htty.github.com/images/google2.png)
117
+ ![Google example #2](http://htty.github.io/images/google2.png)
113
118
 
114
119
  The `cookies-use` command copies cookies out of the response into the next request. The cookie symbol appears next to the _Cookie_ header when you display request headers.
115
120
 
116
- ![Google example #3](http://htty.github.com/images/google3.png)
121
+ ![Google example #3](http://htty.github.io/images/google3.png)
117
122
 
118
123
  An abbreviated history is available through the `history` command. Information about requests in the history includes request method, URL, number of headers (and a cookie symbol, if cookies were sent), and the size of the body. Information about responses in the history includes response code, number of headers (and a cookie symbol, if cookies were received), and the size of the body.
119
124
 
@@ -121,8 +126,8 @@ Note that history contains only numbered HTTP request and response pairs, not a
121
126
 
122
127
  The `reuse` command makes a copy of the headers and body of an earlier request for you to build on.
123
128
 
124
- <a name="history-example"></a>Understanding complex HTTP conversations at a glance using history
125
- ------------------------------------------------------------------------------------------------
129
+ Understanding complex HTTP conversations at a glance using history
130
+ ------------------------------------------------------------------
126
131
 
127
132
  Now we’ll look at <i>htty</i>’s HTTP Basic Authentication support and learn how to display unabbreviated transcripts of _htty_ sessions.
128
133
 
@@ -148,11 +153,11 @@ Assume that we have the following Sinatra application listening on Sinatra’s d
148
153
 
149
154
  This application expects _GET_ and _POST_ requests and responds in various contrived ways.
150
155
 
151
- ![Sinatra application example #1](http://htty.github.com/images/sinatra1.png)
156
+ ![Sinatra application example #1](http://htty.github.io/images/sinatra1.png)
152
157
 
153
158
  When you change the userinfo portion of the address, or the entire address, the appropriate HTTP Basic Authentication header is created for you automatically. Notice that characters that require URL encoding are automatically URL-encoded (unless they are part of a URL-encoded expression).
154
159
 
155
- When userinfo is supplied in a request, a bold mercantile symbol (_@_) appears next to the resulting _Authorization_ header when you display request headers (see below).
160
+ When userinfo is supplied in a request, a bold mercantile symbol ( _@_ ) appears next to the resulting _Authorization_ header when you display request headers (see below).
156
161
 
157
162
  Type `body-set` to enter body data, and terminate it by entering two consecutive blank lines, or by hitting Ctrl-D. The body will only be sent for _POST_ and _PUT_ requests. The appropriate _Content-Length_ header is created for you automatically (see below).
158
163
 
@@ -163,76 +168,56 @@ Different response codes are rendered with colors that suggest their meaning:
163
168
  * Response codes between 400 and 499 appear <span style="background-color: darkred; color: white; font-weight: bold; padding: 0 0.25em 0 0.25em;">white on red</span> to indicate failure
164
169
  * Response codes between 500 and 599 appear <span style="background-color: yellow; color: black; font-weight: bold; padding: 0 0.25em 0 0.25em; text-decoration: blink;">flashing black on yellow</span> to indicate a server error
165
170
 
166
- ![Sinatra application example #2](http://htty.github.com/images/sinatra2.png)
171
+ ![Sinatra application example #2](http://htty.github.io/images/sinatra2.png)
167
172
 
168
173
  As with the abbreviated history demonstrated earlier, verbose history shows a numbered list of requests and the responses they elicited. All information exchanged between client and server is shown.
169
174
 
170
- <a name="help"></a>Getting help
171
- -------------------------------
175
+ Getting help
176
+ ------------
172
177
 
173
178
  You can learn how to use _htty_ commands from within _htty_.
174
179
 
175
- ![htty’s built-in help](http://htty.github.com/images/help.png)
180
+ ![htty’s built-in help](http://htty.github.io/images/help.png)
176
181
 
177
182
  The `help` command takes an optional argument of the abbreviated or full name of a command.
178
183
 
179
- <a name="coming-soon"></a>Coming soon
180
- =====================================
181
-
182
- Here are some features that are coming down the pike.
183
-
184
- <a name="forms-coming-soon"></a>Commands for streamlining web form submission
185
- -----------------------------------------------------------------------------
186
-
187
- These features will make _htty_ better at screen-scraping.
188
-
189
- Using any of the forthcoming `form` commands will clear any non-form content in the body of the request. Adding at least one URL-encoded form parameter to the request will set the _Content-Type_ header to _application/x-www-form-urlencoded_. Removing all URL-encoded form parameters will remove this header.
190
-
191
- * `form` — display all form parameters offered in the response
192
- * `form-fill` — prompt in turn for a value for each of the form inputs in the response
193
- * <code>form-add _name_ _value_</code> — add a URL-encoded form parameter for the request, using the specified name and value
194
- * <code>form-remove _name_</code> — remove a URL-encoded form parameter from the request, using the specified name
195
- * `form-remove-all` — remove all URL-encoded form parameters from the request
196
-
197
- You will also be able to pop open a browser window containing request and response bodies.
198
-
199
- <a name="custom-aliases-coming-soon"></a>Custom command aliases and shell emulation of _http-console_
200
- -----------------------------------------------------------------------------------------------------
201
-
202
- You should be able to make your own command aliases.
203
-
204
- _http-console_ has a nice command-line. We should have an _http-console_ skin for _htty_.
205
-
206
- <a name="contributing"></a>Contributing
207
- =======================================
184
+ Contributing
185
+ ============
208
186
 
209
187
  Report defects and feature requests on [GitHub Issues](http://github.com/htty/htty/issues).
210
188
 
211
189
  Your patches are welcome, and you will receive attribution here for good stuff. Fork [the official _htty_ repository](http://github.com/htty/htty "htty’s ‘htty’ repository at GitHub") and send a pull request.
212
190
 
213
- <a name="contact"></a>News and information
214
- ==========================================
191
+ News and information
192
+ ====================
215
193
 
216
194
  Stay in touch with the _htty_ project by following [@get_htty](http://twitter.com/get_htty "get_htty at Twitter") on Twitter.
217
195
 
218
196
  You can also get help in the [#htty channel on Freenode](http://webchat.freenode.net/?channels=htty).
219
197
 
220
- <a name="credits"></a>Credits
221
- =============================
198
+ Credits
199
+ =======
222
200
 
223
201
  The author, [Nils Jonsson](mailto:htty@nilsjonsson.com), owes a debt of inspiration to the [_http-console_](http://github.com/cloudhead/http-console) project.
224
202
 
225
203
  Thanks to [contributors](http://github.com/htty/htty/contributors "htty contributors at GitHub") (in alphabetical order):
226
204
 
205
+ * Pascal Borreli ([pborreli](http://github.com/pborreli "pborreli at GitHub"))
227
206
  * Rob Dawson (ephox-rob/[rojotek](http://github.com/rojotek "rojotek at GitHub"))
228
207
  * Bo Frederiksen ([bofrede](http://github.com/bofrede "bofrede at GitHub"))
229
208
  * Johannes Gorset ([jgorset](http://github.com/jgorset "jgorset at GitHub"))
209
+ * Gabriele Lana ([gabrielelana](http://github.com/gabrielelana "gabrielelana at GitHub"))
230
210
  * Carson McDonald ([carsonmcdonald](http://github.com/carsonmcdonald "carsonmcdonald at GitHub"))
231
- * Sam X ([dtjm](http://github.com/dtjm "dtjm at GitHub"))
211
+ * Sam Nguyen ([dtjm](http://github.com/dtjm "dtjm at GitHub"))
232
212
  * Robert Pitts ([rbxbx](http://github.com/rbxbx "rbxbx at GitHub"))
233
213
  * Matt Sanders ([nextmat](http://github.com/nextmat "nextmat at GitHub"))
234
214
 
235
- <a name="license"></a>License
236
- =============================
215
+ License
216
+ =======
217
+
218
+ Released under the [MIT License](http://github.com/htty/htty/blob/master/License.markdown).
237
219
 
238
- Released under the [MIT License](http://htty.github.com/file.MIT-LICENSE.html).
220
+ [Travis CI build status]: https://secure.travis-ci.org/htty/htty.png?branch=master
221
+ [Gemnasium build status]: https://gemnasium.com/htty/htty.png
222
+ [Code Climate report]: https://codeclimate.com/github/htty/htty.png
223
+ [RubyGems release]: https://badge.fury.io/rb/htty.png
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ namespace :lib do
23
23
  if verbose?
24
24
  puts "* #{f}"
25
25
  else
26
- print "\x1b[1;32m.\x1b[0m"
26
+ print "\e[32m.\e[0m"
27
27
  end
28
28
  command = "/usr/bin/env ruby -e 'require File.expand_path(#{f.inspect})'"
29
29
  break unless system(command)
@@ -34,7 +34,7 @@ end
34
34
 
35
35
  def define_spec_task(name, options={})
36
36
  RSpec::Core::RakeTask.new name do |t|
37
- t.rspec_opts = ['--color']
37
+ t.rspec_opts ||= []
38
38
  unless options[:debug] == false
39
39
  begin
40
40
  require 'ruby-debug'
data/htty.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['Nils Jonsson']
10
10
  s.email = ['htty@nilsjonsson.com']
11
- s.homepage = 'http://htty.github.com'
11
+ s.homepage = 'http://htty.github.io'
12
12
  s.summary = 'The HTTP TTY'
13
13
  s.description = <<-end_description.gsub(/^\s+/, '').chomp
14
14
  htty is a console application for interacting with web servers.
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency 'mime-types', '~> 1'
23
23
 
24
- s.add_development_dependency 'rake', '~> 0'
24
+ s.add_development_dependency 'rake'
25
25
  s.add_development_dependency 'rspec', '~> 2'
26
26
 
27
27
  s.rubyforge_project = 'htty'
data/lib/htty/cli.rb CHANGED
@@ -1,7 +1,6 @@
1
- require 'readline'
2
1
  require File.expand_path("#{File.dirname __FILE__}/cli/commands")
3
2
  require File.expand_path("#{File.dirname __FILE__}/cli/commands/help")
4
- require File.expand_path("#{File.dirname __FILE__}/cli/commands/quit")
3
+ require File.expand_path("#{File.dirname __FILE__}/cli/input_device")
5
4
  require File.expand_path("#{File.dirname __FILE__}/cli/display")
6
5
  require File.expand_path("#{File.dirname __FILE__}/session")
7
6
  require File.expand_path("#{File.dirname __FILE__}/version")
@@ -18,102 +17,88 @@ class HTTY::CLI
18
17
 
19
18
  # Instantiates a new HTTY::CLI with the specified _command_line_arguments_.
20
19
  def initialize(command_line_arguments)
21
- if command_line_arguments.include?('--version')
22
- puts "v#{HTTY::VERSION}"
23
- exit
24
- end
25
-
26
- if command_line_arguments.include?('--help')
27
- HTTY::CLI::Commands::Help.new.perform
28
- exit
29
- end
30
-
31
- exit unless @session = rescuing_from(ArgumentError) do
32
- everything_but_options = command_line_arguments.reject do |a|
33
- a[0..0] == '-'
34
- end
35
- HTTY::Session.new(everything_but_options.first)
36
- end
37
-
38
- register_completion_proc
20
+ handle_version(command_line_arguments)
21
+ handle_help(command_line_arguments)
22
+ initialize_session(command_line_arguments)
39
23
  end
40
24
 
41
- # Takes over stdin, stdout, and stderr to expose #session to command-line
25
+ # Takes over STDIN, STDOUT, and STDERR to expose #session to command-line
42
26
  # interaction.
43
27
  def run!
44
28
  say_hello
45
-
46
29
  catch :quit do
47
- loop do
48
- begin
49
- unless (command = prompt_for_command)
50
- $stderr.puts notice('Unrecognized command')
51
- puts notice('Try typing ' +
52
- strong(HTTY::CLI::Commands::Help.command_line))
53
- next
54
- end
55
-
56
- if command == :unclosed_quote
57
- $stderr.puts notice('Unclosed quoted expression -- try again')
58
- next
59
- end
60
-
61
- if ARGV.include?('--debug')
62
- command.perform
63
- else
64
- rescuing_from Exception do
65
- command.perform
66
- end
67
- end
68
- rescue Interrupt
69
- puts
70
- throw :quit
71
- end
30
+ HTTY::CLI::InputDevice.new(self).commands do |command_line|
31
+ run_command_line(command_line)
72
32
  end
73
33
  end
74
-
75
34
  say_goodbye
76
35
  end
77
36
 
37
+ # This is something that should belong to Display
38
+ def line(command = '')
39
+ puts formatted_prompt + command
40
+ end
41
+
42
+ # This is something that should belong to Display
43
+ def formatted_prompt
44
+ formatted_prompt_for(@session.requests.last)
45
+ end
46
+
78
47
  private
79
48
 
80
- def prompt_for_command
81
- command_line = ''
82
- while command_line.empty? do
83
- prompt = prompt(session.requests.last)
84
- print prompt
85
- if (command_line = Readline.readline('', true)).nil?
86
- raise Interrupt
87
- end
88
- if whitespace?(command_line) || repeat?(command_line)
89
- Readline::HISTORY.pop
90
- end
91
- command_line.chomp!
92
- command_line.strip!
49
+ def run_command_line(command_line)
50
+ command = HTTY::CLI::Commands.build_for command_line, :session => @session
51
+
52
+ unless command
53
+ STDERR.puts notice('Unrecognized command')
54
+ puts notice(
55
+ 'Try typing ' + strong(HTTY::CLI::Commands::Help.command_line)
56
+ )
57
+ return
58
+ end
59
+
60
+ if command == :unclosed_quote
61
+ STDERR.puts notice('Unclosed quoted expression -- try again')
62
+ return
93
63
  end
94
- HTTY::CLI::Commands.build_for command_line, :session => session
95
- end
96
64
 
97
- def register_completion_proc
98
- Readline.completion_proc = proc do |input|
99
- autocomplete_list = HTTY::CLI::Commands.select do |c|
100
- c.complete_for? input
65
+ if ARGV.include?('--debug')
66
+ command.perform
67
+ else
68
+ rescuing_from Exception do
69
+ command.perform
101
70
  end
102
- autocomplete_list.collect(&:raw_name)
103
71
  end
104
72
  end
105
73
 
106
- def repeat?(command_line)
107
- command_line == Readline::HISTORY.to_a[-2]
74
+ def handle_version(command_line_arguments)
75
+ if command_line_arguments.include?('--version')
76
+ puts "v#{HTTY::VERSION}"
77
+ exit
78
+ end
108
79
  end
109
80
 
110
- def whitespace?(command_line)
111
- command_line.strip.empty?
81
+ def handle_help(command_line_arguments)
82
+ if command_line_arguments.include?('--help')
83
+ HTTY::CLI::Commands::Help.new.perform
84
+ exit
85
+ end
112
86
  end
113
87
 
88
+ def initialize_session(command_line_arguments)
89
+ exit unless @session = rescuing_from(ArgumentError) do
90
+ everything_but_options = command_line_arguments.reject do |a|
91
+ a[0..0] == '-'
92
+ end
93
+ HTTY::Session.new(everything_but_options.first)
94
+ end
95
+ end
114
96
  end
115
97
 
98
+
99
+
116
100
  Dir.glob "#{File.dirname __FILE__}/cli/*.rb" do |f|
117
- require File.expand_path("#{File.dirname __FILE__}/cli/" +
118
- File.basename(f, '.rb'))
101
+ require File.expand_path(
102
+ "#{File.dirname __FILE__}/cli/" + File.basename(f, '.rb')
103
+ )
119
104
  end