researchmap2bib 0.2.2 → 0.3.2
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 +5 -13
- data/README.md +12 -12
- data/exe/researchmap2bib +1 -23
- data/latexmkrc +14 -0
- data/lib/researchmap2bib.rb +5 -154
- data/lib/researchmap2bib/cli.rb +17 -0
- data/lib/researchmap2bib/generator.rb +177 -0
- data/lib/researchmap2bib/unique_id.rb +21 -0
- data/lib/researchmap2bib/utils.rb +31 -0
- data/lib/researchmap2bib/version.rb +1 -1
- metadata +28 -23
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NzNiZTQzZDU3NWFmNGQyN2Y0MmUwYTc0NTcyNTBiMGNkN2E1MmM2MA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1bf1c32cd1ffaa93eb5af908a81b3d973d24167d
|
4
|
+
data.tar.gz: 4c6fd7376fa440c7b92fd63f5a85e92c98374a74
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ODBmYjIyNDg3ZDM3ZDIyYmVjOGM4NDY5YmVkNmI2MDAxMDVhYzM1ZWUzM2Zm
|
11
|
-
MjExOTJiM2U1YzA5MDZmYTNjNTc1ZGY2NWIzZjI0OTA3OWYxNzQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MDYyYmE5NTFhZGQ2YTg4YTdlMjU5ZDE2OTkxMTFjZjY0ZWMwYTU1NDJhZDA4
|
14
|
-
ZTdlZjQzZTBhNTJkMTAyMjBjZmI4ZDA5MThmZmY4NmRjNzZkZGM1ZTFlOGI3
|
15
|
-
MmMzNWY4ZTg2YzI5ZGE3ODczMWFmNWQxMzA1ZWRlNmRiYThjNGY=
|
6
|
+
metadata.gz: 3e98c445ac8cad83801523ab2ee1cfd3e533c3a93fbbfc3509171831db5785a1a4eec406d998d87f94624eec6c7a5e8497dc7726fbf4cbcbcfbadbfe922b16a1
|
7
|
+
data.tar.gz: a1f3c0c9827f44073cd6b401a21480389c8ab535b25bb6bea1a53bebc32f76c3cb0407b0244ae23b7b499cbed7216a228cb6702890253b1cf891938e904c6472
|
data/README.md
CHANGED
@@ -3,31 +3,31 @@
|
|
3
3
|
|
4
4
|
# Researchmap2bib
|
5
5
|
|
6
|
-
|
6
|
+
A script to generate LaTeX (BibTeX) bibliography file of your published papers list which is stored in the [researchmap](https://researchmap.jp/) database.
|
7
7
|
|
8
|
-
|
8
|
+
[researchmap](https://researchmap.jp/)のデータベースに登録された論文一覧からLaTeX(BibTeX)のbibliographyファイルを作成するスクリプトです.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
|
-
|
12
|
+
コマンドのインストールの方法は次のとおりです.システムのRubyにインストールする場合,sudoが必要です.
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem
|
15
|
+
gem install researchmap2bib
|
16
16
|
```
|
17
17
|
|
18
|
-
|
18
|
+
## Usage
|
19
19
|
|
20
|
-
|
20
|
+
[researchmap](https://researchmap.jp/)にログインしてXML形式で業績をダウンロードしてください.zipファイルが1つダウンロードされます.このファイル名がresearcher.zipならば,次のコマンドを実行してください.
|
21
21
|
|
22
|
-
|
22
|
+
```bash
|
23
|
+
resarchmap2bib generate researcher.zip
|
24
|
+
```
|
23
25
|
|
24
|
-
|
26
|
+
「researcher.bib」と「sample.tex」ができますのでご利用ください.
|
25
27
|
|
26
|
-
|
28
|
+
sample.texは確認用のLaTeXファイルです.uplatex用のクラスファイルが設定してありますので,ご自身の環境にあわせて変更してください.
|
27
29
|
|
28
|
-
|
29
|
-
resarchmap2bib researcher.zip
|
30
|
-
```
|
30
|
+
なお,bibtexを走らせると,著者名の数が多すぎるなどのエラーになる場合があります.こちらについては手動でご修正してください.
|
31
31
|
|
32
32
|
## Development
|
33
33
|
|
data/exe/researchmap2bib
CHANGED
@@ -2,27 +2,5 @@
|
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
4
|
require "researchmap2bib"
|
5
|
-
require 'thor'
|
6
5
|
|
7
|
-
|
8
|
-
option 'newline', :type => :boolean
|
9
|
-
desc "generate ZIP_FILE", "researchmapの業績からbibliographyを作成"
|
10
|
-
def generate(file_name)
|
11
|
-
@s = Researchmap2bib::ResearchmapReader.new
|
12
|
-
entries = @s.read_researchmap(file_name)
|
13
|
-
|
14
|
-
results = Array.new
|
15
|
-
entries.each do |entry|
|
16
|
-
results.push(@s.write_bibliography_entry(entry))
|
17
|
-
end
|
18
|
-
|
19
|
-
puts options['newline'] == false ? results : results.join("\n")
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "version", "バージョンを表示"
|
23
|
-
def version
|
24
|
-
puts "researchmap2bib version #{::Researchmap2bib::VERSION}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
CLI.start(ARGV)
|
6
|
+
::Researchmap2bib::CLI.start(ARGV)
|
data/latexmkrc
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
$latex = 'uplatex -shell-escape';
|
3
|
+
$bibtex = 'upbibtex';
|
4
|
+
$dvipdf = 'dvipdfmx -o %D %S';
|
5
|
+
$max_repeat = 5;
|
6
|
+
$pdf_mode = 3; # generates pdf via dvipdfmx
|
7
|
+
|
8
|
+
# Prevent latexmk from removing PDF after typeset.
|
9
|
+
# This enables Skim to chase the update in PDF automatically.
|
10
|
+
$pvc_view_file_via_temporary = 0;
|
11
|
+
|
12
|
+
# Use evince as a previewer
|
13
|
+
$pdf_previewer = "evince";
|
14
|
+
$preview_continuous_mode = 1;
|
data/lib/researchmap2bib.rb
CHANGED
@@ -1,164 +1,15 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require "researchmap2bib/version"
|
3
|
-
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require 'erb'
|
3
|
+
require 'researchmap2bib/utils'
|
4
|
+
require 'researchmap2bib/unique_id'
|
5
|
+
require 'researchmap2bib/cli'
|
6
|
+
require 'researchmap2bib/generator'
|
8
7
|
|
9
8
|
module Researchmap2bib
|
10
9
|
Entry = Struct.new(
|
10
|
+
:id,
|
11
11
|
:title, :author, :summary, :journal, :publisher, :publicationName,
|
12
12
|
:volume, :number, :startingPage, :endingPage, :publicationDate,
|
13
13
|
:referee, :language, :paperType,
|
14
14
|
)
|
15
|
-
|
16
|
-
class ResearchmapReader
|
17
|
-
def read_researchmap(file_name)
|
18
|
-
entries = Zip::File.open(file_name) do |zip_file|
|
19
|
-
entry = zip_file.glob('*\/paper.xml').first
|
20
|
-
read_paper(entry.get_input_stream.read)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def read_paper(xml)
|
25
|
-
doc = REXML::Document.new(xml)
|
26
|
-
entries = Array.new
|
27
|
-
REXML::XPath.each(doc, '/feed/entry') do |entry|
|
28
|
-
entries.push(read_entry(entry))
|
29
|
-
end
|
30
|
-
entries
|
31
|
-
end
|
32
|
-
|
33
|
-
def read_entry(entry)
|
34
|
-
title = entry.elements["title"].text
|
35
|
-
author = entry.elements["author"].elements["name"].text
|
36
|
-
author = to_hankaku(author)
|
37
|
-
summary = entry.elements["summary"].text
|
38
|
-
journal = entry.elements["rm:journal"].text
|
39
|
-
publisher = entry.elements["rm:publisher"].text
|
40
|
-
publicationName = entry.elements["rm:publicationName"].text
|
41
|
-
volume = entry.elements["rm:volume"].text
|
42
|
-
number = entry.elements["rm:number"].text
|
43
|
-
startingPage = entry.elements["rm:startingPage"].text
|
44
|
-
endingPage = entry.elements["rm:endingPage"].text
|
45
|
-
publicationDate = entry.elements["rm:publicationDate"].text
|
46
|
-
referee = entry.elements["rm:referee"] ? true : false
|
47
|
-
language = entry.elements["rm:language"].text
|
48
|
-
paperType = entry.elements["rm:paperType"].elements["id"].text
|
49
|
-
|
50
|
-
Entry.new(
|
51
|
-
title, author, summary, journal, publisher, publicationName,
|
52
|
-
volume, number, startingPage, endingPage, publicationDate,
|
53
|
-
referee, language, paperType,
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
# 0:未設定、1:研究論文(学術雑誌)、2:研究論文(国際会議プロシーディングス)、3:研究論文(大学,研究機関紀要)
|
58
|
-
# 、
|
59
|
-
# 4:研究論文(研究会,シンポジウム資料等)、5:研究論文(その他学術会議資料等)
|
60
|
-
def write_bibliography_entry(entry)
|
61
|
-
key = generate_key(entry.author, entry.publicationDate)
|
62
|
-
year, month = year_month(entry.publicationDate)
|
63
|
-
month = month.to_i
|
64
|
-
case entry.paperType.to_i
|
65
|
-
when 1, 3 then
|
66
|
-
record = <<EOS
|
67
|
-
@Article{<%= key %>,
|
68
|
-
author = {<%= entry.author %>},
|
69
|
-
title = {<%= entry.title %>},
|
70
|
-
journal = {<%= entry.journal %>},
|
71
|
-
EOS
|
72
|
-
record += ' year = <%= year %>'
|
73
|
-
if month > 0
|
74
|
-
record += ",\n month = <%= month %>"
|
75
|
-
end
|
76
|
-
if entry.volume
|
77
|
-
record += ",\n volume = <%= entry.volume %>"
|
78
|
-
end
|
79
|
-
if entry.number
|
80
|
-
record += ",\n number = <%= entry.number %>"
|
81
|
-
end
|
82
|
-
if entry.startingPage && entry.endingPage
|
83
|
-
record += ",\n pages = <%= entry.startingPage %>-<%= entry.endingPage %>"
|
84
|
-
elsif entry.startingPage
|
85
|
-
record += ",\n pages = <%= entry.startingPage %> %>"
|
86
|
-
end
|
87
|
-
record += "}\n"
|
88
|
-
if entry.summary
|
89
|
-
record += "% <%= entry.summary %>\n"
|
90
|
-
end
|
91
|
-
else
|
92
|
-
record = <<EOS
|
93
|
-
@InProceedings{<%= key %>,
|
94
|
-
author = {<%= entry.author %>},
|
95
|
-
title = {<%= entry.title %>},
|
96
|
-
booktitle = {<%= entry.journal %>},
|
97
|
-
EOS
|
98
|
-
record += ' year = <%= year %>'
|
99
|
-
if month > 0
|
100
|
-
record += ",\n month = <%= month %>"
|
101
|
-
end
|
102
|
-
if entry.volume
|
103
|
-
record += ",\n volume = <%= entry.volume %>"
|
104
|
-
end
|
105
|
-
if entry.number
|
106
|
-
record += ",\n number = <%= entry.number %>"
|
107
|
-
end
|
108
|
-
if entry.startingPage && entry.endingPage
|
109
|
-
record += ",\n pages = <%= entry.startingPage %>-<%= entry.endingPage %>"
|
110
|
-
elsif entry.startingPage
|
111
|
-
record += ",\n pages = <%= entry.startingPage %> %>"
|
112
|
-
end
|
113
|
-
if entry.publisher
|
114
|
-
record += ",\n publisher = {<%= entry.publisher %>}"
|
115
|
-
end
|
116
|
-
record += "}\n"
|
117
|
-
if entry.summary
|
118
|
-
record += "% <%= entry.summary %>\n"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
erb = ERB.new(record)
|
122
|
-
erb.result(binding)
|
123
|
-
end
|
124
|
-
|
125
|
-
def to_hankaku(str)
|
126
|
-
str.tr('0-9a-zA-Z,、 ', '0-9a-zA-Z,, ')
|
127
|
-
end
|
128
|
-
|
129
|
-
def year_month(date)
|
130
|
-
/([0-9]{4})([0-9]{2})/.match(date).captures
|
131
|
-
end
|
132
|
-
|
133
|
-
def concatenate_authors(authors)
|
134
|
-
authors.gsub(/ *, */, ' and ')
|
135
|
-
end
|
136
|
-
|
137
|
-
def first_author(authors)
|
138
|
-
r = /([^,]*)/.match(authors)
|
139
|
-
r == nil ? authors.strip : r.captures[0].strip
|
140
|
-
end
|
141
|
-
|
142
|
-
def family_name(author)
|
143
|
-
if /(^\w*) *(\w*)$/ =~ author
|
144
|
-
$2
|
145
|
-
elsif /(^\S*) *(\S*)$/ =~ author
|
146
|
-
$1
|
147
|
-
else
|
148
|
-
author
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def generate_key(authors, date)
|
153
|
-
first_author = first_author(authors)
|
154
|
-
name = family_name(first_author)
|
155
|
-
year, month = year_month(date)
|
156
|
-
year = /[0-9][0-9]([0-9][0-9])/.match(year).captures[0]
|
157
|
-
if month.to_i >0
|
158
|
-
name + year + month
|
159
|
-
else
|
160
|
-
name + year
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
15
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module Researchmap2bib
|
5
|
+
class CLI < Thor
|
6
|
+
desc "generate ZIP_FILE", "researchmapの業績からbibliographyを作成"
|
7
|
+
def generate(file_name)
|
8
|
+
@s = Researchmap2bib::Generator.new
|
9
|
+
@s.generate(file_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "version", "バージョンを表示"
|
13
|
+
def version
|
14
|
+
puts "researchmap2bib version #{::Researchmap2bib::VERSION}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'researchmap2bib/utils'
|
3
|
+
require 'researchmap2bib/unique_id'
|
4
|
+
|
5
|
+
require 'pp'
|
6
|
+
require 'zip'
|
7
|
+
require 'rexml/document'
|
8
|
+
require 'erb'
|
9
|
+
|
10
|
+
module Researchmap2bib
|
11
|
+
class Generator
|
12
|
+
include Utils
|
13
|
+
include UniqueId
|
14
|
+
|
15
|
+
def generate(file_name)
|
16
|
+
bibliography = make_bibliography(file_name)
|
17
|
+
|
18
|
+
base_name = File.basename(file_name, '.zip')
|
19
|
+
File.write(base_name + '.bib', bibliography)
|
20
|
+
|
21
|
+
ids = list_up_id
|
22
|
+
template = <<EOS
|
23
|
+
\\documentclass[uplatex]{jsarticle}
|
24
|
+
\\begin{document}
|
25
|
+
文献\\cite{<%= ids.join(',') %>}
|
26
|
+
\\bibliographystyle{junsrt}
|
27
|
+
\\bibliography{<%= base_name %>}
|
28
|
+
\\end{document}
|
29
|
+
EOS
|
30
|
+
erb = ERB.new(template)
|
31
|
+
sample = erb.result(binding)
|
32
|
+
File.write('sample.tex', sample)
|
33
|
+
end
|
34
|
+
|
35
|
+
def list_up_id
|
36
|
+
ids = Array.new
|
37
|
+
@entries.each do |entry|
|
38
|
+
ids.push(entry.id)
|
39
|
+
end
|
40
|
+
ids
|
41
|
+
end
|
42
|
+
|
43
|
+
def make_bibliography(file_name)
|
44
|
+
@entries = read_researchmap(file_name)
|
45
|
+
|
46
|
+
results = Array.new
|
47
|
+
@entries.each do |entry|
|
48
|
+
results.push(make_bibliography_entry(entry))
|
49
|
+
end
|
50
|
+
|
51
|
+
results.join("\n")
|
52
|
+
end
|
53
|
+
|
54
|
+
def read_researchmap(file_name)
|
55
|
+
entries = Zip::File.open(file_name) do |zip_file|
|
56
|
+
entry = zip_file.glob('*\/paper.xml').first
|
57
|
+
read_paper(entry.get_input_stream.read)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def read_paper(xml)
|
62
|
+
doc = REXML::Document.new(xml)
|
63
|
+
entries = Array.new
|
64
|
+
REXML::XPath.each(doc, '/feed/entry') do |entry|
|
65
|
+
entries.push(read_entry(entry))
|
66
|
+
end
|
67
|
+
entries
|
68
|
+
end
|
69
|
+
|
70
|
+
def read_entry(entry)
|
71
|
+
title = entry.elements["title"].text
|
72
|
+
author = entry.elements["author"].elements["name"].text
|
73
|
+
author = to_hankaku(author)
|
74
|
+
summary = entry.elements["summary"].text
|
75
|
+
journal = entry.elements["rm:journal"].text
|
76
|
+
publisher = entry.elements["rm:publisher"].text
|
77
|
+
publicationName = entry.elements["rm:publicationName"].text
|
78
|
+
volume = entry.elements["rm:volume"].text
|
79
|
+
number = entry.elements["rm:number"].text
|
80
|
+
startingPage = entry.elements["rm:startingPage"].text
|
81
|
+
endingPage = entry.elements["rm:endingPage"].text
|
82
|
+
publicationDate = entry.elements["rm:publicationDate"].text
|
83
|
+
referee = entry.elements["rm:referee"] ? true : false
|
84
|
+
language = entry.elements["rm:language"].text
|
85
|
+
paperType = entry.elements["rm:paperType"].elements["id"].text
|
86
|
+
|
87
|
+
key = generate_key(author, publicationDate)
|
88
|
+
id = unique_id(key)
|
89
|
+
|
90
|
+
Entry.new(
|
91
|
+
id, # id
|
92
|
+
title, author, summary, journal, publisher, publicationName,
|
93
|
+
volume, number, startingPage, endingPage, publicationDate,
|
94
|
+
referee, language, paperType,
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
# 0:未設定、1:研究論文(学術雑誌)、2:研究論文(国際会議プロシーディングス)、
|
99
|
+
# 3:研究論文(大学,研究機関紀要)、
|
100
|
+
# 4:研究論文(研究会,シンポジウム資料等)、5:研究論文(その他学術会議資料等)
|
101
|
+
def make_bibliography_entry(entry)
|
102
|
+
year, month = year_month(entry.publicationDate)
|
103
|
+
month = month.to_i
|
104
|
+
case entry.paperType.to_i
|
105
|
+
when 1, 3 then
|
106
|
+
record = <<EOS
|
107
|
+
@Article{<%= entry.id %>,
|
108
|
+
author = {<%= entry.author %>},
|
109
|
+
title = {<%= entry.title %>},
|
110
|
+
journal = {<%= entry.journal %>},
|
111
|
+
EOS
|
112
|
+
record += ' year = <%= year %>'
|
113
|
+
if month > 0
|
114
|
+
record += ",\n month = <%= month %>"
|
115
|
+
end
|
116
|
+
if entry.volume
|
117
|
+
record += ",\n volume = <%= entry.volume %>"
|
118
|
+
end
|
119
|
+
if entry.number
|
120
|
+
record += ",\n number = <%= entry.number %>"
|
121
|
+
end
|
122
|
+
if entry.startingPage && entry.endingPage
|
123
|
+
record += ",\n pages = {<%= entry.startingPage %>-<%= entry.endingPage %>}"
|
124
|
+
elsif entry.startingPage
|
125
|
+
record += ",\n pages = {<%= entry.startingPage %> %>}"
|
126
|
+
end
|
127
|
+
record += "}\n"
|
128
|
+
if entry.summary
|
129
|
+
record += "% <%= entry.summary %>\n"
|
130
|
+
end
|
131
|
+
else
|
132
|
+
record = <<EOS
|
133
|
+
@InProceedings{<%= entry.id %>,
|
134
|
+
author = {<%= entry.author %>},
|
135
|
+
title = {<%= entry.title %>},
|
136
|
+
booktitle = {<%= entry.journal %>},
|
137
|
+
EOS
|
138
|
+
record += ' year = <%= year %>'
|
139
|
+
if month > 0
|
140
|
+
record += ",\n month = <%= month %>"
|
141
|
+
end
|
142
|
+
if entry.volume
|
143
|
+
record += ",\n volume = <%= entry.volume %>"
|
144
|
+
end
|
145
|
+
if entry.number
|
146
|
+
record += ",\n number = <%= entry.number %>"
|
147
|
+
end
|
148
|
+
if entry.startingPage && entry.endingPage
|
149
|
+
record += ",\n pages = {<%= entry.startingPage %>-<%= entry.endingPage %>}"
|
150
|
+
elsif entry.startingPage
|
151
|
+
record += ",\n pages = {<%= entry.startingPage %>}"
|
152
|
+
end
|
153
|
+
if entry.publisher
|
154
|
+
record += ",\n publisher = {<%= entry.publisher %>}"
|
155
|
+
end
|
156
|
+
record += "}\n"
|
157
|
+
if entry.summary
|
158
|
+
record += "% <%= entry.summary %>\n"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
erb = ERB.new(record)
|
162
|
+
erb.result(binding)
|
163
|
+
end
|
164
|
+
|
165
|
+
def generate_key(authors, date)
|
166
|
+
first_author = first_author(authors)
|
167
|
+
name = family_name(first_author)
|
168
|
+
year, month = year_month(date)
|
169
|
+
year = /[0-9][0-9]([0-9][0-9])/.match(year).captures[0]
|
170
|
+
if month.to_i >0
|
171
|
+
name + year + month
|
172
|
+
else
|
173
|
+
name + year
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module Researchmap2bib
|
3
|
+
module UniqueId
|
4
|
+
@@id_to_entry = Hash.new
|
5
|
+
|
6
|
+
def unique_id(key)
|
7
|
+
if @@id_to_entry[key]
|
8
|
+
i = 2
|
9
|
+
begin
|
10
|
+
new_key = key + ':' + i.to_s
|
11
|
+
i += 1
|
12
|
+
end while @@id_to_entry[new_key]
|
13
|
+
@@id_to_entry[new_key] = true
|
14
|
+
return new_key
|
15
|
+
else
|
16
|
+
@@id_to_entry[key] = true
|
17
|
+
return key
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module Researchmap2bib
|
3
|
+
module Utils
|
4
|
+
def to_hankaku(str)
|
5
|
+
str.tr('0-9a-zA-Z,、 ', '0-9a-zA-Z,, ')
|
6
|
+
end
|
7
|
+
|
8
|
+
def year_month(date)
|
9
|
+
/([0-9]{4})([0-9]{2})/.match(date).captures
|
10
|
+
end
|
11
|
+
|
12
|
+
def concatenate_authors(authors)
|
13
|
+
authors.gsub(/ *, */, ' and ')
|
14
|
+
end
|
15
|
+
|
16
|
+
def first_author(authors)
|
17
|
+
r = /([^,]*)/.match(authors)
|
18
|
+
r == nil ? authors.strip : r.captures[0].strip
|
19
|
+
end
|
20
|
+
|
21
|
+
def family_name(author)
|
22
|
+
if /(^\w*) +(\w*)$/ =~ author
|
23
|
+
$2
|
24
|
+
elsif /(^\S*) +(\S*)$/ =~ author
|
25
|
+
$1
|
26
|
+
else
|
27
|
+
author
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: researchmap2bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshihide Chubachi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.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: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.12'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.12'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '5.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '5.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: guard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: guard-minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: This script creates bibliography files which can be used by LaTeX from
|
@@ -131,8 +131,8 @@ executables:
|
|
131
131
|
extensions: []
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
|
-
- .gitignore
|
135
|
-
- .travis.yml
|
134
|
+
- ".gitignore"
|
135
|
+
- ".travis.yml"
|
136
136
|
- Gemfile
|
137
137
|
- Guardfile
|
138
138
|
- LICENSE.txt
|
@@ -141,7 +141,12 @@ files:
|
|
141
141
|
- bin/console
|
142
142
|
- bin/setup
|
143
143
|
- exe/researchmap2bib
|
144
|
+
- latexmkrc
|
144
145
|
- lib/researchmap2bib.rb
|
146
|
+
- lib/researchmap2bib/cli.rb
|
147
|
+
- lib/researchmap2bib/generator.rb
|
148
|
+
- lib/researchmap2bib/unique_id.rb
|
149
|
+
- lib/researchmap2bib/utils.rb
|
145
150
|
- lib/researchmap2bib/version.rb
|
146
151
|
- researchmap2bib.gemspec
|
147
152
|
homepage: https://github.com/ychubachi/researchmap2bib
|
@@ -154,17 +159,17 @@ require_paths:
|
|
154
159
|
- lib
|
155
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
161
|
requirements:
|
157
|
-
- -
|
162
|
+
- - ">="
|
158
163
|
- !ruby/object:Gem::Version
|
159
164
|
version: '0'
|
160
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
166
|
requirements:
|
162
|
-
- -
|
167
|
+
- - ">="
|
163
168
|
- !ruby/object:Gem::Version
|
164
169
|
version: '0'
|
165
170
|
requirements: []
|
166
171
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
172
|
+
rubygems_version: 2.5.1
|
168
173
|
signing_key:
|
169
174
|
specification_version: 4
|
170
175
|
summary: Create LaTeX bibliography files from the XML exported file form researchmap.
|