module GovukContentSchemaTestHelpers::Util
Public Class Methods
check_govuk_content_schemas_path!()
click to toggle source
# File lib/govuk-content-schema-test-helpers/util.rb, line 13 def self.check_govuk_content_schemas_path! if !File.exist?(Util.govuk_content_schemas_path) message = "Dependency govuk-content-schemas cannot be found at: #{govuk_content_schemas_path}." message += " Clone it to that directory, or set GOVUK_CONTENT_SCHEMAS_PATH (see README.md for details)." raise ImproperlyConfiguredError, message end end
formats()
click to toggle source
Get a list of the formats defined in govuk-content-schemas
# File lib/govuk-content-schema-test-helpers/util.rb, line 22 def self.formats Util.check_govuk_content_schemas_path! formats_directory = File.join(Util.govuk_content_schemas_path, "/formats") format_paths = Dir.glob("#{formats_directory}/*").select { |f| File.directory?(f) } format_paths.map { |path| File.basename(path) } end
govuk_content_schemas_path()
click to toggle source
# File lib/govuk-content-schema-test-helpers/util.rb, line 3 def self.govuk_content_schemas_path if ENV.fetch('GOVUK_CONTENT_SCHEMAS_PATH', '').start_with?("/") ENV['GOVUK_CONTENT_SCHEMAS_PATH'] else relative_path = ENV['GOVUK_CONTENT_SCHEMAS_PATH'] || '../govuk-content-schemas' project_root = GovukContentSchemaTestHelpers.configuration.project_root File.absolute_path(relative_path, project_root) end end