crewait 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +1 -0
- data/README.rdoc +6 -1
- data/Rakefile +1 -1
- data/crewait.gemspec +3 -3
- data/lib/crewait.rb +17 -8
- metadata +5 -5
data/Manifest
CHANGED
data/README.rdoc
CHANGED
@@ -2,9 +2,14 @@
|
|
2
2
|
|
3
3
|
Check out http://jonah.org/articles/crewait_go_.html for a guide to Crewait.
|
4
4
|
|
5
|
+
= Recent heroes
|
6
|
+
|
7
|
+
choffstein added Postgresql support!
|
8
|
+
jakemack resolved some conflicts with Array#to_sql!
|
9
|
+
|
5
10
|
== License
|
6
11
|
|
7
|
-
Copyright (c) 2009 Jonah Bloch-Johnson
|
12
|
+
Copyright (c) 2009-2010 Jonah Bloch-Johnson & Michael Glass
|
8
13
|
|
9
14
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
10
15
|
of this software and associated documentation files (the "Software"), to deal
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'rake'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new('crewait', '0.1.
|
6
|
+
Echoe.new('crewait', '0.1.5') do |p|
|
7
7
|
p.description = "Intuitive and fast bulk insertion in ActiveRecord"
|
8
8
|
p.url = "http://github.com/theAlmanac/crewait"
|
9
9
|
p.author = "Jonah Bloch-Johnson"
|
data/crewait.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{crewait}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jonah Bloch-Johnson"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-07-19}
|
10
10
|
s.description = %q{Intuitive and fast bulk insertion in ActiveRecord}
|
11
11
|
s.email = %q{me@jonah.org}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/crewait.rb"]
|
13
|
-
s.files = ["Manifest", "README.rdoc", "Rakefile", "
|
13
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "crewait.gemspec", "lib/crewait.rb"]
|
14
14
|
s.homepage = %q{http://github.com/theAlmanac/crewait}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Crewait", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
data/lib/crewait.rb
CHANGED
@@ -39,13 +39,22 @@ module Crewait
|
|
39
39
|
|
40
40
|
module BaseMethods
|
41
41
|
def next_insert_id
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
connection = ActiveRecord::Base.connection
|
43
|
+
database = connection.current_database
|
44
|
+
adapter = connection.adapter_name
|
45
|
+
case adapter.downcase
|
46
|
+
when 'postgresql' then
|
47
|
+
ActiveRecord::Base.connection.execute("SELECT nextval('#{self.table_name}_id_seq')")[0]["nextval"].to_i
|
48
|
+
when 'mysql' then
|
49
|
+
ActiveRecord::Base.connection.execute( "
|
50
|
+
SELECT auto_increment
|
51
|
+
FROM information_schema.tables
|
52
|
+
WHERE table_name='#{self.table_name}' AND
|
47
53
|
table_schema ='#{database}'
|
48
|
-
|
54
|
+
" ).fetch_hash['auto_increment'].to_i
|
55
|
+
else
|
56
|
+
raise "your database is not supported by crewait! want to write a patch?"
|
57
|
+
end
|
49
58
|
end
|
50
59
|
|
51
60
|
def crewait(hash)
|
@@ -71,7 +80,7 @@ module Crewait
|
|
71
80
|
values << (self[key].any? {|x| x != true} ? self[key] : self[key].collect {|x| 1})
|
72
81
|
end
|
73
82
|
values = values.transpose
|
74
|
-
sql = values.
|
83
|
+
sql = values.to_crewait_sql
|
75
84
|
|
76
85
|
while !sql.empty? do
|
77
86
|
query_string = "insert into #{model_class} (#{keys.join(', ')}) values #{sql.shift}"
|
@@ -98,7 +107,7 @@ module Crewait
|
|
98
107
|
end
|
99
108
|
|
100
109
|
module ArrayMethods
|
101
|
-
def
|
110
|
+
def to_crewait_sql
|
102
111
|
self.collect {|x| "(#{x.collect{|x| x.nil? ? 'NULL' : "#{ActiveRecord::Base.sanitize(x)}"}.join(', ')})" }
|
103
112
|
end
|
104
113
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crewait
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonah Bloch-Johnson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-19 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -32,8 +32,8 @@ files:
|
|
32
32
|
- Manifest
|
33
33
|
- README.rdoc
|
34
34
|
- Rakefile
|
35
|
-
- lib/crewait.rb
|
36
35
|
- crewait.gemspec
|
36
|
+
- lib/crewait.rb
|
37
37
|
has_rdoc: true
|
38
38
|
homepage: http://github.com/theAlmanac/crewait
|
39
39
|
licenses: []
|