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(config = BlueprintAgreement.configuration) ⇒ DrakovService
constructor
A new instance of DrakovService.
- #install ⇒ Object
- #installed? ⇒ Boolean
- #start(path) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config = BlueprintAgreement.configuration) ⇒ DrakovService
Returns a new instance of DrakovService.
5 6 7 8 9 10 11 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 5 def initialize(config = BlueprintAgreement.configuration) @config = config @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
23 24 25 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 23 def host "#{hostname}:#{port}" end |
#install ⇒ Object
31 32 33 34 35 36 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 31 def install print "installing drakov.." pid = Process.spawn "npm install -g drakov" Process.wait pid print "Drakov installed 🍺 " end |
#installed? ⇒ Boolean
27 28 29 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 27 def installed? `which drakov`.length > 0 end |
#start(path) ⇒ Object
13 14 15 16 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 13 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
18 19 20 21 |
# File 'lib/blueprint_agreement/api_services/drakov_service.rb', line 18 def stop Process.kill 'TERM', @config.active_service[:pid] @config.active_service = nil end |