net-proto 1.0.3-x86-mswin32-60 → 1.0.4-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ == 1.0.4 - 6-Jan-2008
2
+ * The struct returned by Net::Proto.getprotoent is now frozen. This is
3
+ strictly read-only data.
4
+ * It is now explicitly illegal to call Net::Proto.new.
5
+ * Some minor modifications to extconf.rb in terms of how and where the
6
+ the source is built in order to be potentially more friendly to Rubygems.
7
+ * Renamed and refactored the test suite. This library now requires test-unit
8
+ version 2.0.2 or later.
9
+
1
10
  == 1.0.3 - 13-Aug-2007
2
11
  * Fix for OS X (whining about malloced pointer).
3
12
  * Added a Rakefile along with tasks for installation and testing.
data/MANIFEST CHANGED
@@ -10,4 +10,4 @@
10
10
  * ext/linux/linux.c
11
11
  * ext/sunos/sunos.c
12
12
  * ext/windows/windows.c
13
- * test/tc_netproto.rb
13
+ * test/test_net_proto.rb
@@ -16,6 +16,11 @@ extern "C"
16
16
  *
17
17
  * Given a protocol string, returns the corresponding number, or nil if not
18
18
  * found.
19
+ *
20
+ * Examples:
21
+ *
22
+ * Net::Proto.getprotobyname("tcp") # => 6
23
+ * Net::Proto.getprotobyname("bogus") # => nil
19
24
  */
20
25
  static VALUE np_getprotobyname(VALUE klass, VALUE rbProtoName){
21
26
  struct protoent* p;
@@ -36,6 +41,11 @@ static VALUE np_getprotobyname(VALUE klass, VALUE rbProtoName){
36
41
  *
37
42
  * Given a protocol number, returns the corresponding string, or nil if not
38
43
  * found.
44
+ *
45
+ * Examples:
46
+ *
47
+ * Net::Proto.getprotobynumber(6) # => "tcp"
48
+ * Net::Proto.getprotobynumber(999) # => nil
39
49
  */
40
50
  static VALUE np_getprotobynumber(VALUE klass, VALUE v_proto_num)
41
51
  {
@@ -64,7 +74,10 @@ void Init_proto()
64
74
  rb_define_singleton_method(cProto,"getprotobyname",np_getprotobyname,1);
65
75
  rb_define_singleton_method(cProto,"getprotobynumber",np_getprotobynumber,1);
66
76
 
67
- /* 1.0.3: The version of this package. This is a string, not a number */
77
+ /* There is no constructor */
78
+ rb_funcall(cProto, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
79
+
80
+ /* 1.0.4: The version of this library. This is a string, not a number */
68
81
  rb_define_const(cProto, "VERSION", rb_str_new2(NET_PROTO_VERSION));
69
82
  }
70
83
 
data/lib/net/proto.so CHANGED
Binary file
@@ -0,0 +1,126 @@
1
+ ###########################################################################
2
+ # test_net_netproto.rb
3
+ #
4
+ # Test suite for net-proto - all platforms. This test suite should be run
5
+ # via the 'rake test' task.
6
+ ###########################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'net/proto'
11
+ require 'test/unit'
12
+
13
+ class TC_Net_Proto < Test::Unit::TestCase
14
+
15
+ # These were the protocols listed in my own /etc/protocols file on Solaris 9
16
+ def self.startup
17
+ @@protocols = %w/
18
+ ip icmp igmp ggp ipip tcp cbt egp igp pup udp mux hmp
19
+ xns-idp rdp idpr idpr-cmtp sdrp idrp rsvp gre
20
+ mobile ospf pim ipcomp vrrp sctp hopopt ipv6
21
+ ipv6-route ipv6-frag esp ah ipv6-icmp ipv6-nonxt ipv6-opts
22
+ /
23
+ end
24
+
25
+ def setup
26
+ @protoent = nil
27
+ end
28
+
29
+ def test_version
30
+ assert_equal('1.0.4', Net::Proto::VERSION)
31
+ end
32
+
33
+ def test_getprotobynumber_basic
34
+ assert_respond_to(Net::Proto, :getprotobynumber)
35
+ assert_nothing_raised{ 0.upto(132){ |n| Net::Proto.getprotobynumber(n) } }
36
+ assert_kind_of(String, Net::Proto.getprotobynumber(1))
37
+ end
38
+
39
+ def test_getprotobynumber_result_expected
40
+ assert_equal('icmp', Net::Proto.getprotobynumber(1))
41
+ assert_equal('tcp', Net::Proto.getprotobynumber(6))
42
+ end
43
+
44
+ def test_getprotbynumber_result_not_expected
45
+ assert_equal(nil, Net::Proto.getprotobynumber(9999999))
46
+ assert_equal(nil, Net::Proto.getprotobynumber(-1))
47
+ end
48
+
49
+ def test_getprotobynumber_expected_errors
50
+ assert_raise(TypeError){ Net::Proto.getprotobynumber('foo') }
51
+ assert_raise(TypeError){ Net::Proto.getprotobynumber(nil) }
52
+ assert_raise(RangeError){ Net::Proto.getprotobynumber(999999999999) }
53
+ end
54
+
55
+ def test_getprotobyname_basic
56
+ assert_respond_to(Net::Proto, :getprotobyname)
57
+ @@protocols.each{ |n| assert_nothing_raised{ Net::Proto.getprotobyname(n) } }
58
+ end
59
+
60
+ def test_getprotobyname_result_expected
61
+ assert_equal(1, Net::Proto.getprotobyname('icmp'))
62
+ assert_equal(6, Net::Proto.getprotobyname('tcp'))
63
+ end
64
+
65
+ def test_getprotobyname_result_not_expected
66
+ assert_equal(nil, Net::Proto.getprotobyname('foo'))
67
+ assert_equal(nil, Net::Proto.getprotobyname('tcpx'))
68
+ assert_equal(nil, Net::Proto.getprotobyname(''))
69
+ end
70
+
71
+ def test_getprotobyname_expected_errors
72
+ assert_raises(TypeError){ Net::Proto.getprotobyname(1) }
73
+ assert_raises(TypeError){ Net::Proto.getprotobyname(nil) }
74
+ end
75
+
76
+ def test_getprotoent_basic
77
+ omit_if(Config::CONFIG['host_os'].match('mswin'), 'Skipped on MS Windows')
78
+
79
+ assert_respond_to(Net::Proto, :getprotoent)
80
+ assert_nothing_raised{ Net::Proto.getprotoent }
81
+ assert_kind_of(Array, Net::Proto.getprotoent)
82
+ end
83
+
84
+ def test_getprotoent
85
+ omit_if(Config::CONFIG['host_os'].match('mswin'), 'Skipped on MS Windows')
86
+
87
+ assert_kind_of(Struct::ProtoStruct, Net::Proto.getprotoent.first)
88
+ assert_nil(Net::Proto.getprotoent{})
89
+ end
90
+
91
+ def test_getprotoent_struct
92
+ omit_if(Config::CONFIG['host_os'].match('mswin'), 'Skipped on MS Windows')
93
+
94
+ @protoent = Net::Proto.getprotoent.first
95
+ assert_equal(['name', 'aliases', 'proto'], @protoent.members)
96
+ assert_kind_of(String, @protoent.name)
97
+ assert_kind_of(Array, @protoent.aliases)
98
+ assert_kind_of(Integer, @protoent.proto)
99
+ end
100
+
101
+ def test_getprotoent_struct_aliases_member
102
+ omit_if(Config::CONFIG['host_os'].match('mswin'), 'Skipped on MS Windows')
103
+
104
+ @protoent = Net::Proto.getprotoent.first
105
+ assert_true(@protoent.aliases.all?{ |e| e.is_a?(String) })
106
+ end
107
+
108
+ def test_getprotoent_struct_frozen
109
+ omit_if(Config::CONFIG['host_os'].match('mswin'), 'Skipped on MS Windows')
110
+
111
+ @protoent = Net::Proto.getprotoent.first
112
+ assert_true(@protoent.frozen?)
113
+ end
114
+
115
+ def test_constructor_illegal
116
+ assert_raise(NoMethodError){ Net::Proto.new }
117
+ end
118
+
119
+ def teardown
120
+ @protoent = nil
121
+ end
122
+
123
+ def self.shutdown
124
+ @@protocols = nil
125
+ end
126
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-proto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: x86-mswin32-60
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-07 00:00:00 -06:00
12
+ date: 2009-01-07 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: test-unit
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.2
24
+ version:
16
25
  description: The net-proto package provides the getprotobyname(), getprotobynumber() and the getprotoent() methods for Ruby.
17
26
  email: djberg96@gmail.com
18
27
  executables: []
@@ -27,13 +36,12 @@ extra_rdoc_files:
27
36
  - ext/windows/windows.c
28
37
  files:
29
38
  - doc/netproto.txt
30
- - test/tc_netproto.rb
31
- - lib/net
39
+ - test/test_net_proto.rb
32
40
  - lib/net/proto.so
33
- - ext/windows/windows.c
34
41
  - CHANGES
35
42
  - README
36
43
  - MANIFEST
44
+ - ext/windows/windows.c
37
45
  has_rdoc: true
38
46
  homepage: http://www.rubyforge.org/projects/sysutils
39
47
  post_install_message:
@@ -56,9 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
64
  requirements: []
57
65
 
58
66
  rubyforge_project: sysutils
59
- rubygems_version: 1.1.1
67
+ rubygems_version: 1.3.1
60
68
  signing_key:
61
69
  specification_version: 2
62
70
  summary: The net-proto package provides the getprotobyname(), getprotobynumber() and the getprotoent() methods for Ruby.
63
71
  test_files:
64
- - test/tc_netproto.rb
72
+ - test/test_net_proto.rb
data/test/tc_netproto.rb DELETED
@@ -1,71 +0,0 @@
1
- ###########################################################################
2
- # tc_netproto.rb
3
- #
4
- # Test suite for net-proto - all platforms. This test suite should be run
5
- # via the 'rake test' task.
6
- ###########################################################################
7
- require "net/proto"
8
- require "test/unit"
9
- include Net
10
-
11
- class TC_Net_Proto < Test::Unit::TestCase
12
- # These were the protocols listed in my
13
- # own /etc/protocols file on Solaris 9.
14
- def setup
15
- @protocols = %w/
16
- ip icmp igmp ggp ipip tcp cbt egp igp pup udp mux hmp
17
- xns-idp rdp idpr idpr-cmtp sdrp idrp rsvp gre
18
- mobile ospf pim ipcomp vrrp sctp hopopt ipv6
19
- ipv6-route ipv6-frag esp ah ipv6-icmp ipv6-nonxt ipv6-opts
20
- /
21
- end
22
-
23
- def test_version
24
- assert_equal("1.0.3", Proto::VERSION)
25
- end
26
-
27
- def test_getprotobynumber
28
- assert_respond_to(Proto, :getprotobynumber)
29
- assert_raises(TypeError){ Proto.getprotobynumber("foo") }
30
- assert_raises(TypeError){ Proto.getprotobynumber(nil) }
31
- assert_equal(nil, Proto.getprotobynumber(9999999))
32
- assert_equal("tcp", Proto.getprotobynumber(6))
33
- assert_nothing_raised{
34
- 0.upto(132){ |n| Proto.getprotobynumber(n) }
35
- }
36
- end
37
-
38
- def test_getprotobyname
39
- assert_respond_to(Proto, :getprotobyname)
40
- assert_raises(TypeError){ Proto.getprotobyname(1) }
41
- assert_raises(TypeError){ Proto.getprotobyname(nil) }
42
- assert_equal(nil, Proto.getprotobyname("foo"))
43
- assert_equal(6, Proto.getprotobyname("tcp"))
44
- @protocols.each{ |prot|
45
- assert_nothing_raised{ Proto.getprotobyname(prot) }
46
- }
47
- end
48
-
49
- def test_getprotoent
50
- if File::ALT_SEPARATOR
51
- msg = "The getprotoent() function is not supported on this "
52
- msg += "platform - test skipped"
53
- STDERR.puts msg
54
- else
55
- assert_respond_to(Proto, :getprotoent)
56
- p = Proto.getprotoent.first
57
- assert_kind_of(Struct::ProtoStruct, p)
58
- assert_equal(%w/name aliases proto/,p.members)
59
- assert_kind_of(String, p.name, "Bad type for name")
60
- assert_kind_of(Array, p.aliases, "Bad type for aliases")
61
- assert_kind_of(Integer, p.proto, "Bad type for proto")
62
- p.aliases.each{ |a|
63
- assert_kind_of(String, a, "Bad type for aliases member")
64
- }
65
- end
66
- end
67
-
68
- def teardown
69
- @protocols = nil
70
- end
71
- end