Module: Boson

Extended by:
Boson
Included in:
Boson
Defined in:
lib/boson.rb,
lib/boson/util.rb,
lib/boson/loader.rb,
lib/boson/runner.rb,
lib/boson/options.rb,
lib/boson/library.rb,
lib/boson/version.rb,
lib/boson/manager.rb,
lib/boson/command.rb,
lib/boson/scientist.rb,
lib/boson/inspector.rb,
lib/boson/bin_runner.rb,
lib/boson/bare_runner.rb,
lib/boson/option_parser.rb,
lib/boson/runner_library.rb,
lib/boson/option_command.rb,
lib/boson/method_inspector.rb

Overview

This module stores the libraries, commands and the main_object.

Useful documentation links:

  • Boson::Library - All about libraries

  • Boson::Loader - Explains library module callbacks

  • Boson::OptionParser - All about options

Defined Under Namespace

Modules: Commands, Loader, Options, Scientist, Universe, Util Classes: BareRunner, BinRunner, Command, DefaultCommandsRunner, Inspector, Library, LoaderError, Manager, MethodConflictError, MethodInspector, OptionCommand, OptionParser, Runner, RunnerLibrary

Constant Summary

CONFIG =

Default config

{libraries: {}, command_aliases: {}, option_underscore_search: true}
VERSION =
'1.3.0'

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) commands

Array of loaded Boson::Command objects.



53
54
55
# File 'lib/boson.rb', line 53

def commands
  @commands
end

- (Object) config

Global config used by most classes



58
59
60
# File 'lib/boson.rb', line 58

def config
  @config
end

- (Object) debug

Prints debugging info when set



39
40
41
# File 'lib/boson.rb', line 39

def debug
  @debug
end

- (Object) in_shell

Returns true if commands are being executed from a non-ruby shell i.e. bash Returns nil/false if in a ruby shell i.e. irb.



42
43
44
# File 'lib/boson.rb', line 42

def in_shell
  @in_shell
end

- (Object) libraries

Array of loaded Boson::Library objects.



48
49
50
# File 'lib/boson.rb', line 48

def libraries
  @libraries
end

- (Object) main_object Also known as: higgs

The object which holds and executes all command functionality



34
35
36
# File 'lib/boson.rb', line 34

def main_object
  @main_object
end

- (Object) verbose

Returns true if in commandline with verbose flag or if set explicitly. Plugins should use this to display more info.



45
46
47
# File 'lib/boson.rb', line 45

def verbose
  @verbose
end

Instance Method Details

- (Boolean) can_invoke?(meth, priv = true)

Boolean indicating if the main object can invoke the given method/command.

Returns:

  • (Boolean)


83
84
85
# File 'lib/boson.rb', line 83

def can_invoke?(meth, priv=true)
  Boson.main_object.respond_to? meth, priv
end

- (Object) full_invoke(cmd, args)

Similar to invoke but accepts args as an array



78
79
80
# File 'lib/boson.rb', line 78

def full_invoke(cmd, args)
  main_object.send(cmd, *args)
end

- (Object) invoke(*args, &block)

Invoke an action on the main object.



73
74
75
# File 'lib/boson.rb', line 73

def invoke(*args, &block)
  main_object.send(*args, &block)
end

- (Object) library(query, attribute = 'name')

Finds first library that has a value of attribute



68
69
70
# File 'lib/boson.rb', line 68

def library(query, attribute='name')
  libraries.find {|e| e.send(attribute) == query }
end