metro 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/Gemfile +7 -0
- data/Guardfile +4 -0
- data/README.md +8 -0
- data/lib/gosu_ext/color.rb +25 -1
- data/lib/metro.rb +30 -2
- data/lib/metro/animation/animation_factory.rb +14 -0
- data/lib/metro/animation/has_animations.rb +37 -0
- data/lib/metro/error.rb +21 -0
- data/lib/metro/events/event_factory.rb +15 -0
- data/lib/metro/{event_relay.rb → events/event_relay.rb} +83 -25
- data/lib/metro/events/has_events.rb +108 -0
- data/lib/metro/events/unknown_sender.rb +5 -0
- data/lib/metro/game.rb +12 -0
- data/lib/metro/game/dsl.rb +21 -2
- data/lib/metro/missing_scene.rb +21 -0
- data/lib/metro/models/draws.rb +71 -0
- data/lib/metro/models/label.rb +2 -0
- data/lib/metro/models/menu.rb +32 -15
- data/lib/metro/models/model.rb +14 -0
- data/lib/metro/{scene_actor.rb → models/model_factory.rb} +1 -1
- data/lib/metro/scene.rb +124 -70
- data/lib/metro/scenes.rb +8 -5
- data/lib/metro/template_message.rb +31 -0
- data/lib/metro/version.rb +30 -1
- data/lib/templates/message.erb +24 -0
- data/metro.gemspec +38 -6
- data/spec/gosu_ext/color_spec.rb +80 -0
- data/spec/spec_helper.rb +18 -0
- metadata +69 -8
data/lib/metro/scenes.rb
CHANGED
@@ -32,14 +32,17 @@ module Metro
|
|
32
32
|
#
|
33
33
|
def find(scene_name)
|
34
34
|
found_scene = scenes_hash[scene_name]
|
35
|
-
|
35
|
+
|
36
|
+
unless found_scene
|
37
|
+
found_scene = create_missing_scene(scene_name)
|
38
|
+
end
|
39
|
+
|
36
40
|
found_scene
|
37
41
|
end
|
38
42
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
"Known scenes: #{scene_name}" ].join("\n")
|
43
|
+
def create_missing_scene(scene_name)
|
44
|
+
MissingScene.missing_scene = scene_name
|
45
|
+
MissingScene
|
43
46
|
end
|
44
47
|
|
45
48
|
#
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class TemplateMessage
|
2
|
+
|
3
|
+
def initialize(details = {})
|
4
|
+
@messages = Array(details[:message]) + Array(details[:messages])
|
5
|
+
@website = details[:website]
|
6
|
+
@email = Array(details[:email])
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :messages
|
10
|
+
|
11
|
+
def website
|
12
|
+
"* #{@website}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def email
|
16
|
+
@email.map {|email| "* #{email}" }.join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def message_filename
|
20
|
+
File.join(File.dirname(__FILE__),"..","templates","message.erb")
|
21
|
+
end
|
22
|
+
|
23
|
+
def message_template
|
24
|
+
File.read(message_filename)
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
ERB.new(message_template).result(binding)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/metro/version.rb
CHANGED
@@ -1,3 +1,32 @@
|
|
1
1
|
module Metro
|
2
|
-
VERSION = "0.0
|
2
|
+
VERSION = "0.1.0"
|
3
|
+
WEBSITE = "https://github.com/burtlo/metro"
|
4
|
+
CONTACT_EMAILS = ["franklin.webber@gmail.com"]
|
5
|
+
|
6
|
+
def self.changes_for_version(version)
|
7
|
+
|
8
|
+
change = Struct::Changes.new(nil,[])
|
9
|
+
|
10
|
+
grab_changes = false
|
11
|
+
|
12
|
+
changelog_filename = "#{File.dirname(__FILE__)}/../../changelog.md"
|
13
|
+
|
14
|
+
File.open(changelog_filename,'r') do |file|
|
15
|
+
while (line = file.gets) do
|
16
|
+
|
17
|
+
if line =~ /^##\s*#{version.gsub('.','\.')}\s*\/\s*(.+)\s*$/
|
18
|
+
grab_changes = true
|
19
|
+
change.date = $1.strip
|
20
|
+
elsif line =~ /^##\s*.+$/
|
21
|
+
grab_changes = false
|
22
|
+
elsif grab_changes
|
23
|
+
change.changes.push line
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
change
|
30
|
+
end
|
31
|
+
|
3
32
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
********************************************************************************
|
2
|
+
```
|
3
|
+
______ ___ _____
|
4
|
+
___ |/ /_____ __ /_______________
|
5
|
+
__ /|_/ / _ _ \_ __/__ ___/_ __ \
|
6
|
+
_ / / / / __// /_ _ / / /_/ /
|
7
|
+
/_/ /_/ \___/ \__/ /_/ \____/
|
8
|
+
|
9
|
+
```
|
10
|
+
-------------------------------------------------------------------------------
|
11
|
+
<% messages.each do |message| %>
|
12
|
+
## <%= message.title %>
|
13
|
+
|
14
|
+
<%= message.message %>
|
15
|
+
|
16
|
+
## Details
|
17
|
+
|
18
|
+
<%= message.details %>
|
19
|
+
<% end %>
|
20
|
+
## Contact
|
21
|
+
|
22
|
+
<%= website %>
|
23
|
+
<%= email %>
|
24
|
+
********************************************************************************
|
data/metro.gemspec
CHANGED
@@ -3,19 +3,51 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'metro/version'
|
5
5
|
|
6
|
+
Struct.new("Changes",:date,:changes)
|
7
|
+
|
6
8
|
Gem::Specification.new do |gem|
|
7
9
|
gem.name = "metro"
|
8
10
|
gem.version = Metro::VERSION
|
9
11
|
gem.authors = ["Franklin Webber"]
|
10
|
-
gem.email =
|
11
|
-
|
12
|
-
gem.summary =
|
13
|
-
|
14
|
-
|
12
|
+
gem.email = Metro::CONTACT_EMAILS
|
13
|
+
|
14
|
+
gem.summary = <<-EOS
|
15
|
+
Metro is a 2D Gaming framework built around gosu (game development library).
|
16
|
+
Metro makes it easy to create games by enforcing common conceptual structures
|
17
|
+
and conventions.
|
18
|
+
EOS
|
19
|
+
gem.description = <<-EOS
|
20
|
+
Metro is a 2D Gaming framework built around gosu (game development library).
|
21
|
+
Metro makes it easy to create games by enforcing common conceptual structures
|
22
|
+
and conventions.
|
23
|
+
EOS
|
24
|
+
|
25
|
+
gem.homepage = Metro::WEBSITE
|
26
|
+
|
15
27
|
gem.add_dependency 'gosu', '~> 0.7'
|
16
|
-
|
28
|
+
gem.add_dependency 'sender', '~> 1.5.10'
|
29
|
+
gem.add_development_dependency 'rspec', '~> 2.11'
|
30
|
+
|
17
31
|
gem.files = `git ls-files`.split($/)
|
18
32
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
33
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
34
|
gem.require_paths = ["lib"]
|
35
|
+
|
36
|
+
changes = Metro.changes_for_version(::Metro::VERSION)
|
37
|
+
|
38
|
+
gem.post_install_message = <<-EOM
|
39
|
+
______ ___ _____
|
40
|
+
___ |/ /_____ __ /_______________
|
41
|
+
__ /|_/ / _ _ \\_ __/__ ___/_ __ \\
|
42
|
+
_ / / / / __// /_ _ / / /_/ /
|
43
|
+
/_/ /_/ \\___/ \\__/ /_/ \\____/
|
44
|
+
|
45
|
+
Thank you for installing metro #{::Metro::VERSION} / #{changes.date}.
|
46
|
+
---------------------------------------------------------------------
|
47
|
+
Changes:
|
48
|
+
#{changes.changes.map{|change| " #{change}"}.join("")}
|
49
|
+
---------------------------------------------------------------------
|
50
|
+
EOM
|
51
|
+
|
52
|
+
|
21
53
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gosu::Color do
|
4
|
+
|
5
|
+
shared_examples "a correctly defined color" do
|
6
|
+
|
7
|
+
let(:expected_red_value) { expected_color_values[0] }
|
8
|
+
let(:expected_green_value) { expected_color_values[1] }
|
9
|
+
let(:expected_blue_value) { expected_color_values[2] }
|
10
|
+
let(:expected_alpha_value) { expected_color_values[3] }
|
11
|
+
|
12
|
+
it "should have the correct red color" do
|
13
|
+
subject.red.should eq expected_red_value
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have the correct green color" do
|
17
|
+
subject.green.should eq expected_green_value
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have the correct blue color" do
|
21
|
+
subject.blue.should eq expected_blue_value
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have the correct alpha value" do
|
25
|
+
subject.alpha.should eq expected_alpha_value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
shared_examples "a color defined as white" do
|
30
|
+
let(:expected_color_values) { [ 255, 255, 255, 255 ] }
|
31
|
+
it_behaves_like "a correctly defined color"
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#initialize" do
|
35
|
+
|
36
|
+
context "when defined with an existing Gosu Color" do
|
37
|
+
subject { described_class.new color }
|
38
|
+
let(:color) { described_class.new 123, 123, 123, 0 }
|
39
|
+
let(:expected_color_values) { [ 123, 123, 0, 123 ] }
|
40
|
+
it_behaves_like "a correctly defined color"
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when defined with a hexadecimal value" do
|
44
|
+
subject { described_class.new hex }
|
45
|
+
let(:hex) { 0xFF777777 }
|
46
|
+
let(:expected_color_values) { [ 119, 119, 119, 255 ] }
|
47
|
+
it_behaves_like "a correctly defined color"
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when defined with a gosu color hex string" do
|
51
|
+
subject { described_class.new hex }
|
52
|
+
let(:hex) { "0xFF777777" }
|
53
|
+
let(:expected_color_values) { [ 119, 119, 119, 255 ] }
|
54
|
+
it_behaves_like "a correctly defined color"
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when defined with a hex string" do
|
58
|
+
subject { described_class.new hex }
|
59
|
+
let(:hex) { "#777777" }
|
60
|
+
let(:expected_color_values) { [ 119, 119, 119, 255 ] }
|
61
|
+
it_behaves_like "a correctly defined color"
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when defined with a rgb string" do
|
65
|
+
subject { described_class.new rgb }
|
66
|
+
let(:rgb) { "rgb(127,127,127)" }
|
67
|
+
let(:expected_color_values) { [ 127, 127, 127, 255 ] }
|
68
|
+
it_behaves_like "a correctly defined color"
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when defined with a rgba color" do
|
72
|
+
subject { described_class.new rgba }
|
73
|
+
let(:rgba) { "rgba(127,127,127,0.5)" }
|
74
|
+
let(:expected_color_values) { [ 127, 127, 127, 127 ] }
|
75
|
+
it_behaves_like "a correctly defined color"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../lib/metro'
|
2
|
+
# # This file was generated by the `rspec --init` command. Conventionally, all
|
3
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
4
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
5
|
+
# loaded once.
|
6
|
+
#
|
7
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
|
+
config.run_all_when_everything_filtered = true
|
11
|
+
config.filter_run :focus
|
12
|
+
|
13
|
+
# Run specs in random order to surface order dependencies. If you find an
|
14
|
+
# order dependency and want to debug it, you can fix the order by providing
|
15
|
+
# the seed, which is printed after each run.
|
16
|
+
# --seed 1234
|
17
|
+
config.order = 'random'
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gosu
|
@@ -27,7 +27,41 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.7'
|
30
|
-
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sender
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.5.10
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.5.10
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.11'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.11'
|
62
|
+
description: ! " Metro is a 2D Gaming framework built around gosu (game development
|
63
|
+
library).\n Metro makes it easy to create games by enforcing common conceptual
|
64
|
+
structures\n and conventions.\n"
|
31
65
|
email:
|
32
66
|
- franklin.webber@gmail.com
|
33
67
|
executables:
|
@@ -36,7 +70,9 @@ extensions: []
|
|
36
70
|
extra_rdoc_files: []
|
37
71
|
files:
|
38
72
|
- .gitignore
|
73
|
+
- .rspec
|
39
74
|
- Gemfile
|
75
|
+
- Guardfile
|
40
76
|
- LICENSE.txt
|
41
77
|
- README.md
|
42
78
|
- Rakefile
|
@@ -44,29 +80,49 @@ files:
|
|
44
80
|
- lib/gosu_ext/color.rb
|
45
81
|
- lib/metro.rb
|
46
82
|
- lib/metro/animation/animation.rb
|
83
|
+
- lib/metro/animation/animation_factory.rb
|
47
84
|
- lib/metro/animation/easing.rb
|
85
|
+
- lib/metro/animation/has_animations.rb
|
48
86
|
- lib/metro/animation/implicit_animation.rb
|
49
|
-
- lib/metro/
|
87
|
+
- lib/metro/error.rb
|
88
|
+
- lib/metro/events/event_factory.rb
|
89
|
+
- lib/metro/events/event_relay.rb
|
90
|
+
- lib/metro/events/has_events.rb
|
91
|
+
- lib/metro/events/unknown_sender.rb
|
50
92
|
- lib/metro/game.rb
|
51
93
|
- lib/metro/game/dsl.rb
|
94
|
+
- lib/metro/missing_scene.rb
|
95
|
+
- lib/metro/models/draws.rb
|
52
96
|
- lib/metro/models/generic.rb
|
53
97
|
- lib/metro/models/image.rb
|
54
98
|
- lib/metro/models/label.rb
|
55
99
|
- lib/metro/models/menu.rb
|
56
100
|
- lib/metro/models/model.rb
|
101
|
+
- lib/metro/models/model_factory.rb
|
57
102
|
- lib/metro/scene.rb
|
58
|
-
- lib/metro/scene_actor.rb
|
59
103
|
- lib/metro/scene_view/json_view.rb
|
60
104
|
- lib/metro/scene_view/no_view.rb
|
61
105
|
- lib/metro/scene_view/scene_view.rb
|
62
106
|
- lib/metro/scene_view/yaml_view.rb
|
63
107
|
- lib/metro/scenes.rb
|
108
|
+
- lib/metro/template_message.rb
|
64
109
|
- lib/metro/version.rb
|
65
110
|
- lib/metro/window.rb
|
111
|
+
- lib/templates/message.erb
|
66
112
|
- metro.gemspec
|
113
|
+
- spec/gosu_ext/color_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
67
115
|
homepage: https://github.com/burtlo/metro
|
68
116
|
licenses: []
|
69
|
-
post_install_message:
|
117
|
+
post_install_message: ! " ______ ___ _____\n ___ |/ /_____ __ /_______________\n
|
118
|
+
\ __ /|_/ / _ _ \\_ __/__ ___/_ __ \\\n _ / / / / __// /_ _ / /
|
119
|
+
/_/ /\n /_/ /_/ \\___/ \\__/ /_/ \\____/\n\n Thank you for installing
|
120
|
+
metro 0.1.0 / 2012-10-25.\n ---------------------------------------------------------------------\n
|
121
|
+
\ Changes:\n \n * Better error handling for missing metro file and missing scene\n
|
122
|
+
\ * FIX: Scenes without Scene suffix will work again\n * Gosu::Color supports creation
|
123
|
+
with various formats: rgb, rgba, and hex\n * Animations can be defined with class
|
124
|
+
level helpers\n * Removed Scene#events as Events can be defined at the class level\n
|
125
|
+
\ * Scenes and Models can generate custom notification events\n ---------------------------------------------------------------------\n"
|
70
126
|
rdoc_options: []
|
71
127
|
require_paths:
|
72
128
|
- lib
|
@@ -87,5 +143,10 @@ rubyforge_project:
|
|
87
143
|
rubygems_version: 1.8.24
|
88
144
|
signing_key:
|
89
145
|
specification_version: 3
|
90
|
-
summary:
|
91
|
-
|
146
|
+
summary: Metro is a 2D Gaming framework built around gosu (game development library).
|
147
|
+
Metro makes it easy to create games by enforcing common conceptual structures and
|
148
|
+
conventions.
|
149
|
+
test_files:
|
150
|
+
- spec/gosu_ext/color_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
has_rdoc:
|