class Omnibus::PathFetcher

Fetcher implementation for projects on the filesystem

Public Class Methods

new(software) click to toggle source
# File lib/omnibus/fetchers/path_fetcher.rb, line 25
def initialize(software)
  @name = software.name
  @source = software.source
  @project_dir = software.project_dir
  @version = software.version
end

Public Instance Methods

clean() click to toggle source
# File lib/omnibus/fetchers/path_fetcher.rb, line 52
def clean
  # Here, clean will do the same as fetch: reset source to pristine state
  rsync
end
description() click to toggle source
# File lib/omnibus/fetchers/path_fetcher.rb, line 32
    def description
      s=<<-E
source path:    #{@source[:path]}
local location: #{@project_dir}
E
    end
fetch() click to toggle source
# File lib/omnibus/fetchers/path_fetcher.rb, line 57
def fetch
  rsync
end
fetch_required?() click to toggle source
# File lib/omnibus/fetchers/path_fetcher.rb, line 61
def fetch_required?
  true
end
rsync() click to toggle source
# File lib/omnibus/fetchers/path_fetcher.rb, line 39
def rsync
  if OHAI.platform == "windows"
    # Robocopy's return code is 1 if it succesfully copies over the
    # files and 0 if the files are already existing at the destination
    sync_cmd = "robocopy #{@source[:path]}\\ #{@project_dir}\\ /MIR /S"
    shell = Mixlib::ShellOut.new(sync_cmd, :returns => [0, 1])
  else
    sync_cmd = "rsync --delete -a #{@source[:path]}/ #{@project_dir}/"
    shell = Mixlib::ShellOut.new(sync_cmd)
  end
  shell.run_command
end