class ARPM::Package

Attributes

authors[RW]
name[RW]
repository[RW]
versions[RW]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/arpm/package.rb, line 9
def initialize(opts = {})
  opts.each { |k,v| instance_variable_set("@#{k}", v) }
end

Public Instance Methods

install(version) click to toggle source
# File lib/arpm/package.rb, line 88
def install(version)
  # Clone the repository!
  repo = Git.clone(repository, install_path(version))

  # It does, so checkout the right version
  repo.checkout("tags/#{version}")

  # Register the package to the list
  register(version)
end
install_path(version = nil) click to toggle source
# File lib/arpm/package.rb, line 75
def install_path(version = nil)

  # Take the latest_version unless it's been specified
  version = latest_version unless version

  # Creat the install path
  path = ARPM::Config.base_directory + name

  # Arduino doesn't like dots or dashes in library names
  path = path + "_#{version.gsub('.', '_')}"

end
installed_versions() click to toggle source
# File lib/arpm/package.rb, line 115
def installed_versions
  ARPM::List.versions(self.name)
end
latest_version() click to toggle source
# File lib/arpm/package.rb, line 67
def latest_version
  if versions.kind_of?(Array)
    versions.first
  else
    versions.keys.first.to_s
  end
end
register(version) click to toggle source
# File lib/arpm/package.rb, line 107
def register(version)
  ARPM::List.register(self, version)
end
uninstall(version) click to toggle source
# File lib/arpm/package.rb, line 99
def uninstall(version)
  # Remove the files
  FileUtils.rm_r(install_path(version)) rescue ""

  # Unregister it
  unregister(version)
end
unregister(version) click to toggle source
# File lib/arpm/package.rb, line 111
def unregister(version)
  ARPM::List.unregister(self, version)
end