calc_working_hours 0.0.5 → 0.1.0

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.
@@ -1,11 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module CalcWorkingHours
4
- attr_reader :time_card_rows, :card_id, :working_hours
4
+ attr_reader :time_card_rows, :card_id, :working_hours, :id
5
5
  class TimeCard
6
- def initialize(card_id)
6
+ def initialize(card_id, id)
7
7
  @time_card_rows = []
8
8
  @card_id = card_id
9
+ @id = id
9
10
  self
10
11
  end
11
12
 
@@ -5,7 +5,7 @@ require "date"
5
5
  module CalcWorkingHours
6
6
 
7
7
  class TimeCardRow
8
- attr_reader :starting_time, :ending_time, :break_time, :working_hours, :date_string, :time_point, :working_hours_in_range
8
+ attr_reader :starting_time, :ending_time, :break_time, :working_hours, :date_string, :time_point, :working_hours_in_range, :overtime, :id
9
9
  def initialize(starting_time, ending_time, *break_time)
10
10
  unless valid_time_format?(starting_time) && valid_time_format?(ending_time)
11
11
  raise "failure initialize (invalid time format! TimeCardRow class)"
@@ -48,6 +48,11 @@ module CalcWorkingHours
48
48
  self
49
49
  end
50
50
 
51
+ def set_fixed_working_hours(time)
52
+ @overtime = @working_hours.minus_time(time)
53
+ self
54
+ end
55
+
51
56
  def set_date(date)
52
57
  unless date.class == String
53
58
  raise "failure set_date (date should string class)! TimeCardRow class"
@@ -5,11 +5,19 @@ module CalcWorkingHours
5
5
 
6
6
  class TimeRecorder
7
7
  attr_reader :time_cards
8
- def initialize(path_to_csv, card_id_row, starting_time_row, ending_time_row, date_row, ignore_row_flag = 0, *break_time_rows)
8
+ def initialize(path_to_csv, set_encode, id_row, card_id_row, starting_time_row, ending_time_row, date_row, *break_time_rows)
9
+
10
+ csv_data = File.read(path_to_csv) if set_encode == nil || set_encode == false
11
+ csv_data = File.read(path_to_csv, :encoding => set_encode + ":UTF-8") if set_encode
9
12
  time_cards = {}
10
13
  option_of_csv = {:headers => true, :return_headers => false}
11
- CSV.foreach(path_to_csv, option_of_csv) do |row|
12
- if row[starting_time_row] != nil && row[ending_time_row] != nil && row[ignore_row_flag].to_i >= 1
14
+ CSV.new(csv_data, option_of_csv).each do |row|
15
+ header_row_flag = true
16
+ row.each do |r|
17
+ header_row_flag = false unless r[0] == r[1]
18
+ end
19
+ if header_row_flag
20
+ elsif row[starting_time_row] != nil && row[ending_time_row] != nil
13
21
  break_times = []
14
22
  unless break_time_rows.empty?
15
23
  break_time_rows.each do |bt|
@@ -18,9 +26,10 @@ module CalcWorkingHours
18
26
  end
19
27
 
20
28
  if time_cards.has_key?(row[card_id_row])
29
+ raise "id mismatching! (TimeRecorder class)" unless time_cards[row[card_id_row]].id == row[id_row]
21
30
  time_cards[row[card_id_row]].add_row(TimeCardRow.new(row[starting_time_row], row[ending_time_row], *break_times).set_date(row[date_row]))
22
31
  else
23
- time_cards[row[card_id_row]] = TimeCard.new(row[card_id_row])
32
+ time_cards[row[card_id_row]] = TimeCard.new(row[card_id_row], row[id_row])
24
33
  time_cards[row[card_id_row]].add_row(TimeCardRow.new(row[starting_time_row], row[ending_time_row], *break_times).set_date(row[date_row]))
25
34
  end
26
35
  end
@@ -28,5 +37,6 @@ module CalcWorkingHours
28
37
  @time_cards = time_cards
29
38
  self
30
39
  end
40
+
31
41
  end
32
42
  end
@@ -1,3 +1,3 @@
1
1
  module CalcWorkingHours
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,8 +1,12 @@
1
+ require "calc_working_hours/time_card"
2
+ require "calc_working_hours/time_card_row"
3
+ require "calc_working_hours/time_recorder"
4
+ require "calc_working_hours/working_hours"
1
5
  require "calc_working_hours/version"
2
- require "active_support/dependencies"
3
-
4
- module CalcWorkingHours
5
- end
6
-
7
- ActiveSupport::Dependencies.autoload_paths << File.expand_path('..', __FILE__)
8
- ActiveSupport::Dependencies.autoload_paths << File.expand_path('../calc_working_hours', __FILE__)
6
+ #require "active_support/dependencies"
7
+ #
8
+ #module CalcWorkingHours
9
+ #end
10
+ #
11
+ #ActiveSupport::Dependencies.autoload_paths << File.expand_path('..', __FILE__)
12
+ #ActiveSupport::Dependencies.autoload_paths << File.expand_path('../calc_working_hours', __FILE__)
@@ -0,0 +1,128 @@
1
+ "�J�[�h�ԍ�","�]�ƈ��ԍ�","�]�ƈ�����","�����ԍ�","�N/��/��","�V�t�g�ԍ�","����/�x���敪","�s�ݗ��R","�o�Αō�","�o�΃}�[�N","�O�o�ō�","�O�o�}�[�N","�ߑō�","�߃}�[�N","�ދΑō�","�ދ΃}�[�N","�R�����g"
2
+ 0000000001,00000001,�����@������,2,2013/07/21,01,00,,09:55,0,14:30,0,16:30,0,21:03,0,
3
+ 0000000001,00000001,�����@������,2,2013/07/22,01,00,,09:47,0,14:30,0,16:30,0,21:13,0,
4
+ 0000000001,00000001,�����@������,2,2013/07/23,01,00,,09:59,0,14:30,0,16:30,0,21:09,0,
5
+ 0000000001,00000001,�����@������,2,2013/07/24,01,00,,,0,,0,,0,,0,
6
+ 0000000001,00000001,�����@������,2,2013/07/25,01,00,,,0,,0,,0,,0,
7
+ 0000000001,00000001,�����@������,2,2013/07/26,01,00,,09:55,0,14:30,0,16:30,0,21:55,0,
8
+ 0000000001,00000001,�����@������,2,2013/07/27,01,00,,09:40,0,14:30,0,16:30,0,21:00,0,
9
+ 0000000001,00000001,�����@������,2,2013/07/28,01,00,,09:57,0,14:30,0,16:30,0,21:38,0,
10
+ 0000000001,00000001,�����@������,2,2013/07/29,01,00,,10:00,0,14:30,0,16:30,0,21:00,0,
11
+ 0000000001,00000001,�����@������,2,2013/07/30,01,00,,10:00,0,14:30,0,16:30,0,21:55,0,
12
+ 0000000001,00000001,�����@������,2,2013/07/31,01,00,,,0,,0,,0,,0,
13
+ 0000000001,00000001,�����@������,2,2013/08/01,01,00,,,0,,0,,0,,0,
14
+ 0000000001,00000001,�����@������,2,2013/08/02,01,00,,10:01,0,14:30,0,16:30,0,21:43,0,
15
+ 0000000001,00000001,�����@������,2,2013/08/03,01,00,,09:58,0,14:30,0,16:30,0,21:35,0,
16
+ 0000000001,00000001,�����@������,2,2013/08/04,01,00,,10:01,0,14:30,0,16:30,0,21:43,0,
17
+ 0000000001,00000002,�����@������,2,2013/08/05,01,00,,09:53,0,14:30,0,16:30,0,21:00,0,
18
+ 0000000001,00000001,�����@������,2,2013/08/06,01,00,,09:38,0,14:30,0,16:30,0,21:59,0,
19
+ 0000000001,00000001,�����@������,2,2013/08/07,01,00,,,0,,0,,0,,0,
20
+ 0000000001,00000001,�����@������,2,2013/08/08,01,00,,,0,,0,,0,,0,
21
+ 0000000001,00000001,�����@������,2,2013/08/09,01,00,,09:58,0,14:30,0,16:30,0,21:44,0,
22
+ 0000000001,00000001,�����@������,2,2013/08/10,01,00,,09:59,0,14:30,0,16:30,0,21:30,0,
23
+ 0000000001,00000001,�����@������,2,2013/08/11,01,00,,09:56,0,14:30,0,16:30,0,21:36,0,
24
+ 0000000001,00000001,�����@������,2,2013/08/12,01,00,,10:03,0,14:30,0,16:30,0,21:56,0,
25
+ 0000000001,00000001,�����@������,2,2013/08/13,01,00,,10:00,0,14:30,0,16:30,0,22:00,0,
26
+ 0000000001,00000001,�����@������,2,2013/08/14,01,00,,10:00,0,14:30,0,16:30,0,22:03,0,
27
+ 0000000001,00000001,�����@������,2,2013/08/15,01,00,,09:58,0,14:30,0,16:30,0,22:33,0,
28
+ 0000000001,00000001,�����@������,2,2013/08/16,01,00,,10:03,0,14:30,0,16:30,0,22:22,0,
29
+ 0000000001,00000001,�����@������,2,2013/08/17,01,00,,09:59,0,14:30,0,16:30,0,22:10,0,
30
+ 0000000001,00000001,�����@������,2,2013/08/18,01,00,,10:02,0,14:30,0,16:30,0,21:30,0,
31
+ 0000000001,00000001,�����@������,2,2013/08/19,01,00,,10:01,0,14:30,0,16:30,0,22:30,0,
32
+ 0000000001,00000001,�����@������,2,2013/08/20,01,00,,09:32,0,14:30,0,16:30,0,22:21,0,
33
+ "�J�[�h�ԍ�","�]�ƈ��ԍ�","�]�ƈ�����","�����ԍ�","�N/��/��","�V�t�g�ԍ�","����/�x���敪","�s�ݗ��R","�o�Αō�","�o�΃}�[�N","�O�o�ō�","�O�o�}�[�N","�ߑō�","�߃}�[�N","�ދΑō�","�ދ΃}�[�N","�R�����g"
34
+ 0000000002,00000002,�����@������,101,2013/07/21,20,00,,10:00,0,,0,,0,15:10,0,
35
+ 0000000002,00000002,�����@������,101,2013/07/22,20,00,,10:30,0,15:09,0,17:50,0,20:03,0,
36
+ 0000000002,00000002,�����@������,101,2013/07/23,20,00,,,0,,0,,0,,0,
37
+ 0000000002,00000002,�����@������,101,2013/07/24,20,00,,,0,,0,,0,,0,
38
+ 0000000002,00000002,�����@������,101,2013/07/25,20,00,,10:00,0,14:09,0,15:49,0,21:08,0,
39
+ 0000000002,00000002,�����@������,101,2013/07/26,20,00,,10:00,0,14:12,0,15:48,0,21:27,0,
40
+ 0000000002,00000002,�����@������,101,2013/07/27,20,00,,10:00,0,15:55,0,17:19,0,21:08,0,
41
+ 0000000002,00000002,�����@������,101,2013/07/28,20,00,,11:24,0,,0,,0,14:28,0,
42
+ 0000000002,00000002,�����@������,101,2013/07/29,20,00,,10:30,0,14:13,0,15:51,0,21:25,0,
43
+ 0000000002,00000002,�����@������,101,2013/07/30,20,00,,10:30,0,14:09,0,14:49,0,20:27,0,
44
+ 0000000002,00000002,�����@������,101,2013/07/31,20,00,,,0,,0,,0,,0,
45
+ 0000000002,00000002,�����@������,101,2013/08/01,20,00,,,0,,0,,0,,0,
46
+ 0000000002,00000002,�����@������,101,2013/08/02,20,00,,10:00,0,14:02,0,15:51,0,20:13,0,
47
+ 0000000002,00000002,�����@������,101,2013/08/03,20,00,,10:00,0,14:00,0,15:49,0,19:05,0,
48
+ 0000000002,00000002,�����@������,101,2013/08/04,20,00,,10:00,0,,0,,0,16:30,0,
49
+ 0000000002,00000002,�����@������,101,2013/08/05,20,00,,10:30,0,14:13,0,15:53,0,21:29,0,
50
+ 0000000002,00000002,�����@������,101,2013/08/06,20,00,,,0,,0,,0,,0,
51
+ 0000000002,00000002,�����@������,101,2013/08/07,20,00,,11:00,0,,0,,0,15:05,0,
52
+ 0000000002,00000002,�����@������,101,2013/08/08,20,00,,18:30,0,,0,,0,22:43,0,
53
+ 0000000002,00000002,�����@������,101,2013/08/09,20,00,,10:30,0,14:16,0,16:11,0,20:12,0,
54
+ 0000000002,00000002,�����@������,101,2013/08/10,20,00,,10:00,0,16:29,0,17:48,0,21:09,0,
55
+ 0000000002,00000002,�����@������,101,2013/08/11,20,00,,10:00,0,,0,,0,15:05,0,
56
+ 0000000002,00000002,�����@������,101,2013/08/12,20,00,,10:00,0,14:27,0,15:58,0,21:56,0,
57
+ 0000000002,00000002,�����@������,101,2013/08/13,20,00,,,0,,0,,0,,0,
58
+ 0000000002,00000002,�����@������,101,2013/08/14,20,00,,10:00,0,14:00,0,15:50,0,21:01,0,
59
+ 0000000002,00000002,�����@������,101,2013/08/15,20,00,,10:00,0,14:09,0,15:52,0,21:09,0,
60
+ 0000000002,00000002,�����@������,101,2013/08/16,20,00,,,0,,0,,0,,0,
61
+ 0000000002,00000002,�����@������,101,2013/08/17,20,00,,10:00,0,14:08,0,15:49,0,21:07,0,
62
+ 0000000002,00000002,�����@������,101,2013/08/18,20,00,,10:00,0,,0,,0,16:16,0,
63
+ 0000000002,00000002,�����@������,101,2013/08/19,20,00,,10:30,0,14:32,0,16:46,0,21:06,0,
64
+ 0000000002,00000002,�����@������,101,2013/08/20,20,00,,10:00,0,14:12,0,15:49,0,20:51,0,
65
+ "�J�[�h�ԍ�","�]�ƈ��ԍ�","�]�ƈ�����","�����ԍ�","�N/��/��","�V�t�g�ԍ�","����/�x���敪","�s�ݗ��R","�o�Αō�","�o�΃}�[�N","�O�o�ō�","�O�o�}�[�N","�ߑō�","�߃}�[�N","�ދΑō�","�ދ΃}�[�N","�R�����g"
66
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/21,20,00,,12:00,0,,0,,0,17:04,0,
67
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/22,20,00,,12:00,0,,0,,0,17:00,0,
68
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/23,20,00,,12:00,0,,0,,0,17:02,0,
69
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/24,20,00,,,0,,0,,0,,0,
70
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/25,20,00,,11:00,0,,0,,0,16:06,0,
71
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/26,20,00,,12:00,0,,0,,0,16:39,0,
72
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/27,20,00,,12:00,0,,0,,0,17:07,0,
73
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/28,20,00,,12:00,0,,0,,0,17:08,0,
74
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/29,20,00,,12:00,0,,0,,0,17:06,0,
75
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/30,20,00,,12:00,0,,0,,0,17:05,0,
76
+ 0000000084,00000004,�����@�‚Ă�,102,2013/07/31,20,00,,,0,,0,,0,,0,
77
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/01,20,00,,10:30,0,,0,,0,15:30,0,
78
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/02,20,00,,12:00,0,,0,,0,16:51,0,
79
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/03,20,00,,12:00,0,,0,,0,17:05,0,
80
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/04,20,00,,12:00,0,,0,,0,17:04,0,
81
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/05,20,00,,10:30,0,,0,,0,15:42,0,
82
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/06,20,00,,12:00,0,,0,,0,17:21,0,
83
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/07,20,00,,,0,,0,,0,,0,
84
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/08,20,00,,12:00,0,,0,,0,16:35,0,
85
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/09,20,00,,11:00,0,,0,,0,15:14,0,
86
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/10,20,00,,12:00,0,,0,,0,17:05,0,
87
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/11,20,00,,12:00,0,,0,,0,17:10,0,
88
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/12,20,00,,12:00,0,,0,,0,17:13,0,
89
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/13,20,00,,12:00,0,,0,,0,17:05,0,
90
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/14,20,00,,,0,,0,,0,,0,
91
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/15,20,00,,12:00,0,,0,,0,21:30,0,
92
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/16,20,00,,12:00,0,17:04,0,17:46,0,22:22,0,������
93
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/17,20,00,,12:00,0,17:07,0,17:59,0,22:27,0,������
94
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/18,20,00,,12:00,0,,0,,0,17:05,0,
95
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/19,20,00,,12:00,0,,0,,0,17:08,0,
96
+ 0000000084,00000004,�����@�‚Ă�,102,2013/08/20,20,00,,12:00,0,,0,,0,17:02,0,
97
+ "�J�[�h�ԍ�","�]�ƈ��ԍ�","�]�ƈ�����","�����ԍ�","�N/��/��","�V�t�g�ԍ�","����/�x���敪","�s�ݗ��R","�o�Αō�","�o�΃}�[�N","�O�o�ō�","�O�o�}�[�N","�ߑō�","�߃}�[�N","�ދΑō�","�ދ΃}�[�N","�R�����g"
98
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/21,20,00,,,0,,0,,0,,0,
99
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/22,20,00,,10:30,0,,0,,0,15:32,0,
100
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/23,20,00,,10:30,0,,0,,0,15:31,0,
101
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/24,20,00,,,0,,0,,0,,0,
102
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/25,20,00,,10:30,0,,0,,0,15:40,0,
103
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/26,20,00,,,0,,0,,0,,0,
104
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/27,20,01,,10:30,0,,0,,0,16:16,0,
105
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/28,20,00,,,0,,0,,0,,0,
106
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/29,20,00,,10:30,0,,0,,0,15:39,0,
107
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/30,20,00,,10:30,0,,0,,0,15:50,0,
108
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/07/31,20,00,,,0,,0,,0,,0,
109
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/01,20,00,,,0,,0,,0,,0,
110
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/02,20,00,,10:30,0,,0,,0,15:46,0,
111
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/03,20,00,,,0,,0,,0,,0,
112
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/04,20,01,,10:30,0,,0,,0,15:53,0,
113
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/05,20,00,,,0,,0,,0,,0,
114
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/06,20,00,,10:30,0,,0,,0,16:02,0,
115
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/07,20,00,,10:30,0,,0,,0,15:30,0,
116
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/08,20,00,,,0,,0,,0,,0,
117
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/09,20,00,,10:30,0,,0,,0,15:45,0,
118
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/10,20,00,,,0,,0,,0,,0,
119
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/11,20,01,,10:30,0,,0,,0,16:30,0,
120
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/12,20,00,,,0,,0,,0,,0,
121
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/13,20,00,,10:30,0,,0,,0,16:12,0,
122
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/14,20,00,,10:30,0,,0,,0,16:30,0,
123
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/15,20,00,,,0,,0,,0,,0,
124
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/16,20,00,,10:30,0,,0,,0,16:26,0,
125
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/17,20,01,,10:30,0,16:02,0,17:55,0,22:02,0,������
126
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/18,20,00,,,0,,0,,0,,0,
127
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/19,20,00,,,0,,0,,0,,0,
128
+ 0000000005,00000016,�ȂɁ@�ʂ˂�,102,2013/08/20,20,00,,10:30,0,,0,,0,15:47,0,
@@ -41,6 +41,11 @@ describe TimeCardRow do
41
41
  @time_card_row.working_hours_in_range("14:00", "17:00").should == "2:00"
42
42
  end
43
43
 
44
+ it "所定労働時間を7:20とすると、残業時間は0:40となる" do
45
+ @time_card_row.set_fixed_working_hours("7:20").overtime.time_string.should == "0:40"
46
+ end
47
+
48
+
44
49
  end
45
50
 
46
51
  context "適正な時間設定と、不適な設定時間を設定したとき" do
@@ -4,10 +4,10 @@ require 'spec_helper'
4
4
  include CalcWorkingHours
5
5
 
6
6
  describe TimeRecorder do
7
- context "data_sample.csvの通りTimeRecorderが与えられている場合" do
7
+ context "data_sample.csv(Shift_JIS)の通りTimeRecorderが与えられている場合" do
8
8
  before do
9
9
  path_to_csv = File.expand_path(File.dirname(__FILE__)) + "/data_sample.csv"
10
- @time_recorder = TimeRecorder.new(path_to_csv, 0, 8, 14, 4, 0, [10, 12])
10
+ @time_recorder = TimeRecorder.new(path_to_csv, "Shift_JIS", "従業員番号", "カード番号", "出勤打刻", "退勤打刻", "年/月/日", ["外出打刻", "戻打刻"])
11
11
  end
12
12
 
13
13
  it "タイムカードのデータが5件あること" do
@@ -30,5 +30,19 @@ describe TimeRecorder do
30
30
  @time_recorder.time_cards["0000000002"].total_working_hours_in_range("11:00", "16:00").should == "87:02"
31
31
  end
32
32
 
33
+ it "タイムカードのidが0000000084の人物の従業員番号はであること" do
34
+ @time_recorder.time_cards["0000000084"].id.should == "00000004"
35
+ end
36
+
37
+ end
38
+
39
+ context "invalid_data_sample.csv(Shift_JIS)の通りTimeRecorderが与えられている場合" do
40
+
41
+ it "従業員番号が一致していない部分があるのでエラーが発生すること" do
42
+ path_to_csv = File.expand_path(File.dirname(__FILE__)) + "/invalid_data_sample.csv"
43
+ proc{ TimeRecorder.new(path_to_csv, "Shift_JIS", "従業員番号", "カード番号", "出勤打刻", "退勤打刻", "年/月/日", ["外出打刻", "戻打刻"])}.should raise_error
44
+ end
45
+
33
46
  end
47
+
34
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calc_working_hours
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-21 00:00:00.000000000Z
12
+ date: 2013-09-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70311384099360 !ruby/object:Gem::Requirement
16
+ requirement: &70229929699060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70311384099360
24
+ version_requirements: *70229929699060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70311384098460 !ruby/object:Gem::Requirement
27
+ requirement: &70229929698520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70311384098460
35
+ version_requirements: *70229929698520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70311384096960 !ruby/object:Gem::Requirement
38
+ requirement: &70229929697840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70311384096960
46
+ version_requirements: *70229929697840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activesupport
49
- requirement: &70311384095880 !ruby/object:Gem::Requirement
49
+ requirement: &70229929697240 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70311384095880
57
+ version_requirements: *70229929697240
58
58
  description: 例えば、173:08のような表記の時間を計算するライブラリです
59
59
  email:
60
60
  - ''
@@ -77,6 +77,7 @@ files:
77
77
  - lib/calc_working_hours/version.rb
78
78
  - lib/calc_working_hours/working_hours.rb
79
79
  - spec/calc_working_hours/data_sample.csv
80
+ - spec/calc_working_hours/invalid_data_sample.csv
80
81
  - spec/calc_working_hours/time_card_row_spec.rb
81
82
  - spec/calc_working_hours/time_card_spec.rb
82
83
  - spec/calc_working_hours/time_recorder_spec.rb
@@ -98,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
99
  version: '0'
99
100
  segments:
100
101
  - 0
101
- hash: 4216760181021085759
102
+ hash: 2702542142238984905
102
103
  required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  none: false
104
105
  requirements:
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  version: '0'
108
109
  segments:
109
110
  - 0
110
- hash: 4216760181021085759
111
+ hash: 2702542142238984905
111
112
  requirements: []
112
113
  rubyforge_project:
113
114
  rubygems_version: 1.8.10
@@ -116,6 +117,7 @@ specification_version: 3
116
117
  summary: 時間計算
117
118
  test_files:
118
119
  - spec/calc_working_hours/data_sample.csv
120
+ - spec/calc_working_hours/invalid_data_sample.csv
119
121
  - spec/calc_working_hours/time_card_row_spec.rb
120
122
  - spec/calc_working_hours/time_card_spec.rb
121
123
  - spec/calc_working_hours/time_recorder_spec.rb