Sha256: 6e92ddb9c7e0afa3357373c63d35daec8ab14192297e5f687008fa6aa4d1bf4d

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

#!/usr/bin/env ruby

require 'fileutils'

if ARGV.size != 1
  $stderr.puts 'Usage: joybox <command> [<args...>]'
  $stderr.puts 'Commands:'
  $stderr.puts '  install '.ljust(15) + 'Installs the Joybox RubyMotion Templates and Commands'
  $stderr.puts '  uninstall '.ljust(15) + 'Uninstall the Joybox RubyMotion Templates and Commands'
  exit 1
end

if ARGV[0] == 'install'
  ruby_motion_directory = File.expand_path('~/Library/RubyMotion')
  template_directory = File.join(ruby_motion_directory, 'template')
  command_directory = File.join(ruby_motion_directory, 'command')

  FileUtils.mkdir_p(template_directory) unless File.directory?(template_directory)
  FileUtils.mkdir_p(command_directory) unless File.directory?(command_directory)

  joybox_template_directory = File.expand_path('../../template/', __FILE__)
  FileUtils.cp_r(Dir.glob("#{joybox_template_directory}/*"), template_directory)

  joybox_command_directory = File.expand_path('../../command', __FILE__)
  FileUtils.cp_r(Dir.glob("#{joybox_command_directory}/*"), command_directory)

  $stderr.puts 'Joybox RubyMotion Templates and Commands installed correctly'
end


if ARGV[0] == 'uninstall'
  ruby_motion_directory = File.expand_path('~/Library/RubyMotion')
  template_directory = File.join(ruby_motion_directory, 'template')
  command_directory = File.join(ruby_motion_directory, 'command')

  joybox_template_directory = File.expand_path('../../template', __FILE__)

  Dir.glob("#{joybox_template_directory}/**").each do |directory|
    directory = File.expand_path(File.basename(directory), template_directory)
    FileUtils.rm_r(directory) if File.exists?(directory)
  end

  Dir.glob("#{joybox_command_directory}/*").each do |directory|
    directory = File.expand_path(File.basename(directory), command_directory)
    FileUtils.rm_r(directory) if File.exists?(directory)
  end

  $stderr.puts 'Joybox RubyMotion Templates and Commands uninstalled correctly'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
joybox-1.0.0 bin/joybox
joybox-0.0.6 bin/joybox