seed_dump 3.1.0 → 3.2.0
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.
- checksums.yaml +4 -4
- data/Gemfile +9 -8
- data/README.md +20 -10
- data/VERSION +1 -1
- data/lib/seed_dump/dump_methods.rb +24 -7
- data/lib/seed_dump/environment.rb +2 -1
- data/seed_dump.gemspec +23 -19
- data/spec/dump_methods_spec.rb +42 -14
- data/spec/factories/samples.rb +2 -0
- data/spec/helpers.rb +4 -0
- metadata +37 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfceec9ace09fe7f6bec3d37e650177e6d38a498
|
|
4
|
+
data.tar.gz: d29db6f1aeab2121c7d384ff8caf9cb1c3e25cee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1701fa7864603423e03e1fa615a54fcf550c599cee96d11f746e081cb5e677dc4bb628b9153c9dd3981fb829e060b61406b72edd145e345a051eeb37efcec06
|
|
7
|
+
data.tar.gz: c300b879c570e0225fc5091db798375ae5f3e3eecd52c1dfc4c22613458c48fcc51f70e8b44ecc2909fb33ecf0ef3f462e7f21ec199a4ab801644794d942ed6c
|
data/Gemfile
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
gem 'activesupport'
|
|
4
|
-
gem 'activerecord'
|
|
3
|
+
gem 'activesupport', '~> 4'
|
|
4
|
+
gem 'activerecord', '~> 4'
|
|
5
5
|
|
|
6
6
|
group :development, :test do
|
|
7
|
-
gem 'byebug'
|
|
8
|
-
gem 'factory_girl'
|
|
7
|
+
gem 'byebug', '~> 2.0'
|
|
8
|
+
gem 'factory_girl', '~> 4.0'
|
|
9
|
+
gem 'activerecord-import', '~> 0.4'
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
group :development do
|
|
12
|
-
gem 'jeweler',
|
|
13
|
+
gem 'jeweler', '~> 2.0'
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
group :test do
|
|
16
|
-
gem 'rspec'
|
|
17
|
-
gem 'sqlite3'
|
|
18
|
-
gem 'database_cleaner'
|
|
17
|
+
gem 'rspec', '~> 2.0'
|
|
18
|
+
gem 'sqlite3', '~> 1.0'
|
|
19
|
+
gem 'database_cleaner', '~> 1.0'
|
|
19
20
|
end
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Seed Dump is a Rails 4 plugin that adds a rake task named `db:seed:dump`.
|
|
|
5
5
|
|
|
6
6
|
It allows you to create seed data files from the existing data in your database.
|
|
7
7
|
|
|
8
|
-
You can also use Seed Dump from the Rails console.
|
|
8
|
+
You can also use Seed Dump from the Rails console. See below for usage examples.
|
|
9
9
|
|
|
10
10
|
Note: if you want to use Seed Dump with Rails 3 or earlier, use [version 0.5.3](http://rubygems.org/gems/seed_dump/versions/0.5.3).
|
|
11
11
|
|
|
@@ -42,7 +42,7 @@ Result:
|
|
|
42
42
|
|
|
43
43
|
Dump only data from the users table and dump a maximum of 1 record:
|
|
44
44
|
|
|
45
|
-
$ rake db:seed:dump MODELS=User
|
|
45
|
+
$ rake db:seed:dump MODELS=User LIMIT=1
|
|
46
46
|
|
|
47
47
|
Result:
|
|
48
48
|
|
|
@@ -58,6 +58,10 @@ Use another output file instead of `db/seeds.rb`:
|
|
|
58
58
|
|
|
59
59
|
rake db:seed:dump FILE=db/seeds/users.rb
|
|
60
60
|
|
|
61
|
+
Exclude `name` and `age` from the dump:
|
|
62
|
+
|
|
63
|
+
rake db:seed:dump EXCLUDE=name,age
|
|
64
|
+
|
|
61
65
|
There are more options that can be set— see below for all of them.
|
|
62
66
|
|
|
63
67
|
### Console
|
|
@@ -76,24 +80,30 @@ Write the dump to a file:
|
|
|
76
80
|
|
|
77
81
|
Append the dump to a file:
|
|
78
82
|
|
|
79
|
-
irb(main):003:0>
|
|
83
|
+
irb(main):003:0> SeedDump.dump(User, file: 'db/seeds.rb', append: true)
|
|
84
|
+
|
|
85
|
+
Exclude `name` and `age` from the dump:
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
irb(main):004:0> SeedDump.dump(User, exclude: [:name, :age])
|
|
88
|
+
|
|
89
|
+
Options are specified as a Hash for the second argument.
|
|
82
90
|
|
|
83
91
|
Options
|
|
84
92
|
-------
|
|
85
93
|
|
|
86
94
|
Options are common to both the Rake task and the console, except where noted.
|
|
87
95
|
|
|
88
|
-
`append`: If set to `true`, append the data to the file instead of overwriting it.
|
|
96
|
+
`append`: If set to `true`, append the data to the file instead of overwriting it. Default: `false`.
|
|
97
|
+
|
|
98
|
+
`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.
|
|
89
99
|
|
|
90
|
-
`
|
|
100
|
+
`exclude`: Attributes to be excluded from the dump. By default `id`, `created_at`, and `updated_at` are excluded. Pass a comma-separated list to the Rake task (i.e. `name,age`) and an array on the console (i.e. `[:name, :age]`).
|
|
91
101
|
|
|
92
|
-
`
|
|
102
|
+
`file`: Write to the specified output file. The Rake task default is `db/seeds.rb`. The console returns the dump as a string by default.
|
|
93
103
|
|
|
94
|
-
`
|
|
104
|
+
`import`: If `true`, output will be in the format needed by the [activerecord-import](https://github.com/zdennis/activerecord-import) gem, rather than the default format. Default: `false`.
|
|
95
105
|
|
|
96
|
-
`limit`: Dump no more
|
|
106
|
+
`limit`: Dump no more than this amount of data. Default: no limit. Rake task only. In the console just pass in an ActiveRecord::Relation with the appropriate limit (e.g. `SeedDump.dump(User.limit(5))`).
|
|
97
107
|
|
|
98
|
-
`model[s]`: Restrict the dump to the specified comma-separated list of models.
|
|
108
|
+
`model[s]`: Restrict the dump to the specified comma-separated list of models. Default: all models. If you are using a Rails engine you can dump a specific model by passing "EngineName::ModelName". Rake task only. Example: `rake db:seed:dump MODELS="User, Position, Function"`
|
|
99
109
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.2.0
|
|
@@ -18,20 +18,20 @@ class SeedDump
|
|
|
18
18
|
def dump_record(record, options)
|
|
19
19
|
attribute_strings = []
|
|
20
20
|
|
|
21
|
-
options[:exclude] ||= [:id, :created_at, :updated_at]
|
|
22
|
-
|
|
23
21
|
# We select only string attribute names to avoid conflict
|
|
24
22
|
# with the composite_primary_keys gem (it returns composite
|
|
25
23
|
# primary key attribute names as hashes).
|
|
26
24
|
record.attributes.select {|key| key.is_a?(String) }.each do |attribute, value|
|
|
27
|
-
attribute_strings << dump_attribute_new(attribute, value) unless options[:exclude].include?(attribute.to_sym)
|
|
25
|
+
attribute_strings << dump_attribute_new(attribute, value, options) unless options[:exclude].include?(attribute.to_sym)
|
|
28
26
|
end
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
open_character, close_character = options[:import] ? ['[', ']'] : ['{', '}']
|
|
29
|
+
|
|
30
|
+
"#{open_character}#{attribute_strings.join(", ")}#{close_character}"
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def dump_attribute_new(attribute, value)
|
|
34
|
-
"#{attribute}: #{value_to_s(value)}"
|
|
33
|
+
def dump_attribute_new(attribute, value, options)
|
|
34
|
+
options[:import] ? value_to_s(value) : "#{attribute}: #{value_to_s(value)}"
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def value_to_s(value)
|
|
@@ -66,7 +66,14 @@ class SeedDump
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def write_records_to_io(records, io, options)
|
|
69
|
-
|
|
69
|
+
options[:exclude] ||= [:id, :created_at, :updated_at]
|
|
70
|
+
|
|
71
|
+
method = options[:import] ? 'import' : 'create!'
|
|
72
|
+
io.write("#{model_for(records)}.#{method}(")
|
|
73
|
+
if options[:import]
|
|
74
|
+
io.write("[#{attribute_names(records, options).map {|name| name.to_sym.inspect}.join(', ')}], ")
|
|
75
|
+
end
|
|
76
|
+
io.write("[\n ")
|
|
70
77
|
|
|
71
78
|
enumeration_method = if records.is_a?(ActiveRecord::Relation) || records.is_a?(Class)
|
|
72
79
|
:active_record_enumeration
|
|
@@ -90,6 +97,16 @@ class SeedDump
|
|
|
90
97
|
end
|
|
91
98
|
end
|
|
92
99
|
|
|
100
|
+
def attribute_names(records, options)
|
|
101
|
+
attribute_names = if records.is_a?(ActiveRecord::Relation) || records.is_a?(Class)
|
|
102
|
+
records.attribute_names
|
|
103
|
+
else
|
|
104
|
+
records[0].attribute_names
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
attribute_names.select {|name| !options[:exclude].include?(name.to_sym)}
|
|
108
|
+
end
|
|
109
|
+
|
|
93
110
|
def model_for(records)
|
|
94
111
|
if records.is_a?(Class)
|
|
95
112
|
records
|
|
@@ -23,7 +23,8 @@ class SeedDump
|
|
|
23
23
|
append: append,
|
|
24
24
|
batch_size: (env['BATCH_SIZE'] ? env['BATCH_SIZE'].to_i : nil),
|
|
25
25
|
exclude: (env['EXCLUDE'] ? env['EXCLUDE'].split(',').map {|e| e.strip.to_sym} : nil),
|
|
26
|
-
file: (env['FILE'] || 'db/seeds.rb')
|
|
26
|
+
file: (env['FILE'] || 'db/seeds.rb'),
|
|
27
|
+
import: (env['IMPORT'] == 'true'))
|
|
27
28
|
|
|
28
29
|
append = true
|
|
29
30
|
end
|
data/seed_dump.gemspec
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
+
# stub: seed_dump 3.2.0 ruby lib
|
|
5
6
|
|
|
6
7
|
Gem::Specification.new do |s|
|
|
7
8
|
s.name = "seed_dump"
|
|
8
|
-
s.version = "3.
|
|
9
|
+
s.version = "3.2.0"
|
|
9
10
|
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
+
s.require_paths = ["lib"]
|
|
11
13
|
s.authors = ["Rob Halff", "Ryan Oblak"]
|
|
12
|
-
s.date = "2014-
|
|
14
|
+
s.date = "2014-07-27"
|
|
13
15
|
s.description = "Dump (parts) of your database to db/seeds.rb to get a headstart creating a meaningful seeds.rb file"
|
|
14
16
|
s.email = "rroblak@gmail.com"
|
|
15
17
|
s.extra_rdoc_files = [
|
|
@@ -39,32 +41,34 @@ Gem::Specification.new do |s|
|
|
|
39
41
|
]
|
|
40
42
|
s.homepage = "https://github.com/rroblak/seed_dump"
|
|
41
43
|
s.licenses = ["MIT"]
|
|
42
|
-
s.
|
|
43
|
-
s.rubygems_version = "2.0.3"
|
|
44
|
+
s.rubygems_version = "2.2.1"
|
|
44
45
|
s.summary = "{Seed Dumper for Rails}"
|
|
45
46
|
|
|
46
47
|
if s.respond_to? :specification_version then
|
|
47
48
|
s.specification_version = 4
|
|
48
49
|
|
|
49
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
50
|
-
s.add_runtime_dependency(%q<activesupport>, ["
|
|
51
|
-
s.add_runtime_dependency(%q<activerecord>, ["
|
|
52
|
-
s.add_development_dependency(%q<byebug>, ["
|
|
53
|
-
s.add_development_dependency(%q<factory_girl>, ["
|
|
54
|
-
s.add_development_dependency(%q<
|
|
51
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 4"])
|
|
52
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 4"])
|
|
53
|
+
s.add_development_dependency(%q<byebug>, ["~> 2.0"])
|
|
54
|
+
s.add_development_dependency(%q<factory_girl>, ["~> 4.0"])
|
|
55
|
+
s.add_development_dependency(%q<activerecord-import>, ["~> 0.4"])
|
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
|
55
57
|
else
|
|
56
|
-
s.add_dependency(%q<activesupport>, ["
|
|
57
|
-
s.add_dependency(%q<activerecord>, ["
|
|
58
|
-
s.add_dependency(%q<byebug>, ["
|
|
59
|
-
s.add_dependency(%q<factory_girl>, ["
|
|
60
|
-
s.add_dependency(%q<
|
|
58
|
+
s.add_dependency(%q<activesupport>, ["~> 4"])
|
|
59
|
+
s.add_dependency(%q<activerecord>, ["~> 4"])
|
|
60
|
+
s.add_dependency(%q<byebug>, ["~> 2.0"])
|
|
61
|
+
s.add_dependency(%q<factory_girl>, ["~> 4.0"])
|
|
62
|
+
s.add_dependency(%q<activerecord-import>, ["~> 0.4"])
|
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
|
61
64
|
end
|
|
62
65
|
else
|
|
63
|
-
s.add_dependency(%q<activesupport>, ["
|
|
64
|
-
s.add_dependency(%q<activerecord>, ["
|
|
65
|
-
s.add_dependency(%q<byebug>, ["
|
|
66
|
-
s.add_dependency(%q<factory_girl>, ["
|
|
67
|
-
s.add_dependency(%q<
|
|
66
|
+
s.add_dependency(%q<activesupport>, ["~> 4"])
|
|
67
|
+
s.add_dependency(%q<activerecord>, ["~> 4"])
|
|
68
|
+
s.add_dependency(%q<byebug>, ["~> 2.0"])
|
|
69
|
+
s.add_dependency(%q<factory_girl>, ["~> 4.0"])
|
|
70
|
+
s.add_dependency(%q<activerecord-import>, ["~> 0.4"])
|
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
|
68
72
|
end
|
|
69
73
|
end
|
|
70
74
|
|
data/spec/dump_methods_spec.rb
CHANGED
|
@@ -2,20 +2,29 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe SeedDump do
|
|
4
4
|
|
|
5
|
+
def expected_output(include_id = false, id_offset = 0)
|
|
6
|
+
output = "Sample.create!([\n "
|
|
7
|
+
|
|
8
|
+
data = []
|
|
9
|
+
((1 + id_offset)..(3 + id_offset)).each do |i|
|
|
10
|
+
data << "{#{include_id ? "id: #{i}, " : ''}string: \"string\", text: \"text\", integer: 42, float: 3.14, decimal: \"2.72\", datetime: \"1776-07-04 19:14:00\", time: \"2000-01-01 03:15:00\", date: \"1863-11-19\", binary: \"binary\", boolean: false}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
output + data.join(",\n ") + "\n])\n"
|
|
14
|
+
end
|
|
15
|
+
|
|
5
16
|
describe '.dump' do
|
|
6
17
|
before do
|
|
7
18
|
Rails.application.eager_load!
|
|
8
19
|
|
|
9
20
|
create_db
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@expected_output = "Sample.create!([\n {string: \"string\", text: \"text\", integer: 42, float: 3.14, decimal: \"2.72\", datetime: \"1776-07-04 19:14:00\", time: \"2000-01-01 03:15:00\", date: \"1863-11-19\", binary: \"binary\", boolean: false},\n {string: \"string\", text: \"text\", integer: 42, float: 3.14, decimal: \"2.72\", datetime: \"1776-07-04 19:14:00\", time: \"2000-01-01 03:15:00\", date: \"1863-11-19\", binary: \"binary\", boolean: false},\n {string: \"string\", text: \"text\", integer: 42, float: 3.14, decimal: \"2.72\", datetime: \"1776-07-04 19:14:00\", time: \"2000-01-01 03:15:00\", date: \"1863-11-19\", binary: \"binary\", boolean: false}\n])\n"
|
|
22
|
+
FactoryGirl.create_list(:sample, 3)
|
|
14
23
|
end
|
|
15
24
|
|
|
16
25
|
context 'without file option' do
|
|
17
26
|
it 'should return the dump of the models passed in' do
|
|
18
|
-
SeedDump.dump(Sample).should eq(
|
|
27
|
+
SeedDump.dump(Sample).should eq(expected_output)
|
|
19
28
|
end
|
|
20
29
|
end
|
|
21
30
|
|
|
@@ -31,7 +40,7 @@ describe SeedDump do
|
|
|
31
40
|
it 'should dump the models to the specified file' do
|
|
32
41
|
SeedDump.dump(Sample, file: @filename)
|
|
33
42
|
|
|
34
|
-
File.open(@filename) { |file| file.read.should eq(
|
|
43
|
+
File.open(@filename) { |file| file.read.should eq(expected_output) }
|
|
35
44
|
end
|
|
36
45
|
|
|
37
46
|
context 'with append option' do
|
|
@@ -39,7 +48,7 @@ describe SeedDump do
|
|
|
39
48
|
SeedDump.dump(Sample, file: @filename)
|
|
40
49
|
SeedDump.dump(Sample, file: @filename, append: true)
|
|
41
50
|
|
|
42
|
-
File.open(@filename) { |file| file.read.should eq(
|
|
51
|
+
File.open(@filename) { |file| file.read.should eq(expected_output + expected_output) }
|
|
43
52
|
end
|
|
44
53
|
end
|
|
45
54
|
end
|
|
@@ -60,10 +69,7 @@ describe SeedDump do
|
|
|
60
69
|
|
|
61
70
|
context 'without an order parameter' do
|
|
62
71
|
it 'should dump the models sorted by primary key ascending' do
|
|
63
|
-
Sample.
|
|
64
|
-
samples = 3.times {|i| FactoryGirl.create(:sample, integer: i) }
|
|
65
|
-
|
|
66
|
-
SeedDump.dump(Sample).should eq("Sample.create!([\n {string: \"string\", text: \"text\", integer: 0, float: 3.14, decimal: \"2.72\", datetime: \"1776-07-04 19:14:00\", time: \"2000-01-01 03:15:00\", date: \"1863-11-19\", binary: \"binary\", boolean: false},\n {string: \"string\", text: \"text\", integer: 1, float: 3.14, decimal: \"2.72\", datetime: \"1776-07-04 19:14:00\", time: \"2000-01-01 03:15:00\", date: \"1863-11-19\", binary: \"binary\", boolean: false},\n {string: \"string\", text: \"text\", integer: 2, float: 3.14, decimal: \"2.72\", datetime: \"1776-07-04 19:14:00\", time: \"2000-01-01 03:15:00\", date: \"1863-11-19\", binary: \"binary\", boolean: false}\n])\n")
|
|
72
|
+
SeedDump.dump(Sample).should eq(expected_output)
|
|
67
73
|
end
|
|
68
74
|
end
|
|
69
75
|
|
|
@@ -78,7 +84,7 @@ describe SeedDump do
|
|
|
78
84
|
Sample.delete_all
|
|
79
85
|
4.times { FactoryGirl.create(:sample) }
|
|
80
86
|
|
|
81
|
-
SeedDump.dump(Sample.limit(3), batch_size: 2).should eq(
|
|
87
|
+
SeedDump.dump(Sample.limit(3), batch_size: 2).should eq(expected_output(false, 3))
|
|
82
88
|
end
|
|
83
89
|
end
|
|
84
90
|
end
|
|
@@ -89,15 +95,15 @@ describe SeedDump do
|
|
|
89
95
|
end
|
|
90
96
|
|
|
91
97
|
it 'should not cause records to not be dumped' do
|
|
92
|
-
SeedDump.dump(Sample, batch_size: 2).should eq(
|
|
98
|
+
SeedDump.dump(Sample, batch_size: 2).should eq(expected_output)
|
|
93
99
|
|
|
94
|
-
SeedDump.dump(Sample, batch_size: 1).should eq(
|
|
100
|
+
SeedDump.dump(Sample, batch_size: 1).should eq(expected_output)
|
|
95
101
|
end
|
|
96
102
|
end
|
|
97
103
|
|
|
98
104
|
context 'Array' do
|
|
99
105
|
it 'should return the dump of the models passed in' do
|
|
100
|
-
SeedDump.dump(Sample.all.to_a, batch_size: 2).should eq(
|
|
106
|
+
SeedDump.dump(Sample.all.to_a, batch_size: 2).should eq(expected_output)
|
|
101
107
|
end
|
|
102
108
|
|
|
103
109
|
it 'should return nil if the array is empty' do
|
|
@@ -120,6 +126,28 @@ describe SeedDump do
|
|
|
120
126
|
SeedDump.dump([RangeSample.new]).should eq(expected_output)
|
|
121
127
|
end
|
|
122
128
|
end
|
|
129
|
+
|
|
130
|
+
context 'activerecord-import' do
|
|
131
|
+
it 'should dump in the activerecord-import format when import is true' do
|
|
132
|
+
SeedDump.dump(Sample, import: true, exclude: []).should eq <<-RUBY
|
|
133
|
+
Sample.import([:id, :string, :text, :integer, :float, :decimal, :datetime, :time, :date, :binary, :boolean, :created_at, :updated_at], [
|
|
134
|
+
[1, "string", "text", 42, 3.14, "2.72", "1776-07-04 19:14:00", "2000-01-01 03:15:00", "1863-11-19", "binary", false, "1969-07-20 20:18:00", "1989-11-10 04:20:00"],
|
|
135
|
+
[2, "string", "text", 42, 3.14, "2.72", "1776-07-04 19:14:00", "2000-01-01 03:15:00", "1863-11-19", "binary", false, "1969-07-20 20:18:00", "1989-11-10 04:20:00"],
|
|
136
|
+
[3, "string", "text", 42, 3.14, "2.72", "1776-07-04 19:14:00", "2000-01-01 03:15:00", "1863-11-19", "binary", false, "1969-07-20 20:18:00", "1989-11-10 04:20:00"]
|
|
137
|
+
])
|
|
138
|
+
RUBY
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it 'should omit excluded columns if they are specified' do
|
|
142
|
+
SeedDump.dump(Sample, import: true, exclude: [:id, :created_at, :updated_at]).should eq <<-RUBY
|
|
143
|
+
Sample.import([:string, :text, :integer, :float, :decimal, :datetime, :time, :date, :binary, :boolean], [
|
|
144
|
+
["string", "text", 42, 3.14, "2.72", "1776-07-04 19:14:00", "2000-01-01 03:15:00", "1863-11-19", "binary", false],
|
|
145
|
+
["string", "text", 42, 3.14, "2.72", "1776-07-04 19:14:00", "2000-01-01 03:15:00", "1863-11-19", "binary", false],
|
|
146
|
+
["string", "text", 42, 3.14, "2.72", "1776-07-04 19:14:00", "2000-01-01 03:15:00", "1863-11-19", "binary", false]
|
|
147
|
+
])
|
|
148
|
+
RUBY
|
|
149
|
+
end
|
|
150
|
+
end
|
|
123
151
|
end
|
|
124
152
|
end
|
|
125
153
|
|
data/spec/factories/samples.rb
CHANGED
data/spec/helpers.rb
CHANGED
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.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rob Halff
|
|
@@ -9,78 +9,92 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-
|
|
12
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
|
-
- -
|
|
18
|
+
- - ~>
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
20
|
+
version: '4'
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
|
-
- -
|
|
25
|
+
- - ~>
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '
|
|
27
|
+
version: '4'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: activerecord
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- -
|
|
32
|
+
- - ~>
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
34
|
+
version: '4'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
|
-
- -
|
|
39
|
+
- - ~>
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '
|
|
41
|
+
version: '4'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: byebug
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
|
-
- -
|
|
46
|
+
- - ~>
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '0'
|
|
48
|
+
version: '2.0'
|
|
49
49
|
type: :development
|
|
50
50
|
prerelease: false
|
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
|
53
|
-
- -
|
|
53
|
+
- - ~>
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: '0'
|
|
55
|
+
version: '2.0'
|
|
56
56
|
- !ruby/object:Gem::Dependency
|
|
57
57
|
name: factory_girl
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
|
-
- -
|
|
60
|
+
- - ~>
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '0'
|
|
62
|
+
version: '4.0'
|
|
63
63
|
type: :development
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
|
-
- -
|
|
67
|
+
- - ~>
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '0'
|
|
69
|
+
version: '4.0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: activerecord-import
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ~>
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0.4'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ~>
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0.4'
|
|
70
84
|
- !ruby/object:Gem::Dependency
|
|
71
85
|
name: jeweler
|
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
|
73
87
|
requirements:
|
|
74
|
-
- -
|
|
88
|
+
- - ~>
|
|
75
89
|
- !ruby/object:Gem::Version
|
|
76
|
-
version: '0'
|
|
90
|
+
version: '2.0'
|
|
77
91
|
type: :development
|
|
78
92
|
prerelease: false
|
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
|
80
94
|
requirements:
|
|
81
|
-
- -
|
|
95
|
+
- - ~>
|
|
82
96
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: '0'
|
|
97
|
+
version: '2.0'
|
|
84
98
|
description: Dump (parts) of your database to db/seeds.rb to get a headstart creating
|
|
85
99
|
a meaningful seeds.rb file
|
|
86
100
|
email: rroblak@gmail.com
|
|
@@ -129,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
143
|
version: '0'
|
|
130
144
|
requirements: []
|
|
131
145
|
rubyforge_project:
|
|
132
|
-
rubygems_version: 2.
|
|
146
|
+
rubygems_version: 2.2.1
|
|
133
147
|
signing_key:
|
|
134
148
|
specification_version: 4
|
|
135
149
|
summary: '{Seed Dumper for Rails}'
|