class Object

Public Instance Methods

current_package() click to toggle source

Creates a package instance for the current working directory.

# File lib/woodstove/packagemanager.rb, line 201
def current_package
  WoodstovePackage.new 'current package', 'gitlab', FileUtils.pwd, global_kindling_bin
end
global_kindling() click to toggle source

Returns the global kindling directory.

# File lib/woodstove/packagemanager.rb, line 206
def global_kindling
  if OS.mac?
    '~/Library/Application Support/woodstove'
  elsif OS.windows?
    'C:/ProgramData/woodstove/kindling'
  else
    '/usr/var/kindling'
  end
end
global_kindling_bin() click to toggle source

Returns the global kindling bin directory.

# File lib/woodstove/packagemanager.rb, line 217
def global_kindling_bin
  if OS.windows?
    'C:/ProgramData/woodstove/bin'
  else
    '/usr/local/bin'
  end
end
install_package(package, directory, bindir) click to toggle source

Installs the given package into the specified directory.

# File lib/woodstove/packagemanager.rb, line 184
def install_package package, directory, bindir
  data = parse_package_url package, directory
  puts data.inspect
  pkg = WoodstovePackage.new data[:repo], data[:site], data[:path], bindir
  pkg.install data[:branch]
  pkg
end
need_args(args, error) click to toggle source

Prints the error and terminates the program if the args array is empty.

# File lib/woodstove/packagecommands.rb, line 9
def need_args args, error
  if args.length < 1
    puts error
    exit 1
  end
end
parse_package_url(package, directory) click to toggle source
# File lib/woodstove/packagemanager.rb, line 164
def parse_package_url package, directory
  branchget = package.split '@'
  branch = (branchget.length > 1 ? branchget[1] : 'master')
  siteget = branchget[0].split(':')
  site = (siteget.length > 1 ? siteget[0] : 'gitlab')
  repoget = (siteget.length > 1 ? siteget[1] : siteget[0]).split '/'
  packagename = repoget[1]
  packageuser = repoget[0]
  path = "#{directory}/#{packagename}"
  {
    :branch => branch,
    :site => site,
    :name => packagename,
    :user => packageuser,
    :path => path,
    :repo => repoget.join('/')
  }
end
remove_package(package, directory, bindir) click to toggle source

Removes the given package from the specified directory.

# File lib/woodstove/packagemanager.rb, line 193
def remove_package package, directory, bindir
  data = parse_package_url package, directory
  pkg = WoodstovePackage.new data[:repo], data[:site], data[:path], bindir, data[:site]
  pkg.remove
  pkg
end