class Ghundle::Command::Fetch

Tries to figure out what kind of a source the given identifier represents and fetches the hook locally.

Public Instance Methods

call() click to toggle source
# File lib/ghundle/command/fetch.rb, line 12
def call
  args.each do |identifier|
    if identifier =~ /^github.com/
      source = Source::Github.new(identifier)
    elsif File.directory?(identifier)
      source = Source::Directory.new(identifier)
    elsif File.directory?(config.hook_path(identifier))
      # already fetched, do nothing
      return
    else
      error "Can't identify hook source from identifier: #{identifier}"
    end

    hook_name = source.hook_name

    say "Fetching hook #{source.hook_name}..."
    source.fetch(config.hook_path(source.hook_name))
  end
end