/tools/Rake/assemblyinfo.rb

http://github.com/agross/netopenspace · Ruby · 30 lines · 23 code · 7 blank · 0 comment · 0 complexity · 7ef50587acd19316152ff72ba9443ddc MD5 · raw file

  1. require 'rake'
  2. require 'erb'
  3. class AssemblyInfoBuilder
  4. attr_reader :attributes
  5. def initialize(attributes)
  6. @attributes = attributes;
  7. end
  8. def write(file)
  9. template = %q{
  10. using System;
  11. using System.Reflection;
  12. using System.Runtime.InteropServices;
  13. <% @attributes.each do |key, value| %>
  14. [assembly: <%= key %>("<%= value %>")]
  15. <% end %>
  16. }.gsub(/^\s+/, '')
  17. erb = ERB.new(template, 0, "%<>")
  18. File.open(file, 'w') do |f|
  19. f.puts erb.result(binding)
  20. end
  21. puts "Created file #{file}"
  22. end
  23. end