seedbank 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,11 +5,11 @@ Seedbank allows you to structure your Rails seed data instead of having it all d
5
5
 
6
6
  Seedbank assumes common seed data is under db/seeds and any directories under db/seeds/ are specific to an environment, so db/seeds/development is contains all your development only seed data.
7
7
 
8
- The reason behind Seedbank is laziness. When I checkout or re-visit a project I don't want to mess around getting my environment setup I just want the code and a database loaded with data in a known state. Since the Rails core team were good enough to give us rake db:setup it would be rude not to use it.
8
+ The reason behind Seedbank is laziness. When I checkout or re-visit a project I don't want to mess around getting my environment setup I just want the code and a database loaded with data in a known state. Since the Rails core team were good enough to give us rake db:setup it would be rude not to use it.
9
9
 
10
10
  rake db:setup # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)
11
11
 
12
- To achieve this slothful aim Seedbank renames the original db:seed rake task to db:seed:original, makes it a dependency for all the Seedbank seeds and adds a new db:seed task that loads all the common seeds in db/seeds plus all the seeds for the current Rails environment.
12
+ To achieve this slothful aim Seedbank renames the original db:seed rake task to db:seed:original, makes it a dependency for all the Seedbank seeds and adds a new db:seed task that loads all the common seeds in db/seeds plus all the seeds for the current Rails environment.
13
13
 
14
14
  Example
15
15
  =======
@@ -21,7 +21,7 @@ Seedbank seeds follow this structure;
21
21
  develpment/
22
22
  users.seeds.rb
23
23
  foo.seeds.rb
24
-
24
+
25
25
  This would generate the following Rake tasks
26
26
 
27
27
  rake db:seed # 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.
@@ -35,11 +35,11 @@ This would generate the following Rake tasks
35
35
  Therefor assuming RAILS_ENV is not set or is 'development'
36
36
 
37
37
  $ rake db:seed
38
-
39
- would load the seeds in db/seeds.rb, db/seeds/bar.seeds.rb, db/seeds/foo.seeds/rb and db/seeds/development/users.seeds.rb. Whereas
38
+
39
+ would load the seeds in db/seeds.rb, db/seeds/bar.seeds.rb, db/seeds/foo.seeds/rb and db/seeds/development/users.seeds.rb. Whereas
40
40
 
41
41
  $ RAILS_ENV=production db:seed
42
-
42
+
43
43
  would load the seeds in db/seeds.rb, db/seeds/bar.seeds.rb and db/seeds/foo.seeds/rb
44
44
 
45
45
  Installation
@@ -58,7 +58,7 @@ That's it!
58
58
  Add to your config/environment.rb
59
59
 
60
60
  config.gem 'seedbank'
61
-
61
+
62
62
  Install the gem;
63
63
 
64
64
  $ rake gems:install
@@ -67,7 +67,7 @@ Then in the bottom of your applications Rakefile:
67
67
 
68
68
  require 'seedbank'
69
69
  Seedbank.load_tasks if defined?(Seedbank)
70
-
70
+
71
71
  If you vendor the gem you'll need to change the require to the specific path.
72
72
 
73
73
  Note on Patches/Pull Request
@@ -76,7 +76,7 @@ Note on Patches/Pull Request
76
76
  * Fork the project.
77
77
  * Make your feature addition or bug fix.
78
78
  * Add tests for it (when I have some). This is important so I don't break it in a future version unintentionally.
79
- * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but
79
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but
80
80
  bump version in a commit by itself I can ignore it when I pull)
81
81
  * Send me a pull request. Bonus points for topic branches.
82
82
 
data/lib/seedbank.rb CHANGED
@@ -8,17 +8,17 @@ Rake::Task.extend(Seedbank::Task)
8
8
  Rake::Application.send(:include, Seedbank::TaskManager)
9
9
 
10
10
  module Seedbank
11
-
11
+
12
12
  @@seeds_root = 'db/seeds'
13
-
13
+
14
14
  def self.seeds_root
15
15
  @@seeds_root
16
16
  end
17
-
17
+
18
18
  def self.load_tasks
19
- Dir[File.expand_path("tasks/*.rake", File.dirname(__FILE__))].each { |ext| load ext }
19
+ Dir[File.expand_path("tasks/*.rake", File.dirname(__FILE__))].each { |ext| load ext }
20
20
  end
21
-
21
+
22
22
  require 'seedbank/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
23
-
23
+
24
24
  end
data/lib/seedbank/dsl.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Seedbank
2
2
  module DSL
3
-
3
+
4
4
  def override_task(*args, &block)
5
5
  name, params, deps = Rake.application.resolve_args(args.dup)
6
6
  fq_name = Rake.application.instance_variable_get(:@scope).dup.push(name).join(':')
@@ -8,22 +8,22 @@ module Seedbank
8
8
  Rake::Task.rename_task(fq_name, new_name)
9
9
  Rake::Task.define_task(*args, &block)
10
10
  end
11
-
12
- # Creates a task namespaced in @seeds_path
11
+
12
+ # Creates a task namespaced in @seeds_path
13
13
  def define_seed_task(seed_file)
14
14
  relative_root = seed_file.sub(seeds_root + '/', '')
15
15
  scopes = File.dirname(relative_root).gsub(/^\./, '').split('/').unshift('seed')
16
16
  fq_name = scopes.push(File.basename(seed_file, '.seeds.rb')).join(':')
17
17
 
18
18
  args = { fq_name => 'db:abort_if_pending_migrations' }
19
- task = Rake::Task.define_task(args) { load(seed_file) if File.exist?(seed_file) }
19
+ task = Rake::Task.define_task(args) { load(seed_file) if File.exist?(seed_file) }
20
20
  task.add_description "Load the seed data from #{seed_file}"
21
21
  fq_name
22
22
  end
23
-
23
+
24
24
  def seeds_root
25
25
  Seedbank.seeds_root
26
26
  end
27
-
27
+
28
28
  end
29
29
  end
@@ -7,6 +7,6 @@ module Seedbank
7
7
  rake_tasks do
8
8
  Seedbank.load_tasks
9
9
  end
10
-
10
+
11
11
  end
12
12
  end
data/lib/tasks/seed.rake CHANGED
@@ -1,36 +1,36 @@
1
1
  namespace :db do
2
-
2
+
3
3
  include Seedbank::DSL
4
-
4
+
5
5
  base_dependencies = ['db:seed:original']
6
6
  override_dependency = []
7
-
7
+
8
8
  common_dependencies = []
9
- # Create seed tasks for all the seeds in seeds_path and add them to the dependency
9
+ # Create seed tasks for all the seeds in seeds_path and add them to the dependency
10
10
  # list along with the original db/seeds.rb.
11
11
  Dir.glob(File.join(seeds_root, '*.seeds.rb')).each do |seed_file|
12
12
  common_dependencies << define_seed_task(seed_file)
13
13
  end
14
-
14
+
15
15
  desc "Load the seed data from db/seeds.rb and db/seeds/*.seeds.rb."
16
16
  task ['seed', 'common'] => base_dependencies + common_dependencies
17
-
17
+
18
18
  # Glob through the directories under seeds_path assuming they are all environments
19
19
  # and create a task for each and add it to the dependency list. Then create a task
20
20
  # for the environment
21
21
  Dir[seeds_root + '/*/'].each do |e|
22
22
  environment = File.basename(e)
23
-
23
+
24
24
  environment_dependencies = []
25
25
  Dir.glob(File.join(seeds_root, environment, '*.seeds.rb')).each do |seed_file|
26
26
  environment_dependencies << define_seed_task(seed_file)
27
27
  end
28
-
28
+
29
29
  desc <<-EOT
30
30
  Load the seed data from db/seeds.rb, db/seeds/*.seeds.rb and db/seeds/#{environment}/*.seeds.rb.
31
31
  EOT
32
32
  task ['seed', environment] => ['db:seed:common'] + environment_dependencies
33
-
33
+
34
34
  override_dependency << "db:seed:#{environment}" if Rails.env == environment
35
35
  end
36
36
 
@@ -40,5 +40,5 @@ namespace :db do
40
40
  ENVIRONMENT is the current environment in Rails.env.
41
41
  EOT
42
42
  override_task :seed => ['db:seed:common'] + override_dependency
43
-
43
+
44
44
  end
data/seedbank.gemspec CHANGED
@@ -1,30 +1,51 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{seedbank}
3
- s.version = "0.0.6"
3
+ s.version = "0.0.7"
4
+ s.date = %q{2011-03-20}
4
5
 
5
6
  s.required_rubygems_version = Gem::Requirement.new(">=1.2.0") if s.respond_to?(:required_rubygems_version=)
7
+ s.rubygems_version = %q{1.3.5}
8
+
6
9
  s.authors = ["James McCarthy"]
7
- s.date = %q{2011-03-20}
10
+ s.email = %q{james2mccarthy@gmail.com}
11
+ s.homepage = %q{http://github.com/james2m/seedbank}
12
+ s.summary = %q{
13
+ Extends Rails seeds to split out complex seeds into their own file
14
+ and have different seeds for each environment.
15
+ }
8
16
  s.description = %q{
9
- Extends Rails seeds to split out complex seeds into multiple
17
+ Extends Rails seeds to split out complex seeds into multiple
10
18
  files and lets each environment have it's own seeds.
11
19
  }
12
- s.email = %q{james2mccarthy@gmail.com}
20
+
21
+ s.files = Dir.glob('**/*') - Dir.glob('seedbank*.gem')
22
+ s.require_paths = ["lib"]
23
+
24
+ s.rdoc_options = ["--charset=UTF-8"]
13
25
  s.extra_rdoc_files = [
14
26
  "MIT-LICENSE",
15
27
  "README.md"
16
28
  ]
17
- s.files = Dir.glob('**/*') - Dir.glob('seedbank*.gem')
18
- s.homepage = %q{http://github.com/james2m/seedbank}
19
- s.rdoc_options = ["--charset=UTF-8"]
20
- s.require_paths = ["lib"]
21
- s.rubygems_version = %q{1.3.5}
22
- s.summary = %q{
23
- Extends Rails seeds to split out complex seeds into their own file
24
- and have different seeds for each environment.
25
- }
26
- s.test_files = Dir.glob('test/**/*')
27
29
 
30
+ s.test_files = Dir.glob('test/**/*')
28
31
  s.add_development_dependency('test-unit')
32
+
33
+ s.post_install_message = %q{
34
+ ================================================================================
35
+
36
+ Rails 2.x
37
+ ---------
38
+ If you are using Seedbank with Rails 2.x you will need to place the following at
39
+ the end of your Rakefile so Rubygems can load the seedbank tasks;
40
+
41
+ require 'seedbank'
42
+ Seedbank.load_tasks if defined?(Seedbank)
43
+
44
+ Rails 3.x
45
+ ---------
46
+ Your work here is done!
47
+
48
+ ================================================================================
49
+ }
29
50
  end
30
51
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: seedbank
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.6
5
+ version: 0.0.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - James McCarthy
@@ -24,7 +24,7 @@ dependencies:
24
24
  version: "0"
25
25
  type: :development
26
26
  version_requirements: *id001
27
- description: "\n Extends Rails seeds to split out complex seeds into multiple \n files and lets each environment have it's own seeds.\n "
27
+ description: "\n Extends Rails seeds to split out complex seeds into multiple\n files and lets each environment have it's own seeds.\n "
28
28
  email: james2mccarthy@gmail.com
29
29
  executables: []
30
30
 
@@ -53,7 +53,7 @@ has_rdoc: true
53
53
  homepage: http://github.com/james2m/seedbank
54
54
  licenses: []
55
55
 
56
- post_install_message:
56
+ post_install_message: "\n ================================================================================\n\n Rails 2.x\n ---------\n If you are using Seedbank with Rails 2.x you will need to place the following at \n the end of your Rakefile so Rubygems can load the seedbank tasks;\n\n require 'seedbank'\n Seedbank.load_tasks if defined?(Seedbank)\n\n Rails 3.x\n ---------\n Your work here is done!\n\n ================================================================================\n "
57
57
  rdoc_options:
58
58
  - --charset=UTF-8
59
59
  require_paths:
@@ -76,7 +76,7 @@ rubyforge_project:
76
76
  rubygems_version: 1.5.0
77
77
  signing_key:
78
78
  specification_version: 3
79
- summary: Extends Rails seeds to split out complex seeds into their own file and have different seeds for each environment.
79
+ summary: Extends Rails seeds to split out complex seeds into their own file and have different seeds for each environment.
80
80
  test_files:
81
81
  - test/seedbank_test.rb
82
82
  - test/test_helper.rb