subj3ct 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,9 +63,8 @@ The official name is "Subj3ct", however in this API, you can also use "Subject"
63
63
 
64
64
  ## Plans
65
65
 
66
- * starts_with doesn't work at all. It looks like this is a server side problem.
67
66
  * 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...
67
+ * Write more tests: fetching, pagination, ...
69
68
  * 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
69
  * Caching. A minimal caching solution should be built in.
71
70
  * Reduce dependencies. Currently this lib uses active_support only for `blank?`. Instead of open-uri a direct HTTP call could be done.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -9,7 +9,9 @@ begin
9
9
  require 'subj3ct/query'
10
10
  require 'subj3ct/register'
11
11
  require 'subj3ct/feed'
12
- rescue LoadError
13
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
12
+ rescue LoadError => e
13
+ here_path = File.expand_path(File.dirname(__FILE__))
14
+ raise e if $LOAD_PATH.include?(here_path)
15
+ $LOAD_PATH.unshift(here_path)
14
16
  retry
15
17
  end
@@ -1,4 +1,4 @@
1
- require 'active_support'
1
+ require 'active_support/core_ext/object/blank'
2
2
  require 'open-uri'
3
3
  require 'json'
4
4
  require 'cgi'
@@ -23,13 +23,13 @@ module Subj3ct
23
23
  SearchResult.new(request("/webaddresses", params.merge(:uri => representationUri)))
24
24
  end
25
25
 
26
- # uriStartsWith: Must be a URI value. All subjects whose identifier starts with the URI provided are returned.
26
+ # uri: Must be a URI value. All subjects whose identifier starts with the URI provided are returned. Be sure not to include http:// in the query or it will return nothing.
27
27
  # [optional] skip: An integer value that indicates how many results to skip before the service starts returning results.
28
28
  # [optional] take: An integer value that indicates how many results to take and return. [Default = 10, Max Cut Off = 50]
29
29
  # [optional] format: Allowed values are [default]'xml', 'json'. Used to indicate the representation format to be returned.
30
30
  # [optional] callback: Any string that will be used to wrap the json returned. Ignored if the format value is not 'json'
31
31
  def starts_with(uri, params={})
32
- SearchResult.new(request("/identifiers", params.merge(:uriStartsWith => uri)))
32
+ SearchResult.new(request("/identifiers", params.merge(:uri => uri)))
33
33
  end
34
34
 
35
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.
@@ -135,6 +135,11 @@ module Subj3ct
135
135
  end
136
136
  end
137
137
 
138
+ # TODO: should Enumerable be included here? Or all its methods delegated?
139
+ def each(*args,&block)
140
+ @subjects.each(*args, &block)
141
+ end
142
+
138
143
  def size
139
144
  @subjects.size
140
145
  end
@@ -1,5 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rubygems'
3
4
  require 'subj3ct'
4
5
  require 'spec'
5
6
  require 'spec/autorun'
@@ -1,7 +1,55 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Subj3ct" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
4
+ it "should define the namespace Subj3ct" do
5
+ fail unless defined?(::Subj3ct)
6
+ Subj3ct.should be_a_kind_of Module
6
7
  end
8
+
9
+ it "should define the namespace Subject equivalent to Subj3ct" do
10
+ fail unless defined?(::Subject)
11
+ ::Subject.should be_a_kind_of Module
12
+ ::Subj3ct.should == ::Subject
13
+ end
14
+
15
+ it "should have the four query methods" do
16
+ Subj3ct.should respond_to :identifier
17
+ Subj3ct.should respond_to :resource
18
+ Subj3ct.should respond_to :starts_with
19
+ Subj3ct.should respond_to :search
20
+ end
21
+
22
+ describe "identifier" do
23
+ it "should fetch a subject by identifier" do
24
+ sir = Subj3ct.identifier("http://bock.be/njamin")
25
+ sir.should be_a_kind_of Subj3ct::Query::SubjectIdentityRecord
26
+ end
27
+ end
28
+
29
+ describe "resource" do
30
+ it "should fetch one or more subjects by resource" do
31
+ sr = Subj3ct.resource("http://bock.be/njamin")
32
+ sr.should be_a_kind_of Subj3ct::Query::SearchResult
33
+ sr.size.should >= 1
34
+ end
35
+ end
36
+
37
+ describe "starts_with" do
38
+ it "should fetch one or more subjects by prefix of it's identifier" do
39
+ sr = Subj3ct.starts_with("bock.be/njamin")
40
+ sr.should be_a_kind_of Subj3ct::Query::SearchResult
41
+ sr.size.should >= 1
42
+ end
43
+ end
44
+
45
+ describe "search" do
46
+ it "should search for keywords" do
47
+ sr = Subj3ct.search("topic maps")
48
+ sr.should be_a_kind_of Subj3ct::Query::SearchResult
49
+ # there are more than 10000 results now, I don't expect it will become less than 50
50
+ sr.size.should == 50
51
+ sr.total.should > 50
52
+ end
53
+ end
54
+
7
55
  end
@@ -0,0 +1,108 @@
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{subj3ct}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Benjamin Bock"]
12
+ s.date = %q{2010-06-21}
13
+ s.description = %q{==== subj3ct - The DNS for the Semantic Web
14
+
15
+ This is a Ruby adapter for the subj3ct.com webservice.
16
+
17
+ Subj3ct is an infrastructure technology for Web 3.0 applications. These are
18
+ applications that are organised around subjects and semantics rather than
19
+ documents and links. Subj3ct provides the technology and services to enable
20
+ Web 3.0 applications to define and exchange subject definitions.
21
+
22
+ Or in other words: Subj3ct.com is for the Semantic Web what DNS is for the internet.
23
+
24
+ ==== Installing
25
+
26
+ Install the gem:
27
+
28
+ gem install subj3ct
29
+
30
+ ==== Usage
31
+
32
+ Query a specific subject - to be specific: its subject identity record - using it's identifier:
33
+
34
+ Subj3ct.identifier("http://www.topicmapslab.de/publications/TMRA_2009_subj3ct_a_subject_identity_resolution_service")
35
+
36
+ See the README or the github page for more examples.
37
+
38
+ ==== Subj3ct vs. Subject
39
+
40
+ 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.
41
+
42
+ ==== Contribute!
43
+
44
+ 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.
45
+
46
+ ==== Note on Patches/Pull Requests
47
+
48
+ * Fork the project on http://github.bb/subj3ct
49
+ * Make your feature addition or bug fix.
50
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
51
+ * 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)
52
+ * Send me a pull request. Bonus points for topic branches.
53
+
54
+ ==== Copyright
55
+
56
+ Copyright (c) 2010 Benjamin Bock, Topic Maps Lab. See LICENSE for details.
57
+ }
58
+ s.email = %q{bb--github.com@bock.be}
59
+ s.extra_rdoc_files = [
60
+ "LICENSE",
61
+ "README.markdown"
62
+ ]
63
+ s.files = [
64
+ ".document",
65
+ ".gitignore",
66
+ "GemDescription.sm",
67
+ "LICENSE",
68
+ "README.markdown",
69
+ "Rakefile",
70
+ "VERSION",
71
+ "lib/subj3ct.rb",
72
+ "lib/subj3ct/feed.rb",
73
+ "lib/subj3ct/query.rb",
74
+ "lib/subj3ct/register.rb",
75
+ "lib/subject.rb",
76
+ "spec/spec.opts",
77
+ "spec/spec_helper.rb",
78
+ "spec/subj3ct_spec.rb",
79
+ "subj3ct.gemspec",
80
+ "subject.gemspec"
81
+ ]
82
+ s.homepage = %q{http://github.com/bb/subj3ct}
83
+ s.rdoc_options = ["--charset=UTF-8"]
84
+ s.require_paths = ["lib"]
85
+ s.rubygems_version = %q{1.3.7}
86
+ s.summary = %q{Ruby bindings for Subj3ct.com, the DNS for the semantic web.}
87
+ s.test_files = [
88
+ "spec/spec_helper.rb",
89
+ "spec/subj3ct_spec.rb"
90
+ ]
91
+
92
+ if s.respond_to? :specification_version then
93
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
94
+ s.specification_version = 3
95
+
96
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
97
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
98
+ s.add_development_dependency(%q<yard>, [">= 0"])
99
+ else
100
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
101
+ s.add_dependency(%q<yard>, [">= 0"])
102
+ end
103
+ else
104
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
105
+ s.add_dependency(%q<yard>, [">= 0"])
106
+ end
107
+ end
108
+
@@ -0,0 +1,82 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{subject}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Benjamin Bock"]
9
+ s.date = %q{2010-06-15}
10
+ s.description = %q{==== subj3ct - The DNS for the Semantic Web
11
+
12
+ This is a Ruby adapter for the subj3ct.com webservice.
13
+
14
+ Subj3ct is an infrastructure technology for Web 3.0 applications. These are
15
+ applications that are organised around subjects and semantics rather than
16
+ documents and links. Subj3ct provides the technology and services to enable
17
+ Web 3.0 applications to define and exchange subject definitions.
18
+
19
+ Or in other words: Subj3ct.com is for the Semantic Web what DNS is for the internet.
20
+
21
+ ==== Installing
22
+
23
+ Install the gem:
24
+
25
+ gem install subj3ct
26
+
27
+ ==== Usage
28
+
29
+ Query a specific subject - to be specific: its subject identity record - using it's identifier:
30
+
31
+ Subj3ct.identifier("http://www.topicmapslab.de/publications/TMRA_2009_subj3ct_a_subject_identity_resolution_service")
32
+
33
+ See the README or the github page for more examples.
34
+
35
+ ==== Subj3ct vs. Subject
36
+
37
+ 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.
38
+
39
+ ==== Contribute!
40
+
41
+ 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.
42
+
43
+ ==== Note on Patches/Pull Requests
44
+
45
+ * Fork the project on http://github.bb/subj3ct
46
+ * Make your feature addition or bug fix.
47
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
48
+ * 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)
49
+ * Send me a pull request. Bonus points for topic branches.
50
+
51
+ ==== Copyright
52
+
53
+ Copyright (c) 2010 Benjamin Bock, Topic Maps Lab. See LICENSE for details.
54
+ }
55
+ s.email = %q{bb--github.com@bock.be}
56
+ s.extra_rdoc_files = [
57
+ "LICENSE", "README.markdown"
58
+ ]
59
+
60
+ s.homepage = %q{http://github.com/bb/subj3ct}
61
+ s.rdoc_options = ["--charset=UTF-8"]
62
+ s.rubygems_version = %q{1.3.7}
63
+ s.summary = %q{Ruby bindings for Subj3ct.com, the DNS for the semantic web.}
64
+
65
+ if s.respond_to? :specification_version then
66
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
+ s.specification_version = 3
68
+
69
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
70
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
71
+ s.add_development_dependency(%q<yard>, [">= 0"])
72
+ else
73
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
74
+ s.add_dependency(%q<yard>, [">= 0"])
75
+ end
76
+ else
77
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
78
+ s.add_dependency(%q<yard>, [">= 0"])
79
+ end
80
+ s.add_dependency(%q<subj3ct>, [">= 0.0.1"])
81
+ end
82
+
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subj3ct
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 1
10
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Benjamin Bock
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-06-15 00:00:00 +02:00
17
+ date: 2010-06-21 00:00:00 +02:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
30
28
  segments:
31
29
  - 1
32
30
  - 2
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 3
46
43
  segments:
47
44
  - 0
48
45
  version: "0"
@@ -118,6 +115,8 @@ files:
118
115
  - spec/spec.opts
119
116
  - spec/spec_helper.rb
120
117
  - spec/subj3ct_spec.rb
118
+ - subj3ct.gemspec
119
+ - subject.gemspec
121
120
  has_rdoc: true
122
121
  homepage: http://github.com/bb/subj3ct
123
122
  licenses: []
@@ -132,7 +131,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
131
  requirements:
133
132
  - - ">="
134
133
  - !ruby/object:Gem::Version
135
- hash: 3
136
134
  segments:
137
135
  - 0
138
136
  version: "0"
@@ -141,7 +139,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
139
  requirements:
142
140
  - - ">="
143
141
  - !ruby/object:Gem::Version
144
- hash: 3
145
142
  segments:
146
143
  - 0
147
144
  version: "0"