Sha256: 412dd849c37e861af8cd7e64dc78c75d88d6ba85c732c5700156f7f9614e84a5

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require 'fileutils'
require 'alpacabuildtool/tools/tool'

module AlpacaBuildTool
  # tool
  class Nuget < Tool
    def restore(solution_file)
      run_command 'restore', solution_file
    end

    def install(package,
                outputdir = nil,
                prerelease = false,
                exclude_version = false,
                source = nil)
      extra_options = {}
      extra_options['OutputDirectory'] = outputdir if outputdir
      extra_options['Prerelease'] = prerelease if prerelease
      extra_options['ExcludeVersion'] = exclude_version if exclude_version
      extra_options['Source'] = source if source
      run_command 'install', package, extra_options
    end

    def pack(nuspec_or_project, configuration = nil)
      extra_options = {}
      extra_options['Prop'] = "Configuration=#{configuration}" if configuration
      run_command 'pack', nuspec_or_project, extra_options
    end

    def push(package, source)
      run_command 'install', package, 'Source' => source
    end

    private

    def run_command(command, arguments, extra_options = nil)
      options = @configuration['options'] || {}
      options.merge!((@configuration['commands'] || {})[command] || {})
      options.merge! extra_options if extra_options
      output_dir = options['OutputDirectory']
      FileUtils.makedirs output_dir if output_dir
      call([command, arguments, options].flatten)
    end

    def format_option(name, value, switch)
      switch ? "-#{name}" : "-#{name} #{encapsulate(value)}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alpacabuildtool-1.0.0 lib/alpacabuildtool/tools/nuget.rb