bibtex-ruby 4.0.8 → 4.0.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bibtex-ruby might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d64317001625640bf064c17d4887b6b928856de
4
- data.tar.gz: 50cb45e9195303203aebc75d80e47cd854faef6b
3
+ metadata.gz: 2f2055578c69cdfb2aa719688639882a4d68932a
4
+ data.tar.gz: 8c7bd4bd76d72e4ed17ce9389cfb4909021295b9
5
5
  SHA512:
6
- metadata.gz: 022b85f39d311a2eeae7f4e442ab01f221b8f80f6b8db30802626022850772c8f22da68c9bba7120f51b01c23864b82a826681ef26d57409e8098d57f0655674
7
- data.tar.gz: c0ee691a2a1d7ad70f6e05f5e1a998aad491c8b959287d0a09841fe7aa53d133829732c9cb66ee59e717d43d6a8681cf0da66d5e7d5716d08b9276d6463556be
6
+ metadata.gz: cf24c8ee4bb399cfe75a8a095dc121183c1ba0ee0c34bfc80897a875dac1c9258c26c75daddc18bc2b0e8b5f5e8171e7b030b78b71fdc1d0db3f246849a09696
7
+ data.tar.gz: 846351ae31be705763d67ea66ccc460769d0781d0451b16dc6d2cf1949cddcece14649b2d961ee15f7cc9ee9b3ae2d5f78ef66b6fe746fa451d3abf6c5f11380
@@ -1,3 +1,7 @@
1
+ 4.0.9 / 2015-01-20
2
+ ==================
3
+ * Improve BibTeX::Value comparison
4
+
1
5
  4.0.8 / 2015-01-12
2
6
  ==================
3
7
  * Ruby 2.2 support
@@ -5,8 +5,8 @@ require 'bibtex'
5
5
  require 'yaml'
6
6
 
7
7
  if ARGV.length < 1
8
- puts "Usage: #{$0} <bib> [<yml>]"
8
+ puts "Usage: #{$0} <bib> [<yml>]"
9
9
  else
10
10
  out = ARGV.length == 2 ? File.open(ARGV[1], 'w') : STDOUT
11
11
  out.puts BibTeX.open(ARGV[0]).to_yaml
12
- end
12
+ end
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # BibTeX-Ruby
3
- # Copyright (C) 2010-2014 Sylvester Keil <sylvester.keil.or.at>
3
+ # Copyright (C) 2010-2015 Sylvester Keil <sylvester.keil.or.at>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # BibTeX-Ruby
3
- # Copyright (C) 2010-2014 Sylvester Keil <sylvester.keil.or.at>
3
+ # Copyright (C) 2010-2015 Sylvester Keil <sylvester.keil.or.at>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # BibTeX-Ruby
3
- # Copyright (C) 2010-2014 Sylvester Keil <sylvester.keil.or.at>
3
+ # Copyright (C) 2010-2015 Sylvester Keil <sylvester.keil.or.at>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # BibTeX-Ruby
3
- # Copyright (C) 2010-2014 Sylvester Keil <sylvester.keil.or.at>
3
+ # Copyright (C) 2010-2015 Sylvester Keil <sylvester.keil.or.at>
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,17 +1,17 @@
1
1
  #--
2
2
  # BibTeX-Ruby
3
3
  # Copyright (C) 2011 Sylvester Keil <sylvester.keil.or.at>
4
- #
4
+ #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
7
7
  # the Free Software Foundation, either version 3 of the License, or
8
8
  # (at your option) any later version.
9
- #
9
+ #
10
10
  # This program is distributed in the hope that it will be useful,
11
11
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
  # GNU General Public License for more details.
14
- #
14
+ #
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  #++
@@ -21,5 +21,5 @@ module BibTeX
21
21
  module Extensions
22
22
 
23
23
  end
24
-
25
- end
24
+
25
+ end
@@ -1,13 +1,13 @@
1
1
  require 'latex/decode'
2
-
2
+
3
3
  module BibTeX
4
4
  module Filters
5
-
5
+
6
6
  class LaTeX < Filter
7
7
  def apply(value)
8
8
  ::LaTeX.decode(value)
9
9
  end
10
10
  end
11
-
11
+
12
12
  end
13
- end
13
+ end
@@ -1,11 +1,11 @@
1
1
  module BibTeX
2
2
  module Filters
3
-
3
+
4
4
  class LineBreaks < Filter
5
5
  def apply(value)
6
6
  value.to_s.gsub(/\n\s*/, ' ')
7
7
  end
8
8
  end
9
-
9
+
10
10
  end
11
- end
11
+ end
@@ -1,17 +1,17 @@
1
1
  #--
2
2
  # BibTeX-Ruby
3
- # Copyright (C) 2010-2014 Sylvester Keil <http://sylvester.keil.or.at>
4
- #
3
+ # Copyright (C) 2010-2015 Sylvester Keil <http://sylvester.keil.or.at>
4
+ #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
7
7
  # the Free Software Foundation, either version 3 of the License, or
8
8
  # (at your option) any later version.
9
- #
9
+ #
10
10
  # This program is distributed in the hope that it will be useful,
11
11
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
  # GNU General Public License for more details.
14
- #
14
+ #
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  #++
@@ -19,7 +19,7 @@
19
19
  require 'strscan'
20
20
 
21
21
  module BibTeX
22
-
22
+
23
23
  #
24
24
  # The BibTeX::Lexer handles the lexical analysis of BibTeX bibliographies.
25
25
  #
@@ -28,7 +28,7 @@ module BibTeX
28
28
 
29
29
  attr_reader :options, :stack, :mode, :scanner
30
30
  attr_writer :mode
31
-
31
+
32
32
  def_delegator :@scanner, :string, :data
33
33
 
34
34
  @defaults = {
@@ -37,7 +37,7 @@ module BibTeX
37
37
  :allow_missing_keys => false,
38
38
  :strip => true
39
39
  }.freeze
40
-
40
+
41
41
  # Patterns Cache (#37: MacRuby does not cache regular expressions)
42
42
  @patterns = {
43
43
  :space => /[\s]+/o,
@@ -62,18 +62,18 @@ module BibTeX
62
62
  :key => /\s*[[:alpha:][:digit:] \/:_!$\?\.%+;&\*-]+,/io,
63
63
  :optional_key => /\s*[[:alpha:][:digit:] \/:_!$\?\.%+;&\*-]*,/io
64
64
  }.freeze
65
-
65
+
66
66
  MODE = Hash.new(:meta).merge({
67
67
  :bibtex => :bibtex, :entry => :bibtex,
68
68
  :string => :bibtex, :preamble => :bibtex,
69
69
  :comment => :bibtex, :meta => :meta,
70
70
  :literal => :literal, :content => :content
71
71
  }).freeze
72
-
72
+
73
73
  class << self
74
74
  attr_reader :defaults, :patterns
75
75
  end
76
-
76
+
77
77
  #
78
78
  # Creates a new instance. Possible options and their respective
79
79
  # default values are:
@@ -96,14 +96,14 @@ module BibTeX
96
96
  def reset
97
97
  @stack, @brace_level, @mode, @active_object = [], 0, :meta, nil
98
98
  @scanner.reset if @scanner
99
-
99
+
100
100
  # cache options for speed
101
101
  @include_meta_content = @options[:include].include?(:meta_content)
102
102
  @include_errors = @options[:include].include?(:errors)
103
-
103
+
104
104
  self
105
105
  end
106
-
106
+
107
107
  # Sets the source for the lexical analysis and resets the internal state.
108
108
  def data=(data)
109
109
  @scanner = StringScanner.new(data)
@@ -111,7 +111,7 @@ module BibTeX
111
111
  end
112
112
 
113
113
  def symbols; @stack.map(&:first); end
114
-
114
+
115
115
  # Returns the next token from the parse stack.
116
116
  def next_token; @stack.shift; end
117
117
 
@@ -119,7 +119,7 @@ module BibTeX
119
119
  def bibtex_mode?
120
120
  MODE[@mode] == :bibtex
121
121
  end
122
-
122
+
123
123
  [:meta, :literal, :content].each do |m|
124
124
  define_method("#{m}_mode?") { @mode == m }
125
125
  end
@@ -128,26 +128,26 @@ module BibTeX
128
128
  def active?(object)
129
129
  @active_object == object
130
130
  end
131
-
131
+
132
132
  # Returns true if the lexer is currently in strict mode.
133
133
  def strict?
134
134
  !!@options[:strict]
135
135
  end
136
-
136
+
137
137
  def allow_missing_keys?
138
138
  !!@options[:allow_missing_keys]
139
139
  end
140
-
140
+
141
141
  def strip_line_breaks?
142
142
  !!options[:strip] && !active?(:comment)
143
143
  end
144
-
144
+
145
145
  # Pushes a value onto the parse stack. Returns the Lexer.
146
146
  def push(value)
147
147
  case value[0]
148
148
  when :CONTENT, :STRING_LITERAL
149
149
  value[1].gsub!(/\n\s*/, ' ') if strip_line_breaks?
150
-
150
+
151
151
  if !@stack.empty? && value[0] == @stack[-1][0]
152
152
  @stack[-1][1] << value[1]
153
153
  else
@@ -156,22 +156,22 @@ module BibTeX
156
156
  when :ERROR
157
157
  @stack.push(value) if @include_errors
158
158
  leave_object
159
- when :META_CONTENT
159
+ when :META_CONTENT
160
160
  @stack.push(value) if @include_meta_content
161
161
  else
162
162
  @stack.push(value)
163
163
  end
164
-
164
+
165
165
  self
166
166
  end
167
167
 
168
168
  # Start the lexical analysis.
169
169
  def analyse(string = nil)
170
170
  raise(ArgumentError, 'Lexer: failed to start analysis: no source given!') unless
171
- string || @scanner
171
+ string || @scanner
172
172
 
173
173
  self.data = string || @scanner.string
174
-
174
+
175
175
  until @scanner.eos?
176
176
  send("parse_#{MODE[@mode]}")
177
177
  end
@@ -180,7 +180,7 @@ module BibTeX
180
180
  end
181
181
 
182
182
  private
183
-
183
+
184
184
  def parse_bibtex
185
185
  case
186
186
  when @scanner.scan(Lexer.patterns[:lbrace])
@@ -209,10 +209,10 @@ module BibTeX
209
209
  when @scanner.scan(Lexer.patterns[:space])
210
210
  # skip
211
211
  when @scanner.scan(Lexer.patterns[:period])
212
- error_unexpected_token
212
+ error_unexpected_token
213
213
  end
214
214
  end
215
-
215
+
216
216
  def parse_meta
217
217
  match = @scanner.scan_until(Lexer.patterns[strict? ? :strict_next : :next])
218
218
  if @scanner.matched
@@ -253,7 +253,7 @@ module BibTeX
253
253
  error_unterminated_content
254
254
  end
255
255
  end
256
-
256
+
257
257
  def parse_literal
258
258
  match = @scanner.scan_until(Lexer.patterns[:unquote])
259
259
  case @scanner.matched
@@ -281,7 +281,7 @@ module BibTeX
281
281
  error_unterminated_string
282
282
  end
283
283
  end
284
-
284
+
285
285
  # Called when the lexer encounters a new BibTeX object.
286
286
  def enter_object
287
287
  @brace_level = 0
@@ -300,7 +300,7 @@ module BibTeX
300
300
  when @scanner.scan(Lexer.patterns[:entry])
301
301
  @mode = @active_object = :entry
302
302
  push [:NAME, @scanner.matched]
303
-
303
+
304
304
  # TODO: DRY - try to parse key
305
305
  if @scanner.scan(Lexer.patterns[:lbrace])
306
306
  @brace_level += 1
@@ -311,10 +311,10 @@ module BibTeX
311
311
  push [:KEY, @scanner.matched.chop.strip]
312
312
  end
313
313
  end
314
-
314
+
315
315
  else
316
316
  error_unexpected_object
317
- end
317
+ end
318
318
  end
319
319
 
320
320
  # Called when parser leaves a BibTeX object.
@@ -326,7 +326,7 @@ module BibTeX
326
326
  BibTeX.log.warn("Lexer: unbalanced braces at #{@scanner.pos}; brace level #{@brace_level}; mode #{@mode.inspect}.")
327
327
  backtrace [:E_UNBALANCED, @scanner.matched]
328
328
  end
329
-
329
+
330
330
  def error_unterminated_string
331
331
  BibTeX.log.warn("Lexer: unterminated string at #{@scanner.pos}; brace level #{@brace_level}; mode #{@mode.inspect}.")
332
332
  backtrace [:E_UNTERMINATED_STRING, @scanner.matched]
@@ -336,7 +336,7 @@ module BibTeX
336
336
  BibTeX.log.warn("Lexer: unterminated content at #{@scanner.pos}; brace level #{@brace_level}; mode #{@mode.inspect}.")
337
337
  backtrace [:E_UNTERMINATED_CONTENT, @scanner.matched]
338
338
  end
339
-
339
+
340
340
  def error_unexpected_token
341
341
  BibTeX.log.warn("Lexer: unexpected token `#{@scanner.matched}' at #{@scanner.pos}; brace level #{@brace_level}; mode #{@mode.inspect}.")
342
342
  backtrace [:E_UNEXPECTED_TOKEN, @scanner.matched]
@@ -353,7 +353,7 @@ module BibTeX
353
353
  bt << error
354
354
  push [:ERROR,bt]
355
355
  end
356
-
356
+
357
357
  end
358
-
358
+
359
359
  end
@@ -296,7 +296,7 @@ Racc_debug_parser = false
296
296
 
297
297
  module_eval(<<'.,.,', 'names.y', 31)
298
298
  def _reduce_1(val, _values, result)
299
- result = []
299
+ result = []
300
300
  result
301
301
  end
302
302
  .,.,
@@ -305,14 +305,14 @@ module_eval(<<'.,.,', 'names.y', 31)
305
305
 
306
306
  module_eval(<<'.,.,', 'names.y', 33)
307
307
  def _reduce_3(val, _values, result)
308
- result = [val[0]]
308
+ result = [val[0]]
309
309
  result
310
310
  end
311
311
  .,.,
312
312
 
313
313
  module_eval(<<'.,.,', 'names.y', 34)
314
314
  def _reduce_4(val, _values, result)
315
- result << val[2]
315
+ result << val[2]
316
316
  result
317
317
  end
318
318
  .,.,
@@ -320,7 +320,7 @@ module_eval(<<'.,.,', 'names.y', 34)
320
320
  module_eval(<<'.,.,', 'names.y', 38)
321
321
  def _reduce_5(val, _values, result)
322
322
  result = Name.new(:last => val[0])
323
-
323
+
324
324
  result
325
325
  end
326
326
  .,.,
@@ -328,7 +328,7 @@ module_eval(<<'.,.,', 'names.y', 38)
328
328
  module_eval(<<'.,.,', 'names.y', 42)
329
329
  def _reduce_6(val, _values, result)
330
330
  result = Name.new(:first => val[0], :last => val[1])
331
-
331
+
332
332
  result
333
333
  end
334
334
  .,.,
@@ -336,7 +336,7 @@ module_eval(<<'.,.,', 'names.y', 42)
336
336
  module_eval(<<'.,.,', 'names.y', 46)
337
337
  def _reduce_7(val, _values, result)
338
338
  result = Name.new(:first => val[0], :von => val[1], :last => val[2])
339
-
339
+
340
340
  result
341
341
  end
342
342
  .,.,
@@ -344,7 +344,7 @@ module_eval(<<'.,.,', 'names.y', 46)
344
344
  module_eval(<<'.,.,', 'names.y', 50)
345
345
  def _reduce_8(val, _values, result)
346
346
  result = Name.new(:von => val[0], :last => val[1])
347
-
347
+
348
348
  result
349
349
  end
350
350
  .,.,
@@ -352,7 +352,7 @@ module_eval(<<'.,.,', 'names.y', 50)
352
352
  module_eval(<<'.,.,', 'names.y', 54)
353
353
  def _reduce_9(val, _values, result)
354
354
  result = Name.new(:last => val[0], :jr => val[2][0], :first => val[2][1])
355
-
355
+
356
356
  result
357
357
  end
358
358
  .,.,
@@ -360,7 +360,7 @@ module_eval(<<'.,.,', 'names.y', 54)
360
360
  module_eval(<<'.,.,', 'names.y', 58)
361
361
  def _reduce_10(val, _values, result)
362
362
  result = Name.new(:von => val[0], :last => val[1], :jr => val[3][0], :first => val[3][1])
363
-
363
+
364
364
  result
365
365
  end
366
366
  .,.,
@@ -368,7 +368,7 @@ module_eval(<<'.,.,', 'names.y', 58)
368
368
  module_eval(<<'.,.,', 'names.y', 62)
369
369
  def _reduce_11(val, _values, result)
370
370
  result = Name.new(:von => val[0,2].join(' '), :last => val[2], :jr => val[4][0], :first => val[4][1])
371
-
371
+
372
372
  result
373
373
  end
374
374
  .,.,
@@ -377,14 +377,14 @@ module_eval(<<'.,.,', 'names.y', 62)
377
377
 
378
378
  module_eval(<<'.,.,', 'names.y', 67)
379
379
  def _reduce_13(val, _values, result)
380
- result = val.join(' ')
380
+ result = val.join(' ')
381
381
  result
382
382
  end
383
383
  .,.,
384
384
 
385
385
  module_eval(<<'.,.,', 'names.y', 68)
386
386
  def _reduce_14(val, _values, result)
387
- result = val.join(' ')
387
+ result = val.join(' ')
388
388
  result
389
389
  end
390
390
  .,.,
@@ -395,14 +395,14 @@ module_eval(<<'.,.,', 'names.y', 68)
395
395
 
396
396
  module_eval(<<'.,.,', 'names.y', 72)
397
397
  def _reduce_17(val, _values, result)
398
- result = [nil,val[0]]
398
+ result = [nil,val[0]]
399
399
  result
400
400
  end
401
401
  .,.,
402
402
 
403
403
  module_eval(<<'.,.,', 'names.y', 73)
404
404
  def _reduce_18(val, _values, result)
405
- result = [val[0],val[2]]
405
+ result = [val[0],val[2]]
406
406
  result
407
407
  end
408
408
  .,.,
@@ -411,7 +411,7 @@ module_eval(<<'.,.,', 'names.y', 73)
411
411
 
412
412
  module_eval(<<'.,.,', 'names.y', 76)
413
413
  def _reduce_20(val, _values, result)
414
- result = val.join(' ')
414
+ result = val.join(' ')
415
415
  result
416
416
  end
417
417
  .,.,
@@ -424,7 +424,7 @@ module_eval(<<'.,.,', 'names.y', 76)
424
424
 
425
425
  module_eval(<<'.,.,', 'names.y', 81)
426
426
  def _reduce_24(val, _values, result)
427
- result = val.join(' ')
427
+ result = val.join(' ')
428
428
  result
429
429
  end
430
430
  .,.,