Sha256: 419a0110aaf72cca5d339d09ea0665cf3600a29425af795294c6d90d794aabf7

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 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.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

3 entries across 3 versions & 1 rubygems

Version Path
whatsup_github-0.3.1 lib/whatsup_github/runner.rb
whatsup_github-0.3.0 lib/whatsup_github/runner.rb
whatsup_github-0.2.0 lib/whatsup_github/runner.rb