rake-dotnet 0.0.4 → 0.0.5

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 (4) hide show
  1. data/History.txt +12 -0
  2. data/Rakefile +1 -1
  3. data/lib/rake_dotnet.rb +104 -69
  4. metadata +2 -2
data/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 0.0.5 / 2009-04-03
2
+
3
+ * Support non-svn version-control. In this case, write today's date as YYYYMMDD into revision number of assembly version.
4
+ * Write ncover reports into out/reports/ncover, since there may be many, and there are some asset files too.
5
+ * Generate the {project}/Properties/AssemblyInfo.cs in place rather than making users add a link to the common one (friction)
6
+ * Generate the {project}/Properties/AssemblyInfo.cs from either a .template next-door, or the common template in {src_dir}
7
+ * Change the name of the AssemblyInfo template because if it ends in .cs msbuild assumes it should be compiled, which will then fail.
8
+
9
+ === 0.0.4 / 2009-03-31
10
+
11
+ * Gem publishing snafu on my part.
12
+
1
13
  === 0.0.3 / 2009-03-30
2
14
 
3
15
  * Bugfix release
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'hoe'
5
5
  require 'Pathname'
6
6
  require 'rake/clean'
7
7
 
8
- Hoe.new('rake-dotnet', '0.0.4') do |p|
8
+ Hoe.new('rake-dotnet', '0.0.5') do |p|
9
9
  p.author = 'Peter Mounce'
10
10
  p.description = 'Making a .NET build-automation dev\'s life easier, one angle-bracket at a time'
11
11
  p.email = 'pete@neverrunwithscissors.com'
data/lib/rake_dotnet.rb CHANGED
@@ -78,65 +78,89 @@ verbose(VERBOSE)
78
78
 
79
79
 
80
80
  module Rake
81
- class AssemblyInfoTask < Rake::TaskLib
82
- attr_accessor :name, :product_name, :configuration, :company_name, :version
81
+ class AssemblyInfoTask < Rake::TaskLib
82
+ attr_accessor :product_name, :configuration, :company_name, :version
83
83
 
84
- # Create an AssemblyInfo file-task; define a task to run it whose name is :assembly_info
85
- def initialize(name) # :yield: self
86
- @name = name
87
- yield self if block_given?
88
- define
89
- end
84
+ def initialize(params={})
85
+ @src_dir = params[:src_dir] || SRC_DIR
86
+ yield self if block_given?
87
+ define
88
+ end
90
89
 
91
- # Create the tasks defined by this task lib.
92
- def define
93
- file @name do
94
- template_file = Pathname.new(template)
95
- content = template_file.read
96
- token_replacements.each do |key,value|
97
- content = content.gsub(/(\$\{#{key}\})/, value.to_s)
98
- end
99
- of = Pathname.new(@name)
100
- of.delete if of.exist?
101
- of.open('w') { |f| f.puts content }
102
- end
103
-
104
- desc 'Generate the AssemblyInfo.cs file from the template'
105
- task :assembly_info => [@name]
90
+ def define
91
+ src_dir_regex = regexify(@src_dir)
92
+ rule(/#{src_dir_regex}\/[\w\.\d]+\/Properties\/AssemblyInfo.cs/) do |r|
93
+ nextdoor = Pathname.new(r.name + '.template')
94
+ common = Pathname.new(File.join(@src_dir, 'AssemblyInfo.cs.template'))
95
+ if (nextdoor.exist?)
96
+ generate(nextdoor, r.name)
97
+ elsif (common.exist?)
98
+ generate(common, r.name)
99
+ end
100
+ end
101
+
102
+ desc 'Generate the AssemblyInfo.cs file from the template closest'
103
+ task :assembly_info do |t|
104
+ # for each project, invoke the rule
105
+ Dir.foreach(@src_dir) do |e|
106
+ asm_info = File.join(@src_dir, e, 'Properties', 'AssemblyInfo.cs')
107
+ if is_project e
108
+ Rake::FileTask[asm_info].invoke
109
+ end
110
+ end
111
+ end
112
+
113
+ self
114
+ end
106
115
 
107
- self
108
- end
109
-
110
- def template
111
- @template_file ||= @name.sub(/\.cs/, '.template.cs')
112
- end
113
-
114
- def token_replacements
115
- r = {}
116
- r[:built_on] = Time.now
117
- r[:product] = product_name
118
- r[:configuration] = configuration
119
- r[:company] = company_name
120
- r[:version] = version
121
- return r
122
- end
123
-
124
- def product_name
125
- @product_name ||= 'NRWS rake_dotnet'
126
- end
127
-
128
- def configuration
129
- @configuration ||= 'Debug'
130
- end
131
-
132
- def company_name
133
- @company_name ||= 'NRWS'
134
- end
135
-
136
- def version
137
- @version ||= Versioner.new.get
138
- end
139
- end
116
+ def generate(template_file, destination)
117
+ content = template_file.read
118
+ token_replacements.each do |key, value|
119
+ content = content.gsub(/(\$\{#{key}\})/, value.to_s)
120
+ end
121
+ of = Pathname.new(destination)
122
+ of.delete if of.exist?
123
+ of.open('w') { |f| f.puts content }
124
+ end
125
+
126
+ def is_project entry
127
+ if (entry == '.' || entry == '..' || entry == '.svn')
128
+ return false
129
+ end
130
+ if (entry == 'AssemblyInfo.cs.template')
131
+ return false
132
+ end
133
+ #puts "#{entry} is directory? #{File.directory?(entry)}"
134
+ #return File.directory?(entry)
135
+ return true
136
+ end
137
+
138
+ def token_replacements
139
+ r = {}
140
+ r[:built_on] = Time.now
141
+ r[:product] = product_name
142
+ r[:configuration] = configuration
143
+ r[:company] = company_name
144
+ r[:version] = version
145
+ return r
146
+ end
147
+
148
+ def product_name
149
+ @product_name ||= 'NRWS rake_dotnet'
150
+ end
151
+
152
+ def configuration
153
+ @configuration ||= 'Debug'
154
+ end
155
+
156
+ def company_name
157
+ @company_name ||= 'NRWS'
158
+ end
159
+
160
+ def version
161
+ @version ||= Versioner.new.get
162
+ end
163
+ end
140
164
  end
141
165
 
142
166
 
@@ -473,7 +497,7 @@ module Rake
473
497
 
474
498
  @product_name = params[:product_name] || PRODUCT_NAME
475
499
  @bin_dir = params[:bin_dir] || File.join(OUT_DIR, 'bin')
476
- @report_dir = params[:report_dir] || File.join(OUT_DIR, 'reports')
500
+ @report_dir = params[:report_dir] || File.join(OUT_DIR, 'reports', 'ncover')
477
501
  @deps = params[:deps] || []
478
502
  tool_defaults = {:arch => 'x86'}
479
503
  @ncover_options = tool_defaults.merge(params[:ncover_options] || {})
@@ -525,7 +549,7 @@ module Rake
525
549
  task :ncover_summary => [:ncover_profile, ncover_summary_report_html]
526
550
 
527
551
  task :clean_coverage do
528
- rm_rf 'out/reports/*coverage-report*'
552
+ rm_rf @report_dir
529
553
  end
530
554
 
531
555
  self
@@ -803,17 +827,28 @@ end
803
827
 
804
828
 
805
829
  class Versioner
806
- def initialize(template_file=nil)
807
- tf = template_file || 'version.template.txt'
808
- template_file = Pathname.new(tf)
809
- @maj_min = template_file.read.chomp
810
- @build = ENV['BUILD_NUMBER'] || 0
811
- @svn_info = SvnInfo.new(:path => '.')
812
- end
813
-
814
- def get
815
- "#{@maj_min}.#{@build}.#{@svn_info.revision}"
816
- end
830
+ def initialize(template_file=nil)
831
+ tf = template_file || 'version.template.txt'
832
+ file = Pathname.new(tf)
833
+ @maj_min = file.read.chomp
834
+ end
835
+
836
+ def get
837
+ "#{@maj_min}.#{build}.#{revision}"
838
+ end
839
+
840
+ def build
841
+ ENV['BUILD_NUMBER'] || 0
842
+ end
843
+
844
+ def revision
845
+ if (Pathname.new('.svn').exist?)
846
+ SvnInfo.new(:path => '.').revision
847
+ else
848
+ now = Date.today
849
+ "#{now.to_s.gsub('-','')}"
850
+ end
851
+ end
817
852
  end
818
853
 
819
854
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-dotnet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter MouncePeter Mounce
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-31 00:00:00 +01:00
12
+ date: 2009-04-03 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency