darkholme 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/VERSION +1 -1
- data/darkholme.gemspec +6 -3
- data/lib/darkholme.rb +1 -1
- data/lib/darkholme/component.rb +1 -1
- data/lib/darkholme/engine.rb +10 -0
- data/lib/darkholme/entity.rb +4 -4
- data/spec/lib/darkholme/component_spec.rb +2 -2
- data/spec/lib/darkholme/engine_spec.rb +18 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7f5734cf9be7bcbb2db728178e3d95b0a21fe50
|
4
|
+
data.tar.gz: eb4aeb5870c13a2052432b085d303424b9df3f00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a997b59776b89125032d1b5b783ee307034808e82c7f140e75e5158be249deda0299c08f96cb4cd8719d152d11f3a72da658006de1bbfd23f105fdb3b231b2
|
7
|
+
data.tar.gz: 47b7c73f984e928f72c8316df35f1e4c3ab233619ffc26ac1c923fbe87f1b14f3fa900f51942cf8bb27a68e49f0e1df8a95ee5382c98b640cbf7a68a2239ba5e
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/darkholme.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: darkholme 1.
|
5
|
+
# stub: darkholme 1.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "darkholme"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Massive Danger"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-04-06"
|
15
15
|
s.description = "An entity-component system in Ruby"
|
16
16
|
s.email = "evan@massivedanger.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -58,6 +58,7 @@ Gem::Specification.new do |s|
|
|
58
58
|
s.specification_version = 4
|
59
59
|
|
60
60
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
61
|
+
s.add_runtime_dependency(%q<multi_json>, ["~> 1.8.4"])
|
61
62
|
s.add_development_dependency(%q<pry>, ["~> 0.9.12.6"])
|
62
63
|
s.add_development_dependency(%q<rspec>, ["~> 3.0.0.beta1"])
|
63
64
|
s.add_development_dependency(%q<yard>, ["~> 0.7"])
|
@@ -68,6 +69,7 @@ Gem::Specification.new do |s|
|
|
68
69
|
s.add_development_dependency(%q<guard-rspec>, ["~> 4.2.6"])
|
69
70
|
s.add_development_dependency(%q<inch>, ["~> 0.2.3"])
|
70
71
|
else
|
72
|
+
s.add_dependency(%q<multi_json>, ["~> 1.8.4"])
|
71
73
|
s.add_dependency(%q<pry>, ["~> 0.9.12.6"])
|
72
74
|
s.add_dependency(%q<rspec>, ["~> 3.0.0.beta1"])
|
73
75
|
s.add_dependency(%q<yard>, ["~> 0.7"])
|
@@ -79,6 +81,7 @@ Gem::Specification.new do |s|
|
|
79
81
|
s.add_dependency(%q<inch>, ["~> 0.2.3"])
|
80
82
|
end
|
81
83
|
else
|
84
|
+
s.add_dependency(%q<multi_json>, ["~> 1.8.4"])
|
82
85
|
s.add_dependency(%q<pry>, ["~> 0.9.12.6"])
|
83
86
|
s.add_dependency(%q<rspec>, ["~> 3.0.0.beta1"])
|
84
87
|
s.add_dependency(%q<yard>, ["~> 0.7"])
|
data/lib/darkholme.rb
CHANGED
data/lib/darkholme/component.rb
CHANGED
data/lib/darkholme/engine.rb
CHANGED
@@ -26,6 +26,16 @@ module Darkholme
|
|
26
26
|
entity.added_to_engine self
|
27
27
|
end
|
28
28
|
|
29
|
+
# Add an entity from a manifest file
|
30
|
+
#
|
31
|
+
# @param manifest [Object] An Object that is acceptable to JSON.parse
|
32
|
+
#
|
33
|
+
# @return Result of #add_entity
|
34
|
+
def add_entity_from_manifest(manifest)
|
35
|
+
entity = Entity.load(manifest)
|
36
|
+
add_entity(entity)
|
37
|
+
end
|
38
|
+
|
29
39
|
# Remove an entity from the engine (with callbacks). Once removed,
|
30
40
|
# the entity will no longer be updated during the update loop
|
31
41
|
#
|
data/lib/darkholme/entity.rb
CHANGED
@@ -6,14 +6,14 @@ module Darkholme
|
|
6
6
|
|
7
7
|
# Create a new Entity from a JSON manifest
|
8
8
|
#
|
9
|
-
# @param source [Object] An object that works with
|
9
|
+
# @param source [Object] An object that works with MultiJson.load
|
10
10
|
#
|
11
11
|
# @return [Entity] The new Entity
|
12
12
|
def self.load(source)
|
13
|
-
data =
|
13
|
+
data = MultiJson.load(source)
|
14
14
|
components = []
|
15
|
-
data["components"].each do |component_class,
|
16
|
-
components << class_from_string(component_class).
|
15
|
+
data["components"].each do |component_class, data|
|
16
|
+
components << class_from_string(component_class).from_manifest(data)
|
17
17
|
end
|
18
18
|
|
19
19
|
entity = new
|
@@ -17,8 +17,8 @@ module Darkholme
|
|
17
17
|
expect(subject.bit).to eq(:bit)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "can be made
|
21
|
-
component = MockComponent.
|
20
|
+
it "can be made from a manifest" do
|
21
|
+
component = MockComponent.from_manifest {}
|
22
22
|
expect(component).to be_a MockComponent
|
23
23
|
end
|
24
24
|
end
|
@@ -13,6 +13,12 @@ module Darkholme
|
|
13
13
|
}.to change { subject.entities.count }.from(0).to(1)
|
14
14
|
end
|
15
15
|
|
16
|
+
it "can add them from a manifest" do
|
17
|
+
expect {
|
18
|
+
subject.add_entity_from_manifest(entity_json)
|
19
|
+
}.to change { subject.entities.count }.from(0).to(1)
|
20
|
+
end
|
21
|
+
|
16
22
|
it "can remove them" do
|
17
23
|
subject.add_entity(entity)
|
18
24
|
|
@@ -75,6 +81,18 @@ module Darkholme
|
|
75
81
|
expect(subject.families[family]).not_to include(entity)
|
76
82
|
end
|
77
83
|
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def entity_json
|
88
|
+
<<-JSON
|
89
|
+
{
|
90
|
+
"components": {
|
91
|
+
"MockComponent": {}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
JSON
|
95
|
+
end
|
78
96
|
end
|
79
97
|
end
|
80
98
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darkholme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Massive Danger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.4
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: pry
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|