entityjs 0.2.2 → 0.3.0
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.
- data/.gitignore +7 -6
- data/.rspec +2 -0
- data/README.md +170 -49
- data/Rakefile +9 -0
- data/bin/entityjs +24 -14
- data/entityjs.gemspec +15 -9
- data/lib/entityjs/assets.rb +167 -0
- data/lib/entityjs/command.rb +52 -27
- data/lib/entityjs/commands/build.rb +128 -0
- data/lib/entityjs/commands/comp.rb +74 -0
- data/lib/entityjs/commands/font.rb +73 -0
- data/lib/entityjs/commands/new.rb +59 -0
- data/lib/entityjs/commands/server.rb +54 -0
- data/lib/entityjs/commands/templates.rb +28 -0
- data/lib/entityjs/commands/test.rb +69 -0
- data/lib/entityjs/config.rb +130 -0
- data/lib/entityjs/dirc.rb +184 -0
- data/lib/entityjs/parsers/parse_tmx.rb +41 -0
- data/lib/entityjs/parsers/parse_xml.rb +39 -0
- data/lib/entityjs/version.rb +1 -1
- data/lib/entityjs.rb +53 -0
- data/license.txt +1 -1
- data/public/play.html +122 -0
- data/public/qunit/qunit.css +226 -0
- data/public/qunit/qunit.entity.js +190 -0
- data/public/qunit/qunit.input.js +200 -0
- data/public/qunit/qunit.js +1598 -0
- data/public/qunit/qunit.mock.js +97 -0
- data/public/tests.html +45 -0
- data/spec/javascripts/helpers/accept.png +0 -0
- data/spec/javascripts/helpers/alligator.mp3 +0 -0
- data/spec/javascripts/helpers/alligator.ogg +0 -0
- data/spec/javascripts/helpers/canvas.js +15 -0
- data/spec/javascripts/helpers/entityunit.js +50 -0
- data/spec/javascripts/helpers/factories.js +11 -0
- data/spec/javascripts/helpers/jquery-1.7.1.min.js +4 -0
- data/spec/javascripts/src/core/comp_spec.js +145 -0
- data/spec/javascripts/src/core/entity_spec.js +324 -0
- data/spec/javascripts/src/core/load_spec.js +71 -0
- data/spec/javascripts/src/core/query_spec.js +157 -0
- data/spec/javascripts/src/core/re_spec.js +61 -0
- data/spec/javascripts/src/core/system_spec.js +41 -0
- data/spec/javascripts/src/cycle/draw_spec.js +106 -0
- data/spec/javascripts/src/cycle/tick_spec.js +20 -0
- data/spec/javascripts/src/cycle/update_spec.js +86 -0
- data/spec/javascripts/src/display/align_spec.js +43 -0
- data/spec/javascripts/src/display/circle_spec.js +26 -0
- data/spec/javascripts/src/display/group_spec.js +7 -0
- data/spec/javascripts/src/display/image_spec.js +32 -0
- data/spec/javascripts/src/display/imgtext_spec.js +32 -0
- data/spec/javascripts/src/display/rect_spec.js +13 -0
- data/spec/javascripts/src/display/screen_spec.js +47 -0
- data/spec/javascripts/src/display/sprite_spec.js +28 -0
- data/spec/javascripts/src/display/text_spec.js +30 -0
- data/spec/javascripts/src/input/keyboard_spec.js +67 -0
- data/spec/javascripts/src/input/mouse_spec.js +133 -0
- data/spec/javascripts/src/input/pressed_spec.js +31 -0
- data/spec/javascripts/src/math/bisect_spec.js +59 -0
- data/spec/javascripts/src/math/body_spec.js +30 -0
- data/spec/javascripts/src/math/drag_spec.js +38 -0
- data/spec/javascripts/src/math/force_spec.js +134 -0
- data/spec/javascripts/src/math/hit_spec.js +28 -0
- data/spec/javascripts/src/math/hitmap_spec.js +52 -0
- data/spec/javascripts/src/math/limit_spec.js +35 -0
- data/spec/javascripts/src/math/point_spec.js +57 -0
- data/spec/javascripts/src/math/tile_spec.js +78 -0
- data/spec/javascripts/src/media/sound_spec.js +40 -0
- data/spec/javascripts/src/pattern/automap_spec.js +93 -0
- data/spec/javascripts/src/pattern/flicker_spec.js +66 -0
- data/spec/javascripts/src/pattern/timestep_spec.js +23 -0
- data/spec/javascripts/src/save/storage_spec.js +37 -0
- data/spec/javascripts/src/util/log_spec.js +9 -0
- data/spec/javascripts/src/util/polyfill_spec.js +13 -0
- data/spec/javascripts/src/util/random_spec.js +33 -0
- data/spec/javascripts/src/util/scene_spec.js +52 -0
- data/spec/javascripts/src/util/sheet_spec.js +25 -0
- data/spec/javascripts/src/util/support_spec.js +17 -0
- data/spec/javascripts/support/jasmine.yml +76 -0
- data/spec/javascripts/support/jasmine_config.rb +32 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/lib/entityjs/assets_spec.rb +216 -0
- data/spec/lib/entityjs/command_spec.rb +53 -0
- data/spec/lib/entityjs/commands/build_spec.rb +69 -0
- data/spec/lib/entityjs/commands/comp_spec.rb +45 -0
- data/spec/lib/entityjs/commands/font_spec.rb +7 -0
- data/spec/lib/entityjs/commands/new_spec.rb +20 -0
- data/spec/lib/entityjs/commands/templates_spec.rb +9 -0
- data/spec/lib/entityjs/commands/test_spec.rb +31 -0
- data/spec/lib/entityjs/config_spec.rb +19 -0
- data/spec/lib/entityjs/dirc_spec.rb +83 -0
- data/spec/lib/entityjs/version_spec.rb +9 -0
- data/spec/spec_helper.rb +21 -3
- data/spec/support/factories.rb +19 -0
- data/spec/support/mygame.rb +11 -0
- data/src/core/comp.js +318 -0
- data/src/core/entity.js +549 -0
- data/src/core/load.js +242 -0
- data/src/core/query.js +354 -0
- data/src/core/re.js +74 -0
- data/src/core/system.js +121 -0
- data/src/cycle/draw.js +178 -0
- data/src/cycle/tick.js +25 -0
- data/src/{entityjs/cycle → cycle}/tween.js +60 -60
- data/src/{entityjs/cycle → cycle}/update.js +86 -85
- data/src/{entityjs/cycle → cycle}/wait.js +22 -21
- data/src/{entityjs/cycle → cycle}/worker.js +8 -8
- data/src/display/align.js +45 -0
- data/src/display/circle.js +33 -0
- data/src/{entityjs/display → display}/group.js +62 -62
- data/src/display/image.js +35 -0
- data/src/display/imgtext.js +102 -0
- data/src/{entityjs/display → display}/rect.js +18 -18
- data/src/display/screen.js +57 -0
- data/src/display/sprite.js +54 -0
- data/src/display/text.js +44 -0
- data/src/{entityjs/input → input}/keyboard.js +152 -150
- data/src/input/mouse.js +111 -0
- data/src/input/pressed.js +41 -0
- data/src/{entityjs/input → input}/touch.js +24 -28
- data/src/math/bisect.js +84 -0
- data/src/math/body.js +70 -0
- data/src/{entityjs/math → math}/drag.js +44 -38
- data/src/math/force.js +143 -0
- data/src/math/hit.js +32 -0
- data/src/math/hitmap.js +167 -0
- data/src/math/limit.js +37 -0
- data/src/math/point.js +40 -0
- data/src/math/tile.js +109 -0
- data/src/media/channel.js +93 -0
- data/src/{entityjs/media → media}/playlist.js +4 -4
- data/src/media/sound.js +114 -0
- data/src/{entityjs/net → net}/socket.js +51 -51
- data/src/pattern/automap.js +133 -0
- data/src/{entityjs/pattern → pattern}/flicker.js +206 -213
- data/src/pattern/timestep.js +31 -0
- data/src/{entityjs/save → save}/database.js +6 -6
- data/src/{entityjs/save → save}/storage.js +47 -56
- data/src/{entityjs/util → util}/log.js +17 -25
- data/src/{entityjs/util → util}/polyfill.js +24 -24
- data/src/util/random.js +20 -0
- data/src/util/scene.js +102 -0
- data/src/util/sheet.js +35 -0
- data/src/{entityjs/util → util}/support.js +109 -132
- data/{examples/keys → templates/arrow_keys/assets/images}/arrow.png +0 -0
- data/templates/arrow_keys/config.yml +22 -0
- data/templates/arrow_keys/readme.txt +9 -0
- data/templates/arrow_keys/scripts/display/arrow.js +69 -0
- data/templates/arrow_keys/scripts/init.js +10 -0
- data/templates/arrow_keys/scripts/input/controls.js +35 -0
- data/templates/arrow_keys/scripts/scenes/home.js +20 -0
- data/templates/arrow_keys/scripts/scenes/load.js +57 -0
- data/templates/arrow_keys/tests/display/arrow_test.js +29 -0
- data/templates/arrow_keys/tests/init_test.js +4 -0
- data/templates/arrow_keys/tests/input/controls_test.js +32 -0
- data/templates/arrow_keys/tests/scenes/home_test.js +0 -0
- data/templates/arrow_keys/tests/scenes/load_test.js +16 -0
- data/templates/blank/config.yml +22 -0
- data/templates/blank/readme.txt +79 -0
- data/templates/platform/assets/images/bit.png +0 -0
- data/templates/platform/assets/images/hero.png +0 -0
- data/templates/platform/assets/images/items.png +0 -0
- data/templates/platform/assets/images/tiles.png +0 -0
- data/templates/platform/assets/levels/level1.tmx +44 -0
- data/templates/platform/assets/sounds/coin.mp3 +0 -0
- data/templates/platform/assets/sounds/coin.ogg +0 -0
- data/templates/platform/config.yml +22 -0
- data/templates/platform/readme.txt +87 -0
- data/templates/platform/scripts/display/bit.js +12 -0
- data/templates/platform/scripts/display/hero.js +77 -0
- data/templates/platform/scripts/display/tile.js +2 -0
- data/templates/platform/scripts/display/tsprite.js +17 -0
- data/templates/platform/scripts/init.js +7 -0
- data/templates/platform/scripts/items/coin.js +27 -0
- data/templates/platform/scripts/items/item.js +41 -0
- data/templates/platform/scripts/items/spring.js +25 -0
- data/templates/platform/scripts/scenes/home.js +10 -0
- data/templates/platform/scripts/scenes/load.js +27 -0
- data/templates/platform/scripts/scenes/play.js +31 -0
- data/templates/platform/scripts/util/counter.js +34 -0
- data/templates/platform/scripts/util/level.js +84 -0
- data/templates/platform/tests/display/bit_test.js +7 -0
- data/templates/platform/tests/display/hero_test.js +73 -0
- data/templates/platform/tests/display/tile_test.js +7 -0
- data/templates/platform/tests/display/tsprite_test.js +8 -0
- data/templates/platform/tests/factories.js +30 -0
- data/templates/platform/tests/items/coin_test.js +28 -0
- data/templates/platform/tests/items/item_test.js +36 -0
- data/templates/platform/tests/items/spring_test.js +21 -0
- data/templates/platform/tests/scenes/home_test.js +9 -0
- data/templates/platform/tests/scenes/load_test.js +11 -0
- data/templates/platform/tests/scenes/play_test.js +15 -0
- data/templates/platform/tests/util/counter_test.js +9 -0
- data/templates/platform/tests/util/level_test.js +29 -0
- metadata +249 -97
- data/build/build_debug.bat +0 -1
- data/build/build_min.bat +0 -1
- data/build/config.php +0 -64
- data/build/debug.php +0 -48
- data/build/files.php +0 -74
- data/build/jsmin.php +0 -376
- data/build/min.php +0 -50
- data/changelog.txt +0 -53
- data/examples/keys/keys.html +0 -59
- data/examples/keys/keys.js +0 -148
- data/examples/mouse/mouse.html +0 -58
- data/examples/mouse/mouse.js +0 -60
- data/examples/scenes/home.png +0 -0
- data/examples/scenes/scenes.html +0 -55
- data/examples/scenes/scenes.js +0 -134
- data/examples/scenes/win.png +0 -0
- data/examples/sounds/sound1.mp3 +0 -0
- data/examples/sounds/sound1.ogg +0 -0
- data/examples/sounds/sounds.html +0 -56
- data/examples/sounds/sounds.js +0 -44
- data/examples/style/background.png +0 -0
- data/examples/style/sheet.css +0 -762
- data/examples/tiles/tiles.html +0 -56
- data/examples/tiles/tiles.js +0 -85
- data/examples/tiles/tiles.png +0 -0
- data/lib/blank/config.js +0 -4
- data/lib/blank/config.yml +0 -21
- data/lib/blank/home.js +0 -11
- data/lib/blank/init.js +0 -7
- data/lib/blank/load.js +0 -21
- data/lib/blank/play.html +0 -29
- data/lib/entity.debug.js +0 -52
- data/lib/entity.min.js +0 -184
- data/lib/entityjs/comp.rb +0 -11
- data/lib/entityjs/game.rb +0 -93
- data/lib/entityjs/min.rb +0 -11
- data/lib/entityjs/refresh.rb +0 -14
- data/spec/lib/entityjs/game_spec.rb +0 -11
- data/src/entityjs/core/component.js +0 -306
- data/src/entityjs/core/entity.js +0 -516
- data/src/entityjs/core/load.js +0 -224
- data/src/entityjs/core/query.js +0 -410
- data/src/entityjs/core/re.js +0 -70
- data/src/entityjs/core/system.js +0 -125
- data/src/entityjs/cycle/draw.js +0 -185
- data/src/entityjs/cycle/ticker.js +0 -27
- data/src/entityjs/display/anchor.js +0 -53
- data/src/entityjs/display/bitfont.js +0 -93
- data/src/entityjs/display/bitmap.js +0 -37
- data/src/entityjs/display/circle.js +0 -30
- data/src/entityjs/display/font.js +0 -41
- data/src/entityjs/display/screen.js +0 -46
- data/src/entityjs/display/sprite.js +0 -37
- data/src/entityjs/input/mouse.js +0 -123
- data/src/entityjs/input/pressed.js +0 -81
- data/src/entityjs/math/bind.js +0 -76
- data/src/entityjs/math/bisect.js +0 -69
- data/src/entityjs/math/body.js +0 -39
- data/src/entityjs/math/hitmap.js +0 -165
- data/src/entityjs/math/hittest.js +0 -26
- data/src/entityjs/math/physics.js +0 -142
- data/src/entityjs/math/point.js +0 -57
- data/src/entityjs/math/tile.js +0 -91
- data/src/entityjs/media/channel.js +0 -93
- data/src/entityjs/media/sound.js +0 -110
- data/src/entityjs/pattern/arraymap.js +0 -89
- data/src/entityjs/pattern/timestep.js +0 -34
- data/src/entityjs/util/random.js +0 -38
- data/src/entityjs/util/scene.js +0 -101
- data/src/entityjs/util/sheet.js +0 -51
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
#The Dirc class manages all files and folders in the entityjs src and games.
|
|
4
|
+
module Entityjs
|
|
5
|
+
|
|
6
|
+
class Dirc
|
|
7
|
+
|
|
8
|
+
def self.game?
|
|
9
|
+
|
|
10
|
+
#check if config.yml exists
|
|
11
|
+
if File.file? Config.file_name
|
|
12
|
+
|
|
13
|
+
if @game_root.nil?
|
|
14
|
+
@game_root = Dir.pwd
|
|
15
|
+
end
|
|
16
|
+
return true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
return false
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.to_game_root
|
|
23
|
+
Dir.chdir(@game_root)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.game_root
|
|
27
|
+
|
|
28
|
+
@game_root
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.find_tests_url(ignore=nil)
|
|
32
|
+
ignore ||= []
|
|
33
|
+
tests = Dir["#{Dirc.game_root}/#{Config.tests_folder}/**/*.js"]
|
|
34
|
+
|
|
35
|
+
tests = tests.collect do |i|
|
|
36
|
+
i[i.rindex('tests/')..-1]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if ignore.any?
|
|
40
|
+
tests.delete_if {|i| !i.match(/#{ignore.join('|')}/).nil? }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
return tests
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.find_scripts_url(ignore=nil, order=nil)
|
|
47
|
+
ignore ||= []
|
|
48
|
+
order ||= []
|
|
49
|
+
|
|
50
|
+
scripts = self.find_scripts(ignore, order)
|
|
51
|
+
|
|
52
|
+
#change filenames
|
|
53
|
+
scripts = scripts.collect{|k| k[k.rindex('scripts/')..-1] }
|
|
54
|
+
|
|
55
|
+
#ignore files
|
|
56
|
+
if ignore.any?
|
|
57
|
+
scripts = scripts.delete_if {|i| !i.match(/#{ignore.join('|')}/).nil? }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
#order files
|
|
61
|
+
order.reverse.each do |i|
|
|
62
|
+
|
|
63
|
+
scripts.each do |s|
|
|
64
|
+
|
|
65
|
+
if s.match /#{i}/
|
|
66
|
+
scripts.delete(s)
|
|
67
|
+
scripts.unshift(s)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
return scripts
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.find_entity_src_url(ignore=nil)
|
|
78
|
+
ignore ||= []
|
|
79
|
+
srcs = self.find_entity_src(ignore)
|
|
80
|
+
|
|
81
|
+
#remove src directory and replace with entityjs
|
|
82
|
+
srcs = srcs.collect{|k| k[k.rindex('src/')..-1].gsub('src', 'entityjs') }
|
|
83
|
+
|
|
84
|
+
if ignore.any?
|
|
85
|
+
srcs.delete_if {|i| !i.match(/#{ignore.join('|')}/).nil? }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
return srcs
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def self.find_scripts(ignore=nil, order=nil)
|
|
92
|
+
|
|
93
|
+
return Dir["#{Dirc.game_root}/#{Config.scripts_folder}/**/*.js"].sort
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def self.find_entity_src(ignore=nil)
|
|
98
|
+
|
|
99
|
+
ents = Dir[Entityjs::root+"/src/**/*.js"]
|
|
100
|
+
|
|
101
|
+
#sort by name
|
|
102
|
+
ents.sort!
|
|
103
|
+
|
|
104
|
+
#push re.js to the top
|
|
105
|
+
|
|
106
|
+
i = ents.index{|i| i.match(/re\.js$/) }
|
|
107
|
+
|
|
108
|
+
if i.nil?
|
|
109
|
+
puts 'Error cannot find re.js!'
|
|
110
|
+
return ents
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
k = ents.delete_at(i)
|
|
114
|
+
|
|
115
|
+
ents.unshift(k)
|
|
116
|
+
|
|
117
|
+
return ents
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def self.change_dir(name)
|
|
121
|
+
Dir.chdir(Dir.pwd+'/'+name)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def self.get_root(path)
|
|
125
|
+
cut = Dir.pwd.split(root)
|
|
126
|
+
|
|
127
|
+
if cut.length == 2
|
|
128
|
+
path = cut.pop+path
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
return path
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def self.create_dir(name, move=false)
|
|
135
|
+
|
|
136
|
+
if !Dir.exists? name
|
|
137
|
+
Dir.mkdir(name)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if move
|
|
141
|
+
self.change_dir(name)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.create_file(name, contents)
|
|
146
|
+
File.open(name, "w+") {|f| f.write(contents)}
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def self.copy_file(name, new_name=nil)
|
|
150
|
+
|
|
151
|
+
if new_name.nil?
|
|
152
|
+
new_name = name
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
template = self.get_root_path+'/lib/blank/'+name
|
|
156
|
+
::FileUtils.cp template, new_name
|
|
157
|
+
|
|
158
|
+
path = "/#{name}"
|
|
159
|
+
|
|
160
|
+
path = self.get_root(path)
|
|
161
|
+
|
|
162
|
+
puts "Created: #{path}"
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def self.copy_config(name)
|
|
166
|
+
self.copy_file('config.yml')
|
|
167
|
+
|
|
168
|
+
f = File.open('config.yml', 'r')
|
|
169
|
+
|
|
170
|
+
contents = f.read
|
|
171
|
+
|
|
172
|
+
contents = contents.sub(/\$NAME/, name)
|
|
173
|
+
|
|
174
|
+
File.open('config.yml', "w+") do |f|
|
|
175
|
+
|
|
176
|
+
f.write(contents)
|
|
177
|
+
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Entityjs
|
|
2
|
+
|
|
3
|
+
class ParseTMX
|
|
4
|
+
|
|
5
|
+
def self.parse(data)
|
|
6
|
+
|
|
7
|
+
contents = ParseXML.parse_to_hash(data)
|
|
8
|
+
|
|
9
|
+
#convert csv map into json array
|
|
10
|
+
if contents['layer'].is_a? Array
|
|
11
|
+
contents['layer'].each do |k|
|
|
12
|
+
self.parse_layer(k)
|
|
13
|
+
end
|
|
14
|
+
else
|
|
15
|
+
self.parse_layer(contents['layer'])
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
#transform into string
|
|
19
|
+
out = ParseXML.parse(contents)
|
|
20
|
+
|
|
21
|
+
#transform string-numbers into numbers
|
|
22
|
+
|
|
23
|
+
out = out.gsub(/"[0-9\.]*"/){|s| s[1..-2] }
|
|
24
|
+
|
|
25
|
+
return out
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.parse_layer(k)
|
|
29
|
+
|
|
30
|
+
map = k['data']
|
|
31
|
+
#remove encoding
|
|
32
|
+
map.delete '@encoding'
|
|
33
|
+
#convert csv to array
|
|
34
|
+
tiles = map['$'].split(",\n")
|
|
35
|
+
k['data']['$'] = tiles.collect{|i| i.split(',').collect{|j| j.to_i }}
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Entityjs
|
|
2
|
+
|
|
3
|
+
class ParseXML
|
|
4
|
+
|
|
5
|
+
def self.parse_to_hash(contents)
|
|
6
|
+
#might need different transfomration
|
|
7
|
+
#remove header
|
|
8
|
+
|
|
9
|
+
contents = contents.gsub(/<\?xml.*\?>/, '')
|
|
10
|
+
#convert to hash
|
|
11
|
+
contents = CobraVsMongoose.xml_to_hash(contents)
|
|
12
|
+
|
|
13
|
+
#remove root
|
|
14
|
+
contents.each do |i,v|
|
|
15
|
+
if !v.nil?
|
|
16
|
+
contents = v
|
|
17
|
+
break
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
return contents
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.parse(contents)
|
|
26
|
+
if contents.is_a? String
|
|
27
|
+
contents = self.parse_to_hash(contents)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#to string
|
|
31
|
+
contents = contents.to_json
|
|
32
|
+
|
|
33
|
+
#remove @
|
|
34
|
+
return contents.gsub('"@','"')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
data/lib/entityjs/version.rb
CHANGED
data/lib/entityjs.rb
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require "cobravsmongoose"
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts "Could not load 'cobravsmongoose'"
|
|
5
|
+
puts "run 'gem install cobravsmongoose'"
|
|
6
|
+
exit
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
begin
|
|
10
|
+
require "json"
|
|
11
|
+
rescue LoadError
|
|
12
|
+
puts "Could not load 'json'"
|
|
13
|
+
puts "run 'gem install json'"
|
|
14
|
+
exit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
require "uglifier"
|
|
19
|
+
rescue LoadError
|
|
20
|
+
puts "Could not load 'uglifier'"
|
|
21
|
+
puts "run 'gem install uglifier'"
|
|
22
|
+
exit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
begin
|
|
26
|
+
require "sinatra/base"
|
|
27
|
+
rescue LoadError
|
|
28
|
+
puts "Could not load 'sinatra'"
|
|
29
|
+
puts "run 'gem install sinatra'"
|
|
30
|
+
exit
|
|
31
|
+
end
|
|
32
|
+
|
|
1
33
|
require "entityjs/version"
|
|
2
34
|
|
|
3
35
|
module Entityjs
|
|
4
36
|
|
|
37
|
+
def self.root
|
|
38
|
+
@root = File.expand_path('../..',__FILE__)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.default_template
|
|
42
|
+
'blank'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.template_path(name=nil)
|
|
46
|
+
if name.nil? || name.empty?
|
|
47
|
+
name = self.default_template
|
|
48
|
+
end
|
|
49
|
+
path = "#{Entityjs::root}/templates/#{name}"
|
|
50
|
+
if Dir.exists? path
|
|
51
|
+
return Dir.glob(path+'/*')
|
|
52
|
+
else
|
|
53
|
+
return nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
5
56
|
|
|
6
57
|
end
|
|
58
|
+
|
|
59
|
+
require 'entityjs/command'
|
data/license.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/* EntityJS v$VERSION
|
|
1
|
+
/* EntityJS v$VERSION entityjs.com | License entityjs.com/license */
|
data/public/play.html
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
|
6
|
+
|
|
7
|
+
<title>EntityJS Play Game</title>
|
|
8
|
+
|
|
9
|
+
$JS
|
|
10
|
+
|
|
11
|
+
<style type="text/css">
|
|
12
|
+
/*
|
|
13
|
+
Styling for play.html
|
|
14
|
+
*/
|
|
15
|
+
canvas {
|
|
16
|
+
margin-left: auto;
|
|
17
|
+
margin-right: auto;
|
|
18
|
+
display: block;
|
|
19
|
+
border:1px #333 solid;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
body {
|
|
23
|
+
background-color:#F2F2F2;
|
|
24
|
+
font-family: sans-serif;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#content {
|
|
28
|
+
margin:15px 0 15px 0;
|
|
29
|
+
padding:20px 10px 30px 10px;
|
|
30
|
+
min-height:350px;
|
|
31
|
+
border-radius:2px;
|
|
32
|
+
color:#333333;
|
|
33
|
+
background-color:#ffffff;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
h1, h2, h3 {
|
|
37
|
+
font-weight:700;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
h1 {
|
|
41
|
+
font-size:30px;
|
|
42
|
+
margin:10px 0 20px 5px;
|
|
43
|
+
color:#D94E4E;
|
|
44
|
+
}
|
|
45
|
+
a, a:visited {
|
|
46
|
+
color:#5b9463;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
a:hover {
|
|
50
|
+
color:#77b981;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
a.highlight, a.highlight:visited {
|
|
54
|
+
color:#D94E4E;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
a.highlight:hover {
|
|
58
|
+
color:#ec7979;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.block {
|
|
62
|
+
margin-top:25px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
ul li{
|
|
66
|
+
margin:5px;
|
|
67
|
+
display:inline-block;
|
|
68
|
+
}
|
|
69
|
+
.links {
|
|
70
|
+
float:right;
|
|
71
|
+
}
|
|
72
|
+
.game-links {
|
|
73
|
+
float:left;
|
|
74
|
+
}
|
|
75
|
+
.clear {
|
|
76
|
+
|
|
77
|
+
clear: both;
|
|
78
|
+
display: block;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
visibility: hidden;
|
|
81
|
+
width: 0;
|
|
82
|
+
height: 0;
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
85
|
+
</head>
|
|
86
|
+
|
|
87
|
+
<body>
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
<div id="content">
|
|
91
|
+
<h1>Play</h1>
|
|
92
|
+
|
|
93
|
+
<div class="canvas-container">
|
|
94
|
+
<canvas id="$CANVAS_ID" width="$WIDTH" height="$HEIGHT">
|
|
95
|
+
<p>
|
|
96
|
+
Requires a modern browser to play. Try downloading <a href="http://google.com/chrome">Chrome</a>.
|
|
97
|
+
</p>
|
|
98
|
+
</canvas>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div class="block">
|
|
102
|
+
<ul class="game-links">
|
|
103
|
+
<li><a href="/tests">Test Suite</a></li>
|
|
104
|
+
</ul>
|
|
105
|
+
|
|
106
|
+
<ul class="links">
|
|
107
|
+
<li><a href="http://entityjs.com" class="highlight" target="_blank">EntityJS</a></li>
|
|
108
|
+
<li><a href="http://entityjs.com/tutorials" target="_blank">Tutorials</a></li>
|
|
109
|
+
<li><a href="http://entityjs.com/api" target="_blank">API</a></li>
|
|
110
|
+
<li><a href="https://github.com/bendangelo/entityjs" target="_blank">Git Repo</a></li>
|
|
111
|
+
<li><a href="http://entityjs.com/license" target="_blank">License</a></li>
|
|
112
|
+
</ul>
|
|
113
|
+
<div class="clear"></div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
</body>
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
</html>
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QUnit v1.3.0pre - A JavaScript Unit Testing Framework
|
|
3
|
+
*
|
|
4
|
+
* http://docs.jquery.com/QUnit
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2011 John Resig, Jörn Zaefferer
|
|
7
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
|
8
|
+
* or GPL (GPL-LICENSE.txt) licenses.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Font Family and Sizes */
|
|
12
|
+
|
|
13
|
+
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
|
14
|
+
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
|
18
|
+
#qunit-tests { font-size: smaller; }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/** Resets */
|
|
22
|
+
|
|
23
|
+
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/** Header */
|
|
30
|
+
|
|
31
|
+
#qunit-header {
|
|
32
|
+
padding: 0.5em 0 0.5em 1em;
|
|
33
|
+
|
|
34
|
+
color: #8699a4;
|
|
35
|
+
background-color: #0d3349;
|
|
36
|
+
|
|
37
|
+
font-size: 1.5em;
|
|
38
|
+
line-height: 1em;
|
|
39
|
+
font-weight: normal;
|
|
40
|
+
|
|
41
|
+
border-radius: 15px 15px 0 0;
|
|
42
|
+
-moz-border-radius: 15px 15px 0 0;
|
|
43
|
+
-webkit-border-top-right-radius: 15px;
|
|
44
|
+
-webkit-border-top-left-radius: 15px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#qunit-header a {
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
color: #c2ccd1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#qunit-header a:hover,
|
|
53
|
+
#qunit-header a:focus {
|
|
54
|
+
color: #fff;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#qunit-banner {
|
|
58
|
+
height: 5px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#qunit-testrunner-toolbar {
|
|
62
|
+
padding: 0.5em 0 0.5em 2em;
|
|
63
|
+
color: #5E740B;
|
|
64
|
+
background-color: #eee;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#qunit-userAgent {
|
|
68
|
+
padding: 0.5em 0 0.5em 2.5em;
|
|
69
|
+
background-color: #2b81af;
|
|
70
|
+
color: #fff;
|
|
71
|
+
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/** Tests: Pass/Fail */
|
|
76
|
+
|
|
77
|
+
#qunit-tests {
|
|
78
|
+
list-style-position: inside;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#qunit-tests li {
|
|
82
|
+
padding: 0.4em 0.5em 0.4em 2.5em;
|
|
83
|
+
border-bottom: 1px solid #fff;
|
|
84
|
+
list-style-position: inside;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#qunit-tests li strong {
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#qunit-tests li a {
|
|
96
|
+
padding: 0.5em;
|
|
97
|
+
color: #c2ccd1;
|
|
98
|
+
text-decoration: none;
|
|
99
|
+
}
|
|
100
|
+
#qunit-tests li a:hover,
|
|
101
|
+
#qunit-tests li a:focus {
|
|
102
|
+
color: #000;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#qunit-tests ol {
|
|
106
|
+
margin-top: 0.5em;
|
|
107
|
+
padding: 0.5em;
|
|
108
|
+
|
|
109
|
+
background-color: #fff;
|
|
110
|
+
|
|
111
|
+
border-radius: 15px;
|
|
112
|
+
-moz-border-radius: 15px;
|
|
113
|
+
-webkit-border-radius: 15px;
|
|
114
|
+
|
|
115
|
+
box-shadow: inset 0px 2px 13px #999;
|
|
116
|
+
-moz-box-shadow: inset 0px 2px 13px #999;
|
|
117
|
+
-webkit-box-shadow: inset 0px 2px 13px #999;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#qunit-tests table {
|
|
121
|
+
border-collapse: collapse;
|
|
122
|
+
margin-top: .2em;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#qunit-tests th {
|
|
126
|
+
text-align: right;
|
|
127
|
+
vertical-align: top;
|
|
128
|
+
padding: 0 .5em 0 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#qunit-tests td {
|
|
132
|
+
vertical-align: top;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#qunit-tests pre {
|
|
136
|
+
margin: 0;
|
|
137
|
+
white-space: pre-wrap;
|
|
138
|
+
word-wrap: break-word;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#qunit-tests del {
|
|
142
|
+
background-color: #e0f2be;
|
|
143
|
+
color: #374e0c;
|
|
144
|
+
text-decoration: none;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#qunit-tests ins {
|
|
148
|
+
background-color: #ffcaca;
|
|
149
|
+
color: #500;
|
|
150
|
+
text-decoration: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/*** Test Counts */
|
|
154
|
+
|
|
155
|
+
#qunit-tests b.counts { color: black; }
|
|
156
|
+
#qunit-tests b.passed { color: #5E740B; }
|
|
157
|
+
#qunit-tests b.failed { color: #710909; }
|
|
158
|
+
|
|
159
|
+
#qunit-tests li li {
|
|
160
|
+
margin: 0.5em;
|
|
161
|
+
padding: 0.4em 0.5em 0.4em 0.5em;
|
|
162
|
+
background-color: #fff;
|
|
163
|
+
border-bottom: none;
|
|
164
|
+
list-style-position: inside;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*** Passing Styles */
|
|
168
|
+
|
|
169
|
+
#qunit-tests li li.pass {
|
|
170
|
+
color: #5E740B;
|
|
171
|
+
background-color: #fff;
|
|
172
|
+
border-left: 26px solid #C6E746;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
|
176
|
+
#qunit-tests .pass .test-name { color: #366097; }
|
|
177
|
+
|
|
178
|
+
#qunit-tests .pass .test-actual,
|
|
179
|
+
#qunit-tests .pass .test-expected { color: #999999; }
|
|
180
|
+
|
|
181
|
+
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
|
182
|
+
|
|
183
|
+
/*** Failing Styles */
|
|
184
|
+
|
|
185
|
+
#qunit-tests li li.fail {
|
|
186
|
+
color: #710909;
|
|
187
|
+
background-color: #fff;
|
|
188
|
+
border-left: 26px solid #EE5757;
|
|
189
|
+
white-space: pre;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#qunit-tests > li:last-child {
|
|
193
|
+
border-radius: 0 0 15px 15px;
|
|
194
|
+
-moz-border-radius: 0 0 15px 15px;
|
|
195
|
+
-webkit-border-bottom-right-radius: 15px;
|
|
196
|
+
-webkit-border-bottom-left-radius: 15px;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
|
200
|
+
#qunit-tests .fail .test-name,
|
|
201
|
+
#qunit-tests .fail .module-name { color: #000000; }
|
|
202
|
+
|
|
203
|
+
#qunit-tests .fail .test-actual { color: #EE5757; }
|
|
204
|
+
#qunit-tests .fail .test-expected { color: green; }
|
|
205
|
+
|
|
206
|
+
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
/** Result */
|
|
210
|
+
|
|
211
|
+
#qunit-testresult {
|
|
212
|
+
padding: 0.5em 0.5em 0.5em 2.5em;
|
|
213
|
+
|
|
214
|
+
color: #2b81af;
|
|
215
|
+
background-color: #D2E0E6;
|
|
216
|
+
|
|
217
|
+
border-bottom: 1px solid white;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Fixture */
|
|
221
|
+
|
|
222
|
+
#qunit-fixture {
|
|
223
|
+
position: absolute;
|
|
224
|
+
top: -10000px;
|
|
225
|
+
left: -10000px;
|
|
226
|
+
}
|