Class: WhatsupGithub::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/whatsup_github/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(date) ⇒ Runner

Returns a new instance of Runner.



11
12
13
14
15
# File 'lib/whatsup_github/runner.rb', line 11

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

Instance Method Details

#check_dir_at(filepath) ⇒ Object



32
33
34
# File 'lib/whatsup_github/runner.rb', line 32

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

#dataObject



40
41
42
# File 'lib/whatsup_github/runner.rb', line 40

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

#runObject



17
18
19
20
21
22
23
# File 'lib/whatsup_github/runner.rb', line 17

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

#tableObject



36
37
38
# File 'lib/whatsup_github/runner.rb', line 36

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

#write_results(file, formatter) ⇒ Object



25
26
27
28
29
30
# File 'lib/whatsup_github/runner.rb', line 25

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