Sha256: bdfd6d3b74d29d045afb951043e21d0b50bf1ae04cc16bce19de4df20a194a89

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'find'

class HoboRapidGenerator < Hobo::Generator

  default_options :import_tags => false

  def manifest
    if options[:command] == :create
      import_tags if options[:import_tags]
    end
    
    record do |m|
      m.file "hobo-rapid.js", "public/javascripts/hobo-rapid.js"
      m.file "lowpro.js", "public/javascripts/lowpro.js"
      m.file "IE7.js", "public/javascripts/IE7.js"
      m.file "reset.css", "public/stylesheets/reset.css"
      m.file "hobo-rapid.css", "public/stylesheets/hobo-rapid.css"
      create_all(m, "themes/clean/public", "public/hobothemes/clean")
      create_all(m, "themes/clean/views", "app/views/taglibs/themes/clean")
    end
  end
  
  def import_tags
    path = File.join(RAILS_ROOT, "app/views/taglibs/application.dryml")

    tag = "<include src=\"rapid\" plugin=\"hobo\"/>\n\n<set-theme name=\"clean\"/>\n"
      
    src = File.read(path)
    return if src.include?(tag)

    # first try putting it before the first tag
    done = src.sub!(/<(?!!)/, tag + "\n<")
    
    # otherwise append it
    src << tag unless done
    
    File.open(path, 'w') {|f| f.write(src) }
  end


  protected
    def banner
      "Usage: #{$0} #{spec.name} [--import-tags]"
    end

    def add_options!(opt)
      opt.separator ''
      opt.separator 'Options:'
      opt.on("--import-tags",
             "Modify taglibs/application.dryml to import hobo-rapid and theme tags ") do |v|
        options[:import_tags] = true
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hobo-0.7.5 hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb