Module: Phenix

Extended by:
Phenix
Included in:
Phenix
Defined in:
lib/phenix.rb,
lib/phenix/version.rb

Constant Summary collapse

VERSION =
'0.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.current_configurationObject

Returns the value of attribute current_configuration.



7
8
9
# File 'lib/phenix.rb', line 7

def current_configuration
  @current_configuration
end

.database_config_pathObject

Returns the value of attribute database_config_path.



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

def database_config_path
  @database_config_path
end

.schema_pathObject

Returns the value of attribute schema_path.



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

def schema_path
  @schema_path
end

.skip_databaseObject

Returns the value of attribute skip_database.



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

def skip_database
  @skip_database
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Phenix)

    the object that the method was called on



9
10
11
12
13
14
15
# File 'lib/phenix.rb', line 9

def configure
  self.database_config_path = File.join(Dir.pwd, 'test', 'database.yml')
  self.schema_path          = File.join(Dir.pwd, 'test', 'schema.rb')
  self.skip_database        = ->(_, _) { false }

  yield(self) if block_given?
end

Instance Method Details

#burn!Object



24
25
26
# File 'lib/phenix.rb', line 24

def burn!
  drop_databases
end

#load_database_config(config_path = Phenix.database_config_path) ⇒ Object



28
29
30
31
32
# File 'lib/phenix.rb', line 28

def load_database_config(config_path = Phenix.database_config_path)
  erb_config = IO.read(config_path)
  yaml_config = ERB.new(erb_config).result
  ActiveRecord::Base.configurations = Phenix.current_configuration = YAML.load(yaml_config)
end

#rise!(with_schema: true, config_path: Phenix.database_config_path) ⇒ Object



18
19
20
21
22
# File 'lib/phenix.rb', line 18

def rise!(with_schema: true, config_path: Phenix.database_config_path)
  load_database_config(config_path)
  drop_databases
  create_databases(with_schema)
end