rubysip 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/HISTORY +0 -0
- data/LICENSE +21 -0
- data/README +24 -0
- data/Rakefile +56 -0
- data/lib/net/sip.rb +3 -0
- data/lib/net/sip/uri.rb +9 -0
- data/lib/uri/sip.rb +115 -0
- data/test/runner.rb +6 -0
- metadata +62 -0
data/ChangeLog
ADDED
data/HISTORY
ADDED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2007 Hiroki Yagita
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
= Ruby/SIP -- Ruby SIP protocol implementations
|
2
|
+
|
3
|
+
== Getting Started
|
4
|
+
|
5
|
+
comming soon...
|
6
|
+
|
7
|
+
== Download and Installation
|
8
|
+
|
9
|
+
Download and install Ruby/SIP with the following.
|
10
|
+
|
11
|
+
gem install --remote rubysip
|
12
|
+
|
13
|
+
== License
|
14
|
+
|
15
|
+
Author:: Hiroki Yagita <yagita@ys-holder.co.jp>
|
16
|
+
Requires:: Ruby 1.8.0 or later
|
17
|
+
License:: Copyright 2007 by Hiroki Yagita.
|
18
|
+
Released under an MIT-style license. See the LICENSE file
|
19
|
+
included in the distribution.
|
20
|
+
|
21
|
+
== 対応している RFC
|
22
|
+
|
23
|
+
-RFC3428:Session Initiation Protocol (SIP) Extension for Instant Messaging
|
24
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake/gempackagetask"
|
3
|
+
require "rake/clean"
|
4
|
+
require "rake/packagetask"
|
5
|
+
require "rake/rdoctask"
|
6
|
+
|
7
|
+
|
8
|
+
PKG_NAME = "rubysip"
|
9
|
+
PKG_VERSION = "0.0.0"
|
10
|
+
PKG_FILES = Dir.glob("lib/**/*.rb") <<
|
11
|
+
"ChangeLog" <<
|
12
|
+
"HISTORY" <<
|
13
|
+
"LICENSE" <<
|
14
|
+
"README" <<
|
15
|
+
"Rakefile"
|
16
|
+
PKG_RDOC_OPTIONS = [
|
17
|
+
"--main", "README",
|
18
|
+
"--all", "-S", "-N", "-H",
|
19
|
+
"-c", "utf-8",
|
20
|
+
"-w", "4"]
|
21
|
+
|
22
|
+
|
23
|
+
task :default => "test"
|
24
|
+
|
25
|
+
desc "run unit test"
|
26
|
+
task "test" do
|
27
|
+
ruby "test/runner.rb --load-path=lib"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Generate rdoc task.
|
31
|
+
Rake::RDocTask.new do |rd|
|
32
|
+
rd.main = "README"
|
33
|
+
rd.rdoc_files.include "README", "lib/**/*.rb"
|
34
|
+
rd.rdoc_dir = "doc/rdoc"
|
35
|
+
rd.options = PKG_RDOC_OPTIONS
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate *.gem task.
|
39
|
+
spec = Gem::Specification.new do |s|
|
40
|
+
s.summary = "Ruby/SIP is library of SIP(RFC3261 and more) written in pure ruby"
|
41
|
+
s.description ="Ruby/SIP is library of SIP(RFC3261 and more) written in pure ruby"
|
42
|
+
s.name = PKG_NAME
|
43
|
+
s.version = PKG_VERSION
|
44
|
+
s.files = PKG_FILES
|
45
|
+
s.email = "yagita@ys-holder.co.jp"
|
46
|
+
s.homepage = "http://rubysip.rubyforge.org/"
|
47
|
+
s.authors = ["Hiroki Yagita"]
|
48
|
+
s.test_files = ["test/runner.rb"]
|
49
|
+
s.has_rdoc = true
|
50
|
+
s.rdoc_options << PKG_RDOC_OPTIONS
|
51
|
+
s.extra_rdoc_files = ["README"]
|
52
|
+
end
|
53
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
54
|
+
pkg.need_tar_gz = true
|
55
|
+
pkg.need_tar_bz2 = true
|
56
|
+
end
|
data/lib/net/sip.rb
ADDED
data/lib/net/sip/uri.rb
ADDED
data/lib/uri/sip.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module URI # :nodoc:
|
6
|
+
|
7
|
+
# URI::SIP クラスは SIP URI を実装しています.
|
8
|
+
class SIP < Generic
|
9
|
+
|
10
|
+
DEFAULT_PORT = 5060
|
11
|
+
|
12
|
+
COMPONENT =
|
13
|
+
[ :scheme, :userinfo, :host, :port, :uri_parameters, :headers ].freeze
|
14
|
+
|
15
|
+
PATTERN = "(?:[^?=&]*=[^?=&]*)".freeze
|
16
|
+
|
17
|
+
# 汎用的な構成要素から URI::SIP オブジェクトを生成します。
|
18
|
+
# build と異なり、引数の正当性を検査しません。
|
19
|
+
def initialize(*arg)
|
20
|
+
super
|
21
|
+
@uri_parameters = nil
|
22
|
+
@headers = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
# 引数で与えられた URI 構成要素からオブジェクトを生成します.
|
26
|
+
# +args+::
|
27
|
+
# URI 構成要素. [userinfo, host, port, uri_parameters, headers] を
|
28
|
+
# 配列かハッシュで与えます.
|
29
|
+
# +uri_parameters+::
|
30
|
+
# RFC3261 19.1.1 にて規定されている URI parameters を
|
31
|
+
# 配列かハッシュで与えます.
|
32
|
+
# +headers+::
|
33
|
+
# RFC3261 19.1.1 にて規定されている Headers を配列かハッシュで与えます.
|
34
|
+
#
|
35
|
+
def self.build(args)
|
36
|
+
# args をハッシュ化する
|
37
|
+
tmp = Util::make_components_hash(self, args)
|
38
|
+
|
39
|
+
return false unless validate_uri_parameters(tmp[:uri_parameters])
|
40
|
+
return false unless validate_headers(tmp[:headers])
|
41
|
+
|
42
|
+
o = self.new(nil, nil, nil, nil, nil, nil, nil, nil, false)
|
43
|
+
o.scheme = tmp[:scheme]
|
44
|
+
o.userinfo = tmp[:userinfo]
|
45
|
+
o.host = tmp[:host]
|
46
|
+
o.port = tmp[:port]
|
47
|
+
o.uri_parameters = tmp[:uri_parameters]
|
48
|
+
o.headers = tmp[:headers]
|
49
|
+
|
50
|
+
return o
|
51
|
+
end
|
52
|
+
|
53
|
+
# URI-parameters を変更します
|
54
|
+
def uri_parameters=(ary)
|
55
|
+
@uri_parameters = ary
|
56
|
+
end
|
57
|
+
|
58
|
+
# Headers を変更します
|
59
|
+
def headers=(ary)
|
60
|
+
@headers = ary
|
61
|
+
end
|
62
|
+
|
63
|
+
# 文字列化します
|
64
|
+
def to_s
|
65
|
+
s = @scheme + ':'
|
66
|
+
unless self.userinfo.nil?
|
67
|
+
s << "#{self.userinfo}@"
|
68
|
+
end
|
69
|
+
unless @host.nil?
|
70
|
+
s << @host
|
71
|
+
end
|
72
|
+
unless @port.nil?
|
73
|
+
s << ":#{@port}"
|
74
|
+
end
|
75
|
+
unless @uri_parameters.nil?
|
76
|
+
@uri_parameters.each do |x|
|
77
|
+
s << ";#{x}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
unless @headers.nil?
|
81
|
+
s << "?"
|
82
|
+
@headers.each do |x|
|
83
|
+
s << "#{x}&"
|
84
|
+
end
|
85
|
+
s.chop!
|
86
|
+
end
|
87
|
+
return s
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.validate(v, separator)
|
91
|
+
return true unless v
|
92
|
+
|
93
|
+
pattern = Regexp.new("#{PATTERN}(#{separator}#{PATTERN})*")
|
94
|
+
v.each do |i|
|
95
|
+
return false unless pattern =~ i
|
96
|
+
end
|
97
|
+
|
98
|
+
return true
|
99
|
+
end
|
100
|
+
|
101
|
+
# URI parameters を検証します
|
102
|
+
def self.validate_uri_parameters(v)
|
103
|
+
return validate(v, ';')
|
104
|
+
end
|
105
|
+
|
106
|
+
# Headers を検証します
|
107
|
+
def self.validate_headers(v)
|
108
|
+
return validate(v, '&')
|
109
|
+
end
|
110
|
+
|
111
|
+
end # class SIP
|
112
|
+
|
113
|
+
@@schemes['SIP'] = SIP
|
114
|
+
|
115
|
+
end # module URI
|
data/test/runner.rb
ADDED
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: rubysip
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.0
|
7
|
+
date: 2007-04-04 00:00:00 +09:00
|
8
|
+
summary: Ruby/SIP is library of SIP(RFC3261 and more) written in pure ruby
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: yagita@ys-holder.co.jp
|
12
|
+
homepage: http://rubysip.rubyforge.org/
|
13
|
+
rubyforge_project:
|
14
|
+
description: Ruby/SIP is library of SIP(RFC3261 and more) written in pure ruby
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Hiroki Yagita
|
31
|
+
files:
|
32
|
+
- lib/net/sip/uri.rb
|
33
|
+
- lib/net/sip.rb
|
34
|
+
- lib/uri/sip.rb
|
35
|
+
- ChangeLog
|
36
|
+
- HISTORY
|
37
|
+
- LICENSE
|
38
|
+
- README
|
39
|
+
- Rakefile
|
40
|
+
test_files:
|
41
|
+
- test/runner.rb
|
42
|
+
rdoc_options:
|
43
|
+
- - --main
|
44
|
+
- README
|
45
|
+
- --all
|
46
|
+
- -S
|
47
|
+
- -N
|
48
|
+
- -H
|
49
|
+
- -c
|
50
|
+
- utf-8
|
51
|
+
- -w
|
52
|
+
- "4"
|
53
|
+
extra_rdoc_files:
|
54
|
+
- README
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
dependencies: []
|
62
|
+
|