kronk 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.5.3 / 2011-08-31
2
+
3
+ * Bugfixes:
4
+
5
+ * Fix for multiple path transaction delete bug.
6
+
7
+ * Fix for non applied uri options from config.
8
+
1
9
  === 1.5.2 / 2011-08-15
2
10
 
3
11
  * Enhancements:
data/lib/kronk.rb CHANGED
@@ -14,7 +14,7 @@ require 'yaml'
14
14
  class Kronk
15
15
 
16
16
  # This gem's version.
17
- VERSION = '1.5.2'
17
+ VERSION = '1.5.3'
18
18
 
19
19
  require 'kronk/constants'
20
20
  require 'kronk/player'
@@ -285,7 +285,7 @@ class Kronk
285
285
  # Returns a Response instance from a url, file, or IO as a String.
286
286
 
287
287
  def retrieve uri
288
- options = Kronk.config[:no_uri_options] ? options_for_uri(uri) : @options
288
+ options = Kronk.config[:no_uri_options] ? @options : options_for_uri(uri)
289
289
 
290
290
  if IO === uri || StringIO === uri
291
291
  Cmd.verbose "Reading IO #{uri}"
@@ -340,7 +340,6 @@ class Kronk
340
340
  next
341
341
  end
342
342
 
343
-
344
343
  case key
345
344
 
346
345
  # Hash or uri query String
@@ -47,30 +47,31 @@ class Kronk
47
47
  Hash === v1 && Hash === v2 ? v1.merge(v2,&DEEP_MERGE) : v2
48
48
  end
49
49
 
50
+ # The default Kronk user agent.
51
+ DEFAULT_USER_AGENT =
52
+ "Kronk/#{VERSION} (http://github.com/yaksnrainbows/kronk)"
50
53
 
51
54
  # Aliases for various user-agents. Thanks Mechanize! :)
52
55
  USER_AGENTS = {
53
- 'kronk' =>
54
- "Kronk/#{VERSION} (http://github.com/yaksnrainbows/kronk)",
55
- 'iphone' =>
56
+ 'iphone' =>
56
57
  "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3",
57
- 'linux_firefox' =>
58
+ 'linux_firefox' =>
58
59
  "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.1) Gecko/20100122 firefox/3.6.1",
59
- 'linux_mozilla' =>
60
+ 'linux_mozilla' =>
60
61
  "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624",
61
- 'mac_mozilla' =>
62
+ 'mac_mozilla' =>
62
63
  "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401",
63
64
  'linux_konqueror' =>
64
65
  "Mozilla/5.0 (compatible; Konqueror/3; Linux)",
65
- 'mac_firefox' =>
66
+ 'mac_firefox' =>
66
67
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6",
67
- 'mac_safari' =>
68
+ 'mac_safari' =>
68
69
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-at) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10",
69
- 'win_ie6' =>
70
+ 'win_ie6' =>
70
71
  "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
71
- 'win_ie7' =>
72
+ 'win_ie7' =>
72
73
  "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
73
- 'win_mozilla' =>
74
+ 'win_mozilla' =>
74
75
  "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6"
75
76
  }
76
77
 
@@ -150,7 +150,8 @@ class Kronk::Path::Transaction
150
150
  new_curr_data.delete key
151
151
 
152
152
  else
153
- new_curr_data[key] = curr_data[key].dup
153
+ new_curr_data[key] = new_curr_data[key].dup if
154
+ new_curr_data[key] == curr_data[key]
154
155
 
155
156
  if Array === new_curr_data[key]
156
157
  new_curr_data[key] = ary_to_hash new_curr_data[key]
data/lib/kronk/request.rb CHANGED
@@ -323,7 +323,7 @@ class Kronk
323
323
  def user_agent= new_ua
324
324
  @headers['User-Agent'] =
325
325
  new_ua && Kronk.config[:user_agents][new_ua.to_s] ||
326
- new_ua || Kronk.config[:user_agents]['kronk']
326
+ new_ua || Kronk::DEFAULT_USER_AGENT
327
327
  end
328
328
 
329
329
 
data/test/test_helper.rb CHANGED
@@ -133,7 +133,11 @@ end
133
133
 
134
134
 
135
135
  def with_config config={}
136
- old_conf = Kronk.config
136
+ old_conf = Kronk.config.dup
137
+ old_conf.each do |k,v|
138
+ old_conf[k] = v.dup if Array === old_conf[k] || Hash === old_conf[k]
139
+ end
140
+
137
141
  Kronk.instance_variable_set "@config", Kronk.config.merge(config)
138
142
  yield
139
143
 
@@ -159,7 +163,7 @@ def expect_request req_method, url, options={}
159
163
  data &&= Hash === data ? Kronk::Request.build_query(data) : data.to_s
160
164
 
161
165
  headers = options[:headers] || Hash.new
162
- headers['User-Agent'] ||= Kronk.config[:user_agents]['kronk']
166
+ headers['User-Agent'] ||= Kronk::DEFAULT_USER_AGENT
163
167
 
164
168
  req.expects(:start).yields(http).returns res
165
169
 
data/test/test_kronk.rb CHANGED
@@ -28,59 +28,61 @@ class TestKronk < Test::Unit::TestCase
28
28
 
29
29
 
30
30
  def test_load_config
31
- mock_config = {
32
- :content_types => {
33
- 'soap' => "SOAPParser",
34
- 'js' => "JsEngine"
35
- },
36
- :ignore_headers => ["Content-Type"],
37
- :cache_file => Kronk::DEFAULT_CACHE_FILE,
38
- :cookies_file => Kronk::DEFAULT_COOKIES_FILE,
39
- :history_file => Kronk::DEFAULT_HISTORY_FILE,
40
- :indentation => 1,
41
- :show_lines => false,
42
- :use_cookies => true,
43
- :requires => [],
44
- :uri_options => {'example.com' => {:parser => 'JSON'}},
45
- :user_agents => {:win_ie6 => 'piece of crap browser'},
46
- :foo => :bar
47
- }
31
+ with_config do
32
+ mock_config = {
33
+ :content_types => {
34
+ 'soap' => "SOAPParser",
35
+ 'js' => "JsEngine"
36
+ },
37
+ :ignore_headers => ["Content-Type"],
38
+ :cache_file => Kronk::DEFAULT_CACHE_FILE,
39
+ :cookies_file => Kronk::DEFAULT_COOKIES_FILE,
40
+ :history_file => Kronk::DEFAULT_HISTORY_FILE,
41
+ :indentation => 1,
42
+ :show_lines => false,
43
+ :use_cookies => true,
44
+ :requires => [],
45
+ :uri_options => {'example.com' => {:parser => 'JSON'}},
46
+ :user_agents => {:win_ie6 => 'piece of crap browser'},
47
+ :foo => :bar
48
+ }
48
49
 
49
- YAML.expects(:load_file).with(Kronk::DEFAULT_CONFIG_FILE).
50
- returns mock_config
50
+ YAML.expects(:load_file).with(Kronk::DEFAULT_CONFIG_FILE).
51
+ returns mock_config
51
52
 
52
- Kronk.load_config
53
+ Kronk.load_config
53
54
 
54
- YAML.expects(:load_file).with("foobar").
55
- returns mock_config
55
+ YAML.expects(:load_file).with("foobar").
56
+ returns mock_config
56
57
 
57
- Kronk.load_config "foobar"
58
+ Kronk.load_config "foobar"
58
59
 
59
- expected = {
60
- :content_types => {
61
- 'soap' => "SOAPParser",
62
- 'js' => "JsEngine",
63
- 'json' => "JSON",
64
- 'plist' => "PlistParser",
65
- 'xml' => "XMLParser"
66
- },
67
- :default_host => "http://localhost:3000",
68
- :diff_format => :ascii_diff,
69
- :cache_file => Kronk::DEFAULT_CACHE_FILE,
70
- :cookies_file => Kronk::DEFAULT_COOKIES_FILE,
71
- :history_file => Kronk::DEFAULT_HISTORY_FILE,
72
- :indentation => 1,
73
- :requires => [],
74
- :show_lines => false,
75
- :use_cookies => true,
76
- :ignore_headers => ["Content-Type"],
77
- :uri_options => {'example.com' => {:parser => 'JSON'}},
78
- :user_agents =>
79
- Kronk::USER_AGENTS.merge(:win_ie6 => 'piece of crap browser'),
80
- :foo => :bar
81
- }
60
+ expected = {
61
+ :content_types => {
62
+ 'soap' => "SOAPParser",
63
+ 'js' => "JsEngine",
64
+ 'json' => "JSON",
65
+ 'plist' => "PlistParser",
66
+ 'xml' => "XMLParser"
67
+ },
68
+ :default_host => "http://localhost:3000",
69
+ :diff_format => :ascii_diff,
70
+ :cache_file => Kronk::DEFAULT_CACHE_FILE,
71
+ :cookies_file => Kronk::DEFAULT_COOKIES_FILE,
72
+ :history_file => Kronk::DEFAULT_HISTORY_FILE,
73
+ :indentation => 1,
74
+ :requires => [],
75
+ :show_lines => false,
76
+ :use_cookies => true,
77
+ :ignore_headers => ["Content-Type"],
78
+ :uri_options => {'example.com' => {:parser => 'JSON'}},
79
+ :user_agents =>
80
+ Kronk::USER_AGENTS.merge(:win_ie6 => 'piece of crap browser'),
81
+ :foo => :bar
82
+ }
82
83
 
83
- assert_equal expected, Kronk.config
84
+ assert_equal expected, Kronk.config
85
+ end
84
86
  end
85
87
 
86
88
 
@@ -280,6 +280,17 @@ class TestTransaction < Test::Unit::TestCase
280
280
  end
281
281
 
282
282
 
283
+ def test_transaction_delete_many_from_embedded_data
284
+ result = @trans.transaction_delete @data, "key1/key1a/1", "key1/key1a/0"
285
+ expected = {
286
+ :key1a => {2 => "foobar", 3 => {:findme => "thing"}},
287
+ 'key1b' => "findme"
288
+ }
289
+
290
+ assert_equal expected, result[:key1]
291
+ end
292
+
293
+
283
294
  def test_transaction_delete_empty
284
295
  assert_equal @data, @trans.transaction_delete(@data)
285
296
  end
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: 5
4
5
  prerelease:
5
- version: 1.5.2
6
+ segments:
7
+ - 1
8
+ - 5
9
+ - 3
10
+ version: 1.5.3
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-08-17 00:00:00 Z
18
+ date: 2011-08-31 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,6 +87,11 @@ 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
@@ -75,7 +103,12 @@ dependencies:
75
103
  requirements:
76
104
  - - ">="
77
105
  - !ruby/object:Gem::Version
78
- version: 2.9.1
106
+ hash: 35
107
+ segments:
108
+ - 2
109
+ - 9
110
+ - 4
111
+ version: 2.9.4
79
112
  type: :development
80
113
  version_requirements: *id006
81
114
  description: |-
@@ -161,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
194
  requirements:
162
195
  - - ">="
163
196
  - !ruby/object:Gem::Version
164
- hash: -1250647076143869812
197
+ hash: 3
165
198
  segments:
166
199
  - 0
167
200
  version: "0"
@@ -170,11 +203,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
203
  requirements:
171
204
  - - ">="
172
205
  - !ruby/object:Gem::Version
206
+ hash: 3
207
+ segments:
208
+ - 0
173
209
  version: "0"
174
210
  requirements: []
175
211
 
176
212
  rubyforge_project: kronk
177
- rubygems_version: 1.8.6
213
+ rubygems_version: 1.8.5
178
214
  signing_key:
179
215
  specification_version: 3
180
216
  summary: Kronk runs diffs against data from live and cached http responses