Class: Avmtrf1::Tools::Runner::Red

Inherits:
Object
  • Object
show all
Defined in:
lib/avmtrf1/tools/runner/red.rb

Constant Summary collapse

RED_PROFILE_DEFAULT =
'development'

Instance Method Summary collapse

Instance Method Details

#fileObject



56
57
58
# File 'lib/avmtrf1/tools/runner/red.rb', line 56

def file
  required_file(:put)
end

#file_putObject



40
41
42
43
44
45
46
# File 'lib/avmtrf1/tools/runner/red.rb', line 40

def file_put
  result = red_profile.put_file(file)
  require 'pp'
  puts '>' * 20
  puts result
  puts '<' * 20
end

#put?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/avmtrf1/tools/runner/red.rb', line 21

def put?
  parsed.put.present?
end

#red_ini_path_uncachedObject



60
61
62
# File 'lib/avmtrf1/tools/runner/red.rb', line 60

def red_ini_path_uncached
  required_file(:red_ini)
end

#red_ini_profileObject



68
69
70
71
72
# File 'lib/avmtrf1/tools/runner/red.rb', line 68

def red_ini_profile
  return  red_ini.profiles[red_profile_name] if red_ini.profiles.key?(red_profile_name)

  fatal_error "Perfil/seção \"#{red_profile_name}\" não encontrada em \"#{red_ini_path}\""
end

#red_ini_uncachedObject



64
65
66
# File 'lib/avmtrf1/tools/runner/red.rb', line 64

def red_ini_uncached
  ::Avmtrf1::Ini.new(red_ini_path)
end

#red_profile_nameObject



48
49
50
# File 'lib/avmtrf1/tools/runner/red.rb', line 48

def red_profile_name
  parsed.red_profile.if_present(RED_PROFILE_DEFAULT)
end

#red_profile_uncachedObject



52
53
54
# File 'lib/avmtrf1/tools/runner/red.rb', line 52

def red_profile_uncached
  ::Avmtrf1::Red::Profile.by_ini_profile(red_ini_profile)
end

#required_file(option_key) ⇒ Object



74
75
76
77
78
79
# File 'lib/avmtrf1/tools/runner/red.rb', line 74

def required_file(option_key)
  path = parsed[option_key]
  return path if path

  fatal_error("Arquivo \"#{path}\" não existe (Informado na opção #{option_key})")
end

#runObject



25
26
27
28
29
30
31
32
# File 'lib/avmtrf1/tools/runner/red.rb', line 25

def run
  start_banner
  if put?
    file_put
  else
    fatal_error('Subcomando não mapeado (Isto é um defeito do software)')
  end
end

#start_bannerObject



34
35
36
37
38
# File 'lib/avmtrf1/tools/runner/red.rb', line 34

def start_banner
  infov 'red.ini', parsed.red_ini
  infov 'Perfil de red.ini', red_profile_name
  infov 'Arquivo para upload', parsed.put
end