string_utility_belt 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,84 +0,0 @@
1
-
2
- require File.join(File.dirname(__FILE__), "helpers", "string", "regex_me")
3
-
4
- module RegexMe
5
-
6
- module To
7
-
8
- module Search
9
-
10
- private
11
- def options_handler options
12
- {
13
- :exact_word => options[:exact_word],
14
- :case_insensitive => (options[:case_insensitive] ? :i : nil ),
15
- :latin_chars_variation => options[:latin_chars_variation],
16
- :m => (options[:m] ? :m : nil ),
17
- :exact_phrase => options[:exact_phrase]
18
- }
19
- end
20
-
21
- private
22
- def regex_me_to_search regex_empty, border_to, options
23
- opt_handled = options_handler(options)
24
-
25
- return regex_empty if self.strip.empty?
26
- execute_builder(self, opt_handled, border_to)
27
- end
28
-
29
-
30
- public
31
- def regex_me_to_search_ruby options={}
32
- regex_me_to_search(//, :ruby, options)
33
- end
34
-
35
- def regex_me_to_search_mysql options={}
36
- regex_me_to_search("", :mysql, options)
37
- end
38
-
39
- private
40
- def execute_builder string, opt_handled, border_to
41
- result_builder = builder(string, opt_handled[:exact_word], border_to, opt_handled[:latin_chars_variation], opt_handled[:exact_phrase])
42
-
43
- case border_to
44
- when :ruby
45
- eval "/#{result_builder}/#{opt_handled[:case_insensitive]}#{opt_handled[:m]}"
46
- when :mysql
47
- result_builder.gsub(/\\b/,"[[:<:]]").gsub(/\\b$/, "[[:>:]])")
48
- end
49
-
50
- end
51
-
52
- def builder string, exact_word, border_to, latin_chars_variation, exact_phrase
53
-
54
- if exact_phrase
55
- regexp = string.gsub(/\s+/, " ").regex_latin_ci_list.gsub(/\s/, '[^0-9a-zA-Z\_]+').regex_builder(:delete_or => true,
56
- :border => {:to => border_to,
57
- :direction => :both})
58
- else
59
- regexp = '('
60
-
61
- for word in string.strip.split
62
- case word
63
- when/^\*/
64
- regexp << word.regex_builder(:any => true, :border => {:to => border_to, :direction => :right}, :latin_chars_variation => latin_chars_variation)
65
- when /\*$/
66
- regexp << word.regex_builder(:any => true, :border => {:to => border_to, :direction => :left}, :latin_chars_variation => latin_chars_variation)
67
- when /^.*\*.*$/
68
- regexp << word.regex_builder(:any => true, :border => {:to => border_to, :direction => :both}, :latin_chars_variation => latin_chars_variation)
69
- else
70
- regexp << (exact_word ? word.regex_builder(:border => {:to => border_to, :direction => :both}, :latin_chars_variation => latin_chars_variation) : word.regex_builder(:latin_chars_variation => latin_chars_variation))
71
- end
72
- end
73
-
74
- regexp = (regexp << ')').sub!(/\|\)/,')')
75
- end
76
-
77
- return regexp
78
- end
79
-
80
- end
81
-
82
- end
83
-
84
- end
@@ -1,10 +0,0 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "string_utility_belt"
5
- s.version = "0.2.5"
6
- s.description = "Useful methods for strings!"
7
- s.summary = "Useful methods for strings!"
8
- s.author = "Rodrigo Serradura"
9
- s.files = Dir["{lib/**/*.rb,lib/**/**/*.rb,lib/**/**/**/*.rb,README.rdoc,Rakefile,*.gemspec}"]
10
- end