Sha256: 92efdaeea93cfb10dffa94bde5184e4ebf0e83d79bcbc1d7bb355aab09091409

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

require 'tap/tasks/dump'

module Tap
  module Tasks
    class Dump < Tap::Task
      
      # :startdoc::task inspect and dump an object
      #
      # Dumps objects to a file or IO using object.inspect.  An alternate
      # method can be specified for inspection using the inspect_method
      # config.
      #
      #   % tap run -- load/yaml "{key: value}" --: inspect
      #   {"key"=>"value"}
      #
      #   % tap run -- load string --: inspect -m length
      #   6
      #
      class Inspect < Dump
        
        config :inspect_method, 'inspect', :short => :m    # The inspection method
        
        # Dumps the object to io using obj.inspect
        def dump(obj, io)
          io.puts obj.send(inspect_method)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tap-tasks-0.2.0 lib/tap/tasks/dump/inspect.rb