Class: PoiseJavascript::Resources::JavascriptRuntime::Resource

Inherits:
Chef::Resource
  • Object
show all
Defined in:
lib/poise_javascript/resources/javascript_runtime.rb

Overview

A javascript_runtime resource to manage Javascript installations.

Examples:

javascript_runtime '2.7'

Since:

  • 1.0.0

Provides:

  • javascript_runtime

Actions:

  • install

  • uninstall

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#versionString

Version of Javascript to install. This is generally a NodeJS version but because of io.js there are shenanigans.

Examples:

Install any version

javascript_runtime 'any' do
  version ''
end

Returns:

  • (String)


46
# File 'lib/poise_javascript/resources/javascript_runtime.rb', line 46

attribute(:version, kind_of: String, name_attribute: true)

Instance Method Details

#javascript_binaryString

The path to the node binary for this Javascript installation. This is an output property.

Examples:

execute "#{resources('javascript_runtime[nodejs]').javascript_binary} myapp.js"

Returns:

  • (String)

Since:

  • 1.0.0



54
55
56
# File 'lib/poise_javascript/resources/javascript_runtime.rb', line 54

def javascript_binary
  provider_for_action(:javascript_binary).javascript_binary
end

#javascript_environmentHash<String, String>

The environment variables for this Javascript installation. This is an output property.

Examples:

execute '/opt/myapp.js' do
  environment resources('javascript_runtime[nodejs]').javascript_environment
end

Returns:

  • (Hash<String, String>)

Since:

  • 1.0.0



66
67
68
# File 'lib/poise_javascript/resources/javascript_runtime.rb', line 66

def javascript_environment
  provider_for_action(:javascript_environment).javascript_environment
end

#npm_binaryString

The path to the npm binary for this Javascript installation. This is an output property. Can raise an exception if NPM is not supported for this runtime.

Examples:

execute "#{resources('javascript_runtime[nodejs]').npm_binary} install"

Returns:

  • (String)

Since:

  • 1.0.0



77
78
79
# File 'lib/poise_javascript/resources/javascript_runtime.rb', line 77

def npm_binary
  provider_for_action(:npm_binary).npm_binary
end