Class: Albacore::NugetsPack::NuspecTask
- Inherits:
-
Object
- Object
- Albacore::NugetsPack::NuspecTask
- Includes:
- Logging
- Defined in:
- lib/albacore/task_types/nugets_pack.rb
Overview
generate a nuget from a nuspec
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(command_line, config, nuspec) ⇒ NuspecTask
constructor
A new instance of NuspecTask.
- #read_version_from_nuspec ⇒ Object
Methods included from Logging
#debug, #err, #error, #fatal, #info, #puts, #trace, #warn
Constructor Details
#initialize(command_line, config, nuspec) ⇒ NuspecTask
Returns a new instance of NuspecTask.
404 405 406 407 408 409 |
# File 'lib/albacore/task_types/nugets_pack.rb', line 404 def initialize command_line, config, nuspec @config = config @nuspec = nuspec # is a NuspecPack::Cmd @command_line = command_line end |
Class Method Details
.accept?(file) ⇒ Boolean
440 441 442 |
# File 'lib/albacore/task_types/nugets_pack.rb', line 440 def self.accept? file File.extname(file).downcase == '.nuspec' end |
Instance Method Details
#execute ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/albacore/task_types/nugets_pack.rb', line 425 def execute version = read_version_from_nuspec filename = File.basename(@nuspec, File.extname(@nuspec)) @command_line.execute @nuspec path = File.join(@config.opts.get(:out), "#{filename}.#{version}.nupkg") Albacore.publish :artifact, OpenStruct.new( :nuspec => @nuspec, :nupkg => path, :location => path ) end |
#read_version_from_nuspec ⇒ Object
411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/albacore/task_types/nugets_pack.rb', line 411 def read_version_from_nuspec begin nuspec_file = File.open(@nuspec) xml = Nokogiri::XML(nuspec_file) nuspec_file.close nodes = xml.xpath('.//metadata/version') raise "No <version/> found" if nodes.empty? nodes.first.text() rescue => error err "Error reading package version from file: #{error}" raise end end |