sist02 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9281cd934ebf11dd4ecc92b4f6c2fb17fe50c991
4
- data.tar.gz: 6a257f8270ce41cf6e871bc5a57e41dfc3a0836e
3
+ metadata.gz: cc4f9f94688855546b6c052daa85465bdfc23490
4
+ data.tar.gz: efe2674e93ac8f3c31602e28478c573097a0c8cb
5
5
  SHA512:
6
- metadata.gz: c000826e34e0bf0d0190c1f78145cfa72bdf692df6310d189ebbe3f6d33ac2417e494db8886788b88f458e021afb6cf14cd293e982179fff42fb8e1061ba9bd8
7
- data.tar.gz: 7aea25b521fcebbd7e1b2ba3b0ddd883541d7a2c55c63804bdf06cdf4cf70bed812c41c646a90004eed5dae249672ea249d18340e1dcd0cdd4225e8c41e679db
6
+ metadata.gz: 6a94d3d56db68fa819708c9f2a2ed96c990605d92dd3d86589e0e0a3278af78a606260ef35f62b24c4d104dbd41107bb7ce44136409bb71f93b1b15260fd1de9
7
+ data.tar.gz: 8869f21c642dfb71a73e134738d9eb08f29e158b4a7adc536716d48cf133ea8c2a3a4d25f5f82233e89048d9710efd06a6745a7292d4ecdda16eb5e5f4b1b918
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem provides easy way to make SIST-02 formed references.
4
4
 
5
+ Sist02::CiNii is based on [caps](https://github.com/Yousack/caps)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -29,7 +31,7 @@ naid is following (please input as String).
29
31
  ```ruby
30
32
  require 'sist02'
31
33
 
32
- naid = "40020388722"
34
+ naid = "40020388722" #this is exmaple.
33
35
 
34
36
  p Sist02.article_ref(naid)
35
37
 
data/lib/sist02/cinii.rb CHANGED
@@ -3,24 +3,26 @@ require 'json'
3
3
  require 'date'
4
4
 
5
5
  module Sist02
6
- module_function
7
- def article_ref(naid)
8
- begin
9
- html = open("http://ci.nii.ac.jp/naid/#{naid}.json").read
10
- json = JSON.parser.new(html)
11
- hash = json.parse["@graph"][0]
12
- title = hash["dc:title"][0]["@value"]
13
- creator = hash["dc:creator"][0][0]["@value"]
14
- publication_name = hash["prism:publicationName"][0]["@value"]
15
- year = hash["dc:date"].match(/\d{4}/)
16
- volume = hash["prism:volume"]
17
- number = hash["prism:number"]
18
- start_p = hash["prism:startingPage"]
19
- end_p = hash["prism:endingPage"]
20
- result = "#{creator}. #{title}. #{publication_name}. #{year}, #{volume}(#{number}), p. #{start_p}-#{end_p}."
21
- rescue => e
22
- result = e
6
+ module CiNii
7
+ module_function
8
+ def article_ref(naid)
9
+ begin
10
+ html = open("http://ci.nii.ac.jp/naid/#{naid}.json").read
11
+ json = JSON.parser.new(html)
12
+ hash = json.parse["@graph"][0]
13
+ title = hash["dc:title"][0]["@value"]
14
+ creator = hash["dc:creator"][0][0]["@value"]
15
+ publication_name = hash["prism:publicationName"][0]["@value"]
16
+ year = hash["dc:date"].match(/\d{4}/)
17
+ volume = hash["prism:volume"]
18
+ number = hash["prism:number"]
19
+ start_p = hash["prism:startingPage"]
20
+ end_p = hash["prism:endingPage"]
21
+ result = "#{creator}. #{title}. #{publication_name}. #{year}, #{volume}(#{number}), p. #{start_p}-#{end_p}."
22
+ rescue => e
23
+ result = e
24
+ end
25
+ return result
23
26
  end
24
- return result
25
27
  end
26
28
  end
@@ -1,3 +1,3 @@
1
1
  module Sist02
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sist02
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makoto Hiramatsu