fix-protocol 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78bfecbb42df8d4fa0dc000256d0ea61e07756d2
4
- data.tar.gz: 27444889ea27d17d726039237f4b4573c07074ed
3
+ metadata.gz: 8c0beed30259b1a1ac0e530e0b4a96ac0329e5ab
4
+ data.tar.gz: cb85ffdeb3c76826ad078091219ecbbd22e796cc
5
5
  SHA512:
6
- metadata.gz: daed09c49db6d46f3e7aa6827fca4fc3fe880b43187b1d57a9ac8332b1afaf276f19915c59d23cdc391e5d3b48c90a7384ad8145e62fa72a1494553f301b1488
7
- data.tar.gz: 560496f1d487ab9f56eee9721843dc2d8caca933760bd1e920becaa504758ec8f98ee1ede6dab83e0fcc31e1ab764f2a60ab20f1913c8ac1b82b30818cd65bae
6
+ metadata.gz: 620109d57d076bc3ccac65e8edfe1ec96db7e0cc01e048458d495fbb0f69503273148910fa9240eb352e39c7dc8f1d48468a581dba614b63e2480606a99fffbd
7
+ data.tar.gz: fcce3d4785f25e28e4f962c27e525e4a7d803109448265cfb41383bcf2d1a24533beca16c002e536ade01940d3f17feb9ec2aa74a97c7a37919736c0ebe34437
data/lib/fix/protocol.rb CHANGED
@@ -41,8 +41,9 @@ module Fix
41
41
 
42
42
  # Check checksum
43
43
  checksum = str.match(/10\=([^\x01]+)\x01/)[1]
44
- if checksum != ('%03d' % (str.gsub(/10\=[^\x01]+\x01/, '').bytes.inject(&:+) % 256))
45
- errors << "Incorrect checksum"
44
+ expected = ('%03d' % (str.gsub(/10\=[^\x01]+\x01/, '').bytes.inject(&:+) % 256))
45
+ if checksum != expected
46
+ errors << "Incorrect checksum, expected <#{expected}>, got <#{checksum}>"
46
47
  end
47
48
 
48
49
  if errors.empty?
@@ -10,8 +10,16 @@ module Fix
10
10
  #
11
11
  class Message < MessagePart
12
12
 
13
+ # Default version for when we do not specify anything
14
+ DEFAULT_VERSION = 'FIX.4.4'
15
+ @@expected_version = DEFAULT_VERSION
16
+
17
+ def self.version=(v)
18
+ @@expected_version = v
19
+ end
20
+
13
21
  part :header do
14
- field :version, tag: 8, required: true, default: 'FIX.4.4'
22
+ field :version, tag: 8, required: true, default: @@expected_version
15
23
  field :body_length, tag: 9
16
24
 
17
25
  unordered :header_fields do
@@ -58,10 +66,10 @@ module Fix
58
66
  # @return [Array<String>] The errors on the message header
59
67
  #
60
68
  def errors
61
- if (version == 'FIX.4.4')
69
+ if (version == @@expected_version)
62
70
  super
63
71
  else
64
- [super, "Unsupported version: <#{version}>"].flatten
72
+ [super, "Unsupported version: <#{version}>, expected <#{@@expected_version}>"].flatten
65
73
  end
66
74
  end
67
75
 
@@ -19,7 +19,7 @@ module Fix
19
19
  #
20
20
  def errors
21
21
  e = []
22
- e << "EndSeqNo must either be 0 (inifinity) or be >= BeginSeqNo" unless (end_seq_no.zero? || (end_seq_no >= begin_seq_no))
22
+ e << "EndSeqNo must either be 0 (inifinity) or be >= BeginSeqNo" unless (begin_seq_no && (end_seq_no.zero? || (end_seq_no >= begin_seq_no)))
23
23
  [super, e].flatten
24
24
  end
25
25
 
@@ -10,7 +10,7 @@ module Fix
10
10
  class SequenceReset < Message
11
11
 
12
12
  field :gap_fill_flag, tag: 123, type: :yn_bool, default: false
13
- field :new_seq_no, tag: 36, type: integer, required: true
13
+ field :new_seq_no, tag: 36, type: :integer, required: true
14
14
 
15
15
  end
16
16
 
@@ -4,7 +4,7 @@ module Fix
4
4
  #
5
5
  # The fix-protocol gem version string
6
6
  #
7
- VERSION = '1.1.0'
7
+ VERSION = '1.1.1'
8
8
 
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fix-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David François
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec