forked from grosser/maxitest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
35 lines (29 loc) · 1.1 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
require "bundler/setup"
require "bundler/gem_tasks"
require "bump/tasks"
require "wwtd/tasks"
desc "Run all tests"
task :default do
sh "rspec spec/"
end
desc "Update all dependencies"
task :update do
require "open-uri"
Dir["lib/maxitest/vendor/*"].each do |file|
parts = File.read(file).split(%r{(# https://.*)})
parts = [parts[0].strip] + parts[1..-1].each_slice(2).map do |url, section|
do_not_modify = "generated by rake update, do not modify"
code = open(url.sub("# ", "")).read.gsub(/require .*?\n/, "").strip
code = "=begin\n#{code}\n=end" if url.include?("LICENSE")
if url.include?("testrbl.rb")
# nest under Maxitest to avoid collision
code = "module Maxitest\n#{code.gsub(/^/, " ").gsub(/^\s+$/, "")}\nend"
elsif url.include?("line_plugin.rb")
# replace ruby with mtest
raise unless code.sub!(%{output = "ruby \#{file} -l \#{line}"}, %{output = "mtest \#{file}:\#{line}"})
end
"#{url}\n# BEGIN #{do_not_modify}\n#{code.strip}\n#END #{do_not_modify}"
end
File.write(file, parts.reject(&:empty?).join("\n\n"))
end
end