Permalink
Browse files

added a simple mechanism to import / export settings.

Signed-off-by: Jim Gay <jim@saturnflyer.com>
  • Loading branch information...
1 parent 9b798b7 commit 6401aea13805b827c1951d738fbf6c6b8598108e @bryanl bryanl committed with saturnflyer Jan 31, 2009
Showing with 29 additions and 0 deletions.
  1. +29 −0 lib/tasks/settings_extension_tasks.rake
@@ -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.