Class: Opencdd::Entity::VersionHistory

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/opencdd/entity/version_history.rb

Overview

Model object for the per-version provenance captured in downloads/<dict>/<CODE>/_entity.json#versions. Each entry represents one historical version of the entity: which version and revision it was, its status at that point, who committed it, and the change-request ID.

The ShardedDirReader parses _entity.json for each class subdir and attaches a VersionHistory to every entity it creates. The Json exporter then emits it as an array of version entries, matching the IEC CDD "Version history" section on detail pages.

Defined Under Namespace

Classes: Entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries = []) ⇒ VersionHistory

Returns a new instance of VersionHistory.



26
27
28
# File 'lib/opencdd/entity/version_history.rb', line 26

def initialize(entries = [])
  @entries = Array(entries)
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



30
31
32
# File 'lib/opencdd/entity/version_history.rb', line 30

def entries
  @entries
end

Instance Method Details

#attach(entry) ⇒ Object



56
57
58
59
# File 'lib/opencdd/entity/version_history.rb', line 56

def attach(entry)
  @entries << entry
  self
end

#currentObject



44
45
46
# File 'lib/opencdd/entity/version_history.rb', line 44

def current
  @entries.find(&:current?) || @entries.first
end

#each(&block) ⇒ Object



32
33
34
# File 'lib/opencdd/entity/version_history.rb', line 32

def each(&block)
  @entries.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/opencdd/entity/version_history.rb', line 40

def empty?
  @entries.empty?
end

#previousObject



48
49
50
# File 'lib/opencdd/entity/version_history.rb', line 48

def previous
  @entries.reject { |e| e == current }
end

#sizeObject



36
37
38
# File 'lib/opencdd/entity/version_history.rb', line 36

def size
  @entries.size
end

#to_aObject



52
53
54
# File 'lib/opencdd/entity/version_history.rb', line 52

def to_a
  @entries.dup
end