csl 1.5.0 → 2.0.0

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
- SHA1:
3
- metadata.gz: 3891b313aec0cbbfec56bbcecd6fd874097197ce
4
- data.tar.gz: a39948e8a466db44d15805ba18c0213582b49725
2
+ SHA256:
3
+ metadata.gz: c9def0950732e2af79808e712e972c454f49c18b8e71f31dcae1917a61d67b65
4
+ data.tar.gz: 996804a7e5e66aaad59f0679039b6a56b88d408f90a1b0414e6f32741ef0cf26
5
5
  SHA512:
6
- metadata.gz: d0f086551f952a7e7b06c1cbd0979d9316812a96a01cee97e142859bb2cf60b1f1980ab0f69e477b9f6bc0bb315b1aaaf80d160b2666bf64894f8b196f0c6e8c
7
- data.tar.gz: ca47300596bec6740d303d856e07e68b6742e724e6bde74b27a7183d0a8240fe14f711b68eae74c13b25010f13ed33510ba15ccea3c8f7a5ebc96d03e6bc1955
6
+ metadata.gz: f2e5824f038b51ce12dc80cb4bab54d59f2adea043ecf7614fb000742e518f67c082cc09e1f44f0b76ffc52ad24c2f5410c7c866e944ea491b1dd66c599da657
7
+ data.tar.gz: e51bdbd453bbe73c78fce162643a41c4c61697bb3f443dcdf08f7bea8a8fbea28e89cf5d3bfa07876dab1e188dfe5c010d9cff407dcedc8157c1e8af64f12ed9
@@ -0,0 +1,26 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+ branches:
8
+ - master
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ BUNDLE_WITHOUT: debug:extra
14
+ strategy:
15
+ matrix:
16
+ ruby-version:
17
+ - 3.0
18
+ - 2.7
19
+ - 2.6
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+ bundler-cache: true
26
+ - run: bundle exec rake
data/BSDL CHANGED
@@ -1,7 +1,7 @@
1
1
  CSL-Ruby. A Ruby CSL parser and library.
2
2
 
3
3
  Copyright 2012 President and Fellows of Harvard College.
4
- Copyright 2009-2014 Sylvester Keil. All rights reserved.
4
+ Copyright 2009-2020 Sylvester Keil. All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without
7
7
  modification, are permitted provided that the following conditions are met:
data/Gemfile CHANGED
@@ -24,7 +24,6 @@ group :extra do
24
24
  end
25
25
 
26
26
  group :coverage do
27
- gem 'coveralls', require: false if ENV['CI']
28
27
  gem 'simplecov', require: false
29
28
  end
30
29
 
data/README.md CHANGED
@@ -4,10 +4,6 @@ CSL-Ruby provides a Ruby parser and a comprehensive API for the
4
4
  [Citation Style Language](http://citationstyles.org) (CSL), an XML-based
5
5
  format to describe the formatting of citations, notes and bibliographies.
6
6
 
7
- [![Build Status](https://secure.travis-ci.org/inukshuk/csl-ruby.png)](http://travis-ci.org/inukshuk/csl-ruby)
8
- [![Coverage Status](https://coveralls.io/repos/inukshuk/csl-ruby/badge.png?branch=master)](https://coveralls.io/r/inukshuk/csl-ruby?branch=master)
9
- [![Dependency Status](https://gemnasium.com/inukshuk/csl-ruby.png)](https://gemnasium.com/inukshuk/csl-ruby)
10
-
11
7
  Styles and Locales
12
8
  ------------------
13
9
  You can load CSL styles and locales by passing a respective XML string, file
@@ -139,7 +135,7 @@ this project as part of [Google Summer of Code](https://developers.google.com/op
139
135
 
140
136
  Copyright
141
137
  ---------
142
- Copyright 2009-2015 Sylvester Keil. All rights reserved.
138
+ Copyright 2009-2020 Sylvester Keil. All rights reserved.
143
139
 
144
140
  Copyright 2012 President and Fellows of Harvard College.
145
141
 
data/Rakefile CHANGED
@@ -34,14 +34,6 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
34
34
  t.profile = 'default'
35
35
  end
36
36
 
37
- begin
38
- require 'coveralls/rake/task'
39
- Coveralls::RakeTask.new
40
- task :test_with_coveralls => [:spec, :cucumber, 'coveralls:push']
41
- rescue LoadError => e
42
- # ignore
43
- end if ENV['CI']
44
-
45
37
  task :release do |t|
46
38
  system "gem build csl.gemspec"
47
39
  system "git tag #{CSL::VERSION}"
data/csl.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.authors = ['Sylvester Keil']
20
20
  s.email = ['http://sylvester.keil.or.at']
21
21
  s.homepage = 'https://github.com/inukshuk/csl-ruby'
22
- s.license = 'AGPL-3.0'
22
+ s.licenses = ['AGPL-3.0','BSD-2-Clause']
23
23
  s.date = Time.now.strftime('%Y-%m-%d')
24
24
  s.summary = 'A Ruby CSL parser and library'
25
25
  s.description = <<~EOS
@@ -30,11 +30,11 @@ Gem::Specification.new do |s|
30
30
 
31
31
 
32
32
  s.required_ruby_version = '>= 2.2'
33
- s.add_dependency('namae', ['~>1.0'])
33
+ s.add_runtime_dependency('namae', ['~>1.0'])
34
+ s.add_runtime_dependency('rexml')
34
35
 
35
36
  s.files = `git ls-files`.split("\n") - EXCLUDES
36
37
  s.require_path = 'lib'
37
- s.has_rdoc = 'yard'
38
38
  end
39
39
 
40
40
  # vim: syntax=ruby
data/cucumber.yml CHANGED
@@ -1 +1 @@
1
- default: --format progress --require features --color
1
+ default: --format progress --require features --color --publish-quiet
data/lib/csl/locale.rb CHANGED
@@ -330,9 +330,9 @@ module CSL
330
330
  #
331
331
  # Calls block once for each term defined by the locale. If no block is
332
332
  # given, an enumerator is returned instead.
333
- def each_term
333
+ def each_term(&block)
334
334
  if block_given?
335
- terms.each(&Proc.new)
335
+ terms.each(&block)
336
336
  self
337
337
  else
338
338
  enum_for :each_term
@@ -345,12 +345,12 @@ module CSL
345
345
  #
346
346
  # Calls block once for each date format defined by the locale. If no
347
347
  # block is given, an enumerator is returned instead.
348
- def each_date
348
+ def each_date(&block)
349
349
  if block_given?
350
350
  if date.is_a? CSL::Node
351
351
  yield date
352
352
  else
353
- date.each(&Proc.new)
353
+ date.each(&block)
354
354
  end
355
355
  else
356
356
  enum_for :each_date
data/lib/csl/node.rb CHANGED
@@ -268,9 +268,9 @@ module CSL
268
268
  alias has_defaults? has_default_attributes?
269
269
 
270
270
  # Iterates through the Node's attributes
271
- def each
271
+ def each(&block)
272
272
  if block_given?
273
- attributes.each_pair(&Proc.new)
273
+ attributes.each_pair(&block)
274
274
  self
275
275
  else
276
276
  to_enum
data/lib/csl/schema.rb CHANGED
@@ -2,46 +2,172 @@ module CSL
2
2
 
3
3
  class Schema
4
4
 
5
- @version = '1.0.1'.freeze
5
+ @version = '1.0.2'.freeze
6
6
  @major_version = '1.0'.freeze
7
7
 
8
8
  @namespace = 'http://purl.org/net/xbiblio/csl'.freeze
9
9
  @preamble = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".freeze
10
10
 
11
- @default_license = 'http://creativecommons.org/licenses/by-sa/3.0/'
11
+ @default_license = 'https://creativecommons.org/licenses/by-sa/4.0/'
12
12
  @default_rights_string =
13
- 'This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License'
14
-
15
- @types = %w{ article article-journal article-magazine article-newspaper
16
- bill book broadcast chapter entry entry-dictionary entry-encyclopedia
17
- figure graphic interview legal_case legislation manuscript map
18
- motion_picture musical_score pamphlet paper-conference patent
19
- personal_communication post post-weblog report review review-book song
20
- speech thesis treaty webpage }.map(&:to_sym).freeze
13
+ 'This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.'
14
+
15
+ @types = %w{
16
+ article
17
+ article-journal
18
+ article-magazine
19
+ article-newspaper
20
+ bill
21
+ book
22
+ broadcast
23
+ chapter
24
+ classic
25
+ collection
26
+ dataset
27
+ document
28
+ entry
29
+ entry-dictionary
30
+ entry-encyclopedia
31
+ event
32
+ figure
33
+ graphic
34
+ hearing
35
+ interview
36
+ legal_case
37
+ legislation
38
+ manuscript
39
+ map
40
+ motion_picture
41
+ musical_score
42
+ pamphlet
43
+ paper-conference
44
+ patent
45
+ performance
46
+ periodical
47
+ personal_communication
48
+ post
49
+ post-weblog
50
+ regulation
51
+ report
52
+ review
53
+ review-book
54
+ software
55
+ song
56
+ speech
57
+ standard
58
+ thesis
59
+ treaty
60
+ webpage
61
+ }.map(&:to_sym).freeze
21
62
 
22
63
  @variables = Hash.new { |h,k| h.fetch(k.to_sym, nil) }.merge({
23
64
  :date => %w{
24
- accessed container event-date issued original-date submitted
65
+ accessed
66
+ available-date
67
+ event-date
68
+ issued
69
+ original-date
70
+ submitted
25
71
  },
26
72
 
27
73
  :names => %w{
28
- author collection-editor composer container-author recipient editor
29
- editorial-director illustrator interviewer original-author translator
74
+ author
75
+ chair
76
+ collection-editor
77
+ compiler
78
+ composer
79
+ container-author
80
+ contributor
81
+ creator
82
+ curator
83
+ editor
84
+ editorial-director
85
+ executive-producer
86
+ guest
87
+ host
88
+ illustrator
89
+ interviewer
90
+ narrator
91
+ organizer
92
+ original-author
93
+ performer
94
+ producer
95
+ recipient
96
+ translator
97
+ writer
30
98
  },
31
99
 
32
100
  :number => %w{
33
- chapter-number collection-number edition issue number number-of-pages
34
- number-of-volumes volume
101
+ chapter-number
102
+ citation-number
103
+ collection-number
104
+ edition
105
+ first-reference-note-number
106
+ issue
107
+ locator
108
+ number
109
+ number-of-pages
110
+ number-of-volumes
111
+ page
112
+ page-first
113
+ part-number
114
+ printing-number
115
+ section
116
+ supplement-number
117
+ version
118
+ volume
35
119
  },
36
120
 
37
121
  :text => %w{
38
- abstract annote archive archive_location archive-place authority
39
- call-number citation-label citation-number collection-title
40
- container-title container-title-short dimensions DOI event event-place
41
- first-reference-note-number genre ISBN ISSN jurisdiction keyword
42
- locator medium note original-publisher original-publisher-place
43
- original-title page page-first PMID PMCID publisher publisher-place
44
- references section source status title title-short URL version
122
+ abstract
123
+ annote
124
+ archive
125
+ archive_collection
126
+ archive_location
127
+ archive-place
128
+ authority
129
+ call-number
130
+ citation-key
131
+ citation-label
132
+ collection-title
133
+ container-title
134
+ container-title-short
135
+ dimensions
136
+ division
137
+ DOI
138
+ event
139
+ event-place
140
+ event-title
141
+ genre
142
+ ISBN
143
+ ISSN
144
+ jurisdiction
145
+ keyword
146
+ language
147
+ license
148
+ medium
149
+ note
150
+ original-publisher
151
+ original-publisher-place
152
+ original-title
153
+ part
154
+ part-title
155
+ PMCID
156
+ PMID
157
+ printing
158
+ publisher
159
+ publisher-place
160
+ references
161
+ reviewed-genre
162
+ reviewed-title
163
+ scale
164
+ source
165
+ status
166
+ title
167
+ title-short
168
+ translated-title
169
+ URL
170
+ volume-title
45
171
  year-suffix
46
172
  }
47
173
  })
data/lib/csl/treelike.rb CHANGED
@@ -17,9 +17,9 @@ module CSL
17
17
  @nodename ||= self.class.name.split(/::/)[-1].gsub(/([[:lower:]])([[:upper:]])/, '\1-\2').downcase
18
18
  end
19
19
 
20
- def each_child
20
+ def each_child(&block)
21
21
  if block_given?
22
- children.each(&Proc.new)
22
+ children.each(&block)
23
23
  self
24
24
  else
25
25
  enum_for :each_child
@@ -167,11 +167,11 @@ module CSL
167
167
  end
168
168
 
169
169
  # Traverses the node's sub-tree in depth-first order.
170
- def each_descendant
170
+ def each_descendant(&block)
171
171
  if block_given?
172
172
  each_child do |child|
173
173
  yield child
174
- child.each_descendant(&Proc.new)
174
+ child.each_descendant(&block)
175
175
  end
176
176
 
177
177
  self
@@ -230,7 +230,11 @@ module CSL
230
230
  %w{ ancestors descendants siblings root depth }.each do |name|
231
231
  ivar = "@#{name}"
232
232
  define_method("#{name}!") do
233
- instance_variable_get(ivar) || send(name)
233
+ if instance_variable_defined?(ivar)
234
+ instance_variable_get(ivar)
235
+ else
236
+ send(name)
237
+ end
234
238
  end
235
239
  end
236
240
 
@@ -376,9 +380,9 @@ module CSL
376
380
 
377
381
  # Iterates through all children. Nil values are skipped and Arrays
378
382
  # expanded.
379
- def each
383
+ def each(&block)
380
384
  if block_given?
381
- order.each(&Proc.new)
385
+ order.each(&block)
382
386
  self
383
387
  else
384
388
  to_enum
data/lib/csl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CSL
2
- VERSION = '1.5.0'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
@@ -0,0 +1,130 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns:cs="http://purl.org/net/xbiblio/csl" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <div>
4
+ <a:documentation>cs:choose - Conditional Statements"</a:documentation>
5
+ <define name="rendering-element.choose">
6
+ <element name="cs:choose">
7
+ <a:documentation>Use to conditionally render rendering elements.</a:documentation>
8
+ <ref name="choose.if"/>
9
+ <zeroOrMore>
10
+ <ref name="choose.else-if"/>
11
+ </zeroOrMore>
12
+ <optional>
13
+ <ref name="choose.else"/>
14
+ </optional>
15
+ </element>
16
+ </define>
17
+ <define name="choose.if">
18
+ <element name="cs:if">
19
+ <oneOrMore>
20
+ <ref name="condition"/>
21
+ </oneOrMore>
22
+ <ref name="match"/>
23
+ <zeroOrMore>
24
+ <ref name="rendering-element"/>
25
+ </zeroOrMore>
26
+ </element>
27
+ </define>
28
+ <define name="choose.else-if">
29
+ <element name="cs:else-if">
30
+ <oneOrMore>
31
+ <ref name="condition"/>
32
+ </oneOrMore>
33
+ <ref name="match"/>
34
+ <zeroOrMore>
35
+ <ref name="rendering-element"/>
36
+ </zeroOrMore>
37
+ </element>
38
+ </define>
39
+ <define name="choose.else">
40
+ <element name="cs:else">
41
+ <oneOrMore>
42
+ <ref name="rendering-element"/>
43
+ </oneOrMore>
44
+ </element>
45
+ </define>
46
+ <define name="condition">
47
+ <choice>
48
+ <attribute name="disambiguate" a:defaultValue="true">
49
+ <a:documentation>If used, the element content is only rendered if it disambiguates two
50
+ otherwise identical citations. This attempt at disambiguation is only
51
+ made after all other disambiguation methods have failed.</a:documentation>
52
+ <value>true</value>
53
+ </attribute>
54
+ <attribute name="is-numeric">
55
+ <a:documentation>Tests whether the given variables contain numeric text.</a:documentation>
56
+ <list>
57
+ <oneOrMore>
58
+ <ref name="variables"/>
59
+ </oneOrMore>
60
+ </list>
61
+ </attribute>
62
+ <attribute name="is-uncertain-date">
63
+ <a:documentation>Tests whether the given date variables contain approximate dates.</a:documentation>
64
+ <list>
65
+ <oneOrMore>
66
+ <ref name="variables.dates"/>
67
+ </oneOrMore>
68
+ </list>
69
+ </attribute>
70
+ <attribute name="locator">
71
+ <a:documentation>Tests whether the locator matches the given locator types.</a:documentation>
72
+ <list>
73
+ <oneOrMore>
74
+ <ref name="terms.locator"/>
75
+ </oneOrMore>
76
+ </list>
77
+ </attribute>
78
+ <attribute name="position">
79
+ <a:documentation>Tests whether the cite position matches the given positions.</a:documentation>
80
+ <list>
81
+ <oneOrMore>
82
+ <choice>
83
+ <value>first</value>
84
+ <value>subsequent</value>
85
+ <value>ibid</value>
86
+ <value>ibid-with-locator</value>
87
+ <value>near-note</value>
88
+ </choice>
89
+ </oneOrMore>
90
+ </list>
91
+ </attribute>
92
+ <attribute name="type">
93
+ <a:documentation>Tests whether the item matches the given types.</a:documentation>
94
+ <list>
95
+ <oneOrMore>
96
+ <ref name="item-types"/>
97
+ </oneOrMore>
98
+ </list>
99
+ </attribute>
100
+ <attribute name="variable">
101
+ <a:documentation>Tests whether the default ("long") forms of the given variables
102
+ contain non-empty values.</a:documentation>
103
+ <list>
104
+ <oneOrMore>
105
+ <ref name="variables"/>
106
+ </oneOrMore>
107
+ </list>
108
+ </attribute>
109
+ </choice>
110
+ </define>
111
+ <define name="match">
112
+ <optional>
113
+ <attribute name="match" a:defaultValue="all">
114
+ <a:documentation>Set the testing logic.</a:documentation>
115
+ <choice>
116
+ <value>all</value>
117
+ <a:documentation>Element only tests "true" when all conditions test "true" for all
118
+ given test values.</a:documentation>
119
+ <value>any</value>
120
+ <a:documentation>Element tests "true" when any condition tests "true" for any given
121
+ test value.</a:documentation>
122
+ <value>none</value>
123
+ <a:documentation>Element only tests "true" when none of the conditions test "true"
124
+ for any given test value.</a:documentation>
125
+ </choice>
126
+ </attribute>
127
+ </optional>
128
+ </define>
129
+ </div>
130
+ </grammar>