tta_terms_api 0.0.3 → 0.0.4

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: 5c9d8b01f161dc68af43ae55dea7fb436cfa1aac
4
- data.tar.gz: fd5987c321433b7e92aea48ba329d4d49349cd57
3
+ metadata.gz: 1ec35b21089b55773d48ff42498c70b4e8c3ad99
4
+ data.tar.gz: f20d9aa8187a30d31898ceed781bb0c89acb1887
5
5
  SHA512:
6
- metadata.gz: bf700fee0c08b791c9c761576b5882a64df3cb09e293c24b00826aedcd8e12c78d3fb94c5ad5babe53dcd3b0e988801b5b5fdf0c9a8d68f05f33de1f5936a5a5
7
- data.tar.gz: f74dd010c0caa8b5cbfb5ab97dc85b66bda4029936caa3407bb5878331b691fbc74a181d854dd4c77d577852e0704e7e4da8334396451c6929be7b3c18769110
6
+ metadata.gz: b0d6c0d329e9b82643886e8f1af8a43cde3305a9a1d754eeaa8d75a34085d0ce4b9e7ef8ce17fc334bd3d312d079389068b7c68a2c52cbbed778bdf9977d4261
7
+ data.tar.gz: 6b9acc9b360c4e28d7f4208a9f4e2d2c201b00d477e7ccb1033248daf596008cbc38133e3b663fa297df6f1494085463f3da4cc28b6c431ee4d3389303948607
@@ -15,7 +15,8 @@ module TtaTermsApi
15
15
  Word = Struct.new(:name, :origin, :type, :similar, :description)
16
16
 
17
17
  def self.list(options)
18
- html = html(:list, options)
18
+ key = "list-#{options[:search]}"
19
+ html = html(:list, key, options)
19
20
  trs = html.css("#tableWidth tr")
20
21
  trs.pop
21
22
  trs.map do |tr|
@@ -37,13 +38,14 @@ module TtaTermsApi
37
38
  end
38
39
 
39
40
  def self.view(options)
40
- name, origin, type, similar, description = html(:view, options).css("#printSpace font").text.gsub("\t", "").split(/\n/)
41
+ key = "view-#{options[:gubun]}-#{options[:terms_num]}"
42
+ name, origin, type, similar, description = html(:view, key, options).css("#printSpace font").text.gsub("\t", "").split(/\n/)
41
43
  Word.new name, origin, type, similar, description
42
44
  end
43
45
 
44
- def self.html(type, options)
46
+ def self.html(type, key, options)
45
47
  uri = "#{BASE_URL}terms#{type.to_s.capitalize}.jsp?#{options.map{|k,v|"#{k}=#{v}"} * "&"}"
46
- html = STORE.fetch(uri) { STORE[uri] = open(uri).read }
48
+ html = STORE.fetch(key){ STORE[key] = open(uri).read }
47
49
  Nokogiri::HTML(html, nil, "EUC-KR")
48
50
  end
49
51
  end
@@ -1,3 +1,3 @@
1
1
  module TtaTermsApi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -9,6 +9,14 @@ describe TtaTermsApi do
9
9
  expect(list.first.class).to be TtaTermsApi::WordCriteria
10
10
  end
11
11
  end
12
+ describe ".list" do
13
+ let(:list) { TtaTermsApi.list(search: "commit") }
14
+ it "return array of word object" do
15
+ expect(list.class).to be Array
16
+ expect(list.first.class).to be TtaTermsApi::WordCriteria
17
+ expect{ list.map(&:to_word) }.to_not raise_error
18
+ end
19
+ end
12
20
 
13
21
  describe ".view" do
14
22
  let(:view) { TtaTermsApi.view(gubun: 1, terms_num: 17626) }
@@ -18,11 +26,11 @@ describe TtaTermsApi do
18
26
  end
19
27
 
20
28
  describe ".html" do
21
- let(:html) { TtaTermsApi.html("", {}) }
29
+ let(:html) { TtaTermsApi.html("", "cache-test", {}) }
22
30
  it "cache html object" do
23
31
  expect(html).to_not be_nil
24
- expect(TtaTermsApi::STORE["http://word.tta.or.kr/terms/terms.jsp?"]).to_not be_nil
25
- TtaTermsApi::STORE.delete("http://word.tta.or.kr/terms/terms.jsp?")
32
+ expect(TtaTermsApi::STORE["cache-test"]).to_not be_nil
33
+ TtaTermsApi::STORE.delete("cache-test")
26
34
  end
27
35
  end
28
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tta_terms_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shim Tw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri