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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/jax.gems
CHANGED
@@ -1 +1 @@
|
|
1
|
-
bundler -v1.0.
|
1
|
+
bundler -v1.0.14
|
data/jax.gemspec
CHANGED
@@ -12,19 +12,21 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{Framework for creating rich WebGL-enabled applications using JavaScript and Ruby}
|
13
13
|
s.description = %q{Framework for creating rich WebGL-enabled applications using JavaScript and Ruby}
|
14
14
|
|
15
|
-
s.add_dependency 'rake', '~> 0.
|
16
|
-
s.add_dependency 'bundler', '~> 1.0.
|
15
|
+
s.add_dependency 'rake', '~> 0.9.2'
|
16
|
+
s.add_dependency 'bundler', '~> 1.0.15'
|
17
17
|
s.add_dependency "thor", '~> 0.14.6'
|
18
18
|
s.add_dependency 'jasmine', '~> 1.0.2.0'
|
19
|
-
s.add_dependency '
|
20
|
-
s.add_dependency "i18n", '~> 0.5.0' # FIXME Jax doesn't really require this but ActiveSupport won't load without it!
|
19
|
+
s.add_dependency 'railties', '~> 3.0.8'
|
21
20
|
s.add_dependency 'sprockets', '~> 1.0.2'
|
21
|
+
s.add_dependency 'rest-client', '~> 1.6.3'
|
22
|
+
s.add_dependency 'minitar', '~> 0.5.3'
|
22
23
|
|
23
|
-
s.add_development_dependency 'rspec', '~> 2.0'
|
24
24
|
s.add_development_dependency 'coderay', '~> 0.9.7'
|
25
|
-
|
25
|
+
s.add_development_dependency 'fakeweb', '~> 1.3.0'
|
26
|
+
s.add_development_dependency 'ansi'
|
27
|
+
s.add_development_dependency 'turn'
|
28
|
+
|
26
29
|
# required by guides
|
27
|
-
s.add_development_dependency 'actionpack', '~> 3.0'
|
28
30
|
s.add_development_dependency 'RedCloth', '~> 4.2'
|
29
31
|
s.add_development_dependency 'w3c_validators', '~> 1.1.1'
|
30
32
|
|
data/lib/jax.rb
CHANGED
@@ -1,14 +1,23 @@
|
|
1
1
|
require "active_support/core_ext"
|
2
|
+
require "rails/railtie"
|
3
|
+
require File.expand_path("jax/core_ext/kernel", File.dirname(__FILE__))
|
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)
|
2
9
|
|
3
10
|
module Jax
|
4
|
-
autoload :
|
5
|
-
autoload :
|
6
|
-
autoload :
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
11
|
-
autoload :
|
11
|
+
autoload :Engine, "jax/engine"
|
12
|
+
autoload :Generators, "jax/generators/commands"
|
13
|
+
autoload :VERSION, "jax/version"
|
14
|
+
autoload :Version, "jax/version"
|
15
|
+
autoload :Application, "jax/application"
|
16
|
+
autoload :Packager, "jax/packager"
|
17
|
+
autoload :ResourceCompiler, "jax/resource_compiler"
|
18
|
+
autoload :Routes, "jax/routes"
|
19
|
+
autoload :Shader, "jax/shader"
|
20
|
+
autoload :Plugin, "jax/plugin"
|
12
21
|
|
13
22
|
class << self
|
14
23
|
def application
|
@@ -23,7 +32,12 @@ module Jax
|
|
23
32
|
application && application.root
|
24
33
|
end
|
25
34
|
|
26
|
-
|
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
|
27
41
|
end
|
28
42
|
end
|
29
43
|
|
data/lib/jax/application.rb
CHANGED
@@ -1,91 +1,149 @@
|
|
1
1
|
module Jax
|
2
|
-
class Application
|
2
|
+
class Application < Jax::Engine
|
3
|
+
autoload :Configurable, "jax/application/configurable"
|
3
4
|
autoload :Configuration, "jax/application/configuration"
|
5
|
+
autoload :Railties, "jax/application/railties"
|
4
6
|
|
5
7
|
class << self
|
8
|
+
private :new
|
9
|
+
|
10
|
+
def configure(&block)
|
11
|
+
class_eval(&block)
|
12
|
+
end
|
13
|
+
|
6
14
|
def inherited(base)
|
7
15
|
raise "You cannot have more than one Jax::Application" if Jax.application
|
8
16
|
super
|
9
|
-
|
10
|
-
base.called_from = begin
|
11
|
-
# Remove the line number from backtraces making sure we don't leave anything behind
|
12
|
-
call_stack = caller.map { |p| p.sub(/:\d+.*/, '') }
|
13
|
-
File.dirname(call_stack.detect { |p| p !~ %r[jax[\w.-]*/lib/jax] })
|
14
|
-
end
|
15
|
-
|
16
|
-
Jax.application = base.instance
|
17
|
-
Jax.application.config.root ||= Jax.application.find_root_with_flag("app")
|
18
|
-
end
|
19
17
|
|
20
|
-
|
21
|
-
@config ||= Jax::Application::Configuration.new
|
18
|
+
Jax.application = base.instance
|
22
19
|
end
|
23
|
-
|
20
|
+
|
24
21
|
def instance
|
25
|
-
|
22
|
+
@@instance ||= new
|
26
23
|
end
|
27
24
|
|
28
|
-
def
|
29
|
-
|
25
|
+
def routes
|
26
|
+
Jax.application.config.routes
|
30
27
|
end
|
31
|
-
|
32
|
-
def
|
33
|
-
|
28
|
+
|
29
|
+
def respond_to?(*args)
|
30
|
+
super || instance.respond_to?(*args)
|
34
31
|
end
|
35
32
|
|
36
|
-
def
|
37
|
-
|
33
|
+
def initialize!
|
34
|
+
# return silently because we may have to call initialize automatically.
|
35
|
+
# Jax prior to v1.1.0 didn't call #initialize! during boot.
|
36
|
+
return self if @initialized
|
37
|
+
@initialized = true
|
38
|
+
run_initializers(self)
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def method_missing(*args, &block)
|
45
|
+
instance.send(*args, &block)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
delegate :plugins, :to => :railties
|
50
|
+
|
51
|
+
def railties
|
52
|
+
@railties ||= Jax::Application::Railties.new(config)
|
53
|
+
end
|
54
|
+
|
55
|
+
def detect_shaders(paths)
|
56
|
+
for path in paths
|
57
|
+
shader_paths = Dir[File.join(path, "*/{vertex,fragment}.ejs")].collect { |d| File.dirname(d) }.uniq
|
58
|
+
shader_paths.each do |shader_path|
|
59
|
+
shaders.push Jax::Shader.from(shader_path)
|
60
|
+
end
|
38
61
|
end
|
39
62
|
end
|
40
63
|
|
41
|
-
delegate :config, :to => "self.class"
|
42
64
|
delegate :root, :to => :config
|
43
65
|
delegate :routes, :to => :config
|
44
|
-
delegate :
|
66
|
+
delegate :plugin_repository_url, :plugin_repository_url=, :default_plugin_repository_url, :to => :config
|
67
|
+
|
68
|
+
def shader_load_paths
|
69
|
+
if !@shader_load_paths
|
70
|
+
@shader_load_paths = []
|
71
|
+
self.class.initialize!
|
72
|
+
end
|
73
|
+
@shader_load_paths
|
74
|
+
end
|
75
|
+
|
76
|
+
def javascript_load_paths
|
77
|
+
if !@javascript_load_paths
|
78
|
+
@javascript_load_paths = []
|
79
|
+
@javascript_load_paths = javascript_source_roots + @javascript_load_paths
|
80
|
+
end
|
81
|
+
@javascript_load_paths
|
82
|
+
end
|
83
|
+
|
84
|
+
def javascript_sources
|
85
|
+
if !@javascript_sources
|
86
|
+
@javascript_sources = []
|
87
|
+
self.class.initialize!
|
88
|
+
end
|
89
|
+
@javascript_sources
|
90
|
+
end
|
91
|
+
|
92
|
+
def resource_paths
|
93
|
+
if !@resource_files
|
94
|
+
@resource_files = []
|
95
|
+
self.class.initialize!
|
96
|
+
end
|
97
|
+
@resource_files
|
98
|
+
end
|
99
|
+
|
100
|
+
def resources
|
101
|
+
if !@resources
|
102
|
+
@resources = Jax::ResourceCompiler.new
|
103
|
+
self.class.initialize!
|
104
|
+
end
|
105
|
+
@resources
|
106
|
+
end
|
107
|
+
|
108
|
+
def javascript_source_roots
|
109
|
+
if !@javascript_source_roots
|
110
|
+
@javascript_source_roots = []
|
111
|
+
self.class.initialize!
|
112
|
+
end
|
113
|
+
@javascript_source_roots
|
114
|
+
end
|
115
|
+
|
116
|
+
def asset_paths
|
117
|
+
if !@asset_paths
|
118
|
+
@asset_paths = []
|
119
|
+
self.class.initialize!
|
120
|
+
end
|
121
|
+
@asset_paths
|
122
|
+
end
|
45
123
|
|
46
124
|
def shaders
|
47
|
-
|
48
|
-
shaders = []
|
49
|
-
|
50
|
-
shader_paths.each do |name, path|
|
51
|
-
shaders << Jax::Shader.from(path)
|
52
|
-
end
|
53
|
-
|
125
|
+
if !@shaders
|
126
|
+
@shaders = []
|
54
127
|
def shaders.find(name)
|
55
128
|
select { |s| s.name == name }.first
|
56
129
|
end
|
57
130
|
|
58
|
-
|
59
|
-
# end
|
60
|
-
end
|
61
|
-
|
62
|
-
def shader_paths
|
63
|
-
shader_paths = {}
|
64
|
-
shader_load_paths.each do |path|
|
65
|
-
full_path = File.directory?(path) ? path : File.expand_path(path, config.root)
|
66
|
-
glob = File.join(full_path, "*/{fragment,vertex}.ejs")
|
67
|
-
Dir[glob].each do |dir|
|
68
|
-
shader_base = File.dirname(dir)
|
69
|
-
shader_name = File.basename(shader_base)
|
70
|
-
shader_paths[shader_name] = shader_base
|
71
|
-
end
|
131
|
+
self.class.initialize!
|
72
132
|
end
|
73
|
-
|
133
|
+
@shaders
|
74
134
|
end
|
75
135
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
raise "Could not find root path for #{self}" unless root
|
86
|
-
|
87
|
-
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ?
|
88
|
-
Pathname.new(root).expand_path : Pathname.new(root).realpath
|
136
|
+
def initializers
|
137
|
+
# jax doesn't have a bootstrapper or initializer yet, but I think these are good ideas
|
138
|
+
# so I'm leaving this here as a sort of reminder for how to do it.
|
139
|
+
# initializers = Bootstrap.initializers_for(self)
|
140
|
+
initializers = nil
|
141
|
+
railties.all { |r| initializers = initializers ? initializers + r.initializers : r.initializers }
|
142
|
+
initializers = initializers ? initializers + super : super
|
143
|
+
# initializers += Finisher.initializers_for(self)
|
144
|
+
initializers
|
89
145
|
end
|
90
146
|
end
|
91
|
-
end
|
147
|
+
end
|
148
|
+
|
149
|
+
require File.expand_path("application/builtin", File.dirname(__FILE__))
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Jax::Application::Builtin < Jax::Engine
|
2
|
+
# Builtin is just an Engine whose Configuration is instantiated with a hardcoded
|
3
|
+
# path pointing to within the Jax framework (../../../builtin). Engine's initializers
|
4
|
+
# take care of everything else, hence the builtin path is structured the same as any
|
5
|
+
# Jax plugin.
|
6
|
+
|
7
|
+
autoload :Configurable, "jax/application/builtin/configurable"
|
8
|
+
autoload :Configuration, "jax/application/builtin/configuration"
|
9
|
+
|
10
|
+
# not sure why this is necessary. self::Configurable must be resolving to something.
|
11
|
+
include Jax::Application::Builtin::Configurable
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Jax
|
2
|
+
class Application
|
3
|
+
module Configurable
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def inherited(base)
|
10
|
+
raise "You cannot inherit from a Jax::Application child"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def config
|
15
|
+
@config ||= Jax::Application::Configuration.new(self.class.find_root_with_flag("app", Dir.pwd))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Jax::Application::Configuration < Jax::Engine::Configuration
|
4
|
+
attr_accessor :view_paths
|
5
|
+
attr_writer :plugin_repository_url
|
3
6
|
|
4
|
-
def initialize
|
7
|
+
def initialize(*)
|
8
|
+
super
|
5
9
|
@view_paths = ['app/views']
|
6
|
-
|
7
|
-
@root = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? Pathname.new(JAX_ROOT).expand_path : Pathname.new(JAX_ROOT).realpath
|
8
|
-
else
|
9
|
-
@root = nil
|
10
|
-
end
|
10
|
+
read_config_files
|
11
11
|
end
|
12
12
|
|
13
13
|
def routes
|
@@ -18,10 +18,43 @@ class Jax::Application::Configuration
|
|
18
18
|
@routes
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
@
|
23
|
-
|
24
|
-
"
|
25
|
-
|
21
|
+
def paths
|
22
|
+
@paths ||= begin
|
23
|
+
paths = super
|
24
|
+
paths.tmp "tmp"
|
25
|
+
paths.vendor "vendor"
|
26
|
+
paths.vendor.plugins "vendor/plugins"
|
27
|
+
paths
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_plugin_repository_url
|
32
|
+
"http://plugins.jaxgl.com/"
|
33
|
+
end
|
34
|
+
|
35
|
+
def plugin_repository_url
|
36
|
+
@plugin_repository_url ||=
|
37
|
+
@config_file[:plugin_repository_url] ||
|
38
|
+
ENV['JAX_PLUGIN_REPOSITORY_URL'] ||
|
39
|
+
default_plugin_repository_url
|
40
|
+
|
41
|
+
@plugin_repository_url.dup # so that it can't be edited in-place
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def read_config_files
|
46
|
+
@config_file = {}.with_indifferent_access
|
47
|
+
@config_file.merge! hash_from_config_file(File.expand_path("~/.jax", File.dirname(__FILE__)))
|
48
|
+
@config_file.merge! hash_from_config_file(File.expand_path(".jax", root))
|
49
|
+
end
|
50
|
+
|
51
|
+
def hash_from_config_file(path)
|
52
|
+
if File.file? path
|
53
|
+
hash = YAML::load(File.read(path)) || {}
|
54
|
+
raise "Error: #{hash.inspect} is not a hash (read from #{path})" unless hash.kind_of?(Hash)
|
55
|
+
hash
|
56
|
+
else
|
57
|
+
{}
|
58
|
+
end
|
26
59
|
end
|
27
60
|
end
|