class U3d::License

Constants

LICENSES_DIR_LINUX
LICENSES_DIR_MAC
LICENSES_DIR_WINDOWS

Attributes

path[R]

Public Class Methods

from_path(path) click to toggle source
# File lib/u3d/unity_license.rb, line 49
def from_path(path)
  doc = REXML::Document.new(File.read(path))
  fields = {}
  license = REXML::XPath.first(doc, "root/License")
  unless license.nil?
    fields = []
    license.each_element_with_attribute("Value") do |e|
      fields << [e.name, e.attribute('Value').to_s]
    end
  end
  License.new(path: path, fields: fields.to_h)
end
licenses() click to toggle source
# File lib/u3d/unity_license.rb, line 62
def licenses
  glob = File.join(licenses_dir, "*.ulf")
  Dir.glob(glob).map do |path|
    from_path(path)
  end
end
licenses_dir() click to toggle source
# File lib/u3d/unity_license.rb, line 69
def licenses_dir
  return LICENSES_DIR_MAC if U3d::Helper.mac?
  return LICENSES_DIR_WINDOWS if U3d::Helper.windows?
  return LICENSES_DIR_LINUX if U3d::Helper.linux?
end
new(path: nil, fields: nil) click to toggle source
# File lib/u3d/unity_license.rb, line 29
def initialize(path: nil, fields: nil)
  @path = path
  @fields = fields || {}
end

Public Instance Methods

[](index) click to toggle source
# File lib/u3d/unity_license.rb, line 34
def [](index)
  @fields[index]
end
number() click to toggle source

petit cachotier va!

# File lib/u3d/unity_license.rb, line 39
def number
  require 'base64'
  Base64.decode64(self['DeveloperData'])[4..-1]
end