Skip to content

Commit

Permalink
added a simple mechanism to import / export settings.
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Gay <jim@saturnflyer.com>
  • Loading branch information
bryanl authored and saturnflyer committed Jun 30, 2009
1 parent 9b798b7 commit 6401aea
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/tasks/settings_extension_tasks.rake
Expand Up @@ -23,6 +23,35 @@ namespace :radiant do
cp file, RAILS_ROOT + path
end
end

desc "Export settings"
task :export => :environment do
configs = Radiant::Config.find(:all).map do |config|
{:key => config.key, :value => config.value, :description => c.description}
end
File.open('settings.yaml', 'w') do |f|
YAML.dump(configs, f)
end
end

desc "Import/Merge settings"
task :import => :environment do
if File.exist?("settings.yaml")
File.open("settings.yaml") do |f|
configs = YAML.load(f)
configs.each do |config|
if c = Radiant::Config.find_by_key(config[:key])
c.update_attributes(config)
else
Radiant::Config.create config
end
end
end
else
puts "A file called settings.yaml with your settings should exist"
end
end

end
end
end

0 comments on commit 6401aea

Please sign in to comment.