anystyle-parser 0.6.12 → 0.6.13
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.
- checksums.yaml +4 -4
- data/lib/anystyle/parser/normalizer.rb +1 -1
- data/lib/anystyle/parser/version.rb +1 -1
- data/spec/anystyle/parser/normalizer_spec.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c1af591f965670f8ec9463f412b95e5f3f95c9e
|
4
|
+
data.tar.gz: 5e61d0dae3c5bf8fac0b3e038ec02538031ac702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b08d209cb523f7aad6b9c92533e361958feca1ca80e52b165f3fc2eba31d7623a0add19c3e3173190beeeb64ce0769763e3f0724f656fbe7c9b96198d5e7e457
|
7
|
+
data.tar.gz: 6cb39624162a081ea0c55452ee7f7727b5bb1783f4647a1e5970b5d93627c856631feed611416307b1d5b68f1f6317bbd8ae23245ed93be1e9351446308eddf4
|
@@ -91,7 +91,7 @@ module Anystyle
|
|
91
91
|
authors, *dangling = hash[:author]
|
92
92
|
unmatched(:author, hash, dangling) unless dangling.empty?
|
93
93
|
|
94
|
-
if authors =~ /\b[Ee]d(s|itors)
|
94
|
+
if authors =~ /\b[Ee]d((s|itors?|ited)\b|\.)/ && !hash.has_key?(:editor)
|
95
95
|
hash[:editor] = hash.delete(:author)
|
96
96
|
hash = normalize_editor(hash)
|
97
97
|
else
|
@@ -64,6 +64,33 @@ module Anystyle
|
|
64
64
|
|
65
65
|
end
|
66
66
|
|
67
|
+
describe '#normalize_author' do
|
68
|
+
it "detects editors" do
|
69
|
+
expect(n.normalize_author(:author => 'In D. Knuth (ed.)'))
|
70
|
+
.to eq({ :editor => 'Knuth, D.' })
|
71
|
+
|
72
|
+
expect(n.normalize_author(:author => 'D. Knuth (editor)'))
|
73
|
+
.to eq({ :editor => 'Knuth, D.' })
|
74
|
+
|
75
|
+
expect(n.normalize_author(:author => 'D. Knuth (eds.)'))
|
76
|
+
.to eq({ :editor => 'Knuth, D.' })
|
77
|
+
|
78
|
+
expect(n.normalize_author(:author => 'Ed. by D. Knuth'))
|
79
|
+
.to eq({ :editor => 'Knuth, D.' })
|
80
|
+
|
81
|
+
expect(n.normalize_author(:author => 'Edited by D. Knuth'))
|
82
|
+
.to eq({ :editor => 'Knuth, D.' })
|
83
|
+
end
|
84
|
+
|
85
|
+
it "does not erroneously detect editors" do
|
86
|
+
expect(n.normalize_author(:author => 'Eisenberger, P. and Read, W.A.'))
|
87
|
+
.to eq({ :author => 'Eisenberger, P. and Read, W.A.' })
|
88
|
+
|
89
|
+
expect(n.normalize_author(:author => 'K. S. Sohn, D. G. Dempsey, L. Kleinman and Ed Caruthers'))
|
90
|
+
.to eq({ :author => 'Sohn, K.S. and Dempsey, D.G. and Kleinman, L. and Caruthers, Ed' })
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
67
94
|
describe '#normalize_editor' do
|
68
95
|
it "strips in from beginning" do
|
69
96
|
expect(n.normalize_editor(:editor => 'In D. Knuth (ed.)')).to eq({ :editor => 'Knuth, D.' })
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anystyle-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bibtex-ruby
|