Class: Ghundle::Source::Local
- Defined in:
- lib/ghundle/source/local.rb
Overview
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.
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #fetch ⇒ Object
-
#initialize(local_path) ⇒ Local
constructor
A new instance of Local.
- #metadata ⇒ Object
- #metadata_path ⇒ Object
- #name ⇒ Object
- #script_path ⇒ Object
- #validate ⇒ Object
Methods inherited from Common
Constructor Details
#initialize(local_path) ⇒ Local
Returns a new instance of Local.
12 13 14 |
# File 'lib/ghundle/source/local.rb', line 12 def initialize(local_path) @local_path = Pathname.new(local_path) end |
Instance Method Details
#exists? ⇒ Boolean
36 37 38 |
# File 'lib/ghundle/source/local.rb', line 36 def exists? script_path.executable? and .file? end |
#fetch ⇒ Object
45 46 47 |
# File 'lib/ghundle/source/local.rb', line 45 def fetch self end |
#metadata ⇒ Object
40 41 42 43 |
# File 'lib/ghundle/source/local.rb', line 40 def validate Metadata.from_yaml() end |
#metadata_path ⇒ Object
53 54 55 |
# File 'lib/ghundle/source/local.rb', line 53 def @local_path.join('meta.yml') end |
#name ⇒ Object
16 17 18 |
# File 'lib/ghundle/source/local.rb', line 16 def name @local_path.basename.to_s end |
#script_path ⇒ Object
49 50 51 |
# File 'lib/ghundle/source/local.rb', line 49 def script_path @local_path.join('run') end |
#validate ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 .file? raise AppError.new("Metadata file not found: #{}") end end |