seedbank 0.2.0.pre → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -81,14 +81,14 @@ Usage
81
81
 
82
82
  Seeds files are just plain old Ruby executed in your rails application environment so anything you could type into the rails console will work in your seeds.
83
83
 
84
- The seed files under db/seeds are run first in alphanumeric order followed by the ones in the db/seeds/RAILS_ENV. You can add dependencies to your seed files
85
- to enforce the run order. for example;
86
-
87
84
  db/seeds/companies.seeds.rb
88
85
  ```ruby
89
- Company.find_or_create_by_name('Hatch', :url => 'http://thisishatch.co.uk' )
86
+ Company.find_or_create_by_name('Hatch', :url => 'http://thisishatch.co.uk' )
90
87
  ```
91
88
 
89
+ The seed files under db/seeds are run first in alphanumeric order followed by the ones in the db/seeds/RAILS_ENV. You can add dependencies to your seed files
90
+ to enforce the run order. for example;
91
+
92
92
  db/seeds/users.seeds.rb
93
93
  ```ruby
94
94
  after :companies do
@@ -114,6 +114,16 @@ after :projects, :users do
114
114
  end
115
115
  ```
116
116
 
117
+ If the dependencies are in one of the environment folders, you need to namespace the parent task:
118
+
119
+ db/seeds/development/users.seeds.rb
120
+ ```ruby
121
+ after "development:companies" do
122
+ company = Company.find_by_name('Hatch')
123
+ company.users.create(:first_name => 'James', :last_name => 'McCarthy')
124
+ end
125
+ ```
126
+
117
127
  Contributors
118
128
  ============
119
129
  ```shell
@@ -123,6 +133,8 @@ git log | grep Author | sort | uniq
123
133
  * James McCarthy
124
134
  * Andy Triggs
125
135
  * Philip Arndt
136
+ * Peter Suschlik
137
+ * Joost Baaij
126
138
 
127
139
  Note on Patches/Pull Request
128
140
  ============================
data/TODO.txt CHANGED
@@ -1,4 +1,4 @@
1
1
  * Add generator for seeds directories
2
2
  * Add generator for seeds data
3
- * Add ability add or update records in place
3
+ * Add ability to add or update records in place
4
4
  * Make framework agnostic
@@ -1,3 +1,3 @@
1
1
  module Seedbank
2
- VERSION = "0.2.0.pre"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/tasks/seed.rake CHANGED
@@ -3,7 +3,7 @@ namespace :db do
3
3
  include Seedbank::DSL
4
4
 
5
5
  base_dependencies = ['db:seed:original']
6
- override_dependency = []
6
+ override_dependency = ['db:seed:common']
7
7
 
8
8
  namespace :seed do
9
9
  # Create seed tasks for all the seeds in seeds_path and add them to the dependency
@@ -13,9 +13,8 @@ namespace :db do
13
13
  desc "Load the seed data from db/seeds.rb and db/seeds/*.seeds.rb."
14
14
  task 'common' => base_dependencies + common_dependencies
15
15
 
16
- # Glob through the directories under seeds_path assuming they are all environments
17
- # and create a task for each and add it to the dependency list. Then create a task
18
- # for the environment
16
+ # Glob through the directories under seeds_path and create a task for each adding it to the dependency list.
17
+ # Then create a task for the environment
19
18
  glob_seed_files_matching('/*/').each do |directory|
20
19
  environment = File.basename(directory)
21
20
 
@@ -24,15 +23,12 @@ namespace :db do
24
23
  desc "Load the seed data from db/seeds.rb, db/seeds/*.seeds.rb and db/seeds/#{environment}/*.seeds.rb."
25
24
  task environment => ['db:seed:common'] + environment_dependencies
26
25
 
27
- override_dependency << "db:seed:#{environment}" if Rails.env == environment
26
+ override_dependency << "db:seed:#{environment}" if defined?(Rails) && Rails.env == environment
28
27
  end
29
28
  end
30
29
 
31
- # Change db:seed task to run all the base seeds tasks defined above.
32
- desc <<-EOT
33
- Load the seed data from db/seeds.rb, db/seeds/*.seeds.rb and db/seeds/ENVIRONMENT/*.seeds.rb.
34
- ENVIRONMENT is the current environment in Rails.env.
35
- EOT
36
- override_seed_task :seed => ['db:seed:common'] + override_dependency
30
+ # Override db:seed to run all the common and environments seeds plus the original db:seed.
31
+ desc "Load the seed data from db/seeds.rb, db/seeds/*.seeds.rb and db/seeds/ENVIRONMENT/*.seeds.rb. ENVIRONMENT is the current environment in Rails.env."
32
+ override_seed_task :seed => override_dependency
37
33
 
38
34
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seedbank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre
5
- prerelease: 6
4
+ version: 0.2.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - James McCarthy
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-24 00:00:00.000000000 Z
12
+ date: 2012-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest