Class: Skiima::Loader

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Config
Defined in:
lib/skiima/loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Config

#config, #config=, #full_database_path, #full_dependencies_path, #full_scripts_path, #interpolate_sql, #method_missing, #read_db_yml, #read_dependencies_yml, #read_sql_file, #read_yml_or_throw, #symbolize_keys

Constructor Details

#initialize(env, opts = {}) ⇒ Loader

Returns a new instance of Loader.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/skiima/loader.rb', line 19

def initialize(env, opts = {})
  @env = env
  merge_db_config(opts.delete(:db) || {})
  get_config(opts)
  set_vars
  create_logger
  create_resolver
  create_connector
  get_dependency_config
  create_dependency_reader
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Skiima::Config

Instance Attribute Details

#connectorObject

Returns the value of attribute connector.



8
9
10
# File 'lib/skiima/loader.rb', line 8

def connector
  @connector
end

#dbObject

Returns the value of attribute db.



8
9
10
# File 'lib/skiima/loader.rb', line 8

def db
  @db
end

#dependenciesObject

Returns the value of attribute dependencies.



8
9
10
# File 'lib/skiima/loader.rb', line 8

def dependencies
  @dependencies
end

#directionObject

Returns the value of attribute direction.



9
10
11
# File 'lib/skiima/loader.rb', line 9

def direction
  @direction
end

#envObject

Returns the value of attribute env.



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

def env
  @env
end

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/skiima/loader.rb', line 11

def logger
  @logger
end

#readerObject

Returns the value of attribute reader.



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

def reader
  @reader
end

#resolverObject

Returns the value of attribute resolver.



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

def resolver
  @resolver
end

#scriptsObject

Returns the value of attribute scripts.



10
11
12
# File 'lib/skiima/loader.rb', line 10

def scripts
  @scripts
end

#varsObject

Returns the value of attribute vars.



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

def vars
  @vars
end

Instance Method Details

#create_connectorObject



47
48
49
# File 'lib/skiima/loader.rb', line 47

def create_connector
  @connector = resolver.create_connector(db, logger)
end

#create_resolverObject



43
44
45
# File 'lib/skiima/loader.rb', line 43

def create_resolver
  @resolver = Skiima::Db::Resolver.new(db)
end

#defaultsObject



15
16
17
# File 'lib/skiima/loader.rb', line 15

def defaults
  Skiima.config
end

#down(*args) ⇒ Object



37
38
39
40
41
# File 'lib/skiima/loader.rb', line 37

def down(*args)
  @direction = :down
  read_and_execute(*args)
  self
end

#log_message(msg) ⇒ Object



51
52
53
# File 'lib/skiima/loader.rb', line 51

def log_message(msg)
  Skiima.log_message(logger, msg)
end

#read_and_execute(*scripts) ⇒ Object



55
56
57
58
59
# File 'lib/skiima/loader.rb', line 55

def read_and_execute(*scripts)
  read_scripts *scripts
  interpolate_each_script
  execute_each_script
end

#up(*args) ⇒ Object



31
32
33
34
35
# File 'lib/skiima/loader.rb', line 31

def up(*args)
  @direction = :up
  read_and_execute(*args)
  self
end