fy 0.1.0 → 1.0.0
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/bin/fy +1 -1
- data/lib/fy/fanyi.rb +8 -8
- data/lib/fy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 956cb074af820b4bce5c4fa549eb02dbe35d6da8
|
4
|
+
data.tar.gz: 4e0ace04344f0213b5d3390f7fc48e4869670286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824222907a2296150b94c6704c937c5e303f1660e9a0c8d643f239b962315ad6bf19d92db580469f52e8498198791ec7b43305672198a3190243303dd65e5435
|
7
|
+
data.tar.gz: 7cd1623d07db4fbd695b9ae4378058f2c49e7c414102550f9aafe5979654b07818efb33c261d017d4fd5c669c470e6046581db8c2288d44c42cf565f51de19a4
|
data/bin/fy
CHANGED
data/lib/fy/fanyi.rb
CHANGED
@@ -16,29 +16,29 @@ module Fy
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def query_for_hash
|
19
|
-
query_url
|
20
|
-
result_json
|
19
|
+
query_url = api_url + URI.escape(@words.gsub(/ /, '+'))
|
20
|
+
result_json = Net::HTTP.get(URI(query_url))
|
21
21
|
@result_hash = JSON.parse(result_json)
|
22
22
|
end
|
23
23
|
|
24
24
|
def translations
|
25
25
|
translations = @result_hash["translation"]
|
26
|
-
lines
|
26
|
+
lines = translations.collect do |translation|
|
27
27
|
" " + translation.color(:green)
|
28
28
|
end
|
29
29
|
lines << ""
|
30
30
|
end
|
31
31
|
|
32
32
|
def word_and_phonetic
|
33
|
-
line
|
33
|
+
line = " " + @words
|
34
34
|
phonetic = @result_hash["basic"]["phonetic"] if @result_hash["basic"]
|
35
|
-
line
|
35
|
+
line += " [ #{phonetic} ]".color(:magenta) if phonetic
|
36
36
|
[line, ""]
|
37
37
|
end
|
38
38
|
|
39
39
|
def dict_explains
|
40
40
|
dict_explains = @result_hash["basic"]["explains"] if @result_hash["basic"]
|
41
|
-
lines
|
41
|
+
lines = dict_explains.collect do |explain|
|
42
42
|
" - " + explain.color(:green)
|
43
43
|
end
|
44
44
|
lines << ""
|
@@ -46,10 +46,10 @@ module Fy
|
|
46
46
|
|
47
47
|
def web_results
|
48
48
|
return [] unless @result_hash["web"]
|
49
|
-
lines
|
49
|
+
lines = []
|
50
50
|
web_results = @result_hash["web"]
|
51
51
|
web_results.each_with_index do |web_result, i|
|
52
|
-
web_result_key
|
52
|
+
web_result_key = web_result["key"].gsub(/#{@words}/i, @words.color(:yellow))
|
53
53
|
web_result_value = web_result["value"].join(', ').color(:cyan)
|
54
54
|
lines << " #{i+1}. #{web_result_key}"
|
55
55
|
lines << " #{web_result_value}"
|
data/lib/fy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JIANG Di
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.4.
|
92
|
+
rubygems_version: 2.4.6
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: A translate tool in your command line
|