Sha256: ed9cb2486b4414f2a5bfb72dbcc996372511f0e0096023a2826952bdb7988ec2

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

Contents

require 'rails/generators'

module Kthxbye
  module Generators
    class KthxbyeGenerator < Rails::Generators::Base

      desc "installs all necessary Kthxbye files for notification widget"

      class_option :js, :type => :boolean, :default => true, :desc => "install javascript files"
      class_option :img, :type => :boolean, :default => true, :desc => "install widget image"
      class_option :css, :type => :boolean, :default => true, :desc => "install css files"

      def self.source_root
        @source_root ||= File.join(File.dirname(__FILE__), 'templates')
      end

      def self.banner
        "#{$0} kthxbye #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
      end

      def install_all
        install_javascripts
        install_css
        install_images
        install_gems

        puts "Successfully installed Kthxbye resources in public/"
      end

      private

      def install_javascripts
        copy_file("kthxbye.js", "public/javascripts/kthxbye.js") if options[:js]
      end

      def install_css
        copy_file("kthxbye.css", "public/stylesheets/kthxbye.css") if options[:css]
      end

      def install_images
        copy_file("kthxbye_widget.png", "public/images/kthxbye_widget.png") if options[:img]
      end

      def install_gems
        gem("redis", "~> 2.0.10")
        gem("yajl-ruby", "~> 0.7.8")
        gem("kthxbye", "~> #{Kthxbye::Version}")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kthxbye-1.3.2 lib/generators/kthxbye/kthxbye_generator.rb
kthxbye-1.3.0 lib/generators/kthxbye/kthxbye_generator.rb
kthxbye-1.2.1 lib/generators/kthxbye/kthxbye_generator.rb
kthxbye-1.2.0 lib/generators/kthxbye/kthxbye_generator.rb
kthxbye-1.1.1 lib/generators/kthxbye/kthxbye_generator.rb
kthxbye-1.1.0 lib/generators/kthxbye/kthxbye_generator.rb