1
1
require 'rake'
2
2
require 'rake/testtask'
3
3
require 'rake/rdoctask'
4
- require 'erb'
5
- require 'rubygems'
6
- require 'active_record'
7
- require 'active_record/fixtures'
8
4
require 'ftools'
9
5
10
- rails_root = File . expand_path ( RAILS_ROOT )
11
- plugin_root = File . join ( rails_root , 'vendor' , 'plugins' , 'click-to-globalize' )
12
- templates_root = File . join ( plugin_root , 'templates' )
13
- shared_folder = File . join ( rails_root , 'app' , 'views' , 'shared' )
14
-
15
- require plugin_root + '/test/javascript/lib/jstest'
16
-
17
- files = [ File . join ( rails_root , 'public' , 'javascripts' , 'click_to_globalize.js' ) ,
18
- File . join ( rails_root , 'public' , 'stylesheets' , 'click_to_globalize.css' ) ,
19
- File . join ( rails_root , 'app' , 'controllers' , 'locales_controller.rb' ) ,
20
- File . join ( rails_root , 'app' , 'helpers' , 'locales_helper.rb' ) ,
21
- File . join ( rails_root , 'app' , 'views' , 'shared' , '_click_to_globalize.html.erb' ) ,
22
- File . join ( rails_root , 'config' , 'click.yml' ) ]
23
-
24
- desc 'Default: run click task.'
25
- task :default => :click
26
-
27
- desc 'Run tests.'
28
- task :click => [ 'click:test' ]
29
-
30
6
namespace :click do
31
- desc 'Test Click To Globalize.'
32
- task :test => [ 'click:test:all' ]
33
-
34
- namespace :test do
35
- desc 'Test both ruby and javascript code.'
36
- task :all => [ :ruby , :js ]
37
-
38
- desc 'Test ruby code.'
39
- Rake ::TestTask . new ( :ruby ) do |t |
40
- t . libs << "#{ plugin_root } /lib"
41
- t . libs << "#{ plugin_root } /test/test_helper"
42
- t . pattern = "#{ plugin_root } /test/**/*_test.rb"
43
- t . verbose = true
44
- end
45
-
46
- # Taken from Prototype rake tasks.
47
- desc "Runs all the JavaScript unit tests and collects the results"
48
- JavaScriptTestTask . new ( :js ) do |t |
49
- tests_to_run = ENV [ 'TESTS' ] && ENV [ 'TESTS' ] . split ( ',' )
50
- browsers_to_test = ENV [ 'BROWSERS' ] && ENV [ 'BROWSERS' ] . split ( ',' )
51
-
52
- t . mount ( "/public" , "#{ rails_root } /public" )
53
- t . mount ( "/test" , "#{ plugin_root } /test" )
54
-
55
- test_files = ( Dir [ "#{ plugin_root } /test/unit/*.html" ] + Dir [ "#{ plugin_root } /test/functional/*.html" ] )
56
- test_files . sort . reverse . each do |test_file |
57
- test_file = test_file . gsub ( plugin_root , '' )
58
- test_name = test_file [ /.*\/ (.+?)\. html/ , 1 ]
59
- t . run ( test_file ) unless tests_to_run && !tests_to_run . include? ( test_name )
60
- end
61
-
62
- %w( safari firefox ie konqueror opera ) . each do |browser |
63
- t . browser ( browser . to_sym ) unless browsers_to_test && !browsers_to_test . include? ( browser )
64
- end
65
- end
66
-
67
- desc 'Generate documentation for Click to Globalize plugin.'
68
- Rake ::RDocTask . new ( :rdoc ) do |rdoc |
69
- rdoc . rdoc_dir = "#{ plugin_root } /rdoc"
70
- rdoc . title = 'ClickToGlobalize'
71
- rdoc . options << '--line-numbers' << '--inline-source'
72
- rdoc . rdoc_files . include ( "#{ plugin_root } /README" )
73
- rdoc . rdoc_files . include ( "#{ plugin_root } /lib/**/*.rb" )
74
- end
75
- end
76
-
77
7
desc 'Setup Click to Globalize plugin (alias for click:install).'
78
8
task :setup => :install
79
9
@@ -91,18 +21,4 @@ namespace :click do
91
21
targets = Dir [ "#{ Rails . root } /public/**/click_to_globalize.*" ]
92
22
FileUtils . rm targets
93
23
end
94
-
95
- desc 'Show the diffs for each file, camparing the app files with the plugin ones.'
96
- task :diff do
97
- files . each do |file , path |
98
- file = path . split ( File ::SEPARATOR ) . last
99
- res = `diff #{ path } #{ templates_root } /#{ file } `
100
- puts "#{ file . upcase } \n #{ res } " unless res . empty?
101
- end
102
- end
103
-
104
- desc 'Prepare the folder plugin, copying files from the app, here.'
105
- task :prepare do
106
- files . each { |file , path | File . cp path , templates_root }
107
- end
108
24
end
0 commit comments