typo_checker 0.1.7 → 0.1.9
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 -5
- data/lib/typo_checker/cli.rb +2 -1
- data/lib/typo_checker/configuration.rb +4 -3
- data/lib/typo_checker/file_scanner.rb +1 -1
- data/lib/typo_checker/repository_scanner.rb +32 -6
- data/lib/typo_checker/version.rb +1 -1
- data/lib/typo_checker.rb +7 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9140408fbb85977164d301d8023bc484601d97b0b70038fb7b1a9b8163e6ddad
|
4
|
+
data.tar.gz: c9ac12e67b562106c2a90a30605b7c226f5d17eef2937da3461a78d07e850062
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0734fd66b0d6090c6197b95395d6a8ec4df494a850c5ae559a06aa591bdfbf2116a328266c981639f054c53a86e78decd0d57b02b9d5869163c39a73b0c4483a
|
7
|
+
data.tar.gz: 9dc0cc04ac8f7e3e9fad54a6e7c9c16733049bc77341d8b9f6ea750f673c682f7bb2a5954414b9b08b65ed45ac6e6d8072861a5ae948e697ff95687d7fcea63e
|
data/lib/data/typos.csv
CHANGED
@@ -36985,7 +36985,6 @@ duplifaces,duplicates
|
|
36985
36985
|
duplucated,duplicated
|
36986
36986
|
dupplicate,duplicate
|
36987
36987
|
dupplicated,duplicated
|
36988
|
-
dur,due
|
36989
36988
|
durabiblity,durabibility
|
36990
36989
|
durabiity,durability
|
36991
36990
|
durabiliy,durability
|
@@ -62567,7 +62566,6 @@ keywork,keyword
|
|
62567
62566
|
keyworks,keywords
|
62568
62567
|
keyworn,keyword
|
62569
62568
|
keywrod,keyword
|
62570
|
-
kh,kc
|
62571
62569
|
khachindorbatly,khachindorbately
|
62572
62570
|
khaligrpah,khaligraph
|
62573
62571
|
khornofuly,khornofully
|
@@ -85514,7 +85512,6 @@ prviously,previously
|
|
85514
85512
|
pryamid,pyramid
|
85515
85513
|
pryamids,pyramids
|
85516
85514
|
pryor,prior
|
85517
|
-
ps,rs
|
85518
85515
|
psasword,password
|
85519
85516
|
psblogggers,psbloggers
|
85520
85517
|
pschicology,psychology
|
@@ -86459,7 +86456,6 @@ qrite,write
|
|
86459
86456
|
qroperly,properly
|
86460
86457
|
qsueries,queries
|
86461
86458
|
qtuie,quite
|
86462
|
-
qu,quo
|
86463
86459
|
quacamole,guacamole
|
86464
86460
|
quadran,quadrant
|
86465
86461
|
quadrapole,quadrupole
|
@@ -107431,7 +107427,6 @@ tfunction,function
|
|
107431
107427
|
tge,the
|
107432
107428
|
tghe,the
|
107433
107429
|
tghis,this
|
107434
|
-
th,the
|
107435
107430
|
th9s,this
|
107436
107431
|
thagy,shaggy
|
107437
107432
|
thain,train
|
data/lib/typo_checker/cli.rb
CHANGED
@@ -6,11 +6,12 @@ module TypoChecker
|
|
6
6
|
class CLI < Thor
|
7
7
|
desc 'scan REPO_PATH', 'Scan a repository for typos'
|
8
8
|
|
9
|
+
method_option :paths, type: :array, default: [], aliases: '-p', desc: 'Only scan the specified paths'
|
9
10
|
method_option :excludes, type: :array, default: [], aliases: '-e', desc: 'Skip the directories'
|
10
11
|
method_option :skips, type: :array, default: [], aliases: '-s', desc: 'Skip the typos'
|
11
12
|
|
12
13
|
def scan(repo_path)
|
13
|
-
checker = TypoChecker::Checker.new(options[:excludes], options[:skips])
|
14
|
+
checker = TypoChecker::Checker.new(paths: options[:paths], excludes: options[:excludes], skips: options[:skips])
|
14
15
|
checker.scan_repo(repo_path)
|
15
16
|
end
|
16
17
|
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module TypoChecker
|
2
2
|
class Configuration
|
3
|
-
attr_reader :excludes, :skips, :stdoutput
|
3
|
+
attr_reader :paths, :excludes, :skips, :stdoutput
|
4
4
|
|
5
|
-
def initialize(excludes
|
5
|
+
def initialize(paths: [], excludes: [], skips: [], stdoutput: true)
|
6
|
+
@paths = paths || []
|
6
7
|
@excludes = excludes || []
|
7
8
|
@skips = (skips || []).map(&:downcase)
|
8
|
-
@stdoutput = stdoutput.nil?
|
9
|
+
@stdoutput = stdoutput.nil? || stdoutput
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -63,7 +63,7 @@ module TypoChecker
|
|
63
63
|
return unless @stdoutput
|
64
64
|
|
65
65
|
puts "Typo found in #{colorize_light_blue(typo_path)}: " \
|
66
|
-
|
66
|
+
"#{colorize_red(word)} -> #{colorize_green(corrected_word)}"
|
67
67
|
end
|
68
68
|
|
69
69
|
def colorize_red(text)
|
@@ -9,20 +9,46 @@ module TypoChecker
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def scan
|
12
|
-
|
13
|
-
|
14
|
-
next if exclude_path?(path)
|
12
|
+
cops = {}
|
13
|
+
paths = @configuration.paths
|
15
14
|
|
16
|
-
|
15
|
+
if paths.empty?
|
16
|
+
# Find all files in the repository
|
17
|
+
Find.find(@repo_path) do |path|
|
18
|
+
next if exclude_path?(path)
|
19
|
+
|
20
|
+
find_cops(cops, path)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
paths.each do |pattern|
|
24
|
+
# Find files based on the pattern
|
25
|
+
Dir.glob(File.join(@repo_path, pattern)) do |path|
|
26
|
+
next if exclude_path?(path)
|
27
|
+
|
28
|
+
find_cops(cops, path)
|
29
|
+
end
|
30
|
+
end
|
17
31
|
end
|
18
|
-
|
32
|
+
scan_result(cops)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def scan_result(cops)
|
38
|
+
cops.map do |path, data|
|
19
39
|
data[:typos].map do |entry|
|
20
40
|
{ path: path, line: entry[:line], typos: entry[:typos] }
|
21
41
|
end
|
22
42
|
end.flatten
|
23
43
|
end
|
24
44
|
|
25
|
-
|
45
|
+
def find_cops(cops, path)
|
46
|
+
@file_scanner.scan_file(path, cops) if valid_text_file?(path)
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid_text_file?(path)
|
50
|
+
File.file?(path) && text_file?(path)
|
51
|
+
end
|
26
52
|
|
27
53
|
def exclude_path?(path)
|
28
54
|
exclude_patterns.any? { |pattern| path.match?(pattern) }
|
data/lib/typo_checker/version.rb
CHANGED
data/lib/typo_checker.rb
CHANGED
@@ -10,8 +10,13 @@ require_relative 'typo_checker/repository_scanner'
|
|
10
10
|
|
11
11
|
module TypoChecker
|
12
12
|
class Checker
|
13
|
-
def initialize(excludes
|
14
|
-
|
13
|
+
def initialize(paths: [], excludes: [], skips: [], stdoutput: true)
|
14
|
+
raise ArgumentError, '`paths` must be an Array' unless paths.instance_of?(Array)
|
15
|
+
raise ArgumentError, '`excludes` must be an Array' unless excludes.instance_of?(Array)
|
16
|
+
raise ArgumentError, '`skips` must be an Array' unless skips.instance_of?(Array)
|
17
|
+
raise ArgumentError, '`stdoutput` must be a Boolean' unless [TrueClass, FalseClass].include?(stdoutput.class)
|
18
|
+
|
19
|
+
@configuration = Configuration.new(paths: paths, excludes: excludes, skips: skips, stdoutput: stdoutput)
|
15
20
|
end
|
16
21
|
|
17
22
|
def scan_repo(repo_path = Dir.pwd)
|
metadata
CHANGED
@@ -1,13 +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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- datpmt
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: thor
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
|
-
rubygems_version: 3.6.
|
67
|
+
rubygems_version: 3.6.7
|
68
68
|
specification_version: 4
|
69
69
|
summary: TypoChecker is a tool for scanning source code files for common typographical
|
70
70
|
errors.
|