subj3ct 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +23 -0
- data/GemDescription.sm +44 -0
- data/LICENSE +20 -0
- data/README.markdown +88 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/lib/subj3ct.rb +15 -0
- data/lib/subj3ct/feed.rb +6 -0
- data/lib/subj3ct/query.rb +221 -0
- data/lib/subj3ct/register.rb +17 -0
- data/lib/subject.rb +6 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/subj3ct_spec.rb +7 -0
- metadata +157 -0
data/.document
ADDED
data/.gitignore
ADDED
data/GemDescription.sm
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
==== subj3ct - The DNS for the Semantic Web
|
2
|
+
|
3
|
+
This is a Ruby adapter for the subj3ct.com webservice.
|
4
|
+
|
5
|
+
Subj3ct is an infrastructure technology for Web 3.0 applications. These are
|
6
|
+
applications that are organised around subjects and semantics rather than
|
7
|
+
documents and links. Subj3ct provides the technology and services to enable
|
8
|
+
Web 3.0 applications to define and exchange subject definitions.
|
9
|
+
|
10
|
+
Or in other words: Subj3ct.com is for the Semantic Web what DNS is for the internet.
|
11
|
+
|
12
|
+
==== Installing
|
13
|
+
|
14
|
+
Install the gem:
|
15
|
+
|
16
|
+
gem install subj3ct
|
17
|
+
|
18
|
+
==== Usage
|
19
|
+
|
20
|
+
Query a specific subject - to be specific: its subject identity record - using it's identifier:
|
21
|
+
|
22
|
+
Subj3ct.identifier("http://www.topicmapslab.de/publications/TMRA_2009_subj3ct_a_subject_identity_resolution_service")
|
23
|
+
|
24
|
+
See the README or the github page for more examples.
|
25
|
+
|
26
|
+
==== Subj3ct vs. Subject
|
27
|
+
|
28
|
+
The official name is "Subj3ct", however in this API, you can also use "Subject" which may be easier to remember or to type for normal, n0n-1337 people. It should work for the gem, for the require and for the main module.
|
29
|
+
|
30
|
+
==== Contribute!
|
31
|
+
|
32
|
+
Subj3ct is a young and ambitious service. It's free, will stay free and needs your help. Contribute to this library! Create bindings for other languages! Publish your data as linked data to the web and register it with subj3ct.com.
|
33
|
+
|
34
|
+
==== Note on Patches/Pull Requests
|
35
|
+
|
36
|
+
* Fork the project on http://github.bb/subj3ct
|
37
|
+
* Make your feature addition or bug fix.
|
38
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
39
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
40
|
+
* Send me a pull request. Bonus points for topic branches.
|
41
|
+
|
42
|
+
==== Copyright
|
43
|
+
|
44
|
+
Copyright (c) 2010 Benjamin Bock, Topic Maps Lab. See LICENSE for details.
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Benjamin Bock, Topic Maps Lab, http://www.topicmapslab.de
|
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.
|
data/README.markdown
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# subj3ct - The DNS for the Semantic Web
|
2
|
+
|
3
|
+
This is a Ruby adapter for the subj3ct.com webservice.
|
4
|
+
|
5
|
+
Subj3ct is an infrastructure technology for Web 3.0 applications. These are
|
6
|
+
applications that are organised around subjects and semantics rather than
|
7
|
+
documents and links. Subj3ct provides the technology and services to enable
|
8
|
+
Web 3.0 applications to define and exchange subject definitions.
|
9
|
+
|
10
|
+
Or in other words: Subj3ct.com is for the Semantic Web what DNS is for the internet.
|
11
|
+
|
12
|
+
## Quick Links
|
13
|
+
|
14
|
+
* [Subj3ct.com](http://www.subj3ct.com/)
|
15
|
+
* [Wiki](http://wiki.github.com/bb/subj3ct)
|
16
|
+
* [Bugs](http://github.com/bb/subj3ct/issues)
|
17
|
+
* [Gem](http://rubygems.org/gems/subj3ct)
|
18
|
+
|
19
|
+
## Installing
|
20
|
+
|
21
|
+
Install the gem:
|
22
|
+
|
23
|
+
gem install subj3ct
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
First, you have to require the library in your Ruby project (or directly in IRB):
|
28
|
+
|
29
|
+
require 'subj3ct'
|
30
|
+
|
31
|
+
Then you can query the subj3ct.com webservice with different queries:
|
32
|
+
|
33
|
+
Query a specific subject - to be specific: its subject identity record - using it's identifier:
|
34
|
+
|
35
|
+
Subj3ct.identifier("http://www.topicmapslab.de/publications/TMRA_2009_subj3ct_a_subject_identity_resolution_service")
|
36
|
+
|
37
|
+
Query all subjects associated with a given resource (i.e. with a given web address). The result is a list of subjects (without representation or equivalence statements):
|
38
|
+
|
39
|
+
Subj3ct.resource("http://en.wikipedia.org/wiki/Topic_Maps")
|
40
|
+
|
41
|
+
To get the representation and equivalence statements for one of the results you can fetch the complete subject record:
|
42
|
+
|
43
|
+
result = Subj3ct.resource("http://en.wikipedia.org/wiki/Topic_Maps")
|
44
|
+
full_subject = result.subjects.first.fetch
|
45
|
+
|
46
|
+
If you don't know a web address or identifier URI for the thing you're interested in, try a full text search:
|
47
|
+
|
48
|
+
Subj3ct.search("my query")
|
49
|
+
|
50
|
+
To query a specific number of items at a time, the query methods `identifier`, `resource`, `starts_with` and `search` accept a keyword parameter `:take` to specify the maximum number of items to query. The maximum allowed take is 50.
|
51
|
+
To display the results paginated, an offset, may be passed using the `:skip` keyword. The search results also feature methods like `fetch_next` to get the next page etc.. The following example fetches the first 5 pages, each page showing 3 results, then it fetches page 20:
|
52
|
+
|
53
|
+
result = Subj3ct.search("benjamin bock", :take => 3)
|
54
|
+
while result.next? && result.current_page < 5
|
55
|
+
result = result.fetch_next
|
56
|
+
end
|
57
|
+
|
58
|
+
result.fetch_page(20)
|
59
|
+
|
60
|
+
## Subj3ct vs. Subject
|
61
|
+
|
62
|
+
The official name is "Subj3ct", however in this API, you can also use "Subject" which may be easier to remember or to type for normal, n0n-1337 people. It should work for the gem, for the require and for the main module.
|
63
|
+
|
64
|
+
## Plans
|
65
|
+
|
66
|
+
* starts_with doesn't work at all. It looks like this is a server side problem.
|
67
|
+
* Documentation. Currently the code is barely documented, this should be changed soon.
|
68
|
+
* Write tests. Uh... of course we have tests... they're almost done...
|
69
|
+
* Write support. Currently this lib is only reading subj3ct.com. It should be able to register feeds with the service and to create a feed from existing data.
|
70
|
+
* Caching. A minimal caching solution should be built in.
|
71
|
+
* Reduce dependencies. Currently this lib uses active_support only for `blank?`. Instead of open-uri a direct HTTP call could be done.
|
72
|
+
* Threadsafe use of unencrypted and SSL usage in parallel. Due to the current architecture, you can't do SSL-encrypted and unencrypted queries in parallel in a threadsafe way. To work around that, the class methods should be moved to a query processor which should be instantiated and configured if this is needed.
|
73
|
+
|
74
|
+
## Contribute!
|
75
|
+
|
76
|
+
Subj3ct is a young and ambitious service. It's free, will stay free and needs your help. Contribute to this library! Create bindings for other languages! Publish your data as linked data to the web and register it with subj3ct.com.
|
77
|
+
|
78
|
+
## Note on Patches/Pull Requests
|
79
|
+
|
80
|
+
* Fork the project.
|
81
|
+
* Make your feature addition or bug fix.
|
82
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
83
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
84
|
+
* Send me a pull request. Bonus points for topic branches.
|
85
|
+
|
86
|
+
## Copyright
|
87
|
+
|
88
|
+
Copyright (c) 2010 Benjamin Bock, [Topic Maps Lab](http://www.topicmapslab.de/). See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "subj3ct"
|
8
|
+
gem.summary = %Q{Ruby bindings for Subj3ct.com, the DNS for the semantic web.}
|
9
|
+
gem.description = File.read(File.join(File.dirname(__FILE__), "GemDescription.sm"))
|
10
|
+
gem.email = "bb--github.com@bock.be"
|
11
|
+
gem.homepage = "http://github.com/bb/subj3ct"
|
12
|
+
gem.authors = ["Benjamin Bock"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_development_dependency "yard", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'yard'
|
40
|
+
YARD::Rake::YardocTask.new
|
41
|
+
rescue LoadError
|
42
|
+
task :yardoc do
|
43
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
44
|
+
end
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/subj3ct.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# A Ruby API for the subj3ct.com webservice.
|
2
|
+
module Subj3ct
|
3
|
+
DEFAULT_API_BASE = "http://api.subj3ct.com/subjects"
|
4
|
+
DEFAULT_SECURE_API_BASE = DEFAULT_API_BASE.sub(/\Ahttp:/, "https:")
|
5
|
+
end
|
6
|
+
Subject = Subj3ct
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'subj3ct/query'
|
10
|
+
require 'subj3ct/register'
|
11
|
+
require 'subj3ct/feed'
|
12
|
+
rescue LoadError
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
14
|
+
retry
|
15
|
+
end
|
data/lib/subj3ct/feed.rb
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
module Subj3ct
|
7
|
+
# Query the subj3ct.com API
|
8
|
+
module Query
|
9
|
+
# identifier: Must be a URI value. Used to identify the subject to return. It is important that this value is URL encoded.
|
10
|
+
# [optional] format: Allowed values are [default]'xml', 'json', 'atom', 'rss', 'xtm10', 'skos'. Used to indicate the representation format to be returned.
|
11
|
+
# [optional] callback: Any string that will be used to wrap the json returned. Ignored if the format value is not 'json'
|
12
|
+
# [optional, use array for multiple] provenance: Must be a URI value. All statements of equivalence are defined by some source. This source is known as the statements' provenance and is identified by a URI. Passing in one or more provenance parameters will limit the set of equivalent identifiers and web resources to only the ones defined by that provenance(s).
|
13
|
+
def identifier(identifier, params={})
|
14
|
+
SubjectIdentityRecord.new(request("", params.merge(:identifier => identifier)))
|
15
|
+
end
|
16
|
+
|
17
|
+
# uri: Must be a URI value. All subjects that have this resource associated with it will be returned.
|
18
|
+
# [optional] skip: An integer value that indicates how many results to skip before the service starts returning results.
|
19
|
+
# [optional] take: An integer value that indicates how many results to take and return. [Default = 10, Max Cut Off = 50]
|
20
|
+
# [optional] format: Allowed values are [default]'xml', 'json'. Used to indicate the representation format to be returned.
|
21
|
+
# [optional] callback: Any string that will be used to wrap the json returned. Ignored if the format value is not 'json'
|
22
|
+
def resource(representationUri, params={})
|
23
|
+
SearchResult.new(request("/webaddresses", params.merge(:uri => representationUri)))
|
24
|
+
end
|
25
|
+
|
26
|
+
# uriStartsWith: Must be a URI value. All subjects whose identifier starts with the URI provided are returned.
|
27
|
+
# [optional] skip: An integer value that indicates how many results to skip before the service starts returning results.
|
28
|
+
# [optional] take: An integer value that indicates how many results to take and return. [Default = 10, Max Cut Off = 50]
|
29
|
+
# [optional] format: Allowed values are [default]'xml', 'json'. Used to indicate the representation format to be returned.
|
30
|
+
# [optional] callback: Any string that will be used to wrap the json returned. Ignored if the format value is not 'json'
|
31
|
+
def starts_with(uri, params={})
|
32
|
+
SearchResult.new(request("/identifiers", params.merge(:uriStartsWith => uri)))
|
33
|
+
end
|
34
|
+
|
35
|
+
# query: String value. The query term is used to search the subjects to find matches based on name, description and identifier. For more information and syntax for advanced options please see the guide on portal search options.
|
36
|
+
# [optional] skip: An integer value that indicates how many results to skip before the service starts returning results.
|
37
|
+
# [optional] take: An integer value that indicates how many results to take and return. [Default = 10, Max Cut Off = 50]
|
38
|
+
# [optional] format: Allowed values are [default]'xml', 'json', 'atom'. Used to indicate the representation format to be returned.
|
39
|
+
# [optional] callback: Any string that will be used to wrap the json returned. Ignored if the format value is not 'json'
|
40
|
+
def search(query, params={})
|
41
|
+
SearchResult.new(request("/search", params.merge(:query => query)))
|
42
|
+
end
|
43
|
+
|
44
|
+
def api_base=(new_base)
|
45
|
+
@custom_api_base = new_base
|
46
|
+
@secure_custom_api_base = new_base.sub(/\Ahttp:/, "https:")
|
47
|
+
end
|
48
|
+
|
49
|
+
attr_accessor :secure
|
50
|
+
alias :secure? :secure
|
51
|
+
|
52
|
+
def api_base(secure=false)
|
53
|
+
if secure
|
54
|
+
@secure_custom_api_base || DEFAULT_SECURE_API_BASE
|
55
|
+
else
|
56
|
+
@custom_api_base || DEFAULT_API_BASE
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def request(method, params)
|
61
|
+
result = JSON.parse(raw_request(method, params))
|
62
|
+
result[:method] = method
|
63
|
+
result[:take] = params[:take] || 50
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
def raw_request(method, params)
|
68
|
+
begin
|
69
|
+
uri = request_uri(method, params)
|
70
|
+
open(uri).read
|
71
|
+
rescue OpenURI::HTTPError => e
|
72
|
+
raise Subj3ctException.new("Subj3ct returned an HTTP Error on query #{uri}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def request_uri(method, params={})
|
77
|
+
query_params = params
|
78
|
+
query_params[:format] ||= "json"
|
79
|
+
query_params[:identifier] = CGI.escape(query_params[:identifier]) if query_params.key?(:identifier)
|
80
|
+
query_params[:uri] = CGI.escape(query_params[:uri]) if query_params.key?(:uri)
|
81
|
+
query_params[:query] = CGI.escape(query_params[:query]) if query_params.key?(:query)
|
82
|
+
query_string = params.reject{|key,value| key.blank? || value.blank?}.
|
83
|
+
map{|k,v|
|
84
|
+
if v.is_a? Array
|
85
|
+
v.map{|vi| "#{k}=#{vi}" }.join("&")
|
86
|
+
else
|
87
|
+
"#{k}=#{v}"
|
88
|
+
end
|
89
|
+
}.join("&")
|
90
|
+
return "#{api_base(secure?)}#{method}?#{query_string}"
|
91
|
+
end
|
92
|
+
|
93
|
+
class Result
|
94
|
+
def self.abstract?
|
95
|
+
self == Result
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class SubjectIdentityRecord < Result
|
100
|
+
attr_reader :trust, :name, :provenance, :equivalences, :representations, :description, :identifier, :record_link
|
101
|
+
|
102
|
+
# The initialization hash is the parsed JSON from a identity query to subj3ct.com
|
103
|
+
def initialize(result)
|
104
|
+
@trust = result["Trust"]
|
105
|
+
@record_link = result["RecordLink"]
|
106
|
+
@name = result["Name"]
|
107
|
+
@description = result["Description"]
|
108
|
+
@provenance = result["Provenance"]
|
109
|
+
@identifier = result["Identifier"]
|
110
|
+
@representation_uri = result["RepresentationUri"]
|
111
|
+
|
112
|
+
@equivalences = (result["EquivalenceStatements"] || []).map do |eqiv|
|
113
|
+
EquivalenceStatement.new(eqiv)
|
114
|
+
end
|
115
|
+
@representations = (result["RepresentationStatements"] || []).map do |rep|
|
116
|
+
RepresentationStatement.new(rep)
|
117
|
+
end
|
118
|
+
@result = result
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class SearchResult < Result
|
123
|
+
attr_reader :total, :skipped, :taken, :query, :subjects, :request_method
|
124
|
+
# The initialization hash is the parsed JSON hash from a query to subj3ct.com
|
125
|
+
def initialize(result)
|
126
|
+
@total = result["TotalNumberResults"] || 0
|
127
|
+
@skipped = result["Skipped"] || 0
|
128
|
+
@taken = result["Taken"] || 50
|
129
|
+
@query = result["Query"] if result["Query"]
|
130
|
+
@request_method = result[:method]
|
131
|
+
@request_take = result[:take]
|
132
|
+
|
133
|
+
@subjects = (result["Subjects"] || []).map do |subject_hash|
|
134
|
+
SubjectResult.new(subject_hash)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def size
|
139
|
+
@subjects.size
|
140
|
+
end
|
141
|
+
|
142
|
+
# Fetches the details for all subjects on the current page
|
143
|
+
def fetch_all
|
144
|
+
@subjects.map {|subject| subject.fetch}
|
145
|
+
end
|
146
|
+
|
147
|
+
# Fetches the next page (or the one starting at the given record number)
|
148
|
+
def fetch_next(start_record=skipped+@request_take)
|
149
|
+
SearchResult.new(Subj3ct.request(@request_method, :query => query, :skip => start_record, :take => @request_take))
|
150
|
+
end
|
151
|
+
|
152
|
+
# Fetches the next page of results (or any given page using the page number provided.)
|
153
|
+
def fetch_page(page_num=current_page+1)
|
154
|
+
fetch_next((page_num-1)*@request_take)
|
155
|
+
end
|
156
|
+
|
157
|
+
# returns the number of the current page (1-based)
|
158
|
+
def current_page
|
159
|
+
(skipped / @request_take) + 1
|
160
|
+
end
|
161
|
+
|
162
|
+
# returns the number of the last page (1-based)
|
163
|
+
def last_page
|
164
|
+
(total / @request_take) + (((total % @request_take) == 0) ? 0 : 1)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns true if there are more pages to fetch
|
168
|
+
def next?
|
169
|
+
!last?
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns true if we're on the last page
|
173
|
+
def last?
|
174
|
+
current_page == last_page
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
class SubjectResult
|
179
|
+
attr_reader :trust, :record_link, :name, :description, :identifier
|
180
|
+
def initialize(subject_hash)
|
181
|
+
@trust = subject_hash["Trust"]
|
182
|
+
@record_link = subject_hash["RecordLink"]
|
183
|
+
@name = subject_hash["Name"]
|
184
|
+
@description = subject_hash["Description"]
|
185
|
+
@identifier = subject_hash["Identifier"]
|
186
|
+
end
|
187
|
+
|
188
|
+
def fetch
|
189
|
+
Subj3ct.identifier(@identifier)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
class RepresentationStatement
|
194
|
+
attr_reader :trust, :provenance, :representation_uri
|
195
|
+
def initialize(rep_hash)
|
196
|
+
@trust = rep_hash["Trust"]
|
197
|
+
@provenance = rep_hash["Provenance"]
|
198
|
+
@representation_uri = rep_hash["RepresentationUri"]
|
199
|
+
end
|
200
|
+
|
201
|
+
def fetch
|
202
|
+
Subject.resource(@representation_uri)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
class EquivalenceStatement
|
207
|
+
attr_reader :trust, :provenance, :equivalent_identifier
|
208
|
+
def initialize(equiv_hash)
|
209
|
+
@trust = equiv_hash["Trust"]
|
210
|
+
@provenance = equiv_hash["Provenance"]
|
211
|
+
@equivalent_identifier = equiv_hash["EquivalentIdentifier"]
|
212
|
+
end
|
213
|
+
|
214
|
+
def fetch
|
215
|
+
Subj3ct.identifier(@equivalent_identifier)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
class Subj3ctException < Exception;end
|
219
|
+
end
|
220
|
+
extend Query
|
221
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Subj3ct
|
2
|
+
# Register Feeds on the Subj3ct.com website
|
3
|
+
module Register
|
4
|
+
# Step 1: allow to register feeds anonymously
|
5
|
+
|
6
|
+
# The relevant part of the form to register a feed anonymously
|
7
|
+
# <form action="/anonfeed" method="post">
|
8
|
+
# <fieldset>
|
9
|
+
# <label for="FeedUrl">Url:</label>
|
10
|
+
# <input id="FeedUrl" name="FeedUrl" type="text" value="" />
|
11
|
+
# <input type="submit" value="Register Feed" />
|
12
|
+
# </fieldset>
|
13
|
+
# </form>
|
14
|
+
|
15
|
+
# Step 2: allow to login and manage namespaces and feeds
|
16
|
+
end
|
17
|
+
end
|
data/lib/subject.rb
ADDED
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: subj3ct
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Benjamin Bock
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-15 00:00:00 +02: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: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: yard
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
description: |
|
52
|
+
==== subj3ct - The DNS for the Semantic Web
|
53
|
+
|
54
|
+
This is a Ruby adapter for the subj3ct.com webservice.
|
55
|
+
|
56
|
+
Subj3ct is an infrastructure technology for Web 3.0 applications. These are
|
57
|
+
applications that are organised around subjects and semantics rather than
|
58
|
+
documents and links. Subj3ct provides the technology and services to enable
|
59
|
+
Web 3.0 applications to define and exchange subject definitions.
|
60
|
+
|
61
|
+
Or in other words: Subj3ct.com is for the Semantic Web what DNS is for the internet.
|
62
|
+
|
63
|
+
==== Installing
|
64
|
+
|
65
|
+
Install the gem:
|
66
|
+
|
67
|
+
gem install subj3ct
|
68
|
+
|
69
|
+
==== Usage
|
70
|
+
|
71
|
+
Query a specific subject - to be specific: its subject identity record - using it's identifier:
|
72
|
+
|
73
|
+
Subj3ct.identifier("http://www.topicmapslab.de/publications/TMRA_2009_subj3ct_a_subject_identity_resolution_service")
|
74
|
+
|
75
|
+
See the README or the github page for more examples.
|
76
|
+
|
77
|
+
==== Subj3ct vs. Subject
|
78
|
+
|
79
|
+
The official name is "Subj3ct", however in this API, you can also use "Subject" which may be easier to remember or to type for normal, n0n-1337 people. It should work for the gem, for the require and for the main module.
|
80
|
+
|
81
|
+
==== Contribute!
|
82
|
+
|
83
|
+
Subj3ct is a young and ambitious service. It's free, will stay free and needs your help. Contribute to this library! Create bindings for other languages! Publish your data as linked data to the web and register it with subj3ct.com.
|
84
|
+
|
85
|
+
==== Note on Patches/Pull Requests
|
86
|
+
|
87
|
+
* Fork the project on http://github.bb/subj3ct
|
88
|
+
* Make your feature addition or bug fix.
|
89
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
90
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
91
|
+
* Send me a pull request. Bonus points for topic branches.
|
92
|
+
|
93
|
+
==== Copyright
|
94
|
+
|
95
|
+
Copyright (c) 2010 Benjamin Bock, Topic Maps Lab. See LICENSE for details.
|
96
|
+
|
97
|
+
email: bb--github.com@bock.be
|
98
|
+
executables: []
|
99
|
+
|
100
|
+
extensions: []
|
101
|
+
|
102
|
+
extra_rdoc_files:
|
103
|
+
- LICENSE
|
104
|
+
- README.markdown
|
105
|
+
files:
|
106
|
+
- .document
|
107
|
+
- .gitignore
|
108
|
+
- GemDescription.sm
|
109
|
+
- LICENSE
|
110
|
+
- README.markdown
|
111
|
+
- Rakefile
|
112
|
+
- VERSION
|
113
|
+
- lib/subj3ct.rb
|
114
|
+
- lib/subj3ct/feed.rb
|
115
|
+
- lib/subj3ct/query.rb
|
116
|
+
- lib/subj3ct/register.rb
|
117
|
+
- lib/subject.rb
|
118
|
+
- spec/spec.opts
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- spec/subj3ct_spec.rb
|
121
|
+
has_rdoc: true
|
122
|
+
homepage: http://github.com/bb/subj3ct
|
123
|
+
licenses: []
|
124
|
+
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options:
|
127
|
+
- --charset=UTF-8
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
requirements: []
|
149
|
+
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 1.3.7
|
152
|
+
signing_key:
|
153
|
+
specification_version: 3
|
154
|
+
summary: Ruby bindings for Subj3ct.com, the DNS for the semantic web.
|
155
|
+
test_files:
|
156
|
+
- spec/spec_helper.rb
|
157
|
+
- spec/subj3ct_spec.rb
|