Skip to content

Commit

Permalink
Prepared for first release.
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-m-g committed Sep 27, 2013
1 parent f7763bd commit a46c90b
Show file tree
Hide file tree
Showing 22 changed files with 828 additions and 29 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1.0.0
-----
* First release
2 changes: 1 addition & 1 deletion License.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Este software puede ser utilizado sin cargo monetario(gratis) por el usuario. No se puede vender, no se puede obtener dinero de el. En el caso de que se distribuya públicamente por favor mencionarme como autor del mismo, gracias. IgorJorobus.
This software can be used without monetary charge(free) by the user. Can not be sold, can't get money from it. In case you want to distribute it around please mention me, thank you. IgorJorobus.
17 changes: 9 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#encoding: utf-8

#necesario para ejecutar los tests de minitest
require 'rake/testtask'
#necesario para ejecutar los tests de cucumber
Expand All @@ -14,18 +16,12 @@ Rake::TestTask.new do |t|
end

#tarea para ejecutar los tests de cucumber con `cucumber`
Cucumber::Rake::Task.new do |t|
#opciones de cucumber a correr
t.cucumber_opts = %w{--format pretty --color}
end
Cucumber::Rake::Task.new

#tarea para ejecutar cucumber wip(work in progress) con 'rake cucumber_wip'
desc 'Ejecuta cucumber wip'
task :cucumber_wip do
Cucumber::Rake::Task.new do |t|
#opciones de rspec a correr
t.rspec_opts = %w{--format pretty --color --wip @wip:3}
end
system('cucumber --format progress --color --wip --tags @wip:3')
end

#tarea para ejecutar todos los tests de rspec con `rake spec`
Expand All @@ -39,3 +35,8 @@ task :rdoc do
system('rdoc --all --tab-width=1 --format=darkfish --op=doc --force-output')
end

desc 'Genera data/contenido_de_archivos.cocot'
task :generar_contenido_de_archivos do
require_relative('lib/cocot/salvador_de_contenidos')
SalvadorDeContenidos.new.salvar_contenido_de_archivos
end
63 changes: 63 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cocot
=====

Sometimes you have a good 'no-rails' idea, and say for yourself: "what a good idea!", what mostly of the time is followed by "okay, but...I can't, I'm in many proyects and I had to create all the folder and files stuff, will take me 15 minutes, or more, so no". You are lazy and you know it. We are great builders of tools which makes our life easy, cocot is one of those. cocot is a very simple tool that puts you to work in one second, you just have to tell him which will be the name of your proyect and it's done, it creates you the structure of your **BDD** proyect.

It supposes that you...
-----------------------

use RSpec and Cucumber for BDD developing, so it creates the conventional files and folders for work with.

How can I use it?
-----------------

`cocot NameOfTheProyect` or `cocot "name of the proyect"`. Will build the skeleton in the current working directory, so be aware of be positioned where you want your proyect to be.

Gemfile
-------

If you don't have **RSpec** and **Cucumber** installed on your system(or want to update them) you can do it by calling `bundle install` standing on the main folder of your proyect created by cocot. If you neither have **bundler** you will need to install it by calling `gem install bundler`.

Rakefile
--------

cocot packs few pre-defined **rake** tasks:

* `rake cucumber` : same like `cucumber`
* `rake cucumber_wip` : same like `cucumber --format progress --color --wip --tags @wip:3`, specially for order
* `rake spec` : same like `spec --color`
* `rake test` : run minitest tests
* `rake rdoc` : create a doc folder with **RDoc** documentation

Skeleton
--------

cocot builds:

bin\
| proyect*
doc\
features\
| step_definitions\
| support\
| | env.rb
lib\
| proyect*
| proyect*.rb
spec\
| proyect*
| spec_helper.rb
Changelog.md
Gemfile
Gemfile.lock
License.md
Rakefile
ReadMe.md

*proyect is replaced by the name of your proyect

TODO
----

* --full option. It builds you extra folders, like "Data", "Share", and "Test".
* --git-init option. Initialize a git repository(you will need to have **Git** in your system), and stash all the files created by cocot.
3 changes: 3 additions & 0 deletions bin/cocot
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#!/usr/bin/env ruby
#encoding: utf-8

require_relative '../lib/cocot'
58 changes: 58 additions & 0 deletions data/contenido_de_archivos.cocot
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{ :bin/proyectI"Y#!/usr/bin/env ruby
#encoding: utf-8

require_relative '../lib/name_of_the_proyect'
:ET:features/support/env.rbI"�#encoding: utf-8

#if you respect the convention of a Ruby proyect layout then the next lines are fixed
$LOAD_PATH << File.expand_path('../../../lib', __FILE__)
require 'name_of_the_proyect'
;T:lib/proyect.rbI"#encoding: utf-8
;T:spec/spec_helper.rbI"5#encoding: utf-8

require 'name_of_the_proyect'
;T: GemfileI"csource 'https://rubygems.org'

gem 'rspec'
gem 'cucumber'
gem 'rake'
gem 'rdoc'
gem 'bundler'
;T:RakefileI"�#encoding: utf-8

#necesary for minitest tests
require 'rake/testtask'
#necesary for cucumber tests
require 'cucumber/rake/task'
#necesary for rspec tests
require 'rspec/core/rake_task'

#################TASKS#######################

#to execute minitest tests with `rake test`
Rake::TestTask.new do |t|
#search recursively under the folder test for files called test*. You have to create the folder manually.
t.pattern = 'test/**/test*.rb'
end

#to execute cucumber tests with `rake cucumber`
Cucumber::Rake::Task.new

#to execute cucumber wip(work in progress) with 'rake cucumber_wip'. It will kick you if you are working in more than 3 scenarios
#remember to tag each wip scenarios with @wip above the Scenario keyword in the implicit *.feature
desc 'Executes cucumber wip'
task :cucumber_wip do
system('cucumber --format progress --color --wip --tags @wip:3')
end

#to execute all RSpec tests with `rake spec`
RSpec::Core::RakeTask.new do |t|
#opciones de rspec a correr
t.rspec_opts = ['--color']
end

desc 'to generate RDoc documentation'
task :rdoc do
system('rdoc --all --tab-width=1 --format=darkfish --op=doc --force-output')
end
;T
Expand Down
24 changes: 24 additions & 0 deletions features/cocot_construye_esqueleto.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#language: es

Característica: cocot construye el esqueleto del proyecto.

Con el fin de cumplimentar el objetivo principal de la aplicación,
como desarrollador,
quiero poder lograr que cocot construya el esqueleto del nuevo proyecto en la ruta actual desde donde se está ejecutando la aplicación.

@wip
Escenario: genero el árbol de carpetas.
Dado que el usuario ingresó correctamente el comando para esqueletizar su nuevo proyecto, por ejemplo: "cocot Proyecto",
Cuando origino sus carpetas,
Entonces debo encontrar creada una carpeta con nombre "Proyecto",
#realmente el step definition de la siguiente línea testea que estén todos los archivos también
Y dentro de ella debo encontrarme con la siguiente estructura de carpetas creadas:
| bin |
| lib |
| lib/Proyecto |
| spec |
| spec/Proyecto |
| features |
| features/support |
| features/step_definitions |
| doc |
49 changes: 49 additions & 0 deletions features/step_definitions/cocot_construye_esqueleto_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#encoding: utf-8

Dado(/^que el usuario ingresó correctamente el comando para esqueletizar su nuevo proyecto, por ejemplo: "cocot Proyecto",$/) do
cocot.limpiar_argumentos(['Proyecto'])
cocot.juzgar_argumentos
cocot.interrogar_juzgador
(cocot.instance_variable_get(:@error_existente).should_not be true) && (cocot.instance_variable_get(:@ayuda_invocada).should_not be true)
end

Cuando(/^origino sus carpetas,$/) do
#si todo andubo bien, en el accionar se genera el esqueleto
cocot.accionar
end

Entonces(/^debo encontrar creada una carpeta con nombre "Proyecto",$/) do
Dir.exists?("#{Dir.pwd}/#{nombre_del_proyecto()}").should be true
end

Entonces(/^dentro de ella debo encontrarme con la siguiente estructura de carpetas creadas:$/) do |carpetas|
viejo_directorio_de_trabajo = Dir.pwd #: String
#me muevo una carpeta hacia adelante
Dir.chdir("./#{nombre_del_proyecto()}")
#tiene que haber lo siguiente
archivos_y_carpetas = %W{ Changelog.md
Gemfile
Gemfile.lock
License.md
Rakefile
ReadMe.md
bin
bin/#{nombre_del_proyecto()}
doc
features
features/step_definitions
features/support
features/support/env.rb
lib
lib/#{nombre_del_proyecto()}
lib/#{nombre_del_proyecto()}.rb
spec
spec/#{nombre_del_proyecto()}
spec/spec_helper.rb }

Dir.glob('**/**/*').sort.should be === archivos_y_carpetas.sort
#vuelvo al viejo directorio de trabajo
Dir.chdir('..')
#elimino todas las carpetas y archivos creados
FileUtils.remove_dir("./#{nombre_del_proyecto}", true)
end
64 changes: 64 additions & 0 deletions features/step_definitions/usuario_ingresa_comando_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#encoding: utf-8

#hooks del *.feature correspondiente
Around('@carpeta_existente') do |escenario, bloque|
directorio_implicito = 'Proyecto'
unless Dir.exists?(directorio_implicito) then Dir.mkdir(directorio_implicito) end
bloque.call
if Dir.exists?(directorio_implicito) then FileUtils.remove_dir(directorio_implicito, true) end
end

Before do |escenario|
#en el modelo del dominio ::COCOT es utilizada. Apunta a la única instancia Cocot, la aplicación en si.
::COCOT = cocot()
end

#definiciones de pasos
Dado(/^que aún no inicié la aplicación,$/) do
cocot()
end

Cuando(/^ejecuto el comando: "([^"]*)",$/) do |comando_ejecutado|
#extirpo la palabra 'cocot' venida del *.feature y otras
argumentos = comando_ejecutado.split.select {|palabra| (palabra.!=('cocot')) && (palabra.!=('\'\'')) && (palabra.!=('""'))} #: Array
#le digo a cocot que juzgue los argumentos pasados por el usuario al iniciar la aplicación
cocot.limpiar_argumentos(argumentos)
cocot.juzgar_argumentos
end

Entonces(/^debo recibir en consola: "([^"]*)"[.,]$/) do |salida|
cocot.interrogar_juzgador
#el atributo salida es un #Array, cada item es un #String
cocot.instance_variable_get(:@salida).should include(salida.+("\n"))
end

Entonces(/^a continuación: "([^"]*)", terminando el programa.$/) do |salida|
begin
cocot.accionar.should raise_error(SystemExit)
#cucumber falla si algún bloque levanta una excepción y no es rescatada, asi que...
rescue SystemExit
end
end

Entonces(/^el programa debe terminarse\.$/) do
begin
cocot.accionar.should raise_error(SystemExit)
#cucumber falla si algún bloque levanta una excepción y no es rescatada, asi que...
rescue SystemExit
end
end

Entonces(/^debo recibir en consola información que me ayude a comprender el funcionamiento de cocot,$/) do
cocot.interrogar_juzgador
cocot.instance_variable_get(:@ayuda_invocada).should be true
end

Cuando(/^ejecuto el comando: "cocot 'Proyecto Fu Fu'", cocot entiende que el nombre del proyecto será "Proyecto Fu Fu",$/) do
#le digo a cocot que juzgue los argumentos pasados por el usuario al iniciar la aplicación
cocot.limpiar_argumentos(['Proyecto Fu Fu'])
cocot.juzgar_argumentos
end

Dado(/^que existe la carpeta "([^"]*)" en el directorio actual,$/) do |carpeta|
Dir.exists?(carpeta).should be true
end
14 changes: 14 additions & 0 deletions features/support/cocot_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#encoding: utf-8

module CocotHelpers

def cocot
@cocot ||= Cocot.new
end

def nombre_del_proyecto
@nombre_del_proyecto ||= cocot.instance_variable_get(:@juzgador_de_argumentos).cual_será_el_nombre_del_proyecto? #: String
end
end

World(CocotHelpers)
21 changes: 1 addition & 20 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
#encoding: utf-8

#keywords de cucumber en español(para que funcionen poner en la primera línea de cada *.feature "#language: es"):
=begin
"background": "Antecedentes",
"feature": "Característica",
"scenario": "Escenario",
"scenario_outline": "Esquema del escenario",
"examples": "Ejemplos",
"given": "*|Dado|Dada|Dados|Dadas",
"when": "*|Cuando",
"then": "*|Entonces",
"and": "*|Y",
"but": "*|Pero"
=end

#plantilla para describir una característica:
=begin
En orden de <alcanzar un objetivo>
Como un/a <tipo de persona>
Quiero <una característica>
=end
require 'fileutils'

#si se respeta la convención del esqueleto de un proyecto en Ruby entonces la siguiente línea es fija
$LOAD_PATH << File.expand_path('../../../lib', __FILE__)
Expand Down
Loading

0 comments on commit a46c90b

Please sign in to comment.