require "contentful_rails/engine"
require "contentful_rails/development_constraint"
require 'contentful_rails/caching/timestamps'
require "contentful_rails/markdown_renderer"
require "contentful_rails/nested_resource"
require "contentful_rails/sluggable"
require "contentful_rails/preview"
require 'redcarpet'

module ContentfulRails
  class << self
    attr_accessor :configuration
  end

  def self.configure
    self.configuration ||= Configuration.new
    yield(configuration)
  end

  class Configuration
    attr_accessor :authenticate_webhooks,
                  :webhooks_username,
                  :webhooks_password,
                  :slug_delimiter,
                  :perform_caching,
                  :access_token,
                  :preview_access_token,
                  :space,
                  :contentful_options,
                  :preview_username,
                  :preview_password,
                  :preview_domain,
                  :enable_preview_domain

    def initialize
      @authenticate = true
      @slug_delimiter = "-"
      @perform_caching = Rails.configuration.action_controller.perform_caching
      @contentful_options = {}
    end
  end
end

require 'redcarpet'
require 'contentful_model'

require "contentful_rails/engine"
require "contentful_rails/development_constraint"
require 'contentful_rails/caching/timestamps'
require "contentful_rails/markdown_renderer"
require "contentful_rails/nested_resource"
require "contentful_rails/sluggable"
require "contentful_rails/preview"

module ContentfulRails
  class << self
    attr_accessor :configuration
  end

  def self.configure
    self.configuration ||= Configuration.new
    yield(configuration)
  end

  class Configuration
    attr_accessor :authenticate_webhooks,
                  :webhooks_username,
                  :webhooks_password,
                  :slug_delimiter,
                  :perform_caching,
                  :access_token,
                  :preview_access_token,
                  :space,
                  :contentful_options,
                  :preview_username,
                  :preview_password,
                  :preview_domain,
                  :enable_preview_domain

    def initialize
      @authenticate = true
      @slug_delimiter = "-"
      @perform_caching = Rails.configuration.action_controller.perform_caching
      @contentful_options = {}
    end
  end
end

Add explicit require to load contentful_model
Add explicit require to load contentful_model

Also move redcarpet up so that both external gem requires are done
before the "internal" requires of other files within this gem.

Used ActiveRecord as a model for this, knowing it has several external
requirements as well.

https://github.com/rails/rails/blob/c3133f50bc7b09c945f6387f3a64539b75d3dbc9/activerecord/lib/active_record.rb
