Class: Ghundle::Command::Fetch

Inherits:
Common
  • Object
show all
Defined in:
lib/ghundle/command/fetch.rb

Overview

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

Instance Attribute Summary

Attributes inherited from Common

#args

Instance Method Summary collapse

Methods inherited from Common

call, #initialize

Constructor Details

This class inherits a constructor from Ghundle::Command::Common

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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