Class: Cas::Installation
- Inherits:
-
Object
- Object
- Cas::Installation
- Defined in:
- lib/cas/installation.rb
Instance Method Summary collapse
- #generate_sites ⇒ Object
-
#initialize(filename: nil, logger: Rails.logger) ⇒ Installation
constructor
A new instance of Installation.
Constructor Details
#initialize(filename: nil, logger: Rails.logger) ⇒ Installation
Returns a new instance of Installation.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cas/installation.rb', line 3 def initialize(filename: nil, logger: Rails.logger) @logger = logger @filename = filename @filename ||= begin if Rails.env.test? "spec/fixtures/cas.yml" else Cas::CONFIG_PATH end end # Ruby 3.0 comes with Psych 3, while Ruby 3.1 comes with Psych 4, which # has a major breaking change (diff 3.3.2 → 4.0.0). # # The new YAML loading methods (Psych 4) do not load aliases unless # they get the aliases: true argument. The old YAML loading methods # (Psych 3) do not support the :aliases keyword. begin @config = YAML.safe_load_file(@filename, aliases: true) rescue NoMethodError, ArgumentError @config = YAML.load_file(@filename) end end |
Instance Method Details
#generate_sites ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cas/installation.rb', line 27 def generate_sites @logger.info "Creating data..." ActiveRecord::Base.transaction do @logger.info " - admins" create_initial_admins @logger.info " - sites" create_sites @logger.info " - setting superadmins" set_superadmins end @logger.info "Done." end |