arb-dict 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/arb-dict +14 -6
- data/lib/arb/dict/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1806fe389b1b2c454044bc49049c094ca01ff035
|
4
|
+
data.tar.gz: 69e5fdbc03a5ba63e9958bb058fd4b123289b7de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aeeddaf5b4bd8b4df326cc4e3bc3c236b6e0e980ccd5d3363ff2878ed496a289dddbbe32d923d76058d6cc933cbcb324d09dbefaa9a79a826d23d63cee21e2f
|
7
|
+
data.tar.gz: 7b5cf5873e58c9493a641651fb4e777be2dba287c034f72bce9aa024b0f058f087dd4cf6f5374aa460b7a438d396014e361cf9f1c473b1c0babef63415478a62
|
data/bin/arb-dict
CHANGED
@@ -35,6 +35,7 @@ begin
|
|
35
35
|
opts = Slop.parse do |o|
|
36
36
|
o.string *%w{-f --format}, 'available choices: json,csv,raw(default)', default: 'raw'
|
37
37
|
o.string *%w{-s --separator},'separator used in array#join in csv format(default: NEWLINE)',default: "\n"
|
38
|
+
o.string *%w{-i --inputfile},'sepecify data input file in which words or phrases should be separated by line'
|
38
39
|
end
|
39
40
|
rescue Slop::MissingArgument
|
40
41
|
puts 'Missing arguments!'
|
@@ -42,10 +43,20 @@ rescue Slop::UnknownOption
|
|
42
43
|
puts 'Unknown options!'
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
46
|
if opts
|
47
|
-
|
48
|
-
|
47
|
+
unless opts.args.size>0 || opts[:inputfile]
|
48
|
+
puts 'Missing target, please specify a word or phrase!'
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
if opts[:inputfile] && File.exists?(opts[:inputfile])
|
52
|
+
if File.exists?(opts[:inputfile])
|
53
|
+
opts.args<<File.readlines(opts[:inputfile]).map(&:chomp)
|
54
|
+
opts.args.flatten!
|
55
|
+
else
|
56
|
+
puts "Can not find inputfile #{opts[:inputfile]}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
opts.args.each do |entity|
|
49
60
|
tmp_hash = JSON.parse(open("http://dict.youdao.com/jsonresult?q=#{URI.encode(entity)}&type=1").read)
|
50
61
|
main_hash = { entity: entity }
|
51
62
|
if entity.ascii_only?
|
@@ -56,8 +67,5 @@ if opts
|
|
56
67
|
end
|
57
68
|
main_hash[:translation]=strict_value(tmp_hash['basic'],'No Translation')
|
58
69
|
send "fmt_#{opts[:format]}", main_hash,opts[:separator]
|
59
|
-
else
|
60
|
-
puts 'Missing target, please specify a word or phrase!'
|
61
|
-
exit
|
62
70
|
end
|
63
71
|
end
|
data/lib/arb/dict/version.rb
CHANGED