Class: BoPeep::Command

Inherits:
Object
  • Object
show all
Includes:
BehaviorWithoutRegistration
Defined in:
lib/bopeep.rb

Defined Under Namespace

Modules: Behavior, BehaviorWithoutRegistration, Chaining, CommandMissingHook, Naming Classes: Name, Step

Class Attribute Summary collapse

Attributes included from BehaviorWithoutRegistration

#argv, #context, #hosts, #parser, #playlist

Class Method Summary collapse

Methods included from BehaviorWithoutRegistration

#SGR, #call, #chain, #command_name, included, #initialize, #name, #on_failure, #on_stderr, #on_stdout, #on_success, #run, #|

Class Attribute Details

.registryObject (readonly)

Returns the value of attribute registry.



1863
1864
1865
# File 'lib/bopeep.rb', line 1863

def registry
  @registry
end

Class Method Details

.find(argv) ⇒ Object



1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
# File 'lib/bopeep.rb', line 1882

def self.find(argv)
  klass = nil

  argv.each do |arg|
    if @registry.key?(arg)
      klass = @registry.fetch(arg)
    end
  end

  klass
end

.inherited(klass) ⇒ Object



1878
1879
1880
# File 'lib/bopeep.rb', line 1878

def self.inherited(klass)
  register(klass)
end

.register(klass) ⇒ Object



1868
1869
1870
1871
1872
1873
1874
1875
1876
# File 'lib/bopeep.rb', line 1868

def self.register(klass)
  if BoPeep::Command.registry.key?(klass.registry_name)
    # TODO: include debug information in the warning
    $stderr.puts "[WARN] command with the name `#{klass.command_name}' already exists " \
      "and is being replaced"
  end

  BoPeep::Command.registry[klass.registry_name] = klass
end