littlestitious 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/littlestitious.rb +19 -1
- 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: a419ab2a100ca955c223403c37f2312711d457e0
|
4
|
+
data.tar.gz: a1957d07e5c8de375e1e1fb2a8c6088adf1f5613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d5dad3852cd941882e59ec82b307e23a7f206d4d2744bae181677a309ef5d73f09087dd91ebb45a090683ff17c7758fc9c26b456516e42a8c9d054b380f626d
|
7
|
+
data.tar.gz: '0028164d184e4fae62bb0e70f1754532ace803473d0f4733876223fd8f879597e5a3f27e2fad14bc2e76c64445113a66ec22d20517de2d96204ea2e16ec40326'
|
data/lib/littlestitious.rb
CHANGED
@@ -138,7 +138,7 @@ module Littlestitious
|
|
138
138
|
@all_chars.map { |k, v| @char_lookup[v] = k }
|
139
139
|
|
140
140
|
size_ok = @char_lookup.size == @all_chars.size
|
141
|
-
message = "Mismatched charater mapping"
|
141
|
+
message = "Mismatched charater mapping".freeze
|
142
142
|
raise AssertionError, message unless size_ok
|
143
143
|
|
144
144
|
class_instance_vars = \
|
@@ -151,6 +151,8 @@ module Littlestitious
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def includes_zero_width_characters?
|
154
|
+
return false if self.boring?
|
155
|
+
|
154
156
|
self.class.zero_width_chars.each do | char_type, char |
|
155
157
|
return true if self.include? char
|
156
158
|
end
|
@@ -159,6 +161,8 @@ module Littlestitious
|
|
159
161
|
end
|
160
162
|
|
161
163
|
def includes_weird_spaces?
|
164
|
+
return false if self.boring?
|
165
|
+
|
162
166
|
self.class.weird_space_chars.each do | char_type, char |
|
163
167
|
return true if self.include? char
|
164
168
|
end
|
@@ -167,6 +171,8 @@ module Littlestitious
|
|
167
171
|
end
|
168
172
|
|
169
173
|
def includes_non_printing_characters?
|
174
|
+
return false if self.boring?
|
175
|
+
|
170
176
|
self.class.non_printing_chars.each do | char_type, char |
|
171
177
|
return true if self.include? char
|
172
178
|
end
|
@@ -174,10 +180,22 @@ module Littlestitious
|
|
174
180
|
false
|
175
181
|
end
|
176
182
|
|
183
|
+
def boring?
|
184
|
+
# Matches ascii character 10 and 32 to 126
|
185
|
+
# (newline + space + all visible)
|
186
|
+
regex_string = '[^\n -~]'.freeze
|
187
|
+
|
188
|
+
@boring_regex ||= Regexp.new regex_string
|
189
|
+
|
190
|
+
@boring_regex.match(self).nil?
|
191
|
+
end
|
192
|
+
|
177
193
|
def strange_character_count
|
178
194
|
|
179
195
|
char_count = Hash.new(0)
|
180
196
|
|
197
|
+
return char_count if self.boring?
|
198
|
+
|
181
199
|
self.each_char do |char|
|
182
200
|
char_type = self.class.char_lookup[char]
|
183
201
|
next unless char_type
|