Class: IronHammer::Projects::AssemblyInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_hammer/projects/assembly_info.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ AssemblyInfo

Returns a new instance of AssemblyInfo.



6
7
8
# File 'lib/iron_hammer/projects/assembly_info.rb', line 6

def initialize filename
  @filename = filename
end

Instance Method Details

#versionObject



10
11
12
13
# File 'lib/iron_hammer/projects/assembly_info.rb', line 10

def version
  matches = file.match /^\[assembly: AssemblyVersion\("(.*)"\)\]$/
  matches[1] if matches
end

#version=(new_version) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/iron_hammer/projects/assembly_info.rb', line 15

def version= new_version
  content = file
  File.open(@filename, 'w') do |f|
    content.each_line do |line|
      line.gsub!(/^(\[assembly: Assembly(File)?Version\(").*("\)\])$/) do |match|
        "#{$1}#{new_version}#{$3}"
      end
      f << line
    end
  end
end