Sha256: 34e290f4b3d204ee1baebef0c0729019cb5fb8d17ba853c0eea8249a71260dcb

Contents?: true

Size: 1.91 KB

Versions: 18

Compression:

Stored size: 1.91 KB

Contents

module Origen
  module Tester
    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
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
origen-0.2.6 lib/origen/tester/doc/generator/test.rb
origen-0.2.5 lib/origen/tester/doc/generator/test.rb
origen-0.2.4 lib/origen/tester/doc/generator/test.rb
origen-0.2.3 lib/origen/tester/doc/generator/test.rb
origen-0.2.2 lib/origen/tester/doc/generator/test.rb
origen-0.2.1 lib/origen/tester/doc/generator/test.rb
origen-0.2.0 lib/origen/tester/doc/generator/test.rb
origen-0.1.3 lib/origen/tester/doc/generator/test.rb
origen-0.1.2 lib/origen/tester/doc/generator/test.rb
origen-0.1.1 lib/origen/tester/doc/generator/test.rb
origen-0.1.0 lib/origen/tester/doc/generator/test.rb
origen-0.0.9 lib/origen/tester/doc/generator/test.rb
origen-0.0.8 lib/origen/tester/doc/generator/test.rb
origen-0.0.6 lib/origen/tester/doc/generator/test.rb
origen-0.0.5 lib/origen/tester/doc/generator/test.rb
origen-0.0.4 lib/origen/tester/doc/generator/test.rb
origen-0.0.3 lib/origen/tester/doc/generator/test.rb
origen-0.0.2 lib/origen/tester/doc/generator/test.rb