bibtex-ruby 3.1.2 → 3.1.3

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: c042ba0b1e7763904a6e41fa5c0d3de2df2c1963
4
- data.tar.gz: 8bbe22f8178cd6e3072093d2b3bb83fc03145061
3
+ metadata.gz: 776c0bde07264d1b4f928d73c70575ccda925aeb
4
+ data.tar.gz: 87529a9bf231b57e3cbd6f63c1f96de3ad8bc1f7
5
5
  SHA512:
6
- metadata.gz: 296d227e81b7e250bf4bad9385d4a6e6cdc1183385ec4074faac0328824f9718446990b95f7adba20272c930b7ace932a61dddcb5bb68349900c2d0a4a4d3ad6
7
- data.tar.gz: f15dfaff08f2883c5b304b164e01f0cb39f7ef8e0c267ecfad3d43260e1e6a295adb21c0df1592915534fcccc27e4d3fd956dd8ada0817e55ca007b42f33cfbd
6
+ metadata.gz: f0cdb11eba57bd1ddf8509a9f92c2e4bbdaa448ad0f8164b54990e70951d84693a233a61a2e200c9dcc8d4eb8f42b48e2efa52789fcd55ce75aa2635e8bf9eab
7
+ data.tar.gz: 49f8e36b32eb635b1c7a5367942378b802b7ce66aa004b2c69a491285afcec9fd9e6aa4d74afcc39cb9d938ee3659fd90450d327ab982b12b34427930bdc3bd6
@@ -1,3 +1,8 @@
1
+ 3.1.3 / 2014-02-10
2
+ ==================
3
+
4
+ * Fix Ruby warnings
5
+
1
6
  3.1.2 / 2014-01-29
2
7
  ==================
3
8
 
data/Rakefile CHANGED
@@ -71,6 +71,13 @@ task :console, [:script] do |t,args|
71
71
  IRB.start
72
72
  end
73
73
 
74
+ task :check_warnings do
75
+ $VERBOSE = true
76
+ require 'bibtex'
77
+
78
+ puts BibTeX::Version::STRING
79
+ end
80
+
74
81
 
75
82
  desc 'Runs the benchmarks (and plots the results)'
76
83
  task :benchmark => ['racc'] do
@@ -21,7 +21,7 @@ class BibTeX::Bibliography::RDFConverter
21
21
  graph
22
22
  end
23
23
 
24
- private
24
+ protected
25
25
 
26
26
  attr_reader :bibtex, :graph, :agent
27
27
  end
@@ -1,24 +1,9 @@
1
1
  # coding: utf-8
2
2
 
3
- unless Symbol.include?(Comparable)
4
- class Symbol
5
- include Comparable
6
- def <=>(other)
7
- return nil unless other.is_a?(String) || other.is_a?(Symbol)
8
- to_s <=> other.to_s
9
- end
10
- end
11
- end
12
-
13
- if RUBY_VERSION < '1.9'
14
- $KCODE = 'u'
15
- require 'jcode'
16
-
17
- BibTeX::NameParser.patterns[:upper] = /[[:upper:]ÄÖÜ][^\t\r\n\s\{\}\d\\,]*/o
18
- end
19
-
20
3
  module BibTeX
21
4
  begin
5
+ original_verbosity, $VERBOSE = $VERBOSE, nil
6
+
22
7
  require 'iconv'
23
8
 
24
9
  @iconv = Iconv.new('ascii//translit//ignore', 'utf-8')
@@ -34,5 +19,7 @@ module BibTeX
34
19
  def self.transliterate(str)
35
20
  str.gsub(/[äöüÄÖÜß]/, @iconv_replacements)
36
21
  end
22
+ ensure
23
+ $VERBOSE = original_verbosity
37
24
  end
38
25
  end
@@ -109,24 +109,33 @@ module BibTeX
109
109
  self
110
110
  end
111
111
 
112
- # Generate Accessors for required fields (#52)
113
-
112
+ # Generate accessors for required fields (#52)
114
113
  REQUIRED_FIELDS.values.flatten.uniq.each do |name|
115
-
116
114
  define_method(name) do
117
- case
118
- when fields.has_key?(name)
119
- fields[name]
120
- when has_parent? && parent.provides?(name)
121
- parent.provide(name)
122
- else
123
- nil
124
- end
125
- end
115
+ get name
116
+ end unless method_defined? name
117
+
118
+ writer = "#{name}="
126
119
 
127
- define_method("#{name}=") do |value|
120
+ define_method(writer) do |value|
128
121
  add name, value
129
- end
122
+ end unless method_defined? writer
123
+ end
124
+
125
+ # Generate author, editor and translator accessors
126
+ NAME_FIELDS.each do |contributor|
127
+ define_method(contributor) do
128
+ get contributor
129
+ end unless method_defined? contributor
130
+
131
+ writer = "#{contributor}="
132
+
133
+ define_method(writer) do |value|
134
+ add contributor, value
135
+ end unless method_defined? writer
136
+
137
+ alias_method "#{contributor}s", contributor
138
+ alias_method "#{contributor}s=", writer
130
139
  end
131
140
 
132
141
  # call-seq:
@@ -336,16 +345,6 @@ module BibTeX
336
345
  add(name.to_sym, value)
337
346
  end
338
347
 
339
- # Author, Editor and Translator readers
340
- NAME_FIELDS.each do |contributor|
341
- define_method(contributor) do
342
- get(contributor)
343
- end
344
-
345
- alias_method "#{contributor}s", contributor
346
- end
347
-
348
-
349
348
  # call-seq:
350
349
  # add(:author, "Edgar A. Poe")
351
350
  # add(:author, "Edgar A. Poe", :title, "The Raven")
@@ -34,7 +34,7 @@ class BibTeX::Entry::BibTeXMLConverter
34
34
  end
35
35
  end
36
36
 
37
- private
37
+ protected
38
38
 
39
39
  attr_reader :bibtex, :options
40
40
 
@@ -129,7 +129,7 @@ class BibTeX::Entry::CiteProcConverter
129
129
  end
130
130
  end
131
131
 
132
- private
132
+ protected
133
133
 
134
134
  attr_reader :bibtex, :options
135
135
 
@@ -512,10 +512,12 @@ class BibTeX::Entry::RDFConverter
512
512
  graph << [entry, RDF::DC.issued, date]
513
513
  end
514
514
 
515
- private
515
+ protected
516
516
 
517
517
  attr_reader :bibtex, :graph
518
518
 
519
+ private
520
+
519
521
  def bibo
520
522
  @bibo ||= RDF::Vocabulary.new('http://purl.org/ontology/bibo/')
521
523
  end
@@ -12,24 +12,24 @@ module BibTeX
12
12
  class NameParser < Racc::Parser
13
13
 
14
14
  module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
15
-
15
+
16
16
  @patterns = {
17
17
  :and => /,?\s+and\s+/io,
18
- :space => /[\t\r\n\s]+/o,
18
+ :space => /\s+/o,
19
19
  :comma => /,/o,
20
- :lower => /[[:lower:]][^\t\r\n\s\{\}\d\\,]*/o,
21
- :upper => /[[:upper:]][^\t\r\n\s\{\}\d\\,]*/uo,
20
+ :lower => /[[:lower:]][^\s\{\}\d\\,]*/o,
21
+ :upper => /[[:upper:]][^\s\{\}\d\\,]*/uo,
22
22
  :symbols => /(\d|\\.)+/o,
23
23
  :lbrace => /\{/o,
24
24
  :rbrace => /\}/o,
25
25
  :period => /./o,
26
26
  :braces => /[\{\}]/o
27
27
  }
28
-
28
+
29
29
  class << self
30
30
  attr_reader :patterns
31
31
  end
32
-
32
+
33
33
  def initialize(options = {})
34
34
  self.options.merge!(options)
35
35
  end
@@ -37,17 +37,17 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
37
37
  def options
38
38
  @options ||= { :debug => ENV['DEBUG'] == true }
39
39
  end
40
-
40
+
41
41
  def parse(input)
42
42
  @yydebug = options[:debug]
43
43
  scan(input)
44
44
  do_parse
45
45
  end
46
-
46
+
47
47
  def next_token
48
48
  @stack.shift
49
49
  end
50
-
50
+
51
51
  def on_error(tid, val, vstack)
52
52
  BibTeX.log.error("Failed to parse BibTeX Name on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
53
53
  end
@@ -59,7 +59,7 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
59
59
  @word = [:PWORD,'']
60
60
  do_scan
61
61
  end
62
-
62
+
63
63
  private
64
64
 
65
65
  def do_scan
@@ -68,14 +68,14 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
68
68
  when @src.scan(NameParser.patterns[:and])
69
69
  push_word
70
70
  @stack.push([:AND,@src.matched])
71
-
71
+
72
72
  when @src.scan(NameParser.patterns[:space])
73
73
  push_word
74
-
74
+
75
75
  when @src.scan(NameParser.patterns[:comma])
76
76
  push_word
77
77
  @stack.push([:COMMA,@src.matched])
78
-
78
+
79
79
  when @src.scan(NameParser.patterns[:lower])
80
80
  is_lowercase
81
81
  @word[1] << @src.matched
@@ -83,14 +83,14 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
83
83
  when @src.scan(NameParser.patterns[:upper])
84
84
  is_uppercase
85
85
  @word[1] << @src.matched
86
-
86
+
87
87
  when @src.scan(NameParser.patterns[:symbols])
88
88
  @word[1] << @src.matched
89
-
89
+
90
90
  when @src.scan(NameParser.patterns[:lbrace])
91
91
  @word[1] << @src.matched
92
92
  scan_literal
93
-
93
+
94
94
  when @src.scan(NameParser.patterns[:rbrace])
95
95
  error_unbalanced
96
96
 
@@ -98,18 +98,18 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
98
98
  @word[1] << @src.matched
99
99
  end
100
100
  end
101
-
101
+
102
102
  push_word
103
103
  @stack
104
104
  end
105
-
105
+
106
106
  def push_word
107
107
  unless @word[1].empty?
108
108
  @stack.push(@word)
109
109
  @word = [:PWORD,'']
110
110
  end
111
111
  end
112
-
112
+
113
113
  def is_lowercase
114
114
  @word[0] = :LWORD if @word[0] == :PWORD
115
115
  end
@@ -117,7 +117,7 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
117
117
  def is_uppercase
118
118
  @word[0] = :UWORD if @word[0] == :PWORD
119
119
  end
120
-
120
+
121
121
  def scan_literal
122
122
  @brace_level = 1
123
123
 
@@ -140,12 +140,12 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
140
140
  @stack.push [:ERROR,@src.matched]
141
141
  BibTeX.log.warn("NameParser: unexpected token `#{@src.matched}' at position #{@src.pos}; brace level #{@brace_level}.")
142
142
  end
143
-
143
+
144
144
  def error_unbalanced
145
145
  @stack.push [:ERROR,'}']
146
146
  BibTeX.log.warn("NameParser: unbalanced braces at position #{@src.pos}; brace level #{@brace_level}.")
147
147
  end
148
-
148
+
149
149
  # -*- racc -*-
150
150
  ...end names.y/module_eval...
151
151
  ##### State transition tables begin ###
@@ -444,4 +444,4 @@ def _reduce_none(val, _values, result)
444
444
  end
445
445
 
446
446
  end # class NameParser
447
- end # module BibTeX
447
+ end # module BibTeX
@@ -1,17 +1,17 @@
1
1
  #--
2
2
  # BibTeX-Ruby
3
3
  # Copyright (C) 2010-2011 Sylvester Keil <http://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
  #++
@@ -33,7 +33,7 @@ rule
33
33
 
34
34
  names : name { result = [val[0]] }
35
35
  | names AND name { result << val[2] }
36
-
36
+
37
37
  name : word
38
38
  {
39
39
  result = Name.new(:last => val[0])
@@ -69,10 +69,10 @@ rule
69
69
  | von u_words LWORD { result = val.join(' ') }
70
70
 
71
71
  last : LWORD | u_words
72
-
72
+
73
73
  first : opt_words { result = [nil,val[0]] }
74
74
  | opt_words COMMA opt_words { result = [val[0],val[2]] }
75
-
75
+
76
76
  u_words : u_word
77
77
  | u_words u_word { result = val.join(' ') }
78
78
 
@@ -82,7 +82,7 @@ rule
82
82
  | words word { result = val.join(' ') }
83
83
 
84
84
  opt_words : /* empty */ | words
85
-
85
+
86
86
  word : LWORD | UWORD | PWORD
87
87
 
88
88
  end
@@ -91,24 +91,24 @@ end
91
91
  require 'strscan'
92
92
 
93
93
  ---- inner
94
-
94
+
95
95
  @patterns = {
96
96
  :and => /,?\s+and\s+/io,
97
- :space => /[\t\r\n\s]+/o,
97
+ :space => /\s+/o,
98
98
  :comma => /,/o,
99
- :lower => /[[:lower:]][^\t\r\n\s\{\}\d\\,]*/o,
100
- :upper => /[[:upper:]][^\t\r\n\s\{\}\d\\,]*/uo,
99
+ :lower => /[[:lower:]][^\s\{\}\d\\,]*/o,
100
+ :upper => /[[:upper:]][^\s\{\}\d\\,]*/uo,
101
101
  :symbols => /(\d|\\.)+/o,
102
102
  :lbrace => /\{/o,
103
103
  :rbrace => /\}/o,
104
104
  :period => /./o,
105
105
  :braces => /[\{\}]/o
106
106
  }
107
-
107
+
108
108
  class << self
109
109
  attr_reader :patterns
110
110
  end
111
-
111
+
112
112
  def initialize(options = {})
113
113
  self.options.merge!(options)
114
114
  end
@@ -116,17 +116,17 @@ require 'strscan'
116
116
  def options
117
117
  @options ||= { :debug => ENV['DEBUG'] == true }
118
118
  end
119
-
119
+
120
120
  def parse(input)
121
121
  @yydebug = options[:debug]
122
122
  scan(input)
123
123
  do_parse
124
124
  end
125
-
125
+
126
126
  def next_token
127
127
  @stack.shift
128
128
  end
129
-
129
+
130
130
  def on_error(tid, val, vstack)
131
131
  BibTeX.log.error("Failed to parse BibTeX Name on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
132
132
  end
@@ -138,7 +138,7 @@ require 'strscan'
138
138
  @word = [:PWORD,'']
139
139
  do_scan
140
140
  end
141
-
141
+
142
142
  private
143
143
 
144
144
  def do_scan
@@ -147,14 +147,14 @@ require 'strscan'
147
147
  when @src.scan(NameParser.patterns[:and])
148
148
  push_word
149
149
  @stack.push([:AND,@src.matched])
150
-
150
+
151
151
  when @src.scan(NameParser.patterns[:space])
152
152
  push_word
153
-
153
+
154
154
  when @src.scan(NameParser.patterns[:comma])
155
155
  push_word
156
156
  @stack.push([:COMMA,@src.matched])
157
-
157
+
158
158
  when @src.scan(NameParser.patterns[:lower])
159
159
  is_lowercase
160
160
  @word[1] << @src.matched
@@ -162,14 +162,14 @@ require 'strscan'
162
162
  when @src.scan(NameParser.patterns[:upper])
163
163
  is_uppercase
164
164
  @word[1] << @src.matched
165
-
165
+
166
166
  when @src.scan(NameParser.patterns[:symbols])
167
167
  @word[1] << @src.matched
168
-
168
+
169
169
  when @src.scan(NameParser.patterns[:lbrace])
170
170
  @word[1] << @src.matched
171
171
  scan_literal
172
-
172
+
173
173
  when @src.scan(NameParser.patterns[:rbrace])
174
174
  error_unbalanced
175
175
 
@@ -177,18 +177,18 @@ require 'strscan'
177
177
  @word[1] << @src.matched
178
178
  end
179
179
  end
180
-
180
+
181
181
  push_word
182
182
  @stack
183
183
  end
184
-
184
+
185
185
  def push_word
186
186
  unless @word[1].empty?
187
187
  @stack.push(@word)
188
188
  @word = [:PWORD,'']
189
189
  end
190
190
  end
191
-
191
+
192
192
  def is_lowercase
193
193
  @word[0] = :LWORD if @word[0] == :PWORD
194
194
  end
@@ -196,7 +196,7 @@ require 'strscan'
196
196
  def is_uppercase
197
197
  @word[0] = :UWORD if @word[0] == :PWORD
198
198
  end
199
-
199
+
200
200
  def scan_literal
201
201
  @brace_level = 1
202
202
 
@@ -219,10 +219,10 @@ require 'strscan'
219
219
  @stack.push [:ERROR,@src.matched]
220
220
  BibTeX.log.warn("NameParser: unexpected token `#{@src.matched}' at position #{@src.pos}; brace level #{@brace_level}.")
221
221
  end
222
-
222
+
223
223
  def error_unbalanced
224
224
  @stack.push [:ERROR,'}']
225
225
  BibTeX.log.warn("NameParser: unbalanced braces at position #{@src.pos}; brace level #{@brace_level}.")
226
226
  end
227
-
228
- # -*- racc -*-
227
+
228
+ # -*- racc -*-
@@ -471,4 +471,4 @@ def _reduce_none(val, _values, result)
471
471
  end
472
472
 
473
473
  end # class Parser
474
- end # module BibTeX
474
+ end # module BibTeX
@@ -22,7 +22,7 @@ require 'forwardable'
22
22
 
23
23
  module BibTeX
24
24
 
25
- #
25
+
26
26
  # A BibTeX Value is something very much like a string. In BibTeX files it
27
27
  # can appear on the right hand side of @string or @entry field assignments
28
28
  # or as @preamble contents. In the example below [VALUE] indicates possible
@@ -52,7 +52,11 @@ module BibTeX
52
52
  attr_reader :tokens
53
53
  alias to_a tokens
54
54
 
55
- def_delegators :to_s, :=~, :===, *String.instance_methods(false).reject { |m| m =~ /^\W|^length$|^dup$|!$/ }
55
+ def_delegators :to_s, :=~, :===,
56
+ *String.instance_methods(false).reject { |m|
57
+ m =~ /^\W|^(length|dup|replace|to_s|inspect)$|!$/
58
+ }
59
+
56
60
  def_delegators :@tokens, :[], :length
57
61
  def_delegator :@tokens, :each, :each_token
58
62
 
@@ -20,7 +20,7 @@ module BibTeX
20
20
  module Version
21
21
  MAJOR = 3
22
22
  MINOR = 1
23
- PATCH = 2
23
+ PATCH = 3
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibtex-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-29 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: latex-decode