anystyle 1.5.0 → 1.6.0
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/.github/workflows/ci.yml +2 -4
- data/HISTORY.md +4 -0
- data/lib/anystyle/feature/keyword.rb +2 -1
- data/lib/anystyle/format/ris.rb +78 -0
- data/lib/anystyle/parser.rb +3 -2
- data/lib/anystyle/version.rb +1 -1
- data/lib/anystyle.rb +1 -0
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ee4c3d7966aea4ee9ebe011d4a8bee37126caa2f0d1d44e3e238c66d15548f4
|
4
|
+
data.tar.gz: 6accc8256de87e852b4e8ef51485fce60fd566cf7614a1c1bd0b75c1e2ada9af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d56bfa4eb7b43302a2cd48558242ea9cd636efa0625a2217f06cbf318d788c6ef01f3b706a143fb15c0bc843ac6ea3cefba8da6046052dd1bef3967e72fb029
|
7
|
+
data.tar.gz: 4ab2159fada17aa37ab70c17060ab04d5e92cf3ec5a112045f1035828dba49272d6542395f533c44daaf31686ad00b3ede99b3059eb3b653ebf3d2b153a0ba52
|
data/.github/workflows/ci.yml
CHANGED
@@ -15,11 +15,9 @@ jobs:
|
|
15
15
|
strategy:
|
16
16
|
matrix:
|
17
17
|
ruby-version:
|
18
|
-
- "2.7"
|
19
|
-
- "3.0"
|
20
|
-
- "3.1"
|
21
18
|
- "3.2"
|
22
19
|
- "3.3"
|
20
|
+
- "3.4"
|
23
21
|
os:
|
24
22
|
- ubuntu-latest
|
25
23
|
- macos-latest
|
@@ -45,7 +43,7 @@ jobs:
|
|
45
43
|
- name: Compile and run test
|
46
44
|
run: bundle exec rake
|
47
45
|
- name: Upload coverage results
|
48
|
-
if: matrix.ruby-version == '3.
|
46
|
+
if: matrix.ruby-version == '3.3'
|
49
47
|
continue-on-error: true
|
50
48
|
uses: coverallsapp/github-action@v2
|
51
49
|
with:
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
module AnyStyle
|
2
3
|
class Feature
|
3
4
|
class Keyword < Feature
|
@@ -12,7 +13,7 @@ module AnyStyle
|
|
12
13
|
/^(compilador)$/i,
|
13
14
|
/編/
|
14
15
|
:editor
|
15
|
-
when
|
16
|
+
when /著|撰/
|
16
17
|
:author
|
17
18
|
when /^trans(l(ated|ators?|ation))?$/i,
|
18
19
|
/^übers(etz(t|ung))?$/i,
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module AnyStyle
|
2
|
+
module Format
|
3
|
+
module RIS
|
4
|
+
def format_ris(dataset, **opts)
|
5
|
+
format_hash(dataset).map { |entry| format_entry(entry) }.join("\n\n") + "\n"
|
6
|
+
end
|
7
|
+
|
8
|
+
def format_entry(entry)
|
9
|
+
lines = []
|
10
|
+
|
11
|
+
type = ris_type(entry[:type])
|
12
|
+
lines << "TY - #{type}"
|
13
|
+
|
14
|
+
add_authors(lines, entry[:author])
|
15
|
+
lines << "PY - #{unwrap(entry[:issued])}" if entry[:issued]
|
16
|
+
lines << "TI - #{unwrap(entry[:title])}" if entry[:title]
|
17
|
+
lines << "T2 - #{unwrap(entry[:'container-title'])}" if entry[:'container-title']
|
18
|
+
lines << "PB - #{unwrap(entry[:publisher])}" if entry[:publisher]
|
19
|
+
lines << "SN - #{unwrap(entry[:ISBN] || entry[:ISSN])}" if entry[:ISBN] || entry[:ISSN]
|
20
|
+
lines << "DO - #{unwrap(entry[:DOI])}" if entry[:DOI]
|
21
|
+
lines << "UR - #{unwrap(entry[:URL])}" if entry[:URL]
|
22
|
+
lines << "ET - #{unwrap(entry[:edition])}" if entry[:edition]
|
23
|
+
lines << "CY - #{unwrap(entry[:'publisher-place'] || entry[:location])}" if entry[:'publisher-place'] || entry[:location]
|
24
|
+
lines << "VL - #{unwrap(entry[:volume])}" if entry[:volume]
|
25
|
+
lines << "IS - #{unwrap(entry[:issue])}" if entry[:issue]
|
26
|
+
lines << "SP - #{unwrap(entry[:page].to_s.split('-')[0])}" if entry[:page]
|
27
|
+
lines << "EP - #{unwrap(entry[:page].to_s.split('-')[1])}" if entry[:page]&.include?("-")
|
28
|
+
lines << "ER -"
|
29
|
+
|
30
|
+
lines.join("\n")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Extended RIS type mapping
|
34
|
+
def ris_type(type)
|
35
|
+
case type.to_s.downcase
|
36
|
+
when 'book' then 'BOOK' # Book
|
37
|
+
when 'chapter' then 'CHAP' # Book chapter
|
38
|
+
when 'article-journal' then 'JOUR' # Journal article
|
39
|
+
when 'magazine-article', 'magazine' then 'MGZN' # Magazine
|
40
|
+
when 'newspaper-article', 'news' then 'NEWS' # Newspaper
|
41
|
+
when 'conference-paper', 'proceedings-article' then 'CONF' # Conference
|
42
|
+
when 'manuscript' then 'UNPB' # Unpublished
|
43
|
+
when 'thesis' then 'THES' # Thesis/dissertation
|
44
|
+
when 'webpage', 'electronic', 'online' then 'ELEC' # Electronic source
|
45
|
+
when 'film' then 'MPCT' # Motion picture
|
46
|
+
when 'report' then 'RPRT' # Technical report
|
47
|
+
else 'GEN' # Generic fallback
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def unwrap(val)
|
52
|
+
val.is_a?(Array) ? val.first : val
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_authors(lines, authors)
|
56
|
+
return unless authors
|
57
|
+
|
58
|
+
authors.each do |author|
|
59
|
+
name = if author[:literal]
|
60
|
+
author[:literal]
|
61
|
+
elsif author[:family] || author[:given]
|
62
|
+
family = author[:family]
|
63
|
+
given = author[:given]&.gsub('.', '')
|
64
|
+
|
65
|
+
# Add space between adjacent uppercase initials (e.g., "HJ" => "H J")
|
66
|
+
given = given.gsub(/(?<=\A|\s)([A-Z])(?=[A-Z])/, '\1 ') if given
|
67
|
+
|
68
|
+
[family, given].compact.join(', ')
|
69
|
+
else
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
|
73
|
+
lines << "AU - #{name}" if name
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/anystyle/parser.rb
CHANGED
@@ -96,8 +96,9 @@ module AnyStyle
|
|
96
96
|
class Parser < ParserCore
|
97
97
|
include Format::BibTeX
|
98
98
|
include Format::CSL
|
99
|
+
include Format::RIS
|
99
100
|
|
100
|
-
@formats = [:bibtex, :citeproc, :csl, :hash, :wapiti]
|
101
|
+
@formats = [:bibtex, :citeproc, :csl, :hash, :wapiti, :ris]
|
101
102
|
|
102
103
|
@defaults = {
|
103
104
|
model: File.join(SUPPORT, 'parser.mod'),
|
@@ -190,7 +191,7 @@ module AnyStyle
|
|
190
191
|
case format.to_sym
|
191
192
|
when :wapiti
|
192
193
|
label(input, **opts)
|
193
|
-
when :hash, :bibtex, :citeproc, :csl
|
194
|
+
when :hash, :bibtex, :citeproc, :csl, :ris
|
194
195
|
formatter = "format_#{format}".to_sym
|
195
196
|
send(formatter, label(input, **opts), **opts)
|
196
197
|
else
|
data/lib/anystyle/version.rb
CHANGED
data/lib/anystyle.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anystyle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-05-11 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bibtex-ruby
|
@@ -109,6 +108,7 @@ files:
|
|
109
108
|
- lib/anystyle/finder.rb
|
110
109
|
- lib/anystyle/format/bibtex.rb
|
111
110
|
- lib/anystyle/format/csl.rb
|
111
|
+
- lib/anystyle/format/ris.rb
|
112
112
|
- lib/anystyle/normalizer.rb
|
113
113
|
- lib/anystyle/normalizer/arxiv.rb
|
114
114
|
- lib/anystyle/normalizer/brackets.rb
|
@@ -162,7 +162,6 @@ homepage: http://anystyle.io
|
|
162
162
|
licenses:
|
163
163
|
- BSD-2-Clause
|
164
164
|
metadata: {}
|
165
|
-
post_install_message:
|
166
165
|
rdoc_options:
|
167
166
|
- "--line-numbers"
|
168
167
|
- "--inline-source"
|
@@ -183,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
182
|
- !ruby/object:Gem::Version
|
184
183
|
version: '0'
|
185
184
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
187
|
-
signing_key:
|
185
|
+
rubygems_version: 3.6.6
|
188
186
|
specification_version: 4
|
189
187
|
summary: Smart and fast bibliography parser.
|
190
188
|
test_files: []
|