Sha256: d5dd39327ef15af5120b495ac2eebab541cb976ff7e39eaec76752275a6d83bf

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 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"].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"
    template "view.js.haml", "#{view_dir}/create.js.haml"

    ["edit", "new"].each do |act|
      self.action_name = 'form'
      template "edit.js.haml", "#{view_dir}/#{act}.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

3 entries across 3 versions & 1 rubygems

Version Path
casey_jones-0.0.106 lib/generators/loadbehind/loadbehind_generator.rb
casey_jones-0.0.105 lib/generators/loadbehind/loadbehind_generator.rb
casey_jones-0.0.104 lib/generators/loadbehind/loadbehind_generator.rb