seed_dump 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/VERSION +1 -1
- data/lib/seed_dump/dump_methods/enumeration.rb +4 -2
- data/seed_dump.gemspec +2 -2
- data/spec/dump_methods_spec.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e74d0530b68a21db364e020b3b9fb049f219b3d
|
4
|
+
data.tar.gz: 40996a973be8ce7e38b00640656207f745ac6c67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01607738795403a50cefaae252e9e281ffb35efa48cd37b00e0f3335b59af201ca414a7144cde7a1b8fea314b059343627241bb854d4434bc8abe8f6f21805a1
|
7
|
+
data.tar.gz: 18cede62be65f661943ff54442d71be8a503101adbd3a1dab27d8796c1bb32c03d5d83bacfa31ffd7533425a05bd4f2015260ead253c15c849a14737ebfaf358
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ Result:
|
|
40
40
|
{id: 2, password: "234567", username: "test_2"}
|
41
41
|
])
|
42
42
|
|
43
|
-
Dump only data from the users table and dump a maximum
|
43
|
+
Dump only data from the users table and dump a maximum of 1 record:
|
44
44
|
|
45
45
|
$ rake db:seed:dump MODELS=User,Product LIMIT=1
|
46
46
|
|
@@ -87,6 +87,8 @@ Options are common to both the Rake task and the console, except where noted.
|
|
87
87
|
|
88
88
|
`append`: If set to `true`, append the data to the file instead of overwriting it. Default: `false`.
|
89
89
|
|
90
|
+
`batch_size`: Controls the number of records that are written to file at a given time. Default: 1000. If you're running out of memory when dumping, try decreasing this. If things are dumping too slow, trying increasing this.
|
91
|
+
|
90
92
|
`exclude`: Attributes to be excluded from the dump. Default: `id, created_at, updated_at`.
|
91
93
|
|
92
94
|
`file`: Write to the specified output file. Default in Rake task is `db/seeds.rb`. Console returns the dump as a string by default.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.1
|
@@ -24,7 +24,7 @@ class SeedDump
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# Loop through the records of the current batch
|
27
|
-
records.offset((
|
27
|
+
records.offset((batch_number - 1) * batch_size).limit(cur_batch_size).each do |record|
|
28
28
|
record_strings << dump_record(record, options)
|
29
29
|
end
|
30
30
|
|
@@ -58,7 +58,9 @@ class SeedDump
|
|
58
58
|
|
59
59
|
count = records.count
|
60
60
|
|
61
|
-
|
61
|
+
remainder = count % batch_size
|
62
|
+
|
63
|
+
[((count.to_f / batch_size).ceil), batch_size, (remainder == 0 ? batch_size : remainder)]
|
62
64
|
end
|
63
65
|
|
64
66
|
def batch_size_from(records, options)
|
data/seed_dump.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "seed_dump"
|
8
|
-
s.version = "3.0.
|
8
|
+
s.version = "3.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rob Halff", "Ryan Oblak"]
|
12
|
-
s.date = "2013-12-
|
12
|
+
s.date = "2013-12-30"
|
13
13
|
s.description = "Dump (parts) of your database to db/seeds.rb to get a headstart creating a meaningful seeds.rb file"
|
14
14
|
s.email = "rroblak@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/dump_methods_spec.rb
CHANGED
@@ -85,9 +85,14 @@ describe SeedDump do
|
|
85
85
|
|
86
86
|
context 'with a batch_size parameter' do
|
87
87
|
it 'should not raise an exception' do
|
88
|
-
|
89
88
|
SeedDump.dump(Sample, batch_size: 100)
|
90
89
|
end
|
90
|
+
|
91
|
+
it 'should not cause records to not be dumped' do
|
92
|
+
SeedDump.dump(Sample, batch_size: 2).should eq(@expected_output)
|
93
|
+
|
94
|
+
SeedDump.dump(Sample, batch_size: 1).should eq(@expected_output)
|
95
|
+
end
|
91
96
|
end
|
92
97
|
|
93
98
|
context 'Array' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seed_dump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Halff
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|