Sha256: c3412453dbfc87d276cdbf5904fdcad8d757efe5dee78b3dc680a10bf394d0e6

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

require 'fileutils'
require 'ib/version'
require 'ib/parser'
require 'xcodeproj'

class IB::Generator
  def write src, dest
    files = IB::Parser.new.find_all(src)

    FileUtils.mkpath dest

    File.open("#{dest}/stubs.h", 'w') do |f|
      f.write <<-OBJC
// Generated by IB v#{IB::VERSION} gem. Do not edit it manually
// Run `rake design` to refresh

#import <UIKit/UIKit.h>

#{generate_objc(files)}
OBJC
    end
    
  end

  def generate_objc files
    src = files.map do |path, info|
<<-OBJC
@interface #{info[:class][0][0]} : #{info[:class][0][1]}

#{info[:outlets].map {|name, type| "@property IBOutlet #{type} * #{name};" }.join("\n")}

#{info[:actions].map {|action| "-(IBAction) #{action[0]}:(id) sender;" }.join("\n")}

@end
OBJC
    end.join("\n" * 2)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ib-0.0.2 lib/ib/generator.rb
ib-0.0.1 lib/ib/generator.rb