Sha256: 7b9a0d4196a8ee9f723ef814a7c674d866172f6a1c05cec8b2cbc984bfb78911

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module AliadaWebappRails
  class Assets
    def self.webapp_js_file
      @js_filename ||= parse_js_asset_route
    end

    def self.webapp_css_file
      @css_filename ||= parse_css_asset_route
    end

    class << self
      private

      def parse_js_asset_route
        js_file = gem_files.select { |file| webapp_js_file?(file) }.first
        js_file.gsub(/^public/, "")
      end

      def parse_css_asset_route
        css_file = gem_files.select { |file| webapp_css_file?(file) }.first
        css_file.gsub(/^public/, "")
      end

      def gem_files
        Gem::Specification.find_by_name("aliada_webapp_rails").files
      end

      def webapp_js_file?(file)
        case Rails.env
        when 'production'
          file[/public\/aliada_webapp_rails\/assets\/production\/app\..*\.js$/]
        else
          file[/public\/aliada_webapp_rails\/assets\/staging\/app\..*\.js$/]
        end
      end

      def webapp_css_file?(file)
        case Rails.env
        when 'production'
          file[/public\/aliada_webapp_rails\/assets\/production\/app\..*\.css$/]
        else
          file[/public\/aliada_webapp_rails\/assets\/staging\/app\..*\.css$/]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aliada_webapp_rails-1.1.0 config/initializers/aliada_webapp_rails.rb