typo_checker 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e1e06748572f803e8d7e9a46765461b1c5780abc659f9a45287df63abf1f5ae
4
- data.tar.gz: d5d762a890491d39e1fef339ce6276cb3b7ede343b278a9e0d29d27aed0ebc59
3
+ metadata.gz: 993172dbd5d6abda8122d79b5b704a3d33c62b070ec992a32a65b88796ee9a89
4
+ data.tar.gz: fdbf5d4104cdb99b7bd7889cb83173270db123cd171bde3702c0e8687633728b
5
5
  SHA512:
6
- metadata.gz: b96b4c818d693060ef49262b6e8c2eb4177a5be9ae10aae6f6718b3458103dbf1156ae69d0d569de19053e576a3e9462e2d39f55ad246b11a1110e563b39c038
7
- data.tar.gz: b36d80f8c86efe02e3ce38951fdb45e7a17db8c137f056e9baa79733d516506bcb39f601ac30d11251353729a386ea4b61c4174bf05d9ea313de4886f4520a66
6
+ metadata.gz: 664b9a9f3f6123378eaa6560ee3e56753ce4deeea6dd893c45fce5585682d81c8cedf762477dce90af2154da1d6b2b4e2d5a1da91ad6f25e6b3936fb2f5e01f9
7
+ data.tar.gz: 85b93f37c3b1f1da7bbae9e371a872218b5bddc957c8598a13c9bd5bf23767cafbb9dc6434bb6c3cb22797a4eb135a712326e77d4642d64c7bb255151e6f503b
data/README.md CHANGED
@@ -30,7 +30,8 @@ Once installed, you can use TypoChecker in your Ruby project to scan a directory
30
30
  ```bash
31
31
  # typo_checker scan /path/repo
32
32
  typo_checker scan . # current repo
33
- typo_checker scan . excludes node_modules .git
33
+ typo_checker scan . --excludes node_modules .git # or typo_checker scan . -e node_modules .git
34
+ typo_checker scan . --excludes node_modules .git --skips rspec defs # or typo_checker scan . -e node_modules .git -s rspec defs
34
35
  ```
35
36
 
36
37
  ### Output
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TypoChecker
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/typo_checker.rb CHANGED
@@ -6,12 +6,14 @@ require 'fileutils'
6
6
 
7
7
  module TypoChecker
8
8
  class Checker
9
- attr_reader :typos, :excludes, :skips
9
+ attr_reader :typos, :excludes, :skips, :found_typos, :stdoutput
10
10
 
11
- def initialize(excludes = [], skips = [])
11
+ def initialize(excludes = [], skips = [], stdoutput = true)
12
12
  @excludes = excludes
13
- @skips = skips
13
+ @skips = skips.map(&:downcase)
14
14
  @typos = load_typos
15
+ @found_typos = []
16
+ @stdoutput = stdoutput
15
17
  end
16
18
 
17
19
  def scan_repo(repo_path = Dir.pwd)
@@ -20,6 +22,8 @@ module TypoChecker
20
22
 
21
23
  scan_file(path) if File.file?(path) && text_file?(path)
22
24
  end
25
+
26
+ @found_typos
23
27
  end
24
28
 
25
29
  private
@@ -76,8 +80,18 @@ module TypoChecker
76
80
 
77
81
  corrected_word = corrected_word(word, typos[word.downcase])
78
82
  typo_path = "#{file}:#{line_num + 1}:#{char_index + 1}"
79
- puts "Typo found in #{colorize_light_blue(typo_path)}: " \
80
- "#{colorize_red(word)} -> #{colorize_green(corrected_word)}"
83
+ typo_details = {
84
+ path: file,
85
+ line: line_num + 1,
86
+ typos: {
87
+ incorrect_word: word,
88
+ correct_word: corrected_word
89
+ }
90
+ }
91
+
92
+ @found_typos << typo_details
93
+
94
+ stdout(typo_path, word, corrected_word) if stdoutput
81
95
  end
82
96
 
83
97
  def split_function_name(name)
@@ -94,6 +108,11 @@ module TypoChecker
94
108
  end
95
109
  end
96
110
 
111
+ def stdout(typo_path, word, corrected_word)
112
+ puts "Typo found in #{colorize_light_blue(typo_path)}: " \
113
+ "#{colorize_red(word)} -> #{colorize_green(corrected_word)}"
114
+ end
115
+
97
116
  def colorize_red(text)
98
117
  "\e[31m#{text}\e[0m"
99
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typo_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - datpmt