kronk 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,14 @@
1
- === 1.8.2 / 2012-02-15
1
+ === 1.8.4 / 2012-03-20
2
+
3
+ * Enhancements:
4
+
5
+ * Allow setting a fallback host when retrieving mixed full and partial URLs.
6
+
7
+ * Bugfixes:
8
+
9
+ * Fix redirect issue in player.
10
+
11
+ === 1.8.3 / 2012-02-15
2
12
 
3
13
  * Bugfixes:
4
14
 
@@ -12,7 +12,7 @@ require 'yaml'
12
12
  class Kronk
13
13
 
14
14
  # This gem's version.
15
- VERSION = '1.8.3'
15
+ VERSION = '1.8.4'
16
16
 
17
17
  require 'kronk/constants'
18
18
  require 'kronk/queue_runner'
@@ -204,8 +204,8 @@ Parse and run diffs against data from live and cached http responses.
204
204
  end
205
205
 
206
206
 
207
- opt.on('-i', '--include [HEADER1,HEADER2]', Array,
208
- 'Include all or given headers in response') do |value|
207
+ opt.on('-I', '--head [HEADER1,HEADER2]', Array,
208
+ 'Use all or given headers only in the response') do |value|
209
209
  options[:show_headers] ||= []
210
210
 
211
211
  if value
@@ -215,12 +215,12 @@ Parse and run diffs against data from live and cached http responses.
215
215
  options[:show_headers] = true
216
216
  end
217
217
 
218
- options[:no_body] = false
218
+ options[:no_body] = true
219
219
  end
220
220
 
221
221
 
222
- opt.on('-I', '--head [HEADER1,HEADER2]', Array,
223
- 'Use all or given headers only in the response') do |value|
222
+ opt.on('-i', '--include [HEADER1,HEADER2]', Array,
223
+ 'Include all or given headers in response') do |value|
224
224
  options[:show_headers] ||= []
225
225
 
226
226
  if value
@@ -230,7 +230,7 @@ Parse and run diffs against data from live and cached http responses.
230
230
  options[:show_headers] = true
231
231
  end
232
232
 
233
- options[:no_body] = true
233
+ options[:no_body] = false
234
234
  end
235
235
 
236
236
 
@@ -394,6 +394,12 @@ Parse and run diffs against data from live and cached http responses.
394
394
  end
395
395
 
396
396
 
397
+ opt.on('--default-host STR', String,
398
+ 'Default host to use if missing') do |value|
399
+ Kronk.config[:default_host] = value
400
+ end
401
+
402
+
397
403
  opt.on('-F', '--form STR', String,
398
404
  'Set request body with form headers; overrides -d') do |value|
399
405
  options[:form] = value
@@ -47,13 +47,18 @@ class Kronk
47
47
  # path and options.
48
48
 
49
49
  def self.build_uri uri, opts={}
50
- uri ||= opts[:host] || Kronk.config[:default_host]
51
- suffix = opts[:uri_suffix]
50
+ uri ||= opts[:host]
52
51
 
53
- uri = "http://#{uri}" unless uri.to_s =~ %r{^(\w+://|/)}
54
- uri = "#{uri}#{suffix}" if suffix
55
- uri = URI.parse uri unless URI === uri
56
- uri = URI.parse(Kronk.config[:default_host]) + uri unless uri.host
52
+ uri = "#{uri}#{opts[:path]}#{opts[:uri_suffix]}"
53
+ uri = "http://#{uri}" unless uri.to_s =~ %r{^(\w+://|/)}
54
+
55
+ uri = URI.parse uri unless URI === uri
56
+
57
+ unless uri.host
58
+ host = Kronk.config[:default_host]
59
+ host = "http://#{host}" unless host.to_s =~ %r{^\w+://}
60
+ uri = URI.parse(host) + uri
61
+ end
57
62
 
58
63
  if opts[:query]
59
64
  query = build_query opts[:query]
@@ -94,7 +99,7 @@ class Kronk
94
99
  lines.shift.strip =~ REQUEST_LINE_MATCHER
95
100
  opts.merge! :http_method => $1,
96
101
  :host => $2,
97
- :uri_suffix => ($3 || $4)
102
+ :path => ($3 || $4)
98
103
 
99
104
  lines.each_with_index do |line, i|
100
105
  case line
@@ -114,7 +119,7 @@ class Kronk
114
119
  opts[:data] = lines[body_start..-1].join("\n") if body_start
115
120
 
116
121
  opts.delete(:host) if !opts[:host]
117
- opts.delete(:uri_suffix) if !opts[:uri_suffix]
122
+ opts.delete(:path) if !opts[:path]
118
123
  opts.delete(:headers) if opts[:headers].empty?
119
124
  opts.delete(:http_method) if !opts[:http_method]
120
125
  opts.delete(:data) if opts[:data] && opts[:data].strip.empty?
@@ -451,7 +456,7 @@ class Kronk
451
456
  def to_hash
452
457
  hash = {
453
458
  :host => "#{@uri.scheme}://#{@uri.host}:#{@uri.port}",
454
- :uri_suffix => @uri.request_uri,
459
+ :path => @uri.request_uri,
455
460
  :user_agent => self.user_agent,
456
461
  :timeout => @timeout,
457
462
  :http_method => self.http_method,
@@ -500,8 +500,11 @@ class Kronk
500
500
  def follow_redirect opts={}, &block
501
501
  return if !redirect?
502
502
  new_opts = @request ? @request.to_hash : {}
503
+
503
504
  new_opts[:http_method] = "GET" if @code == "303"
504
505
  new_opts.merge!(opts)
506
+
507
+ new_opts.delete(:path)
505
508
  new_opts.delete(:auth) if !opts[:trust_location] &&
506
509
  (!@request || self.location.host != self.uri.host)
507
510
 
@@ -25,7 +25,7 @@ class TestInputReader < Test::Unit::TestCase
25
25
  def test_get_next
26
26
  (1..3).each do |num|
27
27
  expected = {
28
- :uri_suffix => "/path#{num}"
28
+ :path => "/path#{num}"
29
29
  }
30
30
  assert_equal expected, @input.get_next
31
31
  end
@@ -43,7 +43,7 @@ class TestInputReader < Test::Unit::TestCase
43
43
  "Authorization" => "Basic Ym9iOmZvb2Jhcg=="
44
44
  },
45
45
  :http_method => "GET",
46
- :uri_suffix => "/path",
46
+ :path => "/path",
47
47
  :host => "example.com:80",
48
48
  }
49
49
 
@@ -65,7 +65,7 @@ class TestInputReader < Test::Unit::TestCase
65
65
  "Authorization" => "Basic Ym9iOmZvb2Jhcg=="
66
66
  },
67
67
  :http_method => "GET",
68
- :uri_suffix => "/path",
68
+ :path => "/path",
69
69
  :host => "example.com:80",
70
70
  }
71
71
 
@@ -162,21 +162,21 @@ class TestPlayer < Test::Unit::TestCase
162
162
  @player.input.io.rewind
163
163
  @player.input.io.close_write
164
164
 
165
- @player.queue.concat [{:uri_suffix => "/req1"}, {:uri_suffix => "/req2"}]
165
+ @player.queue.concat [{:path => "/req1"}, {:path => "/req2"}]
166
166
 
167
167
  part1 = (1..2).map{|n| "/req#{n}"}
168
168
  part2 = (3..5).map{|n| "/req#{n}"}
169
169
 
170
170
  part1.each do |path|
171
171
  mock_requests "example.com", "beta-example.com",
172
- :uri_suffix => path,
173
- :query => "foo=bar"
172
+ :path => path,
173
+ :query => "foo=bar"
174
174
  end
175
175
 
176
176
  part2.each do |path|
177
177
  mock_requests "example.com", "beta-example.com",
178
- :uri_suffix => path,
179
- :query => "foo=bar"
178
+ :path => path,
179
+ :query => "foo=bar"
180
180
  end
181
181
 
182
182
  @player.compare "example.com", "beta-example.com", :query => "foo=bar"
@@ -42,10 +42,10 @@ class TestRequest < Test::Unit::TestCase
42
42
 
43
43
 
44
44
  def test_parse_to_hash
45
- expected = {:uri_suffix => "/foobar"}
45
+ expected = {:path => "/foobar"}
46
46
  assert_equal expected, Kronk::Request.parse_to_hash("/foobar")
47
47
 
48
- expected = {:http_method => "GET", :uri_suffix => "/foobar"}
48
+ expected = {:http_method => "GET", :path => "/foobar"}
49
49
  assert_equal expected, Kronk::Request.parse_to_hash("GET /foobar")
50
50
 
51
51
  expected.merge! :host => "example.com"
@@ -62,7 +62,7 @@ class TestRequest < Test::Unit::TestCase
62
62
 
63
63
 
64
64
  def test_parse_to_hash_url
65
- expected = {:host => "http://example.com", :uri_suffix => "/foobar?foo=bar"}
65
+ expected = {:host => "http://example.com", :path => "/foobar?foo=bar"}
66
66
  assert_equal expected,
67
67
  Kronk::Request.parse_to_hash("http://example.com/foobar?foo=bar")
68
68
  end
@@ -130,6 +130,15 @@ class TestRequest < Test::Unit::TestCase
130
130
  end
131
131
 
132
132
 
133
+ def test_build_path
134
+ uri = Kronk::Request.build_uri "http://example.com/",
135
+ :path => "/path",
136
+ :uri_suffix => "/to/resource"
137
+
138
+ assert_equal "http://example.com//path/to/resource", uri.to_s
139
+ end
140
+
141
+
133
142
  def test_build_uri_from_uri
134
143
  query = {'a' => '1', 'b' => '2'}
135
144
  uri = Kronk::Request.build_uri URI.parse("http://example.com/path"),
@@ -17,10 +17,10 @@ class TestRequestParser < Test::Unit::TestCase
17
17
 
18
18
 
19
19
  def test_parse
20
- expected = {:uri_suffix => "/foobar"}
20
+ expected = {:path => "/foobar"}
21
21
  assert_equal expected, Kronk::Player::RequestParser.parse("/foobar")
22
22
 
23
- expected = {:http_method => "GET", :uri_suffix => "/foobar"}
23
+ expected = {:http_method => "GET", :path => "/foobar"}
24
24
  assert_equal expected, Kronk::Player::RequestParser.parse("GET /foobar")
25
25
 
26
26
  expected.merge! :host => "example.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kronk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-15 00:00:00.000000000 Z
12
+ date: 2012-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70142332427460 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '1.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70142332427460
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.5'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: cookiejar
27
- requirement: &70142335036320 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 0.3.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70142335036320
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: plist
38
- requirement: &70142335035900 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 3.1.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70142335035900
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: nokogiri
49
- requirement: &70142335035480 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '1.4'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70142335035480
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.4'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: mocha
60
- requirement: &70142335035060 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,18 +85,44 @@ dependencies:
65
85
  version: 0.9.12
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70142335035060
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.9.12
94
+ - !ruby/object:Gem::Dependency
95
+ name: rdoc
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '3.10'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '3.10'
69
110
  - !ruby/object:Gem::Dependency
70
111
  name: hoe
71
- requirement: &70142335034640 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
72
113
  none: false
73
114
  requirements:
74
115
  - - ~>
75
116
  - !ruby/object:Gem::Version
76
- version: '2.12'
117
+ version: '2.13'
77
118
  type: :development
78
119
  prerelease: false
79
- version_requirements: *70142335034640
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.13'
80
126
  description: ! 'Kronk runs diffs against data from live and cached http responses.
81
127
 
82
128
  Kronk was made possible by the sponsoring of AT&T Interactive.'
@@ -173,6 +219,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
219
  - - ! '>='
174
220
  - !ruby/object:Gem::Version
175
221
  version: '0'
222
+ segments:
223
+ - 0
224
+ hash: -3368818525968030457
176
225
  required_rubygems_version: !ruby/object:Gem::Requirement
177
226
  none: false
178
227
  requirements:
@@ -181,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
230
  version: '0'
182
231
  requirements: []
183
232
  rubyforge_project: kronk
184
- rubygems_version: 1.8.11
233
+ rubygems_version: 1.8.18
185
234
  signing_key:
186
235
  specification_version: 3
187
236
  summary: Kronk runs diffs against data from live and cached http responses