one_inch_punch 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +3 -0
- data/lib/punch/core_ext.rb +1 -0
- data/lib/punch/core_ext/fixnum.rb +13 -0
- data/lib/punch/version.rb +1 -1
- data/spec/fixnum_spec.rb +29 -0
- metadata +4 -1
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -7,11 +7,14 @@ bin/punch
|
|
7
7
|
config/hoe.rb
|
8
8
|
config/requirements.rb
|
9
9
|
lib/punch.rb
|
10
|
+
lib/punch/core_ext.rb
|
11
|
+
lib/punch/core_ext/fixnum.rb
|
10
12
|
lib/punch/version.rb
|
11
13
|
script/console
|
12
14
|
script/destroy
|
13
15
|
script/generate
|
14
16
|
setup.rb
|
17
|
+
spec/fixnum_spec.rb
|
15
18
|
spec/punch_command_spec.rb
|
16
19
|
spec/punch_spec.rb
|
17
20
|
spec/spec.opts
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'punch/core_ext/fixnum'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Fixnum
|
2
|
+
def elapsed_time
|
3
|
+
minutes, seconds = divmod(60)
|
4
|
+
hours, minutes = minutes.divmod(60)
|
5
|
+
|
6
|
+
seconds = '%02d' % seconds
|
7
|
+
minutes = '%02d' % minutes
|
8
|
+
|
9
|
+
time = "#{minutes}:#{seconds}"
|
10
|
+
time = "#{hours}:#{time}" unless hours.zero?
|
11
|
+
time
|
12
|
+
end
|
13
|
+
end
|
data/lib/punch/version.rb
CHANGED
data/spec/fixnum_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Fixnum do
|
4
|
+
it 'should give an elapsed time' do
|
5
|
+
50.should respond_to(:elapsed_time)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'giving an elapsed time' do
|
9
|
+
it 'should convert the number as seconds to an HH:MM:SS format' do
|
10
|
+
60174.elapsed_time.should == '16:42:54'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should format seconds as two digits' do
|
14
|
+
135182.elapsed_time.should == '37:33:02'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should format minutes as two digits' do
|
18
|
+
39900.elapsed_time.should == '11:05:00'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should not format hours as two digits' do
|
22
|
+
3900.elapsed_time.should == '1:05:00'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should not includes hours if the time is less than an hour' do
|
26
|
+
890.elapsed_time.should == '14:50'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: one_inch_punch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yossef Mendelssohn
|
@@ -44,11 +44,14 @@ files:
|
|
44
44
|
- config/hoe.rb
|
45
45
|
- config/requirements.rb
|
46
46
|
- lib/punch.rb
|
47
|
+
- lib/punch/core_ext.rb
|
48
|
+
- lib/punch/core_ext/fixnum.rb
|
47
49
|
- lib/punch/version.rb
|
48
50
|
- script/console
|
49
51
|
- script/destroy
|
50
52
|
- script/generate
|
51
53
|
- setup.rb
|
54
|
+
- spec/fixnum_spec.rb
|
52
55
|
- spec/punch_command_spec.rb
|
53
56
|
- spec/punch_spec.rb
|
54
57
|
- spec/spec.opts
|