Sha256: 69fcc7c4d1d0e5cc95baf500568dc5fae7750c5510f830f1894dfb4837626dd4

Contents?: true

Size: 1.68 KB

Versions: 25

Compression:

Stored size: 1.68 KB

Contents

require 'action_view'

module ErpApp
  module ApplicationResourceLoader
		class MobileLoader < ErpApp::ApplicationResourceLoader::BaseLoader
      
		  def initialize(application)
        @application = application
		  end

		  def locate_resources(resource_type)
        @app_name = @application.internal_identifier

        locate_resource_files(resource_type)
		  end

		  private

		  def locate_resource_files(resource_type)
  		  engine_dirs = Rails::Application::Railties.engines.map{|p| p.config.root.to_s}
        root_and_engines_dirs = ([Rails.root] | engine_dirs)

        application_files = []
  			root_and_engines_dirs.each do |engine_dir|
  			  #get all files based on resource type we are loading for the given application type and application
  			  path = File.join(engine_dir,"public/#{resource_type}/erp_app/mobile/applications",@app_name)
          if File.exists? path
  			    application_path = File.join(path,"**/*.#{(resource_type == 'javascripts') ? 'js' : 'css'}")
  			    application_files = application_files | Dir.glob(application_path)
            application_files.map!{|file| file.gsub(path,'')}
  			  end
  			end

        #make sure the base js file is loaded before all others
  			if resource_type == 'javascripts' && (application_files.index{|x| x =~ /app.js/})
  			  index = application_files.index{|x| x =~ /app.js/}
  			  first_load_js = application_files[index]
  			  application_files.delete_at(index)
  			  application_files.push(first_load_js)
  			end
        application_files.map!{|file| File.join("erp_app/mobile/applications",@app_name,file)}
		  end

		end#MobileLoader
  end#ApplicationResourceLoader
end#ErpApp

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
erp_app-3.0.5 lib/erp_app/application_resource_loader/mobile_loader.rb
erp_app-3.0.4 lib/erp_app/application_resource_loader/mobile_loader.rb
erp_app-3.0.3 lib/erp_app/application_resource_loader/mobile_loader.rb
erp_app-3.0.2 lib/erp_app/application_resource_loader/mobile_loader.rb
erp_app-3.0.1 lib/erp_app/application_resource_loader/mobile_loader.rb