pipeline_toolkit 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,11 @@
1
1
  require 'msgpack'
2
+ require 'base64'
2
3
 
3
4
  module PipelineToolkit
4
5
  ##
5
6
  # Encode and decode messages using Marshal
6
7
  #
7
8
  class MessageCoder
8
-
9
- UNESCAPE_MAP = {"@@" => "@","@r" => "\r","@n" => "\n"}
10
- REGEX = UNESCAPE_MAP.keys.join "|"
11
9
 
12
10
  ##
13
11
  # Encode the hash message
@@ -17,10 +15,8 @@ module PipelineToolkit
17
15
  def self.encode(message)
18
16
  # NB: Using Msgpack because it's 9-10x faster than altnatives
19
17
  # See http://gist.github.com/190849
20
- str = MessagePack.pack(message)
21
-
22
- # escape newlines. order is important.
23
- str.gsub(/@/, "@@").gsub(/\n/, "@n").gsub(/\r/, "@r")
18
+ # Using Base64 because ASCII is friendly to pipes.
19
+ Base64.encode64(MessagePack.pack(message)).delete("\r\n")
24
20
  end
25
21
 
26
22
  ##
@@ -30,14 +26,7 @@ module PipelineToolkit
30
26
  #
31
27
  def self.decode(str)
32
28
  str.chomp!
33
-
34
- # unescape newlines
35
-
36
- str.gsub(/#{REGEX}/) do |m|
37
- UNESCAPE_MAP[m]
38
- end
39
-
40
- obj = MessagePack.unpack(str)
29
+ obj = MessagePack.unpack(Base64.decode64(str))
41
30
 
42
31
  obj = case obj
43
32
  when Hash
@@ -50,4 +39,4 @@ module PipelineToolkit
50
39
 
51
40
  end
52
41
 
53
- end
42
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 4
8
- - 1
9
- version: 1.4.1
8
+ - 2
9
+ version: 1.4.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aisha Fenton