<commit_before>require 'fog/core/collection'
require 'fog/rackspace/models/dns/zone'

module Fog
  module DNS
    class Rackspace
      class Zones < Fog::Collection

        model Fog::DNS::Rackspace::Zone

        def all
          clear
          data = service.list_domains.body['domains']
          load(data)
        end
        
        # Returns all domains containing the given substring. Still limited 
        # by the 100-domain pagination limit. Returns an empty array if
        # no matches.
        def find(substring)
          clear
          data = service.list_domains(:name => substring).body['domains']
          load(data)
        end

        def get(zone_id)
          if zone_id.nil? or zone_id.to_s.empty?
            return nil
          end

          data = service.list_domain_details(zone_id).body
          new(data)
        rescue Fog::Rackspace::Errors::NotFound
          nil
        #Accessing a valid (but other customer's) id returns a 503 error
        rescue Fog::Rackspace::Errors::ServiceUnavailable
          nil
        end
      end
    end
  end
end<commit_msg>Add initial support for pulling in >100 zones via Zones.each.<commit_after>require 'fog/core/collection'
require 'fog/rackspace/models/dns/zone'

module Fog
  module DNS
    class Rackspace
      class Zones < Fog::Collection

        model Fog::DNS::Rackspace::Zone

        def all
          clear
          data = service.list_domains.body['domains']
          load(data)
        end
        
        # Returns all domains containing the given substring. Still limited 
        # by the 100-domain pagination limit. Returns an empty array if
        # no matches.
        def find(substring)
          clear
          data = service.list_domains(:name => substring).body['domains']
          load(data)
        end
        
        alias :each_zone_this_page :each
        def each
          if !block_given?
            self
          else
            body = service.list_domains.body
            subset = load(body['domains'])

            subset.each_zone_this_page {|f| yield f}
            while !body['links'].select{|l| l['rel'] == 'next'}.empty?
              url = body['links'].select{|l| l['rel'] == 'next'}.first['href']
              query = url.match(/\?(.+)/)
              parsed = CGI.parse($1)
              
              body = service.list_domains(:offset => parsed['offset'], :limit => parsed['limit']).body
              subset = load(body['domains'])
              subset.each_zone_this_page {|f| yield f}
            end
            self
          end
        end

        def get(zone_id)
          if zone_id.nil? or zone_id.to_s.empty?
            return nil
          end

          data = service.list_domain_details(zone_id).body
          new(data)
        rescue Fog::Rackspace::Errors::NotFound
          nil
        #Accessing a valid (but other customer's) id returns a 503 error
        rescue Fog::Rackspace::Errors::ServiceUnavailable
          nil
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09282422646477946, 'fraction_numerical': 0.005266622778143515, 'mean_word_length': 1.7577132486388385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1065970', 'n_tokens_mistral': 880, 'n_tokens_neox': 838, 'n_words': 222}