Class: Cure::Planner

Inherits:
Object
  • Object
show all
Includes:
Configuration, Log
Defined in:
lib/cure/planner.rb

Instance Method Summary collapse

Methods included from Log

#log_debug, #log_error, #log_info, #log_trace, #log_warn

Methods included from Configuration

#config, #create_config, #register_config

Instance Method Details



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cure/planner.rb', line 71

def print_build_plan
  print_title "Build"
  candidates = config.template.builder.candidates

  if candidates.empty?
    print_empty("Build")
  else
    candidates.each do |c|
      log_info "-- #{c.column || "Multiple columns>"} from #{c.named_range} will be changed with #{c.action}"
    end
  end

  print_spacer
end


38
39
40
41
# File 'lib/cure/planner.rb', line 38

def print_ender
  log_info "_______________________________________________"
  print_spacer
end

rubocop:disable Metrics/AbcSize



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cure/planner.rb', line 43

def print_extract_plan # rubocop:disable Metrics/AbcSize
  print_title "Extract"
  named_ranges = config.template.extraction.named_ranges
  variables = config.template.extraction.variables

  if named_ranges.empty?
    print_empty(named_ranges, "If you wanted to add a named range, please read docs/extraction.md")
  else
    log_info("[#{named_ranges.length}] named ranges specified")
    named_ranges.each do |nr|
      log_info "-- #{nr.name} will extract values from #{nr.section}"
    end
  end

  print_spacer

  if variables.empty?
    print_empty("variables")
  else
    log_info("[#{variables.length}] variables specified")
    variables.each do |v|
      log_info "-- #{v.name} will extract from #{v.location}"
    end
  end

  print_spacer
end

rubocop:disable Metrics/AbcSize



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cure/planner.rb', line 22

def print_starter # rubocop:disable Metrics/AbcSize
  a = Artii::Base.new({font: "isometric1"})
  puts a.asciify("C u r e")
  puts "\nIf you require assistance, please read:"
  puts "https://github.com/williamthom-as/cure/tree/main/docs\n"
  puts ""
  log_info "_______________________________________________"
  print_spacer
  log_info "Cure Execution Plan".bold.underline
  log_info ""
  log_info "Source file location: #{config.source_files.map(&:description).join(",")}"
  log_info "Template file descriptor below"

  print_spacer
end

rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/cure/planner.rb', line 86

def print_transformations_plan # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
  print_title "Transforms"
  candidates = config.template.transformations.candidates
  placeholders = config.template.transformations.placeholders

  if candidates.empty?
    print_empty("Transforms")
  else
    candidates.each do |c|
      log_info "-- #{c.column} from #{c.named_range} will be changed with #{c.translations.size} translation"
      c.translations.each do |tr|
        log_info "\t\t> #{"Replacement".bold} [#{tr.strategy.class}]: #{tr.strategy.describe}"
        log_info "\t\t> #{"Generator".bold} [#{tr.generator.class}]: #{tr.generator.describe}"
      end
    end
  end

  print_spacer

  if placeholders.nil? || placeholders.empty?
    print_empty("Placeholders")
  else
    log_info "-- Variables"
    placeholders.each do |k, v|
      log_info "\t\t> #{k} => #{v}"
    end
  end

  print_spacer
end

#processObject



14
15
16
17
18
19
20
# File 'lib/cure/planner.rb', line 14

def process
  print_starter
  print_extract_plan
  print_build_plan
  print_transformations_plan
  print_ender
end