dxruby_sdl 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,93 +24,52 @@ describe DXRubySDL::Window do
24
24
  }.to raise_error(SystemExit)
25
25
  end
26
26
  end
27
+ end
27
28
 
28
- describe '.draw', 'Imageオブジェクトを描画する' do
29
- subject do
30
- expect {
31
- DXRubySDL::Window.loop do
32
- DXRubySDL::Window.draw(0, 0, image)
33
- SDL::Event.push(SDL::Event::Quit.new)
34
- end
35
- }.to raise_error(SystemExit)
36
- end
37
-
38
- context '(0, 0)-(100,100)の白い線を描いたImageオブジェクトを指定した場合' do
39
- let!(:image) {
40
- i = DXRubySDL::Image.new(640, 480)
41
- i.line(0, 0, 100, 100, [255, 255, 255])
42
- i
43
- }
29
+ shared_context '.draw_font' do
30
+ context 'サイズのみを設定したフォントを指定した場合' do
31
+ let!(:font) { DXRubySDL::Font.new(32) }
32
+ let(:args) { [0, 0, 'やあ', font] }
44
33
 
45
- it '白い線を描画する' do
46
- subject
47
- end
34
+ it '文字列を描画する' do
35
+ subject
48
36
  end
49
37
 
50
- context '(0, 0)-(100,100)の矩形を描いたImageオブジェクトを指定した場合' do
51
- let!(:image) {
52
- i = DXRubySDL::Image.new(640, 480)
53
- i.box(0, 0, 100, 100, [255, 255, 255])
54
- i
55
- }
38
+ hash = { color: [255, 0, 0] }
39
+ context "第5引数に色(#{hash.inspect})を指定した場合" do
40
+ let(:args) { [0, 0, 'やあ', font, hash] }
56
41
 
57
- it '矩形を描画する' do
42
+ it '文字列を描画する' do
58
43
  subject
59
44
  end
60
45
  end
46
+ end
47
+ end
61
48
 
62
- context '(50, 50)、半径25の円を描いたImageオブジェクトを指定した場合' do
63
- let!(:image) {
64
- i = DXRubySDL::Image.new(640, 480)
65
- i.circle(50, 50, 25, [255, 255, 255])
66
- i
67
- }
49
+ describe '.draw_font', '文字列を描画する' do
50
+ include_context '.draw_font'
68
51
 
69
- it '円を描画する' do
70
- subject
52
+ subject do
53
+ expect {
54
+ DXRubySDL::Window.loop do
55
+ DXRubySDL::Window.draw_font(*args)
56
+ SDL::Event.push(SDL::Event::Quit.new)
71
57
  end
72
- end
73
-
74
- context '画像を読み込んだImageオブジェクトを指定した場合' do
75
- it '画像を描画する' do
76
- expect {
77
- path = File.expand_path('../../fixtures/logo.png', __FILE__)
78
- i = DXRubySDL::Image.load(path)
79
- DXRubySDL::Window.loop do
80
- DXRubySDL::Window.draw(0, 0, i)
81
- SDL::Event.push(SDL::Event::Quit.new)
82
- end
83
- }.to raise_error(SystemExit)
84
- end
85
- end
58
+ }.to raise_error(SystemExit)
86
59
  end
87
60
 
88
- describe '.draw_font', '文字列を描画する' do
89
- context 'サイズのみを設定したフォントを指定した場合' do
90
- let!(:font) { DXRubySDL::Font.new(32) }
91
- let(:args) { [0, 0, 'やあ', font] }
92
-
61
+ describe 'alias' do
62
+ describe '.drawFont' do
93
63
  subject do
94
64
  expect {
95
65
  DXRubySDL::Window.loop do
96
- DXRubySDL::Window.draw_font(*args)
66
+ DXRubySDL::Window.drawFont(*args)
97
67
  SDL::Event.push(SDL::Event::Quit.new)
98
68
  end
99
69
  }.to raise_error(SystemExit)
100
70
  end
101
71
 
102
- it '文字列を描画する' do
103
- subject
104
- end
105
-
106
- hash = { color: [255, 0, 0] }
107
- context "第5引数に色(#{hash.inspect})を指定した場合" do
108
- let(:args) { [0, 0, 'やあ', font, hash] }
109
-
110
- it '文字列を描画する' do
111
- subject
112
- end
113
- end
72
+ it_should_behave_like '.draw_font'
114
73
  end
115
74
  end
116
75
  end
@@ -9,23 +9,208 @@ describe DXRubySDL do
9
9
  it { should match(/\A[0-9]\.[0-9]+\.[0-9]+\z/) }
10
10
  end
11
11
 
12
- describe 'require \'dxruby\'' do
13
- before do
14
- require 'dxruby'
12
+ shared_examples 'constant' do |name, value|
13
+ it "::#{name}の値は#{value}である" do
14
+ expect(DXRubySDL.const_get(name.to_sym)).to eq(value)
15
15
  end
16
+ end
16
17
 
17
- %w[
18
- Window
19
- Image
20
- Font
21
- ].each do |klass_name|
22
- it "トップレベルに#{klass_name}が定義されている" do
23
- expect {
24
- # rubocop:disable Eval
25
- eval("::#{klass_name}")
26
- # rubocop:enable Eval
27
- }.not_to raise_error
28
- end
29
- end
18
+ %w[
19
+ DIK_0
20
+ DIK_1
21
+ DIK_2
22
+ DIK_3
23
+ DIK_4
24
+ DIK_5
25
+ DIK_6
26
+ DIK_7
27
+ DIK_8
28
+ DIK_9
29
+ DIK_A
30
+ DIK_ABNT_C1
31
+ DIK_ABNT_C2
32
+ DIK_ADD
33
+ DIK_APOSTROPHE
34
+ DIK_APPS
35
+ DIK_AT
36
+ DIK_AX
37
+ DIK_B
38
+ DIK_BACK
39
+ DIK_BACKSLASH
40
+ DIK_C
41
+ DIK_CALCULATOR
42
+ DIK_CAPITAL
43
+ DIK_COLON
44
+ DIK_COMMA
45
+ DIK_CONVERT
46
+ DIK_D
47
+ DIK_DECIMAL
48
+ DIK_DELETE
49
+ DIK_DIVIDE
50
+ DIK_DOWN
51
+ DIK_E
52
+ DIK_END
53
+ DIK_EQUALS
54
+ DIK_ESCAPE
55
+ DIK_F
56
+ DIK_F1
57
+ DIK_F2
58
+ DIK_F3
59
+ DIK_F4
60
+ DIK_F5
61
+ DIK_F6
62
+ DIK_F7
63
+ DIK_F8
64
+ DIK_F9
65
+ DIK_F10
66
+ DIK_F11
67
+ DIK_F12
68
+ DIK_F13
69
+ DIK_F14
70
+ DIK_F15
71
+ DIK_G
72
+ DIK_GRAVE
73
+ DIK_H
74
+ DIK_HOME
75
+ DIK_I
76
+ DIK_INSERT
77
+ DIK_J
78
+ DIK_K
79
+ DIK_KANA
80
+ DIK_KANJI
81
+ DIK_L
82
+ DIK_LBRACKET
83
+ DIK_LCONTROL
84
+ DIK_LEFT
85
+ DIK_LMENU
86
+ DIK_LSHIFT
87
+ DIK_LWIN
88
+ DIK_M
89
+ DIK_MAIL
90
+ DIK_MEDIASELECT
91
+ DIK_MEDIASTOP
92
+ DIK_MINUS
93
+ DIK_MULTIPLY
94
+ DIK_MUTE
95
+ DIK_MYCOMPUTER
96
+ DIK_N
97
+ DIK_NEXT
98
+ DIK_NEXTTRACK
99
+ DIK_NOCONVERT
100
+ DIK_NUMLOCK
101
+ DIK_NUMPAD0
102
+ DIK_NUMPAD1
103
+ DIK_NUMPAD2
104
+ DIK_NUMPAD3
105
+ DIK_NUMPAD4
106
+ DIK_NUMPAD5
107
+ DIK_NUMPAD6
108
+ DIK_NUMPAD7
109
+ DIK_NUMPAD8
110
+ DIK_NUMPAD9
111
+ DIK_NUMPADCOMMA
112
+ DIK_NUMPADENTER
113
+ DIK_NUMPADEQUALS
114
+ DIK_O
115
+ DIK_OEM_102
116
+ DIK_P
117
+ DIK_PAUSE
118
+ DIK_PERIOD
119
+ DIK_PLAYPAUSE
120
+ DIK_POWER
121
+ DIK_PREVTRACK
122
+ DIK_PRIOR
123
+ DIK_Q
124
+ DIK_R
125
+ DIK_RBRACKET
126
+ DIK_RCONTROL
127
+ DIK_RETURN
128
+ DIK_RIGHT
129
+ DIK_RMENU
130
+ DIK_RSHIFT
131
+ DIK_RWIN
132
+ DIK_S
133
+ DIK_SCROLL
134
+ DIK_SEMICOLON
135
+ DIK_SLASH
136
+ DIK_SLEEP
137
+ DIK_SPACE
138
+ DIK_STOP
139
+ DIK_SUBTRACT
140
+ DIK_SYSRQ
141
+ DIK_T
142
+ DIK_TAB
143
+ DIK_U
144
+ DIK_UNDERLINE
145
+ DIK_UNLABELED
146
+ DIK_UP
147
+ DIK_V
148
+ DIK_VOLUMEDOWN
149
+ DIK_VOLUMEUP
150
+ DIK_W
151
+ DIK_WAKE
152
+ DIK_WEBBACK
153
+ DIK_WEBFAVORITES
154
+ DIK_WEBFORWARD
155
+ DIK_WEBHOME
156
+ DIK_WEBREFRESH
157
+ DIK_WEBSEARCH
158
+ DIK_WEBSTOP
159
+ DIK_X
160
+ DIK_Y
161
+ DIK_YEN
162
+ DIK_Z
163
+ ].each.with_index do |dik_name, i|
164
+ include_examples 'constant', dik_name.sub(/\ADI/, ''), i
165
+ end
166
+
167
+ %w[
168
+ P_LEFT
169
+ P_RIGHT
170
+ P_UP
171
+ P_DOWN
172
+ P_BUTTON0
173
+ P_BUTTON1
174
+ P_BUTTON2
175
+ P_BUTTON3
176
+ P_BUTTON4
177
+ P_BUTTON5
178
+ P_BUTTON6
179
+ P_BUTTON7
180
+ P_BUTTON8
181
+ P_BUTTON9
182
+ P_BUTTON10
183
+ P_BUTTON11
184
+ P_BUTTON12
185
+ P_BUTTON13
186
+ P_BUTTON14
187
+ P_BUTTON15
188
+ P_D_LEFT
189
+ P_D_RIGHT
190
+ P_D_UP
191
+ P_D_DOWN
192
+ P_R_LEFT
193
+ P_R_RIGHT
194
+ P_R_UP
195
+ P_R_DOWN
196
+ ].each.with_index do |name, i|
197
+ include_examples 'constant', name, i
198
+ end
199
+
200
+ %w[
201
+ P_L_LEFT
202
+ P_L_RIGHT
203
+ P_L_UP
204
+ P_L_DOWN
205
+ ].each.with_index do |name, i|
206
+ include_examples 'constant', name, i
207
+ end
208
+
209
+ %w[
210
+ M_LBUTTON
211
+ M_RBUTTON
212
+ M_MBUTTON
213
+ ].each.with_index do |name, i|
214
+ include_examples 'constant', name, i
30
215
  end
31
216
  end
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe 'require \'dxruby\'' do
5
+ before do
6
+ require 'dxruby'
7
+ end
8
+
9
+ %w[
10
+ Window
11
+ Image
12
+ Font
13
+ ].each do |klass_name|
14
+ it "トップレベルに#{klass_name}が定義されている" do
15
+ expect {
16
+ # rubocop:disable Eval
17
+ eval("::#{klass_name}")
18
+ # rubocop:enable Eval
19
+ }.not_to raise_error
20
+ end
21
+ end
22
+ end
Binary file
Binary file
data/spec/spec_helper.rb CHANGED
@@ -5,3 +5,7 @@ Coveralls.wear!
5
5
 
6
6
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
7
7
  require 'dxruby_sdl'
8
+
9
+ Dir.glob(File.expand_path('../support/**/*.rb', __FILE__)).each do |path|
10
+ require path
11
+ end
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # spec/fixturesに配置しているファイルの絶対パスを返す
4
+ #
5
+ # @param [String] filename ファイル名
6
+ def fixture_path(filename)
7
+ return File.expand_path("../../fixtures/#{filename}", __FILE__)
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dxruby_sdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-08 00:00:00.000000000 Z
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,17 +146,39 @@ files:
146
146
  - lib/dxruby_sdl/color.rb
147
147
  - lib/dxruby_sdl/font.rb
148
148
  - lib/dxruby_sdl/image.rb
149
+ - lib/dxruby_sdl/input.rb
150
+ - lib/dxruby_sdl/sound.rb
149
151
  - lib/dxruby_sdl/version.rb
150
152
  - lib/dxruby_sdl/window.rb
151
153
  - lib/dxruby_sdl/window/fpstimer.rb
154
+ - samples/bgm.mid
155
+ - samples/data.png
156
+ - samples/sound.wav
157
+ - samples/tutorial-2-01.rb
158
+ - samples/tutorial-2-02.rb
159
+ - samples/tutorial-2-03.rb
160
+ - samples/tutorial-2-04.rb
161
+ - samples/tutorial-2-05.rb
162
+ - samples/tutorial-2-06.rb
163
+ - samples/tutorial-2-07.rb
164
+ - samples/tutorial-2-08.rb
165
+ - samples/tutorial-2-09.rb
166
+ - samples/tutorial-2-10.rb
152
167
  - spec/dxruby_sdl/color_spec.rb
153
168
  - spec/dxruby_sdl/font_spec.rb
154
169
  - spec/dxruby_sdl/image_spec.rb
170
+ - spec/dxruby_sdl/input_spec.rb
171
+ - spec/dxruby_sdl/sound_spec.rb
172
+ - spec/dxruby_sdl/window__draw_spec.rb
155
173
  - spec/dxruby_sdl/window_spec.rb
156
174
  - spec/dxruby_sdl_spec.rb
175
+ - spec/dxruby_spec.rb
176
+ - spec/fixtures/bgm.mid
157
177
  - spec/fixtures/logo.jpg
158
178
  - spec/fixtures/logo.png
179
+ - spec/fixtures/sound.wav
159
180
  - spec/spec_helper.rb
181
+ - spec/support/fixture_helper.rb
160
182
  homepage: https://github.com/takaokouji/dxruby-sdl
161
183
  licenses:
162
184
  - MIT
@@ -185,8 +207,15 @@ test_files:
185
207
  - spec/dxruby_sdl/color_spec.rb
186
208
  - spec/dxruby_sdl/font_spec.rb
187
209
  - spec/dxruby_sdl/image_spec.rb
210
+ - spec/dxruby_sdl/input_spec.rb
211
+ - spec/dxruby_sdl/sound_spec.rb
212
+ - spec/dxruby_sdl/window__draw_spec.rb
188
213
  - spec/dxruby_sdl/window_spec.rb
189
214
  - spec/dxruby_sdl_spec.rb
215
+ - spec/dxruby_spec.rb
216
+ - spec/fixtures/bgm.mid
190
217
  - spec/fixtures/logo.jpg
191
218
  - spec/fixtures/logo.png
219
+ - spec/fixtures/sound.wav
192
220
  - spec/spec_helper.rb
221
+ - spec/support/fixture_helper.rb