Sha256: 60532bee1d373a2f556b4f05e02e7d1ebb95f15ba7b67f7c900cc77f24229a00

Contents?: true

Size: 788 Bytes

Versions: 3

Compression:

Stored size: 788 Bytes

Contents

module Qa::Authorities::LocalSubauthority

  # Path to sub-authority files is either the full path to a directory or
  # the path to a directory relative to the Rails application
  def subauthorities_path
    if AUTHORITIES_CONFIG[:local_path].starts_with?(File::Separator)
      AUTHORITIES_CONFIG[:local_path]
    else
      File.join(Rails.root, AUTHORITIES_CONFIG[:local_path])
    end
  end

  # Local sub-authorities are any YAML files in the subauthorities_path
  def names
    unless Dir.exists? subauthorities_path
      raise Qa::ConfigDirectoryNotFound, "There's no directory at #{subauthorities_path}. You must create it in order to use local authorities"
    end
    Dir.entries(subauthorities_path).map { |f| File.basename(f, ".yml") if f.match(/yml$/) }.compact
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qa-0.7.0 lib/qa/authorities/local_subauthority.rb
qa-0.6.0 lib/qa/authorities/local_subauthority.rb
qa-0.5.0 lib/qa/authorities/local_subauthority.rb