Class: AlpacaBuildTool::Project
- Inherits:
-
Object
- Object
- AlpacaBuildTool::Project
- Defined in:
- lib/alpacabuildtool/entities/project.rb
Overview
VisualStudioProject provides project representation and methods to modify it’s AssemblyVersion.cs file
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#file ⇒ Object
Returns the value of attribute file.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(line, dir) ⇒ Project
constructor
Creates instance of class.
-
#to_s ⇒ Object
Overrides to_s method to provide nice convertion to string.
-
#update_version(new_version) ⇒ Object
Updates AssemblyInfo.cs file under the project with new_version.
Constructor Details
#initialize(line, dir) ⇒ Project
Creates instance of class
line-
line from .sln file with project information
dir-
solution directory
s = AlpacaBuildTool::VisualStudioProject.new(
'Project("{FAE04EC0...5254043711}"'
'd:\')
# => #<**:VisualStudioProject:** @file="d:/sln1/some.csproj" **>
18 19 20 21 22 23 24 |
# File 'lib/alpacabuildtool/entities/project.rb', line 18 def initialize(line, dir) items = line.gsub(/".*?"/).to_a _, @name, file, _ = items.map { |item| item.to_s.gsub('"', '') } dir = File.(dir) @dir = File.dirname(File.join(dir, file)) @file = File.join(dir, file) end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
6 7 8 |
# File 'lib/alpacabuildtool/entities/project.rb', line 6 def dir @dir end |
#file ⇒ Object
Returns the value of attribute file.
6 7 8 |
# File 'lib/alpacabuildtool/entities/project.rb', line 6 def file @file end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/alpacabuildtool/entities/project.rb', line 6 def name @name end |
Instance Method Details
#to_s ⇒ Object
Overrides to_s method to provide nice convertion to string
28 29 30 |
# File 'lib/alpacabuildtool/entities/project.rb', line 28 def to_s "{#{@name};#{@file}}" end |
#update_version(new_version) ⇒ Object
Updates AssemblyInfo.cs file under the project with new_version
new_version-
version that need to be used as assembly version
and assembly file version
37 38 39 40 41 42 43 |
# File 'lib/alpacabuildtool/entities/project.rb', line 37 def update_version(new_version) info_file = File.join(@dir, 'Properties', 'AssemblyInfo.cs') content = IO.readlines(info_file) open(info_file, 'w') do |io| content.each { |line| io.write replace_version(line, new_version) } end end |