Module: NugetHelper

Includes:
XSemVer
Defined in:
lib/nuget_helper.rb,
lib/nuget_helper/nuspec.rb,
lib/nuget_helper/version.rb

Defined Under Namespace

Classes: NuSpec

Constant Summary collapse

VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.command_path(library, exe) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/nuget_helper.rb', line 15

def self.command_path(library, exe)
  cmd = self.first_command_path(library, exe)
  if cmd.nil?
    raise "Could not find #{exe} at the packages/#{library}*/tools/ path!"
  end
  return cmd
end

.exec(parameters) ⇒ Object



9
10
11
12
13
# File 'lib/nuget_helper.rb', line 9

def self.exec(parameters)
  spec = Gem::Specification.find_by_name("nuget")
  command = File.join(spec.gem_dir, "bin", "nuget.exe")
  self.run_tool(command, parameters)
end

.last_version(files) ⇒ Object



71
72
73
74
75
# File 'lib/nuget_helper.rb', line 71

def self.last_version(files)
  files.max_by do |l|
    self.version_of(l)
  end
end

.mspec_clr4_pathObject



43
44
45
# File 'lib/nuget_helper.rb', line 43

def self.mspec_clr4_path
  self.command_path('Machine.Specifications', 'mspec-clr4.exe')
end

.mspec_pathObject



39
40
41
# File 'lib/nuget_helper.rb', line 39

def self.mspec_path
  self.command_path('Machine.Specifications', 'mspec.exe')
end

.nspec_pathObject



47
48
49
# File 'lib/nuget_helper.rb', line 47

def self.nspec_path
  self.command_path('nspec', 'NSpecRunner.exe')
end

.nunit_pathObject



23
24
25
# File 'lib/nuget_helper.rb', line 23

def self.nunit_path
  self.command_path('NUnit.Runners', 'nunit-console.exe')
end

.run_tool(command, parameters = nil) ⇒ Object



55
56
57
# File 'lib/nuget_helper.rb', line 55

def self.run_tool(command, parameters=nil)
  system( to_shell_string( command, parameters))
end

.run_tool_with_result(command, parameters = nil) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/nuget_helper.rb', line 59

def self.run_tool_with_result(command, parameters=nil)
  stdout_str, stderr_str, status= Open3.capture3( to_shell_string( command, parameters))
  if ! status.success? 
    raise stderr_str
  end
  stdout_str
end

.semver_fromassembly_pathObject



51
52
53
# File 'lib/nuget_helper.rb', line 51

def self.semver_fromassembly_path
  self.command_path('SemVer.FromAssembly', 'SemVer.FromAssembly.exe')
end

.version_of(file) ⇒ Object



67
68
69
# File 'lib/nuget_helper.rb', line 67

def self.version_of(file)
  SemVer.parse(file.gsub(/\.nupkg$/, ''))
end

.xunit2_pathObject



35
36
37
# File 'lib/nuget_helper.rb', line 35

def self.xunit2_path
  self.command_path('xunit.runner.console', 'xunit.console.exe')
end

.xunit_clr4_pathObject



27
28
29
# File 'lib/nuget_helper.rb', line 27

def self.xunit_clr4_path
  self.command_path('xunit.runners', 'xunit.console.clr4.exe')
end

.xunit_pathObject



31
32
33
# File 'lib/nuget_helper.rb', line 31

def self.xunit_path
  self.command_path('xunit.runners', 'xunit.console.exe')
end