Class: AlpacaBuildTool::Solution

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/alpacabuildtool/entities/solution.rb

Overview

Solution provides solution representation and it’s configuration storage

Instance Attribute Summary collapse

Attributes included from Log

#log

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Solution

Creates instance from *.sln file Initializes solution’s semantic version and absolute path to it’s file

file

absolute or relative path to *.sln file



19
20
21
22
23
# File 'lib/alpacabuildtool/entities/solution.rb', line 19

def initialize(file)
  @file = File.expand_path(file)
  @dir = File.dirname(@file)
  @semver = Versioning.find(@dir)
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



12
13
14
# File 'lib/alpacabuildtool/entities/solution.rb', line 12

def dir
  @dir
end

#fileObject (readonly)

Returns the value of attribute file.



12
13
14
# File 'lib/alpacabuildtool/entities/solution.rb', line 12

def file
  @file
end

#projectsObject (readonly)

Returns array of it’s projects (initialized only once)



44
45
46
# File 'lib/alpacabuildtool/entities/solution.rb', line 44

def projects
  @projects
end

Instance Method Details

#build_versionObject

Returns current build version



94
95
96
# File 'lib/alpacabuildtool/entities/solution.rb', line 94

def build_version
  @semver.to_s '%M.%m.%p'
end

#configurationObject

Returns Configuration object for current solution (initialized only once)



38
39
40
# File 'lib/alpacabuildtool/entities/solution.rb', line 38

def configuration
  @configuration ||= Configuration.new(self)
end

#no_build?Boolean

Returns true if solution is marked as nobuild

Returns:

  • (Boolean)


84
85
86
87
88
89
90
# File 'lib/alpacabuildtool/entities/solution.rb', line 84

def no_build?
  solution_name = File.basename(@file, '.*')
  (configuration['no_build'] || []).each do |tag|
    return true if solution_name.include?(tag)
  end
  false
end

#package_versionObject

Returns current package version



100
101
102
# File 'lib/alpacabuildtool/entities/solution.rb', line 100

def package_version
  @semver.to_s '%M.%m.%p%s'
end

#project(name) ⇒ Object

Returns specific project by it’s name

name

project’s name



56
57
58
# File 'lib/alpacabuildtool/entities/solution.rb', line 56

def project(name)
  @projects.find { |p| p.name == name }
end

#specific_projects(type) ⇒ Object

Returns array of projects that correspondes to specific type

type

type of project defined in configuration project_types



74
75
76
77
78
79
80
# File 'lib/alpacabuildtool/entities/solution.rb', line 74

def specific_projects(type)
  types = configuration['project_types'].dup
  types.select! { |t| t['type'] == type } unless type == 'all'
  projects.select do |project|
    types.any? { |t| project.name.include? t['name'] }
  end
end

#to_sObject

Overrides string representation. Spawned to multiple lines



27
28
29
30
31
32
33
34
# File 'lib/alpacabuildtool/entities/solution.rb', line 27

def to_s
  s = '------------'
  s += "\nFile: #{@file}"
  s += "\nVersion: #{build_version}"
  s += "\nProjects:" unless projects.empty?
  projects.each { |p| s += "\n\t#{p}" }
  s + "\n------------"
end

#update_projects_version(version) ⇒ Object

Updates all projects AssemblyInfo.cs files with specific version

version

version to be stored in AssemblyInfo.cs files



64
65
66
67
68
# File 'lib/alpacabuildtool/entities/solution.rb', line 64

def update_projects_version(version)
  projects.each do |project|
    project.update_version version
  end
end