sist02-cli 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bd7f5f7795ebc09127deac02a2ed4b9040da403
4
- data.tar.gz: 7b0f2d77e0ff10c79e6088515a457e82997dc7c4
3
+ metadata.gz: a97eb5013ddc255936babb4e7e74edb87c8ba88f
4
+ data.tar.gz: db58a0365fe0063458a90ccbae83bf5b31d42f3f
5
5
  SHA512:
6
- metadata.gz: 9722216f4174ea5283ed258cdb85d737be5411c2a6dab4b517f8373731e115e11bd189b0dd37f18caf242ba0f5fd4a11ca73ea9199164a5fdca7474cd74329b2
7
- data.tar.gz: 444eb12d0fc01788789cd354eaf4800d81df5a6eebe7a469f76f6cd116c60b8a7cb0272c38e272d0c69393945b2431cc2589f6aff453f962eb6a58805ed1b81a
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).
@@ -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
- begin
12
- html = open("http://ci.nii.ac.jp/naid/#{naid}.json").read
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
- begin
39
- html = open("http://ci.nii.ac.jp/ncid/#{ncid}.json").read
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
@@ -1,5 +1,5 @@
1
1
  module Sist02
2
2
  module Cli
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
data/lib/sist02/cli.rb CHANGED
@@ -7,6 +7,5 @@ module Sist02
7
7
  def self.run
8
8
  File.expand_path("../../bin/sist02", __FILE__)
9
9
  end
10
- # Your code goes here...
11
10
  end
12
11
  end
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.1.2
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-12 00:00:00.000000000 Z
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: