Sha256: d9ab22298aa684e320d975d5c15d15618005902a41361924c2faa223cd6427de

Contents?: true

Size: 1.39 KB

Versions: 17

Compression:

Stored size: 1.39 KB

Contents

module Inch
  # Stores the configuration for Inch
  #
  # @see config/base.rb
  class Config
    class << self
      def instance(language = :ruby)
        if (block = @blocks[language.to_s])
          config = Config::Base.new(language)
          config = config.update(&block)
          config
        else
          fail "Language not registered: #{language}"
        end
      end

      # Registers a configuration block for a given language.
      #
      # @return [void]
      def register(language, &block)
        @blocks ||= {}
        @blocks[language.to_s] = block
      end

      def codebase(language = :ruby)
        instance(language).codebase
      end

      def base(&block)
        Config::Base.new(:__base__).update(&block)
      end

      # Returns the Config object for a given +language+.
      # Optionally parses a given +path+ for inch.yml
      #
      # @return [Config::Base]
      def for(language, path = nil)
        config = instance(language)
        config.codebase.update_via_yaml(path) if path
        config
      end

      def namespace(language, submodule = nil)
        name = language.to_s.split('_').map { |w| w.capitalize }.join
        const = ::Inch::Language.const_get(name)
        const = const.const_get(submodule) unless submodule.nil?
        const
      end
    end
  end
end

require 'inch/config/base'
require 'inch/config/evaluation'
require 'inch/config/codebase'

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
inch-0.5.10 lib/inch/config.rb
inch-0.5.9 lib/inch/config.rb
inch-0.5.8 lib/inch/config.rb
inch-0.5.7 lib/inch/config.rb
inch-0.5.6 lib/inch/config.rb
inch-0.5.5 lib/inch/config.rb
inch-0.5.4 lib/inch/config.rb
inch-0.5.3 lib/inch/config.rb
inch-0.5.2 lib/inch/config.rb
inch-0.5.1 lib/inch/config.rb
inch-0.5.0 lib/inch/config.rb
inch-0.5.0.rc11 lib/inch/config.rb
inch-0.5.0.rc10 lib/inch/config.rb
inch-0.5.0.rc9 lib/inch/config.rb
inch-0.5.0.rc8 lib/inch/config.rb
inch-0.5.0.rc7 lib/inch/config.rb
inch-0.5.0.rc6 lib/inch/config.rb