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.
- data/.gitignore +6 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +28 -0
- data/README.markdown +145 -0
- data/Rakefile +41 -33
- data/lib/string_utility_belt/entities.rb +23 -0
- data/lib/string_utility_belt/general.rb +72 -0
- data/lib/{match_rank → string_utility_belt}/match_rank.rb +30 -24
- data/lib/string_utility_belt/regex_me_helper.rb +100 -0
- data/lib/string_utility_belt/regex_me_to_search.rb +107 -0
- data/lib/string_utility_belt/tags.rb +22 -0
- data/lib/string_utility_belt/version.rb +1 -6
- data/lib/string_utility_belt.rb +6 -17
- data/test/string_utility_belt/entities_test.rb +17 -0
- data/test/string_utility_belt/general_test.rb +73 -0
- data/test/string_utility_belt/match_rank_test.rb +64 -0
- data/test/string_utility_belt/regex_me_helper_test.rb +117 -0
- data/test/string_utility_belt/regex_me_to_search_test.rb +106 -0
- data/test/string_utility_belt/tags_test.rb +25 -0
- data/test/test_helper.rb +5 -0
- metadata +30 -22
- data/lib/general/general.rb +0 -36
- data/lib/html_and_aml/helpers/entities.rb +0 -16
- data/lib/html_and_aml/helpers/tags.rb +0 -13
- data/lib/html_and_aml/html_and_aml.rb +0 -10
- data/lib/regex_me/helpers/string/regex_me.rb +0 -73
- data/lib/regex_me/regex_me.rb +0 -84
- data/string_utility_belt.gemspec +0 -10
data/lib/regex_me/regex_me.rb
DELETED
@@ -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
|
data/string_utility_belt.gemspec
DELETED
@@ -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
|