<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>clearance/config/clearance_crypto_gems.yml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -66,12 +66,11 @@ end
 end
 
 # testing goodies
-gsub_file 'spec/spec_helper.rb', /(#{Regexp.escape(&quot;require 'spec/rails'&quot;)})/mi do |match|
-  &lt;&lt;-EOM
-#{match}
-require 'authlogic/testing/test_unit_helpers'
-  EOM
-end
+file_inject('/spec/spec_helper.rb',
+  &quot;require 'spec/rails'&quot;,
+  &quot;require 'authlogic/testing/test_unit_helpers'\n&quot;,
+  :after
+)
 
 # specs
 run 'mkdir -p spec/fixtures'
@@ -101,3 +100,5 @@ file 'app/views/layouts/application.html.haml',
   open(&quot;#{SOURCE}/authlogic/app/views/layouts/application.html.haml&quot;).read
 git :add =&gt; &quot;.&quot;
 git :commit =&gt; &quot;-a -m 'Added Layout'&quot;
+
+@auth_message = 'Authlogic authentication installed'</diff>
      <filename>authlogic/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,16 @@ def file_append(file, data)
   File.open(file, 'a') {|f| f.write(data) }
 end
 
+def file_inject(file_name, sentinel, string, before_after=:after)
+  gsub_file file_name, /(#{Regexp.escape(sentinel)})/mi do |match|
+    if :after == before_after
+      &quot;#{match}\n#{string}&quot;
+    else
+      &quot;#{string}\n#{match}&quot;
+    end
+  end
+end
+
 # Git
 file '.gitignore', open(&quot;#{SOURCE}/gitignore&quot;).read
 git :init
@@ -148,11 +158,12 @@ git :commit =&gt; &quot;-a -m 'Removed index.html. Added HomeController'&quot;
 
 # Setup Authentication
 templ = case ask(&lt;&lt;-EOQ
+
 Choose an Authentication method:
-                1) Authlogic
-                2) Clearance
-                3) restful_authentication
-                4) None of the above
+  1) Authlogic
+  2) Clearance
+  3) restful_authentication
+  4) None of the above
 EOQ
 ).to_s
   when '1'
@@ -168,5 +179,9 @@ end
 load_template(templ) unless templ.nil?
 
 puts &quot;\n#{'*' * 80}\n\n&quot;
+unless @auth_message.nil?
+  puts &quot;#{@auth_message}&quot;
+  puts ''
+end
 puts &quot;All done. Enjoy.&quot;
 puts &quot;\n#{'*' * 80}\n\n&quot;</diff>
      <filename>base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,8 +29,53 @@ route &quot;map.signup '/signup', :controller =&gt; 'users', :action =&gt; 'new'&quot;
 git :add =&gt; &quot;.&quot;
 git :commit =&gt; &quot;-a -m 'Added Clearance'&quot;
 
+crypto_name = nil
+crypto = case ask(&lt;&lt;-EOQ
+
+Which hashing algorithm do you want to use?
+  1) SHA1 (default in Clearance)
+  2) SHA512
+  3) BCrypt
+EOQ
+).to_s
+  when '2'
+    crypto_name = 'SHA512'
+    'include ClearanceCrypto::SHA512'
+  when '3'
+    crypto_name = 'BCrypt'
+    'include ClearanceCrypto::BCrypt'
+  else
+    nil
+end
+
+if crypto
+  file_append('config/gems.yml',
+    open(&quot;#{SOURCE}/clearance/config/clearance_crypto_gems.yml&quot;).read)
+
+  run 'sudo gemtools install'
+
+  file_inject('app/models/user.rb',
+    'class User &lt; ActiveRecord::Base',
+    &quot;require 'clearance_crypto/#{crypto_name.downcase}'\n&quot;,
+    :before
+  )
+
+  file_inject('app/models/user.rb',
+    'include Clearance::App::Models::User',
+    &quot;  #{crypto}&quot;,
+    :after
+  )
+
+  git :add =&gt; '.'
+  git :commit =&gt; &quot;-a -m 'Added ClearanceCrypto with #{crypto_name}'&quot;
+end
+
 # Application Layout
 file 'app/views/layouts/application.html.haml',
   open(&quot;#{SOURCE}/authlogic/app/views/layouts/application.html.haml&quot;).read
+
 git :add =&gt; &quot;.&quot;
 git :commit =&gt; &quot;-a -m 'Added Layout'&quot;
+
+@auth_message = 'Clearance authentication installed'
+@auth_message &lt;&lt; &quot; with #{crypto_name} hashing&quot; unless crypto_name.nil?
\ No newline at end of file</diff>
      <filename>clearance/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -62,3 +62,11 @@ puts &quot;Be sure to clean up the views converted to Haml (fix indenting, remove - e
 puts &quot;  app/views/sessions/new.html.haml&quot;
 puts &quot;  app/views/users/new.html.haml&quot;
 puts &quot;\n#{'*' * 80}\n&quot;
+
+@auth_message = &lt;&lt;-EOM
+restful_authentication installed
+
+Be sure to clean up the views converted to Haml (fix indenting, remove - end)
+  app/views/sessions/new.html.haml
+  app/views/users/new.html.haml
+EOM</diff>
      <filename>restful_authentication/base.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>113a71b4f3464ca6caf7487a5dfca5515807871d</id>
    </parent>
  </parents>
  <author>
    <name>Michael Moen</name>
    <email>michael@underpantsgnome.com</email>
  </author>
  <url>http://github.com/pixels-and-bits/strappy/commit/9fa3c47fd13d7f11f4cbc8349fd26f843de06072</url>
  <id>9fa3c47fd13d7f11f4cbc8349fd26f843de06072</id>
  <committed-date>2009-02-13T09:35:01-08:00</committed-date>
  <authored-date>2009-02-13T09:35:01-08:00</authored-date>
  <message>add ClearanceCrypto as an option when using Clearance for authentication</message>
  <tree>773d004710ca86e1c8f3d2d459dd60a2541ac873</tree>
  <committer>
    <name>Michael Moen</name>
    <email>michael@underpantsgnome.com</email>
  </committer>
</commit>
