citero-renderers 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bda445210b8e0b7bc7a4d09abe9424a904612714
4
+ data.tar.gz: 33fd3f1953a712d904b9f1d64880226db2f17fbe
5
+ SHA512:
6
+ metadata.gz: 1909dbad0b2db101cbd9414dbcd9d0c63245c8f853845957db5dee19518dc3495297c50c679d0ca06cbe277b78a5c4627cd7314a37ad08d13cababdca448ae2f
7
+ data.tar.gz: fccc57eeb1036e59a731ad0f65ef344940c8ef94ed1e8f1ef3fdfbd86d26c03e1ee1432ff670dda7f9e06fd2a2c9304fa24f9af95bb97658f7b1e04633930286
@@ -0,0 +1,20 @@
1
+ Copyright 2016 NYU Division of Libraries
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = ActsAsCitable
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'CiteroRenderers'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,2 @@
1
+ require 'require_all'
2
+ require_rel 'citero-renderers'
@@ -0,0 +1,5 @@
1
+ require 'action_pack'
2
+ # Mime type for bibtex and an alias, bib
3
+ Mime::Type.register "application/x-bibtex", :bibtex, [:bib], [:bib]
4
+ # Mime type for RIS
5
+ Mime::Type.register "application/x-research-info-systems", :ris
@@ -0,0 +1,32 @@
1
+ require 'action_pack'
2
+ class Array
3
+ # Allow array of objects to be translated to ris
4
+ def to_ris
5
+ self.collect { |r| r.to_ris if r.respond_to? :to_ris}.join("\n\n")
6
+ end
7
+
8
+ # Allow array of objects to be translated to ris
9
+ def to_bibtex
10
+ self.collect { |r| r.to_bibtex if r.respond_to? :to_bibtex }.join("\n\n")
11
+ end
12
+ end
13
+
14
+ # Adds a renderer for RIS.
15
+ ActionController::Renderers.add :ris do |ris, options|
16
+ ris = ris.first if ris.is_a? Array and ris.count == 1
17
+ filename = (ris.respond_to?(:to_param) and ris.class.respond_to?(:acts_as_citable)) ? ris.to_param : "export"
18
+ ris = ris.respond_to?(:to_ris) ? ris.to_ris() : ris
19
+ ris = "#{options[:callback]}(#{ris})" unless options[:callback].blank?
20
+ self.content_type ||= Mime::Type.lookup(:ris)
21
+ self.send_data ris, filename: "#{filename}.ris"
22
+ end
23
+
24
+ # Adds a renderer for BibTeX.
25
+ ActionController::Renderers.add :bibtex do |bibtex, options|
26
+ bibtex = bibtex.first if bibtex.is_a? Array and bibtex.count == 1
27
+ filename = (bibtex.respond_to?(:to_param) and bibtex.class.respond_to?(:acts_as_citable)) ? bibtex.to_param : "export"
28
+ bibtex = bibtex.respond_to?(:to_bibtex) ? bibtex.to_bibtex() : bibtex
29
+ bibtex = "#{options[:callback]}(#{bibtex})" unless options[:callback].blank?
30
+ self.content_type ||= Mime::Type.lookup(:bibtex)
31
+ self.send_data bibtex, filename: "#{filename}.bib"
32
+ end
@@ -0,0 +1,3 @@
1
+ module CiteroRenderers
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: citero-renderers
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - hab278
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.7.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.7.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - hab278@nyu.edu
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.rdoc
50
+ - Rakefile
51
+ - lib/citero-renderers.rb
52
+ - lib/citero-renderers/mime_types.rb
53
+ - lib/citero-renderers/renderers.rb
54
+ - lib/citero-renderers/version.rb
55
+ homepage: https://github.com/NYULibraries/citero-renderers
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.5.1
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Rails renderers and mime types for acts_as_citable gem.
78
+ test_files: []