Sha256: 38421f3b51c99371921bfdfe753ba6482d3dbce4d4eef09cf1e49a942956ae12
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
#!/usr/bin/ruby require 'optparse' require 'pathname' require 'erb' require 'ostruct' require 'fileutils' include FileUtils # get templates directory @templates = Pathname.new(File.dirname(__FILE__)).realpath + '../templates' o = OpenStruct.new OptionParser.new do |opts| opts.on('-c', '--convert [FILE]') {|v| o.convert = true (o.convert_files ||= []) << v if v } opts.parse!(ARGV) end appname = ARGV.shift def convert(header) _, class_name, super_class = */@interface ([^\s]+) : ([^\s]+)/.match(header) outlets = header.scan(/IBOutlet id (.*?);/) actions = header.scan(/^- \(IBAction\)(.*?):\(id\)sender;/) result = ERB.new((@templates + 'class.erb').read, $SAFE, '-').result(binding) end if o.convert if o.convert_files # convert specific *.h o.convert_files.each do |f| f = Pathname.new f target = Pathname.new "#{f.basename(".h")}.rb" puts "Converting #{f} to #{target}..." result = convert(f.read) target.open("w") do |f| f.puts result end end else # convert all *.h Pathname.glob('*.h') do |f| target = Pathname.new "#{f.basename(".h")}.rb" if target.exist? "#{target} is already exists. skip.." next end puts "Converting #{f} to #{target}..." result = convert(f.read) target.open("w") do |f| f.puts result end end end end if appname puts "creating: #{appname}" mkdir appname cd appname do appname = appname.capitalize %w(Rakefile README).each do |file| puts "creating: #{file}" File.open(file, 'w') do |f| f.write ERB.new((@templates + 'Rakefile').read).result(binding) end end puts "creating: other templates" cp_r %w(Info.plist.erb main.rb main.m English.lproj).map{|f| @templates + f}, '.' mkdir 'html' end puts 'NOW, Edit Rakefile' end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
newcocoa-0.0.3 | bin/newcocoa |
newcocoa-0.0.2 | bin/newcocoa |