class Empyrean::CLI

Public Class Methods

new(*argv) click to toggle source
# File lib/empyrean/cli.rb, line 29
def initialize(*argv)
  @options = OptParser.parse(argv)
  @config = ConfigLoader.new(@options).load_config
  
  parsed = analyze_tweets
  print_stats(parsed)
  generate_html(parsed)
end

Public Instance Methods

analyze_tweets() click to toggle source
# File lib/empyrean/cli.rb, line 38
def analyze_tweets
  tweet_files = TweetLoader.read_directory(@options.jsondir)
  parsed = []
  parser = TweetParser.new(@options, @config)
  tweet_files.each do |file|
    tweet = TweetLoader.read_file file
    parsed << parser.parse(tweet)
  end
  TweetParser.merge_parsed parsed
end
generate_html(parsed) click to toggle source
# File lib/empyrean/cli.rb, line 74
def generate_html(parsed)
  puts "Generating HTML"
  template = File.read template_file
  renderer = TemplateRenderer.new @config, template, parsed
  File.open(@options.outfile, 'w') do |outfile|
    outfile.write renderer.render
    outfile.flush
  end
  puts " => #{@options.outfile}"
end
print_stats(parsed) click to toggle source
template_file() click to toggle source
# File lib/empyrean/cli.rb, line 85
def template_file
  if File.exist? File.join(Dir.pwd, @options.template)
    File.join(Dir.pwd, @options.template)
  elsif TemplateLister.list.include? @options.template
    File.join TEMPLATE_DIR, @options.template
  else
    @options.template
  end
end