Sha256: 11dfdfe681d161711ac032526e4d6108dd1d1f359711db2a8b8c039ac1ee4721

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'fileutils'
require_relative 'generator'
require_relative 'config_reader'
require_relative 'yaml_formatter'
require_relative 'table'

module WhatsupGithub
  class Runner
    def initialize(date)
      @generator = Generator.new date
      @config = Config.instance
      @content ||= @generator.content
    end

    def run
      format = @config.output_format
      raise 'Cannot find "output_format" in config.yml' unless format

      table if format.include? 'markdown'
      data if format.include? 'yaml'
    end

    def write_results(file, formatter)
      formatted_content = @generator.run formatter, @content
      check_dir_at File.dirname file
      File.write file, formatted_content
      puts "Done!\nOpen \"#{file}\" to see the result."
    end

    def check_dir_at(filepath)
      FileUtils.mkdir_p filepath unless Dir.exist? filepath
    end

    def table
      write_results 'tmp/whats-new-on-devdocs.md', Table.new
    end

    def data
      write_results 'tmp/whats-new.yml', YAMLFormatter.new
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
whatsup_github-1.0.1 lib/whatsup_github/runner.rb
whatsup_github-1.0.0 lib/whatsup_github/runner.rb
whatsup_github-0.5.0 lib/whatsup_github/runner.rb
whatsup_github-0.4.2 lib/whatsup_github/runner.rb
whatsup_github-0.4.1 lib/whatsup_github/runner.rb
whatsup_github-0.4.0 lib/whatsup_github/runner.rb