bddgenx 0.1.26 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -31
- data/VERSION +1 -0
- data/lib/bddgenx/backup.rb +3 -2
- data/lib/bddgenx/generator.rb +6 -1
- data/lib/bddgenx/parser.rb +37 -31
- data/lib/bddgenx/pdf_exporter.rb +2 -2
- data/lib/bddgenx/tracer.rb +2 -2
- data/lib/bddgenx/version.rb +9 -1
- data/lib/bddgenx.rb +3 -1
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 119bc4e3aa9e3a0022d0e1abd2e7be255a854003e4eaf12f05d59b06611d4ca3
         | 
| 4 | 
            +
              data.tar.gz: 8d7c69b6884718ddd67ea4af3addfbe99514d3767de9de8c544a24178468dad3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ac392e79d2de7909eb419ade1a2d1a6b9a9466c45daa88353140acb584ef0f266e92356d3b15e03970a73f9c38d9405bb803330892af8ede23812d69460911cc
         | 
| 7 | 
            +
              data.tar.gz: b0eaad5600fbb00bb83138e9276cce17d202327b72e527f733a670c44698202af1435caaeda3b21eeba9181453912f6c031face99aa8f0047c16fdfbf8fae77f
         | 
    
        data/README.md
    CHANGED
    
    | @@ -6,37 +6,31 @@ Este projeto gera arquivos `.feature` (Gherkin) e `steps.rb` automaticamente a p | |
| 6 6 |  | 
| 7 7 | 
             
            ## 📂 Estrutura do Projeto
         | 
| 8 8 | 
             
            ```txt
         | 
| 9 | 
            -
            bddgenx/ | 
| 10 | 
            -
            ├── bin/ | 
| 11 | 
            -
             | 
| 12 | 
            -
            ├──  | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
            │    | 
| 16 | 
            -
            │    | 
| 17 | 
            -
            │    | 
| 18 | 
            -
             | 
| 19 | 
            -
            │    | 
| 20 | 
            -
            │   │   ├──  | 
| 21 | 
            -
            │   │    | 
| 22 | 
            -
            │   │ | 
| 23 | 
            -
            │    | 
| 24 | 
            -
            ├──  | 
| 25 | 
            -
            │    | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
            ├──  | 
| 29 | 
            -
            ├──  | 
| 30 | 
            -
            ├──  | 
| 31 | 
            -
            ├──  | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
            ├── bddgenx.gemspec           # gemspec
         | 
| 35 | 
            -
            ├── Gemfile                   # dependências de desenvolvimento
         | 
| 36 | 
            -
            ├── Rakefile                  # tarefas: build, test, release, clean…
         | 
| 37 | 
            -
            ├── .gitignore
         | 
| 38 | 
            -
            └── README.md                 # descrição, instalação, exemplos de uso
         | 
| 39 | 
            -
             | 
| 9 | 
            +
            bddgenx/  
         | 
| 10 | 
            +
            ├── bin/bddgenx              # CLI executável  
         | 
| 11 | 
            +
            ├── input/                   # .txt de histórias de usuário  
         | 
| 12 | 
            +
            ├── features/                # .feature geradas  
         | 
| 13 | 
            +
            ├── features/<nome>/steps/   # step definitions por feature (se existir)  
         | 
| 14 | 
            +
            ├── reports/                 # todos os artefatos de saída  
         | 
| 15 | 
            +
            │   ├── backup/              # versões antigas de .feature  
         | 
| 16 | 
            +
            │   ├── output/              # rastreabilidade.csv  
         | 
| 17 | 
            +
            │   └── pdf/                 # relatórios camelCase  
         | 
| 18 | 
            +
            ├── lib/  
         | 
| 19 | 
            +
            │   ├── bddgenx/  
         | 
| 20 | 
            +
            │   │   ├── parser.rb  
         | 
| 21 | 
            +
            │   │   ├── validator.rb  
         | 
| 22 | 
            +
            │   │   ├── generator.rb  
         | 
| 23 | 
            +
            │   │   ├── steps_generator.rb  
         | 
| 24 | 
            +
            │   │   ├── tracer.rb  
         | 
| 25 | 
            +
            │   │   ├── backup.rb  
         | 
| 26 | 
            +
            │   │   └── pdf_exporter.rb  
         | 
| 27 | 
            +
            │   └── bddgenx.rb           # Runner que orquestra tudo  
         | 
| 28 | 
            +
            ├── Gemfile  
         | 
| 29 | 
            +
            ├── bddgenx.gemspec  
         | 
| 30 | 
            +
            ├── Rakefile 
         | 
| 31 | 
            +
            ├── VERSION
         | 
| 32 | 
            +
            ├── bump_version.sh  
         | 
| 33 | 
            +
            └── README.md
         | 
| 40 34 | 
             
            ```
         | 
| 41 35 | 
             
            ## ▶️ Como Executar
         | 
| 42 36 |  | 
    
        data/VERSION
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            0.1.29
         | 
    
        data/lib/bddgenx/backup.rb
    CHANGED
    
    | @@ -6,10 +6,11 @@ module Bddgenx | |
| 6 6 | 
             
                def self.salvar_versao_antiga(caminho)
         | 
| 7 7 | 
             
                  return unless File.exist?(caminho)
         | 
| 8 8 |  | 
| 9 | 
            -
                   | 
| 9 | 
            +
                  pasta = 'reports/backup'
         | 
| 10 | 
            +
                  FileUtils.mkdir_p(pasta)
         | 
| 10 11 | 
             
                  base = File.basename(caminho, ".feature")
         | 
| 11 12 | 
             
                  timestamp = Time.now.strftime("%Y%m%d_%H%M%S")
         | 
| 12 | 
            -
                  destino = "backup/#{base}_#{timestamp}.feature"
         | 
| 13 | 
            +
                  destino = "reports/backup/#{base}_#{timestamp}.feature"
         | 
| 13 14 |  | 
| 14 15 | 
             
                  FileUtils.cp(caminho, destino)
         | 
| 15 16 | 
             
                  puts "📦 Backup criado: #{destino}"
         | 
    
        data/lib/bddgenx/generator.rb
    CHANGED
    
    | @@ -23,7 +23,12 @@ module Bddgenx | |
| 23 23 | 
             
                    regra:     idioma == 'en' ? 'Rule'             : 'Regra'
         | 
| 24 24 | 
             
                  }
         | 
| 25 25 |  | 
| 26 | 
            -
                   | 
| 26 | 
            +
                  frase_quero = historia[:quero].sub(/^\s*quero\s*/i, '')
         | 
| 27 | 
            +
                  partes     = frase_quero.split(/\s+/)[0,3]    # pega só as 3 primeiras palavras
         | 
| 28 | 
            +
                  slug       = partes.join('_')
         | 
| 29 | 
            +
                                     .gsub(/[^a-z0-9_]/i, '')                    # remove caracteres especiais
         | 
| 30 | 
            +
                                     .downcase
         | 
| 31 | 
            +
                  nome_base  = slug
         | 
| 27 32 | 
             
                  caminho   = "features/#{nome_base}.feature"
         | 
| 28 33 |  | 
| 29 34 | 
             
                  conteudo = <<~GHERKIN
         | 
    
        data/lib/bddgenx/parser.rb
    CHANGED
    
    | @@ -11,55 +11,61 @@ module Bddgenx | |
| 11 11 | 
             
                               .map(&:strip)
         | 
| 12 12 | 
             
                               .reject(&:empty?)
         | 
| 13 13 |  | 
| 14 | 
            -
                  # idioma
         | 
| 14 | 
            +
                  # Detecta idioma (padrão pt, usa en se encontrar '# lang: en')
         | 
| 15 15 | 
             
                  idioma = linhas.first.downcase.include?('# lang: en') ? 'en' : 'pt'
         | 
| 16 16 | 
             
                  linhas.shift if linhas.first.downcase.start_with?('# lang:')
         | 
| 17 17 |  | 
| 18 | 
            -
                  #  | 
| 19 | 
            -
                   | 
| 20 | 
            -
             | 
| 21 | 
            -
                     | 
| 18 | 
            +
                  # Cabeçalho Gherkin (case-insensitive): Como, Eu Como ou As a
         | 
| 19 | 
            +
                  como = nil
         | 
| 20 | 
            +
                  linhas.each_with_index do |l, i|
         | 
| 21 | 
            +
                    if l =~ /^\s*(?:como|eu como|as a)\b/i || l =~ /^\s*(?:COMO|EU COMO|AS A)\b/i
         | 
| 22 | 
            +
                      como = l
         | 
| 23 | 
            +
                      linhas = linhas[(i+1)..]
         | 
| 24 | 
            +
                      break
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  # 'Quero' ou 'Eu Quero'
         | 
| 29 | 
            +
                  quero = nil
         | 
| 30 | 
            +
                  linhas.each_with_index do |l, i|
         | 
| 31 | 
            +
                    if l =~ /^\s*(?:quero|eu quero|quero que)\b/i || l =~ /^\s*(?:QUERO|EU QUERO|QUERO QUE)\b/i
         | 
| 32 | 
            +
                      quero = l
         | 
| 33 | 
            +
                      linhas = linhas[(i+1)..]
         | 
| 34 | 
            +
                      break
         | 
| 35 | 
            +
                    end
         | 
| 22 36 | 
             
                  end
         | 
| 23 | 
            -
                  como  = linha
         | 
| 24 | 
            -
                  quero = linhas.shift
         | 
| 25 | 
            -
                  para  = linhas.shift
         | 
| 26 37 |  | 
| 27 | 
            -
                   | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
                    para | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 38 | 
            +
                  # 'Para', 'Para Eu' ou 'Para Que'
         | 
| 39 | 
            +
                  para = nil
         | 
| 40 | 
            +
                  linhas.each_with_index do |l, i|
         | 
| 41 | 
            +
                    if l =~ /^\s*(?:para|para eu|para que)\b/i || l =~ /^\s*(?:PRA|PARA EU|PARA QUE)\b/i
         | 
| 42 | 
            +
                      para = l
         | 
| 43 | 
            +
                      linhas = linhas[(i+1)..]
         | 
| 44 | 
            +
                      break
         | 
| 45 | 
            +
                    end
         | 
| 46 | 
            +
                  end
         | 
| 34 47 |  | 
| 48 | 
            +
                  historia = { como: como, quero: quero, para: para, idioma: idioma, grupos: [] }
         | 
| 35 49 | 
             
                  exemplos_mode = false
         | 
| 36 | 
            -
                  tipo_atual    = nil
         | 
| 37 | 
            -
                  tag_atual     = nil
         | 
| 38 50 |  | 
| 39 51 | 
             
                  linhas.each do |linha|
         | 
| 40 | 
            -
                    #  | 
| 41 | 
            -
                    if linha =~ /^\[EXAMPLES\](?:@(\w+))?$/
         | 
| 52 | 
            +
                    # Início de bloco de exemplos
         | 
| 53 | 
            +
                    if linha =~ /^\[EXAMPLES\](?:@(\w+))?$/i
         | 
| 42 54 | 
             
                      exemplos_mode = true
         | 
| 43 | 
            -
                      raise "Formato inválido: EXAMPLES sem bloco anterior" if historia[:grupos].empty?
         | 
| 44 55 | 
             
                      historia[:grupos].last[:exemplos] = []
         | 
| 45 56 | 
             
                      next
         | 
| 46 57 | 
             
                    end
         | 
| 47 58 |  | 
| 48 | 
            -
                    #  | 
| 49 | 
            -
                    if linha =~ /^\[(#{TIPOS_BLOCOS.join('|')})\](?:@(\w+))?$/
         | 
| 59 | 
            +
                    # Início de bloco de tipo (SUCCESS, FAILURE etc.)
         | 
| 60 | 
            +
                    if linha =~ /^\[(#{TIPOS_BLOCOS.join('|')})\](?:@(\w+))?$/i
         | 
| 50 61 | 
             
                      exemplos_mode = false
         | 
| 51 | 
            -
                       | 
| 52 | 
            -
                       | 
| 53 | 
            -
                      historia[:grupos] << {
         | 
| 54 | 
            -
                        tipo:     tipo_atual,
         | 
| 55 | 
            -
                        tag:      tag_atual,
         | 
| 56 | 
            -
                        passos:   [],
         | 
| 57 | 
            -
                        exemplos: []
         | 
| 58 | 
            -
                      }
         | 
| 62 | 
            +
                      tipo = $1.upcase
         | 
| 63 | 
            +
                      tag  = $2
         | 
| 64 | 
            +
                      historia[:grupos] << { tipo: tipo, tag: tag, passos: [], exemplos: [] }
         | 
| 59 65 | 
             
                      next
         | 
| 60 66 | 
             
                    end
         | 
| 61 67 |  | 
| 62 | 
            -
                    #  | 
| 68 | 
            +
                    # Atribui linhas ao último grupo existente
         | 
| 63 69 | 
             
                    next if historia[:grupos].empty?
         | 
| 64 70 | 
             
                    atual = historia[:grupos].last
         | 
| 65 71 |  | 
    
        data/lib/bddgenx/pdf_exporter.rb
    CHANGED
    
    | @@ -4,12 +4,12 @@ require 'fileutils' | |
| 4 4 | 
             
            module Bddgenx
         | 
| 5 5 | 
             
              class PDFExporter
         | 
| 6 6 | 
             
                def self.exportar_todos
         | 
| 7 | 
            -
                  FileUtils.mkdir_p('pdf')
         | 
| 7 | 
            +
                  FileUtils.mkdir_p('reports/pdf')
         | 
| 8 8 |  | 
| 9 9 | 
             
                  Dir.glob('features/*.feature').each do |feature_file|
         | 
| 10 10 | 
             
                    base = File.basename(feature_file, '.feature')
         | 
| 11 11 | 
             
                    nome_pdf = camel_case(base)
         | 
| 12 | 
            -
                    destino  = "pdf/#{nome_pdf}.pdf"
         | 
| 12 | 
            +
                    destino  = "reports/pdf/#{nome_pdf}.pdf"
         | 
| 13 13 |  | 
| 14 14 | 
             
                    if File.exist?(destino)
         | 
| 15 15 | 
             
                      puts "⚠️  PDF já existe: #{destino}"
         | 
    
        data/lib/bddgenx/tracer.rb
    CHANGED
    
    | @@ -4,8 +4,8 @@ require 'fileutils' | |
| 4 4 | 
             
            module Bddgenx
         | 
| 5 5 | 
             
              class Tracer
         | 
| 6 6 | 
             
                def self.adicionar_entrada(historia, nome_arquivo_feature)
         | 
| 7 | 
            -
                  FileUtils.mkdir_p('output')
         | 
| 8 | 
            -
                  arquivo_csv = 'output/rastreabilidade.csv'
         | 
| 7 | 
            +
                  FileUtils.mkdir_p('reports/output')
         | 
| 8 | 
            +
                  arquivo_csv = 'reports/output/rastreabilidade.csv'
         | 
| 9 9 |  | 
| 10 10 | 
             
                  cabecalho = ['Funcionalidade', 'Tipo', 'Tag', 'Cenário', 'Passo', 'Origem']
         | 
| 11 11 |  | 
    
        data/lib/bddgenx/version.rb
    CHANGED
    
    | @@ -1,3 +1,11 @@ | |
| 1 1 | 
             
            module Bddgenx
         | 
| 2 | 
            -
               | 
| 2 | 
            +
              # Sobe 3 níveis: lib/bddgenx/version.rb → bddgenx → lib → [raiz do projeto]
         | 
| 3 | 
            +
              VERSION_FILE = File.expand_path("../../../VERSION", __FILE__)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              VERSION = if File.exist?(VERSION_FILE)
         | 
| 6 | 
            +
                          File.read(VERSION_FILE).strip
         | 
| 7 | 
            +
                        else
         | 
| 8 | 
            +
                          warn "WARNING: VERSION file not found, defaulting to 0.0.0"
         | 
| 9 | 
            +
                          "0.0.0"
         | 
| 10 | 
            +
                        end
         | 
| 3 11 | 
             
            end
         | 
    
        data/lib/bddgenx.rb
    CHANGED
    
    | @@ -34,11 +34,13 @@ arquivos.each do |arquivo_path| | |
| 34 34 | 
             
              cont_features += 1 if Bddgenx::Generator.salvar_feature(nome_feature, conteudo_feature)
         | 
| 35 35 | 
             
              cont_steps += 1 if Bddgenx::StepsGenerator.gerar_passos(historia, nome_feature)
         | 
| 36 36 |  | 
| 37 | 
            +
             # cria pasta reports raiz
         | 
| 38 | 
            +
             FileUtils.mkdir_p('reports')
         | 
| 37 39 | 
             
             Bddgenx::Tracer.adicionar_entrada(historia, nome_feature)
         | 
| 38 40 | 
             
             Bddgenx::PDFExporter.exportar_todos
         | 
| 39 41 | 
             
            end
         | 
| 40 42 | 
             
            puts "\n✅ Processamento finalizado. Arquivos gerados em: features/, steps/, output/"
         | 
| 41 | 
            -
            puts "🔄 Versões antigas salvas em: backup/"
         | 
| 43 | 
            +
            puts "🔄 Versões antigas salvas em: reports/backup/"
         | 
| 42 44 |  | 
| 43 45 | 
             
            puts "\n✅ Processamento finalizado:"
         | 
| 44 46 | 
             
            puts "- Arquivos processados: #{cont_total}"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: bddgenx
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.29
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - David Nascimento
         | 
| @@ -35,6 +35,7 @@ extra_rdoc_files: [] | |
| 35 35 | 
             
            files:
         | 
| 36 36 | 
             
            - README.md
         | 
| 37 37 | 
             
            - Rakefile
         | 
| 38 | 
            +
            - VERSION
         | 
| 38 39 | 
             
            - bin/bddgenx
         | 
| 39 40 | 
             
            - lib/bddgenx.rb
         | 
| 40 41 | 
             
            - lib/bddgenx/assets/fonts/DejaVuSansMono-Bold.ttf
         |