Module: Nutella

Defined in:
lib/tmux/tmux.rb,
lib/commands/new.rb,
lib/commands/help.rb,
lib/commands/runs.rb,
lib/commands/stop.rb,
lib/config/config.rb,
lib/commands/reset.rb,
lib/commands/start.rb,
lib/config/runlist.rb,
lib/commands/broker.rb,
lib/commands/checkup.rb,
lib/commands/compile.rb,
lib/commands/install.rb,
lib/core/nutella_cli.rb,
lib/commands/template.rb,
lib/core/nutella_core.rb,
lib/nutella_framework.rb,
lib/commands/dependencies.rb,
lib/commands/meta/command.rb,
lib/config/persisted_hash.rb,
lib/logging/nutella_logger.rb,
lib/logging/nutella_logging.rb,
lib/config/current_app_utils.rb,
lib/commands/meta/run_command.rb,
lib/logging/nutella_logger-remote.rb,
lib/commands/meta/template_command.rb

Defined Under Namespace

Modules: CurrentAppUtils Classes: Broker, Checkup, Command, Compile, Dependencies, Help, Install, New, NutellaCLI, NutellaLogger, NutellaLoggerRemote, NutellaLogging, PersistedHash, Reset, RunCommand, RunListHash, Runs, Start, Stop, Template, TemplateCommand, Tmux

Constant Summary collapse

NUTELLA_HOME =
home_dir[0..-4]
NUTELLA_TMP =
"#{NUTELLA_HOME}.tmp/"

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( "#{ENV['HOME']}/.nutella/config.json" )
end

.current_appObject

Calling this method (Nutella.current_app) simply returns a reference to the CurrentAppUtils module



50
51
52
# File 'lib/config/current_app_utils.rb', line 50

def Nutella.current_app
  CurrentAppUtils
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:

  • config_dir: directory where the configuration files are stored in

  • broker_dir: directory where the local broker is installed in

  • main_interface_port: the port used to serve interfaces



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

def Nutella.init
  Nutella.config['config_dir'] = "#{ENV['HOME']}/.nutella/"
  Nutella.config['broker_dir'] = "#{Nutella.config['config_dir']}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



164
165
166
167
168
# File 'lib/config/runlist.rb', line 164

def Nutella.runlist
  rl = RunListHash.new( "#{ENV['HOME']}/.nutella/runlist.json" )
  rl.clean_list
  rl
end