Skip to content

Commit 4bf40a6

Browse files
committed
Version bump to 0.0.5
1 parent 63dfa8f commit 4bf40a6

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
.bundle
33
Gemfile.lock
44
pkg/*
5-
.rvmrc
65
*.swp

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--color

.rvmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rvm_gemset_create_on_use_flag=1
2+
rvm use 1.9.2@mongoid_auto_increment

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Copyright (c) 2010 Jeff Smith
2+
Copyright (c) 2011 Peter Savichev (proton) <[email protected]>
23

34
Permission is hereby granted, free of charge, to any person obtaining
45
a copy of this software and associated documentation files (the

README.rdoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
= mongoid_auto_inc
2-
Add SQL like auto-incrementing fields to your Mongoid documents.
1+
= mongoid_auto_increment
2+
Add SQL like auto-incrementing fields to your Mongoid documents.
33

44
This gem is inspired by http://ihswebdesign.com/blog/autoincrement-in-mongodb-with-ruby/ and the mongomapper_id2[https://github.com/phstc/mongomapper_id2] gem.
55
== Install
6-
gem install mongoid_auto_inc
6+
gem install mongoid_auto_increment
77
== Usage
88
Just add <tt>auto_increment :field</tt> to your Mongoid model where <tt>:field</tt> is the name of the auto-incremented field you want to create.
99
Example:

lib/mongoid_auto_inc/version.rb

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
require "mongoid_auto_inc/incrementor"
1+
require "mongoid_auto_increment/incrementor"
22

3-
module MongoidAutoInc
3+
module MongoidAutoIncrement
44
extend ActiveSupport::Concern
55

66
module ClassMethods
77
def auto_increment(name, options={})
88
field name, :type => Integer
99
seq_name = "#{self.name.downcase}_#{name}"
10-
@@incrementor = MongoidAutoInc::Incrementor.new(options)
10+
@@incrementor = MongoidAutoInc::Incrementor.new(options)
1111

12-
before_create { self.send("#{name}=", @@incrementor[seq_name].inc) }
12+
before_create { self.send("#{name}=", @@incrementor[seq_name].inc) }
1313
end
1414
end
1515
end
1616

1717
module Mongoid
1818
module Document
19-
include MongoidAutoInc
19+
include MongoidAutoIncrement
2020
end
2121
end

lib/mongoid_auto_inc/incrementor.rb lib/mongoid_auto_increment/incrementor.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is a modified version of the code found on this blog post:
22
# http://ihswebdesign.com/blog/autoincrement-in-mongodb-with-ruby/
3-
module MongoidAutoInc
3+
module MongoidAutoIncrement
44
class Incrementor
55
class Sequence
66
def initialize(sequence, collection_name, seed)
@@ -16,7 +16,7 @@ def inc
1616
def set(number)
1717
update_number_with("$set" => { "number" => number })
1818
end
19-
19+
2020
private
2121

2222
def exists?
@@ -30,15 +30,15 @@ def create(number = 0)
3030
def collection
3131
Mongoid.database[@collection]
3232
end
33-
33+
3434
def query
3535
{ "seq_name" => @sequence }
3636
end
37-
37+
3838
def current
3939
collection.find_one(query)["number"]
4040
end
41-
41+
4242
def update_number_with(mongo_func)
4343
opts = {
4444
"query" => query,
@@ -48,7 +48,7 @@ def update_number_with(mongo_func)
4848
collection.find_and_modify(opts)["number"]
4949
end
5050
end
51-
51+
5252
def initialize(options=nil)
5353
options ||= {}
5454
@collection = options[:collection] || "sequences"

mongoid_auto_inc.gemspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
33
require "mongoid_auto_inc/version"
44

55
Gem::Specification.new do |s|
6-
s.name = "mongoid_auto_inc"
6+
s.name = "mongoid_auto_increment"
77
s.version = MongoidAutoInc::VERSION
88
s.platform = Gem::Platform::RUBY
9-
s.authors = ["Jeff Smith"]
10-
s.email = ["jffreyjs@gmail.com"]
9+
s.authors = ["Peter Savichev (proton)"]
10+
s.email = ["psavichev@gmail.com"]
1111
s.homepage = ""
1212
s.summary = %q{Adds auto increment capabilities to Mongoid::Document}
1313
s.description = %q{Adds auto increment capabilities to Mongoid::Document}

0 commit comments

Comments
 (0)