hana 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fb4c95fd3541788a19d1c4b9d7bd1931242191a
4
- data.tar.gz: 83e628bf62efb6e476121837a710c0d64bfc7590
3
+ metadata.gz: 54a300a1f4f135540a4c590cf3e7e1b8ad617b4a
4
+ data.tar.gz: 499cba6697fe8fca1bd5a4788042cb5492ed01d4
5
5
  SHA512:
6
- metadata.gz: 5b60dc61f8c64a99d6595b7b8e8192b2d1f658a47eab4a74bfca692edc4883dc25979b41bc4a68b3f1a5b02f69f832fdfa9ca744aea279ef7480d836b3ba0463
7
- data.tar.gz: 52c58c0d9d5690a9f37c8e24621ae21dba3fd651566730c723c4603ab41c6b843da2f3b13eca22cf31a7bd0eb12e476b1f0c3f5d50a45d4eac57474b0e896480
6
+ metadata.gz: 50c03edacec8defe7b7e82289a87bfe3c52e77255d019dc96abdc1407be82c9ceb027ebae98bfb2dfb7c2a987d42a73e4ea08e639f5217282de93cabbc856384
7
+ data.tar.gz: fb38bcb65aedbffa1e1cdf3d109776abcf1a7bf6cba5ca91dd32f41df67983f10438027dffc0f3df632c819ddb3b20e4d6da1af8f1aadf8d486250075df5cb4f
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hana
2
- VERSION = '1.3.2'
4
+ VERSION = '1.3.3'
3
5
 
4
6
  class Pointer
5
7
  include Enumerable
@@ -21,7 +23,7 @@ module Hana
21
23
  return nil unless o
22
24
 
23
25
  if Array === o
24
- raise Patch::IndexError unless part =~ /\A\d+\Z/
26
+ raise Patch::IndexError unless part =~ /\A(?:\d|[1-9]\d+)\Z/
25
27
  part = part.to_i
26
28
  end
27
29
  o[part]
@@ -188,8 +190,11 @@ module Hana
188
190
  def rm_op obj, key
189
191
  if Array === obj
190
192
  raise Patch::IndexError unless key =~ /\A\d+\Z/
191
- obj.delete_at key.to_i
193
+ key = key.to_i
194
+ raise Patch::OutOfBoundsException if key >= obj.length
195
+ obj.delete_at key
192
196
  else
197
+ raise Patch::IndexError unless obj.key? key
193
198
  obj.delete key
194
199
  end
195
200
  end
@@ -12,7 +12,16 @@ module Hana
12
12
  tests.each_with_index do |test, i|
13
13
  next unless test['doc']
14
14
 
15
- define_method("test_#{test['comment'] || i }") do
15
+ method = "test_#{test['comment'] || i }"
16
+ loop do
17
+ if method_defined? method
18
+ method = "test_#{test['comment'] || i } x"
19
+ else
20
+ break
21
+ end
22
+ end
23
+
24
+ define_method(method) do
16
25
  skip "disabled" if test['disabled']
17
26
 
18
27
  doc = test['doc']
@@ -50,6 +59,10 @@ module Hana
50
59
  [Hana::Patch::IndexError, Hana::Patch::ObjectOperationOnArrayException]
51
60
  when /bad number$/ then
52
61
  [Hana::Patch::IndexError, Hana::Patch::ObjectOperationOnArrayException]
62
+ when /removing a nonexistent (field|index)/ then
63
+ [Hana::Patch::IndexError, Hana::Patch::OutOfBoundsException]
64
+ when /test op should reject the array value, it has leading zeros/ then
65
+ [Hana::Patch::IndexError]
53
66
  when /missing '(from|value)' parameter/ then
54
67
  [KeyError]
55
68
  when /Unrecognized op 'spam'/ then
@@ -383,5 +383,26 @@
383
383
  { "comment": "unrecognized op should fail",
384
384
  "doc": {"foo": 1},
385
385
  "patch": [{"op": "spam", "path": "/foo", "value": 1}],
386
- "error": "Unrecognized op 'spam'" }
386
+ "error": "Unrecognized op 'spam'" },
387
+
388
+ { "comment": "test with bad array number that has leading zeros",
389
+ "doc": ["foo", "bar"],
390
+ "patch": [{"op": "test", "path": "/00", "value": "foo"}],
391
+ "error": "test op should reject the array value, it has leading zeros" },
392
+
393
+ { "comment": "test with bad array number that has leading zeros",
394
+ "doc": ["foo", "bar"],
395
+ "patch": [{"op": "test", "path": "/01", "value": "bar"}],
396
+ "error": "test op should reject the array value, it has leading zeros" },
397
+
398
+ { "comment": "Removing nonexistent field",
399
+ "doc": {"foo" : "bar"},
400
+ "patch": [{"op": "remove", "path": "/baz"}],
401
+ "error": "removing a nonexistent field should fail" },
402
+
403
+ { "comment": "Removing nonexistent index",
404
+ "doc": ["foo", "bar"],
405
+ "patch": [{"op": "remove", "path": "/2"}],
406
+ "error": "removing a nonexistent index should fail" }
407
+
387
408
  ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-29 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.9'
19
+ version: '5.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.9'
26
+ version: '5.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.15'
47
+ version: '3.16'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.15'
54
+ version: '3.16'
55
55
  description: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.
56
56
  email:
57
57
  - aaron@tenderlovemaking.com
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.6.4
100
+ rubygems_version: 2.6.10
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.