Module: Nutella

Defined in:
lib/core/command.rb,
lib/core/tmux.rb,
lib/config/config.rb,
lib/config/runlist.rb,
lib/cli/nutella_cli.rb,
lib/core/run_command.rb,
lib/core/commands/new.rb,
lib/core/nutella_core.rb,
lib/nutella_framework.rb,
lib/core/commands/help.rb,
lib/core/commands/runs.rb,
lib/core/commands/stop.rb,
lib/core/commands/start.rb,
lib/core/commands/broker.rb,
lib/config/persisted_hash.rb,
lib/core/commands/checkup.rb,
lib/core/commands/install.rb,
lib/config/current_project.rb,
lib/logging/nutella_logger.rb,
lib/logging/nutella_logging.rb,
lib/logging/nutella_logger-remote.rb

Overview

CLI command

Defined Under Namespace

Modules: CurrentProjectUtils Classes: Broker, Checkup, Command, Help, Install, New, NutellaCLI, NutellaLogger, NutellaLoggerRemote, NutellaLogging, PersistedHash, RunCommand, RunListHash, Runs, Start, Stop, Tmux

Constant Summary collapse

NUTELLA_HOME =
home_dir[0..-4]

Class Method Summary collapse

Class Method Details

.command_exists?(command) ⇒ Boolean

This method checks that a particular command exists

Returns:

  • (Boolean)

    true if the command exists, false otherwise



25
26
27
28
29
# File 'lib/core/nutella_core.rb', line 25

def Nutella.command_exists?(command)
  return Nutella.const_get("Nutella::#{command.capitalize}").is_a?(Class)
rescue NameError
  return false
end

.configObject

Calling this method (Nutella.config) simply returns and instance of PersistedHash linked to file config.json in nutella home directory



7
8
9
# File 'lib/config/config.rb', line 7

def Nutella.config
  PersistedHash.new("#{File.dirname(__FILE__)}/../../config.json")
end

.current_projectObject

Calling this method (Nutella.current_project) simply returns a reference to the CurrentProjectUtils module



51
52
53
# File 'lib/config/current_project.rb', line 51

def Nutella.current_project
  CurrentProjectUtils
end

.execute_command(command, args = nil) ⇒ Object

This method executes a particular command

Parameters:

  • command (String)

    the name of the command

  • args (Array<String>) (defaults to: nil)

    command line parameters passed to the command



13
14
15
16
17
18
19
20
21
# File 'lib/core/nutella_core.rb', line 13

def Nutella.execute_command (command, args=nil)
  # Check that the command exists and if it does,
  # execute its run method passing the args parameters
  if command_exists?(command)
    Object::const_get("Nutella::#{command.capitalize}").new.run(args)
  else
    console.error "Unknown command #{command}"
  end
end

.initObject

This method initializes the nutella configuration file (config.json) with:

  • NUTELLA_HOME: the directory nutella is installed in

  • tmp_dir: temporary directory used when installing remote templates

  • broker_dir: directory where the local broker is installed in

  • main_interface_port: the port used to serve interfaces



36
37
38
39
40
41
# File 'lib/core/nutella_core.rb', line 36

def Nutella.init
  Nutella.config['nutella_home'] = NUTELLA_HOME
  Nutella.config['tmp_dir'] = "#{NUTELLA_HOME}.tmp/"
  Nutella.config['broker_dir'] = "#{NUTELLA_HOME}broker/"
  Nutella.config['main_interface_port'] = 57880
end

.runlistObject

Calling this method (Nutella.runlist) simply returns and instance of RunListHash linked to file runlist.json in the nutella home directory



28
29
30
# File 'lib/config/runlist.rb', line 28

def Nutella.runlist
  RunListHash.new( "#{File.dirname(__FILE__)}/../../runlist.json" )
end