Class Tap::Tasks::Dump
In: lib/tap/tasks/dump.rb
Parent: Tap::Task

Dumps data to $stdout or a file output.

  % tap dump content --output FILEPATH

Dump faciliates normal redirection:

  % tap load 'goodnight moon' -: dump | more
  goodnight moon

  % tap load 'goodnight moon' -: dump 1> results.txt
  % more results.txt
  goodnight moon

Dump converts objects to strings using to_s:

  % tap load goodnight -- load moon - dump - sync 0,1 2
  ["goodnight", "moon"]

  % tap load goodnight -- load moon - dump - sync 0,1 2 -i
  goodnight
  moon

Dump serves as a baseclass for more complicated dumps. A YAML dump (see tap-tasks) looks like this:

  class Yaml < Tap::Tasks::Dump
    def dump(obj, io)
      YAML.dump(obj, io)
    end
  end

Methods

call   dump   process   to_spec  

Configurations

output  [RW]  The dump target file ($stdout)
overwrite  [RW]  Overwrite the existing target (false)

Public Instance methods

[Source]

    # File lib/tap/tasks/dump.rb, line 44
44:       def call(input)
45:         process(input)
46:       end

Dumps the object to io, by default dump puts (not prints) obj.to_s.

[Source]

    # File lib/tap/tasks/dump.rb, line 58
58:       def dump(input, io)
59:         io.puts input.to_s
60:       end

The default process prints dump headers as specified in the config, then append the audit value to io.

[Source]

    # File lib/tap/tasks/dump.rb, line 50
50:       def process(input)
51:         open_io(output, overwrite ? 'w' : 'a') do |io|
52:           dump(input, io)
53:         end
54:         input
55:       end

[Source]

    # File lib/tap/tasks/dump.rb, line 62
62:       def to_spec
63:         spec = super
64:         spec['config'].delete('output') if output == $stdout
65:         spec
66:       end

[Validate]