Sha256: 8d6242e830590e1df7db309c48d05dd39c262460b4e1b51a568032f9ae51dd9d

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

require 'rails/generators/base'

module Adhoc
  module Generators
    class Base < Rails::Generators::Base
      def self.source_root
        @_adhoc_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'adhoc', generator_name, 'templates'))
      end

      def self.banner
        "rails g adhoc:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
      end

      private

      def add_gem(name, options = {})
        gemfile_content = File.read(destination_path("Gemfile"))
        File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
        gem name, options unless gemfile_content.include? name
      end

      def print_usage
        self.class.help(Thor::Base.shell.new)
        exit
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adhoc-generators-0.0.5 lib/generators/adhoc.rb
adhoc-generators-0.0.4 lib/generators/adhoc.rb
adhoc-generators-0.0.3 lib/generators/adhoc.rb
adhoc-generators-0.0.1 lib/generators/adhoc.rb