Class: Buildify::AssemblyVersion

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/buildify/assembly_version.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ AssemblyVersion

Returns a new instance of AssemblyVersion.



7
8
9
# File 'lib/buildify/assembly_version.rb', line 7

def initialize(opts = {})
  @options = opts
end

Instance Method Details

#version_assembliesObject



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
# File 'lib/buildify/assembly_version.rb', line 11

def version_assemblies()
  @options[:paths].each do |path|
    if path.include? '.vb'
      File.open(path, 'w') do |f|
        f.puts "Imports System.Reflection"
        f.puts "Imports System.Runtime.InteropServices"
        f.puts "<assembly: AssemblyCompany(\"" + @options[:company_name] + "\")>"
        f.puts "<assembly: AssemblyProduct(\"" + @options[:product_name] + "\")>"
        f.puts "<assembly: AssemblyCopyright(\"Copyright " + Time.now.year.to_s + " " + @options[:company_name] + "\")>"
        f.puts "<assembly: AssemblyVersion(\"" + @options[:version] + "\")>"
        f.puts "<assembly: AssemblyFileVersion(\"" + @options[:version] + "\")>"
      end
    end

    if path.include? '.cs'
      File.open(path, 'w') do |f|
        f.puts "using System.Reflection;"
        f.puts "using System.Runtime.InteropServices;"
        f.puts "[assembly: AssemblyCompany(\"" + @options[:company_name] + "\")]"
        f.puts "[assembly: AssemblyProduct(\"" + @options[:product_name] + "\")]"
        f.puts "[assembly: AssemblyCopyright(\"Copyright " + Time.now.strftime("%Y") + " " + @options[:company_name] + "\")]"
        f.puts "[assembly: AssemblyVersion(\"" + @options[:version] + "\")]"
        f.puts "[assembly: AssemblyFileVersion(\"" + @options[:version] + "\")]"
      end
    end

  end
end