Sha256: 9184680f39a2dbb555d7bdc07d5a8ae9a7e57e8232e4faa966048321d1344ce0

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

module Origen
  module Bugs
    extend ActiveSupport::Concern

    autoload :Bug, 'origen/bugs/bug'

    module ClassMethods # :nodoc:
      # Define a bug on the given IP
      def bug(name, options = {})
        name = name.to_s.downcase.to_sym
        bugs[name] = Bug.new(name, options)
        define_method "has_#{name}_bug?" do
          Origen.deprecate "Use has_bug?(:#{name}) instead of has_#{name}_bug?"
          has_bug?(name)
        end
      end

      def bugs
        @bugs ||= {}
      end
    end

    # Returns true if the version of the IP represented by the object has the bug of the
    # given name
    def has_bug?(name, _options = {})
      unless respond_to?(:version) && version
        puts 'To test for the presence of a bug the object must implement an attribute'
        puts "called 'version' which returns the IP version represented by the the object."
        fail 'Version undefined!'
      end
      name = name.to_s.downcase.to_sym
      if bugs[name]
        bugs[name].present_on_version?(version)
      else
        false
      end
    end

    # Returns a hash containing all known bugs associated with
    # the given IP, regardless of which version they are present on
    def bugs
      self.class.bugs
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
origen-0.60.19 lib/origen/bugs.rb
origen-0.60.18 lib/origen/bugs.rb
origen-0.60.17 lib/origen/bugs.rb
origen-0.60.16 lib/origen/bugs.rb
origen-0.60.14 lib/origen/bugs.rb
origen-0.60.13 lib/origen/bugs.rb
origen-0.60.12 lib/origen/bugs.rb
origen-0.60.11 lib/origen/bugs.rb
origen-0.60.10 lib/origen/bugs.rb
origen-0.60.9 lib/origen/bugs.rb
origen-0.60.8 lib/origen/bugs.rb