Class: U3d::Installation

Inherits:
Object
  • Object
show all
Defined in:
lib/u3d/installation.rb

Constant Summary collapse

NOT_PLAYBACKENGINE_PACKAGES =
%w[Documentation StandardAssets MonoDevelop].freeze
PACKAGE_ALIASES =
{
  'Android' => [],
  'iOS' => ['iPhone'],
  'AppleTV' => ['tvOS'],
  'Linux' => ['StandaloneLinux'],
  'Mac' => %w[StandaloneOSXIntel StandaloneOSXIntel64 StandaloneOSX],
  'Windows' => ['StandaloneWindows'],
  'Metro' => [],
  'UWP-IL2CPP' => [],
  'Samsung-TV' => [],
  'Tizen' => [],
  'WebGL' => [],
  'Facebook-Games' => ['Facebook'],
  'Vuforia-AR' => ['UnityExtensions']
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path: nil, path: nil) ⇒ Installation

Returns a new instance of Installation.



53
54
55
56
# File 'lib/u3d/installation.rb', line 53

def initialize(root_path: nil, path: nil)
  @root_path = root_path
  @path = path
end

Instance Attribute Details

#root_pathObject

Returns the value of attribute root_path.



33
34
35
# File 'lib/u3d/installation.rb', line 33

def root_path
  @root_path
end

Class Method Details

.create(root_path: nil, path: nil) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/u3d/installation.rb', line 58

def self.create(root_path: nil, path: nil)
  UI.deprecated("path is deprecated. Use root_path instead") unless path.nil?
  if Helper.mac?
    MacInstallation.new(root_path: root_path, path: path)
  elsif Helper.linux?
    LinuxInstallation.new(root_path: root_path, path: path)
  else
    WindowsInstallation.new(root_path: root_path, path: path)
  end
end

Instance Method Details

#do_not_move!(dry_run: false) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/u3d/installation.rb', line 77

def do_not_move!(dry_run: false)
  if dry_run
    UI.message "Would create '#{do_not_move_file_path}'"
  else
    begin
      FileUtils.touch do_not_move_file_path
    rescue Errno::EACCES => _e
      U3dCore::AdminTools.create_file(Helper.operating_system, do_not_move_file_path)
    end
  end
end

#do_not_move?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/u3d/installation.rb', line 73

def do_not_move?
  File.exist?(@root_path) && File.exist?(do_not_move_file_path)
end

#package_installed?(package) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
92
93
94
95
96
97
98
99
# File 'lib/u3d/installation.rb', line 89

def package_installed?(package)
  return true if (packages || []).include?(package)

  aliases = PACKAGE_ALIASES[package]

  # If no aliases for the package are found, then it's a new package not yet known by Unity
  # If the exact name doesn't match then we have to suppose it's not installed
  return false unless aliases

  return !(aliases & packages).empty?
end

#packagesObject



69
70
71
# File 'lib/u3d/installation.rb', line 69

def packages
  false
end