Permalink
Browse files

Allow etld_data.rb to be nonexistent for regeneration.

  • Loading branch information...
1 parent 212b08e commit 4df29d276ea0c7ba0b36d71aa8d326f176bea9d5 @knu committed Apr 18, 2013
Showing with 20 additions and 13 deletions.
  1. +20 −13 Rakefile
View
@@ -9,26 +9,25 @@ 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 :import => :etld_data
+#
+# eTLD Database
+#
+
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
- )
+ begin
+ load File.join('.', ETLD_DATA_RB)
+ data = ETLD_DATA_URI.read(
+ 'If-Modified-Since' => Time.parse(DomainName::ETLD_DATA_DATE).rfc2822
+ )
+ rescue LoadError, NameError
+ data = ETLD_DATA_URI.read
+ end
puts 'eTLD database is modified.'
File.write(ETLD_DATA_FILE, data)
File.utime Time.now, data.last_modified, ETLD_DATA_FILE
@@ -42,6 +41,14 @@ task :etld_data do
end
end
+file ETLD_DATA_RB => [
+ ETLD_DATA_FILE,
+ ETLD_DATA_RB + '.erb',
+ 'tool/gen_etld_data.rb'
+] do
+ ruby 'tool/gen_etld_data.rb'
+end
+
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'test'

0 comments on commit 4df29d2

Please sign in to comment.