sist02 0.3.1 → 0.4.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/Gemfile +1 -0
- data/README.md +1 -1
- data/lib/sist02/cinii.rb +51 -45
- data/lib/sist02/version.rb +1 -1
- 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: ac92de232990d6691dde4e19ab925239359835bd
|
4
|
+
data.tar.gz: 8760f071ea9644fe57dbc0c0ef2940f7e508e6c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54e874f84116f29dd2b4c9d902945ffe1580a31ca27f5eb5509db5312d18ac06d698d0704150c1f8bded3cd4e5f6f3d2162a8fef167ee3fe253e014b7492c9a6
|
7
|
+
data.tar.gz: 71f968862b162704338ab319c712bfe0e2c345a60dc44df7bcc9769848ff4a3d3e7747158e6aa2a2577457cabba1ac4ac4743fbd1177550a32d4f0481f592df2
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/sist02/cinii.rb
CHANGED
@@ -4,73 +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
|
-
publisher = hash["dc:publisher"][0]
|
40
|
-
year = hash["dc:date"].match(/\d{4}/)
|
41
|
-
edition = hash["prism:edition"]
|
42
|
-
author_ary = Array.new
|
43
|
-
hash["foaf:maker"].each do |item|
|
44
|
-
author_ary << item["foaf:name"][0]["@value"].gsub(/(\s| |,)+/, '')
|
45
|
-
end
|
46
|
-
author = author_ary.join(", ")
|
47
|
-
|
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"]
|
48
34
|
ris = open("http://ci.nii.ac.jp/ncid/#{ncid}.ris").read
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
result = "#{
|
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
|
58
45
|
|
59
|
-
def
|
46
|
+
def dissertations_ref naid
|
47
|
+
|
60
48
|
begin
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
publisher = hash["dc:publisher"][0]["@value"]
|
67
|
-
year = hash["dc:date"].match(/\d{4}/)
|
68
|
-
result = "#{author}. #{title}. #{publisher}, #{year}, 博士論文."
|
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"]}, 博士論文."
|
69
54
|
rescue => e
|
70
55
|
result = e
|
71
56
|
end
|
72
57
|
return result
|
73
58
|
end
|
74
59
|
|
60
|
+
def get_content url
|
61
|
+
html = 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
|
+
|
75
81
|
end
|
76
82
|
end
|
data/lib/sist02/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sist02
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makoto Hiramatsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|