Sha256: c6aced1e5f0c5e0edba78741055564811fd7082d3e4e9c194d2b54be43c7cfdb

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

class LoadbehindGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)

  IMAGES=["error", "growl_bottom", "growl_repeat", "growl_top", "info"]
  JAVASCRIPTS=["loadbehind", "jquery.growl"]

  def generate_loadbehind
    view_dir = "app/views/#{plural_name}"

    JAVASCRIPTS.each do |js|
      copy_file "#{js}.js", "public/javascripts/#{js}.js"
    end

    IMAGES.each do |image|
      copy_file "images/#{image}.png", "public/images/growl/#{image}.png"
    end

    ["index", "show", "create"].each do |act|
      self.action_name = act
      template "view.js.haml", "#{view_dir}/#{action_name}.js.haml"
    end
    self.action_name = "show"
    template "view.js.haml", "#{view_dir}/update.js.haml"

    ["edit", "new"].each do |act|
      self.action_name = act
      template "edit.js.haml", "#{view_dir}/#{action_name}.js.haml"
    end

    ["destroy.js", "_errors.html"].each do |file|
      template "#{file}.haml", "#{view_dir}/#{file}.haml"
    end

    puts "**** Remember to add loadbehind.js and jquery.growl.js to the
    javascript tags, or add it to your own js files.
    You'll also need to add handling to see that all your
    events are reconnected each time you reload. "
  end

  attr_accessor :action_name

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
casey_jones-0.0.102 lib/generators/loadbehind/loadbehind_generator.rb