Sha256: 7ade1f6ab1f725fcafe740df46a3e7ca9ed25b50d1343059f3cd81251c3659c3

Contents?: true

Size: 1.78 KB

Versions: 8

Compression:

Stored size: 1.78 KB

Contents

module OrigenTesters
  class Doc
    module Generator
      class Test
        attr_accessor :name, :index, :version, :append_version, :attributes

        def initialize(name, attrs = {})
          attrs = {}.merge(attrs)  # Important to keep this to clone the original options
          # so that the caller's copy if not affected by stripping
          # out the flow/relation options
          @attributes = {}
          @append_version = true
          self.name = name
          Origen.interface.extract_relation_options!(attrs)
          Origen.interface.extract_flow_control_options!(attrs)
          attrs.each do |attribute, val|
            @attributes[attribute] = val
          end
        end

        def to_yaml(options = {})
          {
            'attributes' => attributes_to_yaml(options)
          }
        end

        def attributes_to_yaml(_options = {})
          a = {}
          @attributes.each do |name, val|
            a[name.to_s] = val if val
          end
          a['name'] = name
          a
        end

        def method_missing(method, *args, &_block)
          method = method.to_s
          if method.gsub!('=', '')
            @attributes[method] = args.first
          else
            @attributes[method]
          end
        end

        def ==(other_test)
          self.class == other_test.class &&
            unversioned_name.to_s == other_test.unversioned_name.to_s &&
            attributes.size == other_test.attributes.size &&
            attributes.all? { |name, val| other_test.attributes[name] == val }
        end

        def name
          if version && @append_version
            "#{@name}_v#{version}"
          else
            @name.to_s
          end
        end

        def unversioned_name
          @name.to_s
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
origen_testers-0.5.7 lib/origen_testers/doc/generator/test.rb
origen_testers-0.5.6 lib/origen_testers/doc/generator/test.rb
origen_testers-0.5.5 lib/origen_testers/doc/generator/test.rb
origen_testers-0.5.4 lib/origen_testers/doc/generator/test.rb
origen_testers-0.5.3 lib/origen_testers/doc/generator/test.rb
origen_testers-0.5.2 lib/origen_testers/doc/generator/test.rb
origen_testers-0.5.1 lib/origen_testers/doc/generator/test.rb
origen_testers-0.5.0 lib/origen_testers/doc/generator/test.rb