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
Returns a new instance of BranchUpgrade.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 XMigra.log_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.
32 33 34 |
# File 'lib/xmigra/branch_upgrade.rb', line 32 def base_migration @base_migration end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
32 33 34 |
# File 'lib/xmigra/branch_upgrade.rb', line 32 def file_path @file_path end |
#migration_completed ⇒ Object (readonly)
Returns the value of attribute migration_completed.
32 33 34 |
# File 'lib/xmigra/branch_upgrade.rb', line 32 def migration_completed @migration_completed end |
#target_branch ⇒ Object (readonly)
Returns the value of attribute target_branch.
32 33 34 |
# File 'lib/xmigra/branch_upgrade.rb', line 32 def target_branch @target_branch end |
Instance Method Details
#applicable?(mig_chain) ⇒ Boolean
38 39 40 41 42 43 |
# File 'lib/xmigra/branch_upgrade.rb', line 38 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
34 35 36 |
# File 'lib/xmigra/branch_upgrade.rb', line 34 def found? @found end |
#has_warnings? ⇒ Boolean
45 46 47 |
# File 'lib/xmigra/branch_upgrade.rb', line 45 def has_warnings? not @warnings.empty? end |
#migration_completed_id ⇒ Object
63 64 65 |
# File 'lib/xmigra/branch_upgrade.rb', line 63 def migration_completed_id Migration.id_from_filename(XMigra.yaml_path(migration_completed)) end |
#sql ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/xmigra/branch_upgrade.rb', line 53 def sql if Plugin.active @sql.dup.tap do |result| Plugin.active.amend_source_sql(result) end else @sql end end |
#warnings ⇒ Object
49 50 51 |
# File 'lib/xmigra/branch_upgrade.rb', line 49 def warnings @warnings.dup end |