forked from aeden/dns-zonefile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
30 lines (26 loc) · 926 Bytes
/
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
require "bundler/gem_tasks"
require 'rake'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => [ :generate_grammar, :spec ]
desc "Regenerate the grammar definition"
task :generate_grammar do
parser_file = 'lib/dns/zonefile/parser.rb'
File.unlink(parser_file) if File.exists?(parser_file)
puts %x[tt doc/zonefile -o #{parser_file}]
source = "require 'treetop'\n\n"
source += "module DNS\n"
source += " module Zonefile\n"
parser_source = File.open(parser_file, 'r').read
parser_source.gsub!(/(\s+)Zonefile$/, '\1ZonefileGrammar # :nodoc:')
parser_source.gsub!(/(\s+)ZonefileParser/, '\1Parser')
source += parser_source.split(/\n/).map { |l| " #{l}".rstrip }.join("\n")
source += "\n end"
source += "\nend"
File.open(parser_file, 'w') do |f|
f.write(source)
end
end
task :build => [ :generate_grammar, :spec ] do
puts %x[gem build dns-zonefile.gemspec]
end