Class: Ace::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ace/install/install_generator.rb

Constant Summary collapse

@@ace_version =
"0.1.6"
@@ace_version_file =
"ace-#{@@ace_version}.tgz"
@@ace_url =
"http://cloud.github.com/downloads/ajaxorg/ace/#{@@ace_version_file}"
@@tmp_base =
"tmp/ace-install"
@@tmp_file =
File.join @@tmp_base, @@ace_version_file
@@tmp_src_base =
File.join @@tmp_base, "ace-#{@@ace_version}", "src"
@@target_src =
"public/javascripts/ace"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



19
20
21
# File 'lib/generators/ace/install/install_generator.rb', line 19

def self.source_root
  File.dirname(__FILE__) + "/templates"
end

Instance Method Details

#copy_stylesheetObject



39
40
41
42
43
44
45
46
47
# File 'lib/generators/ace/install/install_generator.rb', line 39

def copy_stylesheet
  return unless options.stylesheet?
  
  copy_file "ace-rails.css", "public/stylesheets/ace-rails.css"
  
  application_layout = File.expand_path('app/views/layouts/application.html.erb')
  stylesheet_tag = "\n  <%= stylesheet_link_tag    '/stylesheets/ace-rails.css' %>"
  inject_into_file application_layout, stylesheet_tag, :after => "</title>"
end

#download_and_install_aceObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/ace/install/install_generator.rb', line 23

def download_and_install_ace
  return unless options.download?
  
  remove_dir @@tmp_base
  remove_dir @@target_src
  get @@ace_url, @@tmp_file
  inside @@tmp_base do
    run("tar xzf #{@@ace_version_file}")
  end

  say_status("copying", "ace (#{@@ace_version})", :green)
  FileUtils.cp_r("#{File.expand_path @@tmp_src_base}", @@target_src)
  
  remove_dir @@tmp_base
end