Class: AlpacaBuildTool::PackageManager

Inherits:
Nuget
  • Object
show all
Defined in:
lib/alpacabuildtool/managers/package_manager.rb

Overview

PackageManager provides package management methods for solution

Constant Summary collapse

DOWNLOAD_DIR =

Defines where packages used by alpaca should be downloaded

File.join(File.expand_path('~'), '.download/')

Instance Attribute Summary

Attributes included from Log

#log

Instance Method Summary collapse

Methods inherited from Nuget

#install, #pack, #push, #restore

Methods inherited from Tool

#call

Constructor Details

#initialize(solution) ⇒ PackageManager

Creates an instance Use Nuget as package management tool

solution

solution to be used to configure build manager and to be

used further


22
23
24
25
# File 'lib/alpacabuildtool/managers/package_manager.rb', line 22

def initialize(solution)
  @solution = solution
  super(@solution.configuration['Nuget'])
end

Instance Method Details

#create_package(config, version, options) ⇒ Object

Create and push if requested nuget package

config

package configuration from solution local configuration

version

package version to be created

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


70
71
72
73
74
75
76
77
78
# File 'lib/alpacabuildtool/managers/package_manager.rb', line 70

def create_package(config, version, options)
  config = generate_config(config, version)
  project = @solution.project(config['project'])
  changes, changelog = package_changes(config, project.dir)
  log.info "#{config['id']} unchanged..." unless changes
  return unless changes || options[:force]
  generate_package(project, config, options[:debug], changelog)
  push_packages(config) if options[:push]
end

#get(name, *args) ⇒ Object

Returns named tool configured from current solution

name

tool name

*args

arguments for tool creation

package_manager.get('NUnit')
# => #<AlpacaBuildTool:NUnit **>
package_manager.get('OpenCover', @test_tool)
# => #<AlpacaBuildTool:OpenCover @tool=..NUnit..**>

37
38
39
40
41
42
43
44
45
46
47
# File 'lib/alpacabuildtool/managers/package_manager.rb', line 37

def get(name, *args)
  config = @solution.configuration[name]
  AlpacaBuildTool.const_get(name).new(config, *args) do
    exe_pattern = File.join(DOWNLOAD_DIR, '**', config['exe'])
    unless Dir.glob(exe_pattern).any?
      id, pre = config['package_id'], config['pre_release'] || false
      install(id, DOWNLOAD_DIR, pre)
    end
    Dir.glob(exe_pattern).first
  end
end

#restore_packagesObject

Restore packages for solution


51
52
53
54
55
56
57
# File 'lib/alpacabuildtool/managers/package_manager.rb', line 51

def restore_packages
  if Dir.glob(File.dirname(@solution.file) + '/**/packages.config').empty?
    log.info 'no packages.config discovered'
    return
  end
  restore(@solution.file)
end