ldpath 0.0.0 → 0.0.1
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 +4 -4
- data/README.md +17 -2
- data/ldpath.gemspec +1 -0
- data/lib/ldpath.rb +13 -0
- data/lib/ldpath/field_mapping.rb +2 -0
- data/lib/ldpath/functions.rb +144 -0
- data/lib/ldpath/parser.rb +358 -0
- data/lib/ldpath/program.rb +63 -252
- data/lib/ldpath/selectors.rb +124 -0
- data/lib/ldpath/tests.rb +102 -0
- data/lib/ldpath/transform.rb +143 -0
- data/lib/ldpath/version.rb +1 -1
- data/spec/fixtures/foaf_example.program +9 -0
- data/spec/fixtures/namespaces.ldpath +21 -0
- data/spec/fixtures/program.ldpath +41 -0
- data/spec/ldpath_parser_spec.rb +162 -0
- data/spec/ldpath_program_spec.rb +115 -0
- data/spec/ldpath_transform_spec.rb +62 -0
- metadata +34 -4
- data/spec/ldpath_program_parser_spec.rb +0 -34
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pp'
|
3
|
+
describe Ldpath::Transform do
|
4
|
+
let(:parser) { Ldpath::Parser.new }
|
5
|
+
it "should transform literals" do
|
6
|
+
subject.apply(literal: "xyz")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should transform uris" do
|
10
|
+
subject.apply(uri:"http://www.w3.org/2003/01/geo/wgs84_pos#")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should transform nested uris" do
|
14
|
+
subject.apply(uri: { uri: "info:a"})
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should transform prefix + localNames" do
|
18
|
+
subject.apply(prefix: "info", localName:"a")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should transform mappings" do
|
22
|
+
subject.apply parser.parse("x = . ;")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should transform wildcards" do
|
26
|
+
subject.apply parser.parse("xyz = * ;\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should transform reverse properties" do
|
30
|
+
subject.apply parser.parse("xyz = ^info:a ;\n")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should transform recursive properties" do
|
34
|
+
subject.apply parser.parse("xyz = (info:a)* ;\n")
|
35
|
+
subject.apply parser.parse("xyz = (info:a)+ ;\n")
|
36
|
+
subject.apply parser.parse("xyz = (info:a){,5} ;\n")
|
37
|
+
subject.apply parser.parse("xyz = (info:a){2,5} ;\n")
|
38
|
+
subject.apply parser.parse("xyz = (info:a){2,} ;\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should transform namespaces" do
|
42
|
+
subject.apply parser.parse("@prefix foaf: <http://xmlns.com/foaf/0.1/>")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should transform path selectors" do
|
46
|
+
subject.apply parser.parse("x = . / . ;")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should transform functions" do
|
50
|
+
subject.apply parser.function_selector.parse("fn:concat(foaf:givename,\" \",foaf:surname)")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should transform the foaf example" do
|
54
|
+
subject.apply parser.parse(File.read(File.expand_path(File.join(__FILE__, "..", "fixtures", "foaf_example.program")))
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should parse the program.ldpath" do
|
59
|
+
subject.apply parser.parse File.read(File.expand_path(File.join(__FILE__, "..", "fixtures", "program.ldpath")))
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ldpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: linkeddata
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,10 +96,21 @@ files:
|
|
82
96
|
- Rakefile
|
83
97
|
- ldpath.gemspec
|
84
98
|
- lib/ldpath.rb
|
99
|
+
- lib/ldpath/field_mapping.rb
|
100
|
+
- lib/ldpath/functions.rb
|
101
|
+
- lib/ldpath/parser.rb
|
85
102
|
- lib/ldpath/program.rb
|
103
|
+
- lib/ldpath/selectors.rb
|
104
|
+
- lib/ldpath/tests.rb
|
105
|
+
- lib/ldpath/transform.rb
|
86
106
|
- lib/ldpath/version.rb
|
87
|
-
- spec/
|
107
|
+
- spec/fixtures/foaf_example.program
|
108
|
+
- spec/fixtures/namespaces.ldpath
|
109
|
+
- spec/fixtures/program.ldpath
|
110
|
+
- spec/ldpath_parser_spec.rb
|
111
|
+
- spec/ldpath_program_spec.rb
|
88
112
|
- spec/ldpath_spec.rb
|
113
|
+
- spec/ldpath_transform_spec.rb
|
89
114
|
- spec/spec_helper.rb
|
90
115
|
homepage: http://github.com/cbeer
|
91
116
|
licenses:
|
@@ -112,6 +137,11 @@ signing_key:
|
|
112
137
|
specification_version: 4
|
113
138
|
summary: Ruby implementation of LDPath
|
114
139
|
test_files:
|
115
|
-
- spec/
|
140
|
+
- spec/fixtures/foaf_example.program
|
141
|
+
- spec/fixtures/namespaces.ldpath
|
142
|
+
- spec/fixtures/program.ldpath
|
143
|
+
- spec/ldpath_parser_spec.rb
|
144
|
+
- spec/ldpath_program_spec.rb
|
116
145
|
- spec/ldpath_spec.rb
|
146
|
+
- spec/ldpath_transform_spec.rb
|
117
147
|
- spec/spec_helper.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'parslet/convenience'
|
4
|
-
describe Ldpath::Program do
|
5
|
-
subject { Ldpath::Program.new }
|
6
|
-
context ".parse" do
|
7
|
-
it "should work" do
|
8
|
-
subject.parse ""
|
9
|
-
subject.parse "\n\n"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not parse comments" do
|
13
|
-
subject.line.parse "/* xyz */"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should parse namespaces" do
|
17
|
-
subject.namespace.parse "@prefix a : <xyz>"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should parse mappings" do
|
21
|
-
subject.parse("xyz = . ;\n")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should parse uri mappings" do
|
25
|
-
subject.parse("xyz = <info:a> ;\n")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should parse path mappings" do
|
29
|
-
subject.parse_with_debug("xyz = info:a / info:b :: a:b;\n")
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|