Module: SeedFuNdo

Defined in:
lib/seed-fu-ndo.rb,
lib/seed-fu-ndo/railtie.rb,
lib/seed-fu-ndo/version.rb,
lib/seed-fu-ndo/recorder.rb

Defined Under Namespace

Classes: Railtie, Recorder

Constant Summary collapse

VERSION =

The current version of Seed Fu-ndo

'0.0.2'

Class Method Summary collapse

Class Method Details

.capture(fixture_paths = SeedFu.fixture_paths, filter = nil) ⇒ Object

Captures the seed fixtures without actually inserting anything. Returns a list of seeder objects.



31
32
33
34
35
36
37
# File 'lib/seed-fu-ndo.rb', line 31

def self.capture(fixture_paths = SeedFu.fixture_paths, filter = nil)
  @@recorder = Recorder.new
  SeedFu::Runner.new(fixture_paths, filter).run
  @@recorder.seeders
ensure
  @@recorder = nil
end

.existing_seeds(fixture_paths = SeedFu.fixture_paths, filter = nil) ⇒ Object

Returns all seed records from the given fixture_paths that currently exist in the database. No changes to the database are performed.



21
22
23
24
25
26
27
# File 'lib/seed-fu-ndo.rb', line 21

def self.existing_seeds(fixture_paths = SeedFu.fixture_paths, filter = nil)
  existing = Hash.new {|h, k| h[k] = [] }
  capture(fixture_paths, filter).each do |seeder|
    existing[seeder.model_class] += seeder.existing_records
  end
  existing
end

.unseed(fixture_paths = SeedFu.fixture_paths, filter = nil) ⇒ Object

Unload seed data from files. Main entry point for third-party libraries.

fixture_paths

The paths to look for seed files in.

filter

A regexp. If given, only filenames matching this expression will be loaded.



13
14
15
16
17
# File 'lib/seed-fu-ndo.rb', line 13

def self.unseed(fixture_paths = SeedFu.fixture_paths, filter = nil)
  capture(fixture_paths, filter).reverse.each do |seeder|
    seeder.unseed
  end
end