Sha256: a9363fe05df76be63d075b8621d4a451f6f7c810b46628f707360d0539a79bd5

Contents?: true

Size: 873 Bytes

Versions: 8

Compression:

Stored size: 873 Bytes

Contents

module Wicoris
  module Postman
    class Postman
      def initialize(opts = {})
        @opts = opts
        @logger = opts[:logger]
      end

      # Process each job.
      def run
        jobs.each do |job|
          begin
            job.process
          rescue => e
            @logger.error(e) if @logger
          ensure
            job.clear!
          end
        end
      end

      private

      # @returns [Array<Job>] All jobs created each JSON file
      def jobs
        json_files.map { |f| Job.new(f, @opts) }
      end

      # @returns [Array<String>] JSON files in jobdir.
      def json_files
        # NOTE: This performs case-insensitive globbing.
        Dir.glob(File.join(jobdir, '*.JSON'), File::FNM_CASEFOLD)
      end

      # @returns [String] Path to jobdir directory
      def jobdir
        @opts[:jobdir]
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wicoris-postman-0.12.2 lib/wicoris/postman/postman.rb
wicoris-postman-0.12.1 lib/wicoris/postman/postman.rb
wicoris-postman-0.12.0 lib/wicoris/postman/postman.rb
wicoris-postman-0.11.3 lib/wicoris/postman/postman.rb
wicoris-postman-0.11.2 lib/wicoris/postman/postman.rb
wicoris-postman-0.11.1 lib/wicoris/postman/postman.rb
wicoris-postman-0.11.0 lib/wicoris/postman/postman.rb
wicoris-postman-0.10.0 lib/wicoris/postman/postman.rb