Class: Masamune::Commands::HadoopFilesystem

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/masamune/commands/hadoop_filesystem.rb

Constant Summary collapse

DEFAULT_ATTRIBUTES =
{
  path: 'hadoop',
  options: [],
  extra: [],
  block: nil,
  print: false
}.with_indifferent_access.freeze

Instance Method Summary collapse

Constructor Details

#initialize(delegate, attrs = {}) ⇒ HadoopFilesystem

Returns a new instance of HadoopFilesystem.



36
37
38
39
40
41
# File 'lib/masamune/commands/hadoop_filesystem.rb', line 36

def initialize(delegate, attrs = {})
  super delegate
  DEFAULT_ATTRIBUTES.merge(configuration.commands.hadoop_filesystem).merge(attrs).each do |name, value|
    instance_variable_set("@#{name}", value)
  end
end

Instance Method Details

#command_argsObject



43
44
45
46
47
48
49
50
# File 'lib/masamune/commands/hadoop_filesystem.rb', line 43

def command_args
  args = []
  args << @path
  args << 'fs'
  args << @options.map(&:to_a)
  args << @extra
  args.flatten
end

#handle_stdout(line, _line_no) ⇒ Object



52
53
54
55
# File 'lib/masamune/commands/hadoop_filesystem.rb', line 52

def handle_stdout(line, _line_no)
  @block.call(line) if @block
  console(line) if @print
end