Sha256: d543f8c7563821cd405d1063e3b6eae4e538a1f9d24924bfe29ed1e31d736b72

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

require 'bundler/gem_tasks'
require 'uri'

ETLD_DATA_URI  = URI('http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1')
ETLD_DATA_FILE = 'data/effective_tld_names.dat'
ETLD_DATA_RB   = 'lib/domain_name/etld_data.rb'

task :default => :test

task :test => ETLD_DATA_RB

file ETLD_DATA_RB => [
  ETLD_DATA_FILE,
  ETLD_DATA_RB + '.erb',
  'tool/gen_etld_data.rb'
] do
  ruby 'tool/gen_etld_data.rb'
end

task :etld_data do
  require 'open-uri'
  require 'time'

  begin
    load File.join('.', ETLD_DATA_RB)

    data = ETLD_DATA_URI.read(
      'If-Modified-Since' => Time.parse(DomainName::ETLD_DATA_DATE).rfc2822
    )
    puts 'eTLD database is modified.'
    File.write(ETLD_DATA_FILE, data)
    File.utime Time.now, data.last_modified, ETLD_DATA_FILE
    Rake::Task[ETLD_DATA_RB].execute
  rescue OpenURI::HTTPError => e
    if e.io.status.first == '304' # Not Modified
      puts 'eTLD database is up-to-date.'
    else
      raise
    end
  end
end

require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
  test.libs << 'test'
  test.pattern = 'test/**/test_*.rb'
  test.verbose = true
end

require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
  version = DomainName::VERSION

  rdoc.rdoc_dir = 'rdoc'
  rdoc.title = "domain_name #{version}"
  rdoc.rdoc_files.include('lib/**/*.rb')
  rdoc.rdoc_files.include(Bundler::GemHelper.gemspec.extra_rdoc_files)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
domain_name-0.5.10 Rakefile
domain_name-0.5.9 Rakefile