Sha256: ad5942ab2632e81f52b396aa6cfc7e00002bb6f7490f4bcd6dc854708f124da8
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Alchemy # Utilities for Alchemy's mount point in the host rails app. # class MountPoint MOUNT_POINT_REGEXP = /mount\sAlchemy::Engine\s=>\s['|"](\/\w*)['|"]/ class << self # Returns the path of Alchemy's mount point in current rails app. # # @param [Boolean] remove_leading_slash_if_blank # Pass false to not return a leading slash on empty mount point. # def get(remove_leading_slash_if_blank = true) if path == "/" && remove_leading_slash_if_blank path.gsub(/\A\/\z/, '') else path end end # Returns the mount point path from the Rails app routes. # def path match = File.read(routes_file_path).match(MOUNT_POINT_REGEXP) if match.nil? raise "Alchemy mount point not found! Please run `bin/rake alchemy:mount'" else match[1] end end private def routes_file_path Rails.root.join('config/routes.rb') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alchemy_cms-3.1.0.beta6 | lib/alchemy/mount_point.rb |