Module: Gears::Packages
- Defined in:
- lib/robot_sweatshop/gears/packages.rb
Class Method Summary collapse
- .clone(git_repo, to_path:) ⇒ Object
- .data_for(package_name, path) ⇒ Object
- .install(package_name, from_path:) ⇒ Object
- .packages(gears_path) ⇒ Object
Class Method Details
.clone(git_repo, to_path:) ⇒ Object
6 7 8 |
# File 'lib/robot_sweatshop/gears/packages.rb', line 6 def self.clone(git_repo, to_path:) Git.clone git_repo, File.basename(to_path), path: File.dirname(to_path) end |
.data_for(package_name, path) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/robot_sweatshop/gears/packages.rb', line 15 def self.data_for(package_name, path) install_path = "#{path}/#{package_name}" = "#{path}/#{package_name}.yaml" fail "Metadata for '#{package_name}' not found" unless File.exist? [install_path, YAML.load_file()] end |
.install(package_name, from_path:) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/robot_sweatshop/gears/packages.rb', line 22 def self.install(package_name, from_path:) install_path, = data_for package_name, from_path clone ['repo'], to_path: install_path Announce.success "#{package_name} downloaded" Gears::Dependencies.install from_path: install_path Gears::Binaries.expose from_path: install_path if ['type'] == 'binary' Gears::Services.load from_path: install_path if ['type'] == 'service' rescue Announce.failure 'Error occurred, rolling back installation' FileUtils.rm_rf "#{from_path}/#{package_name}" end |
.packages(gears_path) ⇒ Object
10 11 12 13 |
# File 'lib/robot_sweatshop/gears/packages.rb', line 10 def self.packages(gears_path) paths = Dir["#{gears_path}/*"].select { |path| File.directory? path } paths.map { |path| File. path } end |