rdf_for_sqlite 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David Richards
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ = RDF for SQLite
2
+
3
+ RDF for SQLite is a container gem for getting the simplest RDF-based applications off the ground. It uses quite a few modular gems and fixes a little inconsistency between RDF.rb and ActiveModel. The gems are:
4
+
5
+ * rdf
6
+ * rdf/ntriples
7
+ * data_objects
8
+ * do_sqlite3
9
+ * rdf/do
10
+ * spira
11
+ * active_model
12
+
13
+ This basically boils down to RDF.rb + ActiveModel + Spira + SQLite3 to create a pretty straightforward repository, serializer, parser, and ORM.
14
+
15
+ To get a simple model built, this will work:
16
+
17
+ class Person
18
+ include RDFForSQLite
19
+
20
+ # Choose a useful base URI
21
+ base_uri "http://example.org/people"
22
+
23
+ property :name, :predicate => FOAF.name
24
+
25
+ validate :presence_of_name
26
+
27
+ protected
28
+ def presence_of_name
29
+ assert_set :name
30
+ end
31
+
32
+ end
33
+
34
+ A full example using Sinatra looks like this:
35
+
36
+
37
+
38
+ == Note on Patches/Pull Requests
39
+
40
+ * Fork the project.
41
+ * Make your feature addition or bug fix.
42
+ * Add tests for it. This is important so I don't break it in a
43
+ future version unintentionally.
44
+ * Commit, do not mess with rakefile, version, or history.
45
+ (if you want to have your own version, that is fine but
46
+ bump version in a commit by itself I can ignore when I pull)
47
+ * Send me a pull request. Bonus points for topic branches.
48
+
49
+ == Copyright
50
+
51
+ Copyright (c) 2010 David Richards. See LICENSE for details.
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rdf_for_sqlite"
8
+ gem.summary = %Q{Container gem to get RDF models }
9
+ gem.description = %Q{RDF for SQLite is a container gem for getting the simplest RDF-based applications off the ground. It uses quite a few modular gems and fixes a little inconsistency between RDF.rb and ActiveModel. This basically boils down to RDF.rb + ActiveModel + Spira + SQLite3 to create a pretty straightforward repository, serializer, parser, and ORM. }
10
+ gem.email = "davidlamontrichards@gmail.com"
11
+ gem.homepage = "http://github.com/davidrichards/rdf_for_sqlite"
12
+ gem.authors = ["David Richards"]
13
+ gem.add_development_dependency "rspec"
14
+ gem.add_dependency "rdf"
15
+ gem.add_dependency "data_objects"
16
+ gem.add_dependency "do_sqlite3"
17
+ gem.add_dependency "rdf-do"
18
+ gem.add_dependency "spira"
19
+ gem.add_dependency "activemodel"
20
+ gem.add_dependency "json"
21
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
+
23
+ Jeweler::GemcutterTasks.new
24
+ end
25
+ rescue LoadError
26
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
27
+ end
28
+
29
+ # require 'spec/rake/spectask'
30
+ # Spec::Rake::SpecTask.new(:spec) do |spec|
31
+ # spec.libs << 'lib' << 'spec'
32
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
33
+ # end
34
+ #
35
+ # Spec::Rake::SpecTask.new(:rcov) do |spec|
36
+ # spec.libs << 'lib' << 'spec'
37
+ # spec.pattern = 'spec/**/*_spec.rb'
38
+ # spec.rcov = true
39
+ # end
40
+ #
41
+ # task :spec => :check_dependencies
42
+ #
43
+ # task :default => :spec
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION')
48
+ version = File.read('VERSION')
49
+ else
50
+ version = ""
51
+ end
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "rdf_for_sqlite #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,81 @@
1
+ require 'rubygems'
2
+ require 'rdf'
3
+ require 'rdf/ntriples'
4
+ require 'data_objects'
5
+ require 'do_sqlite3'
6
+ require 'rdf/do'
7
+ require 'spira'
8
+ require 'active_model'
9
+ require 'json'
10
+
11
+ require 'active_support/core_ext/hash/except'
12
+ require 'active_support/core_ext/hash/slice'
13
+
14
+ module FleetVentures
15
+ # Rather than going through a Rails commit process, I've just hijacked this code and run it as my own module.
16
+ # For Spira models, the attributes hash uses symbols rather than strings, and so I have to map them to strings
17
+ # on line 15 below.
18
+ module Serialization
19
+ def serializable_hash(options = nil)
20
+ options ||= {}
21
+
22
+ options[:only] = Array.wrap(options[:only]).map { |n| n.to_s }
23
+ options[:except] = Array.wrap(options[:except]).map { |n| n.to_s }
24
+
25
+ attribute_names = attributes.keys.map {|k| k.to_s}.sort
26
+ if options[:only].any?
27
+ attribute_names &= options[:only]
28
+ elsif options[:except].any?
29
+ attribute_names -= options[:except]
30
+ end
31
+
32
+ method_names = Array.wrap(options[:methods]).inject([]) do |methods, name|
33
+ methods << name if respond_to?(name.to_s)
34
+ methods
35
+ end
36
+
37
+ (attribute_names + method_names).inject({}) { |hash, name|
38
+ hash[name] = send(name)
39
+ hash
40
+ }
41
+ end
42
+ end
43
+ end
44
+
45
+ module RDFForSQLite
46
+ def self.included(base)
47
+ base.send(:include, Spira::Resource)
48
+ base.send(:include, RDF)
49
+ base.send(:include, ActiveModel::Conversion)
50
+ base.extend ActiveModel::Naming
51
+ base.send(:include, FleetVentures::Serialization)
52
+ base.send(:include, ActiveModel::Serializers::JSON)
53
+ base.send(:include, ActiveModel::Serializers::Xml)
54
+ end
55
+
56
+ def initialize(attributes = {})
57
+ super
58
+ attributes.each do |name, value|
59
+ self.send("#{name}=", value)
60
+ end
61
+ end
62
+
63
+ def persisted?
64
+ self.send(:exist?)
65
+ end
66
+
67
+ def update_attributes(hash)
68
+ hash.each do |name, value|
69
+ self.send("#{name}=", value)
70
+ end
71
+ self.save!
72
+ self
73
+ end
74
+
75
+ def update_attribute(name, value)
76
+ self.send("#{name}=", value)
77
+ self.save!
78
+ self
79
+ end
80
+
81
+ end
@@ -0,0 +1,75 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rdf_for_sqlite}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David Richards"]
12
+ s.date = %q{2010-11-03}
13
+ s.description = %q{RDF for SQLite is a container gem for getting the simplest RDF-based applications off the ground. It uses quite a few modular gems and fixes a little inconsistency between RDF.rb and ActiveModel. This basically boils down to RDF.rb + ActiveModel + Spira + SQLite3 to create a pretty straightforward repository, serializer, parser, and ORM. }
14
+ s.email = %q{davidlamontrichards@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/rdf_for_sqlite.rb",
27
+ "rdf_for_sqlite.gemspec",
28
+ "spec/rdf_for_sqlite_spec.rb",
29
+ "spec/spec_helper.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/davidrichards/rdf_for_sqlite}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{Container gem to get RDF models}
36
+ s.test_files = [
37
+ "spec/rdf_for_sqlite_spec.rb",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<rspec>, [">= 0"])
47
+ s.add_runtime_dependency(%q<rdf>, [">= 0"])
48
+ s.add_runtime_dependency(%q<data_objects>, [">= 0"])
49
+ s.add_runtime_dependency(%q<do_sqlite3>, [">= 0"])
50
+ s.add_runtime_dependency(%q<rdf-do>, [">= 0"])
51
+ s.add_runtime_dependency(%q<spira>, [">= 0"])
52
+ s.add_runtime_dependency(%q<activemodel>, [">= 0"])
53
+ s.add_runtime_dependency(%q<json>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<rspec>, [">= 0"])
56
+ s.add_dependency(%q<rdf>, [">= 0"])
57
+ s.add_dependency(%q<data_objects>, [">= 0"])
58
+ s.add_dependency(%q<do_sqlite3>, [">= 0"])
59
+ s.add_dependency(%q<rdf-do>, [">= 0"])
60
+ s.add_dependency(%q<spira>, [">= 0"])
61
+ s.add_dependency(%q<activemodel>, [">= 0"])
62
+ s.add_dependency(%q<json>, [">= 0"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<rspec>, [">= 0"])
66
+ s.add_dependency(%q<rdf>, [">= 0"])
67
+ s.add_dependency(%q<data_objects>, [">= 0"])
68
+ s.add_dependency(%q<do_sqlite3>, [">= 0"])
69
+ s.add_dependency(%q<rdf-do>, [">= 0"])
70
+ s.add_dependency(%q<spira>, [">= 0"])
71
+ s.add_dependency(%q<activemodel>, [">= 0"])
72
+ s.add_dependency(%q<json>, [">= 0"])
73
+ end
74
+ end
75
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "RdfForSqlite" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rdf_for_sqlite'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdf_for_sqlite
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - David Richards
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-03 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rdf
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: data_objects
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: do_sqlite3
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: rdf-do
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ type: :runtime
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: spira
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ type: :runtime
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ name: activemodel
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ type: :runtime
118
+ version_requirements: *id007
119
+ - !ruby/object:Gem::Dependency
120
+ name: json
121
+ prerelease: false
122
+ requirement: &id008 !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ type: :runtime
132
+ version_requirements: *id008
133
+ description: "RDF for SQLite is a container gem for getting the simplest RDF-based applications off the ground. It uses quite a few modular gems and fixes a little inconsistency between RDF.rb and ActiveModel. This basically boils down to RDF.rb + ActiveModel + Spira + SQLite3 to create a pretty straightforward repository, serializer, parser, and ORM. "
134
+ email: davidlamontrichards@gmail.com
135
+ executables: []
136
+
137
+ extensions: []
138
+
139
+ extra_rdoc_files:
140
+ - LICENSE
141
+ - README.rdoc
142
+ files:
143
+ - .document
144
+ - .gitignore
145
+ - LICENSE
146
+ - README.rdoc
147
+ - Rakefile
148
+ - VERSION
149
+ - lib/rdf_for_sqlite.rb
150
+ - rdf_for_sqlite.gemspec
151
+ - spec/rdf_for_sqlite_spec.rb
152
+ - spec/spec_helper.rb
153
+ has_rdoc: true
154
+ homepage: http://github.com/davidrichards/rdf_for_sqlite
155
+ licenses: []
156
+
157
+ post_install_message:
158
+ rdoc_options:
159
+ - --charset=UTF-8
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ hash: 3
168
+ segments:
169
+ - 0
170
+ version: "0"
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ hash: 3
177
+ segments:
178
+ - 0
179
+ version: "0"
180
+ requirements: []
181
+
182
+ rubyforge_project:
183
+ rubygems_version: 1.3.7
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: Container gem to get RDF models
187
+ test_files:
188
+ - spec/rdf_for_sqlite_spec.rb
189
+ - spec/spec_helper.rb