Module: JsImagePaths::Generator

Defined in:
lib/js_image_paths/generator.rb

Class Method Summary collapse

Class Method Details

.app_images_pathObject



18
19
20
# File 'lib/js_image_paths/generator.rb', line 18

def self.app_images_path
  @app_images_path ||= Rails.root.join('app/assets/images').to_s
end

.generateObject



5
6
7
# File 'lib/js_image_paths/generator.rb', line 5

def self.generate
  image_hash.to_json
end

.image_hashObject



9
10
11
12
13
14
15
16
# File 'lib/js_image_paths/generator.rb', line 9

def self.image_hash
  context.environment.each_file.each_with_object({}) do |path, images|
    next unless path.start_with?(app_images_path)

    asset = context.environment.find_asset(path)
    images[asset.logical_path] = context.asset_path(asset.logical_path)
  end
end