uri-handler 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +17 -0
- data/VERSION +1 -1
- data/lib/uri-handler.rb +17 -8
- data/uri-handler.gemspec +2 -2
- metadata +11 -11
data/README.rdoc
CHANGED
@@ -13,24 +13,41 @@ Add to Gemfile for rails and other bundle-enabled projects
|
|
13
13
|
|
14
14
|
gem 'uri-handler'
|
15
15
|
|
16
|
+
=== code sample
|
17
|
+
|
16
18
|
require 'uri-handler'
|
17
19
|
|
18
20
|
puts "testing+123 invalid uri character/s".to_uri # => "testing%2B123+invalid+uri+character%2Fs"
|
19
21
|
|
22
|
+
|
23
|
+
|
20
24
|
val = "testing+123 invalid uri character/s"
|
25
|
+
|
21
26
|
val.to_uri!
|
27
|
+
|
22
28
|
puts val => "testing%2B123+invalid+uri+character%2Fs"
|
23
29
|
|
30
|
+
|
31
|
+
|
24
32
|
puts val.uri_decode # => "testing+123 invalid uri character/s"
|
25
33
|
|
34
|
+
|
35
|
+
|
26
36
|
val.uri_decode!
|
37
|
+
|
27
38
|
puts val # => "testing+123 invalid uri character/s"
|
28
39
|
|
40
|
+
|
41
|
+
|
29
42
|
puts val.uri_encode # => "testing%2B123+invalid+uri+character%2Fs"
|
30
43
|
|
44
|
+
|
45
|
+
|
31
46
|
val.uri_encode!
|
47
|
+
|
32
48
|
puts val # => "testing%2B123+invalid+uri+character%2Fs"
|
33
49
|
|
50
|
+
|
34
51
|
== Copyright
|
35
52
|
|
36
53
|
Copyright (c) 2012 foomip. See LICENSE.txt for
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/uri-handler.rb
CHANGED
@@ -2,14 +2,23 @@
|
|
2
2
|
# make URI encoding tasks easier for people other than just myself :)
|
3
3
|
|
4
4
|
require 'cgi' # better encoding support than uri - in my opinion anyways
|
5
|
-
# if you don't agree,
|
5
|
+
# if you don't agree, fork this project :)
|
6
6
|
|
7
7
|
class String
|
8
|
-
def uri_encode
|
9
|
-
|
8
|
+
def uri_encode encoding=nil
|
9
|
+
begin
|
10
|
+
CGI::escape self
|
11
|
+
rescue ArgumentError=>e
|
12
|
+
if e.to_s == 'invalid byte sequence in UTF-8'
|
13
|
+
encoding = 'binary' if encoding.nil?
|
14
|
+
CGI::escape self.force_encoding(encoding)
|
15
|
+
else
|
16
|
+
raise e
|
17
|
+
end
|
18
|
+
end
|
10
19
|
end
|
11
20
|
|
12
|
-
def uri_encode!
|
21
|
+
def uri_encode! encoding=nil
|
13
22
|
self.replace uri_encode
|
14
23
|
end
|
15
24
|
|
@@ -21,11 +30,11 @@ class String
|
|
21
30
|
self.replace uri_decode
|
22
31
|
end
|
23
32
|
|
24
|
-
def to_uri
|
25
|
-
uri_encode
|
33
|
+
def to_uri encoding=nil
|
34
|
+
uri_encode encoding
|
26
35
|
end
|
27
36
|
|
28
|
-
def to_uri!
|
29
|
-
self.replace to_uri
|
37
|
+
def to_uri! encoding=nil
|
38
|
+
self.replace to_uri encoding
|
30
39
|
end
|
31
40
|
end
|
data/uri-handler.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "uri-handler"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["foomip"]
|
12
|
-
s.date = "2012-01-
|
12
|
+
s.date = "2012-01-25"
|
13
13
|
s.description = "Nothing fancy going on here, this module is just a wrapper around the function CGI::escape\nand CGI::unescape. Functionality is added to the String class, so just add the module and\nthe extra funcitons will be there for you to use (check out the README file for basic usage).\nI just wanted an easier and cleaner way to encode/decode uri strings for my ruby projects."
|
14
14
|
s.email = "nelsondcp@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri-handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-25 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
16
|
-
requirement: &
|
16
|
+
requirement: &70221888459800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70221888459800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70221888459320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70221888459320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70221888458740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70221888458740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70221888458240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70221888458240
|
58
58
|
description: ! 'Nothing fancy going on here, this module is just a wrapper around
|
59
59
|
the function CGI::escape
|
60
60
|
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: 2902958882872454230
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|