Sha256: fefaff50ddf3e94786d1db284b5401e13d45df662d766414cb37097bd11688f6

Contents?: true

Size: 1.74 KB

Versions: 16

Compression:

Stored size: 1.74 KB

Contents

module Nucleon
module Plugin
class Command < Base

  #-----------------------------------------------------------------------------
  # Command plugin interface
  
  def normalize(reload)
    super
  end
  
  #---
   
  def to_s
    return build(export)
  end
  
  #-----------------------------------------------------------------------------
  # Property accessor / modifiers
  
  def command(default = '')
    return string(get(:command, default))
  end
  
  #---
  
  def command=command
    set(:command, string(command))
  end
  
  #---
  
  def args(default = [])
    return array(get(:args, default)) 
  end
  
  #---
  
  def args=args
    set(:args, array(args))
  end
  
  #---
  
  def flags(default = [])
    return array(get(:flags, default)) 
  end
  
  #---
  
  def flags=flags
    set(:flags, array(flags))
  end
  
  #---
  
  def data(default = {})
    return hash(get(:data, default)) 
  end
  
  #---
  
  def data=data
    set(:data, hash(data))
  end
  
  #---
  
  def subcommand=subcommand
    unless Util::Data.empty?(subcommand)
      set(:subcommand, new(hash(subcommand)))
    end
  end
  
  #-----------------------------------------------------------------------------
  # Command operations
  
  def build(components = {}, overrides = nil, override_key = false)
    logger.debug("Building command with #{components.inspect}")
    logger.debug("Overrides: #{overrides.inspect}")
    logger.debug("Override key: #{override_key}")
    
    return '' # Implement in sub classes
  end
  
  #---
  
  def exec(options = {}, overrides = nil)
    logger.debug("Executing command with #{options.inspect}")
    logger.debug("Overrides: #{overrides.inspect}")
    
    # Implement in sub classes (don't forget the yield!)
    return true
  end
end
end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
nucleon-0.1.19 lib/core/plugin/command.rb
nucleon-0.1.18 lib/core/plugin/command.rb
nucleon-0.1.17 lib/core/plugin/command.rb
nucleon-0.1.16 lib/core/plugin/command.rb
nucleon-0.1.15 lib/core/plugin/command.rb
nucleon-0.1.14 lib/core/plugin/command.rb
nucleon-0.1.13 lib/core/plugin/command.rb
nucleon-0.1.12 lib/core/plugin/command.rb
nucleon-0.1.11 lib/core/plugin/command.rb
nucleon-0.1.10 lib/core/plugin/command.rb
nucleon-0.1.9 lib/core/plugin/command.rb
nucleon-0.1.8 lib/core/plugin/command.rb
nucleon-0.1.7 lib/core/plugin/command.rb
nucleon-0.1.6 lib/core/plugin/command.rb
nucleon-0.1.5 lib/core/plugin/command.rb
nucleon-0.1.4 lib/core/plugin/command.rb