Class: EngineAssets::PublicLocator
- Inherits:
-
Object
- Object
- EngineAssets::PublicLocator
- Defined in:
- lib/engine_assets/public_locator.rb
Class Attribute Summary collapse
-
.paths ⇒ Object
readonly
Returns the value of attribute paths.
Class Method Summary collapse
- .locate(file_path) ⇒ Object
-
.register(full_path) ⇒ Object
TODO: expose this as EngineAssets.register(…).
Class Attribute Details
.paths ⇒ Object (readonly)
Returns the value of attribute paths.
3 4 5 |
# File 'lib/engine_assets/public_locator.rb', line 3 def paths @paths end |
Class Method Details
.locate(file_path) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/engine_assets/public_locator.rb', line 27 def locate(file_path) full_paths = (paths || []).map { |base_path| File.join(base_path, file_path) } full_paths.each do |full_path| return full_path if File.exist?(full_path) end nil end |
.register(full_path) ⇒ Object
TODO: expose this as EngineAssets.register(…)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/engine_assets/public_locator.rb', line 6 def register(full_path) raise ArgumentError unless File.exist?(full_path) @paths ||= [] public_path = File.join(full_path, 'public') if File.exist?(public_path) # TODO: # * spec me # * split me into separate implementations if defined?(Rails) && Rails::VERSION::MAJOR == 3 # Rails 3 Rails.configuration.middleware.use ::ActionDispatch::Static, public_path else # Rails 2 paths << public_path end end end |