Sha256: b5178e107b9e3e03c80b2bb852610653a6da908dfd50853c308c8b537b2217b5

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require 'ore/config'
require 'ore/template'

module Ore
  #
  # @api semipublic
  #
  # @since 0.9.0
  #
  module Options
    # Default version
    DEFAULT_VERSION = '0.1.0'

    # Default summary
    DEFAULT_SUMMARY = %q{TODO: Summary}

    # Default description
    DEFAULT_DESCRIPTION = %q{TODO: Description}

    # Default License
    DEFAULT_LICENSE = 'MIT'

    # Default authors
    DEFAULT_AUTHORS = [ENV['USER']]

    def self.included(base)
      base.extend ClassMethods
    end

    #
    # Default options for the generator.
    #
    # @return [Hash{Symbol => Object}]
    #   The option names and default values.
    #
    def self.defaults
      @@defaults ||= {
        :templates      => [],
        :version        => DEFAULT_VERSION,
        :summary        => DEFAULT_SUMMARY,
        :description    => DEFAULT_DESCRIPTION,
        :license        => DEFAULT_LICENSE,
        :authors        => DEFAULT_AUTHORS,
        :gemspec        => true,
        :rubygems_tasks => true,
        :rdoc           => true,
        :rspec          => true,
        :git            => true
      }.merge(Config.options)
    end

    module ClassMethods
      #
      # Defines a generator option.
      #
      # @param [Symbol] name
      #   The name of the option.
      #
      # @param [Hash{Symbol => Object}] options
      #   The Thor options of the option.
      #
      def generator_option(name,options={})
        class_option(name,options.merge(:default => Options.defaults[name]))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ore-0.9.2 lib/ore/options.rb
ore-0.9.1 lib/ore/options.rb
ore-0.9.0 lib/ore/options.rb