getulio 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 104ad665529abcfc494486cc20cb6a15657679c1
4
- data.tar.gz: 12d7228c705a29be5bce6ee23b2d14bcd083bffa
3
+ metadata.gz: 11dd89d43c63496f8f0580e0c25a7ad84eeaca05
4
+ data.tar.gz: 8f569bac152f2900e4ab35ebd0d79d13de24ae07
5
5
  SHA512:
6
- metadata.gz: ac6f770c47afdfe56c11b96c390cce91e0fe56458c07fa5fa53ef5bac3471b61a6a3ae8153a162c4282a64bccb6b06584ff7af5ea4848a27b5dfaaec0b1448fb
7
- data.tar.gz: ddacabf613b08b08b8809546a995b18e11f8dd1752dd6b7175ba4e157b9e8632613005275326b5697fbd7878111a14e76387b077047c5eeba61eb5bd0824ce01
6
+ metadata.gz: d55578c325b2127f3674d8671100a95a8a701d6afd53cf705d39ec941f0f2eba23af1026e521925d0e63a2cc4692a9b90c41a3dffa26ecb694fdaff599afa111
7
+ data.tar.gz: af3b8c7fce8315d1a53430f61a409a51892103afc4ab48090798de458389f445c0f140c075e1eb499e237da5add68f7c1f5d442ab96c17dce40f257f5b29ccd2
data/getulio.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "getulio"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joa\u{303}o Hornburg"]
12
- s.date = "2013-08-04"
12
+ s.date = "2013-08-05"
13
13
  s.description = "generate random timesheets for brazilian workers (according to CLT)"
14
14
  s.email = "joao.hornburg@gmail.com"
15
15
  s.extra_rdoc_files = [
data/lib/getulio.rb CHANGED
@@ -1,3 +1,4 @@
1
- class Getulio
2
-
3
- end
1
+ require "getulio/timesheet"
2
+
3
+ module Getulio
4
+ end
@@ -1,36 +1,37 @@
1
1
  require 'getulio/timesheet_day'
2
2
 
3
- class Getulio::Timesheet
4
-
5
- def self.for_current_month
6
- Getulio::Timesheet.new
7
- end
8
-
9
- def initialize
10
- initialize_days
11
- end
12
-
13
- def days
14
- @days
15
- end
16
-
17
-
18
- private
19
-
20
- def initialize_days
21
- @days = []
22
- date = beginning_of_month
23
- days_until_today.times do
24
- @days << Getulio::TimesheetDay.new(date)
25
- date = date.next
3
+ module Getulio
4
+ class Timesheet
5
+
6
+ def self.for_current_month
7
+ Getulio::Timesheet.new
8
+ end
9
+
10
+ def initialize
11
+ initialize_days
12
+ end
13
+
14
+ def days
15
+ @days
16
+ end
17
+
18
+ private
19
+
20
+ def initialize_days
21
+ @days = []
22
+ date = beginning_of_month
23
+ days_until_today.times do
24
+ @days << Getulio::TimesheetDay.new(date)
25
+ date = date.next
26
+ end
27
+ end
28
+
29
+ def days_until_today
30
+ (Date.today - beginning_of_month).numerator + 1
31
+ end
32
+
33
+ def beginning_of_month
34
+ Date.parse(Time.now.strftime("%Y-%m-01"))
26
35
  end
27
36
  end
28
-
29
- def days_until_today
30
- (Date.today - beginning_of_month).numerator + 1
31
- end
32
-
33
- def beginning_of_month
34
- Date.parse(Time.now.strftime("%Y-%m-01"))
35
- end
36
- end
37
+ end
@@ -1,38 +1,41 @@
1
- class Getulio::TimesheetDay
2
-
3
- TOTAL_WORKING_TIME_SECODS = 8*60*60 + 48*60
4
-
5
- def initialize(date)
6
- @date = date
1
+ module Getulio
2
+ class TimesheetDay
3
+
4
+ TOTAL_WORKING_TIME_SECODS = 8*60*60 + 48*60
5
+
6
+ def initialize(date)
7
+ @date = date
8
+ end
9
+
10
+ def date
11
+ @date
12
+ end
13
+
14
+ def arrival
15
+ @arrival ||= random_time(7,10)
16
+ end
17
+
18
+ def begin_of_lunch
19
+ @begin_of_lunch ||= random_time(11,13)
20
+ end
21
+
22
+ def end_of_lunch
23
+ begin_of_lunch + 60*60
24
+ end
25
+
26
+ def departure
27
+ remaining_time = TOTAL_WORKING_TIME_SECODS - (begin_of_lunch - arrival)
28
+ end_of_lunch + remaining_time
29
+ end
30
+
31
+ private
32
+
33
+ def random_time(from,to)
34
+ hour = rand((to-1 - from)) + from
35
+ minutes = rand(59)
36
+ Time.local(@date.year, @date.month, @date.day, hour, minutes)
37
+ end
38
+
7
39
  end
8
-
9
- def date
10
- @date
11
- end
12
-
13
- def arrival
14
- @arrival ||= random_time(7,10)
15
- end
16
-
17
- def begin_of_lunch
18
- @begin_of_lunch ||= random_time(11,13)
19
- end
20
-
21
- def end_of_lunch
22
- begin_of_lunch + 60*60
23
- end
24
-
25
- def departure
26
- remaining_time = TOTAL_WORKING_TIME_SECODS - (begin_of_lunch - arrival)
27
- end_of_lunch + remaining_time
28
- end
29
-
30
- private
31
-
32
- def random_time(from,to)
33
- hour = rand(from..(to-1))
34
- minutes = rand(0..59)
35
- Time.new(@date.year, @date.month, @date.day, hour, minutes)
36
- end
37
-
38
- end
40
+
41
+ end
@@ -2,7 +2,7 @@ class Getulio
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -2,26 +2,26 @@ require 'spec_helper'
2
2
  require 'getulio/timesheet_day'
3
3
 
4
4
  describe Getulio::TimesheetDay do
5
-
5
+
6
6
  def timesheet_day
7
7
  Getulio::TimesheetDay.new(Date.parse("2013-08-04"))
8
8
  end
9
-
9
+
10
10
  it "has a date" do
11
11
  timesheet_day.date.should eq Date.parse("2013-08-04")
12
12
  end
13
-
13
+
14
14
  describe "#arrival" do
15
-
15
+
16
16
  it "is a Time" do
17
17
  timesheet_day.arrival.should be_a Time
18
18
  end
19
-
19
+
20
20
  it "is between 7:00 and 10:00" do
21
21
  timesheet_day.arrival.hour.should >= 7
22
22
  timesheet_day.arrival.hour.should < 10
23
23
  end
24
-
24
+
25
25
  it "creates default random arrivals" do
26
26
  first_arrival = timesheet_day.arrival
27
27
  second_arrival = timesheet_day.arrival
@@ -31,26 +31,26 @@ describe Getulio::TimesheetDay do
31
31
  second_arrival.should_not eq first_arrival
32
32
  second_arrival.should_not eq third_arrival
33
33
  end
34
-
34
+
35
35
  it "is calculated only once per instance" do
36
36
  tmsd = timesheet_day
37
37
  arrival = tmsd.arrival
38
38
  5.times do tmsd.arrival.should eq arrival end
39
39
  end
40
-
40
+
41
41
  end
42
-
42
+
43
43
  describe "#begin_of_lunch" do
44
-
44
+
45
45
  it "is a Time" do
46
46
  timesheet_day.begin_of_lunch.should be_a Time
47
47
  end
48
-
48
+
49
49
  it "is between 11:00 and 13:00" do
50
50
  timesheet_day.begin_of_lunch.hour.should >= 11
51
51
  timesheet_day.begin_of_lunch.hour.should < 13
52
52
  end
53
-
53
+
54
54
  it "creates default random begin_of_lunchs" do
55
55
  first_begin_of_lunch = timesheet_day.begin_of_lunch
56
56
  second_begin_of_lunch = timesheet_day.begin_of_lunch
@@ -60,39 +60,38 @@ describe Getulio::TimesheetDay do
60
60
  second_begin_of_lunch.should_not eq first_begin_of_lunch
61
61
  second_begin_of_lunch.should_not eq third_begin_of_lunch
62
62
  end
63
-
63
+
64
64
  it "is calculated only once per instance" do
65
65
  tmsd = timesheet_day
66
66
  begin_of_lunch = tmsd.begin_of_lunch
67
67
  5.times do tmsd.begin_of_lunch.should eq begin_of_lunch end
68
68
  end
69
-
69
+
70
70
  end
71
-
71
+
72
72
  describe "#end_of_lunch" do
73
-
73
+
74
74
  it "is a Time" do
75
75
  timesheet_day.begin_of_lunch.should be_a Time
76
76
  end
77
-
77
+
78
78
  it "is 1 hour after begin_of_lunch" do
79
- Getulio::TimesheetDay.any_instance.stub(:begin_of_lunch).and_return(Time.new(2013,12,02,11,45))
80
- timesheet_day.end_of_lunch.should eq Time.new(2013,12,02,12,45)
79
+ Getulio::TimesheetDay.any_instance.stub(:begin_of_lunch).and_return(Time.local(2013,12,02,11,45))
80
+ timesheet_day.end_of_lunch.should eq Time.local(2013,12,02,12,45)
81
81
  end
82
82
  end
83
-
83
+
84
84
  describe "#departure" do
85
-
85
+
86
86
  it "is a Time" do
87
87
  timesheet_day.departure.should be_a Time
88
88
  end
89
-
89
+
90
90
  it "completes 8:48 of work for the given day" do
91
- Getulio::TimesheetDay.any_instance.stub(:arrival).and_return(Time.new(2013,12,02,9,00))
92
- Getulio::TimesheetDay.any_instance.stub(:begin_of_lunch).and_return(Time.new(2013,12,02,12,00))
93
- timesheet_day.departure.should eq Time.new(2013,12,02,18,48)
91
+ Getulio::TimesheetDay.any_instance.stub(:arrival).and_return(Time.local(2013,12,02,9,00))
92
+ Getulio::TimesheetDay.any_instance.stub(:begin_of_lunch).and_return(Time.local(2013,12,02,12,00))
93
+ timesheet_day.departure.should eq Time.local(2013,12,02,18,48)
94
94
  end
95
95
  end
96
-
97
-
98
- end
96
+
97
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getulio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Hornburg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-04 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec