citeproc-ruby 0.0.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.document +4 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.simplecov +4 -0
- data/.travis.yml +17 -0
- data/.yardopts +2 -0
- data/AGPL +662 -0
- data/BSDL +29 -0
- data/Gemfile +42 -0
- data/Guardfile +14 -0
- data/README.md +32 -76
- data/Rakefile +60 -0
- data/citeproc-ruby.gemspec +46 -0
- data/cucumber.yml +1 -0
- data/features/bibliography.feature +25 -0
- data/features/name_options.feature +37 -0
- data/features/names.feature +192 -0
- data/features/renderer.feature +74 -0
- data/features/sort.feature +50 -0
- data/features/step_definitions/renderer.rb +80 -0
- data/features/support/env.rb +33 -0
- data/features/support/hooks.rb +10 -0
- data/lib/citeproc/ruby.rb +32 -0
- data/lib/citeproc/ruby/engine.rb +122 -0
- data/lib/citeproc/ruby/format.rb +303 -0
- data/lib/citeproc/ruby/formats/default.rb +25 -0
- data/lib/citeproc/ruby/formats/html.rb +221 -0
- data/lib/citeproc/ruby/renderer.rb +140 -0
- data/lib/citeproc/ruby/renderer/choose.rb +106 -0
- data/lib/citeproc/ruby/renderer/date.rb +90 -0
- data/lib/citeproc/ruby/renderer/format.rb +129 -0
- data/lib/citeproc/ruby/renderer/group.rb +34 -0
- data/lib/citeproc/ruby/renderer/history.rb +40 -0
- data/lib/citeproc/ruby/renderer/label.rb +66 -0
- data/lib/citeproc/ruby/renderer/layout.rb +20 -0
- data/lib/citeproc/ruby/renderer/locale.rb +26 -0
- data/lib/citeproc/ruby/renderer/macro.rb +20 -0
- data/lib/citeproc/ruby/renderer/names.rb +401 -0
- data/lib/citeproc/ruby/renderer/number.rb +41 -0
- data/lib/citeproc/ruby/renderer/observer.rb +44 -0
- data/lib/citeproc/ruby/renderer/state.rb +96 -0
- data/lib/citeproc/ruby/renderer/text.rb +62 -0
- data/lib/citeproc/ruby/sort.rb +82 -0
- data/lib/citeproc/ruby/version.rb +5 -0
- data/spec/citeproc/ruby/engine_spec.rb +94 -0
- data/spec/citeproc/ruby/formats/default_spec.rb +159 -0
- data/spec/citeproc/ruby/formats/html_spec.rb +162 -0
- data/spec/citeproc/ruby/renderer/choose_spec.rb +293 -0
- data/spec/citeproc/ruby/renderer/date_spec.rb +173 -0
- data/spec/citeproc/ruby/renderer/group_spec.rb +88 -0
- data/spec/citeproc/ruby/renderer/history_spec.rb +38 -0
- data/spec/citeproc/ruby/renderer/label_spec.rb +225 -0
- data/spec/citeproc/ruby/renderer/layout_spec.rb +41 -0
- data/spec/citeproc/ruby/renderer/macro_spec.rb +31 -0
- data/spec/citeproc/ruby/renderer/names_spec.rb +396 -0
- data/spec/citeproc/ruby/renderer/number_spec.rb +120 -0
- data/spec/citeproc/ruby/renderer/text_spec.rb +120 -0
- data/spec/citeproc/ruby/renderer_spec.rb +65 -0
- data/spec/fixtures/items.rb +80 -0
- data/{resource/locale → spec/fixtures/locales}/locales-en-US.xml +2 -11
- data/{resource/locale → spec/fixtures/locales}/locales-fr-FR.xml +77 -66
- data/{resource/style → spec/fixtures/styles}/apa.csl +5 -5
- data/spec/spec_helper.rb +67 -14
- metadata +121 -211
- data/lib/citeproc.rb +0 -100
- data/lib/citeproc/bibliography.rb +0 -57
- data/lib/citeproc/data.rb +0 -149
- data/lib/citeproc/date.rb +0 -133
- data/lib/citeproc/formatter.rb +0 -38
- data/lib/citeproc/item.rb +0 -53
- data/lib/citeproc/name.rb +0 -284
- data/lib/citeproc/processor.rb +0 -166
- data/lib/citeproc/selector.rb +0 -61
- data/lib/citeproc/variable.rb +0 -82
- data/lib/citeproc/version.rb +0 -3
- data/lib/csl/locale.rb +0 -223
- data/lib/csl/node.rb +0 -72
- data/lib/csl/nodes.rb +0 -1418
- data/lib/csl/renderer.rb +0 -88
- data/lib/csl/sort.rb +0 -61
- data/lib/csl/style.rb +0 -110
- data/lib/csl/term.rb +0 -124
- data/lib/extensions/core.rb +0 -43
- data/lib/plugins/filters/bibtex.rb +0 -12
- data/lib/plugins/formats/default.rb +0 -134
- data/lib/plugins/formats/html.rb +0 -67
- data/lib/support/attributes.rb +0 -99
- data/lib/support/compatibility.rb +0 -83
- data/lib/support/tree.rb +0 -80
- data/resource/locale/locales-af-ZA.xml +0 -305
- data/resource/locale/locales-ar-AR.xml +0 -306
- data/resource/locale/locales-bg-BG.xml +0 -305
- data/resource/locale/locales-ca-AD.xml +0 -305
- data/resource/locale/locales-cs-CZ.xml +0 -305
- data/resource/locale/locales-da-DK.xml +0 -305
- data/resource/locale/locales-de-AT.xml +0 -304
- data/resource/locale/locales-de-CH.xml +0 -304
- data/resource/locale/locales-de-DE.xml +0 -332
- data/resource/locale/locales-el-GR.xml +0 -305
- data/resource/locale/locales-en-GB.xml +0 -304
- data/resource/locale/locales-es-ES.xml +0 -305
- data/resource/locale/locales-et-EE.xml +0 -304
- data/resource/locale/locales-eu.xml +0 -305
- data/resource/locale/locales-fa-IR.xml +0 -304
- data/resource/locale/locales-fi-FI.xml +0 -304
- data/resource/locale/locales-fr-CA.xml +0 -306
- data/resource/locale/locales-he-IL.xml +0 -304
- data/resource/locale/locales-hu-HU.xml +0 -305
- data/resource/locale/locales-is-IS.xml +0 -304
- data/resource/locale/locales-it-IT.xml +0 -305
- data/resource/locale/locales-ja-JP.xml +0 -305
- data/resource/locale/locales-kh-KH.xml +0 -303
- data/resource/locale/locales-km-KH.xml +0 -304
- data/resource/locale/locales-ko-KR.xml +0 -305
- data/resource/locale/locales-mn-MN.xml +0 -306
- data/resource/locale/locales-nb-NO.xml +0 -304
- data/resource/locale/locales-nl-NL.xml +0 -304
- data/resource/locale/locales-nn-NO.xml +0 -304
- data/resource/locale/locales-pl-PL.xml +0 -305
- data/resource/locale/locales-pt-BR.xml +0 -304
- data/resource/locale/locales-pt-PT.xml +0 -305
- data/resource/locale/locales-ro-RO.xml +0 -305
- data/resource/locale/locales-ru-RU.xml +0 -306
- data/resource/locale/locales-sk-SK.xml +0 -304
- data/resource/locale/locales-sl-SI.xml +0 -305
- data/resource/locale/locales-sr-RS.xml +0 -305
- data/resource/locale/locales-sv-SE.xml +0 -305
- data/resource/locale/locales-th-TH.xml +0 -304
- data/resource/locale/locales-tr-TR.xml +0 -305
- data/resource/locale/locales-uk-UA.xml +0 -306
- data/resource/locale/locales-vi-VN.xml +0 -305
- data/resource/locale/locales-zh-CN.xml +0 -304
- data/resource/locale/locales-zh-TW.xml +0 -305
- data/resource/schema/csl-categories.rnc +0 -39
- data/resource/schema/csl-data.rnc +0 -98
- data/resource/schema/csl-terms.rnc +0 -106
- data/resource/schema/csl-types.rnc +0 -39
- data/resource/schema/csl-variables.rnc +0 -182
- data/resource/schema/csl.rnc +0 -941
- data/resource/style/bibtex.csl +0 -177
- data/resource/style/chicago-annotated-bibliography.csl +0 -513
- data/resource/style/chicago-author-date-basque.csl +0 -707
- data/resource/style/chicago-author-date-de.csl +0 -394
- data/resource/style/chicago-author-date-listing.csl +0 -434
- data/resource/style/chicago-author-date.csl +0 -425
- data/resource/style/chicago-dated-note-biblio-no-ibid.csl +0 -472
- data/resource/style/chicago-fullnote-bibliography-bb.csl +0 -928
- data/resource/style/chicago-fullnote-bibliography-delimiter-fixes.csl +0 -972
- data/resource/style/chicago-fullnote-bibliography-no-ibid-delimiter-fixes.csl +0 -963
- data/resource/style/chicago-fullnote-bibliography-no-ibid.csl +0 -785
- data/resource/style/chicago-fullnote-bibliography.csl +0 -803
- data/resource/style/chicago-library-list.csl +0 -511
- data/resource/style/chicago-note-biblio-no-ibid.csl +0 -514
- data/resource/style/chicago-note-bibliography.csl +0 -530
- data/resource/style/chicago-note.csl +0 -388
- data/resource/style/chicago-quick-copy.csl +0 -685
- data/resource/style/ieee.csl +0 -299
- data/resource/style/mla-notes.csl +0 -796
- data/resource/style/mla-underline.csl +0 -175
- data/resource/style/mla-url.csl +0 -214
- data/resource/style/mla.csl +0 -394
- data/resource/style/vancouver-brackets.csl +0 -256
- data/resource/style/vancouver-superscript-bracket-only-year.csl +0 -165
- data/resource/style/vancouver-superscript.csl +0 -256
- data/resource/style/vancouver.csl +0 -256
- data/spec/citeproc/bibliography_spec.rb +0 -45
- data/spec/citeproc/citeproc_spec.rb +0 -80
- data/spec/citeproc/date_spec.rb +0 -89
- data/spec/citeproc/formatter_spec.rb +0 -101
- data/spec/citeproc/item_spec.rb +0 -71
- data/spec/citeproc/name_spec.rb +0 -30
- data/spec/citeproc/processor_spec.rb +0 -61
- data/spec/citeproc/selector_spec.rb +0 -82
- data/spec/citeproc/variable_spec.rb +0 -69
- data/spec/csl/locale_spec.rb +0 -208
- data/spec/csl/node_spec.rb +0 -25
- data/spec/csl/nodes_spec.rb +0 -145
- data/spec/csl/style_spec.rb +0 -62
- data/spec/csl/term_spec.rb +0 -56
- data/spec/fixtures/dates.yaml +0 -80
- data/spec/fixtures/names.yaml +0 -115
- data/spec/fixtures/nodes.yaml +0 -245
- data/spec/support/attributes_spec.rb +0 -39
- data/spec/support/tree_spec.rb +0 -163
data/BSDL
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
CiteProc-Ruby. A Ruby CSL cite processor.
|
2
|
+
|
3
|
+
Copyright 2012 President and Fellows of Harvard College.
|
4
|
+
Copyright 2009-2014 Sylvester Keil. All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
1. Redistributions of source code must retain the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
|
17
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
19
|
+
EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
20
|
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
21
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
23
|
+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
24
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
25
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
27
|
+
The views and conclusions contained in the software and documentation are
|
28
|
+
those of the authors and should not be interpreted as representing official
|
29
|
+
policies, either expressed or implied, of the copyright holder.
|
data/Gemfile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
#gem 'citeproc', :github => 'inukshuk/citeproc.git'
|
5
|
+
#gem 'csl', :github => 'inukshuk/csl-ruby.git'
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem 'rake', '~>10.0'
|
9
|
+
gem 'rspec', '~>2.13'
|
10
|
+
gem 'cucumber', '~>1.2'
|
11
|
+
gem 'simplecov', '~>0.8'
|
12
|
+
gem 'rubinius-coverage', :platforms => [:rbx]
|
13
|
+
gem 'coveralls', :require => false
|
14
|
+
end
|
15
|
+
|
16
|
+
group :debug do
|
17
|
+
gem 'ruby-debug', :require => false, :platforms => [:jruby]
|
18
|
+
gem 'debugger', :require => false, :platforms => [:mri]
|
19
|
+
gem 'rubinius-debugger', :require => false, :platforms => [:rbx]
|
20
|
+
gem 'rubinius-compiler', :require => false, :platforms => [:rbx]
|
21
|
+
end
|
22
|
+
|
23
|
+
group :optional do
|
24
|
+
gem 'edtf'
|
25
|
+
gem 'chronic'
|
26
|
+
end
|
27
|
+
|
28
|
+
group :extra do
|
29
|
+
gem 'guard', '~>2.2'
|
30
|
+
gem 'guard-rspec'
|
31
|
+
gem 'guard-cucumber'
|
32
|
+
gem 'rb-fsevent', '~>0.9.1'
|
33
|
+
gem 'pry'
|
34
|
+
gem 'yard', '~>0.8', :platforms => [:mri]
|
35
|
+
gem 'redcarpet', '~>3.0', :platforms => [:mri]
|
36
|
+
end
|
37
|
+
|
38
|
+
platform :rbx do
|
39
|
+
gem 'rubysl'
|
40
|
+
gem 'racc'
|
41
|
+
gem 'json'
|
42
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'cucumber' do
|
11
|
+
watch(%r{^features/.+\.feature$})
|
12
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
13
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
14
|
+
end
|
data/README.md
CHANGED
@@ -1,92 +1,48 @@
|
|
1
1
|
CiteProc-Ruby
|
2
2
|
=============
|
3
|
+
CiteProc-Ruby is a [Citation Style Language](http://citationstyles.org/) (CSL)
|
4
|
+
1.0.1 cite processor written in pure Ruby. This Ruby gem contains the
|
5
|
+
processor's rendering engine only; for more documentation on the whole
|
6
|
+
cite processor, please refer to the documentation of the
|
7
|
+
[citeproc](https://rubygems.org/gems/citeproc) gem instead.
|
3
8
|
|
4
|
-
|
5
|
-
|
9
|
+
[![Build Status](https://secure.travis-ci.org/inukshuk/citeproc-ruby.png)](http://travis-ci.org/inukshuk/citeproc-ruby)
|
10
|
+
[![Coverage Status](https://coveralls.io/repos/inukshuk/citeproc-ruby/badge.png?branch=master)](https://coveralls.io/r/inukshuk/citeproc-ruby?branch=master)
|
11
|
+
[![Dependency Status](https://gemnasium.com/inukshuk/citeproc-ruby.png)](https://gemnasium.com/inukshuk/citeproc-ruby)
|
6
12
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
13
|
+
Development
|
14
|
+
-----------
|
15
|
+
The CiteProc-Ruby source code is
|
16
|
+
[hosted on GitHub](https://github.com/inukshuk/citeproc-ruby).
|
17
|
+
You can check out a copy of the latest code using Git:
|
11
18
|
|
12
|
-
|
13
|
-
and `citeproc-js` gems; meanwhile, however, these gems are not compatible, so if
|
14
|
-
you want to use the current `citeproc-ruby` gem, make sure that neither of the
|
15
|
-
other gems is installed.
|
19
|
+
$ git clone https://github.com/inukshuk/citeproc-ruby.git
|
16
20
|
|
17
|
-
|
18
|
-
by ActiveSupport, by the `unicode` gem (on Ruby 1.8 only), by the Java-based
|
19
|
-
support in JRuby, or naively by the `upcase` and `downcase` methods present
|
20
|
-
in Ruby by default. These gems are not installed automatically; install one
|
21
|
-
manually if you want enhanced Unicode support.
|
21
|
+
To get started, install the development dependencies and run all tests:
|
22
22
|
|
23
|
+
$ cd citeproc-ruby
|
24
|
+
$ bundle install
|
25
|
+
$ rake
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
$ [sudo] gem install unicode-utils # Ruby 1.9
|
29
|
-
$ [sudo] gem install unicode # Ruby 1.8
|
30
|
-
$ irb
|
31
|
-
>> require 'citeproc'
|
32
|
-
>> book = {
|
33
|
-
'author' => [{ 'given' => 'Edgar Allen', 'family' => 'Poe' }],
|
34
|
-
'title' => 'Poetry, Tales, and Selected Essays',
|
35
|
-
'type' => 'book',
|
36
|
-
'issued' => { 'date-parts' => [[1996]] },
|
37
|
-
'editor' => [{ 'family' => 'Quinn', 'given' => 'Patrick F.'}, { 'family' => 'Thompson', 'given' => 'G.R.' }],
|
38
|
-
'publisher' => 'Library of America',
|
39
|
-
'publisher-place' => 'New York'
|
40
|
-
}
|
41
|
-
>> CiteProc.process(book)
|
42
|
-
=> "Poe, E. A. (1996). Poetry, Tales, and Selected Essays. (P. F. Quinn & G. R. Thompson, Eds.). New York: Library of America."
|
43
|
-
>> CiteProc.process(book, :format => :html)
|
44
|
-
=> "Poe, E. A. (1996). <i>Poetry, Tales, and Selected Essays</i>. (P. F. Quinn & G. R. Thompson, Eds.). New York: Library of America."
|
45
|
-
>> CiteProc.process(book, :mode => :citation)
|
46
|
-
=> ["(Poe, 1996)"]
|
47
|
-
>> CiteProc.process(book, :style => "https://github.com/citation-style-language/styles/raw/master/chicago-author-date.csl")
|
48
|
-
=> "Poe, Edgar Allen. 1996. Poetry, Tales, and Selected Essays. Ed. Patrick F. Quinn and G.R. Thompson. New York: Library of America."
|
49
|
-
|
50
|
-
|
51
|
-
The RSpec examples are a valuable resource of usage examples.
|
52
|
-
|
27
|
+
If you've found a bug or have a question, please open an issue on the
|
28
|
+
[issue tracker](https://github.com/inukshuk/citeproc-ruby/issues).
|
29
|
+
Or, for extra credit, clone the CiteProc-Ruby repository, write a failing
|
30
|
+
example, fix the bug and submit a pull request.
|
53
31
|
|
54
32
|
Credits
|
55
33
|
-------
|
34
|
+
Thanks to Rintze M. Zelle, Sebastian Karcher, Frank G. Bennett, Jr.,
|
35
|
+
and Bruce D'Arcus of CSL and citeproc-js fame for their support!
|
36
|
+
|
37
|
+
Thanks to Google and the Berkman Center at Harvard University for supporting
|
38
|
+
this project as part of [Google Summer of Code](https://developers.google.com/open-source/soc/).
|
56
39
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
the [citeproc-test suite](https://bitbucket.org/bdarcus/citeproc-test), and the
|
61
|
-
kind feedback and support at the [xbiblio mailing list](http://sourceforge.net/mail/?group_id=117435).
|
40
|
+
Copyright
|
41
|
+
---------
|
42
|
+
Copyright 2009-2014 Sylvester Keil. All rights reserved.
|
62
43
|
|
44
|
+
Copyright 2012 President and Fellows of Harvard College.
|
63
45
|
|
64
46
|
License
|
65
47
|
-------
|
66
|
-
|
67
|
-
Copyright 2009-2011 Sylvester Keil. All rights reserved.
|
68
|
-
|
69
|
-
Redistribution and use in source and binary forms, with or without
|
70
|
-
modification, are permitted provided that the following conditions are met:
|
71
|
-
|
72
|
-
1. Redistributions of source code must retain the above copyright notice,
|
73
|
-
this list of conditions and the following disclaimer.
|
74
|
-
|
75
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
76
|
-
this list of conditions and the following disclaimer in the documentation
|
77
|
-
and/or other materials provided with the distribution.
|
78
|
-
|
79
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
|
80
|
-
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
81
|
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
82
|
-
EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
83
|
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
84
|
-
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
85
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
86
|
-
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
87
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
88
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
89
|
-
|
90
|
-
The views and conclusions contained in the software and documentation are
|
91
|
-
those of the authors and should not be interpreted as representing official
|
92
|
-
policies, either expressed or implied, of the copyright holder.
|
48
|
+
CiteProc-Ruby is dual licensed under the AGPL and the FreeBSD license.
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
begin
|
5
|
+
Bundler.setup
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
|
12
|
+
$:.unshift(File.join(File.dirname(__FILE__), './lib'))
|
13
|
+
require 'citeproc/ruby/version'
|
14
|
+
|
15
|
+
|
16
|
+
desc 'Run a Pry session with CiteProc-Ruby loaded'
|
17
|
+
task :console do
|
18
|
+
require 'pry'
|
19
|
+
require 'citeproc/ruby'
|
20
|
+
|
21
|
+
Pry.start
|
22
|
+
end
|
23
|
+
|
24
|
+
task :check_warnings do
|
25
|
+
$VERBOSE = true
|
26
|
+
require 'citeproc/ruby'
|
27
|
+
|
28
|
+
puts CiteProc::Ruby::VERSION
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
34
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'cucumber/rake/task'
|
38
|
+
Cucumber::Rake::Task.new(:cucumber) do |t|
|
39
|
+
t.profile = 'default'
|
40
|
+
end
|
41
|
+
|
42
|
+
require 'coveralls/rake/task'
|
43
|
+
Coveralls::RakeTask.new
|
44
|
+
task :test_with_coveralls => [:spec, :cucumber, 'coveralls:push']
|
45
|
+
|
46
|
+
task :release do |t|
|
47
|
+
system "gem build citeproc-ruby.gemspec"
|
48
|
+
system "git tag #{CiteProc::Ruby::VERSION}"
|
49
|
+
system "git push --tags"
|
50
|
+
system "gem push citeproc-ruby-#{CiteProc::Ruby::VERSION}.gem"
|
51
|
+
end
|
52
|
+
|
53
|
+
task :default => [:spec, :cucumber]
|
54
|
+
|
55
|
+
begin
|
56
|
+
require 'yard'
|
57
|
+
YARD::Rake::YardocTask.new
|
58
|
+
rescue LoadError => e
|
59
|
+
# ignore
|
60
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'citeproc/ruby/version'
|
6
|
+
|
7
|
+
EXCLUDES = %w{
|
8
|
+
.coveralls.yml
|
9
|
+
.gitignore
|
10
|
+
.travis.yml
|
11
|
+
citeproc-ruby.gemspec
|
12
|
+
}
|
13
|
+
|
14
|
+
Gem::Specification.new do |s|
|
15
|
+
s.name = 'citeproc-ruby'
|
16
|
+
s.version = CiteProc::Ruby::VERSION.dup
|
17
|
+
s.platform = Gem::Platform::RUBY
|
18
|
+
|
19
|
+
s.authors = ['Sylvester Keil']
|
20
|
+
s.email = ['http://sylvester.keil.or.at']
|
21
|
+
|
22
|
+
s.homepage = 'https://github.com/inukshuk/citeproc-ruby'
|
23
|
+
s.summary = 'A Citation Style Language (CSL) cite processor'
|
24
|
+
s.description =
|
25
|
+
"""
|
26
|
+
CiteProc-Ruby is a Citation Style Language (CSL) 1.0.1 compatible cite
|
27
|
+
processor implementation written in pure Ruby.
|
28
|
+
""".gsub(/^\s+/, '')
|
29
|
+
|
30
|
+
s.license = 'AGPL'
|
31
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
32
|
+
|
33
|
+
s.required_ruby_version = '>= 1.9.3'
|
34
|
+
|
35
|
+
s.add_dependency 'citeproc', '~> 1.0'
|
36
|
+
s.add_dependency 'csl', '~> 1.2'
|
37
|
+
|
38
|
+
s.files = `git ls-files`.split("\n")
|
39
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
40
|
+
s.executables = []
|
41
|
+
s.require_path = 'lib'
|
42
|
+
|
43
|
+
s.has_rdoc = 'yard'
|
44
|
+
end
|
45
|
+
|
46
|
+
# vim: syntax=ruby
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format progress --require features --color
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Rendering bibliography nodes
|
2
|
+
As a hacker of cite processors
|
3
|
+
I want to render citation items
|
4
|
+
Using bibliography nodes
|
5
|
+
|
6
|
+
Scenario: Rendering APA style bibliographies as text
|
7
|
+
Given the "apa" style's bibliography node
|
8
|
+
When I render the following citation items as "text":
|
9
|
+
| type | author | title | issued | publisher | container-title | page | issue |
|
10
|
+
| book | Thomas Pynchon | The crying of lot 49 | November 7, 2006 | Harper Perennial | | | |
|
11
|
+
| article-journal | Derrida, Jacques | The purveyor of truth | 1975 | Yale University Press | Yale French Studies | 31-113 | 52 |
|
12
|
+
Then the results should be:
|
13
|
+
| Pynchon, T. (2006). The crying of lot 49. Harper Perennial. |
|
14
|
+
| Derrida, J. (1975). The purveyor of truth. Yale French Studies, (52), 31–113. |
|
15
|
+
|
16
|
+
Scenario: Rendering APA style bibliographies as HTML
|
17
|
+
Given the "apa" style's bibliography node
|
18
|
+
When I render the following citation item as "html":
|
19
|
+
| type | book |
|
20
|
+
| author | Vladimir Nabokov |
|
21
|
+
| title | Pale fire |
|
22
|
+
| issued | April 23, 1989 |
|
23
|
+
| publisher | Vintage |
|
24
|
+
| publisher-place | London |
|
25
|
+
Then the result should be: Nabokov, V. (1989). <i>Pale fire</i>. London: Vintage.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Feature: Inheritance of Name Options
|
2
|
+
As a style author
|
3
|
+
I want name nodes to inherit attributes
|
4
|
+
From the citation/bibliography and style nodes
|
5
|
+
|
6
|
+
Scenario: Name options from bibliography node
|
7
|
+
Given the following style node:
|
8
|
+
"""
|
9
|
+
<bibliography name-form="short">
|
10
|
+
<layout>
|
11
|
+
<names variable="author">
|
12
|
+
<name />
|
13
|
+
</names>
|
14
|
+
</layout>
|
15
|
+
</bibliography>
|
16
|
+
"""
|
17
|
+
When I render the following citation items as "html":
|
18
|
+
| author |
|
19
|
+
| John Doe |
|
20
|
+
Then the results should be:
|
21
|
+
| Doe |
|
22
|
+
|
23
|
+
Given the following style node:
|
24
|
+
"""
|
25
|
+
<bibliography name-form="short">
|
26
|
+
<layout>
|
27
|
+
<names variable="author"/>
|
28
|
+
<!--it works without a name node-->
|
29
|
+
</layout>
|
30
|
+
</bibliography>
|
31
|
+
"""
|
32
|
+
When I render the following citation items as "html":
|
33
|
+
| author |
|
34
|
+
| John Doe |
|
35
|
+
Then the results should be:
|
36
|
+
| Doe |
|
37
|
+
|
@@ -0,0 +1,192 @@
|
|
1
|
+
Feature: CSL Name Rendering
|
2
|
+
As a CSL hacker
|
3
|
+
I want to render names
|
4
|
+
Using names nodes
|
5
|
+
|
6
|
+
Scenario: Names Rendering
|
7
|
+
Given the following style node:
|
8
|
+
"""
|
9
|
+
<names variable="translator" delimiter=", " prefix="(" suffix=")">
|
10
|
+
<name and="symbol" delimiter=", "/>
|
11
|
+
<label form="short" prefix=", " text-case="capitalize-first" suffix=""/>
|
12
|
+
</names>
|
13
|
+
"""
|
14
|
+
When I render the following citation items as "text":
|
15
|
+
| translator |
|
16
|
+
| Romy Schneider and Peter Sellers |
|
17
|
+
Then the results should be:
|
18
|
+
| (Romy Schneider & Peter Sellers, Trans.) |
|
19
|
+
|
20
|
+
|
21
|
+
Scenario: Initials
|
22
|
+
Given the following style node:
|
23
|
+
"""
|
24
|
+
<names variable="translator author" delimiter=", " prefix="(" suffix=")">
|
25
|
+
<name and="symbol" delimiter=", " initialize-with=". "/>
|
26
|
+
<label form="short" prefix=", " text-case="capitalize-first" suffix=""/>
|
27
|
+
</names>
|
28
|
+
"""
|
29
|
+
When I render the following citation items as "text":
|
30
|
+
| translator | author |
|
31
|
+
| Romy Schneider and Peter Sellers | |
|
32
|
+
Then the results should be:
|
33
|
+
| (R. Schneider & P. Sellers, Trans.) |
|
34
|
+
|
35
|
+
Scenario: Initials when given part is uppercased
|
36
|
+
Given the following style node:
|
37
|
+
"""
|
38
|
+
<names variable="author" suffix=".">
|
39
|
+
<name name-as-sort-order="all" sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="always">
|
40
|
+
<name-part name="family" text-case="uppercase"/>
|
41
|
+
<name-part name="given" text-case="uppercase"/>
|
42
|
+
</name>
|
43
|
+
<et-al prefix=" " font-style="italic"/>
|
44
|
+
<label form="short" prefix=" (" suffix=".)" text-case="uppercase"/>
|
45
|
+
</names>
|
46
|
+
"""
|
47
|
+
When I render the following citation items as "html":
|
48
|
+
| author |
|
49
|
+
| Cole, Steven J. and Moore, Robert |
|
50
|
+
Then the results should be:
|
51
|
+
| COLE, S. J.; MOORE, R. |
|
52
|
+
|
53
|
+
|
54
|
+
Scenario: Name as sort order
|
55
|
+
Given the following style node:
|
56
|
+
"""
|
57
|
+
<names variable="author">
|
58
|
+
<name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
|
59
|
+
</names>
|
60
|
+
"""
|
61
|
+
When I render the following citation items as "html":
|
62
|
+
| author |
|
63
|
+
| John Doe |
|
64
|
+
| John Doe and Jane Doe |
|
65
|
+
Then the results should be:
|
66
|
+
| Doe, John |
|
67
|
+
| Doe, John, and Jane Doe |
|
68
|
+
|
69
|
+
|
70
|
+
Scenario: Substitutions
|
71
|
+
Given the following style node:
|
72
|
+
"""
|
73
|
+
<names variable="author">
|
74
|
+
<name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
|
75
|
+
<substitute>
|
76
|
+
<names variable="editor"/>
|
77
|
+
<text value="UNKNOWN"/>
|
78
|
+
</substitute>
|
79
|
+
</names>
|
80
|
+
"""
|
81
|
+
When I render the following citation items as "html":
|
82
|
+
| editor |
|
83
|
+
| John Doe |
|
84
|
+
| |
|
85
|
+
| John Doe and Jane Doe |
|
86
|
+
Then the results should be:
|
87
|
+
| Doe, John |
|
88
|
+
| UNKNOWN |
|
89
|
+
| Doe, John, and Jane Doe |
|
90
|
+
|
91
|
+
Scenario: Suppression after substitutions
|
92
|
+
Given the following style node:
|
93
|
+
"""
|
94
|
+
<group delimiter=", ">
|
95
|
+
<names variable="author">
|
96
|
+
<name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
|
97
|
+
<substitute>
|
98
|
+
<names variable="editor"/>
|
99
|
+
<text variable="title"/>
|
100
|
+
</substitute>
|
101
|
+
</names>
|
102
|
+
<names variable="editor">
|
103
|
+
<label prefix=" (" suffix=")"/>
|
104
|
+
</names>
|
105
|
+
<text variable="title" text-case="uppercase"/>
|
106
|
+
</group>
|
107
|
+
"""
|
108
|
+
When I render the following citation items as "html":
|
109
|
+
| editor | author | title |
|
110
|
+
| John Doe | Jane Doe | The Title |
|
111
|
+
| John Doe | | The Title |
|
112
|
+
| | | The Title |
|
113
|
+
Then the results should be:
|
114
|
+
| Doe, Jane, John Doe (editor), THE TITLE |
|
115
|
+
| Doe, John, THE TITLE |
|
116
|
+
| The Title |
|
117
|
+
|
118
|
+
Scenario: Subsequent author substitutes complete-all with different roles
|
119
|
+
Given the following style node:
|
120
|
+
"""
|
121
|
+
<bibliography subsequent-author-substitute="---">
|
122
|
+
<layout>
|
123
|
+
<group delimiter=" ">
|
124
|
+
<names variable="author" delimiter=", " suffix=".">
|
125
|
+
<name name-as-sort-order="first"/>
|
126
|
+
<substitute>
|
127
|
+
<names variable="editor">
|
128
|
+
<name name-as-sort-order="first"/>
|
129
|
+
<label form="short" prefix=" " suffix="."/>
|
130
|
+
</names>
|
131
|
+
</substitute>
|
132
|
+
</names>
|
133
|
+
<text variable="title" suffix="."/>
|
134
|
+
</group>
|
135
|
+
</layout>
|
136
|
+
</bibliography>
|
137
|
+
"""
|
138
|
+
When I render the following citation items as "text":
|
139
|
+
| editor | author | title |
|
140
|
+
| | Jane Doe | Title A |
|
141
|
+
| | Jane Doe | Title B |
|
142
|
+
| | John Doe | Title C |
|
143
|
+
| John Doe | | Title D |
|
144
|
+
| | Jane Doe and John Doe | Title E |
|
145
|
+
| | Jane Doe and John Doe | Title F |
|
146
|
+
Then the results should be:
|
147
|
+
| Doe, Jane. Title A. |
|
148
|
+
| ---. Title B. |
|
149
|
+
| Doe, John. Title C. |
|
150
|
+
| --- ed. Title D. |
|
151
|
+
| Doe, Jane, John Doe. Title E. |
|
152
|
+
| ---. Title F. |
|
153
|
+
|
154
|
+
Scenario: Name / Label Order
|
155
|
+
Given the following style node:
|
156
|
+
"""
|
157
|
+
<group delimiter=". ">
|
158
|
+
<names variable="author" delimiter=". ">
|
159
|
+
<name and="symbol" delimiter=", "/>
|
160
|
+
<label prefix=" (" suffix=")"/>
|
161
|
+
</names>
|
162
|
+
<names variable="translator" delimiter=". ">
|
163
|
+
<label form="verb-short" text-case="capitalize-first" suffix=" "/>
|
164
|
+
<name and="symbol" delimiter=", "/>
|
165
|
+
</names>
|
166
|
+
</group>
|
167
|
+
"""
|
168
|
+
When I render the following citation items as "text":
|
169
|
+
| translator | author |
|
170
|
+
| John Doe | Jane Doe |
|
171
|
+
| John Doe and Jack Doe | Jane Doe and Jill Doe |
|
172
|
+
Then the results should be:
|
173
|
+
| Jane Doe (author). Trans. John Doe |
|
174
|
+
| Jane Doe & Jill Doe (authors). Trans. John Doe & Jack Doe |
|
175
|
+
|
176
|
+
Scenario: EtAlUseFirst options
|
177
|
+
Given the following style node:
|
178
|
+
"""
|
179
|
+
<group delimiter=" // ">
|
180
|
+
<names variable="author">
|
181
|
+
<name et-al-min="2" et-al-use-first="0"/>
|
182
|
+
</names>
|
183
|
+
<names variable="author">
|
184
|
+
<name et-al-min="2" et-al-use-first="1"/>
|
185
|
+
</names>
|
186
|
+
</group>
|
187
|
+
"""
|
188
|
+
When I render the following citation item as "text":
|
189
|
+
| author | John Doe and Jane Roe |
|
190
|
+
Then the result should be: John Doe et al.
|
191
|
+
|
192
|
+
|