48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/aka/upgrader.rb', line 48
def self.run(aka_db)
v2 = YAML::load_file(aka_db)
v3 = Configuration.new(:version => '3')
v2[:shortcuts].each do |_, shortcut|
v3.shortcuts << Configuration::Shortcut.new({
:shortcut => shortcut[:shortcut],
:command => shortcut[:command],
:tag => shortcut[:tag],
:description => shortcut[:description],
:function => shortcut[:function]
})
end
(v2[:links] || {}).each do |_, link|
v3.links << Configuration::Link.new({
:tag => link[:tag],
:output => link[:output]
})
end
FileUtils.cp(aka_db, "#{aka_db}.backup")
puts "Backed up to #{aka_db}.backup."
File.open(aka_db, 'w+') do |f|
f.write v3.encode
end
puts "Upgraded #{aka_db}."
end
|