Class: Vara::StaticVersioner
- Inherits:
-
Object
- Object
- Vara::StaticVersioner
- Defined in:
- lib/vara/static_versioner.rb
Constant Summary collapse
- PRODUCT_VERSION_KEY =
'product_version'.freeze
- TO_VERSION_KEY =
'to_version'.freeze
- MIGRATIONS_KEY =
'migrations'.freeze
- MIGRATIONS_RULES_KEY =
'rules'.freeze
- MIGRATIONS_RULES_TO_KEY =
'to'.freeze
Instance Method Summary collapse
-
#initialize(product_directory_path, version) ⇒ StaticVersioner
constructor
A new instance of StaticVersioner.
-
#update_content_migrations(migrations_hash) ⇒ Hash
Content migrations with product version value updated if necessary.
-
#update_metadata(metadata_hash) ⇒ Hash
Product metadata with product version value updated.
Constructor Details
#initialize(product_directory_path, version) ⇒ StaticVersioner
Returns a new instance of StaticVersioner.
13 14 15 16 17 18 19 20 21 22 |
# 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 |
Instance Method Details
#update_content_migrations(migrations_hash) ⇒ Hash
Returns content migrations with product version value updated if necessary.
33 34 35 36 37 38 39 40 41 42 |
# 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) ⇒ Hash
Returns product metadata with product version value updated.
26 27 28 29 |
# File 'lib/vara/static_versioner.rb', line 26 def () [PRODUCT_VERSION_KEY].gsub!(/^.*$/, version) end |