Sha256: 52a581431ea8853319187ca1baec5855d19b2cf6a991a3259816b8fbe15fa2a4
Contents?: true
Size: 1001 Bytes
Versions: 3
Compression:
Stored size: 1001 Bytes
Contents
module Keyrack # Migrate databases from one version to the next. class Migrator def self.run(database) new(database).run end def initialize(database) @database = database @version = database['version'] end def run case @version when 3 migrate_3_to_4(@database.clone) when 4 @database end end private def migrate_3_to_4(database) groups = [database['groups']['top']] until groups.empty? group = groups.pop group['sites'] = group['sites'].inject([]) do |arr, (site_name, site_hash)| site_hash['logins'].each_pair do |username, password| arr.push({ 'name' => site_name, 'username' => username, 'password' => password }) end arr end groups.push(*group['groups'].values) end database['version'] = 4 database end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
keyrack-0.3.2 | lib/keyrack/migrator.rb |
keyrack-0.3.1 | lib/keyrack/migrator.rb |
keyrack-0.3.0 | lib/keyrack/migrator.rb |