Sha256: 7bd32ebd1436525ad5812a51c453cc50ec17fe7c3b1d7a74f04fdfc6c4458b36

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

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.read '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

2 entries across 2 versions & 1 rubygems

Version Path
whatsup_github-0.1.1 lib/whatsup_github/runner.rb
whatsup_github-0.0.1 lib/whatsup_github/runner.rb