module RidgepoleRake
  class Configuration
    include ActiveSupport::Configurable

    # database configuration
    config_accessor :db_config do
      'config/database.yml'
    end

    # schema dir
    config_accessor :schema_dir do
      'db/schemas'
    end

    # schema file
    config_accessor :schema_file do
      'Schemafile'
    end

    # schema file path
    def schema_file_path
      "#{self.schema_dir}/#{self.schema_file}"
    end

    # schema dump file path
    def schema_dump_path
      "#{self.schema_dir}.dump/#{self.schema_file}"
    end

    # environment
    config_accessor :env do
      begin
        require 'rails'
        Rails.env
      rescue LoadError
        'development'
      end
    end

    # table options
    config_accessor :table_options

    # require options
    config_accessor :require_options

    # misc
    config_accessor :misc

    # use Bundler
    config_accessor :use_bundler do
      begin
        require 'bundler'
        true
      rescue LoadError
        false
      end
    end

    # use Bundler.clean_system
    config_accessor :use_clean_system do
      self.use_bundler
    end

    config_accessor :use_brancher do
      begin
        require 'brancher'
        true
      rescue LoadError
        false
      end
    end
  end
end

module RidgepoleRake
  class Configuration
    attr_accessor :ridgepole, :brancher, :bundler

    def initialize
      @ridgepole = Ridgepole.new
      @brancher  = Brancher.new
      @bundler   = Bundler.new
    end

    private

    class Ridgepole
      include ActiveSupport::Configurable

      config_accessor :config, :schema_path, :export_path, :env

      def initialize
        @config      = 'config/database.yml'
        @schema_path = 'db/schemas/Schemafile'
        @schema_path = 'db/schemas.dump/Schemafile'
        @env         = begin
                         require 'rails'
                         Rails.env
                       rescue LoadError
                         'development'
                       end
      end
    end

    class Brancher
      include ActiveSupport::Configurable

      config_accessor :enable

      def initialize
        @enable = begin
                    require 'brancher'
                    true
                  rescue LoadError
                    false
                  end
      end
    end

    class Bundler
      include ActiveSupport::Configurable

      config_accessor :enable, :clean_system

      def initialize
        @enable = begin
                    require 'bundler'
                    true
                  rescue LoadError
                    false
                  end
        @clean_system = @enable
      end
    end
  end
end

Use inner class in Ridgepole::Configuration
Use inner class in Ridgepole::Configuration
