Sha256: fee2761f5276413a318a8732616abb36484be0c2efc7e8c7a9bf72ff256e9c98

Contents?: true

Size: 1.04 KB

Versions: 110

Compression:

Stored size: 1.04 KB

Contents

module Picky

  module Generators

    # Selects the right generator.
    #
    class Selector

      attr_reader :types

      def initialize
        @types = {
          :client               => [Client::Sinatra, :sinatra_client_name],
          :server               => [Server::Sinatra, :sinatra_server_name],
          :all_in_one           => [AllInOne::Sinatra, :"directory_name (use e.g. for Heroku)"]
        }
      end

      # Run the generators with this command.
      #
      # This will "route" the commands to the right specific generator.
      #
      def generate *args
        generator = generator_for *args
        generator.generate
      end

      #
      #
      def generator_for identifier = nil, *args
        generator_info = types[identifier.to_sym]
        generator_class = generator_info.first
        generator_for_class generator_class, identifier, *args
      rescue
        raise NotFoundException.new(self)
      end

      #
      #
      def generator_for_class klass, *args
        klass.new *args
      end
    end

  end

end

Version data entries

110 entries across 110 versions & 1 rubygems

Version Path
picky-generators-4.14.0 lib/picky-generators/generators/selector.rb
picky-generators-4.13.1 lib/picky-generators/generators/selector.rb
picky-generators-4.13.0 lib/picky-generators/generators/selector.rb
picky-generators-4.12.13 lib/picky-generators/generators/selector.rb
picky-generators-4.12.12 lib/picky-generators/generators/selector.rb
picky-generators-4.12.11 lib/picky-generators/generators/selector.rb
picky-generators-4.12.10 lib/picky-generators/generators/selector.rb
picky-generators-4.12.8 lib/picky-generators/generators/selector.rb
picky-generators-4.12.7 lib/picky-generators/generators/selector.rb
picky-generators-4.12.6 lib/picky-generators/generators/selector.rb
picky-generators-4.12.5 lib/picky-generators/generators/selector.rb
picky-generators-4.12.4 lib/picky-generators/generators/selector.rb
picky-generators-4.12.3 lib/picky-generators/generators/selector.rb
picky-generators-4.12.2 lib/picky-generators/generators/selector.rb
picky-generators-4.12.1 lib/picky-generators/generators/selector.rb
picky-generators-4.12.0 lib/picky-generators/generators/selector.rb
picky-generators-4.11.3 lib/picky-generators/generators/selector.rb
picky-generators-4.11.2 lib/picky-generators/generators/selector.rb
picky-generators-4.11.1 lib/picky-generators/generators/selector.rb
picky-generators-4.11.0 lib/picky-generators/generators/selector.rb