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.



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

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.



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

def default_dump_watch_paths
  @default_dump_watch_paths
end

#dump_matching_queriesObject

Returns the value of attribute dump_matching_queries.



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

def dump_matching_queries
  @dump_matching_queries
end

#dump_sequence_startObject

Returns the value of attribute dump_sequence_start.



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

def dump_sequence_start
  @dump_sequence_start
end

#dumps_dirObject

Returns the value of attribute dumps_dir.



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

def dumps_dir
  @dumps_dir
end

#force_matching_dumpsObject

Returns the value of attribute force_matching_dumps.



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

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.



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

def import_dump_via_cli
  @import_dump_via_cli
end

#reporting_enabledObject Also known as: reporting_enabled?

Returns the value of attribute reporting_enabled.



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

def reporting_enabled
  @reporting_enabled
end

Instance Method Details

#after_dump(&block) ⇒ Object



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

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

#before_dump(&block) ⇒ Object



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

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

#dump_sequence_random_startObject



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

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