1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-05 16:24:21 +01:00
fab-manager/lib/plugin_registry.rb

39 lines
755 B
Ruby
Raw Normal View History

2016-05-10 16:50:01 +02:00
class PluginRegistry
class << self
attr_writer :javascripts
attr_writer :stylesheets
def asset_globs
@asset_globs ||= Set.new
end
def javascripts
@javascripts ||= Set.new
end
def stylesheets
@stylesheets ||= Set.new
end
def code_insertions
@code_insertions ||= {}
end
2016-05-10 16:50:01 +02:00
end
def self.register_glob(root, extension, options=nil)
2019-01-31 17:15:26 +01:00
asset_globs << [root, extension, options || {}]
2016-05-10 16:50:01 +02:00
end
2019-01-31 17:15:26 +01:00
def self.register_asset(asset, _opts = nil)
2016-05-10 16:50:01 +02:00
if asset =~ /\.js$|\.js\.erb$|\.js\.es6$|\.coffee$|\.coffee\.erb/
2019-01-31 17:15:26 +01:00
javascripts << asset
2016-05-10 16:50:01 +02:00
elsif asset =~ /\.css$|\.scss$/
2019-01-31 17:15:26 +01:00
stylesheets << asset
2016-05-10 16:50:01 +02:00
end
2016-06-16 17:37:56 +02:00
end
2016-05-25 12:23:25 +02:00
2016-06-16 17:37:56 +02:00
def self.insert_code(key)
2019-01-31 17:15:26 +01:00
code_insertions[key]&.join('\n')
2016-05-10 16:50:01 +02:00
end
end