Sha256: e175ba1ab020643559a03476ec97bd2e33f09d1ab53c66ac2386e3662c92d852

Contents?: true

Size: 919 Bytes

Versions: 15

Compression:

Stored size: 919 Bytes

Contents

require 'yaml'

module LtiProvider
  module LtiConfig
    def self.load_config
      YAML::load(File.open(config_file))[Rails.env]
    end

    def self.config_file
      LtiProvider.app_root.join('config/lti.yml')
    end

    def self.setup!
      config = LtiProvider::Config
      if File.exists?(config_file)
        Rails.logger.info "Initializing LTI key and secret using configuration in #{config_file}"
        load_config.each do |k,v|
          config.send("#{k}=", v)
        end
      elsif ENV['LTI_KEY'].present? && ENV['LTI_SECRET'].present?
        Rails.logger.info "Initializing LTI key and secret using environment vars LTI_KEY and LTI_SECRET"
        config.key = ENV['LTI_KEY']
        config.secret = ENV['LTI_SECRET']
        config.require_canvas = !!ENV['LTI_REQUIRE_CANVAS']
      else
        raise "Warning: LTI key and secret not configured for #{Rails.env})."
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
lti_provider_engine-1.2.0 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.9 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.8 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.7 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.6 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.5 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.4 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.3 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.2 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-2.0.1 lib/lti_provider/lti_config.rb
qalam_lti_provider_engine-1.1.6 lib/lti_provider/lti_config.rb
lti_provider_engine-1.1.0 lib/lti_provider/lti_config.rb
lti_provider_engine-1.0.0 lib/lti_provider/lti_config.rb
lti_provider_engine-0.0.6 lib/lti_provider/lti_config.rb
lti_provider_engine-0.0.5 lib/lti_provider/lti_config.rb