sist02-cli 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/sist02/cli/cinii.rb +5 -47
- data/lib/sist02/cli/version.rb +1 -1
- data/lib/sist02/cli.rb +0 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a97eb5013ddc255936babb4e7e74edb87c8ba88f
|
4
|
+
data.tar.gz: db58a0365fe0063458a90ccbae83bf5b31d42f3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0c001433248bb2441208d4e2cb6c2a9b75c66332a34aa787b50d3971c345a2a7a04d1ea33daccbc7a9e7002b244f06e727def599da837c74edf11291b3fae1
|
7
|
+
data.tar.gz: e76b141bbec4a7f938d31b1774c1bdc5c512460aee10ea696caa60e5c471e7cca339d80e0729e2d376e5847587181b85c5a2cc7b6f048e5b08987bf4248b6b25
|
data/README.md
CHANGED
@@ -86,11 +86,10 @@ sist02 cinii_books BB18507477
|
|
86
86
|
と出力されれば成功です。
|
87
87
|
|
88
88
|
|
89
|
-
|
90
|
-
TODO: Write usage instructions here
|
91
|
-
|
92
89
|
## Development
|
93
90
|
|
91
|
+
このツールは開発中です。不具合を発見したらお手数ですがissueを作成する、もしくは[松之木](https://twitter.com/himkt)までお知らせください。
|
92
|
+
|
94
93
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
95
94
|
|
96
95
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
data/lib/sist02/cli/cinii.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'sist02'
|
1
2
|
require 'open-uri'
|
2
3
|
require 'json'
|
3
4
|
require 'date'
|
@@ -8,57 +9,14 @@ module Sist02
|
|
8
9
|
class CiNii < Thor
|
9
10
|
desc "cinii_articles NAID", "get cinii articles bibliography"
|
10
11
|
def cinii_articles(naid)
|
11
|
-
|
12
|
-
|
13
|
-
json = JSON.parser.new(html)
|
14
|
-
hash = json.parse["@graph"][0]
|
15
|
-
title = hash["dc:title"][0]["@value"]
|
16
|
-
creator_raw = hash["dc:creator"]
|
17
|
-
creator = ''
|
18
|
-
creator_raw.each do |item|
|
19
|
-
creator += "#{item[0]["@value"]}, "
|
20
|
-
end
|
21
|
-
creator = creator.gsub(/\,\s$/, '')
|
22
|
-
publication_name = hash["prism:publicationName"][0]["@value"]
|
23
|
-
year = hash["dc:date"].match(/\d{4}/)
|
24
|
-
volume = hash["prism:volume"]
|
25
|
-
number = hash["prism:number"]
|
26
|
-
start_p = hash["prism:startingPage"]
|
27
|
-
end_p = hash["prism:endingPage"]
|
28
|
-
result = "#{creator}. #{title}. #{publication_name}. #{year}, vol. #{volume}, no. #{number}, p. #{start_p}-#{end_p}."
|
29
|
-
rescue => e
|
30
|
-
result = e
|
31
|
-
end
|
32
|
-
puts result
|
33
|
-
return result
|
12
|
+
puts Sist02::CiNii.article_ref(naid)
|
13
|
+
return Sist02::CiNii.article_ref(naid)
|
34
14
|
end
|
35
15
|
|
36
16
|
desc "cinii_books NCID", "get cinii books bibliography"
|
37
17
|
def cinii_books(ncid)
|
38
|
-
|
39
|
-
|
40
|
-
json = JSON.parser.new(html)
|
41
|
-
hash = json.parse["@graph"][0]
|
42
|
-
title = hash["dc:title"][0]["@value"]
|
43
|
-
publisher = hash["dc:publisher"][0]
|
44
|
-
year = hash["dc:date"].match(/\d{4}/)
|
45
|
-
edition = hash["prism:edition"]
|
46
|
-
author_ary = Array.new
|
47
|
-
hash["foaf:maker"].each do |item|
|
48
|
-
author_ary << item["foaf:name"][0]["@value"].gsub(/(\s| |,)+/, '')
|
49
|
-
end
|
50
|
-
author = author_ary.join(", ")
|
51
|
-
|
52
|
-
ris = open("http://ci.nii.ac.jp/ncid/#{ncid}.ris").read
|
53
|
-
pages = ris.match(/EP - ([a-z]*, )?\d+p/).to_s.gsub(/EP - /, '')
|
54
|
-
pages = "ページ数不明" if pages == ''
|
55
|
-
result = "#{author}. #{title}. #{edition}, #{publisher}, #{year}, #{pages}." unless edition == nil
|
56
|
-
result = "#{author}. #{title}. #{publisher}, #{year}, #{pages}." if edition == nil # for bibliographic information that doesn't have edition display
|
57
|
-
rescue => e
|
58
|
-
result = e
|
59
|
-
end
|
60
|
-
puts result
|
61
|
-
return result
|
18
|
+
puts Sist02::CiNii.book_ref(ncid)
|
19
|
+
return Sist02::CiNii.book_ref(ncid)
|
62
20
|
end
|
63
21
|
end
|
64
22
|
end
|
data/lib/sist02/cli/version.rb
CHANGED
data/lib/sist02/cli.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sist02-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- himkt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sist02
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,3 +105,4 @@ signing_key:
|
|
91
105
|
specification_version: 4
|
92
106
|
summary: gem for sist02 in console
|
93
107
|
test_files: []
|
108
|
+
has_rdoc:
|