tta_terms_api 0.0.3 → 0.0.4
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 +4 -4
- data/lib/tta_terms_api.rb +6 -4
- data/lib/tta_terms_api/version.rb +1 -1
- data/spec/tta_terms_api_spec.rb +11 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ec35b21089b55773d48ff42498c70b4e8c3ad99
|
4
|
+
data.tar.gz: f20d9aa8187a30d31898ceed781bb0c89acb1887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0d6c0d329e9b82643886e8f1af8a43cde3305a9a1d754eeaa8d75a34085d0ce4b9e7ef8ce17fc334bd3d312d079389068b7c68a2c52cbbed778bdf9977d4261
|
7
|
+
data.tar.gz: 6b9acc9b360c4e28d7f4208a9f4e2d2c201b00d477e7ccb1033248daf596008cbc38133e3b663fa297df6f1494085463f3da4cc28b6c431ee4d3389303948607
|
data/lib/tta_terms_api.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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(
|
48
|
+
html = STORE.fetch(key){ STORE[key] = open(uri).read }
|
47
49
|
Nokogiri::HTML(html, nil, "EUC-KR")
|
48
50
|
end
|
49
51
|
end
|
data/spec/tta_terms_api_spec.rb
CHANGED
@@ -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["
|
25
|
-
TtaTermsApi::STORE.delete("
|
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.
|
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-
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|