class Ghundle::Source::Directory
Represents a directory on the filesystem that has a hook-compatible directory structure. It needs to be fetched to the local hook root in order to use the hook.
Attributes
source_path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/ghundle/source/directory.rb, line 15 def initialize(path) @source_path = Pathname.new(path) end
Public Instance Methods
fetch(destination_path)
click to toggle source
# File lib/ghundle/source/directory.rb, line 31 def fetch(destination_path) validate destination_path = Pathname.new(destination_path) local_source = Local.new(destination_path) return local_source if local_source.exists? FileUtils.mkdir_p(destination_path) FileUtils.cp source_path.join("meta.yml"), destination_path.join("meta.yml") FileUtils.cp source_path.join("run"), destination_path.join("run") local_source end
hook_name()
click to toggle source
# File lib/ghundle/source/directory.rb, line 19 def hook_name @source_path.basename end
metadata()
click to toggle source
# File lib/ghundle/source/directory.rb, line 23 def metadata @metadata ||= begin validate Metadata.new(YAML.load_file(source_path.join("meta.yml"))) end end
to_s()
click to toggle source
# File lib/ghundle/source/directory.rb, line 62 def to_s source_path end
validate()
click to toggle source
# File lib/ghundle/source/directory.rb, line 45 def validate source_script_path = source_path.join('run') source_metadata_path = source_path.join('meta.yml') if not source_script_path.file? raise AppError.new("Script not found: #{source_script_path}") end if not source_script_path.executable? raise AppError.new("Script not executable: #{source_script_path}") end if not source_metadata_path.file? raise AppError.new("Metadata file not found: #{metadata_source_path}") end end