Sha256: 6c97485d63731baf00d14e4afa68d7da4e547ace9b44df13dd852f79827107c1

Contents?: true

Size: 1.43 KB

Versions: 106

Compression:

Stored size: 1.43 KB

Contents

module OrigenTesters
  module Parser
    class DescriptionLookup
      def initialize
        @store = { flow: {}, test: {}, usage: {} }
      end

      def for_flow(name, options = {})
        k = flow_key(name)
        @store[:flow][k] || []
      end

      def for_test_definition(name, options = {})
        n = name_key(name)
        @store[:test][n] || []
      end

      def for_test_usage(name, flow, options = {})
        k = flow_key(flow)
        n = name_key(name)
        @store[:usage][k] ||= {}
        @store[:usage][k][n] || []
      end

      def add_for_flow(flow, description, options = {})
        k = flow_key(flow)
        @store[:flow][k] ||= []
        [description].flatten.each do |d|
          @store[:flow][k] << d
        end
      end

      def add_for_test_definition(test, description, option = {})
        n = name_key(test)
        @store[:test][n] ||= []
        [description].flatten.each do |d|
          @store[:test][n] << d
        end
      end

      def add_for_test_usage(test, flow, description, option = {})
        k = flow_key(flow)
        n = name_key(test)
        @store[:usage][k] ||= {}
        @store[:usage][k][n] ||= []
        [description].flatten.each do |d|
          @store[:usage][k][n] << d
        end
      end

      private

      def flow_key(flow)
        Pathname.new(flow).basename('.*').to_s
      end

      def name_key(name)
        name.to_s.downcase
      end
    end
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
origen_testers-0.52.8 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.52.7 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.52.6 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.52.5 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.52.4 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.52.3 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.52.1 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.52.0 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.51.5 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.51.4 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.51.3 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.51.2 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.51.1 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.51.0 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.50.0 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.49.4 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.49.3 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.49.2 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.49.1 lib/origen_testers/parser/description_lookup.rb
origen_testers-0.49.0 lib/origen_testers/parser/description_lookup.rb