middleman-spellcheck 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f583af567927055546ed6b90a526a32f7dd5da52
|
4
|
+
data.tar.gz: de8929bfe29e132208fdea35a3eaec7dbb141fa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52273fd663fed6722d2f711bfc712cc926ac46bfe25495438e65841fbb6668811e3b865c68355f4e3d3876fa91e458baf50f7867d0413099dac6c4dcf21fb5a1
|
7
|
+
data.tar.gz: 67ed22641c257e5904f58d9a06aa6d63312d0f2a7833af7b583a7d789c49708438295aaaaeb5ab6929e7954e16c30233f0664a5e83ec24c04abf651e9d5e9e98
|
data/Gemfile
CHANGED
@@ -10,7 +10,7 @@ class Spellchecker
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.query(text, lang='en')
|
13
|
-
result = `echo "#{text}" | #{@@aspell_path} -a -l #{lang}`
|
13
|
+
result = `echo "#{format_text(text)}" | #{@@aspell_path} -a -l #{lang}`
|
14
14
|
raise 'Aspell command not found' unless result
|
15
15
|
result.split("\n")[1..-1] || []
|
16
16
|
end
|
@@ -19,6 +19,10 @@ class Spellchecker
|
|
19
19
|
result_string == "*"
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.format_text(text)
|
23
|
+
text.gsub("\n", "")
|
24
|
+
end
|
25
|
+
|
22
26
|
def self.check(text, lang='en')
|
23
27
|
words = text.split(/\W+/)
|
24
28
|
results = query(text, lang).map do |query_result|
|
@@ -5,10 +5,25 @@ describe Spellchecker do
|
|
5
5
|
let(:text) { "hello, world! of txet" }
|
6
6
|
let(:result) { Spellchecker.check(text) }
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
context "with one wrong word" do
|
9
|
+
it "can spell check words" do
|
10
|
+
result.should == [{ word: "hello", correct: true },
|
11
|
+
{ word: "world", correct: true },
|
12
|
+
{ word: "of", correct: true },
|
13
|
+
{ word: "txet", correct: false }]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "ignoring special characters" do
|
18
|
+
let(:text) { "Hello, dear!\nMy name is Lucy."}
|
19
|
+
|
20
|
+
it "spells correctly with newline characters" do
|
21
|
+
result.should == [{ word: "Hello", correct: true },
|
22
|
+
{ word: "dear", correct: true},
|
23
|
+
{ word: "My", correct: true},
|
24
|
+
{ word: "name", correct: true},
|
25
|
+
{ word: "is", correct: true},
|
26
|
+
{ word: "Lucy", correct: true}]
|
27
|
+
end
|
13
28
|
end
|
14
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-spellcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zarea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|