forked from weppos/publicsuffix-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
101 lines (72 loc) · 2.43 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
require 'rubygems'
require 'bundler'
$:.unshift(File.dirname(__FILE__) + "/lib")
require 'public_suffix'
# Run test by default.
task :default => :test
spec = Gem::Specification.new do |s|
s.name = "public_suffix"
s.version = PublicSuffix::VERSION
s.summary = "Domain name parser based on the Public Suffix List."
s.description = "PublicSuffix can parse and decompose a domain name into top level domain, domain and subdomains."
s.required_ruby_version = ">= 2.0"
s.author = "Simone Carletti"
s.email = "[email protected]"
s.homepage = "http://simonecarletti.com/code/publicsuffix"
s.license = "MIT"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = %w( lib )
s.add_development_dependency("rake")
s.add_development_dependency("mocha")
s.add_development_dependency("yard")
end
require 'rubygems/package_task'
Gem::PackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
desc "Build the gemspec file #{spec.name}.gemspec"
task :gemspec do
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
File.open(file, "w") {|f| f << spec.to_ruby }
end
desc "Remove any temporary products, including gemspec"
task clean: [:clobber] do
rm "#{spec.name}.gemspec" if File.file?("#{spec.name}.gemspec")
end
desc "Remove any generated file"
task clobber: [:clobber_package]
desc "Package the library and generates the gemspec"
task package: [:gemspec]
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.verbose = !!ENV["VERBOSE"]
t.warning = !!ENV["WARNING"]
end
require 'yard'
require 'yard/rake/yardoc_task'
YARD::Rake::YardocTask.new(:yardoc) do |y|
y.options = %w( --output-dir yardoc )
end
namespace :yardoc do
task :clobber do
rm_r "yardoc" rescue nil
end
end
task clobber: "yardoc:clobber"
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -rubygems -I lib -r public_suffix.rb"
end
desc "Downloads the Public Suffix List file from the repository and stores it locally."
task :upddef do
require "net/http"
DEFINITION_URL = "https://publicsuffix.org/list/effective_tld_names.dat"
File.open("data/definitions.txt", "w+") do |f|
response = Net::HTTP.get_response(URI.parse(DEFINITION_URL))
response.body
f.write(response.body)
end
end