Class: IronHammer::Hammer

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_hammer/hammer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Hammer

Returns a new instance of Hammer.



11
12
13
14
15
16
# File 'lib/iron_hammer/hammer.rb', line 11

def initialize params={}
  @configuration  = params[:configuration] || IronHammer::Defaults::CONFIGURATION_RUN
  @dot_net_environment = IronHammer::Utils::DotNetEnvironment.new params.merge(
    :framework_path => params[:dot_net_path])
  @code_analyzers_environment = CodeAnalyzersEnvironment.new params
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



9
10
11
# File 'lib/iron_hammer/hammer.rb', line 9

def configuration
  @configuration
end

#dot_net_environmentObject

Returns the value of attribute dot_net_environment.



8
9
10
# File 'lib/iron_hammer/hammer.rb', line 8

def dot_net_environment
  @dot_net_environment
end

Instance Method Details

#analyze(*projects) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/iron_hammer/hammer.rb', line 48

def analyze *projects
  return if projects.nil? || projects.empty?
  fxcop = @code_analyzers_environment.fxcop
  rules = @code_analyzers_environment.fxcop_rules
  binaries = projects.collect do |project|
    project.artifacts.map {|artifact| "/file:#{File.join(project.path_to_binaries, artifact)}"}
  end.flatten
  results = @code_analyzers_environment.fxcop_result
  "\"#{fxcop}\" /rule:\"#{rules}\" /out:\"#{results}\" #{binaries.join ' '}"
end

#build(solution) ⇒ Object



29
30
31
32
33
# File 'lib/iron_hammer/hammer.rb', line 29

def build solution
  configuration = @configuration
  solution      = solution.solution
  msbuild "/p:Configuration=#{configuration} #{solution} /t:Rebuild"
end

#detailsObject



18
19
20
21
22
# File 'lib/iron_hammer/hammer.rb', line 18

def details
  ['duration', 'errorstacktrace', 'errormessage', 'outcometext'].inject('') do |buffer, detail|
    buffer << "/detail:#{detail} "
  end
end

#msbuild(args) ⇒ Object



24
25
26
27
# File 'lib/iron_hammer/hammer.rb', line 24

def msbuild args
  msbuild       = @dot_net_environment.msbuild
  "#{msbuild} #{args}"
end

#test(*projects) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/iron_hammer/hammer.rb', line 35

def test *projects
  return if projects.nil? || projects.empty?
  parent_dir = File.join(projects.first.path || '.', '..')
  config = ['LocalTestRun', 'TestRunConfig'].find do |config_name|
    File.exists?(File.join(parent_dir, "#{config_name}.testrunconfig"))
  end
  runconfig = "/runconfig:#{config}.testrunconfig " if config
  containers = projects.collect{|project| "/testcontainer:#{project.container @configuration}"}
  results   = projects.first.results_file
  mstest    = @dot_net_environment.mstest
  "#{mstest} #{runconfig || ''}#{containers.join ' '} /resultsfile:#{results} #{details}"
end