evil-seed 0.1.1 → 0.1.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
- SHA1:
3
- metadata.gz: 411501048ad3322c19a3db3c781b9e7e19d48725
4
- data.tar.gz: 8587a602745f2d08375c9fb6636412c974df963d
2
+ SHA256:
3
+ metadata.gz: b241703e95ddb394e93723c78bc574b53263cb5c12b14dec89c04bd1546e86f9
4
+ data.tar.gz: c0b3a2c17a43706094afcb5ddcb7102aaaa8c2fb422c1abc73a481c03458db14
5
5
  SHA512:
6
- metadata.gz: bf912a9462601ae9b0b47bf987e1031789a46012a60138db5a5ba9d354739a6044d54839935c3c8366e0fce0daf04f4005270b16bdde4612ebb7798e8f7b721b
7
- data.tar.gz: 45219968ddf66748d6d0f40c8a39f86b635b5564d1047266711e14d94ec30679d9a9bd9c02743490ca30de9b7867f83dc7e62cd69018df90910de13458abc395
6
+ metadata.gz: b5f9171b1c00fb4bd3665670b30f4f26eb427dc8202dcb1fc9a03856ce403b358754b90668e3c96ba8bcc147de39ebf451749be8ff4eed2b56f9b34c26b0a336
7
+ data.tar.gz: 0b258a881c6eda7fa7a8c0b87bb3602822203490bc2415418f793735f55fd8403010bfe18790e8c4befb01a691f3d47e715bb63dfabf8aa86d6234f7a4d98667
@@ -11,19 +11,46 @@ addons:
11
11
 
12
12
  matrix:
13
13
  include:
14
- - rvm: 2.4.1
14
+ - rvm: 2.5.0
15
+ gemfile: gemfiles/activerecord_master.gemfile
16
+ env: "DB=sqlite"
17
+ - rvm: 2.5.0
18
+ gemfile: gemfiles/activerecord_master.gemfile
19
+ env: "DB=postgresql"
20
+ - rvm: 2.5.0
21
+ gemfile: gemfiles/activerecord_master.gemfile
22
+ env: "DB=mysql"
23
+ - rvm: 2.5.0
24
+ gemfile: gemfiles/activerecord_5_2.gemfile
25
+ env: "DB=sqlite"
26
+ - rvm: 2.5.0
27
+ gemfile: gemfiles/activerecord_5_2.gemfile
28
+ env: "DB=postgresql"
29
+ - rvm: 2.5.0
30
+ gemfile: gemfiles/activerecord_5_2.gemfile
31
+ env: "DB=mysql"
32
+ - rvm: 2.5.0
33
+ gemfile: gemfiles/activerecord_5_1.gemfile
34
+ env: "DB=sqlite"
35
+ - rvm: 2.5.0
36
+ gemfile: gemfiles/activerecord_5_1.gemfile
37
+ env: "DB=postgresql"
38
+ - rvm: 2.5.0
39
+ gemfile: gemfiles/activerecord_5_1.gemfile
40
+ env: "DB=mysql"
41
+ - rvm: 2.4.3
15
42
  gemfile: gemfiles/activerecord_5_0.gemfile
16
43
  env: "DB=sqlite"
17
- - rvm: 2.4.1
44
+ - rvm: 2.4.3
18
45
  gemfile: gemfiles/activerecord_5_0.gemfile
19
46
  env: "DB=postgresql"
20
- - rvm: 2.4.1
47
+ - rvm: 2.4.3
21
48
  gemfile: gemfiles/activerecord_5_0.gemfile
22
49
  env: "DB=mysql"
23
- - rvm: 2.3.4
50
+ - rvm: 2.3.6
24
51
  gemfile: gemfiles/activerecord_4_2.gemfile
25
52
  env: "DB=postgresql"
26
- - rvm: 2.3.4
53
+ - rvm: 2.3.6
27
54
  gemfile: gemfiles/activerecord_4_2.gemfile
28
55
  env: "DB=sqlite"
29
56
  # Please note that gem can't be tested against MySQL on ActiveRecord 4.2 (Dump and restore test doesn't work)!
data/Appraisals CHANGED
@@ -1,7 +1,25 @@
1
1
  appraise 'activerecord-4-2' do
2
2
  gem 'activerecord', '~> 4.2.0'
3
+ gem 'pg', '~> 0.20'
4
+ gem 'mysql2', '~> 0.3.18'
3
5
  end
4
6
 
5
7
  appraise 'activerecord-5-0' do
6
8
  gem 'activerecord', '~> 5.0.0'
9
+ gem 'pg', '~> 0.20'
10
+ gem 'mysql2', '~> 0.4.4'
11
+ end
12
+
13
+ appraise 'activerecord-5-1' do
14
+ gem 'activerecord', '~> 5.1.0'
15
+ gem 'mysql2', '~> 0.4.4'
16
+ end
17
+
18
+ appraise 'activerecord-5-2' do
19
+ gem 'activerecord', '~> 5.2.0.rc2'
20
+ gem 'mysql2', '~> 0.4.4'
21
+ end
22
+
23
+ appraise 'activerecord-master' do
24
+ gem 'activerecord', git: 'https://github.com/rails/rails.git'
7
25
  end
data/Gemfile CHANGED
@@ -4,7 +4,3 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in evil-seed.gemspec
6
6
  gemspec
7
-
8
- gem 'mysql2'
9
- gem 'pg'
10
- gem 'sqlite3'
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- [![Gem Version](https://badge.fury.io/rb/evil-seed.svg)](https://rubygems.org/gems/evil-seed) [![Build Status](https://travis-ci.org/evilmartians/evil-seed.svg?branch=master)](https://travis-ci.org/evilmartians/evil-seed)
1
+ [![Gem Version](https://badge.fury.io/rb/evil-seed.svg)](https://rubygems.org/gems/evil-seed)
2
+ [![Build Status](https://travis-ci.org/evilmartians/evil-seed.svg?branch=master)](https://travis-ci.org/evilmartians/evil-seed)
3
+ [![Cult of Martians](http://cultofmartians.com/assets/badges/badge.svg)](http://cultofmartians.com/tasks/evil-seed.html)
2
4
 
3
5
  # EvilSeed
4
6
 
@@ -40,7 +42,7 @@ Or install it yourself as:
40
42
  ### Configuration
41
43
 
42
44
  ```ruby
43
- require 'evil-seed'
45
+ require 'evil_seed'
44
46
 
45
47
  EvilSeed.configure do |config|
46
48
  # First, you should specify +root models+ and their +constraints+ to limit the number of dumped records:
@@ -90,7 +92,7 @@ EvilSeed.configure do |config|
90
92
  Just call the `#dump` method and pass a path where you want your SQL dump file to appear!
91
93
 
92
94
  ```ruby
93
- require 'evil-seed'
95
+ require 'evil_seed'
94
96
  EvilSeed.dump('path/to/new_dump.sql')
95
97
  ```
96
98
 
@@ -122,6 +124,53 @@ This gem has been tested against:
122
124
  3. Some internal refactoring is required
123
125
 
124
126
 
127
+ ## Standalone usage
128
+
129
+ If you want to use it as a standalone application, you can place exerything in a single file like this:
130
+
131
+ ```ruby
132
+ #!/usr/bin/env ruby
133
+
134
+ require 'bundler/inline'
135
+
136
+ gemfile do
137
+ source 'https://rubygems.org'
138
+ gem 'activerecord'
139
+ gem 'evil-seed'
140
+ gem 'mysql2'
141
+ end
142
+
143
+ # Describe your database layout with ActiveRecord models.
144
+ # See http://guides.rubyonrails.org/active_record_basics.html
145
+
146
+ class Category < ActiveRecord::Base
147
+ has_many :translations, class_name: "Category::Translation"
148
+ end
149
+
150
+ class Category::Translation < ActiveRecord::Base
151
+ belongs_to :category, inverse_of: :translations
152
+ end
153
+
154
+ # Configure evil-seed itself
155
+ EvilSeed.configure do |config|
156
+ config.root("Category", "id < ?", 1000)
157
+ end
158
+
159
+ # Connect to your database.
160
+ # See http://guides.rubyonrails.org/configuring.html#configuring-a-database)
161
+ ActiveRecord::Base.establish_connection(ENV.fetch("DATABASE_URL"))
162
+
163
+ # Create dump in dump.sql file in the same directory as this script
164
+ EvilSeed.dump(File.join(__dir__, "dump.sql").to_s)
165
+ ```
166
+
167
+ And launch it like so:
168
+
169
+ ```sh
170
+ DATABASE_URL=mysql2://user:pass@host/db ruby path/to/your/script.rb
171
+ ```
172
+
173
+
125
174
  ## Development
126
175
 
127
176
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -31,7 +31,9 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_development_dependency 'rake', '~> 12.0'
33
33
  spec.add_development_dependency 'minitest', '~> 5.0'
34
- spec.add_development_dependency 'pg', '~> 0.20'
34
+ spec.add_development_dependency 'pg', '>= 0.20'
35
+ spec.add_development_dependency 'mysql2'
36
+ spec.add_development_dependency 'sqlite3'
35
37
  spec.add_development_dependency 'rubocop'
36
38
  spec.add_development_dependency 'bundler'
37
39
  spec.add_development_dependency 'pry'
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -2,9 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mysql2"
6
- gem "pg"
7
- gem "sqlite3"
8
5
  gem "activerecord", "~> 4.2.0"
6
+ gem "pg", "~> 0.20"
7
+ gem "mysql2", "~> 0.3.18"
9
8
 
10
- gemspec path: ".."
9
+ gemspec path: "../"
@@ -2,9 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mysql2"
6
- gem "pg"
7
- gem "sqlite3"
8
5
  gem "activerecord", "~> 5.0.0"
6
+ gem "pg", "~> 0.20"
7
+ gem "mysql2", "~> 0.4.4"
9
8
 
10
- gemspec path: ".."
9
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.1.0"
6
+ gem "mysql2", "~> 0.4.4"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.2.0.rc2"
6
+ gem "mysql2", "~> 0.4.4"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", git: "https://github.com/rails/rails.git"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './evil_seed'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'tempfile'
2
3
 
3
4
  module EvilSeed
4
5
  # - Runs all transformation objects for every tuple
@@ -144,7 +144,7 @@ module EvilSeed
144
144
  next false if reflection.options[:polymorphic] # TODO: Add support for polymorphic belongs_to
145
145
  excluded = root.excluded?("#{association_path}.#{reflection.name}") || reflection.name == inverse_reflection
146
146
  if excluded
147
- nullify_columns << reflection.foreign_key
147
+ nullify_columns << reflection.foreign_key if model_class.attribute_names.include?(reflection.foreign_key)
148
148
  else
149
149
  foreign_keys[reflection.name] = reflection.foreign_key
150
150
  table_names[reflection.name] = reflection.table_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvilSeed
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evil-seed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-05-15 00:00:00.000000000 Z
12
+ date: 2018-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -57,16 +57,44 @@ dependencies:
57
57
  name: pg
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0.20'
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
69
  version: '0.20'
70
+ - !ruby/object:Gem::Dependency
71
+ name: mysql2
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: sqlite3
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
70
98
  - !ruby/object:Gem::Dependency
71
99
  name: rubocop
72
100
  requirement: !ruby/object:Gem::Requirement
@@ -143,8 +171,13 @@ files:
143
171
  - bin/console
144
172
  - bin/setup
145
173
  - evil-seed.gemspec
174
+ - gemfiles/.bundle/config
146
175
  - gemfiles/activerecord_4_2.gemfile
147
176
  - gemfiles/activerecord_5_0.gemfile
177
+ - gemfiles/activerecord_5_1.gemfile
178
+ - gemfiles/activerecord_5_2.gemfile
179
+ - gemfiles/activerecord_master.gemfile
180
+ - lib/evil-seed.rb
148
181
  - lib/evil/seed.rb
149
182
  - lib/evil_seed.rb
150
183
  - lib/evil_seed/anonymizer.rb
@@ -177,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
210
  version: '0'
178
211
  requirements: []
179
212
  rubyforge_project:
180
- rubygems_version: 2.6.4
213
+ rubygems_version: 2.7.6
181
214
  signing_key:
182
215
  specification_version: 4
183
216
  summary: Create partial and anonymized production database dumps for use in development