bibsonomy 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bibsonomy.gemspec +2 -2
- data/lib/bibsonomy/csl.rb +36 -8
- data/lib/bibsonomy/version.rb +1 -1
- data/test/csl_test.rb +27 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d663777e3f80abee1893b48f69ea63285cd46831
|
4
|
+
data.tar.gz: ca800a9b1edb0089388c45a2fa374c68c2e6e908
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d59edc42adcc225fb04725882d0752ef68f19850173e1cdc847e5634eb205f6cd1946ae5bdcbf0baa673b90e82a095ba1d633eefd95939cdfa9b972969de0e9
|
7
|
+
data.tar.gz: b71cd309c671a5514522cb55a9086085d7a2d68a2bcc4faef886858a2bc4553409f13cfc3f05b973dcc9666ff8731d983ef389064fcaa240767553557ce48b48
|
data/bibsonomy.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = %q{Wraps the BibSonomy REST API.}
|
12
12
|
spec.description = %q{Enables calls to the BibSonomy REST API with Ruby.}
|
13
13
|
spec.homepage = "https://github.com/rjoberon/bibsonomy-ruby"
|
14
|
-
spec.license = "LGPL
|
14
|
+
spec.license = "LGPL-2.1"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "simplecov", '~> 0.7'
|
30
30
|
|
31
31
|
spec.add_dependency "faraday", "~> 0.9"
|
32
|
-
spec.add_dependency "json", "~>
|
32
|
+
spec.add_dependency "json", "~> 2.0"
|
33
33
|
spec.add_dependency "citeproc", "~> 1.0"
|
34
34
|
spec.add_dependency "citeproc-ruby", "~> 1.0"
|
35
35
|
spec.add_dependency "csl-styles", "~> 1.0"
|
data/lib/bibsonomy/csl.rb
CHANGED
@@ -19,8 +19,12 @@ require 'bibsonomy'
|
|
19
19
|
# - style
|
20
20
|
# - directory
|
21
21
|
# - group
|
22
|
+
# - altmetric
|
22
23
|
#
|
23
24
|
# Changes:
|
25
|
+
# 2017-07-05 (rja)
|
26
|
+
# - added support for Altmetric badges
|
27
|
+
# - adapted options for command line use to support groups
|
24
28
|
# 2017-06-06 (rja)
|
25
29
|
# - added support for DOIs which are actually URLs (i.e., include the resolver)
|
26
30
|
# 2017-05-31 (rja)
|
@@ -71,6 +75,9 @@ module BibSonomy
|
|
71
75
|
# @return [String] the separator between options. (default: ' | ')
|
72
76
|
attr_accessor :opt_sep
|
73
77
|
|
78
|
+
# @return [String] the badge type for embedded Altmetric badges. If set to `nil`, no badge is included. (default: `nil`)
|
79
|
+
attr_accessor :altmetric_badge_type
|
80
|
+
|
74
81
|
# @return [String] When a post has several documents and the
|
75
82
|
# filename of one of them ends with `public_doc_postfix`, only
|
76
83
|
# this document is downloaded and linked, all other are
|
@@ -95,6 +102,7 @@ module BibSonomy
|
|
95
102
|
@year_headings = true
|
96
103
|
@public_doc_postfix = '_oa.pdf'
|
97
104
|
@group = 'public'
|
105
|
+
@altmetric_badge_type = nil
|
98
106
|
|
99
107
|
# optional parts to be rendered (or not)
|
100
108
|
@doi_link = true
|
@@ -202,6 +210,12 @@ module BibSonomy
|
|
202
210
|
result += " <span class='opt'>[" + options.join(@opt_sep) + "]</span>"
|
203
211
|
end
|
204
212
|
|
213
|
+
# attach Altmetric badge
|
214
|
+
if @altmetric_badge_type and doi != ""
|
215
|
+
doi, doi_url = get_doi(doi)
|
216
|
+
result += "<div class='altmetric-embed' data-badge-type='#{@altmetric_badge_type}' data-doi='#{doi}'></div>"
|
217
|
+
end
|
218
|
+
|
205
219
|
result += "</li>\n"
|
206
220
|
end
|
207
221
|
result += "</ul>\n"
|
@@ -327,7 +341,8 @@ module BibSonomy
|
|
327
341
|
options.directory = nil
|
328
342
|
options.tags = []
|
329
343
|
options.style = "apa.csl"
|
330
|
-
options.
|
344
|
+
options.viewable_group = "public"
|
345
|
+
options.altmetric = nil
|
331
346
|
options.posts = 1000
|
332
347
|
|
333
348
|
opt_parser = OptionParser.new do |opts|
|
@@ -339,12 +354,14 @@ module BibSonomy
|
|
339
354
|
# mandatory arguments are handled separately
|
340
355
|
|
341
356
|
# optional arguments
|
342
|
-
opts.on('-u', '--user USER', '
|
357
|
+
opts.on('-u', '--user USER', 'get posts for USER') { |v| options[:user] = v }
|
358
|
+
opts.on('-g', '--group GROUP', 'get posts for GROUP') { |v| options[:group] = v }
|
343
359
|
opts.on('-t', '--tags TAG,TAG,...', Array, 'return posts with the given tags') { |v| options[:tags] = v }
|
344
360
|
opts.on('-s', '--style STYLE', 'use CSL style STYLE for rendering') { |v| options[:style] = v }
|
345
|
-
opts.on('-
|
361
|
+
opts.on('--viewable-group GROUP', 'include only posts viewable for GROUP') { |v| options[:viewable_group] = v }
|
346
362
|
opts.on('-n', '--number-of-posts [COUNT]', Integer, 'number of posts to download') { |v| options[:posts] = v }
|
347
363
|
opts.on('-d', '--directory DIR', 'target directory', ' (if not given, no documents are downloaed)') { |v| options[:directory] = v }
|
364
|
+
opts.on('-a', '--altmetric TYPE', 'render Altmetric badge with type TYPE') { |v| options[:altmetric] = v }
|
348
365
|
|
349
366
|
opts.separator ""
|
350
367
|
opts.separator "Common options:"
|
@@ -385,18 +402,29 @@ module BibSonomy
|
|
385
402
|
exit
|
386
403
|
end
|
387
404
|
|
388
|
-
# set defaults for optional arguments
|
389
|
-
options[:user] = options[:user_name] unless options[:user]
|
390
|
-
|
391
405
|
#
|
392
406
|
# do the actual work
|
393
407
|
#
|
394
408
|
csl = BibSonomy::CSL.new(options[:user_name], options[:api_key])
|
395
409
|
csl.pdf_dir = options[:directory]
|
396
410
|
csl.style = options[:style]
|
397
|
-
csl.group = options[:
|
411
|
+
csl.group = options[:viewable_group]
|
412
|
+
csl.altmetric_badge_type = options[:altmetric]
|
413
|
+
|
414
|
+
if options[:group]
|
415
|
+
grouping = "group"
|
416
|
+
name = options[:group]
|
417
|
+
elsif options[:user]
|
418
|
+
grouping = "user"
|
419
|
+
name = options[:user]
|
420
|
+
else
|
421
|
+
# default: API user
|
422
|
+
grouping = "user"
|
423
|
+
name = options[:user_name]
|
424
|
+
end
|
398
425
|
|
399
|
-
|
426
|
+
puts "call: #{grouping}, #{name}"
|
427
|
+
html = csl.render(grouping, name, options[:tags], options[:posts])
|
400
428
|
|
401
429
|
return html
|
402
430
|
|
data/lib/bibsonomy/version.rb
CHANGED
data/test/csl_test.rb
CHANGED
@@ -19,17 +19,40 @@ class BibSonomyCSLTest < Minitest::Test
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_render_all
|
23
|
+
VCR.use_cassette('render_all') do
|
24
|
+
html = @csl.render("user", "bibsonomy-ruby", [], 10)
|
25
|
+
|
26
|
+
assert_equal "<h3>2015</h3>", html[0..12]
|
27
|
+
assert_equal "<h3>2010</h3>", html[765..777]
|
28
|
+
assert_equal "</ul>", html[-6..-2]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
22
32
|
def test_render_doi
|
23
|
-
VCR.use_cassette('
|
33
|
+
VCR.use_cassette('render_doi') do
|
24
34
|
html = @csl.render("user", "bibsonomy-ruby", ["doiok"], 10)
|
25
35
|
# DOI is correct
|
26
|
-
assert_equal "DOI:<a href='https://dx.doi.org/10.1007/s00778-010-0208-4'>10.1007/s00778-010-0208-4</a>", html[
|
36
|
+
assert_equal "DOI:<a href='https://dx.doi.org/10.1007/s00778-010-0208-4'>10.1007/s00778-010-0208-4</a>", html[339,88]
|
37
|
+
end
|
38
|
+
end
|
27
39
|
|
40
|
+
def test_render_broken_doi
|
41
|
+
VCR.use_cassette('render_broken_doi') do
|
28
42
|
# DOI is a URL
|
29
43
|
html = @csl.render("user", "bibsonomy-ruby", ["brokendoi", "test"], 10)
|
30
|
-
# thus we have http not https
|
31
|
-
assert_equal "DOI:<a href='http://dx.doi.org/10.1145/2786451.2786927'>10.1145/2786451.2786927</a>", html[
|
44
|
+
# thus we have http not https
|
45
|
+
assert_equal "DOI:<a href='http://dx.doi.org/10.1145/2786451.2786927'>10.1145/2786451.2786927</a>", html[374,83]
|
32
46
|
end
|
33
47
|
end
|
34
48
|
|
49
|
+
def test_get_docs
|
50
|
+
VCR.use_cassette('get_docs') do
|
51
|
+
# DOI is a URL
|
52
|
+
@csl.pdf_dir = "docs"
|
53
|
+
html = @csl.render("user", "bibsonomy-ruby", ["test", "doiok"], 10)
|
54
|
+
|
55
|
+
assert_equal "<a href='docs/test.pdf'>PDF</a>", html[339,31]
|
56
|
+
end
|
57
|
+
end
|
35
58
|
end
|
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.10
|
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: 2017-
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '2.0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '2.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: citeproc
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,7 +216,7 @@ files:
|
|
216
216
|
- test/test_helper.rb
|
217
217
|
homepage: https://github.com/rjoberon/bibsonomy-ruby
|
218
218
|
licenses:
|
219
|
-
- LGPL
|
219
|
+
- LGPL-2.1
|
220
220
|
metadata: {}
|
221
221
|
post_install_message:
|
222
222
|
rdoc_options: []
|
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
version: '0'
|
235
235
|
requirements: []
|
236
236
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.
|
237
|
+
rubygems_version: 2.5.2
|
238
238
|
signing_key:
|
239
239
|
specification_version: 4
|
240
240
|
summary: Wraps the BibSonomy REST API.
|