lib/tasks/publish.rake in daddy-0.1.17 vs lib/tasks/publish.rake in daddy-0.1.18
- old
+ new
@@ -40,28 +40,41 @@
system("cp -Rf coverage #{base_dir}/#{branch}/")
end
# 開発日記を統合
if branch == 'master'
- features = []
- features += dad_publish_extract_features(base_dir + '/master')
-
- Dir[base_dir + '/p*'].sort{|a, b| File.basename(b)[1..-1].to_i <=> File.basename(a)[1..-1].to_i}.each do |dir|
- features += dad_publish_extract_features(dir)
+ features = {}
+ dad_publish_sprint_dirs(base_dir).each do |dir|
+ dad_publish_extract_features(dir).each do |div|
+ feature = features[div['id']]
+ if feature
+ div.css('div.scenario').each do |scenario|
+ feature.add_child(scenario)
+ end
+ else
+ features[div['id']] = div
+ end
+ end
end
# 空HTMLを生成
system("bundle exec rake dad:cucumber PUBLISH=true EXPAND=false COVERAGE=false features/support")
doc = Nokogiri::HTML(File.read('features/reports/index.html'))
contents_div = doc.css('div.contents').first
- features.sort{|a, b| a['id'] <=> b['id']}.each do |div|
- contents_div.add_child(div)
+ features.keys.sort.each do |key|
+ contents_div.add_child(features[key])
end
File.write("#{base_dir}/index.html", doc)
end
end
+end
+
+def self.dad_publish_sprint_dirs(base_dir)
+ ret = Dir[base_dir + '/p*'].sort{|a, b| File.basename(a)[1..-1].to_i <=> File.basename(b)[1..-1].to_i}
+ ret << base_dir + '/master'
+ ret
end
def self.dad_publish_extract_features(dir)
ret = []
return [] unless File.exist?(dir) and File.directory?(dir)