uri-component 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/uri/component.rb +45 -0
- data/lib/uri/component/version.rb +1 -1
- metadata +2 -1
@@ -0,0 +1,45 @@
|
|
1
|
+
require "uri/component/userinfo"
|
2
|
+
require "uri/component/path"
|
3
|
+
require "uri/component/query"
|
4
|
+
|
5
|
+
module URI
|
6
|
+
## Handle URI components as an object
|
7
|
+
module Component
|
8
|
+
## Add the following instance methods to the class +klass+:
|
9
|
+
##
|
10
|
+
## userinfo_component::
|
11
|
+
## Returns the userinfo component of the URI as URI::Component::UserInfo
|
12
|
+
## object.
|
13
|
+
## path_component::
|
14
|
+
## Returns the path component of the URI as URI::Component::Path object.
|
15
|
+
## query_component::
|
16
|
+
## Returns the query component of the URI as URI::Component::Query object.
|
17
|
+
##
|
18
|
+
## Usage:
|
19
|
+
##
|
20
|
+
## require "uri"
|
21
|
+
## require "uri/component"
|
22
|
+
##
|
23
|
+
## URI::Component.mixin(URI::HTTP)
|
24
|
+
##
|
25
|
+
## u = URI.parse("http://bob:pass@example.jp/path?foo=12&bar=ab");
|
26
|
+
## i = u.userinfo_component #=> URI::Component::Userinfo.new("bob:pass")
|
27
|
+
## p = u.path_component #=> URI::Component::Path.new("/path")
|
28
|
+
## q = u.query_component #=> URI::Component::Query.new("foo=12&bar=ab")
|
29
|
+
##
|
30
|
+
## i.password = nil
|
31
|
+
## p i.to_s #=> "bob"
|
32
|
+
## p.nodes << "file"
|
33
|
+
## p p.to_s #=> "/path/file"
|
34
|
+
## q.params["baz"] = ["x y z"]
|
35
|
+
## p q.to_s #=> "foo=12&bar=ab&baz=x+y+z"
|
36
|
+
## p u.to_s #=> "http://bob@example.jp/path/file?foo=12&bar=ab&baz=x+y+z"
|
37
|
+
##
|
38
|
+
def self.mixin(klass)
|
39
|
+
URI::Component::UserInfo.mixin(klass) if klass.component.include?(:userinfo)
|
40
|
+
URI::Component::Path.mixin(klass) if klass.component.include?(:path)
|
41
|
+
URI::Component::Query.mixin(klass) if klass.component.include?(:query)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -20,6 +20,7 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- Gemfile
|
22
22
|
- Rakefile
|
23
|
+
- lib/uri/component.rb
|
23
24
|
- lib/uri/component/path.rb
|
24
25
|
- lib/uri/component/query.rb
|
25
26
|
- lib/uri/component/userinfo.rb
|