jax 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +2 -3
- data/.travis.yml +8 -22
- data/README.md +2 -2
- data/Rakefile +128 -96
- data/app/assets/javascripts/jax/controller-list.js.coffee +22 -0
- data/app/assets/javascripts/jax/dom-helpers.js.coffee +17 -0
- data/app/assets/javascripts/jax/jasmine_runner.js +177 -0
- data/app/assets/javascripts/jax/runtime.js +6 -0
- data/app/assets/javascripts/jax/shader_editor.js.coffee +33 -0
- data/app/assets/stylesheets/jax/controller-list.css +5 -0
- data/app/assets/stylesheets/jax/jasmine.css +16 -0
- data/app/assets/stylesheets/jax/nav.css +41 -0
- data/app/assets/stylesheets/jax/runtime.css +47 -0
- data/app/assets/stylesheets/jax/shader_editor.css +3 -0
- data/app/assets/stylesheets/jax/suite.css +82 -0
- data/app/controllers/jax/suite_controller.rb +48 -0
- data/app/views/jax/suite/jasmine.html.erb +38 -0
- data/app/views/jax/suite/run_webgl.html.erb +49 -0
- data/app/views/jax/suite/shader_editor.html.erb +24 -0
- data/app/views/layouts/jax.html.erb +40 -0
- data/bin/jax +8 -4
- data/config/routes.rb +2 -0
- data/config.ru +5 -0
- data/features/rails/resources.feature +45 -0
- data/features/rails/shaders.feature +13 -0
- data/features/rails/specs.feature +24 -0
- data/features/runtime.feature +15 -0
- data/features/step_definitions/environment_steps.rb +15 -0
- data/features/step_definitions/response_steps.rb +13 -0
- data/features/step_definitions/runtime.rb +11 -0
- data/features/step_definitions/web_steps.rb +223 -0
- data/features/support/env.rb +75 -0
- data/features/support/paths.rb +30 -0
- data/features/support/rails_environment.rb +3 -0
- data/features/support/selectors.rb +39 -0
- data/features/support/setup.rb +17 -0
- data/jax.gemspec +22 -16
- data/lib/assets/javascripts/jax/anim_frame.js +64 -0
- data/lib/assets/javascripts/jax/application.js +16 -0
- data/lib/assets/javascripts/jax/builtin/all.js +21 -0
- data/lib/assets/javascripts/jax/builtin/meshes/cube.js +83 -0
- data/lib/assets/javascripts/jax/builtin/meshes/plane.js +67 -0
- data/lib/assets/javascripts/jax/builtin/meshes/quad.js +89 -0
- data/lib/assets/javascripts/jax/builtin/meshes/sphere.js +65 -0
- data/lib/assets/javascripts/jax/builtin/meshes/teapot.js +48 -0
- data/lib/assets/javascripts/jax/builtin/meshes/torus.js +64 -0
- data/lib/assets/javascripts/jax/compatibility.js +312 -0
- data/lib/assets/javascripts/jax/context.js +741 -0
- data/lib/assets/javascripts/jax/core/base.js +69 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/mat3.js +20 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/mat4.js +10 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/quat4.js +148 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/vec2.js +25 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/vec3.js +86 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/vec4.js +28 -0
- data/lib/assets/javascripts/jax/core/helper.js +44 -0
- data/lib/assets/javascripts/jax/core/math.js +61 -0
- data/lib/assets/javascripts/jax/core/matrix_stack.js +310 -0
- data/lib/assets/javascripts/jax/core/util.js +271 -0
- data/lib/assets/javascripts/jax/core.js +43 -0
- data/lib/assets/javascripts/jax/events.js +304 -0
- data/lib/assets/javascripts/jax/geometry/line.js +185 -0
- data/lib/assets/javascripts/jax/geometry/plane.js +371 -0
- data/lib/assets/javascripts/jax/geometry/triangle/inliner.rb +94 -0
- data/lib/assets/javascripts/jax/geometry/triangle/slow_tri_tri_intersect.js +20 -0
- data/lib/assets/javascripts/jax/geometry/triangle/tri_tri_intersect.js +281 -0
- data/lib/assets/javascripts/jax/geometry/triangle/tri_tri_intersect_optimized.js +564 -0
- data/lib/assets/javascripts/jax/geometry/triangle.js +311 -0
- data/lib/assets/javascripts/jax/geometry.js +14 -0
- data/lib/assets/javascripts/jax/mvc/controller.js +188 -0
- data/lib/assets/javascripts/jax/mvc/model.js +302 -0
- data/lib/assets/javascripts/jax/mvc/route_set.js +148 -0
- data/lib/assets/javascripts/jax/mvc/view.js +43 -0
- data/lib/assets/javascripts/jax/mvc/view_manager.js +65 -0
- data/lib/assets/javascripts/jax/noise.js +251 -0
- data/lib/assets/javascripts/jax/prototype/class.js +81 -0
- data/lib/assets/javascripts/jax/prototype/core.js +112 -0
- data/lib/assets/javascripts/jax/prototype/extensions.js +142 -0
- data/lib/assets/javascripts/jax/vendor/ejs.js +1 -0
- data/lib/assets/javascripts/jax/vendor/glMatrix.js +7 -0
- data/lib/assets/javascripts/jax/webgl/camera.js +697 -0
- data/lib/assets/javascripts/jax/webgl/cleanup.js +1 -0
- data/lib/assets/javascripts/jax/webgl/core/buffer.js +292 -0
- data/lib/assets/javascripts/jax/webgl/core/data_region.js +184 -0
- data/lib/assets/javascripts/jax/webgl/core/data_segment.js +255 -0
- data/lib/assets/javascripts/jax/webgl/core/events.js +99 -0
- data/lib/assets/javascripts/jax/webgl/core/framebuffer.js +316 -0
- data/lib/assets/javascripts/jax/webgl/core.js +6 -0
- data/lib/assets/javascripts/jax/webgl/material.js +381 -0
- data/lib/assets/javascripts/jax/webgl/mesh/normals.js +37 -0
- data/lib/assets/javascripts/jax/webgl/mesh/support.js +104 -0
- data/lib/assets/javascripts/jax/webgl/mesh/tangent_space.js +111 -0
- data/lib/assets/javascripts/jax/webgl/mesh.js +440 -0
- data/lib/assets/javascripts/jax/webgl/scene/frustum.js +422 -0
- data/lib/assets/javascripts/jax/webgl/scene/light_manager.js +141 -0
- data/lib/assets/javascripts/jax/webgl/scene/light_source.js +300 -0
- data/lib/assets/javascripts/jax/webgl/scene.js +16 -0
- data/lib/assets/javascripts/jax/webgl/shader/delegator/attribute.js +53 -0
- data/lib/assets/javascripts/jax/webgl/shader/delegator/uniform.js +71 -0
- data/lib/assets/javascripts/jax/webgl/shader/delegator.js +13 -0
- data/lib/assets/javascripts/jax/webgl/shader/manifest.js +70 -0
- data/lib/assets/javascripts/jax/webgl/shader/program.js +138 -0
- data/lib/assets/javascripts/jax/webgl/shader.js +299 -0
- data/lib/assets/javascripts/jax/webgl/shader_chain.js +267 -0
- data/lib/assets/javascripts/jax/webgl/texture.js +506 -0
- data/lib/assets/javascripts/jax/webgl/world.js +279 -0
- data/lib/assets/javascripts/jax/webgl.js +109 -0
- data/lib/assets/javascripts/jax.js +136 -0
- data/{builtin/app/shaders/basic/common.ejs → lib/assets/javascripts/shaders/basic/common.glsl} +0 -0
- data/{builtin/app/shaders/basic/fragment.ejs → lib/assets/javascripts/shaders/basic/fragment.glsl} +0 -0
- data/{builtin/app/shaders/basic/vertex.ejs → lib/assets/javascripts/shaders/basic/vertex.glsl} +1 -1
- data/{builtin/app/shaders/depthmap/common.ejs → lib/assets/javascripts/shaders/depthmap/common.glsl} +0 -0
- data/{builtin/app/shaders/depthmap/fragment.ejs → lib/assets/javascripts/shaders/depthmap/fragment.glsl} +1 -1
- data/{builtin/app → lib/assets/javascripts}/shaders/depthmap/material.js +0 -0
- data/{builtin/app/shaders/depthmap/vertex.ejs → lib/assets/javascripts/shaders/depthmap/vertex.glsl} +0 -0
- data/{builtin/app/shaders/fog/common.ejs → lib/assets/javascripts/shaders/fog/common.glsl} +0 -0
- data/{builtin/app/shaders/fog/fragment.ejs → lib/assets/javascripts/shaders/fog/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/fog/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/fog/material.js +6 -8
- data/{builtin/app/shaders/fog/vertex.ejs → lib/assets/javascripts/shaders/fog/vertex.glsl} +0 -0
- data/{builtin/app/shaders/functions/depth_map.ejs → lib/assets/javascripts/shaders/functions/depth_map.glsl} +0 -0
- data/{builtin/app/shaders/functions/lights.ejs → lib/assets/javascripts/shaders/functions/lights.glsl} +0 -0
- data/{builtin/app/shaders/functions/noise.ejs → lib/assets/javascripts/shaders/functions/noise.glsl} +0 -0
- data/lib/assets/javascripts/shaders/lighting/common.glsl +5 -0
- data/{builtin/app/shaders/lighting/fragment.ejs → lib/assets/javascripts/shaders/lighting/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/lighting/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/lighting/material.js +2 -4
- data/{builtin/app/shaders/lighting/vertex.ejs → lib/assets/javascripts/shaders/lighting/vertex.glsl} +0 -0
- data/{builtin/app/shaders/normal_map/common.ejs → lib/assets/javascripts/shaders/normal_map/common.glsl} +1 -1
- data/{builtin/app/shaders/normal_map/fragment.ejs → lib/assets/javascripts/shaders/normal_map/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/normal_map/manifest.yml +0 -0
- data/lib/assets/javascripts/shaders/normal_map/material.js +11 -0
- data/{builtin/app/shaders/normal_map/vertex.ejs → lib/assets/javascripts/shaders/normal_map/vertex.glsl} +0 -0
- data/{builtin/app/shaders/paraboloid/common.ejs → lib/assets/javascripts/shaders/paraboloid/common.glsl} +0 -0
- data/{builtin/app/shaders/paraboloid/fragment.ejs → lib/assets/javascripts/shaders/paraboloid/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/paraboloid/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/paraboloid/material.js +2 -4
- data/{builtin/app/shaders/paraboloid/vertex.ejs → lib/assets/javascripts/shaders/paraboloid/vertex.glsl} +0 -0
- data/{builtin/app/shaders/picking/common.ejs → lib/assets/javascripts/shaders/picking/common.glsl} +0 -0
- data/{builtin/app/shaders/picking/fragment.ejs → lib/assets/javascripts/shaders/picking/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/picking/material.js +2 -4
- data/{builtin/app/shaders/picking/vertex.ejs → lib/assets/javascripts/shaders/picking/vertex.glsl} +0 -0
- data/{builtin/app/shaders/shadow_map/common.ejs → lib/assets/javascripts/shaders/shadow_map/common.glsl} +2 -1
- data/{builtin/app/shaders/shadow_map/fragment.ejs → lib/assets/javascripts/shaders/shadow_map/fragment.glsl} +1 -1
- data/{builtin/app → lib/assets/javascripts}/shaders/shadow_map/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/shadow_map/material.js +4 -6
- data/{builtin/app/shaders/shadow_map/vertex.ejs → lib/assets/javascripts/shaders/shadow_map/vertex.glsl} +0 -0
- data/{builtin/app/shaders/texture/common.ejs → lib/assets/javascripts/shaders/texture/common.glsl} +0 -0
- data/{builtin/app/shaders/texture/fragment.ejs → lib/assets/javascripts/shaders/texture/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/texture/manifest.yml +0 -0
- data/lib/assets/javascripts/shaders/texture/material.js +17 -0
- data/{builtin/app/shaders/texture/vertex.ejs → lib/assets/javascripts/shaders/texture/vertex.glsl} +0 -0
- data/lib/generators/jax/all.rb +16 -0
- data/lib/generators/jax/application/application_generator.rb +48 -0
- data/lib/generators/jax/base/actions.rb +52 -0
- data/lib/generators/jax/base/coffee_generator.rb +30 -0
- data/lib/generators/jax/base/named_base.rb +17 -0
- data/lib/generators/jax/base/plugin_base.rb +108 -0
- data/lib/generators/jax/base/plugin_credentials.rb +99 -0
- data/lib/generators/jax/base/plugin_manifest.rb +75 -0
- data/lib/generators/jax/base/rails_base.rb +30 -0
- data/lib/generators/jax/base/source_root.rb +5 -0
- data/lib/generators/jax/controller/controller_generator.rb +37 -0
- data/lib/generators/jax/helper/helper_generator.rb +30 -0
- data/lib/generators/jax/install/install_generator.rb +27 -0
- data/lib/generators/jax/jax_generator.rb +13 -0
- data/lib/generators/jax/light/light_generator.rb +23 -0
- data/lib/{jax/generators → generators/jax}/material/USAGE +4 -8
- data/lib/generators/jax/material/material_generator.rb +112 -0
- data/lib/generators/jax/model/model_generator.rb +24 -0
- data/lib/generators/jax/plugin/plugin_generator.rb +72 -0
- data/lib/generators/jax/scaffold/scaffold_generator.rb +35 -0
- data/lib/generators/jax/shader/shader_generator.rb +38 -0
- data/lib/jax/commands/plugin_manager.rb +240 -0
- data/lib/jax/commands.rb +69 -0
- data/lib/jax/configuration.rb +64 -0
- data/lib/jax/directive_processor.rb +53 -0
- data/lib/jax/engine.rb +38 -54
- data/lib/jax/helper_methods.rb +3 -0
- data/lib/jax/rails/application.rb +34 -0
- data/lib/jax/resource_file.rb +29 -0
- data/lib/jax/script_loader.rb +68 -0
- data/lib/jax/server.rb +87 -0
- data/lib/jax/shader.rb +70 -172
- data/lib/jax/testing/rails_environment.rb +94 -0
- data/lib/jax/util/tar.rb +75 -0
- data/lib/jax/util.rb +3 -0
- data/lib/jax/version.rb +7 -8
- data/lib/jax.rb +23 -41
- data/spec/bin/jax_spec.rb +149 -0
- data/{lib/jax/generators/app/templates/app/models/.empty_directory → spec/fixtures/public/favicon.ico} +0 -0
- data/spec/fixtures/public/textures/brickwall.jpg +0 -0
- data/spec/fixtures/public/textures/jacks.jpg +0 -0
- data/spec/fixtures/public/textures/normal_map.jpg +0 -0
- data/spec/fixtures/public/textures/rock.png +0 -0
- data/spec/fixtures/public/textures/rock_normal.png +0 -0
- data/spec/fixtures/public/textures/rss.png +0 -0
- data/spec/generators/jax/application_generator_spec.rb +18 -0
- data/spec/generators/jax/controller_generator_spec.rb +102 -0
- data/spec/generators/jax/helper_generator_spec.rb +55 -0
- data/spec/generators/jax/install_generator_spec.rb +30 -0
- data/spec/generators/jax/jax_generator_spec.rb +21 -0
- data/spec/generators/jax/light_generator_spec.rb +27 -0
- data/spec/generators/jax/material_generator_spec.rb +62 -0
- data/spec/generators/jax/model_generator_spec.rb +72 -0
- data/spec/generators/jax/plugin_generator_spec.rb +143 -0
- data/spec/generators/jax/scaffold_generator_spec.rb +35 -0
- data/spec/generators/jax/shader_generator_spec.rb +37 -0
- data/spec/javascripts/helpers/jasmine_webgl_helper.js +13 -0
- data/{lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers → spec/javascripts/helpers}/jax_spec_environment_helper.js +7 -2
- data/{lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers → spec/javascripts/helpers}/jax_spec_helper.js +0 -0
- data/spec/javascripts/jax/builtin/meshes/cube_spec.js +10 -0
- data/spec/javascripts/jax/builtin/meshes/plane_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/quad_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/sphere_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/teapot_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/torus_spec.js +8 -0
- data/spec/javascripts/jax/compatibility_spec.js +46 -0
- data/spec/javascripts/jax/context_events_spec.js +212 -0
- data/spec/javascripts/jax/context_spec.js +305 -0
- data/spec/javascripts/jax/core/data_region_spec.js +118 -0
- data/spec/javascripts/jax/core/data_segment_spec.js +96 -0
- data/spec/javascripts/jax/core/delegation_spec.js +48 -0
- data/spec/javascripts/jax/core/events_spec.js +17 -0
- data/spec/javascripts/jax/core/glMatrix_extensions_spec.js +8 -0
- data/spec/javascripts/jax/core/helper_spec.js +61 -0
- data/spec/javascripts/jax/core/matrix_stack_spec.js +28 -0
- data/spec/javascripts/jax/core/utils_spec.js +275 -0
- data/spec/javascripts/jax/geometry/line_spec.js +20 -0
- data/spec/javascripts/jax/geometry/plane_spec.js +181 -0
- data/spec/javascripts/jax/geometry/triangle_spec.js +105 -0
- data/spec/javascripts/jax/mvc/controller_spec.js +156 -0
- data/spec/javascripts/jax/mvc/model_spec.js +93 -0
- data/spec/javascripts/jax/mvc/route_set_spec.js +49 -0
- data/spec/javascripts/jax/mvc/view_manager_spec.js +17 -0
- data/spec/javascripts/jax/noise_spec.js +50 -0
- data/spec/javascripts/jax/optimizations/material_limitations_spec.js +85 -0
- data/spec/javascripts/jax/optimizations/shaders/basic_spec.js +65 -0
- data/spec/javascripts/jax/prototype/extensions_spec.js +34 -0
- data/spec/javascripts/jax/webgl/camera_spec.js +237 -0
- data/spec/javascripts/jax/webgl/core/events_spec.js +47 -0
- data/spec/javascripts/jax/webgl/framebuffer_spec.js +44 -0
- data/spec/javascripts/jax/webgl/lighting_spec.js +108 -0
- data/spec/javascripts/jax/webgl/material_spec.js +117 -0
- data/spec/javascripts/jax/webgl/mesh_spec.js +228 -0
- data/spec/javascripts/jax/webgl/shader/manifest_spec.js +57 -0
- data/spec/javascripts/jax/webgl/shader_chain_spec.js +211 -0
- data/spec/javascripts/jax/webgl/shader_spec.js +276 -0
- data/spec/javascripts/jax/webgl/tangent_space_spec.js +142 -0
- data/spec/javascripts/jax/webgl/texture_spec.js +159 -0
- data/spec/javascripts/jax/webgl_spec.js +5 -0
- data/spec/javascripts/jax/world_spec.js +175 -0
- data/spec/javascripts/jax_spec.js +14 -0
- data/spec/javascripts/node/mocks/webgl.js +159 -0
- data/spec/javascripts/node_helper.js +51 -0
- data/spec/javascripts/shaders/core_materials_spec.js +38 -0
- data/spec/javascripts/shaders/fog_spec.js +15 -0
- data/spec/javascripts/shaders/lighting_spec.js +15 -0
- data/spec/javascripts/shaders/normal_map_spec.js +15 -0
- data/spec/javascripts/shaders/paraboloid_spec.js +33 -0
- data/spec/javascripts/shaders/preprocessor_spec.js +45 -0
- data/spec/javascripts/shaders/shadow_map_spec.js +15 -0
- data/spec/javascripts/shaders/texture_spec.js +37 -0
- data/spec/javascripts/suite/controller_select_spec.js.coffee +24 -0
- data/spec/lib/jax/commands/plugin_manager/credentials_spec.rb +56 -0
- data/spec/lib/jax/commands/plugin_manager/push_spec.rb +62 -0
- data/spec/lib/jax/commands/plugin_manager_spec.rb +204 -0
- data/spec/lib/jax/rails/application_spec.rb +23 -0
- data/spec/lib/jax/shader_spec.rb +67 -0
- data/spec/lib/jax/util/tar_spec.rb +26 -0
- data/spec/{test_helper.rb → spec_helper.rb} +37 -28
- data/spec/support/test_model_generator.rb +14 -0
- data/templates/app/Gemfile.tt +17 -0
- data/templates/app/Rakefile +4 -0
- data/templates/app/config/application.rb +16 -0
- data/{lib/jax/generators/app/templates → templates/app}/config/boot.rb +0 -0
- data/templates/app/config/environment.rb +5 -0
- data/templates/app/config/environments/production.rb +4 -0
- data/templates/app/config.ru +6 -0
- data/{lib/jax/generators/app/templates/app/resources → templates/app/public}/.empty_directory +0 -0
- data/templates/app/script/jax +8 -0
- data/{lib/jax/generators/app/templates/app/views → templates/app/spec}/.empty_directory +0 -0
- data/templates/application_controller.js.coffee.erb +3 -0
- data/templates/application_controller.js.erb +6 -0
- data/templates/application_helper.js.coffee.erb +3 -0
- data/templates/application_helper.js.erb +3 -0
- data/templates/controller.js.coffee.erb +9 -0
- data/templates/controller.js.erb +15 -0
- data/templates/controller_spec.js.coffee.erb +9 -0
- data/templates/controller_spec.js.erb +12 -0
- data/templates/helper.js.coffee.erb +2 -0
- data/templates/helper.js.erb +3 -0
- data/templates/helper_spec.js.coffee.erb +8 -0
- data/templates/helper_spec.js.erb +12 -0
- data/{lib/jax/generators/light_source/templates/light.yml.tt → templates/light_source.resource.erb} +3 -3
- data/{lib/jax/generators/material/templates/material.yml.tt → templates/material.resource.erb} +0 -9
- data/templates/model.js.coffee.erb +3 -0
- data/templates/model.js.erb +5 -0
- data/templates/model_defaults.resource.erb +5 -0
- data/templates/model_spec.js.coffee.erb +16 -0
- data/templates/model_spec.js.erb +18 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/controllers/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/helpers/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/models/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/resources/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/views/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates → templates}/new_plugin/init.rb +0 -0
- data/{lib/jax/generators/plugin/templates → templates}/new_plugin/install.rb +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/public → templates/new_plugin/spec}/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates → templates}/new_plugin/uninstall.rb +0 -0
- data/{lib/jax/generators/shader/templates/common.ejs.tt → templates/shader_common.glsl.erb} +0 -0
- data/{lib/jax/generators/shader/templates/fragment.ejs.tt → templates/shader_fragment.glsl.erb} +0 -0
- data/{lib/jax/generators/shader/templates/manifest.yml.tt → templates/shader_manifest.yml.erb} +0 -0
- data/templates/shader_material.js.coffee.erb +22 -0
- data/{lib/jax/generators/shader/templates/material.js.tt → templates/shader_material.js.erb} +0 -0
- data/templates/shader_spec.js.coffee.erb +16 -0
- data/{lib/jax/generators/shader/templates/spec.js.tt → templates/shader_spec.js.erb} +1 -1
- data/{lib/jax/generators/shader/templates/vertex.ejs.tt → templates/shader_vertex.glsl.erb} +0 -0
- data/templates/view.js.coffee.erb +3 -0
- data/{lib/jax/generators/controller/templates/view.js.tt → templates/view.js.erb} +1 -1
- data/vendor/assets/javascripts/ejs.js +505 -0
- data/vendor/assets/javascripts/glMatrix.js +1772 -0
- data/vendor/assets/javascripts/jasmine.js +2476 -0
- data/vendor/assets/stylesheets/jasmine.css +166 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/alias.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class_deprecated.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class_method.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class_property.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/constant.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/constructor.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/deprecated.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/description.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/information.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/instance_method.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/instance_property.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/method.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/method_deprecated.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/mixin.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/namespace.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/property.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/related_to.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/search-background.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/section-background.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/section.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/selected-section-background.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/subclass.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/superclass.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/utility.png +0 -0
- data/vendor/pdoc_template/html/assets/javascripts/pdoc/application.js +478 -0
- data/vendor/pdoc_template/html/assets/javascripts/pdoc/prototype.js +4874 -0
- data/vendor/pdoc_template/html/assets/javascripts/pdoc/tabs.js +506 -0
- data/vendor/pdoc_template/html/assets/stylesheets/jax.css +30 -0
- data/vendor/pdoc_template/html/assets/stylesheets/pdoc/api.css +681 -0
- data/vendor/pdoc_template/html/assets/stylesheets/pdoc/pygments.css +62 -0
- data/vendor/pdoc_template/html/helpers.rb +35 -0
- data/vendor/pdoc_template/html/index.erb +18 -0
- data/vendor/pdoc_template/html/item_index.js.erb +6 -0
- data/vendor/pdoc_template/html/layout.erb +67 -0
- data/vendor/pdoc_template/html/leaf.erb +22 -0
- data/vendor/pdoc_template/html/node.erb +30 -0
- data/vendor/pdoc_template/html/partials/class_relationships.erb +19 -0
- data/vendor/pdoc_template/html/partials/classes.erb +7 -0
- data/vendor/pdoc_template/html/partials/constructor.erb +5 -0
- data/vendor/pdoc_template/html/partials/description.erb +5 -0
- data/vendor/pdoc_template/html/partials/link_list.erb +1 -0
- data/vendor/pdoc_template/html/partials/method_signatures.erb +14 -0
- data/vendor/pdoc_template/html/partials/methodized_note.erb +9 -0
- data/vendor/pdoc_template/html/partials/mixins.erb +7 -0
- data/vendor/pdoc_template/html/partials/namespaces.erb +7 -0
- data/vendor/pdoc_template/html/partials/related_utilities.erb +5 -0
- data/vendor/pdoc_template/html/partials/relationships.erb +11 -0
- data/vendor/pdoc_template/html/partials/short_description_list.erb +7 -0
- data/vendor/pdoc_template/html/partials/title.erb +24 -0
- data/vendor/pdoc_template/html/section.erb +18 -0
- metadata +635 -332
- data/builtin/app/shaders/lighting/common.ejs +0 -5
- data/builtin/app/shaders/normal_map/material.js +0 -16
- data/builtin/app/shaders/texture/material.js +0 -18
- data/jax.gems +0 -1
- data/lib/jax/application/builtin/configurable.rb +0 -5
- data/lib/jax/application/builtin/configuration.rb +0 -5
- data/lib/jax/application/builtin.rb +0 -12
- data/lib/jax/application/configurable.rb +0 -19
- data/lib/jax/application/configuration.rb +0 -60
- data/lib/jax/application/railties.rb +0 -26
- data/lib/jax/application.rb +0 -149
- data/lib/jax/core_ext/kernel.rb +0 -7
- data/lib/jax/engine/configurable.rb +0 -19
- data/lib/jax/engine/configuration.rb +0 -49
- data/lib/jax/generators/app/app_generator.rb +0 -96
- data/lib/jax/generators/app/templates/Gemfile.tt +0 -3
- data/lib/jax/generators/app/templates/Rakefile +0 -6
- data/lib/jax/generators/app/templates/app/controllers/application_controller.js.tt +0 -5
- data/lib/jax/generators/app/templates/app/helpers/application_helper.js.tt +0 -3
- data/lib/jax/generators/app/templates/config/application.rb.tt +0 -6
- data/lib/jax/generators/app/templates/config/environment.rb.tt +0 -5
- data/lib/jax/generators/app/templates/config/routes.rb.tt +0 -5
- data/lib/jax/generators/app/templates/public/index.html.tt +0 -26
- data/lib/jax/generators/app/templates/public/javascripts/jax.js +0 -9462
- data/lib/jax/generators/app/templates/public/stylesheets/%file_name%.css.tt +0 -11
- data/lib/jax/generators/app/templates/public/webgl_not_supported.html +0 -26
- data/lib/jax/generators/app/templates/script/jax +0 -7
- data/lib/jax/generators/app/templates/spec/javascripts/controllers/application_controller_spec.js +0 -11
- data/lib/jax/generators/app/templates/spec/javascripts/helpers/application_helper_spec.js +0 -12
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine.yml +0 -91
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_config.rb +0 -23
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_runner.rb +0 -32
- data/lib/jax/generators/app/templates/spec/javascripts/support/spec_layout.html.erb +0 -104
- data/lib/jax/generators/app.rb +0 -18
- data/lib/jax/generators/commands.rb +0 -220
- data/lib/jax/generators/controller/USAGE +0 -9
- data/lib/jax/generators/controller/controller_generator.rb +0 -66
- data/lib/jax/generators/controller/templates/controller_source.js.tt +0 -16
- data/lib/jax/generators/controller/templates/controller_test.js.tt +0 -11
- data/lib/jax/generators/controller/templates/helper.js.tt +0 -3
- data/lib/jax/generators/controller/templates/helper_test.js.tt +0 -12
- data/lib/jax/generators/interactions.rb +0 -56
- data/lib/jax/generators/light_source/USAGE +0 -14
- data/lib/jax/generators/light_source/light_source_generator.rb +0 -46
- data/lib/jax/generators/material/material_generator.rb +0 -80
- data/lib/jax/generators/material/templates/append.yml.tt +0 -7
- data/lib/jax/generators/model/USAGE +0 -5
- data/lib/jax/generators/model/model_generator.rb +0 -40
- data/lib/jax/generators/model/templates/model.js.tt +0 -11
- data/lib/jax/generators/model/templates/test.js.tt +0 -11
- data/lib/jax/generators/packager/package_generator.rb +0 -32
- data/lib/jax/generators/plugin/USAGE +0 -4
- data/lib/jax/generators/plugin/all.rb +0 -113
- data/lib/jax/generators/plugin/credentials.rb +0 -108
- data/lib/jax/generators/plugin/plugin_generator.rb +0 -72
- data/lib/jax/generators/plugin/plugin_manager.rb +0 -254
- data/lib/jax/generators/plugin/templates/new_plugin/config/routes.rb +0 -3
- data/lib/jax/generators/plugin/templates/new_plugin/spec/.empty_directory +0 -0
- data/lib/jax/generators/script_jax_loader.rb +0 -49
- data/lib/jax/generators/shader/USAGE +0 -4
- data/lib/jax/generators/shader/shader_generator.rb +0 -70
- data/lib/jax/monkeypatch/jasmine/config.rb +0 -45
- data/lib/jax/monkeypatch/jasmine/server.rb +0 -50
- data/lib/jax/monkeypatch/jasmine.rb +0 -3
- data/lib/jax/packager/sprockets_template.rb +0 -77
- data/lib/jax/packager.rb +0 -59
- data/lib/jax/plugin/manifest.rb +0 -71
- data/lib/jax/plugin.rb +0 -49
- data/lib/jax/resource_compiler.rb +0 -60
- data/lib/jax/routes.rb +0 -62
- data/lib/jax/tasks/rake.rb +0 -38
- data/spec/benchmark.htm +0 -93
- data/spec/generators/app_generator_test.rb +0 -42
- data/spec/generators/controller_generator_test.rb +0 -47
- data/spec/generators/light_generator_test.rb +0 -37
- data/spec/generators/material_generator_test.rb +0 -22
- data/spec/generators/model_generator_test.rb +0 -26
- data/spec/generators/plugin_generator_test.rb +0 -114
- data/spec/generators/plugin_manager/push_test.rb +0 -59
- data/spec/generators/plugin_manager_test.rb +0 -192
- data/spec/generators/shader_generator_test.rb +0 -38
- data/spec/javascripts/support/jasmine.yml +0 -85
- data/spec/javascripts/support/jasmine_runner.rb +0 -32
- data/spec/lib/jax/application_test.rb +0 -18
- data/spec/lib/jax/generators/plugin/credentials_test.rb +0 -72
- data/spec/lib/jax/packager_test.rb +0 -87
- data/spec/lib/jax/plugin_test.rb +0 -27
- data/spec/lib/jax/reloading_test.rb +0 -23
- data/spec/lib/jax/routes_test.rb +0 -28
- data/spec/lib/jax/shader_test.rb +0 -29
- data/spec/lib/jax/tasks/jax_rake_test.rb +0 -85
- data/spec/support/bases/generator_test_case.rb +0 -108
- data/spec/support/bases/isolated_test_case.rb +0 -148
- data/spec/support/file_exist_matcher.rb +0 -23
- data/spec/support/spec_shell.rb +0 -110
- data/spec/test_app.rb +0 -3
data/lib/jax/shader.rb
CHANGED
@@ -1,185 +1,83 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@name = name
|
8
|
-
@path = path
|
9
|
-
|
10
|
-
detect_sources
|
11
|
-
end
|
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
|
-
|
28
|
-
def description
|
29
|
-
manifest && manifest['description']
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_s
|
33
|
-
"Jax.shaders['#{name}'] = new Jax.Shader(#{js_options.gsub(/<%/, '<%')});"
|
34
|
-
end
|
35
|
-
|
36
|
-
def default_options
|
37
|
-
manifest && manifest['options'] || {}
|
38
|
-
end
|
39
|
-
|
40
|
-
def save_to(file_or_filename)
|
41
|
-
if file_or_filename.kind_of?(String)
|
42
|
-
File.open(filename, "w") { |f| f.puts to_s }
|
43
|
-
else file_or_filename.puts to_s
|
1
|
+
require 'sprockets'
|
2
|
+
|
3
|
+
module Jax
|
4
|
+
class Shader < Sprockets::DirectiveProcessor
|
5
|
+
def self.default_mime_type
|
6
|
+
"application/javascript"
|
44
7
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def from(path)
|
49
|
-
raise ArgumentError, "Expected path to be a directory" unless File.directory? path
|
50
|
-
new(path)
|
8
|
+
|
9
|
+
def exports
|
10
|
+
@exports ||= {}
|
51
11
|
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def common=(str)
|
55
|
-
@common = preprocess(str).inspect
|
56
|
-
end
|
57
|
-
|
58
|
-
def fragment=(str)
|
59
|
-
@fragment = preprocess(str).inspect
|
60
|
-
end
|
61
|
-
|
62
|
-
def vertex=(str)
|
63
|
-
@vertex = preprocess(str).inspect
|
64
|
-
end
|
65
|
-
|
66
|
-
def preprocess(str)
|
67
|
-
include_dependencies str
|
68
|
-
intercept_export_directives str
|
69
|
-
# intercept_import_directives str
|
70
|
-
# prepend_export_definitions str
|
71
12
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
def detect_manifest
|
82
|
-
if File.file?(file = File.join(path, "manifest.yml"))
|
83
|
-
yml = YAML::load(File.read(file))
|
84
|
-
@manifest = yml || {}
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def detect_ejs
|
89
|
-
%w(common fragment vertex).each do |name|
|
90
|
-
if File.file?(file = File.join(path, "#{name}.ejs"))
|
91
|
-
send("#{name}=", File.read(file))
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def intercept_import_directives(str)
|
97
|
-
str.gsub! /import\s*\(\s*([^\s]*)\s*\)/ do
|
98
|
-
export_name($~[1])
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def prepend_export_definitions(str)
|
103
|
-
exports.each do |name, export|
|
104
|
-
str.insert 0, "#{export[:type]} #{name};\n"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def intercept_export_directives(str)
|
109
|
-
intercept_export_directives_with_assignment(str)
|
110
|
-
intercept_export_directives_without_assignment(str)
|
111
|
-
end
|
112
|
-
|
113
|
-
def intercept_export_directives_without_assignment(str)
|
114
|
-
str.gsub! /export\s*\(\s*([^\s]*),\s*([^\s]*)\s*\);?/ do |match|
|
115
|
-
export $~[1], $~[2]
|
116
|
-
match # we'll do the rest on the JS side
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def intercept_export_directives_with_assignment(str)
|
121
|
-
str.gsub! /export\s*\(\s*([^\s]*),\s*([^\s]*),\s*([^\s]*)\s*\);?/ do |match|
|
122
|
-
export $~[1], $~[2], $~[3]
|
123
|
-
match # we'll do the rest on the JS side
|
13
|
+
def process_require_directive(path)
|
14
|
+
super
|
15
|
+
|
16
|
+
# FIXME this is kind of a hacky solution to get function bodies included.
|
17
|
+
# Should shaders be rewritten entirely, including the JS APIs?
|
18
|
+
shader_name, shader_type = shader_type_and_name_for_path(path)
|
19
|
+
|
20
|
+
str = "<%= Jax.import_shader_code(#{shader_name.inspect}, #{shader_type.inspect}) %>\n"
|
21
|
+
body.insert 0, str unless body[str]
|
124
22
|
end
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
def include_dependencies(str)
|
133
|
-
# look for Sprockets-style require directives
|
134
|
-
str.gsub! /\/\/=\s*require\s*['"]([^'"]*)['"]/m do |sub|
|
135
|
-
filename = $~[1]
|
136
|
-
found = false
|
137
|
-
paths = Jax.shader_load_paths
|
138
|
-
result = nil
|
139
|
-
for path in paths
|
140
|
-
if File.file?(real = File.join(path, "#{filename}.ejs"))
|
141
|
-
found = true
|
142
|
-
macro_name = "dependency_#{filename}".underscore.gsub(/[^a-zA-Z0-9_]/, '_')
|
143
|
-
result = <<-end_code
|
144
|
-
#ifndef #{macro_name}
|
145
|
-
#define #{macro_name}
|
23
|
+
|
24
|
+
def evaluate(context, locals, &block)
|
25
|
+
body = super
|
26
|
+
body = process_exports(body)
|
27
|
+
|
28
|
+
shader_name, shader_type = shader_type_and_name_for_path
|
146
29
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
30
|
+
result = "Jax.shader_data(#{shader_name.inspect})[#{shader_type.inspect}] = #{body.inspect};\n"
|
31
|
+
unless exports.empty?
|
32
|
+
exports_var = "Jax.shader_data(#{shader_name.inspect})[\"exports\"]"
|
33
|
+
exports_str = "#{exports_var} = #{exports_var} || {};\n"
|
34
|
+
exports.each do |name, type|
|
35
|
+
exports_str+= "#{exports_var}[#{name.inspect}] = #{type.inspect};\n"
|
151
36
|
end
|
37
|
+
result.insert 0, exports_str
|
152
38
|
end
|
153
|
-
|
154
|
-
raise "Required file '#{filename}.ejs' not found in load paths #{paths.inspect} for shader '#{name}'!" if !found
|
155
39
|
result
|
156
40
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
%w(common fragment vertex).each do |segment|
|
174
|
-
data = send segment
|
175
|
-
if data
|
176
|
-
result += " #{segment}:#{data},\n"
|
41
|
+
|
42
|
+
def process_exports(body, rx = nil)
|
43
|
+
if rx
|
44
|
+
body.scan(rx).uniq.each do |export|
|
45
|
+
# scan gets us mostly there, but we still need the arguments.
|
46
|
+
export =~ rx
|
47
|
+
type = $~[1]
|
48
|
+
name = $~[2]
|
49
|
+
value = $~[3]
|
50
|
+
exports[name] = type
|
51
|
+
# we may use type later, when we start actively generating the export code.
|
52
|
+
# Currently, that's done in JS.
|
53
|
+
end
|
54
|
+
body
|
55
|
+
else
|
56
|
+
process_exports_without_assignment(process_exports_with_assignment(body))
|
177
57
|
end
|
178
58
|
end
|
179
|
-
result += "exports: #{export_keys_as_js},\n"
|
180
|
-
result += "name: #{name.inspect}"
|
181
|
-
result += "}"
|
182
59
|
|
183
|
-
|
60
|
+
def process_exports_without_assignment(body)
|
61
|
+
process_exports body, /export\s*\(\s*([^\s]*),\s*([^\s]*)\s*\);?/
|
62
|
+
end
|
63
|
+
|
64
|
+
def process_exports_with_assignment(body)
|
65
|
+
process_exports body, /export\s*\(\s*([^\s]*),\s*([^\s]*),\s*([^\)]*)\);?/
|
66
|
+
end
|
67
|
+
|
68
|
+
def shader_type_and_name_for_path(path = nil)
|
69
|
+
if path.nil?
|
70
|
+
logical_path = context.logical_path
|
71
|
+
else
|
72
|
+
logical_path = context.environment.attributes_for(context.resolve path).logical_path
|
73
|
+
end
|
74
|
+
shader_name = File.basename(File.dirname(logical_path))
|
75
|
+
shader_type = File.basename(logical_path)
|
76
|
+
if (shader_type =~ /\.[^\.]+$/)
|
77
|
+
shader_type = $`
|
78
|
+
end
|
79
|
+
|
80
|
+
[shader_name, shader_type]
|
81
|
+
end
|
184
82
|
end
|
185
|
-
end
|
83
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Jax
|
2
|
+
module Testing
|
3
|
+
# Set up a subclass of Rails::Application and set `config.root` to a temporary
|
4
|
+
# path prior to calling #setup_rails_environment.
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
# include Jax::Testing::RailsEnvironment
|
8
|
+
#
|
9
|
+
# setup do
|
10
|
+
# setup_rails_environment
|
11
|
+
#
|
12
|
+
# create_file "app/assets/jax/resources/people/default.resource" do |f|
|
13
|
+
# f.puts "name: Colin"
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# create_file "version", "1.0.0"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
module RailsEnvironment
|
20
|
+
# WARNING: Set Rails.application.config.root to some temporary directory name
|
21
|
+
# before calling this method! This method deletes the Rails root in order to set
|
22
|
+
# up the fixture for the next test run.
|
23
|
+
def setup_rails_environment
|
24
|
+
root = ::Rails.root.to_s
|
25
|
+
|
26
|
+
create_empty_directory root
|
27
|
+
create_directory 'app/assets' # required for Rails to pick up assets paths
|
28
|
+
create_file "config/routes.rb" do |f|
|
29
|
+
f.puts "Rails.application.routes.draw do\nend"
|
30
|
+
end
|
31
|
+
|
32
|
+
Jax.reset_config!
|
33
|
+
end
|
34
|
+
|
35
|
+
def local(path)
|
36
|
+
path =~ /^#{Regexp::escape ::Rails.root.to_s}/ ? path : ::Rails.root.join(path).to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_empty_directory dir
|
40
|
+
FileUtils.rm_rf local(dir)
|
41
|
+
create_directory dir
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_directory(dir)
|
45
|
+
FileUtils.mkdir_p local(dir)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_file(file, content = nil)
|
49
|
+
create_directory File.dirname(file)
|
50
|
+
File.open(local(file), "w") do |f|
|
51
|
+
f.puts content if content
|
52
|
+
yield f if block_given?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_asset(file, content = nil, &block)
|
57
|
+
create_file File.join("app/assets/jax", file), content, &block
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_shader(path, contents = {})
|
61
|
+
create_asset File.join("shaders", path, "common.glsl"), contents[:common] if contents[:common]
|
62
|
+
create_asset File.join("shaders", path, "fragment.glsl"), contents[:fragment] if contents[:fragment]
|
63
|
+
create_asset File.join("shaders", path, "vertex.glsl"), contents[:vertex] if contents[:vertex]
|
64
|
+
end
|
65
|
+
|
66
|
+
def assets
|
67
|
+
::Rails.application.assets
|
68
|
+
end
|
69
|
+
|
70
|
+
def asset(path)
|
71
|
+
asset = assets.find_asset(path)
|
72
|
+
raise "asset not found: #{path} in #{@asset_dir}" unless asset
|
73
|
+
asset.body
|
74
|
+
end
|
75
|
+
|
76
|
+
def append_to_file(file, content = nil, &block)
|
77
|
+
if File.file?(local file)
|
78
|
+
File.open(local(file), "w+") do |f|
|
79
|
+
f.puts content if content
|
80
|
+
yield f if block_given?
|
81
|
+
end
|
82
|
+
else
|
83
|
+
create_file(file, content, &block)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def route(content)
|
88
|
+
append_to_file "config/routes.rb" # create it if missing
|
89
|
+
routes = File.read(local "config/routes.rb")
|
90
|
+
create_file("config/routes.rb", routes.sub(/Rails.application.routes.draw do$/, "\\1#{content}"))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/jax/util/tar.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/package'
|
3
|
+
require 'zlib'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module Jax::Util::Tar
|
7
|
+
# Creates a tar file in memory recursively
|
8
|
+
# from the given path.
|
9
|
+
#
|
10
|
+
# Returns a StringIO whose underlying String
|
11
|
+
# is the contents of the tar file.
|
12
|
+
def tar(path)
|
13
|
+
tarfile = StringIO.new("")
|
14
|
+
Gem::Package::TarWriter.new(tarfile) do |tar|
|
15
|
+
Dir[File.join(path, "**/*")].each do |file|
|
16
|
+
mode = File.stat(file).mode
|
17
|
+
relative_file = file.sub /^#{Regexp::escape path}\/?/, ''
|
18
|
+
|
19
|
+
if File.directory?(file)
|
20
|
+
tar.mkdir relative_file, mode
|
21
|
+
else
|
22
|
+
tar.add_file relative_file, mode do |tf|
|
23
|
+
File.open(file, "rb") { |f| tf.write f.read }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
tarfile.rewind
|
30
|
+
tarfile
|
31
|
+
end
|
32
|
+
|
33
|
+
# gzips the underlying string in the given StringIO,
|
34
|
+
# returning a new StringIO representing the
|
35
|
+
# compressed file.
|
36
|
+
def gzip(tarfile)
|
37
|
+
gz = StringIO.new("")
|
38
|
+
z = Zlib::GzipWriter.new(gz)
|
39
|
+
z.write tarfile.string
|
40
|
+
z.close # this is necessary!
|
41
|
+
|
42
|
+
# z was closed to write the gzip footer, so
|
43
|
+
# now we need a new StringIO
|
44
|
+
StringIO.new gz.string
|
45
|
+
end
|
46
|
+
|
47
|
+
# un-gzips the given IO, returning the
|
48
|
+
# decompressed version as a StringIO
|
49
|
+
def ungzip(tarfile)
|
50
|
+
z = Zlib::GzipReader.new(tarfile)
|
51
|
+
unzipped = StringIO.new(z.read)
|
52
|
+
z.close
|
53
|
+
unzipped
|
54
|
+
end
|
55
|
+
|
56
|
+
# untars the given IO into the specified
|
57
|
+
# directory
|
58
|
+
def untar(io, destination)
|
59
|
+
Gem::Package::TarReader.new io do |tar|
|
60
|
+
tar.each do |tarfile|
|
61
|
+
destination_file = File.join destination, tarfile.full_name
|
62
|
+
|
63
|
+
if tarfile.directory?
|
64
|
+
FileUtils.mkdir_p destination_file
|
65
|
+
else
|
66
|
+
destination_directory = File.dirname(destination_file)
|
67
|
+
FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)
|
68
|
+
File.open destination_file, "wb" do |f|
|
69
|
+
f.print tarfile.read
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/jax/util.rb
ADDED
data/lib/jax/version.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Jax
|
2
2
|
module Version
|
3
|
-
MAJOR
|
4
|
-
MINOR
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
STRING = PREREL ? "#{MAJOR}.#{MINOR}.#{TINY}.#{PREREL}" : "#{MAJOR}.#{MINOR}.#{TINY}"
|
3
|
+
MAJOR = 2
|
4
|
+
MINOR = 0
|
5
|
+
PATCH = 0
|
6
|
+
BUILD = nil
|
7
|
+
STRING = BUILD ? [MAJOR, MINOR, PATCH, BUILD].join(".") : [MAJOR, MINOR, PATCH].join(".")
|
9
8
|
end
|
10
|
-
|
11
|
-
VERSION = Version::STRING
|
9
|
+
|
10
|
+
VERSION = Jax::Version::STRING
|
12
11
|
end
|
data/lib/jax.rb
CHANGED
@@ -1,46 +1,28 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
5
|
-
# Don't raise an error when we extend Jax::Engine or Jax::Application
|
6
|
-
Rails::Railtie::ABSTRACT_RAILTIES << "Jax::Engine" << "Jax::Application"
|
7
|
-
|
8
|
-
JAX_FRAMEWORK_ROOT = File.expand_path('.', File.dirname(__FILE__)) unless defined?(JAX_FRAMEWORK_ROOT)
|
1
|
+
require 'rails'
|
2
|
+
require 'jquery/rails'
|
3
|
+
require 'jax/engine'
|
9
4
|
|
10
5
|
module Jax
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
18
|
-
autoload :
|
19
|
-
autoload :
|
20
|
-
autoload :
|
6
|
+
autoload :Commands, "jax/commands"
|
7
|
+
autoload :Configuration, "jax/configuration"
|
8
|
+
autoload :DirectiveProcessor, "jax/directive_processor"
|
9
|
+
autoload :Generators, "generators/jax/all"
|
10
|
+
autoload :HelperMethods, "jax/helper_methods"
|
11
|
+
autoload :ResourceFile, "jax/resource_file"
|
12
|
+
autoload :Server, "jax/server"
|
13
|
+
autoload :Shader, "jax/shader"
|
14
|
+
autoload :Version, "jax/version"
|
15
|
+
autoload :VERSION, "jax/version"
|
16
|
+
autoload :PluginManager, "jax/commands/plugin_manager"
|
17
|
+
autoload :Util, "jax/util"
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
def root
|
32
|
-
application && application.root
|
33
|
-
end
|
34
|
-
|
35
|
-
def framework_root
|
36
|
-
JAX_FRAMEWORK_ROOT
|
37
|
-
end
|
38
|
-
|
39
|
-
delegate :shader_load_paths, :javascript_load_paths, :plugin_repository_url, :default_plugin_repository_url,
|
40
|
-
:plugin_repository_url=, :to => :application
|
19
|
+
module_function
|
20
|
+
|
21
|
+
def config
|
22
|
+
@config || reset_config!
|
23
|
+
end
|
24
|
+
|
25
|
+
def reset_config!
|
26
|
+
@config = Jax::Configuration.new
|
41
27
|
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if defined?(APP_PATH) && Jax.application.nil?
|
45
|
-
require APP_PATH
|
46
28
|
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
base_dir = File.expand_path '../..', File.dirname(__FILE__)
|
4
|
+
|
5
|
+
class AppFailure < RuntimeError
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'bin/jax' do
|
9
|
+
before :each do
|
10
|
+
FileUtils.rm_rf File.join(base_dir, "tmp/jax-bin")
|
11
|
+
FileUtils.mkdir_p File.join(base_dir, "tmp/jax-bin")
|
12
|
+
FileUtils.chdir File.join(base_dir, "tmp/jax-bin")
|
13
|
+
@args = []
|
14
|
+
end
|
15
|
+
|
16
|
+
subject do
|
17
|
+
jax = File.join base_dir, "bin/jax"
|
18
|
+
result = %x[#{jax} #{@args.join(' ')} 2>&1]
|
19
|
+
if $?.success?
|
20
|
+
result
|
21
|
+
else
|
22
|
+
raise AppFailure, result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def subject_with_rescue
|
27
|
+
@subject ||= subject
|
28
|
+
rescue AppFailure => err
|
29
|
+
@subject = err.message
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "in a rails application" do
|
33
|
+
before :each do
|
34
|
+
FileUtils.mkdir_p "script"
|
35
|
+
FileUtils.mkdir_p "config"
|
36
|
+
File.open "config/application.rb", "w" do |f|
|
37
|
+
f.puts "require 'rails/all'"
|
38
|
+
f.puts "class TmpApp < Rails::Application"
|
39
|
+
f.puts " config.active_support.deprecation = :log"
|
40
|
+
f.puts "end"
|
41
|
+
end
|
42
|
+
File.open "config/environment.rb", "w" do |f|
|
43
|
+
f.puts "require File.expand_path('application', File.dirname(__FILE__))"
|
44
|
+
f.puts "::Rails.application.initialize!"
|
45
|
+
end
|
46
|
+
File.open "script/rails", "w" do |f|
|
47
|
+
f.puts "APP_PATH = File.expand_path('../../config/application', __FILE__)"
|
48
|
+
f.puts "require 'rails/commands'"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
shared_examples_for 'rails app' do
|
53
|
+
it "should give usage" do
|
54
|
+
subject_with_rescue.should =~ /Usage:/
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should invoke `rails g jax` generator" do
|
58
|
+
@args.push "generate"
|
59
|
+
subject_with_rescue.should =~ /You can invoke the following Jax generators:/
|
60
|
+
subject_with_rescue.should =~ /rails generate jax:controller/
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should invoke plugin manager" do
|
65
|
+
@args.push "plugin"
|
66
|
+
subject.should =~ /jax plugin install/
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should revoke generators with destroy" do
|
70
|
+
@args.push "destroy", "controller", "welcome"
|
71
|
+
subject.should match(/remove/)
|
72
|
+
subject.should_not match(/app\/views\/jax\/welcome/)
|
73
|
+
subject.should match(/app\/assets\/jax\/controllers\/welcome_controller.js.coffee/)
|
74
|
+
end
|
75
|
+
|
76
|
+
it_should_behave_like 'rails app'
|
77
|
+
|
78
|
+
describe "subdirectory" do
|
79
|
+
before :each do
|
80
|
+
FileUtils.chdir "script"
|
81
|
+
end
|
82
|
+
|
83
|
+
it_should_behave_like 'rails app'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "in a jax application" do
|
88
|
+
before(:each) do
|
89
|
+
Jax::Generators::ApplicationGenerator.start ["test_app", "--skip-bundle"], :shell => GenSpec::Shell.new
|
90
|
+
FileUtils.chdir "test_app"
|
91
|
+
end
|
92
|
+
|
93
|
+
shared_examples_for 'jax app' do
|
94
|
+
it "should give usage" do
|
95
|
+
subject_with_rescue.should =~ /Usage:/
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should invoke `jax g` generator" do
|
99
|
+
@args.push "generate"
|
100
|
+
subject_with_rescue.should =~ /You can invoke the following Jax generators:/
|
101
|
+
subject_with_rescue.should =~ /jax generate controller/
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should invoke plugin manager" do
|
106
|
+
@args.push "plugin"
|
107
|
+
subject.should =~ /jax plugin install/
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should revoke generators with destroy" do
|
111
|
+
@args.push "destroy", "controller", "welcome"
|
112
|
+
subject.should match(/remove/)
|
113
|
+
subject.should_not match(/app\/views\/jax\/welcome/)
|
114
|
+
subject.should match(/app\/assets\/jax\/controllers\/welcome_controller.js.coffee/)
|
115
|
+
end
|
116
|
+
|
117
|
+
it_should_behave_like 'jax app'
|
118
|
+
|
119
|
+
describe "subdirectory" do
|
120
|
+
before :each do
|
121
|
+
FileUtils.chdir "script"
|
122
|
+
end
|
123
|
+
|
124
|
+
it_should_behave_like 'jax app'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'not in any application' do
|
129
|
+
describe "creating a new jax app" do
|
130
|
+
before :each do
|
131
|
+
@args << 'new' << 'testapp' << '--skip-bundle'
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should create a new jax application" do
|
135
|
+
subject.should_not =~ /Not in a Jax or Rails application\./
|
136
|
+
subject.should =~ /create(\e\[0m|)\s*testapp/
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should not invoke plugin manager" do
|
141
|
+
@args.push "plugin"
|
142
|
+
subject_with_rescue.should_not =~ /jax plugin install/
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should output a friendly help message" do
|
146
|
+
subject_with_rescue.should =~ /Not in a Jax or Rails application\./
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|