depo 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +71 -0
- data/Rakefile +50 -0
- data/generators/depo_config/USAGE +5 -0
- data/generators/depo_config/depo_config_generator.rb +8 -0
- data/generators/depo_config/templates/depo.rb +9 -0
- data/generators/dijit/USAGE +0 -0
- data/generators/dijit/dijit_generator.rb +34 -0
- data/generators/dijit/templates/class.js +30 -0
- data/generators/dijit/templates/style.css +4 -0
- data/generators/dijit/templates/test.html +15 -0
- data/generators/dijit/templates/test.js +11 -0
- data/generators/dpage/USAGE +33 -0
- data/generators/dpage/dpage_generator.rb +39 -0
- data/generators/dpage/templates/app/controllers.js +12 -0
- data/generators/dpage/templates/app/models.js +5 -0
- data/generators/dpage/templates/app/views.js +4 -0
- data/generators/dpage/templates/controller.rb +8 -0
- data/generators/dpage/templates/default_stylesheets/all.css +0 -0
- data/generators/dpage/templates/default_stylesheets/common.css +11 -0
- data/generators/dpage/templates/default_stylesheets/reset.css +51 -0
- data/generators/dpage/templates/default_stylesheets/theme_override.css +3 -0
- data/generators/dpage/templates/dpage.css +6 -0
- data/generators/dpage/templates/dpage.js +4 -0
- data/generators/dpage/templates/helper.rb +9 -0
- data/generators/dpage/templates/helper_test.rb +5 -0
- data/generators/dpage/templates/view.haml +28 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/depo/build.rb +53 -0
- data/lib/depo/config.rb +82 -0
- data/lib/depo/dijit_conventions.rb +101 -0
- data/lib/depo/tasks.rb +1 -0
- data/lib/depo/templates/dojo_src.tpl +4 -0
- data/lib/depo/templates/profile.js +8 -0
- data/lib/depo/view_helpers.rb +32 -0
- data/lib/depo.rb +36 -0
- data/tasks/depo.rake +29 -0
- data/test/action_pack_test.rb +49 -0
- data/test/build_profile_test.rb +32 -0
- data/test/config_test.rb +55 -0
- data/test/database.yml +6 -0
- data/test/generators_test.rb +59 -0
- data/test/path_utils_test.rb +18 -0
- data/test/rails_root/public/ria/src/app/my/Dijit.js +28 -0
- data/test/rails_root/public/ria/src/app/tests/my/Dijit.html +16 -0
- data/test/rails_root/public/ria/src/app/tests/my/Dijit.js +11 -0
- data/test/rails_root/public/ria/src/app/themes/tundra/my/Dijit.css +4 -0
- data/test/test_helper.rb +104 -0
- data/uninstall.rb +1 -0
- metadata +133 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
module Depo
|
3
|
+
class DijitConventions
|
4
|
+
class << self
|
5
|
+
attr :props
|
6
|
+
def prop(key,&block)
|
7
|
+
@props||=[]
|
8
|
+
@props<< key
|
9
|
+
define_method key,&block
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
attr :cmp
|
14
|
+
def initialize(dijit_full_name)
|
15
|
+
@dijit_full_name= dijit_full_name
|
16
|
+
from_full_name(dijit_full_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def from_full_name(dijit_full_name)
|
20
|
+
parts = @dijit_full_name.split('.')
|
21
|
+
cmps ={:base_module=>parts[0],:class_name=>parts[-1]}
|
22
|
+
if parts.length > 2
|
23
|
+
cmps[:modules] = parts[1..-2]
|
24
|
+
end
|
25
|
+
cmps[:dijit_full_name]=dijit_full_name
|
26
|
+
@cmp_hash=cmps
|
27
|
+
@cmp = OpenStruct.new(cmps)
|
28
|
+
end
|
29
|
+
|
30
|
+
prop :dijit_full_name do
|
31
|
+
@dijit_full_name
|
32
|
+
end
|
33
|
+
|
34
|
+
prop :dijit_base_class do
|
35
|
+
'null'
|
36
|
+
end
|
37
|
+
|
38
|
+
prop :dijit_package_name do
|
39
|
+
@dijit_full_name.split('.')[0..-2].join('.')
|
40
|
+
end
|
41
|
+
|
42
|
+
prop :dijit_class_name do
|
43
|
+
cmp.class_name
|
44
|
+
end
|
45
|
+
|
46
|
+
prop :dijit_base_module do
|
47
|
+
cmp.base_module
|
48
|
+
end
|
49
|
+
|
50
|
+
prop :dijit_modules do
|
51
|
+
cmp.modules
|
52
|
+
end
|
53
|
+
|
54
|
+
def from_src(*args)
|
55
|
+
File.join(*args.flatten.unshift(Depo.config.src_path))
|
56
|
+
end
|
57
|
+
|
58
|
+
def j(*args)
|
59
|
+
File.join(*args)
|
60
|
+
end
|
61
|
+
|
62
|
+
prop :package_path do
|
63
|
+
from_src cmp.base_module, cmp.modules
|
64
|
+
end
|
65
|
+
|
66
|
+
prop :style_dir_path do
|
67
|
+
from_src cmp.base_module,'themes', Depo.config.default_theme, cmp.modules
|
68
|
+
end
|
69
|
+
|
70
|
+
prop :test_dir_path do
|
71
|
+
from_src cmp.base_module,'tests', cmp.modules
|
72
|
+
end
|
73
|
+
|
74
|
+
prop :class_path do
|
75
|
+
j(package_path,"#{cmp.class_name}.js")
|
76
|
+
end
|
77
|
+
|
78
|
+
prop :style_path do
|
79
|
+
j(style_dir_path,"#{cmp.class_name}.css")
|
80
|
+
end
|
81
|
+
|
82
|
+
prop :test_code_path do
|
83
|
+
j(test_dir_path,"#{cmp.class_name}.js")
|
84
|
+
end
|
85
|
+
|
86
|
+
prop :test_page_path do
|
87
|
+
j(test_dir_path,"#{cmp.class_name}.html")
|
88
|
+
end
|
89
|
+
|
90
|
+
prop :dijit_style_class_name do
|
91
|
+
@dijit_full_name.split('.').map{|c| c.capitalize}.join('')
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
def to_hash
|
96
|
+
self.class.props.inject({}) do |hash,prp|
|
97
|
+
hash[prp] = send(prp); hash;
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/lib/depo/tasks.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
load File.join(File.dirname(__FILE__),'..','..','tasks','depo.rake')
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Depo
|
2
|
+
module ViewHelpers
|
3
|
+
def webroot
|
4
|
+
Depo.config.env_root_webpath(@opts[:env])
|
5
|
+
end
|
6
|
+
def djConfig
|
7
|
+
Depo.config.env_dj_config(@opts[:env])
|
8
|
+
end
|
9
|
+
#check if ext presented and add if not
|
10
|
+
def add_ext(str,ext)
|
11
|
+
( str.strip=~/\.#{ext}$/ ) ? str.strip : "#{str.strip}.#{ext}"
|
12
|
+
end
|
13
|
+
def css
|
14
|
+
%Q[#{webroot}/app/themes/#{theme}/#{add_ext(@opts[:app],'css')}]
|
15
|
+
end
|
16
|
+
def dojo(opts)
|
17
|
+
return @dojo_tpl if @dojo_tpl
|
18
|
+
raise "You must provide :app name in opts" unless opts[:app]
|
19
|
+
@opts = opts
|
20
|
+
@opts[:env] = (defined? RAILS_ENV && !opts[:env])? RAILS_ENV : opts[:env]
|
21
|
+
tpl_string = IO.readlines("#{File.dirname(__FILE__)}/templates/dojo_src.tpl",'').to_s
|
22
|
+
@dojo_tpl = ERB.new(tpl_string).result(binding)
|
23
|
+
end
|
24
|
+
def theme
|
25
|
+
Depo.config.default_theme
|
26
|
+
end
|
27
|
+
def app_js
|
28
|
+
%Q[#{webroot}/app/pages/#{@opts[:app]}.js]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/depo.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
require 'kung_figure'
|
4
|
+
require 'active_support'
|
5
|
+
|
6
|
+
module Depo
|
7
|
+
VERSION = '0.0.1'
|
8
|
+
autoload :Config, 'depo/config'
|
9
|
+
autoload :Build, 'depo/build'
|
10
|
+
autoload :DijitConventions, 'depo/dijit_conventions'
|
11
|
+
autoload :ViewHelpers, 'depo/view_helpers'
|
12
|
+
include KungFigure
|
13
|
+
class << self
|
14
|
+
alias_method :old_configure, :configure
|
15
|
+
def configure(&block)
|
16
|
+
old_configure(&block)
|
17
|
+
dojofy if Depo.config.enable_dojofy
|
18
|
+
end
|
19
|
+
def dojofy
|
20
|
+
Dir.chdir(RAILS_ROOT) do
|
21
|
+
version = Depo.config.dojo_version
|
22
|
+
system "dojofy _#{version}_ #{Depo.config.src_path}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
def enable
|
26
|
+
return if ActionView::Base.instance_methods.include? 'dojo'
|
27
|
+
if defined?(ActionController::Base)
|
28
|
+
ActionView::Base.send :include, ViewHelpers
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if defined?(Rails) and defined?(ActionView)
|
35
|
+
Depo.enable
|
36
|
+
end
|
data/tasks/depo.rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'depo'
|
3
|
+
|
4
|
+
namespace :dojo do
|
5
|
+
desc "Install dojo"
|
6
|
+
task :install=>:environment do
|
7
|
+
Depo.dojofy
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Generate build profile"
|
11
|
+
task :build_profile=>:environment do
|
12
|
+
Depo::Build.generate_profile(:rails_root=>RAILS_ROOT)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Build dojo"
|
16
|
+
task :build=>:build_profile do
|
17
|
+
profile_file = File.join(RAILS_ROOT,Depo.config.profile_path)
|
18
|
+
Dir.chdir File.join(RAILS_ROOT,Depo.config.buildscripts_path)
|
19
|
+
release_dir=File.join(RAILS_ROOT,Depo.config.builds_path)
|
20
|
+
FileUtils.mkdir_p(release_dir) unless File.exists? release_dir
|
21
|
+
|
22
|
+
options=Depo.config.build_options.get_options.map{ |key, val| "#{key}=#{val}"}.join ' '
|
23
|
+
build_name='build_'+DateTime.now.to_s.gsub(/[^A-Za-z0-9_]/, '_')
|
24
|
+
puts "Start building to #{release_dir}/#{build_name}."
|
25
|
+
cmd= "./build.sh profileFile=#{profile_file} releaseDir=#{release_dir} releaseName=#{build_name} #{options} action=release"
|
26
|
+
puts cmd
|
27
|
+
system cmd
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class ActionView
|
4
|
+
include Depo::ViewHelpers
|
5
|
+
end
|
6
|
+
|
7
|
+
class ActionViewEnv
|
8
|
+
attr_accessor :av_values
|
9
|
+
def css
|
10
|
+
@av_values[:css]
|
11
|
+
end
|
12
|
+
def app_js
|
13
|
+
@av_values[:app_js]
|
14
|
+
end
|
15
|
+
def webroot
|
16
|
+
@av_values[:webroot]
|
17
|
+
end
|
18
|
+
def djConfig
|
19
|
+
@av_values[:djConfig]
|
20
|
+
end
|
21
|
+
def get_template(v)
|
22
|
+
@av_values = v
|
23
|
+
tpl_string = IO.readlines(File.dirname(__FILE__) + '/../lib/depo/templates/dojo_src.tpl').to_s
|
24
|
+
tpl = ERB.new(tpl_string).result(binding)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class ActionPackTest < GeneratorTest
|
29
|
+
def test_dojo_helper_development
|
30
|
+
assert_equal ActionView.new.dojo(:app => 'app', :env => 'development'), ActionViewEnv.new.get_template({
|
31
|
+
:webroot => "/ria/src",
|
32
|
+
:app_js => "/ria/src/app/pages/app.js",
|
33
|
+
:djConfig => "parseOnLoad:true,isDebug:true",
|
34
|
+
:css => "/ria/src/app/themes/tundra/app.css"
|
35
|
+
})
|
36
|
+
Depo.clear_config!
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_dojo_helper_production
|
40
|
+
create_if_missing(File.join(Depo.config.builds_path, 'builddir'))
|
41
|
+
assert_equal ActionView.new.dojo(:app => 'app', :env => 'production'), ActionViewEnv.new.get_template({
|
42
|
+
:webroot => "/ria/builds/builddir",
|
43
|
+
:app_js => "/ria/builds/builddir/app/pages/app.js",
|
44
|
+
:djConfig => "parseOnLoad:true,isDebug:false",
|
45
|
+
:css => "/ria/builds/builddir/app/themes/tundra/app.css"
|
46
|
+
})
|
47
|
+
Depo.clear_config!
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
Depo.configure {
|
4
|
+
author 'niquola@gmail.com'
|
5
|
+
themes ['tundra','verdugo']
|
6
|
+
|
7
|
+
build_options {
|
8
|
+
cssOptimize 'comments.keepLines'
|
9
|
+
optimize 'shrinksafe.keepLines'
|
10
|
+
cssImportIgnore '../dijit.css'
|
11
|
+
internStrings 'true'
|
12
|
+
}
|
13
|
+
|
14
|
+
build_profile {
|
15
|
+
libs<< 'mylib'
|
16
|
+
|
17
|
+
pages<< 'app.pages.admin'
|
18
|
+
pages<< 'app.pages.chart'
|
19
|
+
pages<< 'app.pages.nurse'
|
20
|
+
pages<< 'app.pages.dashboard'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
class BuildProfileTest < GeneratorTest
|
25
|
+
def test_basics
|
26
|
+
Depo::Build.generate_profile(:rails_root=>fake_rails_root)
|
27
|
+
assert_file 'tmp/dojo_build_profile.js'
|
28
|
+
result = read('tmp/dojo_build_profile.js')
|
29
|
+
assert_match(/test\/rails_root\/public\/ria\/src\/mylib/, result)
|
30
|
+
Depo.clear_config!
|
31
|
+
end
|
32
|
+
end
|
data/test/config_test.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class DepoConfigureTest < GeneratorTest
|
4
|
+
def test_roots
|
5
|
+
Depo.clear_config!
|
6
|
+
Depo.configure {
|
7
|
+
author 'niquola@gmail.com'
|
8
|
+
themes ['tundra','verdugo']
|
9
|
+
dojo_version '1.4.2'
|
10
|
+
|
11
|
+
environments {
|
12
|
+
developmentDjConfig 'parseOnLoad:true;isDebug:true;'
|
13
|
+
productionDjConfig 'parseOnLoad:true;isDebug:false;'
|
14
|
+
}
|
15
|
+
|
16
|
+
build_options {
|
17
|
+
cssOptimize 'comments.keepLines'
|
18
|
+
optimize 'shrinksafe.keepLines'
|
19
|
+
cssImportIgnore '../dijit.css'
|
20
|
+
internStrings 'true'
|
21
|
+
}
|
22
|
+
|
23
|
+
build_profile {
|
24
|
+
libs<< 'mylib'
|
25
|
+
|
26
|
+
pages<< 'app.pages.admin'
|
27
|
+
pages<< 'app.pages.chart'
|
28
|
+
pages<< 'app.pages.nurse'
|
29
|
+
pages<< 'app.pages.dashboard'
|
30
|
+
}
|
31
|
+
|
32
|
+
generators {
|
33
|
+
head_of_test_page <<-HTML
|
34
|
+
<link rel="stylesheet" href="#{Depo.config.src_path}/common.css" type="text/css" />
|
35
|
+
HTML
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
config=Depo.config
|
40
|
+
assert_equal('1.4.2', config.dojo_version)
|
41
|
+
assert_equal('public/ria', config.root)
|
42
|
+
assert_equal('/ria', config.root_webpath)
|
43
|
+
assert_equal('public/ria/src', config.src_path)
|
44
|
+
assert_equal('public/ria/builds', config.builds_path)
|
45
|
+
assert_equal('niquola@gmail.com', config.author)
|
46
|
+
|
47
|
+
assert_equal(['tundra','verdugo'],config.themes)
|
48
|
+
assert_equal('parseOnLoad:true;isDebug:true;',config.environments.developmentDjConfig)
|
49
|
+
assert(config.build_profile.pages.include?('app.pages.admin'))
|
50
|
+
assert(config.build_profile.libs.include?('mylib'))
|
51
|
+
|
52
|
+
assert_match(/common.css/, config.generators.head_of_test_page )
|
53
|
+
Depo.clear_config!
|
54
|
+
end
|
55
|
+
end
|
data/test/database.yml
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
|
4
|
+
class GeneratorsTest < GeneratorTest
|
5
|
+
def test_config_generator
|
6
|
+
generate 'depo_config'
|
7
|
+
assert_file 'config/depo.rb'
|
8
|
+
result = read 'config/depo.rb'
|
9
|
+
assert_match(/Depo.config/, result)
|
10
|
+
end
|
11
|
+
|
12
|
+
def from_src(path)
|
13
|
+
File.join(Depo.config.src_path,path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_widget_generator
|
17
|
+
Depo.clear_config!
|
18
|
+
Depo.configure do
|
19
|
+
author 'niquola@gmail.com'
|
20
|
+
generators do
|
21
|
+
head_of_test_page <<-HTML
|
22
|
+
<link rel="stylesheet" href="#{Depo.config.src_path}/common.css" type="text/css" />
|
23
|
+
HTML
|
24
|
+
end
|
25
|
+
end
|
26
|
+
generate 'dijit','app.my.Dijit'
|
27
|
+
|
28
|
+
file = from_src("app/my/Dijit.js")
|
29
|
+
assert_file file
|
30
|
+
result = read file
|
31
|
+
assert_match(/dojo.provide/, result)
|
32
|
+
assert_match(/dojo.declare/, result)
|
33
|
+
|
34
|
+
file = from_src("app/tests/my/Dijit.js")
|
35
|
+
assert_file file
|
36
|
+
result = read file
|
37
|
+
assert_match(/dojo.require/, result)
|
38
|
+
|
39
|
+
file = from_src("app/tests/my/Dijit.html")
|
40
|
+
assert_file file
|
41
|
+
result = read file
|
42
|
+
assert_match(/common.css/, result)
|
43
|
+
|
44
|
+
file = from_src("app/themes/tundra/my/Dijit.css")
|
45
|
+
assert_file file
|
46
|
+
result = read file
|
47
|
+
assert_match(/.AppMyDijit/, result)
|
48
|
+
Depo.clear_config!
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_page_generator
|
52
|
+
generate 'dpage','controller_name', 'pagename'
|
53
|
+
assert_file 'app/controllers/controller_name_controller.rb'
|
54
|
+
assert_file 'app/views/controller_name/pagename.haml'
|
55
|
+
assert_file 'app/helpers/controller_name_helper.rb'
|
56
|
+
assert_file 'test/unit/helpers/controller_name_helper_test.rb'
|
57
|
+
assert_file = from_src("app/pages/pagename.js")
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class DijitConventionsTest < GeneratorTest
|
4
|
+
def test_basics
|
5
|
+
dijit=Depo::DijitConventions.new('app.my.Dijit')
|
6
|
+
|
7
|
+
assert_equal('public/ria/src/app/my', dijit.package_path)
|
8
|
+
assert_equal('public/ria/src/app/themes/tundra/my', dijit.style_dir_path)
|
9
|
+
assert_equal('public/ria/src/app/tests/my', dijit.test_dir_path)
|
10
|
+
|
11
|
+
assert_equal('public/ria/src/app/my/Dijit.js', dijit.class_path)
|
12
|
+
assert_equal('public/ria/src/app/themes/tundra/my/Dijit.css', dijit.style_path)
|
13
|
+
assert_equal('public/ria/src/app/tests/my/Dijit.js', dijit.test_code_path)
|
14
|
+
assert_equal('public/ria/src/app/tests/my/Dijit.html', dijit.test_page_path)
|
15
|
+
|
16
|
+
assert_not_nil(dijit.to_hash)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* app.my.Dijit
|
3
|
+
* Created by niquola@gmail.com
|
4
|
+
**/
|
5
|
+
dojo.provide("app.my.Dijit");
|
6
|
+
|
7
|
+
(function () {
|
8
|
+
//here go private vars and functions
|
9
|
+
dojo.declare("app.my.Dijit",null, {
|
10
|
+
// summary:
|
11
|
+
// HERE WIDGET SUMMARY
|
12
|
+
|
13
|
+
// baseClass: [protected] String
|
14
|
+
baseClass: "AppMyDijit",
|
15
|
+
//templateString: dojo.cache("app.my", "templates/Dijit.html"),
|
16
|
+
//widgetsInTemplate: true,
|
17
|
+
//buildRendering: function () {
|
18
|
+
//this.inherited(arguments);
|
19
|
+
//},
|
20
|
+
//layout: function () {
|
21
|
+
//var cb = this._contentBox;
|
22
|
+
//dojo.marginBox(this.containerNode, cb);
|
23
|
+
//},
|
24
|
+
//postCreate: function () {
|
25
|
+
//this.inherited(arguments);
|
26
|
+
//}
|
27
|
+
});
|
28
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version='1.0' encoding='utf-8' ?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>app.my.Dijit</title>
|
6
|
+
|
7
|
+
<script type="text/javascript" src="/ria/src/dojo/dojo.js" djConfig="isDebug:false,parseOnLoad:true"> </script>
|
8
|
+
<script src="Dijit.js"></script>
|
9
|
+
<link rel="stylesheet" href="public/ria/src/common.css" type="text/css" />
|
10
|
+
|
11
|
+
<link rel="stylesheet" href="/public/ria/src/app/themes/tundra/my/Dijit.css" type="text/css" />
|
12
|
+
</head>
|
13
|
+
<body class="app">
|
14
|
+
</body>
|
15
|
+
</html>
|
16
|
+
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
C_DIR = File.dirname(__FILE__)
|
2
|
+
def path(p)
|
3
|
+
File.join(C_DIR,p)
|
4
|
+
end
|
5
|
+
|
6
|
+
$:.unshift(path('../lib'))
|
7
|
+
require 'rubygems'
|
8
|
+
require 'test/unit'
|
9
|
+
require 'depo'
|
10
|
+
require 'active_support'
|
11
|
+
require 'active_support/test_case'
|
12
|
+
require "rails_generator"
|
13
|
+
require "active_record"
|
14
|
+
require 'rails_generator/scripts/generate'
|
15
|
+
require 'ftools'
|
16
|
+
|
17
|
+
|
18
|
+
gem_root= path('..')
|
19
|
+
Rails::Generator::Base.default_options :collision => :ask, :quiet => false
|
20
|
+
Rails::Generator::Base.reset_sources
|
21
|
+
Rails::Generator::Base.append_sources(Rails::Generator::PathSource.new(:plugin, "#{gem_root}/generators/"))
|
22
|
+
|
23
|
+
RAILS_ROOT = path('rails_root')
|
24
|
+
|
25
|
+
class GeneratorTest < ActiveSupport::TestCase
|
26
|
+
def generate(*args)
|
27
|
+
Rails::Generator::Scripts::Generate.new.run(args, :destination=>fake_rails_root)
|
28
|
+
end
|
29
|
+
|
30
|
+
def read(path)
|
31
|
+
IO.readlines("#{fake_rails_root}/#{path}",'').to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
def assert_file(file)
|
35
|
+
assert_block "File #{file} not exists, as not expected" do
|
36
|
+
File.exists? "#{fake_rails_root}/#{file}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_if_missing *names
|
41
|
+
names.each do |name|
|
42
|
+
File.makedirs(name) unless File.directory?(name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def setup
|
47
|
+
FileUtils.rm_r(fake_rails_root)
|
48
|
+
FileUtils.mkdir_p(fake_rails_root)
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
def fake_rails_root
|
53
|
+
RAILS_ROOT
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class TestDbUtils
|
58
|
+
class<< self
|
59
|
+
def config
|
60
|
+
@config ||= YAML::load(IO.read(path('/database.yml'))).symbolize_keys
|
61
|
+
end
|
62
|
+
|
63
|
+
#create test database
|
64
|
+
def ensure_test_database
|
65
|
+
connect_to_test_db
|
66
|
+
rescue
|
67
|
+
create_database
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_schema
|
71
|
+
ensure_test_database
|
72
|
+
load(path('db/schema.rb'))
|
73
|
+
end
|
74
|
+
|
75
|
+
def ensure_schema
|
76
|
+
load_schema
|
77
|
+
rescue
|
78
|
+
puts "tests database exists: skip schema loading"
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_database
|
82
|
+
connect_to_postgres_db
|
83
|
+
ActiveRecord::Base.connection.create_database(config[:database], config)
|
84
|
+
connect_to_test_db
|
85
|
+
rescue
|
86
|
+
$stderr.puts $!, *($!.backtrace)
|
87
|
+
$stderr.puts "Couldn't create database for #{config.inspect}"
|
88
|
+
end
|
89
|
+
|
90
|
+
def connect_to_test_db
|
91
|
+
ActiveRecord::Base.establish_connection(config)
|
92
|
+
ActiveRecord::Base.connection
|
93
|
+
end
|
94
|
+
|
95
|
+
def connect_to_postgres_db
|
96
|
+
ActiveRecord::Base.establish_connection(config.merge(:database => 'postgres', :schema_search_path => 'public'))
|
97
|
+
end
|
98
|
+
|
99
|
+
def drop_database
|
100
|
+
connect_to_postgres_db
|
101
|
+
ActiveRecord::Base.connection.drop_database config[:database]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|