require 'fileutils' require 'active_support/core_ext/object/blank' require 'active_support/core_ext/class/inheritable_attributes' require 'active_support/concern' module MediaControl class << self attr_accessor :root # Configuration options # * log: Enable message logging using ActiveRecord's logger if available or 'puts' if not. Defaults to true. def options @options ||= { :log => true } end def configure yield(self) if block_given? end # Log a message if logging is enabled in options def log message logger "[media_control] #{message}" if logging? end def logger message #:nodoc: puts message end def logging? #:nodoc: options[:log] end end end # Use Railties if we're using Rails if defined?(Rails) module MediaControl class Railtie < Rails::Railtie initializer "media_control.set_paths" do MediaControl.root = Rails.root.join(Rails.public_path).to_s end end # Since we're using Rails, use ActiveRecord's logger so it honors log levels, etc def logger message #:nodoc: ActiveRecord::Base.logger.info message end end end