Class: Rant::Generators::Resgen

Inherits:
Object
  • Object
show all
Defined in:
lib/rant/import/resgen.rb

Overview

Create a file task for compiling resources

Class Method Summary collapse

Class Method Details

.rant_gen(rant, ch, args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rant/import/resgen.rb', line 3

def self.rant_gen(rant, ch, args, &block)   
  gen_args = args.shift
  gen_args[:build_dir] ||= ''
  gen_args[:build_dir] += '/' if !gen_args[:build_dir].empty?
  gen_args[:namespace] ||= ''
  gen_args[:namespace] += '.' if !gen_args[:namespace].empty?
  prefix = Regexp.escape(gen_args[:build_dir] + gen_args[:namespace])
  regex = Regexp.new("#{prefix}(.+?)\\.resources")
  
  src = lambda { |target| 
    [regex.match(target)[1].gsub(/\./, "/") + ".resx"] 
  }
  
  rant.context.gen Rant::Generators::Rule, regex => src do |t|
    rant.context.sys.sh "resgen /useSourcePath /compile " + 
                        rant.context.sys.sp("#{t.source},#{t.name}")
  end
end