bad_encoding 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/bad_encoding/version.rb +1 -1
- data/lib/bad_encoding.rb +7 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd740580170821d850ea0a9d16728cad0da52d2
|
4
|
+
data.tar.gz: 1b30cf011079aa4da47f89dd107e0b5f19b54c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a8a28169d9abced0b0515dae98120e26d4ea4f26560754bdf311e168758f84ac932eb6cd9ab23c532c59648046704862d611a4d2d9e9aac222c05ce92630fb2
|
7
|
+
data.tar.gz: da7c113b5c9443bacb7dea8ca86f0a4678f1ab2b3c9dd9f4b3d507ec40f574551ba17514d5f9496eac0df26f290dab8a4c574ba714dafecf8c40f4df20fd5142
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Bad Encoding
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
I was having trouble finding bad characters in large strings so I did this manually for like 20 mins. Forget that! Never again!
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -21,6 +19,7 @@ Or install it yourself as:
|
|
21
19
|
$ gem install bad_encoding
|
22
20
|
|
23
21
|
## Usage
|
22
|
+
require 'bad_encoding'
|
24
23
|
|
25
24
|
> good_string.show_bad_encoding
|
26
25
|
=> "no bad segments founds"
|
data/lib/bad_encoding/version.rb
CHANGED
data/lib/bad_encoding.rb
CHANGED
@@ -7,6 +7,7 @@ module BadEncoding
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def search(s, &block)
|
10
|
+
return 'no bad segments found' unless block.call(s)
|
10
11
|
process(s, block)
|
11
12
|
end
|
12
13
|
|
@@ -19,17 +20,12 @@ module BadEncoding
|
|
19
20
|
end_of_list = count - middle
|
20
21
|
|
21
22
|
first_half = s.slice(0, middle)
|
22
|
-
if check.call(first_half)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return process(second_half, check)
|
29
|
-
end
|
30
|
-
|
31
|
-
return 'no bad segments founds'
|
32
|
-
end
|
23
|
+
return if check.call(first_half)
|
24
|
+
process(first_half, check)
|
25
|
+
else
|
26
|
+
second_half = s.slice(middle, end_of_list)
|
27
|
+
process(second_half, check)
|
28
|
+
end
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|