Class: StaticDb::Load

Inherits:
Object
  • Object
show all
Defined in:
lib/static_db/load.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fixture_path:) ⇒ Load

Returns a new instance of Load.



6
7
8
# File 'lib/static_db/load.rb', line 6

def initialize(fixture_path:)
  @fixture_path = Pathname.new(fixture_path)
end

Instance Attribute Details

#fixture_pathObject (readonly)

Returns the value of attribute fixture_path.



4
5
6
# File 'lib/static_db/load.rb', line 4

def fixture_path
  @fixture_path
end

Instance Method Details

#performObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/static_db/load.rb', line 10

def perform
  puts green("Loading fixtures ...")

  reenable_rake_tasks!
  Rake::Task["db:create"].invoke
  Rake::Task["db:schema:load"].invoke
  load_fixtures!

  puts green("Done!")
rescue => e
  puts red("Failed to load fixtures: #{e.message}")
  puts red("Exiting and skipping active_fixtures:dump!")
  $skip_active_fixtures_dump = true
  exit 1
end