csl 1.0.0.pre21 → 1.0.0.pre22

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,12 @@ module CSL
12
12
  end
13
13
  end
14
14
 
15
+ describe '.specialize' do
16
+ it 'filters the passed in hash to contain only match-able entries' do
17
+ Locale::Term.specialize({ :form => 'short', :foo => 'bar' }).should == { :form => 'short' }
18
+ end
19
+ end
20
+
15
21
  describe '#ordinalize' do
16
22
 
17
23
  describe "given standard English terms" do
@@ -17,12 +17,20 @@ module CSL
17
17
  describe 'when the node has a single condition' do
18
18
  let(:node) { Choose::Block.new(:'is-numeric' => 'edition' )}
19
19
 
20
- it 'returns an array with an array containing the type and value of the condition' do
21
- node.conditions.should == [[:'is-numeric', 'edition']]
20
+ it 'returns an array with an array containing the type, matcher and values of the condition' do
21
+ node.conditions.should == [[:'is-numeric', :all?, ['edition']]]
22
+ end
23
+
24
+ describe 'when the condition has multiple values' do
25
+ before { node[:'is-numeric'] << ' issue' }
26
+
27
+ it 'it splits the values in the conditions list' do
28
+ node.conditions.should == [[:'is-numeric', :all?, ['edition', 'issue']]]
29
+ end
22
30
  end
23
31
 
24
32
  describe 'when the node has two conditions' do
25
- before(:each) { node[:disambiguate] = 'true' }
33
+ before { node[:disambiguate] = 'true' }
26
34
 
27
35
  it 'returns an array with two elements' do
28
36
  node.conditions.should have_exactly(2).items
@@ -30,16 +38,24 @@ module CSL
30
38
 
31
39
  it 'returns both conditions as arrays' do
32
40
  node.conditions.map(&:first).sort.should == [:disambiguate, :'is-numeric']
33
- node.conditions.map(&:last).sort.should == ['edition', 'true']
41
+ node.conditions.map(&:last).sort.should == [['edition'], ['true']]
34
42
  end
35
43
  end
36
44
  end
37
45
 
38
- describe 'when the node has a single condition with multiple values' do
39
- let(:node) { Choose::Block.new(:variable => 'author editor' )}
46
+ describe 'when the node has a condition with a match override' do
47
+ let(:node) { Choose::Block.new(:'variable-any' => 'author editor' )}
40
48
 
41
- it 'expands the conditions in the result' do
42
- node.conditions.should == [[:variable, 'author'], [:variable, 'editor']]
49
+ it 'strips the match override from the type name and inserts it as the matcher' do
50
+ node.conditions.should == [[:variable, :any?, ['author', 'editor']]]
51
+ end
52
+
53
+ describe 'other conditions' do
54
+ before { node[:position] = 'false' }
55
+
56
+ it 'are not affected by the override' do
57
+ node.conditions.map { |c| c[1].to_s }.sort.should == %w{ all? any? }
58
+ end
43
59
  end
44
60
  end
45
61
  end
@@ -8,7 +8,7 @@ module CSL
8
8
  it { should_not be_never_pluralize }
9
9
 
10
10
  describe '.terms' do
11
- Hash[%w{
11
+ Hash[*%w{
12
12
  page page
13
13
  issue issue
14
14
  edition edition
@@ -17,7 +17,7 @@ module CSL
17
17
  chapter-number chapter
18
18
  }].each do |variable, term|
19
19
  it "returns #{term.inspect} for #{variable.inspect}" do
20
- Label.terms[variable].should == term
20
+ Style::Label.terms[variable].should == term
21
21
  end
22
22
  end
23
23
  end
@@ -26,19 +26,6 @@ module CSL
26
26
  before(:each) { Style::Names.new << subject }
27
27
 
28
28
  it { should be_names_label }
29
-
30
- describe '#variable' do
31
- before(:each) { subject.parent[:variable] = 'editor' }
32
-
33
- it 'returns the names variable(s)' do
34
- subject.variable.should == 'editor'
35
- end
36
-
37
- it 'returns the names variable(s) even when the local attribute is set' do
38
- subject[:variable] = 'page'
39
- subject.variable.should == 'editor'
40
- end
41
- end
42
29
  end
43
30
 
44
31
  describe '#term' do
@@ -2,15 +2,30 @@ require 'spec_helper'
2
2
 
3
3
  module CSL
4
4
  describe Style do
5
- let(:style) { Style.new }
5
+ before do
6
+ @style = Style.new
7
+ end
6
8
 
7
9
  it 'has a 1.x version by default' do
8
- Style.new[:version].should match(/1\.\d+(\.\d+)?/)
10
+ @style[:version].should match(/1\.\d+(\.\d+)?/)
11
+ end
12
+
13
+ it 'has the default version' do
14
+ @style.default_attribute?(:version).should be_true
15
+ end
16
+
17
+ it 'has a the default namespace attribute' do
18
+ @style[:xmlns].should == CSL::Schema.namespace
19
+ @style.default_attribute?(:xmlns).should be_true
9
20
  end
10
21
 
11
22
  describe '#to_xml' do
12
23
  it 'returns an empty style' do
13
- Style.new.to_xml.should match(/^<style[^>]*\/>/)
24
+ @style.to_xml.should match(/^<style[^>]*\/>/)
25
+ end
26
+
27
+ it 'includes the xml namespace' do
28
+ @style.to_xml.should match(CSL::Schema.namespace)
14
29
  end
15
30
 
16
31
  it 'supports round-trip for apa style' do
@@ -33,47 +48,47 @@ module CSL
33
48
  it { should_not have_bibliography }
34
49
 
35
50
  describe 'when it has a title' do
36
- before(:all) { style.title = 'foo' }
51
+ before { @style.title = 'foo' }
37
52
 
38
- it { style.should have_info }
53
+ it { @style.should have_info }
39
54
 
40
55
  it 'info.title is a text node' do
41
- style.info.title.should be_a(TextNode)
56
+ @style.info.title.should be_a(TextNode)
42
57
  end
43
58
 
44
59
  it '#title returns the title as a string' do
45
- style.title.should be_a(String)
60
+ @style.title.should be_a(String)
46
61
  end
47
62
  end
48
63
  end
49
64
 
50
65
  describe '#id accessor' do
51
66
  it 'returns nil by default' do
52
- Style.new.id.should be_nil
67
+ @style.id.should be_nil
53
68
  end
54
69
 
55
70
  it 'writer sets the id to the passed-in string' do
56
- expect { style.id = 'foobar' }.to change { style.id }.from(nil).to('foobar')
71
+ expect { @style.id = 'foobar' }.to change { @style.id }.from(nil).to('foobar')
57
72
  end
58
73
  end
59
74
 
60
75
  describe 'independent and dependent styles' do
61
76
  it 'styles are independent by default' do
62
- Style.new.should be_independent
77
+ @style.should be_independent
63
78
  end
64
79
 
65
80
  it 'styles do not have independent-parent links by default' do
66
- Style.new.should_not have_independent_parent_link
81
+ @style.should_not have_independent_parent_link
67
82
  end
68
83
 
69
84
  it 'when setting an independet-parent link a style becomes dependent' do
70
- expect { style.independent_parent_link = 'foo' }.to change { style.independent? }
85
+ expect { @style.independent_parent_link = 'foo' }.to change { @style.independent? }
71
86
  end
72
87
  end
73
88
 
74
89
  describe 'macros' do
75
90
  it 'has no macros by default' do
76
- Style.new.should_not have_macros
91
+ @style.should_not have_macros
77
92
  end
78
93
 
79
94
  it 'raises a validation error when adding a macro without name' do
@@ -81,23 +96,23 @@ module CSL
81
96
  end
82
97
 
83
98
  describe 'when it has an "author" macro' do
84
- before(:all) { style << Style::Macro.new(:name => 'author') }
99
+ before { @style << Style::Macro.new(:name => 'author') }
85
100
 
86
101
  it 'has macros' do
87
- style.should have_macros
102
+ @style.should have_macros
88
103
  end
89
104
 
90
105
  it 'the macro is registered in the macros hash' do
91
- style.macros.should have_key('author')
92
- style.macros['author'].should be_a(Style::Macro)
106
+ @style.macros.should have_key('author')
107
+ @style.macros['author'].should be_a(Style::Macro)
93
108
  end
94
109
 
95
110
  it 'raises a validation error when adding a macro with a duplicate name' do
96
- expect { style << Style::Macro.new(:name => 'author') }.to raise_error(ValidationError)
111
+ expect { @style << Style::Macro.new(:name => 'author') }.to raise_error(ValidationError)
97
112
  end
98
113
 
99
114
  it 'unregisters the macro when it is deleted' do
100
- expect { style.delete style.macros['author'] }.to change { style.macros.length }
115
+ expect { @style.delete @style.macros['author'] }.to change { @style.macros.length }
101
116
  end
102
117
  end
103
118
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  begin
2
- require 'simplecov'
3
- require 'debugger'
2
+ if RUBY_VERSION < '1.9'
3
+ # require 'debug'
4
+ # Debugger.start
5
+ else
6
+ require 'simplecov'
7
+ require 'debugger'
8
+ end
4
9
  rescue LoadError
5
10
  # ignore
6
11
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre21
5
- prerelease: 6
4
+ version: 1.0.0.pre22
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sylvester Keil
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-21 00:00:00.000000000 Z
11
+ date: 2013-04-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: namae
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,61 +20,12 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0.3'
30
- - !ruby/object:Gem::Dependency
31
- name: cucumber
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '1.1'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '1.1'
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '2.7'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '2.7'
62
- - !ruby/object:Gem::Dependency
63
- name: rake
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '0.9'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: '0.9'
78
- description: ! "\n\t\tA Ruby parser and library for the Citation Style Language (CSL),
79
- an open\n\t\tXML-based language to describe the formatting of citations and\n\t\tbibliographies.\n\t\t"
27
+ description: "\n\t\tA Ruby parser and library for the Citation Style Language (CSL),\n\t\tan
28
+ open XML-based language to describe the formatting of citations\n\t\tand bibliographies.\n\t\t"
80
29
  email:
81
30
  - http://sylvester.keil.or.at
82
31
  executables: []
@@ -171,30 +120,26 @@ files:
171
120
  homepage: https://github.com/inukshuk/csl-ruby
172
121
  licenses:
173
122
  - AGPL
123
+ metadata: {}
174
124
  post_install_message:
175
125
  rdoc_options: []
176
126
  require_paths:
177
127
  - lib
178
128
  required_ruby_version: !ruby/object:Gem::Requirement
179
- none: false
180
129
  requirements:
181
- - - ! '>='
130
+ - - '>='
182
131
  - !ruby/object:Gem::Version
183
132
  version: '0'
184
- segments:
185
- - 0
186
- hash: -1739872005928970958
187
133
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
134
  requirements:
190
- - - ! '>'
135
+ - - '>'
191
136
  - !ruby/object:Gem::Version
192
137
  version: 1.3.1
193
138
  requirements: []
194
139
  rubyforge_project:
195
- rubygems_version: 1.8.24
140
+ rubygems_version: 2.0.3
196
141
  signing_key:
197
- specification_version: 3
142
+ specification_version: 4
198
143
  summary: A Ruby CSL parser and library
199
144
  test_files:
200
145
  - features/locales/loading.feature