Class: DPL::Provider::Nodejitsu

Inherits:
DPL::Provider show all
Defined in:
lib/dpl/provider/nodejitsu.rb

Constant Summary collapse

CONFIG_FILE =
'.dpl/jitsu.json'

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Instance Method Summary collapse

Methods inherited from DPL::Provider

#create_key, #deploy, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_ssh

Constructor Details

This class inherits a constructor from DPL::Provider

Instance Method Details

#check_appObject



22
23
24
25
26
27
28
29
30
# File 'lib/dpl/provider/nodejitsu.rb', line 22

def check_app
  error "missing package.json" unless File.exist? 'package.json'

  package = JSON.parse File.read('package.json')
  message = "missing %s in package.json, see https://www.nodejitsu.com/documentation/appendix/package-json/"
  error message % "subdomain"    unless package['subdomain']
  error message % "node version" unless package['engines'] and package['engines']['node']
  error message % "start script" unless package['scripts'] and package['scripts']['start']
end

#check_authObject



18
19
20
# File 'lib/dpl/provider/nodejitsu.rb', line 18

def check_auth
  File.open(CONFIG_FILE, 'w') { |f| f << config.to_json }
end

#configObject



10
11
12
13
14
15
16
# File 'lib/dpl/provider/nodejitsu.rb', line 10

def config
  {
    "username"     => option(:username),
    "apiToken"     => option(:api_key),
    "apiTokenName" => "travis"
  }
end

#needs_key?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/dpl/provider/nodejitsu.rb', line 32

def needs_key?
  false
end

#push_appObject



36
37
38
# File 'lib/dpl/provider/nodejitsu.rb', line 36

def push_app
  system "jitsu deploy -j #{CONFIG_FILE}"
end