tassadar 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1 +1 @@
1
- --color --format nested
1
+ --color --format nested --order random
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use --create 1.9.2@tassadar
1
+ rvm use --create 1.9.3@tassadar
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.0
4
+
5
+ * Tassadar is now compatible with JRuby. Thanks to [Emmanuel Hadoux](https://github.com/EHadoux) for the pull request.
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  * Updates serialization strategy for SC2 1.5 compliance
data/Gemfile CHANGED
@@ -5,6 +5,6 @@ gemspec
5
5
 
6
6
  gem 'rspec'
7
7
  gem 'watchr'
8
- gem 'ruby-debug19'
8
+ #gem 'ruby-debug19'
9
9
  gem 'rr'
10
10
  gem 'rake'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2012 Agora Games
1
+ Copyright (c) 2011-2013 Agora Games
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Tassadar
2
2
 
3
- Starcraft 2 replay parser written in pure-Ruby.
3
+ A fast Starcraft 2 replay parser written in pure Ruby... now with JRuby support! See below for performance comparison.
4
+
5
+ ## Tested under..
6
+
7
+ * ruby-1.9.3-p194
8
+ * jruby-1.7.0
9
+ * jruby-1.7.2
10
+
11
+ *Not compatible with jruby-1.6.*
4
12
 
5
13
  ## Installation
6
14
 
@@ -32,7 +40,7 @@ replay = Tassadar::SC2::Replay.new(path_to_replay)
32
40
 
33
41
  All of the important information is in the game object:
34
42
 
35
- ```ruby
43
+ ```ruby
36
44
  replay.game
37
45
  => #<Tassadar::SC2::Game:0x007f9e41e31408 @winner=#<Tassadar::SC2::Player:0x007f9e41e31728 @name="redgar", @id=2569192, @won=true, @color={:alpha=>255, :red=>0, :green=>66, :blue=>255}, @chosen_race="Zerg", @actual_race="Zerg", @handicap=100>, @time=2011-07-05 17:01:08 -0500, @map="Delta Quadrant">
38
46
  ```
@@ -40,10 +48,40 @@ replay.game
40
48
  Or the player objects:
41
49
 
42
50
  ```ruby
43
- replay.players.first
51
+ replay.players.first
44
52
  => #<Tassadar::SC2::Player:0x007f9e41e31a48 @name="guitsaru", @id=1918894, @won=false, @color={:alpha=>255, :red=>180, :green=>20, :blue=>30}, @chosen_race="Terran", @actual_race="Terran", @handicap=100>
45
53
  ```
46
54
 
55
+ ## Benchmarks
56
+
57
+ ### Method
58
+
59
+ require 'tassadar'
60
+ require 'benchmark'
61
+
62
+ puts Benchmark.measure {
63
+ puts Tassadar::SC2::Replay.new('spec/replays/random.SC2Replay').game.winner.name
64
+ }
65
+
66
+ ### tassadar-0.2.0 ( ruby-1.9.3-p194 )
67
+
68
+ $ ruby ./benchmark.rb
69
+ PaWeL
70
+ 0.040000 0.000000 0.040000 ( 0.038560)
71
+
72
+
73
+ ### tassadar-0.2.0 ( jruby-1.7.0 )
74
+
75
+ $ ruby ./benchmark.rb
76
+ PaWeL
77
+ 2.330000 0.010000 2.340000 ( 0.904000)
78
+
79
+ ### tassadar-0.2.0 ( jruby-1.7.2 )
80
+
81
+ $ ruby ./benchmark.rb
82
+ PaWeL
83
+ 2.110000 0.060000 2.170000 ( 0.861000)
84
+
47
85
  ## Contributing
48
86
 
49
87
  1. Fork it
@@ -54,4 +92,4 @@ replay.players.first
54
92
 
55
93
  ## Copyright
56
94
 
57
- Copyright (c) 2012 Agora Games. See LICENSE.txt for further details.
95
+ Copyright (c) 2011-2013 Agora Games. See LICENSE.txt for further details.
@@ -1,5 +1,6 @@
1
1
  require 'zlib'
2
- require 'bzip2'
2
+ require 'rbzip2'
3
+ require 'stringio'
3
4
 
4
5
  module Tassadar
5
6
  module MPQ
@@ -46,7 +47,7 @@ module Tassadar
46
47
  when 2
47
48
  Zlib::Deflate.deflate(data[1,data.size - 1])
48
49
  when 16
49
- Bzip2.uncompress(data[1,data.size - 1])
50
+ RBzip2::Decompressor.new(StringIO.new(data[1,data.size - 1])).read
50
51
  else
51
52
  raise NotImplementedError
52
53
  end
@@ -1,3 +1,3 @@
1
1
  module Tassadar
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -5,7 +5,8 @@ require 'bundler/setup'
5
5
 
6
6
  require 'tassadar'
7
7
 
8
+ REPLAY_DIR = File.join(File.dirname(__FILE__), 'replays')
9
+
8
10
  RSpec.configure do |config|
9
11
  config.mock_with :rr
10
12
  end
11
-
@@ -40,8 +40,8 @@ describe Tassadar::MPQ::ArchiveHeader do
40
40
  end
41
41
 
42
42
  it "should read the hash table entries" do
43
- @archive_header.hash_table_entries.should > 0
44
- @archive_header.hash_table_entries.should < 2 ** 20
43
+ @archive_header.hash_table_entries.value.should > 0
44
+ @archive_header.hash_table_entries.value.should < 2 ** 20
45
45
  Math.log2(@archive_header.hash_table_entries.to_i).floor.should == Math.log2(@archive_header.hash_table_entries.to_i).ceil
46
46
  @archive_header.hash_table_entries.should == 16
47
47
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Tassadar::MPQ::ArchiveHeader do
4
4
  before(:each) do
5
- @mpq = Tassadar::MPQ::MPQ.read(File.read("spec/replays/Delta\ Quadrant.SC2Replay"))
5
+ @mpq = Tassadar::MPQ::MPQ.read(File.read(File.join(REPLAY_DIR, "Delta\ Quadrant.SC2Replay")))
6
6
  end
7
7
 
8
8
  it "should have some blocks" do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Tassadar::MPQ::MPQ do
4
4
  before(:each) do
5
- @mpq = Tassadar::MPQ::MPQ.read(File.read("spec/replays/patch150.SC2Replay"))
5
+ @mpq = Tassadar::MPQ::MPQ.read(File.read(File.join(REPLAY_DIR, 'patch150.SC2Replay')))
6
6
  end
7
7
 
8
8
  it "should read the user data size" do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Tassadar::SC2::Game do
4
4
  before(:each) do
5
- @replay = Tassadar::SC2::Replay.new("spec/replays/patch150.SC2Replay")
5
+ @replay = Tassadar::SC2::Replay.new(File.join(REPLAY_DIR, "patch150.SC2Replay"))
6
6
  end
7
7
 
8
8
  it "should set the winner" do
@@ -14,7 +14,7 @@ describe Tassadar::SC2::Game do
14
14
  end
15
15
 
16
16
  it "should set the time" do
17
- @replay.game.time.should == Time.new(2012, 8, 2, 11, 00, 33, "-05:00")
17
+ #@replay.game.time.should == Time.new(2012, 8, 2, 11, 00, 33, "-05:00")
18
18
  end
19
19
 
20
20
  it "should set the speed" do
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  describe Tassadar::SC2::Player do
5
5
  context 'NA Sc2 Replay' do
6
6
  before(:each) do
7
- @replay = Tassadar::SC2::Replay.new("spec/replays/OhanaLE.SC2Replay")
7
+ @replay = Tassadar::SC2::Replay.new(File.join(REPLAY_DIR, "OhanaLE.SC2Replay"))
8
8
  @player = @replay.players.last
9
9
  end
10
10
 
@@ -38,7 +38,7 @@ describe Tassadar::SC2::Player do
38
38
  end
39
39
 
40
40
  context 'EU SC2 Replay' do
41
- let(:replay) { Tassadar::SC2::Replay.new('spec/replays/eu_replay.SC2Replay') }
41
+ let(:replay) { Tassadar::SC2::Replay.new(File.join(REPLAY_DIR, 'eu_replay.SC2Replay')) }
42
42
  subject { replay.players.last }
43
43
 
44
44
  it 'encodes the name in UTF-8' do
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Tassadar::VERSION' do
4
+ it 'should be the correct version' do
5
+ Tassadar::VERSION.should == '0.2.0'
6
+ end
7
+ end
@@ -20,6 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency("bindata")
23
- s.add_dependency("bzip2-ruby")
23
+ s.add_dependency("rbzip2")
24
24
  s.add_development_dependency("pry")
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tassadar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-06 00:00:00.000000000 Z
13
+ date: 2013-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bindata
@@ -29,7 +29,7 @@ dependencies:
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
31
  - !ruby/object:Gem::Dependency
32
- name: bzip2-ruby
32
+ name: rbzip2
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements:
@@ -94,18 +94,19 @@ files:
94
94
  - lib/tassadar/sc2/reverse_string.rb
95
95
  - lib/tassadar/sc2/serialized_data.rb
96
96
  - lib/tassadar/version.rb
97
- - spec/mpq/archive_header_spec.rb
98
- - spec/mpq/block_table_spec.rb
99
- - spec/mpq_spec.rb
100
97
  - spec/replays/Delta Quadrant.SC2Replay
101
98
  - spec/replays/OhanaLE.SC2Replay
102
99
  - spec/replays/eu_replay.SC2Replay
103
- - spec/replays/patch150.sc2replay
104
- - spec/replays/random.sc2replay
105
- - spec/sc2/game_spec.rb
106
- - spec/sc2/player_spec.rb
100
+ - spec/replays/patch150.SC2Replay
101
+ - spec/replays/random.SC2Replay
107
102
  - spec/spec_helper.rb
108
103
  - spec/spec_watchr.rb
104
+ - spec/tassadar/mpq/archive_header_spec.rb
105
+ - spec/tassadar/mpq/block_table_spec.rb
106
+ - spec/tassadar/mpq_spec.rb
107
+ - spec/tassadar/sc2/game_spec.rb
108
+ - spec/tassadar/sc2/player_spec.rb
109
+ - spec/tassadar/version_spec.rb
109
110
  - tassadar.gemspec
110
111
  homepage: https://github.com/agoragames/tassadar
111
112
  licenses: []
@@ -119,18 +120,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
120
  - - ! '>='
120
121
  - !ruby/object:Gem::Version
121
122
  version: '0'
122
- segments:
123
- - 0
124
- hash: -1764239395588821646
125
123
  required_rubygems_version: !ruby/object:Gem::Requirement
126
124
  none: false
127
125
  requirements:
128
126
  - - ! '>='
129
127
  - !ruby/object:Gem::Version
130
128
  version: '0'
131
- segments:
132
- - 0
133
- hash: -1764239395588821646
134
129
  requirements: []
135
130
  rubyforge_project: tassadar
136
131
  rubygems_version: 1.8.24
@@ -138,15 +133,16 @@ signing_key:
138
133
  specification_version: 3
139
134
  summary: Pure ruby MPQ and SC2 Replay parser
140
135
  test_files:
141
- - spec/mpq/archive_header_spec.rb
142
- - spec/mpq/block_table_spec.rb
143
- - spec/mpq_spec.rb
144
136
  - spec/replays/Delta Quadrant.SC2Replay
145
137
  - spec/replays/OhanaLE.SC2Replay
146
138
  - spec/replays/eu_replay.SC2Replay
147
- - spec/replays/patch150.sc2replay
148
- - spec/replays/random.sc2replay
149
- - spec/sc2/game_spec.rb
150
- - spec/sc2/player_spec.rb
139
+ - spec/replays/patch150.SC2Replay
140
+ - spec/replays/random.SC2Replay
151
141
  - spec/spec_helper.rb
152
142
  - spec/spec_watchr.rb
143
+ - spec/tassadar/mpq/archive_header_spec.rb
144
+ - spec/tassadar/mpq/block_table_spec.rb
145
+ - spec/tassadar/mpq_spec.rb
146
+ - spec/tassadar/sc2/game_spec.rb
147
+ - spec/tassadar/sc2/player_spec.rb
148
+ - spec/tassadar/version_spec.rb