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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802b9f76579fab24a550f34599ebdd1cc7c5f0f2
4
- data.tar.gz: 1a2a565638e4e2384fd0dd04769115b2b36a886f
3
+ metadata.gz: 40fc837047b78dbcd2f32c6a0d81ec1a62026d17
4
+ data.tar.gz: d99bfa05bf980455e7562c388ff4d8fd4f7db552
5
5
  SHA512:
6
- metadata.gz: 81d538d12dfad2cbc8fdfecfc72bd0ed37d32260bc1375552145df4a466c0e0320f38e05cddbcb4263358403f99c0ea85f4f59810fd6024ee2f4f8c0b3ed1b30
7
- data.tar.gz: 018a3e5016569319760d9b279b25974966883525e75ff02d76bc7bccccc8cbd593ead4dac1b3f4bf84089b2b931de02ff1af29e8f61d903645ef57b834ebee3a
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
- Use at your own risk!
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 that the annotation URI contains a pair-tree path that is created by
95
- the Fedora 4 instance that triannon server works on. The annotation ID is
96
- the entire pair-tree path after it is URI escaped. This makes it easier to
97
- work with the ID for tc.get_annotation(id) and tc.delete_annotation(id).
98
- For more information on object storage using pair-trees, see
99
- http://www.slideshare.net/jakkbl/dcc-pair-posterppt
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? response.code
58
+ [200, 202, 204].include?(response.code)
59
59
  rescue RestClient::Exception => e
60
60
  response = e.response
61
- # If an annotation doesn't exist, consider the request a 'success'
62
- return true if [404, 410].include? response.code
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
- exception_response = double()
191
- allow(exception_response).to receive(:code).and_return(450)
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
- exception_response = double()
199
- allow(exception_response).to receive(:code).and_return(404)
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
- exception_response = double()
207
- allow(exception_response).to receive(:code).and_return(410)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'triannon-client'
5
- s.version = '0.4.0'
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
- s.files = `git ls-files`.split($/)
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.0
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-18 00:00:00.000000000 Z
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
@@ -1,14 +0,0 @@
1
- language: ruby
2
-
3
- install: ./bin/setup.sh
4
-
5
- script: ./bin/test.sh
6
-
7
- notifications:
8
- email: triannon-commits@lists.stanford.edu
9
-
10
- rvm:
11
- - 2.0.0
12
- - 2.1.5
13
- - 2.2.0
14
-
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
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- system "find . -name '*.rb' | ctags -f .tags --languages=Ruby -L -"
3
-
4
- if File.exist? './Gemfile'
5
- require 'bundler'
6
- paths = Bundler.load.specs.map(&:full_gem_path).join(' ')
7
- system "ctags -R -f .gemtags --languages=Ruby #{paths}"
8
- end
data/bin/setup.sh DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- rm -f .binstubs/*
6
- bundle install --binstubs .binstubs
7
- bundle package --all --quiet
8
-
9
- # see commentary on this practice at
10
- # http://blog.howareyou.com/post/66375371138/ruby-apps-best-practices
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
@@ -1,4 +0,0 @@
1
- # Ignore everything in this directory
2
- *
3
- # Except this file
4
- !.gitignore