buzzcore 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 0.6.2
1
+ 0.6.3
2
2
 
data/buzzcore.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{buzzcore}
8
- s.version = "0.6.2"
8
+ s.version = "0.6.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["buzzware"]
@@ -103,13 +103,17 @@ String.class_eval do
103
103
  aDefault
104
104
  end
105
105
 
106
- URLIZE_PATTERN_PS = /[ \\\(\)\[\]]/
106
+ # "...Only alphanumerics [0-9a-zA-Z], the special characters "$-_.+!*'()," [not including the quotes - ed], and reserved characters used for their reserved purposes may be used unencoded within a URL."
107
+
108
+ URLIZE_SEPARATORS = /[ \\\(\)\[\]\.*,]/ # was /[ \\\(\)\[\]\.*,]/
107
109
  URLIZE_EXTENSIONS = %w(html htm jpg jpeg png gif bmp mov avi mp3 zip pdf css js doc xdoc)
108
-
110
+ URLIZE_REMOVE = /[^a-z0-9\_\-+~\/]/ # was 'a-z0-9_-+~/'
109
111
  # aKeepExtensions may be an array of extensions to keep, or :none (will remove periods) or :all (any extension <= 4 chars)
110
- def urlize(aSlashChar='+',aKeepExtensions=URLIZE_EXTENSIONS)
112
+ def urlize(aSlashChar='+',aRemove=nil,aKeepExtensions=nil)
113
+ aKeepExtensions=URLIZE_EXTENSIONS if !aKeepExtensions
114
+ aRemove=URLIZE_REMOVE if !aRemove
111
115
  return self if self.empty?
112
- result = self.gsub(URLIZE_PATTERN_PS,'-').downcase
116
+ result = self.downcase
113
117
  ext = nil
114
118
  if (aKeepExtensions!=:none) && last_dot = result.rindex('.')
115
119
  if (ext_len = result.length-last_dot-1) <= 4 # preserve extension without dot if <= 4 chars long
@@ -118,7 +122,9 @@ String.class_eval do
118
122
  result = result[0,last_dot] if ext
119
123
  end
120
124
  end
121
- result = result.gsub(/[^a-z0-9\_\-+~\/]/,'').sub(/-+$/,'').sub(/^-+/,'')
125
+
126
+ result = result.gsub(URLIZE_SEPARATORS,'-')
127
+ result = result.gsub(aRemove,'').sub(/-+$/,'').sub(/^-+/,'')
122
128
  result.gsub!('/',aSlashChar) unless aSlashChar=='/'
123
129
  result.gsub!(/-{2,}/,'-')
124
130
  result += '.'+ext if ext
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buzzcore
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - buzzware