net-dns 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 5
4
- :patch: 2
4
+ :patch: 3
@@ -4,6 +4,7 @@
4
4
 
5
5
 
6
6
 
7
+ require 'rbconfig'
7
8
  require 'socket'
8
9
  require 'timeout'
9
10
  require 'ipaddr'
@@ -1062,7 +1063,7 @@ module Net # :nodoc:
1062
1063
  # Parse a configuration file specified as the argument.
1063
1064
  #
1064
1065
  def parse_config_file
1065
- if RUBY_PLATFORM =~ /win/
1066
+ if self.class.platform_windows?
1066
1067
  require 'win32/resolv'
1067
1068
  arr = Win32::Resolv.get_resolv_info
1068
1069
  self.domain = arr[0]
@@ -1223,7 +1224,21 @@ module Net # :nodoc:
1223
1224
  true
1224
1225
  end
1225
1226
  end
1226
-
1227
+
1228
+
1229
+ class << self
1230
+
1231
+ # Returns true if running on a Windows platform.
1232
+ #
1233
+ # Note. This method doesn't rely on the RUBY_PLATFORM constant
1234
+ # because the comparison will fail when running on JRuby.
1235
+ # On JRuby RUBY_PLATFORM == 'java'.
1236
+ def platform_windows?
1237
+ !!(Config::CONFIG["host_os"] =~ /msdos|mswin|djgpp|mingw/i)
1238
+ end
1239
+
1240
+ end
1241
+
1227
1242
  end # class Resolver
1228
1243
  end # module DNS
1229
1244
  end # module Net
@@ -114,7 +114,7 @@ module Net # :nodoc:
114
114
  # Gives in output the keys from the +Types+ hash
115
115
  # in a format suited for regexps
116
116
  def self.regexp
117
- Types.keys.join("|")
117
+ Types.keys.sort.join("|")
118
118
  end
119
119
 
120
120
  # Creates a new object representing an RR type. Performs some
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{net-dns}
5
- s.version = "0.5.2"
5
+ s.version = "0.5.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Marco Ceresa"]
9
- s.date = %q{2009-06-12}
9
+ s.date = %q{2009-06-16}
10
10
  s.description = %q{Net::DNS is a pure Ruby DNS library, with a clean OO interface and an extensible API}
11
11
  s.email = %q{ceresa@gmail.com}
12
12
  s.extra_rdoc_files = [
@@ -58,6 +58,7 @@ Gem::Specification.new do |s|
58
58
  "test/net/dns/test_header.rb",
59
59
  "test/net/dns/test_packet.rb",
60
60
  "test/net/dns/test_question.rb",
61
+ "test/net/dns/test_resolver.rb",
61
62
  "test/net/dns/test_rr.rb"
62
63
  ]
63
64
  s.homepage = %q{http://github.com/bluemonk/net-dns}
@@ -75,7 +76,8 @@ Gem::Specification.new do |s|
75
76
  "test/net/dns/resolver/test_timeouts.rb",
76
77
  "test/net/dns/test_rr.rb",
77
78
  "test/net/dns/test_packet.rb",
78
- "test/net/dns/test_question.rb"
79
+ "test/net/dns/test_question.rb",
80
+ "test/net/dns/test_resolver.rb"
79
81
  ]
80
82
 
81
83
  if s.respond_to? :specification_version then
@@ -62,10 +62,7 @@ class Test_Types < Test::Unit::TestCase
62
62
  'ANY' => 255,
63
63
  }
64
64
 
65
- @regexp_string = "UNSPEC|ATMA|EID|LOC|NSAP|ISDN|MX|ANY|MAILA|SRV|AFSDB|MD|" +
66
- "A|MAILB|TKEY|GID|KX|GPOS|RT|HINFO|PTR|CNAME|MF|SIGZERO|DNSKEY|DS|AAAA|" +
67
- "MG|UID|NSEC|NIMLOC|NSAP_PTR|X25|TXT|MR|SOA|NS|DNAME|CERT|SIG|AXFR|IXFR|" +
68
- "UINFO|NAPTR|OPT|PX|RP|TSIG|SSHFP|KEY|MINFO|WKS|NULL|RRSIG|NXT|MB"
65
+ @regexp_string = "A|AAAA|AFSDB|ANY|ATMA|AXFR|CERT|CNAME|DNAME|DNSKEY|DS|EID|GID|GPOS|HINFO|ISDN|IXFR|KEY|KX|LOC|MAILA|MAILB|MB|MD|MF|MG|MINFO|MR|MX|NAPTR|NIMLOC|NS|NSAP|NSAP_PTR|NSEC|NULL|NXT|OPT|PTR|PX|RP|RRSIG|RT|SIG|SIGZERO|SOA|SRV|SSHFP|TKEY|TSIG|TXT|UID|UINFO|UNSPEC|WKS|X25"
69
66
  end
70
67
 
71
68
  def test_default
@@ -0,0 +1,56 @@
1
+ require 'test/unit'
2
+ require 'net/dns/resolver'
3
+
4
+ class Net::DNS::Resolver
5
+ attr_reader :config
6
+ end
7
+
8
+
9
+ class TestResolver < Test::Unit::TestCase
10
+
11
+ def test_initialize
12
+ assert_nothing_raised { Net::DNS::Resolver.new }
13
+ end
14
+
15
+ def test_initialize_with_config
16
+ assert_nothing_raised { Net::DNS::Resolver.new({}) }
17
+ end
18
+
19
+ def test_initialize_with_invalid_config_should_raise_error
20
+ assert_raise(ResolverArgumentError) { Net::DNS::Resolver.new("") }
21
+ assert_raise(ResolverArgumentError) { Net::DNS::Resolver.new(0) }
22
+ assert_raise(ResolverArgumentError) { Net::DNS::Resolver.new(:foo) }
23
+ end
24
+
25
+
26
+ RubyPlatforms = [
27
+ ["darwin9.0", false], # Mac OS X
28
+ ["darwin", false], # JRuby on Mac OS X
29
+ ["linux-gnu", false],
30
+ ["mingw32", true], # ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mingw32]
31
+ ["mswin32", true], # ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]
32
+ ["mswin32", true], # ruby 1.8.6 (2008-04-22 rev 6555) [x86-jruby1.1.1]
33
+ ]
34
+
35
+ def test_self_platform_windows_question
36
+ RubyPlatforms.each do |platform, is_windows|
37
+ assert_equal is_windows,
38
+ override_platform(platform) { Net::DNS::Resolver.platform_windows? },
39
+ "Expected `#{is_windows}' with platform `#{platform}'"
40
+ end
41
+ end
42
+
43
+
44
+ protected
45
+
46
+ def override_platform(new_platform, &block)
47
+ raise LocalJumpError, "no block given" unless block_given?
48
+ old_platform = Config::CONFIG["host_os"]
49
+ Config::CONFIG["host_os"] = new_platform
50
+ result = yield
51
+ ensure
52
+ Config::CONFIG["host_os"] = old_platform
53
+ result
54
+ end
55
+
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Ceresa
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-12 00:00:00 +01:00
12
+ date: 2009-06-16 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -67,6 +67,7 @@ files:
67
67
  - test/net/dns/test_header.rb
68
68
  - test/net/dns/test_packet.rb
69
69
  - test/net/dns/test_question.rb
70
+ - test/net/dns/test_resolver.rb
70
71
  - test/net/dns/test_rr.rb
71
72
  has_rdoc: true
72
73
  homepage: http://github.com/bluemonk/net-dns
@@ -106,3 +107,4 @@ test_files:
106
107
  - test/net/dns/test_rr.rb
107
108
  - test/net/dns/test_packet.rb
108
109
  - test/net/dns/test_question.rb
110
+ - test/net/dns/test_resolver.rb