Class: Tap::Tasks::Dump
Overview
:startdoc::task the default dump task
Dumps data to $stdout or a file output.
% tap run -- dump content --output FILEPATH
Dump faciliates normal redirection:
% tap run -- load hello --: dump | more
hello
% tap run -- load hello --: dump 1> results.txt
% more results.txt
hello
Note that dumps are appended to the file. Dump only accepts one object at a time, so joins that produce an array (like sync) need to iterate outputs to dump:
% tap run -- load hello -- load world -- dump --[0,1][2]i.sync
hello
world
:startdoc::task-
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
Constant Summary
Constants inherited from Tap::Task
Tap::Task::DEFAULT_HELP_TEMPLATE
Instance Attribute Summary
Attributes inherited from Tap::Task
Attributes included from App::Node
Instance Method Summary collapse
-
#dump(input, io) ⇒ Object
Dumps the object to io, by default dump puts (not prints) obj.to_s.
-
#process(input) ⇒ Object
The default process prints dump headers as specified in the config, then append the audit value to io.
Methods inherited from Tap::Task
#call, desc, #enq, #execute, #fork, help, inherited, #initialize, #inspect, instance, instantiate, intern, load_config, #log, manifest, #merge, parse, parse!, #sequence, #switch, #sync_merge
Methods included from App::Node
#depends_on, extended, intern, #on_complete
Constructor Details
This class inherits a constructor from Tap::Task
Instance Method Details
#dump(input, io) ⇒ Object
Dumps the object to io, by default dump puts (not prints) obj.to_s.
53 54 55 |
# File 'lib/tap/tasks/dump.rb', line 53 def dump(input, io) io.puts input.to_s end |
#process(input) ⇒ Object
The default process prints dump headers as specified in the config, then append the audit value to io.
45 46 47 48 49 50 |
# File 'lib/tap/tasks/dump.rb', line 45 def process(input) open_io(output, overwrite ? 'w' : 'a') do |io| dump(input, io) end output end |