class Vara::StaticVersioner

Constants

MIGRATIONS_KEY
MIGRATIONS_RULES_KEY
MIGRATIONS_RULES_TO_KEY
PRODUCT_VERSION_KEY
TO_VERSION_KEY

Attributes

product_directory_path[R]
version[R]

Public Class Methods

new(product_directory_path, version) click to toggle source

@param product_directory_path [String] @param version [String] the product version

# File lib/vara/static_versioner.rb, line 13
def initialize(product_directory_path, version)
  begin
    Gem::Version.create(version)
  rescue
    raise Vara::VersionError, "Invalid version: #{version}"
  end

  @product_directory_path = product_directory_path
  @version = version
end

Public Instance Methods

update_content_migrations(migrations_hash) click to toggle source

@param migrations_hash [Hash] Hash contents of full content migrations @return [Hash] content migrations with product version value updated if necessary

# File lib/vara/static_versioner.rb, line 33
def update_content_migrations(migrations_hash)
  migrations_hash[TO_VERSION_KEY] = version unless migrations_hash[TO_VERSION_KEY].nil?
  migrations_hash.fetch(MIGRATIONS_KEY, []).each do |migration|
    migration.fetch(MIGRATIONS_RULES_KEY, []).each do |rule|
      next unless updates_product_version?(rule)
      rule[MIGRATIONS_RULES_TO_KEY] = version
    end
  end
  migrations_hash
end
update_metadata(metadata_hash) click to toggle source

@param metadata_hash [Hash] Hash contents of full product metadata @return [Hash] product metadata with product version value updated

# File lib/vara/static_versioner.rb, line 26
def update_metadata(metadata_hash)
  metadata_hash[PRODUCT_VERSION_KEY].gsub!(/^.*$/, version)
  metadata_hash
end

Private Instance Methods

updates_product_version?(rule_hash) click to toggle source
# File lib/vara/static_versioner.rb, line 48
def updates_product_version?(rule_hash)
  rule_hash['type'] == 'update' && rule_hash['selector'] == 'product_version'
end