siriproxypm-clientstatecache 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -147,6 +147,21 @@ class SiriProxy::PluginManager::ClientStateCache < SiriProxy::PluginManager
|
|
147
147
|
return false
|
148
148
|
end
|
149
149
|
|
150
|
+
def ensure_regexp(regexp)
|
151
|
+
if regexp != nil
|
152
|
+
regexp.is_a?(String)
|
153
|
+
if regexp[0] == '/'
|
154
|
+
#try to make it into a regexp
|
155
|
+
regexp = eval regexp
|
156
|
+
elsif
|
157
|
+
regexp = Regexp.new("^\s*#{regexp}",true);
|
158
|
+
end
|
159
|
+
end
|
160
|
+
if regexp == nil || !regexp.is_a?(Regexp)
|
161
|
+
regexp = nil
|
162
|
+
end
|
163
|
+
return regexp
|
164
|
+
end
|
150
165
|
|
151
166
|
def text_matches(text,list, default_list = [],post =false)
|
152
167
|
text = text.strip
|
@@ -166,20 +181,10 @@ class SiriProxy::PluginManager::ClientStateCache < SiriProxy::PluginManager
|
|
166
181
|
list = default_list
|
167
182
|
end
|
168
183
|
list.each do |regexp|
|
184
|
+
regexp = ensure_regexp(regexp)
|
169
185
|
if regexp == nil
|
170
186
|
next
|
171
187
|
end
|
172
|
-
if regexp.is_a?(String)
|
173
|
-
if regexp[0] == '/'
|
174
|
-
#try to make it into a regexp
|
175
|
-
regexp = eval regexp
|
176
|
-
elsif
|
177
|
-
regexp = Regexp.new("^\s*#{regexp}",true);
|
178
|
-
end
|
179
|
-
end
|
180
|
-
if regexp == nil || !regexp.is_a?(Regexp)
|
181
|
-
next
|
182
|
-
end
|
183
188
|
if post
|
184
189
|
if (match_data = regexp.match(text)) != nil
|
185
190
|
result = match_data.post_match
|