Module: NugetHelper

Defined in:
lib/nuget_helper.rb,
lib/nuget_helper/version.rb

Constant Summary collapse

VERSION =
"0.0.8"

Class Method Summary collapse

Class Method Details

.command_path(library, exe) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/nuget_helper.rb', line 28

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



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

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



69
70
71
72
73
# File 'lib/nuget_helper.rb', line 69

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

.mspec_clr4_pathObject



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

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

.mspec_pathObject



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

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

.nunit_pathObject



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

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

.osObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nuget_helper.rb', line 4

def self.os
  @os ||= (
    host_os = RbConfig::CONFIG['host_os']
    case host_os
    when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
      :windows
    when /darwin|mac os/
      :macosx
    when /linux/
      :linux
    when /solaris|bsd/
      :unix
    else
      raise "unknown os: #{host_os.inspect}"
    end
  )
end

.run_tool(command, parameters = nil) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/nuget_helper.rb', line 56

def self.run_tool(command, parameters=nil)
  parameters = '' if parameters.nil?
  if self.os == :windows
    system "#{command} #{parameters}"
  else
    system "mono --runtime=v4.0 #{command} #{parameters} "
  end
end

.version_of(file) ⇒ Object



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

def self.version_of(file)
  file.gsub(/[a-zA-Z]\.?/,'').split(/\./).map do |i| i.to_i end
end

.xunit_pathObject



40
41
42
43
44
45
46
# File 'lib/nuget_helper.rb', line 40

def self.xunit_path
  old_xunit = self.first_command_path('xunit.runners', 'xunit.console.exe')
  if not old_xunit.nil?
    return old_xunit
  end
  return self.command_path('xunit.runner.console', 'xunit.console.exe')
end