Sha256: ea775b5d15575e0a56972500fbe1486c50b721001c4a42423b5c058cb4b74a29

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby
require 'harvest_wheelman'
require 'optparse'

EXAMPLE = %{{
  "harvest":{
    "site":"---",
    "user":"---",
    "pass":"---"
  }
}}

SETTINGS_HELP = %{#{EXAMPLE}

Optionally include a "pay_period" block, otherwise we automatically use
a 2 week pay period where "to" is set to the closest Sunday to today.

{
  "harvest": { ... },
  "pay_period":{
    "weeks":2, 
    "from":"09/03/2012",
    "to":"09/16/2012" 
  }
}}

SETTINGS_FILE = File.join(File.expand_path('~'), '.harvest_wheelman')
if !File.exists? SETTINGS_FILE
  File.open(SETTINGS_FILE, 'w') do |f|
    f.write EXAMPLE
  end
  puts "Wrote to #{SETTINGS_FILE}"
  puts SETTINGS_HELP
  exit(0)
end

begin
  hs = HarvestWheelman::HarvestSubmit.new(SETTINGS_FILE)
  puts %{
    Pay period is set from: #{hs.from}
                        to: #{hs.to}
    Press enter to open chrome and generate the PDF using these dates.
    Ctrl-C to quit.
  }
  puts hs.drive_to_pdf if STDIN.gets
rescue => ex
puts <<-EOF
Could not start, check your settings file.
Settings file path: #{SETTINGS_FILE}
  
Example:
#{SETTINGS_HELP}

Error: #{ex.message}
------------------
#{ex.backtrace.join("\n")} 
EOF
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
harvest_wheelman-1.0.0 bin/harvest_wheelman