[#47790] [ruby-trunk - Bug #7097][Open] Thread locals don't work inside Enumerator — "tenderlovemaking (Aaron Patterson)" <aaron@...>

32 messages 2012/10/01
[#47791] [ruby-trunk - Bug #7097][Assigned] Thread locals don't work inside Enumerator — "kosaki (Motohiro KOSAKI)" <kosaki.motohiro@...> 2012/10/01

[#47792] Re: [ruby-trunk - Bug #7097][Assigned] Thread locals don't work inside Enumerator — Aaron Patterson <tenderlove@...> 2012/10/01

On Tue, Oct 02, 2012 at 03:05:17AM +0900, kosaki (Motohiro KOSAKI) wrote:

[#47798] Re: [ruby-trunk - Bug #7097][Assigned] Thread locals don't work inside Enumerator — SASADA Koichi <ko1@...> 2012/10/01

(2012/10/02 3:12), Aaron Patterson wrote:

[#47800] Re: [ruby-trunk - Bug #7097][Assigned] Thread locals don't work inside Enumerator — SASADA Koichi <ko1@...> 2012/10/01

(2012/10/02 8:22), SASADA Koichi wrote:

[#47832] [ruby-trunk - Feature #7106][Open] FileUtils.touch should allow touching the symlink itself rather than the file the link points to — "cirrusthinking (Alessandro Diaferia)" <alessandro@...>

18 messages 2012/10/04

[#47847] [ruby-trunk - Bug #7110][Open] CGI: Add support for HTML5 <header> tag — "stomar (Marcus Stollsteimer)" <redmine@...>

16 messages 2012/10/05

[#47870] [ruby-trunk - Bug #7123][Open] Segmentation fault in ruby 1.9.3-p194 — "mscottford (M. Scott Ford)" <scott@...>

13 messages 2012/10/09

[#47880] [ruby-trunk - Bug #7134][Open] Signal handling bug in Mac OS X — "auastro (Andy Kitchen)" <kitchen.andy+rubybug@...>

17 messages 2012/10/10

[#47881] [ruby-trunk - Bug #7135][Open] GC bug in Ruby 1.9.3-p194? — "alexdowad (Alex Dowad)" <alexinbeijing@...>

21 messages 2012/10/10

[#47887] [ruby-trunk - Bug #7137][Open] Date.parse overly lenient when attempting to parse Monday? — "garysweaver (Gary Weaver)" <garysweaver@...>

12 messages 2012/10/10

[#47930] [ruby-trunk - Feature #7148][Open] Improved Tempfile w/o DelegateClass — "Glass_saga (Masaki Matsushita)" <glass.saga@...>

14 messages 2012/10/12

[#47970] [ruby-trunk - Bug #7158][Open] require is slow in its bookkeeping; can make Rails startup 2.2x faster — "gregprice (Greg Price)" <price@...>

30 messages 2012/10/14

[#48027] [Backport93 - Backport #7172][Open] [[Ruby 1.9:]] fix rbconfig for --enable-load-relative (v2) — "mpapis (Michal Papis)" <mpapis@...>

13 messages 2012/10/16

[#48053] [ruby-trunk - Bug #7180][Open] set_trace_func with error in proc block locks up Ruby with 100% cpu usage and no way to exit without killing proc — "garysweaver (Gary Weaver)" <garysweaver@...>

8 messages 2012/10/17

[#48072] [ruby-trunk - Bug #7184][Open] --disable-gems commandline parameter does not show up with ruby -h — "steenslag (siep korteling)" <s.korteling@...>

10 messages 2012/10/18

[#48130] [ruby-trunk - Bug #7200][Open] Setting external encoding with BOM| — "brixen (Brian Ford)" <brixen@...>

14 messages 2012/10/21

[#48191] [ANN] 2.0.0 feature freeze — Yusuke Endoh <mame@...>

Japanese later; 日本語は後で

37 messages 2012/10/24
[#48696] Re: [ANN] 2.0.0 feature freeze — SASADA Koichi <ko1@...> 2012/11/01

(2012/10/24 5:39), Yusuke Endoh wrote:

[#48260] [ruby-trunk - Bug #7214][Open] Ruby 2.0 breaks support for some debugging tools — "banister (john mair)" <jrmair@...>

22 messages 2012/10/25

[#48315] [ruby-trunk - Bug #7220][Open] StringIO#initialize_copy causes aliasing between the objects — "brixen (Brian Ford)" <brixen@...>

13 messages 2012/10/26

[#48413] [ruby-trunk - Bug #7221][Open] Unable to compile kgio under 1.9.3 with error: ruby-1.9.3-<plvl>/lib/ruby/1.9.1/mkmf.rb:597:in `Integer': can't convert nil into Integer (TypeError) — "davidderyldowney (David Deryl Downey)" <me@...>

9 messages 2012/10/27

[#48549] [ruby-trunk - Feature #7240][Open] Inheritable #included/#extended Hooks For Modules — "apotonick (Nick Sutterer)" <apotonick@...>

14 messages 2012/10/29

[#48551] [ruby-trunk - Feature #7241][Open] Enumerable#to_h proposal — "nathan.f77 (Nathan Broadbent)" <nathan.f77@...>

23 messages 2012/10/29

[#48552] [ruby-trunk - Bug #7242][Open] Bignum mathematical accuracy regression in r31695 — "mhall (Matthew Hall)" <mhall@...>

11 messages 2012/10/29

[ruby-core:48519] [ruby-trunk - Feature #1436] Please consider this addition to resolv.rb which adds methods for resolving LOC resources

From: "akr (Akira Tanaka)" <akr@...>
Date: 2012-10-28 14:04:07 UTC
List: ruby-core #48519
Issue #1436 has been updated by akr (Akira Tanaka).

Target version changed from 2.0.0 to next minor


----------------------------------------
Feature #1436: Please consider this addition to resolv.rb which adds methods for resolving LOC resources
https://bugs.ruby-lang.org/issues/1436#change-31883

Author: jabo (JB Smith)
Status: Assigned
Priority: Normal
Assignee: akr (Akira Tanaka)
Category: core
Target version: next minor


=begin
 Please consider this diff which would add support to resolv.rb to permit parsing of LOC resources.
 I would welcome any criticism or guidance that would make this more suitable for inclusion.
 Regards,
 
 JB Smith
 
 
 
 
 Index: lib/resolv.rb
 ===================================================================
 --- lib/resolv.rb	(revision 23349)
 +++ lib/resolv.rb	(working copy)
 @@ -1835,6 +1835,97 @@
        end
  
        ##
 +      # Location resource
 +      
 +      class LOC < Resource
 +      
 +        TypeValue = 29 # :nodoc:
 +        
 +        def initialize(version, ssize, hprecision, vprecision, latitude, longitude, altitude)
 +          @version    = version
 +          @ssize      = Resolv::LOC::Size.create(ssize)
 +          @hprecision = Resolv::LOC::Size.create(hprecision)
 +          @vprecision = Resolv::LOC::Size.create(vprecision)
 +          @latitude   = Resolv::LOC::Coord.create(latitude)
 +          @longitude  = Resolv::LOC::Coord.create(longitude)
 +          @altitude   = Resolv::LOC::Alt.create(altitude)
 +        end
 +        
 +        ##
 +        # Returns the version value for this LOC record which should always be 00
 +        
 +        attr_reader :version
 +        
 +        ##
 +        # The spherical size of this LOC
 +        # in meters using scientific notation as 2 integers of XeY
 +        
 +        attr_reader :ssize
 +        
 +        ##
 +        # The horizontal precision using ssize type values
 +        # in meters using scientific notation as 2 integers of XeY
 +        # for precision use value/2 e.g. 2m = +/-1m
 +        
 +        attr_reader :hprecision
 +        
 +        ##
 +        # The vertical precision using ssize type values
 +        # in meters using scientific notation as 2 integers of XeY
 +        # for precision use value/2 e.g. 2m = +/-1m
 +        
 +        attr_reader :vprecision
 +        
 +        ##
 +        # The latitude for this LOC where 2**31 is the equator
 +        # in thousandths of an arc second as an unsigned 32bit integer
 +        
 +        attr_reader :latitude
 +        
 +        ##
 +        # The longitude for this LOC where 2**31 is the prime meridian
 +        # in thousandths of an arc second as an unsigned 32bit integer
 +        
 +        attr_reader :longitude
 +        
 +        ##
 +        # The altitude of the LOC above a reference sphere whose surface sits 100km below the WGS84 spheroid
 +        # in centimeters as an unsigned 32bit integer
 +        
 +        attr_reader :altitude
 +        
 +        
 +        def encode_rdata(msg) # :nodoc:
 +          msg.put_bytes(@version)
 +          msg.put_bytes(@ssize.scalar)
 +          msg.put_bytes(@hprecision.scalar)
 +          msg.put_bytes(@vprecision.scalar)
 +          msg.put_bytes(@latitude.coordinates)
 +          msg.put_bytes(@longitude.coordinates)
 +          msg.put_bytes(@altitude.altitude)
 +        end
 +        
 +        def self.decode_rdata(msg) # :nodoc:
 +          version    = msg.get_bytes(1)
 +          ssize      = msg.get_bytes(1)
 +          hprecision = msg.get_bytes(1)
 +          vprecision = msg.get_bytes(1)
 +          latitude   = msg.get_bytes(4)
 +          longitude  = msg.get_bytes(4)
 +          altitude   = msg.get_bytes(4)
 +          return self.new(
 +            version, 
 +            Resolv::LOC::Size.new(ssize), 
 +            Resolv::LOC::Size.new(hprecision), 
 +            Resolv::LOC::Size.new(vprecision), 
 +            Resolv::LOC::Coord.new(latitude,"lat"), 
 +            Resolv::LOC::Coord.new(longitude,"lon"), 
 +            Resolv::LOC::Alt.new(altitude)
 +          )
 +        end
 +      end
 +
 +      ##
        # A Query type requesting any RR.
  
        class ANY < Query
 @@ -1842,7 +1933,7 @@
        end
  
        ClassInsensitiveTypes = [ # :nodoc:
 -        NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, ANY
 +        NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, LOC, ANY
        ]
  
        ##
 @@ -2260,6 +2351,223 @@
      end
    end
  
 +  module LOC
 +  
 +    ##
 +    # A Resolv::LOC::Size
 +    
 +    class Size
 +    
 +      Regex = /^(\d+\.*\d*)[m]$/
 +      
 +      ##
 +      # Creates a new LOC::Size from +arg+ which may be:
 +      #
 +      # LOC::Size:: returns +arg+.
 +      # String:: +arg+ must match the LOC::Size::Regex constant
 +      
 +      def self.create(arg)
 +        case arg
 +        when Size
 +          return arg
 +        when String
 +          scalar = ''
 +          if Regex =~ arg
 +            scalar = [(($1.to_f*(1e2)).to_i.to_s[0].to_i*(2**4)+(($1.to_f*(1e2)).to_i.to_s.length-1))].pack("C")
 +          else
 +            raise ArgumentError.new("not a properly formed Size string: " + arg)
 +          end
 +          return Size.new(scalar) 
 +        else
 +          raise ArgumentError.new("cannot interpret as Size: #{arg.inspect}")
 +        end
 +      end
 +      
 +      def initialize(scalar)
 +        @scalar = scalar
 +      end
 +      
 +      ##
 +      # The raw size
 +      
 +      attr_reader :scalar
 +      
 +      def to_s # :nodoc:
 +        s = @scalar.unpack("H2").join.to_s
 +        return ((s[0].to_i)*(10**(s[1].to_i-2))).to_s << "m"
 +      end
 +      
 +      def inspect # :nodoc:
 +        return "#<#{self.class} #{self.to_s}>"
 +      end
 +      
 +      def ==(other) # :nodoc:
 +        return @scalar == other.scalar
 +      end
 +  
 +      def eql?(other) # :nodoc:
 +        return self == other
 +      end
 +  
 +      def hash # :nodoc:
 +        return @scalar.hash
 +      end
 +      
 +    end
 +    
 +    ##
 +    # A Resolv::LOC::Coord
 +    
 +    class Coord
 +    
 +      Regex = /^(\d+)\s(\d+)\s(\d+\.\d+)\s([NESW])$/
 +      
 +      ##
 +      # Creates a new LOC::Coord from +arg+ which may be:
 +      #
 +      # LOC::Coord:: returns +arg+.
 +      # String:: +arg+ must match the LOC::Coord::Regex constant
 +      
 +      def self.create(arg)
 +        case arg
 +        when Coord
 +          return arg
 +        when String
 +          coordinates = ''
 +          if Regex =~ arg &&  $1<180
 +            hemi = ($4[/([NE])/,1]) || ($4[/([SW])/,1]) ? 1 : -1
 +            coordinates = [(($1.to_i*(36e5))+($2.to_i*(6e4))+($3.to_f*(1e3)))*hemi+(2**31)].pack("N")
 +            (orientation ||= '') << $4[[/NS/],1] ? 'lat' : 'lon'
 +          else
 +            raise ArgumentError.new("not a properly formed Coord string: " + arg)
 +          end
 +          return Coord.new(coordinates,orientation) 
 +        else
 +          raise ArgumentError.new("cannot interpret as Coord: #{arg.inspect}")
 +        end
 +      end
 +          
 +      def initialize(coordinates,orientation)
 +        unless coordinates.kind_of?(String)
 +          raise ArgumentError.new("Coord must be a 32bit unsigned integer in hex format: #{coordinates.inspect}")
 +        end
 +        unless orientation.kind_of?(String) && orientation[/^lon$|^lat$/] 
 +          raise ArgumentError.new('Coord expects orientation to be a String argument of "lat" or "lon"')
 +        end  
 +        @coordinates = coordinates
 +        @orientation = orientation
 +      end
 +  
 +      ##
 +      # The raw coordinates
 +  
 +      attr_reader :coordinates
 +      
 +      ## The orientation of the hemisphere as 'lat' or 'lon'
 +      
 +      attr_reader :orientation
 +      
 +      def to_s # :nodoc:
 +          c = @coordinates.unpack("N").join.to_i
 +          val      = (c - (2**31)).abs
 +          fracsecs = (val % 1e3).to_i.to_s 
 +          val      = val / 1e3
 +          secs     = (val % 60).to_i.to_s 
 +          val      = val / 60
 +          mins     = (val % 60).to_i.to_s 
 +          degs     = (val / 60).to_i.to_s
 +          posi = (c >= 2**31)
 +          case posi
 +          when true
 +            hemi = @orientation[/^lat$/] ? "N" : "E"
 +          else
 +            hemi = @orientation[/^lon$/] ? "W" : "S"
 +          end
 +          return degs << " " << mins << " " << secs << "." << fracsecs << " " << hemi
 +      end
 +      
 +      def inspect # :nodoc:
 +        return "#<#{self.class} #{self.to_s}>"
 +      end
 +      
 +      def ==(other) # :nodoc:
 +        return @coordinates == other.coordinates
 +      end
 +  
 +      def eql?(other) # :nodoc:
 +        return self == other
 +      end
 +  
 +      def hash # :nodoc:
 +        return @coordinates.hash
 +      end
 +      
 +    end
 +    
 +    ##
 +    # A Resolv::LOC::Alt
 +    
 +    class Alt
 +      
 +      Regex = /^([+-]*\d+\.*\d*)[m]$/
 +      
 +      ##
 +      # Creates a new LOC::Alt from +arg+ which may be:
 +      #
 +      # LOC::Alt:: returns +arg+.
 +      # String:: +arg+ must match the LOC::Alt::Regex constant
 +      
 +      def self.create(arg)
 +        case arg
 +        when Alt
 +          return arg
 +        when String
 +          altitude = ''
 +          if Regex =~ arg
 +            altitude = [($1.to_f*(1e2))+(1e7)].pack("N")
 +          else
 +            raise ArgumentError.new("not a properly formed Alt string: " + arg)
 +          end
 +          return Alt.new(altitude) 
 +        else
 +          raise ArgumentError.new("cannot interpret as Alt: #{arg.inspect}")
 +        end
 +      end
 +      
 +      def initialize(altitude)
 +        @altitude = altitude
 +      end
 +      
 +      ##
 +      # The raw altitude
 +      
 +      attr_reader :altitude
 +      
 +      def to_s # :nodoc:
 +        a = @altitude.unpack("N").join.to_i
 +        return ((a.to_f/1e2)-1e5).to_s + "m"
 +      end
 +      
 +      def inspect # :nodoc:
 +        return "#<#{self.class} #{self.to_s}>"
 +      end
 +      
 +      def ==(other) # :nodoc:
 +        return @altitude == other.altitude
 +      end
 +  
 +      def eql?(other) # :nodoc:
 +        return self == other
 +      end
 +  
 +      def hash # :nodoc:
 +        return @altitude.hash
 +      end
 +      
 +    end
 +  
 +  end
 +
    ##
    # Default resolver to use for Resolv class methods.
=end



-- 
http://bugs.ruby-lang.org/

In This Thread

Prev Next