bibsonomy 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bibsonomy.gemspec +1 -0
- data/lib/bibsonomy.rb +7 -0
- data/lib/bibsonomy/api.rb +26 -14
- data/lib/bibsonomy/csl.rb +0 -6
- data/lib/bibsonomy/version.rb +1 -1
- data/test/post_test.rb +16 -16
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08a8cca92bb613eee121fc83132952133523cbea'
|
4
|
+
data.tar.gz: b02c0ef8002b4d9bbf3d70688c951d4d30c7c545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 400ef771b97d5dd937dee0412ccdb2a147989b8685792adca8bf0dd631d4a45dfb8a2214f961c473c7fd8e4161f9bbeb3cf1d9c9135631f5ba3a95da5493ae12
|
7
|
+
data.tar.gz: aec2bb9a73eb1caa933b0d59971459b84d6bea767153c459128b33d3d900697ffe351eea62e7558c0d525d9ead7787fa372cce70b58f15bfd71fbcd128c84c89
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# BibSonomy
|
2
2
|
|
3
|
-
[BibSonomy](
|
3
|
+
[BibSonomy](https://www.bibsonomy.org/) client for Ruby
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/bibsonomy.svg)](http://badge.fury.io/rb/bibsonomy)
|
6
6
|
[![Build Status](https://travis-ci.org/rjoberon/bibsonomy-ruby.svg?branch=master)](https://travis-ci.org/rjoberon/bibsonomy-ruby)
|
@@ -51,7 +51,7 @@ print BibSonomy::main(ARGV)
|
|
51
51
|
|
52
52
|
## Testing
|
53
53
|
|
54
|
-
Get an API-Key from <
|
54
|
+
Get an API-Key from <https://www.bibsonomy.org/settings?selTab=1> and
|
55
55
|
then run the following commands:
|
56
56
|
|
57
57
|
```shell
|
data/bibsonomy.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "citeproc-ruby", "~> 1.0", '>= 1.1.10'
|
35
35
|
spec.add_dependency "csl-styles", "~> 1.0"
|
36
36
|
spec.add_dependency "csl", "~> 1.5"
|
37
|
+
spec.add_dependency 'addressable', '~> 2.5'
|
37
38
|
# required by citeproc-ruby when Ruby version <= 2.4
|
38
39
|
spec.add_dependency "unicode", "~> 0.4", ">=0.4.4.4"
|
39
40
|
|
data/lib/bibsonomy.rb
CHANGED
data/lib/bibsonomy/api.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
require 'faraday'
|
3
|
-
require 'json'
|
4
2
|
|
5
3
|
# configuration options
|
6
4
|
$API_URL = "https://www.bibsonomy.org/"
|
@@ -21,6 +19,8 @@ $resource_types_bibtex = ['bibtex', 'pub', 'publication', 'publications', 'publ'
|
|
21
19
|
# @author Robert Jäschke
|
22
20
|
#
|
23
21
|
# Changes:
|
22
|
+
# 2018-10-09 (rja)
|
23
|
+
# - migrated URL handling to addressable library
|
24
24
|
# 2017-05-31 (rja)
|
25
25
|
# - refactored get_posts_for_group and get_posts_for_user into get_posts
|
26
26
|
# 2017-05-30 (rja)
|
@@ -59,6 +59,10 @@ module BibSonomy
|
|
59
59
|
|
60
60
|
@conn.basic_auth(user_name, api_key)
|
61
61
|
|
62
|
+
# initialise URLs
|
63
|
+
@url_post = Addressable::Template.new("/api/users/{user_name}/posts/{intra_hash}?format={format}")
|
64
|
+
@url_posts = Addressable::Template.new("/api/posts{?format,resourcetype,start,end,user,group,tags}")
|
65
|
+
@url_doc = Addressable::Template.new("/api/users/{user_name}/posts/{intra_hash}/documents/{file_name}")
|
62
66
|
end
|
63
67
|
|
64
68
|
|
@@ -69,7 +73,11 @@ module BibSonomy
|
|
69
73
|
# @param intra_hash [String] the intrag hash of the post
|
70
74
|
# @return [BibSonomy::Post, String] the requested post
|
71
75
|
def get_post(user_name, intra_hash)
|
72
|
-
response = @conn.get
|
76
|
+
response = @conn.get @url_post.expand({
|
77
|
+
:user_name => user_name,
|
78
|
+
:intra_hash => intra_hash,
|
79
|
+
:format => @format
|
80
|
+
})
|
73
81
|
|
74
82
|
if @parse
|
75
83
|
attributes = JSON.parse(response.body)
|
@@ -115,24 +123,24 @@ module BibSonomy
|
|
115
123
|
# @param endc [Integer] number of last post to download
|
116
124
|
# @return [Array<BibSonomy::Post>, String] the requested posts
|
117
125
|
def get_posts(grouping, name, resource_type, tags = nil, start = 0, endc = $MAX_POSTS_PER_REQUEST)
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
126
|
+
url = @url_posts.partial_expand({
|
127
|
+
:format => @format,
|
128
|
+
:resourcetype => get_resource_type(resource_type),
|
129
|
+
:start => start,
|
130
|
+
:end => endc
|
131
|
+
})
|
124
132
|
# decide what to get
|
125
133
|
if grouping == "user"
|
126
|
-
|
134
|
+
url = url.partial_expand({:user => name})
|
127
135
|
elsif grouping == "group"
|
128
|
-
|
136
|
+
url = url.partial_expand({:group => name})
|
129
137
|
end
|
130
138
|
# add tags, if requested
|
131
139
|
if tags != nil
|
132
|
-
|
140
|
+
url = url.partial_expand({:tags => tags.join(" ")})
|
133
141
|
end
|
134
142
|
|
135
|
-
response = @conn.get
|
143
|
+
response = @conn.get url.expand({})
|
136
144
|
|
137
145
|
if @parse
|
138
146
|
posts = JSON.parse(response.body)["posts"]["post"]
|
@@ -143,7 +151,11 @@ module BibSonomy
|
|
143
151
|
|
144
152
|
|
145
153
|
def get_document_href(user_name, intra_hash, file_name)
|
146
|
-
return
|
154
|
+
return @url_doc.expand({
|
155
|
+
:user_name => user_name,
|
156
|
+
:intra_hash => intra_hash,
|
157
|
+
:file_name => file_name
|
158
|
+
})
|
147
159
|
end
|
148
160
|
|
149
161
|
#
|
data/lib/bibsonomy/csl.rb
CHANGED
data/lib/bibsonomy/version.rb
CHANGED
data/test/post_test.rb
CHANGED
@@ -5,17 +5,17 @@ class BibSonomyPostTest < Minitest::Test
|
|
5
5
|
def setup
|
6
6
|
@api = BibSonomy::API.new(ENV['BIBSONOMY_USER_NAME'], ENV['BIBSONOMY_API_KEY'], 'ruby')
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def test_exists
|
10
10
|
assert BibSonomy::Post
|
11
11
|
assert BibSonomy::API
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def test_get_post
|
15
15
|
VCR.use_cassette('get_post') do
|
16
16
|
post = @api.get_post("bibsonomy-ruby", "c9437d5ec56ba949f533aeec00f571e3")
|
17
17
|
assert_equal BibSonomy::Post, post.class
|
18
|
-
|
18
|
+
|
19
19
|
# Check that the fields are accessible by our model
|
20
20
|
assert_equal "bibsonomy-ruby", post.user_name
|
21
21
|
assert_equal "c9437d5ec56ba949f533aeec00f571e3", post.intra_hash
|
@@ -27,58 +27,58 @@ class BibSonomyPostTest < Minitest::Test
|
|
27
27
|
def test_get_posts_for_user
|
28
28
|
VCR.use_cassette('get_posts_for_user') do
|
29
29
|
result = @api.get_posts_for_user("bibsonomy-ruby", "publication", ["test"], 0, 20)
|
30
|
-
|
30
|
+
|
31
31
|
# Make sure we got all the posts
|
32
32
|
assert_equal 2, result.length
|
33
|
-
|
33
|
+
|
34
34
|
# Make sure that the JSON was parsed
|
35
35
|
assert result.kind_of?(Array)
|
36
36
|
assert result.first.kind_of?(BibSonomy::Post)
|
37
|
-
end
|
37
|
+
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_get_posts_for_group
|
41
41
|
VCR.use_cassette('get_posts_for_group') do
|
42
42
|
result = @api.get_posts_for_group("iccs", "publication", ["test"], 0, 10)
|
43
|
-
|
43
|
+
|
44
44
|
# Make sure we got all the posts
|
45
45
|
assert_equal 2, result.length
|
46
|
-
|
46
|
+
|
47
47
|
# Make sure that the JSON was parsed
|
48
48
|
assert result.kind_of?(Array)
|
49
49
|
assert result.first.kind_of?(BibSonomy::Post)
|
50
|
-
end
|
50
|
+
end
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_get_posts_user
|
54
54
|
VCR.use_cassette('get_posts_user') do
|
55
55
|
result = @api.get_posts("user", "bibsonomy-ruby", "publication", ["test"], 0, 10)
|
56
|
-
|
56
|
+
|
57
57
|
# Make sure we got all the posts
|
58
58
|
assert_equal 2, result.length
|
59
|
-
|
59
|
+
|
60
60
|
# Make sure that the JSON was parsed
|
61
61
|
assert result.kind_of?(Array)
|
62
62
|
assert result.first.kind_of?(BibSonomy::Post)
|
63
|
-
end
|
63
|
+
end
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_get_posts_group
|
67
67
|
VCR.use_cassette('get_posts_group') do
|
68
68
|
result = @api.get_posts("group", "iccs", "publication", ["test"], 0, 10)
|
69
|
-
|
69
|
+
|
70
70
|
# Make sure we got all the posts
|
71
71
|
assert_equal 2, result.length
|
72
|
-
|
72
|
+
|
73
73
|
# Make sure that the JSON was parsed
|
74
74
|
assert result.kind_of?(Array)
|
75
75
|
assert result.first.kind_of?(BibSonomy::Post)
|
76
|
-
end
|
76
|
+
end
|
77
77
|
end
|
78
78
|
|
79
79
|
|
80
80
|
def test_get_document_href
|
81
|
-
assert_equal "/api/users/bibsonomy-ruby/posts/c9437d5ec56ba949f533aeec00f571e3/documents/paper.pdf", @api.get_document_href("bibsonomy-ruby", "c9437d5ec56ba949f533aeec00f571e3", "paper.pdf")
|
81
|
+
assert_equal Addressable::URI.parse("/api/users/bibsonomy-ruby/posts/c9437d5ec56ba949f533aeec00f571e3/documents/paper%202.pdf"), @api.get_document_href("bibsonomy-ruby", "c9437d5ec56ba949f533aeec00f571e3", "paper 2.pdf")
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_get_document
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibsonomy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Jäschke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -204,6 +204,20 @@ dependencies:
|
|
204
204
|
- - "~>"
|
205
205
|
- !ruby/object:Gem::Version
|
206
206
|
version: '1.5'
|
207
|
+
- !ruby/object:Gem::Dependency
|
208
|
+
name: addressable
|
209
|
+
requirement: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - "~>"
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '2.5'
|
214
|
+
type: :runtime
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - "~>"
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '2.5'
|
207
221
|
- !ruby/object:Gem::Dependency
|
208
222
|
name: unicode
|
209
223
|
requirement: !ruby/object:Gem::Requirement
|