sist02 0.2.4 → 0.4.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 -5
- data/Gemfile +1 -0
- data/README.md +24 -0
- data/lib/sist02/cinii.rb +60 -37
- data/lib/sist02/version.rb +1 -1
- data/sist02.gemspec +2 -2
- metadata +14 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2f615fa514669507b6b56721d04e478adb5210fa54a6f766af8297cae3ac502d
|
4
|
+
data.tar.gz: 8284a9612a243309ff1cfbbf5c2ee37f09f435a4fd868fa0d1d6f9f7749d6ec5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61b5f3d741ef004032bd900bb4e4ed99473b18e1fec52fb2d1303d0ae29eb6945f44c73ff1848896bca8c199177a907a8ab19440495b7f2ae0b5220798c6d145
|
7
|
+
data.tar.gz: 4f6482f68e64bf052734dce9a9be856a8e7a1d9d6e4639edab1a842ab5df77c4eb5032063434d73dba34cbf514d950c0cf7de6390b715913e03b8d50c4f44e69
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
# Sist02
|
2
2
|
|
3
|
+
[](LICENSE)
|
4
|
+
[](https://rubygems.org/gems/sist02)
|
5
|
+
[](https://github.com/himkt/sist02/issues)
|
6
|
+
[](https://github.com/himkt/sist02/stargazers)
|
7
|
+
[](https://github.com/himkt/sist02)
|
8
|
+
[](https://github.com/himkt/sist02)
|
9
|
+
|
10
|
+
|
3
11
|
This gem provides easy way to make SIST-02 formed references.
|
4
12
|
|
5
13
|
Sist02::CiNii is based on [caps](https://github.com/Yousack/caps)
|
6
14
|
|
15
|
+
|
16
|
+
## Related works
|
17
|
+
|
18
|
+
Command line interface is [here](https://github.com/himkt/sist02-cli).
|
19
|
+
|
20
|
+
Web application is [here](https://github.com/himkt/sist02-web) and available on [here](https://sist02-web.herokuapp.com/).
|
21
|
+
|
22
|
+
|
7
23
|
## Installation
|
8
24
|
|
9
25
|
Add this line to your application's Gemfile:
|
@@ -31,6 +47,7 @@ naid is following (please input as String).
|
|
31
47
|
```ruby
|
32
48
|
require 'sist02'
|
33
49
|
|
50
|
+
# 雑誌記事論文
|
34
51
|
naid = "110009886645"
|
35
52
|
p Sist02::CiNii.article_ref(naid)
|
36
53
|
#=> "粟津 妙華, 高田 雅美, 城 和貴. 活字データの分類を用いた進化計算による近代書籍からのルビ除去. 情報処理学会論文誌. 数理モデル化と応用. 2015, 8(1), p. 72-79."
|
@@ -39,9 +56,16 @@ naid = "40020388722"
|
|
39
56
|
p Sist02::CiNii.article_ref(naid)
|
40
57
|
#=> "近藤 宏. 臨床スポーツ鍼灸研究会(10)下肢のスポーツ障害 : 運動連鎖を応用した実践的アプローチ(1). Training journal. 2015, 37(4), p. 37-41."
|
41
58
|
|
59
|
+
# 図書
|
42
60
|
ncid = "BB18507477"
|
43
61
|
p Sist02::CiNii.book_ref(ncid)
|
44
62
|
=> "まちライブラリー, マイクロ・ライブラリーサミット実行委員会, 礒井純充. マイクロ・ライブラリー : 人とまちをつなぐ小さな図書館. 学芸出版社, 2015, 238p."
|
63
|
+
|
64
|
+
# 博士論文
|
65
|
+
naid = "500000587337"
|
66
|
+
p Sist02::CiNii.dissertations_ref(naid)
|
67
|
+
=> "今井, 福司. 日本占領期におけるアメリカ学校図書館の導入 : 日米の学校教育実践における学校図書館の位置づけ. 東京大学, 2013, 博士論文."
|
68
|
+
|
45
69
|
```
|
46
70
|
|
47
71
|
or
|
data/lib/sist02/cinii.rb
CHANGED
@@ -4,56 +4,79 @@ require 'date'
|
|
4
4
|
|
5
5
|
module Sist02
|
6
6
|
module CiNii
|
7
|
+
# enable required program to call following functions
|
7
8
|
module_function
|
8
|
-
|
9
|
+
|
10
|
+
def article_ref naid
|
11
|
+
|
9
12
|
begin
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
creator = creator.gsub(/\,\s$/, '')
|
20
|
-
publication_name = hash["prism:publicationName"][0]["@value"]
|
21
|
-
year = hash["dc:date"].match(/\d{4}/)
|
22
|
-
volume = hash["prism:volume"]
|
23
|
-
number = hash["prism:number"]
|
24
|
-
start_p = hash["prism:startingPage"]
|
25
|
-
end_p = hash["prism:endingPage"]
|
26
|
-
result = "#{creator}. #{title}. #{publication_name}. #{year}, vol. #{volume}, no. #{number}, p. #{start_p}-#{end_p}."
|
13
|
+
|
14
|
+
url = "http://ci.nii.ac.jp/naid/#{naid}.json"
|
15
|
+
content = get_content url
|
16
|
+
common_info = get_common_info content
|
17
|
+
volume = content["prism:volume"]
|
18
|
+
number = content["prism:number"]
|
19
|
+
start_p = content["prism:startingPage"]
|
20
|
+
end_p = content["prism:endingPage"]
|
21
|
+
result = "#{common_info["maker"]}. #{common_info["title"]}. #{common_info["publicationName"]}. #{common_info["year"]}, vol. #{volume}, no. #{number}, p. #{start_p}-#{end_p}."
|
27
22
|
rescue => e
|
28
23
|
result = e
|
29
24
|
end
|
30
25
|
return result
|
31
26
|
end
|
32
27
|
|
33
|
-
def book_ref
|
28
|
+
def book_ref ncid
|
34
29
|
begin
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
author = author_ary.join(", ")
|
47
|
-
|
48
|
-
ris = open("http://ci.nii.ac.jp/ncid/#{ncid}.ris").read
|
49
|
-
pages = ris.match(/EP - ([a-z]*, )?\d+p/).to_s.gsub(/EP - /, '')
|
50
|
-
pages = "ページ数不明" if pages == ''
|
51
|
-
result = "#{author}. #{title}. #{edition}, #{publisher}, #{year}, #{pages}." unless edition == nil
|
52
|
-
result = "#{author}. #{title}. #{publisher}, #{year}, #{pages}." if edition == nil # for bibliographic information that doesn't have edition display
|
30
|
+
url = "http://ci.nii.ac.jp/ncid/#{ncid}.json"
|
31
|
+
content = get_content url
|
32
|
+
common_info = get_common_info content
|
33
|
+
edition = content["prism:edition"]
|
34
|
+
ris = URI.open("http://ci.nii.ac.jp/ncid/#{ncid}.ris").read
|
35
|
+
edition = ris.match(/ET\s{2}-\s(.*)\r/) ? ris.match(/ET\s{2}-\s(.*)\r/)[1] : nil
|
36
|
+
publisher = ris.match(/PB\s{2}-\s(.*)\r/) ? ris.match(/PB\s{2}-\s(.*)\r/)[1] : nil
|
37
|
+
page = ris.match(/EP\s{2}-\s.*?(\d*?p)/) ? ris.match(/EP\s{2}-\s.*?(\d*?p)/)[1] : 'ページ数不明'
|
38
|
+
result = "#{common_info["maker"]}. #{common_info["title"]}. #{edition}, #{publisher}, #{common_info["year"]}, #{page}." if edition
|
39
|
+
result = "#{common_info["maker"]}. #{common_info["title"]}. #{publisher}, #{common_info["year"]}, #{page}." unless edition
|
53
40
|
rescue => e
|
54
41
|
result = e
|
55
42
|
end
|
56
43
|
return result
|
57
44
|
end
|
45
|
+
|
46
|
+
def dissertation_ref naid
|
47
|
+
|
48
|
+
begin
|
49
|
+
|
50
|
+
url = "http://ci.nii.ac.jp/naid/#{naid}.json"
|
51
|
+
content = get_content url
|
52
|
+
common_info = get_common_info content
|
53
|
+
result = "#{common_info["maker"]}. #{common_info["title"]}. #{common_info["publisher"]}, #{common_info["year"]}, 博士論文."
|
54
|
+
rescue => e
|
55
|
+
result = e
|
56
|
+
end
|
57
|
+
return result
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_content url
|
61
|
+
html = URI.open(url).read
|
62
|
+
json = JSON.parser.new(html)
|
63
|
+
json.parse["@graph"][0]
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def get_common_info content
|
68
|
+
common_info = {}
|
69
|
+
common_info["title"] = content["dc:title"][0]["@value"]
|
70
|
+
common_info["publisher"] = content["dc:publisher"][0]["@value"]
|
71
|
+
common_info["publicationName"] = content["prism:publicationName"][0]["@value"] if content["prism:publicationName"]
|
72
|
+
common_info["year"] = content["dc:date"].match(/\d{4}/)
|
73
|
+
author_ary = Array.new
|
74
|
+
content["foaf:maker"].each do |item|
|
75
|
+
author_ary << item["foaf:name"][0]["@value"].gsub(/(\s| |,)+/, '')
|
76
|
+
end
|
77
|
+
common_info["maker"] = author_ary.join(", ")
|
78
|
+
return common_info
|
79
|
+
end
|
80
|
+
|
58
81
|
end
|
59
82
|
end
|
data/lib/sist02/version.rb
CHANGED
data/sist02.gemspec
CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sist02
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makoto Hiramatsu
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
description: make reference via web api
|
42
42
|
email:
|
43
43
|
- himkt@klis.tsukuba.ac.jp
|
@@ -61,7 +61,7 @@ files:
|
|
61
61
|
homepage: https://github.com/himkt/sist02
|
62
62
|
licenses: []
|
63
63
|
metadata: {}
|
64
|
-
post_install_message:
|
64
|
+
post_install_message:
|
65
65
|
rdoc_options: []
|
66
66
|
require_paths:
|
67
67
|
- lib
|
@@ -76,10 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
|
80
|
-
|
81
|
-
signing_key:
|
79
|
+
rubygems_version: 3.0.3
|
80
|
+
signing_key:
|
82
81
|
specification_version: 4
|
83
82
|
summary: easy way to make sist02 formed reference
|
84
83
|
test_files: []
|
85
|
-
has_rdoc:
|