module Extruder
  # A collection of useful functions used by multiple scripts.
  module Script
    module_function

    def process_items(options, type)
      split_on = options.delete(:split_on)
      config = Extruder::Config.new options[:config], options

      if type == 'queue'
        return [config, Extruder::Queue.new(config.location(:queue))]
      end

      files = type == 'file' ? $stdin.read.split(split_on) : ARGV
      [config, files.map { |f| Extruder::Message.new File.open(f), {} }]
    end
  end
end

module Extruder
  # A collection of useful functions used by multiple scripts.
  module Script
    module_function

    def process_items(options, type)
      split_on = options.delete(:split_on)
      config = Extruder::Config.new options[:config], options

      if type == 'queue'
        return [config, Extruder::Queue.new(config.location(:queue))]
      end

      files = type == 'file' ? $stdin.read.split(split_on) : ARGV
      [config, files.map { |f| Extruder::Message.new File.new(f, 'rb'), {} }]
    end
  end
end

Read all messages as binary.
Read all messages as binary.

Messages read by several of the scripts were not read as binary.  Ensure
that binary mode is used, since we cannot guarantee that the files are
in the locale encoding.

Signed-off-by: brian m. carlson <738bdd359be778fee9f0fc4e2934ad72f436ceda@crustytoothpaste.net>
