seedomatic 0.3.0 → 0.4.0

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.
@@ -0,0 +1,9 @@
1
+ require 'rails'
2
+
3
+ module SeedOMatic
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load File.expand_path(File.dirname(__FILE__) + "../../../tasks/seed.rake")
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Seedomatic
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/seedomatic.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "seedomatic/version"
2
+ require "seedomatic/railtie" if defined?(Rails)
2
3
 
3
4
  require 'yaml'
4
5
  require 'active_support/core_ext'
data/readme.markdown CHANGED
@@ -4,12 +4,13 @@
4
4
  Seeds and db:fixture:load are great, but they're usually written in a way that they can only be used on an initial deploy. Seed-O-Matic gives you tools to specify seed data in a way that's repeatable across environments, allowing you to change seed data in a safe way between all of your environments.
5
5
 
6
6
  ## Seed Files
7
- Seed files are set up as YAML files. By default, Seed-O-Matic will look for seed files in `config/seeds`, although you can
7
+ Seed files are set up as JSON or YAML files. By default, Seed-O-Matic will look for seed files in `config/seeds`, although you can
8
8
  specify another directory when you run your seeds. Here's the structure of a typical seed file:
9
9
 
10
10
  my_model:
11
11
  match_on: code
12
12
  tags: [initial_run, professional]
13
+ seed_mode: once
13
14
  items:
14
15
  - name: My Model 1
15
16
  code: my_model
@@ -17,6 +18,7 @@ specify another directory when you run your seeds. Here's the structure of a typ
17
18
  code: my_model_2
18
19
  other_model:
19
20
  match_on: [code, category]
21
+ seed_mode: always
20
22
  items:
21
23
  - name: Other Model 1
22
24
  code: om_1
@@ -30,15 +32,27 @@ specify another directory when you run your seeds. Here's the structure of a typ
30
32
  * You can specify a *match_on* attribute to prevent duplicate entries being created when seeds are run a second time.
31
33
  Seed-O-Matic will try to find an entry which matches your match_on fields, and update if one is found. Multiple items work as well.
32
34
  * You can tag your seed files as well, if you want to import a subset of seeds in particular circumstances.
35
+ * `seed_mode` controls how SeedOMatic handles records that were matched based on the match_on fields. See 'Seed Mode' below for more details.
33
36
 
34
37
  ## Running Seeds
35
38
 
39
+ ### In Ruby
40
+
36
41
  Running seeds is as easy as calling:
37
42
 
38
43
  SeedOMatic.run
39
44
 
40
45
  This will look through the directory `config/seeds`, and import every file in that directory.
41
46
 
47
+ ### As a rake task
48
+
49
+ SeedOMatic provides the following rake task:
50
+
51
+ rake seedomatic:seed
52
+
53
+ This will run seeds in the `config/seeds` directory. You can provide `SEED_DIRECTORY`, `TAGGED_WITH`, and `NOT_TAGGED_WITH`
54
+ arguments to the rake task to customize which seeds are run (See the sections below for valid values for these arguments).
55
+
42
56
  ### Seed Mode
43
57
 
44
58
  You can set a *seed mode* to control how SeedOMatic handles entries that already exist (i.e. models that matched the match_on
@@ -70,4 +84,4 @@ You can load tags using the `tagged_with`, and `not_tagged_with` options:
70
84
  ## TODO
71
85
 
72
86
  * Referencing lookups from other seed files
73
- * Selective updating of data
87
+ * Selective updating of data
data/tasks/seed.rake ADDED
@@ -0,0 +1,12 @@
1
+ namespace :seedomatic do
2
+ desc "Run Seed-O-Matic seed fixtures"
3
+ task :seed => :environment do
4
+ results = SeedOMatic.run :dir => ENV['SEED_DIRECTORY'],
5
+ :tagged_with => ENV['SEED_TAGGED_WITH'],
6
+ :not_tagged_with => ENV['SEED_NOT_TAGGED_WITH']
7
+
8
+ results.each do |model, counts|
9
+ puts "#{model} - [#{counts[:new]} new | #{counts[:updated]} updated]"
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seedomatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70123092620800 !ruby/object:Gem::Requirement
16
+ requirement: &70296477233420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.9.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70123092620800
24
+ version_requirements: *70296477233420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70123096919180 !ruby/object:Gem::Requirement
27
+ requirement: &70296477231760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70123096919180
35
+ version_requirements: *70296477231760
36
36
  description: Create repeatable seed fixtures that you can continually use and deploy
37
37
  to multiple environments and tenants.
38
38
  email:
@@ -46,6 +46,7 @@ files:
46
46
  - Gemfile
47
47
  - Rakefile
48
48
  - lib/seedomatic.rb
49
+ - lib/seedomatic/railtie.rb
49
50
  - lib/seedomatic/runner.rb
50
51
  - lib/seedomatic/seeder.rb
51
52
  - lib/seedomatic/version.rb
@@ -60,6 +61,7 @@ files:
60
61
  - spec/support/seed_directory/dir2.yml
61
62
  - spec/support/single_model.json
62
63
  - spec/support/single_model.yml
64
+ - tasks/seed.rake
63
65
  homepage: http://github.com/ryanbrunner/seedomatic
64
66
  licenses: []
65
67
  post_install_message: