lgromanowski/acme-plugin

View on GitHub
app/models/acme_plugin/challenge.rb

Summary

Maintainability
A
0 mins
Test Coverage
module AcmePlugin
  # if the project doesn't use ActiveRecord, we assume the challenge will
  # be stored in the filesystem
  if AcmePlugin.config.challenge_dir_name.blank? && defined?(ActiveRecord::Base) == 'constant' && ActiveRecord::Base.class == Class
    class Challenge < ActiveRecord::Base
    end
  else
    class Challenge
      attr_accessor :response

      def initialize
        full_challenge_dir = File.join(Rails.root, AcmePlugin.config.challenge_dir_name, 'challenge')
        @response = IO.read(full_challenge_dir)
      end
    end
  end
end