typo_checker 0.1.3 → 0.1.5
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/lib/data/typos.csv +0 -4
- data/lib/typo_checker/version.rb +1 -1
- data/lib/typo_checker.rb +23 -17
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7173dd0294a0f7645db2dde57c7fdd4dedd49643668ce2c7d59bc13d09d1d9f4
|
4
|
+
data.tar.gz: 37477c3e7eb020a7112fae39b9c30bdc3b78d8b4cb526da8ecab38a17e3ecfce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 954a4e7a09375a52125d1db49ac0a5845ae8ef56867eb1e7c984244513ff0e801977a5f691ef181d8f7f91bb471af706fd94b04246c5bdc11a37aced5a6ffaf4
|
7
|
+
data.tar.gz: 38b377026a5433b5800517076afd009222e2a903cbd0df9b324b3e3c2ccd1fbf2e5b7679d7a505f5d073ccbf54bdad6061c2da3e056f4990e5de46cae74ec555
|
data/lib/data/typos.csv
CHANGED
@@ -28555,7 +28555,6 @@ decellerations,decelerations
|
|
28555
28555
|
decellerator,decelerator
|
28556
28556
|
decelopers,developers
|
28557
28557
|
decembeard,december
|
28558
|
-
december,December
|
28559
28558
|
decembre,december
|
28560
28559
|
decement,decrement
|
28561
28560
|
decend,descend
|
@@ -105464,7 +105463,6 @@ sylize,stylize
|
|
105464
105463
|
syllabe,syllable
|
105465
105464
|
syllabel,syllable
|
105466
105465
|
syllabels,syllables
|
105467
|
-
sym,symbolic
|
105468
105466
|
symantec,semantics
|
105469
105467
|
symantic,semantic
|
105470
105468
|
symantics,semantics
|
@@ -108272,7 +108270,6 @@ tmeple,temple
|
|
108272
108270
|
tmerinal,terminal
|
108273
108271
|
tmeselves,themselves
|
108274
108272
|
tmhis,this
|
108275
|
-
tmp,test
|
108276
108273
|
tmplate,template
|
108277
108274
|
tnat,that
|
108278
108275
|
tne,the
|
@@ -111815,7 +111812,6 @@ underround,underground
|
|
111815
111812
|
undersand,understand
|
111816
111813
|
undersatnd,understands
|
111817
111814
|
underscoares,underscores
|
111818
|
-
underscorehomepekedevelrobotframeworkdocuserguiderobotframeworkuserguidehtml,underscore
|
111819
111815
|
undersdand,understand
|
111820
111816
|
undersecore,underscore
|
111821
111817
|
undersetimate,underestimate
|
data/lib/typo_checker/version.rb
CHANGED
data/lib/typo_checker.rb
CHANGED
@@ -6,24 +6,28 @@ require 'fileutils'
|
|
6
6
|
|
7
7
|
module TypoChecker
|
8
8
|
class Checker
|
9
|
-
attr_reader :typos, :excludes, :skips, :
|
9
|
+
attr_reader :typos, :excludes, :skips, :stdoutput
|
10
10
|
|
11
11
|
def initialize(excludes = [], skips = [], stdoutput = true)
|
12
12
|
@excludes = excludes
|
13
13
|
@skips = skips.map(&:downcase)
|
14
14
|
@typos = load_typos
|
15
|
-
@found_typos = []
|
16
15
|
@stdoutput = stdoutput
|
17
16
|
end
|
18
17
|
|
19
18
|
def scan_repo(repo_path = Dir.pwd)
|
19
|
+
result = {}
|
20
20
|
Find.find(repo_path) do |path|
|
21
21
|
next if exclude_path?(path)
|
22
22
|
|
23
|
-
scan_file(path) if File.file?(path) && text_file?(path)
|
23
|
+
scan_file(path, result) if File.file?(path) && text_file?(path)
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
result.map do |path, data|
|
27
|
+
data[:typos].map do |entry|
|
28
|
+
{ path: path, line: entry[:line], typos: entry[:typos] }
|
29
|
+
end
|
30
|
+
end.flatten
|
27
31
|
end
|
28
32
|
|
29
33
|
private
|
@@ -65,33 +69,35 @@ module TypoChecker
|
|
65
69
|
].include? File.extname(path)
|
66
70
|
end
|
67
71
|
|
68
|
-
def scan_file(path)
|
72
|
+
def scan_file(path, result)
|
69
73
|
File.foreach(path).with_index do |line, line_number|
|
70
74
|
words = line.split(/[^a-zA-Z0-9']+/)
|
71
75
|
check_words = words.map { |word| split_function_name(word) }.flatten
|
72
76
|
check_words.each do |word|
|
73
77
|
clean_word = word.gsub(/^[^\w]+|[^\w]+$/, '')
|
74
78
|
char_index = line.index(clean_word)
|
75
|
-
check_word(clean_word, path, line_number, char_index)
|
79
|
+
check_word(clean_word, path, line_number, char_index, result)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
80
|
-
def check_word(word, file, line_num, char_index)
|
84
|
+
def check_word(word, file, line_num, char_index, result)
|
81
85
|
return unless typos.key?(word.downcase)
|
82
86
|
|
83
87
|
corrected_word = corrected_word(word, typos[word.downcase])
|
88
|
+
typo_details = { incorrect_word: word, correct_word: corrected_word }
|
84
89
|
typo_path = "#{file}:#{line_num + 1}:#{char_index + 1}"
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
path = file.sub(%r{^./}, '')
|
91
|
+
|
92
|
+
result[path] ||= {}
|
93
|
+
result[path][:typos] ||= []
|
94
|
+
line_entry = result[path][:typos].find { |entry| entry[:line] == line_num + 1 }
|
95
|
+
|
96
|
+
if line_entry
|
97
|
+
line_entry[:typos] << typo_details
|
98
|
+
else
|
99
|
+
result[path][:typos] << { line: line_num + 1, typos: [typo_details] }
|
100
|
+
end
|
95
101
|
|
96
102
|
stdout(typo_path, word, corrected_word) if stdoutput
|
97
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typo_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- datpmt
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: thor
|
@@ -47,7 +46,6 @@ licenses:
|
|
47
46
|
metadata:
|
48
47
|
source_code_uri: https://github.com/datpmt/typo_checker
|
49
48
|
changelog_uri: https://github.com/datpmt/typo_checker/blob/main/CHANGELOG.md
|
50
|
-
post_install_message:
|
51
49
|
rdoc_options: []
|
52
50
|
require_paths:
|
53
51
|
- lib
|
@@ -62,8 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
60
|
- !ruby/object:Gem::Version
|
63
61
|
version: '0'
|
64
62
|
requirements: []
|
65
|
-
rubygems_version: 3.2
|
66
|
-
signing_key:
|
63
|
+
rubygems_version: 3.6.2
|
67
64
|
specification_version: 4
|
68
65
|
summary: TypoChecker is a tool for scanning source code files for common typographical
|
69
66
|
errors.
|