Class: Origen::Application::VersionTracker
- Defined in:
- lib/origen/application/version_tracker.rb
Overview
Keeps track of production released versions
Constant Summary collapse
Instance Method Summary collapse
-
#add_version(version) ⇒ Object
Adds a new version to the tracker.
-
#check_in ⇒ Object
Check in the persisted storage container.
-
#restore_to_latest ⇒ Object
Force the storage container to the latest checked in version.
-
#save ⇒ Object
Save the persisted storage container to disk.
-
#storage ⇒ Object
Returns the persisted storage container (a Hash).
-
#versions ⇒ Object
Returns an array containing all Production release tags since they started being tracked.
Instance Method Details
#add_version(version) ⇒ Object
Adds a new version to the tracker
14 15 16 17 18 19 |
# File 'lib/origen/application/version_tracker.rb', line 14 def add_version(version) restore_to_latest versions << version save check_in end |
#check_in ⇒ Object
Check in the persisted storage container
44 45 46 |
# File 'lib/origen/application/version_tracker.rb', line 44 def check_in Origen.app.rc.checkin(STORAGE_FILE, force: true, unmanaged: true, comment: 'Recorded new version in the version tracker') end |
#restore_to_latest ⇒ Object
Force the storage container to the latest checked in version
49 50 51 52 53 54 55 |
# File 'lib/origen/application/version_tracker.rb', line 49 def restore_to_latest @storage = nil # Check out the latest version of the storage, forcing to Trunk system "dssc co -get -force '#{STORAGE_FILE};Trunk:Latest'" system "dssc setselector 'Trunk' #{STORAGE_FILE}" `chmod 666 #{STORAGE_FILE}` end |
#save ⇒ Object
Save the persisted storage container to disk
37 38 39 40 41 |
# File 'lib/origen/application/version_tracker.rb', line 37 def save File.open(STORAGE_FILE, 'w') do |f| Marshal.dump(storage, f) end end |
#storage ⇒ Object
Returns the persisted storage container (a Hash)
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/origen/application/version_tracker.rb', line 22 def storage return @storage if @storage if File.exist?(STORAGE_FILE) File.open(STORAGE_FILE) do |f| @storage = Marshal.load(f) rescue @storage = {} end else @storage = {} end end |
#versions ⇒ Object
Returns an array containing all Production release tags since they started being tracked
9 10 11 |
# File 'lib/origen/application/version_tracker.rb', line 9 def versions storage[:versions] ||= [] end |