Class: Catalyst::Manifest
- Inherits:
-
Object
- Object
- Catalyst::Manifest
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/catalyst/manifest.rb
Constant Summary collapse
- AssetMissing =
Class.new(::Catalyst::CatalystError)
- DuplicateAssetReference =
Class.new(::Catalyst::CatalystError)
Instance Method Summary collapse
- #[](path) ⇒ Object
- #has?(path) ⇒ Boolean
-
#initialize ⇒ Manifest
constructor
A new instance of Manifest.
Constructor Details
#initialize ⇒ Manifest
Returns a new instance of Manifest.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/catalyst/manifest.rb', line 21 def initialize if Catalyst.development? @manifest = {} else if Catalyst.config.manifest_path.nil? raise 'Missing "manifest_path" configuration.' end @manifest = JSON.parse(File.read(Catalyst.config.manifest_path)) end end |
Instance Method Details
#[](path) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/catalyst/manifest.rb', line 43 def [](path) path = path.to_s.gsub(/\A\/+/, '') if Catalyst.development? dev_server_host = Catalyst.config.dev_server_host dev_server_port = Catalyst.config.dev_server_port if dev_server_host.nil? raise 'Missing "dev_server_host" configuration.' end if dev_server_port.nil? raise 'Missing "dev_server_port" configuration.' end return "http://#{dev_server_host}:#{dev_server_port}/#{path}" else if @manifest.key?(path) return @manifest[path] else raise AssetMissing, "Couldn't find an asset for path: #{path}" end end end |
#has?(path) ⇒ Boolean
33 34 35 36 37 38 39 40 41 |
# File 'lib/catalyst/manifest.rb', line 33 def has?(path) path = path.to_s.gsub(/\A\/+/, '') if Catalyst.development? false else @manifest.key?(path) end end |