milton 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/History.txt +7 -0
  2. data/Rakefile +4 -4
  3. data/lib/milton.rb +41 -17
  4. metadata +5 -5
@@ -1,3 +1,10 @@
1
+ === 1.0.1 / 2009-06-30
2
+
3
+ * 1 Bugfix
4
+
5
+ * Now handles holidays! Holiday, celebrate. If we took a holiday,
6
+ took some time to celebrate
7
+
1
8
  === 1.0.0 / 2009-02-23
2
9
 
3
10
  * 1 major enhancement
data/Rakefile CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'hoe'
5
- require './lib/milton.rb'
6
5
 
7
- Hoe.new('milton', Milton::VERSION) do |p|
8
- p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
9
- p.extra_deps = [['mechanize', '>= 0.9.2']]
6
+ Hoe.spec 'milton' do |p|
7
+ developer('Aaron Patterson', 'aaronp@rubyforge.org')
8
+ self.extra_deps = [['mechanize', '>= 0.9.2']]
9
+ self.rubyforge_name = 'seattlerb'
10
10
  end
11
11
 
12
12
  # vim: syntax=Ruby
@@ -12,7 +12,7 @@ require 'yaml'
12
12
 
13
13
  class Milton
14
14
 
15
- VERSION = '1.0.0'
15
+ VERSION = '1.0.1'
16
16
 
17
17
  def self.load_config config_file
18
18
  unless File.exist? config_file then
@@ -168,24 +168,35 @@ the current week with eight hours/day.
168
168
  def fill_timesheet
169
169
  rows = []
170
170
  last_date = nil
171
+ filled_in = false
171
172
 
172
173
  parse_timesheet.each do |data|
173
- next if data[0].to_i > 0
174
-
175
174
  department = data[6]
176
175
  employee_id = data[7]
177
176
  date = Date.parse(CGI.unescape(data[1])).strftime('%m/%d/%Y')
178
177
 
179
- start, finish = starting_and_ending_timestamp(date, last_date)
178
+ # skip days with data already filled (like holidays)
179
+ if data[0].to_i > 0 or (filled_in and date == last_date) then
180
+ filled_in = true
181
+ last_date = date
182
+ next
183
+ end
184
+
185
+ filled_in = false
180
186
 
181
- rows << ['0','','False','True','False','False','False',
182
- "#{date} 12:00:00 AM",
183
- start,'',
184
- finish,
185
- '8','',
186
- department,
187
- employee_id,
188
- '','','','','','','','','','','','','','','','','','','','','EDIT','','','','','2','','0','False']
187
+ start, finish = starting_and_ending_timestamp date, last_date
188
+
189
+ rows << [
190
+ '0', '', 'False', 'True', 'False', 'False', 'False',
191
+ "#{date} 12:00:00 AM",
192
+ start, '',
193
+ finish,
194
+ '8', '',
195
+ department,
196
+ employee_id,
197
+ '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
198
+ '', '', '', 'EDIT', '', '', '', '', '2', '', '0', 'False'
199
+ ]
189
200
 
190
201
  # This reset is for the timestamp calculations.
191
202
  last_date = date
@@ -217,12 +228,23 @@ the current week with eight hours/day.
217
228
 
218
229
  puts "-" * 80
219
230
 
231
+ date = nil
232
+ last_date = nil
233
+
220
234
  timesheet.each do |row|
221
- if row[0] == '0' then
235
+ date = row[2]
236
+
237
+ if row[0] == '0' and date == last_date then
238
+ # do nothing
239
+ elsif row[0] == '0' then
222
240
  puts "#{row[2]} no time entered"
241
+ elsif date == last_date then
242
+ puts " %s to %s for %3s hours %s" % row.values_at(3, 4, 5, 8)
223
243
  else
224
- puts "#{row[2]} #{row[3]} to #{row[4]} for %2s hours" % row[5]
244
+ puts "%s %s to %s for %3s hours %s" % row.values_at(2, 3, 4, 5, 8)
225
245
  end
246
+
247
+ last_date = date
226
248
  end
227
249
  end
228
250
 
@@ -261,13 +283,15 @@ the current week with eight hours/day.
261
283
 
262
284
  ##
263
285
  # Returns an array of arrays containing: row id, day start time, date, start
264
- # time, end time, hours, department, employee id. All values are strings.
286
+ # time, end time, hours, department, employee id and earnings code. All
287
+ # values are strings.
265
288
 
266
289
  def parse_timesheet
267
290
  @page.body.scan(/TCMS.oTD.push\((\[.*\])\)/).map do |match|
268
- match[0].gsub(/"/, '').split(',').map { |x|
291
+ row = match[0].gsub(/"/, '').split(',')
292
+ row.map { |x|
269
293
  CGI.unescape(x.strip).delete('[]')
270
- }.values_at(0, 7, 8, 9, 11, 12, 14, 15)
294
+ }.values_at(0, 7, 8, 9, 11, 12, 14, 15, 32)
271
295
  end
272
296
  end
273
297
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milton
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-04 00:00:00 -07:00
12
+ date: 2009-06-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.12.2
33
+ version: 2.2.0
34
34
  version:
35
35
  description: Milton fills out your ADP ezLaborManager timesheet
36
36
  email:
@@ -77,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version:
78
78
  requirements: []
79
79
 
80
- rubyforge_project: milton
81
- rubygems_version: 1.3.3
80
+ rubyforge_project: seattlerb
81
+ rubygems_version: 1.3.4
82
82
  signing_key:
83
83
  specification_version: 3
84
84
  summary: Milton fills out your ADP ezLaborManager timesheet