Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 159 lines (124 sloc) 4.417 kb
41fc7c4 @weppos Remove Echoe dependency
authored
1 require "rubygems"
2 require "rake/testtask"
3 require "rake/gempackagetask"
5a977b4 @weppos Use hanna template if installed
authored
4 begin
5 require "hanna/rdoctask"
6 rescue LoadError
7 require "rake/rdoctask"
8 end
7338571 @weppos Initial commit
authored
9
41fc7c4 @weppos Remove Echoe dependency
authored
10 $:.unshift(File.dirname(__FILE__) + "/lib")
928336d @weppos README updates
authored
11 require "public_suffix_service"
7338571 @weppos Initial commit
authored
12
13
14 # Common package properties
a884054 @weppos Rename library from DomainName to PublicSuffixService to reduce the prob...
authored
15 PKG_NAME = ENV['PKG_NAME'] || PublicSuffixService::GEM
16 PKG_VERSION = ENV['PKG_VERSION'] || PublicSuffixService::VERSION
17 RUBYFORGE_PROJECT = nil
7338571 @weppos Initial commit
authored
18
19 if ENV['SNAPSHOT'].to_i == 1
20 PKG_VERSION << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
21 end
22
23
41fc7c4 @weppos Remove Echoe dependency
authored
24 # Run all the tests in the /test folder
25 Rake::TestTask.new do |t|
26 t.libs << "test"
27 t.test_files = FileList["test/**/*_test.rb"]
28 t.verbose = true
29 end
30
31 # Run test by default.
32 task :default => ["test"]
33
34
35 # This builds the actual gem. For details of what all these options
36 # mean, and other ones you can add, check the documentation here:
37 #
38 # http://rubygems.org/read/chapter/20
39 #
40 spec = Gem::Specification.new do |s|
41
42 s.name = PKG_NAME
43 s.version = PKG_VERSION
44 s.summary = "Domain Name parser based on the Public Suffix List"
45 s.author = "Simone Carletti"
46 s.email = "weppos@weppos.net"
f8c1e12 @weppos http://www.simonecarletti.com/code/public-suffix-service =>
authored
47 s.homepage = "http://www.simonecarletti.com/code/public_suffix_service"
41fc7c4 @weppos Remove Echoe dependency
authored
48 s.description = <<-EOD
d9f6c39 @weppos The library is now known as PublicSuffixList
authored
49 Intelligent domain name parser based in the Public Suffic List. \
50 PublicSuffixService can parse and decompose a domain name into top level domain, \
41fc7c4 @weppos Remove Echoe dependency
authored
51 domain and subdomains.
52 EOD
7338571 @weppos Initial commit
authored
53
41fc7c4 @weppos Remove Echoe dependency
authored
54 s.has_rdoc = true
55 # You should probably have a README of some kind. Change the filename
56 # as appropriate
57 s.extra_rdoc_files = Dir.glob("*.rdoc")
fff4ae6 @weppos Code formatting
authored
58 s.rdoc_options = %w( --main README.rdoc )
7338571 @weppos Initial commit
authored
59
41fc7c4 @weppos Remove Echoe dependency
authored
60 # Add any extra files to include in the gem (like your README)
fff4ae6 @weppos Code formatting
authored
61 s.files = %w( Rakefile ) + Dir.glob("*.{rdoc,gemspec}") + Dir.glob("{test,lib}/**/*")
62 s.require_paths = %w( lib )
41fc7c4 @weppos Remove Echoe dependency
authored
63
64 # If you want to depend on other gems, add them here, along with any
65 # relevant versions
66 # s.add_dependency("some_other_gem", "~> 0.1.0")
67
68 # If your tests use any gems, include them here
0ac5599 @weppos Fixed a but where the RuleList cache is not recreated when a new rule is...
authored
69 s.add_development_dependency("rr")
41fc7c4 @weppos Remove Echoe dependency
authored
70 end
7338571 @weppos Initial commit
authored
71
41fc7c4 @weppos Remove Echoe dependency
authored
72 # This task actually builds the gem. We also regenerate a static
73 # .gemspec file, which is useful if something (i.e. GitHub) will
74 # be automatically building a gem for this project. If you're not
75 # using GitHub, edit as appropriate.
76 Rake::GemPackageTask.new(spec) do |pkg|
77 pkg.gem_spec = spec
7338571 @weppos Initial commit
authored
78 end
79
41fc7c4 @weppos Remove Echoe dependency
authored
80 desc "Build the gemspec file #{spec.name}.gemspec"
81 task :gemspec do
82 file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
83 File.open(file, "w") {|f| f << spec.to_ruby }
84 end
85
cc1b44e @weppos Invalid syntax
authored
86 desc "Remove any temporary products, including gemspec"
41fc7c4 @weppos Remove Echoe dependency
authored
87 task :clean => [:clobber] do
cc72f29 @weppos task :publish_rdoc
authored
88 rm "#{spec.name}.gemspec" if File.file?("#{spec.name}.gemspec")
41fc7c4 @weppos Remove Echoe dependency
authored
89 end
90
91 desc "Remove any generated file"
8103edc @weppos yardoc tasks
authored
92 task :clobber => [:clobber_rdoc, :clobber_package]
41fc7c4 @weppos Remove Echoe dependency
authored
93
94 desc "Package the library and generates the gemspec"
95 task :package => [:gemspec]
96
8103edc @weppos yardoc tasks
authored
97
98 begin
99 require "yard"
100 require "yard/rake/yardoc_task"
101
30a7573 @weppos Output YARD documentation to /yardoc
authored
102 YARD::Rake::YardocTask.new(:yardoc) do |y|
103 y.options = ["--output-dir", "yardoc"]
104 end
8103edc @weppos yardoc tasks
authored
105
106 namespace :yardoc do
107 desc "Publish YARD documentation to the site"
108 task :publish => ["yardoc:clobber", "yardoc"] do
109 ENV["username"] || raise(ArgumentError, "Missing ssh username")
5c93081 @weppos PublicSuffixService.valid? should return false if the domain is not defi...
authored
110 sh "rsync -avz --delete yardoc/ #{ENV["username"]}@code:/var/www/apps/code/#{PKG_NAME}/api"
8103edc @weppos yardoc tasks
authored
111 end
112
113 desc "Remove YARD products"
114 task :clobber do
115 rm_r "yardoc" rescue nil
116 end
117 end
118
119 task :clobber => "yardoc:clobber"
120 rescue LoadError
121 puts "YARD is not available"
122 end
123
124
41fc7c4 @weppos Remove Echoe dependency
authored
125 begin
126 require "rcov/rcovtask"
127
cc1b44e @weppos Invalid syntax
authored
128 desc "Create a code coverage report"
41fc7c4 @weppos Remove Echoe dependency
authored
129 Rcov::RcovTask.new do |t|
130 t.test_files = FileList["test/**/*_test.rb"]
0ac5599 @weppos Fixed a but where the RuleList cache is not recreated when a new rule is...
authored
131 t.ruby_opts << "-Itest -x rr,rcov,Rakefile"
41fc7c4 @weppos Remove Echoe dependency
authored
132 t.verbose = true
133 end
134 rescue LoadError
135 puts "RCov is not available"
136 end
7338571 @weppos Initial commit
authored
137
8103edc @weppos yardoc tasks
authored
138
7338571 @weppos Initial commit
authored
139 desc "Open an irb session preloaded with this library"
140 task :console do
a884054 @weppos Rename library from DomainName to PublicSuffixService to reduce the prob...
authored
141 sh "irb -rubygems -I lib -r public_suffix_service.rb"
7338571 @weppos Initial commit
authored
142 end
143
cc72f29 @weppos task :publish_rdoc
authored
144
e9c8ed5 @weppos Update rake task to download the PSL file from the repository.
authored
145 desc <<-DESC
146 Downloads the Public Suffix List file from the repository \
147 and stores it locally.
148 DESC
149 task :download_definitions do
150 require "net/http"
151
152 DEFINITION_URL = "http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1"
153
154 File.open("lib/public_suffix_service/definitions.dat", "w+") do |f|
155 response = Net::HTTP.get_response(URI.parse(DEFINITION_URL))
156 f.write(response.body)
157 end
7338571 @weppos Initial commit
authored
158 end
Something went wrong with that request. Please try again.