forked from archoncap2/redis-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
51 lines (39 loc) · 883 Bytes
/
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
task :default => [:parse]
task :parse do
require "json"
require "batch"
Dir["**/*.json"].each do |file|
JSON.parse(File.read(file))
end
end
namespace :format do
def format(file)
require "./remarkdown"
return unless File.exist?(file)
STDOUT.print "formatting #{file}..."
STDOUT.flush
body = File.read(file)
body = ReMarkdown.new(body).to_s
body = body.gsub(/^\s+$/, "")
File.open(file, "w") do |f|
f.print body
end
STDOUT.puts
end
desc "Reformat single file"
task :file, :path do |t, args|
format(args[:path])
end
desc "Reformat changes staged for commit"
task :cached do
`git diff --cached --name-only -- commands/`.split.each do |path|
format(path)
end
end
desc "Reformat everything"
task :all do
Dir["commands/*.md"].each do |path|
format(path)
end
end
end