Skip to content

Commit

Permalink
make app package customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola committed Jun 17, 2010
1 parent 2bc1097 commit 989436c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.rdoc
Expand Up @@ -48,6 +48,7 @@ Is attempt to automate many tasks and practices in building RIA using Dojo and R
== CHANGE LOG:

* 0.0.5 remove dependency from dojo_src, to extenrnalize control over it
* 0.0.7 add app_package customization (default left 'app')

== LICENSE:

Expand Down
2 changes: 1 addition & 1 deletion lib/depo.rb
Expand Up @@ -4,7 +4,7 @@
require 'active_support'

module Depo
VERSION = '0.0.6'
VERSION = '0.0.7'
autoload :Config, 'depo/config'
autoload :Build, 'depo/build'
autoload :DijitConventions, 'depo/dijit_conventions'
Expand Down
1 change: 1 addition & 0 deletions lib/depo/config.rb
Expand Up @@ -9,6 +9,7 @@ class Config < KungFigure::Base
define_prop :profile_path,'tmp/dojo_build_profile.js'
define_prop :default_page_lib,'app.pages'
define_prop :enable_dojofy, true
define_prop :app_package, 'app'

def dojo_version(*args)
raise "dojo_version depricated."
Expand Down
8 changes: 6 additions & 2 deletions lib/depo/view_helpers.rb
Expand Up @@ -10,13 +10,17 @@ def djConfig
Depo.config.env_dj_config(@opts[:env])
end

def app_package
@app_package||=Depo.config.app_package
end

#check if ext presented and add if not
def add_ext(str,ext)
( str.strip=~/\.#{ext}$/ ) ? str.strip : "#{str.strip}.#{ext}"
end

def css
%Q[#{webroot}/app/themes/#{theme}/#{add_ext(@opts[:app],'css')}]
%Q[#{webroot}/#{app_package}/themes/#{theme}/#{add_ext(@opts[:app],'css')}]
end

def dojo(opts)
Expand All @@ -33,7 +37,7 @@ def theme
end

def app_js
%Q[#{webroot}/app/pages/#{@opts[:app]}.js]
%Q[#{webroot}/#{app_package}/pages/#{@opts[:app]}.js]
end

end
Expand Down
5 changes: 3 additions & 2 deletions test/action_pack_test.rb
Expand Up @@ -27,11 +27,12 @@ def get_template(v)

class ActionPackTest < GeneratorTest
def test_dojo_helper_development
Depo.config.app_package 'medhub'
assert_equal ActionView.new.dojo(:app => 'app', :env => 'development'), ActionViewEnv.new.get_template({
:webroot => "/ria/src",
:app_js => "/ria/src/app/pages/app.js",
:app_js => "/ria/src/medhub/pages/app.js",
:djConfig => "parseOnLoad:true,isDebug:true",
:css => "/ria/src/app/themes/tundra/app.css"
:css => "/ria/src/medhub/themes/tundra/app.css"
})
Depo.clear_config!
end
Expand Down
3 changes: 3 additions & 0 deletions test/config_test.rb
Expand Up @@ -7,6 +7,8 @@ def test_roots
author 'niquola@gmail.com'
themes ['tundra','verdugo']

app_package 'medhub'

environments {
developmentDjConfig 'parseOnLoad:true;isDebug:true;'
productionDjConfig 'parseOnLoad:true;isDebug:false;'
Expand Down Expand Up @@ -41,6 +43,7 @@ def test_roots
assert_equal('public/ria/src', config.src_path)
assert_equal('public/ria/builds', config.builds_path)
assert_equal('niquola@gmail.com', config.author)
assert_equal('medhub', config.app_package)

assert_equal(['tundra','verdugo'],config.themes)
assert_equal('parseOnLoad:true;isDebug:true;',config.environments.developmentDjConfig)
Expand Down

0 comments on commit 989436c

Please sign in to comment.