Module: Gears::Services
- Defined in:
- lib/robot_sweatshop/gears/services.rb
Overview
Installs service Gears packages
Class Method Summary collapse
- .contains_service?(package_path) ⇒ Boolean
- .dynamically_load_eye(service_list, gears_path) ⇒ Object
- .load(from_path:) ⇒ Object
- .write_and_load(eye_config) ⇒ Object
Class Method Details
.contains_service?(package_path) ⇒ Boolean
15 16 17 18 |
# File 'lib/robot_sweatshop/gears/services.rb', line 15 def self.contains_service?(package_path) = Gears. package_path ['type'] == 'service' end |
.dynamically_load_eye(service_list, gears_path) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/robot_sweatshop/gears/services.rb', line 28 def self.dynamically_load_eye(service_list, gears_path) input = File.read "#{__dir__}/sweatshop_gears.eye.eruby" eruby = Erubis::Eruby.new input context = { services: service_list, gears_path: File.(gears_path) } write_and_load eruby.result(context) end |
.load(from_path:) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/robot_sweatshop/gears/services.rb', line 8 def self.load(from_path:) packages = Gears.packages(from_path).select { |package| contains_service? package } services = packages.map { |package| File.basename package } dynamically_load_eye services, from_path services.each { |service| Announce.success "Loaded #{service} into Eye" } end |
.write_and_load(eye_config) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/robot_sweatshop/gears/services.rb', line 20 def self.write_and_load(eye_config) eye_file = '/tmp/.sweatshop_gears.eye' File.write eye_file, eye_config puts `eye load #{eye_file}` puts `eye stop sweatshop_gears` File.delete eye_file end |