htty 1.1.1 → 1.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -10,14 +10,24 @@ class HTTY::CLI; end
10
10
  # subclasses.
11
11
  module HTTY::CLI::HTTPMethodCommand
12
12
 
13
- include HTTY::CLI::Display
13
+ # Class methods for modules that include HTTY::CLI::HTTPMethodCommand.
14
+ module ClassMethods
15
+
16
+ # Returns the name of a category under which help for the command should
17
+ # appear.
18
+ def category
19
+ 'Issuing Requests'
20
+ end
14
21
 
15
- # Returns the name of a category under which help for the command should
16
- # appear.
17
- def self.category
18
- 'Issuing Requests'
19
22
  end
20
23
 
24
+ # Extends _other_module_ with ClassMethods.
25
+ def self.included(other_module)
26
+ other_module.extend ClassMethods
27
+ end
28
+
29
+ include HTTY::CLI::Display
30
+
21
31
  # Performs the command.
22
32
  def perform
23
33
  add_request_if_has_response do |request|
data/lib/htty/cli.rb CHANGED
@@ -70,12 +70,23 @@ private
70
70
  if (command_line = Readline.readline(prompt, true)).nil?
71
71
  raise Interrupt
72
72
  end
73
+ if whitespace?(command_line) || repeat?(command_line)
74
+ Readline::HISTORY.pop
75
+ end
73
76
  command_line.chomp!
74
77
  command_line.strip!
75
78
  end
76
79
  HTTY::CLI::Commands.build_for command_line, :session => session
77
80
  end
78
81
 
82
+ def repeat?(command_line)
83
+ command_line == Readline::HISTORY.to_a[-2]
84
+ end
85
+
86
+ def whitespace?(command_line)
87
+ command_line.strip.empty?
88
+ end
89
+
79
90
  end
80
91
 
81
92
  Dir.glob "#{File.dirname __FILE__}/cli/*.rb" do |f|
@@ -1,10 +1,11 @@
1
1
  require 'spec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty")
2
3
  require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/request")
3
4
  require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/response")
4
5
 
5
6
  shared_examples_for 'an empty request' do
6
7
  it 'should have only the default headers' do
7
- @request.headers.should == [%w(User-Agent htty/1.1.0)]
8
+ @request.headers.should == [['User-Agent', "htty/#{HTTY::VERSION}"]]
8
9
  end
9
10
 
10
11
  it 'should have no body' do
@@ -18,7 +19,7 @@ end
18
19
 
19
20
  shared_examples_for 'an empty, authenticated request' do
20
21
  it 'should the expected Authorization header plus the default headers' do
21
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
22
+ @request.headers.should == [['User-Agent', "htty/#{HTTY::VERSION}"],
22
23
  ['Authorization', 'Basic bmpvbnNzb24=']]
23
24
  end
24
25
 
@@ -331,7 +332,8 @@ describe HTTY::Request do
331
332
 
332
333
  it 'should the expected Authorization header plus the default ' +
333
334
  'headers' do
334
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
335
+ @request.headers.should == [['User-Agent', 'htty/' +
336
+ HTTY::VERSION],
335
337
  ['Authorization', 'Basic c3RldmU=']]
336
338
  end
337
339
 
@@ -419,7 +421,8 @@ describe HTTY::Request do
419
421
 
420
422
  it 'should the expected Authorization header plus the default ' +
421
423
  'headers' do
422
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
424
+ @request.headers.should == [['User-Agent', 'htty/' +
425
+ HTTY::VERSION],
423
426
  ['Authorization', 'Basic bmlscw==']]
424
427
  end
425
428
 
@@ -445,7 +448,8 @@ describe HTTY::Request do
445
448
 
446
449
  it 'should the expected Authorization header plus the default ' +
447
450
  'headers' do
448
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
451
+ @request.headers.should == [['User-Agent', 'htty/' +
452
+ HTTY::VERSION],
449
453
  ['Authorization', 'Basic bkU=']]
450
454
  end
451
455
 
@@ -749,7 +753,8 @@ describe HTTY::Request do
749
753
 
750
754
  describe '--' do
751
755
  it 'should have the header, plus the default headers' do
752
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
756
+ @request.headers.should == [['User-Agent', 'htty/' +
757
+ HTTY::VERSION],
753
758
  ['Authorization', 'Basic ' +
754
759
  'bmpvbnNzb24='],
755
760
  ['foo', 'bar']]
@@ -763,7 +768,8 @@ describe HTTY::Request do
763
768
  end
764
769
 
765
770
  it 'should have only the default headers' do
766
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
771
+ @request.headers.should == [['User-Agent', 'htty/' +
772
+ HTTY::VERSION],
767
773
  ['Authorization', 'Basic ' +
768
774
  'bmpvbnNzb24=']]
769
775
  end
@@ -775,7 +781,8 @@ describe HTTY::Request do
775
781
  end
776
782
 
777
783
  it 'should have the header, plus the default headers' do
778
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
784
+ @request.headers.should == [['User-Agent', 'htty/' +
785
+ HTTY::VERSION],
779
786
  ['Authorization', 'Basic ' +
780
787
  'bmpvbnNzb24='],
781
788
  ['foo', 'bar']]
@@ -811,7 +818,8 @@ describe HTTY::Request do
811
818
  end
812
819
 
813
820
  it 'should have the cookie header, plus the default headers' do
814
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
821
+ @request.headers.should == [['User-Agent', 'htty/' +
822
+ HTTY::VERSION],
815
823
  ['Authorization', 'Basic ' +
816
824
  'bmpvbnNzb24='],
817
825
  ['Cookie', 'foo=bar']]
@@ -830,7 +838,8 @@ describe HTTY::Request do
830
838
 
831
839
  it 'should have the new cookie header, plus the default ' +
832
840
  'headers' do
833
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
841
+ @request.headers.should == [['User-Agent', 'htty/' +
842
+ HTTY::VERSION],
834
843
  ['Authorization', 'Basic ' +
835
844
  'bmpvbnNzb24='],
836
845
  ['Cookie', 'foo=bar; ' +
@@ -849,7 +858,8 @@ describe HTTY::Request do
849
858
 
850
859
  it 'should have the new cookie header, plus the default ' +
851
860
  'headers' do
852
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
861
+ @request.headers.should == [['User-Agent', 'htty/' +
862
+ HTTY::VERSION],
853
863
  ['Authorization', 'Basic ' +
854
864
  'bmpvbnNzb24='],
855
865
  ['Cookie', 'foo=bar; ' +
@@ -868,7 +878,8 @@ describe HTTY::Request do
868
878
 
869
879
  it 'should have the new cookie header, plus the default ' +
870
880
  'headers' do
871
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
881
+ @request.headers.should == [['User-Agent', 'htty/' +
882
+ HTTY::VERSION],
872
883
  ['Authorization', 'Basic ' +
873
884
  'bmpvbnNzb24='],
874
885
  ['Cookie', 'foo=bar; baz']]
@@ -887,7 +898,8 @@ describe HTTY::Request do
887
898
  end
888
899
 
889
900
  it 'should have only the default headers' do
890
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
901
+ @request.headers.should == [['User-Agent', 'htty/' +
902
+ HTTY::VERSION],
891
903
  ['Authorization', 'Basic ' +
892
904
  'bmpvbnNzb24=']]
893
905
  end
@@ -903,7 +915,8 @@ describe HTTY::Request do
903
915
  end
904
916
 
905
917
  it 'should have the cookie header, plus the default headers' do
906
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
918
+ @request.headers.should == [['User-Agent', 'htty/' +
919
+ HTTY::VERSION],
907
920
  ['Authorization', 'Basic ' +
908
921
  'bmpvbnNzb24='],
909
922
  ['Cookie', 'foo=bar']]
@@ -921,7 +934,8 @@ describe HTTY::Request do
921
934
  end
922
935
 
923
936
  it 'should have only the default headers' do
924
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
937
+ @request.headers.should == [['User-Agent', 'htty/' +
938
+ HTTY::VERSION],
925
939
  ['Authorization', 'Basic ' +
926
940
  'bmpvbnNzb24=']]
927
941
  end
@@ -938,8 +952,9 @@ describe HTTY::Request do
938
952
  end
939
953
 
940
954
  it 'should have the cookie header, plus the default headers' do
941
- @request.headers.should == [%w(User-Agent htty/1.1.0),
942
- %w(Cookie foo=bar)]
955
+ @request.headers.should == [['User-Agent', 'htty/' +
956
+ HTTY::VERSION],
957
+ ['Cookie', 'foo=bar']]
943
958
  end
944
959
  end
945
960
 
@@ -954,7 +969,8 @@ describe HTTY::Request do
954
969
  end
955
970
 
956
971
  it 'should have only the default headers' do
957
- @request.headers.should == [%w(User-Agent htty/1.1.0)]
972
+ @request.headers.should == [['User-Agent',
973
+ "htty/#{HTTY::VERSION}"]]
958
974
  end
959
975
  end
960
976
  end
@@ -971,7 +987,8 @@ describe HTTY::Request do
971
987
  end
972
988
 
973
989
  it 'should have the cookie header, plus the default headers' do
974
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
990
+ @request.headers.should == [['User-Agent', 'htty/' +
991
+ HTTY::VERSION],
975
992
  ['Authorization', 'Basic ' +
976
993
  'bmpvbnNzb24='],
977
994
  ['Cookie', 'foo=bar=baz=qux']]
@@ -996,7 +1013,8 @@ describe HTTY::Request do
996
1013
  end
997
1014
 
998
1015
  it 'should have only the default headers' do
999
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
1016
+ @request.headers.should == [['User-Agent', 'htty/' +
1017
+ HTTY::VERSION],
1000
1018
  ['Authorization', 'Basic ' +
1001
1019
  'bmpvbnNzb24=']]
1002
1020
  end
@@ -1005,7 +1023,7 @@ describe HTTY::Request do
1005
1023
  "'User-Agent' header if we do not exclude the " +
1006
1024
  "'Content-Length' header" do
1007
1025
  @request.headers(true).should == [['User-Agent', 'htty/' +
1008
- '1.1.0'],
1026
+ HTTY::VERSION],
1009
1027
  ['Authorization', 'Basic ' +
1010
1028
  'bmpvbnNz' +
1011
1029
  'b24='],
@@ -1023,7 +1041,8 @@ describe HTTY::Request do
1023
1041
  end
1024
1042
 
1025
1043
  it 'should have only the default headers' do
1026
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
1044
+ @request.headers.should == [['User-Agent', 'htty/' +
1045
+ HTTY::VERSION],
1027
1046
  ['Authorization', 'Basic ' +
1028
1047
  'bmpvbnNzb24=']]
1029
1048
  end
@@ -1044,7 +1063,8 @@ describe HTTY::Request do
1044
1063
  end
1045
1064
 
1046
1065
  it 'should not affect the headers' do
1047
- @request.headers.should == [['User-Agent', 'htty/1.1.0'],
1066
+ @request.headers.should == [['User-Agent', 'htty/' +
1067
+ HTTY::VERSION],
1048
1068
  ['Authorization', 'Basic ' +
1049
1069
  'bmpvbnNzb24=']]
1050
1070
  end
@@ -1286,7 +1306,8 @@ describe HTTY::Request do
1286
1306
  describe '--' do
1287
1307
  it 'should return a request with the header, plus the default ' +
1288
1308
  'headers' do
1289
- @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1309
+ @new_request.headers.should == [['User-Agent', 'htty/' +
1310
+ HTTY::VERSION],
1290
1311
  ['Authorization', 'Basic ' +
1291
1312
  'bmpvbnNzb24='],
1292
1313
  ['foo', 'bar']]
@@ -1304,7 +1325,8 @@ describe HTTY::Request do
1304
1325
  end
1305
1326
 
1306
1327
  it 'should return a request with only the default headers' do
1307
- @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1328
+ @new_request.headers.should == [['User-Agent', 'htty/' +
1329
+ HTTY::VERSION],
1308
1330
  ['Authorization', 'Basic ' +
1309
1331
  'bmpvbnNzb2' +
1310
1332
  '4=']]
@@ -1345,7 +1367,8 @@ describe HTTY::Request do
1345
1367
  end
1346
1368
 
1347
1369
  it 'should return a request with only the default headers' do
1348
- @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1370
+ @new_request.headers.should == [['User-Agent', 'htty/' +
1371
+ HTTY::VERSION],
1349
1372
  ['Authorization', 'Basic ' +
1350
1373
  'bmpvbnNzb2' +
1351
1374
  '4=']]
@@ -1355,7 +1378,7 @@ describe HTTY::Request do
1355
1378
  "header, plus the 'User-Agent' header if we do not exclude " +
1356
1379
  "the 'Content-Length' header" do
1357
1380
  @new_request.headers(true).should == [['User-Agent', 'htty/' +
1358
- '1.1.0'],
1381
+ HTTY::VERSION],
1359
1382
  ['Authorization', 'Basic ' +
1360
1383
  'bmpvbn' +
1361
1384
  'Nzb24='],
@@ -1377,7 +1400,8 @@ describe HTTY::Request do
1377
1400
  end
1378
1401
 
1379
1402
  it 'should return a request with only the default headers' do
1380
- @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1403
+ @new_request.headers.should == [['User-Agent', 'htty/' +
1404
+ HTTY::VERSION],
1381
1405
  ['Authorization', 'Basic ' +
1382
1406
  'bmpvbnNzb2' +
1383
1407
  '4=']]
@@ -0,0 +1,8 @@
1
+ require 'spec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../lib/htty")
3
+
4
+ describe HTTY do
5
+ it 'should have a version constant of the expected format' do
6
+ HTTY::VERSION.should =~ /^\d+\.\d+\.\d+/
7
+ end
8
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 1
9
- version: 1.1.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nils Jonsson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-28 00:00:00 -05:00
17
+ date: 2010-09-29 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -174,6 +174,7 @@ files:
174
174
  - spec/unit/htty/request_spec.rb
175
175
  - spec/unit/htty/response_spec.rb
176
176
  - spec/unit/htty/session_spec.rb
177
+ - spec/unit/htty_spec.rb
177
178
  - bin/htty
178
179
  has_rdoc: true
179
180
  homepage: http://htty.github.com