<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>config.example.yml</filename>
    </added>
    <added>
      <filename>spec/vanilla_app_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,5 @@ pkg
 *.db
 .DS_Store
 *~
-vanilla-authorization.yml
 tmp
-defensio.yml
+config.yml</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ Thee Darke Invocation
 
 $ gem install soup sqlite3-ruby rack ratom RedCloth BlueCloth
 
-$ rake bootstrap
+$ rake setup
 
 ... a bunch of stuff gets created
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -71,8 +71,9 @@ task :upgrade =&gt; [&quot;upgrade:dynasnips&quot;]
 desc 'Add a user (or change an existing password)'
 task :add_user =&gt; :prepare do
   puts &quot;Adding a new user&quot;
-  credential_file = File.join(Vanilla::App.root,'config','vanilla-authorization.yml')
-  credentials = YAML.load(File.open(credential_file)) rescue {}
+  # config_file = ENV['VANILLA_CONFIG'] || 'config.yml'
+  # config_file = YAML.load(File.open(config_file)) rescue {}
+  app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
   print &quot;Username: &quot;
   username = STDIN.gets.chomp.strip
   print &quot;Password: &quot;
@@ -82,14 +83,15 @@ task :add_user =&gt; :prepare do
   if password != confirm_password
     raise &quot;Passwords don't match!&quot;
   else
-    credentials[username] = MD5.md5(password).to_s
-    File.open(credential_file, &quot;w&quot;) { |f| f.write credentials.to_yaml }
+    app.config[:credentials] ||= {}
+    app.config[:credentials][username] = MD5.md5(password).to_s
+    app.config.save!
     puts &quot;User '#{username}' added.&quot;
   end
 end
 
 desc 'Generate file containing secret for cookie-based session storage'
-task :generate_secret_file do
+task :generate_secret do
   # Adapted from old rails secret generator.
   require 'openssl'
   if !File.exist?(&quot;/dev/urandom&quot;)
@@ -103,8 +105,10 @@ task :generate_secret_file do
   end
   data = OpenSSL::BN.rand(2048, -1, false).to_s
   secret = OpenSSL::Digest::SHA512.new(data).hexdigest
-  File.open(File.join(Vanilla::App.root,'config','secret.yml'),'w') {|f| f.write({&quot;secret&quot; =&gt; secret}.to_yaml)}
-  puts &quot;Secret file generated.&quot;
+  app = Vanilla::App.new(ENV['VANILLA_CONFIG'])
+  app.config[:secret] = secret
+  app.config.save!
+  puts &quot;Secret generated.&quot;
 end
 
 
@@ -123,7 +127,11 @@ EOM
   
   puts &lt;&lt;-EOM
   
-Generating the file that will contain the secret for cookie-based session storage.
+Now I'm going to generate your configuration. This will be stored either in
+'config.yml' in the current directory, or in the path you provide via the
+environment variable VANILLA_CONFIG.  
+
+Generating the secret for cookie-based session storage.
 EOM
   Rake::Task[:generate_secret_file].invoke
   </diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -6,4 +6,4 @@ use Rack::Session::Cookie, :key =&gt; 'vanilla.session',
                            :expire_after =&gt; 2592000,
 			   :secret =&gt; YAML.load(File.read(File.join(Vanilla::App.root,'config','secret.yml')))['secret']
 use Rack::Static, :urls =&gt; [&quot;/public&quot;], :root =&gt; File.join(File.dirname(__FILE__), *%w[vanilla])
-run Vanilla::App.new
\ No newline at end of file
+run Vanilla::App.new(ENV['VANILLA_CONFIG'])
\ No newline at end of file</diff>
      <filename>config.ru</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,10 @@ require 'vanilla/request'
 module Vanilla
   class App
     
-    attr_reader :request, :response
+    attr_reader :request, :response, :config
     
-    def initialize
+    def initialize(config_file=nil)
+      prepare_configuration(config_file)
       Soup.prepare
     end
     
@@ -83,9 +84,15 @@ module Vanilla
       &quot;[snip '#{snip_name}' cannot be found]&quot;
     end
     
-    def self.root
-      File.dirname(__FILE__)
-    end
+    private
     
+    def prepare_configuration(config_file)
+      config_file ||= &quot;config.yml&quot;
+      @config = YAML.load(File.open(config_file)) rescue {}
+      @config[:filename] = config_file
+      def @config.save!
+        File.open(self[:filename], 'w') { |f| f.puts self.to_yaml }
+      end
+    end
   end
 end</diff>
      <filename>lib/vanilla/app.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,8 +27,7 @@ class Login &lt; Dynasnip
   end
   
   def post(*args)
-    credentials = YAML.load(File.open(File.join(Vanilla::App.root,'config','vanilla-authorization.yml')))
-    if credentials[cleaned_params[:name]] == MD5.md5(cleaned_params[:password]).to_s
+    if app.config[:credentials][cleaned_params[:name]] == MD5.md5(cleaned_params[:password]).to_s
       app.request.session['logged_in_as'] = cleaned_params[:name]
       login_controls
     else</diff>
      <filename>lib/vanilla/dynasnips/login.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/vanilla/config/secret.yml.example</filename>
    </removed>
    <removed>
      <filename>lib/vanilla/config/vanilla-authorization.yml.example</filename>
    </removed>
    <removed>
      <filename>spec/vanilla_rack_app_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>b4eed26f3f2011eb924a34f915680c9992f8c26f</id>
    </parent>
  </parents>
  <author>
    <name>James Adam</name>
    <email>james@lazyatom.com</email>
  </author>
  <url>http://github.com/lazyatom/vanilla-rb/commit/3e44c1fc51ad326d2f77a71bf676d21a01c80959</url>
  <id>3e44c1fc51ad326d2f77a71bf676d21a01c80959</id>
  <committed-date>2008-12-13T05:19:43-08:00</committed-date>
  <authored-date>2008-12-13T05:19:43-08:00</authored-date>
  <message>There should be a simple, unified way of configuring a running Vanilla application, which doesn't involve putting the config into Vanilla itself. This should make it simpler for Vanilla to simply be a gem in the future.</message>
  <tree>b99be67fd2a3a7998980454d5efefc8c55dffbe6</tree>
  <committer>
    <name>James Adam</name>
    <email>james@lazyatom.com</email>
  </committer>
</commit>
