Sha256: 3b0896f60d20ac9727eecab873f58b511d8f3e142bd6dac1d4a9cfc5dcebb54a

Contents?: true

Size: 905 Bytes

Versions: 7

Compression:

Stored size: 905 Bytes

Contents

require "rails/generators"

module Ahoy
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      def copy_templates
        activerecord = defined?(ActiveRecord)
        mongoid = defined?(Mongoid)

        selection =
          if activerecord && mongoid
            puts <<-MSG

Which data store would you like to use?
 1. ActiveRecord (default)
 2. Mongoid
 3. Neither
            MSG

            ask(">")
          elsif activerecord
            "1"
          elsif mongoid
            "2"
          else
            "3"
          end

        case selection
        when "", "1"
          invoke "ahoy:activerecord"
        when "2"
          invoke "ahoy:mongoid"
        when "3"
          invoke "ahoy:base"
        else
          abort "Error: must enter a number [1-3]"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ahoy_matey-3.0.0 lib/generators/ahoy/install_generator.rb
ahoy_matey-2.2.1 lib/generators/ahoy/install_generator.rb
ahoy_matey-2.2.0 lib/generators/ahoy/install_generator.rb
ahoy_matey-2.1.0 lib/generators/ahoy/install_generator.rb
ahoy_matey-2.0.2 lib/generators/ahoy/install_generator.rb
ahoy_matey-2.0.1 lib/generators/ahoy/install_generator.rb
ahoy_matey-2.0.0 lib/generators/ahoy/install_generator.rb