tta_terms_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/lib/tta_terms_api/version.rb +3 -0
- data/lib/tta_terms_api.rb +46 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/tta_terms_api_spec.rb +19 -0
- data/tta_terms_api.gemspec +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aade2f433fc3b43bda27a170dd5de2eff017b54f
|
4
|
+
data.tar.gz: 64a1f73a18bd37e266ff391fe70fc76f3cf6a67e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86eea325b0b73f881ef5d36d3e79140d6132b31be659c6fe898713f308399c5b408cd0db18dddc8b5c059631cc53f83e1b88f97c8cc420c8ace999f800bc2e93
|
7
|
+
data.tar.gz: 0b14b8eae7aa96ef9e8667b162ecb175386c79b310d3a44732dc21c806c33b883c701f98e8ff8f9d73d1c4a27a8245d2bc92e7e27e7b559490034ec83262334e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Shim Tw
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# TtaTermsApi
|
2
|
+
|
3
|
+
Ruby interface to [정보 통신 용어 사전(telecommunication word terms)](http://word.tta.or.kr/terms/terms.jsp)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'tta_terms_api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install tta_terms_api
|
18
|
+
|
19
|
+
## Requirement
|
20
|
+
|
21
|
+
ruby >= 1.9
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
To start using the gem, you can either perform direct calls on `TtaTermsApi`
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
TtaTermsApi.list search: "commit"
|
29
|
+
TtaTermsApi.view gubun: 1, terms_num: 17624
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( http://github.com/marocchino/tta_terms_api/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "tta_terms_api/version"
|
2
|
+
require "nokogiri"
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
|
6
|
+
module TtaTermsApi
|
7
|
+
BASE_URL = "http://word.tta.or.kr/terms/"
|
8
|
+
WordCritria = Struct.new(:name, :options) do
|
9
|
+
def to_word
|
10
|
+
TtaTermsApi.view(@options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
Word = Struct.new(:name, :origin, :type, :description)
|
14
|
+
|
15
|
+
def self.list(options)
|
16
|
+
html = html(:list, options)
|
17
|
+
trs = html.css("#tableWidth tr")
|
18
|
+
trs.pop
|
19
|
+
trs.map do |tr|
|
20
|
+
name = tr.children.first.text.gsub("\n","")
|
21
|
+
script = tr.css(".input_size0").attr("onkeydown").value
|
22
|
+
script.match(/sendData\(\s*'(.*)',\s*'(.*)',\s*'(.*)',\s*'(.*)',\s*'(.*)',\s*'(.*)',\s*'(.*)',\s*'(.*)',\s*'(.*)',\s*'([^']*)'\s*\)/)
|
23
|
+
WordCritria.new name,
|
24
|
+
gubun: $1,
|
25
|
+
terms_num: $2,
|
26
|
+
title: $3,
|
27
|
+
title_gubun: $4,
|
28
|
+
gubun2: $5,
|
29
|
+
terms_num2: $6,
|
30
|
+
title2: $7,
|
31
|
+
title2_gubun: $8,
|
32
|
+
gabora_gubun: $9,
|
33
|
+
popular: $10
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.view(options)
|
38
|
+
name, origin, type, _, description = html(:view, options).css("#printSpace font").text.gsub("\t", "").split(/\n/)
|
39
|
+
Word.new name, origin, type, description
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.html(type, options)
|
43
|
+
uri = "#{BASE_URL}terms#{type.to_s.capitalize}.jsp?#{options.map{|k,v|"#{k}=#{v}"} * "&"}"
|
44
|
+
Nokogiri::HTML(open(uri), nil, "EUC-KR")
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tta_terms_api'
|
3
|
+
describe TtaTermsApi do
|
4
|
+
subject(:tta_terms_api) { TtaTermsApi }
|
5
|
+
describe ".list" do
|
6
|
+
let(:list) { TtaTermsApi.list(search: "list") }
|
7
|
+
it "return array of word object" do
|
8
|
+
expect(list.class).to be Array
|
9
|
+
expect(list.first.class).to be TtaTermsApi::WordCritria
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".view" do
|
14
|
+
let(:view) { TtaTermsApi.view(gubun: 1, terms_num: 17625) }
|
15
|
+
it "return array of word object" do
|
16
|
+
expect(view.class).to be TtaTermsApi::Word
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tta_terms_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tta_terms_api"
|
8
|
+
spec.version = TtaTermsApi::VERSION
|
9
|
+
spec.authors = ["Shim Tw"]
|
10
|
+
spec.email = ["marocchino@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby interface to 정보 통신 용어 사전(telecommunication word terms)}
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "nokogiri", "~> 1.6.1"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tta_terms_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shim Tw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: ''
|
70
|
+
email:
|
71
|
+
- marocchino@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/tta_terms_api.rb
|
82
|
+
- lib/tta_terms_api/version.rb
|
83
|
+
- spec/spec_helper.rb
|
84
|
+
- spec/tta_terms_api_spec.rb
|
85
|
+
- tta_terms_api.gemspec
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.0
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Ruby interface to 정보 통신 용어 사전(telecommunication word terms)
|
110
|
+
test_files:
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/tta_terms_api_spec.rb
|