Class: RakeDotNet::AssemblyInfoTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RakeDotNet::AssemblyInfoTask
- Defined in:
- lib/rake_dotnet.rb
Instance Attribute Summary collapse
-
#company_name ⇒ Object
Returns the value of attribute company_name.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#product_name ⇒ Object
Returns the value of attribute product_name.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #asm_info_to_generate(pn_entry) ⇒ Object
- #define ⇒ Object
- #generate(template_file, destination) ⇒ Object
-
#initialize(params = {}) {|_self| ... } ⇒ AssemblyInfoTask
constructor
A new instance of AssemblyInfoTask.
- #token_replacements ⇒ Object
Constructor Details
#initialize(params = {}) {|_self| ... } ⇒ AssemblyInfoTask
Returns a new instance of AssemblyInfoTask.
306 307 308 309 310 |
# File 'lib/rake_dotnet.rb', line 306 def initialize(params={}) @src_dir = params[:src_dir] || SRC_DIR yield self if block_given? define end |
Instance Attribute Details
#company_name ⇒ Object
Returns the value of attribute company_name.
304 305 306 |
# File 'lib/rake_dotnet.rb', line 304 def company_name @company_name end |
#configuration ⇒ Object
Returns the value of attribute configuration.
304 305 306 |
# File 'lib/rake_dotnet.rb', line 304 def configuration @configuration end |
#product_name ⇒ Object
Returns the value of attribute product_name.
304 305 306 |
# File 'lib/rake_dotnet.rb', line 304 def product_name @product_name end |
#version ⇒ Object
Returns the value of attribute version.
304 305 306 |
# File 'lib/rake_dotnet.rb', line 304 def version @version end |
Instance Method Details
#asm_info_to_generate(pn_entry) ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/rake_dotnet.rb', line 359 def asm_info_to_generate pn_entry if (pn_entry == '.' || pn_entry == '..' || pn_entry == '.svn') return nil end if (pn_entry == 'AssemblyInfo.cs.template' || pn_entry == 'AssemblyInfo.vb.template') return nil end proj = FileList.new("#{@src_dir}/#{pn_entry}/*.*proj").first return nil if proj.nil? proj_ext = Pathname.new(proj).extname path = case proj_ext when '.csproj' then File.join(@src_dir, pn_entry, 'Properties', 'AssemblyInfo.cs') when '.vbproj' then File.join(@src_dir, pn_entry, 'My Project', 'AssemblyInfo.vb') else nil end return path end |
#define ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/rake_dotnet.rb', line 312 def define src_dir_regex = RakeDotNet::regexify(@src_dir) rule(/#{src_dir_regex}\/[\w\.\d]+\/Properties\/AssemblyInfo.cs/) do |r| dir = Pathname.new(r.name).dirname mkdir_p dir nextdoor = Pathname.new(r.name + '.template') common = Pathname.new(File.join(@src_dir, 'AssemblyInfo.cs.template')) if (nextdoor.exist?) generate(nextdoor, r.name) elsif (common.exist?) generate(common, r.name) end end rule(/#{src_dir_regex}\/[\w\.\d]+\/My Project\/AssemblyInfo.vb/) do |r| dir = Pathname.new(r.name).dirname mkdir_p dir nextdoor = Pathname.new(r.name + '.template') common = Pathname.new(File.join(@src_dir, 'AssemblyInfo.vb.template')) if (nextdoor.exist?) generate(nextdoor, r.name) elsif (common.exist?) generate(common, r.name) end end desc 'Generate the AssemblyInfo.cs file from the template closest' task :assembly_info do |t| Pathname.new(@src_dir).entries.each do |e| asm_info = asm_info_to_generate(e) Rake::FileTask[asm_info].invoke unless asm_info.nil? end end self end |
#generate(template_file, destination) ⇒ Object
349 350 351 352 353 354 355 356 357 |
# File 'lib/rake_dotnet.rb', line 349 def generate(template_file, destination) content = template_file.read token_replacements.each do |key, value| content = content.gsub(/(\$\{#{key}\})/, value.to_s) end of = Pathname.new(destination) of.delete if of.exist? of.open('w') { |f| f.puts content } end |
#token_replacements ⇒ Object
383 384 385 386 387 388 389 390 391 |
# File 'lib/rake_dotnet.rb', line 383 def token_replacements r = {} r[:built_on] = Time.now r[:product] = product_name r[:configuration] = configuration r[:company] = company_name r[:version] = version return r end |