<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>generators/lib/acts_as_trivia_commands.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
-Copyright (c) 2009 Balint Erdi (balint.erdi@gmail.com)
+Copyright (c) 2009 Balint Erdi (balint@bucionrails.com)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the</diff>
      <filename>LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -1,96 +1,49 @@
-* NoMethodError (undefined method `acts\_as\_trivia' for #&lt;Class:0x253e9fc&gt;):
-
-  Make sure you have the config.gem &quot;acts\_as\_trivia&quot; line in your environment.rb
-
-* Trivia will have its own model:
-
-  create_table :trivias, :force =&gt; true do |t|
-    t.string  :on, :null =&gt; false
-    t.string  :about, :null =&gt; false
-  end
-  
-  e.g
-  
-  Trivia.new(:on =&gt; &quot;country&quot;, :about =&gt; &quot;hdi&quot;)
-  
-  class Trivia &lt; ActionRecord::Base
-  
-    def to\_param
-      #{on}-#{about} # e.g country-hdi
-    end
-    
-  And requests to trivias will have a routing like this:
-  
-  /trivias/1, or which is the same
-  /trivias/country-hdi (and that latter will be generated)
-  
-
-* The User class will have the following added associations:
-
-  class User &lt; ActiveRecord::Base
-  
-    has_many :trivia_answers
-    has_many :trivias, :through =&gt; :trivia_answers
-    has_many :correct_trivia_answers, :through =&gt; :trivia_answers, :condition =&gt; { &quot;state = ?&quot;, 'correct' }
-    
-* And the join model will be the TriviaAnswers class:
-
-    create_table :trivia_answers, :force =&gt; true do |t|
-      t.string  :trivia_id, :null =&gt; false
-      t.string  :user_id, :null =&gt; false
-      t.integer :points # how many points the user received for his answer
-    end
+# Acts As Trivia
 
-* when the geneation script is called with the following:
+This gem adds a full-fletched trivia game to your Rails application. It only needs a (or more) model class(es) to operate on (the instances of which can be the subjects of the trivia) and an attribute of this class which is comparable.
 
-  ./script/generate acts_as_trivia country hdi
+## Installation
 
-  then the following things will be generated:
+The gem is stored on github, so you can install it on your system like this:
 
-* a new trivia model OK
-
-  class Trivia &lt; ActiveRecord::Base
-    def to\_param
-      #{on}-#{about} # e.g country-hdi
-    end
-  end
+    gem install balinterdi-acts_as_trivia --source http://gems.github.com
+    
+Or (starting from Rails 2.2) have your Rails application take care of it. Put the following line in your environment.rb:
 
-* a new controller (if it does not exist yet) OK
+    config.gem &quot;balinterdi-acts_as_trivia&quot;, :source =&gt; http://gems.github.com, :lib =&gt; &quot;acts_as_trivia&quot;
+    
+And then install it systemwide:
 
-  class TriviaController
-  end
+    rake gems:install
+    
+Or bundled with your app:
 
-* new resource routes for trivia OK
+    rake gems:unpack
+    
+## Make your Rails app a trivia game
 
-  map.resources :trivias
+Once you have the gem installed you should run the **acts\_as\_trivia** generator:
 
-* in the model (country.rb) OK:
+    ./script/generate acts_as_trivia country population name
 
-  class Country &lt; ActiveRecord::Base
-    acts_as_trivia :hdi
-    ...
-  end
+This will &quot;trivialize&quot; your application and will also add a trivia instance which asks the daring players to rank countries in descending order of their _population_ (they have to assert the first three). The provided helpers use the _name_ attribute of the countries to display to the user. Use _rake db:migrate_ to create the trivia in the database.
 
-* added associations in the user model OK
+The generator will add an acts\_as\_trivia call into your model class, create migrations for the new trivia-related classes, stub out the empty controllers and generate routes for them.
 
-  has_many :trivia_answers
-  has_many :trivias, :through =&gt; :trivia_answers
+If you'd like to add further trivia you should use the **acts\_as\_trivia\_record** generator:
 
-* db migrations
+    ./script/generate acts_as_trivia_record country area name
+    
+To have the new trivia in your app, don't forget to _rake db:migrate_
 
-  * for the trivia class itself OK
+## Rails application template
 
-    create_table :trivias, :force =&gt; true do |t|
-      t.string  :on, :null =&gt; false
-      t.string  :about, :null =&gt; false
-      t.timestamps
-    end
+If you want a &quot;quick-start&quot; course or got to like the gem so much you would like to have it in your app from start, fear not. I assembled an application template just for this (this will work starting from Rails 2.3):
 
-  * for the join model between the user and the trivia OK
+    rails my_shiny_new_app -m http://gist.github.com/raw/107361/f31caad451f0cca699288700aa3d98291a259fd1/gistfile1.rb
+    
+## How does it work
 
-    create_table :trivia_answers, :force =&gt; true do |t|
-      t.string  :trivia_id, :null =&gt; false
-      t.string  :user_id, :null =&gt; false
-      t.integer :points # how many points the user received for his answer
-    end
+Acts\_as\_trivia uses instances of the Trivia and TriviaAnswer classes to assess the knowledge of users. It only supposes that you have a User class of which the instances are the users of your application. 
 
+It tries to mingle with your application as little as possible and provide a clean interface to work with. (if you feel this is not so, please let me know) It adds a couple of helper methods you can use in your views to create a trivia answer (trivia\_user\_panel and trivia_dropdown) and to show the correct answer (with\_each\_solution\_value) </diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -10,13 +10,4 @@ Example:
         create  app/views/country_trivia/population.html.erb
         create  app/views/country_trivia/gdp.html.erb
         route   map.with_options(:controller =&gt; 'country_trivia') do ...
-        
-In routes.rb it will add the following:
-
-    ActionController::Routing::Routes.draw do |map|
-      
-      map.with_options(:controller =&gt; 'country_trivia') do |trivia|
-        trivia.country_hdi_trivia '/countries/trivia/hdi', :action =&gt; &quot;hdi&quot;
-        trivia.country_hdi_trivia '/countries/trivia/population', :action =&gt; &quot;population&quot;
-        trivia.country_hdi_trivia '/countries/trivia/hdi', :action =&gt; &quot;gdp&quot;
-      end
\ No newline at end of file
+        
\ No newline at end of file</diff>
      <filename>generators/acts_as_trivia/USAGE</filename>
    </modified>
    <modified>
      <diff>@@ -1,75 +1,11 @@
 require 'rails_generator'
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'acts_as_trivia_commands'))
 
-module ActsAsTriviaAddedContent
-
-  def route_trivia_answers_as_nested_resource
-    sentinel = &quot;ActionController::Routing::Routes.draw do |map|&quot;
-    unless options[:pretend]
-      gsub_file &quot;config/routes.rb&quot;, /(#{Regexp.escape(sentinel)})/mi do |match|
-&lt;&lt;-EOS
-#{match}
-  map.resources :users do |users|
-    users.resources :trivias do |trivias|
-      trivias.resources :trivia_answers
-    end
-  end
-  
-EOS
-      end
-    end
-    
-  end
-  
-  def model_acts_as_trivia_includes(questions)
-    acts_as_trivia_calls = questions.map do |question|
-      &quot;acts_as_trivia :#{question}&quot;
-    end
-    logger.modify acts_as_trivia_calls.join(&quot;, &quot;)
-
-    sentinel = &quot;class #{class_name} &lt; ActiveRecord::Base&quot;
-    unless options[:pretend]
-      gsub_file File.join(&quot;app/models&quot;, class_path, &quot;#{singular_name}.rb&quot;), /(#{Regexp.escape(sentinel)})/mi do |match|
-&lt;&lt;-EOS
-#{match}
-  #{acts_as_trivia_calls.join(&quot;\n&quot;)}
-EOS
-      end
-    end
-  end
-
-end
-
-class ActsAsTriviaGenerator &lt; Rails::Generator::NamedBase # ControllerGenerator
+class ActsAsTriviaGenerator &lt; Rails::Generator::Base # ControllerGenerator
 
   # this is snatched from the resource generator in the Rails source
   default_options :skip_timestamps =&gt; false, :skip_migration =&gt; false
 
-  attr_reader   :controller_name,
-                :controller_class_path,
-                :controller_file_path,
-                :controller_class_nesting,
-                :controller_class_nesting_depth,
-                :controller_class_name,
-                :controller_singular_name,
-                :controller_plural_name
-  alias_method  :controller_file_name,  :controller_singular_name
-  alias_method  :controller_table_name, :controller_plural_name
-
-  def initialize(runtime_args, runtime_options = {})
-    super
-
-    @controller_name = @name.pluralize
-
-    base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
-    @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
-
-    if @controller_class_nesting.empty?
-      @controller_class_name = @controller_class_name_without_nesting
-    else
-      @controller_class_name = &quot;#{@controller_class_nesting}::#{@controller_class_name_without_nesting}&quot;
-    end
-  end
-
   def manifest
     record do |m|
       # Check whether the given class names are already taken by
@@ -90,14 +26,9 @@ class ActsAsTriviaGenerator &lt; Rails::Generator::NamedBase # ControllerGenerator
       m.route_resources &quot;trivias&quot;
       m.route_trivia_answers_as_nested_resource
 
-      m.model_acts_as_trivia_includes actions
-
       unless options[:skip_migration]
         m.migration_template 'trivias_migration.rb', 'db/migrate', :assigns =&gt; {
           :migration_name =&gt; &quot;CreateTrivias&quot;,
-          :trivia_on =&gt; singular_name,
-          :trivia_about =&gt; actions.first,
-          :trivia_displayed =&gt; actions.last,
         }, :migration_file_name =&gt; &quot;create_trivias&quot;
       end
 
@@ -107,4 +38,4 @@ class ActsAsTriviaGenerator &lt; Rails::Generator::NamedBase # ControllerGenerator
   end
 end
 
-Rails::Generator::Commands::Base.send(:include, ActsAsTriviaAddedContent)
\ No newline at end of file
+Rails::Generator::Commands::Base.send(:include, ActsAsTriviaCommands)
\ No newline at end of file</diff>
      <filename>generators/acts_as_trivia/acts_as_trivia_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,6 @@ class &lt;%= migration_name %&gt; &lt; ActiveRecord::Migration
 &lt;% end -%&gt;
     end
 
-    Trivia.create(:on =&gt; &lt;%= %(&quot;#{trivia_on}&quot;) %&gt;, :about =&gt; &lt;%= %(&quot;#{trivia_about}&quot;) %&gt;, :displayed =&gt; &lt;%= %(&quot;#{trivia_displayed}&quot;) %&gt;)
   end
 
   def self.down</diff>
      <filename>generators/acts_as_trivia/templates/trivias_migration.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,13 @@
+require 'rails_generator'
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'acts_as_trivia_commands'))
+
 class ActsAsTriviaRecordGenerator &lt; Rails::Generator::NamedBase
+  
   def manifest
     record do |m|
+      trivia_about = actions.first
+      m.model_acts_as_trivia_includes trivia_about
+      
       m.migration_template 'migration.rb', 'db/migrate', :assigns =&gt; {
         :migration_name =&gt; &quot;CreateTriviaFor#{plural_name.capitalize}#{actions.first.capitalize}&quot;,
         :trivia_on =&gt; singular_name,
@@ -9,4 +16,6 @@ class ActsAsTriviaRecordGenerator &lt; Rails::Generator::NamedBase
       }, :migration_file_name =&gt; &quot;create_trivia_for_#{plural_name}_#{actions.first}&quot;
     end
   end
-end
\ No newline at end of file
+end
+
+Rails::Generator::Commands::Base.send(:include, ActsAsTriviaCommands)
\ No newline at end of file</diff>
      <filename>generators/acts_as_trivia_record/acts_as_trivia_record_generator.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>55ab0f2676235c8c021f96ec09d503e8613763bb</id>
    </parent>
  </parents>
  <author>
    <name>Balint Erdi</name>
    <email>balint.erdi@gmail.com</email>
  </author>
  <url>http://github.com/balinterdi/acts_as_trivia/commit/69384dd6fa3fca92823dd4ff8cab6b33c4d002fa</url>
  <id>69384dd6fa3fca92823dd4ff8cab6b33c4d002fa</id>
  <committed-date>2009-05-05T23:17:25-07:00</committed-date>
  <authored-date>2009-05-05T23:17:25-07:00</authored-date>
  <message>* acts_as_trivia generator does not generate a trivia instance, for a clearer separation of concerns
* refactored acts_as_trivia related generator commands into its own module
* updated README

Signed-off-by: Balint Erdi &lt;balint.erdi@gmail.com&gt;</message>
  <tree>ad8b2284601d9a99b46e183ed6949d5ccce351c0</tree>
  <committer>
    <name>Balint Erdi</name>
    <email>balint.erdi@gmail.com</email>
  </committer>
</commit>
