fix-protocol 0.0.41 → 0.0.50

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: 9ac67d01fa57ccfa5afe685f930ddadbf019a811
4
- data.tar.gz: 19a31a25cd16be7ae00c3bd50d563d7976b58a4e
3
+ metadata.gz: 96b5b76bae3597fa647b18c74cb51ba7f4642453
4
+ data.tar.gz: 6137f2443418785d8e2096d783a9bb2d708b0728
5
5
  SHA512:
6
- metadata.gz: af15983b1cd341165148f5dbf8917a46f93ff6021cb2a452fd046ff21467b37e230ecba6313b17606bab47a55d1a95b2ca005e6f70a3ef1d8d53da794d75ed11
7
- data.tar.gz: 99b289677c11e08d5818b9db818871480b6395bc7200e883dacb9544a4d4ebc4792b3ed4a9c7fc5f74ca8f2c5e2671d0286a496a189a271bc3eef9d21fbd0b19
6
+ metadata.gz: b70e3e1003ff7c46a15870b64b111cb559a654e973b9ea148ff530edd03fc6e9511f5a7c20329a79b0840c458d38f0ade3080536981d1a522b12af5c9ac6408b
7
+ data.tar.gz: fdf0434585c0d37b15cd9be858bf9dcf39dfc33a33fb94a61e532f4907d8f36c854dec613319e9f22cfc341fad5a40e6055d01dc27deeaa44f4979b641f8caa4
@@ -27,6 +27,10 @@ module Fix
27
27
  @value && "#{tag}=#{@value}\x01"
28
28
  end
29
29
 
30
+ def can_parse?(str)
31
+ str.match(/^#{tag}\=[^\x01]+\x01/)
32
+ end
33
+
30
34
  #
31
35
  # Parses the value for this field from the beginning of the string passed as parameter
32
36
  # and return the rest of the string. The field value is assigned to the +@value+ instance variable
@@ -0,0 +1,18 @@
1
+ module Fix
2
+ module Protocol
3
+
4
+ #
5
+ # The fields in the header for which the order is not enforced
6
+ #
7
+ class HeaderFields < UnorderedPart
8
+
9
+ field :msg_type, tag: 35, required: true
10
+ field :sender_comp_id, tag: 49, required: true
11
+ field :target_comp_id, tag: 56, required: true
12
+ field :msg_seq_num, tag: 34, required: true, type: :integer
13
+ field :sending_time, tag: 52, required: true, type: :timestamp, default: proc { Time.now }
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -3,6 +3,7 @@ require 'treetop'
3
3
  require 'forwardable'
4
4
 
5
5
  require 'fix/protocol/message_part'
6
+ require 'fix/protocol/unordered_part'
6
7
  require 'fix/protocol/repeating_message_part'
7
8
  require 'fix/protocol/message_header'
8
9
 
@@ -1,4 +1,5 @@
1
1
  require 'fix/protocol/message_part'
2
+ require 'fix/protocol/header_fields'
2
3
 
3
4
  module Fix
4
5
  module Protocol
@@ -8,13 +9,14 @@ module Fix
8
9
  #
9
10
  class MessageHeader < MessagePart
10
11
 
12
+ extend Forwardable
13
+ def_delegators :header_fields, :msg_type, :msg_type=, :sender_comp_id, :sender_comp_id=, :target_comp_id,
14
+ :target_comp_id=, :msg_seq_num, :msg_seq_num=, :sending_time, :sending_time=
15
+
11
16
  field :version, tag: 8, required: true, default: 'FIX.4.4'
12
- field :body_length, tag: 9, default: 0
13
- field :msg_type, tag: 35, required: true
14
- field :sender_comp_id, tag: 49, required: true
15
- field :target_comp_id, tag: 56, required: true
16
- field :msg_seq_num, tag: 34, required: true, type: :integer
17
- field :sending_time, tag: 52, required: true, type: :timestamp, default: proc { Time.now }
17
+ field :body_length, tag: 9
18
+
19
+ unordered :header_fields, klass: HeaderFields
18
20
 
19
21
  #
20
22
  # Returns the errors relevant to the message header
@@ -62,6 +62,8 @@ module Fix
62
62
  nodes << FP::Field.new(node)
63
63
  elsif node[:node_type] == :collection
64
64
  nodes << FP::RepeatingMessagePart.new(node)
65
+ elsif node[:node_type] == :unordered
66
+ nodes << node[:klass].new(node)
65
67
  end
66
68
  end
67
69
 
@@ -121,6 +123,17 @@ module Fix
121
123
  end
122
124
  end
123
125
 
126
+ #
127
+ # Defines an unordered fields collection
128
+ #
129
+ # @param name [String] The part name, this will be the name of a dynamically created accessor on the message part
130
+ # @param opts [Hash] Options hash
131
+ #
132
+ def self.unordered(name, opts = {})
133
+ part(name, opts.merge({ node_type: :unordered }))
134
+ end
135
+
136
+
124
137
  #
125
138
  # Defines a field as part of the structure for this class
126
139
  #
@@ -0,0 +1,34 @@
1
+ module Fix
2
+ module Protocol
3
+
4
+ #
5
+ # Represents a collection of unordered fields
6
+ #
7
+ class UnorderedPart < MessagePart
8
+
9
+ #
10
+ # Parses a full or partial FIX message string into the message part nodes
11
+ #
12
+ # @return [String] The string part that wasn't consumed during the parsing
13
+ #
14
+ def parse(str)
15
+ left_to_parse = str
16
+ left_before_pass = nil
17
+
18
+ while (left_to_parse != left_before_pass) && !parse_failure
19
+ left_before_pass = left_to_parse
20
+
21
+ nodes.each do |node|
22
+ if node.can_parse?(left_to_parse)
23
+ left_to_parse = node.parse(left_to_parse)
24
+ self.parse_failure = node.parse_failure
25
+ end
26
+ end
27
+ end
28
+
29
+ left_to_parse
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -4,7 +4,7 @@ module Fix
4
4
  #
5
5
  # The fix-protocol gem version string
6
6
  #
7
- VERSION = '0.0.41'
7
+ VERSION = '0.0.50'
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: 0.0.41
4
+ version: 0.0.50
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: 2014-10-22 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -132,6 +132,7 @@ files:
132
132
  - lib/fix/protocol/field.rb
133
133
  - lib/fix/protocol/grammar.treetop
134
134
  - lib/fix/protocol/grammar_extensions/message.rb
135
+ - lib/fix/protocol/header_fields.rb
135
136
  - lib/fix/protocol/message.rb
136
137
  - lib/fix/protocol/message_class_mapping.rb
137
138
  - lib/fix/protocol/message_header.rb
@@ -152,6 +153,7 @@ files:
152
153
  - lib/fix/protocol/parse_failure.rb
153
154
  - lib/fix/protocol/repeating_message_part.rb
154
155
  - lib/fix/protocol/type_conversions.rb
156
+ - lib/fix/protocol/unordered_part.rb
155
157
  - lib/fix/protocol/version.rb
156
158
  - lib/fix/protocol.rb
157
159
  - LICENSE