Sha256: f860a17c88f361da2531784edc5390ce5412a21b16f0dbce52413f3452c5c7f1

Contents?: true

Size: 827 Bytes

Versions: 27

Compression:

Stored size: 827 Bytes

Contents

require 'active_support/inflector'

module Brightcontent
  class RoutesParser

    def self.parse(routes_hash=nil, engine_resources=nil)
      new(routes_hash, engine_resources).user_resource
    end

    def initialize(routes_hash=nil, engine_resources=nil)
      @routes_hash = routes_hash
      @engine_resources = engine_resources
    end

    def user_resource
      resource_names - engine_resources
    end

    private

    def resource_names
      routes_hash.map do |route|
        if route && route[:action] == "index"
          route[:controller].match(/brightcontent\/(.+)/)[1]
        end
      end.compact.uniq
    end

    def routes_hash
      @routes_hash ||= Engine.routes.routes.map(&:defaults)
    end

    def engine_resources
      @engine_resources ||= Brightcontent.engine_resources
    end

  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
brightcontent-core-2.0.30 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.29 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.28 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.27 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.26 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.25 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.24 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.23 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.22 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.21 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.20 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.19 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.18 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.17 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.16 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.15 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.14 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.13 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.12 lib/brightcontent/routes_parser.rb
brightcontent-core-2.0.11 lib/brightcontent/routes_parser.rb