Class: LesliSystem::Engines
- Inherits:
-
Object
- Object
- LesliSystem::Engines
- Defined in:
- lib/lesli_system/engines.rb
Constant Summary collapse
- ENGINES =
{}
Class Method Summary collapse
-
.engine(engine, property = nil) ⇒ Object
engine(“LesliAdmin”) engine(“LesliAdmin”, “name”).
-
.engines(local: false) ⇒ Object
Lesli::System.engines() Lesli::System.engines(:local => true).
Class Method Details
.engine(engine, property = nil) ⇒ Object
engine(“LesliAdmin”) engine(“LesliAdmin”, “name”)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lesli_system/engines.rb', line 8 def self.engine(engine, property=nil) engine = engine.to_s.camelize engines() if ENGINES.empty? # the Root engine represents the host Rails app engine = "Root" unless LESLI_ENGINES.include?(engine) # return specific property if requested return ENGINES[engine][property.to_sym] unless property.blank? # return the engine info return ENGINES[engine] end |
.engines(local: false) ⇒ Object
Lesli::System.engines() Lesli::System.engines(:local => true)
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/lesli_system/engines.rb', line 26 def self.engines local: false return ENGINES unless ENGINES.empty? # due we do not know the engine mounted path we have to look up for it every # time we load the html view so we can use the dynamic route from the main rails app # we use this in the url plugin LESLI_ENGINES.each do |engine| # skip if engine is not installed next unless Object.const_defined?(engine) # convert engine name to Ruby object engine_instance = "#{engine}".constantize # check if engines installed locally are required if local # build the path were engines should be installed engine_local_path = Rails.root.join("engines", engine) # do not include engines if not is locally installed next unless File.exist?(engine_local_path) end gem_specification = Gem::Specification.find_by_name(engine.underscore) # engine completelly information ENGINES[engine] = { :code => engine.underscore, :name => engine, :path => engine_instance::Engine.routes.find_script_name({}), :version => engine_instance::VERSION, :summary => gem_specification.summary, :description => gem_specification.description, :metadata => gem_specification., :build => engine_instance::BUILD, :dir => gem_specification.gem_dir } end # also include the rails main_app ENGINES["Root"] = { :code => "root", :name => "Root", :path => "/", :version => "1.0.0", :summary => "", :description => "", :metadata => [], :build => "0000000", :dir => Rails.root.to_s } ENGINES end |