Sha256: 75fc8487ba2b5577210fb47a576137698f33219cbf464da54ac94acebf9955ee

Contents?: true

Size: 1.58 KB

Versions: 60

Compression:

Stored size: 1.58 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 "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:
    # - 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
    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

end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
nutella_framework-0.9.2 lib/core/nutella_core.rb
nutella_framework-0.9.1 lib/core/nutella_core.rb
nutella_framework-0.9.0 lib/core/nutella_core.rb
nutella_framework-0.8.0 lib/core/nutella_core.rb
nutella_framework-0.7.3 lib/core/nutella_core.rb
nutella_framework-0.7.2 lib/core/nutella_core.rb
nutella_framework-0.7.1 lib/core/nutella_core.rb
nutella_framework-0.7.0 lib/core/nutella_core.rb
nutella_framework-0.6.21 lib/core/nutella_core.rb
nutella_framework-0.6.20 lib/core/nutella_core.rb
nutella_framework-0.6.19 lib/core/nutella_core.rb
nutella_framework-0.6.18 lib/core/nutella_core.rb
nutella_framework-0.6.17 lib/core/nutella_core.rb
nutella_framework-0.6.16 lib/core/nutella_core.rb
nutella_framework-0.6.15 lib/core/nutella_core.rb
nutella_framework-0.6.13 lib/core/nutella_core.rb
nutella_framework-0.6.12 lib/core/nutella_core.rb
nutella_framework-0.6.11 lib/core/nutella_core.rb
nutella_framework-0.6.10 lib/core/nutella_core.rb
nutella_framework-0.6.9 lib/core/nutella_core.rb