clausewitz-spelling 0.1.5 → 0.1.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/clausewitz/spelling/checker.rb +12 -8
- data/lib/clausewitz/spelling/results.rb +12 -4
- data/lib/clausewitz/spelling/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adb9e6a92780070203cbdebb8c4ed53de713acc5
|
4
|
+
data.tar.gz: 478dfd5e51b6a7d55b4011beabde495b51aa95dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d23c534633cdc1de14d40c0ce87832b35138b8fc014ba647be056a310ddd134fac6b19d10106d0d1dec69e0fe3be38b6c4607b7e6fa2f72ef6cd6e652392ea44
|
7
|
+
data.tar.gz: c1329c0a425fb5f0aaa83d0a43ba43403b14d965184f3f403cc9d20e164db1ef28b0f9b22ca518298009f908ba90805e9579d3635f7193c09f4f457d681192f3
|
data/Gemfile.lock
CHANGED
@@ -35,11 +35,14 @@ module Clausewitz; module Spelling
|
|
35
35
|
@custom_words_filepath = generate_word_list
|
36
36
|
@en_speller.set('extra-dicts', @custom_words_filepath)
|
37
37
|
@en_speller.set('ignore-accents', true)
|
38
|
+
else
|
39
|
+
@dict_words = Set.new([])
|
40
|
+
@en_speller.set('ignore-accents', true)
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
def check_file(file_path)
|
42
|
-
$stderr.
|
45
|
+
$stderr.puts "Checking #{file_path}..."
|
43
46
|
loc = load_file(file_path)
|
44
47
|
# Poorly formatted YAML files often lack proper indentation; you can
|
45
48
|
# easily discover this by checking to make sure all top level keys are
|
@@ -61,18 +64,19 @@ module Clausewitz; module Spelling
|
|
61
64
|
|
62
65
|
def check_files(file_paths)
|
63
66
|
results = Array(file_paths).map do |file_path|
|
64
|
-
check_file(file_path)
|
67
|
+
check_file(file_path) unless File.directory?(file_path)
|
65
68
|
end
|
66
|
-
OverallResults.new(results)
|
69
|
+
OverallResults.new(results.compact)
|
67
70
|
end
|
68
71
|
|
69
72
|
def check_entries(lang, entries)
|
70
73
|
misspellings = []
|
71
|
-
entries
|
72
|
-
|
73
|
-
|
74
|
+
if entries && !entries.empty?
|
75
|
+
entries.each do |key, text|
|
76
|
+
result = check_entry(key, text)
|
77
|
+
misspellings << result unless result.check_results.empty?
|
78
|
+
end
|
74
79
|
end
|
75
|
-
misspellings
|
76
80
|
LangResults.new(lang, misspellings)
|
77
81
|
end
|
78
82
|
|
@@ -119,7 +123,7 @@ module Clausewitz; module Spelling
|
|
119
123
|
private
|
120
124
|
|
121
125
|
def bad_lang_key(key)
|
122
|
-
key !~
|
126
|
+
key !~ /^l_.+/
|
123
127
|
end
|
124
128
|
|
125
129
|
def is_ordinal?(word)
|
@@ -21,8 +21,17 @@ module Clausewitz; module Spelling
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def render
|
24
|
-
|
25
|
-
|
24
|
+
successful, failed = @lang_results.partition do |lang|
|
25
|
+
lang.key_results.empty?
|
26
|
+
end
|
27
|
+
successful.each do |lang|
|
28
|
+
puts " #{@file_path}:#{lang.lang} passed".green
|
29
|
+
end
|
30
|
+
failed.each do |lang|
|
31
|
+
failed_count = lang.key_results.size.to_s.red
|
32
|
+
puts " #{@file_path}:#{lang.lang} has #{failed_count} langs with errors:"
|
33
|
+
lang.key_results.each(&:render)
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
28
37
|
|
@@ -46,8 +55,7 @@ module Clausewitz; module Spelling
|
|
46
55
|
end
|
47
56
|
|
48
57
|
def render
|
49
|
-
|
50
|
-
puts " #{@file_path} has unknown languages #{langs}!".red
|
58
|
+
puts " #{@file_path} has unknown language keys!".red
|
51
59
|
puts " Make sure that each loc key has *two* leading *spaces*.".yellow
|
52
60
|
end
|
53
61
|
end
|