PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/install.rb

http://github.com/paolodona/rails-widgets
Ruby | 27 lines | 23 code | 3 blank | 1 comment | 0 complexity | 5bb76936c3bcb80275a9ae4becb0cdb9 MD5 | raw file
Possible License(s): MIT
 1def copy(file_name, from_dir, to_dir)
 2  FileUtils.mkdir to_dir unless File.exist?(File.expand_path(to_dir))   
 3  from = File.expand_path(File.join(from_dir,file_name))
 4  to = File.expand_path(File.join(to_dir, file_name))
 5  FileUtils.cp from, to, :verbose => true unless File.exist?(to)
 6end
 7
 8def copy_image(file_name)
 9  plugin_images = File.join(File.dirname(__FILE__), 'images')
10  app_images = File.join(RAILS_ROOT, 'public/images/widgets')
11  copy file_name, plugin_images, app_images 
12end
13
14def copy_javascript(file_name)
15  plugin_javascripts = File.join(File.dirname(__FILE__), 'javascripts')
16  app_javascripts = File.join(RAILS_ROOT, 'public/javascripts/widgets')
17  copy file_name, plugin_javascripts, app_javascripts 
18end
19
20# copy static assets
21begin 
22  copy_image 'tooltip_arrow.gif'
23  copy_image 'tooltip_image.gif'
24  copy_javascript 'tooltip.js'
25rescue Exception => e
26  puts "There are problems copying widgets assets to you app: #{e.message}"
27end