arb-dict 0.2.0 → 0.2.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/arb-dict +14 -6
  3. data/lib/arb/dict/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b214c7c10d773613245dba86caa18295da2d08e9
4
- data.tar.gz: 4c55d7e6356b7204f38e1a517c3c0ca8f69a32e9
3
+ metadata.gz: 1806fe389b1b2c454044bc49049c094ca01ff035
4
+ data.tar.gz: 69e5fdbc03a5ba63e9958bb058fd4b123289b7de
5
5
  SHA512:
6
- metadata.gz: 42f711661b908e8c7224c257e9cc73dab2b89b51bd6302a076e8b7022522d245b267f54a14dcb176a2af3809fea17e5847bc00369126579b3ba2d47b0d797973
7
- data.tar.gz: 72644150cbec7620239c0f8e8790eb8e2a9ebf01f913fb29d02574836bc5ff20a8a5a8ff731087928c47ed5f65c4fdfa188ff3233cb44c9ba2185a10100edc0f
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
- entity = opts.args.first
48
- if entity
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
@@ -1,5 +1,5 @@
1
1
  module Arb
2
2
  module Dict
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arb-dict
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - arybin