citero_renderers 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +38 -0
- data/lib/citero_renderers.rb +25 -0
- data/lib/citero_renderers/bibtex_renderable.rb +7 -0
- data/lib/citero_renderers/mime_types/bibtex_mime_type.rb +6 -0
- data/lib/citero_renderers/mime_types/ris_mime_type.rb +6 -0
- data/lib/citero_renderers/ris_renderable.rb +7 -0
- data/lib/citero_renderers/version.rb +3 -0
- data/spec/lib/bibtex_renderable_spec.rb +39 -0
- data/spec/lib/ris_renderable_spec.rb +39 -0
- data/spec/spec_helper.rb +28 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d2ac9337d99806004919e883bcde7e07cf4d9333
|
4
|
+
data.tar.gz: 3e936ba1f9a98933b16a046e5191dca915c81e84
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0d2959b04c2cc4b53a41c2ab90fccbf43687d44134a15ad57fb1c48e261ab58b416dd7fad4e24149519f634a64fefc2868a0025906456cae51e4748ce8b172c
|
7
|
+
data.tar.gz: 0ee0106e933ea4840edfcf84879d5ac19eb0c80b48274cebfa0487e8a78456d58f02a4ff70155f29560b93b88032c34b979f1326e8061621e8cca2a384cf7e0c
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 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.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -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,25 @@
|
|
1
|
+
module CiteroRenderers
|
2
|
+
class CiteroRenderersRailTie < ::Rails::Railtie
|
3
|
+
config.after_initialize do
|
4
|
+
require 'citero_renderers/bibtex_renderable'
|
5
|
+
require 'citero_renderers/ris_renderable'
|
6
|
+
require 'citero_renderers/mime_types/ris_mime_type'
|
7
|
+
require 'citero_renderers/mime_types/bibtex_mime_type'
|
8
|
+
require 'action_controller/metal/renderers'
|
9
|
+
# Adds a renderer for BibTeX.
|
10
|
+
ActionController.add_renderer :bibtex do |bibtex,option|
|
11
|
+
bibtex.extend CiteroRenderers::BibtexRenderable unless bibtex.respond_to?(:to_bibtex)
|
12
|
+
filename = (bibtex.respond_to?(:to_param) and bibtex.class.respond_to?(:acts_as_citable)) ? bibtex.to_param : "export"
|
13
|
+
bibtex = bibtex.to_bibtex
|
14
|
+
send_data bibtex, type: Mime::Type.lookup(:bibtex), disposition: "attachment; filename=#{filename}.bib"
|
15
|
+
end
|
16
|
+
# Adds a renderer for RIS.
|
17
|
+
ActionController.add_renderer :ris do |ris, option|
|
18
|
+
ris.extend CiteroRenderers::RisRenderable unless ris.respond_to?(:to_ris)
|
19
|
+
filename = (ris.respond_to?(:to_param) and ris.class.respond_to?(:acts_as_citable)) ? ris.to_param : "export"
|
20
|
+
ris = ris.to_ris()
|
21
|
+
send_data ris, type: Mime::Type.lookup(:ris), disposition: "attachment; filename=#{filename}.ris"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe CiteroRenderers::BibtexRenderable do
|
4
|
+
|
5
|
+
context 'object is an array' do
|
6
|
+
let(:bibtex_renderable_array) { array.extend CiteroRenderers::BibtexRenderable }
|
7
|
+
context 'array is empty' do
|
8
|
+
let(:array) { Array.new }
|
9
|
+
it 'returns an empty string' do
|
10
|
+
expect(bibtex_renderable_array.to_bibtex).to eql('')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'array has one citero object' do
|
14
|
+
let(:array) { [Citero.map("itemType: book").from_csf] }
|
15
|
+
it 'returns an empty string' do
|
16
|
+
expect(bibtex_renderable_array.to_bibtex).to eql("@book{????\n}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context 'array has one active record' do
|
20
|
+
let(:array) { [RecordChangedField.create!(data: "itemType: book", from_format: "csf")] }
|
21
|
+
it 'returns an empty string' do
|
22
|
+
expect(bibtex_renderable_array.to_bibtex).to eql("@book{????\n}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context 'array has many citero objects' do
|
26
|
+
let(:array) { [Citero.map("itemType: book").from_csf, Citero.map("itemType: book").from_csf] }
|
27
|
+
it 'returns an empty string' do
|
28
|
+
expect(bibtex_renderable_array.to_bibtex).to eql("@book{????\n}\n\n@book{????\n}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'array has many active records' do
|
32
|
+
let(:array) { [RecordChangedField.create!(data: "itemType: book", from_format: "csf"),
|
33
|
+
RecordChangedField.create!(data: "itemType: book", from_format: "csf")] }
|
34
|
+
it 'returns an empty string' do
|
35
|
+
expect(bibtex_renderable_array.to_bibtex).to eql("@book{????\n}\n\n@book{????\n}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe CiteroRenderers::RisRenderable do
|
4
|
+
|
5
|
+
context 'object is an array' do
|
6
|
+
let(:ris_renderable_array) { array.extend CiteroRenderers::RisRenderable }
|
7
|
+
context 'array is empty' do
|
8
|
+
let(:array) { Array.new }
|
9
|
+
it 'returns an empty string' do
|
10
|
+
expect(ris_renderable_array.to_ris).to eql('')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'array has one citero object' do
|
14
|
+
let(:array) { [Citero.map("itemType: book").from_csf] }
|
15
|
+
it 'returns an empty string' do
|
16
|
+
expect(ris_renderable_array.to_ris).to eql("TY - BOOK\nER -\n\n")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context 'array has one active record' do
|
20
|
+
let(:array) { [RecordChangedField.create!(data: "itemType: book", from_format: "csf")] }
|
21
|
+
it 'returns an empty string' do
|
22
|
+
expect(ris_renderable_array.to_ris).to eql("TY - BOOK\nER -\n\n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context 'array has many citero objects' do
|
26
|
+
let(:array) { [Citero.map("itemType: book").from_csf, Citero.map("itemType: book").from_csf] }
|
27
|
+
it 'returns an empty string' do
|
28
|
+
expect(ris_renderable_array.to_ris).to eql("TY - BOOK\nER -\n\n\n\nTY - BOOK\nER -\n\n")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'array has many active records' do
|
32
|
+
let(:array) { [RecordChangedField.create!(data: "itemType: book", from_format: "csf"),
|
33
|
+
RecordChangedField.create!(data: "itemType: book", from_format: "csf")] }
|
34
|
+
it 'returns an empty string' do
|
35
|
+
expect(ris_renderable_array.to_ris).to eql("TY - BOOK\nER -\n\n\n\nTY - BOOK\nER -\n\n")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rails/all'
|
5
|
+
require 'rspec/rails'
|
6
|
+
require 'citero_renderers/ris_renderable'
|
7
|
+
require 'citero_renderers/bibtex_renderable'
|
8
|
+
require 'acts_as_citable'
|
9
|
+
|
10
|
+
# Requires supporting files with custom matchers and macros, etc,
|
11
|
+
# in ./support/ and its subdirectories.
|
12
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
13
|
+
|
14
|
+
|
15
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
16
|
+
|
17
|
+
ActiveRecord::Schema.define(:version => 1) do
|
18
|
+
create_table :record_changed_fields, :force => true do |t|
|
19
|
+
t.string :data
|
20
|
+
t.string :from_format
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class RecordChangedField < ActiveRecord::Base
|
25
|
+
acts_as_citable do |c|
|
26
|
+
c.format_field = 'from_format'
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: citero_renderers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hab278
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '3.0'
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: citero-jruby
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.0'
|
39
|
+
prerelease: false
|
40
|
+
type: :runtime
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activerecord-jdbcsqlite3-adapter
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.12'
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.12'
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: acts_as_citable
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
83
|
+
description: Renders citero objects for Rails applications.
|
84
|
+
email:
|
85
|
+
- hab278@nyu.edu
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- lib/citero_renderers.rb
|
91
|
+
- lib/citero_renderers/bibtex_renderable.rb
|
92
|
+
- lib/citero_renderers/ris_renderable.rb
|
93
|
+
- lib/citero_renderers/version.rb
|
94
|
+
- lib/citero_renderers/mime_types/bibtex_mime_type.rb
|
95
|
+
- lib/citero_renderers/mime_types/ris_mime_type.rb
|
96
|
+
- MIT-LICENSE
|
97
|
+
- Rakefile
|
98
|
+
- README.rdoc
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/lib/bibtex_renderable_spec.rb
|
101
|
+
- spec/lib/ris_renderable_spec.rb
|
102
|
+
homepage: https://github.com/NYULibraries/citero_renderers
|
103
|
+
licenses: []
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.1.9
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Renderers for some citero objects.
|
125
|
+
test_files:
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
- spec/lib/bibtex_renderable_spec.rb
|
128
|
+
- spec/lib/ris_renderable_spec.rb
|