Module: NugetHelper

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.0"

Class Method Summary collapse

Class Method Details

.command_path(library, exe) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/nuget_helper.rb', line 13

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



7
8
9
10
11
# File 'lib/nuget_helper.rb', line 7

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



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

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

.mspec_clr4_pathObject



41
42
43
# File 'lib/nuget_helper.rb', line 41

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

.mspec_pathObject



37
38
39
# File 'lib/nuget_helper.rb', line 37

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

.nspec_pathObject



45
46
47
# File 'lib/nuget_helper.rb', line 45

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

.nunit_pathObject



21
22
23
# File 'lib/nuget_helper.rb', line 21

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

.run_tool(command, parameters = nil) ⇒ Object



49
50
51
# File 'lib/nuget_helper.rb', line 49

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

.run_tool_with_result(command, parameters = nil) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/nuget_helper.rb', line 53

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

.version_of(file) ⇒ Object



61
62
63
# File 'lib/nuget_helper.rb', line 61

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

.xunit2_pathObject



33
34
35
# File 'lib/nuget_helper.rb', line 33

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

.xunit_clr4_pathObject



25
26
27
# File 'lib/nuget_helper.rb', line 25

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

.xunit_pathObject



29
30
31
# File 'lib/nuget_helper.rb', line 29

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