csl 1.0.0.pre1 → 1.0.0.pre2

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.
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  module CSL
4
4
  describe 'Schema' do
5
5
 
6
+ it 'cannot be instantiated' do
7
+ Schema.should_not respond_to(:new)
8
+ end
9
+
6
10
  describe '.version' do
7
11
  it 'returns a version string' do
8
12
  Schema.version.should match(/^\d+\.\d+\.\d+/)
@@ -54,10 +58,8 @@ module CSL
54
58
 
55
59
  describe '.categories' do
56
60
  it 'given a field name returns the corresponding type' do
57
- Schema.categories[:author].should == :names
58
- Schema.categories[:issued].should == :date
59
- Schema.categories[:abstract].should == :text
60
- Schema.categories[:issue].should == :number
61
+ Schema.categories.values_at(:author, :issued, :abstract, :issue).should ==
62
+ [:names, :date, :text, :number]
61
63
  end
62
64
 
63
65
  it 'accepts either string or symbol input' do
@@ -66,5 +68,36 @@ module CSL
66
68
  end
67
69
  end
68
70
 
71
+ describe '.validate' do
72
+ it 'accepts and validates a locale instance' do
73
+ Schema.validate(Locale.load('en-US')).should == []
74
+ end
75
+
76
+ it 'accepts and validates a locale file path' do
77
+ Schema.validate(File.join(Locale.root, 'locales-en-US.xml')).should == []
78
+ end
79
+
80
+ it 'accepts and validates a locale file' do
81
+ Schema.validate(File.open(File.join(Locale.root, 'locales-en-US.xml'))).should == []
82
+ end
83
+
84
+ it 'accepts and validates a locale wildcard path' do
85
+ Schema.validate(File.join(Locale.root, 'locales-en-*.xml')).should == []
86
+ end
87
+
88
+ it 'accepts and validates a style file path' do
89
+ Schema.validate(File.join(Style.root, 'apa.csl')).should == []
90
+ end
91
+
92
+ it 'accepts and validates the xml contents of a style instance' do
93
+ Schema.validate(Style.load(:apa).pretty_print).should == []
94
+ end
95
+
96
+ it 'accepts and validates a style instance' do
97
+ Schema.validate(Style.load(:apa)).should == []
98
+ end
99
+
100
+ end
101
+
69
102
  end
70
103
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module CSL
4
- describe Style::Conditional do
4
+ describe Style::Choose do
5
5
 
6
6
  end
7
7
  end
@@ -3,8 +3,6 @@ require 'spec_helper'
3
3
  module CSL
4
4
  describe Style do
5
5
 
6
- it { should be }
7
-
8
6
  it 'has a 1.x version by default' do
9
7
  Style.new[:version].should match(/1\.\d+(\.\d+)?/)
10
8
  end
@@ -13,6 +11,10 @@ module CSL
13
11
  it 'returns an empty style' do
14
12
  Style.new.to_xml.should match(/<style[^>]*\/>/)
15
13
  end
14
+
15
+ it 'supports round-trip for apa style' do
16
+ Style.parse(Style.load(:apa).to_xml).should be_a(Style)
17
+ end
16
18
  end
17
19
 
18
20
  end
@@ -5,11 +5,11 @@ rescue LoadError
5
5
  # ignore
6
6
  end
7
7
 
8
- require 'csl'
9
-
10
8
  require 'rexml/document'
11
9
  require 'nokogiri'
12
10
 
11
+ require 'csl'
12
+
13
13
  module SilentWarnings
14
14
  require 'stringio'
15
15
  #
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <div>
4
+ <a:documentation>Categories for style metadata</a:documentation>
5
+ <define name="category.citation-format">
6
+ <choice>
7
+ <value>author</value>
8
+ <value>author-date</value>
9
+ <value>label</value>
10
+ <value>note</value>
11
+ <value>numeric</value>
12
+ </choice>
13
+ </define>
14
+ <define name="category.field">
15
+ <a:documentation>Use "generic-base" for styles that are non-discipline specific, such as
16
+ APA, Harvard, etc.</a:documentation>
17
+ <choice>
18
+ <value>anthropology</value>
19
+ <value>astronomy</value>
20
+ <value>biology</value>
21
+ <value>botany</value>
22
+ <value>chemistry</value>
23
+ <value>communications</value>
24
+ <value>engineering</value>
25
+ <value>generic-base</value>
26
+ <value>geography</value>
27
+ <value>geology</value>
28
+ <value>history</value>
29
+ <value>humanities</value>
30
+ <value>law</value>
31
+ <value>linguistics</value>
32
+ <value>literature</value>
33
+ <value>math</value>
34
+ <value>medicine</value>
35
+ <value>philosophy</value>
36
+ <value>physics</value>
37
+ <value>political_science</value>
38
+ <value>psychology</value>
39
+ <value>science</value>
40
+ <value>social_science</value>
41
+ <value>sociology</value>
42
+ <value>theology</value>
43
+ <value>zoology</value>
44
+ </choice>
45
+ </define>
46
+ </div>
47
+ </grammar>
@@ -0,0 +1,144 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <div>
4
+ <a:documentation>Terms</a:documentation>
5
+ <define name="terms">
6
+ <choice>
7
+ <ref name="category.field"/>
8
+ <ref name="terms.gender-assignable"/>
9
+ <ref name="terms.gender-variants"/>
10
+ <ref name="terms.locator"/>
11
+ <ref name="variables.names">
12
+ <a:documentation>Contributor roles</a:documentation>
13
+ </ref>
14
+ <value>editortranslator</value>
15
+ <value>accessed</value>
16
+ <a:documentation>Miscellaneous terms</a:documentation>
17
+ <value>ad</value>
18
+ <value>and</value>
19
+ <value>and others</value>
20
+ <value>anonymous</value>
21
+ <value>at</value>
22
+ <value>available at</value>
23
+ <value>bc</value>
24
+ <value>by</value>
25
+ <value>circa</value>
26
+ <value>cited</value>
27
+ <value>et-al</value>
28
+ <value>forthcoming</value>
29
+ <value>from</value>
30
+ <value>ibid</value>
31
+ <value>in</value>
32
+ <value>in press</value>
33
+ <value>internet</value>
34
+ <value>interview</value>
35
+ <value>letter</value>
36
+ <value>no date</value>
37
+ <value>online</value>
38
+ <value>presented at</value>
39
+ <value>reference</value>
40
+ <value>retrieved</value>
41
+ <value>scale</value>
42
+ <value>open-quote</value>
43
+ <a:documentation>Punctuation</a:documentation>
44
+ <value>close-quote</value>
45
+ <value>open-inner-quote</value>
46
+ <value>close-inner-quote</value>
47
+ <value>page-range-delimiter</value>
48
+ <value>season-01</value>
49
+ <a:documentation>Seasons</a:documentation>
50
+ <value>season-02</value>
51
+ <value>season-03</value>
52
+ <value>season-04</value>
53
+ </choice>
54
+ </define>
55
+ <define name="terms.gender-assignable">
56
+ <a:documentation>Terms to which a gender may be assigned</a:documentation>
57
+ <choice>
58
+ <value>month-01</value>
59
+ <a:documentation>Months</a:documentation>
60
+ <value>month-02</value>
61
+ <value>month-03</value>
62
+ <value>month-04</value>
63
+ <value>month-05</value>
64
+ <value>month-06</value>
65
+ <value>month-07</value>
66
+ <value>month-08</value>
67
+ <value>month-09</value>
68
+ <value>month-10</value>
69
+ <value>month-11</value>
70
+ <value>month-12</value>
71
+ <ref name="terms.non-locator-number-variables"/>
72
+ <ref name="terms.locator-number-variables"/>
73
+ </choice>
74
+ </define>
75
+ <define name="terms.gender-variants">
76
+ <a:documentation>Terms for which gender variants may be specified</a:documentation>
77
+ <choice>
78
+ <value>ordinal-01</value>
79
+ <a:documentation>Ordinals</a:documentation>
80
+ <value>ordinal-02</value>
81
+ <value>ordinal-03</value>
82
+ <value>ordinal-04</value>
83
+ <value>long-ordinal-01</value>
84
+ <a:documentation>Long ordinals</a:documentation>
85
+ <value>long-ordinal-02</value>
86
+ <value>long-ordinal-03</value>
87
+ <value>long-ordinal-04</value>
88
+ <value>long-ordinal-05</value>
89
+ <value>long-ordinal-06</value>
90
+ <value>long-ordinal-07</value>
91
+ <value>long-ordinal-08</value>
92
+ <value>long-ordinal-09</value>
93
+ <value>long-ordinal-10</value>
94
+ </choice>
95
+ </define>
96
+ <define name="terms.locator">
97
+ <a:documentation>Locators</a:documentation>
98
+ <choice>
99
+ <ref name="terms.locator.testable"/>
100
+ <value>sub verbo</value>
101
+ <a:documentation>"sub verbo" is recognized as "sub" &amp; "verbo" in attribute lists; term
102
+ should be renamed to "sub-verbo"</a:documentation>
103
+ </choice>
104
+ </define>
105
+ <define name="terms.locator.testable">
106
+ <a:documentation>Locator terms that can be tested with the "locator" conditional
107
+ ("sub verbo" can be tested with "sub-verbo")</a:documentation>
108
+ <choice>
109
+ <value>book</value>
110
+ <value>chapter</value>
111
+ <value>column</value>
112
+ <value>figure</value>
113
+ <value>folio</value>
114
+ <value>line</value>
115
+ <value>note</value>
116
+ <value>opus</value>
117
+ <value>page</value>
118
+ <value>paragraph</value>
119
+ <value>part</value>
120
+ <value>section</value>
121
+ <value>verse</value>
122
+ <ref name="terms.locator-number-variables"/>
123
+ </choice>
124
+ </define>
125
+ <define name="terms.locator-number-variables">
126
+ <a:documentation>Locator terms with matching number variables</a:documentation>
127
+ <choice>
128
+ <value>issue</value>
129
+ <value>volume</value>
130
+ </choice>
131
+ </define>
132
+ <define name="terms.non-locator-number-variables">
133
+ <a:documentation>Non-locator terms accompanying number variables</a:documentation>
134
+ <choice>
135
+ <value>chapter-number</value>
136
+ <value>collection-number</value>
137
+ <value>edition</value>
138
+ <value>number</value>
139
+ <value>number-of-pages</value>
140
+ <value>number-of-volumes</value>
141
+ </choice>
142
+ </define>
143
+ </div>
144
+ </grammar>
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <div>
4
+ <a:documentation>Item types</a:documentation>
5
+ <define name="item-types">
6
+ <choice>
7
+ <value>article</value>
8
+ <value>article-journal</value>
9
+ <value>article-magazine</value>
10
+ <value>article-newspaper</value>
11
+ <value>bill</value>
12
+ <value>book</value>
13
+ <value>broadcast</value>
14
+ <value>chapter</value>
15
+ <value>dataset</value>
16
+ <value>entry</value>
17
+ <value>entry-dictionary</value>
18
+ <value>entry-encyclopedia</value>
19
+ <value>figure</value>
20
+ <value>graphic</value>
21
+ <value>interview</value>
22
+ <value>legal_case</value>
23
+ <value>legislation</value>
24
+ <value>manuscript</value>
25
+ <value>map</value>
26
+ <value>motion_picture</value>
27
+ <value>musical_score</value>
28
+ <value>pamphlet</value>
29
+ <value>paper-conference</value>
30
+ <value>patent</value>
31
+ <value>personal_communication</value>
32
+ <value>post</value>
33
+ <value>post-weblog</value>
34
+ <value>report</value>
35
+ <value>review</value>
36
+ <value>review-book</value>
37
+ <value>song</value>
38
+ <value>speech</value>
39
+ <value>thesis</value>
40
+ <value>treaty</value>
41
+ <value>webpage</value>
42
+ </choice>
43
+ </define>
44
+ </div>
45
+ </grammar>
@@ -0,0 +1,114 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <div>
4
+ <a:documentation>Variables</a:documentation>
5
+ <define name="variables">
6
+ <a:documentation>All variables</a:documentation>
7
+ <choice>
8
+ <ref name="variables.dates"/>
9
+ <ref name="variables.names"/>
10
+ <ref name="variables.numbers"/>
11
+ <ref name="variables.strings"/>
12
+ </choice>
13
+ </define>
14
+ <define name="variables.standard">
15
+ <a:documentation>Standard variables</a:documentation>
16
+ <choice>
17
+ <ref name="variables.numbers"/>
18
+ <ref name="variables.strings"/>
19
+ </choice>
20
+ </define>
21
+ <define name="variables.dates">
22
+ <a:documentation>Date variables</a:documentation>
23
+ <choice>
24
+ <value>accessed</value>
25
+ <value>container</value>
26
+ <value>event-date</value>
27
+ <value>issued</value>
28
+ <value>original-date</value>
29
+ <value>submitted</value>
30
+ </choice>
31
+ </define>
32
+ <define name="variables.names">
33
+ <a:documentation>Name variables</a:documentation>
34
+ <choice>
35
+ <value>author</value>
36
+ <value>collection-editor</value>
37
+ <value>composer</value>
38
+ <value>container-author</value>
39
+ <value>director</value>
40
+ <value>editor</value>
41
+ <value>editorial-director</value>
42
+ <value>illustrator</value>
43
+ <value>interviewer</value>
44
+ <value>original-author</value>
45
+ <value>recipient</value>
46
+ <value>reviewed-author</value>
47
+ <value>translator</value>
48
+ </choice>
49
+ </define>
50
+ <define name="variables.numbers">
51
+ <a:documentation>Number variables</a:documentation>
52
+ <choice>
53
+ <value>chapter-number</value>
54
+ <value>collection-number</value>
55
+ <value>edition</value>
56
+ <value>issue</value>
57
+ <value>number</value>
58
+ <value>number-of-pages</value>
59
+ <value>number-of-volumes</value>
60
+ <value>volume</value>
61
+ </choice>
62
+ </define>
63
+ <define name="variables.strings">
64
+ <a:documentation>String variables</a:documentation>
65
+ <choice>
66
+ <value>abstract</value>
67
+ <value>annote</value>
68
+ <value>archive</value>
69
+ <value>archive_location</value>
70
+ <value>archive-place</value>
71
+ <value>authority</value>
72
+ <value>call-number</value>
73
+ <value>citation-label</value>
74
+ <value>citation-number</value>
75
+ <value>collection-title</value>
76
+ <value>container-title</value>
77
+ <value>container-title-short</value>
78
+ <value>dimensions</value>
79
+ <value>DOI</value>
80
+ <value>event</value>
81
+ <value>event-place</value>
82
+ <value>first-reference-note-number</value>
83
+ <value>genre</value>
84
+ <value>ISBN</value>
85
+ <value>ISSN</value>
86
+ <value>jurisdiction</value>
87
+ <value>keyword</value>
88
+ <value>locator</value>
89
+ <value>medium</value>
90
+ <value>note</value>
91
+ <value>original-publisher</value>
92
+ <value>original-publisher-place</value>
93
+ <value>original-title</value>
94
+ <value>page</value>
95
+ <value>page-first</value>
96
+ <value>PMID</value>
97
+ <value>PMCID</value>
98
+ <value>publisher</value>
99
+ <value>publisher-place</value>
100
+ <value>references</value>
101
+ <value>reviewed-title</value>
102
+ <value>scale</value>
103
+ <value>section</value>
104
+ <value>source</value>
105
+ <value>status</value>
106
+ <value>title</value>
107
+ <value>title-short</value>
108
+ <value>URL</value>
109
+ <value>version</value>
110
+ <value>year-suffix</value>
111
+ </choice>
112
+ </define>
113
+ </div>
114
+ </grammar>