albacore 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
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,10 @@
1
+ require 'albacore/ncoverreports/reportfilterbase'
2
+
3
+ module NCover
4
+ class AssemblyFilter < NCover::ReportFilterBase
5
+ def initialize(params={})
6
+ super("Assembly", params)
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ require 'albacore/ncoverreports/codecoveragebase'
2
+
3
+ module NCover
4
+ class BranchCoverage < NCover::CodeCoverageBase
5
+ def initialize(params={})
6
+ super("BranchCoverage", params)
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,9 @@
1
+ require 'albacore/ncoverreports/reportfilterbase'
2
+
3
+ module NCover
4
+ class ClassFilter < NCover::ReportFilterBase
5
+ def initialize(params={})
6
+ super("Class", params)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ require 'albacore/support/albacore_helper'
2
+
3
+ module NCover
4
+ class CodeCoverageBase
5
+ include YAMLConfig
6
+
7
+ attr_accessor :coverage_type, :minimum, :item_type
8
+
9
+ def initialize(coverage_type, params={})
10
+ super()
11
+ @coverage_type = coverage_type
12
+ @minimum = 0
13
+ @item_type = :View
14
+ parse_config(params) unless params.nil?
15
+ end
16
+
17
+ def get_coverage_options
18
+ options = "#{@coverage_type}"
19
+ options << ":#{@minimum}" unless @minimum.nil?
20
+ options << ":#{@item_type}" unless @item_type.nil?
21
+ options
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,23 @@
1
+ require 'albacore/support/albacore_helper'
2
+
3
+ module NCover
4
+ class CyclomaticComplexity
5
+ include YAMLConfig
6
+
7
+ attr_accessor :maximum, :item_type
8
+
9
+ def initialize(params={})
10
+ super()
11
+ @maximum = 100
12
+ @item_type = :View
13
+ parse_config(params) unless params.nil?
14
+ end
15
+
16
+ def get_coverage_options
17
+ options = "CyclomaticComplexity"
18
+ options << ":#{maximum}" unless maximum.nil?
19
+ options << ":#{item_type}" unless item_type.nil?
20
+ options
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ require 'albacore/ncoverreports/reportfilterbase'
2
+
3
+ module NCover
4
+ class DocumentFilter < NCover::ReportFilterBase
5
+ def initialize(params={})
6
+ super("Document", params)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ require 'albacore/support/albacore_helper'
2
+
3
+ module NCover
4
+ class FullCoverageReport
5
+ include YAMLConfig
6
+
7
+ attr_accessor :output_path
8
+
9
+ def initialize
10
+ super()
11
+ end
12
+
13
+ def report_type
14
+ :FullCoverageReport
15
+ end
16
+
17
+ def report_format
18
+ :Html
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ require 'albacore/ncoverreports/codecoveragebase'
2
+
3
+ module NCover
4
+ class MethodCoverage < NCover::CodeCoverageBase
5
+ def initialize(params={})
6
+ super("MethodCoverage", params)
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,9 @@
1
+ require 'albacore/ncoverreports/reportfilterbase'
2
+
3
+ module NCover
4
+ class MethodFilter < NCover::ReportFilterBase
5
+ def initialize(params={})
6
+ super("Method", params)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'albacore/ncoverreports/reportfilterbase'
2
+
3
+ module NCover
4
+ class NamespaceFilter < NCover::ReportFilterBase
5
+ def initialize(params={})
6
+ super("Namespace", params)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ require 'albacore/support/albacore_helper'
2
+
3
+ module NCover
4
+ class ReportFilterBase
5
+ include YAMLConfig
6
+
7
+ attr_accessor :filter, :filter_type, :item_type, :is_regex
8
+
9
+ def initialize(item_type, params={})
10
+ super()
11
+ @filter = ""
12
+ @item_type = item_type
13
+ @is_regex = false
14
+ @filter_type = :exclude
15
+ parse_config(params) unless params.nil?
16
+ end
17
+
18
+ def get_filter_options
19
+ filter = "\"#{@filter}\""
20
+ filter << ":#{@item_type}"
21
+ filter << ":#{@is_regex}"
22
+ filter << ":#{(@filter_type == :include)}"
23
+ filter
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ require 'albacore/support/albacore_helper'
2
+
3
+ module NCover
4
+ class SummaryReport
5
+ include YAMLConfig
6
+
7
+ attr_accessor :output_path
8
+
9
+ def initialize
10
+ super()
11
+ @report_format = :Xml
12
+ end
13
+
14
+ def report_type
15
+ :Summary
16
+ end
17
+
18
+ def report_format
19
+ :Html
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ require 'albacore/ncoverreports/codecoveragebase'
2
+
3
+ module NCover
4
+ class SymbolCoverage < NCover::CodeCoverageBase
5
+ def initialize(params={})
6
+ super("SymbolCoverage", params)
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,38 @@
1
+ require 'albacore/support/albacore_helper'
2
+
3
+ class NUnitTestRunner
4
+ include RunCommand
5
+ include YAMLConfig
6
+
7
+ attr_accessor :assemblies, :options
8
+
9
+ def initialize(path_to_command='')
10
+ super()
11
+ @path_to_command = path_to_command
12
+ @options=[]
13
+ @assemblies=[]
14
+ end
15
+
16
+ def get_command_line
17
+ command_params = get_command_parameters
18
+ commandline = command_params.join(" ")
19
+ @logger.debug "Build NUnit Test Runner Command Line: " + commandline
20
+ commandline
21
+ end
22
+
23
+ def get_command_parameters
24
+ command_params = []
25
+ command_params << @path_to_command
26
+ command_params << @assemblies.join(" ") unless @assemblies.nil?
27
+ command_params << @options.join(" ") unless @options.nil?
28
+ command_params
29
+ end
30
+
31
+ def execute()
32
+ command_params = get_command_parameters
33
+ result = run_command "NUnit", command_params
34
+
35
+ failure_message = 'NUnit Failed. See Build Log For Detail'
36
+ fail_with_message failure_message if !result
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ require 'albacore/support/albacore_helper'
2
+ require 'net/sftp'
3
+
4
+ class Sftp
5
+ include YAMLConfig
6
+ include Logging
7
+
8
+ attr_accessor :server, :username, :password, :upload_files
9
+
10
+ def initialize
11
+ super()
12
+ @upload_files = {}
13
+ end
14
+
15
+ def upload()
16
+ Net::SFTP.start(@server, @username, :password => @password) do |sftp|
17
+ @logger.debug "Starting File Upload"
18
+ @upload_files.each {|local_file, remote_file|
19
+ @logger.debug "Uploading #{local_file} to #{remote_file}"
20
+ sftp.upload!(local_file, remote_file)
21
+ }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,55 @@
1
+ require 'albacore/support/albacore_helper'
2
+
3
+ class SQLCmd
4
+ include RunCommand
5
+ include YAMLConfig
6
+
7
+ attr_accessor :server, :database, :username, :password, :scripts, :variables
8
+
9
+ def initialize
10
+ super()
11
+ @require_valid_command = false
12
+ @scripts=[]
13
+ @variables={}
14
+ end
15
+
16
+ def run
17
+ check_command
18
+ return if @failed
19
+
20
+ cmd_params=[]
21
+ cmd_params << build_parameter("S", @server) unless @server.nil?
22
+ cmd_params << build_parameter("d", @database) unless @database.nil?
23
+ cmd_params << build_parameter("U", @username) unless @username.nil?
24
+ cmd_params << build_parameter("P", @password) unless @password.nil?
25
+ cmd_params << build_variable_list if @variables.length > 0
26
+ cmd_params << build_script_list if @scripts.length > 0
27
+
28
+ result = run_command "SQLCmd", cmd_params.join(" ")
29
+
30
+ failure_msg = 'SQLCmd Failed. See Build Log For Detail.'
31
+ fail_with_message failure_msg if !result
32
+ end
33
+
34
+ def check_command
35
+ return if @path_to_command
36
+ fail_with_message 'SQLCmd.path_to_command cannot be nil.'
37
+ end
38
+
39
+ def build_script_list
40
+ @scripts.map{|s| "-i \"#{s}\""}.join(" ")
41
+ end
42
+
43
+ def build_parameter(param_name, param_value)
44
+ "-#{param_name} \"#{param_value}\""
45
+ end
46
+
47
+ def build_variable_list
48
+ vars = []
49
+ @variables.each do |k,v|
50
+ vars << "-v #{k}=#{v}"
51
+ end
52
+ vars.join(" ")
53
+ end
54
+
55
+ end
@@ -0,0 +1,25 @@
1
+ require 'albacore/support/albacore_helper'
2
+ require 'net/ssh'
3
+
4
+ class Ssh
5
+ include YAMLConfig
6
+ include Logging
7
+
8
+ attr_accessor :server, :username, :password, :commands
9
+
10
+ def initialize
11
+ super()
12
+ @commands = []
13
+ end
14
+
15
+ def execute()
16
+ Net::SSH.start(@server, @username, :password => @password) do |ssh|
17
+ @commands.each{|cmd|
18
+ @logger.info "Executing remote command: #{cmd}"
19
+ output = ssh.exec!(cmd)
20
+ @logger.info 'SSH output: '
21
+ @logger.info output
22
+ }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ require File.join(File.dirname(__FILE__), 'logging')
2
+ require File.join(File.dirname(__FILE__), 'failure')
3
+ require File.join(File.dirname(__FILE__), 'runcommand')
4
+ require File.join(File.dirname(__FILE__), 'yamlconfig')
@@ -0,0 +1,22 @@
1
+ require 'albacore/support/logging'
2
+
3
+ module Failure
4
+ include Logging
5
+
6
+ attr_accessor :failed
7
+
8
+ def initialize
9
+ super()
10
+ @failed = false
11
+ end
12
+
13
+ def fail
14
+ @failed = true
15
+ end
16
+
17
+ def fail_with_message(msg)
18
+ @logger.fatal msg
19
+ fail
20
+ end
21
+ end
22
+
@@ -0,0 +1,32 @@
1
+ require 'logger'
2
+
3
+ module Logging
4
+
5
+ attr_accessor :logger, :current_log_device
6
+
7
+ def initialize
8
+ super()
9
+ create_logger(STDOUT, Logger::INFO)
10
+ end
11
+
12
+ def log_device=(logdev)
13
+ level = @logger.level
14
+ create_logger(logdev, level)
15
+ end
16
+
17
+ def log_level=(level)
18
+ if (level == :verbose)
19
+ loglevel = Logger::DEBUG
20
+ else
21
+ loglevel = Logger::INFO
22
+ end
23
+ create_logger(@current_log_device, loglevel)
24
+ end
25
+
26
+ def create_logger(device, level)
27
+ @current_log_device = device
28
+ @logger = Logger.new(device)
29
+ @logger.level = level
30
+ end
31
+
32
+ end
@@ -0,0 +1,45 @@
1
+ require 'albacore/support/failure'
2
+
3
+ module RunCommand
4
+ include Failure
5
+
6
+ attr_accessor :path_to_command, :require_valid_command, :command_directory
7
+
8
+ def initialize
9
+ super()
10
+ @require_valid_command = true
11
+ @command_directory = Dir.pwd
12
+ end
13
+
14
+ def run_command(command_name="Command Line", command_parameters="")
15
+ if @require_valid_command
16
+ return false unless valid_command_exists
17
+ end
18
+
19
+ command = "\"#{@path_to_command}\" #{command_parameters}"
20
+ @logger.debug "Executing #{command_name}: #{command}"
21
+
22
+ set_working_directory
23
+ result = system command
24
+ reset_working_directory
25
+
26
+ result
27
+ end
28
+
29
+ def valid_command_exists
30
+ return true if File.exist?(@path_to_command)
31
+ msg = 'Command not found: ' + @path_to_command
32
+ @logger.fatal msg
33
+ end
34
+
35
+ def set_working_directory
36
+ @original_directory = Dir.pwd
37
+ return if @command_directory == @original_directory
38
+ Dir.chdir(@command_directory)
39
+ end
40
+
41
+ def reset_working_directory
42
+ return if Dir.pwd == @original_directory
43
+ Dir.chdir(@original_directory)
44
+ end
45
+ end