json-repair 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1873dc4a32f871c8dc79227074438b0118837f32bc3f36d004510604b265de4a
4
- data.tar.gz: 33e15f3df710287842b41aa0a7490b239e5022d7fa53433ae272a103dc34d242
3
+ metadata.gz: 83ede681caac8ebbc294902937c8af11ebc90fe066beed41e15013782fbd0b96
4
+ data.tar.gz: da309d72a1c564f05dd405c02115985572c38c8b2c28aad85f778b94cc2a68e9
5
5
  SHA512:
6
- metadata.gz: a61ee9fa2a2220c494ded4bba09da73e5366a1af65e5cd6ae4ed08141c93db2ad445f5fe5571b7778e0693b5826e0c2506d042d0b3f8a91c8f78e9f6b213ca08
7
- data.tar.gz: 8f1953f3959e5a571e0c6a02de0dab1ad775b007c4024ba21f7ae8b1d70e235b145a1de90bd1ddbf29d1ee16d36649dc68dceca6d536bc5f343ff4c150a7b2a6
6
+ metadata.gz: da63df705106d20701700dd55712ed06676cdb4e6615f36d915cae12f3bdf7ac085ea919a553c77e8e0876663e5ad7d0067b46b00fddd3a7cca837eb38e54fc8
7
+ data.tar.gz: d4471c07b5a3a39505ec890b8afc359ca12fa3042c953143675af2d88bd8a4f56fe6225f00e0d4665eaf66465862f2b273929a2bb7fd54a81f79f1abf39ecfa1
data/CHANGELOG.md CHANGED
Binary file
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSON
4
4
  module Repair
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
data/lib/json/repair.rb CHANGED
@@ -4,7 +4,14 @@ require_relative 'repair/version'
4
4
  require_relative 'repairer'
5
5
 
6
6
  module JSON
7
- class JSONRepairError < StandardError; end
7
+ class JSONRepairError < StandardError
8
+ attr_reader :position
9
+
10
+ def initialize(message = nil, position = nil)
11
+ super(message && position ? "#{message} at index #{position}" : message)
12
+ @position = position
13
+ end
14
+ end
8
15
 
9
16
  def self.repair(json)
10
17
  Repairer.new(json).repair
data/lib/json/repairer.rb CHANGED
@@ -739,28 +739,28 @@ module JSON
739
739
  end
740
740
 
741
741
  def throw_invalid_character(char)
742
- raise JSONRepairError, "Invalid character #{char.inspect} at index #{@index}"
742
+ raise JSONRepairError.new("Invalid character #{char.inspect}", @index)
743
743
  end
744
744
 
745
745
  def throw_unexpected_character
746
- raise JSONRepairError, "Unexpected character #{@json[@index].inspect} at index #{@index}"
746
+ raise JSONRepairError.new("Unexpected character #{@json[@index].inspect}", @index)
747
747
  end
748
748
 
749
749
  def throw_unexpected_end
750
- raise JSONRepairError, 'Unexpected end of json string'
750
+ raise JSONRepairError.new('Unexpected end of json string', @index)
751
751
  end
752
752
 
753
753
  def throw_object_key_expected
754
- raise JSONRepairError, 'Object key expected'
754
+ raise JSONRepairError.new('Object key expected', @index)
755
755
  end
756
756
 
757
757
  def throw_colon_expected
758
- raise JSONRepairError, 'Colon expected'
758
+ raise JSONRepairError.new('Colon expected', @index)
759
759
  end
760
760
 
761
761
  def throw_invalid_unicode_character
762
762
  chars = @json[@index, 6]
763
- raise JSONRepairError, "Invalid unicode character #{chars.inspect} at index #{@index}"
763
+ raise JSONRepairError.new("Invalid unicode character #{chars.inspect}", @index)
764
764
  end
765
765
  end
766
766
  end
data/sig/json/repair.rbs CHANGED
@@ -1,5 +1,8 @@
1
1
  module JSON
2
2
  class JSONRepairError < StandardError
3
+ attr_reader position: ::Integer?
4
+
5
+ def initialize: (?::String? message, ?::Integer? position) -> void
3
6
  end
4
7
 
5
8
  module Repair
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-repair
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandr Zykov