~ubuntu-branches/ubuntu/trusty/zonecheck/trusty

« back to all changes in this revision

Viewing changes to zc/framework.rb

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Delafond
  • Date: 2010-07-08 12:55:39 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100708125539-gazuzu1eb58l3tot
Tags: 3.0.2-1
* New upstream release (Closes: #587419).
* Updated watch file.
* Bumped up Standards revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: framework.rb,v 1.52 2010/06/14 11:47:54 chabannf Exp $
 
1
# $Id: framework.rb,v 1.55 2010/06/25 08:39:37 chabannf Exp $
2
2
 
3
3
4
4
# CONTACT     : zonecheck@nic.fr
5
5
# AUTHOR      : Stephane D'Alu <sdalu@nic.fr>
6
6
#
7
7
# CREATED     : 2002/08/02 13:58:17
8
 
# REVISION    : $Revision: 1.52 $ 
9
 
# DATE        : $Date: 2010/06/14 11:47:54 $
 
8
# REVISION    : $Revision: 1.55 $ 
 
9
# DATE        : $Date: 2010/06/25 08:39:37 $
10
10
#
11
11
# CONTRIBUTORS: (see also CREDITS file)
12
12
#
206
206
          bytes, bits_shift = size / 8, 8 - (size % 8)
207
207
          address = arg.address.slice(0, bytes) + 
208
208
              ("\0" * (arg.address.size - bytes))
209
 
          address[bytes] = (arg.address[bytes] >> bits_shift) << bits_shift
 
209
          if arg.address.respond_to?("bytes")
 
210
            a = arg.address.bytes.to_a
 
211
            a[bytes] = (a[bytes] >> bits_shift) << bits_shift
 
212
            address = a.map { |e| e.chr }.join
 
213
          else
 
214
            address[bytes] = (arg.address[bytes] >> bits_shift) << bits_shift
 
215
          end
210
216
          Dnsruby::IPv4::new(address.freeze)
211
217
        end
212
218
      when Dnsruby::IPv6
219
225
        bytes, bits_shift = size / 8, 8 - (size % 8)
220
226
        address = arg.address.slice(0, bytes) + 
221
227
            ("\0" * (arg.address.size - bytes))
222
 
        address[bytes] = (arg.address[bytes] >> bits_shift) << bits_shift
 
228
        if arg.address.respond_to?("bytes")
 
229
          a = arg.address.bytes.to_a
 
230
          a[bytes] = (a[bytes] >> bits_shift) << bits_shift
 
231
          address = a.map { |e| e.chr }.join
 
232
        else
 
233
          address[bytes] = (arg.address[bytes] >> bits_shift) << bits_shift
 
234
        end
223
235
        Dnsruby::IPv6::new(address.freeze)
224
236
      else
225
237
        raise ArgumentError, "Could not fing the prefix of : #{address}"