timeclock 0.1.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/clock CHANGED
@@ -32,6 +32,14 @@ else
32
32
  when "daily"
33
33
  require 'pp'
34
34
  pp Timeclock::Clock.daily_log
35
+ when "automate"
36
+ Timeclock::Clock.automate
37
+ when 'begin'
38
+ Timeclock::Clock.setup_automate
39
+ when 'end'
40
+ Timeclock::Clock.unsetup_automate
41
+ when "clay"
42
+ puts Timeclock::Clock.clay
35
43
  else
36
44
  help
37
45
  end
data/config/schedule.rb CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  # Example:
7
7
  #
8
- # set :output, "~/.timeclock.log"
8
+ set :output, "~/.timeclock.log"
9
9
 
10
- # every 1.minute do
11
- # command "clock automate"
12
- # end
10
+ every 1.minute do
11
+ command "clock automate"
12
+ end
13
13
 
14
14
  # every 4.days do
15
15
  # runner "AnotherModel.prune_old_records"
@@ -53,6 +53,19 @@ module Timeclock
53
53
  puts "clocking in at #{Time.now}"
54
54
  end
55
55
 
56
+ def automate_clock_in
57
+ string = get_log_string
58
+ array = string.split("\n")
59
+ if !array.empty?
60
+ if array.last.include? "in"
61
+ exit(1)
62
+ end
63
+ end
64
+ array << "in del11009 #{Time.now}"
65
+ put_log_string array.join("\n")
66
+ puts "clocking in at #{Time.now}"
67
+ end
68
+
56
69
  def clock_out
57
70
  string = get_log_string
58
71
  array = string.split("\n")
@@ -65,6 +78,17 @@ module Timeclock
65
78
  puts "clocking out at #{Time.now.to_s}"
66
79
  end
67
80
 
81
+ def automate_clock_out
82
+ string = get_log_string
83
+ array = string.split("\n")
84
+ if array.last.include? "out"
85
+ exit(1)
86
+ end
87
+ array << "out #{Time.now}"
88
+ put_log_string array.join("\n")
89
+ puts "clocking out at #{Time.now.to_s}"
90
+ end
91
+
68
92
  def total
69
93
  total = 0.0
70
94
  collect.each {|value|total += value[:hours]}
@@ -120,7 +144,7 @@ module Timeclock
120
144
  puts collect
121
145
  print "who should I send this to: "
122
146
  to = STDIN.gets.strip
123
- begin
147
+ # begin
124
148
  require 'pony'
125
149
  require 'erb'
126
150
 
@@ -129,6 +153,7 @@ module Timeclock
129
153
  :from => "Lyon <lyon@delorum.com>",
130
154
  :subject => "Time card",
131
155
  :content_type => 'text/html',
156
+ :domain => "localhost.localdomain",
132
157
  :html_body => ERB.new(File.new("templates/email.html.erb").read).result(binding),
133
158
  :body => "You are reading this because your email client sux and cant interperate html... fix it." #,
134
159
  # :via => :smtp, :via_options => {
@@ -142,10 +167,33 @@ module Timeclock
142
167
  # }
143
168
  )
144
169
  puts "Time card has been sent to #{to}."
145
- rescue Exception => e
146
- puts "Time card not sent because pony is dumb."
170
+ # rescue Exception => e
171
+ # puts "Time card not sent because pony is dumb."
172
+ # end
173
+
174
+ end
175
+
176
+ def setup_automate
177
+ puts `whenever -w config/schedule.rb`
178
+ end
179
+
180
+ def unsetup_automate
181
+ puts `whenever -c config/schedule.rb`
182
+ end
183
+
184
+ def automate
185
+ if `ps aux | grep Adium | grep -v grep`.split("\n").size > 0
186
+ puts "AUTOMATE CLOCK IN"
187
+ automate_clock_in
188
+ else
189
+ puts "AUTOMATE CLOCK OUT"
190
+ automate_clock_out
147
191
  end
192
+ end
148
193
 
194
+ def clay
195
+ require 'erb'
196
+ ERB.new(File.new("templates/email.html.erb").read).result(binding)
149
197
  end
150
198
 
151
199
  def email
@@ -1,3 +1,3 @@
1
1
  module Timeclock
2
- VERSION = "0.1.1"
2
+ VERSION = "0.7.3"
3
3
  end
@@ -1,4 +1,14 @@
1
- Hay dude. this will be my email someday
2
- <%= collect.to_s %>
3
- <%= total %>
4
- <%= daily_log %>
1
+ <pre>
2
+ Hay. This is the best formatting I can do.. I'm just a meager programmer..
3
+ <% dl = daily_log %>
4
+ <% total = dl.delete(:total)%>
5
+ <% dl.each do |key, value| %>
6
+ on <%= key.to_s %> I got <%= value[:total] %> hours
7
+ <% value[:log].each do |ele| %>
8
+ <%= ele.to_s %>
9
+ <%end%>
10
+ <%end%>
11
+ For a total of <%= total %> hours
12
+
13
+ Thank you!
14
+ </pre>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timeclock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-24 00:00:00.000000000 -06:00
13
- default_executable:
12
+ date: 2011-07-27 00:00:00.000000000Z
14
13
  dependencies: []
15
14
  description: A simple console based clock in/clock out system.
16
15
  email:
@@ -31,7 +30,6 @@ files:
31
30
  - lib/timeclock/version.rb
32
31
  - templates/email.html.erb
33
32
  - timeclock.gemspec
34
- has_rdoc: true
35
33
  homepage: http://github.com/lyondhill/timeclock
36
34
  licenses: []
37
35
  post_install_message:
@@ -52,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
50
  version: '0'
53
51
  requirements: []
54
52
  rubyforge_project: timeclock
55
- rubygems_version: 1.5.3
53
+ rubygems_version: 1.8.5
56
54
  signing_key:
57
55
  specification_version: 3
58
56
  summary: Timeclock is a small but useful timeclock system that allows users to push