Module: Gears::Services

Defined in:
lib/robot_sweatshop/gears/services.rb

Overview

Installs service Gears packages

Class Method Summary collapse

Class Method Details

.dynamically_load_eye(service, gears_path) ⇒ Object



23
24
25
26
27
28
# File 'lib/robot_sweatshop/gears/services.rb', line 23

def self.dynamically_load_eye(service, gears_path)
  input = File.read "#{__dir__}/sweatshop_gears.eye.eruby"
  eruby = Erubis::Eruby.new input
  context = { service: service, gears_path: File.expand_path(gears_path) }
  write_and_load eruby.result(context)
end

.load(from_path:) ⇒ Object



8
9
10
11
12
# File 'lib/robot_sweatshop/gears/services.rb', line 8

def self.load(from_path:)
  service = File.basename from_path
  dynamically_load_eye service, from_path
  Announce.success "Loaded #{service} into Eye"
end

.write_and_load(eye_config) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/robot_sweatshop/gears/services.rb', line 14

def self.write_and_load(eye_config)
  eye_file = '/tmp/.sweatshop_gears.eye'
  File.write eye_file, eye_config
  puts eye_config
  puts `eye load #{eye_file}`
  puts `eye stop sweatshop_gears`
  File.delete eye_file
end