Class: XMigra::BranchUpgrade
Constant Summary collapse
- TARGET_BRANCH =
"resulting branch"- MIGRATION_COMPLETED =
"completes migration to"
Instance Attribute Summary collapse
-
#base_migration ⇒ Object
readonly
Returns the value of attribute base_migration.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#migration_completed ⇒ Object
readonly
Returns the value of attribute migration_completed.
-
#target_branch ⇒ Object
readonly
Returns the value of attribute target_branch.
Instance Method Summary collapse
- #applicable?(mig_chain) ⇒ Boolean
- #found? ⇒ Boolean
- #has_warnings? ⇒ Boolean
-
#initialize(path) ⇒ BranchUpgrade
constructor
A new instance of BranchUpgrade.
- #migration_completed_id ⇒ Object
- #sql ⇒ Object
- #warnings ⇒ Object
Constructor Details
#initialize(path) ⇒ BranchUpgrade
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/xmigra/branch_upgrade.rb', line 10 def initialize(path) @file_path = path @warnings = [] verinc_info = {} if path.exist? @found = true begin verinc_info = YAML.load_file(path) rescue Error => e warning "Failed to load branch upgrade migration (#{e.class}).\n #{e}" verinc_info = {} end end @base_migration = verinc_info[Migration::FOLLOWS] @target_branch = (XMigra.secure_digest(verinc_info[TARGET_BRANCH]) if verinc_info.has_key? TARGET_BRANCH) @migration_completed = verinc_info[MIGRATION_COMPLETED] @sql = verinc_info['sql'] end |
Instance Attribute Details
#base_migration ⇒ Object (readonly)
Returns the value of attribute base_migration.
31 32 33 |
# File 'lib/xmigra/branch_upgrade.rb', line 31 def base_migration @base_migration end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
31 32 33 |
# File 'lib/xmigra/branch_upgrade.rb', line 31 def file_path @file_path end |
#migration_completed ⇒ Object (readonly)
Returns the value of attribute migration_completed.
31 32 33 |
# File 'lib/xmigra/branch_upgrade.rb', line 31 def migration_completed @migration_completed end |
#target_branch ⇒ Object (readonly)
Returns the value of attribute target_branch.
31 32 33 |
# File 'lib/xmigra/branch_upgrade.rb', line 31 def target_branch @target_branch end |
Instance Method Details
#applicable?(mig_chain) ⇒ Boolean
37 38 39 40 41 42 |
# File 'lib/xmigra/branch_upgrade.rb', line 37 def applicable?(mig_chain) return false if mig_chain.length < 1 return false unless (@base_migration && @target_branch) return File.basename(mig_chain[-1].file_path) == XMigra.yaml_path(@base_migration) end |
#found? ⇒ Boolean
33 34 35 |
# File 'lib/xmigra/branch_upgrade.rb', line 33 def found? @found end |
#has_warnings? ⇒ Boolean
44 45 46 |
# File 'lib/xmigra/branch_upgrade.rb', line 44 def has_warnings? not @warnings.empty? end |
#migration_completed_id ⇒ Object
62 63 64 |
# File 'lib/xmigra/branch_upgrade.rb', line 62 def migration_completed_id Migration.id_from_filename(XMigra.yaml_path(migration_completed)) end |
#sql ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/xmigra/branch_upgrade.rb', line 52 def sql if Plugin.active @sql.dup.tap do |result| Plugin.active.amend_source_sql(result) end else @sql end end |
#warnings ⇒ Object
48 49 50 |
# File 'lib/xmigra/branch_upgrade.rb', line 48 def warnings @warnings.dup end |