dict 0.3.5 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dict (0.3.4)
4
+ dict (0.3.6)
5
5
  nokogiri (~> 1.5.5)
6
6
  slop (~> 3.3.2)
7
7
 
data/README.md CHANGED
@@ -14,6 +14,14 @@ To search for `WORD`:
14
14
  - `-v` or `--version` - used to show version, authors, license
15
15
  - `-c` or `--clean` - used to delete examples from translation
16
16
 
17
+ ## Contributing
18
+
19
+ 1. Fork it
20
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
21
+ 3. Create test to your feature in RSpec
22
+ 4. Commit your changes (`git commit -am 'Added some feature'`)
23
+ 5. Push to the branch (`git push origin my-new-feature`)
24
+ 6. Create new Pull Request
17
25
 
18
26
 
19
27
  ## People
@@ -19,7 +19,7 @@ module Dict
19
19
  opts = Slop.parse! do
20
20
  banner <<-END
21
21
  Przykład użycia: dict SŁOWO [OPCJE]
22
- Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
22
+ Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
23
23
  END
24
24
 
25
25
  on '-h', :help=, 'Wyświetl pomoc', :argument => :optional
@@ -27,7 +27,7 @@ Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
27
27
  on '-d', :dict=, "Wybierz słownik. Dostępne są : #{Dict.available_dictionaries.join(', ')}"
28
28
  on '-v', :version=, "Informacje o gemie, autorach, licencji", :argument => :optional
29
29
  on '-c', :clean=, "Nie wyświetlaj przykładów użycia", :argument => :optional
30
-
30
+
31
31
  end
32
32
  end
33
33
 
@@ -39,8 +39,6 @@ Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
39
39
  Dict.get_all_dictionaries_translations(word)
40
40
  end
41
41
  end
42
- rescue Timeout::Error
43
- "Upłynął limit czasu żądania."
44
42
  end
45
43
 
46
44
  def expected_argument_description(option)
@@ -55,7 +53,7 @@ Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
55
53
  end
56
54
 
57
55
  MSG = "Przykład użycia: dict SŁOWO [OPCJE]\n `dict --help, aby uzyskać więcej informacji.\n"
58
- VERSION = "dict wersja #{Dict::VERSION}\nWyszukaj SŁOWO w dict, open-source'owym agregatorze słowników. \nCopyright (C) 2012 by\nZespół:\n Jan Borwin\n Mateusz Czerwiński\n Kosma Dunikowski\n Aleksander Gozdek\n Rafał Ośko\n Michał Podlecki\nMentorzy:\n Grzegorz Kołodziejski\n Michał Kwiatkowski\nLicencja: MIT\nStworzono na praktykach w : http://ragnarson.com/\nHosting: Shelly Cloud :\t http://shellycloud.com/\nStrona domowa:\t\t http://github.com/Ragnarson/dict-gem/\nSłowniki:\t\t http://wiktionary.org/\n\t\t\t http://glosbe.com/\n"
56
+ VERSION = "dict wersja #{Dict::VERSION}\nWyszukaj SŁOWO w dict, open-source'owym agregatorze słowników. \nCopyright (C) 2012 by\nZespół:\n Jan Borwin\n Mateusz Czerwiński\n Kosma Dunikowski\n Aleksander Gozdek\n Rafał Ośko\n Michał Podlecki\nMentorzy:\n Grzegorz Kołodziejski\n Michał Kwiatkowski\nLicencja: MIT\nStworzono na praktykach w : http://ragnarson.com/\nHosting: Shelly Cloud :\t http://shellycloud.com/\nStrona domowa:\t\t http://github.com/Ragnarson/dict-gem/\nSłowniki:\t\t http://wiktionary.org/\n\t\t\t http://glosbe.com/\n"
59
57
 
60
58
  # Returns array without duplicates
61
59
  def clean_translation(results)
@@ -67,7 +65,7 @@ Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
67
65
  end
68
66
  clean.uniq
69
67
  end
70
-
68
+
71
69
  # Prints translations from all dictionaries
72
70
  def print_all_dictionaries_translations(results)
73
71
  results.each do |dictionary, translations_hash|
@@ -90,13 +88,19 @@ Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
90
88
  end
91
89
  end
92
90
  end
93
-
91
+
94
92
  # Prints array elements one by one vertically
95
93
  def print_array(arr)
96
- puts "Znaleziono: #{arr.size} tłumaczeń"
94
+ translations_string = case arr.size
95
+ when 1 then "tłumaczenie"
96
+ when 2..4 then "tłumaczenia"
97
+ else "tłumaczeń"
98
+ end
99
+
100
+ puts "Znaleziono: #{arr.size} #{translations_string}"
97
101
  arr.each { |el| puts "- #{el}" }
98
102
  end
99
-
103
+
100
104
  def run
101
105
  begin
102
106
  opts = parse_parameters
@@ -105,32 +109,37 @@ Wyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.
105
109
  description = expected_argument_description(incomplete_option)
106
110
  abort("Brakujący argument. Spodziewano: #{description}")
107
111
  end
108
-
112
+
109
113
  if opts.help?
110
114
  abort(opts.to_s)
111
- elsif opts.version?
115
+ end
116
+
117
+ if opts.version?
112
118
  abort(VERSION)
113
- elsif opts.time?
119
+ end
120
+
121
+ if opts.time?
114
122
  if (opts[:time].to_i) == 0
115
123
  abort("Nieprawidłowa wartość czasu.")
116
- else
117
- print_all_dictionaries_translations(get_translations(opts, ARGV[0]))
118
124
  end
125
+ end
126
+
127
+ if !parameters_valid?
128
+ abort(MSG)
129
+ end
130
+
131
+ translations = get_translations(opts, ARGV[0])
132
+ if opts.clean? && !opts.dict?
133
+ print_translations(clean_translation(translations))
119
134
  else
120
- if !parameters_valid?
121
- abort(MSG)
135
+ if opts.dict?
136
+ print_translations(translations)
122
137
  else
123
- if opts.clean? && !opts.dict?
124
- print_translations(clean_translation(get_translations(opts, ARGV[0])))
125
- else
126
- if opts.dict?
127
- print_translations(get_translations(opts, ARGV[0]))
128
- else
129
- print_all_dictionaries_translations(get_translations(opts, ARGV[0]))
130
- end
131
- end
138
+ print_all_dictionaries_translations(translations)
132
139
  end
133
140
  end
141
+ rescue Timeout::Error
142
+ puts "Upłynął limit czasu żądania."
134
143
  end
135
144
  end
136
145
  end
data/lib/dict/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dict
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
@@ -57,15 +57,15 @@ describe "get_translations" do
57
57
  it "should return timeout message for word słowik and -t 5" do
58
58
  stub_const("ARGV", ["słowik","-t","5"])
59
59
  runner = Dict::CLI::Runner.new
60
- opts = runner.parse_parameters
61
60
  Dict.should_receive(:get_all_dictionaries_translations).
62
61
  and_return { sleep 20 }
63
- runner.get_translations(opts, "słowik").should == "Upłynął limit czasu żądania."
62
+ runner.should_receive(:puts).with("Upłynął limit czasu żądania.");
63
+ runner.run
64
64
  end
65
65
  end
66
66
 
67
67
  describe "CLI::Runner" do
68
- HELP_MSG = "Przykład użycia: dict SŁOWO [OPCJE]\nWyszukaj SŁOWO w dict, open-source'owym agregatorze słowników. \n\n -h, --help Wyświetl pomoc\n -t, --time Ustaw limit czasu żądania w sekundach. Domyślnie: 300\n -d, --dict Wybierz słownik. Dostępne są : wiktionary, glosbe\n -v, --version Informacje o gemie, autorach, licencji\n -c, --clean Nie wyświetlaj przykładów użycia"
68
+ HELP_MSG = "Przykład użycia: dict SŁOWO [OPCJE]\nWyszukaj SŁOWO w dict, open-source'owym agregatorze słowników.\n\n -h, --help Wyświetl pomoc\n -t, --time Ustaw limit czasu żądania w sekundach. Domyślnie: 300\n -d, --dict Wybierz słownik. Dostępne są : wiktionary, glosbe\n -v, --version Informacje o gemie, autorach, licencji\n -c, --clean Nie wyświetlaj przykładów użycia"
69
69
  DICT_MSG = "Brakujący argument. Spodziewano: wiktionary, glosbe"
70
70
  TIME_MSG = "Brakujący argument. Spodziewano: liczba sekund"
71
71
  T_MSG = "Nieprawidłowa wartość czasu."
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.3.5
4
+ version: 0.3.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2012-07-26 00:00:00.000000000 Z
17
+ date: 2012-07-27 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: slop
@@ -197,22 +197,4 @@ rubygems_version: 1.8.24
197
197
  signing_key:
198
198
  specification_version: 3
199
199
  summary: Gem stworzony dla aplikacji słownikowej
200
- test_files:
201
- - spec/dict/lib_dict_cli_runner_spec.rb
202
- - spec/dict/lib_dict_spec.rb
203
- - spec/dict/lib_glosbe_spec.rb
204
- - spec/dict/lib_wiktionary_spec.rb
205
- - spec/dict/spec_helper.rb
206
- - spec/dict/vcr_cassettes/glosbe_translations_asdfff_cassette.yml
207
- - spec/dict/vcr_cassettes/glosbe_translations_atomic_cassette.yml
208
- - spec/dict/vcr_cassettes/glosbe_translations_usage_cassette.yml
209
- - spec/dict/vcr_cassettes/glosbe_translations_woda_cassette.yml
210
- - spec/dict/vcr_cassettes/slowik_runner_cassette.yml
211
- - spec/dict/vcr_cassettes/translations_dragon_cassette.yml
212
- - spec/dict/vcr_cassettes/translations_slownik_cassette.yml
213
- - spec/dict/vcr_cassettes/wiktionary_no_usage_examples.yml
214
- - spec/dict/vcr_cassettes/wiktionary_translate_result_uppercase.yml
215
- - spec/dict/vcr_cassettes/wiktionary_translations_field_cassette.yml
216
- - spec/dict/vcr_cassettes/wiktionary_translations_samochod_cassette.yml
217
- - spec/dict/vcr_cassettes/wiktionary_usage_examples_kot.yml
218
- - spec/dict/vcr_setup.rb
200
+ test_files: []