clausewitz-spelling 0.1.18 → 0.1.19

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: 45dfa3f0e350c7b4b3ba9d1a6f69c970cb884134
4
- data.tar.gz: c4ffb8579ab8787115d447b11fa49cb4a3159569
3
+ metadata.gz: 55b8f238c7ccf5a99e18aea147d865baa3eba23e
4
+ data.tar.gz: 737b15a9ea8c6dfb3b1279d1170986aa9b080e8f
5
5
  SHA512:
6
- metadata.gz: 4661cea315ffec778213bf3b67ea6322973d19ce5a6302a23b2f8afef4eb1231583df251b7b098274bfd7b32b9d3f40cf01bca6cc65efd87bc3bd8581cd73e69
7
- data.tar.gz: 44c9608f76e094a80d7ffd4924641ab65ede46b46a10a99daad2b70a4f7c9d0934df1f6b243a84deb23a71a9e21b2734e6205012f42d8c173e5cda9883bc6f97
6
+ metadata.gz: 523a1c3c5cbed97de4454eca5422a181846544338e7fc108457f924f2a9a3ba9f3b1b1329679e5358f958b12b10d94972bc6a05767fc5feacf7b9bb804444ce5
7
+ data.tar.gz: 3206f38862471223cc8fd4096cb398b1b42864b15ef8a60bb82de1e507f4bf497bfb86e7e46fbbe57d8eb643141f18d4e42c2f22940314e36c3e6b82feaa4cf6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clausewitz-spelling (0.1.18)
4
+ clausewitz-spelling (0.1.19)
5
5
  colorize
6
6
  damerau-levenshtein
7
7
  ffi-aspell
@@ -74,13 +74,13 @@ module Clausewitz; module Spelling
74
74
  if ignored_keys.include?(key)
75
75
  IgnoredEntryResult.new(key)
76
76
  else
77
- check_entry(aspell_checker, wordlist, key, entry)
77
+ check_entry(lc, aspell_checker, wordlist, key, entry)
78
78
  end
79
79
  end
80
80
  LangResults.new(lc.clausewitz_name, checks)
81
81
  end
82
82
 
83
- def check_entry(checker, wordlist, key, entry)
83
+ def check_entry(lc, checker, wordlist, key, entry)
84
84
  # We don't want to pay attention to scripted localisation, so we'll strip
85
85
  # it out before we start.
86
86
  # TODO: Look into supporting escaped square brackets as part of the
@@ -117,7 +117,7 @@ module Clausewitz; module Spelling
117
117
  #end.join(" ")
118
118
 
119
119
  opts = {
120
- language: :en,
120
+ language: lc.base.to_sym,
121
121
  punctuation: :none,
122
122
  downcase: false
123
123
  }
@@ -131,6 +131,7 @@ module Clausewitz; module Spelling
131
131
 
132
132
  def check_word(checker, wordlist, word)
133
133
  return if is_number?(word)
134
+ return if is_plural_number?(word)
134
135
  return if is_ordinal?(word)
135
136
  return if is_percentage?(word)
136
137
  return if is_icon?(word)
@@ -143,6 +144,10 @@ module Clausewitz; module Spelling
143
144
  end
144
145
  end
145
146
 
147
+ def is_plural_number?(word)
148
+ word =~ /\d+'s/
149
+ end
150
+
146
151
  def is_psalm?(word)
147
152
  word =~ /^\d+:\d+$/
148
153
  end
@@ -159,7 +164,8 @@ module Clausewitz; module Spelling
159
164
  aspell_suggestions = checker.suggestions(word)
160
165
 
161
166
  custom_suggestions = wordlist.select do |dict_word|
162
- DamerauLevenshtein.distance(word, dict_word) < word.size
167
+ min = [word.size, dict_word.size].min
168
+ DamerauLevenshtein.distance(word, dict_word) < min
163
169
  end
164
170
 
165
171
  aspell_suggestions.each { |sug| suggestions.add(sug) }
@@ -146,6 +146,17 @@ module Clausewitz; module Spelling
146
146
  def failed?
147
147
  true
148
148
  end
149
+
150
+ def to_s
151
+ to_str
152
+ end
153
+
154
+ def to_str(indent = 0)
155
+ spacer = ' ' * indent
156
+ secondspacer = ' ' * (indent + 2)
157
+ "#{spacer}#{@filepath} is invalid\n".red +
158
+ "#{secondspacer}#{@error.message}".red
159
+ end
149
160
  end
150
161
 
151
162
  # Result capturing problems parsing a readable file.
@@ -1,5 +1,5 @@
1
1
  module Clausewitz
2
2
  module Spelling
3
- VERSION = "0.1.18"
3
+ VERSION = "0.1.19"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clausewitz-spelling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Chappell