albacore 0.2.3 → 0.2.4
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/README.markdown +9 -4
- data/VERSION +1 -1
- data/lib/albacore/assemblyinfo.rb +64 -33
- data/lib/albacore/assemblyinfolanguages/csharpengine.rb +6 -2
- data/lib/albacore/assemblyinfolanguages/vbnetengine.rb +6 -2
- data/lib/albacore/nuspec.rb +1 -1
- data/rakefile.rb +21 -7
- data/spec/assemblyinfo_spec.rb +34 -0
- data/spec/nuspec_spec.rb +53 -20
- data/spec/support/assemblyinfotester.rb +8 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -80,20 +80,25 @@ Anyone can fork the main repository and submit patches, as well. And lastly, the
|
|
80
80
|
Many thanks for contributions to albacore are due (in alphabetical order):
|
81
81
|
|
82
82
|
* [Andreone](http://github.com/Andreone): Significant Wiki contributions, questions and contributions on the google group
|
83
|
+
* [Andrew Vos](http://github.com/AndrewVos): Fixes and additions to SQLCmd task
|
83
84
|
* [Ben Hall](http://github.com/benhall): Primary contributor. SSH, SFTP, ZipDirectory, Rename, YAML auto config, Wiki pages, and many other great additions
|
84
85
|
* [Brett Veenstra](http://github.com/brettveenstra): SQLCmd options (truted connection, batch abort), etc
|
85
86
|
* [Brian Donahue](http://github.com/briandonahue): Inspiration and initial code for the ExpandTemplates task
|
86
|
-
* [
|
87
|
-
* [Hernan Garcia](http://github.com/hgarcia
|
87
|
+
* [Dotan Nahum](http://github.com/jondot): NChurn task, Output task
|
88
|
+
* [Hernan Garcia](http://github.com/hgarcia): Specflow Report task
|
88
89
|
* [Hibri Marzook](http://github.com/hibri): PLink (deprecated) and NDepend tasks
|
89
90
|
* [James Gregory](http://github.com/jagregory): Docu task, zip task contributions
|
90
91
|
* [Kevin Colyar](http://github.com/kevincolyar): Testing and updating of MSBuild to work with Cygwin
|
91
92
|
* [Louis Salin](http://github.com/louissalin): Support for *nix path separators in CSC task
|
93
|
+
* [Mark Boltuc](http://github.com/mboltuc): Fluent Migrator task
|
92
94
|
* [Mark Wilkins](http://github.com/markwilk): VB.NET Language Generator For The AssemblyInfo Task
|
93
95
|
* [Mike Nichols](http://github.com/mnichols): XUnit contributions, bug reports, etc
|
96
|
+
* [Nathan Fisher](:http://github.com/nfisher): additions to CSC task
|
94
97
|
* [Nils Jonsson](http://github.com/njonsson): AssemblyInfo corrections, rakefile corrections
|
95
|
-
* [Prabir Shrestha](http://github.com/prabirshrestha):
|
98
|
+
* [Prabir Shrestha](http://github.com/prabirshrestha): Nupack task, bug fixes for xunit test runner, etc.
|
99
|
+
* [Panda Wood](http://github.com/pandawood): NCover Console options and wiki edits
|
96
100
|
* [Sean Biefeld](http://github.com/seanbiefeld): MSpecTestRunner for NCoverConsole
|
97
101
|
* [Steven Harman](http://github.com/stevenharman): Primary contributor. Nant task, issue tickets, disucssions, and much much more.
|
102
|
+
* [Steve Hebert](http://github.com/stevehebert): Nuspec task
|
98
103
|
* [Steven Johnson](http://github.com/2020steve): Expand Templates (deprecated task) supplimental data, etc
|
99
|
-
* [
|
104
|
+
* [Tobias Grimm](http://github.com/e-tobi): AssemblyInfo custom_data, working directory code refactoring, relative project paths for executables
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
@@ -5,7 +5,8 @@ require 'albacore/assemblyinfolanguages/vbnetengine'
|
|
5
5
|
class AssemblyInfo
|
6
6
|
include Albacore::Task
|
7
7
|
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :input_file, :output_file
|
9
|
+
attr_accessor :version, :title, :description, :custom_attributes
|
9
10
|
attr_accessor :copyright, :com_visible, :com_guid, :company_name, :product_name
|
10
11
|
attr_accessor :file_version, :trademark, :lang_engine, :custom_data
|
11
12
|
|
@@ -18,22 +19,42 @@ class AssemblyInfo
|
|
18
19
|
super()
|
19
20
|
update_attributes Albacore.configuration.assemblyinfo.to_hash
|
20
21
|
end
|
22
|
+
|
23
|
+
def use(file)
|
24
|
+
@input_file = @output_file = file
|
25
|
+
end
|
21
26
|
|
22
27
|
def execute
|
23
28
|
@lang_engine = CSharpEngine.new unless check_lang_engine
|
24
|
-
write_assemblyinfo @output_file
|
29
|
+
write_assemblyinfo @output_file, @input_file
|
25
30
|
end
|
26
31
|
|
27
|
-
def write_assemblyinfo(assemblyinfo_file)
|
32
|
+
def write_assemblyinfo(assemblyinfo_file, input_file)
|
28
33
|
valid = check_output_file assemblyinfo_file
|
29
34
|
return if !valid
|
30
|
-
|
31
|
-
|
35
|
+
|
36
|
+
input_data = read_input_file input_file
|
37
|
+
asm_data = build_assembly_info_data input_data
|
32
38
|
|
33
39
|
@logger.info "Generating Assembly Info File At: " + File.expand_path(assemblyinfo_file)
|
34
40
|
File.open(assemblyinfo_file, 'w') do |f|
|
35
|
-
|
41
|
+
asm_data.each do |line|
|
42
|
+
f.puts line
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def read_input_file(file)
|
48
|
+
data = []
|
49
|
+
return data if file.nil?
|
50
|
+
|
51
|
+
File.open(file, 'r') do |file|
|
52
|
+
file.each_line do |line|
|
53
|
+
data << line.strip
|
54
|
+
end
|
36
55
|
end
|
56
|
+
|
57
|
+
data
|
37
58
|
end
|
38
59
|
|
39
60
|
def check_output_file(file)
|
@@ -46,35 +67,51 @@ class AssemblyInfo
|
|
46
67
|
return !@lang_engine.nil?
|
47
68
|
end
|
48
69
|
|
49
|
-
def build_assembly_info_data
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
70
|
+
def build_assembly_info_data(data)
|
71
|
+
if data.empty?
|
72
|
+
data = build_using_statements
|
73
|
+
end
|
74
|
+
|
75
|
+
build_attribute(data, "AssemblyTitle", @title) if @title != nil
|
76
|
+
build_attribute(data, "AssemblyDescription", @description) if @description != nil
|
77
|
+
build_attribute(data, "AssemblyCompany", @company_name) if @company_name != nil
|
78
|
+
build_attribute(data, "AssemblyProduct", @product_name) if @product_name != nil
|
56
79
|
|
57
|
-
|
58
|
-
|
80
|
+
build_attribute(data, "AssemblyCopyright", @copyright) if @copyright != nil
|
81
|
+
build_attribute(data, "AssemblyTrademark", @trademark) if @trademark != nil
|
59
82
|
|
60
|
-
|
61
|
-
|
83
|
+
build_attribute(data, "ComVisible", @com_visible) if @com_visible != nil
|
84
|
+
build_attribute(data, "Guid", @com_guid) if @com_guid != nil
|
62
85
|
|
63
|
-
|
64
|
-
|
86
|
+
build_attribute(data, "AssemblyVersion", @version) if @version != nil
|
87
|
+
build_attribute(data, "AssemblyFileVersion", @file_version) if @file_version != nil
|
65
88
|
|
66
|
-
|
89
|
+
data << ""
|
67
90
|
if @custom_attributes != nil
|
68
91
|
attributes = build_custom_attributes()
|
69
|
-
|
70
|
-
|
92
|
+
data += attributes
|
93
|
+
data << ""
|
71
94
|
end
|
72
|
-
|
95
|
+
|
73
96
|
if @custom_data != nil
|
74
|
-
@custom_data.each
|
97
|
+
@custom_data.each do |cdata|
|
98
|
+
data << cdata unless data.include? cdata
|
99
|
+
end
|
75
100
|
end
|
76
101
|
|
77
|
-
|
102
|
+
data
|
103
|
+
end
|
104
|
+
|
105
|
+
def build_attribute(data, attr_name, attr_data)
|
106
|
+
attr_value = @lang_engine.build_attribute(attr_name, attr_data)
|
107
|
+
attr_re = @lang_engine.build_attribute_re(attr_name)
|
108
|
+
result = nil
|
109
|
+
@logger.debug "Build Assembly Info Attribute: " + attr_value
|
110
|
+
data.each do |line|
|
111
|
+
break unless result.nil?
|
112
|
+
result = line.sub! attr_re, attr_value
|
113
|
+
end
|
114
|
+
data << attr_value if result.nil?
|
78
115
|
end
|
79
116
|
|
80
117
|
def build_using_statements
|
@@ -84,7 +121,7 @@ class AssemblyInfo
|
|
84
121
|
@namespaces << "System.Runtime.InteropServices"
|
85
122
|
@namespaces.uniq!
|
86
123
|
|
87
|
-
ns =
|
124
|
+
ns = []
|
88
125
|
@namespaces.each do |n|
|
89
126
|
ns << @lang_engine.build_using_statement(n)
|
90
127
|
end
|
@@ -92,16 +129,10 @@ class AssemblyInfo
|
|
92
129
|
ns
|
93
130
|
end
|
94
131
|
|
95
|
-
def build_attribute(attr_name, attr_data)
|
96
|
-
attribute = @lang_engine.build_attribute(attr_name, attr_data)
|
97
|
-
@logger.debug "Build Assembly Info Attribute: " + attribute
|
98
|
-
attribute
|
99
|
-
end
|
100
|
-
|
101
132
|
def build_custom_attributes()
|
102
133
|
attributes = []
|
103
134
|
@custom_attributes.each do |key, value|
|
104
|
-
attributes << build_attribute(key, value)
|
135
|
+
attributes << @lang_engine.build_attribute(key, value)
|
105
136
|
end
|
106
137
|
attributes
|
107
138
|
end
|
@@ -1,14 +1,18 @@
|
|
1
1
|
class CSharpEngine
|
2
|
+
def build_attribute_re(attr_name)
|
3
|
+
/^\[assembly: #{attr_name}(.+)/
|
4
|
+
end
|
5
|
+
|
2
6
|
def build_attribute(attr_name, attr_data)
|
3
7
|
attribute = "[assembly: #{attr_name}("
|
4
8
|
attribute << "#{attr_data.inspect}" if attr_data != nil
|
5
|
-
attribute << ")]
|
9
|
+
attribute << ")]"
|
6
10
|
|
7
11
|
attribute
|
8
12
|
end
|
9
13
|
|
10
14
|
def build_using_statement(namespace)
|
11
|
-
"using #{namespace}
|
15
|
+
"using #{namespace};"
|
12
16
|
end
|
13
17
|
|
14
18
|
end
|
@@ -1,14 +1,18 @@
|
|
1
1
|
class VbNetEngine
|
2
|
+
def build_attribute_re(attr_name)
|
3
|
+
/^\<assembly: #{attr_name}(.+)/
|
4
|
+
end
|
5
|
+
|
2
6
|
def build_attribute(attr_name, attr_data)
|
3
7
|
attribute = "<assembly: #{attr_name}("
|
4
8
|
attribute << "#{attr_data.inspect}" if attr_data != nil
|
5
|
-
attribute << ")
|
9
|
+
attribute << ")>"
|
6
10
|
|
7
11
|
attribute
|
8
12
|
end
|
9
13
|
|
10
14
|
def build_using_statement(namespace)
|
11
|
-
"Imports #{namespace}
|
15
|
+
"Imports #{namespace}"
|
12
16
|
end
|
13
17
|
|
14
18
|
end
|
data/lib/albacore/nuspec.rb
CHANGED
data/rakefile.rb
CHANGED
@@ -134,13 +134,14 @@ namespace :albacore do
|
|
134
134
|
|
135
135
|
desc "Run a complete Albacore build sample"
|
136
136
|
task :sample => ['albacore:assemblyinfo',
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
137
|
+
'albacore:assemblyinfo_modify',
|
138
|
+
'albacore:msbuild',
|
139
|
+
'albacore:ncoverconsole',
|
140
|
+
'albacore:ncoverreport',
|
141
|
+
'albacore:mspec',
|
142
|
+
'albacore:nunit',
|
143
|
+
'albacore:xunit',
|
144
|
+
'albacore:fluentmigrator']
|
144
145
|
|
145
146
|
desc "Run a sample MSBuild with YAML autoconfig"
|
146
147
|
msbuild :msbuild
|
@@ -157,6 +158,19 @@ namespace :albacore do
|
|
157
158
|
|
158
159
|
asm.output_file = "spec/support/AssemblyInfo/AssemblyInfo.cs"
|
159
160
|
end
|
161
|
+
|
162
|
+
desc "Run a sample assembly info modifier"
|
163
|
+
assemblyinfo :assemblyinfo_modify do|asm|
|
164
|
+
# modify existing
|
165
|
+
asm.version = "0.1.2.3"
|
166
|
+
asm.company_name = "a test company"
|
167
|
+
|
168
|
+
# new attribute
|
169
|
+
asm.file_version = "4.5.6.7"
|
170
|
+
|
171
|
+
asm.input_file = "spec/support/AssemblyInfo/AssemblyInfoInput.test"
|
172
|
+
asm.output_file = "spec/support/AssemblyInfo/AssemblyInfoOutput.cs"
|
173
|
+
end
|
160
174
|
|
161
175
|
desc "Run a sample NCover Console code coverage"
|
162
176
|
ncoverconsole do |ncc|
|
data/spec/assemblyinfo_spec.rb
CHANGED
@@ -505,3 +505,37 @@ describe AssemblyInfo, "when specifying custom data" do
|
|
505
505
|
@filedata.scan('// bar').length.should == 1
|
506
506
|
end
|
507
507
|
end
|
508
|
+
|
509
|
+
describe AssemblyInfo, "when an input file is provided" do
|
510
|
+
before :all do
|
511
|
+
@tester = AssemblyInfoTester.new
|
512
|
+
asm = AssemblyInfo.new
|
513
|
+
|
514
|
+
asm.version = @tester.version
|
515
|
+
asm.file_version = @tester.file_version
|
516
|
+
|
517
|
+
asm.custom_data "// foo", "// baz"
|
518
|
+
|
519
|
+
# make it use existing file
|
520
|
+
@tester.use_input_file
|
521
|
+
|
522
|
+
# Generate the same file twice.
|
523
|
+
@tester.build_and_read_assemblyinfo_file asm
|
524
|
+
@filedata = @tester.build_and_read_assemblyinfo_file asm
|
525
|
+
end
|
526
|
+
it "should contain correct version attribute" do
|
527
|
+
@filedata.scan(%Q|[assembly: AssemblyVersion("#{@tester.version}")]|).length.should == 1
|
528
|
+
end
|
529
|
+
it "shoud leave comment untouched" do
|
530
|
+
@filedata.scan(%Q|// A comment we want to see maintained|).length.should == 1
|
531
|
+
end
|
532
|
+
it "should introduce a new fileversion attribute" do
|
533
|
+
@filedata.scan(%Q|[assembly: AssemblyFileVersion("#{@tester.file_version}")]|).length.should == 1
|
534
|
+
end
|
535
|
+
it "should still leave custom data that's already in there intact" do
|
536
|
+
@filedata.scan(%Q|// foo|).length.should == 1
|
537
|
+
end
|
538
|
+
it "should add custom data that's still missing" do
|
539
|
+
@filedata.scan(%Q|// baz|).length.should == 1
|
540
|
+
end
|
541
|
+
end
|
data/spec/nuspec_spec.rb
CHANGED
@@ -8,37 +8,70 @@ else
|
|
8
8
|
require 'support\nokogiri_validator'
|
9
9
|
end
|
10
10
|
|
11
|
-
describe Nuspec
|
11
|
+
describe Nuspec do
|
12
12
|
let(:working_dir) do
|
13
13
|
wd = File.expand_path(File.join(File.dirname(__FILE__), 'support/nuspec/output'))
|
14
14
|
FileUtils.mkdir(wd) unless File.exist?(wd)
|
15
15
|
wd
|
16
16
|
end
|
17
|
-
|
18
17
|
let(:nuspec_output) { File.join(working_dir, 'nuspec_test.nuspec') }
|
19
18
|
let(:schema_file) { File.expand_path(File.join(working_dir, '../', 'nuspec.xsd')) }
|
20
19
|
|
21
|
-
|
22
|
-
nuspec
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
describe 'when creating a file with minimum requirements' do
|
21
|
+
let(:nuspec) do
|
22
|
+
nuspec = Nuspec.new
|
23
|
+
nuspec.id="nuspec_test"
|
24
|
+
nuspec.output_file = "nuspec_test.nuspec"
|
25
|
+
nuspec.version = "1.2.3"
|
26
|
+
nuspec.authors = "Author Name"
|
27
|
+
nuspec.description = "test_xml_document"
|
28
|
+
nuspec.working_directory = working_dir
|
29
|
+
nuspec
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
before do
|
33
|
+
nuspec.execute
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should produce the nuspec xml" do
|
37
|
+
File.exist?(nuspec_output).should be_true
|
38
|
+
end
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
it "should produce a valid xml file" do
|
41
|
+
is_valid = XmlValidator.validate(nuspec_output, schema_file)
|
42
|
+
is_valid.should be_true
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
describe "file targets" do
|
47
|
+
let(:dll) { File.expand_path(File.join(working_dir, '../', 'somedll.dll')) }
|
48
|
+
|
49
|
+
let(:nuspec) do
|
50
|
+
nuspec = Nuspec.new
|
51
|
+
nuspec.id="nuspec_test"
|
52
|
+
nuspec.output_file = "nuspec_test.nuspec"
|
53
|
+
nuspec.version = "1.2.3"
|
54
|
+
nuspec.authors = "Author Name"
|
55
|
+
nuspec.description = "test_xml_document"
|
56
|
+
nuspec.working_directory = working_dir
|
57
|
+
nuspec.file(dll, "lib")
|
58
|
+
nuspec
|
59
|
+
end
|
60
|
+
|
61
|
+
before do
|
62
|
+
nuspec.execute
|
63
|
+
File.open(nuspec_output, "r") do |f|
|
64
|
+
@filedata = f.read
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should produce a valid nuspec file" do
|
69
|
+
is_valid = XmlValidator.validate(nuspec_output, schema_file)
|
70
|
+
is_valid.should be_true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should contain the file and it's target" do
|
74
|
+
@filedata.should include("<file src='C:/dev/albacore/spec/support/nuspec/somedll.dll' target='lib'/>")
|
75
|
+
end
|
43
76
|
end
|
44
77
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'albacore/assemblyinfo'
|
2
2
|
|
3
3
|
class AssemblyInfoTester < AssemblyInfo
|
4
|
-
|
4
|
+
|
5
5
|
attr_accessor :assemblyinfo_file
|
6
6
|
|
7
7
|
def initialize(lang_engine = nil)
|
@@ -15,6 +15,8 @@ class AssemblyInfoTester < AssemblyInfo
|
|
15
15
|
@product_name = "my product, yo."
|
16
16
|
@file_version = "1.0.0.0"
|
17
17
|
@trademark = "some trademark info goes here"
|
18
|
+
|
19
|
+
@input_file = nil
|
18
20
|
end
|
19
21
|
|
20
22
|
def setup_assemblyinfo_file
|
@@ -23,10 +25,15 @@ class AssemblyInfoTester < AssemblyInfo
|
|
23
25
|
@assemblyinfo_file = File.join(File.dirname(__FILE__), "AssemblyInfo", "AssemblyInfo.test")
|
24
26
|
File.delete @assemblyinfo_file if File.exist? @assemblyinfo_file
|
25
27
|
end
|
28
|
+
|
29
|
+
def use_input_file
|
30
|
+
@input_file = File.join(File.dirname(__FILE__), "AssemblyInfo", "AssemblyInfoInput.test")
|
31
|
+
end
|
26
32
|
|
27
33
|
def build_and_read_assemblyinfo_file(assemblyinfo)
|
28
34
|
setup_assemblyinfo_file
|
29
35
|
|
36
|
+
assemblyinfo.input_file = @input_file unless @input_file.nil?
|
30
37
|
assemblyinfo.output_file = @assemblyinfo_file
|
31
38
|
assemblyinfo.execute
|
32
39
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 4
|
9
|
+
version: 0.2.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Derick Bailey
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-03-
|
20
|
+
date: 2011-03-06 00:00:00 -06:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|