forked from AnthonyDiGirolamo/smithy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
62 lines (53 loc) · 1.5 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'rubygems'
require 'rdoc/task'
require 'rake/clean'
require 'rubygems/package_task'
require 'cucumber'
require 'cucumber/rake/task'
task :default => :features
# Gem building
spec = eval(File.read('smithy.gemspec'))
Gem::PackageTask.new(spec) do |pkg|
end
# Run Cucumber Tests
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format progress -x"
t.fork = false
end
# RDoc Generation
Rake::RDocTask.new do |rd|
rd.main = "smithy.rdoc"
rd.rdoc_files.include("smithy.rdoc","lib/**/*.rb","bin/**/*")
rd.title = 'Smithy'
end
# Helper Tasks
# rake 'generate_markdown[DIR]'
desc "Generate markdown from html file"
task :generate_markdown, [:html_file] do |t, args|
require 'rainbow'
require 'kramdown'
require 'smithy'
include Smithy
#require 'debugger'
description_files = []
description_file = File.expand_path(args[:html_file])
if File.directory?(description_file)
description_files = Dir.glob(description_file+"/*.html")
else
description_files << description_file
end
description_files.each do |description_file|
markdown_file = description_file.gsub(/\.html$/,'') + ".markdown"
notice_command description_file, " -> "+markdown_file
begin
f = File.open description_file
content = f.read
d = File.open(markdown_file, "w+")
k = Kramdown::Document.new(content, :input => 'html')
d.write(k.to_kramdown)
d.close
rescue => exception
raise "#{exception}\nCannot parse #{description_file}"
end
end
end