Sha256: e763b4195ab8a046ac4e336eff7ffa9e44aee08ef67fc314bbcc6d7092b6c799

Contents?: true

Size: 919 Bytes

Versions: 5

Compression:

Stored size: 919 Bytes

Contents

require 'rails/generators/base'

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

      def self.banner
        "rails generate bootstrap:#{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 destination_path(path)
        File.join(destination_root, path)
      end
      
      def print_usage
        self.class.help(Thor::Base.shell.new)
        exit
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bootstrapped-2.0.4 lib/generators/bootstrapped.rb
bootstrapped-2.0.3 lib/generators/bootstrapped.rb
bootstrapped-1.0.1 lib/generators/bootstrapped.rb
bootstrapped-1.0.0 lib/generators/bootstrapped.rb
bootstrapped-0.9.0 lib/generators/bootstrapped.rb