Class: BlueprintAgreement::DrakovService
- Inherits:
-
Object
- Object
- BlueprintAgreement::DrakovService
- Defined in:
- lib/blueprint_agreement/api_services/drakov_service.rb
Instance Attribute Summary collapse
-
#allow_headers ⇒ Object
readonly
Returns the value of attribute allow_headers.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize ⇒ DrakovService
constructor
A new instance of DrakovService.
- #install ⇒ Object
- #installed? ⇒ Boolean
- #start(path) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ DrakovService
Returns a new instance of DrakovService.
5 6 7 8 9 10 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 5 def initialize @port = Config.port @allow_headers = Config.allow_headers @hostname = Config.hostname @root_path = Config.server_path end |
Instance Attribute Details
#allow_headers ⇒ Object (readonly)
Returns the value of attribute allow_headers.
3 4 5 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 3 def allow_headers @allow_headers end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
3 4 5 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 3 def hostname @hostname end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
3 4 5 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 3 def pid @pid end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 3 def port @port end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
3 4 5 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 3 def root_path @root_path end |
Instance Method Details
#host ⇒ Object
22 23 24 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 22 def host "#{hostname}:#{port}" end |
#install ⇒ Object
30 31 32 33 34 35 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 30 def install print "installing drakov.." pid = Process.spawn "npm install -g drakov" Process.wait pid print "Drakov installed 🍺 " end |
#installed? ⇒ Boolean
26 27 28 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 26 def installed? `which drakov`.length > 0 end |
#start(path) ⇒ Object
12 13 14 15 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 12 def start(path) @pid = spawn "drakov -f #{root_path}/#{path} -p #{port} #{allow_headers}".strip, Config.active_service = { pid: @pid, path: path } end |
#stop ⇒ Object
17 18 19 20 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 17 def stop Process.kill 'TERM', Config.active_service[:pid] Config.active_service = nil end |