dict 0.2.6 → 0.2.7
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.
- data/Gemfile.lock +1 -1
- data/dict.gemspec +1 -1
- data/lib/dict/cli/runner.rb +13 -5
- data/lib/dict/version.rb +1 -1
- data/spec/dict/lib_dict_cli_runner_spec.rb +3 -3
- metadata +2 -1
data/Gemfile.lock
CHANGED
data/dict.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.name = %q{dict}
|
14
14
|
s.version = Dict::VERSION
|
15
|
-
s.authors = ['Aleksander Gozdek', 'Mateusz Czerwinski', 'Michał Podlecki','Rafał Ośko']
|
15
|
+
s.authors = ['Aleksander Gozdek', 'Mateusz Czerwinski', 'Michał Podlecki', 'Rafał Ośko', 'Kosma Dunikowski']
|
16
16
|
s.email = ['mtczerwinski@gmail.com']
|
17
17
|
s.date = Time.now.strftime('%Y-%m-%d')
|
18
18
|
s.summary = %q{Gem made for dictionary application}
|
data/lib/dict/cli/runner.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'dict/dict'
|
4
|
+
require 'dict/version'
|
4
5
|
require 'slop'
|
5
6
|
require 'timeout'
|
6
7
|
|
@@ -18,9 +19,10 @@ Usage: dict WORD [OPTIONS]
|
|
18
19
|
Search WORD in dict, an open source dictionary aggregator.
|
19
20
|
END
|
20
21
|
|
21
|
-
on '-h', :help
|
22
|
+
on '-h', :help=, 'Display this help message', :argument => :optional
|
22
23
|
on '-t', :time=, 'Set timeout in seconds. Default: 300', :as => :int
|
23
24
|
on '-d', :dict=, "Select desired dictionary. Available options: #{Dict.available_dictionaries.join(', ')}"
|
25
|
+
on '-v', :version=, "Information about gem, authors, license", :argument => :optional
|
24
26
|
end
|
25
27
|
opts
|
26
28
|
end
|
@@ -48,6 +50,10 @@ Search WORD in dict, an open source dictionary aggregator.
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
53
|
+
MSG = "Usage: dict WORD [OPTIONS]\nTry `dict --help for more information.\n"
|
54
|
+
VERSION = "dict version #{Dict::VERSION} \nCopyright (C) 2012 by Mateusz Czerwiński, Michał Podlecki,\nAleksander Gozdek, Rafał Ośko, Jan Borwin, Kosma Dunikowski\nLicense: MIT\nHomepage: https://github.com/Ragnarson/dict-gem\nSearch WORD in dict, an open source dictionary aggregator.\n"
|
55
|
+
|
56
|
+
|
51
57
|
def run
|
52
58
|
begin
|
53
59
|
opts = parse_parameters
|
@@ -57,15 +63,17 @@ Search WORD in dict, an open source dictionary aggregator.
|
|
57
63
|
abort("Missing argument. Expected: #{description}")
|
58
64
|
|
59
65
|
end
|
60
|
-
|
66
|
+
|
61
67
|
if opts.help?
|
62
68
|
abort(opts.to_s)
|
69
|
+
elsif opts.version?
|
70
|
+
abort(VERSION)
|
63
71
|
else
|
64
72
|
if !parameters_valid?
|
65
|
-
abort(
|
73
|
+
abort(MSG)
|
66
74
|
else
|
67
75
|
if opts.time?
|
68
|
-
if opts[:time].to_i == 0
|
76
|
+
if (opts[:time].to_i) == 0
|
69
77
|
abort("Wrong time value.")
|
70
78
|
else
|
71
79
|
puts get_translations(opts, ARGV[0])
|
@@ -75,7 +83,7 @@ Search WORD in dict, an open source dictionary aggregator.
|
|
75
83
|
end
|
76
84
|
end
|
77
85
|
end
|
78
|
-
|
86
|
+
|
79
87
|
end
|
80
88
|
end
|
81
89
|
end
|
data/lib/dict/version.rb
CHANGED
@@ -22,14 +22,14 @@ describe "parse_parameters" do
|
|
22
22
|
stub_const("ARGV", ["słowik", "-t", "36"])
|
23
23
|
runner = Dict::CLI::Runner.new
|
24
24
|
opts = runner.parse_parameters
|
25
|
-
{:help=>nil, :time=>"36", :dict=>nil}.should == opts.to_hash
|
25
|
+
{:help=>nil, :time=>"36", :dict=>nil, :version=>nil}.should == opts.to_hash
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return Hash for parameters słowik" do
|
29
29
|
stub_const("ARGV", ["słowik"])
|
30
30
|
runner = Dict::CLI::Runner.new
|
31
31
|
opts = runner.parse_parameters
|
32
|
-
{:help=>nil, :time=>nil, :dict=>nil}.should == opts.to_hash
|
32
|
+
{:help=>nil, :time=>nil, :dict=>nil, :version=>nil}.should == opts.to_hash
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -64,7 +64,7 @@ describe "get_translations" do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "CLI::Runner" do
|
67
|
-
HELP_MSG = "Usage: dict WORD [OPTIONS]\nSearch WORD in dict, an open source dictionary aggregator.\n\n -h, --help
|
67
|
+
HELP_MSG = "Usage: dict WORD [OPTIONS]\nSearch WORD in dict, an open source dictionary aggregator.\n\n -h, --help Display this help message\n -t, --time Set timeout in seconds. Default: 300\n -d, --dict Select desired dictionary. Available options: wiktionary, dictpl\n -v, --version Information about gem, authors, license"
|
68
68
|
DICT_MSG = "Missing argument. Expected: wiktionary, dictpl"
|
69
69
|
TIME_MSG = "Missing argument. Expected: number of seconds"
|
70
70
|
T_MSG = "Wrong time value."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,6 +9,7 @@ authors:
|
|
9
9
|
- Mateusz Czerwinski
|
10
10
|
- Michał Podlecki
|
11
11
|
- Rafał Ośko
|
12
|
+
- Kosma Dunikowski
|
12
13
|
autorequire:
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|