darkholme 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/VERSION +1 -1
- data/darkholme.gemspec +6 -5
- data/lib/darkholme.rb +2 -0
- data/lib/darkholme/component.rb +9 -0
- data/lib/darkholme/entity.rb +27 -0
- data/spec/lib/darkholme/component_spec.rb +5 -0
- data/spec/lib/darkholme/entity_spec.rb +17 -0
- metadata +27 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c0f59d1ded420b19d3e3657a5ae959f9be117b
|
4
|
+
data.tar.gz: a5b2e646ad6e72baac1a8f232afbfbd7bee3c090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 371176ad264d101af62235dc3be3080b04f74615b1ec24a1470e442d47681a954036daffe96bcc80bef11ae98d29ca3e72b58bd5d0a1a8af7f8240f06094dd60
|
7
|
+
data.tar.gz: 7580e14ada9937d6ed39fd833731296df32597fdb6e64e7ac9fb51ab92c427bad4f2e3fd72e7621bf8cca42824cbee9e611555de6fe3b7cdf54c33b0d79ca92e
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/darkholme.gemspec
CHANGED
@@ -2,15 +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.0
|
5
|
+
# stub: darkholme 1.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "darkholme"
|
9
|
-
s.version = "1.0
|
9
|
+
s.version = "1.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
12
13
|
s.authors = ["Massive Danger"]
|
13
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-03-01"
|
14
15
|
s.description = "An entity-component system in Ruby"
|
15
16
|
s.email = "evan@massivedanger.com"
|
16
17
|
s.extra_rdoc_files = [
|
@@ -20,6 +21,7 @@ Gem::Specification.new do |s|
|
|
20
21
|
s.files = [
|
21
22
|
".document",
|
22
23
|
".rspec",
|
24
|
+
".ruby-version",
|
23
25
|
".travis.yml",
|
24
26
|
"Gemfile",
|
25
27
|
"Guardfile",
|
@@ -49,8 +51,7 @@ Gem::Specification.new do |s|
|
|
49
51
|
]
|
50
52
|
s.homepage = "http://github.com/evanwalsh/darkholme"
|
51
53
|
s.licenses = ["MIT"]
|
52
|
-
s.
|
53
|
-
s.rubygems_version = "2.1.11"
|
54
|
+
s.rubygems_version = "2.2.2"
|
54
55
|
s.summary = "An entity-component system in Ruby for"
|
55
56
|
|
56
57
|
if s.respond_to? :specification_version then
|
data/lib/darkholme.rb
CHANGED
data/lib/darkholme/component.rb
CHANGED
@@ -13,6 +13,15 @@ module Darkholme
|
|
13
13
|
@bits[klass] ||= @next_bit += 1
|
14
14
|
end
|
15
15
|
|
16
|
+
# Create a new Component instance from arguments from a data file
|
17
|
+
#
|
18
|
+
# @param data [Hash] The arguments passed from the JSON file
|
19
|
+
#
|
20
|
+
# @return [Component] A new component instance
|
21
|
+
def self.from_json(data = {})
|
22
|
+
new
|
23
|
+
end
|
24
|
+
|
16
25
|
# Get the current instance's class' bit
|
17
26
|
#
|
18
27
|
# @return [Fixnum] The bit for the instance's class
|
data/lib/darkholme/entity.rb
CHANGED
@@ -4,6 +4,26 @@ module Darkholme
|
|
4
4
|
class Entity
|
5
5
|
attr_accessor :engine, :components, :component_bits, :family_bits
|
6
6
|
|
7
|
+
# Create a new Entity from a JSON manifest
|
8
|
+
#
|
9
|
+
# @param source [Object] An object that works with JSON.parse
|
10
|
+
#
|
11
|
+
# @return [Entity] The new Entity
|
12
|
+
def self.load(source)
|
13
|
+
data = JSON.parse(source)
|
14
|
+
components = []
|
15
|
+
data["components"].each do |component_class, args|
|
16
|
+
components << class_from_string(component_class).from_json(args)
|
17
|
+
end
|
18
|
+
|
19
|
+
entity = new
|
20
|
+
components.each do |component|
|
21
|
+
entity.add_component(component)
|
22
|
+
end
|
23
|
+
|
24
|
+
entity
|
25
|
+
end
|
26
|
+
|
7
27
|
# Create a new Entity
|
8
28
|
#
|
9
29
|
# @return [Entity] The new Entity
|
@@ -73,5 +93,12 @@ module Darkholme
|
|
73
93
|
def component_for(component_class)
|
74
94
|
self.components[component_class]
|
75
95
|
end
|
96
|
+
|
97
|
+
def self.class_from_string(class_string)
|
98
|
+
class_string.split("::").inject(Object) do |mod, class_name|
|
99
|
+
mod.const_get class_name
|
100
|
+
end
|
101
|
+
end
|
102
|
+
private_class_method :class_from_string
|
76
103
|
end
|
77
104
|
end
|
@@ -87,5 +87,22 @@ module Darkholme
|
|
87
87
|
expect(subject.component_for(component.class)).to be_a MockComponent
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
it "can be created from a JSON manifest" do
|
92
|
+
entity = Entity.load(entity_json)
|
93
|
+
expect(entity.has_component? MockComponent).to eq(true)
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def entity_json
|
99
|
+
<<-JSON
|
100
|
+
{
|
101
|
+
"components": {
|
102
|
+
"MockComponent": {}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
JSON
|
106
|
+
end
|
90
107
|
end
|
91
108
|
end
|
metadata
CHANGED
@@ -1,139 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darkholme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.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-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.9.12.6
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.9.12.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.0.0.beta1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.0.0.beta1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: yard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.7'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: jeweler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 2.0.1
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.0.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: guard-rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 4.2.6
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 4.2.6
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: inch
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 0.2.3
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.2.3
|
139
139
|
description: An entity-component system in Ruby
|
@@ -144,9 +144,10 @@ extra_rdoc_files:
|
|
144
144
|
- LICENSE.txt
|
145
145
|
- README.md
|
146
146
|
files:
|
147
|
-
- .document
|
148
|
-
- .rspec
|
149
|
-
- .
|
147
|
+
- ".document"
|
148
|
+
- ".rspec"
|
149
|
+
- ".ruby-version"
|
150
|
+
- ".travis.yml"
|
150
151
|
- Gemfile
|
151
152
|
- Guardfile
|
152
153
|
- LICENSE.txt
|
@@ -182,17 +183,17 @@ require_paths:
|
|
182
183
|
- lib
|
183
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
184
185
|
requirements:
|
185
|
-
- -
|
186
|
+
- - ">="
|
186
187
|
- !ruby/object:Gem::Version
|
187
188
|
version: '0'
|
188
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
190
|
requirements:
|
190
|
-
- -
|
191
|
+
- - ">="
|
191
192
|
- !ruby/object:Gem::Version
|
192
193
|
version: '0'
|
193
194
|
requirements: []
|
194
195
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.2.2
|
196
197
|
signing_key:
|
197
198
|
specification_version: 4
|
198
199
|
summary: An entity-component system in Ruby for
|