bibtex-ruby 3.1.4 → 3.1.5
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.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/Rakefile +0 -2
- data/lib/bibtex/names.rb +14 -2
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_names.rb +28 -0
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9c5960eac9a590e5f05b0a5527dd2ad0943d6ae
|
4
|
+
data.tar.gz: adb8c68069904a0d342bfdbad92bc1f0d8525cea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb4aa621fcef9031ad62dece59b9c2efe4c506d4f20253f69e78fbc82487e7a43cae2bec14fa02fa7979ac26771b7fc78428e5da8ddfcd7de1a28fc4e54f2eb
|
7
|
+
data.tar.gz: 423c6b640f45762e512bb90ee9baa00f11247cfe7a1a5b04c0aa87d148a7e47bf1805d42fab8a3bdb30ced56916e1502e6798d9fba019b33698237fda5889a8e
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/lib/bibtex/names.rb
CHANGED
@@ -164,7 +164,14 @@ module BibTeX
|
|
164
164
|
|
165
165
|
# Returns the first name (or the passed-in string) as initials.
|
166
166
|
def initials(token = first)
|
167
|
-
token.to_s.gsub(/([[:upper:]])[[:
|
167
|
+
token.to_s.gsub(/([[:upper:]])[^[:upper:]\s-]*\s*/, '\1.')
|
168
|
+
end
|
169
|
+
|
170
|
+
def normalize_initials(token = first)
|
171
|
+
token = token.dup.to_s
|
172
|
+
token.gsub!(/([[:upper:]])([[:upper:]])/, '\1 \2')
|
173
|
+
token.gsub!(/\b([[:upper:]])\b[^[:alpha:]-]*/, '\1.')
|
174
|
+
token
|
168
175
|
end
|
169
176
|
|
170
177
|
# Returns true if the first name consists solely of initials.
|
@@ -176,7 +183,12 @@ module BibTeX
|
|
176
183
|
# for_last and the current first name has the same initials as with_first.
|
177
184
|
def extend_initials(with_first, for_last)
|
178
185
|
rename_if :first => with_first do |name|
|
179
|
-
name.last == for_last
|
186
|
+
if name.last == for_last
|
187
|
+
mine = name.initials.split(/\.[^[:alpha:]]*/)
|
188
|
+
other = initials(with_first).split(/\.[^[:alpha:]]*/)
|
189
|
+
|
190
|
+
mine == other || mine.length < other.length && mine == other[0, mine.length]
|
191
|
+
end
|
180
192
|
end
|
181
193
|
end
|
182
194
|
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_names.rb
CHANGED
@@ -101,13 +101,41 @@ module BibTeX
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
describe '#normalize_initials' do
|
105
|
+
it 'returns normalized initials of existing initials only' do
|
106
|
+
Name.new(:first => 'Edgar A.', :last => 'Poe').normalize_initials.must_equal 'Edgar A.'
|
107
|
+
Name.new(:first => 'E.A.', :last => 'Poe').normalize_initials.must_equal 'E.A.'
|
108
|
+
Name.new(:first => 'E. A.', :last => 'Poe').normalize_initials.must_equal 'E.A.'
|
109
|
+
Name.new(:first => 'E. A', :last => 'Poe').normalize_initials.must_equal 'E.A.'
|
110
|
+
Name.new(:first => 'E A', :last => 'Poe').normalize_initials.must_equal 'E.A.'
|
111
|
+
Name.new(:first => 'Edgar A P', :last => 'Poe').normalize_initials.must_equal 'Edgar A.P.'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
104
115
|
describe '#extend_initials' do
|
105
116
|
it 'extends the first name if the last name and initials match' do
|
106
117
|
Name.new(:first => 'E.A.', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
107
118
|
Name.new(:first => 'Edgar A.', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
108
119
|
Name.new(:first => 'E. A.', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
120
|
+
Name.new(:first => 'E. A', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
121
|
+
Name.new(:first => 'E A', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
109
122
|
Name.new(:first => 'E. Allen', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
110
123
|
Name.new(:first => 'E.A.', :last => 'Poe').extend_initials('Edgar A.', 'Poe').first.must_equal 'Edgar A.'
|
124
|
+
|
125
|
+
Name.new(:first => 'Edgar-A.', :last => 'Poe').extend_initials('Edgar-Allen', 'Poe').first.must_equal 'Edgar-Allen'
|
126
|
+
Name.new(:first => 'E.-Allen', :last => 'Poe').extend_initials('Edgar-Allen', 'Poe').first.must_equal 'Edgar-Allen'
|
127
|
+
Name.new(:first => 'E.-A.', :last => 'Poe').extend_initials('Edgar-Allen', 'Poe').first.must_equal 'Edgar-Allen'
|
128
|
+
Name.new(:first => 'E.-A', :last => 'Poe').extend_initials('Edgar-Allen', 'Poe').first.must_equal 'Edgar-Allen'
|
129
|
+
Name.new(:first => 'E-A', :last => 'Poe').extend_initials('Edgar-Allen', 'Poe').first.must_equal 'Edgar-Allen'
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'extends the first name if the last name and initials name match with extra middle names' do
|
133
|
+
Name.new(:first => 'E.', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
134
|
+
Name.new(:first => 'E', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
135
|
+
Name.new(:first => 'Edgar', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
|
136
|
+
|
137
|
+
Name.new(:first => 'E.A.', :last => 'Poe').extend_initials('Edgar', 'Poe').first.must_equal 'E.A.'
|
138
|
+
Name.new(:first => 'A.', :last => 'Poe').extend_initials('Edgar', 'Poe').first.must_equal 'A.'
|
111
139
|
end
|
112
140
|
|
113
141
|
it 'does not extend the first name if the last name or initials do not match' do
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.5
|
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-03-
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.0'
|
27
27
|
description: |
|
@@ -135,12 +135,12 @@ require_paths:
|
|
135
135
|
- lib
|
136
136
|
required_ruby_version: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- -
|
138
|
+
- - '>='
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - '>='
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
@@ -150,18 +150,18 @@ signing_key:
|
|
150
150
|
specification_version: 4
|
151
151
|
summary: A BibTeX parser, converter and API for Ruby.
|
152
152
|
test_files:
|
153
|
-
- test/bibtex/
|
153
|
+
- test/bibtex/entry/test_rdf_converter.rb
|
154
|
+
- test/bibtex/test_bibliography.rb
|
155
|
+
- test/bibtex/test_elements.rb
|
156
|
+
- test/bibtex/test_entry.rb
|
157
|
+
- test/bibtex/test_filters.rb
|
154
158
|
- test/bibtex/test_lexer.rb
|
159
|
+
- test/bibtex/test_name_parser.rb
|
155
160
|
- test/bibtex/test_names.rb
|
156
161
|
- test/bibtex/test_parser.rb
|
157
|
-
- test/bibtex/test_bibliography.rb
|
158
|
-
- test/bibtex/test_filters.rb
|
159
|
-
- test/bibtex/test_utilities.rb
|
160
162
|
- test/bibtex/test_string.rb
|
161
|
-
- test/bibtex/
|
162
|
-
- test/bibtex/
|
163
|
-
- test/bibtex/test_elements.rb
|
164
|
-
- test/bibtex/entry/test_rdf_converter.rb
|
163
|
+
- test/bibtex/test_utilities.rb
|
164
|
+
- test/bibtex/test_value.rb
|
165
165
|
- test/test_bibtex.rb
|
166
166
|
- test/test_export.rb
|
167
167
|
has_rdoc: yard
|