string-utils 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1,2 @@
1
+ 0.2.0 - Works with ruby 1.9.2, fixed encoding issue
1
2
  0.1.0 - First commit
@@ -1,5 +1,4 @@
1
- string-utils
2
- ==========
1
+ =string-utils gem
3
2
 
4
3
  This small extension enables string sanitization in models and controller.
5
4
 
@@ -9,10 +8,11 @@ Provides also a function for making url friendly strings removing all unwanted c
9
8
 
10
9
  Basically it adds some methods and shortcuts to the String class, see the example section for usage.
11
10
 
12
- Works with Rails ~> 2.3.6 and ~> 3.0.0 beta
11
+ Works with Rails ~> 2.3.6 and ~> 3.0.0
12
+ Tested on Ruby 1.8.7 and 1.9.2
13
13
 
14
- Install
15
- =======
14
+
15
+ ==Install
16
16
 
17
17
  Specify it in your Rails project config/environment.rb under the "Rails::Initializer.run do |config|" block
18
18
 
@@ -28,39 +28,46 @@ Or install manually with:
28
28
  sudo gem install string-utils --source http://gemcutter.org
29
29
 
30
30
 
31
- Examples
32
- =======
31
+ ==Examples
33
32
 
34
- >> my_unsafe_text.sanitize
35
33
  Applies the sanitize helper to text.
36
34
  Works not only in views but also in models, controllers and libs!
37
35
 
38
- >> my_unsafe_text.san
36
+ my_unsafe_text.sanitize
37
+
39
38
  Shortcut for my_unsafe_text.sanitize
40
39
 
41
- >> "Fire in the hole: <script>alert('bam!');</script>".san
42
- => "Fire in the hole: "
40
+ my_unsafe_text.san
41
+
42
+
43
+ "Fire in the hole: <script>alert('bam!');</script>".san
44
+ "Fire in the hole: "
45
+
46
+ "Some tags: <asdasd>an asdasd tag</adsasd>".san
47
+ "Some tags: an asdasd tag"
43
48
 
44
- >> "Some tags: <asdasd>an asdasd tag</adsasd>".san
45
- => "Some tags: an asdasd tag"
46
49
 
47
- >> my_SAFE_text.hs
48
50
  Shortcut for my_SAFE_text.html_safe
49
51
  USE WITH CAUTION
50
52
  Forces the string to be html safe so it won't be escaped.
51
53
  Useful for quick-and-dirty monkey scripting in views.
54
+
55
+ my_SAFE_text.hs
56
+
57
+
58
+ message = "I really need this <script>alert('popup')</script>".hs
59
+ "I really need this <script>alert('popup')</script>"
60
+ message.html_safe?
61
+ true
52
62
 
53
- >> message = "I really need this <script>alert('popup')</script>".hs
54
- => "I really need this <script>alert('popup')</script>"
55
- >> message.html_safe?
56
- => true
57
63
 
64
+ urlify is a function for making url friendly strings removing all unwanted characters.
58
65
 
59
- "My really great post".urlify
60
- => "my-really-great-post"
66
+ "My really great post".urlify
67
+ "my-really-great-post"
61
68
 
62
- "O come l'è GANZA 'sta gemma!".urlify
63
- => "o-come-l-e-ganza-sta-gemma"
69
+ "O come l'è GANZA 'sta gemma!".urlify
70
+ "o-come-l-e-ganza-sta-gemma"
64
71
 
65
72
 
66
73
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('string-utils', '0.1.0') do |p|
5
+ Echoe.new('string-utils', '0.2.0') do |p|
6
6
  p.description = "This small extension enables string sanitization in models and controller. Provides also a function for making url friendly strings removing all unwanted characters."
7
7
  p.url = "http://github.com/silviorelli/string-utils"
8
8
  p.author = "Silvio Relli"
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  # Silvio Relli's string_utils gem - released under the MIT License
2
3
  class String
3
4
 
@@ -23,7 +24,7 @@ class String
23
24
  def urlify
24
25
  str = self.downcase.gsub(/ /,'-')
25
26
  str.gsub!(/À|à|á|Â|â|Ã|ã|Ä|ä/i,'a')
26
- str.gsub!(/È|è|É|é|Ê|ê|Ë|ë/i,'e')
27
+ str.gsub!(/È|è|É|é|Ê|ê|Ë|ë|&/i,'e')
27
28
  str.gsub!(/Ì|ì|í|Î|î/i,'i')
28
29
  str.gsub!(/Ò|ò|ó|Ô|ô|Õ|õ|Ö|ö/i,'o')
29
30
  str.gsub!(/Ù|ù|ú|Û|û|Ü|ü/i,'u')
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{string-utils}
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Silvio Relli"]
9
- s.date = %q{2010-06-08}
9
+ s.date = %q{2011-01-23}
10
10
  s.description = %q{This small extension enables string sanitization in models and controller. Provides also a function for making url friendly strings removing all unwanted characters.}
11
11
  s.email = %q{silvio@relli.org}
12
12
  s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc", "lib/string-utils.rb"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string-utils
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Silvio Relli
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-08 00:00:00 +02:00
18
+ date: 2011-01-23 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21