lib/Standupguy.rb in Standupguy-0.0.6 vs lib/Standupguy.rb in Standupguy-0.0.8

- old
+ new

@@ -44,31 +44,38 @@ # Generic methods that were moved from bin/standupguy to here # in order to better test this code. Mostly init stuff. class Core DATA_ROOT = File.join(ENV["HOME"], ".standupguy") + + attr_accessor :options + def initialize(options) + @options = options + first_time! unless Dir.exist?(DATA_ROOT) - if options[:item] + @options[:date] ||= DateTime.now.strftime("%Y-%m-%d") + + if @options[:item] item = Standupguy::Item.new - item.add_to_today(options[:item]) + item.add_to_today(@options[:item]) item.save - date = DateTime.now.strftime("%Y-%m-%d") - options = { report: "TEXT", date: date }.merge(options) end + end - report(options).show unless options[:report].nil? + def show + report.show end - def report(options) - case options[:report] + def report + case @options[:report] when "HTML" - Standupguy::HTMLReport.new(options[:date]) - when "TEXT" - Standupguy::TextReport.new(options[:date]) + Standupguy::HTMLReport.new(@options[:date]) when "EMAIL" - Standupguy::EmailReport.new(options[:date]) + Standupguy::EmailReport.new(@options[:date]) + else + Standupguy::TextReport.new(@options[:date]) end end def first_time! Kernel.puts("First time running...\nCreating data directory")