geekdict 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 +8 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/README.md +21 -0
- data/Rakefile +8 -0
- data/bin/geekdict +6 -0
- data/geekdict.gemspec +27 -0
- data/lib/geekdict/cli.rb +18 -0
- data/lib/geekdict/google/.keep +0 -0
- data/lib/geekdict/version.rb +3 -0
- data/lib/geekdict/youdao/api.rb +26 -0
- data/lib/geekdict/youdao/config.rb +13 -0
- data/lib/geekdict.rb +6 -0
- data/spec/.keep +0 -0
- data/spec/cli_spec.rb +13 -0
- data/spec/youdao/api_spec.rb +12 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2469553df77ddbe3664fb8a8a2edd965741b727d
|
4
|
+
data.tar.gz: 7484c1ac4f61feabee89183636dc64b8ca0aa269
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49f8ed1feae8dbe3deb945963d84110841a585ec0a70ef223663f5844888e616b841df9f4fead7f4e49fbcb8628788db9313340c7546f66d5c92595ea591974f
|
7
|
+
data.tar.gz: a9dd8b1af171b4af7ccfa43e18389e55fcef10ae5f3de9b776f835e06e98a3c2ec6bee13a6e504d127c11af0e9a6e4f1518d41d91c17ff1513e9416bb7a3b14c
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Geek Dict
|
2
|
+
---------
|
3
|
+
A command line tool for translation.
|
4
|
+
|
5
|
+
## Commands
|
6
|
+
|
7
|
+
#### Translate a word
|
8
|
+
```
|
9
|
+
$dict t hello
|
10
|
+
你好
|
11
|
+
```
|
12
|
+
|
13
|
+
#### List all my new works
|
14
|
+
```
|
15
|
+
$dict list
|
16
|
+
```
|
17
|
+
|
18
|
+
#### Set target language
|
19
|
+
```
|
20
|
+
$dict settings --lang chinese
|
21
|
+
```
|
data/Rakefile
ADDED
data/bin/geekdict
ADDED
data/geekdict.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "geekdict/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "geekdict"
|
7
|
+
s.version = GeekDict::VERSION
|
8
|
+
s.authors = ["Bruce Li"]
|
9
|
+
s.email = ["wbinglee@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A command line tool for translation.}
|
12
|
+
s.description = %q{A command line tool for translation.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "geekdict"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
s.add_development_dependency "rspec", "~> 2.13.0"
|
23
|
+
|
24
|
+
s.add_runtime_dependency "thor", "~> 0.19.1"
|
25
|
+
s.add_runtime_dependency "httpclient", "~> 2.4.0"
|
26
|
+
|
27
|
+
end
|
data/lib/geekdict/cli.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module GeekDict
|
4
|
+
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "t", "Translate a word"
|
8
|
+
option :lang, :aliases=>'-l'
|
9
|
+
def t(word)
|
10
|
+
result = GeekDict::Youdao.translate word
|
11
|
+
output = result.join "\n"
|
12
|
+
puts output
|
13
|
+
output
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'geekdict/youdao/config'
|
5
|
+
|
6
|
+
module GeekDict
|
7
|
+
module Youdao
|
8
|
+
|
9
|
+
#Youdao API version
|
10
|
+
|
11
|
+
module_function
|
12
|
+
|
13
|
+
def translate(word)
|
14
|
+
client = HTTPClient.new
|
15
|
+
query = { keyfrom: APIKEYFROM, key: APIKEY, type: 'data', doctype: 'json',version: APIVERSION, q: word }
|
16
|
+
res = client.get(APIURL, query)
|
17
|
+
res = JSON.parse res.body
|
18
|
+
error_code = res['errorCode']
|
19
|
+
if error_code == 0
|
20
|
+
res['basic']['explains']
|
21
|
+
else
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/geekdict.rb
ADDED
data/spec/.keep
ADDED
File without changes
|
data/spec/cli_spec.rb
ADDED
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geekdict
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruce Li
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.13.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.13.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.19.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.19.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httpclient
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.4.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.4.0
|
69
|
+
description: A command line tool for translation.
|
70
|
+
email:
|
71
|
+
- wbinglee@gmail.com
|
72
|
+
executables:
|
73
|
+
- geekdict
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".ruby-version"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/geekdict
|
83
|
+
- geekdict.gemspec
|
84
|
+
- lib/geekdict.rb
|
85
|
+
- lib/geekdict/cli.rb
|
86
|
+
- lib/geekdict/google/.keep
|
87
|
+
- lib/geekdict/version.rb
|
88
|
+
- lib/geekdict/youdao/api.rb
|
89
|
+
- lib/geekdict/youdao/config.rb
|
90
|
+
- spec/.keep
|
91
|
+
- spec/cli_spec.rb
|
92
|
+
- spec/youdao/api_spec.rb
|
93
|
+
homepage: ''
|
94
|
+
licenses: []
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project: geekdict
|
112
|
+
rubygems_version: 2.2.2
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: A command line tool for translation.
|
116
|
+
test_files:
|
117
|
+
- spec/cli_spec.rb
|
118
|
+
- spec/youdao/api_spec.rb
|