Class: DatabaseResetter
- Inherits:
-
Object
- Object
- DatabaseResetter
- Defined in:
- lib/database_resetter.rb
Instance Method Summary collapse
-
#initialize(options = { }) ⇒ DatabaseResetter
constructor
A new instance of DatabaseResetter.
- #reset_if_required ⇒ Object
Constructor Details
#initialize(options = { }) ⇒ DatabaseResetter
Returns a new instance of DatabaseResetter.
4 5 6 7 8 9 |
# File 'lib/database_resetter.rb', line 4 def initialize( = { }) # NOTE There are no features/specs to prove the defaults are present @environment = .fetch(:environment, ENV["RAILS_ENV"]) @command_pattern = .fetch(:command_pattern, "rake db:reset RAILS_ENV=%ENV%") @files_to_watch = "#{.fetch(:migration_directory, "db/migrate")}/**/*.rb" end |
Instance Method Details
#reset_if_required ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/database_resetter.rb', line 11 def reset_if_required if migration_dir.empty? puts "*** No migrations" return end if migrations_changed_since_last_database_reset? reset else puts "*** Skipping database reset (migrations not changed since last run)" puts "*** Run `#{reset_command}` if necessary, or touch a migration" end end |