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.
Files changed (186) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.document +4 -0
  4. data/.gitignore +10 -0
  5. data/.rspec +3 -0
  6. data/.simplecov +4 -0
  7. data/.travis.yml +17 -0
  8. data/.yardopts +2 -0
  9. data/AGPL +662 -0
  10. data/BSDL +29 -0
  11. data/Gemfile +42 -0
  12. data/Guardfile +14 -0
  13. data/README.md +32 -76
  14. data/Rakefile +60 -0
  15. data/citeproc-ruby.gemspec +46 -0
  16. data/cucumber.yml +1 -0
  17. data/features/bibliography.feature +25 -0
  18. data/features/name_options.feature +37 -0
  19. data/features/names.feature +192 -0
  20. data/features/renderer.feature +74 -0
  21. data/features/sort.feature +50 -0
  22. data/features/step_definitions/renderer.rb +80 -0
  23. data/features/support/env.rb +33 -0
  24. data/features/support/hooks.rb +10 -0
  25. data/lib/citeproc/ruby.rb +32 -0
  26. data/lib/citeproc/ruby/engine.rb +122 -0
  27. data/lib/citeproc/ruby/format.rb +303 -0
  28. data/lib/citeproc/ruby/formats/default.rb +25 -0
  29. data/lib/citeproc/ruby/formats/html.rb +221 -0
  30. data/lib/citeproc/ruby/renderer.rb +140 -0
  31. data/lib/citeproc/ruby/renderer/choose.rb +106 -0
  32. data/lib/citeproc/ruby/renderer/date.rb +90 -0
  33. data/lib/citeproc/ruby/renderer/format.rb +129 -0
  34. data/lib/citeproc/ruby/renderer/group.rb +34 -0
  35. data/lib/citeproc/ruby/renderer/history.rb +40 -0
  36. data/lib/citeproc/ruby/renderer/label.rb +66 -0
  37. data/lib/citeproc/ruby/renderer/layout.rb +20 -0
  38. data/lib/citeproc/ruby/renderer/locale.rb +26 -0
  39. data/lib/citeproc/ruby/renderer/macro.rb +20 -0
  40. data/lib/citeproc/ruby/renderer/names.rb +401 -0
  41. data/lib/citeproc/ruby/renderer/number.rb +41 -0
  42. data/lib/citeproc/ruby/renderer/observer.rb +44 -0
  43. data/lib/citeproc/ruby/renderer/state.rb +96 -0
  44. data/lib/citeproc/ruby/renderer/text.rb +62 -0
  45. data/lib/citeproc/ruby/sort.rb +82 -0
  46. data/lib/citeproc/ruby/version.rb +5 -0
  47. data/spec/citeproc/ruby/engine_spec.rb +94 -0
  48. data/spec/citeproc/ruby/formats/default_spec.rb +159 -0
  49. data/spec/citeproc/ruby/formats/html_spec.rb +162 -0
  50. data/spec/citeproc/ruby/renderer/choose_spec.rb +293 -0
  51. data/spec/citeproc/ruby/renderer/date_spec.rb +173 -0
  52. data/spec/citeproc/ruby/renderer/group_spec.rb +88 -0
  53. data/spec/citeproc/ruby/renderer/history_spec.rb +38 -0
  54. data/spec/citeproc/ruby/renderer/label_spec.rb +225 -0
  55. data/spec/citeproc/ruby/renderer/layout_spec.rb +41 -0
  56. data/spec/citeproc/ruby/renderer/macro_spec.rb +31 -0
  57. data/spec/citeproc/ruby/renderer/names_spec.rb +396 -0
  58. data/spec/citeproc/ruby/renderer/number_spec.rb +120 -0
  59. data/spec/citeproc/ruby/renderer/text_spec.rb +120 -0
  60. data/spec/citeproc/ruby/renderer_spec.rb +65 -0
  61. data/spec/fixtures/items.rb +80 -0
  62. data/{resource/locale → spec/fixtures/locales}/locales-en-US.xml +2 -11
  63. data/{resource/locale → spec/fixtures/locales}/locales-fr-FR.xml +77 -66
  64. data/{resource/style → spec/fixtures/styles}/apa.csl +5 -5
  65. data/spec/spec_helper.rb +67 -14
  66. metadata +121 -211
  67. data/lib/citeproc.rb +0 -100
  68. data/lib/citeproc/bibliography.rb +0 -57
  69. data/lib/citeproc/data.rb +0 -149
  70. data/lib/citeproc/date.rb +0 -133
  71. data/lib/citeproc/formatter.rb +0 -38
  72. data/lib/citeproc/item.rb +0 -53
  73. data/lib/citeproc/name.rb +0 -284
  74. data/lib/citeproc/processor.rb +0 -166
  75. data/lib/citeproc/selector.rb +0 -61
  76. data/lib/citeproc/variable.rb +0 -82
  77. data/lib/citeproc/version.rb +0 -3
  78. data/lib/csl/locale.rb +0 -223
  79. data/lib/csl/node.rb +0 -72
  80. data/lib/csl/nodes.rb +0 -1418
  81. data/lib/csl/renderer.rb +0 -88
  82. data/lib/csl/sort.rb +0 -61
  83. data/lib/csl/style.rb +0 -110
  84. data/lib/csl/term.rb +0 -124
  85. data/lib/extensions/core.rb +0 -43
  86. data/lib/plugins/filters/bibtex.rb +0 -12
  87. data/lib/plugins/formats/default.rb +0 -134
  88. data/lib/plugins/formats/html.rb +0 -67
  89. data/lib/support/attributes.rb +0 -99
  90. data/lib/support/compatibility.rb +0 -83
  91. data/lib/support/tree.rb +0 -80
  92. data/resource/locale/locales-af-ZA.xml +0 -305
  93. data/resource/locale/locales-ar-AR.xml +0 -306
  94. data/resource/locale/locales-bg-BG.xml +0 -305
  95. data/resource/locale/locales-ca-AD.xml +0 -305
  96. data/resource/locale/locales-cs-CZ.xml +0 -305
  97. data/resource/locale/locales-da-DK.xml +0 -305
  98. data/resource/locale/locales-de-AT.xml +0 -304
  99. data/resource/locale/locales-de-CH.xml +0 -304
  100. data/resource/locale/locales-de-DE.xml +0 -332
  101. data/resource/locale/locales-el-GR.xml +0 -305
  102. data/resource/locale/locales-en-GB.xml +0 -304
  103. data/resource/locale/locales-es-ES.xml +0 -305
  104. data/resource/locale/locales-et-EE.xml +0 -304
  105. data/resource/locale/locales-eu.xml +0 -305
  106. data/resource/locale/locales-fa-IR.xml +0 -304
  107. data/resource/locale/locales-fi-FI.xml +0 -304
  108. data/resource/locale/locales-fr-CA.xml +0 -306
  109. data/resource/locale/locales-he-IL.xml +0 -304
  110. data/resource/locale/locales-hu-HU.xml +0 -305
  111. data/resource/locale/locales-is-IS.xml +0 -304
  112. data/resource/locale/locales-it-IT.xml +0 -305
  113. data/resource/locale/locales-ja-JP.xml +0 -305
  114. data/resource/locale/locales-kh-KH.xml +0 -303
  115. data/resource/locale/locales-km-KH.xml +0 -304
  116. data/resource/locale/locales-ko-KR.xml +0 -305
  117. data/resource/locale/locales-mn-MN.xml +0 -306
  118. data/resource/locale/locales-nb-NO.xml +0 -304
  119. data/resource/locale/locales-nl-NL.xml +0 -304
  120. data/resource/locale/locales-nn-NO.xml +0 -304
  121. data/resource/locale/locales-pl-PL.xml +0 -305
  122. data/resource/locale/locales-pt-BR.xml +0 -304
  123. data/resource/locale/locales-pt-PT.xml +0 -305
  124. data/resource/locale/locales-ro-RO.xml +0 -305
  125. data/resource/locale/locales-ru-RU.xml +0 -306
  126. data/resource/locale/locales-sk-SK.xml +0 -304
  127. data/resource/locale/locales-sl-SI.xml +0 -305
  128. data/resource/locale/locales-sr-RS.xml +0 -305
  129. data/resource/locale/locales-sv-SE.xml +0 -305
  130. data/resource/locale/locales-th-TH.xml +0 -304
  131. data/resource/locale/locales-tr-TR.xml +0 -305
  132. data/resource/locale/locales-uk-UA.xml +0 -306
  133. data/resource/locale/locales-vi-VN.xml +0 -305
  134. data/resource/locale/locales-zh-CN.xml +0 -304
  135. data/resource/locale/locales-zh-TW.xml +0 -305
  136. data/resource/schema/csl-categories.rnc +0 -39
  137. data/resource/schema/csl-data.rnc +0 -98
  138. data/resource/schema/csl-terms.rnc +0 -106
  139. data/resource/schema/csl-types.rnc +0 -39
  140. data/resource/schema/csl-variables.rnc +0 -182
  141. data/resource/schema/csl.rnc +0 -941
  142. data/resource/style/bibtex.csl +0 -177
  143. data/resource/style/chicago-annotated-bibliography.csl +0 -513
  144. data/resource/style/chicago-author-date-basque.csl +0 -707
  145. data/resource/style/chicago-author-date-de.csl +0 -394
  146. data/resource/style/chicago-author-date-listing.csl +0 -434
  147. data/resource/style/chicago-author-date.csl +0 -425
  148. data/resource/style/chicago-dated-note-biblio-no-ibid.csl +0 -472
  149. data/resource/style/chicago-fullnote-bibliography-bb.csl +0 -928
  150. data/resource/style/chicago-fullnote-bibliography-delimiter-fixes.csl +0 -972
  151. data/resource/style/chicago-fullnote-bibliography-no-ibid-delimiter-fixes.csl +0 -963
  152. data/resource/style/chicago-fullnote-bibliography-no-ibid.csl +0 -785
  153. data/resource/style/chicago-fullnote-bibliography.csl +0 -803
  154. data/resource/style/chicago-library-list.csl +0 -511
  155. data/resource/style/chicago-note-biblio-no-ibid.csl +0 -514
  156. data/resource/style/chicago-note-bibliography.csl +0 -530
  157. data/resource/style/chicago-note.csl +0 -388
  158. data/resource/style/chicago-quick-copy.csl +0 -685
  159. data/resource/style/ieee.csl +0 -299
  160. data/resource/style/mla-notes.csl +0 -796
  161. data/resource/style/mla-underline.csl +0 -175
  162. data/resource/style/mla-url.csl +0 -214
  163. data/resource/style/mla.csl +0 -394
  164. data/resource/style/vancouver-brackets.csl +0 -256
  165. data/resource/style/vancouver-superscript-bracket-only-year.csl +0 -165
  166. data/resource/style/vancouver-superscript.csl +0 -256
  167. data/resource/style/vancouver.csl +0 -256
  168. data/spec/citeproc/bibliography_spec.rb +0 -45
  169. data/spec/citeproc/citeproc_spec.rb +0 -80
  170. data/spec/citeproc/date_spec.rb +0 -89
  171. data/spec/citeproc/formatter_spec.rb +0 -101
  172. data/spec/citeproc/item_spec.rb +0 -71
  173. data/spec/citeproc/name_spec.rb +0 -30
  174. data/spec/citeproc/processor_spec.rb +0 -61
  175. data/spec/citeproc/selector_spec.rb +0 -82
  176. data/spec/citeproc/variable_spec.rb +0 -69
  177. data/spec/csl/locale_spec.rb +0 -208
  178. data/spec/csl/node_spec.rb +0 -25
  179. data/spec/csl/nodes_spec.rb +0 -145
  180. data/spec/csl/style_spec.rb +0 -62
  181. data/spec/csl/term_spec.rb +0 -56
  182. data/spec/fixtures/dates.yaml +0 -80
  183. data/spec/fixtures/names.yaml +0 -115
  184. data/spec/fixtures/nodes.yaml +0 -245
  185. data/spec/support/attributes_spec.rb +0 -39
  186. data/spec/support/tree_spec.rb +0 -163
@@ -1,256 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" page-range-format="minimal">
3
- <info>
4
- <title>Vancouver</title>
5
- <id>http://www.zotero.org/styles/vancouver</id>
6
- <link href="http://www.zotero.org/styles/vancouver" rel="self"/>
7
- <author>
8
- <name>Michael Berkowitz</name>
9
- <email>mberkowi@gmu.edu</email>
10
- </author>
11
- <contributor>
12
- <name>Sean Takats</name>
13
- <email>stakats@gmu.edu</email>
14
- </contributor>
15
- <contributor>
16
- <name>Sebastian Karcher</name>
17
- </contributor>
18
- <category field="medicine"/>
19
- <category citation-format="numeric"/>
20
- <updated>2008-09-16T00:00:00+00:00</updated>
21
- <summary>
22
- Vancouver style as outlined by International Committee of Medical Journal Editors Uniform Requirements for Manuscripts Submitted to Biomedical Journals: Sample References
23
- </summary>
24
- <link href="http://www.nlm.nih.gov/bsd/uniform_requirements.html" rel="documentation"/>
25
- <rights>This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/</rights>
26
- </info>
27
- <locale xml:lang="en">
28
- <terms>
29
- <term name="retrieved">available</term>
30
- <term name="section" form="short">sect.</term>
31
- </terms>
32
- </locale>
33
- <locale xml:lang="de">
34
- <terms>
35
- <term name="retrieved">verfügbar</term>
36
- <term name="from">unter</term>
37
- </terms>
38
- </locale>
39
- <macro name="author">
40
- <names variable="author">
41
- <name sort-separator=" " initialize-with="" name-as-sort-order="all" delimiter=", " delimiter-precedes-last="always"/>
42
- <label form="long" prefix=", "/>
43
- <substitute>
44
- <names variable="editor"/>
45
- </substitute>
46
- </names>
47
- </macro>
48
- <macro name="editor">
49
- <group delimiter=": ">
50
- <choose>
51
- <if type="chapter paper-conference">
52
- <text term="in" text-case="capitalize-first"/>
53
- </if>
54
- </choose>
55
- <names variable="editor" suffix=".">
56
- <name sort-separator=" " initialize-with="" name-as-sort-order="all" delimiter=", " delimiter-precedes-last="always"/>
57
- <label form="long" prefix=", "/>
58
- </names>
59
- </group>
60
- </macro>
61
- <macro name="publisher">
62
- <group delimiter=": " suffix=";">
63
- <choose>
64
- <if type="thesis">
65
- <text variable="publisher-place" prefix="[" suffix="]"/>
66
- </if>
67
- <else>
68
- <text variable="publisher-place"/>
69
- </else>
70
- </choose>
71
- <text variable="publisher"/>
72
- </group>
73
- </macro>
74
- <macro name="access">
75
- <choose>
76
- <if variable="URL">
77
- <group delimiter=": ">
78
- <group delimiter=" ">
79
- <text term="retrieved" text-case="capitalize-first"/>
80
- <text term="from"/>
81
- </group>
82
- <text variable="URL"/>
83
- </group>
84
- </if>
85
- </choose>
86
- </macro>
87
- <macro name="accessed-date">
88
- <choose>
89
- <if variable="URL">
90
- <group prefix="[" suffix="]" delimiter=" ">
91
- <text term="cited" text-case="lowercase"/>
92
- <date variable="accessed" suffix="">
93
- <date-part name="year"/>
94
- <date-part name="month" prefix=" " form="short" strip-periods="true"/>
95
- <date-part name="day" prefix=" "/>
96
- </date>
97
- </group>
98
- </if>
99
- </choose>
100
- </macro>
101
- <macro name="container-title">
102
- <choose>
103
- <if type="article-journal article-magazine chapter paper-conference article-newspaper" match="any">
104
- <group suffix="." delimiter=" ">
105
- <text variable="container-title" form="short"/>
106
- <choose>
107
- <if variable="URL">
108
- <text term="internet" prefix="[" suffix="]" text-case="capitalize-first"/>
109
- </if>
110
- </choose>
111
- </group>
112
- <text macro="edition" prefix=" "/>
113
- </if>
114
- <!--add event-name and event-place once they become available-->
115
- <else-if type="bill legislation">
116
- <group delimiter=", ">
117
- <group delimiter=". ">
118
- <text variable="container-title" form="short"/>
119
- <group delimiter=" ">
120
- <text term="section" form="short" text-case="capitalize-first"/>
121
- <text variable="section"/>
122
- </group>
123
- </group>
124
- <text variable="number"/>
125
- </group>
126
- </else-if>
127
- <else>
128
- <text variable="container-title" suffix="." form="short"/>
129
- </else>
130
- </choose>
131
- </macro>
132
- <macro name="title">
133
- <text variable="title"/>
134
- <choose>
135
- <if type="article-journal article-magazine chapter paper-conference article-newspaper" match="none">
136
- <choose>
137
- <if variable="URL">
138
- <text term="internet" prefix=" [" suffix="]" text-case="capitalize-first"/>
139
- </if>
140
- </choose>
141
- <text macro="edition" prefix=". "/>
142
- </if>
143
- </choose>
144
- <choose>
145
- <if type="thesis">
146
- <text variable="genre" prefix=" [" suffix="]"/>
147
- </if>
148
- </choose>
149
- </macro>
150
- <macro name="edition">
151
- <choose>
152
- <if is-numeric="edition">
153
- <group delimiter=" ">
154
- <number variable="edition" form="ordinal"/>
155
- <text term="edition" form="short"/>
156
- </group>
157
- </if>
158
- <else>
159
- <text variable="edition" suffix="."/>
160
- </else>
161
- </choose>
162
- </macro>
163
- <macro name="date">
164
- <choose>
165
- <if type="article-journal article-magazine article-newspaper" match="any">
166
- <group suffix=";" delimiter=" ">
167
- <date variable="issued" delimiter=" ">
168
- <date-part name="year"/>
169
- <date-part name="month" form="short" strip-periods="true"/>
170
- <date-part name="day"/>
171
- </date>
172
- <text macro="accessed-date"/>
173
- </group>
174
- </if>
175
- <else-if type="bill legislation">
176
- <group delimiter=", ">
177
- <date variable="issued" delimiter=" ">
178
- <date-part name="month" form="short" strip-periods="true"/>
179
- <date-part name="day"/>
180
- </date>
181
- <date variable="issued">
182
- <date-part name="year"/>
183
- </date>
184
- </group>
185
- </else-if>
186
- <else-if type="report">
187
- <date variable="issued" delimiter=" ">
188
- <date-part name="year"/>
189
- <date-part name="month" form="short" strip-periods="true"/>
190
- </date>
191
- </else-if>
192
- <else>
193
- <group suffix=".">
194
- <date variable="issued">
195
- <date-part name="year"/>
196
- </date>
197
- <text macro="accessed-date" prefix=" "/>
198
- </group>
199
- </else>
200
- </choose>
201
- </macro>
202
- <macro name="pages">
203
- <choose>
204
- <if type="article-journal article-magazine article-newspaper" match="any">
205
- <text variable="page" prefix=":"/>
206
- </if>
207
- <else>
208
- <text variable="page" prefix=" p. "/>
209
- </else>
210
- </choose>
211
- </macro>
212
- <macro name="journal-location">
213
- <choose>
214
- <if type="article-journal article-magazine" match="any">
215
- <text variable="volume"/>
216
- <text variable="issue" prefix="(" suffix=")"/>
217
- </if>
218
- </choose>
219
- </macro>
220
- <macro name="report-details">
221
- <choose>
222
- <if type="report">
223
- <text variable="number" prefix="Report No.: "/>
224
- </if>
225
- </choose>
226
- </macro>
227
- <citation collapse="citation-number">
228
- <sort>
229
- <key variable="citation-number"/>
230
- </sort>
231
- <layout prefix="(" suffix=")" delimiter=",">
232
- <text variable="citation-number"/>
233
- </layout>
234
- </citation>
235
- <bibliography et-al-min="7" et-al-use-first="6" second-field-align="flush">
236
- <layout>
237
- <text variable="citation-number" suffix=". "/>
238
- <group delimiter=". " suffix=". ">
239
- <text macro="author"/>
240
- <text macro="title"/>
241
- </group>
242
- <group delimiter=" " suffix=". ">
243
- <text macro="editor"/>
244
- <text macro="container-title"/>
245
- <text macro="publisher"/>
246
- <group>
247
- <text macro="date"/>
248
- <text macro="journal-location"/>
249
- <text macro="pages"/>
250
- </group>
251
- </group>
252
- <text macro="report-details" suffix=". "/>
253
- <text macro="access"/>
254
- </layout>
255
- </bibliography>
256
- </style>
@@ -1,45 +0,0 @@
1
- module CiteProc
2
- describe Bibliography do
3
-
4
- let(:json) {'[{"test":"test","bibliography-errors":[]},["1","2"]]'}
5
-
6
- describe '#new' do
7
- it { should_not be_nil }
8
-
9
- it 'accepts a JSON string' do
10
- Bibliography.new(json).should_not be_empty
11
- end
12
-
13
- it 'accepts a data array' do
14
- Bibliography.new([1,2,3]).data.should == [1,2,3]
15
- end
16
-
17
- it 'accepts an options hash' do
18
- Bibliography.new('test'=>'test').options['test'].should == 'test'
19
- end
20
-
21
- it 'accepts an options hash with errors' do
22
- Bibliography.new('bibliography-errors'=>[1,2,3]).errors.should == [1,2,3]
23
- end
24
- end
25
-
26
- describe '#to_json' do
27
- it 'returns valid JSON when empty' do
28
- JSON.parse(Bibliography.new.to_json).should_not be_nil
29
- end
30
- it 'returns valid JSON with data' do
31
- JSON.parse(Bibliography.new([1,2,3]).to_json).should_not be_nil
32
- end
33
- it 'returns valid JSON with options' do
34
- JSON.parse(Bibliography.new({'test'=>'test'}).to_json).should_not be_nil
35
- end
36
- it 'returns valid JSON with options and data' do
37
- JSON.parse(Bibliography.new([{'test'=>'test'}, [1,2]]).to_json).should_not be_nil
38
- end
39
- it 'supports round-trips' do
40
- Bibliography.new(json).to_json.should == json
41
- end
42
- end
43
-
44
- end
45
- end
@@ -1,80 +0,0 @@
1
- #
2
- # This generates RSpec tests from the JSON test cases of the citeproc-tests
3
- # suite.
4
- #
5
-
6
-
7
- #
8
- # Filter applied to each test to decide whether we should run it. Use this
9
- # to stay sane while the Processor is not feature-complete!
10
- #
11
- def filter(file, fixture)
12
- # return ['affix_InterveningEmpty.json'].include?(File.basename(file))
13
- # File.basename(file) =~ /bugreports_greek/i
14
- # File.basename(file) =~ /sort_stripmark/i
15
- # return File.basename(file) =~ /^date_rawparsesimpledate/i
16
- true
17
- end
18
-
19
- module CiteProc
20
-
21
- describe 'citeproc' do
22
-
23
- let(:proc) { Processor.new }
24
-
25
- Test::Fixtures::Processor.each_pair do |file, fixture|
26
-
27
- tokens = File.basename(file).split(/_|\.json/)
28
-
29
- describe tokens[0].downcase do
30
-
31
- name = tokens[1].gsub(/([[:lower:]])([[:upper:]])/, '\1 \2').downcase
32
-
33
- it name do
34
- pending if tokens[0] =~ /^(position|disambiguate|integration|flipflop|collapse|parallel)/
35
-
36
- proc.style = fixture['csl']
37
- proc.import(fixture['input'])
38
- proc.format = :html
39
-
40
- if tokens[1] =~ /LocalizedDateFormats-([\w-]+)/
41
- proc.locale = $1
42
- end
43
-
44
- proc.add_abbreviations(fixture['abbreviations']) if fixture['abbreviations']
45
-
46
- case fixture['mode']
47
-
48
- when 'citation'
49
- # citations => process_citation_cluster
50
- # citation_items || :all => make_citation_cluster
51
- data = fixture['citation_items']
52
-
53
- unless data
54
- result = proc.cite((fixture['bibentries'] && fixture['bibentries'].last) || :all).map { |d| d[1] }.join
55
- else
56
- result = data.map { |d| proc.cite(d).map { |c| c[1] }.join }.join("\n")
57
- end
58
-
59
- when 'bibliography'
60
- result = proc.bibliography(fixture['bibsection'] || :all).to_s
61
-
62
- when 'bibliography-header'
63
- pending('not yet implemented')
64
-
65
- when 'bibliography-nosort'
66
- pending('not yet implemented')
67
-
68
- else
69
- CiteProc.log.warn "unkown processor mode: #{fixture['mode']}"
70
- pending('not yet implemented')
71
- end
72
-
73
- result.should == fixture['result']
74
-
75
- end
76
- end if filter(file, fixture)
77
-
78
- end
79
- end
80
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module CiteProc
4
-
5
- describe Date do
6
-
7
- describe '#new' do
8
- it { should_not be_nil }
9
-
10
- it 'accepts date-parts containing a single year' do
11
- Date.new('date-parts' => [[1998]]).year.should == 1998
12
- end
13
-
14
- end
15
-
16
- describe '.create' do
17
- it 'accepts parameters and returns a new instance' do
18
- Date.create('date-parts' => [[2001, 1]]).year.should == 2001
19
- end
20
- end
21
-
22
- describe '#sort' do
23
-
24
- let(:ad2k) { Date.create('date-parts' => [[2000]])}
25
- let(:may) { Date.create('date-parts' => [[2000, 5]])}
26
- let(:first_of_may) { Date.create('date-parts' => [[2000, 5, 1]])}
27
-
28
- let(:bc100) { Date.create('date-parts' => [[-100]]) }
29
- let(:bc50) { Date.create('date-parts' => [[-50]]) }
30
- let(:ad50) { Date.create('date-parts' => [[50]]) }
31
- let(:ad100) { Date.create('date-parts' => [[100]]) }
32
-
33
- it 'dates with more date-parts will come after those with fewer parts' do
34
- (ad2k < may && may < first_of_may).should be true
35
- end
36
-
37
- it 'negative years are sorted inversely' do
38
- [ad50, bc100, bc50, ad100].sort.map(&:year).should == [-100, -50, 50, 100]
39
- end
40
- end
41
-
42
- Test::Fixtures::Dates.keys.each do |feature|
43
- describe feature do
44
- Test::Fixtures::Dates[feature].each do |example|
45
-
46
- it example['it'] do
47
- dates = example['dates'].map { |date| Date.new(date) }
48
- expected = example['expected']
49
- options = example['options']
50
-
51
- result = case feature
52
- when 'display'
53
- dates.map { |date| date.display(options) }
54
- when 'json-api'
55
- dates.map(&:to_json)
56
- end
57
-
58
- result.should == expected
59
- end
60
-
61
- end
62
- end
63
- end
64
-
65
- describe 'literal dates' do
66
-
67
- it 'is not literal by default' do
68
- Date.new.should_not be_literal
69
- end
70
-
71
- it 'is literal if it contains only a literal field' do
72
- Date.create(:literal => 'foo').should be_literal
73
- end
74
-
75
- it 'is literal if it contains a literal field' do
76
- Date.create('date-parts' => [[2000]], :literal => 'foo').should be_literal
77
- end
78
- end
79
-
80
- describe 'uncertain dates' do
81
- it 'are uncertain' do
82
- Date.new({ 'date-parts' => [[-225]], 'circa' => '1' }).should be_uncertain
83
- Date.new { |d| d.parts = [[-225]]; d.circa = true }.should be_uncertain
84
- end
85
- end
86
-
87
- end
88
-
89
- end