that_language 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41ecd55149abde5d1b27e64be73afd2e63d0b821
4
- data.tar.gz: 82764566978fa2fdee98eaf3f8d7f7b71bdb6742
3
+ metadata.gz: 98adc3d50c5db166ed67999b80c33c57b591f62a
4
+ data.tar.gz: eee7118251bc0fd2ff3ff406c49d62290bf164c4
5
5
  SHA512:
6
- metadata.gz: f4c718d69f9f1f38da49d24f80d01507064aa32a6571bfbe31ac99f2ac5ce45fdbd2437c2a9599cb1be6d9f36ae4838ec1783491826e1bd4642b714f9c5e83f3
7
- data.tar.gz: 8d1482da930ffe300f288476b11274f22b001df698f49d7901fdfbb6944b827b75f37a0f3650892ce3433932fb843dd918c5425a3b285cbd7c99a95229624233
6
+ metadata.gz: 57460596ffd60c2c2bd69c17c1088e39db6de20e820ef7e20b8a3ae3021c5ee420009882e463da1f13d07fca095a05c615873c61230a52432cd4defdabdb6578
7
+ data.tar.gz: 792b5f984d2d14c234a2d7fcdbd0e397ab7405532949032b7e38b81a0a72506ff37b8fd99ef0f756d00950ea90a429bc839eef768d468a7e68fbb01134effeb0
@@ -10,7 +10,7 @@ module ThatLanguage
10
10
  end
11
11
 
12
12
  def language(text)
13
- Iso639[detect(text).language_code]
13
+ detect(text).language
14
14
  end
15
15
 
16
16
  def language_code(text)
@@ -28,7 +28,11 @@ module ThatLanguage
28
28
 
29
29
  words.each do |word|
30
30
  word_result = lookup_context.normalized(word)
31
- word_result.each { |language_code, value| result_set.for(language_code).add(value) }
31
+ word_result.each do |language_code, value|
32
+ next unless value > 0
33
+
34
+ result_set.for(language_code).add(value)
35
+ end
32
36
  end
33
37
 
34
38
  result_set
@@ -44,7 +44,7 @@ module ThatLanguage
44
44
  end
45
45
 
46
46
  def language
47
- Iso639[language_code]
47
+ Iso639[language_code] if language_code
48
48
  end
49
49
 
50
50
  def to_h
@@ -2,6 +2,9 @@ module ThatLanguage
2
2
  class ResultSet
3
3
  include Enumerable
4
4
 
5
+ # TODO: Handle no result in a better way (NullObject anyone?)
6
+ NO_RESULT = Result.new(language_code: nil)
7
+
5
8
  def initialize(words_count)
6
9
  @words_count = words_count
7
10
  end
@@ -11,7 +14,7 @@ module ThatLanguage
11
14
  end
12
15
 
13
16
  def winner
14
- results.max
17
+ results.max || NO_RESULT
15
18
  end
16
19
 
17
20
  def results
@@ -1,3 +1,3 @@
1
1
  module ThatLanguage
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: that_language
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Helm