<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>query_reviewer_defaults.yml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,25 +1,30 @@
 # QueryReviewer
 require &quot;ostruct&quot;
-require &quot;query_reviewer/array_extensions&quot;
-require &quot;query_reviewer/sql_query&quot;
-require &quot;query_reviewer/sql_sub_query&quot;
-require &quot;query_reviewer/mysql_adapter_extensions&quot;
-require &quot;query_reviewer/controller_extensions&quot;
-
 
 module QueryReviewer
-  CONFIGURATION = YAML.load(File.read(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;query_reviewer.yml&quot;)))[&quot;all&quot;] || {}
-  CONFIGURATION.merge!(YAML.load(File.read(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;query_reviewer.yml&quot;)))[RAILS_ENV || &quot;development&quot;])
+  CONFIGURATION = {}
   
-  if CONFIGURATION[&quot;enabled&quot;]
-    begin      
-      CONFIGURATION[&quot;uv&quot;] ||= !Gem.searcher.find(&quot;uv&quot;).nil?
-      if CONFIGURATION[&quot;uv&quot;]
-        require &quot;uv&quot;
-      end
-    rescue
-      CONFIGURATION[&quot;uv&quot;] ||= false    
+  def self.load_configuration
+    CONFIGURATION.merge!(YAML.load(File.read(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;query_reviewer_defaults.yml&quot;)))[&quot;all&quot;] || {})
+    CONFIGURATION.merge!(YAML.load(File.read(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;query_reviewer_defaults.yml&quot;)))[RAILS_ENV || &quot;test&quot;] || {})
+    
+    app_config_file = File.join(RAILS_ROOT, &quot;config&quot;, &quot;query_reviewer.yml&quot;)
+    
+    if File.exist?(app_config_file)
+      CONFIGURATION.merge!(YAML.load(File.read(app_config_file))[&quot;all&quot;] || {}) 
+      CONFIGURATION.merge!(YAML.load(File.read(app_config_file))[RAILS_ENV || &quot;test&quot;] || {}) 
     end
+    
+    if CONFIGURATION[&quot;enabled&quot;]
+      begin      
+        CONFIGURATION[&quot;uv&quot;] ||= !Gem.searcher.find(&quot;uv&quot;).nil?
+        if CONFIGURATION[&quot;uv&quot;]
+          require &quot;uv&quot;
+        end
+      rescue
+        CONFIGURATION[&quot;uv&quot;] ||= false    
+      end
+    end    
   end
   
   class QueryWarning
@@ -37,4 +42,11 @@ module QueryReviewer
       @id = (self.class.next_id += 1)
     end
   end
-end
\ No newline at end of file
+end
+
+QueryReviewer.load_configuration
+require &quot;query_reviewer/array_extensions&quot;
+require &quot;query_reviewer/sql_query&quot;
+require &quot;query_reviewer/sql_sub_query&quot;
+require &quot;query_reviewer/mysql_adapter_extensions&quot;
+require &quot;query_reviewer/controller_extensions&quot;
\ No newline at end of file</diff>
      <filename>lib/query_reviewer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,22 +7,27 @@ module QueryReviewer
     end
     
     def self.included(base)
-      base.alias_method_chain :perform_action, :query_review
+      base.alias_method_chain :perform_action, :query_review if QueryReviewer::CONFIGURATION[&quot;inject_view&quot;]
       base.alias_method_chain :process, :query_review
+      base.helper_method :query_review_output
     end
     
     def add_query_output_to_view
       if response.body.match(/&lt;\/body&gt;/i) &amp;&amp; Thread.current[&quot;queries&quot;]
         idx = (response.body =~ /&lt;\/body&gt;/i)
-        faux_view = QueryViewBase.new([File.join(File.dirname(__FILE__), &quot;views&quot;)], {}, self)
-        queries = SqlQueryCollection.new(Thread.current[&quot;queries&quot;])
-        queries.analyze!
-        faux_view.instance_variable_set(&quot;@queries&quot;, queries)
-        html = faux_view.render(:partial =&gt; &quot;/box.rhtml&quot;)
+        html = query_review_output
         response.body.insert(idx, html)
       end
     end
     
+    def query_review_output
+      faux_view = QueryViewBase.new([File.join(File.dirname(__FILE__), &quot;views&quot;)], {}, self)
+      queries = SqlQueryCollection.new(Thread.current[&quot;queries&quot;])
+      queries.analyze!
+      faux_view.instance_variable_set(&quot;@queries&quot;, queries)
+      html = faux_view.render(:partial =&gt; &quot;/box.rhtml&quot;)      
+    end
+    
     def perform_action_with_query_review
       r = perform_action_without_query_review
       add_query_output_to_view if response.content_type.blank? || response.content_type == &quot;text/html&quot;</diff>
      <filename>lib/query_reviewer/controller_extensions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,7 +31,7 @@ module QueryReviewer
     end
     
     def max_severity
-      warnings.empty? &amp;&amp; collection_warnings.empty? ? 0 : [warnings.collect(&amp;:severity).flatten.max, collection_warnings.collect(&amp;:severity).flatten.max].max
+      warnings.empty? &amp;&amp; collection_warnings.empty? ? 0 : [warnings.empty? ? 0 : warnings.collect(&amp;:severity).flatten.max, collection_warnings.empty? ? 0 : collection_warnings.collect(&amp;:severity).flatten.max].max
     end
     
     def total_severity</diff>
      <filename>lib/query_reviewer/sql_query_collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,7 @@
 # desc &quot;Explaining what the task does&quot;
-# task :query_reviewer do
-#   # Task goes here
-# end
+namespace :query_reviewer do
+  desc &quot;Create a default config/query_reviewer.yml&quot;
+  task :setup do
+    FileUtils.copy(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;query_reviewer_defaults.yml&quot;), File.join(RAILS_ROOT, &quot;config&quot;, &quot;query_reviewer.yml&quot;))
+  end  
+end</diff>
      <filename>tasks/query_reviewer_tasks.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>install.rb</filename>
    </removed>
    <removed>
      <filename>query_reviewer.yml</filename>
    </removed>
    <removed>
      <filename>uninstall.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>9485a8f98951f0be7641c9c8a6b756aecba496d9</id>
    </parent>
  </parents>
  <author>
    <name>David Stevenson</name>
    <email>david@flouri.sh</email>
  </author>
  <url>http://github.com/dsboulder/query_reviewer/commit/cc95a571168dd6b1b1da2801294ff27d10e3747c</url>
  <id>cc95a571168dd6b1b1da2801294ff27d10e3747c</id>
  <committed-date>2007-12-09T11:25:30-08:00</committed-date>
  <authored-date>2007-12-09T11:25:30-08:00</authored-date>
  <message>fixes to defaults, view helper avail</message>
  <tree>362270093d1b5478d3ed5b22920f484922b347dc</tree>
  <committer>
    <name>David Stevenson</name>
    <email>david@flouri.sh</email>
  </committer>
</commit>
