citeproc-ruby 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a49591a9c8da3f7b39735dafb3f856f8b1d2dc9
4
- data.tar.gz: 484c4cb981f1f20d7db2eb0e17eb6e6e1716c107
3
+ metadata.gz: 2433b5b1f4dd36a3d56c7faf79dd6052699b98ec
4
+ data.tar.gz: 7b10890a22be22daa7592c8ce3eff268f9988f38
5
5
  SHA512:
6
- metadata.gz: 1a976cd92d8adcaf507f9dad08877476c3662cdac64ca79ce5ed598ab6841a7a673477003479277c16b639c5891c9d623862ccdec3c7cf66fb9b7d5611147fc7
7
- data.tar.gz: 8568d601396504c8b6fe8ab3b11e5b4caca5cdabe720e43c62f2776b8430edd775374d58256937693da324f9e594e64daeb49ffcfa7d474ca46cfca1df21c024
6
+ metadata.gz: 13ecf2f3659e060df54a32acd0aa0518fb2fc21e724a12938bb6988687457a43e3d4af249a5ef4a5784af38f50e56771aa4fe5fc7474b09f7e94cfa8e10800b6
7
+ data.tar.gz: 961189fe7024379256a8480f0db3aa1acb42bf9cd0b0bc772d2d2972591edb5b289a8fad6a6ed0f36d53aed2dc5850f16ead12d0abe7ca1bad800393a699584f
data/README.md CHANGED
@@ -10,6 +10,113 @@ cite processor, please refer to the documentation of the
10
10
  [![Coverage Status](https://coveralls.io/repos/inukshuk/citeproc-ruby/badge.png?branch=master)](https://coveralls.io/r/inukshuk/citeproc-ruby?branch=master)
11
11
  [![Dependency Status](https://gemnasium.com/inukshuk/citeproc-ruby.png)](https://gemnasium.com/inukshuk/citeproc-ruby)
12
12
 
13
+ Quickstart
14
+ ----------
15
+ Install CiteProc-Ruby and all official CSL styles (optional).
16
+
17
+ $ [sudo] gem install citeproc-ruby
18
+ $ [sudo] gem install csl-styles
19
+
20
+ Start rendering you references with any CSL style!
21
+
22
+ require 'citeproc'
23
+ require 'csl/styles'
24
+
25
+ # Create a new processor with the desired style,
26
+ # format, and locale.
27
+ cp = CiteProc::Processor.new style: 'apa', format: 'text'
28
+
29
+ # To see what styles are available in your current
30
+ # environment, run `CSL::Style.ls'; this also works for
31
+ # locales as `CSL::Locale.ls'.
32
+
33
+ # Tell the processor where to find your references. In this
34
+ # example we load them from a BibTeX bibliography using the
35
+ # bibtex-ruby gem.
36
+ cp.import BibTeX.open('./references.bib').to_citeproc
37
+
38
+ # Now you are ready for rendering; the processor API
39
+ # provides three main rendering methods: `process',
40
+ # `append', or `bibliography'.
41
+
42
+ # For simple one-off renditions, you can also call
43
+ # `render' in bibliography or citation mode:
44
+ cp.render :bibliography, id: 'knuth'
45
+
46
+ # This will return a rendered reference, like:
47
+ #-> Knuth, D. (1968). The art of computer programming. Boston: Addison-Wesley.
48
+
49
+ # CiteProc-Ruby exposes a full CSL API to you; this
50
+ # makes it possible to just alter CSL styles on the
51
+ # fly. For example, what if we want names not to be
52
+ # initialized even though APA style is configured to
53
+ # do so? We could change the CSL style itself, but
54
+ # we can also make a quick adjustment at runtime:
55
+ name = cp.engine.style.macros['author'] > 'names' > 'name'
56
+
57
+ # What just happened? We selected the current style's
58
+ # 'author' macro and then descended to the CSL name
59
+ # node via its parent names node. Now we can change
60
+ # this name node and the cite processor output will
61
+ # pick-up the changes right away:
62
+ name[:initialize] = 'false'
63
+
64
+ cp.render :bibliography, id: 'knuth'
65
+ #-> Knuth, Donald. (1968). The art of computer programming (Vol. 1). Boston: Addison-Wesley.
66
+
67
+ # Note that we have picked 'text' as the output format;
68
+ # if we want to make us of richer output formats we
69
+ # can switch to HTML instead:
70
+ cp.engine.format = 'html'
71
+
72
+ cp.render :bibliography, id: 'knuth'
73
+ #-> Knuth, Donald. (1968). <i>The art of computer programming</i> (Vol. 1). Boston: Addison-Wesley.
74
+
75
+ # You can also render citations on the fly.
76
+ cp.render :citation, id: 'knuth', locator: '23'
77
+ #-> (Knuth, 1968, p. 23)
78
+
79
+ Documentation
80
+ -------------
81
+ * [CiteProc Documentation](http://rubydoc.info/gems/citeproc/)
82
+ * [CiteProc-Ruby API Documentation](http://rubydoc.info/gems/citeproc-ruby/)
83
+ * [CSL-Ruby API Documentation](http://rubydoc.info/gems/csl/)
84
+
85
+ Optional Dependencies
86
+ ---------------------
87
+ CiteProc-Ruby tries to minimize hard dependencies for increased compatibility.
88
+ You can speed up the XML parsing by installing
89
+ [Nokogiri](https://rubygems.org/gems/nokogiri); otherwise the REXML from the
90
+ Ruby standard library will be used.
91
+
92
+ Similarly, you can install either of the gems
93
+ [EDTF](https://rubygems.org/gems/edtf) or
94
+ [Chronic](https://rubygems.org/gems/chronic) to support a wide range of
95
+ additional inputs for date variables.
96
+
97
+ CSL Styles and Locales
98
+ ----------------------
99
+ You can load CSL styles and locales by passing a respective XML string, file
100
+ name, or URL. You can also load styles and locales by name if the
101
+ corresponding files are installed in your local styles and locale directories.
102
+ By default, CSL-Ruby looks for CSL styles and locale files in
103
+
104
+ /usr/local/share/csl/styles
105
+ /usr/local/share/csl/locales
106
+
107
+ You can change these locations by changing the value of `CSL::Style.root` and
108
+ `CSL::Locale.root` respectively.
109
+
110
+ Alternatively, you can `gem install csl-styles` to install all official CSL
111
+ styles and locales. To make the styles and locales available, simply
112
+ `require 'csl/styles`.
113
+
114
+ Compatibility
115
+ -------------
116
+ The cite processor and the CSL API libraries have been developed for MRI,
117
+ Rubinius, and JRuby. Please note that we try to support only Ruby versions
118
+ 1.9.3 and upwards.
119
+
13
120
  Development
14
121
  -----------
15
122
  The CiteProc-Ruby source code is
@@ -22,10 +22,10 @@ module CiteProc
22
22
  text = item.data.variable(node.variable, node.variable_options).to_s
23
23
 
24
24
  # Check for abbreviations or short-form fallbacks!
25
- context, was_short_form = node.variable.split(/-short/, 2)
25
+ context, was_short_form = node.variable.split(/-short$/, 2)
26
26
 
27
- if was_short_form || node[:form] == 'short'
28
- if text.empty?
27
+ if !was_short_form.nil? || node[:form] == 'short'
28
+ if text.empty? && context != node.variable
29
29
  text = item.data.variable(context, node.variable_options).to_s
30
30
  end
31
31
 
@@ -1,5 +1,5 @@
1
1
  module CiteProc
2
2
  module Ruby
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -58,7 +58,7 @@ module CiteProc
58
58
  describe 'when the form attribute is set to :short' do
59
59
  before(:each) {
60
60
  item.data.title = 'the full title'
61
- node[:form] = :short
61
+ node[:form] = 'short'
62
62
  }
63
63
 
64
64
  it "prefers the short version if available" do
@@ -69,6 +69,11 @@ module CiteProc
69
69
  it "falls back to the variable if unavailable" do
70
70
  renderer.render_text(item, node).should == 'the full title'
71
71
  end
72
+
73
+ it "falls back to the long form if the short form variable is not present" do
74
+ node[:variable] = 'title-short'
75
+ renderer.render_text(item, node).should == 'the full title'
76
+ end
72
77
  end
73
78
  end
74
79
 
data/spec/spec_helper.rb CHANGED
@@ -16,9 +16,9 @@ end
16
16
 
17
17
  begin
18
18
  case
19
- when RUBY_PLATFORM < 'java'
20
- require 'debug'
21
- Debugger.start
19
+ when RUBY_PLATFORM == 'java'
20
+ # require 'debug'
21
+ # Debugger.start
22
22
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
23
23
  require 'rubinius/debugger'
24
24
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citeproc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: citeproc
@@ -47,12 +47,9 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
- - .coveralls.yml
51
50
  - .document
52
- - .gitignore
53
51
  - .rspec
54
52
  - .simplecov
55
- - .travis.yml
56
53
  - .yardopts
57
54
  - AGPL
58
55
  - BSDL
@@ -60,7 +57,6 @@ files:
60
57
  - Guardfile
61
58
  - README.md
62
59
  - Rakefile
63
- - citeproc-ruby.gemspec
64
60
  - cucumber.yml
65
61
  - features/bibliography.feature
66
62
  - features/name_options.feature
@@ -131,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
127
  version: '0'
132
128
  requirements: []
133
129
  rubyforge_project:
134
- rubygems_version: 2.0.14
130
+ rubygems_version: 2.2.2
135
131
  signing_key:
136
132
  specification_version: 4
137
133
  summary: A Citation Style Language (CSL) cite processor
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- Gemfile.lock
2
- .DS_Store
3
- doc
4
- .yardoc
5
- .rbx
6
- *.rbc
7
- coverage
8
- .bundle
9
- .ruby-version
10
- *.swp
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
- bundler_args: --without debug extra
3
- script: bundle exec rake test_with_coveralls
4
- rvm:
5
- - 2.1.0
6
- - 2.0.0
7
- - 1.9.3
8
- - jruby-19mode
9
- # - jruby-head
10
- - rbx
11
- - rbx-2.2.3
12
- notifications:
13
- email:
14
- recipients:
15
- - sylvester@keil.or.at
16
- on_success: change
17
- on_failure: always
@@ -1,46 +0,0 @@
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