Skip to content
Newer
Older
100644 154 lines (125 sloc) 4.38 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 p…
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 # Generate documentation
32 Rake::RDocTask.new do |rd|
33 rd.main = "README.rdoc"
34 rd.rdoc_files.include("*.rdoc", "lib/**/*.rb")
35 rd.rdoc_dir = "rdoc"
36 end
37
38 # Run test by default.
39 task :default => ["test"]
40
41
42 # This builds the actual gem. For details of what all these options
43 # mean, and other ones you can add, check the documentation here:
44 #
45 # http://rubygems.org/read/chapter/20
46 #
47 spec = Gem::Specification.new do |s|
48
49 s.name = PKG_NAME
50 s.version = PKG_VERSION
51 s.summary = "Domain Name parser based on the Public Suffix List"
52 s.author = "Simone Carletti"
53 s.email = "weppos@weppos.net"
f8c1e12 @weppos http://www.simonecarletti.com/code/public-suffix-service =>
authored
54 s.homepage = "http://www.simonecarletti.com/code/public_suffix_service"
41fc7c4 @weppos Remove Echoe dependency
authored
55 s.description = <<-EOD
d9f6c39 @weppos The library is now known as PublicSuffixList
authored
56 Intelligent domain name parser based in the Public Suffic List. \
57 PublicSuffixService can parse and decompose a domain name into top level domain, \
41fc7c4 @weppos Remove Echoe dependency
authored
58 domain and subdomains.
59 EOD
7338571 @weppos Initial commit
authored
60
41fc7c4 @weppos Remove Echoe dependency
authored
61 s.has_rdoc = true
62 # You should probably have a README of some kind. Change the filename
63 # as appropriate
64 s.extra_rdoc_files = Dir.glob("*.rdoc")
65 s.rdoc_options = %w(--main README.rdoc)
7338571 @weppos Initial commit
authored
66
41fc7c4 @weppos Remove Echoe dependency
authored
67 # Add any extra files to include in the gem (like your README)
86465bb @weppos Missing details for the new Rakefile
authored
68 s.files = %w(Rakefile) + Dir.glob("*.{rdoc,gemspec}") + Dir.glob("{test,lib}/**/*")
41fc7c4 @weppos Remove Echoe dependency
authored
69 s.require_paths = ["lib"]
70
71 # If you want to depend on other gems, add them here, along with any
72 # relevant versions
73 # s.add_dependency("some_other_gem", "~> 0.1.0")
74
75 # If your tests use any gems, include them here
86465bb @weppos Missing details for the new Rakefile
authored
76 s.add_development_dependency("mocha")
41fc7c4 @weppos Remove Echoe dependency
authored
77 end
7338571 @weppos Initial commit
authored
78
41fc7c4 @weppos Remove Echoe dependency
authored
79 # This task actually builds the gem. We also regenerate a static
80 # .gemspec file, which is useful if something (i.e. GitHub) will
81 # be automatically building a gem for this project. If you're not
82 # using GitHub, edit as appropriate.
83 Rake::GemPackageTask.new(spec) do |pkg|
84 pkg.gem_spec = spec
7338571 @weppos Initial commit
authored
85 end
86
41fc7c4 @weppos Remove Echoe dependency
authored
87 desc "Build the gemspec file #{spec.name}.gemspec"
88 task :gemspec do
89 file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
90 File.open(file, "w") {|f| f << spec.to_ruby }
91 end
92
cc1b44e @weppos Invalid syntax
authored
93 desc "Remove any temporary products, including gemspec"
41fc7c4 @weppos Remove Echoe dependency
authored
94 task :clean => [:clobber] do
cc72f29 @weppos task :publish_rdoc
authored
95 rm "#{spec.name}.gemspec" if File.file?("#{spec.name}.gemspec")
41fc7c4 @weppos Remove Echoe dependency
authored
96 end
97
98 desc "Remove any generated file"
99 task :clobber => [:clobber_rdoc, :clobber_rcov, :clobber_package]
100
101 desc "Package the library and generates the gemspec"
102 task :package => [:gemspec]
103
104 begin
105 require "rcov/rcovtask"
106
cc1b44e @weppos Invalid syntax
authored
107 desc "Create a code coverage report"
41fc7c4 @weppos Remove Echoe dependency
authored
108 Rcov::RcovTask.new do |t|
109 t.test_files = FileList["test/**/*_test.rb"]
110 t.ruby_opts << "-Itest -x mocha,rcov,Rakefile"
111 t.verbose = true
112 end
113 rescue LoadError
114 task :clobber_rcov
115 puts "RCov is not available"
116 end
7338571 @weppos Initial commit
authored
117
118 desc "Open an irb session preloaded with this library"
119 task :console do
a884054 @weppos Rename library from DomainName to PublicSuffixService to reduce the p…
authored
120 sh "irb -rubygems -I lib -r public_suffix_service.rb"
7338571 @weppos Initial commit
authored
121 end
122
123 begin
cc1b44e @weppos Invalid syntax
authored
124 require "code_statistics"
7338571 @weppos Initial commit
authored
125 desc "Show library's code statistics"
126 task :stats do
a884054 @weppos Rename library from DomainName to PublicSuffixService to reduce the p…
authored
127 CodeStatistics.new(["Public Suffix Service", "lib"],
7338571 @weppos Initial commit
authored
128 ["Tests", "test"]).to_s
129 end
130 rescue LoadError
131 puts "CodeStatistics (Rails) is not available"
132 end
133
cc72f29 @weppos task :publish_rdoc
authored
134 desc "Publish documentation to the site"
de64b38 @weppos task :publish_rdoc should only :clobber_rdoc
authored
135 task :publish_rdoc => [:clobber_rdoc, :rdoc] do
cc72f29 @weppos task :publish_rdoc
authored
136 ENV["username"] || raise(ArgumentError, "Missing ssh username")
cc1b44e @weppos Invalid syntax
authored
137 sh "rsync -avz --delete rdoc/ #{ENV["username"]}@code:/var/www/apps/code/#{PKG_NAME}/api"
cc72f29 @weppos task :publish_rdoc
authored
138 end
139
e9c8ed5 @weppos Update rake task to download the PSL file from the repository.
authored
140 desc <<-DESC
141 Downloads the Public Suffix List file from the repository \
142 and stores it locally.
143 DESC
144 task :download_definitions do
145 require "net/http"
146
147 DEFINITION_URL = "http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1"
148
149 File.open("lib/public_suffix_service/definitions.dat", "w+") do |f|
150 response = Net::HTTP.get_response(URI.parse(DEFINITION_URL))
151 f.write(response.body)
152 end
7338571 @weppos Initial commit
authored
153 end
Something went wrong with that request. Please try again.