Class: JuzgadorDeArgumentos

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

Constant Summary collapse

ERRORES_CONOCIDOS =
{ningun_argumento: "Error: cocot needs to know the name of the further proyect. `cocot '<name_of_the_proyect>'`.\n", \
dos_o_mas_argumentos_como_nombre: "Error: cocot just need one argument: the name of the further proyect. If its name have more than a word you must put these inside "".\n"}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fullObject (readonly)

Returns the value of attribute full.



8
9
10
# File 'lib/cocot/juzgador_de_argumentos.rb', line 8

def full
  @full
end

#modoObject (readonly)

Returns the value of attribute modo.



8
9
10
# File 'lib/cocot/juzgador_de_argumentos.rb', line 8

def modo
  @modo
end

Instance Method Details

#cual_será_el_nombre_del_proyecto?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/cocot/juzgador_de_argumentos.rb', line 65

def cual_será_el_nombre_del_proyecto?
  @nombre_del_proyecto || "Not defined.\n"
end

#describime_el_errorObject



55
56
57
58
59
# File 'lib/cocot/juzgador_de_argumentos.rb', line 55

def describime_el_error
  if hubo_algun_error?
    return ERRORES_CONOCIDOS[@error_presente_en_argumentos]
  end
end

#fue_la_ayuda_solicitada?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/cocot/juzgador_de_argumentos.rb', line 61

def fue_la_ayuda_solicitada?
  if @ayuda_solicitada then true else false end
end

#hubo_algun_error?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/cocot/juzgador_de_argumentos.rb', line 51

def hubo_algun_error?
  true if @error_presente_en_argumentos
end

#juzgar_argumentos(argumentos) ⇒ Object

Parameters:

  • argumentos (Array)

    .



11
12
13
14
15
16
17
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
46
47
48
# File 'lib/cocot/juzgador_de_argumentos.rb', line 11

def juzgar_argumentos(argumentos)
  if argumentos.length.==(0)
    @error_presente_en_argumentos = :ningun_argumento #: Symbol
  elsif argumentos.include?('--help')
    @ayuda_solicitada = true
  else
    # voy a limpiar los argumentos opciones para que me quede(n) el potencial nombre del proyecto
    if(_argumentos = argumentos.select {|i| i[0..1].!=('--')}).length == 1
      @full = \
        if argumentos.include?('--full')
          ::COCOT.salida.escribir("\"Full\" option detected.\n")
          true
        else
          false
        end
      @modo = \
        if argumentos.include?('--rspec-only')
          ::COCOT.salida.escribir("\"RSpec only\" option detected.\n")
          '--rspec-only'
        elsif argumentos.include?('--cucumber-only')
          ::COCOT.salida.escribir("\"Cucumber only\" option detected.\n")
          '--cucumber-only'
        elsif argumentos.include?('--minitest-only')
          ::COCOT.salida.escribir("\"Minitest only\" option detected.\n")
          '--minitest-only'
        elsif argumentos.include?('--clean')
          ::COCOT.salida.escribir("\"Clean\" option detected.\n")
          '--clean'
        else
          ::COCOT.salida.escribir("Attempting to make a normal instalation(RSpec and Cucumber support).\n")
          nil
        end
      @nombre_del_proyecto = _argumentos[0].strip
    else
      @error_presente_en_argumentos = :dos_o_mas_argumentos_como_nombre #: Symbol
    end
  end
end