Class: GitDownloadStrategy
- Inherits:
-
AbstractDownloadStrategy
- Object
- AbstractDownloadStrategy
- GitDownloadStrategy
- Includes:
- GitCommands
- Defined in:
- lib/lace/download_strategy.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from AbstractDownloadStrategy
#resource, #target_folder, #uri
Instance Method Summary collapse
Methods included from GitCommands
#clone_args, #clone_repo, #git_dir, #repo_modified?, #repo_valid?, #reset, #submodules?, #update_repo, #update_submodules
Methods inherited from AbstractDownloadStrategy
Constructor Details
This class inherits a constructor from AbstractDownloadStrategy
Instance Method Details
#fetch ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/lace/download_strategy.rb', line 129 def fetch ohai "Cloning #{@uri}" if @target_folder.exist? && repo_valid? puts "Updating #{@target_folder}" @target_folder.cd do update_repo reset update_submodules if submodules? end elsif @target_folder.exist? puts 'Removing invalid .git repo' FileUtils.rm_rf @target_folder clone_repo else clone_repo end @target_folder end |
#name ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/lace/download_strategy.rb', line 149 def name if super super elsif @uri.include? 'github.com' @uri.split('/')[-2] elsif File.directory? @uri File.basename(@uri) else raise "Cannot determine a proper name with #{@uri}" end end |