ldpath 0.3.0 → 0.3.1

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: 901eaf079202867fe88880b4e6297361dcd4574a
4
- data.tar.gz: 9d80b28a1555f00f2400d84bb4573733cc1158c3
3
+ metadata.gz: d28ccab2d84a4940b22d84fb600e064502c13e66
4
+ data.tar.gz: df43a5b99ec5247b4dfe47a6cb13a9d8ce2049ba
5
5
  SHA512:
6
- metadata.gz: d110b7f52841afd8dec645ce426a117692ae0a7c64f90585196b481c80765472ad7d148fc132da7e79fcb25a373783007a3d8a23a252c883606ba293a5c4b8db
7
- data.tar.gz: b2fd98589dfd3dceec73c5eac70eba71696647878d54f6acd437707f3427b6cc28361b88b0e94d20325738aac2f08c65e9958f4e03a1afdfefd02a58b1da6a20
6
+ metadata.gz: da380d1b4292306f3465036491ecb03ce233bf4b14620e0a3ad9ceeddc37628c78c67acebb1061f5c1ac5ce4a591c4c00e7b2fe791bb32189d45c1c8888def06
7
+ data.tar.gz: 3a37f12008af97a7acd1cacf11d469efe5d6825f902b6d00927264a0a49bad51ae34412ef17e393b702cc649f192ab1bdc3004c728adc3b6c5c2fa673530c8c6
@@ -2,14 +2,21 @@ module Ldpath
2
2
  class Program
3
3
  include Ldpath::Functions
4
4
 
5
+ ParseError = Class.new StandardError
6
+
5
7
  class << self
6
8
  def parse(program, transform_context = {})
7
- parsed = parser.parse(program)
8
- ast = transform.apply parsed, transform_context
9
+ ast = transform.apply load(program), transform_context
9
10
 
10
11
  Ldpath::Program.new ast.compact, transform_context
11
12
  end
12
13
 
14
+ def load(program)
15
+ parser.parse(program, reporter: Parslet::ErrorReporter::Deepest.new)
16
+ rescue Parslet::ParseFailed => e
17
+ fail ParseError, e.cause.ascii_tree
18
+ end
19
+
13
20
  private
14
21
 
15
22
  def transform
@@ -1,3 +1,3 @@
1
1
  module Ldpath
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -305,4 +305,10 @@ title_with_loose = ~dc:title :: xsd:string ;
305
305
  expect(result).to be_empty
306
306
  end
307
307
  end
308
+
309
+ describe "error handling" do
310
+ it "should provide a reasonable exception" do
311
+ expect { Ldpath::Program.parse "title .= <oops> ;" }.to raise_error /Expected "=", but got "."/
312
+ end
313
+ end
308
314
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldpath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer