Class: ElmInstall::DirectorySource
- Defined in:
- lib/elm_install/directory_source.rb
Overview
This clas handles sources that point to a local directory.
Instance Attribute Summary collapse
-
#dir ⇒ Dir
readonly
The directory.
Attributes inherited from Source
Instance Method Summary collapse
-
#copy_to(_, directory) ⇒ Object
Copies the directory to the given other directory.
-
#fetch(_) ⇒ Dir
Returns the directory.
-
#initialize(dir) ⇒ DirectorySource
constructor
Initializes a directory source with the given directory.
-
#to_log ⇒ String
Returns the log format.
-
#versions(_) ⇒ Array
Returns the available versions for a repository.
Constructor Details
#initialize(dir) ⇒ DirectorySource
Initializes a directory source with the given directory.
13 14 15 16 |
# File 'lib/elm_install/directory_source.rb', line 13 def initialize(dir) @dir = dir self end |
Instance Attribute Details
#dir ⇒ Dir (readonly)
Returns The directory.
5 6 7 |
# File 'lib/elm_install/directory_source.rb', line 5 def dir @dir end |
Instance Method Details
#copy_to(_, directory) ⇒ Object
Copies the directory to the given other directory
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/elm_install/directory_source.rb', line 35 def copy_to(_, directory) # Delete the directory to make sure no pervious version remains FileUtils.rm_rf(directory) if directory.exist? # Create parent directory FileUtils.mkdir_p(directory.parent) # Create symlink FileUtils.ln_s(@dir., directory) nil end |
#fetch(_) ⇒ Dir
Returns the directory
24 25 26 |
# File 'lib/elm_install/directory_source.rb', line 24 def fetch(_) Dir.new(@dir.) end |
#to_log ⇒ String
Returns the log format
62 63 64 |
# File 'lib/elm_install/directory_source.rb', line 62 def to_log @dir..to_s end |
#versions(_) ⇒ Array
Returns the available versions for a repository
54 55 56 |
# File 'lib/elm_install/directory_source.rb', line 54 def versions(_) [identifier.version(fetch(''))] end |