/
Runfile
65 lines (52 loc) · 1.57 KB
/
Runfile
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
63
64
require "runfile-tasks"
require "byebug"
require "lp"
require_relative 'lib/madman'
title "Madman Developer Toolbelt"
summary "Runfile tasks for building the Madman gem"
version Madman::VERSION
RunfileTasks::RubyGems.all 'madman'
RunfileTasks::Testing.rspec
usage_commands = {
'usage' => 'madman',
'render' => 'madman render',
'render-help' => 'madman render --help',
'preview' => 'madman preview',
'preview-help' => 'madman preview --help',
'serve' => 'madman serve',
'serve-help' => 'madman serve --help',
'nav' => 'madman nav',
'nav-help' => 'madman nav --help',
'readme' => 'madman readme',
'readme-help' => 'madman readme --help',
}
help "Run interactive console"
action :console, :c do
run "bundle exec bin/console"
end
help "Generate TOC to toc.txt"
action :toc do
run! 'gh-md-toc README.md > toc.txt'
end
help "Generate changelog"
action :changelog do
run 'github_changelog_generator --cache-file tmp/changlog-cache'
run "git commit -am 'update changelog' && git push"
end
help "Inject usage to README"
action :usage do
doc = Madman::Document.from_file 'README.md'
usage_commands.each do |marker, command|
doc.inject command_output(command), marker: marker
end
doc.save
end
help "Count lines of code"
action :cloc do
run "cloc . --exclude-dir coverage,spec,templates,tmp,dev --exclude-ext yml"
end
def command_output(command)
say "Executing !txtgrn!#{command}"
"\n```\n" + "$ #{command}\n" + `#{command}`.chomp + "\n```\n"
end
require_relative 'debug.rb' if File.exist? 'debug.rb'