kronk 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,15 @@
1
+ === 1.9.3 / 2012-07-16
2
+
3
+ * Bugfixes:
4
+
5
+ * Don't override missing dependency errors.
6
+
7
+ * Fix for passing uri options to request initializer.
8
+
9
+ * Enable colors by default.
10
+
11
+ * Keep only 500 URIs in the benchmark player.
12
+
1
13
  === 1.9.2 / 2012-05-23
2
14
 
3
15
  * Bugfixes:
@@ -44,6 +44,7 @@ test/mocks/301_response.txt
44
44
  test/mocks/302_response.txt
45
45
  test/mocks/cookies.yml
46
46
  test/mocks/get_request.txt
47
+ test/mocks/mock_config.yml
47
48
  test/test_assertions.rb
48
49
  test/test_cmd.rb
49
50
  test/test_data_string.rb
@@ -178,7 +178,7 @@ One of Kronk's most powerful features is its ability to segregate data.
178
178
  From the command line, this is done by passing data paths after '--'.
179
179
 
180
180
  All data manipulation is handled by the
181
- {ruby-path gem}[http://github.com/yaksnrainbows/ruby-path].
181
+ {ruby-path gem}[http://rubygems.org/gems/ruby-path].
182
182
 
183
183
  === Selecting and Deleting:
184
184
 
@@ -14,7 +14,7 @@ require 'yaml'
14
14
  class Kronk
15
15
 
16
16
  # This gem's version.
17
- VERSION = '1.9.2'
17
+ VERSION = '1.9.3'
18
18
 
19
19
  require 'kronk/constants'
20
20
  require 'kronk/queue_runner'
@@ -379,16 +379,17 @@ class Kronk
379
379
 
380
380
  if IO === uri || StringIO === uri || BufferedIO === uri
381
381
  Cmd.verbose "Reading IO #{uri}" if defined?(Cmd)
382
- Response.new uri, options
382
+ Response.new uri, opts
383
383
 
384
384
  elsif File.file? uri.to_s
385
385
  Cmd.verbose "Reading file: #{uri}\n" if defined?(Cmd)
386
- Response.read_file uri, options
386
+ Response.read_file uri, opts
387
387
 
388
388
  else
389
- req = Request.new uri, options
389
+
390
+ req = Request.new uri, opts
390
391
  Cmd.verbose "Retrieving URL: #{req.uri}\n" if defined?(Cmd)
391
- resp = req.retrieve options
392
+ resp = req.retrieve opts
392
393
 
393
394
  hist_uri = req.uri.to_s[0..-req.uri.request_uri.length]
394
395
  hist_uri = hist_uri[(req.uri.scheme.length + 3)..-1]
@@ -82,11 +82,11 @@ class Kronk
82
82
  DEFAULT_CONFIG = {
83
83
  :content_types => DEFAULT_CONTENT_TYPES.dup,
84
84
  :cache_file => DEFAULT_CACHE_FILE,
85
- :color_data => false,
85
+ :color_data => true,
86
86
  :context => 3,
87
87
  :cookies_file => DEFAULT_COOKIES_FILE,
88
88
  :default_host => "http://localhost:3000",
89
- :diff_format => 'ascii',
89
+ :diff_format => 'color',
90
90
  :history_file => DEFAULT_HISTORY_FILE,
91
91
  :indentation => 1,
92
92
  :max_history => 100,
@@ -75,7 +75,6 @@ class Kronk
75
75
  @paths[uri] ||= [0, 0]
76
76
  pcount = @paths[uri][1] + 1
77
77
  @paths[uri][0] = (@paths[uri][0] * @paths[uri][1] + time) / pcount
78
- @paths[uri][0] = @paths[uri][0].round @precision
79
78
  @paths[uri][1] = pcount
80
79
 
81
80
  clean_req_log
@@ -84,7 +83,7 @@ class Kronk
84
83
 
85
84
  def clean_req_log
86
85
  if @paths.length > 500
87
- order_reqs[500..-1].each{|(uri, vals)| @paths.delete uri }
86
+ order_reqs[500..-1].each{|(uri,_)| @paths.delete uri }
88
87
  end
89
88
  end
90
89
 
@@ -158,7 +157,7 @@ class Kronk
158
157
 
159
158
 
160
159
  def order_reqs
161
- @paths.to_a.sort{|x,y| y[1] <=> x[1]}
160
+ @paths.to_a.sort{|x,y| y[1][0] <=> x[1][0]}
162
161
  end
163
162
 
164
163
 
@@ -387,6 +387,9 @@ class Kronk
387
387
  begin
388
388
  @parsed_body = new_parser.parse(self.body) or raise RuntimeError
389
389
 
390
+ rescue MissingDependency
391
+ raise
392
+
390
393
  rescue => e
391
394
  msg = ParserError === e ?
392
395
  e.message : "#{new_parser} failed parsing body"
@@ -0,0 +1,4 @@
1
+ uri_options:
2
+ example.com:
3
+ query:
4
+ foo: bar
@@ -4,6 +4,7 @@ class TestDiff < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
6
  @diff = Kronk::Diff.new mock_302_response, mock_301_response
7
+ @diff.output.format = Kronk::Diff::AsciiFormat
7
8
  end
8
9
 
9
10
 
@@ -170,7 +170,7 @@ def expect_request req_method, url, opts={}
170
170
  http = mock 'http'
171
171
  req = mock 'req'
172
172
 
173
- data = opts[:data]
173
+ data = opts.delete(:data)
174
174
  data &&= Hash === data ? Kronk::Request.build_query(data) : data.to_s
175
175
 
176
176
  req.stubs(:body).returns(data)
@@ -179,7 +179,7 @@ def expect_request req_method, url, opts={}
179
179
  req.stubs(:[]).with('Content-Length').returns(data)
180
180
  req.stubs(:[]=)
181
181
 
182
- headers = opts[:headers] || Hash.new
182
+ headers = opts.delete(:headers) || Hash.new
183
183
  headers['User-Agent'] ||= Kronk::DEFAULT_USER_AGENT
184
184
  headers['Connection'] ||= 'Keep-Alive'
185
185
 
@@ -190,13 +190,13 @@ def expect_request req_method, url, opts={}
190
190
  Kronk::Request::VanillaRequest.expects(:new).
191
191
  with(req_method.to_s.upcase, uri.request_uri, headers).returns req
192
192
 
193
- proxy = opts[:proxy] || {}
193
+ proxy = opts.delete(:proxy) || {}
194
194
 
195
195
  Kronk::HTTP.expects(:new).
196
- with(uri.host, uri.port, {:proxy => proxy, :ssl => !!opts[:ssl]}).
196
+ with(uri.host, uri.port, {:proxy => proxy, :ssl => !!opts.delete(:ssl)}).
197
197
  returns http
198
198
 
199
- http.expects(:request).with(req, nil, {}).returns resp
199
+ http.expects(:request).with(req, nil, opts).returns resp
200
200
 
201
201
  yield http, req, resp if block_given?
202
202
 
@@ -19,7 +19,7 @@ class TestKronk < Test::Unit::TestCase
19
19
  :history_file => Kronk::DEFAULT_HISTORY_FILE,
20
20
  :indentation => 1,
21
21
  :default_host => "http://localhost:3000",
22
- :diff_format => 'ascii',
22
+ :diff_format => 'color',
23
23
  :max_history => 100,
24
24
  :show_lines => false,
25
25
  :use_cookies => true,
@@ -77,7 +77,7 @@ class TestKronk < Test::Unit::TestCase
77
77
  },
78
78
  :context => 3,
79
79
  :default_host => "http://localhost:3000",
80
- :diff_format => 'ascii',
80
+ :diff_format => 'color',
81
81
  :cache_file => Kronk::DEFAULT_CACHE_FILE,
82
82
  :color_data => false,
83
83
  :cookies_file => Kronk::DEFAULT_COOKIES_FILE,
@@ -99,6 +99,18 @@ class TestKronk < Test::Unit::TestCase
99
99
  end
100
100
 
101
101
 
102
+ def test_load_config_uri_options
103
+ with_config do
104
+ Kronk.load_config 'test/mocks/mock_config.yml'
105
+ expected = {'example.com' => {:query => {'foo' => 'bar'}}}
106
+ assert_equal expected, Kronk.config[:uri_options]
107
+
108
+ expect_request :get, "http://example.com/path?foo=bar", :query => {"foo"=>"bar"}
109
+ Kronk.request "http://example.com/path"
110
+ end
111
+ end
112
+
113
+
102
114
  def test_parser_for
103
115
  assert_equal JSON, Kronk.parser_for('json')
104
116
  assert_equal Kronk::XMLParser, Kronk.parser_for('xml')
metadata CHANGED
@@ -1,182 +1,182 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: kronk
3
- version: !ruby/object:Gem::Version
4
- version: 1.9.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 53
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 9
9
+ - 3
10
+ version: 1.9.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Jeremie Castagna
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-05-23 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-07-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: json
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.5'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '1.5'
30
- - !ruby/object:Gem::Dependency
31
- name: cookiejar
32
- requirement: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
33
24
  none: false
34
- requirements:
25
+ requirements:
35
26
  - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 0.3.0
27
+ - !ruby/object:Gem::Version
28
+ hash: 5
29
+ segments:
30
+ - 1
31
+ - 5
32
+ version: "1.5"
38
33
  type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: cookiejar
39
37
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
43
+ hash: 19
44
+ segments:
45
+ - 0
46
+ - 3
47
+ - 0
45
48
  version: 0.3.0
46
- - !ruby/object:Gem::Dependency
47
- name: ruby-path
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 1.0.0
54
49
  type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: ruby-path
55
53
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
57
55
  none: false
58
- requirements:
56
+ requirements:
59
57
  - - ~>
60
- - !ruby/object:Gem::Version
58
+ - !ruby/object:Gem::Version
59
+ hash: 23
60
+ segments:
61
+ - 1
62
+ - 0
63
+ - 0
61
64
  version: 1.0.0
62
- - !ruby/object:Gem::Dependency
63
- name: mime-types
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 1.18.0
70
65
  type: :runtime
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: mime-types
71
69
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
73
71
  none: false
74
- requirements:
72
+ requirements:
75
73
  - - ~>
76
- - !ruby/object:Gem::Version
74
+ - !ruby/object:Gem::Version
75
+ hash: 95
76
+ segments:
77
+ - 1
78
+ - 18
79
+ - 0
77
80
  version: 1.18.0
78
- - !ruby/object:Gem::Dependency
81
+ type: :runtime
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
79
84
  name: rdoc
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ~>
84
- - !ruby/object:Gem::Version
85
- version: '3.10'
86
- type: :development
87
85
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: '3.10'
94
- - !ruby/object:Gem::Dependency
95
- name: plist
96
- requirement: !ruby/object:Gem::Requirement
86
+ requirement: &id005 !ruby/object:Gem::Requirement
97
87
  none: false
98
- requirements:
88
+ requirements:
99
89
  - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 3.1.0
90
+ - !ruby/object:Gem::Version
91
+ hash: 19
92
+ segments:
93
+ - 3
94
+ - 10
95
+ version: "3.10"
102
96
  type: :development
97
+ version_requirements: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ name: plist
103
100
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
101
+ requirement: &id006 !ruby/object:Gem::Requirement
105
102
  none: false
106
- requirements:
103
+ requirements:
107
104
  - - ~>
108
- - !ruby/object:Gem::Version
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 3
109
+ - 1
110
+ - 0
109
111
  version: 3.1.0
110
- - !ruby/object:Gem::Dependency
111
- name: nokogiri
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- version: '1.4'
118
112
  type: :development
113
+ version_requirements: *id006
114
+ - !ruby/object:Gem::Dependency
115
+ name: nokogiri
119
116
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
117
+ requirement: &id007 !ruby/object:Gem::Requirement
121
118
  none: false
122
- requirements:
119
+ requirements:
123
120
  - - ~>
124
- - !ruby/object:Gem::Version
125
- version: '1.4'
126
- - !ruby/object:Gem::Dependency
127
- name: mocha
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
133
- version: 0.9.12
121
+ - !ruby/object:Gem::Version
122
+ hash: 7
123
+ segments:
124
+ - 1
125
+ - 4
126
+ version: "1.4"
134
127
  type: :development
128
+ version_requirements: *id007
129
+ - !ruby/object:Gem::Dependency
130
+ name: mocha
135
131
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
132
+ requirement: &id008 !ruby/object:Gem::Requirement
137
133
  none: false
138
- requirements:
134
+ requirements:
139
135
  - - ~>
140
- - !ruby/object:Gem::Version
136
+ - !ruby/object:Gem::Version
137
+ hash: 35
138
+ segments:
139
+ - 0
140
+ - 9
141
+ - 12
141
142
  version: 0.9.12
142
- - !ruby/object:Gem::Dependency
143
- name: hoe
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ~>
148
- - !ruby/object:Gem::Version
149
- version: '3.0'
150
143
  type: :development
144
+ version_requirements: *id008
145
+ - !ruby/object:Gem::Dependency
146
+ name: hoe
151
147
  prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
148
+ requirement: &id009 !ruby/object:Gem::Requirement
153
149
  none: false
154
- requirements:
150
+ requirements:
155
151
  - - ~>
156
- - !ruby/object:Gem::Version
157
- version: '3.0'
158
- description: ! 'Kronk is a command line swiss-army-knife for HTTP services.
159
-
160
-
152
+ - !ruby/object:Gem::Version
153
+ hash: 7
154
+ segments:
155
+ - 3
156
+ - 0
157
+ version: "3.0"
158
+ type: :development
159
+ version_requirements: *id009
160
+ description: |-
161
+ Kronk is a command line swiss-army-knife for HTTP services.
162
+
161
163
  With Kronk, you easily parse and segregate data, run diffs between
162
-
163
164
  the parsed data from different queries, and easily replay logs and loadtest
164
-
165
165
  your HTTP applications.
166
-
167
-
168
- Kronk was made possible by the sponsoring of YP.com.'
169
- email:
166
+
167
+ Kronk was made possible by the sponsoring of YP.com.
168
+ email:
170
169
  - yaksnrainbows@gmail.com
171
- executables:
170
+ executables:
172
171
  - kronk
173
172
  extensions: []
174
- extra_rdoc_files:
173
+
174
+ extra_rdoc_files:
175
175
  - History.rdoc
176
176
  - Manifest.txt
177
177
  - README.rdoc
178
178
  - TODO.rdoc
179
- files:
179
+ files:
180
180
  - .autotest
181
181
  - History.rdoc
182
182
  - Manifest.txt
@@ -223,6 +223,7 @@ files:
223
223
  - test/mocks/302_response.txt
224
224
  - test/mocks/cookies.yml
225
225
  - test/mocks/get_request.txt
226
+ - test/mocks/mock_config.yml
226
227
  - test/test_assertions.rb
227
228
  - test/test_cmd.rb
228
229
  - test/test_data_string.rb
@@ -242,31 +243,39 @@ files:
242
243
  - .gemtest
243
244
  homepage: http://kronk.me
244
245
  licenses: []
246
+
245
247
  post_install_message:
246
- rdoc_options:
248
+ rdoc_options:
247
249
  - --main
248
250
  - README.rdoc
249
- require_paths:
251
+ require_paths:
250
252
  - lib
251
- required_ruby_version: !ruby/object:Gem::Requirement
253
+ required_ruby_version: !ruby/object:Gem::Requirement
252
254
  none: false
253
- requirements:
254
- - - ! '>='
255
- - !ruby/object:Gem::Version
256
- version: '0'
257
- required_rubygems_version: !ruby/object:Gem::Requirement
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ hash: 3
259
+ segments:
260
+ - 0
261
+ version: "0"
262
+ required_rubygems_version: !ruby/object:Gem::Requirement
258
263
  none: false
259
- requirements:
260
- - - ! '>='
261
- - !ruby/object:Gem::Version
262
- version: '0'
264
+ requirements:
265
+ - - ">="
266
+ - !ruby/object:Gem::Version
267
+ hash: 3
268
+ segments:
269
+ - 0
270
+ version: "0"
263
271
  requirements: []
272
+
264
273
  rubyforge_project: kronk
265
- rubygems_version: 1.8.18
274
+ rubygems_version: 1.8.24
266
275
  signing_key:
267
276
  specification_version: 3
268
277
  summary: Kronk is a command line swiss-army-knife for HTTP services
269
- test_files:
278
+ test_files:
270
279
  - test/test_assertions.rb
271
280
  - test/test_cmd.rb
272
281
  - test/test_data_string.rb