Sha256: 5a43ec3dc8178943051503ff521e66b86cf401e3b856032c95f1877809a3635e

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

module Wukong
  class Processor

    # A widget that yields whatever you instantiate it with.
    #
    # This is most useful when you have a small but predictable input
    # that you don't want or can't pass via usual input channels like
    # STDIN.
    #
    # @example Works just like you think on the command line
    #
    #   $ echo something else | wu-local echo --input=hello
    #   hello
    #
    # @example Pass some fixed input to your downstream code.
    #
    #   # my_flow.rb
    #   Wukong.dataflow(:my_flow) do
    #     echo(input: {key: 'value'}) | my_proc | ...
    #   end
    #
    # This differs from from the `:identity` processor because it
    # doesn't pass on what it receives but what you instantiate it
    # with.
    #
    # @see Identity
    class Echo < Processor

      description <<EOF
A widget that yields whatever you instantiate it with.

This is most useful when you have a small but predictable input
that you don't want or can't pass via usual input channels like
STDIN.

Works just like you think on the command line (the process won't terminate)

  $ echo something else | wu-local echo --input=hello
  hello
EOF

      field :input, Whatever, :default => nil, :doc => "The record to echo"

      # Yields the `input` no matter what you pass it.
      #
      # @param [Object] _ the new input record which is ignored
      # @yield [input]
      # @yieldparam [Object] input the original input
      def process _
        yield input
      end
      register
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
ul-wukong-4.1.1 lib/wukong/widget/echo.rb
ul-wukong-4.1.0 lib/wukong/widget/echo.rb
wukong-4.0.0 lib/wukong/widget/echo.rb