Created
March 5, 2012 13:18
-
-
Save tychobrailleur/1978277 to your computer and use it in GitHub Desktop.
Extract cucumber-jvm mappings from stepdefs ("already implemented stepdefs") and prints them in alphabetical order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
mappings = [] | |
features = File.join("**", "*.java") | |
current_dir = ARGV[0] | |
Dir.chdir(current_dir) | |
Dir.glob(features).each do |file_name| | |
puts "Processing #{file_name}" if $DEBUG | |
File.open(file_name).each do |line| | |
mapping = line.scan(/@(When|Then|And|Given)\("\^?(.+?)\$?"\)/) | |
mappings << mapping[0][1] if not mapping.empty? | |
end | |
end | |
@mappings = mappings.map{ |m| m.capitalize }.sort | |
simple_template =<<TEMPLATE | |
<html> | |
<body> | |
<% for @mapping in @mappings %> | |
<p><%= @mapping %></p> | |
<% end %> | |
</body> | |
</html> | |
TEMPLATE | |
output_file = File.join(File.dirname(__FILE__), "mappings.html") | |
renderer = ERB.new(simple_template) | |
File.open(output_file, "w") { |f| f.write(renderer.result()) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment