Class: Railbow::MultiDb::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/railbow/multi_db.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBatch

Returns a new instance of Batch.



17
18
19
20
21
22
# File 'lib/railbow/multi_db.rb', line 17

def initialize
  @sections = []
  @skipped = []
  @git_cache = {}
  @help_shown = false
end

Instance Attribute Details

#git_cacheObject (readonly)

Returns the value of attribute git_cache.



15
16
17
# File 'lib/railbow/multi_db.rb', line 15

def git_cache
  @git_cache
end

Instance Method Details

#add(section) ⇒ Object

Databases sharing a migrations path see the same files, so they merge into one section that carries a status per database.



32
33
34
35
36
37
38
39
# File 'lib/railbow/multi_db.rb', line 32

def add(section)
  existing = @sections.find { |s| s.same_migrations?(section) }
  if existing
    existing.merge!(section)
  else
    @sections << section
  end
end

#claim_helpObject



41
42
43
44
45
# File 'lib/railbow/multi_db.rb', line 41

def claim_help
  return false if @help_shown

  @help_shown = true
end

#empty?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/railbow/multi_db.rb', line 47

def empty?
  @sections.empty? && @skipped.empty?
end

#flushObject



51
52
53
54
55
56
57
# File 'lib/railbow/multi_db.rb', line 51

def flush
  return if empty?

  Railbow::Status::Printer.new(@sections, skipped: @skipped).print
  @sections = []
  @skipped = []
end

#skip(name) ⇒ Object

A database excluded by RBW_DB. Recorded rather than dropped so the run can say what it left out.



26
27
28
# File 'lib/railbow/multi_db.rb', line 26

def skip(name)
  @skipped << name.to_s
end