iron_hammer 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/iron_hammer.rb +1 -0
- data/lib/iron_hammer/hammer.rb +10 -0
- data/lib/iron_hammer/projects/dependency.rb +13 -1
- data/lib/iron_hammer/projects/test_project.rb +5 -7
- data/lib/iron_hammer/tasks.rb +27 -11
- data/lib/iron_hammer/utils/code_analyzers_environment.rb +34 -0
- data/lib/iron_hammer/utils/ivy_builder.rb +5 -3
- metadata +2 -1
data/Rakefile
CHANGED
data/lib/iron_hammer.rb
CHANGED
@@ -31,6 +31,7 @@ require 'iron_hammer/projects/project_types'
|
|
31
31
|
require 'iron_hammer/projects/test_project'
|
32
32
|
require 'iron_hammer/solutions/solution'
|
33
33
|
require 'iron_hammer/solutions/solution_file'
|
34
|
+
require 'iron_hammer/utils/code_analyzers_environment'
|
34
35
|
require 'iron_hammer/utils/dot_net_environment'
|
35
36
|
require 'iron_hammer/utils/file_system'
|
36
37
|
require 'iron_hammer/utils/ivy_builder'
|
data/lib/iron_hammer/hammer.rb
CHANGED
@@ -12,6 +12,7 @@ module IronHammer
|
|
12
12
|
@configuration = params[:configuration] || IronHammer::Defaults::CONFIGURATION_RUN
|
13
13
|
@dot_net_environment = IronHammer::Utils::DotNetEnvironment.new params.merge(
|
14
14
|
:framework_path => params[:dot_net_path])
|
15
|
+
@code_analyzers_environment = CodeAnalyzersEnvironment.new params
|
15
16
|
end
|
16
17
|
|
17
18
|
def details
|
@@ -37,6 +38,15 @@ module IronHammer
|
|
37
38
|
"#{mstest} #{runconfig || ''}#{containers.join ' '} /resultsfile:#{results} #{details}"
|
38
39
|
end
|
39
40
|
|
41
|
+
def analyze *projects
|
42
|
+
return if projects.nil? || projects.empty?
|
43
|
+
fxcop = @code_analyzers_environment.fxcop
|
44
|
+
rules = @code_analyzers_environment.fxcop_rules
|
45
|
+
binaries = projects.collect {|project| "/file:#{project.path_to_binaries}"}
|
46
|
+
results = @code_analyzers_environment.fxcop_result
|
47
|
+
"\"#{fxcop}\" /rule:\"#{rules}\" /out:\"#{results}\" #{binaries.join ' '}"
|
48
|
+
end
|
49
|
+
|
40
50
|
end unless defined? Hammer
|
41
51
|
end
|
42
52
|
|
@@ -3,10 +3,12 @@ module IronHammer
|
|
3
3
|
class Dependency
|
4
4
|
attr_accessor :name
|
5
5
|
attr_accessor :version
|
6
|
+
attr_accessor :extension
|
6
7
|
|
7
8
|
def initialize params = {}
|
8
9
|
@name = params[:name] || raise(ArgumentError.new('you must specify a name'))
|
9
10
|
@version = params[:version]
|
11
|
+
@extension = params[:extension] || 'dll'
|
10
12
|
end
|
11
13
|
|
12
14
|
def == other
|
@@ -22,7 +24,17 @@ module IronHammer
|
|
22
24
|
name = includes.split(', ')[0]
|
23
25
|
match = includes.match /Version=(.+?),/
|
24
26
|
version = match[1] if match
|
25
|
-
|
27
|
+
extension = get_extension reference
|
28
|
+
Dependency.new :name => name, :version => version, :extension => extension
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def self.get_extension reference
|
33
|
+
hint_path = reference.elements["HintPath"]
|
34
|
+
return hint_path.text.split(/\./).last if hint_path
|
35
|
+
|
36
|
+
executable_extension = reference.elements["ExecutableExtension"]
|
37
|
+
executable_extension.text.gsub(/\./, '') if executable_extension
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
@@ -5,21 +5,19 @@ module IronHammer
|
|
5
5
|
module Projects
|
6
6
|
class TestProject < GenericProject
|
7
7
|
attr_accessor :config
|
8
|
-
attr_accessor :dll
|
9
|
-
attr_accessor :name
|
10
|
-
attr_accessor :path
|
11
8
|
|
12
9
|
def initialize params = {}
|
13
10
|
params[:name] ||= "#{ params[:project] || params[:solution] }.Tests"
|
14
|
-
@
|
15
|
-
@dll = "#{ params[:dll] || @name}.dll"
|
11
|
+
@dll = "#{params[:dll]}.dll" if params[:dll]
|
16
12
|
@config = params[:config] || IronHammer::Defaults::TEST_CONFIG
|
17
|
-
@path = params[:path]
|
18
13
|
super(params)
|
19
14
|
end
|
20
15
|
|
16
|
+
def dll
|
17
|
+
@dll ||= "#{assembly_name}.dll"
|
18
|
+
end
|
21
19
|
def container configuration
|
22
|
-
[@
|
20
|
+
[@path, 'bin', configuration, dll].patheticalize
|
23
21
|
end
|
24
22
|
|
25
23
|
def results_file
|
data/lib/iron_hammer/tasks.rb
CHANGED
@@ -5,34 +5,49 @@ require 'iron_hammer'
|
|
5
5
|
CLEAN.include("TestResults/**")
|
6
6
|
CLEAN.include("ivy*.xml")
|
7
7
|
|
8
|
+
|
8
9
|
namespace :iron do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
@anvil = Anvil.load_from '.'
|
11
|
+
@hammer = Hammer.new(
|
12
|
+
(defined?(VISUAL_STUDIO_PATH) ? {:visual_studio_path => VISUAL_STUDIO_PATH} : {}).merge(
|
13
|
+
:configuration => ENV['Configuration']
|
14
|
+
))
|
15
|
+
FileUtils.mkdir 'TestResults' unless (File.exists?('TestResults') && File.directory?('TestResults'))
|
16
|
+
|
17
|
+
desc 'Executes the default lifecycle'
|
18
|
+
task :default => [:clean, "ivy:retrieve", :build, "test:unit", "ivy:publish"]
|
14
19
|
|
15
20
|
desc 'Builds the solution'
|
16
|
-
task :build => [:clean
|
21
|
+
task :build => [:clean] do
|
17
22
|
sh @hammer.build @anvil.solution
|
18
23
|
end
|
19
24
|
|
20
25
|
namespace :test do
|
21
26
|
desc 'Runs the unit tests'
|
22
27
|
task :unit => [:build] do
|
23
|
-
|
28
|
+
command = @hammer.test *@anvil.test_projects
|
29
|
+
puts "There are no tests to run" unless command
|
30
|
+
sh command if command
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :analyze do
|
35
|
+
desc 'Analyze the code using fxcop'
|
36
|
+
task :fxcop do
|
37
|
+
sh @hammer.analyze *@anvil.projects do |ok, response|
|
38
|
+
puts response
|
39
|
+
end
|
24
40
|
end
|
25
41
|
end
|
26
42
|
|
27
43
|
namespace :ivy do
|
28
44
|
desc 'Publish project dependencies into ivy repository'
|
29
|
-
task :setup do
|
30
|
-
@anvil = Anvil.load_from '.'
|
45
|
+
task :setup, [:binaries_path] do |t, args|
|
31
46
|
@anvil.projects.each do |project|
|
32
47
|
project.dependencies.each do |dependency|
|
33
48
|
dependency_project = DependencyProject.new(
|
34
49
|
:name => dependency.name,
|
35
|
-
:binaries_path =>
|
50
|
+
:binaries_path => args.binaries_path,
|
36
51
|
:version => dependency.version)
|
37
52
|
|
38
53
|
puts "Dependency #{dependency.name}"
|
@@ -47,7 +62,8 @@ namespace :iron do
|
|
47
62
|
end
|
48
63
|
|
49
64
|
desc 'Generates ivy-<project_name>.xml for all projects of the solution'
|
50
|
-
task :generate
|
65
|
+
task :generate do
|
66
|
+
puts "Generating ivy files for projects"
|
51
67
|
@anvil.projects.each do |project|
|
52
68
|
builder = IvyBuilder.new project
|
53
69
|
builder.write_to "ivy-#{project.name}.xml"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'iron_hammer/utils/windows'
|
2
|
+
|
3
|
+
module IronHammer
|
4
|
+
module Utils
|
5
|
+
class CodeAnalyzersEnvironment
|
6
|
+
attr_accessor :fxcop_path
|
7
|
+
|
8
|
+
def initialize params={}
|
9
|
+
@fxcop_path = params[:fxcop_path] || default_fxcop_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def fxcop
|
13
|
+
[@fxcop_path, 'fxcopcmd.exe'].patheticalize
|
14
|
+
end
|
15
|
+
|
16
|
+
def fxcop_rules
|
17
|
+
[@fxcop_path, 'Rules'].patheticalize
|
18
|
+
end
|
19
|
+
|
20
|
+
def fxcop_result
|
21
|
+
"fxcop-result.xml"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def default_fxcop_path
|
26
|
+
[
|
27
|
+
ENV['ProgramFiles'] || IronHammer::Defaults::PROGRAM_FILES,
|
28
|
+
'Microsoft FxCop 1.35'
|
29
|
+
].patheticalize
|
30
|
+
end
|
31
|
+
end unless defined? CodeAnalyzersEnvironment
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -18,13 +18,15 @@ module IronHammer
|
|
18
18
|
name = @project.assembly_name
|
19
19
|
xml.info :organisation => @organisation, :module => name
|
20
20
|
xml.publications do
|
21
|
-
|
22
|
-
xml.artifact :name => name, :type =>
|
21
|
+
xml.artifact :name => name, :type => 'dll'
|
22
|
+
xml.artifact :name => name, :type => 'exe'
|
23
23
|
end if @project.is_a? DllProject
|
24
24
|
|
25
25
|
xml.dependencies do
|
26
26
|
@project.dependencies.each do |dependency|
|
27
|
-
xml.dependency :org => @organisation, :name => dependency.name, :rev => dependency.version
|
27
|
+
xml.dependency :org => @organisation, :name => dependency.name, :rev => dependency.version do
|
28
|
+
xml.artifact :type => dependency.extension, :name => dependency.name
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end unless @project.dependencies.empty?
|
30
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_hammer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mozair Alves do Carmo Junior
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/iron_hammer/solutions/solution.rb
|
97
97
|
- lib/iron_hammer/solutions/solution_file.rb
|
98
98
|
- lib/iron_hammer/tasks.rb
|
99
|
+
- lib/iron_hammer/utils/code_analyzers_environment.rb
|
99
100
|
- lib/iron_hammer/utils/dot_net_environment.rb
|
100
101
|
- lib/iron_hammer/utils/file_system.rb
|
101
102
|
- lib/iron_hammer/utils/ivy_builder.rb
|