kronk 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.rdoc +30 -2
- data/Manifest.txt +14 -0
- data/README.rdoc +5 -7
- data/Rakefile +88 -4
- data/bin/kronk +2 -1
- data/bin/yzma +13 -0
- data/lib/kronk.rb +112 -430
- data/lib/kronk/cmd.rb +469 -0
- data/lib/kronk/data_set.rb +38 -44
- data/lib/kronk/diff.rb +105 -112
- data/lib/kronk/diff/ascii_format.rb +35 -0
- data/lib/kronk/diff/color_format.rb +49 -0
- data/lib/kronk/request.rb +6 -6
- data/lib/kronk/test.rb +15 -0
- data/lib/kronk/test/assertions.rb +97 -0
- data/lib/kronk/test/core_ext.rb +65 -0
- data/lib/kronk/test/helper_methods.rb +86 -0
- data/lib/yzma.rb +174 -0
- data/lib/yzma/randomizer.rb +54 -0
- data/lib/yzma/report.rb +47 -0
- data/test/test_assertions.rb +93 -0
- data/test/test_core_ext.rb +74 -0
- data/test/test_data_set.rb +41 -32
- data/test/test_diff.rb +50 -24
- data/test/test_helper_methods.rb +177 -0
- data/test/test_kronk.rb +3 -1
- metadata +36 -19
data/test/test_diff.rb
CHANGED
@@ -7,6 +7,33 @@ class TestDiff < Test::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
|
10
|
+
def test_find_common
|
11
|
+
arr1 = [1,2,3,4,5,6,7,8,9,0]
|
12
|
+
arr2 = [2,3,1,4,7,8,9,0,5,6]
|
13
|
+
|
14
|
+
assert_equal [[2, 1, 0], [1, 3, 3], [4, 6, 4]],
|
15
|
+
@diff.find_common(arr1, arr2).compact
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def test_find_common_prelast_only_diff
|
20
|
+
arr1 = [1,2,3,4,5,6,0]
|
21
|
+
arr2 = [1,2,3,4,5,0]
|
22
|
+
|
23
|
+
assert_equal [[5,0,0],[1,6,5]],
|
24
|
+
@diff.find_common(arr1, arr2).compact
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def test_find_common_many
|
29
|
+
arr1 = [1,2,3,4,5,6,7,8,9,0,7,8,9,1,2,0,4,4]
|
30
|
+
arr2 = [2,3,1,4,7,8,9,0,5,6,1,7,8,0,0,9,1,2,4,4]
|
31
|
+
|
32
|
+
assert_equal [[2,1,0],[1,3,3],[4,6,4],[2,10,11],[3,12,15],[2,16,18]],
|
33
|
+
@diff.find_common(arr1, arr2).compact
|
34
|
+
end
|
35
|
+
|
36
|
+
|
10
37
|
def test_new_from_data
|
11
38
|
other_data = {:foo => :bar}
|
12
39
|
|
@@ -297,9 +324,8 @@ STR
|
|
297
324
|
|
298
325
|
expected = [
|
299
326
|
"line1",
|
300
|
-
[["line right"], ["line left", "line2", "line3"]],
|
327
|
+
[["line right", "line4"], ["line left", "line2", "line3"]],
|
301
328
|
"line4",
|
302
|
-
[["line4"], []],
|
303
329
|
"line5",
|
304
330
|
[["line6", "line2", "line7"], []]
|
305
331
|
]
|
@@ -468,28 +494,28 @@ STR
|
|
468
494
|
|
469
495
|
def diff_302_301_color
|
470
496
|
str = <<STR
|
471
|
-
\033[
|
472
|
-
\033[
|
473
|
-
\033[
|
474
|
-
\033[
|
475
|
-
Content-Type: text/html; charset=UTF-8
|
476
|
-
Date: Fri, 26 Nov 2010 16:14:45 GMT
|
477
|
-
Expires: Sun, 26 Dec 2010 16:14:45 GMT
|
478
|
-
Cache-Control: public, max-age=2592000
|
479
|
-
Server: gws
|
480
|
-
\033[
|
481
|
-
\033[
|
482
|
-
X-XSS-Protection: 1; mode=block
|
483
|
-
|
484
|
-
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
|
485
|
-
\033[31m<TITLE>302 Found</TITLE></HEAD><BODY>\033[0m
|
486
|
-
\033[31m<H1>302 Found</H1>\033[0m
|
487
|
-
\033[32m<TITLE>301 Moved</TITLE></HEAD><BODY>\033[0m
|
488
|
-
\033[32m<H1>301 Moved</H1>\033[0m
|
489
|
-
The document has moved
|
490
|
-
<A HREF="http://www.google.com/">here</A>.
|
491
|
-
\033[31m<A HREF="http://igoogle.com/">here</A>.\033[0m
|
492
|
-
</BODY></HTML>
|
497
|
+
\033[31m- HTTP/1.1 302 Found\033[0m
|
498
|
+
\033[31m- Location: http://igoogle.com/\033[0m
|
499
|
+
\033[32m+ HTTP/1.1 301 Moved Permanently\033[0m
|
500
|
+
\033[32m+ Location: http://www.google.com/\033[0m
|
501
|
+
Content-Type: text/html; charset=UTF-8
|
502
|
+
Date: Fri, 26 Nov 2010 16:14:45 GMT
|
503
|
+
Expires: Sun, 26 Dec 2010 16:14:45 GMT
|
504
|
+
Cache-Control: public, max-age=2592000
|
505
|
+
Server: gws
|
506
|
+
\033[31m- Content-Length: 260\033[0m
|
507
|
+
\033[32m+ Content-Length: 219\033[0m
|
508
|
+
X-XSS-Protection: 1; mode=block
|
509
|
+
|
510
|
+
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
|
511
|
+
\033[31m- <TITLE>302 Found</TITLE></HEAD><BODY>\033[0m
|
512
|
+
\033[31m- <H1>302 Found</H1>\033[0m
|
513
|
+
\033[32m+ <TITLE>301 Moved</TITLE></HEAD><BODY>\033[0m
|
514
|
+
\033[32m+ <H1>301 Moved</H1>\033[0m
|
515
|
+
The document has moved
|
516
|
+
<A HREF="http://www.google.com/">here</A>.
|
517
|
+
\033[31m- <A HREF="http://igoogle.com/">here</A>.\033[0m
|
518
|
+
</BODY></HTML>
|
493
519
|
STR
|
494
520
|
str.strip
|
495
521
|
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'test/test_helper'
|
2
|
+
require 'lib/kronk/test/helper_methods'
|
3
|
+
|
4
|
+
class TestHelperMethods < Test::Unit::TestCase
|
5
|
+
include Kronk::Test::HelperMethods
|
6
|
+
|
7
|
+
def setup
|
8
|
+
io = StringIO.new mock_resp("200_response.json")
|
9
|
+
@json = JSON.parse mock_resp("200_response.json").split("\r\n\r\n")[1]
|
10
|
+
@mock_resp = Kronk::Response.read_new io
|
11
|
+
@mock_resp2 = Kronk::Response.read_new \
|
12
|
+
StringIO.new mock_resp("200_response.json")
|
13
|
+
|
14
|
+
Kronk::Request.stubs(:retrieve).returns @mock_resp
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def test_get
|
19
|
+
Kronk::Request.expects(:retrieve).
|
20
|
+
with("host.com", :foo => "bar", :http_method => :get).
|
21
|
+
returns @mock_resp
|
22
|
+
|
23
|
+
get "host.com", :foo => "bar", :http_method => :foobar
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def test_get_two
|
28
|
+
Kronk::Request.expects(:retrieve).times(2).
|
29
|
+
with("host.com", :foo => "bar", :http_method => :get).
|
30
|
+
returns @mock_resp
|
31
|
+
|
32
|
+
get "host.com", "host.com", :foo => "bar", :http_method => :foobar
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def test_post
|
37
|
+
Kronk::Request.expects(:retrieve).
|
38
|
+
with("host.com", :foo => "bar", :http_method => :post).
|
39
|
+
returns @mock_resp
|
40
|
+
|
41
|
+
post "host.com", :foo => "bar", :http_method => :foobar
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def test_post_two
|
46
|
+
Kronk::Request.expects(:retrieve).times(2).
|
47
|
+
with("host.com", :foo => "bar", :http_method => :post).
|
48
|
+
returns @mock_resp
|
49
|
+
|
50
|
+
post "host.com", "host.com", :foo => "bar", :http_method => :foobar
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def test_put
|
55
|
+
Kronk::Request.expects(:retrieve).
|
56
|
+
with("host.com", :foo => "bar", :http_method => :put).
|
57
|
+
returns @mock_resp
|
58
|
+
|
59
|
+
put "host.com", :foo => "bar", :http_method => :foobar
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def test_put_two
|
64
|
+
Kronk::Request.expects(:retrieve).times(2).
|
65
|
+
with("host.com", :foo => "bar", :http_method => :put).
|
66
|
+
returns @mock_resp
|
67
|
+
|
68
|
+
put "host.com", "host.com", :foo => "bar", :http_method => :foobar
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
def test_delete
|
74
|
+
Kronk::Request.expects(:retrieve).
|
75
|
+
with("host.com", :foo => "bar", :http_method => :delete).
|
76
|
+
returns @mock_resp
|
77
|
+
|
78
|
+
delete "host.com", :foo => "bar", :http_method => :foobar
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def test_delete_two
|
83
|
+
Kronk::Request.expects(:retrieve).times(2).
|
84
|
+
with("host.com", :foo => "bar", :http_method => :delete).
|
85
|
+
returns @mock_resp
|
86
|
+
|
87
|
+
delete "host.com", "host.com", :foo => "bar", :http_method => :foobar
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def test_retrieve_one
|
92
|
+
Kronk::Request.expects(:retrieve).
|
93
|
+
with("host.com", :foo => "bar", :test => "thing").returns @mock_resp
|
94
|
+
|
95
|
+
@mock_resp.expects(:selective_data).with(:foo => "bar", :test => "thing").
|
96
|
+
returns @json
|
97
|
+
|
98
|
+
retrieve "host.com", {:foo => "bar"}, :test => "thing"
|
99
|
+
|
100
|
+
assert_equal @mock_resp, @response
|
101
|
+
assert_equal [@mock_resp], @responses
|
102
|
+
|
103
|
+
assert_equal @json, @data
|
104
|
+
assert_equal [@json], @datas
|
105
|
+
|
106
|
+
assert_nil @diff
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
def test_retrieve_two
|
111
|
+
Kronk::Request.expects(:retrieve).
|
112
|
+
with("host1.com", :foo => "bar").returns @mock_resp
|
113
|
+
|
114
|
+
Kronk::Request.expects(:retrieve).
|
115
|
+
with("host2.com", :foo => "bar").returns @mock_resp2
|
116
|
+
|
117
|
+
@mock_resp.expects(:selective_data).with(:foo => "bar").returns @json
|
118
|
+
|
119
|
+
@mock_resp2.expects(:selective_data).with(:foo => "bar").returns @json
|
120
|
+
|
121
|
+
retrieve "host1.com", "host2.com", :foo => "bar"
|
122
|
+
|
123
|
+
assert_equal @mock_resp2, @response
|
124
|
+
assert_equal [@mock_resp, @mock_resp2], @responses
|
125
|
+
|
126
|
+
assert_equal @json, @data
|
127
|
+
assert_equal [@json, @json], @datas
|
128
|
+
|
129
|
+
expected_diff = Kronk::Diff.new_from_data(*@datas)
|
130
|
+
|
131
|
+
assert_equal expected_diff.str1, @diff.str1
|
132
|
+
assert_equal expected_diff.str2, @diff.str2
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def test_retrieve_unparsable
|
137
|
+
mock_resp = Kronk::Response.read_new StringIO.new(mock_200_response)
|
138
|
+
|
139
|
+
Kronk::Request.expects(:retrieve).
|
140
|
+
with("host.com", :foo => "bar").returns mock_resp
|
141
|
+
|
142
|
+
retrieve "host.com", :foo => "bar"
|
143
|
+
|
144
|
+
assert_equal mock_resp, @response
|
145
|
+
assert_equal [mock_resp], @responses
|
146
|
+
|
147
|
+
assert_equal mock_resp.body, @data
|
148
|
+
assert_equal [mock_resp.body], @datas
|
149
|
+
|
150
|
+
assert_nil @diff
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
def test_retrieve_two_unparsable
|
155
|
+
mock_resp = Kronk::Response.read_new StringIO.new(mock_200_response)
|
156
|
+
|
157
|
+
Kronk::Request.expects(:retrieve).
|
158
|
+
with("host1.com", :foo => "bar").returns mock_resp
|
159
|
+
|
160
|
+
Kronk::Request.expects(:retrieve).
|
161
|
+
with("host2.com", :foo => "bar").returns mock_resp
|
162
|
+
|
163
|
+
|
164
|
+
retrieve "host1.com", "host2.com", :foo => "bar"
|
165
|
+
|
166
|
+
assert_equal mock_resp, @response
|
167
|
+
assert_equal [mock_resp, mock_resp], @responses
|
168
|
+
|
169
|
+
assert_equal mock_resp.body, @data
|
170
|
+
assert_equal [mock_resp.body, mock_resp.body], @datas
|
171
|
+
|
172
|
+
expected_diff = Kronk::Diff.new_from_data(*@datas)
|
173
|
+
|
174
|
+
assert_equal expected_diff.str1, @diff.str1
|
175
|
+
assert_equal expected_diff.str2, @diff.str2
|
176
|
+
end
|
177
|
+
end
|
data/test/test_kronk.rb
CHANGED
@@ -79,6 +79,8 @@ class TestKronk < Test::Unit::TestCase
|
|
79
79
|
def test_make_config_file
|
80
80
|
file = mock 'file'
|
81
81
|
file.expects(:<<).with Kronk::DEFAULT_CONFIG.to_yaml
|
82
|
+
File.expects(:directory?).with(Kronk::CONFIG_DIR).returns false
|
83
|
+
Dir.expects(:mkdir).with Kronk::CONFIG_DIR
|
82
84
|
File.expects(:open).with(Kronk::DEFAULT_CONFIG_FILE, "w+").yields file
|
83
85
|
|
84
86
|
Kronk.make_config_file
|
@@ -484,7 +486,7 @@ STR
|
|
484
486
|
options = {}
|
485
487
|
argv = %w{this is --argv -- one -two -- -three four :parents :-not_parents}
|
486
488
|
|
487
|
-
options = Kronk.parse_data_path_args options, argv
|
489
|
+
options = Kronk::Cmd.parse_data_path_args options, argv
|
488
490
|
|
489
491
|
assert_equal %w{one four}, options[:only_data]
|
490
492
|
assert_equal %w{two - three}, options[:ignore_data]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kronk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremie Castagna
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-06-01 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: plist
|
@@ -42,11 +41,11 @@ dependencies:
|
|
42
41
|
requirements:
|
43
42
|
- - ~>
|
44
43
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
44
|
+
hash: 5
|
46
45
|
segments:
|
47
46
|
- 1
|
48
|
-
-
|
49
|
-
version: "1.
|
47
|
+
- 5
|
48
|
+
version: "1.5"
|
50
49
|
type: :runtime
|
51
50
|
version_requirements: *id002
|
52
51
|
- !ruby/object:Gem::Dependency
|
@@ -57,11 +56,11 @@ dependencies:
|
|
57
56
|
requirements:
|
58
57
|
- - ~>
|
59
58
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
59
|
+
hash: 7
|
61
60
|
segments:
|
62
61
|
- 1
|
63
|
-
-
|
64
|
-
version: "1.
|
62
|
+
- 4
|
63
|
+
version: "1.4"
|
65
64
|
type: :runtime
|
66
65
|
version_requirements: *id003
|
67
66
|
- !ruby/object:Gem::Dependency
|
@@ -70,7 +69,7 @@ dependencies:
|
|
70
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
70
|
none: false
|
72
71
|
requirements:
|
73
|
-
- -
|
72
|
+
- - ">="
|
74
73
|
- !ruby/object:Gem::Version
|
75
74
|
hash: 1
|
76
75
|
segments:
|
@@ -150,12 +149,12 @@ dependencies:
|
|
150
149
|
requirements:
|
151
150
|
- - ">="
|
152
151
|
- !ruby/object:Gem::Version
|
153
|
-
hash:
|
152
|
+
hash: 35
|
154
153
|
segments:
|
155
154
|
- 2
|
156
|
-
-
|
157
|
-
-
|
158
|
-
version: 2.
|
155
|
+
- 9
|
156
|
+
- 4
|
157
|
+
version: 2.9.4
|
159
158
|
type: :development
|
160
159
|
version_requirements: *id009
|
161
160
|
description: |-
|
@@ -165,6 +164,7 @@ email:
|
|
165
164
|
- yaksnrainbows@gmail.com
|
166
165
|
executables:
|
167
166
|
- kronk
|
167
|
+
- yzma
|
168
168
|
extensions: []
|
169
169
|
|
170
170
|
extra_rdoc_files:
|
@@ -178,13 +178,24 @@ files:
|
|
178
178
|
- README.rdoc
|
179
179
|
- Rakefile
|
180
180
|
- bin/kronk
|
181
|
+
- bin/yzma
|
181
182
|
- lib/kronk.rb
|
183
|
+
- lib/kronk/cmd.rb
|
182
184
|
- lib/kronk/data_set.rb
|
183
185
|
- lib/kronk/diff.rb
|
186
|
+
- lib/kronk/diff/ascii_format.rb
|
187
|
+
- lib/kronk/diff/color_format.rb
|
184
188
|
- lib/kronk/plist_parser.rb
|
185
189
|
- lib/kronk/request.rb
|
186
190
|
- lib/kronk/response.rb
|
191
|
+
- lib/kronk/test.rb
|
192
|
+
- lib/kronk/test/assertions.rb
|
193
|
+
- lib/kronk/test/core_ext.rb
|
194
|
+
- lib/kronk/test/helper_methods.rb
|
187
195
|
- lib/kronk/xml_parser.rb
|
196
|
+
- lib/yzma.rb
|
197
|
+
- lib/yzma/randomizer.rb
|
198
|
+
- lib/yzma/report.rb
|
188
199
|
- script/kronk_completion
|
189
200
|
- test/mocks/200_response.json
|
190
201
|
- test/mocks/200_response.plist
|
@@ -192,6 +203,9 @@ files:
|
|
192
203
|
- test/mocks/200_response.xml
|
193
204
|
- test/mocks/301_response.txt
|
194
205
|
- test/mocks/302_response.txt
|
206
|
+
- test/test_assertions.rb
|
207
|
+
- test/test_core_ext.rb
|
208
|
+
- test/test_helper_methods.rb
|
195
209
|
- test/test_data_set.rb
|
196
210
|
- test/test_diff.rb
|
197
211
|
- test/test_helper.rb
|
@@ -199,7 +213,7 @@ files:
|
|
199
213
|
- test/test_request.rb
|
200
214
|
- test/test_response.rb
|
201
215
|
- test/test_xml_parser.rb
|
202
|
-
|
216
|
+
- .gemtest
|
203
217
|
homepage: https://github.com/yaksnrainbows/kronk
|
204
218
|
licenses: []
|
205
219
|
|
@@ -230,14 +244,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
244
|
requirements: []
|
231
245
|
|
232
246
|
rubyforge_project: kronk
|
233
|
-
rubygems_version: 1.
|
247
|
+
rubygems_version: 1.8.4
|
234
248
|
signing_key:
|
235
249
|
specification_version: 3
|
236
250
|
summary: Kronk runs diffs against data from live and cached http responses
|
237
251
|
test_files:
|
252
|
+
- test/test_assertions.rb
|
253
|
+
- test/test_core_ext.rb
|
238
254
|
- test/test_data_set.rb
|
239
255
|
- test/test_diff.rb
|
240
256
|
- test/test_helper.rb
|
257
|
+
- test/test_helper_methods.rb
|
241
258
|
- test/test_kronk.rb
|
242
259
|
- test/test_request.rb
|
243
260
|
- test/test_response.rb
|