Sha256: 03156d49e552394fc6263e2a5ef74660eeeb7f451a32fd4a67fe9f53a5f4b977

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby
# needs to handle passing config. ~/.insulin or somrthing
require 'insulin'
require 'thor'

module Insulin
  class I < Thor
    @@mongo = Insulin::MongoHandle.new ({"database" => "insulin"})

#    map "-i" => :ingest

    desc "ingest FILE", "ingest OnTrack CSV export FILE"
    def ingest file
      csv = Insulin::OnTrack::CsvFile.new file
      csv.save_events @@mongo
    end

    desc "day DATE", "show stats for day DATE (default is today)"
    def day date = nil
      if not date
        require 'time'
        date = Time.new.strftime "%F"
      end
      begin
        d = Insulin::Day.new date, @@mongo
        puts d
      rescue NoMethodError
        puts "No data for %s" % date
      end
    end

    desc "week DATE", "show stats for week commencing DATE (defaults to previous 7 days)"
    def week date = nil
      if not date
        require 'time'
        date = (Time.new - (6 * 86400)).strftime "%F"
      end
      w = Insulin::Week.new date, @@mongo
      puts w.to_s
    end

    default_task :day
  end
end

Insulin::I.start

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
insulin-0.0.18 bin/insulin