Sha256: 101221d69264f8b3d66b0213c0e0b3a1eb61fe43c051d1d496655ab8935380f3

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

# Require all commands by iterating through all the files
# in the commands directory
Dir["#{File.dirname(__FILE__)}/commands/*.rb"].each do |file|
  # noinspection RubyResolve
  require "core/commands/#{File.basename(file, File.extname(file))}"
end

module Nutella
      
    # This method executes a particular command
    # @param command [String] the name of the command
    # @param args [Array<String>] command line parameters passed to the command
    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
    
    # This method checks that a particular command exists
    # @return [Boolean] true if the command exists, false otherwise
    def Nutella.command_exists?(command)
      return Nutella.const_get("Nutella::#{command.capitalize}").is_a?(Class)
    rescue NameError
      return false
    end
    
    # 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
    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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nutella_framework-0.3.0 lib/core/nutella_core.rb
nutella_framework-0.2.1 lib/core/nutella_core.rb
nutella_framework-0.2.0 lib/core/nutella_core.rb