punchcard 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/punchcard/person.rb +1 -1
- data/lib/punchcard/punch.rb +0 -1
- data/lib/views/layout.haml +1 -3
- data/lib/views/screen.sass +1 -0
- data/punchcard.gemspec +4 -1
- data/test/helper.rb +1 -0
- data/test/test_database.rb +17 -16
- metadata +15 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
punchcard (0.
|
4
|
+
punchcard (0.2.4)
|
5
5
|
activerecord (~> 3.0.0)
|
6
6
|
bson_ext
|
7
7
|
gravtastic
|
@@ -42,6 +42,7 @@ GEM
|
|
42
42
|
sqlite3 (0.1.1)
|
43
43
|
ffi (>= 0.6.3)
|
44
44
|
tilt (1.1)
|
45
|
+
timecop (0.3.5)
|
45
46
|
tzinfo (0.3.23)
|
46
47
|
|
47
48
|
PLATFORMS
|
@@ -58,3 +59,4 @@ DEPENDENCIES
|
|
58
59
|
shoulda (= 2.10.3)
|
59
60
|
sinatra (>= 1.0.0)
|
60
61
|
sqlite3
|
62
|
+
timecop
|
data/Rakefile
CHANGED
@@ -19,6 +19,7 @@ begin
|
|
19
19
|
gem.add_development_dependency "shoulda", "2.10.3"
|
20
20
|
gem.add_development_dependency "rack-test", ">= 0.5.6"
|
21
21
|
gem.add_development_dependency 'sqlite3', '>= 0'
|
22
|
+
gem.add_development_dependency 'timecop', '>= 0'
|
22
23
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
23
24
|
end
|
24
25
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/lib/punchcard/person.rb
CHANGED
@@ -18,7 +18,7 @@ class Person < ActiveRecord::Base
|
|
18
18
|
if punch = pending?
|
19
19
|
punch.punch_out!
|
20
20
|
else
|
21
|
-
if recently_finished = punches.recently_finished.
|
21
|
+
if recently_finished = punches.finished.first and recently_finished.checked_out_at > 30.minutes.ago
|
22
22
|
recently_finished.reopen!
|
23
23
|
else
|
24
24
|
punches.create!
|
data/lib/punchcard/punch.rb
CHANGED
@@ -5,7 +5,6 @@ class Punch < ActiveRecord::Base
|
|
5
5
|
|
6
6
|
scope :pending, where("checked_out_at IS NULL").order("checked_in_at ASC")
|
7
7
|
scope :finished, where("checked_in_at IS NOT NULL AND checked_out_at IS NOT NULL").order('checked_out_at DESC')
|
8
|
-
scope :recently_finished, where("checked_out_at > ?", 30.minutes.ago).order('checked_out_at DESC')
|
9
8
|
|
10
9
|
before_validation do |p|
|
11
10
|
p.checked_in_at ||= Time.now
|
data/lib/views/layout.haml
CHANGED
@@ -15,9 +15,7 @@
|
|
15
15
|
<li id="${_id}">
|
16
16
|
<img src="${gravatar_url}" title="${name}" class="gravatar {{if pending == true}}pending{{/if}} ${pending}"/>
|
17
17
|
<div class="person">${name}</div>
|
18
|
-
{{if checked_in_at}}
|
19
|
-
<abbr class="timeago" title="${checked_in_at}"></abbr>
|
20
|
-
{{/if}}
|
18
|
+
<abbr class="timeago" title="{{if checked_in_at}}${checked_in_at}{{/if}}"> </abbr>
|
21
19
|
</li>
|
22
20
|
</script>
|
23
21
|
|
data/lib/views/screen.sass
CHANGED
data/punchcard.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{punchcard}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Christoph Olszowka"]
|
@@ -69,6 +69,7 @@ Gem::Specification.new do |s|
|
|
69
69
|
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
70
70
|
s.add_development_dependency(%q<rack-test>, [">= 0.5.6"])
|
71
71
|
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
72
|
+
s.add_development_dependency(%q<timecop>, [">= 0"])
|
72
73
|
else
|
73
74
|
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
74
75
|
s.add_dependency(%q<bson_ext>, [">= 0"])
|
@@ -79,6 +80,7 @@ Gem::Specification.new do |s|
|
|
79
80
|
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
80
81
|
s.add_dependency(%q<rack-test>, [">= 0.5.6"])
|
81
82
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
83
|
+
s.add_dependency(%q<timecop>, [">= 0"])
|
82
84
|
end
|
83
85
|
else
|
84
86
|
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
@@ -90,6 +92,7 @@ Gem::Specification.new do |s|
|
|
90
92
|
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
91
93
|
s.add_dependency(%q<rack-test>, [">= 0.5.6"])
|
92
94
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
95
|
+
s.add_dependency(%q<timecop>, [">= 0"])
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
data/test/helper.rb
CHANGED
data/test/test_database.rb
CHANGED
@@ -23,10 +23,12 @@ class TestDatabase < Test::Unit::TestCase
|
|
23
23
|
|
24
24
|
context "that got punched 2 hours ago" do
|
25
25
|
setup do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
Timecop.freeze(2.hours.ago) do
|
27
|
+
assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
|
28
|
+
punch = @person.pending?
|
29
|
+
punch.checked_in_at = 2.hours.ago
|
30
|
+
punch.save!
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
should "have one pending punch" do
|
@@ -41,13 +43,15 @@ class TestDatabase < Test::Unit::TestCase
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
context "and
|
46
|
+
context "and checked out 25 minutes ago" do
|
45
47
|
setup do
|
46
|
-
|
48
|
+
Timecop.freeze(25.minutes.ago) do
|
49
|
+
assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
|
50
|
+
end
|
47
51
|
end
|
48
52
|
|
49
53
|
should "have finished the pending punch" do
|
50
|
-
assert @person.punches.first.checked_out_at >
|
54
|
+
assert @person.punches.first.checked_out_at < 24.minutes.ago and @person.punches.first.checked_out_at > 26.minutes.ago
|
51
55
|
end
|
52
56
|
|
53
57
|
should "not be pending" do
|
@@ -60,7 +64,7 @@ class TestDatabase < Test::Unit::TestCase
|
|
60
64
|
assert_equal 1, @person.punches.finished.count
|
61
65
|
end
|
62
66
|
|
63
|
-
context "and
|
67
|
+
context "and punches in again now" do
|
64
68
|
setup do
|
65
69
|
assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
|
66
70
|
end
|
@@ -76,15 +80,12 @@ class TestDatabase < Test::Unit::TestCase
|
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
79
|
-
context "and gets punched yet again
|
83
|
+
context "and gets punched yet again 1 hour later" do
|
80
84
|
setup do
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
punch.save!
|
86
|
-
assert_nil @person.pending?
|
87
|
-
assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
|
85
|
+
Timecop.freeze(1.hour.from_now) do
|
86
|
+
assert_nil @person.pending?
|
87
|
+
assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
|
88
|
+
end
|
88
89
|
end
|
89
90
|
|
90
91
|
should "be pending" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 5
|
9
|
+
version: 0.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Christoph Olszowka
|
@@ -146,6 +146,19 @@ dependencies:
|
|
146
146
|
version: "0"
|
147
147
|
type: :development
|
148
148
|
version_requirements: *id009
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: timecop
|
151
|
+
prerelease: false
|
152
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
segments:
|
158
|
+
- 0
|
159
|
+
version: "0"
|
160
|
+
type: :development
|
161
|
+
version_requirements: *id010
|
149
162
|
description: Simple sinatra/activerecord based app for tracking time when people have been in the office
|
150
163
|
email: christoph at olszowka de
|
151
164
|
executables: []
|