albacore 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -4
- data/.bundle/config +2 -2
- data/.rvmrc +1 -1
- data/Gemfile +12 -12
- data/README.markdown +92 -68
- data/VERSION +1 -1
- data/lib/albacore.rb +9 -9
- data/lib/albacore/albacoretask.rb +50 -50
- data/lib/albacore/aspnetcompiler.rb +58 -58
- data/lib/albacore/assemblyinfo.rb +140 -140
- data/lib/albacore/assemblyinfolanguages/cppcliengine.rb +17 -0
- data/lib/albacore/assemblyinfolanguages/csharpengine.rb +18 -18
- data/lib/albacore/assemblyinfolanguages/vbnetengine.rb +18 -18
- data/lib/albacore/config/aspnetcompilerconfig.rb +29 -29
- data/lib/albacore/config/assemblyinfoconfig.rb +13 -13
- data/lib/albacore/config/config.rb +22 -22
- data/lib/albacore/config/cscconfig.rb +28 -28
- data/lib/albacore/config/docuconfig.rb +23 -23
- data/lib/albacore/config/execconfig.rb +15 -15
- data/lib/albacore/config/fluentmigratorrunnerconfig.rb +15 -15
- data/lib/albacore/config/msbuildconfig.rb +29 -29
- data/lib/albacore/config/mspectestrunnerconfig.rb +15 -15
- data/lib/albacore/config/mstesttestrunnerconfig.rb +15 -15
- data/lib/albacore/config/nantconfig.rb +15 -15
- data/lib/albacore/config/nchurnconfig.rb +15 -15
- data/lib/albacore/config/ncoverconsoleconfig.rb +15 -15
- data/lib/albacore/config/ncoverreportconfig.rb +15 -15
- data/lib/albacore/config/ndependconfig.rb +15 -15
- data/lib/albacore/config/netversion.rb +21 -21
- data/lib/albacore/config/nugetpackconfig.rb +3 -3
- data/lib/albacore/config/nugetpublishconfig.rb +19 -0
- data/lib/albacore/config/nugetpushconfig.rb +19 -0
- data/lib/albacore/config/nunittestrunnerconfig.rb +14 -14
- data/lib/albacore/config/specflowreportconfig.rb +24 -24
- data/lib/albacore/config/sqlcmdconfig.rb +15 -15
- data/lib/albacore/config/unzipconfig.rb +15 -15
- data/lib/albacore/config/vssgetconfig.rb +14 -0
- data/lib/albacore/config/xbuildconfig.rb +15 -15
- data/lib/albacore/config/xunittestrunnerconfig.rb +15 -15
- data/lib/albacore/config/zipdirectoryconfig.rb +15 -15
- data/lib/albacore/csc.rb +66 -62
- data/lib/albacore/docu.rb +41 -41
- data/lib/albacore/exec.rb +18 -18
- data/lib/albacore/fluentmigratorrunner.rb +51 -46
- data/lib/albacore/msbuild.rb +55 -55
- data/lib/albacore/mspectestrunner.rb +50 -50
- data/lib/albacore/mstesttestrunner.rb +43 -43
- data/lib/albacore/nant.rb +38 -38
- data/lib/albacore/nchurn.rb +74 -74
- data/lib/albacore/ncoverconsole.rb +68 -68
- data/lib/albacore/ncoverreport.rb +62 -62
- data/lib/albacore/ncoverreports/assemblyfilter.rb +9 -9
- data/lib/albacore/ncoverreports/branchcoverage.rb +9 -9
- data/lib/albacore/ncoverreports/classfilter.rb +9 -9
- data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -25
- data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -23
- data/lib/albacore/ncoverreports/documentfilter.rb +9 -9
- data/lib/albacore/ncoverreports/fullcoveragereport.rb +13 -13
- data/lib/albacore/ncoverreports/methodcoverage.rb +9 -9
- data/lib/albacore/ncoverreports/methodfilter.rb +9 -9
- data/lib/albacore/ncoverreports/namespacefilter.rb +9 -9
- data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -26
- data/lib/albacore/ncoverreports/summaryreport.rb +18 -18
- data/lib/albacore/ncoverreports/symbolcoverage.rb +9 -9
- data/lib/albacore/ndepend.rb +33 -33
- data/lib/albacore/nugetpublish.rb +47 -0
- data/lib/albacore/nugetpush.rb +46 -0
- data/lib/albacore/nunittestrunner.rb +41 -41
- data/lib/albacore/nuspec.rb +133 -109
- data/lib/albacore/output.rb +99 -99
- data/lib/albacore/plink.rb +47 -47
- data/lib/albacore/specflowreport.rb +62 -62
- data/lib/albacore/sqlcmd.rb +80 -80
- data/lib/albacore/support/attrmethods.rb +33 -33
- data/lib/albacore/support/createtask.rb +50 -30
- data/lib/albacore/support/failure.rb +15 -15
- data/lib/albacore/support/logging.rb +38 -38
- data/lib/albacore/support/openstruct.rb +13 -13
- data/lib/albacore/support/runcommand.rb +45 -45
- data/lib/albacore/support/supportlinux.rb +23 -23
- data/lib/albacore/support/updateattributes.rb +13 -13
- data/lib/albacore/support/yamlconfig.rb +18 -18
- data/lib/albacore/unzip.rb +28 -28
- data/lib/albacore/vssget.rb +44 -0
- data/lib/albacore/xbuild.rb +54 -54
- data/lib/albacore/xunittestrunner.rb +52 -52
- data/lib/albacore/zipdirectory.rb +105 -105
- data/rakefile.rb +297 -297
- data/spec/albacoremodel_spec.rb +53 -53
- data/spec/assemblyinfo_spec.rb +541 -541
- data/spec/attrmethods_spec.rb +136 -136
- data/spec/config_spec.rb +34 -34
- data/spec/createtask_spec.rb +236 -236
- data/spec/csc_spec.rb +253 -253
- data/spec/docu_spec.rb +109 -109
- data/spec/exec_spec.rb +45 -45
- data/spec/fluentmigratorrunner_spec.rb +254 -185
- data/spec/msbuild_spec.rb +215 -215
- data/spec/mspec_spec.rb +28 -28
- data/spec/mstesttestrunner_spec.rb +142 -142
- data/spec/nant_spec.rb +110 -110
- data/spec/nchurn_spec.rb +75 -75
- data/spec/ncoverconsole_spec.rb +353 -353
- data/spec/ncoverreport_spec.rb +619 -619
- data/spec/ndepend_spec.rb +72 -72
- data/spec/nunittestrunner_spec.rb +122 -122
- data/spec/nuspec_spec.rb +78 -78
- data/spec/patches/docu_patch.rb +12 -12
- data/spec/patches/fail_patch.rb +8 -8
- data/spec/patches/system_patch.rb +20 -20
- data/spec/plink_spec.rb +62 -62
- data/spec/runcommand_spec.rb +94 -94
- data/spec/spec_helper.rb +17 -17
- data/spec/specflowreport_spec.rb +146 -146
- data/spec/sqlcmd_spec.rb +334 -334
- data/spec/support/assemblyinfotester.rb +51 -51
- data/spec/support/ironruby_validator.rb +26 -26
- data/spec/support/msbuildtestdata.rb +32 -32
- data/spec/support/nanttestdata.rb +33 -33
- data/spec/support/ncoverconsoletestdata.rb +19 -19
- data/spec/support/ncoverreporttestdata.rb +26 -26
- data/spec/support/nokogiri_validator.rb +15 -15
- data/spec/support/outputtestdata.rb +12 -12
- data/spec/support/ziptestdata.rb +12 -12
- data/spec/unzip_spec.rb +15 -15
- data/spec/xbuild_spec.rb +15 -15
- data/spec/xunit_spec.rb +168 -168
- data/spec/yamlconfig_spec.rb +49 -49
- data/spec/zip_spec.rb +104 -104
- data/watchrtesting.rb +8 -8
- metadata +15 -119
@@ -1,10 +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
|
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
10
|
|
@@ -1,9 +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
|
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
|
@@ -1,9 +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
|
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
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require 'albacore/support/updateattributes'
|
2
|
-
|
3
|
-
module NCover
|
4
|
-
class ReportFilterBase
|
5
|
-
include UpdateAttributes
|
6
|
-
|
7
|
-
attr_accessor :filter, :filter_type, :item_type, :is_regex
|
8
|
-
|
9
|
-
def initialize(item_type, params={})
|
10
|
-
@filter = ""
|
11
|
-
@item_type = item_type
|
12
|
-
@is_regex = false
|
13
|
-
@filter_type = :exclude
|
14
|
-
update_attributes(params) unless params.nil?
|
15
|
-
super()
|
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
|
1
|
+
require 'albacore/support/updateattributes'
|
2
|
+
|
3
|
+
module NCover
|
4
|
+
class ReportFilterBase
|
5
|
+
include UpdateAttributes
|
6
|
+
|
7
|
+
attr_accessor :filter, :filter_type, :item_type, :is_regex
|
8
|
+
|
9
|
+
def initialize(item_type, params={})
|
10
|
+
@filter = ""
|
11
|
+
@item_type = item_type
|
12
|
+
@is_regex = false
|
13
|
+
@filter_type = :exclude
|
14
|
+
update_attributes(params) unless params.nil?
|
15
|
+
super()
|
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
|
@@ -1,18 +1,18 @@
|
|
1
|
-
module NCover
|
2
|
-
class SummaryReport
|
3
|
-
attr_accessor :output_path
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@report_format = :Xml
|
7
|
-
super()
|
8
|
-
end
|
9
|
-
|
10
|
-
def report_type
|
11
|
-
:Summary
|
12
|
-
end
|
13
|
-
|
14
|
-
def report_format
|
15
|
-
:Html
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
module NCover
|
2
|
+
class SummaryReport
|
3
|
+
attr_accessor :output_path
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@report_format = :Xml
|
7
|
+
super()
|
8
|
+
end
|
9
|
+
|
10
|
+
def report_type
|
11
|
+
:Summary
|
12
|
+
end
|
13
|
+
|
14
|
+
def report_format
|
15
|
+
:Html
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,9 +1,9 @@
|
|
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
|
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
|
data/lib/albacore/ndepend.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
require 'albacore/albacoretask'
|
2
|
-
|
3
|
-
class NDepend
|
4
|
-
include Albacore::Task
|
5
|
-
include Albacore::RunCommand
|
6
|
-
|
7
|
-
attr_accessor :project_file
|
8
|
-
|
9
|
-
def initialize()
|
10
|
-
super()
|
11
|
-
update_attributes Albacore.configuration.ndepend.to_hash
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute
|
15
|
-
return unless check_command
|
16
|
-
result = run_command @command, create_parameters.join(" ")
|
17
|
-
failure_message = 'Command Failed. See Build Log For Detail'
|
18
|
-
fail_with_message failure_message if !result
|
19
|
-
end
|
20
|
-
|
21
|
-
def create_parameters
|
22
|
-
params = []
|
23
|
-
params << File.expand_path(@project_file)
|
24
|
-
return params
|
25
|
-
end
|
26
|
-
|
27
|
-
def check_command
|
28
|
-
return true if @project_file
|
29
|
-
fail_with_message 'A ndepend project file is required'
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
1
|
+
require 'albacore/albacoretask'
|
2
|
+
|
3
|
+
class NDepend
|
4
|
+
include Albacore::Task
|
5
|
+
include Albacore::RunCommand
|
6
|
+
|
7
|
+
attr_accessor :project_file
|
8
|
+
|
9
|
+
def initialize()
|
10
|
+
super()
|
11
|
+
update_attributes Albacore.configuration.ndepend.to_hash
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
return unless check_command
|
16
|
+
result = run_command @command, create_parameters.join(" ")
|
17
|
+
failure_message = 'Command Failed. See Build Log For Detail'
|
18
|
+
fail_with_message failure_message if !result
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_parameters
|
22
|
+
params = []
|
23
|
+
params << File.expand_path(@project_file)
|
24
|
+
return params
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_command
|
28
|
+
return true if @project_file
|
29
|
+
fail_with_message 'A ndepend project file is required'
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'albacore/albacoretask'
|
2
|
+
require 'albacore/config/nugetpublishconfig'
|
3
|
+
require 'albacore/support/supportlinux'
|
4
|
+
|
5
|
+
class NuGetPublish
|
6
|
+
include Albacore::Task
|
7
|
+
include Albacore::RunCommand
|
8
|
+
include Configuration::NuGetPublish
|
9
|
+
include SupportsLinuxEnvironment
|
10
|
+
|
11
|
+
attr_accessor :id, # Package Id
|
12
|
+
:version, # Package Version
|
13
|
+
:apikey,
|
14
|
+
:source,
|
15
|
+
:command
|
16
|
+
|
17
|
+
def initialize(command = "NuGet.exe") # users might have put the NuGet.exe in path
|
18
|
+
super()
|
19
|
+
update_attributes nugetpublish.to_hash
|
20
|
+
@command = command
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute
|
24
|
+
|
25
|
+
fail_with_message 'id must be specified.' if @id.nil?
|
26
|
+
fail_with_message 'version must be specified.' if @version.nil?
|
27
|
+
# don't validate @apikey as required, coz it might have been set in the config file using 'SetApiKey'
|
28
|
+
|
29
|
+
puts @create_only
|
30
|
+
params = []
|
31
|
+
params << "publish"
|
32
|
+
params << "#{@id}"
|
33
|
+
params << "#{@version}"
|
34
|
+
params << "#{@apikey}" if @apikey
|
35
|
+
params << "-Source #{source}" unless @source.nil?
|
36
|
+
|
37
|
+
merged_params = params.join(' ')
|
38
|
+
|
39
|
+
@logger.debug "Build NuGet publish Command Line: #{merged_params}"
|
40
|
+
|
41
|
+
result = run_command "NuGet", merged_params
|
42
|
+
|
43
|
+
failure_message = 'NuGet Publish Failed. See Build Log For Details'
|
44
|
+
fail_with_message failure_message if !result
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'albacore/albacoretask'
|
2
|
+
require 'albacore/config/nugetpushconfig'
|
3
|
+
require 'albacore/support/supportlinux'
|
4
|
+
|
5
|
+
class NuGetPush
|
6
|
+
include Albacore::Task
|
7
|
+
include Albacore::RunCommand
|
8
|
+
include Configuration::NuGetPush
|
9
|
+
include SupportsLinuxEnvironment
|
10
|
+
|
11
|
+
attr_accessor :package,
|
12
|
+
:apikey,
|
13
|
+
:create_only,
|
14
|
+
:source,
|
15
|
+
:command
|
16
|
+
|
17
|
+
def initialize(command = "NuGet.exe") # users might have put the NuGet.exe in path
|
18
|
+
super()
|
19
|
+
@create_only = false
|
20
|
+
update_attributes nugetpush.to_hash
|
21
|
+
@command = command
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute
|
25
|
+
|
26
|
+
fail_with_message 'package must be specified.' if @package.nil?
|
27
|
+
# don't validate @apikey as required, coz it might have been set in the config file using 'SetApiKey'
|
28
|
+
|
29
|
+
params = []
|
30
|
+
params << "push"
|
31
|
+
params << "\"#{@package}\""
|
32
|
+
params << "#{@apikey}" if @apikey
|
33
|
+
params << "-CreateOnly" if @create_only
|
34
|
+
params << "-Source #{source}" unless @source.nil?
|
35
|
+
|
36
|
+
merged_params = params.join(' ')
|
37
|
+
|
38
|
+
@logger.debug "Build NuGet push Command Line: #{merged_params}"
|
39
|
+
|
40
|
+
result = run_command "NuGet", merged_params
|
41
|
+
|
42
|
+
failure_message = 'NuGet push Failed. See Build Log For Details'
|
43
|
+
fail_with_message failure_message if !result
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -1,41 +1,41 @@
|
|
1
|
-
require 'albacore/albacoretask'
|
2
|
-
|
3
|
-
class NUnitTestRunner
|
4
|
-
TaskName = :nunit
|
5
|
-
include Albacore::Task
|
6
|
-
include Albacore::RunCommand
|
7
|
-
|
8
|
-
attr_array :assemblies, :options
|
9
|
-
|
10
|
-
def initialize(command=nil)
|
11
|
-
@options=[]
|
12
|
-
@assemblies=[]
|
13
|
-
super()
|
14
|
-
update_attributes Albacore.configuration.nunit.to_hash
|
15
|
-
@command = command unless command.nil?
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_command_line
|
19
|
-
command_params = []
|
20
|
-
command_params << @command
|
21
|
-
command_params << get_command_parameters
|
22
|
-
commandline = command_params.join(" ")
|
23
|
-
@logger.debug "Build NUnit Test Runner Command Line: " + commandline
|
24
|
-
commandline
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_command_parameters
|
28
|
-
command_params = []
|
29
|
-
command_params << @options.join(" ") unless @options.nil?
|
30
|
-
command_params << @assemblies.map{|asm| "\"#{asm}\""}.join(' ') unless @assemblies.nil?
|
31
|
-
command_params
|
32
|
-
end
|
33
|
-
|
34
|
-
def execute()
|
35
|
-
command_params = get_command_parameters
|
36
|
-
result = run_command "NUnit", command_params.join(" ")
|
37
|
-
|
38
|
-
failure_message = 'NUnit Failed. See Build Log For Detail'
|
39
|
-
fail_with_message failure_message if !result
|
40
|
-
end
|
41
|
-
end
|
1
|
+
require 'albacore/albacoretask'
|
2
|
+
|
3
|
+
class NUnitTestRunner
|
4
|
+
TaskName = :nunit
|
5
|
+
include Albacore::Task
|
6
|
+
include Albacore::RunCommand
|
7
|
+
|
8
|
+
attr_array :assemblies, :options
|
9
|
+
|
10
|
+
def initialize(command=nil)
|
11
|
+
@options=[]
|
12
|
+
@assemblies=[]
|
13
|
+
super()
|
14
|
+
update_attributes Albacore.configuration.nunit.to_hash
|
15
|
+
@command = command unless command.nil?
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_command_line
|
19
|
+
command_params = []
|
20
|
+
command_params << @command
|
21
|
+
command_params << get_command_parameters
|
22
|
+
commandline = command_params.join(" ")
|
23
|
+
@logger.debug "Build NUnit Test Runner Command Line: " + commandline
|
24
|
+
commandline
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_command_parameters
|
28
|
+
command_params = []
|
29
|
+
command_params << @options.join(" ") unless @options.nil?
|
30
|
+
command_params << @assemblies.map{|asm| "\"#{asm}\""}.join(' ') unless @assemblies.nil?
|
31
|
+
command_params
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute()
|
35
|
+
command_params = get_command_parameters
|
36
|
+
result = run_command "NUnit", command_params.join(" ")
|
37
|
+
|
38
|
+
failure_message = 'NUnit Failed. See Build Log For Detail'
|
39
|
+
fail_with_message failure_message if !result
|
40
|
+
end
|
41
|
+
end
|
data/lib/albacore/nuspec.rb
CHANGED
@@ -1,109 +1,133 @@
|
|
1
|
-
require 'albacore/albacoretask'
|
2
|
-
require 'rexml/document'
|
3
|
-
|
4
|
-
class NuspecFile
|
5
|
-
def initialize(src, target)
|
6
|
-
@src = src
|
7
|
-
@target = target
|
8
|
-
end
|
9
|
-
|
10
|
-
def render(xml)
|
11
|
-
depend = xml.add_element 'file', { 'src' => @src }
|
12
|
-
|
13
|
-
depend.add_attribute( 'target', @target ) unless @target.nil?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class NuspecDependency
|
18
|
-
|
19
|
-
attr_accessor :id, :version
|
20
|
-
|
21
|
-
def initialize(id, version)
|
22
|
-
@id = id
|
23
|
-
@version = version
|
24
|
-
end
|
25
|
-
|
26
|
-
def render( xml )
|
27
|
-
depend = xml.add_element 'dependency', {'id' => @id, 'version' => @version}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
1
|
+
require 'albacore/albacoretask'
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
class NuspecFile
|
5
|
+
def initialize(src, target)
|
6
|
+
@src = src
|
7
|
+
@target = target
|
8
|
+
end
|
9
|
+
|
10
|
+
def render(xml)
|
11
|
+
depend = xml.add_element 'file', { 'src' => @src }
|
12
|
+
|
13
|
+
depend.add_attribute( 'target', @target ) unless @target.nil?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class NuspecDependency
|
18
|
+
|
19
|
+
attr_accessor :id, :version
|
20
|
+
|
21
|
+
def initialize(id, version)
|
22
|
+
@id = id
|
23
|
+
@version = version
|
24
|
+
end
|
25
|
+
|
26
|
+
def render( xml )
|
27
|
+
depend = xml.add_element 'dependency', {'id' => @id, 'version' => @version}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class NuspecFrameworkAssembly
|
32
|
+
|
33
|
+
attr_accessor :name, :target_framework
|
34
|
+
|
35
|
+
def initialize(name, target_framework)
|
36
|
+
@name = name
|
37
|
+
@target_framework = target_framework
|
38
|
+
end
|
39
|
+
|
40
|
+
def render( xml )
|
41
|
+
depend = xml.add_element 'frameworkAssembly', {'assemblyName' => @name, 'targetFramework' => @target_framework}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Nuspec
|
46
|
+
include Albacore::Task
|
47
|
+
|
48
|
+
attr_accessor :id, :version, :title, :authors, :description, :language, :licenseUrl, :projectUrl, :output_file,
|
49
|
+
:owners, :summary, :iconUrl, :requireLicenseAcceptance, :tags, :working_directory
|
50
|
+
|
51
|
+
def initialize()
|
52
|
+
@dependencies = Array.new
|
53
|
+
@files = Array.new
|
54
|
+
@frameworkAssemblies = Array.new
|
55
|
+
super()
|
56
|
+
end
|
57
|
+
|
58
|
+
def dependency(id, version)
|
59
|
+
@dependencies.push NuspecDependency.new(id, version)
|
60
|
+
end
|
61
|
+
|
62
|
+
def file(src, target=nil)
|
63
|
+
@files.push NuspecFile.new(src, target)
|
64
|
+
end
|
65
|
+
|
66
|
+
def framework_assembly(name, target_framework)
|
67
|
+
@frameworkAssemblies.push NuspecFrameworkAssembly.new(name, target_framework)
|
68
|
+
end
|
69
|
+
|
70
|
+
def execute
|
71
|
+
check_required_field @output_file, "output_file"
|
72
|
+
check_required_field @id, "id"
|
73
|
+
check_required_field @version, "version"
|
74
|
+
check_required_field @authors, "authors"
|
75
|
+
check_required_field @description, "description"
|
76
|
+
|
77
|
+
if(! @working_directory.nil?)
|
78
|
+
@working_output_file = File.join(@working_directory, @output_file)
|
79
|
+
else
|
80
|
+
@working_output_file = @output_file
|
81
|
+
end
|
82
|
+
|
83
|
+
builder = REXML::Document.new
|
84
|
+
build(builder)
|
85
|
+
output=""
|
86
|
+
builder.write(output)
|
87
|
+
|
88
|
+
File.open(@working_output_file, 'w') {|f| f.write(output) }
|
89
|
+
end
|
90
|
+
|
91
|
+
def build(document)
|
92
|
+
document << REXML::XMLDecl.new
|
93
|
+
|
94
|
+
package = document.add_element('package')
|
95
|
+
package.add_attribute("xmlns", "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd")
|
96
|
+
|
97
|
+
metadata = package.add_element('metadata')
|
98
|
+
|
99
|
+
metadata.add_element('id').add_text(@id)
|
100
|
+
metadata.add_element('version').add_text(@version)
|
101
|
+
metadata.add_element('title').add_text(@title)
|
102
|
+
metadata.add_element('authors').add_text(@authors)
|
103
|
+
metadata.add_element('description').add_text(@description)
|
104
|
+
metadata.add_element('language').add_text(@language) if !@language.nil?
|
105
|
+
metadata.add_element('licenseUrl').add_text(@licenseUrl) if !@licenseUrl.nil?
|
106
|
+
metadata.add_element('projectUrl').add_text(@projectUrl) if !@projectUrl.nil?
|
107
|
+
metadata.add_element('owners').add_text(@owners) if !@owners.nil?
|
108
|
+
metadata.add_element('summary').add_text(@summary) if !@summary.nil?
|
109
|
+
metadata.add_element('iconUrl').add_text(@iconUrl) if !@iconUrl.nil?
|
110
|
+
metadata.add_element('requireLicenseAcceptance').add_text(@requireLicenseAcceptance) if !@requireLicenseAcceptance.nil?
|
111
|
+
metadata.add_element('tags').add_text(@tags) if !@tags.nil?
|
112
|
+
|
113
|
+
if @dependencies.length > 0
|
114
|
+
depend = metadata.add_element('dependencies')
|
115
|
+
@dependencies.each {|x| x.render(depend)}
|
116
|
+
end
|
117
|
+
|
118
|
+
if @files.length > 0
|
119
|
+
files = package.add_element('files')
|
120
|
+
@files.each {|x| x.render(files)}
|
121
|
+
end
|
122
|
+
|
123
|
+
if @frameworkAssemblies.length > 0
|
124
|
+
depend = metadata.add_element('frameworkAssemblies')
|
125
|
+
@frameworkAssemblies.each {|x| x.render(depend)}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def check_required_field(field, fieldname)
|
130
|
+
return true if !field.nil?
|
131
|
+
raise "Nuget: required field '#{fieldname}' is not defined"
|
132
|
+
end
|
133
|
+
end
|