spellcop 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/spellcop +17 -4
- data/lib/spellcop/file_checker.rb +1 -1
- data/lib/spellcop/folder_checker.rb +2 -1
- data/lib/spellcop/ignore.rb +1 -1
- data/lib/spellcop/version.rb +1 -1
- data/spellcop.gemspec +1 -1
- metadata +7 -11
- data/bin/console +0 -14
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e716ab22a99f007fd4c589a00400c403fc10dbe
|
4
|
+
data.tar.gz: 2b8334d3a1728bc3b8e3759d1e64e689f848051b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e8ead080edb6e2ae8e660e5226c5bd6b2dff213801d79d1c5d4454374a369bed2dc9cc02dd59abc6f475c818d708b2fd92d322473d532aab87ed3fcce53853
|
7
|
+
data.tar.gz: 8db0e6dadf76e33ff19c431a1bcc70f1a4c10976cca32d692e87df045d5f001779e0b67e2c99fc7a6f9a65d310d8845cc5097337ba279fa924b967ae5b5a59d7
|
data/bin/spellcop
CHANGED
@@ -1,13 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'colorize'
|
2
5
|
require './lib/spellcop'
|
3
6
|
|
4
7
|
class Spellcop::CLI
|
5
8
|
# desc 'spellcop filename|foldername', 'a file or a folder to search for typos'
|
6
|
-
def
|
9
|
+
def check!(name)
|
7
10
|
if File.file?(name)
|
8
|
-
|
11
|
+
@warnings = [{ file: name, warnings: Spellcop::FileChecker.new(name).check! }]
|
9
12
|
else
|
10
|
-
|
13
|
+
@warnings = Spellcop::FolderChecker.new(name).check!
|
14
|
+
end
|
15
|
+
show_results
|
16
|
+
end
|
17
|
+
|
18
|
+
def show_results
|
19
|
+
@warnings.each do |file|
|
20
|
+
puts "#{file[:file].colorize :red}:"
|
21
|
+
file[:warnings].each do |warning|
|
22
|
+
puts "\t#{warning[:word].colorize(:red).bold} (#{warning[:suggestions].first(3).join(', ')}...)"
|
23
|
+
end
|
11
24
|
end
|
12
25
|
end
|
13
26
|
end
|
@@ -15,5 +28,5 @@ end
|
|
15
28
|
if ARGV.empty?
|
16
29
|
puts 'usage...'
|
17
30
|
else
|
18
|
-
Spellcop::CLI.check(ARGV.join ' ')
|
31
|
+
Spellcop::CLI.new.check!(ARGV.join ' ')
|
19
32
|
end
|
@@ -16,7 +16,7 @@ module Spellcop
|
|
16
16
|
word = result.compact.first
|
17
17
|
# puts "wrong: #{word}" if word == 'tihs'
|
18
18
|
if !@dict.check? word and !word.spellcop_ignore?
|
19
|
-
@warnings << { word: word,
|
19
|
+
@warnings << { word: word, suggestions: @dict.suggest(word) }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -14,7 +14,8 @@ module Spellcop
|
|
14
14
|
|
15
15
|
def check!
|
16
16
|
Dir[@folder].each do |file|
|
17
|
-
|
17
|
+
result = { file: file, warnings: FileChecker.new(file).check! }
|
18
|
+
@warnings << result unless result[:warnings].empty?
|
18
19
|
@files << file
|
19
20
|
end
|
20
21
|
@warnings
|
data/lib/spellcop/ignore.rb
CHANGED
@@ -3,7 +3,7 @@ module Spellcop
|
|
3
3
|
|
4
4
|
class ::String
|
5
5
|
def spellcop_ignore?
|
6
|
-
IGNORE.include? downcase or chars.first == chars.first.upcase or include? '_' or include? '-'
|
6
|
+
IGNORE.include? downcase or chars.first == chars.first.upcase or include? '_' or include? '-' or chars.size < 4
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
data/lib/spellcop/version.rb
CHANGED
data/spellcop.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'ffi-hunspell', '~> 0.3'
|
22
|
-
spec.add_dependency '
|
22
|
+
spec.add_dependency 'colorize', '~> 0.7'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spellcop
|
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
|
- Hugo Abonizio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-hunspell
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: colorize
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: '0.7'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: '0.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,8 +84,6 @@ description: Search for typos on your code.
|
|
84
84
|
email:
|
85
85
|
- hugo_abonizio@hotmail.com
|
86
86
|
executables:
|
87
|
-
- console
|
88
|
-
- setup
|
89
87
|
- spellcop
|
90
88
|
extensions: []
|
91
89
|
extra_rdoc_files: []
|
@@ -97,8 +95,6 @@ files:
|
|
97
95
|
- LICENSE.txt
|
98
96
|
- README.md
|
99
97
|
- Rakefile
|
100
|
-
- bin/console
|
101
|
-
- bin/setup
|
102
98
|
- bin/spellcop
|
103
99
|
- lib/spellcop.rb
|
104
100
|
- lib/spellcop/file_checker.rb
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "spellcop"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|