class Cocot

Clase principal de la aplicación.

Attributes

juzgador_de_argumentos[R]
salida[R]

Public Class Methods

new() click to toggle source
# File lib/cocot/cocot.rb, line 8
def initialize
  @salida = SalidaEstándar.new($stdout)
end

Public Instance Methods

accionar() click to toggle source

El “accionar” de parte del programa se da una sola vez, luego del interrogatorio al juzgador.

# File lib/cocot/cocot.rb, line 37
def accionar
  exit(false) if @error_existente
  exit(true) if @ayuda_invocada
  #llegado a este punto se entiende que el usuario ingresó correctamente el comando de inicio, aunqué puede que el constructor de esqueleto encuentre un problema
  unless construir_esqueleto() then exit(false) end
  #todo anduvo bien
  true
end
construir_esqueleto() click to toggle source
# File lib/cocot/cocot.rb, line 46
def construir_esqueleto
  @constructor_de_esqueleto = ConstructorDeEsqueleto.new
  #si la siguiente acción tiene éxito devuelve true, de otra forma false, lo cual quiere decir que hubo un problema
  if @constructor_de_esqueleto.construir_esqueleto(@nombre_del_proyecto)
    @salida.escribir("Structure built. Have fun developing! :)\n")
    true
  else
    @salida.escribir(@constructor_de_esqueleto.explicar_inconveniente)
    false
  end
end
interrogar_juzgador() click to toggle source

Interroga al juzgador de argumentos en búsqueda de saber si hubo algún error en ellos.

# File lib/cocot/cocot.rb, line 24
def interrogar_juzgador
  if @juzgador_de_argumentos.hubo_algun_error?
    @error_existente = true
    @salida.escribir(@juzgador_de_argumentos.describime_el_error)
  elsif @juzgador_de_argumentos.fue_la_ayuda_solicitada?
    @ayuda_invocada = true
    mostrar_ayuda_en_pantalla()
  else
    @salida.escribir("Building skeletal structure for #{@nombre_del_proyecto = @juzgador_de_argumentos.cual_será_el_nombre_del_proyecto?}.\n")
  end
end
juzgar_argumentos() click to toggle source

@param argumentos [Array].

# File lib/cocot/cocot.rb, line 18
def juzgar_argumentos
  @juzgador_de_argumentos = JuzgadorDeArgumentos.new #: JuzgadorDeArgumentos
  @juzgador_de_argumentos.juzgar_argumentos(@argumentos)
end
limpiar_argumentos(argumentos) click to toggle source

@param argumentos [Array]. Se quieren limpiar todos aquellos argumentos vacíos, como por ejemplo aquellos que surgen al pasar '' o “” en la línea de comandos.

# File lib/cocot/cocot.rb, line 13
def limpiar_argumentos(argumentos)
  @argumentos = argumentos.select {|arg| arg.strip.length.!=(0)} #: Array
end
mostrar_ayuda_en_pantalla() click to toggle source
# File lib/cocot/cocot.rb, line 58
def mostrar_ayuda_en_pantalla
  msj_de_ayuda = " cocot builds the skeleton layout of your BDD proyects.\n\n You just have to give him the name of your proyect like this: `cocot \"name of the proyect\"`.\n\n You can pass around these options:\n\n --full\t\t\tBuild extra folders suchs as \"data\", \"share\" and \"ext\".\n\n The next options works as solo and can be combined with previous one:\n\n --rspec-only\t\tStandard skeleton + folders and files needed to work with RSpec.\n --cucumber-only\tStandard skeleton + folders and files needed to work with Cucumber.\n --minitest-only\tStandard skeleton + folders and files needed to work with minitest.\n --clean\t\tStandard skeleton.\n\n If you don't use any of the previous 4 options cocot will build the standard skeleton plus folders and files needed to work with Cucumber and RSpec."
  @salida.escribir(msj_de_ayuda)
end