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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e68a311668435ac3671cea8f316a78f7ed0e614f
4
- data.tar.gz: 6c0e787af6ba4a654443ac96bc54232e1f244376
3
+ metadata.gz: 9b4e4cffee80f290d4cfd89e9f9e2e2cd4f13934
4
+ data.tar.gz: ca16d9c36607e1ebdfee10c23e76b08e8ce499b4
5
5
  SHA512:
6
- metadata.gz: 0b566197175084fde13648a4bf0315a7b443bce05c6a97fe5b06bdb1e3ef5d57b81ed0661c0077393d2d85844760d49858d35a35e157d409753668a4e0cf48b0
7
- data.tar.gz: a574f0f3671f6de35e23f38950747b3d62106ac34e13bf016c1fe8f4865c30a6f578ffd9cea0dcf2df0de3f5f62afbdee77da064d4820ed506bbf5ea4ccd1cd0
6
+ metadata.gz: 6909a0dc975fe479d0fb863058a50a40452f688a99460fff9e737cda91b143f07970271e14ff055190e243c922690f7788b736d15c9125705ea4df2b2c5b66a1
7
+ data.tar.gz: 453a49a2c934461af62aac6b5d9a4dce8774e82ed6826690da4c64c5ba46bdfee218d191cd91636a50988a1c635c2ab4d09d22deb5ad43b60d4c92c0c8843256
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.1
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
- models = if env['MODEL'] || env['MODELS']
8
- (env['MODEL'] || env['MODELS']).split(',').collect {|x| x.strip.underscore.singularize.camelize.constantize }
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.select do |model|
11
- (model.to_s != 'ActiveRecord::SchemaMigration') && \
12
- model.table_exists? && \
13
- model.exists?
14
- end
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.1 ruby lib
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.1"
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 = "2014-12-15"
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 = [
@@ -77,45 +77,37 @@ describe SeedDump do
77
77
  end
78
78
  end
79
79
 
80
- describe 'MODEL' do
81
- it 'if MODEL is not specified it should dump all non-empty models' do
82
- FactoryGirl.create(:another_sample)
80
+ ['', 'S'].each do |model_suffix|
81
+ model_env = 'MODEL' + model_suffix
83
82
 
84
- [Sample, AnotherSample].each do |model|
85
- SeedDump.should_receive(:dump).with(model, anything)
86
- end
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
- SeedDump.dump_using_environment
89
- end
88
+ [Sample, AnotherSample].each do |model|
89
+ SeedDump.should_receive(:dump).with(model, anything)
90
+ end
90
91
 
91
- it 'if MODEL is specified it should only dump the specified model' do
92
- FactoryGirl.create(:another_sample)
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
- SeedDump.dump_using_environment
109
- end
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
- it 'if MODELS is specified it should only dump those models' do
112
- FactoryGirl.create(:another_sample)
113
- FactoryGirl.create(:yet_another_sample)
100
+ SeedDump.should_receive(:dump).with(Sample, anything)
114
101
 
115
- SeedDump.should_receive(:dump).with(Sample, anything)
116
- SeedDump.should_receive(:dump).with(AnotherSample, anything)
102
+ SeedDump.dump_using_environment(model_env => 'Sample')
103
+ end
117
104
 
118
- SeedDump.dump_using_environment('MODELS' => 'Sample, AnotherSample')
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.1
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: 2014-12-15 00:00:00.000000000 Z
12
+ date: 2015-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport