Class: AssetPathsFromManifest::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/asset_paths_from_manifest/manifest.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_path) ⇒ Manifest

Returns a new instance of Manifest.



15
16
17
18
# File 'lib/asset_paths_from_manifest/manifest.rb', line 15

def initialize(json_path)
  @json_path = json_path
  load
end

Class Method Details

.file_pathObject



10
11
12
# File 'lib/asset_paths_from_manifest/manifest.rb', line 10

def file_path
  AssetPathsFromManifest.configuration.manifest_json_path
end

.loadObject



6
7
8
# File 'lib/asset_paths_from_manifest/manifest.rb', line 6

def load
  new(file_path)
end

Instance Method Details

#loadObject



20
21
22
# File 'lib/asset_paths_from_manifest/manifest.rb', line 20

def load
  @data = File.exist?(@json_path) ? JSON.parse(File.read(@json_path)) : {}.freeze
end

#lookup(name) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/asset_paths_from_manifest/manifest.rb', line 24

def lookup(name)
  load if Rails.env.development?
  if @data['files']
    @data['files'][name]
  else
    @data[name]
  end
end