Class: PgSync::TaskResolver
- Inherits:
-
Object
- Object
- PgSync::TaskResolver
- Includes:
- Utils
- Defined in:
- lib/pgsync/task_resolver.rb
Constant Summary
Constants included from Utils
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#first_schema ⇒ Object
readonly
Returns the value of attribute first_schema.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #group?(group) ⇒ Boolean
-
#initialize(args:, opts:, source:, destination:, config:, first_schema:) ⇒ TaskResolver
constructor
A new instance of TaskResolver.
- #tasks ⇒ Object
Methods included from Utils
#colorize, #confirm_tables_exist, #db_config_file, #deprecated, #escape, #friendly_name, #log, #monotonic_time, #output, #quote_ident, #quote_ident_full, #quote_string, #task_name, #warning
Constructor Details
#initialize(args:, opts:, source:, destination:, config:, first_schema:) ⇒ TaskResolver
Returns a new instance of TaskResolver.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/pgsync/task_resolver.rb', line 7 def initialize(args:, opts:, source:, destination:, config:, first_schema:) @args = args @opts = opts @source = source @destination = destination @config = config @groups = config["groups"] || {} @first_schema = first_schema @notes = [] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/pgsync/task_resolver.rb', line 5 def args @args end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/pgsync/task_resolver.rb', line 5 def config @config end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
5 6 7 |
# File 'lib/pgsync/task_resolver.rb', line 5 def destination @destination end |
#first_schema ⇒ Object (readonly)
Returns the value of attribute first_schema.
5 6 7 |
# File 'lib/pgsync/task_resolver.rb', line 5 def first_schema @first_schema end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
5 6 7 |
# File 'lib/pgsync/task_resolver.rb', line 5 def notes @notes end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
5 6 7 |
# File 'lib/pgsync/task_resolver.rb', line 5 def opts @opts end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/pgsync/task_resolver.rb', line 5 def source @source end |
Instance Method Details
#group?(group) ⇒ Boolean
47 48 49 |
# File 'lib/pgsync/task_resolver.rb', line 47 def group?(group) @groups.key?(group) end |
#tasks ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pgsync/task_resolver.rb', line 18 def tasks tasks = [] # get lists from args groups, tables = process_args # expand groups into tasks groups.each do |group| tasks.concat(group_to_tasks(group)) end # expand tables into tasks tables.each do |table| tasks.concat(table_to_tasks(table)) end # get default if none given if !opts[:groups] && !opts[:tables] && args.size == 0 tasks.concat(default_tasks) end # resolve any tables that need it tasks.each do |task| task[:table] = fully_resolve(task[:table]) end tasks end |