Class: AlpacaBuildTool::Application

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

Overview

Application is a main entry point for CLI

Instance Attribute Summary

Attributes included from Log

#log

Instance Method Summary collapse

Instance Method Details

#compile(pattern, options) ⇒ Object

Compiles solution [s]

pattern

pattern for solutions search

options

hash with compilation options

options[:debug] = true is to compile solution in debug mode
options[:update_version] = true is to update project versions before compiling

app.compile('**/*.sln', debug: true, update_version: true)
# => building found solutions in debug mode
#    with updating project versions

26
27
28
29
30
31
32
# File 'lib/alpacabuildtool/application.rb', line 26

def compile(pattern, options)
  log.header 'Compile'
  each_solution(pattern) do |solution|
    build_manager = BuildManager.new(solution)
    build_manager.build(options[:debug], options[:update_version])
  end
end

#configure_global(properties) ⇒ Object

Update/create *~/.alpaca.conf*

properties

array of properties to store in global configuration

in format node1.node2.property=value

app.configure_global(['hello.world=yay'])
# => produce yaml text in ~/.alpaca.conf:
#    hello:
#      world: yay

157
158
159
160
# File 'lib/alpacabuildtool/application.rb', line 157

def configure_global(properties)
  log.header 'Configure'
  Configuration.set(properties)
end

#configure_local(pattern, properties) ⇒ Object

Update/create *local configuration*

pattern

pattern for solutions search

properties

array of properties to store in global configuration

in format node1.node2.property=value

app.configure_local('**/*.sln', ['hello.world=yay'])
# => produce yaml text in .alpaca.conf for each solution:
#    hello:
#      world: yay

173
174
175
176
177
178
179
# File 'lib/alpacabuildtool/application.rb', line 173

def configure_local(pattern, properties)
  log.header 'Configure'
  Solutions.each(pattern) do |solution|
    log.puts "saving configuration for #{solution.name}"
    Configuration.new(solution).set(properties)
  end
end

#package(pattern, options) ⇒ Object

Create packages for solution [s]

pattern

pattern for solutions search

options

hash with packaging options

options[:debug] = true is to create packages from debug mode<br> options[:push] = true is to push packages after they are created <br> options[:force] = true is to create/push packages even if it has no changes

app.package('**/*.sln')
# => creating only packages with changes in release mode without
#    pushing them

88
89
90
91
92
93
94
95
96
97
# File 'lib/alpacabuildtool/application.rb', line 88

def package(pattern, options)
  log.header 'Package'
  each_solution(pattern) do |solution|
    version = solution.package_version
    package_manager = PackageManager.new(solution)
    (solution.configuration['packages'] || []).each do |package|
      package_manager.create_package(package, version, options)
    end
  end
end

#release(pattern, options) ⇒ Object

Release packages for solution [s]

Updates .semver file to get release version if it is not release yet Rebuilds solution and create release package Changes are checked from last release package

pattern

pattern for solutions search

options

hash with releasing options

options[:push] = true is to push packages after they are created
options[:force] = true is to create/push packages even if it has no changes

app.release('**/*.sln')
# => creating only packages with changes without pushing them

115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/alpacabuildtool/application.rb', line 115

def release(pattern, options)
  log.header 'Release'
  each_solution(pattern) do |solution|
    semver = Versioning.find(solution.dir)
    semver.release if semver.prerelease?
    Versioning.save semver
  end
  compile(pattern, debug: false, update_version: true)
  test(pattern, {})
  options[:debug] = false
  package(pattern, options)
end

#report(pattern, options) ⇒ Object

Convert test results into reports for solution [s]

pattern

pattern for solutions search

options

hash with reporting options

options[:type] = 'all' is to convert 'all' results into reports ('all', 'tests', 'coverage')

app.report('**/*.sln', type: 'coverage')
# => converting coverage results into html reports

66
67
68
69
70
71
72
# File 'lib/alpacabuildtool/application.rb', line 66

def report(pattern, options)
  log.header 'Report'
  each_solution(pattern) do |solution|
    report_manager = ReportManager.new(solution)
    report_manager.convert(options[:type])
  end
end

#test(pattern, options) ⇒ Object

Run tests for solution [s]

pattern

pattern for solutions search

options

hash with testing options

options[:debug] = true is to run tests in debug mode
options[:coverage] = true is to run coverage
options[:type] = 'all' is to run 'all' test types ('all', 'unit', 'service')

app.test('**/*.sln', coverage: true, type: 'unit')
# => running unit tests with coverage

46
47
48
49
50
51
52
53
54
# File 'lib/alpacabuildtool/application.rb', line 46

def test(pattern, options)
  log.header 'Test'
  each_solution(pattern) do |solution|
    test_projects = solution.specific_projects(options[:type])
    next log.info 'no tests discovered' if test_projects.empty?
    test_manager = TestManager.new(solution)
    test_manager.test(test_projects, options[:coverage], options[:debug])
  end
end

#update(pattern, options) ⇒ Object

Update .semver files for solution [s]

pattern

pattern for solutions search

options

hash with releasing options

options['dimension'] = :patch is to update version patch (major, minor, patch, prerelease)

app.update('**/*.sln', 'dimension' => :minor)
# => increase minor version in .semver by 1

138
139
140
141
142
143
144
145
# File 'lib/alpacabuildtool/application.rb', line 138

def update(pattern, options)
  log.header 'Update'
  each_solution(pattern) do |solution|
    semver = Versioning.find(solution.dir)
    semver.increase(options['dimension'].to_sym)
    Versioning.save semver
  end
end