seed-do 3.0.1 → 3.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18ec9fb81796b2fb8c24d686eb2e2f7bb7434f13e69e968f13ea5683b48cf211
4
- data.tar.gz: d67817e2f0bc3bf16ac5a05c853669e485151c4b412cf5ab33f08e41acf80028
3
+ metadata.gz: 69d211a80ebaf45211662e4516fe8afce5faa791200698f33981c26e4ad42b8a
4
+ data.tar.gz: 2e0e1451a4ff850f37bc45a6680963544d18b9127445f8a7890445cebc363e5d
5
5
  SHA512:
6
- metadata.gz: 26032a64a24b0e543e4bd5bcabf776551c3c615a1fe49b948e07b2572e84ed9b58bc70286ad6ed7d146891653279cec411515c3c89227afe26ba2d0c8ee46ef5
7
- data.tar.gz: ef24c2ad905e56f29d9c50f56325074ea7509cd9681269fe6ce8923a4f1ccb07187593325810de7f9c1595fa33f241ed9699169bcf501c40b9e799330c23690a
6
+ metadata.gz: 34a8c84e4af898151f69807c9d5f6fdf57972f1172b63b8666ecb5f7cf4554f5083af01018091876ff6d02ef0abd94e60db39551dc0e71418f730ad8731d4380
7
+ data.tar.gz: 16987682e15bc6265c08e6fb4998f8dea8e44e50f4d835f703dc4e951fa3c51edd6525ff6820390d06774330028485bc04ef5c604816de2e693adc1c44de4679
data/README.md CHANGED
@@ -4,39 +4,14 @@ This project is a fork of [seed-fu](https://github.com/mbleigh/seed-fu).
4
4
 
5
5
  Seed Do is an attempt to once and for all solve the problem of inserting and maintaining seed data in a database. It uses a variety of techniques gathered from various places around the web and combines them to create what is hopefully the most robust seed data system around.
6
6
 
7
- ## Basic Example
8
-
9
- ### In `db/fixtures/users.rb`
10
-
11
- ```ruby
12
- User.seed do |s|
13
- s.id = 1
14
- s.login = "jon"
15
- s.email = "jon@example.com"
16
- s.name = "Jon"
17
- end
18
-
19
- User.seed do |s|
20
- s.id = 2
21
- s.login = "emily"
22
- s.email = "emily@example.com"
23
- s.name = "Emily"
24
- end
25
- ```
26
-
27
- ### To load the data:
28
-
29
- ```ruby
30
- $ rake db:seed_do
31
- == Seed from /path/to/app/db/fixtures/users.rb
32
- - User {:id=>1, :login=>"jon", :email=>"jon@example.com", :name=>"Jon"}
33
- - User {:id=>2, :login=>"emily", :email=>"emily@example.com", :name=>"Emily"}
34
- ```
35
-
36
7
  ## Installation
37
8
 
38
9
  Just add `gem 'seed-do'` to your `Gemfile`
39
10
 
11
+ ## Documentation
12
+
13
+ For detailed API documentation, please visit: https://rubydoc.info/github/willnet/seed-do
14
+
40
15
  ## Migrating from seed-fu
41
16
 
42
17
  If you are migrating from seed-fu to seed-do, you'll need to make the following changes:
@@ -70,6 +45,36 @@ require 'seed-do/capistrano'
70
45
  require 'seed-do/capistrano3'
71
46
  ```
72
47
 
48
+ ## Basic Example
49
+
50
+
51
+ ### In `db/fixtures/users.rb`
52
+
53
+ ```ruby
54
+ User.seed do |s|
55
+ s.id = 1
56
+ s.login = "jon"
57
+ s.email = "jon@example.com"
58
+ s.name = "Jon"
59
+ end
60
+
61
+ User.seed do |s|
62
+ s.id = 2
63
+ s.login = "emily"
64
+ s.email = "emily@example.com"
65
+ s.name = "Emily"
66
+ end
67
+ ```
68
+
69
+ ### To load the data:
70
+
71
+ ```ruby
72
+ $ rake db:seed_do
73
+ == Seed from /path/to/app/db/fixtures/users.rb
74
+ - User {:id=>1, :login=>"jon", :email=>"jon@example.com", :name=>"Jon"}
75
+ - User {:id=>2, :login=>"emily", :email=>"emily@example.com", :name=>"Emily"}
76
+ ```
77
+
73
78
  ## Constraints
74
79
 
75
80
  Constraints are used to identify seeds, so that they can be updated if necessary. For example:
@@ -175,6 +180,26 @@ require 'seed-do/capistrano3'
175
180
  before 'deploy:publishing', 'db:seed_do'
176
181
  ```
177
182
 
183
+ ## Development
184
+
185
+ ### To run the specs
186
+
187
+ ```
188
+ bundle install # Install the dependencies
189
+ bundle exec rspec # Run the specs
190
+ ```
191
+
192
+ By default an sqlite3 database is used.
193
+
194
+ ### To test others
195
+
196
+ ```
197
+ DB=mysql2 bundle exec rspec
198
+ DB=postgresql bundle exec rspec
199
+ ```
200
+
201
+ The connection paramaters for each of these are specified in spec/connections/, which you can edit if necessary (for example to change the username/password).
202
+
178
203
  ## Original Author
179
204
 
180
205
  [Michael Bleigh](http://www.mbleigh.com/) is the original author
@@ -64,13 +64,7 @@ module SeedDo
64
64
 
65
65
  puts " - #{@model_class} #{data.inspect}" unless @options[:quiet]
66
66
 
67
- # Rails 3 or Rails 4 + rails/protected_attributes
68
- if record.class.respond_to?(:protected_attributes) && record.class.respond_to?(:accessible_attributes)
69
- record.assign_attributes(data, :without_protection => true)
70
- # Rails 4 without rails/protected_attributes
71
- else
72
- record.assign_attributes(data)
73
- end
67
+ record.assign_attributes(data)
74
68
  record.save(:validate => false) || raise(ActiveRecord::RecordNotSaved, 'Record not saved!')
75
69
  record
76
70
  end
@@ -91,8 +85,7 @@ module SeedDo
91
85
  quoted_id = @model_class.connection.quote_column_name(@model_class.primary_key)
92
86
  sequence = @model_class.sequence_name
93
87
 
94
- # TODO postgresql_version was made public in Rails 5.0.0, remove #send when support for earlier versions are dropped
95
- if @model_class.connection.send(:postgresql_version) >= 100000
88
+ if @model_class.connection.postgresql_version >= 100000
96
89
  sql =<<-EOS
97
90
  SELECT setval('#{sequence}', (SELECT GREATEST(MAX(#{quoted_id})+(SELECT seqincrement FROM pg_sequence WHERE seqrelid = '#{sequence}'::regclass), (SELECT seqmin FROM pg_sequence WHERE seqrelid = '#{sequence}'::regclass)) FROM #{@model_class.quoted_table_name}), false)
98
91
  EOS
@@ -1,3 +1,3 @@
1
1
  module SeedDo
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seed-do
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinichi Maeshima