geoip 0.8.1 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +1 -18
- data/{README.txt → README.rdoc} +12 -10
- data/Rakefile +22 -3
- data/lib/geoip.rb +43 -7
- data/test/test_helper.rb +1 -0
- metadata +16 -30
- data/License.txt +0 -16
- data/config/hoe.rb +0 -71
- data/config/requirements.rb +0 -17
- data/lib/geoip/version.rb +0 -9
- data/log/debug.log +0 -0
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -74
- data/website/index.txt +0 -45
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
    
        data/Manifest.txt
    CHANGED
    
    | @@ -1,24 +1,7 @@ | |
| 1 1 | 
             
            History.txt
         | 
| 2 | 
            -
            License.txt
         | 
| 3 2 | 
             
            Manifest.txt
         | 
| 4 | 
            -
            README. | 
| 3 | 
            +
            README.rdoc
         | 
| 5 4 | 
             
            Rakefile
         | 
| 6 | 
            -
            config/hoe.rb
         | 
| 7 | 
            -
            config/requirements.rb
         | 
| 8 5 | 
             
            lib/geoip.rb
         | 
| 9 | 
            -
            lib/geoip/version.rb
         | 
| 10 | 
            -
            log/debug.log
         | 
| 11 | 
            -
            script/destroy
         | 
| 12 | 
            -
            script/generate
         | 
| 13 | 
            -
            script/txt2html
         | 
| 14 | 
            -
            setup.rb
         | 
| 15 | 
            -
            tasks/deployment.rake
         | 
| 16 | 
            -
            tasks/environment.rake
         | 
| 17 | 
            -
            tasks/website.rake
         | 
| 18 6 | 
             
            test/test_geoip.rb
         | 
| 19 7 | 
             
            test/test_helper.rb
         | 
| 20 | 
            -
            website/index.html
         | 
| 21 | 
            -
            website/index.txt
         | 
| 22 | 
            -
            website/javascripts/rounded_corners_lite.inc.js
         | 
| 23 | 
            -
            website/stylesheets/screen.css
         | 
| 24 | 
            -
            website/template.rhtml
         | 
    
        data/{README.txt → README.rdoc}
    RENAMED
    
    | @@ -1,6 +1,6 @@ | |
| 1 | 
            -
            =  | 
| 1 | 
            +
            = geoip
         | 
| 2 2 |  | 
| 3 | 
            -
            http:// | 
| 3 | 
            +
            * http://github.com/cjheath/geoip
         | 
| 4 4 |  | 
| 5 5 | 
             
            == DESCRIPTION:
         | 
| 6 6 |  | 
| @@ -10,20 +10,24 @@ and the city, ISP and other information, if you have that database version. | |
| 10 10 |  | 
| 11 11 | 
             
            == FEATURES/PROBLEMS:
         | 
| 12 12 |  | 
| 13 | 
            -
            This release  | 
| 14 | 
            -
            prevent GeoIP blowing up under multi-threaded usage.
         | 
| 13 | 
            +
            This release adds support for ASN data files, thanks to Roland Matiz
         | 
| 15 14 |  | 
| 16 15 | 
             
            == SYNOPSIS:
         | 
| 17 16 |  | 
| 18 | 
            -
            require 'geoip'
         | 
| 19 | 
            -
            GeoIP.new('GeoIP.dat').country("www.netscape.sk")
         | 
| 20 | 
            -
            => ["www.netscape.sk", "217.67.16.35", 196, "SK", "SVK", "Slovakia", "EU"]
         | 
| 17 | 
            +
              require 'geoip'
         | 
| 18 | 
            +
              GeoIP.new('GeoIP.dat').country("www.netscape.sk")
         | 
| 19 | 
            +
              => ["www.netscape.sk", "217.67.16.35", 196, "SK", "SVK", "Slovakia", "EU"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              GeoIP.new('GeoIPASNum.dat').asn("www.fsb.ru")
         | 
| 22 | 
            +
              => ["AS8342", "RTComm.RU Autonomous System"]
         | 
| 21 23 |  | 
| 22 24 | 
             
            == REQUIREMENTS:
         | 
| 23 25 |  | 
| 24 26 | 
             
            You need at least the free GeoIP.dat, for which the last known download
         | 
| 25 27 | 
             
            location is <http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz>,
         | 
| 26 28 | 
             
            or the city database from <http://www.maxmind.com/app/geolitecity>.
         | 
| 29 | 
            +
            The ASN database location is
         | 
| 30 | 
            +
            <http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz>.
         | 
| 27 31 |  | 
| 28 32 | 
             
            This API requires the file to be decompressed for searching. Other versions
         | 
| 29 33 | 
             
            of this database are available for purchase which contain more detailed
         | 
| @@ -38,7 +42,7 @@ sudo gem install geoip | |
| 38 42 |  | 
| 39 43 | 
             
            (The MIT License)
         | 
| 40 44 |  | 
| 41 | 
            -
            Copyright (c)  | 
| 45 | 
            +
            Copyright (c) 2009 Clifford Heath
         | 
| 42 46 |  | 
| 43 47 | 
             
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 44 48 | 
             
            a copy of this software and associated documentation files (the
         | 
| @@ -58,5 +62,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
| 58 62 | 
             
            CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
         | 
| 59 63 | 
             
            TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
         | 
| 60 64 | 
             
            SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 61 | 
            -
             | 
| 62 | 
            -
            ==
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,4 +1,23 @@ | |
| 1 | 
            -
            require ' | 
| 2 | 
            -
             | 
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            gem 'hoe', '>= 2.1.0'
         | 
| 3 | 
            +
            require 'hoe'
         | 
| 4 | 
            +
            require 'fileutils'
         | 
| 5 | 
            +
            require './lib/geoip'
         | 
| 3 6 |  | 
| 4 | 
            -
             | 
| 7 | 
            +
            Hoe.plugin :newgem
         | 
| 8 | 
            +
            Hoe.plugin :website
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Generate all the Rake tasks
         | 
| 11 | 
            +
            # Run 'rake -T' to see list of generated tasks (from gem root directory)
         | 
| 12 | 
            +
            $hoe = Hoe.spec 'geoip' do
         | 
| 13 | 
            +
              self.developer 'Clifford Heath', 'clifford.heath@gmail.com'
         | 
| 14 | 
            +
              self.developer 'Roland Moriz', 'rmoriz@gmail.com'
         | 
| 15 | 
            +
              self.rubyforge_name       = self.name # TODO this is default value
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            require 'newgem/tasks'
         | 
| 19 | 
            +
            Dir['tasks/**/*.rake'].each { |t| load t }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            # TODO - want other tests/tasks run by default? Add them to the list
         | 
| 22 | 
            +
            # remove_task :default
         | 
| 23 | 
            +
            # task :default => [:spec, :features]
         | 
    
        data/lib/geoip.rb
    CHANGED
    
    | @@ -42,10 +42,10 @@ $:.unshift File.dirname(__FILE__) | |
| 42 42 | 
             
            #
         | 
| 43 43 | 
             
            #=end
         | 
| 44 44 | 
             
            require 'thread'  # Needed for Mutex
         | 
| 45 | 
            -
             | 
| 46 45 | 
             
            require 'socket'
         | 
| 47 46 |  | 
| 48 47 | 
             
            class GeoIP
         | 
| 48 | 
            +
                VERSION = "0.8.4"
         | 
| 49 49 | 
             
                private
         | 
| 50 50 | 
             
                CountryCode = [
         | 
| 51 51 | 
             
                    "--","AP","EU","AD","AE","AF","AG","AI","AL","AM","AN",
         | 
| @@ -411,6 +411,7 @@ class GeoIP | |
| 411 411 | 
             
                STRUCTURE_INFO_MAX_SIZE = 20
         | 
| 412 412 | 
             
                DATABASE_INFO_MAX_SIZE = 100
         | 
| 413 413 | 
             
                MAX_ORG_RECORD_LENGTH = 300
         | 
| 414 | 
            +
                MAX_ASN_RECORD_LENGTH = 300 # unverified
         | 
| 414 415 | 
             
                US_OFFSET = 1
         | 
| 415 416 | 
             
                CANADA_OFFSET = 677
         | 
| 416 417 | 
             
                WORLD_OFFSET = 1353
         | 
| @@ -436,7 +437,7 @@ class GeoIP | |
| 436 437 | 
             
                    @file.seek(-3, IO::SEEK_END)
         | 
| 437 438 | 
             
                    0.upto(STRUCTURE_INFO_MAX_SIZE-1) { |i|
         | 
| 438 439 | 
             
                        if @file.read(3) == "\xFF\xFF\xFF"
         | 
| 439 | 
            -
                            @databaseType = @file.getc
         | 
| 440 | 
            +
                            @databaseType = @file.respond_to?(:getbyte) ? @file.getbyte : @file.getc
         | 
| 440 441 | 
             
                            @databaseType -= 105 if @databaseType >= 106
         | 
| 441 442 |  | 
| 442 443 | 
             
                            if (@databaseType == GEOIP_REGION_EDITION_REV0)
         | 
| @@ -473,11 +474,6 @@ class GeoIP | |
| 473 474 | 
             
                    end
         | 
| 474 475 | 
             
                end
         | 
| 475 476 |  | 
| 476 | 
            -
                # Close the file handle for the GeoIP data file.
         | 
| 477 | 
            -
                def close
         | 
| 478 | 
            -
                  @file.close
         | 
| 479 | 
            -
                end
         | 
| 480 | 
            -
             | 
| 481 477 | 
             
                # Search the GeoIP database for the specified host, returning country info
         | 
| 482 478 | 
             
                #
         | 
| 483 479 | 
             
                # +hostname+ is a String holding the host's DNS name or numeric IP address.
         | 
| @@ -500,6 +496,7 @@ class GeoIP | |
| 500 496 | 
             
                    if ip.kind_of?(String) && ip !~ /^[0-9.]*$/
         | 
| 501 497 | 
             
                        # Lookup IP address, we were given a name
         | 
| 502 498 | 
             
                        ip = IPSocket.getaddress(hostname)
         | 
| 499 | 
            +
                        ip = '0.0.0.0' if ip == '::1'
         | 
| 503 500 | 
             
                    end
         | 
| 504 501 |  | 
| 505 502 | 
             
                    # Convert numeric IP address to an integer
         | 
| @@ -541,6 +538,7 @@ class GeoIP | |
| 541 538 |  | 
| 542 539 | 
             
                    # The country code is the first byte:
         | 
| 543 540 | 
             
                    code = record[0]
         | 
| 541 | 
            +
                    code = code.ord if code.respond_to?(:ord)
         | 
| 544 542 | 
             
                    record = record[1..-1]
         | 
| 545 543 | 
             
                    @iter_pos += 1 unless @iter_pos.nil?
         | 
| 546 544 |  | 
| @@ -625,6 +623,7 @@ class GeoIP | |
| 625 623 | 
             
                    if ip.kind_of?(String) && ip !~ /^[0-9.]*$/
         | 
| 626 624 | 
             
                        # Lookup IP address, we were given a name
         | 
| 627 625 | 
             
                        ip = IPSocket.getaddress(hostname)
         | 
| 626 | 
            +
                        ip = '0.0.0.0' if ip == '::1'
         | 
| 628 627 | 
             
                    end
         | 
| 629 628 |  | 
| 630 629 | 
             
                    # Convert numeric IP address to an integer
         | 
| @@ -647,6 +646,7 @@ class GeoIP | |
| 647 646 | 
             
                    if ip.kind_of?(String) && ip !~ /^[0-9.]*$/
         | 
| 648 647 | 
             
                        # Lookup IP address, we were given a name
         | 
| 649 648 | 
             
                        ip = IPSocket.getaddress(hostname)
         | 
| 649 | 
            +
                        ip = '0.0.0.0' if ip == '::1'
         | 
| 650 650 | 
             
                    end
         | 
| 651 651 |  | 
| 652 652 | 
             
                    # Convert numeric IP address to an integer
         | 
| @@ -663,6 +663,41 @@ class GeoIP | |
| 663 663 | 
             
                    record = record.sub(/\000.*/, '')
         | 
| 664 664 | 
             
                    record
         | 
| 665 665 | 
             
                end
         | 
| 666 | 
            +
                
         | 
| 667 | 
            +
                # Search a ASN GeoIP database for the specified host, returning the AS number + description
         | 
| 668 | 
            +
                #
         | 
| 669 | 
            +
                # +hostname+ is a String holding the host's DNS name or numeric IP address.
         | 
| 670 | 
            +
                # Return the AS number + description
         | 
| 671 | 
            +
                #
         | 
| 672 | 
            +
                # Source:
         | 
| 673 | 
            +
                # http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
         | 
| 674 | 
            +
                #   
         | 
| 675 | 
            +
                def asn(hostname)
         | 
| 676 | 
            +
                    ip = hostname
         | 
| 677 | 
            +
                    if ip.kind_of?(String) && ip !~ /^[0-9.]*$/
         | 
| 678 | 
            +
                        # Lookup IP address, we were given a name
         | 
| 679 | 
            +
                        ip = IPSocket.getaddress(hostname)
         | 
| 680 | 
            +
                        ip = '0.0.0.0' if ip == '::1'
         | 
| 681 | 
            +
                    end
         | 
| 682 | 
            +
             | 
| 683 | 
            +
                    # Convert numeric IP address to an integer
         | 
| 684 | 
            +
                    ipnum = iptonum(ip)
         | 
| 685 | 
            +
                    if (@databaseType != GEOIP_ASNUM_EDITION)
         | 
| 686 | 
            +
                        throw "Invalid GeoIP database type, can't look up ASN by IP"
         | 
| 687 | 
            +
                    end
         | 
| 688 | 
            +
                    pos = seek_record(ipnum);
         | 
| 689 | 
            +
                    record = ""
         | 
| 690 | 
            +
                    @mutex.synchronize {
         | 
| 691 | 
            +
                      @file.seek(pos + (2*@record_length-1) * @databaseSegments[0])
         | 
| 692 | 
            +
                      record = @file.read(MAX_ASN_RECORD_LENGTH)
         | 
| 693 | 
            +
                    }
         | 
| 694 | 
            +
                    record = record.sub(/\000.*/, '')
         | 
| 695 | 
            +
                    
         | 
| 696 | 
            +
                    if record =~ /^(AS\d+)\s(.*)$/
         | 
| 697 | 
            +
                      # AS####, Description 
         | 
| 698 | 
            +
                      return [$1, $2]
         | 
| 699 | 
            +
                    end
         | 
| 700 | 
            +
                end
         | 
| 666 701 |  | 
| 667 702 | 
             
                # Search a ISP GeoIP database for the specified host, returning the organization
         | 
| 668 703 | 
             
                #
         | 
| @@ -689,6 +724,7 @@ class GeoIP | |
| 689 724 | 
             
                end
         | 
| 690 725 |  | 
| 691 726 | 
             
                private
         | 
| 727 | 
            +
                  
         | 
| 692 728 | 
             
                def iptonum(ip)     # Convert numeric IP address to integer
         | 
| 693 729 | 
             
                    if ip.kind_of?(String) &&
         | 
| 694 730 | 
             
                        ip =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,16 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: geoip
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.8. | 
| 4 | 
            +
              version: 0.8.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Clifford Heath
         | 
| 8 | 
            +
            - Roland Moriz
         | 
| 8 9 | 
             
            autorequire: 
         | 
| 9 10 | 
             
            bindir: bin
         | 
| 10 11 | 
             
            cert_chain: []
         | 
| 11 12 |  | 
| 12 | 
            -
            date: 2009- | 
| 13 | 
            +
            date: 2009-09-04 00:00:00 +10:00
         | 
| 13 14 | 
             
            default_executable: 
         | 
| 14 15 | 
             
            dependencies: 
         | 
| 15 16 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -20,53 +21,38 @@ dependencies: | |
| 20 21 | 
             
                requirements: 
         | 
| 21 22 | 
             
                - - ">="
         | 
| 22 23 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 23 | 
            -
                    version:  | 
| 24 | 
            +
                    version: 2.3.2
         | 
| 24 25 | 
             
                version: 
         | 
| 25 | 
            -
            description:  | 
| 26 | 
            -
             | 
| 26 | 
            +
            description: |-
         | 
| 27 | 
            +
              GeoIP searches a GeoIP database for a given host or IP address, and
         | 
| 28 | 
            +
              returns information about the country where the IP address is allocated,
         | 
| 29 | 
            +
              and the city, ISP and other information, if you have that database version.
         | 
| 30 | 
            +
            email: 
         | 
| 31 | 
            +
            - clifford.heath@gmail.com
         | 
| 32 | 
            +
            - rmoriz@gmail.com
         | 
| 27 33 | 
             
            executables: []
         | 
| 28 34 |  | 
| 29 35 | 
             
            extensions: []
         | 
| 30 36 |  | 
| 31 37 | 
             
            extra_rdoc_files: 
         | 
| 32 38 | 
             
            - History.txt
         | 
| 33 | 
            -
            - License.txt
         | 
| 34 39 | 
             
            - Manifest.txt
         | 
| 35 | 
            -
            - README.txt
         | 
| 36 | 
            -
            - website/index.txt
         | 
| 37 40 | 
             
            files: 
         | 
| 38 41 | 
             
            - History.txt
         | 
| 39 | 
            -
            - License.txt
         | 
| 40 42 | 
             
            - Manifest.txt
         | 
| 41 | 
            -
            - README. | 
| 43 | 
            +
            - README.rdoc
         | 
| 42 44 | 
             
            - Rakefile
         | 
| 43 | 
            -
            - config/hoe.rb
         | 
| 44 | 
            -
            - config/requirements.rb
         | 
| 45 45 | 
             
            - lib/geoip.rb
         | 
| 46 | 
            -
            - lib/geoip/version.rb
         | 
| 47 | 
            -
            - log/debug.log
         | 
| 48 | 
            -
            - script/destroy
         | 
| 49 | 
            -
            - script/generate
         | 
| 50 | 
            -
            - script/txt2html
         | 
| 51 | 
            -
            - setup.rb
         | 
| 52 | 
            -
            - tasks/deployment.rake
         | 
| 53 | 
            -
            - tasks/environment.rake
         | 
| 54 | 
            -
            - tasks/website.rake
         | 
| 55 46 | 
             
            - test/test_geoip.rb
         | 
| 56 47 | 
             
            - test/test_helper.rb
         | 
| 57 | 
            -
            - website/index.html
         | 
| 58 | 
            -
            - website/index.txt
         | 
| 59 | 
            -
            - website/javascripts/rounded_corners_lite.inc.js
         | 
| 60 | 
            -
            - website/stylesheets/screen.css
         | 
| 61 | 
            -
            - website/template.rhtml
         | 
| 62 48 | 
             
            has_rdoc: true
         | 
| 63 | 
            -
            homepage: http://geoip | 
| 49 | 
            +
            homepage: http://github.com/cjheath/geoip
         | 
| 64 50 | 
             
            licenses: []
         | 
| 65 51 |  | 
| 66 52 | 
             
            post_install_message: 
         | 
| 67 53 | 
             
            rdoc_options: 
         | 
| 68 54 | 
             
            - --main
         | 
| 69 | 
            -
            - README. | 
| 55 | 
            +
            - README.rdoc
         | 
| 70 56 | 
             
            require_paths: 
         | 
| 71 57 | 
             
            - lib
         | 
| 72 58 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| @@ -84,10 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 84 70 | 
             
            requirements: []
         | 
| 85 71 |  | 
| 86 72 | 
             
            rubyforge_project: geoip
         | 
| 87 | 
            -
            rubygems_version: 1.3. | 
| 73 | 
            +
            rubygems_version: 1.3.5
         | 
| 88 74 | 
             
            signing_key: 
         | 
| 89 75 | 
             
            specification_version: 3
         | 
| 90 | 
            -
            summary:  | 
| 76 | 
            +
            summary: GeoIP searches a GeoIP database for a given host or IP address, and returns information about the country where the IP address is allocated, and the city, ISP and other information, if you have that database version.
         | 
| 91 77 | 
             
            test_files: 
         | 
| 92 78 | 
             
            - test/test_geoip.rb
         | 
| 93 79 | 
             
            - test/test_helper.rb
         | 
    
        data/License.txt
    DELETED
    
    | @@ -1,16 +0,0 @@ | |
| 1 | 
            -
            This version Copyright (C) 2005-2007 Clifford Heath
         | 
| 2 | 
            -
            Derived from the C version, Copyright (C) 2003 MaxMind LLC
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            This library is free software; you can redistribute it and/or
         | 
| 5 | 
            -
            modify it under the terms of the GNU General Public
         | 
| 6 | 
            -
            License as published by the Free Software Foundation; either
         | 
| 7 | 
            -
            version 2.1 of the License, or (at your option) any later version.
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            This library is distributed in the hope that it will be useful,
         | 
| 10 | 
            -
            but WITHOUT ANY WARRANTY; without even the implied warranty of
         | 
| 11 | 
            -
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
         | 
| 12 | 
            -
            General Public License for more details.
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            You should have received a copy of the GNU General Public
         | 
| 15 | 
            -
            License along with this library; if not, write to the Free Software
         | 
| 16 | 
            -
            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
         | 
    
        data/config/hoe.rb
    DELETED
    
    | @@ -1,71 +0,0 @@ | |
| 1 | 
            -
            require 'geoip/version'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            AUTHOR = 'Clifford Heath'  # can also be an array of Authors
         | 
| 4 | 
            -
            EMAIL = "cjheath@rubyforge.org"
         | 
| 5 | 
            -
            DESCRIPTION = "description of gem"
         | 
| 6 | 
            -
            GEM_NAME = 'geoip' # what ppl will type to install your gem
         | 
| 7 | 
            -
            RUBYFORGE_PROJECT = 'geoip' # The unix name for your project
         | 
| 8 | 
            -
            HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
         | 
| 9 | 
            -
            DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            @config_file = "~/.rubyforge/user-config.yml"
         | 
| 12 | 
            -
            @config = nil
         | 
| 13 | 
            -
            RUBYFORGE_USERNAME = "unknown"
         | 
| 14 | 
            -
            def rubyforge_username
         | 
| 15 | 
            -
              unless @config
         | 
| 16 | 
            -
                begin
         | 
| 17 | 
            -
                  @config = YAML.load(File.read(File.expand_path(@config_file)))
         | 
| 18 | 
            -
                rescue
         | 
| 19 | 
            -
                  puts <<-EOS
         | 
| 20 | 
            -
            ERROR: No rubyforge config file found: #{@config_file}
         | 
| 21 | 
            -
            Run 'rubyforge setup' to prepare your env for access to Rubyforge
         | 
| 22 | 
            -
             - See http://newgem.rubyforge.org/rubyforge.html for more details
         | 
| 23 | 
            -
                  EOS
         | 
| 24 | 
            -
                  exit
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
              RUBYFORGE_USERNAME.replace @config["username"]
         | 
| 28 | 
            -
            end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
            REV = nil 
         | 
| 32 | 
            -
            # UNCOMMENT IF REQUIRED: 
         | 
| 33 | 
            -
            # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
         | 
| 34 | 
            -
            VERS = Geoip::VERSION::STRING + (REV ? ".#{REV}" : "")
         | 
| 35 | 
            -
            RDOC_OPTS = ['--quiet', '--title', 'geoip documentation',
         | 
| 36 | 
            -
                "--opname", "index.html",
         | 
| 37 | 
            -
                "--line-numbers", 
         | 
| 38 | 
            -
                "--main", "README",
         | 
| 39 | 
            -
                "--inline-source"]
         | 
| 40 | 
            -
             | 
| 41 | 
            -
            class Hoe
         | 
| 42 | 
            -
              def extra_deps 
         | 
| 43 | 
            -
                @extra_deps.reject! { |x| Array(x).first == 'hoe' } 
         | 
| 44 | 
            -
                @extra_deps
         | 
| 45 | 
            -
              end 
         | 
| 46 | 
            -
            end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
            # Generate all the Rake tasks
         | 
| 49 | 
            -
            # Run 'rake -T' to see list of generated tasks (from gem root directory)
         | 
| 50 | 
            -
            hoe = Hoe.new(GEM_NAME, VERS) do |p|
         | 
| 51 | 
            -
              p.author = AUTHOR 
         | 
| 52 | 
            -
              p.description = DESCRIPTION
         | 
| 53 | 
            -
              p.email = EMAIL
         | 
| 54 | 
            -
              p.summary = DESCRIPTION
         | 
| 55 | 
            -
              p.url = HOMEPATH
         | 
| 56 | 
            -
              p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
         | 
| 57 | 
            -
              p.test_globs = ["test/**/test_*.rb"]
         | 
| 58 | 
            -
              p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']  #An array of file patterns to delete on clean.
         | 
| 59 | 
            -
              
         | 
| 60 | 
            -
              # == Optional
         | 
| 61 | 
            -
              p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
         | 
| 62 | 
            -
              #p.extra_deps = []     # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
         | 
| 63 | 
            -
              
         | 
| 64 | 
            -
              #p.spec_extras = {}    # A hash of extra values to set in the gemspec.
         | 
| 65 | 
            -
              
         | 
| 66 | 
            -
            end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
            CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
         | 
| 69 | 
            -
            PATH    = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
         | 
| 70 | 
            -
            hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
         | 
| 71 | 
            -
            hoe.rsync_args = '-av --delete --ignore-errors'
         | 
    
        data/config/requirements.rb
    DELETED
    
    | @@ -1,17 +0,0 @@ | |
| 1 | 
            -
            require 'fileutils'
         | 
| 2 | 
            -
            include FileUtils
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            %w[rake hoe newgem rubigen].each do |req_gem|
         | 
| 6 | 
            -
              begin
         | 
| 7 | 
            -
                require req_gem
         | 
| 8 | 
            -
              rescue LoadError
         | 
| 9 | 
            -
                puts "This Rakefile requires the '#{req_gem}' RubyGem."
         | 
| 10 | 
            -
                puts "Installation: gem install #{req_gem} -y"
         | 
| 11 | 
            -
                exit
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
            end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            require 'geoip'
         |