galaxy 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/.idea/.rakeTasks +7 -0
  4. data/.idea/encodings.xml +5 -0
  5. data/.idea/galaxy.iml +10 -0
  6. data/.idea/misc.xml +14 -0
  7. data/.idea/modules.xml +9 -0
  8. data/.idea/vcs.xml +8 -0
  9. data/.idea/workspace.xml +486 -0
  10. data/LICENSE +20 -0
  11. data/README.rdoc +36 -0
  12. data/Rakefile +62 -0
  13. data/VERSION +1 -0
  14. data/doc/plan.txt +5 -0
  15. data/doc/pseudo.txt +43 -0
  16. data/features/galaxy.feature +9 -0
  17. data/features/step_definitions/galaxy_steps.rb +0 -0
  18. data/features/support/env.rb +4 -0
  19. data/galaxy.gemspec +95 -0
  20. data/galaxy/.loadpath +5 -0
  21. data/galaxy/.project +17 -0
  22. data/galaxy/.settings/org.eclipse.mylyn.tasks.ui.prefs +4 -0
  23. data/galaxy/.settings/org.eclipse.wst.sse.core.prefs +5 -0
  24. data/galaxy/experiments.rb +26 -0
  25. data/lib/galaxy.rb +8 -0
  26. data/lib/galaxy/models/bombing.rb +64 -0
  27. data/lib/galaxy/models/fleet.rb +62 -0
  28. data/lib/galaxy/models/group.rb +178 -0
  29. data/lib/galaxy/models/models.rb +16 -0
  30. data/lib/galaxy/models/planet.rb +181 -0
  31. data/lib/galaxy/models/product.rb +84 -0
  32. data/lib/galaxy/models/race.rb +112 -0
  33. data/lib/galaxy/models/route.rb +60 -0
  34. data/lib/galaxy/order.rb +24 -0
  35. data/lib/galaxy/report.rb +176 -0
  36. data/lib/galaxy/section.rb +226 -0
  37. data/lib/galaxy/utils.rb +109 -0
  38. data/lib/galaxy/virtual_base.rb +165 -0
  39. data/spec/spec_helper.rb +9 -0
  40. data/test/test_helper.rb +4 -0
  41. data/test/unit/models_test.rb +1469 -0
  42. data/test/unit/report_test.rb +187 -0
  43. data/test/unit/utils_test.rb +421 -0
  44. data/test/unit/virtual_base_test.rb +224 -0
  45. metadata +123 -0
@@ -0,0 +1,224 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ #require 'active_record'
3
+ #require 'virtual_base.rb'
4
+
5
+ ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ":memory:", :timeout => 500
6
+ ActiveRecord::Base.send(:include, ActiveRecord::VirtualBase)
7
+
8
+ class VirtualBaseModel < ActiveRecord::Base
9
+ tableless :columns => [
10
+ [:email, :string],
11
+ [:password, :string],
12
+ [:password_confirmation] ]
13
+
14
+ validates_presence_of :email, :password, :password_confirmation
15
+ validates_confirmation_of :password
16
+ end
17
+
18
+ class B_TablelessTest < Test::Unit::TestCase
19
+
20
+ def setup
21
+ super
22
+ @valid_attributes = {
23
+ :email => "robin@bogus.com",
24
+ :password => "password",
25
+ :password_confirmation => "password"
26
+ }
27
+ end
28
+
29
+ def test_create
30
+ assert VirtualBaseModel.create(@valid_attributes).valid?
31
+ end
32
+
33
+ def test_validations
34
+ # Just check a few validations to make sure we didn't break ActiveRecord::Validations::ClassMethods
35
+ assert_not_nil VirtualBaseModel.create(@valid_attributes.merge(:email => "")).errors[:email]
36
+ assert_not_nil VirtualBaseModel.create(@valid_attributes.merge(:password => "")).errors[:password]
37
+ assert_not_nil VirtualBaseModel.create(@valid_attributes.merge(:password_confirmation => "")).errors[:password]
38
+ end
39
+
40
+ def test_save
41
+ assert VirtualBaseModel.new(@valid_attributes).save
42
+ assert !VirtualBaseModel.new(@valid_attributes.merge(:password => "no_match")).save
43
+ end
44
+
45
+ def test_valid?
46
+ assert VirtualBaseModel.new(@valid_attributes).valid?
47
+ assert !VirtualBaseModel.new(@valid_attributes.merge(:password => "no_match")).valid?
48
+ end
49
+
50
+ def test_exists!
51
+ m = VirtualBaseModel.new(@valid_attributes)
52
+
53
+ assert_nil m.id
54
+ assert m.new_record?
55
+
56
+ m.exists!
57
+ assert_equal 1, m.id
58
+ assert !m.new_record?
59
+
60
+ m.exists!(250)
61
+ assert_equal 250, m.id
62
+ assert !m.new_record?
63
+ end
64
+ end
65
+
66
+ class B_ReportWithVBTest < Test::Unit::TestCase
67
+
68
+ def setup
69
+ require 'report.rb'
70
+
71
+ rep = Report.new 'rep/ArVit187.rep'
72
+ @data = ActiveRecord::Base.establish_dataset(rep)
73
+ @data.owner='ArVitallian'
74
+
75
+ @av = Race.new %w[ArVitallian 13.00 11.61 11.08 5.48 2276614.82 2028341.13 2515 - 2276.61],{}
76
+ @vd = Race.new %w[Vildok 10.33 1.00 1.00 6.07 2035.74 0.00 1 War 0.00], {}
77
+ @raz = Product.new %w[raz 1.00 0 0.00 0.00 0.00 1.00],{:race=>@vd}
78
+ @q = Product.new %w[QAK 1.00 0 0.00 2.33 0.00 3.33],{:race=>@av}
79
+ @s1 = Product.new %w[MoveTo_6300_12504 6299.55 12503.99 0 0],{:race=>@av}
80
+ @mark = Product.new %w[MAPKEP 8.00 0 0.00 0.00 1.00 9.00],{:race=>@av}
81
+ @p1 = Planet.new %w[9802 10483.56 10512.20 N-A4 2500.00 2349.00 2200.00 0.03 QAK 49.75 5214.30 2005.14 2300.00], {:race=>@av}
82
+ @p2 = Planet.new %w[7346 13906.25 17458.86 CYB 2500.00 0.07 0.00 3819.89], {}
83
+ @p3 = Planet.new %w[7261 15768.34 11160.36], {}
84
+ @p4 = Planet.new %w[7810 8-14R], {}
85
+ @f1 = Fleet.new %w[1 fgtr5 6 N-A4 - 0.00 112.50 In_Orbit], {:owner=>'ArVitallian'}
86
+ @g1 = Group.new %w[0 1 MAPKEP 2.22 0.00 0.00 1.00 COL 0.03 N-A4 - 0.00 39.34 9.03 - In_Orbit],
87
+ {:planet=>@p1, :race=>@av, :product=>@mark}
88
+ @g2 = Group.new %w[6830 1170 QAK 13.00 0.00 9.99 0.00 - 0.00 N-A4 - 0.00 78.08 3.33 fgtr5 In_Orbit],
89
+ {:planet=>@p1, :race=>@av, :product=>@q, :fleet=>@f1}
90
+ @r = Route.new %w[N-A4 - #7346 - -], {:owner=>'ArVitallian'}
91
+ end
92
+
93
+ def test_add
94
+ # Models are automatically added to dataset upon creation
95
+ assert @vd.add # Multiple add leaves object in the same place of dataset
96
+ assert @vd.add
97
+ assert_equal @vd, @data.races[1]
98
+ assert_equal @av, @data.races.first
99
+ assert_equal 2, @data.races.size
100
+ assert_equal @raz, @data.products[6] #first products (drive, cap, etc...) defined in Report
101
+ assert_equal @mark, @data.ships.last
102
+ assert_equal @mark, @data.products[-1]
103
+ assert_equal @s1, @data.sciences[0]
104
+ assert_equal @p1, @data.planets['N-A4']
105
+ assert_equal @p1, @data.your_planets[0]
106
+ assert_equal @p2, @data.planets['#7346']
107
+ assert_equal @p2, @data.uninhabited_planets[0]
108
+ assert_equal @p3, @data.planets['#7261']
109
+ assert_equal @p3, @data.unknown_planets[0]
110
+ assert_equal @f1, @data.fleets.first
111
+ assert_equal @g1, @data.groups.first
112
+ assert_equal @r, @data.routes.first
113
+
114
+ #Update a Planet and make sure no duplicates added to dataset
115
+ @p4.update_planet %w[7810 10483.56 10512.20 NEW 2500.00 2349.00 2200.00 0.03 QAK 49.75 5214.30 2005.14 2300.00], {:race=>@av}
116
+ assert_equal 4, @data.planets.size
117
+ assert_equal @p4, @data.planets['#7810']
118
+ assert_equal @p4, @data.planets['8-14R']
119
+ assert_equal @p4, @data.planets['NEW']
120
+ end
121
+
122
+ def test_lookup
123
+ assert_equal @av, Race.lookup(:first)
124
+ assert_equal @av, Race.lookup(0)
125
+ assert_equal @av, Race.lookup(@av.key)
126
+ assert_equal @av, Race.lookup(@av.idx)
127
+ assert_equal @vd, Race.lookup(:last)
128
+ assert_equal @vd, Race.lookup('Vildok')
129
+ assert_equal [@av,@vd], Race.lookup(:all)
130
+ assert_equal 'Drive', Product.lookup(:first).name # Auto-created by Report
131
+ assert_equal @mark, Product.lookup(:last)
132
+ assert_equal @s1, Product.lookup(8)
133
+ assert_equal @raz, Product.lookup(@raz.key)
134
+ assert_equal 10, Product.lookup(:all).size
135
+ assert_equal @p1, Planet.lookup(:first)
136
+ assert_equal @p4, Planet.lookup(:last)
137
+ assert_equal @p1, Planet.lookup('N-A4')
138
+ assert_equal @p1, Planet.lookup(@p1.key)
139
+ assert_equal @p1, Planet.lookup(@p1.idx)
140
+ assert_equal @p2, Planet.lookup('#7346')
141
+ assert_equal 4, Planet.lookup(:all).size
142
+ assert_equal @f1, Fleet.lookup(:first)
143
+ assert_equal @f1, Fleet.lookup(:last)
144
+ assert_equal @f1, Fleet.lookup('ArVitallian.fgtr5')
145
+ assert_equal @f1, Fleet.lookup(@f1.key)
146
+ assert_equal @f1, Fleet.lookup(@f1.idx)
147
+ assert_equal @f1, Fleet.lookup(0)
148
+ assert_equal @g1, Group.lookup(:first)
149
+ assert_equal @g2, Group.lookup(:last)
150
+ assert_equal @g1, Group.lookup('ArVitallian.0')
151
+ assert_equal @g1, Group.lookup(@g1.key)
152
+ assert_equal @g1, Group.lookup(@g1.idx)
153
+ assert_equal @g1, Group.lookup(0)
154
+ assert_equal @r, Route.lookup(:first)
155
+ assert_equal @r, Route.lookup(:last)
156
+ assert_equal @r, Route.lookup('9802.7346.mat')
157
+ assert_equal @r, Route.lookup(@r.key)
158
+ assert_equal @r, Route.lookup(@r.idx)
159
+ assert_equal @r, Route.lookup(0)
160
+ end
161
+
162
+ def test_kill
163
+ assert @raz.kill
164
+ assert_nil @data.products[@raz.key]
165
+ assert @mark.kill
166
+ assert_nil @data.products[@mark.key]
167
+ assert @q.kill
168
+ assert @data.ships.empty?
169
+ assert @s1.kill
170
+ assert_nil @data.sciences[0]
171
+ assert_nil @data.products[-1]
172
+ assert @p1.kill
173
+ assert_nil @data.planets['N-A4']
174
+ assert_nil @data.your_planets[0]
175
+ assert @p2.kill
176
+ assert_nil @data.planets['#7346']
177
+ assert_nil @data.uninhabited_planets[0]
178
+ assert @p3.kill
179
+ assert_nil @data.planets['#7261']
180
+ assert_nil @data.unknown_planets[1]
181
+ assert @f1.kill
182
+ assert_nil @data.fleets.first
183
+ assert @g1.kill
184
+ assert_nil @data.groups.first
185
+ assert @r.kill
186
+ assert_nil @data.routes.first
187
+ assert @av.kill
188
+ assert_nil @data.races.first
189
+ assert_nil @data.races['ArVitallian']
190
+ assert @vd.kill
191
+ assert_nil @data.races.last
192
+ assert_nil @vd.idx
193
+ end
194
+
195
+ def test_class_kill
196
+ Product.kill 'Vildok.raz'
197
+ assert_nil @data.products[@raz.key]
198
+ Product.kill :all
199
+ assert_nil @data.ships.last
200
+ assert_nil @data.products[@mark.key]
201
+ assert_nil @data.sciences[0]
202
+ assert_nil @data.products[-1]
203
+ Planet.kill 'N-A4'
204
+ assert_nil @data.your_planets[0]
205
+ assert_nil @data.planets['N-A4']
206
+ Planet.kill '#7346'
207
+ assert_nil @data.planets['#7346']
208
+ assert_nil @data.uninhabited_planets[0]
209
+ Planet.kill :last
210
+ assert_nil @data.planets['#7810']
211
+ assert_nil @data.unknown_planets[1]
212
+ Fleet.kill @f1.idx
213
+ assert_nil @data.fleets.first
214
+ Group.kill :first
215
+ assert_nil @data.groups.first
216
+ Route.kill :first
217
+ assert_nil @data.routes.first
218
+ Race.kill 'ArVitallian'
219
+ assert_nil @data.races['ArVitallian']
220
+ Race.kill :last
221
+ assert_nil @data.races.last
222
+ assert_nil @vd.idx
223
+ end
224
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: galaxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - arvicco
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-11 00:00:00 +03:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: cucumber
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: Report parser for Galaxy Plus PBEM
36
+ email: arvitallian@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - .idea/.rakeTasks
48
+ - .idea/encodings.xml
49
+ - .idea/galaxy.iml
50
+ - .idea/misc.xml
51
+ - .idea/modules.xml
52
+ - .idea/vcs.xml
53
+ - .idea/workspace.xml
54
+ - LICENSE
55
+ - README.rdoc
56
+ - Rakefile
57
+ - VERSION
58
+ - doc/plan.txt
59
+ - doc/pseudo.txt
60
+ - features/galaxy.feature
61
+ - features/step_definitions/galaxy_steps.rb
62
+ - features/support/env.rb
63
+ - galaxy.gemspec
64
+ - galaxy/.loadpath
65
+ - galaxy/.project
66
+ - galaxy/.settings/org.eclipse.mylyn.tasks.ui.prefs
67
+ - galaxy/.settings/org.eclipse.wst.sse.core.prefs
68
+ - galaxy/experiments.rb
69
+ - lib/galaxy.rb
70
+ - lib/galaxy/models/bombing.rb
71
+ - lib/galaxy/models/fleet.rb
72
+ - lib/galaxy/models/group.rb
73
+ - lib/galaxy/models/models.rb
74
+ - lib/galaxy/models/planet.rb
75
+ - lib/galaxy/models/product.rb
76
+ - lib/galaxy/models/race.rb
77
+ - lib/galaxy/models/route.rb
78
+ - lib/galaxy/order.rb
79
+ - lib/galaxy/report.rb
80
+ - lib/galaxy/section.rb
81
+ - lib/galaxy/utils.rb
82
+ - lib/galaxy/virtual_base.rb
83
+ - spec/spec_helper.rb
84
+ - test/test_helper.rb
85
+ - test/unit/models_test.rb
86
+ - test/unit/report_test.rb
87
+ - test/unit/utils_test.rb
88
+ - test/unit/virtual_base_test.rb
89
+ has_rdoc: true
90
+ homepage: http://github.com/arvicco/galaxy
91
+ licenses: []
92
+
93
+ post_install_message:
94
+ rdoc_options:
95
+ - --charset=UTF-8
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: "0"
103
+ version:
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: "0"
109
+ version:
110
+ requirements: []
111
+
112
+ rubyforge_project:
113
+ rubygems_version: 1.3.5
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Report parser for Galaxy Plus PBEM
117
+ test_files:
118
+ - spec/spec_helper.rb
119
+ - test/test_helper.rb
120
+ - test/unit/models_test.rb
121
+ - test/unit/report_test.rb
122
+ - test/unit/utils_test.rb
123
+ - test/unit/virtual_base_test.rb