batch_insert 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +7 -12
  2. data/Rakefile +1 -1
  3. data/init.rb +3 -1
  4. data/rails/init.rb +3 -0
  5. metadata +4 -2
data/README.md CHANGED
@@ -10,20 +10,17 @@ by ActiveRecord, but will not return a saved object to the caller.
10
10
  Example
11
11
  =======
12
12
 
13
- Previously:
14
- -----------
13
+ **Previously:**
15
14
 
16
15
  100.times { ModelClass.create! :name => 'Test', :description => 'An example object being created.' }
17
16
 
18
- Now:
19
- ----
17
+ **Now:**
20
18
 
21
19
  ModelClass.batch_insert do
22
20
  100.times { ModelClass.insert :name => 'Test', :description => 'An example object being created.' }
23
21
  end
24
22
 
25
- Batch insertions return the same result as new()
26
- ------------------------------------------------
23
+ **Batch insertions return the same result as new()**
27
24
 
28
25
  ModelClass.batch_insert do
29
26
  args = {:name => 'Test', :description => 'An example object being created.'}
@@ -33,21 +30,19 @@ Batch insertions return the same result as new()
33
30
  ModelClass.insert(args).id # nil
34
31
  end # The insertion is done at this point in the code.
35
32
 
36
- Invalid objects will immediately cause an exception
37
- ---------------------------------------------------
33
+ **Invalid objects will immediately cause an exception**
38
34
 
39
35
  ModelClass.batch_insert do
40
36
  invalid_args = {}
41
37
  ModelClass.insert(invalid_args) # Exception!
42
38
  end
43
39
 
44
- Constraint violations will cause an exception when the batch is inserted
45
- ------------------------------------------------------------------------
40
+ **Constraint violations will cause an exception when the batch is inserted**
46
41
 
47
42
  ModelClass.batch_insert do
48
43
  conflict = {:unique_value => 'Collide!'}
49
- ModelClass.insert(args)
50
- ModelClass.insert(args)
44
+ ModelClass.insert(conflict)
45
+ ModelClass.insert(conflict)
51
46
  end # Exception!
52
47
 
53
48
  Copyright (c) 2010 Shaun Mangelsdorf, released under the MIT license
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ PKG_FILES = FileList[
14
14
 
15
15
  spec = Gem::Specification.new do |s|
16
16
  s.name = 'batch_insert'
17
- s.version = '0.1'
17
+ s.version = '0.1.1'
18
18
  s.author = 'Shaun Mangelsdorf'
19
19
  s.email = 's.mangelsdorf@gmail.com'
20
20
  s.homepage = 'http://smangelsdorf.github.com'
data/init.rb CHANGED
@@ -1 +1,3 @@
1
- ActiveRecord::Base.send :include, ActiveRecord::BatchInsert
1
+ # Released under the MIT license. See the LICENSE file for details
2
+
3
+ require File.join(File.dirname(__FILE__), 'rails', 'init')
data/rails/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'batch_insert'
2
+
3
+ ActiveRecord::Base.send :include, ActiveRecord::BatchInsert
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- version: "0.1"
8
+ - 1
9
+ version: 0.1.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Shaun Mangelsdorf
@@ -13,7 +14,7 @@ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-11-10 00:00:00 +10:00
17
+ date: 2010-11-11 00:00:00 +10:00
17
18
  default_executable:
18
19
  dependencies: []
19
20
 
@@ -36,6 +37,7 @@ files:
36
37
  - install.rb
37
38
  - lib/batch_insert.rb
38
39
  - lib/tasks/batch_insert.rake
40
+ - rails/init.rb
39
41
  has_rdoc: true
40
42
  homepage: http://smangelsdorf.github.com
41
43
  licenses: []