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
|
# File 'lib/approvals/cli.rb', line 9
def verify
approvals = File.read('.approvals').split("\n")
rejected = []
approvals.each do |approval|
approved, received = approval.split(/\s+/)
if received.include?(".approved.")
received, approved = approved, received
end
diff_command = "#{options[:diff]} #{approved} #{received}"
puts diff_command
system(diff_command)
if options[:ask] && yes?("Approve? [y/N] ")
system("mv #{received} #{approved}")
else
rejected << approval
end
end
File.open('.approvals', 'w') do |f|
f.write rejected.join("\n")
end
end
|