summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Jahnke2012-03-07 10:05:25 -0600
committerAdam Jahnke2012-03-07 10:05:25 -0600
commit75a36ec65641f1e6e2d31c76a8868b0f2377b67f (patch)
treeac02d180804298cfa0c7f3a9234f2c592e8b81b3 /lib
parent5b84478c7b184c2a9e72bc750e983c54fb3055a4 (diff)
downloadhcl-75a36ec65641f1e6e2d31c76a8868b0f2377b67f.tar.bz2
Cleaning up whitespace and trailing spaces
Diffstat (limited to 'lib')
-rw-r--r--lib/hcl/app.rb16
-rw-r--r--lib/hcl/commands.rb18
-rw-r--r--lib/hcl/day_entry.rb3
-rw-r--r--lib/hcl/task.rb3
-rw-r--r--lib/hcl/timesheet_resource.rb8
5 files changed, 23 insertions, 25 deletions
diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb
index 83c52ca..9569dc5 100644
--- a/lib/hcl/app.rb
+++ b/lib/hcl/app.rb
@@ -35,10 +35,10 @@ module HCl
class App
include HCl::Utility
include HCl::Commands
-
+
SETTINGS_FILE = "#{ENV['HOME']}/.hcl_settings"
CONFIG_FILE = "#{ENV['HOME']}/.hcl_config"
-
+
def initialize
read_config
read_settings
@@ -56,7 +56,7 @@ module HCl
def command? command
Commands.method_defined? command
end
-
+
# Start the application.
def run
begin
@@ -88,7 +88,7 @@ module HCl
exit 1
end
end
-
+
def process_args *args
Trollop::options(args) do
stop_on Commands.instance_methods
@@ -124,7 +124,7 @@ EOM
end
protected
-
+
def read_config
if File.exists? CONFIG_FILE
config = YAML::load File.read(CONFIG_FILE)
@@ -144,14 +144,14 @@ EOM
write_config config
end
end
-
+
def write_config config
puts "Writing configuration to #{CONFIG_FILE}."
File.open(CONFIG_FILE, 'w') do |f|
f.write config.to_yaml
end
end
-
+
def read_settings
if File.exists? SETTINGS_FILE
@settings = YAML.load(File.read(SETTINGS_FILE))
@@ -159,7 +159,7 @@ EOM
@settings = {}
end
end
-
+
def write_settings
File.open(SETTINGS_FILE, 'w') do |f|
f.write @settings.to_yaml
diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb
index 47fd93b..fdc50a3 100644
--- a/lib/hcl/commands.rb
+++ b/lib/hcl/commands.rb
@@ -9,7 +9,7 @@ module HCl
end
nil
end
-
+
def set key = nil, *args
if key.nil?
@settings.each do |k, v|
@@ -23,16 +23,16 @@ module HCl
end
nil
end
-
+
def unset key
@settings.delete key
write_settings
end
-
+
def aliases
@settings.keys.select { |s| s =~ /^task\./ }.map { |s| s.slice(5..-1) }
end
-
+
def start *args
starting_time = args.detect {|x| x =~ /^\+\d*(\.|:)?\d+$/ }
if starting_time
@@ -53,7 +53,7 @@ module HCl
timer = task.start(:starting_time => starting_time, :note => args.join(' '))
puts "Started timer for #{timer} (at #{current_time})"
end
-
+
def stop *args
entry = DayEntry.with_timer
if entry
@@ -64,7 +64,7 @@ module HCl
puts "No running timers found."
end
end
-
+
def note *args
message = args.join ' '
entry = DayEntry.with_timer
@@ -75,7 +75,7 @@ module HCl
puts "No running timers found."
end
end
-
+
def show *args
date = args.empty? ? nil : Chronic.parse(args.join(' '))
total_hours = 0.0
@@ -87,7 +87,7 @@ module HCl
puts "\t" + '-' * 13
puts "\t#{as_hours total_hours}\ttotal (as of #{current_time})"
end
-
+
def resume
entry = DayEntry.last
if entry
@@ -97,7 +97,7 @@ module HCl
puts "No timers found"
end
end
-
+
private
def current_time
Time.now.strftime('%I:%M %p').downcase
diff --git a/lib/hcl/day_entry.rb b/lib/hcl/day_entry.rb
index d4fe69d..c274126 100644
--- a/lib/hcl/day_entry.rb
+++ b/lib/hcl/day_entry.rb
@@ -42,7 +42,7 @@ module HCl
def self.with_timer
all.detect {|t| t.running? }
end
-
+
def self.last
all.sort {|a,b| a.updated_at<=>b.updated_at}[-1]
end
@@ -65,6 +65,5 @@ module HCl
def formatted_hours
as_hours hours
end
-
end
end
diff --git a/lib/hcl/task.rb b/lib/hcl/task.rb
index fef3a11..3922600 100644
--- a/lib/hcl/task.rb
+++ b/lib/hcl/task.rb
@@ -14,7 +14,7 @@ module HCl
end
end
end
-
+
def self.cache_file
File.join(ENV['HOME'],'.hcl_tasks')
end
@@ -63,7 +63,6 @@ module HCl
DayEntry.from_xml(Task.get("daily/timer/#{day.id}")).first
end
end
-
end
end
diff --git a/lib/hcl/timesheet_resource.rb b/lib/hcl/timesheet_resource.rb
index b9ba99a..fd6257b 100644
--- a/lib/hcl/timesheet_resource.rb
+++ b/lib/hcl/timesheet_resource.rb
@@ -12,7 +12,7 @@ module HCl
yield self
end
end
-
+
# configuration accessors
%w[ login password subdomain ssl ].each do |config_var|
class_eval <<-EOC
@@ -24,11 +24,11 @@ module HCl
end
EOC
end
-
+
def initialize params
@data = params
end
-
+
def self.get action
http_do Net::HTTP::Get, action
end
@@ -53,7 +53,7 @@ module HCl
raise Failure, "Unexpected response from the upstream API"
end
end
-
+
def id
@data[:id]
end