class Ghundle::Source::Local

Represents the local source of a hook. This means that the hook has already been fetched to a local directory where it can easily be installed in a repository.

Public Class Methods

new(local_path) click to toggle source
# File lib/ghundle/source/local.rb, line 12
def initialize(local_path)
  @local_path = Pathname.new(local_path)
end

Public Instance Methods

exists?() click to toggle source
# File lib/ghundle/source/local.rb, line 36
def exists?
  script_path.executable? and metadata_path.file?
end
fetch() click to toggle source
# File lib/ghundle/source/local.rb, line 45
def fetch
  self
end
metadata() click to toggle source
# File lib/ghundle/source/local.rb, line 40
def metadata
  validate
  Metadata.from_yaml(metadata_path)
end
metadata_path() click to toggle source
# File lib/ghundle/source/local.rb, line 53
def metadata_path
  @local_path.join('meta.yml')
end
name() click to toggle source
# File lib/ghundle/source/local.rb, line 16
def name
  @local_path.basename.to_s
end
script_path() click to toggle source
# File lib/ghundle/source/local.rb, line 49
def script_path
  @local_path.join('run')
end
validate() click to toggle source
# File lib/ghundle/source/local.rb, line 20
def validate
  return if exists?

  if not script_path.file?
    raise AppError.new("Script not found: #{script_path}")
  end

  if not script_path.executable?
    raise AppError.new("Script not executable: #{script_path}")
  end

  if not metadata_path.file?
    raise AppError.new("Metadata file not found: #{metadata_path}")
  end
end