ndl 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c1d243048364da4f1e596dfcdb785290bcbf588
4
- data.tar.gz: 9b19aab2c8dad91b34db1a8c44fc044ee749ce0d
3
+ metadata.gz: 9b0105c2700228b1341771c6965312520f968937
4
+ data.tar.gz: d74cba26baed8e0927d48d6384f162aaa58e420a
5
5
  SHA512:
6
- metadata.gz: 25b538dedeb8c22d19df4a1c8bee9cc04726916191f7ffd7e45752b5fcc770a6e5f7ae6ae40e610d35151d0373201e4d26be0310634fa3709e54b3cd1b45b365
7
- data.tar.gz: bf8a7bb04f28215cc3aab3bbf2755a4a809c065cfcc8db30dec5b324982ec03ae8932a0c29dd9fc9aff82d986a71d353682e858af2fb2da348e70bd4d68772e6
6
+ metadata.gz: 4d0026b2fad4ee26832f0091ef838ed47ca5c21c4d412067f7520f37185e42f15f766c954836163fdba8de1bc7a88201b4b1ff934ded73660056a49b9fdd8623
7
+ data.tar.gz: 442fac12e6f2e3f3c19589abc25a4337cac7bec81abe4611c2859a2a0880ecafd22c709af1a39a78ca42ebbf7ee633af4494fbdff84d0c0f97e3b4eaf59353b9
data/README.md CHANGED
@@ -22,7 +22,27 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ### OpenSearch
26
+
27
+ * The following arguments are available
28
+ - :dpid
29
+ - :dpgroupid
30
+ - :any
31
+ - :title
32
+ - :creator
33
+ - :publisher
34
+ - :ndc
35
+ - :from
36
+ - :until
37
+ - :cnt
38
+ - :idx
39
+ - :isbn
40
+ - :mediatype
41
+
42
+ ```ruby
43
+ open_search = OpenSearch.new
44
+ open_search.search(:title=>'a', :from=>'1111-11-11', :cnt=>2)
45
+ ```
26
46
 
27
47
  ## Development
28
48
 
data/lib/ndl.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "ndl/version"
2
+ require "ndl/opensearch"
2
3
 
3
4
  module Ndl
4
5
  # Your code goes here...
@@ -0,0 +1,22 @@
1
+ require 'open-uri'
2
+
3
+ module Ndl
4
+ class OpenSearch
5
+ def initialize
6
+ @url = "http://iss.ndl.go.jp/api/opensearch?"
7
+ end
8
+ def search(*query)
9
+ # delete query that don't have value
10
+ query = query[0].delete_if{|k,v|v==''}
11
+ # make url for ndl-opensearch-api
12
+ query.each_with_index do |(k,v), i|
13
+ @url += "#{k}=#{v}"
14
+ @url += "&" if (i != query.size-1)
15
+ end
16
+ # return #StringIO or #Tempfile via gem 'open-uri'
17
+ # about 'open-uri', please refer to http://docs.ruby-lang.org/ja/2.1.0/library/open=2duri.html
18
+ result = open(@url)
19
+ return result
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Ndl
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -6,7 +6,7 @@ require 'ndl/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ndl"
8
8
  spec.version = Ndl::VERSION
9
- spec.authors = ["himkt"]
9
+ spec.authors = ["Makoto Hiramatsu"]
10
10
  spec.email = ["s1311536@u.tsukuba.ac.jp"]
11
11
 
12
12
  spec.summary = %q{ndl tool}
data/test.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'ndl'
2
+
3
+ open_search = Ndl::OpenSearch.new
4
+
5
+ result = open_search.search(:title=>'a', :from=>'1111-11-11', :cnt=>2)
6
+
7
+ while line = result.gets
8
+ puts line
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - himkt
7
+ - Makoto Hiramatsu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,8 +56,10 @@ files:
56
56
  - bin/console
57
57
  - bin/setup
58
58
  - lib/ndl.rb
59
+ - lib/ndl/opensearch.rb
59
60
  - lib/ndl/version.rb
60
61
  - ndl.gemspec
62
+ - test.rb
61
63
  homepage: https://github.com/himkt/ndl
62
64
  licenses:
63
65
  - MIT