seed_dump 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/seed_dump/environment.rb +11 -7
- data/seed_dump.gemspec +3 -3
- data/spec/environment_spec.rb +23 -31
- 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: 9b4e4cffee80f290d4cfd89e9f9e2e2cd4f13934
|
4
|
+
data.tar.gz: ca16d9c36607e1ebdfee10c23e76b08e8ce499b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6909a0dc975fe479d0fb863058a50a40452f688a99460fff9e737cda91b143f07970271e14ff055190e243c922690f7788b736d15c9125705ea4df2b2c5b66a1
|
7
|
+
data.tar.gz: 453a49a2c934461af62aac6b5d9a4dce8774e82ed6826690da4c64c5ba46bdfee218d191cd91636a50988a1c635c2ab4d09d22deb5ad43b60d4c92c0c8843256
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.2
|
@@ -4,14 +4,18 @@ class SeedDump
|
|
4
4
|
def dump_using_environment(env = {})
|
5
5
|
Rails.application.eager_load!
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
models_env = env['MODEL'] || env['MODELS']
|
8
|
+
models = if models_env
|
9
|
+
models_env.split(',')
|
10
|
+
.collect {|x| x.strip.underscore.singularize.camelize.constantize }
|
9
11
|
else
|
10
|
-
ActiveRecord::Base.descendants
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
ActiveRecord::Base.descendants
|
13
|
+
end
|
14
|
+
|
15
|
+
models = models.select do |model|
|
16
|
+
(model.to_s != 'ActiveRecord::SchemaMigration') && \
|
17
|
+
model.table_exists? && \
|
18
|
+
model.exists?
|
15
19
|
end
|
16
20
|
|
17
21
|
append = (env['APPEND'] == 'true')
|
data/seed_dump.gemspec
CHANGED
@@ -2,16 +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.
|
5
|
+
# stub: seed_dump 3.2.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "seed_dump"
|
9
|
-
s.version = "3.2.
|
9
|
+
s.version = "3.2.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Rob Halff", "Ryan Oblak"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2015-03-03"
|
15
15
|
s.description = "Dump (parts) of your database to db/seeds.rb to get a headstart creating a meaningful seeds.rb file"
|
16
16
|
s.email = "rroblak@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
data/spec/environment_spec.rb
CHANGED
@@ -77,45 +77,37 @@ describe SeedDump do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
FactoryGirl.create(:another_sample)
|
80
|
+
['', 'S'].each do |model_suffix|
|
81
|
+
model_env = 'MODEL' + model_suffix
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
describe model_env do
|
84
|
+
context "if #{model_env} is not specified" do
|
85
|
+
it "should dump all non-empty models" do
|
86
|
+
FactoryGirl.create(:another_sample)
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
[Sample, AnotherSample].each do |model|
|
89
|
+
SeedDump.should_receive(:dump).with(model, anything)
|
90
|
+
end
|
90
91
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
SeedDump.should_receive(:dump).with(Sample, anything)
|
95
|
-
|
96
|
-
SeedDump.dump_using_environment('MODEL' => 'Sample')
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe 'MODELS' do
|
101
|
-
it 'if MODELS is not specified it should dump all non-empty models' do
|
102
|
-
FactoryGirl.create(:another_sample)
|
103
|
-
|
104
|
-
[Sample, AnotherSample].each do |model|
|
105
|
-
SeedDump.should_receive(:dump).with(model, anything)
|
92
|
+
SeedDump.dump_using_environment
|
93
|
+
end
|
106
94
|
end
|
107
95
|
|
108
|
-
|
109
|
-
|
96
|
+
context "if #{model_env} is specified" do
|
97
|
+
it "should dump only the specified model" do
|
98
|
+
FactoryGirl.create(:another_sample)
|
110
99
|
|
111
|
-
|
112
|
-
FactoryGirl.create(:another_sample)
|
113
|
-
FactoryGirl.create(:yet_another_sample)
|
100
|
+
SeedDump.should_receive(:dump).with(Sample, anything)
|
114
101
|
|
115
|
-
|
116
|
-
|
102
|
+
SeedDump.dump_using_environment(model_env => 'Sample')
|
103
|
+
end
|
117
104
|
|
118
|
-
|
105
|
+
it "should not dump empty models" do
|
106
|
+
SeedDump.should_not_receive(:dump).with(EmptyModel, anything)
|
107
|
+
|
108
|
+
SeedDump.dump_using_environment(model_env => 'EmptyModel, Sample')
|
109
|
+
end
|
110
|
+
end
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|
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.2.
|
4
|
+
version: 3.2.2
|
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:
|
12
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|