mirror of https://github.com/AMT-Cheif/Stylet.git
Update Rakefile to generate StyletIoC.cs from all of its composite files
This commit is contained in:
parent
d69507b7be
commit
1b03f1e7ad
38
Rakefile
38
Rakefile
|
@ -98,30 +98,44 @@ end
|
||||||
|
|
||||||
desc "Extract StyletIoC as a standalone file"
|
desc "Extract StyletIoC as a standalone file"
|
||||||
task :"extract-stylet-ioc" do
|
task :"extract-stylet-ioc" do
|
||||||
files = Dir['Stylet/StyletIoC/*.cs']
|
filenames = Dir['Stylet/StyletIoC/**/*.cs']
|
||||||
usings = Set.new
|
usings = Set.new
|
||||||
merged_contents = ""
|
files = []
|
||||||
|
|
||||||
files.each do |file|
|
filenames.each do |file|
|
||||||
contents = File.read(file)
|
contents = File.read(file)
|
||||||
file_usings = contents.scan(/using .*?;$/)
|
file_usings = contents.scan(/using .*?;$/)
|
||||||
usings.merge(file_usings)
|
usings.merge(file_usings)
|
||||||
|
|
||||||
file_contents = contents[/namespace .+?{\n(.+)}.*/m, 1]
|
matches = contents.match(/namespace (.+?)\n{\n(.+)}.*/m)
|
||||||
merged_contents << " // Originally from #{file}\n\n" << file_contents << "\n"
|
namespace, file_contents = matches.captures
|
||||||
|
|
||||||
|
files << {
|
||||||
|
:from => file,
|
||||||
|
:contents => file_contents,
|
||||||
|
:namespace => namespace
|
||||||
|
}
|
||||||
|
# merged_contents << " // Originally from #{file}\n\n" << file_contents << "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
File.open('StyletIoC.cs', 'w') do |outf|
|
File.open('StyletIoC.cs', 'w') do |outf|
|
||||||
outf.write(usings.to_a.join("\n"))
|
outf.write(usings.reject{ |x| x.start_with?('using StyletIoC') }.join("\n"))
|
||||||
|
|
||||||
outf.puts("\n\n")
|
outf.puts
|
||||||
|
|
||||||
outf.puts("namespace StyletIoC")
|
files.group_by{ |x| x[:namespace ] }.each do |namespace, ns_files|
|
||||||
outf.puts("{")
|
outf.puts("\nnamespace #{namespace}")
|
||||||
outf.puts(merged_contents)
|
outf.puts("{")
|
||||||
outf.puts("}")
|
|
||||||
|
ns_files.each do |file|
|
||||||
|
outf.puts("\n // Originally from #{file[:from]}\n\n")
|
||||||
|
outf.puts(file[:contents])
|
||||||
|
end
|
||||||
|
|
||||||
|
outf.puts("}\n")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# puts merged_contents
|
# puts merged_contents
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue