finance-fix 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/Changes ADDED
@@ -0,0 +1,5 @@
1
+ Revision history for Finance::FIX
2
+
3
+ 0.0.1 2010-11-15 16:19
4
+ First release of Finance::FIX, a library for parsing FIX protocol messages.
5
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Blair Christensen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = finance-fix.ruby
2
+
3
+ Parse FIX protocol messages.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Blair Christensen. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ #require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ require File.join( '.', 'lib', 'finance-fix.rb' )
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "finance-fix"
9
+ gem.version = Finance::FIX::VERSION
10
+ gem.summary = %Q{Parse FIX protocol messages.}
11
+ gem.description = %Q{Parse FIX protocol messages.}
12
+ gem.email = "blair.christensen@gmail.com"
13
+ gem.homepage = "http://github.com/blairc/finance-fix.ruby"
14
+ gem.authors = ["Blair Christensen"]
15
+ gem.add_development_dependency "shoulda", ">= 0"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError => e
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler: #{e}"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/test_*.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "finance-fix #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
@@ -0,0 +1,17 @@
1
+ module Finance # :nodoc
2
+ # Finance::FIX - Parse FIX protocol messages
3
+ class FIX
4
+ VERSION = '0.0.1'
5
+
6
+ def new
7
+ yield self if block_given?
8
+ end
9
+
10
+ # Parse "message", returning array of FIX message nodes, broken down in arrays of keys and
11
+ # values.
12
+ def parse(msg)
13
+ msg.split(/\x01/).collect { |pair| pair.split(/=/) } # Split on "SOH then "="
14
+ end
15
+
16
+ end # class FIX
17
+ end # module Finance
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'finance-fix'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+
3
+ class TestFinanceFix < Test::Unit::TestCase
4
+ should "be able to instantiate Finance::FIX" do
5
+ assert Finance::FIX.new
6
+ assert_kind_of Finance::FIX, Finance::FIX.new
7
+ end
8
+
9
+ should "be able to parse a sample FIX message" do
10
+ # From http://en.wikipedia.org/wiki/Financial_Information_eXchange
11
+ msg = "8=FIX.4.29=17835=849=PHLX56=PERS52=20071123-05:30:00.00011=ATOMNOCCC999090020=3150=E39=E55=MSFT167=CS54=138=1540=244=1558=PHLX EQUITY TESTING59=047=C32=031=0151=1514=06=010=128";
12
+
13
+ Finance::FIX.new do |fix|
14
+ nodes = fix.parse(msg)
15
+
16
+ assert_not_nil nodes, 'parse() returned something'
17
+ assert_equal 25, nodes.size, 'parse() returned right number of nodes'
18
+ assert_equal '8', nodes[0][0], "[0][0] == '8'"
19
+ assert_equal 'FIX.4.2', nodes[0][1], "[0][1] == 'FIX.4.2'"
20
+ assert_equal '10', nodes[24][0], "[24][0] == '10'"
21
+ assert_equal '128', nodes[24][1], "[24][1] == '128'"
22
+ end
23
+ end
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: finance-fix
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Blair Christensen
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-13 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: shoulda
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
33
+ description: Parse FIX protocol messages.
34
+ email: blair.christensen@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - LICENSE
41
+ - README.rdoc
42
+ files:
43
+ - .document
44
+ - .gitignore
45
+ - Changes
46
+ - LICENSE
47
+ - README.rdoc
48
+ - Rakefile
49
+ - lib/finance-fix.rb
50
+ - test/helper.rb
51
+ - test/test_finance-fix.rb
52
+ has_rdoc: true
53
+ homepage: http://github.com/blairc/finance-fix.ruby
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options:
58
+ - --charset=UTF-8
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.3.7
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Parse FIX protocol messages.
84
+ test_files:
85
+ - test/helper.rb
86
+ - test/test_finance-fix.rb