sparql 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.
@@ -0,0 +1,72 @@
1
+ # This file is part of Sparql.rb.
2
+ #
3
+ # Sparql.rb is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Lesser General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Sparql.rb is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # along with Sparql.rb. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require 'pathname'
17
+
18
+ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
19
+ describe "SparqlParser", '#parse' do
20
+
21
+ before(:all) do
22
+ end
23
+
24
+ it "should recognize a basic SELECT query with one variable and one triple pattern" do
25
+ basic_valid_select_query = 'SELECT ?foo WHERE { ?x foaf:knows ?y . }'
26
+ parser = SparqlParser.new
27
+ parser.parse(basic_valid_select_query).well_formed?.should == true
28
+ parser.parse(basic_valid_select_query).prologue.text_value.should == ""
29
+ parser.parse(basic_valid_select_query).query_part.text_value.should == "SELECT ?foo WHERE { ?x foaf:knows ?y . }"
30
+ parser.parse('SELECT ?foo ?bar WHERE { ?x foaf:knows ?y . ?z foaf:name ?y . }').should_not == nil
31
+ end
32
+
33
+ it "should recognize a basic SELECT query with one variable, one triple pattern, and a PREFIX declaration" do
34
+ basic_valid_select_query_with_prologue = 'PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?foo WHERE { ?x foaf:knows ?y . }'
35
+ parser = SparqlParser.new
36
+ parser.parse(basic_valid_select_query_with_prologue).well_formed?.should == true
37
+ parser.parse(basic_valid_select_query_with_prologue).prologue.text_value.should == "PREFIX foaf: <http://xmlns.com/foaf/0.1/>"
38
+ parser.parse(basic_valid_select_query_with_prologue).query_part.text_value.should == "SELECT ?foo WHERE { ?x foaf:knows ?y . }"
39
+ end
40
+
41
+ it "should recognize a basic SELECT query with one variable, two triple patterns, and a PREFIX declaration" do
42
+ query = 'PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?foo WHERE { ?x foaf:knows ?y . ?z foaf:knows ?x .}'
43
+ parser = SparqlParser.new
44
+ parser.parse(query).well_formed?.should == true
45
+ parser.parse(query).prologue.text_value.should == "PREFIX foaf: <http://xmlns.com/foaf/0.1/>"
46
+ parser.parse(query).query_part.text_value.should == "SELECT ?foo WHERE { ?x foaf:knows ?y . ?z foaf:knows ?x .}"
47
+ end
48
+
49
+ it "should recognize a SELECT query with a literal" # do
50
+ # query = 'SELECT ?v WHERE { ?v ?p "cat" }'
51
+ # parser = SparqlParser.new
52
+ # parser.parse(query).well_formed?.should == true
53
+ # parser.parse(query).prologue.text_value.should == ""
54
+ # parser.parse(query).query_part.text_value.should == 'SELECT ?v WHERE { ?v ?p "cat"@en }'
55
+ # end
56
+
57
+ it "should recognize a SELECT query with a LANGTAG" # do
58
+ # query = 'SELECT ?v WHERE { ?v ?p "cat"@en }'
59
+ # parser = SparqlParser.new
60
+ # parser.parse(query).well_formed?.should == true
61
+ # parser.parse(query).prologue.text_value.should == ""
62
+ # parser.parse(query).query_part.text_value.should == 'SELECT ?v WHERE { ?v ?p "cat"@en }'
63
+ # end
64
+
65
+
66
+
67
+
68
+ it "should recognize a CONSTRUCT query"
69
+ it "should recognize an ASK query"
70
+ it "should recognize a DESCRIBE query"
71
+
72
+ end
@@ -0,0 +1,36 @@
1
+ # This file is part of Sparql.rb.
2
+ #
3
+ # Sparql.rb is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Lesser General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Sparql.rb is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # along with Sparql.rb. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require 'pathname'
17
+
18
+ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
19
+
20
+ describe "VariablesParser", '#parse' do
21
+
22
+ before(:all) do
23
+ @parser = VariablesParser.new
24
+ end
25
+
26
+ it "should recognize a variable beginning with ?" do
27
+ some_var = '?x'
28
+ @parser.parse(some_var).should_not == nil
29
+ end
30
+
31
+ it "should recognize a variable beginning with $" do
32
+ some_var = '$x'
33
+ @parser.parse(some_var).should_not == nil
34
+ end
35
+
36
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sparql
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pius Uzamere
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-07-15 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: treetop
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.4
24
+ version:
25
+ description: sparql is a Ruby library for parsing SPARQL queries. Implements the formal grammar of SPARQL as a parsing expression grammar.
26
+ email: pius+github@uyiosa.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - README.markdown
35
+ - Rakefile
36
+ - sparql.gemspec
37
+ - lib/sparql.rb
38
+ - lib/sparql/execute_sparql.rb
39
+ - lib/sparql/sparql.treetop
40
+ - coverage/index.html
41
+ - coverage/lib-sparql-execute_sparql_rb.html
42
+ - coverage/lib-sparql_rb.html
43
+ has_rdoc: true
44
+ homepage: http://github.com/pius/sparql
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options: []
49
+
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.5
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: SPARQL library for Ruby.
71
+ test_files:
72
+ - spec/spec.opts
73
+ - spec/spec_helper.rb
74
+ - spec/unit/graph_parsing_spec.rb
75
+ - spec/unit/graph_parsing_spec.rb
76
+ - spec/unit/iri_parsing_spec.rb
77
+ - spec/unit/sparql_parsing_spec.rb
78
+ - spec/unit/variables_parsing_spec.rb
79
+ - spec/unit/primitives_parsing_spec.rb
80
+ - spec/unit/prefixed_names_parsing_spec.rb