Sha256: 61da6fb7fa0e6cd2b5c8e0193bb111536315df876e9fe6119a22e2b8a7ecb598

Contents?: true

Size: 866 Bytes

Versions: 7

Compression:

Stored size: 866 Bytes

Contents

require 'pinch_hitter/message/xml'
require 'pinch_hitter/message/json'
require 'pinch_hitter/message/content_type'
require 'pinch_hitter/core_ext/string'

module PinchHitter::Message
    class MessageStore
    include Xml
    include Json
    include ContentType

    attr_accessor :message_directory

    def initialize(message_directory)
      @message_directory = message_directory
    end

    def load(file, overrides={})
      filename = find_filename file
      if filename =~ /xml$/
        xml_message filename, overrides
      else
        json_message filename, overrides
      end
    end

    def find_filename(file)
      filename = Dir["#{message_directory}/#{file}*"].first
      unless filename
        fail "Could not find message for '#{file}' in '#{File.expand_path(File.dirname(message_directory))}'"
      end
      filename
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pinch_hitter-0.5.5 lib/pinch_hitter/message/message_store.rb
pinch_hitter-0.5.4 lib/pinch_hitter/message/message_store.rb
pinch_hitter-0.5.3 lib/pinch_hitter/message/message_store.rb
pinch_hitter-0.5.2 lib/pinch_hitter/message/message_store.rb
pinch_hitter-0.5.1 lib/pinch_hitter/message/message_store.rb
pinch_hitter-0.5 lib/pinch_hitter/message/message_store.rb
pinch_hitter-0.4 lib/pinch_hitter/message/message_store.rb