Class: TestProf::AnyFixture::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/test_prof/any_fixture.rb

Overview

AnyFixture configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/test_prof/any_fixture.rb', line 23

def initialize
  @reporting_enabled = ENV["ANYFIXTURE_REPORT"] == "1"
  @dumps_dir = "any_dumps"
  @default_dump_watch_paths = %w[
    db/schema.rb
    db/structure.sql
  ]
  @dump_sequence_start = 123_654
  @dump_matching_queries = /^$/
  @import_dump_via_cli = ENV["ANYFIXTURE_IMPORT_DUMP_CLI"] == "1"
  @before_dump = []
  @after_dump = []
  @force_matching_dumps =
    if ENV["ANYFIXTURE_FORCE_DUMP"] == "1"
      /.*/
    elsif ENV["ANYFIXTURE_FORCE_DUMP"]
      /#{ENV["ANYFIXTURE_FORCE_DUMP"]}/
    else
      /^$/
    end
end

Instance Attribute Details

#default_dump_watch_pathsObject (readonly)

Returns the value of attribute default_dump_watch_paths.



18
19
20
# File 'lib/test_prof/any_fixture.rb', line 18

def default_dump_watch_paths
  @default_dump_watch_paths
end

#dump_matching_queriesObject

Returns the value of attribute dump_matching_queries.



16
17
18
# File 'lib/test_prof/any_fixture.rb', line 16

def dump_matching_queries
  @dump_matching_queries
end

#dump_sequence_startObject

Returns the value of attribute dump_sequence_start.



16
17
18
# File 'lib/test_prof/any_fixture.rb', line 16

def dump_sequence_start
  @dump_sequence_start
end

#dumps_dirObject

Returns the value of attribute dumps_dir.



16
17
18
# File 'lib/test_prof/any_fixture.rb', line 16

def dumps_dir
  @dumps_dir
end

#force_matching_dumpsObject

Returns the value of attribute force_matching_dumps.



16
17
18
# File 'lib/test_prof/any_fixture.rb', line 16

def force_matching_dumps
  @force_matching_dumps
end

#import_dump_via_cliObject Also known as: import_dump_via_cli?

Returns the value of attribute import_dump_via_cli.



16
17
18
# File 'lib/test_prof/any_fixture.rb', line 16

def import_dump_via_cli
  @import_dump_via_cli
end

#reporting_enabledObject Also known as: reporting_enabled?

Returns the value of attribute reporting_enabled.



16
17
18
# File 'lib/test_prof/any_fixture.rb', line 16

def reporting_enabled
  @reporting_enabled
end

Instance Method Details

#after_dump(&block) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/test_prof/any_fixture.rb', line 53

def after_dump(&block)
  if block
    @after_dump << block
  else
    @after_dump
  end
end

#before_dump(&block) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/test_prof/any_fixture.rb', line 45

def before_dump(&block)
  if block
    @before_dump << block
  else
    @before_dump
  end
end

#dump_sequence_random_startObject



61
62
63
# File 'lib/test_prof/any_fixture.rb', line 61

def dump_sequence_random_start
  rand(dump_sequence_start..(dump_sequence_start * 2))
end