kronk 1.6.2 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/History.rdoc +29 -1
  2. data/Manifest.txt +6 -1
  3. data/README.rdoc +74 -28
  4. data/Rakefile +4 -3
  5. data/TODO.rdoc +7 -5
  6. data/bin/kronk +2 -11
  7. data/lib/kronk/async/em_ext.rb +34 -0
  8. data/lib/kronk/async/request.rb +73 -0
  9. data/lib/kronk/async/response.rb +70 -0
  10. data/lib/kronk/async.rb +118 -0
  11. data/lib/kronk/cmd.rb +111 -43
  12. data/lib/kronk/constants.rb +1 -0
  13. data/lib/kronk/core_ext.rb +1 -1
  14. data/lib/kronk/data_string.rb +251 -0
  15. data/lib/kronk/diff/output.rb +132 -100
  16. data/lib/kronk/diff.rb +20 -24
  17. data/lib/kronk/path/matcher.rb +8 -4
  18. data/lib/kronk/path/path_match.rb +48 -4
  19. data/lib/kronk/path/transaction.rb +74 -53
  20. data/lib/kronk/path.rb +11 -6
  21. data/lib/kronk/player/benchmark.rb +11 -12
  22. data/lib/kronk/player/input_reader.rb +40 -3
  23. data/lib/kronk/player/request_parser.rb +4 -1
  24. data/lib/kronk/player/stream.rb +2 -2
  25. data/lib/kronk/player/suite.rb +16 -9
  26. data/lib/kronk/player.rb +93 -143
  27. data/lib/kronk/queue_runner.rb +238 -0
  28. data/lib/kronk/request.rb +25 -20
  29. data/lib/kronk/response.rb +39 -10
  30. data/lib/kronk/test/assertions.rb +2 -2
  31. data/lib/kronk/test/helper_methods.rb +1 -1
  32. data/lib/kronk.rb +56 -24
  33. data/test/test_assertions.rb +4 -4
  34. data/test/test_cmd.rb +38 -10
  35. data/test/test_data_string.rb +242 -1
  36. data/test/test_diff.rb +8 -303
  37. data/test/test_helper.rb +1 -1
  38. data/test/test_kronk.rb +21 -28
  39. data/test/test_path.rb +29 -0
  40. data/test/test_path_match.rb +47 -2
  41. data/test/test_path_matcher.rb +42 -1
  42. data/test/test_player.rb +71 -72
  43. data/test/test_request.rb +31 -6
  44. data/test/test_request_parser.rb +7 -1
  45. data/test/test_response.rb +1 -1
  46. data/test/test_transaction.rb +78 -30
  47. metadata +64 -8
  48. data/lib/kronk/data_renderer.rb +0 -219
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kronk
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 11
4
5
  prerelease:
5
- version: 1.6.2
6
+ segments:
7
+ - 1
8
+ - 7
9
+ - 0
10
+ version: 1.7.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Jeremie Castagna
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-09-12 00:00:00 Z
18
+ date: 2011-10-09 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: json
@@ -20,6 +25,10 @@ dependencies:
20
25
  requirements:
21
26
  - - ~>
22
27
  - !ruby/object:Gem::Version
28
+ hash: 5
29
+ segments:
30
+ - 1
31
+ - 5
23
32
  version: "1.5"
24
33
  type: :runtime
25
34
  version_requirements: *id001
@@ -31,6 +40,11 @@ dependencies:
31
40
  requirements:
32
41
  - - ~>
33
42
  - !ruby/object:Gem::Version
43
+ hash: 19
44
+ segments:
45
+ - 0
46
+ - 3
47
+ - 0
34
48
  version: 0.3.0
35
49
  type: :runtime
36
50
  version_requirements: *id002
@@ -42,6 +56,11 @@ dependencies:
42
56
  requirements:
43
57
  - - ~>
44
58
  - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 3
62
+ - 1
63
+ - 0
45
64
  version: 3.1.0
46
65
  type: :development
47
66
  version_requirements: *id003
@@ -53,6 +72,10 @@ dependencies:
53
72
  requirements:
54
73
  - - ~>
55
74
  - !ruby/object:Gem::Version
75
+ hash: 7
76
+ segments:
77
+ - 1
78
+ - 4
56
79
  version: "1.4"
57
80
  type: :development
58
81
  version_requirements: *id004
@@ -64,20 +87,45 @@ dependencies:
64
87
  requirements:
65
88
  - - ~>
66
89
  - !ruby/object:Gem::Version
90
+ hash: 35
91
+ segments:
92
+ - 0
93
+ - 9
94
+ - 12
67
95
  version: 0.9.12
68
96
  type: :development
69
97
  version_requirements: *id005
70
98
  - !ruby/object:Gem::Dependency
71
- name: hoe
99
+ name: em-http-request
72
100
  prerelease: false
73
101
  requirement: &id006 !ruby/object:Gem::Requirement
74
102
  none: false
75
103
  requirements:
76
- - - ">="
104
+ - - ~>
77
105
  - !ruby/object:Gem::Version
78
- version: 2.9.1
106
+ hash: 23
107
+ segments:
108
+ - 1
109
+ - 0
110
+ - 0
111
+ version: 1.0.0
79
112
  type: :development
80
113
  version_requirements: *id006
114
+ - !ruby/object:Gem::Dependency
115
+ name: hoe
116
+ prerelease: false
117
+ requirement: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ hash: 21
123
+ segments:
124
+ - 2
125
+ - 11
126
+ version: "2.11"
127
+ type: :development
128
+ version_requirements: *id007
81
129
  description: |-
82
130
  Kronk runs diffs against data from live and cached http responses.
83
131
  Kronk was made possible by the sponsoring of AT&T Interactive.
@@ -100,10 +148,14 @@ files:
100
148
  - Rakefile
101
149
  - bin/kronk
102
150
  - lib/kronk.rb
151
+ - lib/kronk/async.rb
152
+ - lib/kronk/async/em_ext.rb
153
+ - lib/kronk/async/request.rb
154
+ - lib/kronk/async/response.rb
103
155
  - lib/kronk/cmd.rb
104
156
  - lib/kronk/constants.rb
105
157
  - lib/kronk/core_ext.rb
106
- - lib/kronk/data_renderer.rb
158
+ - lib/kronk/data_string.rb
107
159
  - lib/kronk/diff.rb
108
160
  - lib/kronk/diff/ascii_format.rb
109
161
  - lib/kronk/diff/color_format.rb
@@ -120,6 +172,7 @@ files:
120
172
  - lib/kronk/player/suite.rb
121
173
  - lib/kronk/player/stream.rb
122
174
  - lib/kronk/plist_parser.rb
175
+ - lib/kronk/queue_runner.rb
123
176
  - lib/kronk/request.rb
124
177
  - lib/kronk/response.rb
125
178
  - lib/kronk/test.rb
@@ -169,7 +222,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
222
  requirements:
170
223
  - - ">="
171
224
  - !ruby/object:Gem::Version
172
- hash: -3702389185383603132
225
+ hash: 3
173
226
  segments:
174
227
  - 0
175
228
  version: "0"
@@ -178,11 +231,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
231
  requirements:
179
232
  - - ">="
180
233
  - !ruby/object:Gem::Version
234
+ hash: 3
235
+ segments:
236
+ - 0
181
237
  version: "0"
182
238
  requirements: []
183
239
 
184
240
  rubyforge_project: kronk
185
- rubygems_version: 1.8.6
241
+ rubygems_version: 1.8.8
186
242
  signing_key:
187
243
  specification_version: 3
188
244
  summary: Kronk runs diffs against data from live and cached http responses
@@ -1,219 +0,0 @@
1
- class Kronk
2
-
3
- ##
4
- # A String with per-line metadata.
5
-
6
- class DataString < String
7
-
8
- attr_accessor :meta
9
-
10
- def initialize str="", metadata=nil
11
- @meta = [metadata].compact * str.length
12
- super str
13
- end
14
-
15
-
16
- ##
17
- # Add a string with metadata to the data string.
18
-
19
- def append str, metadata=nil
20
- dstr = self.class.new str
21
- dstr.meta = [metadata] * str.length
22
- self << dstr
23
- end
24
-
25
-
26
- def << str
27
- if str.class == self.class
28
- @meta.concat str.meta
29
- else
30
- @meta.concat([@meta.last] * str.length)
31
- end
32
- super str
33
- end
34
-
35
-
36
- def [] arg
37
- dstr = self.class.new super
38
- dstr.meta = @meta[arg]
39
- dstr
40
- end
41
-
42
-
43
- def split pattern=$;, *more
44
- arr = super
45
- i = 0
46
- interval = 0
47
- interval = (self.length - arr.join.length) / (arr.length - 1) if
48
- arr.length > 1
49
-
50
- arr.map do |str|
51
- ds = self.class.new str
52
- ds.meta = @meta[i,str.length]
53
- i += str.length + interval
54
- ds
55
- end
56
- end
57
- end
58
-
59
-
60
- ##
61
- # Creates ordered data strings for rendering to the output.
62
-
63
- module DataRenderer
64
-
65
- ##
66
- # Returns a ruby data string that is diff-able, meaning sorted by
67
- # Hash keys when available.
68
-
69
- def self.ruby data, struct_only=false
70
- ordered_data_string data, struct_only do |type, obj|
71
- case type
72
- when :key_assign then " =>"
73
- when :key then obj.inspect
74
- when :value then obj.inspect
75
- when :struct
76
- (obj == true || obj == false) ? "Boolean" : obj.class
77
- end
78
- end
79
- end
80
-
81
-
82
- ##
83
- # Returns a json data string that is diff-able, meaning sorted by
84
- # Hash keys when available.
85
-
86
- def self.json data, struct_only=false
87
- ordered_data_string data, struct_only do |type, obj|
88
- case type
89
- when :key_assign then ":"
90
- when :key
91
- (Symbol === obj ? obj.inspect : obj.to_s).to_json
92
- when :value
93
- (Symbol === obj ? obj.inspect : obj).to_json
94
- when :struct
95
- ((obj == true || obj == false) ? "Boolean" : obj.class).to_json
96
- end
97
- end
98
- end
99
-
100
-
101
- ##
102
- # Turns a data set into an ordered string output for diff-ing.
103
-
104
- def self.ordered_data_string data, struct_only=false, path=[], &block
105
- i_width = Kronk.config[:indentation] || 1
106
- indent = (path.length + 1) * i_width
107
- pad = " " * indent
108
- path_str = Path.join path
109
-
110
- case data
111
-
112
- when Hash
113
- return DataString.new("{}", path_str) if data.empty?
114
- output = DataString.new "{\n", path_str
115
-
116
- sorted_keys = sort_any data.keys
117
-
118
- data_values =
119
- sorted_keys.map do |key|
120
- value = data[key]
121
- new_path = path.dup << key
122
- subdata = ordered_data_string value, struct_only, new_path, &block
123
- line = "#{pad}#{ yield(:key, key) }#{ yield(:key_assign) } "
124
- line = DataString.new line, path_str
125
- line << subdata
126
- end
127
-
128
- data_values.each_with_index do |val, i|
129
- val << "," unless i == data_values.length - 1
130
- output << val << "\n"
131
- end
132
-
133
- output.append(("#{" " * (indent - i_width)}}"), path_str)
134
-
135
- when Array
136
- return DataString.new("[]", path_str) if data.empty?
137
- output = DataString.new "[\n", path_str
138
-
139
- data_values =
140
- (0...data.length).map do |key|
141
- value = data[key]
142
- new_path = path.dup << key
143
- subdata = ordered_data_string value, struct_only, new_path, &block
144
- line = DataString.new pad, path_str
145
- line << subdata
146
- end
147
-
148
- data_values.each_with_index do |val, i|
149
- val << "," unless i == data_values.length - 1
150
- output << val << "\n"
151
- end
152
-
153
- output.append(("#{" " * (indent - i_width)}]"), path_str)
154
-
155
- else
156
- output = struct_only ? yield(:struct, data) : yield(:value, data)
157
- DataString.new(output.to_s, path_str)
158
- end
159
- end
160
-
161
-
162
- ##
163
- # Sorts an array of any combination of string, integer, or symbols.
164
-
165
- def self.sort_any arr
166
- i = 1
167
- until i >= arr.length
168
- j = i-1
169
- val = arr[i]
170
- prev_val = arr[j]
171
-
172
- loop do
173
- if smaller?(val, arr[j])
174
- arr[j+1] = arr[j]
175
- j = j - 1
176
- break if j < 0
177
-
178
- else
179
- break
180
- end
181
- end
182
-
183
- arr[j+1] = val
184
-
185
- i = i.next
186
- end
187
-
188
- arr
189
- end
190
-
191
-
192
- ##
193
- # Compares Numerics, Strings, and Symbols and returns true if the left
194
- # side is 'smaller' than the right side.
195
-
196
- def self.smaller? left, right
197
- case left
198
- when Numeric
199
- case right
200
- when Numeric then right > left
201
- else true
202
- end
203
-
204
- when Symbol
205
- case right
206
- when Numeric then false
207
- when Symbol then right.to_s > left.to_s
208
- else true
209
- end
210
-
211
- when String
212
- case right
213
- when String then right > left
214
- else false
215
- end
216
- end
217
- end
218
- end
219
- end