buzzcore 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/buzzcore.gemspec +2 -2
- data/lib/buzzcore/extend_base_classes.rb +21 -2
- data/lib/buzzcore/html_utils.rb +11 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
data/buzzcore.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{buzzcore}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["buzzware"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-15}
|
13
13
|
s.description = %q{buzzcore is the ruby core library developed and used by Buzzware Solutions.}
|
14
14
|
s.email = %q{contact@buzzware.com.au}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -88,10 +88,25 @@ String.class_eval do
|
|
88
88
|
result
|
89
89
|
end
|
90
90
|
|
91
|
-
def to_nil
|
92
|
-
|
91
|
+
def to_nil(aPattern=nil)
|
92
|
+
return nil if self.empty?
|
93
|
+
if aPattern
|
94
|
+
return nil if (aPattern.is_a? Regexp) && (self =~ aPattern)
|
95
|
+
return nil if aPattern.to_s == self
|
96
|
+
end
|
97
|
+
self
|
93
98
|
end
|
94
99
|
|
100
|
+
# uses
|
101
|
+
#URLIZE_PATTERN = /[ \/\\\(\)\[\]]/
|
102
|
+
URLIZE_PATTERN_PS = /[ \\\(\)\[\]]/
|
103
|
+
def urlize(aSlashChar='+')
|
104
|
+
return self if self.empty?
|
105
|
+
result = self.gsub(URLIZE_PATTERN_PS,'-').downcase.gsub(/[^a-z0-9_\-+,\.\/]/,'')
|
106
|
+
result.gsub!('/',aSlashChar) unless aSlashChar=='/'
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
95
110
|
end
|
96
111
|
|
97
112
|
|
@@ -153,6 +168,10 @@ Time.class_eval do
|
|
153
168
|
self.strftime('%Y%m%d')
|
154
169
|
end
|
155
170
|
|
171
|
+
def to_universal
|
172
|
+
self.strftime("%d %b %Y")
|
173
|
+
end
|
174
|
+
|
156
175
|
# create a new Time from eg. "20081231"
|
157
176
|
def self.from_date_numeric(aString)
|
158
177
|
return nil unless aString
|
data/lib/buzzcore/html_utils.rb
CHANGED
@@ -25,5 +25,16 @@ module HtmlUtils
|
|
25
25
|
result
|
26
26
|
end
|
27
27
|
|
28
|
+
def self.gen_seo_title(*aValues)
|
29
|
+
aValues = [aValues] unless aValues.is_a? Array
|
30
|
+
aValues = aValues.map {|f| f.to_s.strip }
|
31
|
+
aValues.delete_if {|v| v.empty? }
|
32
|
+
aValues.join(' ').gsub(/ {2,}/,' ')
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.url_name_from(*aValues)
|
36
|
+
gen_seo_title(*aValues).urlize
|
37
|
+
end
|
38
|
+
|
28
39
|
end
|
29
40
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buzzcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- buzzware
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-15 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|