jax 1.0.1 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/.travis.yml +32 -0
- data/CHANGELOG +126 -0
- data/README.md +1 -1
- data/Rakefile +125 -19
- data/bin/jax +1 -1
- data/builtin/{shaders → app/shaders}/basic/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/basic/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/basic/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/material.js +0 -0
- data/builtin/{shaders → app/shaders}/depthmap/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/fog/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/fog/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/fog/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/fog/material.js +0 -0
- data/builtin/{shaders → app/shaders}/fog/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/functions/depth_map.ejs +0 -0
- data/builtin/{shaders → app/shaders}/functions/lights.ejs +0 -0
- data/builtin/{shaders → app/shaders}/functions/noise.ejs +0 -0
- data/builtin/{shaders → app/shaders}/lighting/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/lighting/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/lighting/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/lighting/material.js +0 -0
- data/builtin/{shaders → app/shaders}/lighting/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/material.js +0 -0
- data/builtin/{shaders → app/shaders}/normal_map/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/material.js +0 -0
- data/builtin/{shaders → app/shaders}/paraboloid/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/picking/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/picking/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/picking/material.js +0 -0
- data/builtin/{shaders → app/shaders}/picking/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/material.js +0 -0
- data/builtin/{shaders → app/shaders}/shadow_map/vertex.ejs +0 -0
- data/builtin/{shaders → app/shaders}/texture/common.ejs +0 -0
- data/builtin/{shaders → app/shaders}/texture/fragment.ejs +0 -0
- data/builtin/{shaders → app/shaders}/texture/manifest.yml +0 -0
- data/builtin/{shaders → app/shaders}/texture/material.js +0 -0
- data/builtin/{shaders → app/shaders}/texture/vertex.ejs +0 -0
- data/jax.gems +1 -1
- data/jax.gemspec +9 -7
- data/lib/jax.rb +23 -9
- data/lib/jax/application.rb +118 -60
- data/lib/jax/application/builtin.rb +12 -0
- data/lib/jax/application/builtin/configurable.rb +5 -0
- data/lib/jax/application/builtin/configuration.rb +5 -0
- data/lib/jax/application/configurable.rb +19 -0
- data/lib/jax/application/configuration.rb +46 -13
- data/lib/jax/application/railties.rb +26 -0
- data/lib/jax/core_ext/kernel.rb +7 -0
- data/lib/jax/engine.rb +64 -0
- data/lib/jax/engine/configurable.rb +19 -0
- data/lib/jax/engine/configuration.rb +49 -0
- data/lib/jax/generators/app.rb +3 -2
- data/lib/jax/generators/app/app_generator.rb +9 -2
- data/lib/jax/generators/app/templates/config/environment.rb.tt +5 -0
- data/lib/jax/generators/app/templates/public/index.html.tt +26 -0
- data/lib/jax/generators/app/templates/public/javascripts/jax.js +8726 -1
- data/lib/jax/generators/app/templates/public/stylesheets/%file_name%.css.tt +11 -0
- data/lib/jax/generators/app/templates/public/webgl_not_supported.html +1 -1
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine.yml +1 -0
- data/lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers/jax_spec_environment_helper.js +13 -5
- data/lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers/jax_spec_helper.js +6 -10
- data/lib/jax/generators/commands.rb +168 -42
- data/lib/jax/generators/controller/controller_generator.rb +9 -2
- data/lib/jax/generators/interactions.rb +56 -0
- data/lib/jax/generators/light_source/light_source_generator.rb +1 -2
- data/lib/jax/generators/material/material_generator.rb +1 -2
- data/lib/jax/generators/model/model_generator.rb +1 -3
- data/lib/jax/generators/packager/package_generator.rb +32 -0
- data/lib/jax/generators/plugin/USAGE +4 -0
- data/lib/jax/generators/plugin/all.rb +113 -0
- data/lib/jax/generators/plugin/credentials.rb +108 -0
- data/lib/jax/generators/plugin/plugin_generator.rb +72 -0
- data/lib/jax/generators/plugin/plugin_manager.rb +254 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/controllers/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/helpers/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/models/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/resources/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/app/views/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/config/routes.rb +3 -0
- data/lib/jax/generators/plugin/templates/new_plugin/init.rb +1 -0
- data/lib/jax/generators/plugin/templates/new_plugin/install.rb +2 -0
- data/lib/jax/generators/plugin/templates/new_plugin/public/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/spec/.empty_directory +0 -0
- data/lib/jax/generators/plugin/templates/new_plugin/uninstall.rb +2 -0
- data/lib/jax/generators/script_jax_loader.rb +17 -0
- data/lib/jax/generators/shader/shader_generator.rb +2 -3
- data/lib/jax/monkeypatch/jasmine/config.rb +25 -1
- data/lib/jax/monkeypatch/jasmine/server.rb +1 -1
- data/lib/jax/packager.rb +12 -11
- data/lib/jax/packager/sprockets_template.rb +15 -6
- data/lib/jax/plugin.rb +49 -0
- data/lib/jax/plugin/manifest.rb +71 -0
- data/lib/jax/resource_compiler.rb +24 -14
- data/lib/jax/routes.rb +1 -0
- data/lib/jax/shader.rb +16 -1
- data/lib/jax/tasks/rake.rb +1 -1
- data/lib/jax/version.rb +3 -3
- data/spec/benchmark.htm +93 -0
- data/spec/fixtures/web/plugins/404.http +39 -0
- data/spec/fixtures/web/plugins/all.xml +106 -0
- data/spec/fixtures/web/plugins/author/create_account.xml.http +20 -0
- data/spec/fixtures/web/plugins/author/create_new_plugin.xml.http +27 -0
- data/spec/fixtures/web/plugins/author/login_existing_account.xml.http +19 -0
- data/spec/fixtures/web/plugins/author/login_not_found.xml.http +14 -0
- data/spec/fixtures/web/plugins/author/login_password_invalid.xml.http +12 -0
- data/spec/fixtures/web/plugins/clouds.xml +51 -0
- data/spec/fixtures/web/plugins/example.tgz.http +0 -0
- data/spec/fixtures/web/plugins/example.tgz.http.old +0 -0
- data/spec/fixtures/web/plugins/none.http +13 -0
- data/spec/fixtures/web/plugins/vert.xml +68 -0
- data/spec/fixtures/web/plugins/vertex-blob.xml +37 -0
- data/spec/fixtures/web/plugins/vertex-height-map.xml +44 -0
- data/spec/generators/app_generator_test.rb +42 -0
- data/spec/generators/controller_generator_test.rb +47 -0
- data/spec/generators/light_generator_test.rb +37 -0
- data/spec/generators/material_generator_test.rb +22 -0
- data/spec/generators/model_generator_test.rb +26 -0
- data/spec/generators/plugin_generator_test.rb +114 -0
- data/spec/generators/plugin_manager/push_test.rb +59 -0
- data/spec/generators/plugin_manager_test.rb +192 -0
- data/spec/generators/shader_generator_test.rb +38 -0
- data/spec/lib/jax/application_test.rb +18 -0
- data/spec/lib/jax/generators/plugin/credentials_test.rb +72 -0
- data/spec/lib/jax/packager_test.rb +87 -0
- data/spec/lib/jax/plugin_test.rb +27 -0
- data/spec/lib/jax/reloading_test.rb +23 -0
- data/spec/lib/jax/routes_test.rb +28 -0
- data/spec/lib/jax/shader_test.rb +29 -0
- data/spec/lib/jax/tasks/jax_rake_test.rb +85 -0
- data/spec/support/bases/generator_test_case.rb +108 -0
- data/spec/support/bases/isolated_test_case.rb +148 -0
- data/spec/support/fixtures_helper.rb +21 -0
- data/spec/support/spec_shell.rb +14 -1
- data/spec/test_app.rb +3 -0
- data/spec/test_helper.rb +55 -0
- metadata +200 -92
- data/spec/generators/app_generator_spec.rb +0 -47
- data/spec/generators/controller_generator_spec.rb +0 -68
- data/spec/generators/light_generator_spec.rb +0 -51
- data/spec/generators/material_generator_spec.rb +0 -35
- data/spec/generators/model_generator_spec.rb +0 -43
- data/spec/lib/jax/routes_spec.rb +0 -24
- data/spec/lib/jax/shader_spec.rb +0 -57
- data/spec/lib/jax/tasks/jax_rake_spec.rb +0 -92
- data/spec/spec_helper.rb +0 -11
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# This file is executed whenever Jax loads or reloads this plugin.
|
File without changes
|
File without changes
|
@@ -1,5 +1,21 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
|
+
if ARGV.include? '-v' or ARGV.include? '--version'
|
4
|
+
require 'thor'
|
5
|
+
require File.expand_path("../version", File.dirname(__FILE__))
|
6
|
+
|
7
|
+
class VersionGenerator < Thor
|
8
|
+
map "--version" => :version, "-v" => :version
|
9
|
+
desc "--version, -v", "display the Jax version number"
|
10
|
+
def version
|
11
|
+
say "Jax v#{Jax::VERSION}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
VersionGenerator.start(['--version'])
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
|
3
19
|
module Jax
|
4
20
|
module Generators
|
5
21
|
# Shamelessly lifted from Ruby on Rails
|
@@ -9,6 +25,7 @@ module Jax
|
|
9
25
|
|
10
26
|
def self.exec_script_jax!
|
11
27
|
cwd = Dir.pwd
|
28
|
+
ENV['JAX_CWD'] ||= cwd
|
12
29
|
return unless in_jax_application? || in_jax_application_subdirectory?
|
13
30
|
exec RUBY, SCRIPT_JAX, *ARGV if in_jax_application?
|
14
31
|
Dir.chdir("..") do
|
@@ -3,8 +3,7 @@ require 'active_support/core_ext'
|
|
3
3
|
module Jax
|
4
4
|
module Generators
|
5
5
|
module Shader
|
6
|
-
class ShaderGenerator < Jax::Generators::
|
7
|
-
include Thor::Actions
|
6
|
+
class ShaderGenerator < Jax::Generators::PluggableCommand
|
8
7
|
argument :name, :desc => "The name of this shader", :banner => "[name]"
|
9
8
|
|
10
9
|
def self.source_root
|
@@ -12,7 +11,7 @@ module Jax
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def check_conflicts
|
15
|
-
if Jax.application.shaders.find(file_name)
|
14
|
+
if Jax.application.shaders.find(file_name) && behavior != :revoke
|
16
15
|
raise ArgumentError, "A shader called '#{file_name}' already exists!"
|
17
16
|
end
|
18
17
|
end
|
@@ -1,14 +1,38 @@
|
|
1
1
|
module Jasmine
|
2
2
|
class Config
|
3
|
+
def plugin_and_app_files(src_files)
|
4
|
+
src_files.collect do |src_file|
|
5
|
+
Jax.application.plugins.inject([]) { |ary, plugin|
|
6
|
+
ary + [File.join(plugin.relative_path, src_file)]
|
7
|
+
} + [src_file]
|
8
|
+
end.flatten
|
9
|
+
end
|
10
|
+
|
3
11
|
# overridden so that we can map source files separately from /public
|
4
12
|
def src_files
|
5
13
|
if simple_config['src_files']
|
6
|
-
match_files(src_dir, simple_config['src_files']).collect
|
14
|
+
match_files(src_dir, plugin_and_app_files(simple_config['src_files'])).collect do |f|
|
15
|
+
File.join("__src__", f)
|
16
|
+
end.uniq
|
7
17
|
else
|
8
18
|
[]
|
9
19
|
end
|
10
20
|
end
|
11
21
|
|
22
|
+
def helpers
|
23
|
+
helpers = simple_config['helpers'] || ['helpers/**/*.js']
|
24
|
+
helpers.collect! { |s| File.expand_path(s, spec_dir).gsub(/^#{Regexp::escape Jax.root.to_s}\/?/, '') }
|
25
|
+
|
26
|
+
match_files(project_root, plugin_and_app_files(helpers)).uniq
|
27
|
+
end
|
28
|
+
|
29
|
+
def spec_files
|
30
|
+
spec_files = simple_config['spec_files'] || ['**/*[sS]pec.js']
|
31
|
+
spec_files.collect! { |s| File.expand_path(s, spec_dir).gsub(/^#{Regexp::escape Jax.root.to_s}\/?/, '') }
|
32
|
+
|
33
|
+
match_files(project_root, plugin_and_app_files(spec_files)).uniq
|
34
|
+
end
|
35
|
+
|
12
36
|
# new, used by overridden 'server.rb' so that we can map /public to root
|
13
37
|
def root_dir
|
14
38
|
if simple_config['root_dir']
|
@@ -32,7 +32,7 @@ module Jasmine
|
|
32
32
|
map("/__suite__") { run Jasmine::FocusedSuite.new(config) }
|
33
33
|
|
34
34
|
map("/__JASMINE_ROOT__") { run Rack::File.new(Jasmine.root) }
|
35
|
-
map(config.spec_path) { run Rack::File.new(config.
|
35
|
+
map(config.spec_path) { run Rack::File.new(config.project_root) }
|
36
36
|
map(config.root_path) { run Rack::File.new(config.project_root) }
|
37
37
|
|
38
38
|
map '/' do
|
data/lib/jax/packager.rb
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
require 'sprockets'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
class Jax::Packager
|
5
|
+
include FileUtils
|
4
6
|
attr_reader :pkg_path, :path, :project
|
5
7
|
autoload :SprocketsTemplate, File.join(File.dirname(__FILE__), "packager/sprockets_template")
|
6
8
|
|
7
9
|
class << self
|
8
10
|
def invoke
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
package = new pkg_dir
|
13
|
-
puts package.project.template
|
14
|
-
|
15
|
-
package.build!
|
16
|
-
|
11
|
+
puts "DEPRECATED"
|
12
|
+
puts
|
13
|
+
puts "Please invoke the Jax packager with the following command:"
|
17
14
|
puts
|
18
|
-
puts "
|
19
|
-
puts " #{package.pkg_path}"
|
15
|
+
puts " jax package"
|
20
16
|
puts
|
17
|
+
puts "This notice will be removed sometime around Jax v1.2."
|
18
|
+
puts
|
19
|
+
puts
|
20
|
+
|
21
|
+
Jax::Generators::Packager::PackageGenerator.start([])
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -45,7 +46,7 @@ class Jax::Packager
|
|
45
46
|
@secretary = Sprockets::Secretary.new(
|
46
47
|
:root => Jax.root,
|
47
48
|
:asset_root => @pkg_path.to_s,
|
48
|
-
:load_path =>
|
49
|
+
:load_path => Jax.application.javascript_load_paths,
|
49
50
|
:source_files => []
|
50
51
|
)
|
51
52
|
@project = Jax::Packager::SprocketsTemplate.new(@secretary.environment)
|
@@ -10,12 +10,11 @@ class Jax::Packager::SprocketsTemplate < Sprockets::SourceFile
|
|
10
10
|
template = [
|
11
11
|
'Jax.environment = Jax.PRODUCTION;',
|
12
12
|
'',
|
13
|
-
|
13
|
+
asset_paths,
|
14
14
|
''
|
15
|
-
]
|
16
|
-
|
17
|
-
|
18
|
-
Dir[Jax.root.join("app/**/*.js")].each { |jsfi| try_to_add_file(template, jsfi) }
|
15
|
+
].flatten
|
16
|
+
|
17
|
+
Jax.application.javascript_sources.each { |jsfi| try_to_add_file(template, jsfi) }
|
19
18
|
|
20
19
|
template
|
21
20
|
end
|
@@ -29,7 +28,7 @@ class Jax::Packager::SprocketsTemplate < Sprockets::SourceFile
|
|
29
28
|
|
30
29
|
def add_file(template, jsfi)
|
31
30
|
relative_path = jsfi.sub(/^#{Regexp::escape Jax.root.to_s}[\/\\]?/, '')
|
32
|
-
template << "//= require
|
31
|
+
template << "//= require <#{relative_path}>"
|
33
32
|
added_files << jsfi
|
34
33
|
end
|
35
34
|
|
@@ -41,6 +40,16 @@ class Jax::Packager::SprocketsTemplate < Sprockets::SourceFile
|
|
41
40
|
@added_files ||= []
|
42
41
|
end
|
43
42
|
|
43
|
+
def asset_paths
|
44
|
+
Jax.application.asset_paths.collect do |path|
|
45
|
+
if File.directory?(path)
|
46
|
+
"//= provide \"#{File.join(path, "").gsub(/^#{Regexp::escape Jax.root.to_s}\/?/, '')}\""
|
47
|
+
end
|
48
|
+
end.reject do |result|
|
49
|
+
result.nil?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
def source_lines
|
45
54
|
# basically the same as super but with a string instead of a file
|
46
55
|
# TODO would templating be a worthy addition to Sprockets itself?
|
data/lib/jax/plugin.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
require 'rails/initializable'
|
3
|
+
|
4
|
+
class Jax::Plugin < Jax::Engine
|
5
|
+
autoload :Manifest, 'jax/plugin/manifest'
|
6
|
+
|
7
|
+
attr_reader :relative_path
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def all(list, paths)
|
11
|
+
plugins = []
|
12
|
+
paths.each do |path|
|
13
|
+
Dir["#{path}/*"].each do |plugin_path|
|
14
|
+
plugin = new(plugin_path)
|
15
|
+
next unless list.include?(plugin.name) || list.include?(:all)
|
16
|
+
plugins << plugin
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
plugins.sort_by do |p|
|
21
|
+
[list.index(p.name) || list.index(:all), p.name.to_s]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(path)
|
27
|
+
super()
|
28
|
+
@relative_path = path.sub(/^#{Regexp::escape Jax.root.to_s}\/?/, '')
|
29
|
+
end
|
30
|
+
|
31
|
+
def manifest
|
32
|
+
@manifest ||= begin
|
33
|
+
manifest = Jax::Plugin::Manifest.new(name)
|
34
|
+
manifest.load
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def full_path
|
39
|
+
File.expand_path(relative_path, Jax.root)
|
40
|
+
end
|
41
|
+
|
42
|
+
def name
|
43
|
+
File.basename(relative_path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def config
|
47
|
+
@config ||= Jax::Engine::Configuration.new(full_path)
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'active_support/hash_with_indifferent_access'
|
2
|
+
|
3
|
+
class Jax::Plugin::Manifest < ActiveSupport::HashWithIndifferentAccess
|
4
|
+
class << self
|
5
|
+
def find(name)
|
6
|
+
man = new name
|
7
|
+
man.load
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(plugin_name)
|
12
|
+
super()
|
13
|
+
self[:name] = plugin_name
|
14
|
+
defaults
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
self[:name]
|
19
|
+
end
|
20
|
+
|
21
|
+
def name=(n)
|
22
|
+
self[:name] = n
|
23
|
+
end
|
24
|
+
|
25
|
+
def version
|
26
|
+
self[:version]
|
27
|
+
end
|
28
|
+
|
29
|
+
def version=(n)
|
30
|
+
self[:version] = n
|
31
|
+
end
|
32
|
+
|
33
|
+
def description
|
34
|
+
self[:description]
|
35
|
+
end
|
36
|
+
|
37
|
+
def description=(n)
|
38
|
+
self[:description] = n
|
39
|
+
end
|
40
|
+
|
41
|
+
def load
|
42
|
+
load_from path
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_from(path)
|
46
|
+
yml = YAML::load(File.read(path))
|
47
|
+
yml.each do |key, value|
|
48
|
+
self[key] = value
|
49
|
+
end
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def save
|
54
|
+
save_to path
|
55
|
+
end
|
56
|
+
|
57
|
+
def save_to(path)
|
58
|
+
File.open(path, "w") { |f| f.print to_yaml }
|
59
|
+
self
|
60
|
+
end
|
61
|
+
|
62
|
+
def path
|
63
|
+
File.join(Jax.root, "vendor/plugins", name, "manifest.yml")
|
64
|
+
end
|
65
|
+
|
66
|
+
def defaults
|
67
|
+
self[:description] ||= ""
|
68
|
+
self[:version] ||= "0.0.1"
|
69
|
+
self
|
70
|
+
end
|
71
|
+
end
|
@@ -1,32 +1,42 @@
|
|
1
1
|
class Jax::ResourceCompiler
|
2
2
|
def save(destination_file)
|
3
|
-
resources = gather_resources
|
4
|
-
|
5
3
|
if destination_file.kind_of?(IO)
|
6
|
-
save_resources destination_file
|
4
|
+
save_resources destination_file
|
7
5
|
else
|
8
6
|
mkdir_p File.dirname(destination_file) unless File.exist?(File.dirname(destination_file))
|
9
7
|
File.open destination_file, "w" do |f|
|
10
|
-
save_resources f
|
8
|
+
save_resources f
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
io.puts "#{model_name.camelize}.addResources(#{instances.to_json});"
|
13
|
+
def to_s
|
14
|
+
resources.inject("") do |result, (model_name, instances)|
|
15
|
+
result + "#{model_name.camelize}.addResources(#{instances.to_json});\n"
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
19
|
+
def resources
|
20
|
+
gather_resources
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def save_resources(io)
|
25
|
+
io.puts to_s
|
26
|
+
end
|
27
|
+
|
22
28
|
def gather_resources
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
# app.resource_files.concat config.paths.app.resources.to_a
|
30
|
+
|
31
|
+
Jax.application.resource_paths.inject({}) do |resources, paths|
|
32
|
+
paths.to_a.each do |yml|
|
33
|
+
model_name = File.basename(File.dirname(yml)).singularize
|
34
|
+
resource_id = File.basename(yml).sub(/^(.*)\..*$/, '\1')
|
35
|
+
hash = YAML::load(File.read(yml)) || {}
|
27
36
|
|
28
|
-
|
29
|
-
|
37
|
+
resources[model_name] ||= {}
|
38
|
+
resources[model_name].merge!({ resource_id => hash })
|
39
|
+
end
|
30
40
|
resources
|
31
41
|
end
|
32
42
|
end
|
data/lib/jax/routes.rb
CHANGED
data/lib/jax/shader.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Jax::Shader
|
2
|
-
attr_reader :common, :fragment, :vertex
|
2
|
+
# attr_reader :common, :fragment, :vertex
|
3
3
|
attr_accessor :name, :path, :exports, :manifest
|
4
4
|
|
5
5
|
def initialize(path, name = File.basename(path))
|
@@ -10,6 +10,21 @@ class Jax::Shader
|
|
10
10
|
detect_sources
|
11
11
|
end
|
12
12
|
|
13
|
+
def common
|
14
|
+
detect_sources # force reloads the latest sources
|
15
|
+
@common
|
16
|
+
end
|
17
|
+
|
18
|
+
def fragment
|
19
|
+
detect_sources # force reloads the latest sources
|
20
|
+
@fragment
|
21
|
+
end
|
22
|
+
|
23
|
+
def vertex
|
24
|
+
detect_sources # force reloads the latest sources
|
25
|
+
@vertex
|
26
|
+
end
|
27
|
+
|
13
28
|
def description
|
14
29
|
manifest && manifest['description']
|
15
30
|
end
|
data/lib/jax/tasks/rake.rb
CHANGED
@@ -19,7 +19,7 @@ namespace :jax do
|
|
19
19
|
|
20
20
|
task :generate_files do
|
21
21
|
# resources
|
22
|
-
Jax
|
22
|
+
Jax.application.resources.save(Jax.root.join 'tmp/resources.js')
|
23
23
|
|
24
24
|
# routes
|
25
25
|
File.open("tmp/shaders.js", "w") { |file| Jax.application.shaders.each { |shader| shader.save_to file } }
|