<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>tasks/acts_as_random_id_tasks.rake</filename>
    </added>
    <added>
      <filename>test/acts_as_random_id_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,4 @@
 #ignore eclipse project settings
-.project
\ No newline at end of file
+.project
+
+test/debug.log
\ No newline at end of file</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-Copyright (c) 2009 [name of plugin creator]
+Copyright (c) 2009 hashtrain.com
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the</diff>
      <filename>MIT-LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,14 @@
-ActAsRandomId
+ActsAsRandomId
 =============
 
-Introduction goes here.
+Generating unique random id for ActiveRecord models
 
 
 Example
 =======
 
-Example goes here.
+class Comment &lt; ActiveRecord::Base
+  acts_as_random_id
+end
 
-
-Copyright (c) 2009 [name of plugin creator], released under the MIT license
+Copyright (c) 2009 hashtrain.com, released under the MIT license</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -10,14 +10,14 @@ require 'rake/gempackagetask'
 desc 'Default: run unit tests.'
 task :default =&gt; :test
 
-desc 'Test the act_as_random_id plugin.'
+desc 'Test the acts_as_random_id plugin.'
 Rake::TestTask.new(:test) do |t|
   t.libs &lt;&lt; 'lib'
   t.pattern = 'test/**/*_test.rb'
   t.verbose = true
 end
 
-desc 'Generate documentation for the act_as_random_id plugin.'
+desc 'Generate documentation for the acts_as_random_id plugin.'
 Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'rdoc'
   rdoc.title    = 'ActAsRandomId'
@@ -37,7 +37,7 @@ PKG_FILES = FileList[
 ]
 
 spec = Gem::Specification.new do |s| 
-   s.name             = &quot;act_as_random_id&quot; 
+   s.name             = &quot;acts_as_random_id&quot; 
    s.version          = &quot;0.0.1&quot;
    s.author           = &quot;hashtrain.com and author idea Stanislav Pogrebnyak&quot;
    s.email            = &quot;mail@hashtrain.com&quot;</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -20,14 +20,33 @@ module ActsAsRandomId
   end
 
   module ClassMethods 
-    def acts_as_random_id
-      before_create :generate_random_id
+    def acts_as_random_id(options = {})
+      cattr_accessor :random_id_type, :random_id_step
+      before_create  :generate_random_id
+
+      self.random_id_type = (options[:type] || :auto_increment)
+      self.random_id_step = (options[:step] || 10).to_i
+      self.random_id_step = 1 if self.random_id_step &lt;= 0
+
+      def generate_random_id
+        case self.random_id_type
+        when :auto_increment
+          auto_increment
+        else
+          indentation_right
+        end
+      end
       
-      def get_new_random_id
+      def auto_increment
+        max_id = ActiveRecord::Base.connection.select_value(&quot;SELECT max(#{self.primary_key}) FROM #{self.table_name}&quot;).to_i
+        max_id + self.random_id_step
+      end
+      
+      def indentation_right
         max_id                 = ActiveRecord::Base.connection.select_value(&quot;SELECT max(#{self.primary_key}) FROM #{self.table_name}&quot;)
         max_id_size            = max_id.to_s.size
         current_auto_incriment = (max_id_size &gt; 5) ? max_id.to_s.first(max_id_size - 5).to_i : max_id.to_i
-        new_auto_incriment     = (current_auto_incriment + rand(19) + 1).to_i
+        new_auto_incriment     = (current_auto_incriment + rand(self.random_id_step) + 1).to_i
         new_id                 = (new_auto_incriment.to_s + rand.to_s.last(5).to_s).to_i
         new_id
       end
@@ -39,9 +58,10 @@ module ActsAsRandomId
   module InstanceMethods
     protected
     def generate_random_id
-      self.id = self.class.get_new_random_id
+      self.id = self.class.generate_random_id
     end
   end
+
 end
 
 ActiveRecord::Base.send :include, ActsAsRandomId
\ No newline at end of file</diff>
      <filename>lib/acts_as_random_id.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@
 #   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
 development:
   adapter: mysql
-  database: mooze_development
+  database: acts_as_random_id_development
   username: root
   password: 
   socket: /var/run/mysqld/mysqld.sock
@@ -23,14 +23,14 @@ development:
 # Do not set this db to the same as development or production.
 test:
   adapter: mysql
-  database: mooze_test
+  database: acts_as_random_id_test
   username: root
   password:
   socket: /var/run/mysqld/mysqld.sock
 
 production:
   adapter: mysql
-  database: mooze_development
+  database: acts_as_random_id_production
   username: root
   password: 
   socket: /var/run/mysqld/mysqld.sock
\ No newline at end of file</diff>
      <filename>test/database.yml</filename>
    </modified>
    <modified>
      <diff>@@ -7,15 +7,4 @@ ActiveRecord::Schema.define(:version =&gt; 20090217091952) do
     t.datetime &quot;updated_at&quot;
   end
 
-  create_table &quot;groups&quot;, :force =&gt; true do |t|
-    t.integer  &quot;user_id&quot;
-    t.string   &quot;name&quot;
-    t.string   &quot;description&quot;
-    t.boolean  &quot;official&quot;,       :default =&gt; false
-    t.datetime &quot;created_at&quot;
-    t.datetime &quot;updated_at&quot;
-    t.string   &quot;access_type&quot;,    :default =&gt; &quot;PUBLIC&quot;
-    t.integer  &quot;comments_count&quot;, :default =&gt; 0
-  end
-
 end</diff>
      <filename>test/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,8 +7,8 @@ require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
 def load_schema
   config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
   ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + &quot;/debug.log&quot;) 
-  
-  db_adapter = ENV['DB']
+
+  db_adapter = ENV['DB'] || 'mysql'
   
   # no db passed, try one of these fine config-free DBs before bombing.  
   db_adapter ||= </diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>tasks/act_as_random_id_tasks.rake</filename>
    </removed>
    <removed>
      <filename>test/act_as_random_id_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>e596c21ec5909d9b4a3abbed82415575cbfe8359</id>
    </parent>
  </parents>
  <author>
    <name>Shaliko Usubov</name>
    <email>shaliko@ezid.ru</email>
  </author>
  <url>http://github.com/hashtrain/acts_as_random_id/commit/61b04d4811367ef005e162364032ba7984927bb9</url>
  <id>61b04d4811367ef005e162364032ba7984927bb9</id>
  <committed-date>2009-04-24T12:50:23-07:00</committed-date>
  <authored-date>2009-04-24T12:50:23-07:00</authored-date>
  <message>Add options :step and :type. Write new type</message>
  <tree>2575c28557b8d6a078ec1b37f836d89d97863685</tree>
  <committer>
    <name>Shaliko Usubov</name>
    <email>shaliko@ezid.ru</email>
  </committer>
</commit>
