Sha256: ee6cd2dcd944c61ff26ba7a5fde2edeb56802c66a344d1526666727b83e02519

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

require 'furoshiki/base_app'
require 'plist'

module Furoshiki
  class MacApp < BaseApp
    private

    def app_name
      "#{config.name}.app"
    end

    def archive_name
      "#{config.name}-mac.tar.gz"
    end

    def template_basename
      'mac-app-template'
    end

    def latest_template_version
      '0.0.3'
    end

    def remote_template_url
      "https://github.com/shoes/mac-app-templates/releases/download/v#{latest_template_version}/mac-app-template-#{latest_template_version}.zip"
    end

    def inject_jar
      jar_path = ensure_jar_exists
      cp Pathname.new(jar_path), File.join(tmp_app_path, "Contents", "Java", "app.jar")
    end

    def inject_files
      inject_icon
      inject_config
    end

    def inject_config
      plist = tmp_app_path.join 'Contents/Info.plist'
      template = Plist.parse_xml(plist)
      template['CFBundleIdentifier'] = "com.hackety.shoes.#{config.shortname}"
      template['CFBundleDisplayName'] = config.name
      template['CFBundleName'] = config.name
      template['CFBundleVersion'] = config.version
      template['CFBundleIconFile'] = Pathname.new(config.icons[:osx]).basename.to_s if config.icons[:osx]
      File.open(plist, 'w') { |f| f.write template.to_plist }
    end

    def inject_icon
      if config.icons[:osx]
        icon_path = working_dir.join(config.icons[:osx])
        raise IOError, "Couldn't find app icon at #{icon_path}" unless icon_path.exist?
        resources_dir = tmp_app_path.join('Contents/Resources')
        cp icon_path, resources_dir.join(icon_path.basename)
      end
    end

    def executable_path
      app_path.join('Contents/MacOS/app')
    end

    def tmp_app_path
      tmp.join "#{template_basename}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
furoshiki-0.6.0 lib/furoshiki/mac_app.rb