citeproc 0.0.3 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
-
2
1
  module CiteProc
2
+
3
3
  module Utilities
4
4
 
5
5
  # call-seq:
@@ -14,6 +14,7 @@ module CiteProc
14
14
  def bibliography(items, options = {})
15
15
  process(:bibliography, items, options)
16
16
  end
17
-
17
+
18
18
  end
19
+
19
20
  end
@@ -1,3 +1,3 @@
1
1
  module CiteProc
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
@@ -2,59 +2,63 @@ require 'spec_helper'
2
2
  require 'tempfile'
3
3
 
4
4
  module CiteProc
5
-
6
- describe 'Assets' do
7
- let(:file) { Tempfile.new('asset') }
8
- let(:root) { File.dirname(file.path) }
9
- let(:name) { File.basename(file.path) }
10
- let(:extension) { File.extname(name) }
11
-
12
- before(:all) do
13
- file.write("asset content\n")
14
- file.close
15
- end
16
-
17
- after(:all) { file.unlink }
18
-
19
- describe 'Style' do
20
-
21
- before(:all) do
22
- @default_root = Style.root
23
- @default_extension = Style.extension
24
- Style.root = root
25
- Style.extension = extension
26
- end
27
-
28
- after(:all) do
29
- Style.root = @default_root
30
- Style.extension = @default_extension
31
- end
32
-
33
- describe '.load' do
34
-
35
- it 'accepts an absolute file name' do
36
- Style.load(file.path).to_s.should == "asset content\n"
37
- end
38
-
39
- it 'accepts a file name' do
40
- Style.load(name).to_s.should == "asset content\n"
41
- end
42
-
43
- it 'accepts a file name without extension' do
44
- Style.load(name.sub(/#{extension}$/,'')).to_s.should == "asset content\n"
45
- end
46
-
47
-
48
- it 'accepts a uri' do
49
- pending
50
- end
51
-
52
- it 'returns the given string if it is neither file nor uri' do
53
- Style.load('foo bar!').to_s.should == 'foo bar!'
54
- end
55
-
56
- end
57
-
58
- end
59
- end
5
+
6
+ describe 'Assets' do
7
+ let(:file) { Tempfile.new('asset') }
8
+ let(:root) { File.dirname(file.path) }
9
+ let(:name) { File.basename(file.path) }
10
+ let(:extension) { File.extname(name) }
11
+
12
+ before(:all) do
13
+ file.write("asset content\n")
14
+ file.close
15
+ end
16
+
17
+ after(:all) { file.unlink }
18
+
19
+ describe 'Style' do
20
+
21
+ before(:all) do
22
+ @default_root = Style.root
23
+ @default_extension = Style.extension
24
+ Style.root = root
25
+ Style.extension = extension
26
+ end
27
+
28
+ after(:all) do
29
+ Style.root = @default_root
30
+ Style.extension = @default_extension
31
+ end
32
+
33
+ it 'should not be open by default' do
34
+ Style.new.should_not be_open
35
+ end
36
+
37
+ describe '.open' do
38
+
39
+ it 'accepts an absolute file name' do
40
+ Style.open(file.path).to_s.should == "asset content\n"
41
+ end
42
+
43
+ it 'accepts a file name' do
44
+ Style.open(name).to_s.should == "asset content\n"
45
+ end
46
+
47
+ it 'accepts a file name without extension' do
48
+ Style.open(name.sub(/#{extension}$/,'')).to_s.should == "asset content\n"
49
+ end
50
+
51
+
52
+ it 'accepts an io object' do
53
+ Style.open(file.open).to_s.should == "asset content\n"
54
+ end
55
+
56
+ it 'returns the given string if it looks like XML' do
57
+ Style.open('<b>foo bar!</b>').to_s.should == '<b>foo bar!</b>'
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+ end
60
64
  end
@@ -1,72 +1,72 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module CiteProc
4
-
5
- describe Bibliography do
6
-
7
- it { should be_empty }
8
- it { should_not have_errors }
9
-
10
- describe '#to_citeproc conversion' do
11
-
12
- it 'returns an array' do
13
- subject.to_citeproc.should be_a(Array)
14
- end
15
-
16
- it 'returns exactly two elements' do
17
- subject.to_citeproc.should have(2).elements
18
- end
19
-
20
- it 'returns formatting options as the first element' do
21
- subject.to_citeproc.first.should be_a(Hash)
22
- end
4
+
5
+ describe Bibliography do
6
+
7
+ it { should be_empty }
8
+ it { should_not have_errors }
9
+
10
+ describe '#to_citeproc conversion' do
11
+
12
+ it 'returns an array' do
13
+ subject.to_citeproc.should be_a(Array)
14
+ end
15
+
16
+ it 'returns exactly two elements' do
17
+ subject.to_citeproc.should have(2).elements
18
+ end
19
+
20
+ it 'returns formatting options as the first element' do
21
+ subject.to_citeproc.first.should be_a(Hash)
22
+ end
23
23
 
24
- describe 'the formatting options' do
25
- let(:options) { subject.to_citeproc[0] }
26
-
27
- it 'contains a the error list' do
28
- options.should have_key('bibliography_errors')
29
- options['bibliography_errors'].should be_empty
30
- end
31
-
32
- end
33
-
34
- it 'returns the list of references as the second element' do
35
- subject.to_citeproc.last.should be_a(Array)
36
- end
37
-
38
- end
39
-
40
- describe '.parse (citeproc parser)' do
41
- let(:js) { <<-JS_END }
42
- [
43
- {
44
- "maxoffset": 0,
45
- "entryspacing": 0,
46
- "linespacing": 0,
47
- "hangingindent": 0,
48
- "second-field-align": true,
49
- "bibstart": "<div class=\\"csl-bib-body\\">\\n",
50
- "bibend": "</div>",
51
- "bibliography_errors": []
52
- },
53
- [
54
- "<div class=\\"csl-entry\\">Book A</div>",
55
- "<div class=\\"csl-entry\\">Book C</div>"
56
- ]
57
- ]
58
- JS_END
59
-
60
- it 'parses citeproc/json strings' do
61
- b = Bibliography.parse(js)
62
- b.should be_a(Bibliography)
63
- b.should have(2).references
64
- b.should_not have_errors
65
- b.options[:align].should be true
66
- end
67
-
68
- end
69
-
70
- end
71
-
24
+ describe 'the formatting options' do
25
+ let(:options) { subject.to_citeproc[0] }
26
+
27
+ it 'contains a the error list' do
28
+ options.should have_key('bibliography_errors')
29
+ options['bibliography_errors'].should be_empty
30
+ end
31
+
32
+ end
33
+
34
+ it 'returns the list of references as the second element' do
35
+ subject.to_citeproc.last.should be_a(Array)
36
+ end
37
+
38
+ end
39
+
40
+ describe '.create (citeproc parser)' do
41
+ let(:js) { <<-JS_END }
42
+ [
43
+ {
44
+ "maxoffset": 0,
45
+ "entryspacing": 0,
46
+ "linespacing": 0,
47
+ "hangingindent": 0,
48
+ "second-field-align": true,
49
+ "bibstart": "<div class=\\"csl-bib-body\\">\\n",
50
+ "bibend": "</div>",
51
+ "bibliography_errors": []
52
+ },
53
+ [
54
+ "<div class=\\"csl-entry\\">Book A</div>",
55
+ "<div class=\\"csl-entry\\">Book C</div>"
56
+ ]
57
+ ]
58
+ JS_END
59
+
60
+ it 'parses citeproc/json strings' do
61
+ b = Bibliography.create(js)
62
+ b.should be_a(Bibliography)
63
+ b.should have(2).references
64
+ b.should_not have_errors
65
+ b.options[:align].should be true
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
72
  end
@@ -8,16 +8,12 @@ module CiteProc
8
8
  end
9
9
 
10
10
  describe 'subclasses' do
11
- let(:subject) { Class.new(Engine).new { |e| e.processor = double(:processor) } }
11
+ let(:subject) { Class.new(Engine).new }
12
12
 
13
13
  it 'can be instantiated' do
14
14
  subject.should_not be nil
15
15
  end
16
-
17
- it 'can be started' do
18
- expect { subject.start }.to change { subject.running? }.from(false).to(true)
19
- end
20
-
16
+
21
17
  end
22
18
 
23
19
  end
@@ -4,11 +4,83 @@ module CiteProc
4
4
  describe Processor do
5
5
  before { Class.new(Engine) }
6
6
 
7
- let(:subject) { Processor.new }
7
+ let(:p) { Processor.new }
8
+ let(:palefire) { Item.new(:id => 'palefire', :type => :book, :title => 'Pale Fire') }
9
+ let(:despair) { Item.new(:id => 'despair', :type => :book, :title => 'Despair') }
8
10
 
9
11
  it { should_not be nil }
10
12
 
13
+ describe '#register' do
14
+
15
+ it 'adds the passed-in item to the items hash' do
16
+ expect { p.register(palefire) }.to change { p.items.length }.by(1)
17
+ end
18
+
19
+ it 'register the item with its id' do
20
+ expect { p.register(palefire) }.to change { p.has_key?(:palefire) }
21
+ end
22
+
23
+ end
24
+
25
+ describe '#<<' do
26
+
27
+ it 'registers the passed in item' do
28
+ expect { p << palefire }.to change { p.has_key?(:palefire) }
29
+ end
30
+
31
+ it 'returns the processor' do
32
+ (p << palefire).should be_equal(p)
33
+ end
34
+
35
+ end
36
+
37
+ describe '#[]' do
38
+
39
+ describe 'when there is no item with the passed-in id' do
40
+ it 'returns nil' do
41
+ p[:palefire].should be nil
42
+ end
43
+ end
44
+
45
+ describe 'when there is an item with the passed-in id' do
46
+ before(:each) { p.register(palefire) }
47
+
48
+ it 'returns the item' do
49
+ p[:palefire].should equal(palefire)
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '#update' do
55
+
56
+ it 'accepts a single item and adds it to the item hash' do
57
+ expect { p.update(palefire) }.to change { p.items.length }.by(1)
58
+ end
59
+
60
+ it 'registers the passed-in item with its id' do
61
+ expect { p.update(palefire) }.to change { p[:palefire] }.from(nil).to(palefire)
62
+ end
63
+
64
+ describe 'when passed a hash' do
65
+ it 'registers the value with the key as id' do
66
+ p.update(:foo => palefire)[:foo].should equal(palefire)
67
+ end
68
+
69
+ it 'converts the value to an item' do
70
+ p.update(:foo => { :title => 'The Story of Foo' })[:foo].should be_a(Item)
71
+ end
72
+ end
73
+
74
+ it 'adds all items in the array when passed an array' do
75
+ expect { p.update([palefire, despair]) }.to change { p.items.length }.by(2)
76
+ end
11
77
 
78
+ it 'adds all items in when passed multiple items' do
79
+ expect { p.update(palefire, despair) }.to change { p.items.length }.by(2)
80
+ end
81
+
82
+ end
83
+
12
84
  describe '#bibliography (generates the bibliography)' do
13
85
 
14
86
  describe 'when no items have been processed' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citeproc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-05 00:00:00.000000000Z
12
+ date: 2011-11-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &2157057820 !ruby/object:Gem::Requirement
16
+ requirement: &2157117740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157057820
24
+ version_requirements: *2157117740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cucumber
27
- requirement: &2157054940 !ruby/object:Gem::Requirement
27
+ requirement: &2157114740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2157054940
35
+ version_requirements: *2157114740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2157052260 !ruby/object:Gem::Requirement
38
+ requirement: &2157112700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2157052260
46
+ version_requirements: *2157112700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: watchr
49
- requirement: &2157045420 !ruby/object:Gem::Requirement
49
+ requirement: &2157105760 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0.7'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2157045420
57
+ version_requirements: *2157105760
58
58
  description: A a cite processor for Citation Style Language (CSL) styles.
59
59
  email: http://sylvester.keil.or.at
60
60
  executables: []