Module: Boson

Extended by:
Boson
Included in:
Boson
Defined in:
lib/boson.rb,
lib/boson/pipe.rb,
lib/boson/repo.rb,
lib/boson/util.rb,
lib/boson/view.rb,
lib/boson/index.rb,
lib/boson/pipes.rb,
lib/boson/loader.rb,
lib/boson/runner.rb,
lib/boson/command.rb,
lib/boson/library.rb,
lib/boson/manager.rb,
lib/boson/options.rb,
lib/boson/version.rb,
lib/boson/inspector.rb,
lib/boson/namespace.rb,
lib/boson/scientist.rb,
lib/boson/repo_index.rb,
lib/boson/option_parser.rb,
lib/boson/option_command.rb,
lib/boson/runners/bin_runner.rb,
lib/boson/libraries/gem_library.rb,
lib/boson/libraries/file_library.rb,
lib/boson/runners/console_runner.rb,
lib/boson/libraries/module_library.rb,
lib/boson/inspectors/method_inspector.rb,
lib/boson/inspectors/comment_inspector.rb

Overview

This module stores the libraries, commands, repos and main object used throughout Boson.

Useful documentation links:

  • Boson::BinRunner - Runs the boson executable

  • Boson::ConsoleRunner - Runs Boson from the ruby console

  • Boson::Repo.config - Explains main config file

  • Boson::Library - All about libraries

  • Boson::FileLibrary - Explains creating libraries as files

  • Boson::Loader - Explains library module callbacks

  • Boson::OptionParser - All about options

Defined Under Namespace

Modules: ArgumentInspector, Commands, CommentInspector, Index, Inspector, Loader, MethodInspector, Options, Pipe, Pipes, Scientist, Universe, Util, View Classes: AppendFeaturesFalseError, BinRunner, Command, ConsoleRunner, FileLibrary, GemLibrary, IndifferentAccessHash, Library, LoaderError, LocalFileLibrary, Manager, MethodConflictError, ModuleLibrary, Namespace, OptionCommand, OptionParser, Repo, RepoIndex, RequireLibrary, Runner

Constant Summary collapse

NAMESPACE =

Delimits namespace from command

'.'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandsObject

Array of loaded Boson::Command objects.



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

def commands
  @commands
end

#librariesObject

Array of loaded Boson::Library objects.



30
31
32
# File 'lib/boson.rb', line 30

def libraries
  @libraries
end

#main_objectObject Also known as: higgs

The object which holds and executes all command functionality



25
26
27
# File 'lib/boson.rb', line 25

def main_object
  @main_object
end

Class Method Details

.versionObject



2
3
4
# File 'lib/boson/version.rb', line 2

def self.version
  '0.304.3'
end

Instance Method Details

#can_invoke?(meth, priv = true) ⇒ Boolean

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

Returns:

  • (Boolean)


94
95
96
# File 'lib/boson.rb', line 94

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

#full_invoke(cmd, args) ⇒ Object

Invoke command string even with namespaces



87
88
89
90
91
# File 'lib/boson.rb', line 87

def full_invoke(cmd, args) #:nodoc:
  command, subcommand = cmd.include?(NAMESPACE) ? cmd.split(NAMESPACE, 2) : [cmd, nil]
  dispatcher = subcommand ? Boson.invoke(command) : Boson.main_object
  dispatcher.send(subcommand || command, *args)
end

#global_repoObject

Optional global repository at /etc/boson



63
64
65
# File 'lib/boson.rb', line 63

def global_repo
  File.exists?('/etc/boson') ? Repo.new('/etc/boson') : nil
end

#invoke(*args, &block) ⇒ Object

Invoke an action on the main object.



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

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

#library(query, attribute = 'name') ⇒ Object

:nodoc:



71
72
73
# File 'lib/boson.rb', line 71

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

#local_repoObject

An optional local repository which defaults to ./lib/boson or ./.boson.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/boson.rb', line 45

def local_repo
  @local_repo ||= begin
    ignored_dirs = (repo.config[:ignore_directories] || []).map {|e| File.expand_path(e) }
    $:.collect {|e| 
      e = "#{File.dirname(e)}/.boson"
      if (File.directory?(e) && File.expand_path(e) != repo.dir && !ignored_dirs.include?(File.expand_path('.')))
        Repo.new(e)
      end
    }.compact
  end
end

#repoObject

The main required repository which defaults to ~/.boson.



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

def repo
  @repo ||= Repo.new("#{Util.find_home}/.boson")
end

#reposObject

The array of loaded repositories containing the main repo and possible local and global repos



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

def repos
  @repos ||= [repo, local_repo, global_repo].flatten.compact
end

#start(options = {}) ⇒ Object

Start Boson by loading repositories and their configured libraries. See ConsoleRunner.start for its options.



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

def start(options={})
  ConsoleRunner.start(options)
end