clausewitz-spelling 0.2.17 → 0.2.18

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
  SHA256:
3
- metadata.gz: c7068d2ed59ef6a208ee2f18e86e1ba32d824065b1cec88654ea59f3b689d998
4
- data.tar.gz: 141d5a09103f95f44415d4d65c464485c6187fec964e448ca26c67322f77b5ca
3
+ metadata.gz: ddafbaefcfa38ddf7a3fb270d49d88bf12833b63423e4ca39ecfff7a2fb24763
4
+ data.tar.gz: 2a3b7a8111741d88c2c198f64c442485d3cabaa42f29eadc0812e6969fb52162
5
5
  SHA512:
6
- metadata.gz: 1201a42008e483b88ecd89e3dc826385f546a3000576a4121c520f9b8cea4286c90dfe3ca534d6f76e732c5eed0076940f14e033fc6e59dab635b21a622df5c2
7
- data.tar.gz: 3355650f99636c77df5a84ecfaec6010d3ea049591f09310e67af4dbb44b4847013fcb03d27ec1d5b22540537529c77df58975433cd6450296d8876feb36ef24
6
+ metadata.gz: 6e1976d6d96abf18f713a6d14c6649669700f377642cfeba128e4ec7943d80c5c05a91c8e229b9e187c71065ed9e6d06381da50ca428a2d556f3afb65564db23
7
+ data.tar.gz: a8513b7b18b001182918c55861aca28760c1fff2c7e38ede6d5777a82d93905c21d4a975f7794fbd0ab84acd974adb88a42de96575a5aebfaa500facbcfb79ca
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clausewitz-spelling (0.2.17)
4
+ clausewitz-spelling (0.2.18)
5
5
  colorize
6
6
  damerau-levenshtein
7
7
  ffi-hunspell-wtchappell
@@ -26,31 +26,27 @@ module Clausewitz; module Spelling
26
26
  @commit_range = opts[:commit_range]
27
27
 
28
28
  @check_cache = {}
29
-
30
- load_dictionaries!
29
+ @loaded_dicts = {}
31
30
  end
32
31
 
33
- def load_dictionaries!
34
- @loaded_dicts = {}
35
- Localisation::LANG_MAP.each do |_, config|
36
- if @dialect_map.key?(config.name)
37
- config.select_dialect(@dialect_map[config.name])
38
- end
32
+ def load_dictionary!(config)
33
+ if @dialect_map.key?(config.name)
34
+ config.select_dialect(@dialect_map[config.name])
35
+ end
39
36
 
40
- dict = FFI::Hunspell.dict(config.full_name)
37
+ dict = FFI::Hunspell.dict(config.full_name)
41
38
 
42
- @custom_dicts.each do |custom_dict|
43
- path = @custom_dict_root.join("#{config.full_name}_#{custom_dict}")
44
- path = Pathname.new("#{path}.dic")
45
- if path.exist?
46
- dict.add_dic(path.to_s)
47
- else
48
- $stderr.puts("Could not load dictionary '#{path}', skipping...")
49
- end
39
+ @custom_dicts.each do |custom_dict|
40
+ path = @custom_dict_root.join("#{config.full_name}_#{custom_dict}")
41
+ path = Pathname.new("#{path}.dic")
42
+ if path.exist?
43
+ dict.add_dic(path.to_s)
44
+ else
45
+ $stderr.puts("Could not load dictionary '#{path}', skipping...")
50
46
  end
51
-
52
- @loaded_dicts[config.name] = dict
53
47
  end
48
+
49
+ @loaded_dicts[config.name] = dict
54
50
  end
55
51
 
56
52
  def check_file(filepath)
@@ -90,14 +86,22 @@ module Clausewitz; module Spelling
90
86
  end
91
87
 
92
88
  checks = contents.map do |lang_name, entries|
93
- lc = language_config(lang_name)
94
89
  if @commit_range
95
90
  ignore = entries&.keys&.select do |key|
96
91
  !changed_keys.include?(key)
97
92
  end
98
93
  end
99
94
  ignore ||= []
100
- check_entries(entries, lc, ignore)
95
+ lc = language_config(lang_name)
96
+ begin
97
+ load_dictionary!(lc) unless @loaded_dicts.keys.include?(lang_name)
98
+ rescue ArgumentError => e
99
+ if e.message =~ /unable to find the dictionary/
100
+ MissingLangResult.new(lc.clausewitz_name)
101
+ end
102
+ else
103
+ check_entries(entries, lc, ignore)
104
+ end
101
105
  end
102
106
  FileResults.new(filepath, checks)
103
107
  end
@@ -84,6 +84,41 @@ module Clausewitz; module Spelling
84
84
  end
85
85
  end
86
86
 
87
+ class MissingLangResult
88
+ def initialize(lang)
89
+ @lang = lang
90
+ end
91
+
92
+ def ignored?
93
+ false
94
+ end
95
+
96
+ def ignored
97
+ []
98
+ end
99
+
100
+ def failed?
101
+ true
102
+ end
103
+
104
+ def failures
105
+ []
106
+ end
107
+
108
+ def size
109
+ 0
110
+ end
111
+
112
+ def to_s
113
+ to_str
114
+ end
115
+
116
+ def to_str(indent = 0)
117
+ firstspacer = ' ' * indent
118
+ "#{firstspacer}#{@lang} failed - missing #{@lang} dictionaries!".red
119
+ end
120
+ end
121
+
87
122
  class IgnoredLangResult
88
123
  def initialize(lang)
89
124
  @lang = lang
@@ -1,5 +1,5 @@
1
1
  module Clausewitz
2
2
  module Spelling
3
- VERSION = "0.2.17"
3
+ VERSION = "0.2.18"
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.2.17
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Chappell