albacore 0.0.7

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.
Files changed (111) hide show
  1. data/EULA.txt +19 -0
  2. data/README.markdown +70 -0
  3. data/VERSION +1 -0
  4. data/lib/albacore.rb +9 -0
  5. data/lib/albacore/assemblyinfo.rb +104 -0
  6. data/lib/albacore/expandtemplates.rb +64 -0
  7. data/lib/albacore/msbuild.rb +63 -0
  8. data/lib/albacore/mspectestrunner.rb +33 -0
  9. data/lib/albacore/ncoverconsole.rb +64 -0
  10. data/lib/albacore/ncoverreport.rb +61 -0
  11. data/lib/albacore/ncoverreports/assemblyfilter.rb +10 -0
  12. data/lib/albacore/ncoverreports/branchcoverage.rb +10 -0
  13. data/lib/albacore/ncoverreports/classfilter.rb +9 -0
  14. data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -0
  15. data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -0
  16. data/lib/albacore/ncoverreports/documentfilter.rb +9 -0
  17. data/lib/albacore/ncoverreports/fullcoveragereport.rb +21 -0
  18. data/lib/albacore/ncoverreports/methodcoverage.rb +10 -0
  19. data/lib/albacore/ncoverreports/methodfilter.rb +9 -0
  20. data/lib/albacore/ncoverreports/namespacefilter.rb +9 -0
  21. data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -0
  22. data/lib/albacore/ncoverreports/summaryreport.rb +22 -0
  23. data/lib/albacore/ncoverreports/symbolcoverage.rb +10 -0
  24. data/lib/albacore/nunittestrunner.rb +38 -0
  25. data/lib/albacore/sftp.rb +24 -0
  26. data/lib/albacore/sqlcmd.rb +55 -0
  27. data/lib/albacore/ssh.rb +25 -0
  28. data/lib/albacore/support/albacore_helper.rb +4 -0
  29. data/lib/albacore/support/failure.rb +22 -0
  30. data/lib/albacore/support/logging.rb +32 -0
  31. data/lib/albacore/support/runcommand.rb +45 -0
  32. data/lib/albacore/support/yamlconfig.rb +30 -0
  33. data/lib/albacore/zipdirectory.rb +55 -0
  34. data/lib/rake/assemblyinfotask.rb +22 -0
  35. data/lib/rake/expandtemplatestask.rb +21 -0
  36. data/lib/rake/msbuildtask.rb +22 -0
  37. data/lib/rake/ncoverconsoletask.rb +22 -0
  38. data/lib/rake/ncoverreporttask.rb +22 -0
  39. data/lib/rake/nunittask.rb +22 -0
  40. data/lib/rake/renametask.rb +25 -0
  41. data/lib/rake/sftptask.rb +21 -0
  42. data/lib/rake/sqlcmdtask.rb +22 -0
  43. data/lib/rake/sshtask.rb +21 -0
  44. data/lib/rake/ziptask.rb +21 -0
  45. data/rakefile.rb +144 -0
  46. data/spec/assemblyinfo_spec.rb +246 -0
  47. data/spec/assemblyinfotask_spec.rb +31 -0
  48. data/spec/expandtemplates_spec.rb +127 -0
  49. data/spec/expandtemplatestask_spec.rb +31 -0
  50. data/spec/msbuild_spec.rb +173 -0
  51. data/spec/msbuildtask_spec.rb +31 -0
  52. data/spec/ncoverconsole_spec.rb +247 -0
  53. data/spec/ncoverconsoletask_spec.rb +31 -0
  54. data/spec/ncoverreport_spec.rb +577 -0
  55. data/spec/ncoverreporttask_spec.rb +31 -0
  56. data/spec/nunittask_spec.rb +31 -0
  57. data/spec/patches/system_patch.rb +16 -0
  58. data/spec/patches/tasklib_patch.rb +12 -0
  59. data/spec/renametask_spec.rb +30 -0
  60. data/spec/sftp_spec.rb +30 -0
  61. data/spec/sftptask_spec.rb +41 -0
  62. data/spec/sqlcmd_spec.rb +139 -0
  63. data/spec/sqlcmdtask_spec.rb +31 -0
  64. data/spec/ssh_spec.rb +48 -0
  65. data/spec/sshtask_spec.rb +39 -0
  66. data/spec/support/AssemblyInfo/assemblyinfo.yml +2 -0
  67. data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.NUnit.dll +0 -0
  68. data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.dll +0 -0
  69. data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.MSpecTests.dll +0 -0
  70. data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.dll +0 -0
  71. data/spec/support/CodeCoverage/mspec/assemblies/nunit.framework.dll +0 -0
  72. data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.Tests.dll +0 -0
  73. data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.dll +0 -0
  74. data/spec/support/CodeCoverage/nunit/assemblies/nunit.framework.dll +0 -0
  75. data/spec/support/CodeCoverage/nunit/failing_assemblies/TestSolution.FailingTests.dll +0 -0
  76. data/spec/support/CodeCoverage/nunit/failing_assemblies/nunit.framework.dll +0 -0
  77. data/spec/support/CodeCoverage/report/coverage.xml +4578 -0
  78. data/spec/support/TestSolution/TestSolution.FailingTests/FailingTestFixture.cs +19 -0
  79. data/spec/support/TestSolution/TestSolution.FailingTests/Properties/AssemblyInfo.cs +36 -0
  80. data/spec/support/TestSolution/TestSolution.FailingTests/TestSolution.FailingTests.csproj +63 -0
  81. data/spec/support/TestSolution/TestSolution.MSpecTests/Properties/AssemblyInfo.cs +36 -0
  82. data/spec/support/TestSolution/TestSolution.MSpecTests/SomeSpecTest.cs +18 -0
  83. data/spec/support/TestSolution/TestSolution.MSpecTests/TestSolution.MSpecTests.csproj +77 -0
  84. data/spec/support/TestSolution/TestSolution.Tests/Properties/AssemblyInfo.cs +36 -0
  85. data/spec/support/TestSolution/TestSolution.Tests/SomeTestFixture.cs +23 -0
  86. data/spec/support/TestSolution/TestSolution.Tests/TestSolution.Tests.csproj +69 -0
  87. data/spec/support/TestSolution/TestSolution.sln +38 -0
  88. data/spec/support/TestSolution/TestSolution/Class1.cs +17 -0
  89. data/spec/support/TestSolution/TestSolution/Properties/AssemblyInfo.cs +36 -0
  90. data/spec/support/TestSolution/TestSolution/TestSolution.csproj +59 -0
  91. data/spec/support/assemblyinfotester.rb +42 -0
  92. data/spec/support/expandtemplates/datafiles/multiplevalues.yml +3 -0
  93. data/spec/support/expandtemplates/datafiles/multitemplate-specificfile.yml +11 -0
  94. data/spec/support/expandtemplates/datafiles/multitemplate.yml +4 -0
  95. data/spec/support/expandtemplates/datafiles/sample.yml +1 -0
  96. data/spec/support/expandtemplates/templates/multipleinstance.config +4 -0
  97. data/spec/support/expandtemplates/templates/multiplevalues.config +1 -0
  98. data/spec/support/expandtemplates/templates/sample.config +1 -0
  99. data/spec/support/expandtemplatestestdata.rb +69 -0
  100. data/spec/support/msbuildtestdata.rb +32 -0
  101. data/spec/support/ncoverreporttestdata.rb +26 -0
  102. data/spec/support/spec_helper.rb +15 -0
  103. data/spec/support/test.yml +4 -0
  104. data/spec/support/zip/files/subfolder/sub file.txt +1 -0
  105. data/spec/support/zip/files/testfile.txt +1 -0
  106. data/spec/support/ziptestdata.rb +8 -0
  107. data/spec/yamlconfig_spec.rb +62 -0
  108. data/spec/zip_spec.rb +18 -0
  109. data/spec/ziptask_spec.rb +31 -0
  110. data/yaml_autoconfig_test.yml +1 -0
  111. metadata +262 -0
@@ -0,0 +1,30 @@
1
+ require 'yaml'
2
+
3
+ module YAMLConfig
4
+ def initialize
5
+ super()
6
+ configure_if_config_exists(self.class.to_s.downcase)
7
+ end
8
+
9
+ def YAMLConfig.extend_object(obj)
10
+ obj.configure_if_config_exists(obj.class.to_s.downcase)
11
+ end
12
+
13
+ def configure_if_config_exists(task_name)
14
+ task_config = task_name + '.yml'
15
+ configure(task_config) if File.exists?(task_config)
16
+ end
17
+
18
+ def configure(yml_file)
19
+ config = YAML::load(File.open(yml_file))
20
+ parse_config config
21
+ end
22
+
23
+ def parse_config(config)
24
+ config.each do |key, value|
25
+ setter = "#{key}="
26
+ self.class.send(:attr_accessor, key) if !respond_to?(setter)
27
+ send setter, value
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,55 @@
1
+ require 'albacore/support/albacore_helper'
2
+ require 'zip/zip'
3
+ require 'zip/zipfilesystem'
4
+ include Zip
5
+
6
+ class ZipDirectory
7
+ include YAMLConfig
8
+
9
+ attr_accessor :directory_to_zip
10
+ attr_accessor :additional_files
11
+ attr_accessor :file
12
+
13
+ def initialize
14
+ super()
15
+ end
16
+
17
+ def package()
18
+ return if @directory_to_zip.nil?
19
+
20
+ @directory_to_zip.sub!(%r[/$],'')
21
+ remove zip_name
22
+
23
+ ZipFile.open(zip_name, 'w') do |zipfile|
24
+ zip_directory(zipfile)
25
+ zip_additional(zipfile)
26
+ end
27
+ end
28
+
29
+ def remove(filename)
30
+ FileUtils.rm filename, :force=>true
31
+ end
32
+
33
+ def reject_file(f)
34
+ f == zip_name
35
+ end
36
+
37
+ def zip_name()
38
+ File.join(@directory_to_zip, @file)
39
+ end
40
+
41
+ def zip_directory(zipfile)
42
+ Dir["#{@directory_to_zip}/**/**"].reject{|f| reject_file(f)}.each do |file_path|
43
+ file_name = file_path.sub(@directory_to_zip+'/','');
44
+ zipfile.add(file_name, file_path)
45
+ end
46
+ end
47
+
48
+ def zip_additional(zipfile)
49
+ return if @additional_files.nil?
50
+ @additional_files.reject{|f| reject_file(f)}.each do |file_path|
51
+ file_name = file_path#.split('/').last
52
+ zipfile.add(file_name, file_path)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class AssemblyInfoTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:assemblyinfo, &block)
8
+ @name = name
9
+ @asm = AssemblyInfo.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@asm) unless @block.nil?
17
+ @asm.write
18
+ fail if @asm.failed
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class ExpandTemplatesTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:expandtemplates, &block)
8
+ @name = name
9
+ @exp = ExpandTemplates.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task @name do
16
+ @block.call(@exp) unless @block.nil?
17
+ @exp.expand
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class MSBuildTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:msbuild, &block)
8
+ @name = name
9
+ @msbuild = MSBuild.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@msbuild) unless @block.nil?
17
+ @msbuild.build
18
+ fail if @msbuild.failed
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class NCoverConsoleTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:ncoverconsole, &block)
8
+ @name = name
9
+ @ncover = NCoverConsole.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@ncover) unless @block.nil?
17
+ @ncover.run
18
+ fail if @ncover.failed
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class NCoverReportTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:ncoverreport, &block)
8
+ @name = name
9
+ @ncoverreport = NCoverReport.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@ncoverreport) unless @block.nil?
17
+ @ncoverreport.run
18
+ fail if @ncoverreport.failed
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class NUnitTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:nunit, &block)
8
+ @name = name
9
+ @nunit = NUnitTestRunner.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@nunit) unless @block.nil?
17
+ @nunit.execute
18
+ fail if @nunit.failed
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class RenameTask < Rake::TaskLib
5
+ attr_accessor :name
6
+ attr_accessor :actual_name, :target_name
7
+
8
+ def initialize(name=:rename, &block)
9
+ @name = name
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(self) unless @block.nil?
17
+ if (@actual_name.nil? || @target_name.nil?)
18
+ fail
19
+ else
20
+ File.rename(@actual_name, @target_name)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class SftpTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:sftp, &block)
8
+ @name = name
9
+ @sftp = Sftp.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@sftp) unless @block.nil?
17
+ @sftp.upload
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class SQLCmdTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:sqlcmd, &block)
8
+ @name = name
9
+ @sqlcmd = SQLCmd.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@sqlcmd) unless @block.nil?
17
+ @sqlcmd.run
18
+ fail if @sqlcmd.failed
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class SshTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:ssh, &block)
8
+ @name = name
9
+ @ssh = Ssh.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@ssh) unless @block.nil?
17
+ @ssh.execute
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'rake/tasklib'
2
+
3
+ module Albacore
4
+ class ZipTask < Rake::TaskLib
5
+ attr_accessor :name
6
+
7
+ def initialize(name=:zip, &block)
8
+ @name = name
9
+ @zip = ZipDirectory.new
10
+ @block = block
11
+ define
12
+ end
13
+
14
+ def define
15
+ task name do
16
+ @block.call(@zip) unless @block.nil?
17
+ @zip.package
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,144 @@
1
+ task :default => ['albacore:sample']
2
+
3
+ namespace :specs do
4
+ require 'spec/rake/spectask'
5
+
6
+ @spec_opts = '--colour --format specdoc'
7
+
8
+ desc "Run functional specs for Albacore"
9
+ Spec::Rake::SpecTask.new :all do |t|
10
+ t.spec_files = 'spec/**/*_spec.rb'
11
+ t.spec_opts << @spec_opts
12
+ end
13
+
14
+ desc "Run rake task specs for Albacore"
15
+ Spec::Rake::SpecTask.new :tasks do |t|
16
+ t.spec_files = 'spec/**/*task_spec.rb'
17
+ t.spec_opts << @spec_opts
18
+ end
19
+
20
+ desc "Assembly info functional specs"
21
+ Spec::Rake::SpecTask.new :assemblyinfo do |t|
22
+ t.spec_files = 'spec/assemblyinfo*_spec.rb'
23
+ t.spec_opts << @spec_opts
24
+ end
25
+
26
+ desc "MSBuild functional specs"
27
+ Spec::Rake::SpecTask.new :msbuild do |t|
28
+ t.spec_files = 'spec/msbuild*_spec.rb'
29
+ t.spec_opts << @spec_opts
30
+ end
31
+
32
+ desc "SQLServer SQLCmd functional specs"
33
+ Spec::Rake::SpecTask.new :sqlcmd do |t|
34
+ t.spec_files = 'spec/sqlcmd*_spec.rb'
35
+ t.spec_opts << @spec_opts
36
+ end
37
+
38
+ desc "NCover Console functional specs"
39
+ Spec::Rake::SpecTask.new :ncoverconsole do |t|
40
+ t.spec_files = 'spec/ncoverconsole*_spec.rb'
41
+ t.spec_opts << @spec_opts
42
+ end
43
+
44
+ desc "NCover Report functional specs"
45
+ Spec::Rake::SpecTask.new :ncoverreport do |t|
46
+ t.spec_files = 'spec/ncoverreport*_spec.rb'
47
+ t.spec_opts << @spec_opts
48
+ end
49
+
50
+ desc "SSH functional specs"
51
+ Spec::Rake::SpecTask.new :ssh do |t|
52
+ t.spec_files = 'spec/ssh*_spec.rb'
53
+ t.spec_opts << @spec_opts
54
+ end
55
+
56
+ desc "Expand Templates functional specs"
57
+ Spec::Rake::SpecTask.new :ssh do |t|
58
+ t.spec_files = 'spec/expandtemplates*_spec.rb'
59
+ t.spec_opts << @spec_opts
60
+ end
61
+ end
62
+
63
+ namespace :albacore do
64
+ require 'lib/albacore'
65
+
66
+ desc "Run a complete Albacore build sample"
67
+ task :sample => ['albacore:assemblyinfo', 'albacore:msbuild', 'albacore:ncoverconsole', 'albacore:ncoverreport']
68
+
69
+ desc "Run a sample build using the MSBuildTask"
70
+ Albacore::MSBuildTask.new(:msbuild) do |msb|
71
+ msb.properties = {:configuration => :Debug}
72
+ msb.targets [:Clean, :Build]
73
+ msb.solution = "spec/support/TestSolution/TestSolution.sln"
74
+ end
75
+
76
+ desc "Run a sample assembly info generator"
77
+ Albacore::AssemblyInfoTask.new(:assemblyinfo) do |asm|
78
+ asm.version = "0.1.2.3"
79
+ asm.company_name = "a test company"
80
+ asm.product_name = "a product name goes here"
81
+ asm.title = "my assembly title"
82
+ asm.description = "this is the assembly description"
83
+ asm.copyright = "copyright some year, by some legal entity"
84
+ asm.custom_attributes :SomeAttribute => "some value goes here", :AnotherAttribute => "with some data"
85
+
86
+ asm.output_file = "spec/support/AssemblyInfo/AssemblyInfo.cs"
87
+ end
88
+
89
+ desc "Run a sample NCover Console code coverage"
90
+ Albacore::NCoverConsoleTask.new(:ncoverconsole) do |ncc|
91
+ @xml_coverage = "spec/support/CodeCoverage/test-coverage.xml"
92
+ File.delete(@xml_coverage) if File.exist?(@xml_coverage)
93
+
94
+ ncc.log_level = :verbose
95
+ ncc.path_to_command = "spec/support/Tools/NCover-v3.3/NCover.Console.exe"
96
+ ncc.output = {:xml => @xml_coverage}
97
+ ncc.working_directory = "spec/support/CodeCoverage/nunit"
98
+
99
+ nunit = NUnitTestRunner.new("spec/support/Tools/NUnit-v2.5/nunit-console.exe")
100
+ nunit.log_level = :verbose
101
+ nunit.assemblies << "assemblies/TestSolution.Tests.dll"
102
+ nunit.options << '/noshadow'
103
+
104
+ ncc.testrunner = nunit
105
+ end
106
+
107
+ desc "Run a sample NCover Report to check code coverage"
108
+ Albacore::NCoverReportTask.new(:ncoverreport => :ncoverconsole) do |ncr|
109
+ @xml_coverage = "spec/support/CodeCoverage/test-coverage.xml"
110
+
111
+ ncr.path_to_command = "spec/support/Tools/NCover-v3.3/NCover.Reporting.exe"
112
+ ncr.coverage_files << @xml_coverage
113
+
114
+ fullcoveragereport = NCover::FullCoverageReport.new
115
+ fullcoveragereport.output_path = "spec/support/CodeCoverage/report/output"
116
+ ncr.reports << fullcoveragereport
117
+
118
+ ncr.required_coverage << NCover::BranchCoverage.new(:minimum => 10)
119
+ ncr.required_coverage << NCover::CyclomaticComplexity.new(:maximum => 1)
120
+ end
121
+ end
122
+
123
+ namespace :jeweler do
124
+ require 'jeweler'
125
+ Jeweler::Tasks.new do |gs|
126
+ gs.name = "albacore"
127
+ gs.summary = "A Suite of Rake Build Tasks For .Net Solutions"
128
+ gs.description = "Easily build your .NET solutions with rake, using this suite of custom tasks."
129
+ gs.email = "derickbailey@gmail.com"
130
+ gs.homepage = "http://github.com/derickbailey/Albacore"
131
+ gs.authors = ["Derick Bailey", "Ben Hall"]
132
+ gs.has_rdoc = false
133
+ gs.files.exclude("albacore.gemspec", ".gitignore", "spec/support/Tools")
134
+
135
+ gs.add_dependency('rake', '>= 0.8.7')
136
+ gs.add_dependency('net-ssh', '>= 2.0.15')
137
+ gs.add_dependency('net-sftp', '>= 2.0.2')
138
+ gs.add_dependency('rubyzip', '>= 0.9.1')
139
+
140
+ gs.add_development_dependency('rspec', '>= 1.2.8')
141
+ gs.add_development_dependency('jeweler', '>= 1.2.1')
142
+ gs.add_development_dependency('derickbailey-notamock', '>= 0.0.1')
143
+ end
144
+ end