Rakefile in watir-webdriver-0.7.0 vs Rakefile in watir-webdriver-0.8.0
- old
+ new
@@ -18,76 +18,77 @@
spec.rspec_opts = "--format html --out #{ENV["SPEC_REPORT"] || "specs.html"}"
spec.pattern = 'spec/**/*_spec.rb'
end
end
-task :default => [:spec, 'yard:doctest']
+{
+ html: 'https://www.whatwg.org/specs/web-apps/current-work/',
+ svg: 'http://www.w3.org/TR/SVG2/single-page.html'
+}.each do |type, spec_uri|
+ namespace type do
+ spec_path = "support/#{type}.html"
-namespace :html5 do
- SPEC_URI = "https://www.whatwg.org/specs/web-apps/current-work/"
- SPEC_PATH = "support/html5.html"
+ task generator_lib: :lib do
+ require "watir-webdriver/generator"
+ end
- task :html_lib => :lib do
- require 'watir-webdriver/html'
- end
+ desc "Download #{type.upcase} spec from #{spec_uri}"
+ task :download do
+ require "open-uri"
+ mv spec_path, "#{spec_path}.old" if File.exist?(spec_path)
+ downloaded_bytes = 0
- desc "Download the HTML5 spec from #{SPEC_URI}"
- task :download do
- require "open-uri"
- mv SPEC_PATH, "#{SPEC_PATH}.old" if File.exist?(SPEC_PATH)
- downloaded_bytes = 0
+ File.open(spec_path, "w") do |io|
+ io << "<!-- downloaded from #{spec_uri} on #{Time.now} -->\n"
+ io << data = open(spec_uri).read
+ downloaded_bytes = data.bytesize
+ end
- File.open(SPEC_PATH, "w") do |io|
- io << "<!-- downloaded from #{SPEC_URI} on #{Time.now} -->\n"
- io << data = open(SPEC_URI).read
- downloaded_bytes = data.bytesize
+ puts "#{spec_uri} => #{spec_path} (#{downloaded_bytes} bytes)"
end
- puts "#{SPEC_URI} => #{SPEC_PATH} (#{downloaded_bytes} bytes)"
- end
+ desc "Print IDL parts from #{spec_uri}"
+ task print: :generator_lib do
+ extractor = Watir::Generator.const_get("#{type.upcase}::SpecExtractor").new(spec_path)
- desc "Print IDL parts from #{SPEC_URI}"
- task :print => :html_lib do
- extractor = Watir::HTML::SpecExtractor.new(SPEC_PATH)
+ extractor.process.each do |tag_name, interface_definitions|
+ puts "#{tag_name.ljust(10)} => #{interface_definitions.map(&:name)}"
+ end
- extractor.process.each do |tag_name, interface_definitions|
- puts "#{tag_name.ljust(10)} => #{interface_definitions.map { |e| e.name }}"
- end
+ extractor.print_hierarchy
- extractor.print_hierarchy
-
- unless extractor.errors.empty?
- puts "\n\n<======================= ERRORS =======================>\n\n"
- puts extractor.errors.join("\n" + "="*80 + "\n")
+ if extractor.errors.any?
+ puts "\n\n<======================= ERRORS =======================>\n\n"
+ puts extractor.errors.join("\n" + "=" * 80 + "\n")
+ end
end
- end
- desc 'Re-generate the base Watir element classes from the spec'
- task :generate => :html_lib do
- old_file = "lib/watir-webdriver/elements/generated.rb"
- generator = Watir::HTML::Generator.new
+ desc 'Re-generate the base Watir element classes from the spec'
+ task generate: :generator_lib do
+ old_file = "lib/watir-webdriver/elements/#{type}_elements.rb"
+ generator = Watir::Generator.const_get(type.upcase).new
- File.open("#{old_file}.new", "w") do |file|
- generator.generate(SPEC_PATH, file)
+ File.open("#{old_file}.new", "w") do |file|
+ generator.generate(spec_path, file)
+ end
+
+ if File.exist?(old_file)
+ system "diff -Naut #{old_file} #{old_file}.new | less"
+ end
end
- if File.exist?(old_file)
- system "diff -Naut #{old_file} #{old_file}.new | less"
+ desc "Move #{type}.rb.new to #{type}.rb"
+ task :overwrite do
+ file = "lib/watir-webdriver/elements/#{type}_elements.rb"
+ mv "#{file}.new", file
end
- end
- desc 'Move generated.rb.new to generated.rb'
- task :overwrite do
- file = "lib/watir-webdriver/elements/generated.rb"
- mv "#{file}.new", file
+ desc "download spec -> generate -> #{type}.rb"
+ task update: [:download, :generate, :overwrite]
end
+end
- desc 'download spec -> generate -> generated.rb'
- task :update => [:download, :generate, :overwrite]
-end # html5
-
-
require 'yard'
YARD::Rake::YardocTask.new do |task|
task.options = %w[--debug] # this is pretty slow, so nice with some output
end
@@ -100,21 +101,23 @@
task :differ do
require './support/version_differ'
end
desc 'Update CHANGES.md'
- task :update => :differ do
+ task update: :differ do
VersionDiffer.new.update('CHANGES.md')
end
desc 'Generate CHANGES.md from scratch'
- task :generate => :differ do
+ task generate: :differ do
VersionDiffer.new.generate('CHANGES.md')
end
desc 'Print latest diff'
- task :print => :differ do
+ task print: :differ do
VersionDiffer.new.print_latest(STDOUT)
end
end
load "spec/watirspec/watirspec.rake" if File.exist?("spec/watirspec/watirspec.rake")
+
+task default: [:spec, 'yard:doctest']