Sha256: 0c36256be8356ffde06983b303cbc719dda8af29977db7188de3fc6fa29d5004

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Roro
  class CLI < Thor
    desc 'generate:harvest', 'Generate harvest.'
    map 'generate:harvest' => 'generate_harvest'

    def generate_harvest
      reflector = Roro::Reflector.new
      content = {
        cases: reflector.cases.map { |c| c.join(' ') },
        structure_human: reflector.adventure_structure_human,
        structure_choices: reflector.adventure_structure_choices
        # itineraries: harvest_itineraries,
        # metadata: @reflector.metadata
      }
      content.each do |key, value|
        create_file ".harvest/#{key}.yml", value.to_yaml
      end
    end

    no_commands do
      def harvest_itineraries
        itineraries = {}
        @reflector.itineraries.each do |i|
          itineraries[harvest_adventure_title(i)] = 'blah'
        end
        itineraries
      end

      def harvest_test_files
        harvest = {}
        harvest[:test_files] = gather_test_files
        create_file '.harvest.yml', harvest.to_yaml
      end

      def gather_test_files
        Dir.glob("#{Dir.pwd}/lib/roro/stacks/**/*_test.rb")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roro-0.3.33 lib/roro/cli/generate/generate_harvest.rb