gosu_extensions 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,9 +8,13 @@ begin
8
8
  gemspec.description = ""
9
9
  gemspec.authors = ["Florian Hanke"]
10
10
  gemspec.rdoc_options = ["--inline-source", "--charset=UTF-8"]
11
- gemspec.files = FileList["[A-Z]*", "{generators,lib,rails,spec}/**/*"]
11
+ gemspec.files = FileList["[A-Z]*", "{generator,lib}/**/*"]
12
+ gemspec.test_files = FileList["spec/**/*_spec.rb"]
12
13
  gemspec.add_dependency 'gosu'
13
14
  gemspec.add_dependency 'chipmunk'
15
+ # gemspec.bindir = 'bin'
16
+ # gemspec.executables = ['bin/gogogosu']
17
+ # gemspec.default_executable = 'bin/gogogosu'
14
18
  end
15
19
  Jeweler::GemcutterTasks.new
16
20
  rescue LoadError => e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -0,0 +1,26 @@
1
+ module Generator
2
+ class Gogogosu
3
+
4
+ def initialize
5
+ @basedir = Dir.pwd
6
+ end
7
+
8
+ # Generates a directory.
9
+ #
10
+ def dir name
11
+ Dir.mkdir name unless File.file?(name) || File.exist?(name)
12
+ if block_given?
13
+ Dir.chdir name
14
+ yield
15
+ Dir.chdir '..'
16
+ end
17
+ end
18
+
19
+ # Generates a file. Will be rendered with erb.
20
+ #
21
+ def file name
22
+
23
+ end
24
+
25
+ end
26
+ end
data/lib/traits/pod.rb CHANGED
@@ -75,6 +75,12 @@ module Pod
75
75
  self.attachments << attachment
76
76
  end
77
77
 
78
+ #
79
+ #
80
+ def detach attachment
81
+ self.attachments.delete attachment if self.attachments
82
+ end
83
+
78
84
  #
79
85
  #
80
86
  def move_attachments
@@ -1,5 +1,9 @@
1
1
  module ShortLived
2
2
 
3
+ # TODO Explain better what to do.
4
+ #
5
+ class LifetimeMissingError < StandardError; end
6
+
3
7
  def self.included klass
4
8
  klass.extend ClassMethods
5
9
  end
@@ -7,6 +11,7 @@ module ShortLived
7
11
  def initialize window
8
12
  super window
9
13
 
14
+ raise ShortLived::LifetimeMissingError.new unless self.respond_to? :lifetime
10
15
  threaded self.lifetime do
11
16
  self.destroy!
12
17
  end
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe Numeric do
4
+
5
+ describe "radians_to_vec2" do
6
+ it "should convert radians into a vector" do
7
+ 10.0.radians_to_vec2.should == nil
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,14 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe Shooter do
4
+
5
+ before(:each) do
6
+ @shooter = Class.new do
7
+ include Shooter
8
+ end
9
+ end
10
+ it "should define a constant Shoot" do
11
+ Shooter::Shoot.should == :shoot
12
+ end
13
+
14
+ end
@@ -0,0 +1,60 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe ShortLived do
4
+
5
+ before(:all) do
6
+ @window = stub :window
7
+ end
8
+
9
+ class SuperClass; def initialize(*); end; end
10
+
11
+ module ThreadedMock
12
+ def threaded lifetime
13
+ # TODO
14
+ end
15
+ end
16
+
17
+ def self.threaded_mock expected
18
+
19
+ end
20
+
21
+ context 'lifetime given as block' do
22
+ before(:each) do
23
+ @short_lived_class = Class.new(SuperClass) do
24
+ include ShortLived
25
+
26
+ lifetime { 10 + 10 }
27
+
28
+ def threaded(*); end
29
+ end
30
+ end
31
+ it "should define a method lifetime which returns the result of the block" do
32
+ @short_lived_class.new(@window).lifetime.should == 20
33
+ end
34
+ end
35
+ context 'lifetime given normally' do
36
+ before(:each) do
37
+ @short_lived_class = Class.new(SuperClass) do
38
+ include ShortLived
39
+
40
+ lifetime 30
41
+
42
+ def threaded(*); end
43
+ end
44
+ end
45
+ it "should define a method lifetime which returns the set value" do
46
+ @short_lived_class.new(@window).lifetime.should == 30
47
+ end
48
+ end
49
+ context 'no lifetime given – what now?' do
50
+ before(:each) do
51
+ @short_lived_class = Class.new(SuperClass) do
52
+ include ShortLived
53
+ end
54
+ end
55
+ it "should raise a LifetimeMissingError" do
56
+ lambda { @short_lived_class.new(@window) }.should raise_error(ShortLived::LifetimeMissingError)
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,51 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe Shot do
4
+
5
+ before(:each) do
6
+ @shot = Class.new do
7
+ include Shot
8
+ end.new
9
+ end
10
+ it "should define an attr_reader :velocity" do
11
+ lambda { @shot.velocity }.should_not raise_error
12
+ end
13
+ it "should define an attr_writer :velocity" do
14
+ lambda { @shot.velocity = :some_value }.should_not raise_error
15
+ end
16
+ it "should define an attr_reader :originator" do
17
+ lambda { @shot.originator }.should_not raise_error
18
+ end
19
+ it "should define an attr_writer :originator" do
20
+ lambda { @shot.originator = :some_value }.should_not raise_error
21
+ end
22
+
23
+ describe "shoot_from" do
24
+ before(:each) do
25
+ @window = stub :window, :null_object => true
26
+ @shot.stub :position= => nil
27
+ @shot.stub :window => @window
28
+ @shooter = stub :shooter, :muzzle_position => :some_muzzle_position
29
+ end
30
+ it "should return itself" do
31
+ @shot.shoot_from(@shooter).should == @shot
32
+ end
33
+ it "should set its position to the muzzle position of the shooter" do
34
+ @shot.should_receive(:position=).once.with :some_muzzle_position
35
+
36
+ @shot.shoot_from @shooter
37
+ end
38
+ it "should set its originator to the shooter" do
39
+ @shot.should_receive(:originator=).once.with @shooter
40
+
41
+ @shot.shoot_from @shooter
42
+ end
43
+ it "should register itself with the window" do
44
+ # TODO Or should it?
45
+ @window.should_receive(:register).once.with @shot
46
+
47
+ @shot.shoot_from @shooter
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe Targetable do
4
+
5
+ before(:each) do
6
+ @targetable = Class.new do
7
+ include Targetable
8
+ end.new
9
+ end
10
+ describe "distance_from" do
11
+ before(:each) do
12
+ @targetable.stub! :position => CP::Vec2.new(6, 8)
13
+ @shooter = stub :shooter, :position => CP::Vec2.new(3, 4)
14
+ end
15
+ it "should return the right distance" do
16
+ @targetable.distance_from(@shooter).should == 5.0
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe Targeting do
4
+
5
+ it "should define a module" do
6
+ Targeting.class.should == Module
7
+ end
8
+
9
+ end
@@ -0,0 +1,65 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe Turnable do
4
+
5
+ context 'default' do
6
+ before(:each) do
7
+ @turnable = Class.new do
8
+ include Turnable
9
+ end.new
10
+ end
11
+ describe "turn_speed" do
12
+ it "should have a defined turn_speed method" do
13
+ lambda { @turnable.turn_speed }.should_not raise_error
14
+ end
15
+ it "should return the class defined turn_speed" do
16
+ @turnable.turn_speed.should == 0.5
17
+ end
18
+ end
19
+ end
20
+
21
+ context 'non-default' do
22
+ before(:each) do
23
+ @turnable = Class.new do
24
+ include Turnable
25
+
26
+ turn_speed 1.3
27
+ end.new
28
+ @turnable.stub! :rotation => 1.0
29
+ end
30
+
31
+ describe "Constants" do
32
+ it "should have turn left" do
33
+ Turnable::Left.should == :turn_left
34
+ end
35
+ it "should have turn right" do
36
+ Turnable::Right.should == :turn_right
37
+ end
38
+ end
39
+
40
+ describe "turn_speed" do
41
+ it "should have a defined turn_speed method" do
42
+ lambda { @turnable.turn_speed }.should_not raise_error
43
+ end
44
+ it "should return the class defined turn_speed divided by 2" do
45
+ @turnable.turn_speed.should == 0.65
46
+ end
47
+ end
48
+
49
+ describe "turn_left" do
50
+ it "should subtract an amount from the rotation" do
51
+ @turnable.should_receive(:rotation=).once.with 0.9935
52
+
53
+ @turnable.turn_left
54
+ end
55
+ end
56
+ describe "turn_right" do
57
+ it "should add an amount to the rotation" do
58
+ @turnable.should_receive(:rotation=).once.with 1.0065
59
+
60
+ @turnable.turn_right
61
+ end
62
+ end
63
+ end
64
+
65
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 8
9
- version: 0.1.8
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-24 00:00:00 +01:00
17
+ date: 2010-04-04 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -52,6 +52,7 @@ extra_rdoc_files: []
52
52
  files:
53
53
  - Rakefile
54
54
  - VERSION
55
+ - generator/gogogosu.rb
55
56
  - lib/controls.rb
56
57
  - lib/extensions/module.rb
57
58
  - lib/extensions/numeric.rb
@@ -111,5 +112,11 @@ rubygems_version: 1.3.6
111
112
  signing_key:
112
113
  specification_version: 3
113
114
  summary: Default extensions built onto the popular Gosu Framework. Uses Chipmunk for game physics. That's it for now. I'm working on them. Anyway, GAME ON!
114
- test_files: []
115
-
115
+ test_files:
116
+ - spec/lib/extensions/numeric_spec.rb
117
+ - spec/lib/traits/shooter_spec.rb
118
+ - spec/lib/traits/short_lived_spec.rb
119
+ - spec/lib/traits/shot_spec.rb
120
+ - spec/lib/traits/targetable_spec.rb
121
+ - spec/lib/traits/targeting_spec.rb
122
+ - spec/lib/traits/turnable_spec.rb