citeproc-js 0.0.2 → 0.0.6

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.
data/Gemfile CHANGED
@@ -1,10 +1,18 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
- group :debug do
5
- gem 'ruby-debug', :platforms => [:ruby_18, :jruby]
6
- gem 'ruby-debug19', :require => 'ruby-debug', :platforms => [:ruby_19]
4
+
5
+ platforms :ruby_19 do
6
+ gem 'johnson', '~>2.0.0.pre3'
7
+ gem 'ruby-debug19', :require => 'ruby-debug', :group => :debug
8
+ end
9
+
10
+ platforms :ruby_18 do
11
+ # gem 'johnson', '~>1.2'
12
+ gem 'ruby-debug', :group => :debug
7
13
  end
8
14
 
9
- gem 'therubyrhino', '~>1.72', :require => 'rhino', :platforms => [:jruby]
10
- gem 'johnson', '~>1.2', :platforms => [:ruby_18]
15
+ platforms :jruby do
16
+ gem 'therubyrhino', '~>1.72', :require => 'rhino'
17
+ gem 'ruby-debug', :group => :debug
18
+ end
data/README.md CHANGED
@@ -3,7 +3,7 @@ CiteProc::JS Engine
3
3
 
4
4
  CiteProc::JS Engine is a CSL 1.0 compatible engine for
5
5
  [citeproc](http://rubygems.org/gems/citeproc); it is implemented as a
6
- thin Ruby wrapper around Frank G. Benett's awesome
6
+ thin Ruby wrapper around Frank G. Bennett's awesome
7
7
  [citeproc-js](https://bitbucket.org/fbennett/citeproc-js/overview).
8
8
 
9
9
 
@@ -13,7 +13,10 @@ Requirements
13
13
  In addition to the dependencies defined by the gem, please make sure to
14
14
  your environment meets the following requirements depending on your platform;
15
15
 
16
- * For Ruby 1.8.7, please install [johnson](https://github.com/jbarnette/johnson).
16
+ * For Ruby 1.9, please install this [experimental branch of johnson](https://github.com/inukshuk/johnson):
17
+ download/clone the repository and run `rake compile` followed by `rake gem`;
18
+ find and install the pre-release gem in the `pkg` directory.
19
+ * For Ruby 1.8.7, please install stable [johnson](https://github.com/jbarnette/johnson).
17
20
  * For JRuby, please install [therubyrhino](https://github.com/cowboyd/therubyrhino).
18
21
 
19
22
  Support for other platforms is still in development.
@@ -18,3 +18,5 @@ def run (cmd)
18
18
  puts cmd
19
19
  system cmd
20
20
  end
21
+
22
+ rspec 'spec'
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.description = 'A citeproc engine based on the citeproc-js CSL (Citation Style Language) processor.'
16
16
  s.license = 'AGPLv3'
17
17
 
18
- s.add_runtime_dependency('citeproc', ['~>0.0'])
18
+ s.add_runtime_dependency('citeproc', ['~>0.0.5'])
19
19
  s.add_runtime_dependency('execjs', ['>=1.2.4', '<1.3.0'])
20
20
 
21
21
  s.add_development_dependency('cucumber', ['>=1.0.2'])
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.executables = []
28
28
  s.require_path = 'lib'
29
29
 
30
- s.rdoc_options = %w{--line-numbers --inline-source --title "CiteProc-JS\ Rubygem" --main README.md --webcvs=http://github.com/inukshuk/citeproc-js/tree/master/}
30
+ s.rdoc_options = %w{--line-numbers --inline-source --title "CiteProc-JS" --main README.md --webcvs=http://github.com/inukshuk/citeproc-js/tree/master/}
31
31
  s.extra_rdoc_files = %w{README.md}
32
32
 
33
33
  end
@@ -1,9 +1,7 @@
1
1
 
2
2
  require 'citeproc/js/compatibility'
3
3
 
4
- ruby_18 do
5
- ENV['EXECJS_RUNTIME'] = 'Johnson'
6
- end
4
+ ENV['EXECJS_RUNTIME'] = 'Johnson'
7
5
 
8
6
  jruby do
9
7
  ENV['EXECJS_RUNTIME'] = 'RubyRhino'
@@ -22,5 +20,4 @@ require 'forwardable'
22
20
  require 'citeproc'
23
21
 
24
22
  require 'citeproc/js/version'
25
- require 'citeproc/js/assets'
26
23
  require 'citeproc/js/engine'
@@ -1,29 +1,29 @@
1
1
 
2
2
  module CiteProc
3
3
  module JS
4
-
4
+
5
5
  class Engine < CiteProc::Engine
6
6
 
7
7
  @name = 'citeproc-js'.freeze
8
8
  @type = 'CSL'.freeze
9
9
  @version = '1.0'
10
10
  @priority = 0
11
-
11
+
12
12
  @path = File.expand_path('../support', __FILE__)
13
13
 
14
14
  class << self
15
-
15
+
16
16
  attr_reader :path
17
-
17
+
18
18
  def parser
19
19
  ExecJS.runtime.name =~ /rhino|spidermonkey/i ? 'xmle4x.js' : 'xmldom.js'
20
20
  end
21
-
21
+
22
22
  # Returns the citeproc-js JavaScript code.
23
23
  def source
24
24
  @source || reload
25
25
  end
26
-
26
+
27
27
  # Forces a reload citeproc-js JavaScript code. Returns the source
28
28
  # code.
29
29
  def reload
@@ -33,7 +33,7 @@ module CiteProc
33
33
  end
34
34
 
35
35
  private
36
-
36
+
37
37
  def attr_context(*arguments)
38
38
  arguments.flatten.each do |m|
39
39
  define_method(underscore(m)) do
@@ -41,7 +41,7 @@ module CiteProc
41
41
  end
42
42
  end
43
43
  end
44
-
44
+
45
45
  def delegate_context(*arguments)
46
46
  arguments.flatten.each do |m|
47
47
  define_method(underscore(m)) do |*args|
@@ -49,7 +49,7 @@ module CiteProc
49
49
  end
50
50
  end
51
51
  end
52
-
52
+
53
53
  def underscore(javascript_method)
54
54
  word = javascript_method.to_s.split(/\./)[-1]
55
55
  word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
@@ -58,20 +58,9 @@ module CiteProc
58
58
  word
59
59
  end
60
60
  end
61
-
62
61
 
63
- #
64
- # instance methods
65
- #
66
62
 
67
- def style=(style)
68
- @style = Style.load(style.to_s)
69
- end
70
-
71
- def locales=(locale)
72
- @locales = { locale.to_sym => Locale.load(locale.to_s) }
73
- end
74
-
63
+
75
64
  attr_context :processor_version, :csl_version, :opt
76
65
 
77
66
  alias flags opt
@@ -79,75 +68,84 @@ module CiteProc
79
68
  delegate_context %w{ setOutputFormat updateItems updateUncitedItems
80
69
  makeBibliography appendCitationCluster processCitationCluster
81
70
  previewCitationCluster registry.getSortedRegistryItems }
82
-
71
+
83
72
  alias format= set_output_format
84
- alias bibliography make_bibliography
85
73
 
86
74
  alias sorted_registry_items get_sorted_registry_items
87
75
 
88
76
  %w{ append process preview }.each do |m|
89
77
  alias_method m, "#{m}_citation_cluster"
90
78
  end
91
-
79
+
80
+ # Don't expose all delegates to public interface
81
+ private :opt, :append_citation_cluster, :process_citation_cluster,
82
+ :set_output_format, :make_bibliography, :preview_citation_cluster,
83
+ :get_sorted_registry_items
84
+
92
85
  def registry
93
86
  @registry ||= Hash.new { |h,k| delegate "citeproc.registry.#{k}" }
94
87
  end
95
-
88
+
96
89
  def citation_registry
97
90
  @citation_registry ||= Hash.new { |h,k| registry["citationreg.#{k}"] }
98
91
  end
99
-
100
- def language; options[:locale]; end
101
-
102
- def start
103
- return if started?
104
- super
105
-
106
- self.style = processor.options[:style] if @style.nil?
107
- self.locales = processor.options[:locale] if @locales.nil?
108
92
 
109
- @context = ExecJS.compile(Engine.source)
110
- update_system
111
-
112
- delegate "citeproc = new CSL.Engine(system, #{style.inspect}, #{language.inspect})", :exec
113
- set_output_format(options[:format])
114
-
115
- self
116
- rescue => e
117
- stop
118
- raise EngineError.new('failed to start engine', e)
93
+ # The processor's items converted to citeproc-js format
94
+ def items
95
+ Hash[*processor.items.map { |id, item|
96
+ [id.to_s, item.respond_to?(:to_citeproc) ? item.to_citeproc : item.to_s]
97
+ }.flatten]
119
98
  end
120
99
 
121
- def stop
122
- @context = nil
123
- super
100
+ # The locale put into a hash to make citeproc-js happy
101
+ def locales
102
+ { locale.name => locale.to_s }
124
103
  end
125
104
 
126
- def set_abbreviations(namespace)
105
+ # Sets the abbreviation's namespace, both in Ruby and JS land
106
+ def namespace=(namespace)
127
107
  delegate "citeproc.setAbbreviations(#{ namespace.to_s.inspect })"
128
- @default_namespace = namespace.to_sym
108
+ @namespace = namespace.to_sym
129
109
  end
130
110
 
131
- alias default_namespace= set_abbreviations
111
+ def bibliography(selector = Selector.new)
112
+ Bibliography(make_bibliography(selector.to_citeproc))
113
+ end
114
+
115
+ def append(citation)
116
+ append_citation_cluster(citation.to_citeproc, false)
117
+ end
132
118
 
133
119
  private
134
120
 
121
+ def context
122
+ @context || compile_context
123
+ end
124
+
125
+ def compile_context
126
+ @context = ExecJS.compile(Engine.source)
127
+ update_system(:abbreviations, :items, :locales)
128
+
129
+ delegate "citeproc = new CSL.Engine(system, #{style.to_s.inspect}, #{locale.name.inspect})", :exec
130
+ set_output_format(options[:format])
131
+
132
+ @context
133
+ rescue => e
134
+ raise EngineError, "failed to compile engine context: #{e.message}"
135
+ end
136
+
135
137
  def update_system(*arguments)
136
- arguments = [:abbreviations, :items, :locales] if arguments.empty?
137
- delegate "system.update(#{ MultiJson.encode(Hash[*arguments.flatten.map { |a| [a, send(a)] }.flatten]) })"
138
+ arguments = arguments.flatten.map { |a| [a, send(a)] }
139
+ delegate "system.update(#{ MultiJson.encode(Hash[*arguments.flatten]) })"
138
140
  end
139
-
141
+
140
142
  def delegate(script, method = :eval)
141
- if running?
142
- @context.send(method, script)
143
- else
144
- warn "not executing script: engine has not been started"
145
- end
143
+ context.send(method, script)
146
144
  rescue => e
147
- raise EngineError.new('failed to execute javascript:', e)
145
+ raise EngineError, "failed to execute javascript: #{e.message}"
148
146
  end
149
-
147
+
150
148
  end
151
-
149
+
152
150
  end
153
151
  end
@@ -1,5 +1,5 @@
1
1
  module CiteProc
2
2
  module JS
3
- VERSION = '0.0.2'.freeze
3
+ VERSION = '0.0.6'.freeze
4
4
  end
5
5
  end
@@ -1,132 +1,131 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module CiteProc
4
6
  module JS
5
7
  describe 'Engine' do
8
+
9
+ let(:items) { load_items('items') }
10
+
11
+ let(:processor) do
12
+ p = Processor.new(:style => 'apa')
13
+ p.update(items)
14
+ p
15
+ end
16
+
6
17
  before(:all) do
7
18
  Style.root = File.expand_path('../../../fixtures/styles', __FILE__)
8
19
  Locale.root = File.expand_path('../../../fixtures/locales', __FILE__)
9
20
  end
10
-
11
- let(:subject) do
12
- Engine.new do |e|
13
- p = double(:processor)
14
- p.stub(:options).and_return { Processor.defaults }
15
- p.stub(:items).and_return { load_items('items') }
16
- e.processor = p
17
- end
21
+
22
+ let(:engine) do
23
+ processor.engine = Engine.new(processor)
18
24
  end
19
-
25
+
20
26
  it { should_not be nil }
21
-
22
- describe '#style' do
23
- let(:apa) { load_style('apa') }
24
- it 'accepts a style name' do
25
- subject.style = :apa
26
- subject.style.to_s.should == apa
27
- end
28
- it 'accepts a style name with extension' do
29
- subject.style = 'apa.csl'
30
- subject.style.to_s.should == apa
31
- end
32
- it 'accepts a full style' do
33
- subject.style = apa
34
- subject.style.to_s.should == apa
35
- end
36
- end
37
-
27
+
28
+
38
29
  describe '#version' do
39
30
  it 'returns a 1.x version string' do
40
- subject.version.should =~ /^1\.[\d\.]+/
31
+ engine.version.should =~ /^1\.[\d\.]+/
41
32
  end
42
33
  end
43
34
 
44
35
  describe '#name' do
45
36
  it 'returns "citeproc-js"' do
46
- subject.name.should == 'citeproc-js'
37
+ engine.name.should == 'citeproc-js'
47
38
  end
48
39
  end
49
-
40
+
50
41
  describe '#type' do
51
42
  it 'returns "CSL"' do
52
- subject.type.should == 'CSL'
43
+ engine.type.should == 'CSL'
53
44
  end
54
45
  end
55
-
56
- context 'when started' do
57
- let(:subject) do
58
- Engine.new do |e|
59
- p = double(:processor)
60
- p.stub(:options).and_return { Processor.defaults }
61
- p.stub(:items).and_return { load_items('items') }
62
- e.processor = p
63
- e.style = :apa
64
- e.locales = :'en-US'
65
- e.start
66
- end
46
+
47
+
48
+ describe '#processor_version' do
49
+ it 'returns the citeproc-js version' do
50
+ engine.processor_version.should =~ /^[\d\.]+$/
67
51
  end
52
+ end
68
53
 
69
- describe '#processor_version' do
70
- it 'returns the citeproc-js version' do
71
- subject.processor_version.should =~ /^[\d\.]+$/
72
- end
54
+ describe '#flags' do
55
+ it 'returns a hash of flags' do
56
+ engine.flags.should have_key('sort_citations')
73
57
  end
74
-
75
- describe '#flags' do
76
- it 'returns a hash of flags' do
77
- subject.flags.should have_key('sort_citations')
78
- end
58
+ end
59
+
60
+ describe '#namespace=' do
61
+ it 'sets the abbreviation namespace' do
62
+ lambda { engine.namespace = :default }.should_not raise_error
79
63
  end
64
+ end
80
65
 
81
- describe '#default_namespace=' do
82
- it 'sets the abbreviation namespace' do
83
- lambda { subject.default_namespace = :default }.should_not raise_error
84
- end
66
+ describe '#registry' do
67
+ it 'is a hash' do
68
+ engine.registry.should be_a(Hash)
85
69
  end
70
+ end
86
71
 
87
- describe '#registry' do
88
- it 'is a hash' do
89
- subject.registry.should be_a(Hash)
90
- end
72
+ describe '#update_items' do
73
+ it 'given a list of ids, loads the corresponding items into the engine' do
74
+ expect { engine.update_items(['ITEM-1']) }.to
75
+ change { engine.registry[:inserts].length }.by(1)
91
76
  end
92
-
93
- describe '#update_items' do
94
- it 'given a list of ids, loads the corresponding items into the engine' do
95
- expect { subject.update_items(['ITEM-1']) }.to
96
- change { subject.registry[:inserts].length }.by(1)
97
- end
77
+ end
78
+
79
+ describe '#bibliography' do
80
+ it 'returns an empty bibliography by default' do
81
+ engine.bibliography.should be_empty
98
82
  end
99
83
 
100
- describe '#bibliography' do
101
- it 'returns an empty bibliography by default' do
102
- subject.bibliography[1].should be_empty
103
- end
84
+ describe 'when items were updated' do
85
+ before(:each) { engine.update_items(['ITEM-1']) }
104
86
 
105
- describe 'when items were processed' do
106
- before(:each) { subject.update_items(['ITEM-1']) }
107
-
108
- it 'returns the bibliography when at least one item was processed' do
109
- subject.bibliography[1].should_not be_empty
110
- end
87
+ it 'returns the bibliography when at least one item was processed' do
88
+ engine.bibliography.should_not be_empty
111
89
  end
112
- end
113
-
114
- describe '#sorted_registry_items' do
115
- it 'returns an empty bibliography by default' do
116
- subject.sorted_registry_items.should be_empty
90
+
91
+ it 'the bibliography contains the processed items' do
92
+ engine.bibliography[0].should match(/Boundaries of Dissent/)
117
93
  end
94
+ end
95
+ end
118
96
 
119
- describe 'when items were processed' do
120
- before(:each) { subject.update_items(['ITEM-1']) }
121
-
122
- it 'returns the bibliography when at least one item was processed' do
123
- subject.sorted_registry_items.should_not be_empty
124
- end
125
- end
97
+ describe '#append' do
98
+
99
+ it 'returns the citation id and string for the item' do
100
+ engine.append(CitationData.new([{:id => 'ITEM-1'}]))[0][1].should == '(D’Arcus, 2006)'
101
+ end
102
+
103
+ it 'increases the citation index on subsequent calls' do
104
+ x = engine.append(CitationData.new([{:id => 'ITEM-1'}]))[0][0]
105
+ engine.append(CitationData.new([{:id => 'ITEM-1'}]))[0][0].should > x
106
+ end
107
+
108
+ it 'includes the locator' do
109
+ engine.append(CitationData.new([{:id => 'ITEM-1', :locator => 'PAGE'}]))[0][1].should match(/PAGE/)
126
110
  end
127
111
 
128
112
  end
129
113
 
130
- end
131
- end
114
+ describe '#sorted_registry_items' do
115
+ it 'returns an empty bibliography by default' do
116
+ engine.sorted_registry_items.should be_empty
117
+ end
118
+
119
+ describe 'when items were processed' do
120
+ before(:each) { engine.update_items(['ITEM-1']) }
121
+
122
+ it 'returns the bibliography when at least one item was processed' do
123
+ engine.sorted_registry_items.should_not be_empty
124
+ end
125
+ end
126
+ end
127
+
128
+ end
129
+
130
+ end
132
131
  end
@@ -9,9 +9,9 @@
9
9
  "static-ordering": false
10
10
  }
11
11
  ],
12
- "note":"The apostrophe in Bruce's name appears in proper typeset form.",
12
+ "note":"The apostrophe in Bruce's name appears in proper typeset form.",
13
13
  "publisher": "Routledge",
14
- "publisher-place": "New York",
14
+ "publisher-place": "New York",
15
15
  "issued": {
16
16
  "date-parts":[
17
17
  [2006]
metadata CHANGED
@@ -1,118 +1,83 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: citeproc-js
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Sylvester Keil
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-09 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: citeproc
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2153050420 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 11
29
- segments:
30
- - 0
31
- - 0
32
- version: "0.0"
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.5
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: execjs
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2153050420
25
+ - !ruby/object:Gem::Dependency
26
+ name: execjs
27
+ requirement: &2153048140 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 23
44
- segments:
45
- - 1
46
- - 2
47
- - 4
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
48
32
  version: 1.2.4
49
33
  - - <
50
- - !ruby/object:Gem::Version
51
- hash: 27
52
- segments:
53
- - 1
54
- - 3
55
- - 0
34
+ - !ruby/object:Gem::Version
56
35
  version: 1.3.0
57
36
  type: :runtime
58
- version_requirements: *id002
59
- - !ruby/object:Gem::Dependency
60
- name: cucumber
61
37
  prerelease: false
62
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ version_requirements: *2153048140
39
+ - !ruby/object:Gem::Dependency
40
+ name: cucumber
41
+ requirement: &2153046920 !ruby/object:Gem::Requirement
63
42
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- hash: 19
68
- segments:
69
- - 1
70
- - 0
71
- - 2
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
72
46
  version: 1.0.2
73
47
  type: :development
74
- version_requirements: *id003
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
48
  prerelease: false
78
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ version_requirements: *2153046920
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ requirement: &2153046100 !ruby/object:Gem::Requirement
79
53
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 23
84
- segments:
85
- - 2
86
- - 6
87
- - 0
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
88
57
  version: 2.6.0
89
58
  type: :development
90
- version_requirements: *id004
91
- - !ruby/object:Gem::Dependency
92
- name: watchr
93
59
  prerelease: false
94
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ version_requirements: *2153046100
61
+ - !ruby/object:Gem::Dependency
62
+ name: watchr
63
+ requirement: &2153042660 !ruby/object:Gem::Requirement
95
64
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 5
100
- segments:
101
- - 0
102
- - 7
103
- version: "0.7"
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
104
69
  type: :development
105
- version_requirements: *id005
106
- description: A citeproc engine based on the citeproc-js CSL (Citation Style Language) processor.
107
- email:
70
+ prerelease: false
71
+ version_requirements: *2153042660
72
+ description: A citeproc engine based on the citeproc-js CSL (Citation Style Language)
73
+ processor.
74
+ email:
108
75
  - http://sylvester.keil.or.at
109
76
  executables: []
110
-
111
77
  extensions: []
112
-
113
- extra_rdoc_files:
78
+ extra_rdoc_files:
114
79
  - README.md
115
- files:
80
+ files:
116
81
  - .gitignore
117
82
  - .rspec
118
83
  - Gemfile
@@ -121,7 +86,6 @@ files:
121
86
  - auto.watchr
122
87
  - citeproc-js.gemspec
123
88
  - lib/citeproc/js.rb
124
- - lib/citeproc/js/assets.rb
125
89
  - lib/citeproc/js/compatibility.rb
126
90
  - lib/citeproc/js/engine.rb
127
91
  - lib/citeproc/js/support/citeproc.js
@@ -129,53 +93,44 @@ files:
129
93
  - lib/citeproc/js/support/xmldom.js
130
94
  - lib/citeproc/js/support/xmle4x.js
131
95
  - lib/citeproc/js/version.rb
132
- - spec/citeproc/js/assets_spec.rb
133
96
  - spec/citeproc/js/engine_spec.rb
134
97
  - spec/fixtures/items/items.json
135
98
  - spec/fixtures/locales/locales-en-US.xml
136
99
  - spec/fixtures/styles/apa.csl
137
100
  - spec/spec_helper.rb
138
101
  homepage: http://inukshuk.github.com/citeproc-js
139
- licenses:
102
+ licenses:
140
103
  - AGPLv3
141
104
  post_install_message:
142
- rdoc_options:
105
+ rdoc_options:
143
106
  - --line-numbers
144
107
  - --inline-source
145
108
  - --title
146
- - "\"CiteProc-JS Rubygem\""
109
+ - ! '"CiteProc-JS"'
147
110
  - --main
148
111
  - README.md
149
112
  - --webcvs=http://github.com/inukshuk/citeproc-js/tree/master/
150
- require_paths:
113
+ require_paths:
151
114
  - lib
152
- required_ruby_version: !ruby/object:Gem::Requirement
115
+ required_ruby_version: !ruby/object:Gem::Requirement
153
116
  none: false
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- hash: 3
158
- segments:
159
- - 0
160
- version: "0"
161
- required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
122
  none: false
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- hash: 3
167
- segments:
168
- - 0
169
- version: "0"
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
170
127
  requirements: []
171
-
172
128
  rubyforge_project:
173
- rubygems_version: 1.8.5
129
+ rubygems_version: 1.8.10
174
130
  signing_key:
175
131
  specification_version: 3
176
132
  summary: A citeproc engine based on citeproc-js.
177
- test_files:
178
- - spec/citeproc/js/assets_spec.rb
133
+ test_files:
179
134
  - spec/citeproc/js/engine_spec.rb
180
135
  - spec/fixtures/items/items.json
181
136
  - spec/fixtures/locales/locales-en-US.xml
@@ -1,68 +0,0 @@
1
- require 'uri'
2
-
3
- module CiteProc
4
- module JS
5
- module Asset
6
-
7
- def self.included(base)
8
- base.extend(ClassMethods)
9
- end
10
-
11
- attr_accessor :asset
12
-
13
- alias to_s asset
14
-
15
- def inspect
16
- to_s.inspect
17
- end
18
-
19
- module ClassMethods
20
-
21
- attr_accessor :root, :extension, :prefix
22
-
23
- def load(asset)
24
- instance = new
25
- case
26
- when File.exists?(asset)
27
- instance.asset = read(asset)
28
- when File.exists?(File.join(root.to_s, extend_name(asset)))
29
- instance.asset = read(File.join(root.to_s, extend_name(asset)))
30
- else
31
- instance.asset = asset
32
- end
33
- instance
34
- end
35
-
36
- private
37
-
38
- def read(name)
39
- io = open(name, 'r:UTF-8')
40
- io.read
41
- ensure
42
- io.close
43
- end
44
-
45
- def extend_name(file)
46
- file = File.extname(file).empty? ? [file, extension].compact.join : file
47
- file = file.start_with?(prefix.to_s) ? file : [prefix,file].join
48
- file
49
- end
50
- end
51
-
52
- end
53
-
54
- class Style
55
- include Asset
56
- @root = '/usr/local/share/citation-style-language/styles'.freeze
57
- @extension = '.csl'.freeze
58
- end
59
-
60
- class Locale
61
- include Asset
62
- @root = '/usr/local/share/citation-style-language/locales'.freeze
63
- @extension = '.xml'.freeze
64
- @prefix = 'locales-'
65
- end
66
-
67
- end
68
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
-
4
- module CiteProc
5
- module JS
6
-
7
- describe 'Assets' do
8
- let(:file) { Tempfile.new('asset') }
9
- let(:root) { File.dirname(file.path) }
10
- let(:name) { File.basename(file.path) }
11
- let(:extension) { File.extname(name) }
12
-
13
- before(:all) do
14
- file.write("asset content\n")
15
- file.close
16
- end
17
-
18
- after(:all) { file.unlink }
19
-
20
- describe 'Style' do
21
-
22
- before(:all) do
23
- @default_root = Style.root
24
- @default_extension = Style.extension
25
- Style.root = root
26
- Style.extension = extension
27
- end
28
-
29
- after(:all) do
30
- Style.root = @default_root
31
- Style.extension = @default_extension
32
- end
33
-
34
- describe '.load' do
35
-
36
- it 'accepts an absolute file name' do
37
- Style.load(file.path).to_s.should == "asset content\n"
38
- end
39
-
40
- it 'accepts a file name' do
41
- Style.load(name).to_s.should == "asset content\n"
42
- end
43
-
44
- # it 'accepts a file name without extension' do
45
- # Style.load(name.sub(/#{extension}$/,'')).to_s.should == "asset content\n"
46
- # end
47
- #
48
- #
49
- # it 'accepts a uri' do
50
- # pending
51
- # end
52
-
53
- it 'returns the given string if it is neither file nor uri' do
54
- Style.load('foo bar!').to_s.should == 'foo bar!'
55
- end
56
-
57
- end
58
-
59
- end
60
- end
61
- end
62
- end