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 +4 -4
- data/lib/ldpath/program.rb +9 -2
- data/lib/ldpath/version.rb +1 -1
- data/spec/ldpath_program_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d28ccab2d84a4940b22d84fb600e064502c13e66
|
4
|
+
data.tar.gz: df43a5b99ec5247b4dfe47a6cb13a9d8ce2049ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da380d1b4292306f3465036491ecb03ce233bf4b14620e0a3ad9ceeddc37628c78c67acebb1061f5c1ac5ce4a591c4c00e7b2fe791bb32189d45c1c8888def06
|
7
|
+
data.tar.gz: 3a37f12008af97a7acd1cacf11d469efe5d6825f902b6d00927264a0a49bad51ae34412ef17e393b702cc649f192ab1bdc3004c728adc3b6c5c2fa673530c8c6
|
data/lib/ldpath/program.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/ldpath/version.rb
CHANGED
data/spec/ldpath_program_spec.rb
CHANGED
@@ -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
|