rubyrdf 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.
Files changed (53) hide show
  1. data/History.txt +4 -0
  2. data/License.txt +24 -0
  3. data/Manifest.txt +52 -0
  4. data/README.txt +79 -0
  5. data/Rakefile +4 -0
  6. data/config/hoe.rb +70 -0
  7. data/config/requirements.rb +15 -0
  8. data/lib/rdf/blank_node.rb +41 -0
  9. data/lib/rdf/exceptions.rb +26 -0
  10. data/lib/rdf/format/ntriples.rb +493 -0
  11. data/lib/rdf/graph/base.rb +118 -0
  12. data/lib/rdf/graph/memory.rb +146 -0
  13. data/lib/rdf/graph/tests.rb +137 -0
  14. data/lib/rdf/namespace.rb +90 -0
  15. data/lib/rdf/plain_literal_node.rb +36 -0
  16. data/lib/rdf/query/binding.rb +68 -0
  17. data/lib/rdf/query/executer.rb +42 -0
  18. data/lib/rdf/query/result.rb +54 -0
  19. data/lib/rdf/query.rb +54 -0
  20. data/lib/rdf/triple.rb +61 -0
  21. data/lib/rdf/typed_literal_node.rb +39 -0
  22. data/lib/rdf/uri_node.rb +35 -0
  23. data/lib/rdf/version.rb +9 -0
  24. data/lib/rubyrdf.rb +59 -0
  25. data/log/debug.log +0 -0
  26. data/script/console +11 -0
  27. data/script/destroy +14 -0
  28. data/script/generate +14 -0
  29. data/script/txt2html +74 -0
  30. data/setup.rb +1585 -0
  31. data/tasks/deployment.rake +34 -0
  32. data/tasks/environment.rake +7 -0
  33. data/tasks/website.rake +17 -0
  34. data/test/helper.rb +14 -0
  35. data/test/test_blank_node.rb +67 -0
  36. data/test/test_format_ntriples.rb +247 -0
  37. data/test/test_graph_base.rb +71 -0
  38. data/test/test_graph_memory.rb +146 -0
  39. data/test/test_namespace.rb +130 -0
  40. data/test/test_plain_literal_node.rb +83 -0
  41. data/test/test_query.rb +49 -0
  42. data/test/test_query_binding.rb +84 -0
  43. data/test/test_query_result.rb +111 -0
  44. data/test/test_rdf.rb +56 -0
  45. data/test/test_triple.rb +147 -0
  46. data/test/test_typed_literal_node.rb +61 -0
  47. data/test/test_uri_node.rb +45 -0
  48. data/website/index.html +169 -0
  49. data/website/index.txt +92 -0
  50. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  51. data/website/stylesheets/screen.css +138 -0
  52. data/website/template.html.erb +48 -0
  53. metadata +139 -0
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-04-07
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2008 Paul Stadig
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are
5
+ met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ 3. The name of the author may not be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
18
+ SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20
+ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ CONTRACT,STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
23
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
24
+ OF SUCH DAMAGE.
data/Manifest.txt ADDED
@@ -0,0 +1,52 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ lib/rdf/blank_node.rb
9
+ lib/rdf/exceptions.rb
10
+ lib/rdf/format/ntriples.rb
11
+ lib/rdf/graph/base.rb
12
+ lib/rdf/graph/memory.rb
13
+ lib/rdf/graph/tests.rb
14
+ lib/rdf/namespace.rb
15
+ lib/rdf/plain_literal_node.rb
16
+ lib/rdf/query.rb
17
+ lib/rdf/query/binding.rb
18
+ lib/rdf/query/executer.rb
19
+ lib/rdf/query/result.rb
20
+ lib/rdf/triple.rb
21
+ lib/rdf/typed_literal_node.rb
22
+ lib/rdf/uri_node.rb
23
+ lib/rdf/version.rb
24
+ lib/rubyrdf.rb
25
+ log/debug.log
26
+ script/console
27
+ script/destroy
28
+ script/generate
29
+ script/txt2html
30
+ setup.rb
31
+ tasks/deployment.rake
32
+ tasks/environment.rake
33
+ tasks/website.rake
34
+ test/helper.rb
35
+ test/test_blank_node.rb
36
+ test/test_format_ntriples.rb
37
+ test/test_graph_base.rb
38
+ test/test_graph_memory.rb
39
+ test/test_namespace.rb
40
+ test/test_plain_literal_node.rb
41
+ test/test_query.rb
42
+ test/test_query_binding.rb
43
+ test/test_query_result.rb
44
+ test/test_rdf.rb
45
+ test/test_triple.rb
46
+ test/test_typed_literal_node.rb
47
+ test/test_uri_node.rb
48
+ website/index.html
49
+ website/index.txt
50
+ website/javascripts/rounded_corners_lite.inc.js
51
+ website/stylesheets/screen.css
52
+ website/template.html.erb
data/README.txt ADDED
@@ -0,0 +1,79 @@
1
+ = rubyrdf
2
+
3
+ * {https://launchpad.net/rubyrdf/}[https://launchpad.net/rubyrdf/]
4
+ * {http://rubyforge.org/projects/rubyrdf/}[http://rubyforge.org/projects/rubyrdf/]
5
+
6
+ == DESCRIPTION:
7
+
8
+ A library for working with RDF data in Ruby.
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * A in-memory, pure ruby implementation of the RDF graph model.
13
+
14
+ == SYNOPSIS:
15
+
16
+ ===Adding data to a graph
17
+
18
+ g = RDF::Graph::Memory.new
19
+ g.add(UriNode.new('http://paul.stadig.name/'), RDF::type, RDF::Resource)
20
+
21
+ ===Registering a new namespace
22
+
23
+ RDF::Namespace.register(:dc, 'http://purl.org/dc/elements/1.1/')
24
+
25
+ # you can also create instances of Triple and add them to the graph
26
+ t = RDF::Triple.new(UriNode.new('http://paul.stadig.name/'),
27
+ DC::author,
28
+ g.new_blank_node('paul'))
29
+ g.add(t)
30
+
31
+ ===Querying a graph
32
+
33
+ q = Query.new
34
+ q.select(:x, :y).where(:x, DC::author, :y)
35
+ result = g.execute(q)
36
+ result.bindings.each do |b|
37
+ puts "x = #{b[:x]}"
38
+ puts "y = #{b[:y]}"
39
+ end
40
+
41
+ == REQUIREMENTS:
42
+
43
+ * ruby >= 1.8
44
+ * rubygems >= 0.9.8
45
+ * utf8proc >= 1.0.3
46
+ * uuidtools >= 1.0.1
47
+
48
+ == INSTALL:
49
+
50
+ * sudo gem install rubyrdf
51
+
52
+ == LICENSE:
53
+
54
+ (The BSD License (revised))
55
+
56
+ Copyright (c) 2008 Paul Stadig
57
+
58
+ Redistribution and use in source and binary forms, with or without modification,
59
+ are permitted provided that the following conditions are
60
+ met:
61
+
62
+ 1. Redistributions of source code must retain the above copyright notice,
63
+ this list of conditions and the following disclaimer.
64
+ 2. Redistributions in binary form must reproduce the above copyright notice,
65
+ this list of conditions and the following disclaimer in the documentation
66
+ and/or other materials provided with the distribution.
67
+ 3. The name of the author may not be used to endorse or promote products
68
+ derived from this software without specific prior written permission.
69
+
70
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
71
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
72
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
73
+ SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
74
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
75
+ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
76
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
77
+ CONTRACT,STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
78
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
79
+ OF SUCH DAMAGE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/config/hoe.rb ADDED
@@ -0,0 +1,70 @@
1
+ require 'rdf/version'
2
+
3
+ AUTHOR = 'Paul Stadig' # can also be an array of Authors
4
+ EMAIL = 'paul@stadig.name'
5
+ DESCRIPTION = 'A library for working with RDF data in Ruby'
6
+ GEM_NAME = 'rubyrdf' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'rubyrdf' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "unknown"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
+ VERS = RDF::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'rubyrdf documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.developer(AUTHOR, EMAIL)
52
+ p.description = DESCRIPTION
53
+ p.summary = DESCRIPTION
54
+ p.url = HOMEPATH
55
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
56
+ p.test_globs = ["test/**/test_*.rb"]
57
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
58
+
59
+ # == Optional
60
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
+ p.extra_deps = [['utf8proc', '>=1.0.3'], ['uuidtools', '>=1.0.1']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+
63
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
+
65
+ end
66
+
67
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
69
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
70
+ $hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen mocha].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,41 @@
1
+ module RDF
2
+ # A blank node. In RDF a blank node is a graph local node, it can be used only with the graph
3
+ # to which it is associated. See UnassociatedBlankNodeSubjectError and
4
+ # UnassociatedBlankNodeObjectError.
5
+ class BlankNode
6
+ # the graph to which this BlankNode is associated.
7
+ attr_reader :graph
8
+ # the name of this BlankNode.
9
+ attr_reader :name
10
+
11
+ # Creates a new blank node using the specified name and graph. Raises an
12
+ # ArgumentError if +name+ is an empty string, or if +graph+ is nil.
13
+ def initialize(name, graph = nil)
14
+ @name = name.to_s
15
+ @graph = graph
16
+
17
+ raise ArgumentError, 'name cannot be empty' if @name.empty?
18
+ raise ArgumentError, 'graph cannot be nil' if @graph.nil?
19
+ end
20
+
21
+ # Returns true if +o+ is a BlankNode with the same +graph+ and +name+.
22
+ def ==(o)
23
+ if RDF::BlankNode?(o)
24
+ graph == o.graph &&
25
+ name == o.name
26
+ end
27
+ end
28
+
29
+ alias :eql? :==
30
+
31
+ # Returns a hash value for this BlankNode.
32
+ def hash
33
+ [769847830, graph.hash, name.hash].hash
34
+ end
35
+
36
+ # Returns the NTriples representation of this BlankNode.
37
+ def to_s
38
+ Format::NTriples.export_node(self)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,26 @@
1
+ module RDF
2
+ # Base class for other RDF related errors.
3
+ #
4
+ # see also SyntaxError, LiteralNodeSubjectError, LiteralNodePredicateError,
5
+ # BlankNodePredicateError, UnassociatedBlankNodeSubjectError, UnassociatedBlankNodeObjectError
6
+ class Error < StandardError; end
7
+
8
+ # Base class for RDF syntax errors.
9
+ #
10
+ # see also LiteralNodeSubjectError, LiteralNodePredicateError, BlankNodePredicateError
11
+ class SyntaxError < Error; end
12
+
13
+ # Raised when a LiteralNode is in the subject position of a triple.
14
+ class InvalidSubjectError < SyntaxError; end
15
+
16
+ # Raised when a LiteralNode or BlankNode is in the predicate position of a
17
+ # triple.
18
+ class InvalidPredicateError < SyntaxError; end
19
+
20
+ # Raised when there is an attempt to add a BlankNode in the subject or object
21
+ # position to a graph to which it is not associated.
22
+ class UnassociatedBlankNodeError < Error; end
23
+
24
+ # Raised when the requested import/export format is not supported by a graph implementation
25
+ class UnsupportedFormatError < Error; end
26
+ end