Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created September 5, 2012 21:53
Show Gist options
  • Select an option

  • Save havenwood/3645626 to your computer and use it in GitHub Desktop.

Select an option

Save havenwood/3645626 to your computer and use it in GitHub Desktop.
Create an OS X .app Executable With Your Choice Of Language For Script
module MacApp
class << self
def new
ask_name
ask_file_extension
ask_language
create_directories
create_files
end
def run
system "open #@name"
end
private
def ask_name
print 'App Name: '
@name = gets.chomp.split.map(&:capitalize).join << '.app'
end
def ask_file_extension
print 'File Extension: '
@ext = gets.chomp.delete('.').downcase
end
def ask_language
print 'Language: '
@lang = gets.chomp.downcase
end
def create_directories
Dir.mkdir @name
Dir.mkdir "#@name/Contents"
Dir.mkdir "#@name/Contents/MacOS"
Dir.mkdir "#@name/Contents/Resources"
end
def create_files
File.open "#@name/Contents/Info.plist", 'w'
File.open "#@name/Contents/MacOS/app.#@ext", 'w'
File.open "#@name/Contents/Resources/#@name.icns", 'w'
end
end
end
MacApp.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment