heckler 0.0.1 → 0.0.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 +4 -4
- data/CHANGELOG.md +3 -3
- data/bin/heckler +28 -0
- data/lib/heckler/aspell.rb +9 -9
- data/lib/heckler/checker/file_system.rb +8 -11
- data/lib/heckler/version.rb +1 -1
- data/lib/heckler.rb +5 -2
- metadata +4 -6
- data/exe/heckler +0 -6
- data/lib/heckler/cli.rb +0 -50
- data/lib/heckler/personn.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9733f79bc2c0954718b84cef40e963eea19e61093d1afc6f3bb9fae077d7a342
|
4
|
+
data.tar.gz: 4c383a199322fca8fcc1efb8a1420bb3b6900b998557c839b534d1b7c609009e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edf2983e808bdbc69173410794727734284fb1bead0a607a06dcd809ca848270fea42d4f211f6f50a668fdca67603f2afcc6328514c9faac4fa1946bc188a806
|
7
|
+
data.tar.gz: 8fe464cd042f1ec1b2809515ba3b81ff9ea0afe638017db7d092da1fcf962a96ae8810edc3ddb4cda516233308cfdef10339a1fc13bb4a84072df1ecf17f7003
|
data/CHANGELOG.md
CHANGED
data/bin/heckler
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/heckler'
|
4
|
+
|
5
|
+
$stdout.sync = true
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
command = ARGV.shift
|
9
|
+
|
10
|
+
case command
|
11
|
+
when 'init'
|
12
|
+
Config.init
|
13
|
+
when nil
|
14
|
+
config = Heckler::Config.instance
|
15
|
+
aspell = Heckler::Aspell.new(config)
|
16
|
+
directory = Dir.pwd
|
17
|
+
@checkers = [Heckler::Checker::FileSystem.new(config, aspell)]
|
18
|
+
issues = []
|
19
|
+
|
20
|
+
@checkers.each do |checker|
|
21
|
+
issues.concat(checker.check(directory))
|
22
|
+
end
|
23
|
+
|
24
|
+
puts issues.inspect
|
25
|
+
else
|
26
|
+
puts "Unknown command: #{command}"
|
27
|
+
puts 'Available commands: init, or no command for default behavior'
|
28
|
+
end
|
data/lib/heckler/aspell.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require_relative
|
1
|
+
require 'open3'
|
2
|
+
require_relative 'config'
|
3
3
|
|
4
4
|
Misspelling = Data.define(:word, :suggestions)
|
5
5
|
|
@@ -19,8 +19,7 @@ module Heckler
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def get_misspellings(text)
|
22
|
-
|
23
|
-
misspellings
|
22
|
+
run(text)
|
24
23
|
end
|
25
24
|
|
26
25
|
def take_suggestions(suggestions)
|
@@ -29,17 +28,18 @@ module Heckler
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def run(text)
|
32
|
-
stdin, stdout, stderr,
|
31
|
+
stdin, stdout, stderr, _wait_thr = Open3.popen3('aspell', '--encoding', 'utf-8', '-a', '--ignore-case',
|
32
|
+
'--lang=en_US', '--sug-mode=ultra')
|
33
33
|
stdin.puts text
|
34
34
|
stdin.close
|
35
35
|
output = stdout.read
|
36
36
|
stdout.close
|
37
37
|
stderr.close
|
38
38
|
|
39
|
-
output.lines.select { |line| line.start_with?(
|
40
|
-
word_metadata, suggestions = line.strip.split(
|
41
|
-
word = word_metadata.split(
|
42
|
-
suggestions = suggestions.strip.split(
|
39
|
+
output.lines.select { |line| line.start_with?('&') }.map do |line|
|
40
|
+
word_metadata, suggestions = line.strip.split(':')
|
41
|
+
word = word_metadata.split(' ')[1]
|
42
|
+
suggestions = suggestions.strip.split(', ')
|
43
43
|
Misspelling.new(word, take_suggestions(suggestions))
|
44
44
|
end
|
45
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../aspell'
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'find'
|
4
4
|
|
5
5
|
# The Checker::FileSystem class provides functionality to check spelling in file and directory names within a given directory structure.
|
6
6
|
#
|
@@ -30,21 +30,18 @@ module Heckler
|
|
30
30
|
def check(directory)
|
31
31
|
files_or_directories = []
|
32
32
|
Find.find(directory) do |path|
|
33
|
-
next if File.basename(path).start_with?(
|
34
|
-
next if File.fnmatch(
|
33
|
+
next if File.basename(path).start_with?('.')
|
34
|
+
next if File.fnmatch('*/.*/*', path)
|
35
35
|
|
36
36
|
files_or_directories << path
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
39
|
files_or_directories.sort_by! { |path| File.realpath(path) }
|
41
40
|
|
42
|
-
puts files_or_directories
|
43
|
-
|
44
41
|
issues = []
|
45
42
|
|
46
43
|
files_or_directories.each do |file_or_directory|
|
47
|
-
name = SpellcheckFormatter.format(File.basename(file_or_directory,
|
44
|
+
name = SpellcheckFormatter.format(File.basename(file_or_directory, '.*'))
|
48
45
|
new_issues = @spellchecker.check(name).map do |misspelling|
|
49
46
|
Issue.new(misspelling, File.realpath(file_or_directory), 0)
|
50
47
|
end
|
@@ -60,10 +57,10 @@ module Heckler
|
|
60
57
|
class SpellcheckFormatter
|
61
58
|
def self.format(input)
|
62
59
|
# Remove leading underscores
|
63
|
-
input = input.gsub(/^_+/,
|
60
|
+
input = input.gsub(/^_+/, '')
|
64
61
|
|
65
62
|
# Replace underscores and dashes with spaces
|
66
|
-
input = input.tr(
|
63
|
+
input = input.tr('_-', ' ')
|
67
64
|
|
68
65
|
# Insert spaces between lowercase and uppercase letters (camelCase or PascalCase)
|
69
66
|
input = input.gsub(/([a-z])([A-Z])/, '\1 \2')
|
@@ -72,7 +69,7 @@ module Heckler
|
|
72
69
|
input = input.gsub(/([A-Z]+)([A-Z][a-z])/, '\1 \2')
|
73
70
|
|
74
71
|
# Replace multiple spaces with a single space
|
75
|
-
input = input.gsub(/\s+/,
|
72
|
+
input = input.gsub(/\s+/, ' ')
|
76
73
|
|
77
74
|
# Convert the final result to lowercase
|
78
75
|
input.downcase
|
data/lib/heckler/version.rb
CHANGED
data/lib/heckler.rb
CHANGED
@@ -3,8 +3,11 @@
|
|
3
3
|
# @see https://github.com/peckphp/peck
|
4
4
|
##
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative 'heckler/config'
|
7
|
+
require_relative 'heckler/aspell'
|
8
|
+
require_relative 'heckler/preset'
|
9
|
+
require_relative 'heckler/checker/file_system'
|
10
|
+
require_relative 'heckler/version'
|
8
11
|
|
9
12
|
module Heckler
|
10
13
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heckler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislav (Stas) Katkov
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "**Heckler** is a tool to identify wording or spelling mistakes in ruby
|
14
14
|
codebase: filenames, class names, method names, property names and more. Spelling
|
@@ -25,14 +25,12 @@ files:
|
|
25
25
|
- LICENSE.txt
|
26
26
|
- README.md
|
27
27
|
- Rakefile
|
28
|
-
-
|
28
|
+
- bin/heckler
|
29
29
|
- heckler.json
|
30
30
|
- lib/heckler.rb
|
31
31
|
- lib/heckler/aspell.rb
|
32
32
|
- lib/heckler/checker/file_system.rb
|
33
|
-
- lib/heckler/cli.rb
|
34
33
|
- lib/heckler/config.rb
|
35
|
-
- lib/heckler/personn.rb
|
36
34
|
- lib/heckler/preset.rb
|
37
35
|
- lib/heckler/presets/base.stub
|
38
36
|
- lib/heckler/version.rb
|
data/exe/heckler
DELETED
data/lib/heckler/cli.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
|
-
require_relative "config"
|
4
|
-
require_relative "aspell"
|
5
|
-
require_relative "preset"
|
6
|
-
require_relative "checker/file_system"
|
7
|
-
|
8
|
-
|
9
|
-
module Heckler
|
10
|
-
class Runner
|
11
|
-
attr_reader :checkers
|
12
|
-
|
13
|
-
def initialize(checkers)
|
14
|
-
@checkers = checkers
|
15
|
-
end
|
16
|
-
|
17
|
-
def run(directory)
|
18
|
-
issues = []
|
19
|
-
|
20
|
-
puts directory
|
21
|
-
|
22
|
-
@checkers.each do |checker|
|
23
|
-
issues.concat(checker.check(directory))
|
24
|
-
end
|
25
|
-
|
26
|
-
issues
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class CLI
|
31
|
-
def self.start(args)
|
32
|
-
command = args.shift
|
33
|
-
|
34
|
-
case command
|
35
|
-
when 'init'
|
36
|
-
Config.init
|
37
|
-
when nil
|
38
|
-
config = Config.instance
|
39
|
-
aspell = Aspell.new(config)
|
40
|
-
|
41
|
-
Runner.new([
|
42
|
-
Heckler::Checker::FileSystem.new(config, aspell)
|
43
|
-
]).run(Dir.pwd)
|
44
|
-
else
|
45
|
-
puts "Unknown command: #{command}"
|
46
|
-
puts "Available commands: init, or no command for default behavior"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/heckler/personn.rb
DELETED
File without changes
|