Class: Pokotarou::Operater

Inherits:
Object
  • Object
show all
Defined in:
lib/pokotarou.rb

Defined Under Namespace

Classes: NotFoundLoader

Class Method Summary collapse

Class Method Details

.execute(input) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pokotarou.rb', line 10

def execute input
  AdditionalMethods::Main.init()
  
  # if input is filepath, generate config_data
  return_val =
    if input.kind_of?(String)
      SeedDataRegister::Main.register(gen_config(input))
    else
      SeedDataRegister::Main.register(input)
    end
  
  AdditionalMethods::Main.remove_filepathes_from_yml()
  
  return_val
end

.gen_handler(filepath) ⇒ Object



70
71
72
73
74
# File 'lib/pokotarou.rb', line 70

def gen_handler filepath
  AdditionalMethods::Main.init()
  
  PokotarouHandler.new(gen_config(filepath))
end

.gen_handler_with_cache(filepath) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/pokotarou.rb', line 76

def gen_handler_with_cache filepath
  AdditionalMethods::Main.init()
  
  @handler_cache ||= {}
  @handler_cache[filepath] ||= PokotarouHandler.new(gen_config(filepath))
  
  @handler_cache[filepath].deep_dup
end

.import(filepath) ⇒ Object



54
55
56
57
# File 'lib/pokotarou.rb', line 54

def import filepath
  AdditionalMethods::Main.init()
  AdditionalMethods::Main.import(filepath)
end

.pipeline_execute(input_arr) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pokotarou.rb', line 26

def pipeline_execute input_arr
  AdditionalMethods::Main.init()
  
  return_vals = []
  input_arr.each do |e|
    handler = gen_handler_with_cache(e[:filepath])
  
    if e[:change_data].present?
      e[:change_data].each do |block, config|
        config.each do |model, seed|
          seed.each do |col_name, val|         
            handler.change_seed(block, model, col_name, val)
          end
        end
      end
    end
    
    e[:args] ||= {}
    e[:args][:passed_return_val] = return_vals.last
    set_args(e[:args])
  
    return_vals << Pokotarou.execute(handler.get_data())
    AdditionalMethods::Main.remove_filepathes_from_yml()
  end
  
  return_vals
end

.resetObject



63
64
65
66
67
68
# File 'lib/pokotarou.rb', line 63

def reset
  AdditionalMethods::Main.remove()
  AdditionalArguments::Main.remove()
  AdditionalVariables::Main.remove()
  @handler_chache = {}
end

.set_args(hash) ⇒ Object



59
60
61
# File 'lib/pokotarou.rb', line 59

def set_args hash
  AdditionalArguments::Main.import(hash)
end