triannon-client 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -9
- data/lib/triannon-client/triannon_client.rb +9 -5
- data/spec/lib/triannon-client/triannon_client_spec.rb +6 -12
- data/triannon-client.gemspec +5 -6
- metadata +3 -13
- data/.travis.yml +0 -14
- data/bin/console +0 -11
- data/bin/ctags.rb +0 -8
- data/bin/setup.sh +0 -10
- data/bin/test.sh +0 -15
- data/log/.gitignore +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40fc837047b78dbcd2f32c6a0d81ec1a62026d17
|
4
|
+
data.tar.gz: d99bfa05bf980455e7562c388ff4d8fd4f7db552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6754fccc7db31f606a505964b682e885a44857adced25fae0452cc083a66ef6e212e7c15e85cbe28ba789d1ae70129d81cfc245f33cbab768e6e17cf4072df2
|
7
|
+
data.tar.gz: ce3b499fdaf82636d202dc580a68eee150e5fd5575d7687e1657f770e35bbda5ce3d56e6132540baa7d140ddb7f390e3b6e85dc9dcf2523576923f1ed21581b4
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# Under construction!
|
5
5
|
|
6
|
-
|
6
|
+
Any gem released prior to 1.x may have an unstable API. As the triannon server and this client are in rapid development (as of 2015), expect new gem releases that could break the API.
|
7
7
|
|
8
8
|
|
9
9
|
# Triannon Client
|
@@ -87,17 +87,16 @@ tc.post_annotation(open_annotation_jsonld)
|
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
uri = RDF::URI.new("http://your.triannon-server.com/annotations/45/4a/c0/93/454ac093-b37d-4580-bebd-449f8dabddc9")
|
90
|
-
tc.annotation_id(uri) #=> "45%2F4a%2Fc0%2F93%2F454ac093-b37d-4580-bebd-449f8dabddc9"
|
90
|
+
id = tc.annotation_id(uri) #=> "45%2F4a%2Fc0%2F93%2F454ac093-b37d-4580-bebd-449f8dabddc9"
|
91
91
|
tc.delete_annotation(id)
|
92
92
|
```
|
93
93
|
|
94
|
-
Note
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
https://wiki.ucop.edu/display/Curation/PairTree
|
94
|
+
Note: the annotation URI contains a pair-tree path (created by a Fedora 4 repository for
|
95
|
+
triannon annotations). The annotation ID is the entire pair-tree path, after a URI escape.
|
96
|
+
The URI escape makes it easier to work with the ID for tc.get_annotation(id) and
|
97
|
+
tc.delete_annotation(id). For more information on object storage using pair-trees, see
|
98
|
+
- http://www.slideshare.net/jakkbl/dcc-pair-posterppt
|
99
|
+
- https://wiki.ucop.edu/display/Curation/PairTree
|
101
100
|
|
102
101
|
## Development
|
103
102
|
|
@@ -55,13 +55,18 @@ module TriannonClient
|
|
55
55
|
# 202 (Accepted) if the action has not yet been enacted, or
|
56
56
|
# 204 (No Content) if the action has been enacted but the response
|
57
57
|
# does not include an entity.
|
58
|
-
[200, 202, 204].include?
|
58
|
+
[200, 202, 204].include?(response.code)
|
59
59
|
rescue RestClient::Exception => e
|
60
60
|
response = e.response
|
61
|
-
|
62
|
-
|
61
|
+
if response.is_a?(RestClient::Response)
|
62
|
+
# If an annotation doesn't exist, consider the request a 'success'
|
63
|
+
return true if [404, 410].include?(response.code)
|
64
|
+
msg = response.body
|
65
|
+
else
|
66
|
+
msg = e.message
|
67
|
+
end
|
68
|
+
@config.logger.error("Failed to DELETE annotation: #{id}, #{msg}")
|
63
69
|
binding.pry if @config.debug
|
64
|
-
@config.logger.error("Failed to DELETE annotation: #{id}, #{response.body}")
|
65
70
|
false
|
66
71
|
rescue => e
|
67
72
|
binding.pry if @config.debug
|
@@ -127,7 +132,6 @@ module TriannonClient
|
|
127
132
|
# TODO: switch yard for different response.code?
|
128
133
|
response2graph(response)
|
129
134
|
rescue => e
|
130
|
-
# response = e.response
|
131
135
|
binding.pry if @config.debug
|
132
136
|
@config.logger.error("Failed to GET annotation: #{id}, #{e.message}")
|
133
137
|
RDF::Graph.new # return an empty graph
|
@@ -187,26 +187,20 @@ describe TriannonClient, :vcr do
|
|
187
187
|
expect( tc.delete_annotation(id) ).to be true
|
188
188
|
end
|
189
189
|
it 'logs exceptions' do
|
190
|
-
|
191
|
-
|
192
|
-
allow(exception_response).to receive(:body).and_return('delete_logs_exceptions')
|
193
|
-
allow_any_instance_of(RestClient::Exception).to receive(:response).and_return(exception_response)
|
190
|
+
allow_any_instance_of(RestClient::Response).to receive(:code).and_return(450)
|
191
|
+
allow_any_instance_of(RestClient::Response).to receive(:body).and_return('delete_logs_exceptions')
|
194
192
|
expect(TriannonClient.configuration.logger).to receive(:error).with(/delete_logs_exceptions/)
|
195
193
|
tc.delete_annotation('delete_logs_exceptions')
|
196
194
|
end
|
197
195
|
it 'does not log exceptions for missing annotations (404 responses)' do
|
198
|
-
|
199
|
-
|
200
|
-
allow(exception_response).to receive(:body).and_return('delete_does_not_log_404_exceptions')
|
201
|
-
allow_any_instance_of(RestClient::Exception).to receive(:response).and_return(exception_response)
|
196
|
+
allow_any_instance_of(RestClient::Response).to receive(:code).and_return(404)
|
197
|
+
allow_any_instance_of(RestClient::Response).to receive(:body).and_return('delete_does_not_log_404_exceptions')
|
202
198
|
expect(TriannonClient.configuration.logger).not_to receive(:error)
|
203
199
|
tc.delete_annotation('delete_does_not_log_404_exceptions')
|
204
200
|
end
|
205
201
|
it 'does not log exceptions for missing annotations (410 responses)' do
|
206
|
-
|
207
|
-
|
208
|
-
allow(exception_response).to receive(:body).and_return('delete_does_not_log_410_exceptions')
|
209
|
-
allow_any_instance_of(RestClient::Exception).to receive(:response).and_return(exception_response)
|
202
|
+
allow_any_instance_of(RestClient::Response).to receive(:code).and_return(410)
|
203
|
+
allow_any_instance_of(RestClient::Response).to receive(:body).and_return('delete_does_not_log_410_exceptions')
|
210
204
|
expect(TriannonClient.configuration.logger).not_to receive(:error)
|
211
205
|
tc.delete_annotation('delete_does_not_log_410_exceptions')
|
212
206
|
end
|
data/triannon-client.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'triannon-client'
|
5
|
-
s.version = '0.4.
|
5
|
+
s.version = '0.4.1'
|
6
6
|
s.licenses = ['Apache-2.0']
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
|
@@ -34,12 +34,11 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_development_dependency 'vcr'
|
35
35
|
s.add_development_dependency 'webmock'
|
36
36
|
|
37
|
-
|
37
|
+
git_files = `git ls-files`.split($/)
|
38
|
+
bin_files = %w(bin/console bin/ctags.rb bin/setup.sh bin/test.sh)
|
39
|
+
dot_files = %w(.gitignore .travis.yml log/.gitignore)
|
40
|
+
s.files = git_files - (bin_files + dot_files)
|
38
41
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
39
42
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
40
43
|
|
41
|
-
dev_files = %w(.gitignore bin/console bin/ctags.rb bin/setup.sh bin/test.sh)
|
42
|
-
dev_files.each {|f| s.files.delete f; s.executables.delete f; }
|
43
|
-
|
44
44
|
end
|
45
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triannon-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Weber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -181,30 +181,20 @@ dependencies:
|
|
181
181
|
description: A client for RESTful transactions with a triannon annotation server
|
182
182
|
email:
|
183
183
|
- triannon-commits@lists.stanford.edu
|
184
|
-
executables:
|
185
|
-
- console
|
186
|
-
- ctags.rb
|
187
|
-
- setup.sh
|
188
|
-
- test.sh
|
184
|
+
executables: []
|
189
185
|
extensions: []
|
190
186
|
extra_rdoc_files:
|
191
187
|
- README.md
|
192
188
|
- LICENSE
|
193
189
|
files:
|
194
190
|
- ".env_example"
|
195
|
-
- ".travis.yml"
|
196
191
|
- Gemfile
|
197
192
|
- LICENSE
|
198
193
|
- README.md
|
199
194
|
- Rakefile
|
200
|
-
- bin/console
|
201
|
-
- bin/ctags.rb
|
202
|
-
- bin/setup.sh
|
203
|
-
- bin/test.sh
|
204
195
|
- lib/triannon-client.rb
|
205
196
|
- lib/triannon-client/configuration.rb
|
206
197
|
- lib/triannon-client/triannon_client.rb
|
207
|
-
- log/.gitignore
|
208
198
|
- spec/fixtures/vcr_cassettes/TriannonClient/GET_annotation_by_ID_/_get_annotation/with_content_type/cannot_get_an_open_annotation_by_ID_with_content_type_application/n-quads_.yml
|
209
199
|
- spec/fixtures/vcr_cassettes/TriannonClient/GET_annotation_by_ID_/_get_annotation/with_content_type/cannot_get_an_open_annotation_by_ID_with_content_type_application/n-triples_.yml
|
210
200
|
- spec/fixtures/vcr_cassettes/TriannonClient/GET_annotation_by_ID_/_get_annotation/with_content_type/cannot_get_an_open_annotation_by_ID_with_content_type_application/rdf_json_.yml
|
data/.travis.yml
DELETED
data/bin/console
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'triannon-client'
|
3
|
-
CONFIG = TriannonClient.configuration
|
4
|
-
|
5
|
-
tc = TriannonClient::TriannonClient.new
|
6
|
-
oa_jsonld = '{"@context":"http://iiif.io/api/presentation/2/context.json","@graph":[{"@id":"_:g70349699654640","@type":["dctypes:Text","cnt:ContentAsText"],"chars":"I love this!","format":"text/plain","language":"en"},{"@type":"oa:Annotation","motivation":"oa:commenting","on":"http://purl.stanford.edu/kq131cs7229","resource":"_:g70349699654640"}]}'
|
7
|
-
g = RDF::Graph.new
|
8
|
-
format = RDF::Format.for(:jsonld)
|
9
|
-
format.reader.new(oa_jsonld) {|r| r.each_statement {|s| g << s }}
|
10
|
-
|
11
|
-
binding.pry
|
data/bin/ctags.rb
DELETED
data/bin/setup.sh
DELETED
data/bin/test.sh
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
set -e
|
4
|
-
|
5
|
-
[[ -s .env ]] && mv .env .env_bak
|
6
|
-
cp .env_example .env
|
7
|
-
|
8
|
-
# The `|| echo ''` enables the bash script to continue after rspec failure
|
9
|
-
EXIT=0
|
10
|
-
.binstubs/rspec --color || EXIT=1
|
11
|
-
#.binstubs/cucumber --strict || EXIT=1
|
12
|
-
|
13
|
-
[[ -s .env_bak ]] && mv .env_bak .env
|
14
|
-
exit $EXIT
|
15
|
-
|
data/log/.gitignore
DELETED